Exemple #1
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 #2
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 #3
0
  NoteEditor::NoteEditor(const Glib::RefPtr<Gtk::TextBuffer> & buffer)
    : Gtk::TextView(buffer)
  {
    set_wrap_mode(Gtk::WRAP_WORD);
    set_left_margin(default_margin());
    set_right_margin(default_margin());
    property_can_default().set_value(true);

    Glib::RefPtr<Gio::Settings> settings = Preferences::obj().get_schema_settings(Preferences::SCHEMA_GNOTE);
    //Set up the schema to watch the default document font
    Glib::RefPtr<Gio::Settings> desktop_settings = Preferences::obj()
      .get_schema_settings(Preferences::SCHEMA_DESKTOP_GNOME_INTERFACE);
    if(desktop_settings) {
      desktop_settings->signal_changed().connect(
        sigc::mem_fun(*this, &NoteEditor::on_font_setting_changed));
    }

    // Set Font from preference
    if (settings->get_boolean(Preferences::ENABLE_CUSTOM_FONT)) {
      std::string font_string = settings->get_string(Preferences::CUSTOM_FONT_FACE);
      override_font (Pango::FontDescription(font_string));
    }
    else {
      override_font (get_gnome_document_font_description ());
    }

    settings->signal_changed().connect(sigc::mem_fun(*this, &NoteEditor::on_font_setting_changed));

    // Set extra editor drag targets supported (in addition
    // to the default TextView's various text formats)...
    Glib::RefPtr<Gtk::TargetList> list = drag_dest_get_target_list();

    
    list->add ("text/uri-list", (Gtk::TargetFlags)0, 1);
    list->add ("_NETSCAPE_URL", (Gtk::TargetFlags)0, 1);

    signal_key_press_event().connect(sigc::mem_fun(*this, &NoteEditor::key_pressed), false);
    signal_button_press_event().connect(sigc::mem_fun(*this, &NoteEditor::button_pressed), false);
  }
/** \brief Registrate stock icons for this program. */
void
IconLoader::register_stock_items()
{
	Glib::RefPtr<Gtk::IconFactory> factory = Gtk::IconFactory::create();

	int i = 0;
	while (icons[i].file) {
		Gtk::IconSource source;

		try {
			// This throws an exception if the file is not found:
			source.set_pixbuf(Gdk::Pixbuf::create_from_file(icons[i].file));
		}
		catch (const Glib::Exception& ex) {
			std::cout << ex.what() << std::endl;
		}

		source.set_size(Gtk::ICON_SIZE_SMALL_TOOLBAR);
		// Icon may be scaled.
		source.set_size_wildcarded();

		Gtk::IconSet icon_set;
		// More than one source per set is allowed.
		icon_set.add_source(source);

		const Gtk::StockID stock_id(icons[i].id);
		factory->add( stock_id, icon_set);
		Gtk::Stock::add(Gtk::StockItem( stock_id, gettext(icons[i].label)));
		++i;
	}

	// Add factory to list of factories:
	factory->add_default();

	// register 64x64 pixels icon size
	Gtk::IconSize::register_new( icon_size_64x64, 64, 64);
}
Exemple #5
0
    Window::Window (App& parent) : 
      Gtk::Window (Gtk::WINDOW_TOPLEVEL), 
      app (parent),
      close_button (Gtk::Stock::CLOSE),
      stop_button (Gtk::Stock::STOP),
      start_button (Gtk::Stock::EXECUTE),
      message_level_label ("Message level"),
      options_label ("Add option"),
      description_frame ("Description"),
      arguments_frame ("Arguments"),
      options_frame ("Options"),
      text_frame ("Program output")
    {
      window = this;
      realize();

      description_label.set_line_wrap (true);
      description_label.set_single_line_mode (false);
      description_label.set_justify (Gtk::JUSTIFY_FILL);
      description_label.set_selectable (true);

      if (app.command_description[0]) {
        description_label.set_text (app.command_description[0]);
        if (app.command_description[1]) {
          String desc (app.command_description[1]);
          for (const gchar** p = app.command_description+2; *p; p++) { desc += "\n\n"; desc += *p; }
          description_label.set_tooltip_text (desc);
        }
      }
      else description_label.set_text ("no description available");

      inner_description_box.set_border_width (GUI_SPACING);
      inner_description_box.add (description_label);
      description_frame.add (inner_description_box);

 
      for (const MR::Argument* arg = app.command_arguments; arg->is_valid(); arg++) {
        Argument* argument = manage (new Argument (*arg));
        arguments_box.pack_start (*argument, Gtk::PACK_SHRINK);
      }
      arguments_frame.add (arguments_box);

      message_level.append_text (message_level_options[0]);
      message_level.append_text (message_level_options[1]);
      message_level.append_text (message_level_options[2]);
      message_level.set_active (0);

      message_level_box.set_spacing (GUI_SPACING);
      message_level_box.pack_start (message_level_label, Gtk::PACK_SHRINK);
      message_level_box.pack_start (message_level);

      top_box.set_border_width (GUI_SPACING);
      top_box.set_spacing (GUI_SPACING);
      top_box.pack_start (description_frame);
      top_box.pack_start (arguments_frame);
      
      if (app.command_options[0].is_valid()) {
        options_box.pack_start (option_menu_box, Gtk::PACK_SHRINK);
        options_box.set_spacing (GUI_SPACING);
        options_box.set_border_width (GUI_SPACING);
        option_menu_box.pack_start (options_label, Gtk::PACK_SHRINK);
        option_menu_box.pack_start (option_combobox);
        option_menu_box.set_spacing (GUI_SPACING);
        for (guint n = 0; App::command_options[n].is_valid(); n++) {
          if (App::command_options[n].mandatory) {
            Option* opt = manage (new Option (*this, App::command_options[n], n));
            options_box.pack_start (*opt, Gtk::PACK_SHRINK);
          }
        }
        set_option_list();
        options_frame.add (options_box);
        top_box.pack_start (options_frame);
        option_combobox.signal_changed().connect (sigc::mem_fun (*this, &Window::on_add_option));
      }

      top_box.pack_start (message_level_box, Gtk::PACK_SHRINK);

      top.set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
      top.set_shadow_type (Gtk::SHADOW_NONE);
      top.add (top_box);

      Glib::RefPtr<Gtk::TextBuffer::TagTable> tags = text.get_buffer()->get_tag_table();
      red  = Gtk::TextBuffer::Tag::create(); red->property_foreground()  = "red";  tags->add (red);
      blue = Gtk::TextBuffer::Tag::create(); blue->property_foreground() = "blue"; tags->add (blue);
      grey = Gtk::TextBuffer::Tag::create(); grey->property_foreground() = "grey"; tags->add (grey);

      text.set_editable (false);
      text.set_cursor_visible (false);
      inner_text_frame.set_shadow_type (Gtk::SHADOW_IN);
      inner_text_frame.set_border_width (GUI_SPACING);
      inner_text_frame.add (text);
      text_frame.add (inner_text_frame);

      close_button.signal_clicked().connect (sigc::mem_fun(*this, &Window::on_close_button));
      stop_button.set_sensitive (false);
      stop_button.signal_clicked().connect (sigc::mem_fun(*this, &Window::on_stop_button));
      start_button.signal_clicked().connect (sigc::mem_fun(*this, &Window::on_start_button));

      button_box.set_spacing (GUI_SPACING);
      button_box.set_homogeneous();
      button_box.pack_start (close_button);
      button_box.pack_start (stop_button);
      button_box.pack_start (start_button);



      bottom_box.set_border_width (GUI_SPACING);
      bottom_box.set_spacing (GUI_SPACING);
      bottom_box.pack_start (progressbar, Gtk::PACK_SHRINK);
      bottom_box.pack_start (text_frame);
      bottom_box.pack_start (button_box, Gtk::PACK_SHRINK);


      splitter.pack1 (top, true, false);
      splitter.pack2 (bottom_box, true, false);
      add (splitter);
      set_icon (App::gui_icon);


      ProgressBar::init_func = ProgressBar::init_func_gui;
      ProgressBar::display_func = ProgressBar::display_func_gui;
      ProgressBar::done_func = ProgressBar::done_func_gui;

      print = gui_print;
      error = gui_error;
      info = gui_info;
      debug = gui_debug;



      set_default_size (400, 800);
      show_all_children();
    }
Exemple #6
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;
}
BackupDialog::BackupDialog(Gtk::Window& parent, Config* ppConfig, tSectionID section)
	: Dialog("Backup", parent), mSection(section),
	mOptionDummyRun("Dummy run"),
	mpConfig(ppConfig), mpBackupThread(NULL), mOptionLevel(1.0),
	mExecButton(Stock::EXECUTE)
{
#ifdef DEBUG
	cerr << "BackupDialog constructor" << endl;
#endif

	set_default_size(650,550);
	// add close button
	add_button(Stock::CLOSE, 1);

	VBox* mainbox = get_vbox(); 
	
	// add Option frame
	Frame* poptionFrame = manage(new Frame());

	poptionFrame->set_border_width(2);
	poptionFrame->set_label("Options");
	mainbox->pack_start(*poptionFrame, false, false);	

	/// add options
	{
		ustring backupType = mpConfig->get_option(mSection, "type");
		Table* optionTable = manage(new Table(2,2));

		Label* label = manage(new Label("Level:"));
		optionTable->attach(*label, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL, 5, 0);
		optionTable->attach(mOptionLevel, 1, 2, 0, 1, Gtk::FILL, Gtk::FILL, 5, 0);						
		label->set_sensitive(false);
		mOptionLevel.set_sensitive(false);

		if(backupType == "incremental") // incremental backup
		{
//TODO: automatic level			mOptionLevel.set_value(mpConfig->get_num_option(mSection, "level"));
			mOptionLevel.set_range(1,999);
			mOptionLevel.set_increments(1,2);
			mOptionLevel.set_numeric();
			mOptionLevel.set_sensitive();
			label->set_sensitive();
		}

		// dummy run option
		mOptionDummyRun.set_active(false);
		optionTable->attach(mOptionDummyRun, 0, 2, 1, 2, FILL, FILL, 5, 0);
		
		// add option table to option frame
		poptionFrame->add(*optionTable);
	}


	// Buttons
	HButtonBox* buttons = manage(new HButtonBox(BUTTONBOX_START));
	buttons->set_border_width(2);
	buttons->set_spacing(10);
	mainbox->pack_start(*buttons, false, false);

	mExecButton.set_use_stock(true);
	mExecButton.signal_clicked().connect( sigc::mem_fun(*this, &BackupDialog::on_button_exec) );
	buttons->pack_start(mExecButton);

	// Log Frame
	Frame* logframe = manage(new Frame());
	logframe->set_border_width(2);
	logframe->set_label("Output");
	mainbox->pack_start(*logframe, true, true);
	
	ScrolledWindow* scrolled = manage(new ScrolledWindow());
	scrolled->set_policy(POLICY_AUTOMATIC, POLICY_ALWAYS);
	scrolled->set_shadow_type(SHADOW_IN);
	scrolled->set_border_width(2);
	logframe->add(*scrolled);

	// Log buffer

	mrefTag = Gtk::TextBuffer::Tag::create();
	mrefTag->property_foreground() = "red";

	Glib::RefPtr<Gtk::TextBuffer::TagTable> refTagTable = Gtk::TextBuffer::TagTable::create();
	refTagTable->add(mrefTag);
	
	mrefLogBuffer = Gtk::TextBuffer::create(refTagTable);
	mLogEnd = mrefLogBuffer->create_mark("bottom", mrefLogBuffer->end());
	mrefLogBuffer->signal_insert().connect(sigc::mem_fun(*this, &BackupDialog::on_buffer_insert));
	
	mLogView.set_buffer(mrefLogBuffer);
	mLogView.set_editable(false);
	mLogView.set_cursor_visible(false);
	scrolled->add(mLogView);

	mpLog = new TextBufferLog(mrefTag, mrefLogBuffer, &mLogView);
	signal_delete_event().connect(
			sigc::mem_fun(*this, &BackupDialog::on_delete_it));

	show_all_children();
}
Exemple #8
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 #9
0
level_editor::header::header():
  group_level_actions(Gtk::ActionGroup::create()),

  action_file(Gtk::Action::create("FileMenu", "_File")),
  action_file_new(Gtk::Action::create("FileNew", Gtk::Stock::NEW)),
  action_file_open(Gtk::Action::create("FileOpen", Gtk::Stock::OPEN)),
  action_file_save(Gtk::Action::create("FileSave", Gtk::Stock::SAVE)),
  action_file_save_as(Gtk::Action::create("FileSaveAs", Gtk::Stock::SAVE_AS)),
  action_file_quit(Gtk::Action::create("FileQuit", Gtk::Stock::QUIT)),

  action_edit(Gtk::Action::create("EditMenu", "_Edit")),
  action_edit_undo(Gtk::Action::create("EditUndo", Gtk::Stock::UNDO)),
  action_edit_redo(Gtk::Action::create("EditRedo", Gtk::Stock::REDO)),
  action_edit_cut(Gtk::Action::create("EditCut", Gtk::Stock::CUT)),
  action_edit_copy(Gtk::Action::create("EditCopy", Gtk::Stock::COPY)),
  action_edit_paste(Gtk::Action::create("EditPaste", Gtk::Stock::PASTE)),
  action_edit_delete(Gtk::Action::create("EditDelete", Gtk::Stock::DELETE)),
  action_edit_preferences(Gtk::Action::create("EditPreferences",
    Gtk::Stock::PREFERENCES)),

  action_level(Gtk::Action::create("LevelMenu", "_Level")),
  action_level_create_link(
    Gtk::Action::create("LevelCreateLink",
                        Gtk::Stock::GO_FORWARD, "Create link",
                        "Create a link from the selected tiles.")),
  action_level_links(
    Gtk::Action::create("LevelLinks",
                        Gtk::Stock::FULLSCREEN, "Links",
                        "Show a list of level links.")),
  action_level_signs(
    Gtk::Action::create("LevelSigns",
                        Gtk::Stock::DND_MULTIPLE, "Signs",
                        "Show a list of signs.")),
  action_level_npcs(
    Gtk::Action::create("LevelNPCs",
                        Gtk::Stock::SELECT_COLOR, "NPCs",
                        "Show a list of NPCs.")),
  action_level_tilesets(
    Gtk::Action::create("LevelTilesets",
                        Gtk::Stock::SELECT_COLOR, "Tilesets",
                        "Show a list of tilesets.")),
#ifdef WIN32
  action_level_play(Gtk::Action::create("LevelPlay", Gtk::Stock::EXECUTE)),
#endif
  action_level_screenshot(
    Gtk::Action::create("LevelScreenshot",
                        Gtk::Stock::ZOOM_FIT, "Screenshot",
                        "Take a screenshot of the level.")),
  
  action_help(Gtk::Action::create("HelpMenu", "_Help")),
  action_help_about(Gtk::Action::create("HelpAbout", Gtk::Stock::ABOUT)) 

{
  group_level_actions->add(action_file_save);
  group_level_actions->add(action_file_save_as);

  group_level_actions->add(action_level);
  group_level_actions->add(action_level_create_link);
  group_level_actions->add(action_level_links);
  group_level_actions->add(action_level_signs);
  group_level_actions->add(action_level_npcs);
  group_level_actions->add(action_level_tilesets);
#ifdef WIN32
  group_level_actions->add(action_level_play);
#endif
  group_level_actions->add(action_level_screenshot);
  
  group_level_actions->add(action_edit_undo, Gtk::AccelKey("<control>z"));
  group_level_actions->add(action_edit_redo, Gtk::AccelKey("<control>y"));
  group_level_actions->add(action_edit_cut);
  group_level_actions->add(action_edit_copy);
  group_level_actions->add(action_edit_paste);
  group_level_actions->add(action_edit_delete, Gtk::AccelKey("Delete"));

  Glib::RefPtr<Gtk::ActionGroup> actions = Gtk::ActionGroup::create();
  actions->add(action_file);
  actions->add(action_file_new);
  actions->add(action_file_open);
  actions->add(action_file_quit);
  actions->add(action_help);
  actions->add(action_help_about);
  actions->add(action_edit);
  actions->add(action_edit_preferences);

  m_ui_manager = Gtk::UIManager::create();
  m_ui_manager->add_ui_from_string(ui_xml);
  m_ui_manager->insert_action_group(group_level_actions);
  m_ui_manager->insert_action_group(actions);
  
  m_menubar = static_cast<Gtk::MenuBar*>(m_ui_manager->get_widget("/MenuBar"));
  pack_start(*m_menubar, Gtk::PACK_SHRINK);
  
  m_toolbar = static_cast<Gtk::Toolbar*>(m_ui_manager->get_widget("/ToolBar"));
  m_toolbar->set_toolbar_style(Gtk::TOOLBAR_ICONS);
  pack_start(*m_toolbar, Gtk::PACK_SHRINK);
}