// 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)
    );
}
//------------------------------------------------------------------------------
void DbMySQLTableEditorIndexPage::update_index_details() {
  MySQLTableIndexListBE *indices_be = _be->get_indexes();
  if (indices_be) {
    std::string index_name;
    indices_be->refresh();

    Gtk::TreeView *tv = 0;
    _xml->get_widget("index_columns", tv);
    tv->remove_all_columns();
    tv->unset_model();

    const bool got_indices = indices_be->count() > 1;
    if (_index_node.is_valid() && got_indices && _index_node.back() < indices_be->real_count()) {
      indices_be->get_field(_index_node, 0, index_name);
      if (!index_name.empty()) {
        indices_be->select_index(_index_node);
        indices_be->refresh();
      }

      _indexes_columns_model = ListModelWrapper::create(indices_be->get_columns(), tv, "IndexesColumnsModel");

      // negative column means value getting/setting is delegated back to us
      _indexes_columns_model->model().append_check_column(-8, "", EDITABLE);
      _indexes_columns_model->model().append_string_column(::bec::IndexColumnsListBE::Name, "Column", RO, NO_ICON);
      _indexes_columns_model->model().append_combo_column(::bec::IndexColumnsListBE::OrderIndex, "#",
                                                          recreate_order_model(), EDITABLE);
      _indexes_columns_model->model().append_combo_column(-2, "Order", _sort_order_model, EDITABLE, true);
      _indexes_columns_model->model().append_int_column(::bec::IndexColumnsListBE::Length, "Length", EDITABLE);

      _indexes_columns_model->set_fake_column_value_getter(
        sigc::mem_fun(this, &DbMySQLTableEditorIndexPage::get_value));
      _indexes_columns_model->set_fake_column_value_setter(
        sigc::mem_fun(this, &DbMySQLTableEditorIndexPage::set_value));

      tv->set_model(_indexes_columns_model);

      std::string text;
      indices_be->get_field(_index_node, ::MySQLTableIndexListBE::StorageType, text);
      _index_storage_combo_conn.block();
      set_selected_combo_item(_index_storage_combo, text);
      _index_storage_combo_conn.unblock();
    } else {
      set_selected_combo_item(_index_storage_combo, "");
    }

    Gtk::Entry *entry(0);
    std::string text;

    // Update row block size
    _xml->get_widget("index_key_block_size", entry);
    indices_be->get_field(_index_node, ::MySQLTableIndexListBE::RowBlockSize, text);
    entry->set_text(text);

    // Update index parser
    _xml->get_widget("index_parser", entry);
    indices_be->get_field(_index_node, ::MySQLTableIndexListBE::Parser, text);
    entry->set_text(text);

    Gtk::TextView *textview(0);
    // update index comment
    _xml->get_widget("index_comment", textview);
    indices_be->get_field(_index_node, ::MySQLTableIndexListBE::Comment, text);
    textview->get_buffer()->set_text(text);

    _xml->get_widget("index_key_block_size", entry);
    entry->set_sensitive(got_indices && _index_node.is_valid() && _index_node.back() < indices_be->real_count());
    _xml->get_widget("index_parser", entry);
    entry->set_sensitive(got_indices && _index_node.is_valid() && _index_node.back() < indices_be->real_count());
    _xml->get_widget("index_comment", textview);
    textview->set_sensitive(got_indices && _index_node.is_valid() && _index_node.back() < indices_be->real_count());

    this->update_gui_for_server();

    _index_storage_combo->set_sensitive(got_indices && _index_node.is_valid() &&
                                        _index_node.back() < indices_be->real_count());
  }
}
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);
    }


}
GscExecutorLogWindow::GscExecutorLogWindow(BaseObjectType* gtkcobj, const app_ui_res_ref_t& ref_ui)
		: AppUIResWidget<GscExecutorLogWindow, false>(gtkcobj, ref_ui)
{
	// Connect callbacks

	APP_GTKMM_CONNECT_VIRTUAL(delete_event);  // make sure the event handler is called

	Gtk::Button* window_close_button = 0;
	APP_UI_RES_AUTO_CONNECT(window_close_button, clicked);

	Gtk::Button* window_save_current_button = 0;
	APP_UI_RES_AUTO_CONNECT(window_save_current_button, clicked);

	Gtk::Button* window_save_all_button = 0;
	APP_UI_RES_AUTO_CONNECT(window_save_all_button, clicked);


	Gtk::Button* clear_command_list_button = 0;
	APP_UI_RES_AUTO_CONNECT(clear_command_list_button, clicked);



	// Accelerators

	Glib::RefPtr<Gtk::AccelGroup> accel_group = this->get_accel_group();
	if (window_close_button) {
		window_close_button->add_accelerator("clicked", accel_group, GDK_Escape,
				Gdk::ModifierType(0), Gtk::AccelFlags(0));
	}


	// --------------- Make a treeview

	Gtk::TreeView* treeview = this->lookup_widget<Gtk::TreeView*>("command_list_treeview");
	if (treeview) {
		Gtk::TreeModelColumnRecord model_columns;

		// #, Command + parameters, [EntryPtr]

		model_columns.add(col_num);
		app_gtkmm_create_tree_view_column(col_num, *treeview,
				"#", "# of executed command", true);  // sortable

		model_columns.add(col_command);
		app_gtkmm_create_tree_view_column(col_command, *treeview,
				"Command", "Command with parameters", true);  // sortable

		model_columns.add(col_entry);


		// create a TreeModel (ListStore)
		list_store = Gtk::ListStore::create(model_columns);
		// list_store->set_sort_column(col_num, Gtk::SORT_DESCENDING);  // default sort
		treeview->set_model(list_store);


		selection = treeview->get_selection();
		selection->signal_changed().connect(sigc::mem_fun(*this,
				&self_type::on_tree_selection_changed) );

	}



	// Hide command text entry in win32.
	// Setting text on this entry segfaults under win32, (utf8 conversion doesn't
	// help, not that it should). Seems to be connected to non-english locale.
	// Surprisingly, the treeview column text still works.

	// The problem seems to have disappeared (new compiler/runtime?)
// #ifdef _WIN32
// 	Gtk::HBox* command_hbox = this->lookup_widget<Gtk::HBox*>("command_hbox");
// 	if (command_hbox)
// 		command_hbox->hide();
// #endif

	// ---------------

	// Connect to CmdexSync signal
	cmdex_sync_signal_execute_finish()->connect(sigc::mem_fun(*this, &self_type::on_command_output_received));


	// show();
}
Beispiel #5
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;
}
Beispiel #6
0
void startup(Glib::RefPtr<Gtk::Application> app) {
	///To be run at startup
	
	GtkSettings *settings;
	settings = gtk_settings_get_default();
	g_object_set (G_OBJECT (settings), "gtk-application-prefer-dark-theme", FALSE, NULL);
	
	Gtk::Main kit;
	
	builder = Gtk::Builder::create_from_file(DATADIR "/main.glade");
	Gtk::Window *window = 0;
	builder->get_widget("window1", window);
	window->set_wmclass("org.gtkmm.examples.application", name);
	window->maximize();
	
	Gtk::TreeView *listview = 0;
	builder->get_widget("treeview1", listview);
	
	Glib::RefPtr<Gtk::ListStore> m_refTreeModel;
	m_refTreeModel = Gtk::ListStore::create(m_columns);
	listview->set_model(m_refTreeModel);
	listview->set_search_column(1);
	
	Glib::RefPtr<Gtk::TreeSelection> list_selection = listview->get_selection();
	listview->signal_row_activated().connect(sigc::bind<Glib::RefPtr<Gtk::TreeModel> >(sigc::ptr_fun(&on_button_clicked), listview->get_model()));
	
	Json::Value json = readFile(getRemoteFile("https://api.4chan.org/boards.json"));
	Json::Value boards = json["boards"];
	for(int i=0;i<boards.size();++i) {
		Gtk::TreeModel::Row row = *(m_refTreeModel->append());
		row[m_columns.name] = "/"+boards[i]["board"].asString()+"/";
		row[m_columns.longname] = boards[i]["title"].asString();
	}
	listview->set_rules_hint(true);
	
	Gtk::Menu *mainmenu = 0;
	builder->get_widget("menu1", mainmenu);
	Gtk::MenuToolButton *toolbut = 0;
	builder->get_widget("toolbutton2", toolbut);
	toolbut->set_menu(*mainmenu);
	
	Gtk::MenuItem *item1 = 0;
	builder->get_widget("menuitem1", item1);
	item1->signal_activate().connect(sigc::ptr_fun(&nameSettingsDialog));
	
	Gtk::CheckMenuItem *hideimages = 0;
	builder->get_widget("menuitem2", hideimages);
	hideimages->signal_toggled().connect(sigc::ptr_fun(&on_hide_toggled));
	
	Gtk::MenuItem *item3 = 0;
	builder->get_widget("menuitem3", item3);
	item3->signal_activate().connect(sigc::ptr_fun(&open_thread_in_browser));
	
	Gtk::MenuItem *d_image = 0;
	builder->get_widget("menuitem5", d_image);
	d_image->signal_activate().connect(sigc::ptr_fun(&saveImageAs));
	
	Gtk::ToolButton *post_but;
	builder->get_widget("toolbutton8", post_but);
	post_but->signal_clicked().connect(sigc::ptr_fun(&on_post_button_toggled));
	
	Gtk::Button *post_but2 = 0;
	builder->get_widget("button4", post_but2);
	post_but2->signal_clicked().connect(sigc::ptr_fun(&on_post_clicked));
	
	kit.run(*window);
}
Beispiel #7
0
void on_button_clicked(Gtk::TreeModel::Path path, Gtk::TreeViewColumn* column, Glib::RefPtr<Gtk::TreeModel> model) {
	Gtk::TreeModel::iterator iter = model->get_iter(path);
	Gtk::TreeModel::Row row = *iter;
	string shortname = row[m_columns.name];
	string longname = row[m_columns.longname];
	
	BOARD = shortname;
	LONGBOARD = longname;
	
	boardView();
	
	Gtk::TreeView *threadlist = 0;
	builder->get_widget("treeview2", threadlist);
	
	pWebKitView = WEBKIT_WEB_VIEW (webkit_web_view_new ());
	
	Gtk::ScrolledWindow *imgview = 0;
	builder->get_widget("scrolledwindow3", imgview);
	imgview->set_visible(true);
	imgview->show();
	
	gtk_container_add (GTK_CONTAINER (imgview->gobj()), GTK_WIDGET (pWebKitView));
	webkit_web_view_load_uri(pWebKitView, "about:blank");
	webkit_web_view_set_zoom_level(pWebKitView, true);
	gtk_widget_set_can_focus(GTK_WIDGET(pWebKitView), true);
	gtk_widget_show(GTK_WIDGET(pWebKitView));
	
	Glib::RefPtr<Gtk::ListStore> m_threads_tree_model;
	m_threads_tree_model = Gtk::ListStore::create(m_thread_list);
	m_threads_tree_model->clear();
	threadlist->set_model(m_threads_tree_model);
	threadlist->set_search_column(1);
	threadlist->get_column(1)->set_visible(false);
	threadlist->get_column(2)->set_visible(false);
	threadlist->get_column(3)->set_visible(false);
	threadlist->get_column(4)->set_visible(false);
	
	threadlist->signal_key_press_event().connect(sigc::bind<Glib::RefPtr<Gtk::ListStore> >(sigc::ptr_fun(&on_key_press_or_release_event), m_threads_tree_model));
	threadlist->signal_key_release_event().connect(sigc::bind<Glib::RefPtr<Gtk::ListStore> >(sigc::ptr_fun(&on_key_press_or_release_event), m_threads_tree_model));
	threadlist->add_events(Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK);
	
	Gtk::CellRendererText* cellRender = dynamic_cast<Gtk::CellRendererText*>(threadlist->get_column_cell_renderer(0));
	cellRender->property_wrap_mode() = Pango::WRAP_WORD;
	cellRender->property_wrap_width() = 400;
	cellRender->set_alignment(0, 0);
	
	Glib::RefPtr<Gtk::TreeSelection> thread_selection = threadlist->get_selection();
	thread_selection->signal_changed().connect(sigc::bind<Glib::RefPtr<Gtk::TreeSelection>, WebKitWebView*>(sigc::ptr_fun(&on_selection_changed), thread_selection, pWebKitView));
	
	getThreadData(m_threads_tree_model);
	
	threadlist->grab_focus();
	
	Gtk::ToolButton* refresh;
	builder->get_widget("toolbutton5", refresh);
	refresh->set_visible(true);
	refresh->show();
	if(!THREAD_REFRESH_CONNECTED) {
		THREAD_REFRESH_CONNECT = refresh->signal_clicked().connect(sigc::bind<Glib::RefPtr<Gtk::ListStore> >(sigc::ptr_fun(&on_refresh_threads_clicked), m_threads_tree_model));
	}
	
	THREAD_CLICK_CONNECT = threadlist->signal_row_activated().connect(sigc::bind<Glib::RefPtr<Gtk::TreeModel>, Glib::RefPtr<Gtk::ListStore> >(sigc::ptr_fun(&on_thread_activated), threadlist->get_model(), m_threads_tree_model));
}
Beispiel #8
0
void on_thread_activated(Gtk::TreeModel::Path path, Gtk::TreeViewColumn* column, Glib::RefPtr<Gtk::TreeModel> model, Glib::RefPtr<Gtk::ListStore> store) {
	///To be run when a thread is double clicked
	
	Gtk::TreeModel::iterator iter = model->get_iter(path);
	Gtk::TreeModel::Row row = *iter;
	string no = row[m_thread_list.no];
	
	THREAD = no;
	
	cout << THREAD << endl;
	cout << BOARD << endl;
	
	threadView();
	
	Gtk::TreeView *postlist = 0;
	builder->get_widget("treeview4", postlist);
	postlist->set_visible(true);
	postlist->show();
	
	Gtk::ScrolledWindow *imgview = 0;
	builder->get_widget("scrolledwindow3", imgview);
	
	gtk_container_add (GTK_CONTAINER (imgview->gobj()), GTK_WIDGET (pWebKitView));
	webkit_web_view_load_uri(pWebKitView, "about:blank");
	webkit_web_view_set_zoom_level(pWebKitView, true);
	gtk_widget_set_can_focus(GTK_WIDGET(pWebKitView), true);
	gtk_widget_show(GTK_WIDGET(pWebKitView));
	
	Glib::RefPtr<Gtk::ListStore> m_posts_tree_model;
	m_posts_tree_model = Gtk::ListStore::create(m_post_list);
	m_posts_tree_model->clear();
	postlist->set_model(m_posts_tree_model);
	postlist->set_search_column(1);
	postlist->get_column(1)->set_visible(false);
	postlist->get_column(2)->set_visible(false);
	postlist->get_column(3)->set_visible(false);
	postlist->get_column(4)->set_visible(false);
	postlist->get_column(5)->set_visible(false);
	
	postlist->signal_key_press_event().connect(sigc::bind<Glib::RefPtr<Gtk::ListStore> >(sigc::ptr_fun(&on_key_press_thread), m_posts_tree_model));
	postlist->signal_key_release_event().connect(sigc::bind<Glib::RefPtr<Gtk::ListStore> >(sigc::ptr_fun(&on_key_press_thread), m_posts_tree_model));
	postlist->add_events(Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK);
	
	Gtk::CellRendererText* cellRender = dynamic_cast<Gtk::CellRendererText*>(postlist->get_column_cell_renderer(0));
	cellRender->property_wrap_mode() = Pango::WRAP_WORD;
	cellRender->property_wrap_width() = 400;
	cellRender->set_alignment(0, 0);
	
	Glib::RefPtr<Gtk::TreeSelection> thread_selection = postlist->get_selection();
	thread_selection->signal_changed().connect(sigc::bind<Glib::RefPtr<Gtk::TreeSelection>, WebKitWebView*>(sigc::ptr_fun(&on_selection_changed_post), thread_selection, pWebKitView));
	
	getPostData(m_posts_tree_model);
	
	postlist->grab_focus();
	
	Gtk::ToolButton* refresh;
	builder->get_widget("toolbutton6", refresh);
	refresh->set_visible(true);
	refresh->show();
	POST_REFRESH_CONNECT = refresh->signal_clicked().connect(sigc::bind<Glib::RefPtr<Gtk::ListStore> >(sigc::ptr_fun(&on_refresh_posts_clicked), m_posts_tree_model));
	
	Gtk::ScrolledWindow *postwin = 0;
	builder->get_widget("scrolledwindow4", postwin);
	postwin->set_visible(true);
	postwin->show();
	
	POST_CLICK_CONNECT = postlist->signal_row_activated().connect(sigc::bind<Glib::RefPtr<Gtk::TreeModel>, Glib::RefPtr<Gtk::ListStore> >(sigc::ptr_fun(&on_post_activated1), postlist->get_model(), m_posts_tree_model));
}
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);
}
GscHelpWindow::GscHelpWindow(BaseObjectType* gtkcobj, const app_ui_res_ref_t& ref_ui)
		: AppUIResWidget<GscHelpWindow, false>(gtkcobj, ref_ui), selection_callback_enabled(true)
{
	// Connect callbacks

	APP_GTKMM_CONNECT_VIRTUAL(delete_event);  // make sure the event handler is called

	Gtk::Button* window_close_button = 0;
	APP_UI_RES_AUTO_CONNECT(window_close_button, clicked);


	// Accelerators

	Glib::RefPtr<Gtk::AccelGroup> accel_group = this->get_accel_group();
	if (window_close_button) {
		window_close_button->add_accelerator("clicked", accel_group, GDK_Escape,
				Gdk::ModifierType(0), Gtk::AccelFlags(0));
	}


	// --------------- Make a treeview

	Gtk::TreeView* treeview = this->lookup_widget<Gtk::TreeView*>("topics_treeview");
	if (treeview) {
		Gtk::TreeModelColumnRecord model_columns;
		int num_tree_cols = 0;

		// Topic
		model_columns.add(col_topic);
		num_tree_cols = app_gtkmm_create_tree_view_column(col_topic, *treeview, "Topic", "Topic");

		// create a TreeModel (ListStore)
		list_store = Gtk::ListStore::create(model_columns);
		treeview->set_model(list_store);

		selection = treeview->get_selection();
		selection->signal_changed().connect(sigc::mem_fun(*this,
				&self_type::on_tree_selection_changed) );

	}


	// --------------- Parse help text

	/*
	README.txt File Format

	The whole text is converted to unix newline format before parsing.
	Sections are separated by 3 newlines (two empty lines).
	The first line of the section is its header.
	When splitting the file to sections and headers, any leading or trailing
		whitespace is removed.
	If there is a single newline inside a section, it is converted to
		space to enable correct wrapping.
	If there are two consequent newlines, they are left as they are,
		essentially making a paragraph break.
	*/

	std::string readme = hz::string_any_to_unix_copy(ReadmeTextResData().get_string());

	// split by double-newlines

	std::vector<std::string> topics;
	hz::string_split(readme, "\n\n\n", topics, true);  // skip empty


	// add to treeview and textview

	Gtk::TextView* content = this->lookup_widget<Gtk::TextView*>("content_textview");

	if (treeview && content) {
		Glib::RefPtr<Gtk::TextBuffer> buffer = content->get_buffer();

		buffer->create_mark("Begin", buffer->begin(), true);

		for (unsigned int i = 0; i < topics.size(); ++i) {
			std::string topic = hz::string_trim_copy(topics[i]);

			// The first line of topic is its title
			std::vector<std::string> topic_split;
			hz::string_split(topic, "\n\n", topic_split, true, 2);  // skip empty, get 2 elements only

			if (topic_split.size() < 2) {
				debug_out_warn("app", DBG_FUNC_MSG << "Cannot extract topic title in topic " << i << "\n");
				continue;
			}

			std::string topic_title = hz::string_trim_copy(topic_split[0]);
			std::string topic_body = hz::string_trim_copy(topic_split[1]);

			buffer->create_mark(topic_title, buffer->end(), true);  // set topic mark to the end of what's there

			// add the title and make it bold
			buffer->insert(buffer->end(), "\n" + topic_title);

			Gtk::TextIter first = buffer->end(), last = first;
			first.backward_lines(1);

			Glib::RefPtr<Gtk::TextTag> tag = buffer->create_tag();
			tag->property_weight() = Pango::WEIGHT_BOLD;
			tag->property_size_points() = 14;

			buffer->apply_tag(tag, first, last);

			// add the rest

			// single newlines to spaces, to allow proper wrapping.
			app_pcre_replace("/([^\\n])\\n([^\\n])/", "\\1 \\2", topic_body);
			buffer->insert(buffer->end(), "\n\n" + topic_body + "\n\n");


			// Add to treeview

			Gtk::TreeRow row = *(list_store->append());
			row[col_topic] = topic_title;

		}

	}


	// ---------------


	// show();
}
// 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)
    );
}
Beispiel #12
0
// 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();
	}
}