static GtkWidget* ink_action_create_menu_item( GtkAction* action ) { InkAction* act = INK_ACTION( action ); GtkWidget* item = 0; if ( act->private_data->iconId ) { gchar* label = 0; g_object_get( G_OBJECT(act), "label", &label, NULL ); item = gtk_image_menu_item_new_with_mnemonic( label ); GtkWidget* child = sp_icon_new( Inkscape::ICON_SIZE_MENU, act->private_data->iconId ); // TODO this work-around is until SPIcon will live properly inside of a popup menu if ( SP_IS_ICON(child) ) { SPIcon* icon = SP_ICON(child); sp_icon_fetch_pixbuf( icon ); GdkPixbuf* target = icon->pb; if ( target ) { child = gtk_image_new_from_pixbuf( target ); gtk_widget_set_sensitive(child, gtk_action_is_sensitive(action)); gtk_widget_destroy( GTK_WIDGET(icon) ); } } gtk_widget_show_all( child ); gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(item), child ); g_free( label ); label = 0; } else { item = GTK_ACTION_CLASS(ink_action_parent_class)->create_menu_item( action ); } return item; }
static void gtk_switch_update (GtkActivatable *activatable, GtkAction *action, const gchar *property_name) { G_GNUC_BEGIN_IGNORE_DEPRECATIONS; if (strcmp (property_name, "visible") == 0) { if (gtk_action_is_visible (action)) gtk_widget_show (GTK_WIDGET (activatable)); else gtk_widget_hide (GTK_WIDGET (activatable)); } else if (strcmp (property_name, "sensitive") == 0) { gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action)); } else if (strcmp (property_name, "active") == 0) { gtk_action_block_activate (action); gtk_switch_set_active (GTK_SWITCH (activatable), gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))); gtk_action_unblock_activate (action); } G_GNUC_END_IGNORE_DEPRECATIONS; }
static gboolean caja_navigation_window_key_press_event (GtkWidget *widget, GdkEventKey *event) { CajaNavigationWindow *window; int i; window = CAJA_NAVIGATION_WINDOW (widget); for (i = 0; i < G_N_ELEMENTS (extra_navigation_window_keybindings); i++) { if (extra_navigation_window_keybindings[i].keyval == event->keyval) { GtkAction *action; action = gtk_action_group_get_action (window->details->navigation_action_group, extra_navigation_window_keybindings[i].action); g_assert (action != NULL); if (gtk_action_is_sensitive (action)) { gtk_action_activate (action); return TRUE; } break; } } return GTK_WIDGET_CLASS (caja_navigation_window_parent_class)->key_press_event (widget, event); }
static void gtk_tool_item_update (GtkActivatable *activatable, GtkAction *action, const gchar *property_name) { if (strcmp (property_name, "visible") == 0) { if (gtk_action_is_visible (action)) gtk_widget_show (GTK_WIDGET (activatable)); else gtk_widget_hide (GTK_WIDGET (activatable)); } else if (strcmp (property_name, "sensitive") == 0) gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action)); else if (strcmp (property_name, "tooltip") == 0) gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (activatable), gtk_action_get_tooltip (action)); else if (strcmp (property_name, "visible-horizontal") == 0) gtk_tool_item_set_visible_horizontal (GTK_TOOL_ITEM (activatable), gtk_action_get_visible_horizontal (action)); else if (strcmp (property_name, "visible-vertical") == 0) gtk_tool_item_set_visible_vertical (GTK_TOOL_ITEM (activatable), gtk_action_get_visible_vertical (action)); else if (strcmp (property_name, "is-important") == 0) gtk_tool_item_set_is_important (GTK_TOOL_ITEM (activatable), gtk_action_get_is_important (action)); }
/** * gtk_action_activate: * @action: the action object * * Emits the "activate" signal on the specified action, if it isn't * insensitive. This gets called by the proxy widgets when they get * activated. * * It can also be used to manually activate an action. * * Since: 2.4 */ void gtk_action_activate (GtkAction *action) { g_return_if_fail (GTK_IS_ACTION (action)); if (action->private_data->activate_blocked) return; if (gtk_action_is_sensitive (action)) _gtk_action_emit_activate (action); }
static void closure_accel_activate (GClosure *closure, GValue *return_value, guint n_param_values, const GValue *param_values, gpointer invocation_hint, gpointer marshal_data) { if (gtk_action_is_sensitive (GTK_ACTION (closure->data))) { _gtk_action_emit_activate (GTK_ACTION (closure->data)); /* we handled the accelerator */ g_value_set_boolean (return_value, TRUE); } }
static void gtk_switch_sync_action_properties (GtkActivatable *activatable, GtkAction *action) { if (!action) return; if (gtk_action_is_visible (action)) gtk_widget_show (GTK_WIDGET (activatable)); else gtk_widget_hide (GTK_WIDGET (activatable)); gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action)); gtk_action_block_activate (action); gtk_switch_set_active (GTK_SWITCH (activatable), gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action))); gtk_action_unblock_activate (action); }
/* Search all history actions which match "keyword" with function * match_func(action, keyword). * * @return a list of GtkAction*, to free with: * g_list_free_full (result, (GDestroyNotify) g_object_unref); */ GList * gimp_action_history_search (Gimp *gimp, GimpActionMatchFunc match_func, const gchar *keyword) { GimpGuiConfig *config; GimpUIManager *manager; GList *actions; GList *result = NULL; gint i; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (match_func != NULL, NULL); config = GIMP_GUI_CONFIG (gimp->config); manager = gimp_ui_managers_from_name ("<Image>")->data; for (actions = history.items, i = 0; actions && i < config->action_history_size; actions = g_list_next (actions), i++) { GimpActionHistoryItem *item = actions->data; GtkAction *action; action = gimp_ui_manager_find_action (manager, NULL, item->action_name); if (action == NULL) continue; if (! gtk_action_is_sensitive (action) && ! config->search_show_unavailable) continue; if (match_func (action, keyword, NULL, gimp)) result = g_list_prepend (result, g_object_ref (action)); } return g_list_reverse (result); }
static void gtk_tool_item_sync_action_properties (GtkActivatable *activatable, GtkAction *action) { if (!action) return; if (gtk_action_is_visible (action)) gtk_widget_show (GTK_WIDGET (activatable)); else gtk_widget_hide (GTK_WIDGET (activatable)); gtk_widget_set_sensitive (GTK_WIDGET (activatable), gtk_action_is_sensitive (action)); gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (activatable), gtk_action_get_tooltip (action)); gtk_tool_item_set_visible_horizontal (GTK_TOOL_ITEM (activatable), gtk_action_get_visible_horizontal (action)); gtk_tool_item_set_visible_vertical (GTK_TOOL_ITEM (activatable), gtk_action_get_visible_vertical (action)); gtk_tool_item_set_is_important (GTK_TOOL_ITEM (activatable), gtk_action_get_is_important (action)); }
gboolean update(ParasiteActionList *actionlist) { GSList *i; gtk_tree_store_clear(actionlist->priv->model); for (i = actionlist->priv->uimanagers; i != NULL; i = g_slist_next(i)) { GtkUIManager *uimanager; GList *action_groups; GList *j; gchar *name; uimanager = GTK_UI_MANAGER(i->data); GtkTreeIter i_iter; gtk_tree_store_append(actionlist->priv->model, &i_iter, NULL); name = g_strdup_printf("UIManager at %p", uimanager); gtk_tree_store_set(actionlist->priv->model, &i_iter, ACTION_LABEL, name, SORT_NAME, name, ADDRESS, uimanager, -1); g_free(name); action_groups = gtk_ui_manager_get_action_groups(uimanager); for (j = action_groups; j != NULL; j = g_list_next(j)) { GtkActionGroup *action_group; GtkTreeIter j_iter; GList *actions; GList *k; action_group = GTK_ACTION_GROUP(j->data); gtk_tree_store_append(actionlist->priv->model, &j_iter, &i_iter); name = (gchar*) gtk_action_group_get_name(action_group); gtk_tree_store_set(actionlist->priv->model, &j_iter, ACTION_LABEL, name, SORT_NAME, name, ROW_COLOR, gtk_action_group_get_sensitive(action_group) ? "black" : "grey", ADDRESS, action_group, -1); actions = gtk_action_group_list_actions(action_group); for (k = actions; k != NULL; k = g_list_next(k)) { GtkTreeIter k_iter; GtkAction *action; gchar *action_label; gchar *action_name; gchar *action_stock; gchar *sort_name; action = GTK_ACTION(k->data); g_object_get(action, "label", &action_label, "name", &action_name, "stock-id", &action_stock, NULL); sort_name = g_strdup_printf("%s%s", name, action_name); gtk_tree_store_append(actionlist->priv->model, &k_iter, &j_iter); // FIXME: format the mnemonic gtk_tree_store_set(actionlist->priv->model, &k_iter, ACTION_LABEL, action_label, ACTION_NAME, action_name, ACTION_ICON, action_stock, ROW_COLOR, gtk_action_is_sensitive(action) ? "black" : "grey", SORT_NAME, sort_name, ADDRESS, action, -1); g_free(sort_name); g_free(action_stock); g_free(action_name); g_free(action_label); } } } // FIXME: I'm undecided about this, but I also don't really want to try to // preserve the exsting expansion state of the whole tree. gtk_tree_view_expand_all(GTK_TREE_VIEW(actionlist)); actionlist->priv->update_timeout = 0; return FALSE; }
static VALUE rg_is_sensitive_p(VALUE self) { return CBOOL2RVAL(gtk_action_is_sensitive(_SELF(self))); }