Пример #1
0
//
// 下端へ移動
//
void SelectItemPref::slot_bottom()
{
    Gtk::TreeModel::Children children = m_store_shown->children();
    if( children.empty() ) return;

    // 移動先のイテレータ
    Gtk::TreeIter bottom_it = children.end();

    std::list< Gtk::TreePath > selection_path = m_tree_shown.get_selection()->get_selected_rows();
    std::list< Gtk::TreePath >::reverse_iterator it = selection_path.rbegin();
    while( it != selection_path.rend() )
    {
        Gtk::TreeIter src_it = m_store_shown->get_iter( *it );
        Gtk::TreeIter dst_it = bottom_it;

        // 元と先が同じでない
        if( src_it != dst_it )
        {
            // 参照渡しなので書き換えられてしまう
            m_store_shown->move( src_it, dst_it );
            bottom_it = dst_it;
        }

        // 移動先の位置を上げる
        if( bottom_it != children.begin() ) --bottom_it;

        ++it;
    }

    // フォーカスを移す
    set_focus( m_tree_shown );
}
Пример #2
0
//
// Gtk::TreeModel::Children からノードツリーを生成
//
// ただし列は SKELETON::EditColumns を継承したものであること
//
void Dom::parse( const Gtk::TreeModel::Children& children, SKELETON::EditColumns& columns )
{
    if( ! this || children.empty() ) return;

    // Gtk::TreeModel::Children を走査
    Gtk::TreeModel::iterator it = children.begin();
    while( it != children.end() )
    {
        Gtk::TreeModel::Row row = *it;

        // 各値を取得( skeleton/editcolumns.h を参照 )
        const int type = row[ columns.m_type ];
        const Glib::ustring url = row[ columns.m_url ];
        const Glib::ustring data = row[ columns.m_data ];
        const Glib::ustring name = row[ columns.m_name ];
        const size_t dirid = row[ columns.m_dirid ];
        const bool expand = row[ columns.m_expand ];

        if( type != TYPE_UNKNOWN )
        {
            // タイプにより要素名を決定( board や link など)
            const std::string node_name = XML::get_name( type );

            if( ! node_name.empty() )
            {
                Dom* node = appendChild( NODE_TYPE_ELEMENT, node_name );
                if( type == TYPE_DIR && expand ) node->setAttribute( "open", "y" );
                if( ! name.empty() ) node->setAttribute( "name", name );
                if( ! url.empty() ) node->setAttribute( "url", url );
                if( ! data.empty() ) node->setAttribute( "data", data );
                if( dirid ) node->setAttribute( "dirid", dirid );

                // 再帰
                if( ! row.children().empty() ) node->parse( row.children(), columns );
            }
        }

        ++it;
    }
}
Пример #3
0
//
// 下へ移動
//
void SelectItemPref::slot_down()
{
    Gtk::TreeModel::Children children = m_store_shown->children();
    if( children.empty() ) return;

    // 下限のイテレータ
    Gtk::TreeIter bottom_it = --children.end();

    std::list< Gtk::TreePath > selection_path = m_tree_shown.get_selection()->get_selected_rows();
    std::list< Gtk::TreePath >::reverse_iterator it = selection_path.rbegin();
    while( it != selection_path.rend() )
    {
        Gtk::TreePath src = *it;
        Gtk::TreeIter src_it = m_store_shown->get_iter( src );

        // 限度位置に達していなければ入れ替え
        if( src_it != bottom_it )
        {
            Gtk::TreePath dst( src );

            dst.next();

            Gtk::TreeIter dst_it = m_store_shown->get_iter( dst );

            if( dst_it )
            {
                m_store_shown->iter_swap( src_it, dst_it );
            }
        }
        // 下限に達していたら次の限度位置を上げる
        else if( bottom_it != children.begin() ) --bottom_it;

        ++it;
    }

    // フォーカスを移す
    set_focus( m_tree_shown );
}
Пример #4
0
//
// 上へ移動
//
void SelectItemPref::slot_up()
{
    Gtk::TreeModel::Children children = m_store_shown->children();
    if( children.empty() ) return;

    // 上限のイテレータ
    Gtk::TreeIter upper_it = children.begin();

    std::list< Gtk::TreePath > selection_path = m_tree_shown.get_selection()->get_selected_rows();
    std::list< Gtk::TreePath >::iterator it = selection_path.begin();
    while( it != selection_path.end() )
    {
        Gtk::TreePath src = *it;
        Gtk::TreeIter src_it = m_store_shown->get_iter( src );

        // 限度位置に達していなければ入れ替え
        if( src_it != upper_it )
        {
            Gtk::TreePath dst( src );

            if( dst.prev() )
            {
                Gtk::TreeIter dst_it = m_store_shown->get_iter( dst );

                m_store_shown->iter_swap( src_it, dst_it );
            }
        }
        // 上限に達していたら次の限度位置を下げる
        else if( upper_it != children.end() ) ++upper_it;

        ++it;
    }

    // フォーカスを移す
    set_focus( m_tree_shown );
}
Пример #5
0
/*
 * vim: softtabstop=4 shiftwidth=4 cindent foldmethod=marker expandtab
 *
 * $LastChangedDate$
 * $Revision$
 * $LastChangedBy$
 * $URL$
 *
 * Copyright 2009-2011 Eric Connell
 *
 * This file is part of Mangler.
 *
 * Mangler is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Mangler is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Mangler.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "mangler.h"
#include "manglerrecorder.h"
#include "mangleraudio.h"
#include "manglercharset.h"

#include <unistd.h>
#include <sys/stat.h>
#include <dirent.h>

ManglerRecorder::ManglerRecorder(Glib::RefPtr<Gtk::Builder> builder) {/*{{{*/
    this->builder = builder;

    builder->get_widget("recWindow", recWindow);
    builder->get_widget("recHide", menuitem);
    menuitem->signal_activate().connect(sigc::mem_fun(this, &ManglerRecorder::hide_activate_cb));

    builder->get_widget("recOpen", menuitem);
    menuitem->signal_activate().connect(sigc::mem_fun(this, &ManglerRecorder::open_activate_cb));
    builder->get_widget("recClose", menuitem);
    menuitem->signal_activate().connect(sigc::mem_fun(this, &ManglerRecorder::close_activate_cb));
    builder->get_widget("recSaveAs", menuitem);
    menuitem->signal_activate().connect(sigc::mem_fun(this, &ManglerRecorder::saveas_activate_cb));
    builder->get_widget("recDelete", menuitem);
    menuitem->signal_activate().connect(sigc::mem_fun(this, &ManglerRecorder::delete_activate_cb));

    builder->get_widget("recPlayPause", button);
    button->signal_clicked().connect(sigc::mem_fun(this, &ManglerRecorder::playpause_clicked_cb));
    builder->get_widget("recStop", button);
    button->signal_clicked().connect(sigc::mem_fun(this, &ManglerRecorder::stop_clicked_cb));
    builder->get_widget("recRecord", recordbutton);
    recordbutton->signal_toggled().connect(sigc::mem_fun(this, &ManglerRecorder::record_toggled_cb));
    builder->get_widget("recInfo", button);
    button->signal_clicked().connect(sigc::mem_fun(this, &ManglerRecorder::info_clicked_cb));

    builder->get_widget("recOpenEntry", fileentry);
    builder->get_widget("recOpenButton", button);
    button->signal_clicked().connect(sigc::mem_fun(this, &ManglerRecorder::open_activate_cb));

    filedialog = new Gtk::FileChooserDialog("Open Recording", Gtk::FILE_CHOOSER_ACTION_OPEN);
    filedialog->add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
    filedialog->add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK);
    Gtk::FileFilter vrf_filter;
    vrf_filter.set_name("Ventrilo Recording File (*.vrf)");
    vrf_filter.add_pattern("*.vrf");
    filedialog->add_filter(vrf_filter);
    Gtk::FileFilter all_filter;
    all_filter.set_name("All Files");
    all_filter.add_pattern("*");
    filedialog->add_filter(all_filter);

    builder->get_widget("recScrolledWindow", recScrolledWindow);
    recListModel = Gtk::ListStore::create(recRecord);
    builder->get_widget("recListTree", recListTree);
    recListTree->set_model(recListModel);
    recListTree->append_column("Time", recRecord.time);
    recListTree->append_column("Duration", recRecord.duration);
    recListTree->append_column("Status", recRecord.status);
    recListTree->append_column("Username", recRecord.username);
    recListTree->append_column("", recRecord.text);
    recListTree->signal_cursor_changed().connect(sigc::mem_fun(this, &ManglerRecorder::recListTree_cursor_changed_cb));
    recListTree->signal_row_activated().connect(sigc::mem_fun(this, &ManglerRecorder::recListTree_row_activated_cb));

    builder->get_widget("recInfoDialog", recInfoDialog);
    builder->get_widget("recInfoCancel", button);
    button->signal_clicked().connect(sigc::mem_fun(this, &ManglerRecorder::recInfoDialog_cancel_clicked_cb));
    builder->get_widget("recInfoSave", button);
    button->signal_clicked().connect(sigc::mem_fun(this, &ManglerRecorder::recInfoDialog_save_clicked_cb));

    recdir = ManglerConfig::confdir() + "/recordings";
    DIR *testdir;
    if ((testdir = opendir(recdir.c_str()))) {
        closedir(testdir);
    } else {
        mkdir(recdir.c_str(), 0700);
    }
    filedialog->set_current_folder(recdir);

    isPlaying   = false;
    isRecording = false;

    vrfh = NULL;
    player = NULL;
}/*}}}*/
ManglerRecorder::~ManglerRecorder() {/*{{{*/
    reset(true);
    delete filedialog;
}/*}}}*/

void
ManglerRecorder::show(void) {/*{{{*/
    recWindow->present();
}/*}}}*/
void
ManglerRecorder::hide_activate_cb(void) {/*{{{*/
    recWindow->hide();
}/*}}}*/
void
ManglerRecorder::open_activate_cb(void) {/*{{{*/
    int result = filedialog->run();
    filedialog->hide();
    if (result == Gtk::RESPONSE_OK) {
        path = filedialog->get_current_folder();
        filename = filedialog->get_filename();
        set(false);
    }
}/*}}}*/
void
ManglerRecorder::close_activate_cb(void) {/*{{{*/
    reset();
}/*}}}*/
void
ManglerRecorder::saveas_activate_cb(void) {/*{{{*/
}/*}}}*/
void
ManglerRecorder::delete_activate_cb(void) {/*{{{*/
    if (!vrfh || filename.empty()) {
        return;
    }
    Gtk::MessageDialog confirm("<b>Are you sure you want to delete \"" + fileentry->get_text() + "\"?</b>",
            true, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_YES_NO, true);
    if (confirm.run() == Gtk::RESPONSE_YES) {
        reset();
        unlink(filename.c_str());
    }
}/*}}}*/
void
ManglerRecorder::playpause_clicked_cb(void) {/*{{{*/
    if (!vrfh) {
        return;
    }
    isPlaying = true;
    player = Glib::Thread::create(sigc::mem_fun(*this, &ManglerRecorder::play), false);
}/*}}}*/
void
ManglerRecorder::stop_clicked_cb(void) {/*{{{*/
    player = NULL;
}/*}}}*/
void
ManglerRecorder::record_toggled_cb(void) {/*{{{*/
    if (recordbutton->get_active()) {
        path = recdir;
        filename = path + "/" + timestamp() + ".vrf";
        set(true);
    } else {
        set(false);
    }
}/*}}}*/
void
ManglerRecorder::info_clicked_cb(void) {/*{{{*/
    if (!vrfh) {
        return;
    }
    v3_vrf_data vrfd;
    if (v3_vrf_get_info(vrfh, &vrfd) != V3_OK) {
        mangler->errorDialog(c_to_ustring(_v3_error(NULL)));
        return;
    }
    builder->get_widget("recInfoByEntry", entry);
    entry->set_text(c_to_ustring(vrfd.username));
    builder->get_widget("recInfoComment", textview);
    textview->get_buffer()->set_text(c_to_ustring(vrfd.comment));
    builder->get_widget("recInfoURL", textview);
    textview->get_buffer()->set_text(c_to_ustring(vrfd.url));
    builder->get_widget("recInfoCopyright", textview);
    textview->get_buffer()->set_text(c_to_ustring(vrfd.copyright));
    recInfoDialog->set_icon(mangler->icons["tray_icon"]);
    recInfoDialog->present();
}/*}}}*/
void
ManglerRecorder::recListTree_cursor_changed_cb(void) {/*{{{*/
    if (!vrfh) {
        return;
    }
    builder->get_widget("recPlayPause", widget);
    widget->set_sensitive(recListTree->get_selection()->get_selected());
}/*}}}*/
void
ManglerRecorder::recListTree_row_activated_cb(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column) {/*{{{*/
    if (!vrfh) {
        return;
    }
    isPlaying = false;
    player = Glib::Thread::create(sigc::mem_fun(*this, &ManglerRecorder::play), false);
}/*}}}*/
void
ManglerRecorder::set(bool isRecording) {/*{{{*/
    reset();
    if (isRecording) {
        if (v3_vrf_record_start(filename.c_str()) != V3_OK) {
            mangler->errorDialog(c_to_ustring(_v3_error(NULL)));
            recordbutton->set_active(false);
            return;
        }
        this->isRecording = true;
    } else {
        this->isRecording = false;
        if (!(vrfh = v3_vrf_init(filename.c_str()))) {
            mangler->errorDialog(c_to_ustring(_v3_error(NULL)));
            return;
        }
        v3_vrf_data vrfd;
        if (v3_vrf_get_info(vrfh, &vrfd) != V3_OK) {
            reset();
            mangler->errorDialog(c_to_ustring(_v3_error(NULL)));
            return;
        }
        builder->get_widget("recSize", label);
        label->set_text(bytes_to_readable(vrfd.size));
        builder->get_widget("recCount", label);
        label->set_text(float_to_ustring(v3_vrf_get_count(vrfh), 0));
        builder->get_widget("recPlatform", label);
        label->set_text(c_to_ustring(vrfd.platform));
        builder->get_widget("recVersion", label);
        label->set_text(c_to_ustring(vrfd.version));
        builder->get_widget("recCodec", label);
        label->set_text(c_to_ustring(v3_get_codec(vrfd.codec, vrfd.codecformat)->name));
        totalduration = 0;
        for (uint32_t ctr = 0, cnt = v3_vrf_get_count(vrfh); ctr < cnt; ctr++) {
            if (v3_vrf_get_segment(vrfh, ctr, &vrfd) != V3_OK) {
                reset();
                mangler->errorDialog(c_to_ustring(_v3_error(NULL)));
                return;
            }
            Gtk::TreeModel::Row row = *(recListModel->append());
            row[recRecord.id]           = ctr;
            row[recRecord.time_val]     = vrfd.time;
            row[recRecord.duration_val] = vrfd.duration;
            row[recRecord.time]         = msec_to_timestamp(vrfd.time);
            row[recRecord.duration]     = float_to_ustring(vrfd.duration / 1000.0, 2);
            row[recRecord.status]       = "";
            row[recRecord.username]     = c_to_ustring(vrfd.username);
            row[recRecord.text]         = "";
            totalduration += vrfd.duration;
        }
        builder->get_widget("recDuration", label);
        label->set_text(float_to_ustring(totalduration / 60000.0, 1) + " min");
        builder->get_widget("recInfo", widget);
        widget->set_sensitive(true);
    }
    fileentry->set_text(filename.substr(path.length() + 1));
    builder->get_widget("recType", label);
    label->set_text("VRF");
    recListTree->set_sensitive(true);
    builder->get_widget("recClose", widget);
    widget->set_sensitive(true);
    builder->get_widget("recDelete", widget);
    widget->set_sensitive(true);
    builder->get_widget("recInfos", widget);
    widget->set_sensitive(true);
    recScrolledWindow->get_vadjustment()->set_value(0);
    if (recListModel->children().size()) {
        recListTree->set_cursor(recListModel->get_path(recListModel->children().begin()));
        builder->get_widget("recPlayPause", widget);
        widget->grab_focus();
    }
}/*}}}*/
void
ManglerRecorder::reset(bool destroying) {/*{{{*/
    player = (Glib::Thread*)destroying;
    isPlaying = false;
    if (isRecording) {
        v3_vrf_record_stop();
        recordbutton->set_active(false);
    }
    isRecording = false;
    if (vrfh) {
        v3_vrf_destroy(vrfh);
        vrfh = NULL;
    }
    recListModel->clear();
    if (destroying) {
        return;
    }
    for (int ctr = 0, cnt = recListTree->get_columns().size(); ctr < cnt; ctr++) {
        recListTree->get_column(ctr)->queue_resize();
    }
    recListTree->set_sensitive(false);
    fileentry->set_text("");
    builder->get_widget("recType", label);
    label->set_text("N/A");
    builder->get_widget("recSize", label);
    label->set_text("N/A");
    builder->get_widget("recCount", label);
    label->set_text("N/A");
    builder->get_widget("recDuration", label);
    label->set_text("N/A");
    builder->get_widget("recPlatform", label);
    label->set_text("N/A");
    builder->get_widget("recVersion", label);
    label->set_text("N/A");
    builder->get_widget("recCodec", label);
    label->set_text("N/A");
    builder->get_widget("recClose", widget);
    widget->set_sensitive(false);
    builder->get_widget("recDelete", widget);
    widget->set_sensitive(false);
    builder->get_widget("recInfos", widget);
    widget->set_sensitive(false);
    builder->get_widget("recPlayPause", widget);
    widget->set_sensitive(false);
    builder->get_widget("recInfo", widget);
    widget->set_sensitive(false);
    builder->get_widget("recInfoByEntry", entry);
    entry->set_text("");
    builder->get_widget("recInfoComment", textview);
    textview->get_buffer()->set_text("");
    builder->get_widget("recInfoURL", textview);
    textview->get_buffer()->set_text("");
    builder->get_widget("recInfoCopyright", textview);
    textview->get_buffer()->set_text("");
    recInfoDialog->hide();
}/*}}}*/
void
ManglerRecorder::can_record(bool isConnected) {/*{{{*/
    if (!isConnected && isRecording) {
        set(false);
    }
    recordbutton->set_sensitive(isConnected);
}/*}}}*/
void
ManglerRecorder::record(Glib::ustring username, Glib::ustring text, uint32_t index, uint32_t time, bool stopped, bool flushed) {/*{{{*/
    if (!isRecording) {
        return;
    }
    Gtk::TreeModel::Children children = recListModel->children();
    Gtk::TreeModel::Row row;
    if (!flushed && !children[index]) {
        row = *(recListModel->append());
        row[recRecord.id]           = index;
        row[recRecord.time_val]     = time;
        row[recRecord.duration_val] = 0;
        row[recRecord.diff_val]     = 0;
        row[recRecord.time]         = msec_to_timestamp(time);
        row[recRecord.duration]     = float_to_ustring(0, 2);
        row[recRecord.status]       = "Rec";
        row[recRecord.username]     = username;
        row[recRecord.text]         = (text.length()) ? text : "";
        builder->get_widget("recCount", label);
        label->set_text(float_to_ustring(children.size(), 0));
        recListTree->set_cursor(recListModel->get_path(row));
    }
    if (flushed) {
        for (Gtk::TreeModel::iterator iter = children.begin(); iter != children.end(); iter++) {
            (*iter)[recRecord.status] = "*";
        }
        return;
    }
    row = children[index];
    if (stopped) {
        row[recRecord.status] = "*";
    } else {
        row[recRecord.duration_val] = time - row[recRecord.time_val];
    }
    if (stopped || row[recRecord.diff_val] + 100 < row[recRecord.duration_val]) {
        row[recRecord.diff_val] = time - row[recRecord.time_val];
        row[recRecord.duration] = float_to_ustring(row[recRecord.duration_val] / 1000.0, 2);
    }
}/*}}}*/
void
ManglerRecorder::play(void) {/*{{{*/
    Glib::Thread *self = Glib::Thread::self();
    Gtk::TreeModel::iterator iter = recListTree->get_selection()->get_selected();
    Gtk::TreeModel::Children children = recListModel->children();
    if (!vrfh || !iter || children.empty() || player != self) {
        if (player == self) {
            player = NULL;
        }
        return;
    } else {
        gdk_threads_enter();
        builder->get_widget("recStop", widget);
        widget->set_sensitive(true);
        gdk_threads_leave();
    }
    std::map<uint32_t, ManglerRecorderData *> recData;
    std::map<uint32_t, ManglerRecorderData *>::iterator recIter;
    v3_vrf_data *next = NULL;
    double elapsed;
    struct timeval start, now, diff;
    elapsed = (*iter)[recRecord.time_val];
    gettimeofday(&start, NULL);
    for (;;) {
        if (!next && iter != children.end()) {
            next = (v3_vrf_data *)malloc(sizeof(v3_vrf_data));
            v3_vrf_data_init(next);
            if (v3_vrf_get_segment(vrfh, (*iter)[recRecord.id], next) != V3_OK) {
                free(next);
                next = NULL;
                iter++;
            } else if (isPlaying && children.size()) {
                gdk_threads_enter();
                Gtk::Adjustment *vadjustment = recScrolledWindow->get_vadjustment();
                float adj = vadjustment->get_upper() * ((*iter)[recRecord.id] / (float)children.size()) - vadjustment->get_page_size() / 2.0;
                if (adj < 0) {
                    adj = 0;
                } else if (adj > vadjustment->get_upper() - vadjustment->get_page_size()) {
                    adj = vadjustment->get_upper() - vadjustment->get_page_size();
                }
                vadjustment->set_value(adj);
                recListTree->set_cursor(recListModel->get_path(iter));
                gdk_threads_leave();
            }
            if (!isPlaying) {
                iter = children.end();
            }
        }
        gettimeofday(&now, NULL);
        timeval_subtract(&diff, &now, &start);
        gettimeofday(&start, NULL);
        elapsed += diff.tv_sec * 1000.0 + diff.tv_usec / 1000.0;
        if ((player != self || (iter == children.end() && !next)) && recData.empty()) {
            if (next) {
                v3_vrf_data_destroy(next);
                free(next);
            }
            break;
        }
        if (next && next->time <= elapsed) {
            recData[next->id] = new ManglerRecorderData(next);
            next = NULL;
            if (isPlaying) {
                iter++;
            }
        }
        double duration = 0;
        for (recIter = recData.begin(); recIter != recData.end() && recData.size();) {
            ManglerRecorderData *recd = recIter->second;
            if (player == self && recd->next > elapsed) {
                recIter++;
                continue;
            }
            v3_vrf_data *vrfd = recd->vrfd;
            if (player == self) {
                v3_vrf_get_audio(vrfh, vrfd->id, vrfd);
            }
            switch ((player == self) ? vrfd->type : V3_VRF_DATA_NULL) {
              case V3_VRF_DATA_AUDIO:
                if (!recd->outputAudio) {
                    recd->outputAudio = new ManglerAudio(AUDIO_OUTPUT, vrfd->rate, vrfd->channels, 0, 0, false);
                }
                if (vrfd->length) {
                    recd->outputAudio->queue(vrfd->length, (uint8_t *)vrfd->data);
                }
                if (!recd->next) {
                    recd->next = vrfd->time;
                    gdk_threads_enter();
                    children[recIter->first][recRecord.status] = "Play";
                    builder->get_widget("recCodec", label);
                    label->set_text(c_to_ustring(v3_get_codec(vrfd->codec, vrfd->codecformat)->name));
                    gdk_threads_leave();
                }
                duration += (vrfd->length / (float)(vrfd->rate * sizeof(int16_t) * vrfd->channels)) * 1000.0;
                if (duration < 10) {
                    continue;
                }
                recd->next += duration;
                recIter++;
                break;
              case V3_VRF_DATA_TEXT:
                gdk_threads_enter();
                children[recIter->first][recRecord.text] = c_to_ustring(vrfd->text);
                children[recIter->first][recRecord.status] = "*";
                gdk_threads_leave();
                recIter++;
                break;
              case V3_VRF_DATA_NULL:
              default:
                if (recd->outputAudio) {
                    recd->outputAudio->finish();
                }
                v3_vrf_data_destroy(vrfd);
                free(vrfd);
                delete recd;
                gdk_threads_enter();
                if (vrfh && children[recIter->first] && children[recIter->first][recRecord.status] == "Play") {
                    children[recIter->first][recRecord.status] = "*";
                }
                gdk_threads_leave();
                recData.erase(recIter);
                recIter = recData.begin();
                break;
            }
            duration = 0;
        }
        usleep(10000);
    }
    if (!player || player == self) {
        gdk_threads_enter();
        builder->get_widget("recStop", widget);
        widget->set_sensitive(false);
        gdk_threads_leave();
    }
}/*}}}*/
Пример #6
0
void
CanvasTreeStore::rebuild_row(Gtk::TreeModel::Row &row, bool do_children)
{
	synfigapp::ValueDesc value_desc=(synfigapp::ValueDesc)row[model.value_desc];

	if(value_desc && value_desc.get_value_node())
	{
		ValueNode::Handle value_node;
		value_node=value_desc.get_value_node();

		assert(value_node);if(!value_node)return;

		if(value_node && value_node!=(ValueNode::Handle)row[model.value_node])
		{
//			Gtk::TreeModel::Children children = row.children();
//			while(!children.empty() && erase(children.begin()));

			set_row(row,value_desc,do_children);
			return;
		}

		LinkableValueNode::Handle linkable;
		linkable=LinkableValueNode::Handle::cast_dynamic(value_node);

		if( do_children && linkable && (int)row[model.link_count] != linkable->link_count())
		{
//			Gtk::TreeModel::Children children = row.children();
//			while(!children.empty() && erase(children.begin()));

			set_row(row,value_desc);
			return;
		}

		//if(!value_node)
		//	value_node=row[model.value_node];

		row[model.id]=value_node->get_id();

		// Setup the row's label
		if(value_node->get_id().empty())
			row[model.label] = Glib::ustring(row[model.name]);
		else if(Glib::ustring(row[model.name]).empty())
			row[model.label] = value_node->get_id();
		else
			row[model.label] = Glib::ustring(row[model.name])+" ("+value_node->get_id()+')';
	}
	else
	{
		row[model.label] = Glib::ustring(row[model.name]);
		row[model.is_value_node] = false;
		row[model.is_editable] = true;
		Gtk::TreeModel::Children children = row.children();
		while(!children.empty() && erase(children.begin()))
			;
	}
	if(!do_children)
		return;

	Gtk::TreeModel::Children children = row.children();
	Gtk::TreeModel::Children::iterator iter;
	if(!children.empty())
	for(iter = children.begin(); iter != children.end(); ++iter)
	{
		Gtk::TreeRow row=*iter;
		rebuild_row(row);
	}
}
Пример #7
0
void
CanvasTreeStore::refresh_row(Gtk::TreeModel::Row &row, bool do_children)
{
	synfigapp::ValueDesc value_desc=row[model.value_desc];

	if(value_desc)
	{
		if((bool)row[model.is_value_node] != value_desc.is_value_node() ||
			(!bool(row[model.is_value_node]) && row[model.link_count]!=0))
		{
			set_row(row,value_desc,do_children);
			return;
		}

		if(row[model.is_value_node])
		{
			ValueNode::Handle value_node(value_desc.get_value_node());

			if(ValueNode::Handle(row[model.value_node])!=value_node)
			{
				rebuild_row(row,do_children);
				return;
			}

			//row[model.id]=value_node->get_id();

			// Setup the row's label
			/*
			if(value_node->get_id().empty())
				row[model.label] = Glib::ustring(row[model.name]);
			else if(Glib::ustring(row[model.name]).empty())
				row[model.label] = value_node->get_id();
			else
				row[model.label] = Glib::ustring(row[model.name])+" ("+value_node->get_id()+')';
			*/

			LinkableValueNode::Handle linkable;
			linkable=LinkableValueNode::Handle::cast_dynamic(value_node);
			if(do_children && linkable && ((int)row[model.link_count] != linkable->link_count()))
			{
	//			Gtk::TreeModel::Children children = row.children();
	//			while(!children.empty() && erase(children.begin()));

				set_row(row,value_desc);
				return;
			}
		}
		else
		{
			//row[model.label] = Glib::ustring(row[model.name]);
			//row[model.is_value_node] = false;
			//row[model.is_editable] = true;
		}
	}
	if(!do_children)
		return;

	Gtk::TreeModel::Children children = row.children();
	Gtk::TreeModel::Children::iterator iter;

	if(!children.empty())
	for(iter = children.begin(); iter != children.end(); ++iter)
	{
		Gtk::TreeRow row=*iter;
		refresh_row(row);
	}
}
Пример #8
0
void
CanvasTreeStore::set_row(Gtk::TreeRow row,synfigapp::ValueDesc value_desc, bool do_children)
{
	Gtk::TreeModel::Children children = row.children();
	while(!children.empty() && erase(children.begin()))
		;

	row[model.value_desc]=value_desc;
	try
	{
		//row[model.icon] = get_tree_pixbuf(value_desc.get_value_type());

		if(value_desc.is_value_node())
		{
			ValueNode::Handle value_node=value_desc.get_value_node();

			// todo: if the parent is animated and expanded, and we drag the time slider so that it changes,
			// it's not updated.  it still shows the previous bone valuenode.

			// maybe replace the ValueNode_Const or ValueNode_Animated with the contained ValueNode_Bone
			value_node = expandable_bone_parent(value_node);

			assert(value_node);

			row[model.value_node] = value_node;
			//row[model.is_canvas] = false;
			//row[model.is_value_node] = true;
			//row[model.is_editable] = synfigapp::is_editable(value_node);
			//row[model.id]=value_node->get_id();

			// Set the canvas
			if(value_desc.parent_is_canvas())
				row[model.canvas]=value_desc.get_canvas();
			else
				row[model.canvas]=canvas_interface()->get_canvas();

			LinkableValueNode::Handle linkable;
			// printf("%s:%d value_node = %s\n", __FILE__, __LINE__, value_node->get_description().c_str());
			linkable=LinkableValueNode::Handle::cast_dynamic(value_node);

			// printf("linkable: %d; do_children: %d\n", bool(linkable), bool(do_children));
			if(linkable && do_children)
			{
				row[model.link_count] = linkable->link_count();
				LinkableValueNode::Vocab vocab(linkable->get_children_vocab());
				LinkableValueNode::Vocab::iterator iter(vocab.begin());
				for(int i=0;i<linkable->link_count();i++, iter++)
				{
					if(iter->get_hidden())
						continue;
					Gtk::TreeRow child_row=*(append(row.children()));
					child_row[model.link_id] = i;
					child_row[model.canvas] = static_cast<Canvas::Handle>(row[model.canvas]);
					child_row[model.name] = linkable->link_local_name(i);
					child_row[model.tooltip] = iter->get_description();
					child_row[model.child_param_desc] = *iter;
					set_row(child_row,synfigapp::ValueDesc(linkable,i));
				}
			}
			return;
		}
		else
		{
			//row[model.is_value_node] = false;
			//row[model.is_editable] = true;
			//row[model.label] = Glib::ustring(row[model.name]);
			return;
		}
	}
	catch(synfig::Exception::IDNotFound x)
	{
		synfig::error(__FILE__":%d: IDNotFound thrown",__LINE__);
		erase(row);
		return;
	}

	// We should never get to this point
	assert(0);
}