static void setup_accelerators(gmpv_handle *ctx) { add_accelerator(ctx->app, "<Control>o", "app.open"); add_accelerator(ctx->app, "<Control>l", "app.openloc"); add_accelerator(ctx->app, "<Control>S", "app.playlist_save"); add_accelerator(ctx->app, "<Control>q", "app.quit"); add_accelerator(ctx->app, "<Control>p", "app.pref"); add_accelerator(ctx->app, "F9", "app.playlist_toggle"); add_accelerator(ctx->app, "<Control>1", "app.normalsize"); add_accelerator(ctx->app, "<Control>2", "app.doublesize"); add_accelerator(ctx->app, "<Control>3", "app.halfsize"); add_accelerator(ctx->app, "F11", "app.fullscreen"); }
void UnderlineMenuItem::on_note_foregrounded() { add_accelerator("activate", m_note_addin->get_window()->get_accel_group(), GDK_KEY_U, PLATFORM_ACCELERATOR_MASK, Gtk::ACCEL_VISIBLE); }
std::map<int, Gtk::Widget*> TableofcontentsNoteAddin::get_actions_popover_widgets() const { auto widgets = NoteAddin::get_actions_popover_widgets(); auto toc_item = gnote::utils::create_popover_submenu_button("tableofcontents-menu", _("Table of Contents")); gnote::utils::add_item_to_ordered_map(widgets, gnote::TABLE_OF_CONTENTS_ORDER, toc_item); auto toc_menu = gnote::utils::create_popover_submenu("tableofcontents-menu"); gnote::utils::add_item_to_ordered_map(widgets, 100000, toc_menu); std::vector<Gtk::Widget*> toc_items; get_toc_popover_items(toc_items); if(toc_items.size()) { for(auto & toc_button : toc_items) { toc_menu->add(*toc_button); } toc_menu->add(*manage(new Gtk::Separator)); } auto item = manage(gnote::utils::create_popover_button("win.tableofcontents-heading1", _("Heading 1"))); item->add_accelerator("activate", get_window()->get_accel_group(), GDK_KEY_1, Gdk::CONTROL_MASK, Gtk::ACCEL_VISIBLE); toc_menu->add(*item); item = manage(gnote::utils::create_popover_button("win.tableofcontents-heading2", _("Heading 2"))); item->add_accelerator("activate", get_window()->get_accel_group(), GDK_KEY_2, Gdk::CONTROL_MASK, Gtk::ACCEL_VISIBLE); toc_menu->add(*item); item = manage(gnote::utils::create_popover_button("win.tableofcontents-help", _("Table of Contents Help"))); toc_menu->add(*item); toc_menu->add(*manage(new Gtk::Separator)); auto back_item = gnote::utils::create_popover_submenu_button("main", _("_Back")); dynamic_cast<Gtk::ModelButton*>(back_item)->property_inverted() = true; toc_menu->add(*back_item); return widgets; }
FixedWidthMenuItem::FixedWidthMenuItem(mnote::NoteAddin *addin) : Gtk::CheckMenuItem(Glib::ustring("<span font_family=\"monospace\">") + _("Fixed Wid_th") + "</span>", true) , m_note_addin(addin) , m_event_freeze(false) { mnote::NoteTextMenu::markup_label(*this); m_note_addin->get_window()->text_menu()->signal_show().connect( sigc::mem_fun(*this, &FixedWidthMenuItem::menu_shown)); add_accelerator ("activate", addin->get_window()->get_accel_group(), GDK_T, Gdk::CONTROL_MASK, Gtk::ACCEL_VISIBLE); show_all(); }
UnderlineMenuItem::UnderlineMenuItem(gnote::NoteAddin *addin) : Gtk::CheckMenuItem(Glib::ustring("<u>") + _("_Underline") + "</u>", true) , m_note_addin(addin) , m_event_freeze(false) { gnote::NoteTextMenu::markup_label(*this); m_note_addin->get_window()->text_menu()->signal_show().connect( sigc::mem_fun(*this, &UnderlineMenuItem::menu_shown)); add_accelerator ("activate", addin->get_window()->get_accel_group(), GDK_KEY_U, Gdk::CONTROL_MASK, Gtk::ACCEL_VISIBLE); show_all(); }
static void gedit_app_startup (GApplication *application) { GeditAppPrivate *priv; GtkCssProvider *css_provider; GtkSourceStyleSchemeManager *manager; const gchar *dir; gchar *icon_dir; #ifndef ENABLE_GVFS_METADATA const gchar *cache_dir; gchar *metadata_filename; #endif priv = gedit_app_get_instance_private (GEDIT_APP (application)); G_APPLICATION_CLASS (gedit_app_parent_class)->startup (application); /* Setup debugging */ gedit_debug_init (); gedit_debug_message (DEBUG_APP, "Startup"); gedit_debug_message (DEBUG_APP, "Set icon"); dir = gedit_dirs_get_gedit_data_dir (); icon_dir = g_build_filename (dir, "icons", NULL); gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (), icon_dir); g_free (icon_dir); setup_theme_extensions (GEDIT_APP (application)); #ifndef ENABLE_GVFS_METADATA cache_dir = gedit_dirs_get_user_cache_dir (); metadata_filename = g_build_filename (cache_dir, "gedit-metadata.xml", NULL); gedit_metadata_manager_init (metadata_filename); g_free (metadata_filename); #endif /* Load settings */ priv->settings = gedit_settings_new (); priv->ui_settings = g_settings_new ("org.gnome.gedit.preferences.ui"); priv->window_settings = g_settings_new ("org.gnome.gedit.state.window"); /* initial lockdown state */ priv->lockdown = gedit_settings_get_lockdown (GEDIT_SETTINGS (priv->settings)); g_action_map_add_action_entries (G_ACTION_MAP (application), app_entries, G_N_ELEMENTS (app_entries), application); /* menus */ priv->window_menu = gtk_application_get_menubar (GTK_APPLICATION (application)); if (priv->window_menu == NULL) { priv->window_menu = get_menu_model (GEDIT_APP (application), "gear-menu"); } else { g_object_ref (priv->window_menu); } priv->notebook_menu = get_menu_model (GEDIT_APP (application), "notebook-menu"); priv->tab_width_menu = get_menu_model (GEDIT_APP (application), "tab-width-menu"); priv->line_col_menu = get_menu_model (GEDIT_APP (application), "line-col-menu"); /* Accelerators */ add_accelerator (GTK_APPLICATION (application), "app.new-window", "<Primary>N"); add_accelerator (GTK_APPLICATION (application), "app.quit", "<Primary>Q"); add_accelerator (GTK_APPLICATION (application), "app.help", "F1"); add_accelerator (GTK_APPLICATION (application), "win.gear-menu", "F10"); add_accelerator (GTK_APPLICATION (application), "win.open", "<Primary>O"); add_accelerator (GTK_APPLICATION (application), "win.save", "<Primary>S"); add_accelerator (GTK_APPLICATION (application), "win.save-as", "<Primary><Shift>S"); add_accelerator (GTK_APPLICATION (application), "win.save-all", "<Primary><Shift>L"); add_accelerator (GTK_APPLICATION (application), "win.new-tab", "<Primary>T"); add_accelerator (GTK_APPLICATION (application), "win.reopen-closed-tab", "<Primary><Shift>T"); add_accelerator (GTK_APPLICATION (application), "win.close", "<Primary>W"); add_accelerator (GTK_APPLICATION (application), "win.close-all", "<Primary><Shift>W"); add_accelerator (GTK_APPLICATION (application), "win.print", "<Primary>P"); add_accelerator (GTK_APPLICATION (application), "win.find", "<Primary>F"); add_accelerator (GTK_APPLICATION (application), "win.find-next", "<Primary>G"); add_accelerator (GTK_APPLICATION (application), "win.find-prev", "<Primary><Shift>G"); add_accelerator (GTK_APPLICATION (application), "win.replace", "<Primary>H"); add_accelerator (GTK_APPLICATION (application), "win.clear-highlight", "<Primary><Shift>K"); add_accelerator (GTK_APPLICATION (application), "win.goto-line", "<Primary>I"); add_accelerator (GTK_APPLICATION (application), "win.focus-active-view", "Escape"); add_accelerator (GTK_APPLICATION (application), "win.side-panel", "F9"); add_accelerator (GTK_APPLICATION (application), "win.bottom-panel", "<Primary>F9"); add_accelerator (GTK_APPLICATION (application), "win.fullscreen", "F11"); add_accelerator (GTK_APPLICATION (application), "win.new-tab-group", "<Primary><Alt>N"); add_accelerator (GTK_APPLICATION (application), "win.previous-tab-group", "<Primary><Shift><Alt>Page_Up"); add_accelerator (GTK_APPLICATION (application), "win.next-tab-group", "<Primary><Shift><Alt>Page_Down"); add_accelerator (GTK_APPLICATION (application), "win.previous-document", "<Primary><Alt>Page_Up"); add_accelerator (GTK_APPLICATION (application), "win.next-document", "<Primary><Alt>Page_Down"); load_accels (); /* Load custom css */ g_object_unref (load_css_from_resource ("gedit-style.css", TRUE)); css_provider = load_css_from_resource ("gedit-style-os.css", FALSE); g_clear_object (&css_provider); /* * We use the default gtksourceview style scheme manager so that plugins * can obtain it easily without a gedit specific api, but we need to * add our search path at startup before the manager is actually used. */ manager = gtk_source_style_scheme_manager_get_default (); gtk_source_style_scheme_manager_append_search_path (manager, gedit_dirs_get_user_styles_dir ()); priv->engine = gedit_plugins_engine_get_default (); priv->extensions = peas_extension_set_new (PEAS_ENGINE (priv->engine), GEDIT_TYPE_APP_ACTIVATABLE, "app", GEDIT_APP (application), NULL); g_signal_connect (priv->extensions, "extension-added", G_CALLBACK (extension_added), application); g_signal_connect (priv->extensions, "extension-removed", G_CALLBACK (extension_removed), application); peas_extension_set_foreach (priv->extensions, (PeasExtensionSetForeachFunc) extension_added, application); }
void ui_menu_create(GtkWidget *w, GtkAccelGroup *accel, const char *menu_name, ui_menu_entry_t *list) { static int level = 0; unsigned int i, j; ui_menu_cb_obj *obj = NULL; level++; #ifdef DEBUG_MENUS printf("allocate new: %s\t(%p)\t%s\n", gtk_type_name(GTK_WIDGET_TYPE(w)), w, menu_name); #endif for (i = j = 0; list[i].string; i++) { GtkWidget *new_item = NULL; int do_right_justify = 0; char name[256]; sprintf(name, "MenuItem%d", j); /* ugly... */ switch (*list[i].string) { case '-': /* line */ new_item = gtk_menu_item_new(); break; case '*': /* toggle */ { /* Add this item to the list of calls to perform to update the menu status. */ char *label = make_menu_label(&list[i]); if (list[i].callback) { checkmark_t *cmt; new_item = gtk_check_menu_item_new_with_label(label + 1); cmt = (checkmark_t *)lib_malloc(sizeof(checkmark_t)); cmt->name = lib_stralloc(list[i].string+1); cmt->w = new_item; cmt->cb = list[i].callback; cmt->obj.value = (void*) list[i].callback_data; cmt->obj.status = CB_NORMAL; cmt->handlerid = g_signal_connect(G_OBJECT(new_item),"activate", G_CALLBACK(list[i].callback), (gpointer) &(cmt->obj)); g_signal_connect(G_OBJECT(new_item), "destroy", G_CALLBACK(delete_checkmark_cb), (gpointer) cmt); checkmark_list = g_list_prepend(checkmark_list, cmt); obj = &cmt->obj; } else new_item = gtk_menu_item_new_with_label(label + 1); j++; lib_free(label); break; } case 0: break; default: { char *item, *itemp; item = itemp = make_menu_label(&list[i]); if (strncmp(item, "RJ", 2) == 0) { do_right_justify = 1; item += 2; } new_item = gtk_menu_item_new_with_label(item); if (list[i].callback) { obj = (ui_menu_cb_obj*)lib_malloc(sizeof(ui_menu_cb_obj)); obj->value = (void*) list[i].callback_data; g_signal_connect(G_OBJECT(new_item),"activate", G_CALLBACK(list[i].callback), (gpointer) obj); } lib_free(itemp); j++; } } if (new_item) { gtk_menu_shell_append(GTK_MENU_SHELL(w), new_item); gtk_widget_show(new_item); if (do_right_justify) gtk_menu_item_set_right_justified(GTK_MENU_ITEM(new_item), TRUE); #ifdef DEBUG_MENUS printf("allocate new: %s\t(%p)\t%s\n", gtk_type_name(GTK_WIDGET_TYPE(new_item)), new_item, list[i].string); #endif } if (list[i].sub_menu) { GtkWidget *sub; if (new_item && *list[i].string != '-') { sub = gtk_menu_new(); gtk_menu_item_set_submenu(GTK_MENU_ITEM(new_item),sub); } else { sub = w; } ui_menu_create(sub, accel, list[i].string, list[i].sub_menu); } else { /* no submenu */ if (accel && list[i].hotkey_keysym != KEYSYM_NONE && list[i].callback != NULL && new_item != NULL) add_accelerator(new_item, accel, list[i].hotkey_keysym, list[i].hotkey_modifier); } } level--; }
AppWindow::AppWindow() { m_viewer = new Viewer(this); set_title("CS488 Assignment Two, by Alex Klen"); // Application Menu. Gtk::MenuItem *reset = Gtk::manage(new Gtk::MenuItem("_Reset", true)); Gtk::MenuItem *quit = Gtk::manage(new Gtk::MenuItem("_Quit", true)); reset->signal_activate().connect(sigc::mem_fun(*this, &AppWindow::reset_view)); quit->signal_activate().connect(sigc::mem_fun(*this, &AppWindow::hide)); add_accelerator(reset, 'a'); add_accelerator(quit, 'q'); m_menu_app.items().push_back(*reset); m_menu_app.items().push_back(*quit); // Mode Menu. const char shortcuts[] = { 'o', 'n', 'p', 'r', 't', 's', 'v' }; const std::string names[] = { "R_otate View", "Tra_nslate View", "_Perspective", "_Rotate Model", "_Translate Model", "_Scale Model", "_Viewport" }; // Create and wire signals for radio buttons for each mode. Gtk::RadioMenuItem::Group view_mode_group; sigc::slot1<void, Viewer::Mode> view_mode_slot = sigc::mem_fun(*m_viewer, &Viewer::set_mode); for (int mode = 0; mode < Viewer::NUM_MODES; mode++) { Gtk::RadioMenuItem *rb = Gtk::manage(new Gtk::RadioMenuItem(view_mode_group, names[mode], true)); add_accelerator(rb, shortcuts[mode]); rb->signal_activate().connect(sigc::bind(view_mode_slot, (Viewer::Mode) mode)); m_menu_mode.items().push_back(*rb); } // Set up the menu bar m_menubar.items().push_back(Gtk::Menu_Helpers::MenuElem("_Application", m_menu_app)); m_menubar.items().push_back(Gtk::Menu_Helpers::MenuElem("_Mode", m_menu_mode)); // Select default radio button. m_menu_mode.items()[Viewer::DEFAULT_MODE].activate(); // Pack in our widgets // First add the vertical box as our single "top" widget add(m_vbox); // Put the menubar on the top, and make it as small as possible m_vbox.pack_start(m_menubar, Gtk::PACK_SHRINK); // Put the viewer below the menubar. pack_start "grows" the widget // by default, so it'll take up the rest of the window. m_viewer->set_size_request(600, 600); m_vbox.pack_start(*m_viewer); m_vbox.pack_start(m_main_label, false, false); show_all(); }