EntityChooser::EntityChooser() :
	gtkutil::DialogElement(), // create an Element without label
	_entityStore(Gtk::ListStore::create(_listColumns))
{
	Gtk::VBox* vbox = Gtk::manage(new Gtk::VBox(false, 6));
	_widgets[WIDGET_TOPLEVEL] = vbox;

	// Initialise the base class
	DialogElement::setValueWidget(_widgets[WIDGET_TOPLEVEL]);

	Gtk::TreeView* treeView = Gtk::manage(new Gtk::TreeView(_entityStore));
	_widgets[WIDGET_TREEVIEW] = treeView;

	treeView->set_headers_visible(false);

	// Use the TreeModel's full string search function
	treeView->set_search_equal_func(sigc::ptr_fun(&gtkutil::TreeModel::equalFuncStringContains));

	// Head Name column
	treeView->append_column("", _listColumns.name);

	// Set the tree store to sort on this column
	_entityStore->set_sort_column_id(_listColumns.name, Gtk::SORT_ASCENDING);

	_selection = treeView->get_selection();
	_selection->signal_changed().connect(sigc::mem_fun(*this, &EntityChooser::onSelectionChanged));

	// Scrolled Frame
	vbox->pack_start(*Gtk::manage(new gtkutil::ScrolledFrame(*treeView)), true, true, 0);

	populateEntityList();
}
// Create the objects panel (for manipulating the target_addobjectives objects)
void ObjectivesEditor::setupEntitiesPanel()
{
	// Tree view listing the target_addobjectives entities
    Gtk::TreeView* entityList = gladeWidget<Gtk::TreeView>(
        "entitiesTreeView"
    );
    entityList->set_model(_objectiveEntityList);
	entityList->set_headers_visible(false);

	entityList->get_selection()->signal_changed().connect(
		sigc::mem_fun(*this, &ObjectivesEditor::_onEntitySelectionChanged)
    );
	
	// Active-at-start column (checkbox)
	Gtk::CellRendererToggle* startToggle = Gtk::manage(new Gtk::CellRendererToggle);
	startToggle->signal_toggled().connect(
        sigc::mem_fun(*this, &ObjectivesEditor::_onStartActiveCellToggled)
    );
	
	Gtk::TreeViewColumn* startCol = Gtk::manage(new Gtk::TreeViewColumn(_("Start")));
	startCol->add_attribute(startToggle->property_active(), _objEntityColumns.startActive);
	
	entityList->append_column(*startCol);
	
	// Name column
	entityList->append_column(*Gtk::manage(new gtkutil::TextColumn("", _objEntityColumns.displayName)));
	
    // Connect button signals
    Gtk::Button* addButton = gladeWidget<Gtk::Button>("createEntityButton");
	addButton->signal_clicked().connect(
        sigc::mem_fun(*this, &ObjectivesEditor::_onAddEntity)
    );

    Gtk::Button* delButton = gladeWidget<Gtk::Button>("deleteEntityButton");
	delButton->set_sensitive(false); // disabled at start
	delButton->signal_clicked().connect(
        sigc::mem_fun(*this, &ObjectivesEditor::_onDeleteEntity)
    );
}
示例#3
0
ExampleWindow::ExampleWindow(regex_key_value &regx)
		: m_Box(Gtk::ORIENTATION_VERTICAL),m_VBox(Gtk::ORIENTATION_VERTICAL),m_HBox(Gtk::ORIENTATION_VERTICAL),
		m_frame("Data from file :"),o_frame("Output from file :"),m_Alignment(Gtk::ALIGN_END, Gtk::ALIGN_CENTER, 1.0, 0.0)
{
		set_title("Key Value Extraction");
		set_default_size(800, 600);
		set_position(Gtk::WIN_POS_CENTER);
		add(m_Box);
		// put a MenuBar at the top of the box and other stuff below it.
		//Create actions for menus and toolbars:
		m_refActionGroup = Gtk::ActionGroup::create();
		//File|New sub menu:
		// m_refActionGroup->add(Gtk::Action::create("FileNewStandard",
		// 						Gtk::Stock::NEW, "_New", "Create a new file"),
		// 				sigc::mem_fun(*this, &ExampleWindow::on_menu_file_new_generic));
		m_refActionGroup->add(Gtk::Action::create("FileNewStandard",
								Gtk::Stock::EXECUTE, "_New", "Output"),
						sigc::mem_fun(*this, &ExampleWindow::on_button_output_click));


		//file menu subgroups
		// m_refActionGroup->add(Gtk::Action::create("FileNewFoo",
		// 						Gtk::Stock::NEW, "New Foo", "Create a new foo"),
		// 				sigc::mem_fun(*this, &ExampleWindow::on_menu_file_new_generic));
		// m_refActionGroup->add(Gtk::Action::create("FileNewGoo",
		// 						Gtk::Stock::NEW, "_New Goo", "Create a new goo"),
		// 				sigc::mem_fun(*this, &ExampleWindow::on_menu_file_new_generic));
		//File menu:
		m_refActionGroup->add(Gtk::Action::create("FileMenu", "File"));
		//Sub-menu.
		//m_refActionGroup->add(Gtk::Action::create("FileNew", Gtk::Stock::NEW));

		m_refActionGroup->add(Gtk::Action::create("FileOpen",
								Gtk::Stock::OPEN, "_Open", "Open File"),
						sigc::mem_fun(*this, &ExampleWindow::on_menu_folder_open));

		m_refActionGroup->add(Gtk::Action::create("FileSave",
								Gtk::Stock::SAVE, "_Save", "Save File"),
						sigc::mem_fun(*this, &ExampleWindow::on_menu_others));
		// m_refActionGroup->add(Gtk::Action::create("FilePageSetup", Gtk::Stock::PRINT,"Page Setup"),
		// 				sigc::mem_fun(*this, &ExampleWindow::on_menu_file_quit));
		// m_refActionGroup->add(Gtk::Action::create("FilePrintPreview", Gtk::Stock::PRINT, "Print Preview"),
		// 				sigc::mem_fun(*this, &ExampleWindow::on_menu_file_quit));

		// m_refActionGroup->add(Gtk::Action::create("FilePrint",
		// 						Gtk::Stock::PRINT,"_Print","Print"),
		// 				sigc::mem_fun(*this, &ExampleWindow::on_menu_others));


		m_refActionGroup->add(Gtk::Action::create("FileQuit",
								Gtk::Stock::QUIT, "_Quit","Quit"),
						sigc::mem_fun(*this, &ExampleWindow::on_menu_file_quit));
		//m_refActionGroup->add(Gtk::Action::create("FileQuit", Gtk::Stock::QUIT),
		//sigc::mem_fun(*this, &ExampleWindow::on_menu_file_quit));
		//Edit menu:
		// m_refActionGroup->add(Gtk::Action::create("EditMenu", "Edit"));
		// m_refActionGroup->add(Gtk::Action::create("EditCut", Gtk::Stock::CUT),
		// 				sigc::mem_fun(*this, &ExampleWindow::on_menu_others));
		// m_refActionGroup->add(Gtk::Action::create("EditCopy", Gtk::Stock::COPY),
		// 				sigc::mem_fun(*this, &ExampleWindow::on_menu_others));
		// m_refActionGroup->add(Gtk::Action::create("EditPaste", Gtk::Stock::PASTE),
		// 				sigc::mem_fun(*this, &ExampleWindow::on_menu_others));
		// m_refActionGroup->add(Gtk::Action::create("EditUndo", Gtk::Stock::UNDO),
		// 				sigc::mem_fun(*this, &ExampleWindow::on_menu_others));
		// m_refActionGroup->add(Gtk::Action::create("EditRedo", Gtk::Stock::REDO),
		// 				sigc::mem_fun(*this, &ExampleWindow::on_menu_others));
		//
		m_refActionGroup->add( Gtk::Action::create("HelpMenu", "More") );
		m_refActionGroup->add( Gtk::Action::create("About", Gtk::Stock::ABOUT),
						sigc::mem_fun(*this, &ExampleWindow::on_menu_about) );
						m_refActionGroup->add( Gtk::Action::create("Help", Gtk::Stock::ABOUT,"_Help","Help"),
										sigc::mem_fun(*this, &ExampleWindow::on_menu_help) );
		m_refUIManager = Gtk::UIManager::create();
		m_refUIManager->insert_action_group(m_refActionGroup);
		add_accel_group(m_refUIManager->get_accel_group());


		//Layout the actions in a menubar and toolbar:
		Glib::ustring ui_info =
				"<ui>"
				" <menubar name='MenuBar'>"
				" <menu action='FileMenu'>"
				//" <menu action='FileNew'>"
				//" <menuitem action='FileNewStandard'/>"
				//" <menuitem action='FileNewFoo'/>"
				//" <menuitem action='FileNewGoo'/>"
				//" </menu>"
				" <menuitem action='FileOpen'/>"
				" <menuitem action='FileSave'/>"
				//" <menuitem action='FilePageSetup'/>"
				//" <menuitem action='FilePrintPreview'/>"
				//" <menuitem action='FilePrint'/>"
				" <menuitem action='FileQuit'/>"
				" </menu>"
				//" <menu action='EditMenu'>"
				//" <menuitem action='EditCut'/>"
				//" <menuitem action='EditCopy'/>"
				//" <menuitem action='EditPaste'/>"
				//" <menuitem action='EditUndo'/>"
				//" <menuitem action='EditRedo'/>"
				//" </menu>"
				" <menu action='HelpMenu'>"
				" <menuitem action='About'/>"
				" <menuitem action='Help'/>"
				" </menu>"
				" </menubar>"
				" <toolbar name='ToolBar'>"
				" <toolitem action='FileNewStandard'/>"
				" <separator/>"
				" <toolitem action='FileOpen'/>"
				" <separator/>"
				" <toolitem action='FileSave'/>"
				" <separator/>"
			//	" <toolitem action='FilePrint'/>"
				" <separator/>"
				" <toolitem action='FileQuit'/>"
				" </toolbar>"
				"</ui>";
		try
		{
				m_refUIManager->add_ui_from_string(ui_info);
		}
		catch(const Glib::Error& ex)
		{
				std::cerr << "building menus failed: " << ex.what();
		}
		//Get the menubar and toolbar widgets, and add them to a container widget:
		Gtk::Widget* pMenubar = m_refUIManager->get_widget("/MenuBar");
		if(pMenubar)
				m_Box.pack_start(*pMenubar, Gtk::PACK_SHRINK);
		Gtk::Widget* pToolbar = m_refUIManager->get_widget("/ToolBar") ;
		if(pToolbar)
				m_Box.pack_start(*pToolbar, Gtk::PACK_SHRINK);
		show_all_children();
		//add the grid for the treeview and button
		//Add the Notebook, with the button underneath:
		m_Notebook.set_border_width(10);
		m_Box.pack_start(m_Notebook);
		m_Box.pack_start(m_ButtonBox, Gtk::PACK_SHRINK);
		//m_ButtonBox.pack_start(m_Button_Quit, Gtk::PACK_SHRINK);
		//m_Button_Quit.signal_clicked().connect(sigc::mem_fun(*this, &ExampleWindow::on_quit_click) );
		//Add the Notebook pages:
		m_Notebook.append_page(m_grid, "Regex");
		m_Notebook.append_page(m_grid2, "Log File");
		m_Notebook.append_page(m_grid3, "Output");
		m_Notebook.signal_switch_page().connect(sigc::mem_fun(*this, &ExampleWindow::on_notebook_switch_page) );


		add(m_grid);

		m_grid.set_border_width(20);
		m_grid.set_row_spacing(5);
		m_Box.add(m_grid);


		Gtk::TreeView *treeview = Gtk::manage(new Gtk::TreeView);
		treeview->set_hexpand(true);
		treeview->set_vexpand(true);
		//treeview->get_selection()->set_mode(Gtk::SELECTION_MULTIPLE) ;
		treeview->set_search_column(columns.col_cnt) ;
		treeview_ScrolledWindow.add(*treeview)  ;
		//Only show the scrollbars when they are necessary:
		treeview_ScrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
		m_grid.attach(treeview_ScrolledWindow, 0, 0, 3, 1);

		refTreeModel = Gtk::ListStore::create(columns);

		treeview->set_model(refTreeModel);
		treeview->append_column("S.N", columns.col_cnt);
		treeview->append_column("Datatype", columns.col_text);
		treeview->append_column("Regex Data", columns.col_text2);

		label = Gtk::manage(new Gtk::Label);
		label2 = Gtk::manage(new Gtk::Label);
		label->set_markup("<b><span color='black'>Enter Datatype: </span></b>");
		label2->set_markup("<b><span color='black'>Enter Regex Data: </span></b>");
		m_grid.attach(*label, 0, 1, 1, 1);
		m_grid.attach(*label2, 0, 2, 1, 1);

		text = Gtk::manage(new Gtk::Entry);
		m_grid.attach(*text, 1, 1, 2, 1);
		text2 = Gtk::manage(new Gtk::Entry);
		m_grid.attach(*text2, 1, 2, 2, 3);

		Gtk::Button *b_add = Gtk::manage(new Gtk::Button("Click to add"));
		b_add->signal_clicked().connect(sigc::mem_fun(*this, &ExampleWindow::on_button_add_data_click));
		m_grid.attach(*b_add, 2, 8, 1, 1);

		Gtk::Button *b_remove = Gtk::manage(new Gtk::Button("Click to remove"));
		b_remove->signal_clicked().connect(sigc::mem_fun(*this, &ExampleWindow::on_button_delete_data_click));
		//m_grid.attach(*b_remove, 2, 10, 1, 1);

		// Gtk::Button *b_output = Gtk::manage(new Gtk::Button("Press here for output"));
		// b_output->signal_clicked().connect(sigc::mem_fun(*this, &ExampleWindow::on_button_output_click));
		// m_grid.attach(*b_output, 2, 10, 1, 1);


		m_grid.show_all();




		add(m_grid2);

		m_grid2.set_border_width(20);
		m_grid2.set_row_spacing(5);
		m_Box.add(m_grid2);


		label3 = Gtk::manage(new Gtk::Label);
		label3->set_markup("<b><span color='black'>Open a text file: </span></b>");
		m_grid2.attach(*label3, 0, 1, 1, 1);
		text3 = Gtk::manage(new Gtk::Entry);
		m_grid2.attach(*text3, 10, 1, 1, 1);
		Gtk::Button *b_addfile = Gtk::manage(new Gtk::Button("Browse"));
		b_addfile->signal_clicked().connect(sigc::mem_fun(*this, &ExampleWindow::on_menu_folder_open));
		m_grid2.attach(*b_addfile, 15, 1, 1, 1);

		//m_Entry.set_max_length(50);
		//label2->set_markup("<b><span color='black'>Text file data: </span></b>");
		//m_grid2.attach(*label4, 1, 2, 1, 1);

		add(m_HBox);
		add(m_Alignment);
		m_HBox.pack_start(m_VBox);
		//m_frame.add(m_Label_Normal);
		m_grid2.attach(m_frame, 0,5,200,100);
		//label4 = Gtk::manage(new Gtk::Label);
		//label4->set_markup("<b><span color='black'>The data from text file will appear here. </span></b>");
		//m_Entry.set_text("The data from text file");
		//m_Entry.set_text(m_Entry.get_text() + " will appear here.");
		//m_Entry.select_region(0, m_Entry.get_text_length());
		//m_grid2.attach(m_Entry, 10, 10, 100, 10);
		//m_frame.add(*label4);
		editor = Gtk::manage(new Gtk::TextView) ;
		editor_buffer = Gtk::TextBuffer::create() ;
		editor->set_buffer(editor_buffer) ;
		editor->set_cursor_visible(true) ;
		editor_ScrolledWindow.add(*editor)  ;
		//Only show the scrollbars when they are necessary:
		editor_ScrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
		m_frame.add(editor_ScrolledWindow) ;
		m_frame.set_hexpand(true);
		m_frame.set_vexpand(true);
		// Gtk::Button *m_Button = Gtk::manage(new Gtk::Button("Output"));
		// m_Button->signal_clicked().connect(sigc::mem_fun(*this, &ExampleWindow::on_button_output_click));
		//m_frame.set_label_align(Gtk::ALIGN_END, Gtk::ALIGN_START);
		//m_grid2.attach(*m_Button,40,1,20,1);
		//m_Alignment.add(*m_Button);
		m_frame.add(m_Alignment);
		m_frame.set_shadow_type(Gtk::SHADOW_ETCHED_OUT);
		m_Alignment.show_all();
		m_HBox.show_all();



		m_grid2.show_all();

		//-----------------------------------------------------------------------------------
		add(m_grid3);

		m_grid3.set_border_width(20);
		m_grid3.set_row_spacing(5);
		m_Box.add(m_grid3);

		add(m_HBox);
		add(o_Alignment);
		m_HBox.pack_start(m_VBox);
		m_grid3.attach(o_frame, 0,5,200,100);

		_output = Gtk::manage(new Gtk::TextView) ;
		_output_buffer = Gtk::TextBuffer::create() ;
		_output->set_buffer(_output_buffer) ;
		_output->set_cursor_visible(true) ;
		_output_ScrolledWindow.add(*_output)  ;
		//Only show the scrollbars when they are necessary:
		_output_ScrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
		o_frame.add(_output_ScrolledWindow) ;
		o_frame.set_hexpand(true);
		o_frame.set_vexpand(true);
		Gtk::Button *analyse_Button = Gtk::manage(new Gtk::Button("Analyse"));
		analyse_Button->signal_clicked().connect(sigc::mem_fun(*this, &ExampleWindow::on_button_analyse_click));
		//o_frame.set_label_align(Gtk::ALIGN_START,Gtk::ALIGN_END);
		//attach (Widget& child, int left, int top, int width, int height)
		m_grid3.attach(*analyse_Button,100,110,100,1);
		o_Alignment.add(*analyse_Button);
		o_frame.add(o_Alignment);
		o_frame.set_shadow_type(Gtk::SHADOW_ETCHED_OUT);
		o_Alignment.show_all();
		m_HBox.show_all();



		m_grid3.show_all();

		//---------------------------------------------------------------------------------------------
		reg = &regx  ;
		//reg->readFromFile("regex.tl") ;
		show_all_children();
      rowcount = 0 ;
      for(; rowcount < reg->get_regex_count();rowcount++){
        Gtk::TreeModel::Row row = *(refTreeModel->append());
        row[columns.col_cnt] = rowcount;
        row[columns.col_text] = reg->gettype(rowcount);
        row[columns.col_text2] = reg->getRegex(rowcount);
    }


}
示例#4
0
Frame_FilesTab::Frame_FilesTab()
{
    this->set_shadow_type(Gtk::SHADOW_IN);
    this->set_margin_top(5);
    this->set_margin_left(5);
    this->set_margin_right(5);
    this->set_margin_bottom(5);

    Gtk::ScrolledWindow *ScrolledWindow = Gtk::manage(new Gtk::ScrolledWindow);
    ScrolledWindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
    this->add(*ScrolledWindow);

    Gtk::TreeView *tvFiles = Gtk::manage(new Gtk::TreeView);
    tvFiles->set_grid_lines(Gtk::TREE_VIEW_GRID_LINES_BOTH);
    ScrolledWindow->add(*tvFiles);

    refTreeModel = Gtk::ListStore::create(FilesColumns);
    tvFiles->set_model(refTreeModel);

    tvFiles->append_column("Name", FilesColumns.Name);


    Gtk::CellRendererText *cellrenderer_FileType = Gtk::manage(new Gtk::CellRendererText);
    Gtk::TreeView::Column *tvFiles_FileType = Gtk::manage(new Gtk::TreeView::Column);
    tvFiles_FileType->set_title("Type");
    //tvFiles_FileType->set_resizable(true);
    tvFiles_FileType->pack_start(*cellrenderer_FileType);
    tvFiles_FileType->set_cell_data_func(*cellrenderer_FileType, sigc::mem_fun(*this, &Frame_FilesTab::treeviewcolumn_filetype));
    tvFiles->append_column(*tvFiles_FileType);

    Gtk::CellRendererText *cellrenderer_FileSize = Gtk::manage(new Gtk::CellRendererText);
    Gtk::TreeView::Column *tvFiles_FileSize = Gtk::manage(new Gtk::TreeView::Column);
    tvFiles_FileSize->set_title("Type");
    //tvFiles_FileSize->set_resizable(true);
    tvFiles_FileSize->pack_start(*cellrenderer_FileSize);
    tvFiles_FileSize->set_cell_data_func(*cellrenderer_FileSize, sigc::mem_fun(*this, &Frame_FilesTab::treeviewcolumn_filesize));
    tvFiles->append_column(*tvFiles_FileSize);

    Gtk::CellRendererProgress *cellrenderer_FileProgress = Gtk::manage(new Gtk::CellRendererProgress);
    Gtk::TreeView::Column *tvFiles_FileProgress = Gtk::manage(new Gtk::TreeView::Column);
    tvFiles_FileProgress->set_title("Progress");
    //tvFiles_FileProgress->set_resizable(true);
    tvFiles_FileProgress->pack_start(*cellrenderer_FileProgress);
    tvFiles_FileProgress->set_cell_data_func(*cellrenderer_FileProgress, sigc::mem_fun(*this, &Frame_FilesTab::treeviewcolumn_fileprogress));
    tvFiles->append_column(*tvFiles_FileProgress);

    Gtk::CellRendererText *cellrenderer_FilePriority = Gtk::manage(new Gtk::CellRendererText);
    Gtk::TreeView::Column *tvFiles_FilePriority = Gtk::manage(new Gtk::TreeView::Column);
    tvFiles_FilePriority->set_title("Priority");
    //tvFiles_FilePriority->set_resizable(true);
    tvFiles_FilePriority->pack_start(*cellrenderer_FilePriority);
    tvFiles_FilePriority->set_cell_data_func(*cellrenderer_FilePriority, sigc::mem_fun(*this, &Frame_FilesTab::treeviewcolumn_filepriority));
    tvFiles->append_column(*tvFiles_FilePriority);


    // TODO: REMOVE TEST DATA BELOW
    Gtk::TreeModel::Row row = *(refTreeModel->append());
    row[FilesColumns.Name] = "File Name.Mp4";
    row[FilesColumns.Size] = (1024 * 1024) *1023 + 5504;
    row[FilesColumns.Progress] = 75;
    row[FilesColumns.Priority] = 2;
}
void GstPropertiesModule::show_pad_properties()
{
	auto pad = std::dynamic_pointer_cast<PadModel>(controller->get_selected_object());

	if (!pad)
	{
		return;
	}

	PadPropertyModelColumns cols;
	auto model = Gtk::TreeStore::create(cols);
	Gtk::TreeView *tree = Gtk::manage(new Gtk::TreeView());
	tree->append_column(_("Property Name"), cols.m_col_name);
	tree->append_column(_("Property Value"), cols.m_col_value);
	tree->set_model(model);

#define APPEND_ROW(name, value) \
	do { \
		row = *(model->append()); \
		row[cols.m_col_name] = name; \
		row[cols.m_col_value] = value; \
	} while (false);

	std::string peer_pad = pad->get_peer() ? ElementPathProcessor::get_object_path(pad->get_peer()) : std::string("NO PEER PAD");

	Gtk::TreeModel::Row row;
	APPEND_ROW(_("Name"), pad->get_name());

	if (pad->get_template())
	{
		display_template_info(pad->get_template(), model, cols.m_col_name, cols.m_col_value);
	}

	APPEND_ROW(_("Presence"), get_presence_str(pad->get_presence()));
	APPEND_ROW(_("Direction"), get_direction_str(pad->get_direction()));
	APPEND_ROW(_("Peer pad"), peer_pad);

	if (pad->get_current_caps())
	{
		APPEND_ROW(_("Current caps"), "");
		display_caps(pad->get_current_caps(), model, cols.m_col_name, cols.m_col_value, row);
	}
	else
	{
		APPEND_ROW(_("Current caps"), _("unknown"));
	}

	if (pad->get_allowed_caps())
	{
		APPEND_ROW(_("Allowed caps"), "");
		display_caps(pad->get_allowed_caps(), model, cols.m_col_name, cols.m_col_value, row);
	}
	else
	{
		APPEND_ROW(_("Allowed caps"), _("unknown"));
	}

#undef APPEND_ROW

	tree->show();
	properties_box->pack_start(*tree, true, true, 0);
}
// Create the main objective editing widgets
void ObjectivesEditor::setupObjectivesPanel()
{
    // Tree view
    Gtk::TreeView* objList = gladeWidget<Gtk::TreeView>(
        "objectivesTreeView"
    );
    objList->set_model(_objectiveList);
    objList->set_headers_visible(true);

    objList->get_selection()->signal_changed().connect(
        sigc::mem_fun(*this, &ObjectivesEditor::_onObjectiveSelectionChanged)
    );
    
    // Key and value text columns
    objList->append_column(*Gtk::manage(
        new gtkutil::TextColumn("#", _objectiveColumns.objNumber, false)));
    objList->append_column(*Gtk::manage(
        new gtkutil::TextColumn(_("Description"), _objectiveColumns.description, false)));
    objList->append_column(*Gtk::manage(
        new gtkutil::TextColumn(_("Diff."), _objectiveColumns.difficultyLevel, false)));
    
    Gtk::Button* addButton = gladeWidget<Gtk::Button>("addObjButton");
    addButton->signal_clicked().connect(
        sigc::mem_fun(*this, &ObjectivesEditor::_onAddObjective)
    );

    Gtk::Button* editObjButton = gladeWidget<Gtk::Button>(
        "editObjButton"
    );
    editObjButton->set_sensitive(false); // not enabled without selection 
    editObjButton->signal_clicked().connect(
        sigc::mem_fun(*this, &ObjectivesEditor::_onEditObjective)
    );

    Gtk::Button* moveUpObjButton = gladeWidget<Gtk::Button>(
        "objMoveUpButton"
    );
    moveUpObjButton->set_sensitive(false); // not enabled without selection 
    moveUpObjButton->signal_clicked().connect(
        sigc::mem_fun(*this, &ObjectivesEditor::_onMoveUpObjective)
    );

    Gtk::Button* moveDownObjButton = gladeWidget<Gtk::Button>(
        "objMoveDownButton"
    );
    moveDownObjButton->set_sensitive(false); // not enabled without selection 
    moveDownObjButton->signal_clicked().connect(
        sigc::mem_fun(*this, &ObjectivesEditor::_onMoveDownObjective)
    );

    Gtk::Button* delObjButton = gladeWidget<Gtk::Button>(
        "delObjButton"
    );
    delObjButton->set_sensitive(false); // not enabled without selection 
    delObjButton->signal_clicked().connect(
        sigc::mem_fun(*this, &ObjectivesEditor::_onDeleteObjective)
    );
    
    Gtk::Button* clearObjButton = gladeWidget<Gtk::Button>(
        "clearObjectivesButton"
    );
    clearObjButton->set_sensitive(false); // requires >0 objectives
    clearObjButton->signal_clicked().connect(
        sigc::mem_fun(*this, &ObjectivesEditor::_onClearObjectives)
    );
}
示例#7
0
文件: viz_tab.cpp 项目: drmorr0/viz
// This is horribly inefficient right now, but I have other things I'd rather focus on.
void VizTab::updateSelectionText()
{
    string info = ""; 
    if (mCurrSelection.size() == 1)
    {   
        int gid = mCurrSelection.back();
        graph::VertexData* data = pGraph->vertexData(gid);
        for (auto prop = data->properties.begin(); prop != data->properties.end(); ++prop)
            info += prop->first + ": " + prop->second + "\n";
        TheBuilder::get<Gtk::Button>("viz_compare_button")->hide();
    }   
    else if (mCurrSelection.size() > 1)
    {   
        TheBuilder::get<Gtk::Button>("viz_compare_button")->show();
        info = "You have selected " + to_string(mCurrSelection.size()) + " items.";
    }   
    else TheBuilder::get<Gtk::Button>("viz_compare_button")->hide();
    Gtk::TextView* infoBox = TheBuilder::get<Gtk::TextView>("viz_sel_info_box");
    infoBox->get_buffer()->set_text(info);

	map<string, vector<string>> selectedProperties;
	for (int i = 0; i < mCurrSelection.size(); ++i)
	{
		graph::VertexData* data = pGraph->vertexData(mCurrSelection[i]);
		for (auto prop = data->properties.begin(); prop != data->properties.end(); ++prop)
			selectedProperties[prop->first];
	}

	Gtk::TreeModel::ColumnRecord colRec;
	vector<Gtk::TreeModelColumn<Glib::ustring>*> cols;
	for (int i = 0; i < selectedProperties.size(); ++i)
	{
		cols.push_back(new Gtk::TreeModelColumn<Glib::ustring>);
		colRec.add(*cols.back());
	}
	
	auto listStore = Gtk::ListStore::create(colRec);

	for (int i = 0; i < mCurrSelection.size(); ++i)
	{
		auto row = listStore->append();
		int j = 0;
		for (auto prop = selectedProperties.begin(); prop != selectedProperties.end(); ++prop)
		{
			string val;
			graph::VertexData* data = pGraph->vertexData(mCurrSelection[i]);
			if (data->properties.find(prop->first) != data->properties.end())
				val = data->properties[prop->first];
			row->set_value(j++, val);
		}
	}

	Gtk::TreeView* tv = TheBuilder::get<Gtk::TreeView>("compare_treeview");
	tv->set_model(listStore);
	int i = 0;
	for (auto prop = selectedProperties.begin(); prop != selectedProperties.end(); ++prop)
	{
		tv->append_column(prop->first, *(cols[i]));
		tv->get_column(i++)->set_reorderable();
	}
}