void ide_editor_frame_actions_init (IdeEditorFrame *self) { GSimpleActionGroup *group; GAction *action; g_assert (IDE_IS_EDITOR_FRAME (self)); group = g_simple_action_group_new (); g_action_map_add_action_entries (G_ACTION_MAP (group), IdeEditorFrameActions, G_N_ELEMENTS (IdeEditorFrameActions), self); gtk_widget_insert_action_group (GTK_WIDGET (self), "frame", G_ACTION_GROUP (group)); g_object_unref (group); group = g_simple_action_group_new (); g_action_map_add_action_entries (G_ACTION_MAP (group), IdeEditorFrameSearchActions, G_N_ELEMENTS (IdeEditorFrameSearchActions), self); /* Disable replace and replace-all by default; they should only be enabled * when the corresponding operations would make sense. */ action = g_action_map_lookup_action (G_ACTION_MAP (group), "replace"); g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE); action = g_action_map_lookup_action (G_ACTION_MAP (group), "replace-all"); g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE); gtk_widget_insert_action_group (GTK_WIDGET (self->search_frame), "search-entry", G_ACTION_GROUP (group)); g_object_unref (group); }
void ide_editor_view_actions_init (IdeEditorView *self) { g_autoptr(GSimpleActionGroup) group = NULL; group = g_simple_action_group_new (); g_action_map_add_action_entries (G_ACTION_MAP (group), IdeEditorViewActions, G_N_ELEMENTS (IdeEditorViewActions), self); gtk_widget_insert_action_group (GTK_WIDGET (self), "view", G_ACTION_GROUP (group)); gtk_widget_insert_action_group (GTK_WIDGET (self->tweak_widget), "view", G_ACTION_GROUP (group)); #define WATCH_PROPERTY(name) \ G_STMT_START { \ g_signal_connect (self->frame1->source_view, \ "notify::"name, \ G_CALLBACK (ide_editor_view_actions_source_view_notify), \ group); \ g_object_notify (G_OBJECT (self->frame1->source_view), name); \ } G_STMT_END WATCH_PROPERTY ("auto-indent"); WATCH_PROPERTY ("highlight-current-line"); WATCH_PROPERTY ("insert-spaces-instead-of-tabs"); WATCH_PROPERTY ("show-line-numbers"); WATCH_PROPERTY ("show-right-margin"); WATCH_PROPERTY ("smart-backspace"); WATCH_PROPERTY ("tab-width"); #undef WATCH_PROPERTY }
static void gtk_application_window_init (GtkApplicationWindow *window) { window->priv = gtk_application_window_get_instance_private (window); window->priv->actions = gtk_application_window_actions_new (window); window->priv->app_menu_section = g_menu_new (); window->priv->menubar_section = g_menu_new (); window->priv->accels = gtk_accel_group_new (); gtk_window_add_accel_group (GTK_WINDOW (window), window->priv->accels); gtk_widget_insert_action_group (GTK_WIDGET (window), "win", G_ACTION_GROUP (window->priv->actions)); /* window->priv->actions is the one and only ref on the group, so when * we dispose, the action group will die, disconnecting all signals. */ g_signal_connect_swapped (window->priv->actions, "action-added", G_CALLBACK (g_action_group_action_added), window); g_signal_connect_swapped (window->priv->actions, "action-enabled-changed", G_CALLBACK (g_action_group_action_enabled_changed), window); g_signal_connect_swapped (window->priv->actions, "action-state-changed", G_CALLBACK (g_action_group_action_state_changed), window); g_signal_connect_swapped (window->priv->actions, "action-removed", G_CALLBACK (g_action_group_action_removed), window); }
static void gb_preferences_switch_update_settings (GbPreferencesSwitch *self) { g_assert (GB_IS_PREFERENCES_SWITCH (self)); if ((self->settings != NULL) && (self->settings_schema_key != NULL)) { GSimpleActionGroup *group; GAction *action; gchar *name; action = g_settings_create_action (self->settings, self->settings_schema_key); group = g_simple_action_group_new (); g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action)); gtk_widget_insert_action_group (GTK_WIDGET (self), "settings", G_ACTION_GROUP (group)); g_object_unref (action); name = g_strdup_printf ("settings.%s", self->settings_schema_key); if (self->is_radio) { gtk_actionable_set_action_name (GTK_ACTIONABLE (self->settings_radio), name); gtk_actionable_set_action_name (GTK_ACTIONABLE (self->settings_switch), NULL); } else { gtk_actionable_set_action_name (GTK_ACTIONABLE (self->settings_radio), NULL); gtk_actionable_set_action_name (GTK_ACTIONABLE (self->settings_switch), name); } g_free (name); } }
void ide_workbench_set_visible_perspective (IdeWorkbench *self, IdePerspective *perspective) { GActionGroup *actions; GtkStack *stack; gchar *id; g_return_if_fail (IDE_IS_WORKBENCH (self)); g_return_if_fail (IDE_IS_PERSPECTIVE (perspective)); stack = GTK_STACK (gtk_widget_get_ancestor (GTK_WIDGET (perspective), GTK_TYPE_STACK)); id = ide_perspective_get_id (perspective); if (!ide_str_equal0 (gtk_stack_get_visible_child_name (stack), id)) { gtk_stack_set_visible_child_name (stack, id); gtk_stack_set_visible_child_name (self->titlebar_stack, id); } g_free (id); actions = ide_perspective_get_actions (perspective); gtk_widget_insert_action_group (GTK_WIDGET (self), "perspective", actions); if ((stack == self->perspectives_stack) && !ide_str_equal0 (gtk_stack_get_visible_child_name (self->top_stack), "perspectives")) { gtk_stack_set_visible_child_name (self->top_stack, "perspectives"); g_timeout_add (1000 + gtk_stack_get_transition_duration (self->top_stack), remove_early_perspectives, g_object_ref (self)); } }
static void ide_workbench_notify_visible_child (IdeWorkbench *self, GParamSpec *pspec, GtkStack *stack) { IdePerspective *perspective; g_assert (IDE_IS_WORKBENCH (self)); g_assert (GTK_IS_STACK (stack)); perspective = IDE_PERSPECTIVE (gtk_stack_get_visible_child (stack)); if (perspective != NULL) { GActionGroup *actions; gchar *id; id = ide_perspective_get_id (perspective); gtk_stack_set_visible_child_name (self->titlebar_stack, id); actions = ide_perspective_get_actions (perspective); gtk_widget_insert_action_group (GTK_WIDGET (self), "perspective", actions); g_clear_object (&actions); g_free (id); } }
void gb_project_tree_actions_init (GbProjectTree *self) { g_autoptr(GSettings) settings = NULL; g_autoptr(GSettings) tree_settings = NULL; g_autoptr(GSimpleActionGroup) actions = NULL; g_autoptr(GAction) action = NULL; g_autoptr(GVariant) show_icons = NULL; actions = g_simple_action_group_new (); settings = g_settings_new ("org.gtk.Settings.FileChooser"); action = g_settings_create_action (settings, "sort-directories-first"); g_action_map_add_action (G_ACTION_MAP (actions), action); g_action_map_add_action_entries (G_ACTION_MAP (actions), GbProjectTreeActions, G_N_ELEMENTS (GbProjectTreeActions), self); gtk_widget_insert_action_group (GTK_WIDGET (self), "project-tree", G_ACTION_GROUP (actions)); tree_settings = g_settings_new ("org.gnome.builder.project-tree"); show_icons = g_settings_get_value (tree_settings, "show-icons"); action_set (G_ACTION_GROUP (actions), "show-icons", "state", show_icons, NULL); gb_project_tree_actions_update (self); }
static gboolean geyes_applet_fill (PanelApplet *applet) { EyesApplet *eyes_applet; GSimpleActionGroup *action_group; GAction *action; gchar *ui_path; panel_applet_set_flags (applet, PANEL_APPLET_EXPAND_MINOR); eyes_applet = create_eyes (applet); eyes_applet->settings = panel_applet_settings_new (applet, GEYES_PREFS_SCHEMA); eyes_applet->timeout_id = g_timeout_add ( UPDATE_TIMEOUT, (GSourceFunc) timer_cb, eyes_applet); action_group = g_simple_action_group_new (); g_action_map_add_action_entries (G_ACTION_MAP (action_group), geyes_applet_menu_actions, G_N_ELEMENTS (geyes_applet_menu_actions), eyes_applet); ui_path = g_build_filename (GEYES_MENU_UI_DIR, "geyes-applet-menu.xml", NULL); panel_applet_setup_menu_from_file (eyes_applet->applet, ui_path, action_group, GETTEXT_PACKAGE); g_free (ui_path); gtk_widget_insert_action_group (GTK_WIDGET (applet), "geyes", G_ACTION_GROUP (action_group)); action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "preferences"); g_object_bind_property (applet, "locked-down", action, "enabled", G_BINDING_DEFAULT|G_BINDING_INVERT_BOOLEAN|G_BINDING_SYNC_CREATE); g_object_unref (action_group); gtk_widget_set_tooltip_text (GTK_WIDGET (eyes_applet->applet), _("Eyes")); set_atk_name_description (GTK_WIDGET (eyes_applet->applet), _("Eyes"), _("The eyes look in the direction of the mouse pointer")); g_signal_connect (eyes_applet->vbox, "destroy", G_CALLBACK (destroy_cb), eyes_applet); gtk_widget_show_all (GTK_WIDGET (eyes_applet->applet)); /* setup here and not in create eyes so the destroy signal is set so * that when there is an error within loading the theme * we can emit this signal */ if (properties_load (eyes_applet) == FALSE) return FALSE; setup_eyes (eyes_applet); return TRUE; }
/** * gpm_applet_cb: * @_applet: GpmInhibitApplet instance created by the applet factory * @iid: Applet id * * the function called by libpanel-applet factory after creation **/ static gboolean gpm_applet_cb (PanelApplet *_applet, const gchar *iid, gpointer data) { GpmInhibitApplet *applet = GPM_INHIBIT_APPLET(_applet); GSimpleActionGroup *action_group; gchar *ui_path; static const GActionEntry menu_actions [] = { { "about", gpm_applet_dialog_about_cb, NULL, NULL, NULL }, }; if (strcmp (iid, GPM_INHIBIT_APPLET_ID) != 0) { return FALSE; } action_group = g_simple_action_group_new (); g_action_map_add_action_entries (G_ACTION_MAP (action_group), menu_actions, G_N_ELEMENTS (menu_actions), applet); ui_path = g_build_filename (INHIBIT_MENU_UI_DIR, "inhibit-applet-menu.xml", NULL); panel_applet_setup_menu_from_file (PANEL_APPLET (applet), ui_path, action_group, GETTEXT_PACKAGE); g_free (ui_path); gtk_widget_insert_action_group (GTK_WIDGET (applet), "inhibit", G_ACTION_GROUP (action_group)); g_object_unref (action_group); return TRUE; }
void _ide_layout_stack_actions_init (IdeLayoutStack *self) { g_assert (IDE_IS_LAYOUT_STACK (self)); self->actions = g_simple_action_group_new (); g_action_map_add_action_entries (G_ACTION_MAP (self->actions), gbViewStackActions, G_N_ELEMENTS (gbViewStackActions), self); gtk_widget_insert_action_group (GTK_WIDGET (self), "view-stack", G_ACTION_GROUP (self->actions)); }
void gstyle_color_widget_actions_init (GstyleColorWidget *self) { g_autoptr (GSimpleActionGroup) action_group = NULL; action_group = g_simple_action_group_new (); g_action_map_add_action_entries (G_ACTION_MAP (action_group), actions, G_N_ELEMENTS (actions), self); gtk_widget_insert_action_group (GTK_WIDGET (self), "gstyle-color-widget-menu", G_ACTION_GROUP (action_group)); }
static void activate (GApplication *app, gpointer user_data) { GtkWidget *win; GtkWidget *button; GSimpleActionGroup *doc_actions; GtkBuilder *builder; GMenuModel *doc_menu; GMenuModel *win_menu; GMenu *button_menu; GMenuItem *section; if (gtk_application_get_windows (GTK_APPLICATION (app)) != NULL) return; win = gtk_application_window_new (GTK_APPLICATION (app)); doc_actions = g_simple_action_group_new (); g_action_map_add_action_entries (G_ACTION_MAP (doc_actions), doc_entries, G_N_ELEMENTS (doc_entries), win); g_action_map_add_action_entries (G_ACTION_MAP (win), win_entries, G_N_ELEMENTS (win_entries), win); builder = gtk_builder_new (); gtk_builder_add_from_string (builder, menu_ui, -1, NULL); doc_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "doc-menu")); win_menu = G_MENU_MODEL (gtk_builder_get_object (builder, "win-menu")); button_menu = g_menu_new (); section = g_menu_item_new_section (NULL, doc_menu); g_menu_item_set_attribute (section, "action-namespace", "s", "doc"); g_menu_append_item (button_menu, section); g_object_unref (section); section = g_menu_item_new_section (NULL, win_menu); g_menu_item_set_attribute (section, "action-namespace", "s", "win"); g_menu_append_item (button_menu, section); g_object_unref (section); button = gtk_menu_button_new (); gtk_button_set_label (GTK_BUTTON (button), "Menu"); gtk_widget_insert_action_group (button, "doc", G_ACTION_GROUP (doc_actions)); gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), G_MENU_MODEL (button_menu)); gtk_container_add (GTK_CONTAINER (win), button); gtk_container_set_border_width (GTK_CONTAINER (win), 12); gtk_widget_show_all (win); g_object_unref (button_menu); g_object_unref (doc_actions); g_object_unref (builder); }
void gstyle_color_panel_actions_init (GstyleColorPanel *self) { g_autoptr (GSimpleActionGroup) pages_group = NULL; GActionGroup *palette_widget_actions_group; pages_group = g_simple_action_group_new (); g_action_map_add_action_entries (G_ACTION_MAP (pages_group), ColorPanelPagesPrefsActions, G_N_ELEMENTS (ColorPanelPagesPrefsActions), self); gtk_widget_insert_action_group (GTK_WIDGET (self), "gstyle-pages-prefs", G_ACTION_GROUP (pages_group)); if (self->palette_widget != NULL) { palette_widget_actions_group = gtk_widget_get_action_group (GTK_WIDGET (self->palette_widget), "gstyle-palettes-prefs"); if (palette_widget_actions_group != NULL) gtk_widget_insert_action_group (GTK_WIDGET (self), "gstyle-palettes-prefs", palette_widget_actions_group); } }
void _ide_editor_perspective_init_actions (IdeEditorPerspective *self) { g_autoptr(GSimpleActionGroup) group = NULL; group = g_simple_action_group_new (); g_action_map_add_action_entries (G_ACTION_MAP (group), editor_actions, G_N_ELEMENTS (editor_actions), self); gtk_widget_insert_action_group (GTK_WIDGET (self), "editor", G_ACTION_GROUP (group)); }
static void photos_import_dialog_init (PhotosImportDialog *self) { GApplication *app; GVariant *initial_state; PhotosSearchContextState *state; gtk_widget_init_template (GTK_WIDGET (self)); app = g_application_get_default (); state = photos_search_context_get_state (PHOTOS_SEARCH_CONTEXT (app)); self->cancellable = g_cancellable_new (); self->collections = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_object_unref); self->action_group = g_simple_action_group_new (); gtk_widget_insert_action_group (GTK_WIDGET (self), "dialog", G_ACTION_GROUP (self->action_group)); initial_state = g_variant_new_string (""); self->add_existing_action = g_simple_action_new_stateful ("add-existing", G_VARIANT_TYPE_STRING, initial_state); g_signal_connect_swapped (self->add_existing_action, "notify::state", G_CALLBACK (photos_import_dialog_add_existing_notify_state), self); g_action_map_add_action (G_ACTION_MAP (self->action_group), G_ACTION (self->add_existing_action)); self->item_mngr = g_object_ref (state->item_mngr); { g_autoptr (GError) error = NULL; self->queue = photos_tracker_queue_dup_singleton (NULL, &error); if (G_UNLIKELY (error != NULL)) g_warning ("Unable to create PhotosTrackerQueue: %s", error->message); } if (G_LIKELY (self->queue != NULL)) { g_autoptr (PhotosQuery) query = NULL; query = photos_query_builder_fetch_collections_local (state); photos_tracker_queue_select (self->queue, query, self->cancellable, photos_import_dialog_fetch_collections_local_query_executed, self, NULL); } photos_import_dialog_show_add_existing (self, FALSE); gtk_dialog_set_response_sensitive (GTK_DIALOG (self), GTK_RESPONSE_OK, FALSE); }
GtkWidget * Ekiga::GActorMenu::get_menu (const Ekiga::GActorMenuStore & store) { GMenuModel *model = get_model (store, false); if (!model) return NULL; GtkWidget *menu = gtk_menu_new_from_model (model); gtk_widget_insert_action_group (menu, context.c_str (), G_ACTION_GROUP (g_application_get_default ())); g_object_ref (menu); return menu; }
void nautilus_toolbar_reset_menus (NautilusToolbar *self) { NautilusWindowSlot *slot; NautilusView *view; GActionGroup *view_action_group; GVariant *variant; GVariantIter iter; gboolean show_sort_trash, show_sort_search, show_sort_access, show_sort_modification, enable_sort; const gchar *hint; /* Allow actions from the current view to be activated through * the view menu and action menu of the toolbar */ slot = nautilus_window_get_active_slot (self->priv->window); view = nautilus_window_slot_get_current_view (slot); view_action_group = nautilus_view_get_action_group (view); gtk_widget_insert_action_group (GTK_WIDGET (self), "view", G_ACTION_GROUP (view_action_group)); gtk_widget_set_visible (self->priv->visible_columns, g_action_group_has_action (view_action_group, "visible-columns")); enable_sort = g_action_group_get_action_enabled (view_action_group, "sort"); show_sort_trash = show_sort_search = show_sort_modification = show_sort_access = FALSE; gtk_widget_set_visible (self->priv->sort_menu, enable_sort); if (enable_sort) { variant = g_action_group_get_action_state_hint (view_action_group, "sort"); g_variant_iter_init (&iter, variant); while (g_variant_iter_next (&iter, "&s", &hint)) { if (g_strcmp0 (hint, "trash-time") == 0) show_sort_trash = TRUE; if (g_strcmp0 (hint, "search-relevance") == 0) show_sort_search = TRUE; } g_variant_unref (variant); } gtk_widget_set_visible (self->priv->sort_trash_time, show_sort_trash); gtk_widget_set_visible (self->priv->sort_search_relevance, show_sort_search); variant = g_action_group_get_action_state (view_action_group, "zoom-to-level"); gtk_adjustment_set_value (self->priv->zoom_adjustment, g_variant_get_int32 (variant)); g_variant_unref (variant); }
static void gbp_grep_tree_addin_unload (IdeTreeAddin *addin, IdeTree *tree, IdeTreeModel *model) { GbpGrepTreeAddin *self = (GbpGrepTreeAddin *)addin; g_assert (IDE_IS_MAIN_THREAD ()); g_assert (GBP_IS_GREP_TREE_ADDIN (self)); g_assert (IDE_IS_TREE (tree)); g_assert (IDE_IS_TREE_MODEL (model)); gtk_widget_insert_action_group (GTK_WIDGET (tree), "grep", NULL); self->tree = NULL; }
static void ekiga_window_init_menu (EkigaWindow *mw) { mw->priv->builder = gtk_builder_new (); gtk_builder_add_from_string (mw->priv->builder, win_menu, -1, NULL); g_action_map_add_action (G_ACTION_MAP (g_application_get_default ()), g_settings_create_action (mw->priv->video_devices_settings->get_g_settings (), "enable-preview")); g_action_map_add_action (G_ACTION_MAP (g_application_get_default ()), g_settings_create_action (mw->priv->user_interface_settings->get_g_settings (), "panel-section")); gtk_widget_insert_action_group (GTK_WIDGET (mw), "win", G_ACTION_GROUP (g_application_get_default ())); }
gint main (gint argc, gchar *argv[]) { GtkBuilder *builder = NULL; GtkWindow *window = NULL; GActionGroup *group; GtkWidget *dockbin; GtkWidget *dockoverlay; GtkCssProvider *provider; GError *error = NULL; gtk_init (&argc, &argv); provider = gtk_css_provider_new (); gtk_css_provider_load_from_path (provider, "test-panel.css", &error); g_assert_no_error (error); gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); builder = gtk_builder_new (); gtk_builder_add_callback_symbol (builder, "toggle_all", G_CALLBACK (toggle_all)); gtk_builder_add_from_file (builder, "test-panel.ui", &error); g_assert_no_error (error); window = GTK_WINDOW (gtk_builder_get_object (builder, "window")); g_signal_connect (window, "delete-event", gtk_main_quit, NULL); dockoverlay = GTK_WIDGET (gtk_builder_get_object (builder, "dockoverlay")); _pnl_dock_item_printf (PNL_DOCK_ITEM (dockoverlay)); dockbin = GTK_WIDGET (gtk_builder_get_object (builder, "dockbin")); group = gtk_widget_get_action_group (dockbin, "dockbin"); gtk_widget_insert_action_group (GTK_WIDGET (window), "dockbin", group); gtk_builder_connect_signals (builder, dockbin); gtk_window_present (window); gtk_main (); g_clear_object (&builder); return 0; }
static void anchored_cb(GtkWidget* widget, GtkWidget* prev_toplevel, gpointer udata) { GtTwitchChatView* self = GT_TWITCH_CHAT_VIEW(udata); GtTwitchChatViewPrivate* priv = gt_twitch_chat_view_get_instance_private(self); GtWin* win = GT_WIN_TOPLEVEL(self); gtk_widget_insert_action_group(GTK_WIDGET(win), "chat-view", G_ACTION_GROUP(priv->action_group)); credentials_set_cb(NULL, NULL, self); g_signal_connect(main_app, "notify::oauth-token", G_CALLBACK(credentials_set_cb), self); g_signal_handlers_disconnect_by_func(self, anchored_cb, udata); //One-shot }
GtkWidget * do_modelbutton (GtkWidget *do_widget) { static GtkWidget *window = NULL; static GActionEntry win_entries[] = { { "color", NULL, "s", "'red'", NULL }, { "chocolate", NULL, NULL, "true", NULL }, { "vanilla", NULL, NULL, "false", NULL }, { "sprinkles", NULL, NULL, NULL, NULL } }; if (!window) { GtkBuilder *builder; GActionGroup *actions; builder = gtk_builder_new_from_resource ("/modelbutton/modelbutton.ui"); gtk_builder_add_callback_symbol (builder, "tool_clicked", G_CALLBACK (tool_clicked)); gtk_builder_connect_signals (builder, NULL); window = GTK_WIDGET (gtk_builder_get_object (builder, "window1")); gtk_window_set_screen (GTK_WINDOW (window), gtk_widget_get_screen (do_widget)); g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window); actions = (GActionGroup*)g_simple_action_group_new (); g_action_map_add_action_entries (G_ACTION_MAP (actions), win_entries, G_N_ELEMENTS (win_entries), window); gtk_widget_insert_action_group (window, "win", actions); g_object_unref (builder); } if (!gtk_widget_get_visible (window)) gtk_widget_show_all (window); else gtk_widget_destroy (window); return window; }
static void pnl_tab_strip_init (PnlTabStrip *self) { PnlTabStripPrivate *priv = pnl_tab_strip_get_instance_private (self); GSimpleActionGroup *group; static const GActionEntry entries[] = { { "tab", NULL, "i", "0", set_tab_state }, }; gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_HORIZONTAL); group = g_simple_action_group_new (); g_action_map_add_action_entries (G_ACTION_MAP (group), entries, G_N_ELEMENTS (entries), self); priv->action = g_object_ref (g_action_map_lookup_action (G_ACTION_MAP (group), "tab")); gtk_widget_insert_action_group (GTK_WIDGET (self), "tab-strip", G_ACTION_GROUP (group)); g_object_unref (group); pnl_tab_strip_set_edge (self, GTK_POS_TOP); }
static void ide_debugger_editor_addin_unload (IdeEditorAddin *addin, IdeEditorSurface *editor) { IdeDebuggerEditorAddin *self = (IdeDebuggerEditorAddin *)addin; IdeRunManager *run_manager; IdeWorkspace *workspace; IdeContext *context; IDE_ENTRY; g_assert (IDE_IS_DEBUGGER_EDITOR_ADDIN (self)); g_assert (IDE_IS_EDITOR_SURFACE (editor)); if (!ide_workbench_has_project (self->workbench)) return; context = ide_workbench_get_context (self->workbench); run_manager = ide_run_manager_from_context (context); if ((workspace = ide_widget_get_workspace (GTK_WIDGET (editor)))) gtk_widget_insert_action_group (GTK_WIDGET (workspace), "debugger", NULL); /* Remove the handler to initiate the debugger */ ide_run_manager_remove_handler (run_manager, "debugger"); g_clear_object (&self->debugger_signals); g_clear_object (&self->debug_manager_signals); if (self->panel != NULL) gtk_widget_destroy (GTK_WIDGET (self->panel)); if (self->controls != NULL) gtk_widget_destroy (GTK_WIDGET (self->controls)); if (self->disassembly_view != NULL) gtk_widget_destroy (GTK_WIDGET (self->disassembly_view)); self->editor = NULL; self->workbench = NULL; IDE_EXIT; }
/** * panel_applet_setup_menu: * @applet: a #PanelApplet. * @xml: a menu XML string.. * * Sets up the context menu of @applet. @xml is a #GtkUIManager UI definition, * describing how to display the menu items. @action_group contains the * various #GtkAction that are referenced in @xml. * * See also the <link linkend="getting-started.context-menu">Context * Menu</link> section. **/ void panel_applet_setup_menu (PanelApplet *applet, const gchar *xml) { gchar *new_xml; GError *error = NULL; g_return_if_fail (PANEL_IS_APPLET (applet)); g_return_if_fail (xml != NULL); gtk_widget_insert_action_group (GTK_WIDGET (applet), "applet", G_ACTION_GROUP (applet->priv->action_group)); new_xml = g_strdup_printf ("<interface><menu id=\"panel-applet-popup\">%s</menu></interface>\n", xml); gtk_builder_add_from_string (applet->priv->builder, new_xml, -1, &error); g_free (new_xml); if (error) { g_warning ("Error merging menus: %s\n", error->message); g_error_free (error); } }
static void gbp_grep_tree_addin_load (IdeTreeAddin *addin, IdeTree *tree, IdeTreeModel *model) { GbpGrepTreeAddin *self = (GbpGrepTreeAddin *)addin; g_autoptr(GActionMap) group = NULL; static const GActionEntry actions[] = { { "find-in-files", find_in_files_action }, }; g_assert (IDE_IS_MAIN_THREAD ()); g_assert (GBP_IS_GREP_TREE_ADDIN (self)); g_assert (IDE_IS_TREE (tree)); g_assert (IDE_IS_TREE_MODEL (model)); self->tree = tree; group = G_ACTION_MAP (g_simple_action_group_new ()); g_action_map_add_action_entries (group, actions, G_N_ELEMENTS (actions), self); gtk_widget_insert_action_group (GTK_WIDGET (tree), "grep", G_ACTION_GROUP (group)); }
static void debug_manager_notify_debugger (IdeDebuggerEditorAddin *self, GParamSpec *pspec, IdeDebugManager *debug_manager) { IdeDebugger *debugger; IdeWorkspace *workspace; g_assert (IDE_IS_DEBUGGER_EDITOR_ADDIN (self)); g_assert (IDE_IS_DEBUG_MANAGER (debug_manager)); if (!gtk_widget_get_visible (GTK_WIDGET (self->panel))) { GtkWidget *stack = gtk_widget_get_parent (GTK_WIDGET (self->panel)); gtk_widget_show (GTK_WIDGET (self->panel)); if (GTK_IS_STACK (stack)) gtk_stack_set_visible_child (GTK_STACK (stack), GTK_WIDGET (self->panel)); } debugger = ide_debug_manager_get_debugger (debug_manager); if ((workspace = ide_widget_get_workspace (GTK_WIDGET (self->editor)))) gtk_widget_insert_action_group (GTK_WIDGET (workspace), "debugger", G_ACTION_GROUP (debugger)); ide_debugger_breakpoints_view_set_debugger (self->breakpoints_view, debugger); ide_debugger_locals_view_set_debugger (self->locals_view, debugger); ide_debugger_libraries_view_set_debugger (self->libraries_view, debugger); ide_debugger_registers_view_set_debugger (self->registers_view, debugger); ide_debugger_threads_view_set_debugger (self->threads_view, debugger); dzl_signal_group_set_target (self->debugger_signals, debugger); }
int main (int argc, char *argv[]) { GtkWidget *win; GtkWidget *box; GtkWidget *button; GtkWidget *button2; GtkBuilder *builder; GMenuModel *model; GSimpleActionGroup *actions; GtkWidget *overlay; GtkWidget *grid; GtkWidget *popover; GtkWidget *popover2; GtkWidget *label; GtkWidget *check; GtkWidget *combo; gtk_init (&argc, &argv); win = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (win), 400, 600); actions = g_simple_action_group_new (); g_action_map_add_action_entries (G_ACTION_MAP (actions), entries, G_N_ELEMENTS (entries), NULL); gtk_widget_insert_action_group (win, "top", G_ACTION_GROUP (actions)); overlay = gtk_overlay_new (); gtk_container_add (GTK_CONTAINER (win), overlay); grid = gtk_grid_new (); gtk_widget_set_halign (grid, GTK_ALIGN_FILL); gtk_widget_set_valign (grid, GTK_ALIGN_FILL); gtk_grid_set_row_spacing (GTK_GRID (grid), 10); gtk_grid_set_column_spacing (GTK_GRID (grid), 10); gtk_container_add (GTK_CONTAINER (overlay), grid); label = gtk_label_new (""); gtk_widget_set_hexpand (label, TRUE); gtk_widget_set_vexpand (label, TRUE); gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1); label = gtk_label_new (""); gtk_widget_set_hexpand (label, TRUE); gtk_widget_set_vexpand (label, TRUE); gtk_grid_attach (GTK_GRID (grid), label, 3, 6, 1, 1); builder = gtk_builder_new_from_file ("popover.ui"); model = (GMenuModel *)gtk_builder_get_object (builder, "menu"); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); button = gtk_menu_button_new (); gtk_container_add (GTK_CONTAINER (box), button); button2 = gtk_menu_button_new (); gtk_container_add (GTK_CONTAINER (box), button2); gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (button), model); gtk_menu_button_set_use_popover (GTK_MENU_BUTTON (button), TRUE); popover = GTK_WIDGET (gtk_menu_button_get_popover (GTK_MENU_BUTTON (button))); builder = gtk_builder_new_from_file ("popover2.ui"); popover2 = (GtkWidget *)gtk_builder_get_object (builder, "popover"); gtk_menu_button_set_popover (GTK_MENU_BUTTON (button2), popover2); g_object_set (box, "margin", 10, NULL); gtk_widget_set_halign (box, GTK_ALIGN_END); gtk_widget_set_valign (box, GTK_ALIGN_START); gtk_overlay_add_overlay (GTK_OVERLAY (overlay), box); label = gtk_label_new ("Popover hexpand"); check = gtk_check_button_new (); g_object_bind_property (check, "active", popover, "hexpand", G_BINDING_DEFAULT); g_object_bind_property (check, "active", popover2, "hexpand", G_BINDING_DEFAULT); gtk_grid_attach (GTK_GRID (grid), label , 1, 1, 1, 1); gtk_grid_attach (GTK_GRID (grid), check, 2, 1, 1, 1); label = gtk_label_new ("Popover vexpand"); check = gtk_check_button_new (); g_object_bind_property (check, "active", popover, "vexpand", G_BINDING_DEFAULT); g_object_bind_property (check, "active", popover2, "vexpand", G_BINDING_DEFAULT); gtk_grid_attach (GTK_GRID (grid), label , 1, 2, 1, 1); gtk_grid_attach (GTK_GRID (grid), check, 2, 2, 1, 1); label = gtk_label_new ("Button direction"); combo = gtk_combo_box_text_new (); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "up", "Up"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "down", "Down"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "left", "Left"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "right", "Right"); g_object_bind_property (combo, "active", button, "direction", G_BINDING_DEFAULT); g_object_bind_property (combo, "active", button2, "direction", G_BINDING_DEFAULT); gtk_grid_attach (GTK_GRID (grid), label , 1, 3, 1, 1); gtk_grid_attach (GTK_GRID (grid), combo, 2, 3, 1, 1); label = gtk_label_new ("Button halign"); combo = gtk_combo_box_text_new (); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "fill", "Fill"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "start", "Start"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "end", "End"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "center", "Center"); g_object_bind_property (combo, "active", box, "halign", G_BINDING_DEFAULT); gtk_grid_attach (GTK_GRID (grid), label , 1, 4, 1, 1); gtk_grid_attach (GTK_GRID (grid), combo, 2, 4, 1, 1); label = gtk_label_new ("Button valign"); combo = gtk_combo_box_text_new (); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "fill", "Fill"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "start", "Start"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "end", "End"); gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), "center", "Center"); g_object_bind_property (combo, "active", box, "valign", G_BINDING_DEFAULT); gtk_grid_attach (GTK_GRID (grid), label , 1, 5, 1, 1); gtk_grid_attach (GTK_GRID (grid), combo, 2, 5, 1, 1); gtk_widget_show_all (win); gtk_main (); return 0; }
gboolean workspace_switcher_applet_fill (PanelApplet *applet) { PagerData *pager; GSimpleActionGroup *action_group; GAction *action; gboolean display_names; pager = g_new0 (PagerData, 1); pager->applet = GTK_WIDGET (applet); panel_applet_set_flags (PANEL_APPLET (pager->applet), PANEL_APPLET_EXPAND_MINOR); setup_gsettings (pager); pager->n_rows = g_settings_get_int (pager->settings, "num-rows"); display_names = g_settings_get_boolean (pager->settings, "display-workspace-names"); if (display_names) { pager->display_mode = WNCK_PAGER_DISPLAY_NAME; } else { pager->display_mode = WNCK_PAGER_DISPLAY_CONTENT; } pager->display_all = g_settings_get_boolean (pager->settings, "display-all-workspaces"); switch (panel_applet_get_orient (applet)) { case PANEL_APPLET_ORIENT_LEFT: case PANEL_APPLET_ORIENT_RIGHT: pager->orientation = GTK_ORIENTATION_VERTICAL; break; case PANEL_APPLET_ORIENT_UP: case PANEL_APPLET_ORIENT_DOWN: default: pager->orientation = GTK_ORIENTATION_HORIZONTAL; break; } pager->pager = wnck_pager_new (); pager->screen = NULL; pager->wm = PAGER_WM_UNKNOWN; wnck_pager_set_shadow_type (WNCK_PAGER (pager->pager), GTK_SHADOW_IN); g_signal_connect (G_OBJECT (pager->pager), "destroy", G_CALLBACK (destroy_pager), pager); gtk_container_add (GTK_CONTAINER (pager->applet), pager->pager); gtk_widget_show (pager->pager); g_signal_connect (G_OBJECT (pager->applet), "realize", G_CALLBACK (applet_realized), pager); g_signal_connect (G_OBJECT (pager->applet), "unrealize", G_CALLBACK (applet_unrealized), pager); g_signal_connect (G_OBJECT (pager->applet), "change_orient", G_CALLBACK (applet_change_orient), pager); g_signal_connect (G_OBJECT (pager->applet), "change_background", G_CALLBACK (applet_change_background), pager); gtk_widget_show (pager->applet); action_group = g_simple_action_group_new (); g_action_map_add_action_entries (G_ACTION_MAP (action_group), pager_menu_actions, G_N_ELEMENTS (pager_menu_actions), pager); panel_applet_setup_menu_from_resource (PANEL_APPLET (pager->applet), WNCKLET_RESOURCE_PATH "workspace-switcher-menu.xml", action_group, GETTEXT_PACKAGE); gtk_widget_insert_action_group (GTK_WIDGET (applet), "ws", G_ACTION_GROUP (action_group)); action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "preferences"); g_object_bind_property (pager->applet, "locked-down", action, "enabled", G_BINDING_DEFAULT|G_BINDING_INVERT_BOOLEAN|G_BINDING_SYNC_CREATE); g_object_unref (action_group); return TRUE; }
GtkWidget * reader_window_new(GtkApplication *application, CainteoirSettings *settings, CainteoirSpeechSynthesizers *synthesizers, const gchar *filename) { ReaderWindow *reader = READER_WINDOW(g_object_new(READER_TYPE_WINDOW, "application", application, nullptr)); ReaderWindowPrivate *priv = READER_WINDOW_PRIVATE(reader); priv->self = GTK_WIDGET(reader); priv->settings = CAINTEOIR_SETTINGS(g_object_ref(G_OBJECT(settings))); priv->tts = CAINTEOIR_SPEECH_SYNTHESIZERS(g_object_ref(G_OBJECT(synthesizers))); priv->application = READER_APPLICATION(application); gtk_window_set_default_size(GTK_WINDOW(reader), INDEX_PANE_WIDTH + DOCUMENT_PANE_WIDTH + 5, 300); gtk_window_set_title(GTK_WINDOW(reader), i18n("Cainteoir Text-to-Speech")); GtkWidget *layout = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); gtk_container_add(GTK_CONTAINER(reader), layout); priv->header = gtk_header_bar_new(); gtk_header_bar_set_title(GTK_HEADER_BAR(priv->header), i18n("Cainteoir Text-to-Speech")); if (cainteoir_settings_get_boolean(priv->settings, "window", "have-csd", TRUE)) { // Use client-side decorations (e.g. on Gnome Shell and Unity) ... gtk_header_bar_set_show_close_button(GTK_HEADER_BAR(priv->header), TRUE); gtk_window_set_titlebar(GTK_WINDOW(reader), priv->header); } else { // Don't use client-side decorations (e.g. on KDE) ... gtk_box_pack_start(GTK_BOX(layout), priv->header, FALSE, FALSE, 0); } priv->actions = create_action_group(priv); gtk_widget_insert_action_group(GTK_WIDGET(reader), "cainteoir", G_ACTION_GROUP(priv->actions)); priv->view = reader_document_view_new(priv->settings); gtk_box_pack_start(GTK_BOX(layout), priv->view, TRUE, TRUE, 0); reader_document_view_set_index_pane_close_action_name(READER_DOCUMENT_VIEW(priv->view), "cainteoir.side-pane"); GtkWidget *bottombar = gtk_toolbar_new(); gtk_widget_set_size_request(bottombar, -1, 45); gtk_style_context_add_class(gtk_widget_get_style_context(bottombar), "bottombar"); gtk_box_pack_start(GTK_BOX(layout), bottombar, FALSE, FALSE, 0); GtkToolItem *record = gtk_tool_button_new(gtk_image_new_from_icon_name("media-record-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR), nullptr); gtk_toolbar_insert(GTK_TOOLBAR(bottombar), record, -1); gtk_actionable_set_action_name(GTK_ACTIONABLE(record), "cainteoir.record"); priv->play_stop = gtk_tool_button_new(nullptr, nullptr); gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(priv->play_stop), "media-playback-start-symbolic"); gtk_toolbar_insert(GTK_TOOLBAR(bottombar), priv->play_stop, -1); gtk_actionable_set_action_name(GTK_ACTIONABLE(priv->play_stop), "cainteoir.play-stop"); GtkToolItem *open = gtk_tool_button_new(gtk_image_new_from_icon_name("document-open-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR), nullptr); gtk_toolbar_insert(GTK_TOOLBAR(bottombar), open, -1); gtk_actionable_set_action_name(GTK_ACTIONABLE(open), "cainteoir.open"); GtkToolItem *timebar = gtk_tool_item_new(); gtk_tool_item_set_expand(GTK_TOOL_ITEM(timebar), TRUE); gtk_toolbar_insert(GTK_TOOLBAR(bottombar), timebar, -1); priv->timebar = cainteoir_timebar_new(); gtk_style_context_add_class(gtk_widget_get_style_context(priv->timebar), "timebar"); gtk_container_add(GTK_CONTAINER(timebar), priv->timebar); priv->previous = gtk_button_new(); gtk_button_set_image(GTK_BUTTON(priv->previous), gtk_image_new_from_icon_name("go-previous-symbolic", GTK_ICON_SIZE_SMALL_TOOLBAR)); gtk_header_bar_pack_start(GTK_HEADER_BAR(priv->header), priv->previous); gtk_actionable_set_action_name(GTK_ACTIONABLE(priv->previous), "cainteoir.view-previous"); GtkWidget *menu_button = gtk_menu_button_new(); gtk_button_set_image(GTK_BUTTON(menu_button), gtk_image_new_from_icon_name(HAMBURGER_MENU_ICON, GTK_ICON_SIZE_SMALL_TOOLBAR)); gtk_menu_button_set_menu_model(GTK_MENU_BUTTON(menu_button), create_main_menu()); gtk_header_bar_pack_end(GTK_HEADER_BAR(priv->header), menu_button); g_signal_connect(reader, "window-state-event", G_CALLBACK(on_window_state_changed), priv->settings); g_signal_connect(reader, "delete_event", G_CALLBACK(on_window_delete), priv); g_signal_connect(reader, "show", G_CALLBACK(on_window_show), priv); g_signal_connect(priv->tts, "speaking", G_CALLBACK(on_speaking), priv); g_signal_connect(priv->tts, "text-range-changed", G_CALLBACK(on_text_range_changed), priv); gtk_window_resize(GTK_WINDOW(reader), cainteoir_settings_get_integer(priv->settings, "window", "width", 700), cainteoir_settings_get_integer(priv->settings, "window", "height", 445)); gtk_window_move(GTK_WINDOW(reader), cainteoir_settings_get_integer(priv->settings, "window", "left", 0), cainteoir_settings_get_integer(priv->settings, "window", "top", 0)); if (cainteoir_settings_get_boolean(priv->settings, "window", "maximized", FALSE)) gtk_window_maximize(GTK_WINDOW(reader)); if (filename) reader_window_load_document(reader, filename); else { gchar *prev_filename = cainteoir_settings_get_string(priv->settings, "document", "filename", nullptr); if (prev_filename) { reader_window_load_document(reader, prev_filename); g_free(prev_filename); } } gchar *anchor = cainteoir_settings_get_string(priv->settings, "highlight", "anchor", "none"); if (anchor) { if (!strcmp(anchor, "top")) reader_window_set_highlight_anchor(reader, GTK_ALIGN_START); else if (!strcmp(anchor, "middle")) reader_window_set_highlight_anchor(reader, GTK_ALIGN_CENTER); else if (!strcmp(anchor, "bottom")) reader_window_set_highlight_anchor(reader, GTK_ALIGN_END); g_free(anchor); } return GTK_WIDGET(reader); }