ParticlePreview::ParticlePreview() { // Add one additional toolbar for particle-related stuff Gtk::Toolbar* toolbar = Gtk::manage(new Gtk::Toolbar); toolbar->set_toolbar_style(Gtk::TOOLBAR_ICONS); _showAxesButton = Gtk::manage(new Gtk::ToggleToolButton); _showAxesButton->signal_toggled().connect( sigc::mem_fun(this, &ParticlePreview::queue_draw) ); _showAxesButton->set_icon_widget(*Gtk::manage(new Gtk::Image( GlobalUIManager().getLocalPixbufWithMask("axes.png")))); _showAxesButton->set_tooltip_text(_("Show coordinate axes")); Gtk::ToolButton* reloadButton = Gtk::manage(new Gtk::ToolButton); reloadButton->set_icon_widget(*Gtk::manage(new Gtk::Image(Gtk::Stock::REFRESH, Gtk::ICON_SIZE_MENU))); reloadButton->set_tooltip_text(_("Reload Particle Defs")); IEventPtr ev = GlobalEventManager().findEvent("ReloadParticles"); ev->connectWidget(reloadButton); _showWireFrameButton = Gtk::manage(new Gtk::ToggleToolButton); _showWireFrameButton->set_icon_widget(*Gtk::manage(new Gtk::Image( GlobalUIManager().getLocalPixbufWithMask("wireframe.png")))); _showWireFrameButton->set_tooltip_text(_("Show wireframe")); _showWireFrameButton->signal_toggled().connect( sigc::mem_fun(this, &ParticlePreview::queue_draw) ); _automaticLoopButton = Gtk::manage(new Gtk::ToggleToolButton(_("Auto Loop"))); _automaticLoopButton->set_tooltip_text(_("Auto Loop")); toolbar->insert(*_showAxesButton, 0); toolbar->insert(*_showWireFrameButton, 0); toolbar->insert(*_automaticLoopButton, 0); toolbar->insert(*reloadButton, 0); addToolbar(*toolbar); }
Main_window::Main_window(const Main_window_settings& settings) : m::gtk::Window("", settings.window, 800, 600, 0), gui(new Gui) { Client_settings& client_settings = get_client_settings(); Main_window_settings& main_window_settings = client_settings.gui.main_window; // Заголовок окна --> this->gui->orig_window_title = APP_NAME; if(get_application().get_config_dir_path() != get_default_config_dir_path()) this->gui->orig_window_title = " (" + get_application().get_config_dir_path() + ")"; Gtk::Window::set_title(this->gui->orig_window_title); // Заголовок окна <-- // Трей show_tray_icon(client_settings.gui.show_tray_icon); // Меню --> this->gui->ui_manager = Gtk::UIManager::create(); Glib::RefPtr<Gtk::ActionGroup> action_group = Gtk::ActionGroup::create(); action_group->add( app_icons::create_action("app", app_icons::ICON_APP, APP_NAME), sigc::mem_fun(*this, &Main_window::on_tray_activated) ); action_group->add(Gtk::Action::create("file", _("_File"))); action_group->add( Gtk::Action::create("create", Gtk::Stock::NEW, _("_Create")), sigc::mem_fun(*this, &Main_window::on_create_callback) ); action_group->add( Gtk::Action::create("open", Gtk::Stock::OPEN, _("_Open a torrent")), sigc::mem_fun(*this, &Main_window::on_open_callback) ); action_group->add( Gtk::Action::create("open_magnet", Gtk::Stock::JUMP_TO, _("_Open a magnet link")), sigc::mem_fun(*this, &Main_window::on_open_magnet_callback) ); action_group->add( Gtk::Action::create("quit", Gtk::Stock::QUIT, _("_Quit")), sigc::mem_fun(get_application(), &Application::close )); action_group->add(Gtk::Action::create("edit", _("_Edit"))); action_group->add( app_icons::create_action("statistics", app_icons::ICON_STATISTICS, _("_Statistics")), sigc::mem_fun(*this, &Main_window::on_show_statistics_callback) ); action_group->add( Gtk::Action::create("preferences", Gtk::Stock::PREFERENCES, _("_Preferences")), sigc::mem_fun(*this, &Main_window::on_show_settings_window_callback) ); action_group->add(Gtk::Action::create("view", _("_View"))); // Toolbar --> action_group->add(Gtk::Action::create("toolbar", _("_Toolbar"))); this->gui->menu_show_toolbar_action = Gtk::ToggleAction::create( "toolbar/show", _Q("'Show ...' toggle|_Show"), "", get_client_settings().gui.show_toolbar ); action_group->add( this->gui->menu_show_toolbar_action, sigc::mem_fun(*this, &Main_window::on_show_toolbar_toggled_callback) ); // Стиль панели инструментов --> { Gtk::RadioButtonGroup radio_group; std::map< m::gtk::toolbar::Style, Glib::RefPtr<Gtk::RadioAction> > toolbar_style_buttons; action_group->add(Gtk::Action::create("toolbar/style", _("Toolbar _style"))); action_group->add( toolbar_style_buttons[m::gtk::toolbar::DEFAULT] = Gtk::RadioAction::create( radio_group, "toolbar/style/default", _("_Desktop default") ), sigc::bind<m::gtk::toolbar::Style>( sigc::mem_fun(*this, &Main_window::change_toolbar_style), m::gtk::toolbar::DEFAULT ) ); action_group->add( toolbar_style_buttons[m::gtk::toolbar::ICONS] = Gtk::RadioAction::create( radio_group, "toolbar/style/icons", _("_Icons") ), sigc::bind<m::gtk::toolbar::Style>( sigc::mem_fun(*this, &Main_window::change_toolbar_style), m::gtk::toolbar::ICONS ) ); action_group->add( toolbar_style_buttons[m::gtk::toolbar::TEXT] = Gtk::RadioAction::create( radio_group, "toolbar/style/text", _("_Text") ), sigc::bind<m::gtk::toolbar::Style>( sigc::mem_fun(*this, &Main_window::change_toolbar_style), m::gtk::toolbar::TEXT ) ); action_group->add( toolbar_style_buttons[m::gtk::toolbar::BOTH] = Gtk::RadioAction::create( radio_group, "toolbar/style/both", _("_Both") ), sigc::bind<m::gtk::toolbar::Style>( sigc::mem_fun(*this, &Main_window::change_toolbar_style), m::gtk::toolbar::BOTH ) ); action_group->add( toolbar_style_buttons[m::gtk::toolbar::BOTH_HORIZ] = Gtk::RadioAction::create( radio_group, "toolbar/style/both_horiz", _("Both _horizontal") ), sigc::bind<m::gtk::toolbar::Style>( sigc::mem_fun(*this, &Main_window::change_toolbar_style), m::gtk::toolbar::BOTH_HORIZ ) ); toolbar_style_buttons[get_client_settings().gui.toolbar_style]->set_active(); } // Стиль панели инструментов <-- // Toolbar <-- // Categories <-- { Glib::RefPtr<Gtk::ToggleAction> action; action_group->add(Gtk::Action::create("categories", _("_Categories"))); action = Gtk::ToggleAction::create( "categories/show", _Q("'Show ...' toggle|_Show"), "", get_client_settings().gui.main_window.torrents_viewport.categories_view->visible ); action_group->add( action, sigc::bind< Glib::RefPtr<Gtk::ToggleAction> >( sigc::mem_fun(*this->gui, &Main_window::Gui::on_show_categories_toggle_cb), action) ); action = Gtk::ToggleAction::create( "categories/show_names", _("Show _names"), "", get_client_settings().gui.main_window.torrents_viewport.categories_view->show_names ); action_group->add( action, sigc::bind< Glib::RefPtr<Gtk::ToggleAction> >( sigc::mem_fun(*this->gui, &Main_window::Gui::on_show_categories_names_toggle_cb), action) ); action = Gtk::ToggleAction::create( "categories/show_counters", _("Show _counters"), "", get_client_settings().gui.main_window.torrents_viewport.categories_view->show_counters ); action_group->add( action, sigc::bind< Glib::RefPtr<Gtk::ToggleAction> >( sigc::mem_fun(*this->gui, &Main_window::Gui::on_show_categories_counters_toggle_cb), action) ); } // Categories <-- // Torrents --> action_group->add(Gtk::Action::create("torrents", _("_Torrents"))); action_group->add(Gtk::Action::create("resume", Gtk::Stock::MEDIA_PLAY, _("_Resume"))); action_group->add( app_icons::create_action("resume/all", app_icons::ICON_DOWNLOAD_AND_UPLOAD, _("_All")), sigc::bind<Torrents_group>( sigc::mem_fun(*this, &Main_window::on_resume_torrents_callback), ALL ) ); action_group->add( app_icons::create_action("resume/downloads", app_icons::ICON_DOWNLOAD, _("_Downloads")), sigc::bind<Torrents_group>( sigc::mem_fun(*this, &Main_window::on_resume_torrents_callback), DOWNLOADS ) ); action_group->add( app_icons::create_action("resume/uploads", app_icons::ICON_UPLOAD, _("_Uploads")), sigc::bind<Torrents_group>( sigc::mem_fun(*this, &Main_window::on_resume_torrents_callback), UPLOADS ) ); action_group->add(Gtk::Action::create("pause", Gtk::Stock::MEDIA_PAUSE, _("_Pause"))); action_group->add( app_icons::create_action("pause/all", app_icons::ICON_DOWNLOAD_AND_UPLOAD, _("_All")), sigc::bind<Torrents_group>( sigc::mem_fun(*this, &Main_window::on_pause_torrents_callback), ALL ) ); action_group->add( app_icons::create_action("pause/downloads", app_icons::ICON_DOWNLOAD, _("_Downloads")), sigc::bind<Torrents_group>( sigc::mem_fun(*this, &Main_window::on_pause_torrents_callback), DOWNLOADS ) ); action_group->add( app_icons::create_action("pause/uploads", app_icons::ICON_UPLOAD, _("_Uploads")), sigc::bind<Torrents_group>( sigc::mem_fun(*this, &Main_window::on_pause_torrents_callback), UPLOADS ) ); // Temporary --> gui->resume_temporary = Gtk::Action::create( "resume_temporary", Gtk::Stock::MEDIA_PLAY, _("R_esume temporary")); action_group->add(gui->resume_temporary); action_group->add( app_icons::create_action("resume_temporary/all", app_icons::ICON_DOWNLOAD_AND_UPLOAD, _("_All")), sigc::bind< std::pair<Temporary_action,Torrents_group> >( sigc::mem_fun(*this, &Main_window::on_temporary_process_torrents_cb), std::pair<Temporary_action,Torrents_group>( TEMPORARY_ACTION_RESUME, ALL ) ) ); action_group->add( app_icons::create_action("resume_temporary/downloads", app_icons::ICON_DOWNLOAD, _("_Downloads")), sigc::bind< std::pair<Temporary_action,Torrents_group> >( sigc::mem_fun(*this, &Main_window::on_temporary_process_torrents_cb), std::pair<Temporary_action,Torrents_group>( TEMPORARY_ACTION_RESUME, DOWNLOADS ) ) ); action_group->add( app_icons::create_action("resume_temporary/uploads", app_icons::ICON_UPLOAD, _("_Uploads")), sigc::bind< std::pair<Temporary_action,Torrents_group> >( sigc::mem_fun(*this, &Main_window::on_temporary_process_torrents_cb), std::pair<Temporary_action,Torrents_group>( TEMPORARY_ACTION_RESUME, UPLOADS ) ) ); gui->pause_temporary = Gtk::Action::create( "pause_temporary", Gtk::Stock::MEDIA_PAUSE, _("P_ause temporary")); action_group->add(gui->pause_temporary); action_group->add( app_icons::create_action("pause_temporary/all", app_icons::ICON_DOWNLOAD_AND_UPLOAD, _("_All")), sigc::bind< std::pair<Temporary_action,Torrents_group> >( sigc::mem_fun(*this, &Main_window::on_temporary_process_torrents_cb), std::pair<Temporary_action,Torrents_group>( TEMPORARY_ACTION_PAUSE, ALL ) ) ); action_group->add( app_icons::create_action("pause_temporary/downloads", app_icons::ICON_DOWNLOAD, _("_Downloads")), sigc::bind< std::pair<Temporary_action,Torrents_group> >( sigc::mem_fun(*this, &Main_window::on_temporary_process_torrents_cb), std::pair<Temporary_action,Torrents_group>( TEMPORARY_ACTION_PAUSE, DOWNLOADS ) ) ); action_group->add( app_icons::create_action("pause_temporary/uploads", app_icons::ICON_UPLOAD, _("_Uploads")), sigc::bind< std::pair<Temporary_action,Torrents_group> >( sigc::mem_fun(*this, &Main_window::on_temporary_process_torrents_cb), std::pair<Temporary_action,Torrents_group>( TEMPORARY_ACTION_PAUSE, UPLOADS ) ) ); gui->complete_temporary_action = Gtk::Action::create( "complete_temporary_action", Gtk::Stock::APPLY, _("C_omplete pending temporary action")); action_group->add( gui->complete_temporary_action, sigc::bind<bool>( sigc::mem_fun(*this, &Main_window::on_interrupt_temporary_action_cb), true ) ); gui->cancel_temporary_action = Gtk::Action::create( "cancel_temporary_action", Gtk::Stock::STOP, _("_Cancel pending temporary action")); action_group->add( gui->cancel_temporary_action, sigc::bind<bool>( sigc::mem_fun(*this, &Main_window::on_interrupt_temporary_action_cb), false ) ); // Temporary <-- // Torrents <-- action_group->add( app_icons::create_action("set_upload_rate_limit", app_icons::ICON_UPLOAD, _("Set _upload rate limit")), sigc::bind<Traffic_type>( sigc::mem_fun(*this, &Main_window::on_change_rate_limit_callback), UPLOAD ) ); action_group->add( app_icons::create_action("set_download_rate_limit", app_icons::ICON_DOWNLOAD, _("Set _download rate limit")), sigc::bind<Traffic_type>( sigc::mem_fun(*this, &Main_window::on_change_rate_limit_callback), DOWNLOAD ) ); action_group->add(Gtk::Action::create("help", _("_Help"))); action_group->add( Gtk::Action::create("about", Gtk::Stock::ABOUT, _("_About")), sigc::mem_fun(*this, &Main_window::on_show_about_dialog_callback) ); this->gui->ui_manager->insert_action_group(action_group); Glib::ustring ui_info = "<ui>" " <menubar name='menu_bar'>" " <menu action='file'>" " <menuitem action='create'/>" " <menuitem action='open'/>" " <menuitem action='open_magnet'/>" " <menuitem action='quit'/>" " </menu>" " <menu action='edit'>" " <menuitem action='statistics'/>" " <menuitem action='preferences'/>" " </menu>" " <menu action='view'>" " <menu action='toolbar'>" " <menuitem action='toolbar/show'/>" " <menu action='toolbar/style'>" " <menuitem action='toolbar/style/default'/>" " <menuitem action='toolbar/style/icons'/>" " <menuitem action='toolbar/style/text'/>" " <menuitem action='toolbar/style/both'/>" " <menuitem action='toolbar/style/both_horiz'/>" " </menu>" " </menu>" " <menu action='categories'>" " <menuitem action='categories/show'/>" " <menuitem action='categories/show_names'/>" " <menuitem action='categories/show_counters'/>" " </menu>" " </menu>" " <menu action='torrents'>" " <menu action='resume'>" " <menuitem action='resume/all'/>" " <menuitem action='resume/uploads'/>" " <menuitem action='resume/downloads'/>" " </menu>" " <menu action='pause'>" " <menuitem action='pause/all'/>" " <menuitem action='pause/uploads'/>" " <menuitem action='pause/downloads'/>" " </menu>" " <separator/>" " <menu action='resume_temporary'>" " <menuitem action='resume_temporary/all'/>" " <menuitem action='resume_temporary/uploads'/>" " <menuitem action='resume_temporary/downloads'/>" " </menu>" " <menu action='pause_temporary'>" " <menuitem action='pause_temporary/all'/>" " <menuitem action='pause_temporary/uploads'/>" " <menuitem action='pause_temporary/downloads'/>" " </menu>" " <menuitem action='complete_temporary_action'/>" " <menuitem action='cancel_temporary_action'/>" " </menu>" " <menu action='help'>" " <menuitem action='about'/>" " </menu>" " </menubar>" " <popup name='appindicator'>" " <menuitem action='app'/>" " <separator/>" " <menuitem action='open'/>" " <menuitem action='open_magnet'/>" " <separator/>" " <menu action='resume'>" " <menuitem action='resume/all'/>" " <menuitem action='resume/uploads'/>" " <menuitem action='resume/downloads'/>" " </menu>" " <menu action='pause'>" " <menuitem action='pause/all'/>" " <menuitem action='pause/uploads'/>" " <menuitem action='pause/downloads'/>" " </menu>" " <separator/>" " <menu action='resume_temporary'>" " <menuitem action='resume_temporary/all'/>" " <menuitem action='resume_temporary/uploads'/>" " <menuitem action='resume_temporary/downloads'/>" " </menu>" " <menu action='pause_temporary'>" " <menuitem action='pause_temporary/all'/>" " <menuitem action='pause_temporary/uploads'/>" " <menuitem action='pause_temporary/downloads'/>" " </menu>" " <menuitem action='complete_temporary_action'/>" " <menuitem action='cancel_temporary_action'/>" " <separator/>" " <menuitem action='set_upload_rate_limit'/>" " <menuitem action='set_download_rate_limit'/>" " <separator/>" " <menuitem action='quit'/>" " </popup>" " <popup name='tray_popup_menu'>" " <menuitem action='open'/>" " <menuitem action='open_magnet'/>" " <separator/>" " <menu action='resume'>" " <menuitem action='resume/all'/>" " <menuitem action='resume/uploads'/>" " <menuitem action='resume/downloads'/>" " </menu>" " <menu action='pause'>" " <menuitem action='pause/all'/>" " <menuitem action='pause/uploads'/>" " <menuitem action='pause/downloads'/>" " </menu>" " <separator/>" " <menu action='resume_temporary'>" " <menuitem action='resume_temporary/all'/>" " <menuitem action='resume_temporary/uploads'/>" " <menuitem action='resume_temporary/downloads'/>" " </menu>" " <menu action='pause_temporary'>" " <menuitem action='pause_temporary/all'/>" " <menuitem action='pause_temporary/uploads'/>" " <menuitem action='pause_temporary/downloads'/>" " </menu>" " <menuitem action='complete_temporary_action'/>" " <menuitem action='cancel_temporary_action'/>" " <separator/>" " <menuitem action='set_upload_rate_limit'/>" " <menuitem action='set_download_rate_limit'/>" " <separator/>" " <menuitem action='quit'/>" " </popup>" "</ui>"; this->gui->ui_manager->add_ui_from_string(ui_info); this->add_accel_group(this->gui->ui_manager->get_accel_group()); // Меню <-- Gtk::VBox* main_vbox = Gtk::manage(new Gtk::VBox()); this->add(*main_vbox); // Панель меню --> Gtk::Widget* menu_bar = this->gui->ui_manager->get_widget("/menu_bar"); main_vbox->pack_start(*menu_bar, false, true); // Панель меню <-- // Панель инструментов main_vbox->pack_start(this->gui->toolbar, false, false); // Список торрентов --> this->gui->torrents_viewport = Gtk::manage(new Torrents_viewport(main_window_settings.torrents_viewport)); main_vbox->pack_start(*this->gui->torrents_viewport, true, true); // Настройки отдельных виджетов this->gui->torrents_viewport->get_log_view().set_max_lines(client_settings.gui.max_log_lines); // Список торрентов <-- // status bar --> { Gtk::Alignment* alignment = Gtk::manage(new Gtk::Alignment()); alignment->property_top_padding() = m::gtk::VBOX_SPACING / 2; main_vbox->pack_start(*alignment, false, false); alignment->add(this->gui->status_bar); this->gui->status_bar.push(""); } // status bar <-- // AppIndicator --> #if HAVE_APP_INDICATOR { app_indicator_set_menu(this->gui->appindicator, GTK_MENU( gtk_ui_manager_get_widget(this->gui->ui_manager->gobj(), "/ui/appindicator"))); g_signal_connect(G_OBJECT(this->gui->appindicator), APP_INDICATOR_SIGNAL_CONNECTION_CHANGED, G_CALLBACK(&Main_window::on_appindicator_connection_changed), this); } #endif // AppIndicator <-- // Панель инструментов --> { // Заполнять ее лучше в самом конце, когда уже созданы все необходимые // виджеты. Gtk::ToolButton* button; button = Gtk::manage(new Gtk::ToolButton(Gtk::Stock::NEW)); button->set_label(_("Create")); button->set_tooltip_text(_("Create a new torrent")); button->set_is_important(); this->gui->toolbar.append( *button, sigc::mem_fun(*this, &Main_window::on_create_callback) ); button = Gtk::manage(new Gtk::ToolButton(Gtk::Stock::OPEN)); button->set_label(_("Open")); button->set_tooltip_text(_("Open a torrent")); button->set_is_important(); this->gui->toolbar.append( *button, sigc::mem_fun(*this, &Main_window::on_open_callback) ); button = Gtk::manage(new Gtk::ToolButton(Gtk::Stock::JUMP_TO)); button->set_label(_("Magnet link")); button->set_tooltip_text(_("Open a magnet link")); button->set_is_important(); this->gui->toolbar.append( *button, sigc::mem_fun(*this, &Main_window::on_open_magnet_callback) ); this->gui->toolbar.append( *Gtk::manage(new Gtk::SeparatorToolItem()) ); button = this->gui->toolbar_resume_button = Gtk::manage(new Gtk::ToolButton(Gtk::Stock::MEDIA_PLAY)); button->set_label(_("Resume")); button->set_tooltip_text(_("Resume torrent(s)")); button->set_is_important(); this->gui->toolbar.append( *button, sigc::bind<Torrent_process_action>( sigc::mem_fun(*this->gui->torrents_viewport, &Torrents_viewport::process_torrents), RESUME ) ); button = this->gui->toolbar_pause_button = Gtk::manage(new Gtk::ToolButton(Gtk::Stock::MEDIA_PAUSE)); button->set_label(_("Pause")); button->set_tooltip_text(_("Pause torrent(s)")); button->set_is_important(); this->gui->toolbar.append( *button, sigc::bind<Torrent_process_action>( sigc::mem_fun(*this->gui->torrents_viewport, &Torrents_viewport::process_torrents), PAUSE ) ); button = this->gui->toolbar_remove_button = Gtk::manage(new Gtk::ToolButton(Gtk::Stock::REMOVE)); button->set_label(_("Remove")); button->set_tooltip_text(_("Remove torrent(s)")); button->set_is_important(); this->gui->toolbar.append( *button, sigc::bind<Torrent_process_action>( sigc::mem_fun(*this->gui->torrents_viewport, &Torrents_viewport::process_torrents), REMOVE ) ); this->gui->toolbar.append( *Gtk::manage(new Gtk::SeparatorToolItem()) ); button = Gtk::manage(new Gtk::ToolButton()); button->set_label(_("Statistics")); app_icons::set_for_tool_button(*button, app_icons::ICON_STATISTICS); button->set_tooltip_text(_("Statistics")); button->set_is_important(); this->gui->toolbar.append( *button, sigc::mem_fun(*this, &Main_window::on_show_statistics_callback) ); button = Gtk::manage(new Gtk::ToolButton(Gtk::Stock::PREFERENCES)); button->set_label(_("Preferences")); button->set_tooltip_text(_("Preferences")); button->set_is_important(); this->gui->toolbar.append( *button, sigc::mem_fun(*this, &Main_window::on_show_settings_window_callback) ); this->gui->toolbar.show_all_children(); if(get_client_settings().gui.show_toolbar) this->gui->toolbar.show(); this->gui->toolbar.set_no_show_all(); } // Панель инструментов <-- // Устанавливаем интервал обновления GUI this->set_gui_update_interval(client_settings.gui.update_interval); // Обновление доступных в данный момент кнопок --> this->on_torrent_process_actions_changed_callback(0); gui->torrent_process_actions_changed_connection = this->gui->torrents_viewport->signal_torrent_process_actions_changed().connect( sigc::mem_fun(*this, &Main_window::on_torrent_process_actions_changed_callback) ); // Обновление доступных в данный момент кнопок <-- // Автоматическое сохранение настроек gui->autosave_settings_connection = Glib::signal_timeout().connect( sigc::mem_fun(*this, &Main_window::on_save_settings_timeout), SAVE_SETTINGS_INTERVAL ); // Обработчик сигнала на изменение состояния окна this->signal_window_state_event().connect(sigc::mem_fun( *this, &Main_window::on_window_state_changed_callback )); // Закрытие окна this->signal_delete_event().connect(sigc::mem_fun(*this, &Main_window::on_close_callback)); if(client_settings.gui.show_tray_icon && client_settings.gui.hide_app_to_tray_at_startup) this->show_all_children(); else this->show_all(); // В gtkmm 2.16.0 (Ubuntu 9.04) есть небольшая бага, из-за которой // this->show_all() отображает даже элементы меню, для которых была // выполнена Gtk::Action::set_visible(false). // Поэтому скрываем элементы меню в самый последний момент. COMPATIBILITY gui->complete_temporary_action->set_visible(true); gui->cancel_temporary_action->set_visible(true); }
void CategoryWindowGTKMM::connectSignals() { // The delete event to close the program categoryWindow->signal_delete_event().connect( sigc::mem_fun( this, &EngineGTKMM::quit) ); //Get the Glade-instantiated Button, and connect a signal handler: Gtk::ToolButton* pToolButton = 0; // New button refXml->get_widget("toolbutton14", pToolButton); if(pToolButton) { pToolButton->signal_clicked().connect( sigc::mem_fun( this, &CategoryWindowGTKMM::onButton_new) ); pToolButton->set_tooltip_text("Create a new category."); } else { // TODO throw error } // Open button refXml->get_widget("toolbutton15", pToolButton); if(pToolButton) { pToolButton->signal_clicked().connect( sigc::mem_fun( this, &CategoryWindowGTKMM::onButton_open) ); pToolButton->set_tooltip_text("Open a category from file."); } else { // TODO throw error } // Save button refXml->get_widget("toolbutton16", pToolButton); if(pToolButton) { pToolButton->signal_clicked().connect( sigc::mem_fun( this, &EngineGTKMM::saveCategory) ); pToolButton->set_tooltip_text("Save a category to file."); } else { // TODO throw error } // Save as button refXml->get_widget("toolbutton32", pToolButton); if(pToolButton) { pToolButton->signal_clicked().connect( sigc::mem_fun( this, &EngineGTKMM::saveAsCategory) ); pToolButton->set_tooltip_text("Save as a category to file."); } else { // TODO throw error } // Back button refXml->get_widget("toolbutton17", pToolButton); if(pToolButton) { pToolButton->signal_clicked().connect( sigc::mem_fun( this, &CategoryWindowGTKMM::onButton_back) ); pToolButton->set_tooltip_text("Display previous category."); } else { // TODO throw error } // Forward button refXml->get_widget("toolbutton18", pToolButton); if(pToolButton) { pToolButton->signal_clicked().connect( sigc::mem_fun( this, &CategoryWindowGTKMM::onButton_forward) ); pToolButton->set_tooltip_text("Display next category."); } else { // TODO throw error } // Add button refXml->get_widget("toolbutton21", pToolButton); if(pToolButton) { pToolButton->signal_clicked().connect( sigc::mem_fun( this, &CategoryWindowGTKMM::onButton_add) ); pToolButton->set_tooltip_text("Add a field to the category."); } else { // TODO throw error fieldTableGTKMM = new FieldTableGTKMM(); } // Delete button refXml->get_widget("toolbutton22", pToolButton); if(pToolButton) { pToolButton->signal_clicked().connect( sigc::mem_fun( this, &CategoryWindowGTKMM::onButton_delete) ); pToolButton->set_tooltip_text("Delete the selected field from the category."); } else { // TODO throw error } // Up button refXml->get_widget("toolbutton23", pToolButton); if(pToolButton) { pToolButton->signal_clicked().connect( sigc::mem_fun( this, &CategoryWindowGTKMM::onButton_up) ); pToolButton->set_tooltip_text("Move the selected category up."); } else { // TODO throw error } // Down button refXml->get_widget("toolbutton24", pToolButton); if(pToolButton) { pToolButton->signal_clicked().connect( sigc::mem_fun( this, &CategoryWindowGTKMM::onButton_down) ); pToolButton->set_tooltip_text("Move the selected category down."); } else { // TODO throw error } // When clicking on a field in the tree view of the category window, change the selection categoryGTKMM->get_signal_selectionChange().connect( sigc::mem_fun( this, &CategoryWindowGTKMM::fieldSelected) ); };