void fixup_labels( GObject *gobject, GParamSpec *arg1, gpointer user_data ) { /* TODO: handle 'use-markup' getting changed also */ if ( arg1 && arg1->name && (strcmp("label", arg1->name) == 0) ) { GSList* proxies = gtk_action_get_proxies( GTK_ACTION(gobject) ); gchar* str = 0; g_object_get( gobject, "label", &str, NULL ); (void)user_data; while ( proxies ) { if ( GTK_IS_TOOL_ITEM(proxies->data) ) { /* Search for the things we built up in create_tool_item() */ GList* children = gtk_container_get_children( GTK_CONTAINER(proxies->data) ); if ( children && children->data ) { if ( GTK_IS_HBOX(children->data) ) { children = gtk_container_get_children( GTK_CONTAINER(children->data) ); if ( children && g_list_next(children) ) { GtkWidget* child = GTK_WIDGET( g_list_next(children)->data ); if ( GTK_IS_LABEL(child) ) { GtkLabel* lbl = GTK_LABEL(child); if ( EGE_OUTPUT_ACTION(gobject)->private_data->useMarkup ) { gtk_label_set_markup( lbl, str ); } else { gtk_label_set_text( lbl, str ); } } } } } } proxies = g_slist_next( proxies ); } g_free( str ); } }
static void ink_toggle_action_update_icon( InkToggleAction* action ) { if ( action ) { GSList* proxies = gtk_action_get_proxies( GTK_ACTION(action) ); while ( proxies ) { if ( GTK_IS_TOOL_ITEM(proxies->data) ) { if ( GTK_IS_TOOL_BUTTON(proxies->data) ) { GtkToolButton* button = GTK_TOOL_BUTTON(proxies->data); GtkWidget* child = sp_icon_new( action->private_data->iconSize, action->private_data->iconId ); #if GTK_CHECK_VERSION(3,0,0) gtk_widget_set_hexpand(child, FALSE); gtk_widget_set_vexpand(child, FALSE); gtk_widget_show_all(child); gtk_tool_button_set_icon_widget(button, child); #else GtkWidget* align = gtk_alignment_new( 0.5, 0.5, 0.0, 0.0 ); gtk_container_add( GTK_CONTAINER(align), child ); gtk_widget_show_all( align ); gtk_tool_button_set_icon_widget( button, align ); #endif } } proxies = g_slist_next( proxies ); } } }
static void gimp_action_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { GimpAction *action = GIMP_ACTION (object); gboolean set_proxy = FALSE; switch (prop_id) { case PROP_CONTEXT: if (action->context) g_object_unref (action->context); action->context = g_value_dup_object (value); break; case PROP_COLOR: if (action->color) g_free (action->color); action->color = g_value_dup_boxed (value); set_proxy = TRUE; break; case PROP_VIEWABLE: if (action->viewable) g_object_unref (action->viewable); action->viewable = g_value_dup_object (value); set_proxy = TRUE; break; case PROP_ELLIPSIZE: action->ellipsize = g_value_get_enum (value); set_proxy = TRUE; break; case PROP_MAX_WIDTH_CHARS: action->max_width_chars = g_value_get_int (value); set_proxy = TRUE; break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } if (set_proxy) { GSList *list; for (list = gtk_action_get_proxies (GTK_ACTION (action)); list; list = g_slist_next (list)) { gimp_action_set_proxy (action, list->data); } } }
void on_empty_trash(GtkAction* act, gpointer user_data) { /* FIXME: This is very dirty, but it's inevitable. :-( */ GSList* proxies = gtk_action_get_proxies(act); GtkWidget* menu_item = proxies->data ? GTK_WIDGET(proxies->data) : NULL; GtkWidget* menu = gtk_widget_get_parent(menu_item); GtkWidget* view = gtk_menu_get_attach_widget(GTK_MENU(menu)); fm_empty_trash(view ? GTK_WINDOW(gtk_widget_get_toplevel(view)) : NULL); }
/** Since Gtk+ 2.6 you cannot press a button twice, without moving the * mouse. */ void action_set_sensitive(GtkAction * action, gboolean sensitive) { GSList *widgets; widgets = gtk_action_get_proxies(action); while (widgets) { widget_set_sensitive(GTK_WIDGET(widgets->data), sensitive); widgets = g_slist_next(widgets); } gtk_action_set_sensitive(action, sensitive); }
static void action_mark(void *p) { GtkAction *action; GSList *node; action = GTK_ACTION(p); for (node = gtk_action_get_proxies(action); node; node = g_slist_next(node)) { GtkWidget *proxy = node->data; rbgobj_gc_mark_instance(proxy); } }
static void gimp_action_tooltip_notify (GimpAction *action, const GParamSpec *pspec, gpointer data) { GSList *list; for (list = gtk_action_get_proxies (GTK_ACTION (action)); list; list = g_slist_next (list)) { gimp_action_set_proxy_tooltip (action, list->data); } }
gboolean go_action_combo_pixmaps_select_id (GOActionComboPixmaps *paction, int id) { gboolean res = TRUE; GSList *ptr = gtk_action_get_proxies (GTK_ACTION (paction)); paction->selected_id = id; for ( ; ptr != NULL ; ptr = ptr->next) if (GO_IS_TOOL_COMBO_PIXMAPS (ptr->data)) res |= go_combo_pixmaps_select_id ( GO_TOOL_COMBO_PIXMAPS (ptr->data)->combo, id); return res; }
static void sync_proxies_use_underline (gpointer action, gboolean use_underline) { GSList *proxies; proxies = g_slist_copy (gtk_action_get_proxies (GTK_ACTION (action))); g_slist_foreach (proxies, (GFunc) g_object_ref, NULL); while (proxies) { proxy_set_use_underline (GTK_WIDGET (proxies->data), use_underline); g_object_unref (proxies->data); proxies = g_slist_delete_link (proxies, proxies); } }
/* Helper function to get the toplevel window that contains the action's proxy, in case it wasn't passed as a user data parameter to the action callback. */ static GtkWindow * get_toplevel_for_action(GtkAction *action) { GSList *list; GtkWidget *parent = NULL; for(list = gtk_action_get_proxies(action) ; list; list = g_slist_next(list)) { GtkWidget *toplevel = gtk_widget_get_toplevel((GtkWidget *)list->data); if(GTK_IS_MENU(toplevel)) toplevel = gtk_widget_get_toplevel(gtk_menu_get_attach_widget(GTK_MENU(toplevel))); if(toplevel && gtk_widget_is_toplevel(toplevel)) { parent = toplevel; break; } } return GTK_WINDOW(parent); }
static void cb_selection_changed (GOComboPixmaps *combo, int id, GOActionComboPixmaps *paction) { GSList *ptr; if (paction->updating_proxies) return; paction->selected_id = id; paction->updating_proxies = TRUE; ptr = gtk_action_get_proxies (GTK_ACTION (paction)); for ( ; ptr != NULL ; ptr = ptr->next) if (GO_IS_COMBO_PIXMAPS (ptr->data) && go_combo_pixmaps_get_selected (ptr->data, NULL) != id) go_combo_pixmaps_select_id (ptr->data, id); paction->updating_proxies = FALSE; g_signal_emit_by_name (G_OBJECT (paction), "combo-activate"); gtk_action_activate (GTK_ACTION (paction)); }
static void ink_toggle_action_update_icon( InkToggleAction* action ) { if ( action ) { GSList* proxies = gtk_action_get_proxies( GTK_ACTION(action) ); while ( proxies ) { if ( GTK_IS_TOOL_ITEM(proxies->data) ) { if ( GTK_IS_TOOL_BUTTON(proxies->data) ) { GtkToolButton* button = GTK_TOOL_BUTTON(proxies->data); GtkWidget* child = sp_icon_new( action->private_data->iconSize, action->private_data->iconId ); gtk_widget_show_all( child ); gtk_tool_button_set_icon_widget( button, child ); } } proxies = g_slist_next( proxies ); } } }
void shell_action_set_active(const gchar *action_name, gboolean setting) { GtkAction *action; GSList *proxies; /* FIXME: Ugh. Are you sure there isn't any simpler way? O_o */ action = gtk_action_group_get_action(shell->action_group, action_name); if (action) { proxies = gtk_action_get_proxies(action); for (; proxies; proxies = proxies->next) { GtkWidget *widget = (GtkWidget *)proxies->data; if (GTK_IS_CHECK_MENU_ITEM(widget)) { gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(widget), setting); return; } } } }
static void button_press_cb (GtkWidget *button, GdkEventButton *event, EphyPageMenuAction *action) { GtkWidget *menu; EphyWindow *window; GtkUIManager *manager; guint event_button = 1; guint32 event_time = 0; if (!button) { GSList *l = gtk_action_get_proxies (GTK_ACTION (action)); if (GTK_IS_BUTTON (l->data)) button = GTK_WIDGET (l->data); } g_return_if_fail (GTK_IS_BUTTON (button)); if (!action->priv->menu) { window = ephy_window_action_get_window (EPHY_WINDOW_ACTION (action)); manager = ephy_window_get_ui_manager (window); menu = gtk_ui_manager_get_widget (manager, "/ui/PagePopup"); g_signal_connect (menu, "notify::visible", G_CALLBACK (visible_cb), button); action->priv->menu = g_object_ref (menu); action->priv->button = g_object_ref (button); } if (event) { event_button = event->button; event_time = event->time; } gtk_menu_popup (GTK_MENU (action->priv->menu), NULL, NULL, (GtkMenuPositionFunc)menu_position_func, button, event_button, event_time); }
static void _create_mac_integration (void) { GtkosxApplication *theOsxApp = g_object_new(GTKOSX_TYPE_APPLICATION, NULL); GtkWidget *menubar = NULL; /* from control-x to command-x in one call? Does _not_ work as advertized */ gtkosx_application_set_use_quartz_accelerators (theOsxApp, TRUE); /* might be too early ... */ menus_get_integrated_ui_menubar (&menubar, NULL, NULL); if (menubar) { gtk_widget_hide (menubar); /* not working, it's shown elsewhere */ /* move some items to the dia menu */ { GSList *proxies, *proxy; GtkAction *action; action = menus_get_action ("HelpAbout"); proxies = gtk_action_get_proxies (action); for (proxy = proxies; proxy != NULL; proxy = g_slist_next (proxy)) { g_print ("XXX "); if (1 || GTK_IS_MENU_ITEM (proxy->data)) { gtkosx_application_insert_app_menu_item (theOsxApp, GTK_WIDGET (proxy->data), 0); break; } } } /* hijack the menubar */ gtkosx_application_set_menu_bar(theOsxApp, GTK_MENU_SHELL(menubar)); /* setup the dock icon */ gtkosx_application_set_dock_icon_pixbuf (theOsxApp, gdk_pixbuf_new_from_inline (-1, dia_app_icon, FALSE, NULL)); } /* without this all the above wont have any effect */ gtkosx_application_ready(theOsxApp); }
void stickynotes_applet_update_menus(void) { GList *l; gboolean inconsistent = FALSE; gboolean locked = gconf_client_get_bool(stickynotes->gconf, GCONF_PATH "/settings/locked", NULL); gboolean locked_writable = gconf_client_key_is_writable(stickynotes->gconf, GCONF_PATH "/settings/locked", NULL); for (l = stickynotes->notes; l != NULL; l = l->next) { StickyNote *note = l->data; if (note->locked != locked) { inconsistent = TRUE; break; } } for (l = stickynotes->applets; l != NULL; l = l->next) { StickyNotesApplet *applet = l->data; GSList *proxies, *p; GtkAction *action = gtk_action_group_get_action (applet->action_group, "lock"); g_object_set (action, "active", locked, "sensitive", locked_writable, NULL); proxies = gtk_action_get_proxies (action); for (p = proxies; p; p = g_slist_next (p)) { if (GTK_IS_CHECK_MENU_ITEM (p->data)) { gtk_check_menu_item_set_inconsistent (GTK_CHECK_MENU_ITEM (p->data), inconsistent); } } } }
/* Helper for gtkhtml_editor_update_context() */ static void editor_spell_checkers_foreach (GtkhtmlSpellChecker *checker, GtkhtmlEditor *editor) { const GtkhtmlSpellLanguage *language; const gchar *language_code; GtkActionGroup *action_group; GtkUIManager *manager; GtkHTML *html; GList *list; gchar *path; gchar *word; gint count = 0; guint merge_id; language = gtkhtml_spell_checker_get_language (checker); language_code = gtkhtml_spell_language_get_code (language); html = gtkhtml_editor_get_html (editor); word = html_engine_get_spell_word (html->engine); list = gtkhtml_spell_checker_get_suggestions (checker, word, -1); manager = gtkhtml_editor_get_ui_manager (editor); action_group = editor->priv->suggestion_actions; merge_id = editor->priv->spell_suggestions_merge_id; path = g_strdup_printf ( "/context-menu/context-spell-suggest/" "context-spell-suggest-%s-menu", language_code); while (list != NULL) { gchar *suggestion = list->data; gchar *action_name; gchar *action_label; GtkAction *action; GtkWidget *child; GSList *proxies; /* Action name just needs to be unique. */ action_name = g_strdup_printf ( "suggest-%s-%d", language_code, count++); action_label = g_markup_printf_escaped ( "<b>%s</b>", suggestion); action = gtk_action_new ( action_name, action_label, NULL, NULL); g_object_set_data_full ( G_OBJECT (action), "word", g_strdup (suggestion), g_free); g_signal_connect ( action, "activate", G_CALLBACK ( action_context_spell_suggest_cb), editor); gtk_action_group_add_action (action_group, action); gtk_ui_manager_add_ui ( manager, merge_id, path, action_name, action_name, GTK_UI_MANAGER_AUTO, FALSE); /* XXX GtkAction offers no supports for Pango markup, * so we have to manually set "use-markup" on the * child of the proxy widget. */ gtk_ui_manager_ensure_update (manager); proxies = gtk_action_get_proxies (action); child = gtk_bin_get_child (proxies->data); g_object_set (child, "use-markup", TRUE, NULL); g_free (suggestion); g_free (action_name); g_free (action_label); list = g_list_delete_link (list, list); } g_free (path); g_free (word); }
static void editor_inline_spelling_suggestions (GtkhtmlEditor *editor, GtkhtmlSpellChecker *checker) { GtkActionGroup *action_group; GtkUIManager *manager; GtkHTML *html; GList *list; const gchar *path; gchar *word; guint count = 0; guint length; guint merge_id; guint threshold; html = gtkhtml_editor_get_html (editor); word = html_engine_get_spell_word (html->engine); list = gtkhtml_spell_checker_get_suggestions (checker, word, -1); path = "/context-menu/context-spell-suggest/"; manager = gtkhtml_editor_get_ui_manager (editor); action_group = editor->priv->suggestion_actions; merge_id = editor->priv->spell_suggestions_merge_id; /* Calculate how many suggestions to put directly in the * context menu. The rest will go in a secondary menu. */ length = g_list_length (list); if (length <= MAX_LEVEL1_SUGGESTIONS) threshold = length; else if (length - MAX_LEVEL1_SUGGESTIONS < MIN_LEVEL2_SUGGESTIONS) threshold = length; else threshold = MAX_LEVEL1_SUGGESTIONS; while (list != NULL) { gchar *suggestion = list->data; gchar *action_name; gchar *action_label; GtkAction *action; GtkWidget *child; GSList *proxies; /* Once we reach the threshold, put all subsequent * spelling suggestions in a secondary menu. */ if (count == threshold) path = "/context-menu/context-more-suggestions-menu/"; /* Action name just needs to be unique. */ action_name = g_strdup_printf ("suggest-%d", count++); action_label = g_markup_printf_escaped ( "<b>%s</b>", suggestion); action = gtk_action_new ( action_name, action_label, NULL, NULL); g_object_set_data_full ( G_OBJECT (action), "word", g_strdup (suggestion), g_free); g_signal_connect ( action, "activate", G_CALLBACK ( action_context_spell_suggest_cb), editor); gtk_action_group_add_action (action_group, action); gtk_ui_manager_add_ui ( manager, merge_id, path, action_name, action_name, GTK_UI_MANAGER_AUTO, FALSE); /* XXX GtkAction offers no support for Pango markup, * so we have to manually set "use-markup" on the * child of the proxy widget. */ gtk_ui_manager_ensure_update (manager); proxies = gtk_action_get_proxies (action); child = gtk_bin_get_child (proxies->data); g_object_set (child, "use-markup", TRUE, NULL); g_free (suggestion); g_free (action_name); g_free (action_label); list = g_list_delete_link (list, list); } g_free (word); }
static VALUE rg_proxies(VALUE self) { return GOBJGSLIST2RVAL(gtk_action_get_proxies(_SELF(self))); }
static VALUE rg_proxies(VALUE self) { /* Owned by GTK+ */ return GSLIST2ARY(gtk_action_get_proxies(_SELF(self))); }
void connect_proxy( GtkAction *action, GtkWidget *proxy ) { GTK_ACTION_CLASS(ege_select_one_action_parent_class)->connect_proxy( action, proxy ); } void disconnect_proxy( GtkAction *action, GtkWidget *proxy ) { GTK_ACTION_CLASS(ege_select_one_action_parent_class)->disconnect_proxy( action, proxy ); } void resync_active( EgeSelectOneAction* act, gint active, gboolean override ) { if ( override || (act->private_data->active != active) ) { act->private_data->active = active; GSList* proxies = gtk_action_get_proxies( GTK_ACTION(act) ); while ( proxies ) { if ( GTK_IS_TOOL_ITEM(proxies->data) ) { /* Search for the things we built up in create_tool_item() */ GList* children = gtk_container_get_children( GTK_CONTAINER(proxies->data) ); if ( children && children->data ) { gpointer combodata = g_object_get_data( G_OBJECT(children->data), "ege-combo-box" ); #if !GTK_CHECK_VERSION(3,0,0) if (!combodata && GTK_IS_ALIGNMENT(children->data)) { GList *other = gtk_container_get_children( GTK_CONTAINER(children->data) ); combodata = g_object_get_data( G_OBJECT(other->data), "ege-combo-box" ); } #endif if ( GTK_IS_COMBO_BOX(combodata) ) {