Esempio n. 1
0
static void ClearStore(RefPtr<ObjectStore> os)
{
    Gtk::TreeModel::Children children = os->children();
    // с конца быстрее - не требуется реиндексация
    while( children.size() )
        DeleteMedia(os, --children.end());
}
void VistaCrearVideo::on_button_Descargar(){
	std::stringstream ss;
	ss << m_FPSEntry.get_text().c_str();
	double f=0.0;
	ss >> f;

	std::cerr << "FPS: " << f << std::endl;
	if (f<0.5)
		return this->ventanaError("Ingresa las FPS!\n\n\n--mayor o igual a 0.5--", "Error");
	if (f>50)
		return this->ventanaError("Imposible tantos FPS!", "Error");

	/*Abro el dialogo para elegir nombre de archivo, la extencion sera mp4*/
	Gtk::FileChooserDialog dialog("Elige donde y con que nombre guardar el video",
			Gtk::FILE_CHOOSER_ACTION_SAVE);

	//Add response buttons the the dialog:
	dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
	dialog.add_button("Select", Gtk::RESPONSE_OK);

	int result = dialog.run();
	std::string nombre;
	//Handle the response:
	switch(result){
	case(Gtk::RESPONSE_OK):{
		std::cerr << "Select clicked." << std::endl;
		std::cerr << "Folder selected: " << dialog.get_filename()
		        				<< std::endl;

		nombre = (dialog.get_filename().c_str());
		nombre+=".mp4";

		break;
	}
	case(Gtk::RESPONSE_CANCEL):{
		std::cerr << "Cancel clicked." << std::endl;
		return;
	}
	default:{
		std::cerr << "Unexpected button clicked." << std::endl;
		return;
	}
	}

	Gtk::TreeModel::Children children = m_refImagenesListStore->children();
	Gtk::TreeModel::Children::iterator it;

	std::vector<std::string> rutaFrames;

	for(it=children.begin(); it != children.end(); ++it){
		Gtk::TreeModel::Row row = *it;
		Glib::ustring s = row[m_ImagenesList.m_Columns.m_col_ruta];
		std::string strin(s.c_str());
		rutaFrames.push_back(strin);
	}

	common::Video::guardarAPartirDeImagenes(nombre,rutaFrames,f);
}
Esempio n. 3
0
Gtk::TreeModel::iterator MemberList::getListIter(Gtk::TreeModel::
                Children children,
                const Glib::ustring & id)
{
        /*查找好友列表项 */
        return find_if(children.begin(),
                       children.end(),
                       bind2nd(CompareMember(columns), id));
}
Esempio n. 4
0
void ParentChooser::setID(int ID)
{
	Gtk::TreeIter iter;
	Gtk::TreeModel::Children children = model->children();
	iter = findRow(ID);
	if (iter != children.end())
	{
		model->erase(iter);
	}
}
Esempio n. 5
0
 /**
  * Select (highlight it) string from ComboBoxString if exist.
  *
  * @param str string to select from ComboBoxString.
  */
 void select_string(const Glib::ustring& str) {
     Gtk::TreeModel::Children children = mListStore->children();
     Gtk::TreeModel::Children::iterator it = children.begin();
     while (it != children.end()) {
         Gtk::TreeModel::Row row = (*it);
         if (row and row[mColumn.mString] == str) {
             set_active(it);
         }
         ++it;
     }
 }
void VistaCrearVideo::actualizarFramesReproductor(){
	Gtk::TreeModel::Children children = m_refImagenesListStore->children();
	Gtk::TreeModel::Children::iterator it;

	std::vector< Gtk::Image* > frames;

	for(it=children.begin(); it != children.end(); ++it){
		Gtk::TreeModel::Row row = *it;
		frames.push_back((row[m_ImagenesList.m_Columns.m_col_imgGrande]));
	}
	reproductor.setearFrames(frames);
}
Esempio n. 7
0
void MemberList::clearMember()
{
        Gtk::TreeModel::Children children = refListStore->children();
        Gtk::TreeModel::iterator iter = children.begin();

        while ( iter != children.end()) {
                //Glib::ustring name = (*iter)[columns.name];
                //std::cout<<"erase ============"<<name<<std::endl;
                iter = refListStore->erase(iter);
        }

        m_number = 0;
}
void ConfigurationDialog::on_remove_button_clicked()
{
  Glib::RefPtr<Gtk::TreeSelection> refTreeSelection = m_treeView.get_selection();
  Gtk::TreeModel::iterator it = refTreeSelection->get_selected();
  if(!it) return;
  m_toolkit->removeSynapseDefinition((*it)[m_indexColumn]);
  m_refTreeModel2->erase(it);
  Gtk::TreeModel::Children rows = m_refTreeModel2->children();
  m_scIndex = 0;
  for(Gtk::TreeModel::Children::iterator jt = rows.begin(); jt != rows.end(); jt++){
    (*jt)[m_indexColumn] = m_scIndex;
    m_scIndex++;
  }
}
void SimulOutSetsAdapterModelImpl::setSelectedSetName(std::string SetName)
{
  Gtk::TreeModel::Children Children = mref_ListStore->children();

  for (Gtk::TreeModel::Children::iterator it = Children.begin(); it
      != Children.end(); ++it)
  {
    if (it->get_value(m_Columns.m_Name) == SetName)
    {
      m_SelectedRowRef = mref_ListStore->createRowRefFromIter(it);
      return;
    }
  }
}
Esempio n. 10
0
Gtk::TreeModel::iterator ParentChooser::findRow(int id)
{
	Gtk::TreeIter iter;
	Gtk::TreeModel::Children children = model->children();

	for (iter = children.begin(); iter != children.end(); iter++)
	{
		Gtk::TreeModel::Row row = *iter;
		if (row[Columns.col_id] == id)
		{
			break;
		}
	}
	return iter;
}
Esempio n. 11
0
//
// 全ての有効な項目を文字列で取得
//
std::string SelectItemPref::get_items()
{
    std::string items;

    const Gtk::TreeModel::Children children = m_store_shown->children();
    Gtk::TreeModel::iterator it = children.begin();
    while( it != children.end() )
    {
        Gtk::TreeModel::Row row = *it;
        items.append( row[ m_columns_shown.m_column_text ] + " " );
        ++it;
    }

    return items;
}
Esempio n. 12
0
void EntityChooser::importFromString(const std::string& str)
{
	Gtk::TreeModel::Children children = _entityStore->children();

	for (Gtk::TreeModel::Children::iterator i = children.begin(); i != children.end(); ++i)
	{
		Gtk::TreeModel::Row row = *i;

		if (row[_listColumns.name] == str)
		{
			_selection->select(i);
			break;
		}
	}
}
Esempio n. 13
0
void setup_model(){
	{
		//treeview
		treemodel = Gtk::ListStore::create(columns);	
		treeview1->set_model(treemodel);
		treeview1->append_column("Filename", columns.Filename);
		treeview1->append_column("Url", columns.url);
		treeview1->append_column("Size", columns.size);
		treeview1->append_column("%", columns.percentage_complete);
		treeview1->append_column("Time Left", columns.time_left);
		treeview1->append_column("Action", columns.action);

		//make all columns resizeable and set width
		std::vector<Gtk::TreeViewColumn*> tv_columns = treeview1->get_columns();	
		std::vector<Gtk::TreeViewColumn*>::iterator iter = tv_columns.begin();
		int count = 0;
		for (; iter!=tv_columns.end(); iter++, count++){
			Gtk::TreeViewColumn* col = *iter;
			col->set_resizable(true);
			col->set_fixed_width(column_widths[count]);
		}
		Gtk::TreeModel::Row row = *(treemodel->append());
		row[columns.Filename] = "33";
		row[columns.url] = "SFDSD";

		Gtk::TreeModel::Children children = treemodel->children();
		for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter){
			Gtk::TreeModel::Row row = *iter;
			row->set_value(0, (Glib::ustring)"asdfaksdhfakshdfklasjdfhklsafdhlaskjdhflksajdhfasdfads");
			row->set_value(4, (Glib::ustring)"asdfads");
		}
	}
	{
		comboboxmodel = Gtk::ListStore::create(combo_columns);	
		combobox_size->set_model(comboboxmodel);
		Gtk::TreeModel::Row row = *(comboboxmodel->append());
		combobox_size->set_id_column(0);
		Gtk::CellRendererText *cell = new Gtk::CellRendererText(); 
		combobox_size->pack_start(*cell);
		combobox_size->add_attribute(*cell, "text", combo_columns.size); 
		row[combo_columns.size] = "kB";
		(*(comboboxmodel->append()))[combo_columns.size] = "MB";
		combobox_size->set_active(0);
	}
}
Esempio n. 14
0
//
// 非表示項目から指定した項目を削除
//
void SelectItemPref::erase_hidden( const std::string& name )
{
    if( name == ITEM_NAME_SEPARATOR ) return;

    const Gtk::TreeModel::Children children = m_store_hidden->children();
    Gtk::TreeModel::iterator it = children.begin();
    while( it != children.end() )
    {
        Gtk::TreeModel::Row row = *it;
        if( row[ m_columns_hidden.m_column_text ] == name )
        {
            m_store_hidden->erase( *it );
            break;
        }

        ++it;
    }
}
Esempio n. 15
0
void ParentChooser::setParentID(int parentID)
{
	if (parentID >= 0)
	{
		this->parentID = parentID;
	}
	else
	{
		this->parentID = 0;
	}
	Gtk::TreeIter iter;
	Gtk::TreeModel::Children children = model->children();
	iter = findRow(parentID);
	if (iter != children.end())
	{
		set_active(iter);
	}
}
Esempio n. 16
0
/// @fn void LibraryView::loadImagesByTags()
/// @brief Method (signal handler) responsible for updating thumbnails in right panel.
///        Called when tag from tags list is selected.
/// @param path Path to selected row, provided by signal system.
/// @param column Clicked column, provided by signal system, not used.
void LibraryView::loadImagesByTags() {
  Gtk::TreeModel::Children children = tags_list->children();
  Gtk::TreeModel::Children::iterator iter = children.begin();
  Gtk::TreeModel::Row row;
  std::set<std::string> selected_tags;

  //looking for selected tags
  for(; iter != children.end(); ++iter) {
    row = *iter;
    if((*row)[tags_columns.selected])
      selected_tags.insert((std::string)(*row)[tags_columns.name]);
  }

  //loading photos
  if(!selected_tags.empty()) {
    core->setCurrentTagSet(selected_tags);
    //window->showEditView();
  }
}
VistaCrearVideo::~VistaCrearVideo() {
	reproductor.matar();
	pthread_cond_broadcast(&cond); //para que salga del bloqueo
	std::cerr << "JOINEO REPRODUCTOR\n";
	reproductor.join();
	std::cerr << "REPRODUCTOR JOINEADO\n";

	pthread_cond_destroy(&cond);


	Gtk::TreeModel::Children children = m_refImagenesListStore->children();
	Gtk::TreeModel::Children::iterator it;

	/*Libero las imagenes*/
	for(it=children.begin(); it != children.end(); ++it){
		Gtk::TreeModel::Row row = *it;
		if (row[m_ImagenesList.m_Columns.m_col_imgGrande])
			delete row[m_ImagenesList.m_Columns.m_col_imgGrande];

	}
}
Esempio n. 18
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;
    }
}
Esempio n. 19
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);
    }
}/*}}}*/
Esempio n. 20
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 );
}
//------------------------------------------------------------------------------
void QueryOutputView::refresh()
{
  const int mode = _mode.get_active_row_number();
  switch (mode)
  {

    case 2: // History output
    {
      const Glib::RefPtr<Gtk::TreeModel> entry_model = _entries_grid.get_model();
      const Gtk::TreeModel::Children children = entry_model->children();
      const int size = children.size();
      if (size > 0)
      {
        const Gtk::TreeIter iter = (--children.end());
        const Gtk::TreePath path = entry_model->get_path(iter);
        _entries_grid.set_cursor(path);
      }

      _details_grid.scroll_to(1);
    }
    case 0: // Action Output - always need refresh even if it's not visible
    case 1: //Text output
    {
      _action_output.refresh(false);

      const int log_row_count = _action_output.row_count();
      if (log_row_count > 0)
      {
        Gtk::TreePath path;
        path.push_back(log_row_count-1);
        _action_output.scroll_to_row(path);
        _action_output.set_cursor(path);
      }
      break;
    }
  }
}
Esempio n. 22
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 );
}
//------------------------------------------------------------------------------
void mforms::gtk::ToolBarImpl::set_item_text(mforms::ToolBarItem *item, const std::string &label) {
  const mforms::ToolBarItemType type = item->get_type();

  switch (type) {
    case mforms::TextActionItem:
    case mforms::ActionItem:
    case mforms::SegmentedToggleItem:
    case mforms::ToggleItem:
    case mforms::SwitcherItem: {
      Gtk::Button *btn = cast<Gtk::Button *>(item->get_data_ptr());
      if (type == mforms::SwitcherItem) {
        btn->set_label(label);
        btn->get_style_context()->add_class("SwitcherItem");
      } else
        btn->add_label(label);
      btn->set_name(label);
      break;
    }
    case mforms::TitleItem:
    case mforms::LabelItem: {
      Gtk::Label *lbl = cast<Gtk::Label *>(item->get_data_ptr());
      if (lbl) {
        lbl->set_markup("<small>" + label + "</small>");
        lbl->set_name(label);
      }
      break;
    }
    case mforms::FlatSelectorItem:
    case mforms::SelectorItem: {
      Gtk::ComboBoxText *ct = cast<Gtk::ComboBoxText *>(item->get_data_ptr());
      if (ct)
        ct->set_active_text(label);
      break;
    }
    case mforms::ColorSelectorItem: {
      Gtk::ComboBox *combo = cast<Gtk::ComboBox *>(item->get_data_ptr());
      if (combo) {
        Glib::RefPtr<Gtk::TreeModel> model = combo->get_model();
        if (model) {
          const Gtk::TreeModel::Children children = model->children();
          const Gtk::TreeIter last = children.end();
          Gtk::TreeRow row;

          for (Gtk::TreeIter it = children.begin(); it != last; ++it) {
            row = *it;
            if (row.get_value(color_combo_columns->color) == label) {
              combo->set_active(it);
              break;
            }
          }
        }
      }
      break;
    }
    case mforms::SearchFieldItem:
    case mforms::TextEntryItem: {
      Gtk::Entry *e = cast<Gtk::Entry *>(item->get_data_ptr());
      if (e)
        e->set_text(label);
      break;
    }
    case mforms::SeparatorItem:
    case mforms::ExpanderItem:
    case mforms::ImageBoxItem:
      break;
  }
}
Esempio n. 24
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);
	}
}
Esempio n. 25
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);
	}
}
Esempio n. 26
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();
    }
}/*}}}*/
Esempio n. 27
0
void
HybrisMonitorGtkWindow::on_planner_status_cb()
{
  continual_planning_msgs::ContinualPlanningStatus status;

  {
    boost::mutex::scoped_lock lock(msgmtx_planner_status_);
    if (msgq_planner_status_.empty()) {
      return;
    }
    status = msgq_planner_status_.front();
    msgq_planner_status_.pop();
  }

  // Some weird convention to keep the "before" state
  if (status.description == "-")  return;

  switch(status.component) {
  case continual_planning_msgs::ContinualPlanningStatus::PLANNING:
    {
      std::vector<std::string> strs, tmp;
      boost::split(tmp, status.description, boost::is_any_of("\n"));
      for (size_t i = 0; i < tmp.size(); ++i) {
	if (tmp[i] != "") {
	  strs.push_back(tmp[i]);
	}
      }
      plan_list_->clear();
      for (size_t i = 0; i < strs.size(); ++i) {
	Gtk::TreeModel::Row row;
	row = *(plan_list_->append());
	row[plan_record_.step] = strs[i];
      }

      if (strs.empty()) {
	      lab_plan_status_->set_text("");
      } else {
	      std::string status_string = "Plan size: " + std::to_string(strs.size());
	      lab_plan_status_->set_text(status_string);
      }
    }
    break;

  case continual_planning_msgs::ContinualPlanningStatus::CURRENT_PLAN:
    {
      std::vector<std::string> strs, tmp;
      boost::split(tmp, status.description, boost::is_any_of("\n"));
      for (size_t i = 0; i < tmp.size(); ++i) {
        if (tmp[i] != "") {
          strs.push_back(tmp[i]);
        }
      }
      Gtk::TreeModel::Children children = plan_list_->children();

      ssize_t active = -1;
      if (children.size() >= strs.size()) {
	active = children.size() - strs.size();
      }

      ssize_t i = 0;
      for (Gtk::TreeModel::Children::iterator c = children.begin(); c != children.end(); ++c) {
	Gdk::Color color;
	if (i == active) {
	  //trv_plan_->set_cursor(plan_list_->get_path(c));
	  color.set_rgb_p(0.8, 0.8, 1.0);
	} else {
	  color.set_rgb_p(1.0, 1.0, 1.0);
	}
	(*c)[plan_record_.background] = color;
	++i;
      }
    }
    break;

      /*
  case continual_planning_msgs::ContinualPlanningStatus::EXECUTION:
    {
      std::string active_action = get_action_description(status.description);

      Gtk::TreeModel::Children children = plan_list_->children();
      for (Gtk::TreeModel::Children::iterator c = children.begin(); c != children.end(); ++c) {
	Gdk::Color color;
	if (get_action_description((Glib::ustring)(*c)[plan_record_.step]) == active_action) {
	  //trv_plan_->set_cursor(plan_list_->get_path(c));
	  color.set_rgb_p(0.8, 0.8, 1.0);
	} else {
	  color.set_rgb_p(1.0, 1.0, 1.0);
	}
	(*c)[plan_record_.background] = color;
      }
    }
    break;
      */

  default: // ignored
    break;
  } 

  Glib::RefPtr<Gtk::Adjustment> adjustment = window_plan_->get_vadjustment();
  adjustment->set_value(adjustment->get_upper());
}
Esempio n. 28
0
Gtk::TreeIter
ConfigTreeView::get_iter(const char* p)
{
  char* path;
  char* full_path;

  if (asprintf(&full_path, "%s", p) == -1) {
    throw OutOfMemoryException("get_iter(): asprintf() failed");
  }
  char* node = strtok(full_path, "/");

  if (asprintf(&path, "/%s", node) == -1) {
    throw OutOfMemoryException("get_iter(): asprintf() failed");
  }

  Gtk::TreeModel::Children children = m_config_tree->children();
  Gtk::TreeIter iter = children.begin();

  while ( node != NULL )
    {
      bool found = false;
      iter = children.begin();

      while ( !found && iter != children.end() )
	{
	  Gtk::TreeModel::Row row = *iter;

	  Glib::ustring r = row[m_config_record.node];
	  if ( strcmp(r.c_str(), node) == 0 )
	    {
	      found = true;
	      children = row.children();
	      iter = children.begin();
	    }
	  else
	    { ++iter; }
	}

      if ( !found )
      {
	iter = m_config_tree->append(children);
	Gtk::TreeModel::Row row = *iter;
	row[m_config_record.node] = Glib::ustring(node);
	row[m_config_record.path] = Glib::ustring(path);
	
	children = row.children();
      }

      node = strtok(NULL, "/");

      char* t;
      if (asprintf(&t, "%s/%s", path, node) == -1) {
	throw OutOfMemoryException("get_iter(): asprintf() failed");
      }
      free(path);
      path = t;
    }

  free(path);
  free(full_path);

  return iter;
}
Esempio n. 29
0
void
file_chooser::on_response (int response_id)
{
  if (Gtk::RESPONSE_ACCEPT != response_id) return;

  if (get_current_extension ().empty ())
    set_current_extension (default_extension_);

  std::string fmt;
  {                             // check whether extension is known
    std::string ext (get_current_extension ());
    bool found = false;
    Gtk::TreeModel::Children children (file_type_.get_model ()->children ());

    for (Gtk::TreeModel::Children::const_iterator it = children.begin ();
         !found && children.end () != it;
         ++it)
      {
        Gtk::TreeModel::Row r = *it;
        extension_list      l = r[column->exts];

        found = count (l.begin (), l.end (), ext);

        if (found) fmt = r[column->text];
      }

    if (!found)
      {
        Gtk::MessageDialog tbd
          (*this, _("Unsupported file format."),
           use_markup, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, modal);

        tbd.set_secondary_text
          ((format (_("The '%1%' file extension is not associated with"
                      " a supported file format.  Please select a file"
                      " format or use one of the known file extensions."))
            % ext).str ());

        if (dynamic_cast< Gtk::Window * > (this))
          get_group ()->add_window (tbd);

        tbd.run ();
        signal_response ().emission_stop ();
        response (Gtk::RESPONSE_CANCEL);
        return;
      }
  }
  if (!single_image_mode_
      && requests_single_file (get_current_name ()))
    {                           // check whether single file is okay
      if (!supports_multi_image (get_current_name ()))
        {
          Gtk::MessageDialog tbd
            (*this, (format (_("The %1% format does not support multiple"
                               " images in a single file.")) % fmt).str (),
             use_markup, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, modal);

          tbd.set_secondary_text
            ((format (_("Please save to PDF or TIFF if you want a single"
                        " file.  If you prefer the %1% image format, use"
                        " a filename such as 'Untitled-%%3i%2%'."))
              % fmt % get_current_extension ()).str ());

          if (dynamic_cast< Gtk::Window * > (this))
            get_group ()->add_window (tbd);

          tbd.run ();
          signal_response ().emission_stop ();
          response (Gtk::RESPONSE_CANCEL);
          return;
        }
    }

  if (!do_overwrite_confirmation_) return;

  format message;
  format details;

  if (requests_single_file (get_current_name ()))
    {
      if (!fs::exists (std::string (get_filename ()))) return;

      message = format (_("The name \"%1%\" already exists.\n"
                          "OK to overwrite this name using the new settings?"));
      details = format (_("The file already exists in \"%1%\"."
                          "  Replacing it will overwrite its contents."));
    }
  else
    {
      // FIXME Add meaningful checking
      // if (no_possible_matches ) return;

      message = format (_("Files matching \"%1%\" may already exist."
                          "  Do you want to replace them?"));
    //details = format (_("These files already exist in \"%1%\"."
    //                    "  Replacing them may overwrite their contents."));

      // FIXME show list of matching files in an expander with details
    }

  message % get_current_name ();
  if (0 < details.size ())
    details % get_current_folder ();

  Gtk::MessageDialog tbd (*this, message.str (), use_markup,
                          Gtk::MESSAGE_QUESTION,
                          Gtk::BUTTONS_NONE, modal);

  if (0 < details.size ())
    tbd.set_secondary_text (details.str ());
  tbd.add_button (Gtk::Stock::NO , Gtk::RESPONSE_CANCEL);
  tbd.add_button (Gtk::Stock::YES, Gtk::RESPONSE_ACCEPT);
  tbd.set_default_response (Gtk::RESPONSE_ACCEPT);

  if (dynamic_cast< Gtk::Window * > (this))
    get_group ()->add_window (tbd);

  if (Gtk::RESPONSE_ACCEPT != tbd.run ())
    {
      signal_response ().emission_stop ();
      response (Gtk::RESPONSE_CANCEL);
    }
}
Esempio n. 30
0
int ukwd_wiring_dialog::run()
{
    int result = 42, res_temp;
    Glib::RefPtr<Gtk::ListStore> m;
    set<pair<char, char> > plugs;
    vector<pair<char, char> > steckers_temp;
    Gtk::TreeModel::Children::iterator iter;    
    Glib::ustring first_help, second_help;     
    Gtk::TreeView *t = NULL;
    ref_xml->get_widget("stecker_treeview" + name_post_fix, t);
    
    do
    {
        res_temp = dialog->run();

        // OK clicked?        
        if (res_temp == 0)
        {
            // Yes!
            steckers_temp.clear();
            m = m.cast_dynamic(t->get_model());
            Gtk::TreeModel::Children children = m->children();
            
            // Iterate over all connections in TreeView
            for (iter = children.begin(); iter != children.end(); ++iter)
            {
                pair<char, char> help;
                first_help = (*iter)[plugboard_cols.first];
                second_help = (*iter)[plugboard_cols.second];
                
                help.first = tolower((char)(first_help[0]));
                help.second = tolower((char)(second_help[0]));
                
                steckers_temp.push_back(help);                
            }        
        
            // Check if user selected exactly 13 connections
            if (steckers_temp.size() == 13)
            {
                // Yes! -> set result variables
                current_steckers = steckers_temp;                
                result = res_temp;
            }
            else
            {
                // No! -> error message
                Gtk::MessageDialog msg(*dialog, "There have to be exactly 13 connections.", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
                msg.set_title("Enigma");
                msg.run();                            
            }            
        }
        else
        {
            // No!
            result = res_temp;
        }
    
    } while(result == 42); 
       
    dialog->hide();
    
    return result;
}