static void action_set_enabled (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_enabled (G_SIMPLE_ACTION (action), value); } }
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 action_set (GActionGroup *group, const gchar *action_name, const gchar *first_param, ...) { GAction *action; va_list args; g_assert (G_IS_ACTION_GROUP (group)); g_assert (G_IS_ACTION_MAP (group)); action = g_action_map_lookup_action (G_ACTION_MAP (group), action_name); g_assert (G_IS_SIMPLE_ACTION (action)); va_start (args, first_param); g_object_set_valist (G_OBJECT (action), first_param, args); va_end (args); }
static void ide_editor_view_actions_source_view_notify (IdeSourceView *source_view, GParamSpec *pspec, GActionMap *actions) { g_autoptr(GVariant) param = NULL; GtkSourceView *gsv; GAction *action = NULL; g_assert (IDE_IS_SOURCE_VIEW (source_view)); g_assert (pspec != NULL); g_assert (G_IS_ACTION_MAP (actions)); gsv = GTK_SOURCE_VIEW (source_view); if (g_str_equal (pspec->name, "show-line-numbers")) { gboolean show_line_numbers; action = g_action_map_lookup_action (actions, "show-line-numbers"); show_line_numbers = gtk_source_view_get_show_line_numbers (gsv); param = g_variant_new_boolean (show_line_numbers); } else if (g_str_equal (pspec->name, "show-right-margin")) { gboolean show_right_margin; action = g_action_map_lookup_action (actions, "show-right-margin"); show_right_margin = gtk_source_view_get_show_right_margin (gsv); param = g_variant_new_boolean (show_right_margin); } else if (g_str_equal (pspec->name, "highlight-current-line")) { gboolean highlight_current_line; action = g_action_map_lookup_action (actions, "highlight-current-line"); g_object_get (gsv, "highlight-current-line", &highlight_current_line, NULL); param = g_variant_new_boolean (highlight_current_line); } else if (g_str_equal (pspec->name, "auto-indent")) { gboolean auto_indent; action = g_action_map_lookup_action (actions, "auto-indent"); g_object_get (source_view, "auto-indent", &auto_indent, NULL); param = g_variant_new_boolean (auto_indent); } else if (g_str_equal (pspec->name, "tab-width")) { guint tab_width; action = g_action_map_lookup_action (actions, "tab-width"); g_object_get (source_view, "tab-width", &tab_width, NULL); param = g_variant_new_int32 (tab_width); } else if (g_str_equal (pspec->name, "insert-spaces-instead-of-tabs")) { gboolean use_spaces; action = g_action_map_lookup_action (actions, "use-spaces"); g_object_get (source_view, "insert-spaces-instead-of-tabs", &use_spaces, NULL); param = g_variant_new_boolean (use_spaces); } else if (g_str_equal (pspec->name, "smart-backspace")) { gboolean smart_backspace; action = g_action_map_lookup_action (actions, "smart-backspace"); g_object_get (source_view, "smart-backspace", &smart_backspace, NULL); param = g_variant_new_boolean (smart_backspace); } if (action && param) { g_simple_action_set_state (G_SIMPLE_ACTION (action), param); param = NULL; } }