void initialize_app_menu (GApplication *application) { GSettings *settings; g_action_map_add_action_entries (G_ACTION_MAP (application), app_menu_entries, G_N_ELEMENTS (app_menu_entries), application); _gtk_application_add_accelerators (GTK_APPLICATION (application), fr_app_accelerators, G_N_ELEMENTS (fr_app_accelerators)); settings = fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_UI); g_simple_action_set_state (GET_ACTION (PREF_UI_VIEW_SIDEBAR), g_variant_new_boolean (g_settings_get_boolean (settings, PREF_UI_VIEW_SIDEBAR))); settings = fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_LISTING); g_simple_action_set_state (GET_ACTION (PREF_LISTING_LIST_MODE), g_variant_new_string (_g_enum_type_get_value (FR_TYPE_WINDOW_LIST_MODE, g_settings_get_enum (settings, PREF_LISTING_LIST_MODE))->value_nick)); g_signal_connect (fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_UI), "changed::" PREF_UI_VIEW_SIDEBAR, G_CALLBACK (pref_view_sidebar_changed), application); g_signal_connect (fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_LISTING), "changed::" PREF_LISTING_LIST_MODE, G_CALLBACK (pref_list_mode_changed), application); }
void initialize_app_menubar (GApplication *application) { GtkBuilder *builder; GSettings *settings; g_action_map_add_action_entries (G_ACTION_MAP (application), app_menu_entries, G_N_ELEMENTS (app_menu_entries), application); builder = _gtk_builder_new_from_resource ("app-menubar.ui"); gtk_application_set_menubar (GTK_APPLICATION (application), G_MENU_MODEL (gtk_builder_get_object (builder, "app-menubar"))); g_object_unref (builder); settings = fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_UI); g_simple_action_set_state (GET_ACTION (PREF_UI_VIEW_SIDEBAR), g_variant_new_boolean (g_settings_get_boolean (settings, PREF_UI_VIEW_SIDEBAR))); settings = fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_LISTING); g_simple_action_set_state (GET_ACTION (PREF_LISTING_LIST_MODE), g_variant_new_string (_g_enum_type_get_value (FR_TYPE_WINDOW_LIST_MODE, g_settings_get_enum (settings, PREF_LISTING_LIST_MODE))->value_nick)); g_signal_connect (fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_UI), "changed::" PREF_UI_VIEW_SIDEBAR, G_CALLBACK (pref_view_sidebar_changed), application); g_signal_connect (fr_application_get_settings (FR_APPLICATION (application), FILE_ROLLER_SCHEMA_LISTING), "changed::" PREF_LISTING_LIST_MODE, G_CALLBACK (pref_list_mode_changed), application); }
void on_menu_changed(gpointer instance, GVariant *parameters, gpointer user_data) { WorkraveApplet *applet = WORKRAVE_APPLET(user_data); GVariantIter *iter; g_variant_get (parameters, "(a(sii))", &iter); char *text; int id; int flags; gboolean visible[sizeof(menu_data)/sizeof(struct Menuitems)]; for (int i = 0; i < sizeof(menu_data)/sizeof(struct Menuitems); i++) { visible[i] = menu_data[i].visible_when_not_running; } while (g_variant_iter_loop(iter, "(sii)", &text, &id, &flags)) { int index = lookup_menu_index_by_id((enum MenuCommand)id); if (index == -1) { continue; } GAction *action = g_action_map_lookup_action(G_ACTION_MAP(applet->priv->action_group), menu_data[index].action); if (flags & MENU_ITEM_FLAG_SUBMENU_END || flags & MENU_ITEM_FLAG_SUBMENU_BEGIN) { continue; } visible[index] = TRUE; if (g_action_get_state_type(G_ACTION(action)) != NULL) { if (menu_data[index].state == NULL) { g_simple_action_set_state(G_SIMPLE_ACTION(action), g_variant_new_boolean(flags & MENU_ITEM_FLAG_ACTIVE)); } else { if (flags & MENU_ITEM_FLAG_ACTIVE) { g_simple_action_set_state(G_SIMPLE_ACTION(action), g_variant_new_string(menu_data[index].state)); } } } } g_variant_iter_free (iter); for (int i = 0; i < sizeof(menu_data)/sizeof(struct Menuitems); i++) { GAction *action = g_action_map_lookup_action(G_ACTION_MAP(applet->priv->action_group), menu_data[i].action); g_simple_action_set_enabled(G_SIMPLE_ACTION(action), visible[i]); } }
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 change_toggle_state (GSimpleAction *action, GVariant *state, gpointer data) { g_simple_action_set_state (action, state); }
static void show_settings_cb(GSimpleAction* action, GVariant* par, gpointer udata) { GtWin* self = GT_WIN(udata); GtWinPrivate* priv = gt_win_get_instance_private(self); if (!priv->settings_dlg) { priv->settings_dlg = gt_settings_dlg_new(self); g_object_add_weak_pointer(G_OBJECT(priv->settings_dlg), (gpointer *) &priv->settings_dlg); } if (par) { GEnumClass* eclass = g_type_class_ref(GT_TYPE_SETTINGS_DLG_VIEW); GEnumValue* eval = g_enum_get_value_by_nick(eclass, g_variant_get_string(par, NULL)); gt_settings_dlg_set_view(priv->settings_dlg, eval->value); g_simple_action_set_state(action, par); g_type_class_unref(eclass); } gtk_window_present(GTK_WINDOW(priv->settings_dlg)); }
void gth_browser_activate_image_zoom (GSimpleAction *action, GVariant *parameter, gpointer user_data) { GthBrowser *browser = user_data; const char *state; GthImageViewer *image_viewer; state = g_variant_get_string (parameter, NULL); g_simple_action_set_state (action, g_variant_new_string (state)); if (state == NULL) return; image_viewer = GTH_IMAGE_VIEWER (gth_image_viewer_page_get_image_viewer (GTH_IMAGE_VIEWER_PAGE (gth_browser_get_viewer_page (browser)))); if (strcmp (state, "automatic") == 0) gth_image_viewer_set_fit_mode (image_viewer, GTH_FIT_SIZE_IF_LARGER); else if (strcmp (state, "fit") == 0) gth_image_viewer_set_fit_mode (image_viewer, GTH_FIT_SIZE); else if (strcmp (state, "fit-width") == 0) gth_image_viewer_set_fit_mode (image_viewer, GTH_FIT_WIDTH); else if (strcmp (state, "fit-height") == 0) gth_image_viewer_set_fit_mode (image_viewer, GTH_FIT_HEIGHT); else if (strcmp (state, "50") == 0) gth_image_viewer_set_zoom (image_viewer, 0.5); else if (strcmp (state, "100") == 0) gth_image_viewer_set_zoom (image_viewer, 1.0); else if (strcmp (state, "200") == 0) gth_image_viewer_set_zoom (image_viewer, 2.0); else if (strcmp (state, "300") == 0) gth_image_viewer_set_zoom (image_viewer, 3.0); }
static void change_radio_state (GSimpleAction *action, GVariant *state, gpointer user_data) { g_simple_action_set_state (action, state); }
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 auto_spell_cb (GSimpleAction *action, GVariant *state, gpointer data) { GeditSpellPlugin *plugin = GEDIT_SPELL_PLUGIN (data); GeditSpellPluginPrivate *priv = plugin->priv; GeditView *view; gboolean active; gedit_debug (DEBUG_PLUGINS); active = g_variant_get_boolean (state); gedit_debug_message (DEBUG_PLUGINS, active ? "Auto Spell activated" : "Auto Spell deactivated"); view = gedit_window_get_active_view (priv->window); if (view != NULL) { GeditDocument *doc; doc = GEDIT_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view))); gedit_document_set_metadata (doc, GEDIT_METADATA_ATTRIBUTE_SPELL_ENABLED, active ? "1" : NULL, NULL); set_auto_spell (priv->window, view, active); g_simple_action_set_state (action, g_variant_new_boolean (active)); } }
static void change_show_processes_state (GSimpleAction *action, GVariant *state, gpointer data) { GsmApplication *app = (GsmApplication *) data; auto state_var = Glib::wrap(state, true); g_simple_action_set_state (action, state); app->settings->set_value (GSM_SETTING_SHOW_WHOSE_PROCESSES, state_var); }
void on_feedlist_reduced_activate (GSimpleAction *action, GVariant *parameter, gpointer user_data) { GVariant *state = g_action_get_state (G_ACTION (action)); gboolean val = !g_variant_get_boolean (state); feed_list_view_set_reduce_mode (val); g_simple_action_set_state (action, g_variant_new_boolean (val)); g_object_unref (state); }
static void change_show_dependencies_state (GSimpleAction *action, GVariant *state, gpointer data) { GsmApplication *app = (GsmApplication *) data; auto state_var = Glib::wrap(state, true); g_simple_action_set_state (action, state); app->settings->set_value (GSM_SETTING_SHOW_DEPENDENCIES, state_var); }
static void change_show_page_state (GSimpleAction *action, GVariant *state, gpointer data) { GsmApplication *app = (GsmApplication *) data; auto state_var = Glib::wrap(state, true); g_simple_action_set_state (action, state); app->settings->set_value (GSM_SETTING_CURRENT_TAB, state_var); }
G_MODULE_EXPORT void show_preview_action_cb(GSimpleAction *action, GVariant *value, signal_user_data_t *ud) { gboolean state = g_variant_get_boolean(value); g_simple_action_set_state(action, value); ghb_preview_set_visible(ud, state); update_preview_labels(ud, state); }
static void photos_searchbar_change_state (PhotosSearchbar *self, GVariant *value) { g_simple_action_set_state (G_SIMPLE_ACTION (self->priv->search), value); if (g_variant_get_boolean (value)) photos_searchbar_show (self); else photos_searchbar_hide (self); }
void gth_browser_activate_apply_icc_profile (GSimpleAction *action, GVariant *state, gpointer user_data) { GthBrowser *browser = user_data; g_simple_action_set_state (action, state); gth_image_viewer_page_apply_icc_profile (GTH_IMAGE_VIEWER_PAGE (gth_browser_get_viewer_page (browser)), g_variant_get_boolean (state)); }
static void g_simple_action_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { GSimpleAction *simple = G_SIMPLE_ACTION (object); switch (prop_id) { case PROP_NAME: g_assert (simple->priv->name == NULL); simple->priv->name = g_value_dup_string (value); break; case PROP_PARAMETER_TYPE: g_assert (simple->priv->parameter_type == NULL); simple->priv->parameter_type = g_value_dup_boxed (value); break; case PROP_ENABLED: g_simple_action_set_enabled (simple, g_value_get_boolean (value)); break; case PROP_STATE: /* PROP_STATE is marked as G_PARAM_CONSTRUCT so we always get a * call during object construction, even if it is NULL. We treat * that first call differently, for a number of reasons. * * First, we don't want the value to be rejected by the * possibly-overridden .set_state() function. Second, we don't * want to be tripped by the assertions in g_simple_action_set_state() * that would enforce the catch22 that we only provide a value of * the same type as the existing value (when there is not yet an * existing value). */ if (simple->priv->state_set) g_simple_action_set_state (G_ACTION (simple), g_value_get_variant (value)); else /* this is the special case */ { /* only do it the first time. */ simple->priv->state_set = TRUE; /* blindly set it. */ simple->priv->state = g_value_dup_variant (value); } break; default: g_assert_not_reached (); } }
static gboolean actual_slide (gpointer user_data) { Action *slide_action = user_data; g_simple_action_set_state(G_SIMPLE_ACTION(slide_action->action), slide_action->value); g_message ("sliding %f", g_variant_get_double(slide_action->value)); free(slide_action); return FALSE; }
static void pref_playlist_shuffle_changed (GSettings *settings, const char *key, gpointer user_data) { GooApplication *application = user_data; g_simple_action_set_state (G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (application), PREF_PLAYLIST_SHUFFLE)), g_variant_new_boolean (g_settings_get_boolean (application->priv->settings, PREF_PLAYLIST_SHUFFLE))); update_actions_sensitivity (G_APPLICATION (application)); }
static void pref_view_sidebar_changed (GSettings *settings, const char *key, gpointer user_data) { GApplication *application = user_data; g_simple_action_set_state (GET_ACTION (PREF_UI_VIEW_SIDEBAR), g_variant_new_boolean (g_settings_get_boolean (settings, PREF_UI_VIEW_SIDEBAR))); update_app_menu_sensitivity (application); }
static void change_fullscreen_state (GSimpleAction *action, GVariant *state, gpointer user_data) { if (g_variant_get_boolean (state)) gtk_window_fullscreen (user_data); else gtk_window_unfullscreen (user_data); g_simple_action_set_state (action, state); }
static void action_set_active_bool (GActionGroup *group, const gchar *action_name, bool value) { g_assert (G_IS_ACTION_GROUP (group)); g_assert (G_IS_ACTION_MAP (group)); GAction *action = g_action_map_lookup_action (G_ACTION_MAP (group), action_name); if (action) { g_simple_action_set_state (G_SIMPLE_ACTION (action), g_variant_new_boolean (value)); } }
static void change_titlebar_state (GSimpleAction *action, GVariant *state, gpointer user_data) { GtkWindow *window = user_data; gtk_window_set_hide_titlebar_when_maximized (GTK_WINDOW (window), g_variant_get_boolean (state)); g_simple_action_set_state (action, state); }
static void fsearch_window_action_show_menubar (GSimpleAction *action, GVariant *variant, gpointer user_data) { FsearchApplicationWindow *self = user_data; g_simple_action_set_state (action, variant); GtkWidget *menubar = GTK_WIDGET (fsearch_application_window_get_menubar (self)); gtk_widget_set_visible (menubar, g_variant_get_boolean (variant)); FsearchConfig *config = fsearch_application_get_config (FSEARCH_APPLICATION_DEFAULT); config->show_menubar = g_variant_get_boolean (variant); }
static void pref_list_mode_changed (GSettings *settings, const char *key, gpointer user_data) { GApplication *application = user_data; g_simple_action_set_state (GET_ACTION (PREF_LISTING_LIST_MODE), g_variant_new_string (_g_enum_type_get_value (FR_TYPE_WINDOW_LIST_MODE, g_settings_get_enum (settings, PREF_LISTING_LIST_MODE))->value_nick)); update_app_menu_sensitivity (application); }
static void on_index_pane_toggle_action(GSimpleAction *action, GVariant *parameter, ReaderWindowPrivate *priv) { GVariant *action_state = g_action_get_state(G_ACTION(action)); gboolean active = !g_variant_get_boolean(action_state); g_simple_action_set_state(action, g_variant_new_boolean(active)); cainteoir_settings_set_boolean(priv->settings, "index", "visible", active); cainteoir_settings_save(priv->settings); reader_document_view_set_index_pane_visible(READER_DOCUMENT_VIEW(priv->view), active); }
static void gcal_application_changed_view (GSettings *settings, gchar *key, gpointer user_data) { GcalApplicationPrivate *priv; g_return_if_fail (GCAL_IS_APPLICATION (user_data)); priv = GCAL_APPLICATION (user_data)->priv; g_simple_action_set_state (priv->view, g_settings_get_value (priv->settings, "active-view")); }
void gth_browser_activate_show_thumbnail_list (GSimpleAction *action, GVariant *state, gpointer user_data) { GSettings *settings; g_simple_action_set_state (action, state); settings = g_settings_new (GTHUMB_BROWSER_SCHEMA); g_settings_set_boolean (settings, PREF_BROWSER_THUMBNAIL_LIST_VISIBLE, g_variant_get_boolean (state)); g_object_unref (settings); }
void gth_browser_activate_show_hidden_files (GSimpleAction *action, GVariant *state, gpointer user_data) { GSettings *settings; g_simple_action_set_state (action, state); settings = g_settings_new (GTHUMB_BROWSER_SCHEMA); g_settings_set_boolean (settings, PREF_BROWSER_SHOW_HIDDEN_FILES, g_variant_get_boolean (state)); g_object_unref (settings); }