static void ide_editor_frame_add_search_actions (IdeEditorFrame *self, GActionGroup *group) { GPropertyAction *prop_action; GtkSourceSearchContext *search_context; GtkSourceSearchSettings *search_settings; g_assert (IDE_IS_EDITOR_FRAME (self)); g_assert (G_IS_ACTION_GROUP (group)); search_context = ide_source_view_get_search_context (self->source_view); search_settings = gtk_source_search_context_get_settings (search_context); prop_action = g_property_action_new ("change-case-sensitive", search_settings, "case-sensitive"); g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (prop_action)); g_object_unref (prop_action); prop_action = g_property_action_new ("change-word-boundaries", search_settings, "at-word-boundaries"); g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (prop_action)); g_object_unref (prop_action); prop_action = g_property_action_new ("change-regex-enabled", search_settings, "regex-enabled"); g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (prop_action)); g_object_unref (prop_action); prop_action = g_property_action_new ("change-wrap-around", search_settings, "wrap-around"); g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (prop_action)); g_object_unref (prop_action); }
static void gstyle_color_panel_actions_toggle_page (GSimpleAction *action, GVariant *variant, gpointer user_data) { GstyleColorPanel *self = (GstyleColorPanel *)user_data; g_autoptr (GVariant) value = NULL; g_autofree gchar *page_name = NULL; const gchar *name; gboolean state; g_assert (GSTYLE_IS_COLOR_PANEL (self)); value = g_action_get_state (G_ACTION (action)); state = g_variant_get_boolean (value); name = g_action_get_name(G_ACTION (action)); if (!g_str_has_prefix (name, "toggle-")) return; page_name = g_strdup (&name [7]); g_simple_action_set_state (action, g_variant_new_boolean (!state)); if (!state) { _gstyle_color_panel_update_prefs_page (self, page_name); gtk_stack_set_visible_child_name (self->prefs_stack, page_name); } gstyle_slidein_reveal_slide (GSTYLE_SLIDEIN (self->prefs_slidein), !gstyle_slidein_get_revealed (GSTYLE_SLIDEIN (self->prefs_slidein))); }
static void _brio_application_set_app_menu (GApplication *app) { GMenu *app_menu = g_menu_new (); GSimpleAction *about; GSimpleAction *quit; about = g_simple_action_new ("about", NULL); g_signal_connect (about, "activate", G_CALLBACK (_brio_application_show_about), app); g_action_map_add_action ( G_ACTION_MAP (app), G_ACTION (about)); g_menu_append (app_menu, _("About"), "app.about"); quit = g_simple_action_new ("quit", NULL); g_signal_connect (quit, "activate", G_CALLBACK (_brio_application_quit), app); g_action_map_add_action ( G_ACTION_MAP (app), G_ACTION (quit)); g_menu_append (app_menu, _("Quit"), "app.quit"); gtk_application_set_app_menu (GTK_APPLICATION (app), G_MENU_MODEL (app_menu)); }
static void on_activate_toggle (GSimpleAction *action, GVariant *parameter, gpointer data) { GVariant *state = g_action_get_state (G_ACTION (action)); g_action_change_state (G_ACTION (action), g_variant_new_boolean (!g_variant_get_boolean (state))); g_variant_unref (state); }
static GSimpleActionGroup * create_action_group(ReaderWindowPrivate *priv) { GSimpleActionGroup *actions = g_simple_action_group_new(); gboolean side_pane = cainteoir_settings_get_boolean(priv->settings, "index", "visible", TRUE); priv->index_pane_action = g_simple_action_new_stateful("side-pane", nullptr, g_variant_new_boolean(side_pane)); g_action_map_add_action(G_ACTION_MAP(actions), G_ACTION(priv->index_pane_action)); g_signal_connect(priv->index_pane_action, "activate", G_CALLBACK(on_index_pane_toggle_action), priv); priv->open_action = g_simple_action_new("open", nullptr); g_action_map_add_action(G_ACTION_MAP(actions), G_ACTION(priv->open_action)); g_signal_connect(priv->open_action, "activate", G_CALLBACK(on_open_file_action), priv); priv->play_stop_action = g_simple_action_new("play-stop", nullptr); g_action_map_add_action(G_ACTION_MAP(actions), G_ACTION(priv->play_stop_action)); g_signal_connect(priv->play_stop_action, "activate", G_CALLBACK(on_play_stop_action), priv); priv->record_action = g_simple_action_new("record", nullptr); g_action_map_add_action(G_ACTION_MAP(actions), G_ACTION(priv->record_action)); g_signal_connect(priv->record_action, "activate", G_CALLBACK(on_record_action), priv); return actions; }
static void shell_add_actions (GApplication *application) { GActionMap *action_map; GSimpleAction *action; action_map = G_ACTION_MAP (application); /* Add actions that remote instances can invoke. */ action = g_simple_action_new ("new-window", G_VARIANT_TYPE_STRING); g_signal_connect ( action, "activate", G_CALLBACK (shell_action_new_window_cb), application); g_action_map_add_action (action_map, G_ACTION (action)); g_object_unref (action); action = g_simple_action_new ( "handle-uris", G_VARIANT_TYPE_STRING_ARRAY); g_signal_connect ( action, "activate", G_CALLBACK (shell_action_handle_uris_cb), application); g_action_map_add_action (action_map, G_ACTION (action)); g_object_unref (action); action = g_simple_action_new ("quit", NULL); g_signal_connect ( action, "activate", G_CALLBACK (shell_action_quit_cb), application); g_action_map_add_action (action_map, G_ACTION (action)); g_object_unref (action); }
static void application_startup_cb (GApplication *application, GnomeControlCenter *shell) { GMenu *menu, *section; GAction *action; action = G_ACTION (g_simple_action_new ("help", NULL)); g_action_map_add_action (G_ACTION_MAP (application), action); g_signal_connect (action, "activate", G_CALLBACK (help_activated), shell); action = G_ACTION (g_simple_action_new ("quit", NULL)); g_action_map_add_action (G_ACTION_MAP (application), action); g_signal_connect (action, "activate", G_CALLBACK (quit_activated), shell); menu = g_menu_new (); section = g_menu_new (); g_menu_append (section, _("Help"), "app.help"); g_menu_append (section, _("Quit"), "app.quit"); g_menu_append_section (menu, NULL, G_MENU_MODEL (section)); gtk_application_set_app_menu (GTK_APPLICATION (application), G_MENU_MODEL (menu)); gtk_application_add_accelerator (GTK_APPLICATION (application), "F1", "app.help", NULL); /* nothing else to do here, we don't want to show a window before * we've looked at the commandline */ }
static void impl_activate (PeasActivatable *plugin) { TotemDiscRecorderPlugin *pi = TOTEM_DISC_RECORDER_PLUGIN (plugin); TotemDiscRecorderPluginPrivate *priv = pi->priv; GMenu *menu; char *path; /* make sure brasero is in the path */ path = g_find_program_in_path ("brasero"); if (!path) return; g_free (path); priv->totem = g_object_get_data (G_OBJECT (plugin), "object"); g_signal_connect (priv->totem, "file-opened", G_CALLBACK (totem_disc_recorder_file_opened), plugin); g_signal_connect (priv->totem, "file-closed", G_CALLBACK (totem_disc_recorder_file_closed), plugin); /* Create the actions */ priv->dvd_action = g_simple_action_new ("media-optical-video-new", NULL); g_signal_connect (G_OBJECT (priv->dvd_action), "activate", G_CALLBACK (totem_disc_recorder_plugin_burn), plugin); g_action_map_add_action (G_ACTION_MAP (priv->totem), G_ACTION (priv->dvd_action)); priv->copy_action = g_simple_action_new ("media-optical-copy", NULL); g_signal_connect (G_OBJECT (priv->copy_action), "activate", G_CALLBACK (totem_disc_recorder_plugin_copy), plugin); g_action_map_add_action (G_ACTION_MAP (priv->totem), G_ACTION (priv->copy_action)); priv->copy_vcd_action = g_simple_action_new ("media-optical-copy-vcd", NULL); g_signal_connect (G_OBJECT (priv->copy_vcd_action), "activate", G_CALLBACK (totem_disc_recorder_plugin_copy), plugin); g_action_map_add_action (G_ACTION_MAP (priv->totem), G_ACTION (priv->copy_vcd_action)); /* Install the menu */ menu = totem_object_get_menu_section (priv->totem, "burn-placeholder"); menu_append_hidden (G_MENU (menu), _("_Create Video Disc…"), "app.media-optical-video-new"); menu_append_hidden (G_MENU (menu), _("Copy Vide_o DVD…"), "app.media-optical-copy"); menu_append_hidden (G_MENU (menu), _("Copy (S)VCD…"), "app.media-optical-copy-vcd"); if (!totem_object_is_paused (priv->totem) && !totem_object_is_playing (priv->totem)) { set_menu_items_state (pi, FALSE, FALSE, FALSE); } else { char *mrl; mrl = totem_object_get_current_mrl (priv->totem); totem_disc_recorder_file_opened (priv->totem, mrl, pi); g_free (mrl); } }
static void cc_application_startup (GApplication *application) { CcApplication *self = CC_APPLICATION (application); GMenu *menu; GMenu *section; GSimpleAction *action; G_APPLICATION_CLASS (cc_application_parent_class)->startup (application); #ifdef HAVE_CHEESE if (gtk_clutter_init (NULL, NULL) != CLUTTER_INIT_SUCCESS) { g_critical ("Unable to initialize Clutter"); return; } #endif /* HAVE_CHEESE */ /* register a symbolic icon size for use in sidebar lists */ gtk_icon_size_register ("cc-sidebar-list", 24, 24); action = g_simple_action_new ("help", NULL); g_action_map_add_action (G_ACTION_MAP (application), G_ACTION (action)); g_signal_connect (action, "activate", G_CALLBACK (help_activated), self); g_object_unref (action); action = g_simple_action_new ("quit", NULL); g_action_map_add_action (G_ACTION_MAP (application), G_ACTION (action)); g_signal_connect (action, "activate", G_CALLBACK (cc_application_quit), self); g_object_unref (action); /* Launch panel by id. The parameter is a (panel_id, array_of_panel_parameters) * tuple. The GVariant-containing array usually is just the same array of * strings that would be generated by passing panel-specific arguments on * the command line. */ action = g_simple_action_new ("launch-panel", G_VARIANT_TYPE ("(sav)")); g_action_map_add_action (G_ACTION_MAP (application), G_ACTION (action)); g_signal_connect (action, "activate", G_CALLBACK (launch_panel_activated), self); g_object_unref (action); menu = g_menu_new (); section = g_menu_new (); g_menu_append (section, _("Help"), "app.help"); g_menu_append (section, _("Quit"), "app.quit"); g_menu_append_section (menu, NULL, G_MENU_MODEL (section)); gtk_application_set_app_menu (GTK_APPLICATION (application), G_MENU_MODEL (menu)); gtk_application_add_accelerator (GTK_APPLICATION (application), "F1", "app.help", NULL); self->priv->window = cc_window_new (GTK_APPLICATION (application)); }
static void activate_action (GSimpleAction *action, GVariant *parameter, gpointer data) { GAction *win_action = get_corresponding_window_action (GTK_APPLICATION (data), G_ACTION (action)); g_action_activate (win_action, parameter); if (parameter) g_action_change_state (G_ACTION (action), parameter); }
void libbalsa_toggle_activated(GSimpleAction * action, GVariant * parameter, gpointer user_data) { GVariant *action_state; gboolean state; action_state = g_action_get_state(G_ACTION(action)); state = g_variant_get_boolean(action_state); g_action_change_state(G_ACTION(action), g_variant_new_boolean(!state)); g_variant_unref(action_state); }
static void toggle_speed (GtkToggleButton *button, gpointer data) { GMenuModel *model; GActionGroup *group; GSimpleAction *action; gboolean adding; GMenuModel *m; GMenu *submenu; GtkTreeView *tv = data; GtkTreeModel *store; model = g_object_get_data (G_OBJECT (button), "model"); group = g_object_get_data (G_OBJECT (button), "group"); store = gtk_tree_view_get_model (tv); adding = gtk_toggle_button_get_active (button); m = g_menu_model_get_item_link (model, 1, G_MENU_LINK_SECTION); if (adding) { action = g_simple_action_new ("faster", NULL); g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action)); g_signal_connect (action, "activate", G_CALLBACK (activate_action), NULL); g_object_unref (action); action = g_simple_action_new ("slower", NULL); g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action)); g_signal_connect (action, "activate", G_CALLBACK (activate_action), NULL); g_object_unref (action); action_list_add (store, "faster"); action_list_add (store, "slower"); submenu = g_menu_new (); g_menu_append (submenu, "Faster", "faster"); g_menu_append (submenu, "Slower", "slower"); g_menu_append_submenu (G_MENU (m), "Speed", G_MENU_MODEL (submenu)); } else { g_action_map_remove_action (G_ACTION_MAP (group), "faster"); g_action_map_remove_action (G_ACTION_MAP (group), "slower"); action_list_remove (store, "faster"); action_list_remove (store, "slower"); g_menu_remove (G_MENU (m), g_menu_model_get_n_items (m) - 1); } }
static void gcal_application_set_app_menu (GApplication *app) { GcalApplicationPrivate *priv; GMenu *app_menu; GMenu *view_as; GSimpleAction *about; GSimpleAction *quit; g_return_if_fail (GCAL_IS_APPLICATION (app)); priv = GCAL_APPLICATION (app)->priv; app_menu = g_menu_new (); priv->view = g_simple_action_new_stateful ( "view", G_VARIANT_TYPE_STRING, g_settings_get_value (priv->settings, "active-view")); g_signal_connect (priv->view, "activate", G_CALLBACK (gcal_application_change_view), app); g_action_map_add_action ( G_ACTION_MAP (app), G_ACTION (priv->view)); view_as = g_menu_new (); g_menu_append (view_as, _("Weeks"), "app.view::week"); g_menu_append (view_as, _("Months"), "app.view::month"); g_menu_append_section (app_menu, _("View as"), G_MENU_MODEL (view_as)); about = g_simple_action_new ("about", NULL); g_signal_connect (about, "activate", G_CALLBACK (gcal_application_show_about), app); g_action_map_add_action ( G_ACTION_MAP (app), G_ACTION (about)); g_menu_append (app_menu, _("About"), "app.about"); quit = g_simple_action_new ("quit", NULL); g_signal_connect (quit, "activate", G_CALLBACK (gcal_application_quit), app); g_action_map_add_action ( G_ACTION_MAP (app), G_ACTION (quit)); g_menu_append (app_menu, _("Quit"), "app.quit"); gtk_application_set_app_menu (GTK_APPLICATION (app), G_MENU_MODEL (app_menu)); }
static void photos_application_action_toggle (GSimpleAction *simple, GVariant *parameter, gpointer user_data) { GVariant *state; GVariant *new_state; state = g_action_get_state (G_ACTION (simple)); if (state == NULL) return; new_state = g_variant_new ("b", !g_variant_get_boolean (state)); g_action_change_state (G_ACTION (simple), new_state); g_variant_unref (state); }
static void action_toggle_state (GSimpleAction *action, GVariant *parameter, gpointer user_data) { GVariant *state; gboolean new_state; state = g_action_get_state (G_ACTION (action)); new_state = !g_variant_get_boolean (state); g_action_change_state (G_ACTION (action), g_variant_new_boolean (new_state)); g_variant_unref (state); }
static void on_activate_search (GSimpleAction *action, GVariant *parameter, gpointer data) { GsmApplication *app = (GsmApplication *) data; GVariant *state = g_action_get_state (G_ACTION (action)); gboolean is_search_shortcut = g_variant_get_boolean (parameter); gboolean is_search_bar = gtk_search_bar_get_search_mode (app->search_bar); gtk_widget_set_visible (GTK_WIDGET (app->search_bar), is_search_bar || is_search_shortcut); if (is_search_shortcut && is_search_bar) { gtk_widget_grab_focus (GTK_WIDGET (app->search_entry)); } else { g_action_change_state (G_ACTION (action), g_variant_new_boolean (!g_variant_get_boolean (state))); } g_variant_unref (state); }
static void startup (GApplication *app, gpointer user_data) { GSimpleAction *new_action; GSimpleAction *quit_action; new_action = g_simple_action_new ("new", NULL); g_signal_connect (new_action, "activate", G_CALLBACK (new_callback), app); g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (new_action)); quit_action = g_simple_action_new ("quit", NULL); g_signal_connect (quit_action, "activate", G_CALLBACK (quit_callback), app); g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (quit_action)); }
static void activate_toggle_action (GSimpleAction *action, GVariant *parameter, gpointer data) { GVariant *state = g_action_get_state (G_ACTION (action)); gboolean value = g_variant_get_boolean (state); GAction *win_action; win_action = get_corresponding_window_action (GTK_APPLICATION (data), G_ACTION (action)); g_action_change_state (win_action, g_variant_new_boolean (!value)); g_action_change_state (G_ACTION (action), g_variant_new_boolean (!value)); g_variant_unref (state); }
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); } }
/* Object initialization * Create private structure and set up default values */ static void xfdashboard_application_init(XfdashboardApplication *self) { XfdashboardApplicationPrivate *priv; GSimpleAction *action; priv=self->priv=XFDASHBOARD_APPLICATION_GET_PRIVATE(self); /* Set default values */ priv->isDaemon=FALSE; priv->isSuspended=FALSE; priv->themeName=NULL; priv->inited=FALSE; priv->xfconfChannel=NULL; priv->viewManager=NULL; priv->searchManager=NULL; priv->focusManager=NULL; priv->theme=NULL; priv->xfconfThemeChangedSignalID=0L; priv->isQuitting=FALSE; priv->sessionManagementClient=NULL; /* Add callable DBUS actions for this application */ action=g_simple_action_new("Quit", NULL); g_signal_connect(action, "activate", G_CALLBACK(xfdashboard_application_quit_forced), NULL); g_action_map_add_action(G_ACTION_MAP(self), G_ACTION(action)); g_object_unref(action); }
/* Startup function for the menu we are creating in this sample */ static void startup (GApplication *app, gpointer user_data) { GMenu *menu; GSimpleAction *quit_action; /* Initialize the GMenu, and add a menu item with label "About" and action * "win.about". Also add another menu item with label "Quit" and action * "app.quit" */ menu = g_menu_new (); g_menu_append (menu, "About", "win.about"); g_menu_append (menu, "Quit", "app.quit"); /* Create a new simple action for the application. (In this case it is the * "quit" action. */ quit_action = g_simple_action_new ("quit", NULL); /* Ensure that the menu we have just created is set for the overall application */ gtk_application_set_app_menu (GTK_APPLICATION (app), G_MENU_MODEL (menu)); g_signal_connect (quit_action, "activate", G_CALLBACK (quit_cb), app); g_action_map_add_action (G_ACTION_MAP (app), G_ACTION (quit_action)); }
static void gt_twitch_chat_view_init(GtTwitchChatView* self) { GtTwitchChatViewPrivate* priv = gt_twitch_chat_view_get_instance_private(self); gtk_widget_init_template(GTK_WIDGET(self)); priv->action_group = g_simple_action_group_new(); priv->dark_theme_action = g_property_action_new("dark-theme", self, "dark-theme"); g_action_map_add_action(G_ACTION_MAP(priv->action_group), G_ACTION(priv->dark_theme_action)); priv->chat_css_provider = gtk_css_provider_new(); gtk_style_context_add_provider(gtk_widget_get_style_context(GTK_WIDGET(self)), GTK_STYLE_PROVIDER(priv->chat_css_provider), GTK_STYLE_PROVIDER_PRIORITY_USER); priv->chat_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(priv->chat_view)); priv->tag_table = gtk_text_buffer_get_tag_table(priv->chat_buffer); priv->twitch_emotes = g_hash_table_new(g_direct_hash, g_direct_equal); gtk_text_buffer_get_end_iter(priv->chat_buffer, &priv->bottom_iter); priv->bottom_mark = gtk_text_buffer_create_mark(priv->chat_buffer, "end", &priv->bottom_iter, TRUE); priv->chat = gt_twitch_chat_client_new(); priv->cur_chan = NULL; priv->joined_channel = FALSE; g_signal_connect(priv->chat_entry, "key-press-event", G_CALLBACK(key_press_cb), self); g_signal_connect(self, "hierarchy-changed", G_CALLBACK(anchored_cb), self); g_source_set_callback((GSource*) priv->chat->source, (GSourceFunc) twitch_chat_source_cb, self, NULL); ADD_STYLE_CLASS(self, "gt-twitch-chat-view"); }
static void activate (GSimpleAction *action, GVariant *parameter, gpointer user_data) { g_print ("%s activated\n", g_action_get_name (G_ACTION (action))); }
static void on_menu_toggle_changed(GSimpleAction *action, GVariant *value, gpointer user_data) { WorkraveApplet *applet = WORKRAVE_APPLET(user_data); gboolean new_state = g_variant_get_boolean(value); int index = lookup_menu_index_by_action(g_action_get_name(G_ACTION(action))); if (index == -1) { return; } g_simple_action_set_state(action, value); GDBusProxy *proxy = workrave_timerbox_control_get_control_proxy(applet->priv->timerbox_control); if (proxy != NULL) { g_dbus_proxy_call(proxy, menu_data[index].dbuscmd, g_variant_new("(b)", new_state), G_DBUS_CALL_FLAGS_NO_AUTO_START, -1, NULL, (GAsyncReadyCallback) dbus_call_finish, &applet); } }
static void activate (GtkApplication *app, gpointer user_data) { GtkWidget *window; GSimpleAction *about_action; /* Create a window with a title and a default size */ window = gtk_application_window_new (app); gtk_window_set_title (GTK_WINDOW (window), "AboutDialog Example"); gtk_window_set_default_size (GTK_WINDOW (window), 200, 200); /* Create a new simple action, giving it a NULL parameter type. It will * always be NULL for actions invoked from a menu. (e.g clicking on an "ok" * or "cancel" button) */ about_action = g_simple_action_new ("about", NULL); /* Connect the "activate" signal to the appropriate callback function. * It will indicate that the action was just activated. */ g_signal_connect (about_action, "activate", G_CALLBACK (about_cb), GTK_WINDOW (window)); /* Adds the about_action to the overall action map. An Action map is an * interface that contains a number of named GAction instances * (such as about_action) */ g_action_map_add_action (G_ACTION_MAP (window), G_ACTION (about_action)); gtk_widget_show_all (window); }
static void toggle_italic (GtkToggleButton *button, gpointer data) { GMenuModel *model; GActionGroup *group; GSimpleAction *action; gboolean adding; GMenuModel *m; GtkTreeView *tv = data; GtkTreeModel *store; model = g_object_get_data (G_OBJECT (button), "model"); group = g_object_get_data (G_OBJECT (button), "group"); store = gtk_tree_view_get_model (tv); adding = gtk_toggle_button_get_active (button); m = g_menu_model_get_item_link (model, g_menu_model_get_n_items (model) - 1, G_MENU_LINK_SECTION); if (adding) { action = g_simple_action_new_stateful ("italic", NULL, g_variant_new_boolean (FALSE)); g_action_map_add_action (G_ACTION_MAP (group), G_ACTION (action)); g_signal_connect (action, "activate", G_CALLBACK (activate_toggle), NULL); g_object_unref (action); action_list_add (store, "italic"); g_menu_insert (G_MENU (m), 1, "Italic", "italic"); } else { g_action_map_remove_action (G_ACTION_MAP (group), "italic"); action_list_remove (store, "italic"); g_menu_remove (G_MENU (m), 1); } }
static void activate_radio (GSimpleAction *action, GVariant *parameter, gpointer user_data) { GVariant *old_state, *new_state; old_state = g_action_get_state (G_ACTION (action)); new_state = g_variant_new_string (g_variant_get_string (parameter, NULL)); g_print ("Radio action %s activated, state changes from %s to %s\n", g_action_get_name (G_ACTION (action)), g_variant_get_string (old_state, NULL), g_variant_get_string (new_state, NULL)); g_simple_action_set_state (action, new_state); g_variant_unref (old_state); }
static void activate_toggle (GSimpleAction *action, GVariant *parameter, gpointer user_data) { GVariant *old_state, *new_state; old_state = g_action_get_state (G_ACTION (action)); new_state = g_variant_new_boolean (!g_variant_get_boolean (old_state)); g_print ("Toggle action %s activated, state changes from %d to %d\n", g_action_get_name (G_ACTION (action)), g_variant_get_boolean (old_state), g_variant_get_boolean (new_state)); g_simple_action_set_state (action, new_state); g_variant_unref (old_state); }
void libbalsa_radio_activated(GSimpleAction * action, GVariant * parameter, gpointer user_data) { g_action_change_state(G_ACTION(action), parameter); }
static void g_simple_action_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { GAction *action = G_ACTION (object); switch (prop_id) { case PROP_NAME: g_value_set_string (value, g_simple_action_get_name (action)); break; case PROP_PARAMETER_TYPE: g_value_set_boxed (value, g_simple_action_get_parameter_type (action)); break; case PROP_ENABLED: g_value_set_boolean (value, g_simple_action_get_enabled (action)); break; case PROP_STATE_TYPE: g_value_set_boxed (value, g_simple_action_get_state_type (action)); break; case PROP_STATE: g_value_take_variant (value, g_simple_action_get_state (action)); break; default: g_assert_not_reached (); } }