std::string myg_menu_get_id_at_index(Gtk::Menu &menu, int index) { for (unsigned int i= 0; i < menu.items().size(); i++) { if (index-- == 0) { const char *d= (const char*)menu.items()[i].get_data("id"); return d; } } return ""; }
int myg_menu_get_index_with_id(Gtk::Menu &menu, const std::string &id) { int idx= -1; for (unsigned int i= 0; i < menu.items().size(); i++) { idx++; const char *d= (const char*)menu.items()[i].get_data("id"); if (d && strcmp(d, id.c_str())==0) break; } return idx; }
void myg_menu_set_sensitive(Gtk::Menu &menu, const std::string &id, bool flag) { bool found= false; for (unsigned int i= 0; i < menu.items().size(); i++) { const char *d= (const char*)menu.items()[i].get_data("id"); if (d && strcmp(d, id.c_str())==0) { menu.items()[i].set_sensitive(flag); found= true; break; } } if (!found) g_warning("menu item with identifier %s not found", id.c_str()); }
Gtk::Menu* Port::build_enum_menu() { SPtr<const BlockModel> block = dynamic_ptr_cast<BlockModel>(model()->parent()); Gtk::Menu* menu = Gtk::manage(new Gtk::Menu()); PluginModel::ScalePoints points = block->plugin_model()->port_scale_points( model()->index()); for (PluginModel::ScalePoints::iterator i = points.begin(); i != points.end(); ++i) { menu->items().push_back(Gtk::Menu_Helpers::MenuElem(i->second)); Gtk::MenuItem* menu_item = &(menu->items().back()); menu_item->signal_activate().connect( sigc::bind(sigc::mem_fun(this, &Port::on_scale_point_activated), i->first)); } return menu; }
SendMsgDlg::SendMsgDlg(const char *name, time_t when, const char *text) : LinqWindow(WIN_SEND_MESSAGE) { signal_delete_event().connect(SigC::slot(*this, &SendMsgDlg::on_window_delete_event)); set_title (_("LinQ - Send message")); m_notebook.set_scrollable(true); m_notebook.popup_enable(); Gtk::VBox *vbox; vbox = Gtk::manage(new Gtk::VBox(false, 0)); Gtk::MenuBar *menubar; menubar = Gtk::manage(new Gtk::MenuBar()); Gtk::Menu *menu; menu = Gtk::manage(new Gtk::Menu()); Gtk::Menu::MenuList& menulist = menu->items(); menulist.push_back(Gtk::Menu_Helpers::MenuElem(_("View _histroy"))); menulist.push_back(Gtk::Menu_Helpers::MenuElem(_("_Close"))); menubar->items().push_back( Gtk::Menu_Helpers::MenuElem("_Conservation", *menu) ); menu = Gtk::manage(new Gtk::Menu()); menulist = menu->items(); menulist.push_back(Gtk::Menu_Helpers::CheckMenuElem(_("Enabel _sound"))); menubar->items().push_back( Gtk::Menu_Helpers::MenuElem("_Conservation", *menu) ); vbox->pack_start(*menubar, false, true, 0); vbox->pack_start(m_notebook, true, true, 0); add(*vbox); SendMsgDlgTab *tab; tab = new SendMsgDlgTab(this, name); if (text) tab->onRecvMessage(when, text); tab->doPresent(); show_all(); }
void InheritanceWindow::serverAdded(Server * s) { std::cout << "SERVER ADDED" << std::endl << std::flush; Gtk::Menu * menu = m_serverMenu->get_menu(); bool newMenu = false; if (menu == 0) { newMenu = true; menu = manage( new Gtk::Menu() ); m_serverMenu->set_menu(*menu); } Gtk::Menu_Helpers::MenuList & server_menu = menu->items(); std::stringstream ident; ident << s->getName() << "-" << s->getServerNo(); server_menu.push_back(Gtk::Menu_Helpers::MenuElem(ident.str(), sigc::bind<Server*>(sigc::mem_fun(*this, &InheritanceWindow::currentServerChanged), s))); if (newMenu) { m_serverMenu->set_history(0); currentServerChanged(s); } }
void LayerWindow::modelAdded(Model * model) { std::cout << "Got add model" << std::endl << std::flush; Gtk::Menu * menu = m_modelMenu->get_menu(); bool newMenu = false; if (menu == NULL) { newMenu = true; menu = manage( new Gtk::Menu() ); m_modelMenu->set_menu(*menu); set_sensitive(true); } Gtk::Menu_Helpers::MenuList& model_menu = menu->items(); std::stringstream ident; ident << model->getName() << "-" << model->getModelNo(); model_menu.push_back(Gtk::Menu_Helpers::MenuElem(ident.str(), sigc::bind<Model*>(sigc::mem_fun(*this, &LayerWindow::currentModelChanged),model))); if (newMenu) { m_modelMenu->set_history(0); currentModelChanged(model); } }
bool SDLConfig::display(void) { Gtk::Main kit(0, NULL); std::string sharedir( SHAREDIR ); Glib::RefPtr<Gnome::Glade::Xml> xml = Gnome::Glade::Xml::create( sharedir + "/ogre-config.glade"); if (!xml) { LogManager::getSingleton().logMessage("Problem loading config"); exit(1); } _winConfig = NULL; xml->get_widget("winConfig", _winConfig); if (!_winConfig) { LogManager::getSingleton().logMessage("Invalid window."); exit(1); } xml->get_widget("lstOptions", _lstOptions); xml->get_widget("optRenderer", _optRenderer); xml->get_widget("lblOptName", _lblOptName); xml->get_widget("optOptValues", _optOptValues); Gtk::Button* btn_ok; xml->get_widget("btnOk", btn_ok); Gtk::Button* btn_cancel; xml->get_widget("btnCancel", btn_cancel); _opt_menu = NULL; // Hookup signals _winConfig->signal_delete_event().connect(sigc::mem_fun(this, &SDLConfig::on_window_delete)); _option_selection = _lstOptions->get_selection(); _option_selection->signal_changed().connect(sigc::mem_fun(this, &SDLConfig::on_option_changed)); _optRenderer->signal_changed().connect(sigc::mem_fun(this, &SDLConfig::on_renderer_changed)); _optOptValues->signal_changed().connect(sigc::mem_fun(this, &SDLConfig::on_value_changed)); btn_ok->signal_clicked().connect(sigc::mem_fun(this, &SDLConfig::on_btn_ok)); btn_cancel->signal_clicked().connect(sigc::ptr_fun(&Gtk::Main::quit)); // Initialize _list_store = Gtk::ListStore::create(_columns); _lstOptions->set_model(_list_store); _lstOptions->append_column("Option", _columns.col_name); _lstOptions->append_column("Value", _columns.col_value); // Setup initial values _renderers = Root::getSingleton().getAvailableRenderers(); Gtk::Menu* menu = Gtk::manage(new Gtk::Menu()); MenuList items = menu->items(); for (RenderSystemList::iterator pRend = _renderers->begin(); pRend != _renderers->end(); pRend++) { items.push_back(MenuElem((*pRend)->getName())); } _optRenderer->set_menu(*menu); _selected_renderer = *(_renderers->begin()); update_option_list(); _option_selection->select(_list_store->children().begin()); _winConfig->show(); kit.run(); return true; }
Toolbox::Toolbox(): Gtk::Window(Gtk::WINDOW_TOPLEVEL), dialog_settings(this,"toolbox") { GRAB_HINT_DATA( "toolbox", //#ifdef __APPLE__ Gdk::WINDOW_TYPE_HINT_NORMAL //#else // Gdk::WINDOW_TYPE_HINT_UTILITY //#endif ); set_keep_above(false); set_role("toolbox"); recent_files_menu= manage(new class Gtk::Menu()); Gtk::Menu *filemenu =manage(new class Gtk::Menu()); dock_dialogs=manage(new class Gtk::Menu()); dock_dialogs->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Vertical Dock: Canvases, History"),sigc::ptr_fun(_create_stock_dialog1))); dock_dialogs->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Horizontal Dock: Layers, Library, Parameters"),sigc::ptr_fun(_create_stock_dialog2))); dock_dialogs->items().push_back(Gtk::Menu_Helpers::SeparatorElem()); dock_dialogs->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Reset Windows to Original Layout"),sigc::ptr_fun(App::reset_initial_window_configuration))); dock_dialogs->items().push_back(Gtk::Menu_Helpers::SeparatorElem()); filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::NEW, sigc::ptr_fun(&studio::App::new_instance))); filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::OPEN, sigc::bind(sigc::ptr_fun(&studio::App::dialog_open), ""))); filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Open Recent"),*recent_files_menu)); filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::SAVE, sigc::ptr_fun(save_selected_instance))); filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::SAVE_AS, sigc::ptr_fun(save_as_selected_instance))); filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-saveall"), sigc::ptr_fun(save_all))); filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::CLOSE, sigc::ptr_fun(close_selected_instance))); filemenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem()); filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Panels"),*dock_dialogs)); filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Input Devices..."), sigc::ptr_fun(&show_dialog_input))); filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Setup..."), sigc::ptr_fun(&studio::App::show_setup))); filemenu->items().push_back(Gtk::Menu_Helpers::MenuElem(_("Reset to default Setup values"), sigc::ptr_fun(&studio::App::reset_initial_preferences))); filemenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem()); filemenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID(Gtk::Stock::QUIT), sigc::ptr_fun(studio::App::quit))); #define WIKI(title,page) \ helpmenu->items().push_back(Gtk::Menu_Helpers::MenuElem(title, \ sigc::bind(sigc::ptr_fun(&studio::App::open_url),String("http://synfig.org/wiki")+page))) #define SITE(title,page) \ helpmenu->items().push_back(Gtk::Menu_Helpers::MenuElem(title, \ sigc::bind(sigc::ptr_fun(&studio::App::open_url),String("http://synfig.org/cms")+page))) Gtk::Menu *helpmenu = manage(new class Gtk::Menu()); helpmenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::Stock::HELP, sigc::ptr_fun(studio::App::dialog_help))); helpmenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem()); /* TRANSLATORS: Help menu entry */ WIKI(_("Tutorials"), /* TRANSLATORS: a wiki page */ _("/Category:Tutorials") ); /* TRANSLATORS: Help menu entry */ WIKI(_("Reference"), /* TRANSLATORS: a wiki page */ _("/Category:Reference") ); /* TRANSLATORS: Help menu entry */ WIKI(_("Frequently Asked Questions"),/* TRANSLATORS: a wiki page */ _("/FAQ") ); helpmenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem()); /* TRANSLATORS: Help menu entry */ SITE(_("Get Support"), /* TRANSLATORS: a website page */ _("/en/support") ); helpmenu->items().push_back(Gtk::Menu_Helpers::SeparatorElem()); helpmenu->items().push_back(Gtk::Menu_Helpers::StockMenuElem(Gtk::StockID("synfig-about"), sigc::ptr_fun(studio::App::dialog_about))); Gtk::MenuBar *menubar1 = manage(new class Gtk::MenuBar()); menubar1->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_File"),*filemenu)); menubar1->items().push_back(Gtk::Menu_Helpers::MenuElem(_("_Help"),*helpmenu)); menubar1->show(); Gtk::Image *icon; ADD_TOOLBOX_BUTTON(button_new,"gtk-new",_("New...")); ADD_TOOLBOX_BUTTON(button_open,"gtk-open",_("Open...")); ADD_TOOLBOX_BUTTON(button_save,"gtk-save",_("Save")); ADD_TOOLBOX_BUTTON(button_saveas,"gtk-save-as",_("Save As...")); ADD_TOOLBOX_BUTTON(button_save_all,"synfig-saveall",_("Save All")); TOOLBOX_BUTTON(button_undo,"gtk-undo",_("Undo")); TOOLBOX_BUTTON(button_redo,"gtk-redo",_("Redo")); ADD_TOOLBOX_BUTTON(button_setup,"gtk-properties",_("Setup")); ADD_TOOLBOX_BUTTON(button_about,"synfig-about",_("About Synfig Studio")); ADD_TOOLBOX_BUTTON(button_help,"gtk-help",_("Help")); button_setup->signal_clicked().connect(sigc::ptr_fun(studio::App::show_setup)); button_about->signal_clicked().connect(sigc::ptr_fun(studio::App::dialog_about)); button_help->signal_clicked().connect(sigc::ptr_fun(studio::App::dialog_help)); button_new->signal_clicked().connect(sigc::ptr_fun(studio::App::new_instance)); button_open->signal_clicked().connect(sigc::bind(sigc::ptr_fun(studio::App::dialog_open), "")); button_save->signal_clicked().connect(sigc::ptr_fun(save_selected_instance)); button_saveas->signal_clicked().connect(sigc::ptr_fun(save_as_selected_instance)); button_save_all->signal_clicked().connect(sigc::ptr_fun(save_all)); button_undo->signal_clicked().connect(sigc::ptr_fun(studio::App::undo)); button_redo->signal_clicked().connect(sigc::ptr_fun(studio::App::redo)); // Create the file button cluster Gtk::Table *file_buttons=manage(new class Gtk::Table()); file_buttons->attach(*button_new, 0,1, 0,1, Gtk::EXPAND, Gtk::EXPAND, 0, 0); file_buttons->attach(*button_open, 1,2, 0,1, Gtk::EXPAND, Gtk::EXPAND, 0, 0); file_buttons->attach(*button_save, 2,3, 0,1, Gtk::EXPAND, Gtk::EXPAND, 0, 0); file_buttons->attach(*button_saveas, 3,4, 0,1, Gtk::EXPAND, Gtk::EXPAND, 0, 0); file_buttons->attach(*button_save_all, 4,5, 0,1, Gtk::EXPAND, Gtk::EXPAND, 0, 0); file_buttons->attach(*button_undo, 0,1, 1,2, Gtk::EXPAND, Gtk::EXPAND, 0, 0); file_buttons->attach(*button_redo, 1,2, 1,2, Gtk::EXPAND, Gtk::EXPAND, 0, 0); file_buttons->attach(*button_setup, 2,3, 1,2, Gtk::EXPAND, Gtk::EXPAND, 0, 0); file_buttons->attach(*button_about, 3,4, 1,2, Gtk::EXPAND, Gtk::EXPAND, 0, 0); file_buttons->attach(*button_help, 4,5, 1,2, Gtk::EXPAND, Gtk::EXPAND, 0, 0); file_buttons->show(); tool_table=manage(new class Gtk::Table()); tool_table->show(); Gtk::HandleBox* handle_tools(manage(new Gtk::HandleBox())); handle_tools->add(*tool_table); handle_tools->show(); handle_tools->set_handle_position(Gtk::POS_TOP); handle_tools->set_snap_edge(Gtk::POS_TOP); Widget_Defaults* widget_defaults(manage(new Widget_Defaults())); widget_defaults->show(); Gtk::HandleBox* handle_defaults(manage(new Gtk::HandleBox())); handle_defaults->add(*widget_defaults); handle_defaults->show(); handle_defaults->set_handle_position(Gtk::POS_TOP); handle_defaults->set_snap_edge(Gtk::POS_TOP); // Create the toplevel table Gtk::Table *table1 = manage(new class Gtk::Table(1, 2, false)); table1->set_row_spacings(0); table1->set_col_spacings(0); table1->attach(*menubar1, 0,1, 0,1, Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK, 0, 0); table1->attach(*file_buttons, 0,1, 1,2, Gtk::FILL|Gtk::EXPAND,Gtk::EXPAND|Gtk::FILL, 0, 0); table1->attach(*handle_tools, 0,1, 2,3, Gtk::FILL|Gtk::EXPAND,Gtk::EXPAND|Gtk::FILL, 0, 0); table1->attach(*handle_defaults, 0,1, 3,4, Gtk::FILL|Gtk::EXPAND,Gtk::EXPAND|Gtk::FILL, 0, 0); table1->show_all(); // Set the parameters for this window add(*table1); set_title(_("Synfig Studio")); set_modal(false); property_window_position().set_value(Gtk::WIN_POS_NONE); signal_delete_event().connect(sigc::ptr_fun(App::shutdown_request)); set_resizable(false); App::signal_instance_selected().connect( sigc::hide( sigc::mem_fun(*this,&studio::Toolbox::update_undo_redo) ) ); App::signal_recent_files_changed().connect( sigc::mem_fun(*this,&studio::Toolbox::on_recent_files_changed) ); button_undo->set_sensitive(false); button_redo->set_sensitive(false); std::list<Gtk::TargetEntry> listTargets; listTargets.push_back( Gtk::TargetEntry("text/plain") ); listTargets.push_back( Gtk::TargetEntry("image") ); // listTargets.push_back( Gtk::TargetEntry("image/x-sif") ); drag_dest_set(listTargets); signal_drag_data_received().connect( sigc::mem_fun(*this, &studio::Toolbox::on_drop_drag_data_received) ); App::dock_manager->signal_dockable_registered().connect(sigc::mem_fun(*this,&Toolbox::dockable_registered)); changing_state_=false; add_accel_group(App::ui_manager()->get_accel_group()); App::signal_present_all().connect(sigc::mem_fun0(*this,&Toolbox::present)); }