Glib::RefPtr<Gtk::UIManager> SmartChessWindow::createUIManager(
            Glib::RefPtr<Gtk::ActionGroup> &action_group) {
        auto ui_manager = Gtk::UIManager::create();

        ui_manager->insert_action_group(action_group);
        add_accel_group(ui_manager->get_accel_group());

        Glib::ustring ui_info =
                "<ui>"
                "  <menubar name='MenuBar'>"
                "    <menu action='MenuFile'>"
                "      <separator/>"
                "      <menuitem action='Quit'/>"
                "    </menu>"
                "       <menu action='MenuView'>"
                "           <menuitem action='ShowOptionsArea' />"
                "           <menuitem action='ShowLogArea' />"
                "       </menu>"
                "       <menu action='MenuHelp'>"
                "           <menuitem action='About' />"
                "       </menu>"
                "  </menubar>"
                "  <toolbar  name='ToolBar'>"
                "    <toolitem action='Quit'/>"
                "  </toolbar>"
                "</ui>";

        ui_manager->add_ui_from_string(ui_info);
        return ui_manager;
    }
Exemple #2
0
OCEWindow::OCEWindow() : mbox(Gtk::ORIENTATION_VERTICAL) {
    add(mbox);

    Glib::RefPtr<Gtk::ActionGroup> actions = Gtk::ActionGroup::create();
    actions->add(Gtk::Action::create("MenuFile", "_File"));
    actions->add(Gtk::Action::create("New", "_New"));

    Glib::RefPtr<Gtk::UIManager> umanager = Gtk::UIManager::create();
    umanager->insert_action_group(actions);
    add_accel_group(umanager->get_accel_group());

    Glib::ustring ui_info =
            "<ui>"
                    "	<menubar name='MenuBar'>"
                    "		<menu action='MenuFile'>"
                    "			<menuitem action='New'/>"
                    "		</menu>"
                    "	</menubar>"
                    "</ui>";

    umanager->add_ui_from_string(ui_info);

    Gtk::Widget *menuBar = umanager->get_widget("/MenuBar");
    mbox.pack_start(*menuBar, Gtk::PACK_SHRINK);
    mbox.pack_start(screens);

    show_all_children();
}
Exemple #3
0
Window::Window()
{
	Glib::RefPtr<Gtk::ActionGroup> mActionGroup = Gtk::ActionGroup::create();
	
	mActionGroup->add(Gtk::Action::create("MenuFile", "_File"));
	mActionGroup->add(Gtk::Action::create("New", Gtk::Stock::NEW),
						sigc::mem_fun(*this, &Window::on_action_file_new));
  	mActionGroup->add(Gtk::Action::create("Export", "_Export..."),
						sigc::mem_fun(*this, &Window::on_action_file_export));
	mActionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),
						sigc::mem_fun(*this, &Window::on_action_file_quit));
				
	mActionGroup->add(Gtk::Action::create("MenuView", "_View"));
	mActionGroup->add(Gtk::ToggleAction::create("Toolbar", "_Toolbar", "", true),
						sigc::mem_fun(*this, &Window::on_action_view_toolbar));
	mActionGroup->add(Gtk::ToggleAction::create("Status Bar", "Status _Bar", "", true),
						sigc::mem_fun(*this, &Window::on_action_view_statusbar));

	mUIManager = Gtk::UIManager::create();
	mUIManager->insert_action_group(mActionGroup);
	add_accel_group(mUIManager->get_accel_group());
	
	Glib::ustring ui_info =
        "<ui>"
        "  <menubar name='MenuBar'>"
        "    <menu action='MenuFile'>"
        "      <menuitem action='New'/>"
        "      <separator/>"
        "      <menuitem action='Export'/>"
        "      <separator/>"
        "      <menuitem action='Quit'/>"
        "    </menu>"
        "    <menu action='MenuView'>"
        "      <menuitem action='Toolbar'/>"
        "      <menuitem action='Status Bar'/>"
        "    </menu>"
        "  </menubar>"
        "  <toolbar  name='ToolBar'>"
        "    <toolitem action='New'/>"
        "    <separator/>"
        "    <toolitem action='Quit'/>"
        "  </toolbar>"
        "</ui>";

    mUIManager->add_ui_from_string(ui_info);	
    Gtk::Widget	*pMenuBar = mUIManager->get_widget("/MenuBar");
    mVBox.pack_start(*pMenuBar, Gtk::PACK_SHRINK);

    Gtk::Widget	*pToolBar = mUIManager->get_widget("/ToolBar");
    mVBox.pack_start(*pToolBar, Gtk::PACK_SHRINK);

	mVBox.pack_start(mView);
	mVBox.pack_start(mStatusBar, Gtk::PACK_SHRINK);
	add(mVBox);	
}
Exemple #4
0
Scanner::Scanner(int argc, char** argv)
{
  set_title("Parameter Scanner - NIA v0.7");
  set_default_size(500,700);
  m_maxThreads = boost::thread::hardware_concurrency() - 1;
  m_activeThreads = 0;
  m_configFile = "default.cfg";
  m_outputDir = "";

  for(int i = 1; i < argc; i++){
    std::string str = argv[i];
    if(str.find("outdir=") == 0) m_outputDir = str.substr(7);
    else if(str.find("config=") == 0) m_configFile = str.substr(7);
    else m_inputFiles.push_back(str);
  }

  add(m_vbox);
  m_refActionGroup = Gtk::ActionGroup::create();
  m_refActionGroup->add(Gtk::Action::create("fileMenu","File"));
  m_refActionGroup->add(Gtk::Action::create("run","Run Scan"),Gtk::AccelKey("<control>R"),sigc::mem_fun(*this, &Scanner::run));
  m_refUIManager = Gtk::UIManager::create();
  m_refUIManager->insert_action_group(m_refActionGroup);
  add_accel_group(m_refUIManager->get_accel_group());

  Glib::ustring ui_info = 
    "<ui>"
    " <menubar name='menuBar'>"
    "  <menu action='fileMenu'>"
    "   <menuitem action='run'/>"
    "  </menu>"
    " </menubar>"
    "</ui>";
  try{ m_refUIManager->add_ui_from_string(ui_info); }
  catch(const Glib::Error& ex){}
  Gtk::Widget* pMenubar = m_refUIManager->get_widget("/menuBar");
  if(pMenubar) m_vbox.pack_start(*pMenubar, Gtk::PACK_SHRINK);

  m_textBuffer = Gtk::TextBuffer::create();
  m_textView.set_buffer(m_textBuffer);
  m_scrolledWindow.add(m_textView);
  m_scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC);
  m_vbox.pack_start(m_scrolledWindow, Gtk::PACK_EXPAND_WIDGET);
  show_all_children();
}
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);
    }


}
Exemple #6
0
void MainWindow::create_menu(Gtk::VBox *vbox)
{
  // Create actions for menu and toolbar.
  refActionGroup = Gtk::ActionGroup::create();
  
  // File menu
  refActionGroup->add(Gtk::Action::create("MenuFile", _("_File")));

  // File submenu
  refActionGroup->add(Gtk::Action::create("FileNew", Gtk::Stock::NEW, _("_New project...")),
		      sigc::mem_fun(*this, &MainWindow::on_action_file_new));
  refActionGroup->add(Gtk::Action::create("FileOpen", Gtk::Stock::OPEN, _("_Open project")),
		      sigc::mem_fun(*this, &MainWindow::on_action_file_open));
  refActionGroup->add(Gtk::Action::create("FileDelete", Gtk::Stock::DELETE, _("_Delete project")),
		      sigc::mem_fun(*this, &MainWindow::on_action_file_delete));
  refActionGroup->add(Gtk::Action::create("FileExport", Gtk::Stock::GO_FORWARD, _("_Export project...")),
		      sigc::mem_fun(*this, &MainWindow::on_action_file_export));
  refActionGroup->add(Gtk::Action::create("FileImport", Gtk::Stock::GO_BACK, _("_Import project...")),
		      sigc::mem_fun(*this, &MainWindow::on_action_file_import));
  refActionGroup->add(Gtk::Action::create("FileExit", Gtk::Stock::QUIT, _("_Quit")),
		      sigc::mem_fun(*this, &MainWindow::on_action_file_exit));

  // Help menu
  refActionGroup->add(Gtk::Action::create("MenuHelp", _("_Help")));

  // Help submenu
  refActionGroup->add(Gtk::Action::create("HelpHelp", Gtk::Stock::HELP),
		      sigc::mem_fun(*this, &MainWindow::on_action_help_help));
  refActionGroup->add(Gtk::Action::create("HelpAbout", Gtk::Stock::ABOUT, _("_About Handle Project")),
		      sigc::mem_fun(*this, &MainWindow::on_action_help_about));

  refUIManager = Gtk::UIManager::create();
  refUIManager->insert_action_group(refActionGroup);

  add_accel_group(refUIManager->get_accel_group());

  Glib::ustring ui_info =
    "<ui>"
    "  <menubar name='MenuBar'>"
    "    <menu action='MenuFile'>"
    "      <menuitem action='FileNew'/>"
    "      <menuitem action='FileOpen'/>"
    "      <separator/>"
    "      <menuitem action='FileDelete'/>"
    "      <separator/>"
    "      <menuitem action='FileExport'/>"
    "      <menuitem action='FileImport'/>"
    "      <separator/>"
    "      <menuitem action='FileExit'/>"
    "    </menu>"
    "    <menu action='MenuHelp'>"
    "      <menuitem action='HelpHelp'/>"
    "      <menuitem action='HelpAbout'/>"
    "    </menu>"
    "  </menubar>"
    "  <toolbar name='ToolBar'>"
    "    <toolitem action='FileNew'/>"
    "    <toolitem action='FileOpen'/>"
    "    <toolitem action='FileDelete'/>"
    "  </toolbar>"
    "</ui>";

  try
  {
    refUIManager->add_ui_from_string(ui_info);
  }
  catch(const Glib::Error& err)
  {
    new_error("Can not create menu and toolbar."+ err.what(), "mainwindow.cpp", 
	      "MainWindow::create_menu()");
  }
  
  Gtk::Widget* pMenubar = refUIManager->get_widget("/MenuBar");
  if(pMenubar)
    vbox->pack_start(*pMenubar, Gtk::PACK_SHRINK);
  Gtk::Widget* pToolbar = refUIManager->get_widget("/ToolBar");
  if(pToolbar)
    vbox->pack_start(*pToolbar, Gtk::PACK_SHRINK);
}
Exemple #7
0
GridWindow::GridWindow(Grid &grid)
	: mGrid(grid)
	, mGridView(mGrid, mStatusBar)
	, mCrosswordNumber(0)
	, mpPrefsDialog(0)
{
	Glib::RefPtr<Gtk::ActionGroup> mActionGroup = Gtk::ActionGroup::create();
	
	mActionGroup->add(Gtk::Action::create("MenuFile", "_File"));
	mActionGroup->add(Gtk::Action::create("New", Gtk::Stock::NEW),
						sigc::mem_fun(*this, &GridWindow::on_action_file_new));
	mActionGroup->add(Gtk::Action::create("Open", Gtk::Stock::OPEN),
						sigc::mem_fun(*this, &GridWindow::on_action_file_open));
	mActionGroup->add(Gtk::Action::create("Save", Gtk::Stock::SAVE),
						sigc::mem_fun(*this, &GridWindow::on_action_file_save));
	mActionGroup->add(Gtk::Action::create("Save As", Gtk::Stock::SAVE_AS, "Save _As..."),
						sigc::mem_fun(*this, &GridWindow::on_action_file_saveas));
  	mActionGroup->add(Gtk::Action::create("Export", "_Export..."),
						sigc::mem_fun(*this, &GridWindow::on_action_file_export));
  	mActionGroup->add(Gtk::Action::create("Properties", Gtk::Stock::PROPERTIES),
						sigc::mem_fun(*this, &GridWindow::on_action_file_properties));
	mActionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),
						sigc::mem_fun(*this, &GridWindow::on_action_file_quit));

	mActionGroup->add(Gtk::Action::create("MenuEdit", "_Edit"));
	mActionGroup->add(Gtk::Action::create("Preferences", Gtk::Stock::PREFERENCES),
						sigc::mem_fun(*this, &GridWindow::on_action_edit_preferences));
						
	mActionGroup->add(Gtk::Action::create("MenuView", "_View"));
	mActionGroup->add(Gtk::ToggleAction::create("Toolbar", "_Toolbar", "", true),
						sigc::mem_fun(*this, &GridWindow::on_action_view_toolbar));
	mActionGroup->add(Gtk::ToggleAction::create("Status Bar", "Status _Bar", "", true),
						sigc::mem_fun(*this, &GridWindow::on_action_view_statusbar));
	mActionGroup->add(Gtk::ToggleAction::create("Answers", "_Answers", "", false),
						sigc::mem_fun(*this, &GridWindow::on_action_view_answers));

	mActionGroup->add(Gtk::Action::create("MenuGrid", "_Grid"));
	mActionGroup->add(Gtk::Action::create("Fill", "_Fill"),
						sigc::mem_fun(*this, &GridWindow::on_action_grid_fill));
	mActionGroup->add(Gtk::Action::create("Rules", "_Rules"),
						sigc::mem_fun(*this, &GridWindow::on_action_grid_rules));

	mUIManager = Gtk::UIManager::create();
	mUIManager->insert_action_group(mActionGroup);
	add_accel_group(mUIManager->get_accel_group());
	
	Glib::ustring ui_info =
        "<ui>"
        "  <menubar name='MenuBar'>"
        "    <menu action='MenuFile'>"
        "      <menuitem action='New'/>"
        "      <menuitem action='Open'/>"
        "      <separator/>"
        "      <menuitem action='Save'/>"
        "      <menuitem action='Save As'/>"
        "      <separator/>"
        "      <menuitem action='Export'/>"
        "      <separator/>"
        "      <menuitem action='Properties'/>"
        "      <separator/>"
        "      <menuitem action='Quit'/>"
        "    </menu>"
        "    <menu action='MenuEdit'>"
        "      <menuitem action='Preferences'/>"
        "    </menu>"
        "    <menu action='MenuView'>"
        "      <menuitem action='Toolbar'/>"
        "      <menuitem action='Status Bar'/>"
        "      <menuitem action='Answers'/>"
        "    </menu>"
        "    <menu action='MenuGrid'>"
        "      <menuitem action='Fill'/>"
        "      <menuitem action='Rules'/>"
        "    </menu>"
        "  </menubar>"
        "  <toolbar  name='ToolBar'>"
        "    <toolitem action='New'/>"
        "    <toolitem action='Open'/>"
        "    <toolitem action='Save'/>"
        "    <separator/>"
        "    <toolitem action='Answers'/>"
        "    <toolitem action='Fill'/>"
        "    <toolitem action='Rules'/>"
        "    <separator/>"
        "    <toolitem action='Quit'/>"
        "  </toolbar>"
        "</ui>";

    mUIManager->add_ui_from_string(ui_info);	
    Gtk::Widget	*pMenuBar = mUIManager->get_widget("/MenuBar");
    mVBox.pack_start(*pMenuBar, Gtk::PACK_SHRINK);

    Gtk::Widget	*pToolBar = mUIManager->get_widget("/ToolBar");
    mVBox.pack_start(*pToolBar, Gtk::PACK_SHRINK);

	mHBox.pack_start(mGridView);
	mHBox.pack_start(mCluesView);
	mVBox.pack_start(mHBox);
	mStatusBar.set_has_resize_grip(false);
	mVBox.pack_start(mStatusBar, Gtk::PACK_SHRINK);
	
	set_resizable(false);
	add(mVBox);
	
	gSignalServer.signal_grid_dirty().connect(sigc::mem_fun(*this, &GridWindow::on_grid_dirty));	
	gSignalServer.signal_grid_redraw().connect(sigc::mem_fun(*this, &GridWindow::on_grid_redraw));	
	
	char buffer[256];
	sprintf(buffer, "crossword%03d", ++mCrosswordNumber);
	mTitle = buffer;
}
void ExampleWindow::build_main_menu()
{
  //Create actions for menus and toolbars:
  m_refActionGroup = Gtk::ActionGroup::create();

  //File menu:
  m_refActionGroup->add(
    Gtk::Action::create("FileMenu", "_File"));

  m_refActionGroup->add(
    Gtk::Action::create("New", Gtk::Stock::NEW),
    sigc::mem_fun(*this, &ExampleWindow::on_menu_file_new));

  m_refActionGroup->add(
    Gtk::Action::create("PageSetup", "Page _Setup"),
    sigc::mem_fun(*this, &ExampleWindow::on_menu_file_page_setup));

  m_refActionGroup->add(
    Gtk::Action::create("PrintPreview", "Print Preview"),
    sigc::mem_fun(*this, &ExampleWindow::on_menu_file_print_preview));

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

  m_refActionGroup->add(
    Gtk::Action::create("Quit", Gtk::Stock::QUIT),
    sigc::mem_fun(*this, &ExampleWindow::on_menu_file_quit));

  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'>"
        "      <menuitem action='New'/>"
        "      <menuitem action='PageSetup'/>"
        "      <menuitem action='PrintPreview'/>"
        "      <menuitem action='Print'/>"
        "      <separator/>"
        "      <menuitem action='Quit'/>"
        "    </menu>"
        "  </menubar>"
        "  <toolbar  name='ToolBar'>"
        "    <toolitem action='New'/>"
        "    <toolitem action='Print'/>"
        "      <separator/>"
        "    <toolitem action='Quit'/>"
        "  </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_VBox.pack_start(*pMenubar, Gtk::PACK_SHRINK);

  Gtk::Widget* pToolbar = m_refUIManager->get_widget("/ToolBar") ;
  if(pToolbar)
    m_VBox.pack_start(*pToolbar, Gtk::PACK_SHRINK);
}
jobManWindow::jobManWindow() :
		refreshWorker(services) {
	isMaximized = false;
	positionValid = false;
	waitCursorCounter = 0;

	refreshWorker.sig_done.connect(sigc::mem_fun(*this, &jobManWindow::on_refresh_complete));
	startWorker.sig_done.connect(sigc::mem_fun(*this, &jobManWindow::on_start_complete));
	stopWorker.sig_done.connect(sigc::mem_fun(*this, &jobManWindow::on_stop_complete));

	// We need this to precisely return window to it's previous possition
	set_gravity(Gdk::GRAVITY_STATIC);

	// Prepare menu etc.
	//Create actions for menus and toolbars:
	refActionGroup = Gtk::ActionGroup::create();

	refActionGroup->add(Gtk::Action::create("FileMenu", "_File"));
	refActionGroup->add(Gtk::Action::create("FileExit", Gtk::Stock::QUIT, "E_xit", "Exit the application"),
			sigc::mem_fun(*this, &jobManWindow::on_menu_file_exit));

	refActionGroup->add(Gtk::Action::create("HelpMenu", "_Help"));
	refActionGroup->add(Gtk::Action::create("HelpAbout", Gtk::Stock::ABOUT, "_About", "About JobMan"),
			sigc::mem_fun(*this, &jobManWindow::on_menu_help_about));

	refUIManager = Gtk::UIManager::create();
	refUIManager->insert_action_group(refActionGroup);

	add_accel_group(refUIManager->get_accel_group());

	Glib::ustring ui_info = "<ui>"
			"  <menubar name='MenuBar'>"
			"    <menu action='FileMenu'>"
			"      <separator/>"
			"      <menuitem action='FileExit'/>"
			"    </menu>"
			"    <menu action='HelpMenu'>"
			"      <menuitem action='HelpAbout'/>"
			"    </menu>"
			"  </menubar>"
			"</ui>";

	try {
		refUIManager->add_ui_from_string(ui_info);
	} catch (const Glib::Error& ex) {
		std::cerr << "building menus failed: " << ex.what();
	}

	Gtk::Widget* pMenubar = refUIManager->get_widget("/MenuBar");
	if (pMenubar) {
		vMainBox.pack_start(*pMenubar, Gtk::PACK_SHRINK);
	}
	vMainBox.pack_start(paned, Gtk::PACK_EXPAND_WIDGET);

	add(vMainBox);

	paned.set_hexpand(true);
	paned.set_vexpand(true);

	scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
	scrolledWindow.add(treeView);

	treeModel = Gtk::ListStore::create(modelColumns);

	treeView.set_model(treeModel);
	//treeView.signal_selection_received().connect(sigc::mem_fun(*this, &mmWindow::on_job_selected));
	treeView.get_selection()->signal_changed().connect(sigc::mem_fun(*this, &jobManWindow::on_job_selected_handler));

	// Show columns in the vew
	treeView.append_column("Name", modelColumns.jobName);
	treeView.get_column(0)->set_expand(true);
	treeView.append_column("Running", modelColumns.someInstanceRunning);
	treeView.append_column("Manual\n(Disabled)", modelColumns.setToManual);
	treeView.append_column("Description", modelColumns.description);
	treeView.get_column(3)->set_expand(true);

	paned.pack1(scrolledWindow, Gtk::FILL);

	scrolledWindowLabel.add(detailsLabel);

	hBoxRightButtons.pack_start(buttonStart, true, true, 2);
	hBoxRightButtons.pack_start(buttonRestart, true, true, 2);
	hBoxRightButtons.pack_start(buttonStop, true, true, 2);

	hBoxRightLower.pack_start(buttonSetManual, true, true, 2);

	hBoxRightLower.pack_start(buttonReefresh, true, true, 2);

	vBoxRightOuter.pack_start(scrolledWindowLabel, true, true, 2); // add(detailsLabel);
	vBoxRightOuter.pack_start(hBoxRightButtons, false, true, 2);
	vBoxRightOuter.pack_start(hBoxRightLower, false, true, 2);

	buttonStart.set_label("Start");
	buttonRestart.set_label("Restart");
	buttonStop.set_label("Stop");
	buttonSetManual.set_label("Enable (remove manual)");
	buttonReefresh.set_label("Refresh list");

	// Initially buttons are disabled, and label is empty:
	initRightPanel();

	buttonReefresh.signal_clicked().connect(sigc::mem_fun(*this, &jobManWindow::on_refresh_clicked));
	buttonStart.signal_clicked().connect(sigc::mem_fun(*this, &jobManWindow::on_start_clicked));
	buttonRestart.signal_clicked().connect(sigc::mem_fun(*this, &jobManWindow::on_restart_clicked));
	buttonStop.signal_clicked().connect(sigc::mem_fun(*this, &jobManWindow::on_stop_clicked));
	buttonSetManual.signal_clicked().connect(sigc::mem_fun(*this, &jobManWindow::on_set_manual_clicked));

	//detailsLabel.set_markup("&lt;empty&gt;");
	detailsLabel.set_line_wrap(true);
	detailsLabel.set_use_markup(true);
	detailsLabel.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_START);

	paned.pack2(vBoxRightOuter, Gtk::FILL);

	services.loadUpstartJobs();

	show_all_children();

}
Exemple #10
0
void playlistWindow::initPlaylistMenuPopup
(
    void
)
{
    // Create an action group for the popup menu which has to
    // be included into the opening playlist button and the adding
    openPlaylistActionGroup = Gtk::ActionGroup::create();
    appendPlaylistActionGroup = Gtk::ActionGroup::create();
    //Add a new item action menu to the action group
    openPlaylistActionGroup->add(Gtk::Action::create("openPlaylistMenu", "Open Playlist Menu"));
    appendPlaylistActionGroup->add(Gtk::Action::create("appendPlaylistMenu", "Append Playlist Menu"));
    // add new menu items with their own action menu, a keyboard shortcut
    // and a listener ; open a new playlist or append a playlist to the
    // current playlist
    openPlaylistActionGroup->add
    (
        Gtk::Action::create
        (
            "openPlaylistMenuNew",
            Gtk::Stock::NEW,
            "Open a playlist file",
            "Close any playlist opened before to open new one..."
        ),
        Gtk::AccelKey("<control>O"),
        sigc::bind<bool,bool>
        (
            sigc::mem_fun
            (
                *this,
                &playlistWindow::on_openPlaylistFile_clicked
            ),
            true, // close the current playlist before to load the new one
            false // is playlist file
        )
    );
    openPlaylistActionGroup->add
    (
        Gtk::Action::create
        (
            "openPlaylistMenuNewDirectory",
            Gtk::Stock::NEW,
            "Open a directory as playlist",
            "Close any playlist opened before to open a directory as new playlist..."
        ),
        Gtk::AccelKey("<control>d"),
        sigc::bind<bool,bool>
        (
            sigc::mem_fun
            (
                *this,
                &playlistWindow::on_openPlaylistFile_clicked
            ),
            true, // close the current playlist before to load the new one
            true // is a directory
        )
    );
    appendPlaylistActionGroup->add
    (

        Gtk::Action::create
        (
            "appendPlaylistMenuFiles",
            Gtk::Stock::ADD,
            "Append files to the playlist",
            "Add files to the current playlist..."
        ),
        Gtk::AccelKey("<control>F"),
        sigc::mem_fun
        (
            *this,
            &playlistWindow::on_addFileToPlaylist_clicked
        )
    );
    appendPlaylistActionGroup->add
    (

        Gtk::Action::create
        (
            "appendPlaylistMenuAppend",
            Gtk::Stock::ADD,
            "Append a playlist file",
            "Append a M3U playlist to the current one..."
        ),
        Gtk::AccelKey("<control>A"),
        sigc::bind<bool,bool>
        (
            sigc::mem_fun
            (
                *this,
                &playlistWindow::on_openPlaylistFile_clicked
            ),
            false, // append a playlist to the current playlist
            false // is a playlist file
        )
    );
    appendPlaylistActionGroup->add
    (
        Gtk::Action::create
        (
            "appendPlaylistMenuAppendDirectory",
            Gtk::Stock::NEW,
            "Append a directory as playlist",
            "Append a multimedia directory to the current playlist..."
        ),
        Gtk::AccelKey("<control>m"),
        sigc::bind<bool,bool>
        (
            sigc::mem_fun
            (
                *this,
                &playlistWindow::on_openPlaylistFile_clicked
            ),
            false, // close the current playlist before to load the new one
            true // is a directory
        )
    );

    openPlaylistUIManager = Gtk::UIManager::create();
    appendPlaylistUIManager = Gtk::UIManager::create();
    openPlaylistUIManager->insert_action_group(openPlaylistActionGroup);
    appendPlaylistUIManager->insert_action_group(appendPlaylistActionGroup);

    add_accel_group(openPlaylistUIManager->get_accel_group());
    add_accel_group(appendPlaylistUIManager->get_accel_group());

    //Layout the actions in a menubar and toolbar:
    Glib::ustring ui_info =
        "<ui>"
        "  <popup name='openPlaylistPopupMenu'>"
        "    <menuitem action='openPlaylistMenuNew'/>"
        "    <menuitem action='openPlaylistMenuNewDirectory'/>"
        "  </popup>"
        "</ui>";

    try
    {
        openPlaylistUIManager->add_ui_from_string(ui_info);
    } catch(const Glib::Error& ex) {
        std::cerr << "building menus failed: " <<  ex.what();
    }
    openPlaylistMenuPopup = dynamic_cast<Gtk::Menu*>
                            (
                                openPlaylistUIManager->get_widget("/openPlaylistPopupMenu")
                            );
    if(!openPlaylistMenuPopup)
        g_warning("menu not found");

    //Layout the actions in a menubar and toolbar:
    ui_info =
        "<ui>"
        "  <popup name='appendPlaylistPopupMenu'>"
        "    <menuitem action='appendPlaylistMenuFiles'/>"
        "    <menuitem action='appendPlaylistMenuAppend'/>"
        "    <menuitem action='appendPlaylistMenuAppendDirectory'/>"
        "  </popup>"
        "</ui>";

    try
    {
        appendPlaylistUIManager->add_ui_from_string(ui_info);
    } catch(const Glib::Error& ex) {
        std::cerr << "building menus failed: " <<  ex.what();
    }
    appendPlaylistMenuPopup = dynamic_cast<Gtk::Menu*>
                              (
                                  appendPlaylistUIManager->get_widget("/appendPlaylistPopupMenu")
                              );
    if(!appendPlaylistMenuPopup)
        g_warning("menu not found");

    // set the popup
    openPlaylistFile->set_popup(*openPlaylistMenuPopup);
    addFileToPlaylist->set_popup(*appendPlaylistMenuPopup);

}
Exemple #11
0
ListUsb::ListUsb()
{
    set_title("lsusb");
    maximize();
    
    add(m_box);
    m_scrolled_window.add(m_tree_view);
    m_scrolled_window.set_policy(Gtk::POLICY_AUTOMATIC,Gtk::POLICY_AUTOMATIC);

    m_refActionGroup=Gtk::ActionGroup::create();
    m_refActionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),
          sigc::mem_fun(*this, &ListUsb::on_quit));
    m_refActionGroup->add(Gtk::Action::create("Refresh", Gtk::Stock::REFRESH),
          sigc::mem_fun(*this, &ListUsb::on_refresh));
  
    m_refUIManager=Gtk::UIManager::create();
    m_refUIManager->insert_action_group(m_refActionGroup);

    add_accel_group(m_refUIManager->get_accel_group());

    Glib::ustring ui_info = 
        "<ui>"
        "  <toolbar  name='ToolBar'>"
        "    <toolitem action='Refresh'/>"
        "    <toolitem action='Quit'/>"
        "  </toolbar>"
        "</ui>";

    #ifdef GLIBMM_EXCEPTIONS_ENABLED
    try
    {
        m_refUIManager->add_ui_from_string(ui_info);
    }
    catch(const Glib::Error& ex)
    {
        fprintf(stderr,"building menus failed: %s",ex.what().c_str());
    }
    #else
    std::auto_ptr<Glib::Error> ex;
    m_refUIManager->add_ui_from_string(ui_info,ex);
    if(ex.get())
    {
        fprintf(stderr,"building menus failed: %s",ex->what());
    }
    #endif //GLIBMM_EXCEPTIONS_ENABLED

    Gtk::Widget* pToolbar = m_refUIManager->get_widget("/ToolBar") ;
    if(pToolbar)
        m_box.pack_start(*pToolbar,Gtk::PACK_SHRINK);
    m_box.pack_start(m_scrolled_window);

    m_ref_tree_model=Gtk::TreeStore::create(m_columns);
    m_tree_view.set_model(m_ref_tree_model);
    
    //Add the TreeView's view columns:
    Gtk::TreeViewColumn col_name("Name",m_columns.m_col_name);
    Gtk::TreeViewColumn col_value("Value",m_columns.m_col_value);
    Gtk::TreeViewColumn col_comment("Comment",m_columns.m_col_comment);
    
    col_name.set_resizable();
    col_value.set_resizable();
    col_comment.set_resizable();
    
    m_tree_view.append_column(col_name);
    m_tree_view.append_column(col_value);
    m_tree_view.append_column(col_comment);

    show_all_children();
    
    on_refresh();
}
Exemple #12
0
  cGtkmmMainWindow::cGtkmmMainWindow(int argc, char** argv) :
    updateChecker(*this),
    notifyMainThread(*this),
    pMenuPopup(nullptr),
    comboBoxFolder(true),
    statusBar("0 photos"),
    photoBrowser(*this)
  {
    settings.Load();

    set_title(BUILD_APPLICATION_NAME);
    set_size_request(400, 400);
    set_default_size(800, 800);

    // Restore the window size
    size_t width = 800;
    size_t height = 800;
    settings.GetMainWindowSize(width, height);
    resize(width, height);

    if (settings.IsMainWindowMaximised()) maximize();

    // Set icon list
    std::vector<Glib::RefPtr<Gdk::Pixbuf> > icons;
    icons.push_back(Gdk::Pixbuf::create_from_file("data/icons/application_16x16.png"));
    icons.push_back(Gdk::Pixbuf::create_from_file("data/icons/application_32x32.png"));
    icons.push_back(Gdk::Pixbuf::create_from_file("data/icons/application_48x48.png"));
    icons.push_back(Gdk::Pixbuf::create_from_file("data/icons/application_64x64.png"));
    icons.push_back(Gdk::Pixbuf::create_from_file("data/icons/application_128x128.png"));
    icons.push_back(Gdk::Pixbuf::create_from_file("data/icons/application_256x256.png"));
    // GTK complains if we pass icons larger than 256x256
    //icons.push_back(Gdk::Pixbuf::create_from_file("data/icons/application_512x512.png"));
    set_icon_list(icons);

    // Menu and toolbar

    // void Gtk::Application::set_app_menu(const Glib::RefPtr< Gio::MenuModel > &  app_menu)
    // Sets or unsets the application menu for application.
    // The application menu is a single menu containing items that typically impact the application as a whole, rather than acting on a specific window or document. For example, you would expect to see "Preferences" or "Quit" in an application menu, but not "Save" or "Print".
    // If supported, the application menu will be rendered by the desktop environment.
    // You might call this method in your Application::property_startup() signal handler.
    // Use the base ActionMap interface to add actions, to respond to the user selecting these menu items.
    // Since gtkmm 3.4:


    // Create actions for menus and toolbars
    m_refActionGroup = Gtk::ActionGroup::create();

    // File menu
    m_refActionGroup->add(Gtk::Action::create("FileMenu", "File"));
    m_refActionGroup->add(Gtk::Action::create("FileAddFiles", "Add Files"),
            sigc::mem_fun(*this, &cGtkmmMainWindow::OnMenuFileBrowseFiles));
    m_refActionGroup->add(Gtk::Action::create("FileAddFolder", "Add Folder"),
            sigc::mem_fun(*this, &cGtkmmMainWindow::OnMenuFileBrowseFolder));
    m_refActionGroup->add(Gtk::Action::create("FileAddFilesFromPicturesFolder", "Add Files From Pictures Folder"),
            sigc::mem_fun(*this, &cGtkmmMainWindow::OnActionAddFilesFromPicturesFolder));
    m_refActionGroup->add(Gtk::Action::create("FileImportFolder", "Import Folder From Removable Media"),
            sigc::mem_fun(*this, &cGtkmmMainWindow::OnMenuFileImportFolder));
    //m_refActionGroup->add(Gtk::Action::create("FileRemove", "Remove"),
    //        sigc::mem_fun(*this, &cGtkmmMainWindow::OnActionRemoveTrack));
    //m_refActionGroup->add(Gtk::Action::create("FileMoveToFolderMenu", "Move to Folder"));
    //m_refActionGroup->add(Gtk::Action::create("FileMoveToFolderBrowse", "Browse..."),
    //        sigc::mem_fun(*this, &cGtkmmMainWindow::OnActionTrackMoveToFolderBrowse));
    //m_refActionGroup->add(Gtk::Action::create("FileMoveToRubbishBin", "Move to the Rubbish Bin"),
    //        sigc::mem_fun(*this, &cGtkmmMainWindow::OnActionTrackMoveToRubbishBin));
    //m_refActionGroup->add(Gtk::Action::create("FileShowInFileManager", "Show in the File Manager"),
    //        sigc::mem_fun(*this, &cGtkmmMainWindow::OnActionTrackShowInFileManager));
    //m_refActionGroup->add(Gtk::Action::create("FileProperties", "Properties"),
    //        sigc::mem_fun(*this, &cGtkmmMainWindow::OnActionTrackProperties));
    m_refActionGroup->add(Gtk::Action::create("FileQuit", Gtk::Stock::QUIT),
            sigc::mem_fun(*this, &cGtkmmMainWindow::OnMenuFileQuit));

    // Edit menu
    m_refActionGroup->add(Gtk::Action::create("EditMenu", "Edit"));
    //Edit Tags -> edits each track separately
    //Batch Edit Tags -> edits all tracks at the same time
    m_refActionGroup->add(Gtk::Action::create("EditPreferences", Gtk::Stock::PREFERENCES),
            sigc::mem_fun(*this, &cGtkmmMainWindow::OnMenuEditPreferences));

    // Playback menu
    m_refActionGroup->add(Gtk::Action::create("PlaybackMenu", "Playback"));
    //m_refActionGroup->add(Gtk::Action::create("PlaybackPrevious", Gtk::Stock::MEDIA_PREVIOUS),
    //        sigc::mem_fun(*this, &cGtkmmMainWindow::OnPlaybackPreviousClicked));
    //pPlayPauseAction = Gtk::ToggleAction::create("PlaybackPlayPause", Gtk::Stock::MEDIA_PLAY, "Play/Pause");
    //m_refActionGroup->add(pPlayPauseAction, sigc::mem_fun(*this, &cGtkmmMainWindow::OnPlaybackPlayPauseMenuToggled));
    //m_refActionGroup->add(Gtk::Action::create("PlaybackNext", Gtk::Stock::MEDIA_NEXT),
    //        sigc::mem_fun(*this, &cGtkmmMainWindow::OnPlaybackNextClicked));
    //m_refActionGroup->add(Gtk::Action::create("JumpToPlaying", "Jump to Playing"),
    //        Gtk::AccelKey("<control>J"),
    //        sigc::mem_fun(*this, &cGtkmmMainWindow::OnActionJumpToPlaying));
    //pRepeatAction = Gtk::ToggleAction::create("PlaybackRepeatToggle", Gtk::Stock::GOTO_TOP, "Repeat");
    //m_refActionGroup->add(pRepeatAction, sigc::mem_fun(*this, &cGtkmmMainWindow::OnPlaybackRepeatMenuToggled));

    // Help menu
    m_refActionGroup->add( Gtk::Action::create("HelpMenu", "Help") );
    m_refActionGroup->add( Gtk::Action::create("HelpAbout", Gtk::Stock::ABOUT),
            sigc::mem_fun(*this, &cGtkmmMainWindow::OnMenuHelpAbout) );

    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'>"
        "      <menuitem action='FileAddFiles'/>"
        "      <menuitem action='FileAddFolder'/>"
        "      <menuitem action='FileAddFilesFromPicturesFolder'/>"
        "      <menuitem action='FileImportFolder'/>"
        //"      <menuitem action='FileRemove'/>"
        //"      <menu action='FileMoveToFolderMenu'>"
        //"        <menuitem action='FileMoveToFolderBrowse'/>"
        //"      </menu>"
        //"      <menuitem action='FileMoveToRubbishBin'/>"
        //"      <menuitem action='FileShowInFileManager'/>"
        //"      <menuitem action='FileProperties'/>"
        //"      <separator/>"
        "      <menuitem action='FileQuit'/>"
        "    </menu>"
        "    <menu action='EditMenu'>"
        "      <menuitem action='EditPreferences'/>"
        "    </menu>"
        "    <menu action='PlaybackMenu'>"
        //"      <menuitem action='PlaybackPrevious'/>"
        //"      <menuitem action='PlaybackPlayPause'/>"
        //"      <menuitem action='PlaybackNext'/>"
        //"      <menuitem action='JumpToPlaying'/>"
        //"      <separator/>"
        //"      <menuitem action='PlaybackRepeatToggle'/>"
        "    </menu>"
        "    <menu action='HelpMenu'>"
        "      <menuitem action='HelpAbout'/>"
        "    </menu>"
        "  </menubar>"
        "  <toolbar name='ToolBar'>"
        //"    <toolitem action='PlaybackPrevious'/>"
        //"    <toolitem action='PlaybackPlayPause'/>"
        //"    <toolitem action='PlaybackNext'/>"
        //"    <toolitem action='PlaybackRepeatToggle'/>"
        "  </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 != nullptr) boxMainWindow.pack_start(*pMenubar, Gtk::PACK_SHRINK);


    // Photo browser right click menu
    Glib::RefPtr<Gtk::ActionGroup> popupActionGroupRef;


    // Right click menu
    popupActionGroupRef = Gtk::ActionGroup::create();

    // File|New sub menu:
    // These menu actions would normally already exist for a main menu, because a context menu should
    // not normally contain menu items that are only available via a context menu.
    popupActionGroupRef->add(Gtk::Action::create("ContextMenu", "Context Menu"));

    popupActionGroupRef->add(Gtk::Action::create("ContextAddFiles", "Add Files"),
            sigc::mem_fun(*this, &cGtkmmMainWindow::OnActionBrowseFiles));

    popupActionGroupRef->add(Gtk::Action::create("ContextAddFolder", "Add Folder"),
            Gtk::AccelKey("<control>P"),
            sigc::mem_fun(*this, &cGtkmmMainWindow::OnActionBrowseFolder));

    popupActionGroupRef->add(Gtk::Action::create("ContextRemove", "Remove"),
            sigc::mem_fun(*this, &cGtkmmMainWindow::OnActionRemovePhoto));

    //Edit Tags -> edits each track separately
    //Batch Edit Tags -> edits all tracks at the same time

    /*/popupActionGroupRef->add(Gtk::Action::create("ContextMoveToFolderMenu", "Move to Folder"));

    popupActionGroupRef->add(Gtk::Action::create("ContextTrackMoveToFolderBrowse", "Browse..."),
            sigc::mem_fun(*this, &cGtkmmMainWindow::OnActionTrackMoveToFolderBrowse));

    popupActionGroupRef->add(Gtk::Action::create("ContextTrackMoveToRubbishBin", "Move to the Rubbish Bin"),
            sigc::mem_fun(*this, &cGtkmmMainWindow::OnActionTrackMoveToRubbishBin));

    popupActionGroupRef->add(Gtk::Action::create("ContextShowInFileManager", "Show in the File Manager"),
            sigc::mem_fun(*this, &cGtkmmMainWindow::OnActionTrackShowInFileManager));

    popupActionGroupRef->add(Gtk::Action::create("ContextProperties", "Properties"),
            sigc::mem_fun(*this, &cGtkmmMainWindow::OnActionTrackProperties));*/

    popupUIManagerRef = Gtk::UIManager::create();
    popupUIManagerRef->insert_action_group(popupActionGroupRef);

    add_accel_group(popupUIManagerRef->get_accel_group());

    // Layout the actions in our popup menu
    {
      Glib::ustring ui_info =
        "<ui>"
        "  <popup name='PopupMenu'>"
        "    <menuitem action='ContextAddFiles'/>"
        "    <menuitem action='ContextAddFolder'/>"
        "    <menuitem action='ContextRemove'/>"
        /*"    <menu action='ContextMoveToFolderMenu'>"
        "      <menuitem action='ContextTrackMoveToFolderBrowse'/>"
        "    </menu>"
        "    <menuitem action='ContextTrackMoveToRubbishBin'/>"
        "    <menuitem action='ContextShowInFileManager'/>"
        "    <menuitem action='ContextProperties'/>"*/
        "  </popup>"
        "</ui>";

      try
      {
        popupUIManagerRef->add_ui_from_string(ui_info);
      }
      catch(const Glib::Error& ex)
      {
        std::cerr<<"building menus failed: "<<ex.what();
      }
    }

    // Get the menu
    pMenuPopup = dynamic_cast<Gtk::Menu*>(popupUIManagerRef->get_widget("/PopupMenu"));
    if (pMenuPopup == nullptr) g_warning("Popup menu not found");
    assert(pMenuPopup != nullptr);


    // In gtkmm 3 set_orientation is not supported so we create our own toolbar out of plain old buttons
    //Gtk::Toolbar* pToolbar = dynamic_cast<Gtk::Toolbar*>(m_refUIManager->get_widget("/ToolBar"));
    //if (pToolbar != nullptr) {
    //  pToolbar->property_orientation() = Gtk::ORIENTATION_VERTICAL;
    //  //pToolbar->set_orientation(Gtk::ORIENTATION_VERTICAL);
    //  pToolbar->set_toolbar_style(Gtk::TOOLBAR_ICONS);
    //  boxToolbar.pack_start(*pToolbar);
    //}

    buttonAddFiles.signal_clicked().connect(sigc::mem_fun(*this, &cGtkmmMainWindow::OnActionBrowseFiles));
    buttonAddFolder.signal_clicked().connect(sigc::mem_fun(*this, &cGtkmmMainWindow::OnActionBrowseFolder));

    boxToolbar.pack_start(buttonFolderUp, Gtk::PACK_SHRINK);
    boxToolbar.pack_start(buttonFolderShowInFileManager, Gtk::PACK_SHRINK);
    boxToolbar.pack_start(buttonAddFiles, Gtk::PACK_SHRINK);
    boxToolbar.pack_start(buttonAddFolder, Gtk::PACK_SHRINK);

    boxToolbar.pack_start(*Gtk::manage(new Gtk::Separator()), Gtk::PACK_SHRINK);


    // Controls
    comboBoxFolder.get_entry()->signal_changed().connect(sigc::mem_fun(*this, &cGtkmmMainWindow::OnActionChangeFolder));
    buttonFolderUp.signal_clicked().connect(sigc::mem_fun(*this, &cGtkmmMainWindow::OnActionFolderUp));
    buttonFolderUp.set_tooltip_text("Move up");
    buttonFolderShowInFileManager.signal_clicked().connect(sigc::mem_fun(*this, &cGtkmmMainWindow::OnActionFolderShowInFileManager));
    buttonFolderShowInFileManager.set_tooltip_text("Show folder in file manager");

    buttonStopLoading.signal_clicked().connect(sigc::mem_fun(*this, &cGtkmmMainWindow::OnActionStopLoading));

    photoBrowser.Init(argc, argv);

    boxControls.pack_start(comboBoxFolder, Gtk::PACK_SHRINK);
    boxControls.pack_start(photoBrowser.GetWidget(), Gtk::PACK_EXPAND_WIDGET);

    boxControlsAndToolbar.pack_start(boxControls, Gtk::PACK_EXPAND_WIDGET);
    boxControlsAndToolbar.pack_start(boxToolbar, Gtk::PACK_SHRINK);

    // Hide the stop button until we start loading some files
    buttonStopLoading.hide();

    boxStatusBar.pack_start(statusBar, Gtk::PACK_SHRINK);
    boxStatusBar.pack_start(buttonStopLoading, Gtk::PACK_SHRINK);
    //... show progress bar indeterminate when we are loading any files or playlists

    boxMainWindow.pack_start(boxControlsAndToolbar, Gtk::PACK_EXPAND_WIDGET);
    boxMainWindow.pack_start(boxStatusBar, Gtk::PACK_SHRINK);

    // Add the box layout to the main window
    add(boxMainWindow);


    {
      // Get a typical selection colour for the selections on our photo browser
      Gtk::Table table;
      Glib::RefPtr<Gtk::StyleContext> pStyleContext = table.get_style_context();
      ASSERT(pStyleContext);

      const Gdk::RGBA colour = pStyleContext->get_background_color(Gtk::STATE_FLAG_SELECTED);
      const spitfire::math::cColour colourSelected(colour.get_red(), colour.get_green(), colour.get_blue(), colour.get_alpha());
      photoBrowser.SetSelectionColour(colourSelected);
    }


    // Register our icon theme and update our icons
    iconTheme.RegisterThemeChangedListener(*this);

    UpdateIcons();

    ApplySettings();

    show_all_children();

    // Start the update checker now that we have finished doing the serious work
    updateChecker.Run();

    notifyMainThread.Create();
  }
Exemple #13
0
    HIGMessageDialog::HIGMessageDialog(Gtk::Window *parent,
                                       GtkDialogFlags flags, Gtk::MessageType msg_type, 
                                       Gtk::ButtonsType btn_type, const Glib::ustring & header,
                                       const Glib::ustring & msg)
      : Gtk::Dialog()
      , m_extra_widget(NULL)
    {
      set_border_width(5);
      set_resizable(false);
      set_title("");

      get_vbox()->set_spacing(12);
      get_action_area()->set_layout(Gtk::BUTTONBOX_END);

      m_accel_group = Glib::RefPtr<Gtk::AccelGroup>(Gtk::AccelGroup::create());
      add_accel_group(m_accel_group);

      Gtk::HBox *hbox = manage(new Gtk::HBox (false, 12));
      hbox->set_border_width(5);
      hbox->show();
      get_vbox()->pack_start(*hbox, false, false, 0);

      switch (msg_type) {
      case Gtk::MESSAGE_ERROR:
        m_image = new Gtk::Image (Gtk::Stock::DIALOG_ERROR,
                                  Gtk::ICON_SIZE_DIALOG);
        break;
      case Gtk::MESSAGE_QUESTION:
        m_image = new Gtk::Image (Gtk::Stock::DIALOG_QUESTION,
                                  Gtk::ICON_SIZE_DIALOG);
        break;
      case Gtk::MESSAGE_INFO:
        m_image = new Gtk::Image (Gtk::Stock::DIALOG_INFO,
                                  Gtk::ICON_SIZE_DIALOG);
        break;
      case Gtk::MESSAGE_WARNING:
        m_image = new Gtk::Image (Gtk::Stock::DIALOG_WARNING,
                                  Gtk::ICON_SIZE_DIALOG);
        break;
      default:
        m_image = new Gtk::Image ();
        break;
      }

      if (m_image) {
        Gtk::manage(m_image);
        m_image->show();
        m_image->property_yalign().set_value(0);
        hbox->pack_start(*m_image, false, false, 0);
      }

      Gtk::VBox *label_vbox = manage(new Gtk::VBox (false, 0));
      label_vbox->show();
      hbox->pack_start(*label_vbox, true, true, 0);

      std::string title = str(boost::format("<span weight='bold' size='larger'>%1%"
                                            "</span>\n") % header.c_str());

      Gtk::Label *label;

      label = manage(new Gtk::Label (title));
      label->set_use_markup(true);
      label->set_justify(Gtk::JUSTIFY_LEFT);
      label->set_line_wrap(true);
      label->set_alignment (0.0f, 0.5f);
      label->show();
      label_vbox->pack_start(*label, false, false, 0);

      label = manage(new Gtk::Label(msg));
      label->set_use_markup(true);
      label->set_justify(Gtk::JUSTIFY_LEFT);
      label->set_line_wrap(true);
      label->set_alignment (0.0f, 0.5f);
      label->show();
      label_vbox->pack_start(*label, false, false, 0);
      
      m_extra_widget_vbox = manage(new Gtk::VBox (false, 0));
      m_extra_widget_vbox->show();
      label_vbox->pack_start(*m_extra_widget_vbox, true, true, 12);

      switch (btn_type) {
      case Gtk::BUTTONS_NONE:
        break;
      case Gtk::BUTTONS_OK:
        add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK, true);
        break;
      case Gtk::BUTTONS_CLOSE:
        add_button (Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE, true);
        break;
      case Gtk::BUTTONS_CANCEL:
        add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL, true);
        break;
      case Gtk::BUTTONS_YES_NO:
        add_button (Gtk::Stock::NO, Gtk::RESPONSE_NO, false);
        add_button (Gtk::Stock::YES, Gtk::RESPONSE_YES, true);
        break;
      case Gtk::BUTTONS_OK_CANCEL:
        add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL, false);
        add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK, true);
        break;
      }

      if (parent){
        set_transient_for(*parent);
      }

      if ((flags & GTK_DIALOG_MODAL) != 0) {
        set_modal(true);
      }

      if ((flags & GTK_DIALOG_DESTROY_WITH_PARENT) != 0) {
        property_destroy_with_parent().set_value(true);
      }
    }
Exemple #14
0
YarpScope::MainWindow::MainWindow() :
    mPriv(new Private(this))
{
    set_border_width(3);
    set_default_size(640, 480);
    set_icon_name("yarpscope"); // FIXME

    add(mPriv->windowBox);

    // Setup actions
    mPriv->refActionGroup = Gtk::ActionGroup::create();

    mPriv->refActionGroup->add(Gtk::Action::create("MenuFile", _("_File")));
    mPriv->refActionGroup->add(Gtk::Action::create("Quit", Gtk::Stock::QUIT),
                               sigc::mem_fun(*mPriv, &MainWindow::Private::on_action_file_quit));
    mPriv->refActionGroup->add(Gtk::Action::create("MenuActions", _("_Actions")));
    mPriv->refActionGroup->add(Gtk::ToggleAction::create_with_icon_name("StopStart", "media-playback-pause", _("Stop"), _("Stop plotting")),
                               sigc::mem_fun(*mPriv, &MainWindow::Private::on_action_actions_stop_start));
    mPriv->refActionGroup->add(Gtk::Action::create_with_icon_name("Clear", "edit-clear", _("Clear"), _("Clear plots")),
                               sigc::mem_fun(*mPriv, &MainWindow::Private::on_action_actions_clear));
    mPriv->refActionGroup->add(Gtk::Action::create_with_icon_name("AutoRescale", "transform-scale", _("Auto Rescale"), _("Automatically rescale plots")),
                               sigc::mem_fun(*mPriv, &MainWindow::Private::on_action_actions_autorescale));
    mPriv->refActionGroup->add(Gtk::Action::create("MenuHelp", _("Help")));
    mPriv->refActionGroup->add(Gtk::Action::create("About", Gtk::Stock::ABOUT),
                               sigc::mem_fun(*mPriv, &MainWindow::Private::on_action_help_about));

    mPriv->refUIManager->insert_action_group(mPriv->refActionGroup);
    add_accel_group(mPriv->refUIManager->get_accel_group());

    Glib::ustring ui_info =
        "<ui>"
        "  <menubar name='MenuBar'>"
        "    <menu action='MenuFile'>"
        "      <separator />"
        "      <menuitem action='Quit'/>"
        "    </menu>"
        "    <menu action='MenuActions'>"
        "      <menuitem action='StopStart'/>"
        "      <menuitem action='Clear'/>"
        "      <menuitem action='AutoRescale'/>"
        "    </menu>"
        "    <menu action='MenuHelp'>"
        "      <menuitem action='About'/>"
        "    </menu>"
        "  </menubar>"
        "  <toolbar  name='ToolBar'>"
        "    <toolitem action='StopStart'/>"
        "    <toolitem action='Clear'/>"
        "    <toolitem action='AutoRescale'/>"
        "  </toolbar>"
        "</ui>";

    try {
        mPriv->refUIManager->add_ui_from_string(ui_info);
    }
    catch(const Glib::Error& ex) {
        fatal() << "building menus failed: " <<  ex.what();
    }

    // Setup menu bar
    Gtk::MenuBar* menubar = dynamic_cast<Gtk::MenuBar*>(mPriv->refUIManager->get_widget("/MenuBar"));
    if(menubar) {
        mPriv->windowBox.pack_start(*menubar, Gtk::PACK_SHRINK);
    } else {
        fatal() << "building menus failed: \"/MenuBar\" is missing";
    }

    // Setup toolbar
    Gtk::Toolbar* toolbar = dynamic_cast<Gtk::Toolbar*>(mPriv->refUIManager->get_widget("/ToolBar"));
    if(toolbar) {
        mPriv->windowBox.pack_start(*toolbar, Gtk::PACK_SHRINK);
        toolbar->set_toolbar_style(Gtk::TOOLBAR_BOTH);
    } else {
        fatal() << "building menus failed: \"/ToolBar\" is missing";
    }

    mPriv->intervalSpinButton.set_value(PortReader::instance().interval());
    mPriv->intervalSpinButton.signal_value_changed().connect(sigc::mem_fun(*mPriv, &YarpScope::MainWindow::Private::on_action_interval_value_changed));
    mPriv->intervalVBox.pack_start(mPriv->intervalSpinButton);
    mPriv->intervalVBox.pack_start(mPriv->intervalLabel);
    mPriv->intervalToolItem.add(mPriv->intervalVBox);
    toolbar->prepend(mPriv->intervalToolItem);

    mPriv->windowBox.pack_start(*PlotManager::instance().getPlotWidget());

    show_all_children();
}
Exemple #15
0
PC_Render::PC_Render() :
    mainBox( Gtk::ORIENTATION_VERTICAL )
{
    renderer_open = false;

    /* Create the main window */
    set_title("Point Cloud Renderer");
    set_position( Gtk::WIN_POS_CENTER );
    set_size_request( BUFFER_SIZE+128, BUFFER_SIZE+128);
    set_resizable(true);
    add( mainBox );

    mainBox.set_border_width(1);

    viewBox.set_orientation(Gtk::ORIENTATION_HORIZONTAL);
    viewBox.set_border_width(1);
    viewBox.set_size_request(-1, -1);

    actionGroup = Gtk::ActionGroup::create();

    // File Sub Menu Items
    actionGroup->add( Gtk::Action::create("MenuFile", "_File") );
    actionGroup->add( Gtk::Action::create("Open", Gtk::Stock::OPEN),
        sigc::mem_fun( *this, &PC_Render::file_open) );
    actionGroup->add( Gtk::Action::create("Save", Gtk::Stock::SAVE),
        sigc::mem_fun( *this, &PC_Render::file_print) );
    actionGroup->add( Gtk::Action::create("Close", Gtk::Stock::CLOSE),
        sigc::mem_fun( *this, &PC_Render::file_close) );
    actionGroup->add( Gtk::Action::create("Quit", Gtk::Stock::QUIT),
        sigc::mem_fun( *this, &PC_Render::delete_event) );

    manager = Gtk::UIManager::create();
    manager->insert_action_group( actionGroup );
    add_accel_group( manager->get_accel_group() );

        Glib::ustring ui_info =
            "<ui>"
            "   <menubar name='MenuBar'>"
            "       <menu action='MenuFile'>"
            "           <menuitem action='Open'/>"
            "           <menuitem action='Save'/>"
            "           <menuitem action='Close'/>"
            "           <separator/>"
            "           <menuitem action='Quit'/>"
            "       </menu>"
            "   </menubar>"
            "   <toolbar name='ToolBar'>"
            "       <toolitem action='Open'/>"
            "       <toolitem action='Close'/>"
            "       <toolitem action='Quit'/>"
            "   </toolbar>"
            "</ui>";

        manager->add_ui_from_string(ui_info);

    menuBar = manager->get_widget("/MenuBar");
    mainBox.pack_start( *menuBar, Gtk::PACK_SHRINK );

    toolBar = manager->get_widget("/ToolBar");
    mainBox.pack_start( *toolBar, Gtk::PACK_SHRINK );

    label.set_text("CWD:");
    cwdLabel.set_text("...");

    cwdBox.set_orientation( Gtk::ORIENTATION_HORIZONTAL );
    cwdBox.set_border_width(0);
    cwdBox.pack_start( label, false, false, 2 );
    cwdBox.pack_start( cwdLabel, false, false, 2);

    mainBox.pack_start( viewBox, true, true, 2);
    mainBox.pack_start( cwdBox,  false, false, 2);

    show_all_children();
}
/**
* Sets up the main window.
*/
GtkMainWindow::GtkMainWindow() :
	m_core(Application::getSingleton()->getCore())
{
	//TODO:This needs to be refactored
	this->set_position(Gtk::WIN_POS_CENTER);
	this->set_default_size(800, 500);
	Gtk::Paned *panel = Gtk::manage(new Gtk::Paned(Gtk::ORIENTATION_VERTICAL));

	m_infobar =  Gtk::manage(new GtkTorrentInfoBar());
	m_treeview = Gtk::manage(new GtkTorrentTreeView(m_infobar));

	panel->pack1(*m_treeview);
	panel->pack2(*m_infobar);

	Glib::     signal_timeout().connect(sigc::mem_fun(*this, &GtkMainWindow::onSecTick), 1000);
	this->signal_delete_event().connect(sigc::mem_fun(*this, &GtkMainWindow::onDestroy));

	header = Gtk::manage(new Gtk::HeaderBar());
	header->set_show_close_button(true);
	header->set_title("gTorrent");

	Glib::RefPtr<Gtk::ActionGroup> action_group = Gtk::ActionGroup::create();

	action_group->add(Gtk::Action::create( "Properties", Gtk::Stock::PROPERTIES));
	action_group->add(Gtk::Action::create(   "Add Link", Gtk::Stock::PASTE),       sigc::mem_fun(*this, &GtkMainWindow::onAddMagnetBtnClicked));
	action_group->add(Gtk::Action::create("Add Torrent", Gtk::Stock::ADD),         sigc::mem_fun(*this, &GtkMainWindow::onAddBtnClicked));
	action_group->add(Gtk::Action::create(     "Remove", Gtk::Stock::CANCEL),      sigc::mem_fun(*this, &GtkMainWindow::onRemoveBtnClicked));
	action_group->add(Gtk::Action::create(     "Resume", Gtk::Stock::MEDIA_PLAY),  sigc::mem_fun(*this, &GtkMainWindow::onResumeBtnClicked));
	action_group->add(Gtk::Action::create(      "Pause", Gtk::Stock::MEDIA_PAUSE), sigc::mem_fun(*this, &GtkMainWindow::onPauseBtnClicked));
	action_group->add(Gtk::Action::create(         "Up", Gtk::Stock::GO_UP));
	action_group->add(Gtk::Action::create(       "Down", Gtk::Stock::GO_DOWN));

	Glib::RefPtr<Gtk::UIManager> ui_manager = Gtk::UIManager::create();
	ui_manager->insert_action_group(action_group);
	add_accel_group(ui_manager->get_accel_group());

	Glib::ustring ui_info =
	    "<ui>"
	    "	<toolbar  name='ToolBar'>"
	    "		<toolitem action='Properties' />"
	    "		<separator />"
	    "		<toolitem action='Add Link' />"
	    "		<toolitem action='Add Torrent' />"
	    "		<separator />"
	    "		<toolitem action='Remove' />"
	    "		<toolitem action='Pause' />"
	    "		<toolitem action='Resume' />"
	    "		<separator />"
	    "		<toolitem action='Down' />"
	    "		<toolitem action='Up' />"
	    "		<separator />"
	    "	</toolbar>"
	    "</ui>";

	ui_manager->add_ui_from_string(ui_info);
	this->add(*panel);
	Gtk::Widget* pToolBar = ui_manager->get_widget("/ToolBar");
	pToolBar->override_background_color(Gdk::RGBA("0, 0, 0, 0"));
	header->add(*pToolBar);

	// Let's add some DnD goodness
	vector<Gtk::TargetEntry> listTargets;
	listTargets.push_back(Gtk::TargetEntry("STRING"));
	listTargets.push_back(Gtk::TargetEntry("text/plain"));
	listTargets.push_back(Gtk::TargetEntry("text/uri-list"));
	listTargets.push_back(Gtk::TargetEntry("application/x-bittorrent"));

	m_treeview->drag_dest_set(listTargets, Gtk::DEST_DEFAULT_MOTION | Gtk::DEST_DEFAULT_DROP, Gdk::ACTION_COPY | Gdk::ACTION_MOVE | Gdk::ACTION_LINK | Gdk::ACTION_PRIVATE);
	m_treeview->signal_drag_data_received().connect(sigc::mem_fun(*this, &GtkMainWindow::onFileDropped));

	this->set_titlebar(*header);
	this->show_all();

	panel->set_position(this->get_height() * 0.5);
}