PanelWidget * menu_get_panel (GtkWidget *menu) { PanelWidget *retval = NULL; g_return_val_if_fail (menu != NULL, NULL); if (GTK_IS_MENU_ITEM (menu)) menu = gtk_widget_get_parent (menu); g_return_val_if_fail (GTK_IS_MENU (menu), NULL); while (menu) { retval = g_object_get_data (G_OBJECT (menu), "menu_panel"); if (retval) break; menu = gtk_widget_get_parent (gtk_menu_get_attach_widget (GTK_MENU (menu))); if (!GTK_IS_MENU (menu)) break; } if (retval && !PANEL_IS_WIDGET (retval)) { g_warning ("Invalid PanelWidget associated with menu"); retval = NULL; } if (!retval) { g_warning ("Cannot find the PanelWidget associated with menu"); retval = panels->data; } return retval; }
static void serializer_visit (Serializer* self, GtkWidget* widget) { g_return_if_fail (self != NULL); g_return_if_fail (widget != NULL); if (GTK_IS_MENU_BAR (widget)) { GtkWidget* _tmp0_; serializer_visit_menubar (self, (_tmp0_ = widget, GTK_IS_MENU_BAR (_tmp0_) ? ((GtkMenuBar*) _tmp0_) : NULL)); } else { if (GTK_IS_MENU (widget)) { GtkWidget* _tmp1_; serializer_visit_menu (self, (_tmp1_ = widget, GTK_IS_MENU (_tmp1_) ? ((GtkMenu*) _tmp1_) : NULL)); } else { if (GTK_IS_MENU_ITEM (widget)) { GtkWidget* _tmp2_; serializer_visit_menuitem (self, (_tmp2_ = widget, GTK_IS_MENU_ITEM (_tmp2_) ? ((GtkMenuItem*) _tmp2_) : NULL)); } else { if (GTK_IS_LABEL (widget)) { GtkWidget* _tmp3_; serializer_visit_label (self, (_tmp3_ = widget, GTK_IS_LABEL (_tmp3_) ? ((GtkLabel*) _tmp3_) : NULL)); } else { if (GTK_IS_IMAGE (widget)) { GtkWidget* _tmp4_; serializer_visit_image (self, (_tmp4_ = widget, GTK_IS_IMAGE (_tmp4_) ? ((GtkImage*) _tmp4_) : NULL)); } else { if (GTK_IS_CONTAINER (widget)) { GtkWidget* _tmp5_; serializer_visit_container (self, (_tmp5_ = widget, GTK_IS_CONTAINER (_tmp5_) ? ((GtkContainer*) _tmp5_) : NULL)); } } } } } } }
static void menu_choice_activate (GtkWidget *item, gpointer data) { gpointer udata = gtk_object_get_user_data (GTK_OBJECT (item)); if (GTK_IS_MENU (current_popup_menu)) { gtk_object_set_data (GTK_OBJECT (current_popup_menu), "BstChoice", udata); if (modal_loop_quit_on_menu_item_activate) modal_loop_running = FALSE; } else /* current_popup_menu is not set e.g. for option menus */ { while (GTK_IS_MENU (item->parent)) { GtkWidget *tmp; item = item->parent; tmp = gtk_menu_get_attach_widget (GTK_MENU (item)); if (GTK_IS_MENU_ITEM (tmp)) item = tmp; } g_assert (GTK_IS_MENU (item)); gtk_object_set_data (GTK_OBJECT (item), "BstChoice", udata); } }
ui::Widget lookup_widget(ui::Widget widget, const gchar *widget_name ){ ui::Widget parent{ui::null}; for (;; ) { if ( GTK_IS_MENU( widget ) ) { parent = ui::Widget::from(gtk_menu_get_attach_widget( GTK_MENU( widget ) )); } else{ parent = ui::Widget::from(gtk_widget_get_parent(widget)); } if ( !parent ) { parent = ui::Widget::from(g_object_get_data( G_OBJECT( widget ), "GladeParentKey" )); } if ( parent == NULL ) { break; } widget = parent; } auto found_widget = ui::Widget::from(g_object_get_data( G_OBJECT( widget ), widget_name )); if ( !found_widget ) { g_warning( "Widget not found: %s", widget_name ); } return found_widget; }
void book_view_gtk_populate_menu (BookViewGtk *self, GtkWidget *menu) { g_return_if_fail (IS_BOOK_VIEW_GTK (self)); g_return_if_fail (GTK_IS_MENU (menu)); GtkTreeSelection *selection = NULL; GtkTreeModel *model = NULL; GtkTreeIter iter; Ekiga::Contact *contact = NULL; GtkWidget *item = NULL; MenuBuilderGtk builder (menu); self->priv->book->populate_menu (builder); selection = gtk_tree_view_get_selection (self->priv->tree_view); if (gtk_tree_selection_get_selected (selection, &model, &iter)) { gtk_tree_model_get (model, &iter, COLUMN_CONTACT_POINTER, &contact, -1); if (contact) { item = gtk_separator_menu_item_new (); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); contact->populate_menu (builder); } } }
static void gtk_tearoff_menu_item_parent_set (GtkWidget *widget, GtkWidget *previous) { GtkTearoffMenuItem *tearoff_menu_item = GTK_TEAROFF_MENU_ITEM (widget); GtkTearoffMenuItemPrivate *priv = tearoff_menu_item->priv; GtkMenu *menu; GtkWidget *parent; parent = gtk_widget_get_parent (widget); menu = GTK_IS_MENU (parent) ? GTK_MENU (parent) : NULL; if (previous) g_signal_handlers_disconnect_by_func (previous, tearoff_state_changed, tearoff_menu_item); if (menu) { priv->torn_off = gtk_menu_get_tearoff_state (menu); g_signal_connect (menu, "notify::tearoff-state", G_CALLBACK (tearoff_state_changed), tearoff_menu_item); } }
static void gtk_tearoff_menu_item_get_preferred_height (GtkWidget *widget, gint *minimum, gint *natural) { GtkStyleContext *context; GtkBorder padding; GtkStateFlags state; GtkWidget *parent; guint border_width; context = gtk_widget_get_style_context (widget); state = gtk_widget_get_state_flags (widget); gtk_style_context_get_padding (context, state, &padding); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); *minimum = *natural = (border_width * 2) + padding.top + padding.bottom; parent = gtk_widget_get_parent (widget); if (GTK_IS_MENU (parent) && gtk_menu_get_tearoff_state (GTK_MENU (parent))) { *minimum += ARROW_SIZE; *natural += ARROW_SIZE; } else { *minimum += padding.top + 4; *natural += padding.top + 4; } }
GtkWidget* lookup_widget (GtkWidget *widget, const gchar *widget_name) { GtkWidget *parent = 0, *found_widget = 0; if (widget) { for (;;) { if (GTK_IS_MENU (widget)) parent = gtk_menu_get_attach_widget (GTK_MENU (widget)); else parent = widget->parent; if (parent == NULL) break; widget = parent; } found_widget = (GtkWidget*) gtk_object_get_data (GTK_OBJECT (widget), widget_name); if (!found_widget) g_warning ("Widget not found: %s", widget_name); } else { g_warning ("Widget is NULL: %s", widget_name); } return found_widget; }
static void maybe_check_submenu_state (GtkMenuItem *menu_item, ThemeMatchData *match_data) { /* Distinguish between active and passive focus, depending on whether the * focus is in submenu. * * Active focus: * function = BOX * state = PRELIGHT * * Passive focus: * function = BOX * state = SELECTED */ if (menu_item->submenu) { GtkWidget *sub_item; sub_item = GTK_MENU_SHELL (menu_item->submenu)->active_menu_item; if (sub_item && gtk_widget_get_state (sub_item) != GTK_STATE_NORMAL) match_data->state = GTK_STATE_SELECTED; } /* This is a hack to cover the cases where a menu item is being * used outside the usual a GtkMenu. More specificaly, this covers * menu items inside the hildon-desktop custom menu widget. */ if (!GTK_IS_MENU (GTK_WIDGET (menu_item)->parent) && !gtk_widget_is_focus (GTK_WIDGET (menu_item)) && gtk_widget_get_state (GTK_WIDGET (menu_item)) != GTK_STATE_NORMAL) match_data->state = GTK_STATE_SELECTED; }
static void ppg_menu_tool_item_set_menu (PpgMenuToolItem *item, GtkMenu *menu) { PpgMenuToolItemPrivate *priv; g_return_if_fail(PPG_IS_MENU_TOOL_ITEM(item)); g_return_if_fail(!menu || GTK_IS_MENU(menu)); priv = item->priv; if (priv->menu) { g_signal_handler_disconnect(priv->menu, priv->menu_deactivate); priv->menu = NULL; priv->menu_deactivate = 0; } if (menu) { priv->menu = GTK_WIDGET(menu); priv->menu_deactivate = g_signal_connect(menu, "deactivate", G_CALLBACK(ppg_menu_tool_item_menu_deactivate), item); } }
static void adwaita_draw_box (GtkStyle * style, GdkWindow * window, GtkStateType state_type, GtkShadowType shadow_type, GdkRectangle * area, GtkWidget * widget, const gchar * detail, gint x, gint y, gint width, gint height) { if (GTK_IS_MENU (widget) && g_strcmp0 (detail, "menu") == 0 && wm_is_fallback ()) { cairo_t *cr = drawable_to_cairo (window, area); cairo_set_source_rgb (cr, 0.34, 0.34, 0.33); cairo_rectangle (cr, x, y, width, height); cairo_stroke (cr); cairo_destroy (cr); } else { GTK_STYLE_CLASS (adwaita_style_parent_class)->draw_box (style, window, state_type, shadow_type, area, widget, detail, x, y, width, height); } }
GtkWidget* lookup_widget (GtkWidget *widget, const gchar *widget_name) { GtkWidget *parent, *found_widget; GtkBuilder *builder; g_return_val_if_fail(widget != NULL, NULL); for (;;) { if (GTK_IS_MENU (widget)) parent = gtk_menu_get_attach_widget (GTK_MENU (widget)); else parent = widget->parent; if (parent == NULL) break; widget = parent; } builder = g_object_get_data (G_OBJECT (widget), "_sheet_dialogs_builder"); found_widget = GTK_WIDGET (gtk_builder_get_object (builder, widget_name)); /* not everything is under control of the builder, * e.g. "wrapbox_left" */ if (!found_widget) found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget), widget_name); if (!found_widget) g_warning (_("Widget not found: %s"), widget_name); return found_widget; }
GtkWidget* search_box_new (AnjutaDocman *docman) { SearchBox* search_box; AnjutaUI *ui; search_box = SEARCH_BOX (g_object_new (SEARCH_TYPE_BOX, "homogeneous", FALSE, NULL)); g_signal_connect (G_OBJECT (docman), "document-changed", G_CALLBACK (on_document_changed), search_box); search_box->priv->status = anjuta_shell_get_status (docman->shell, NULL); ui = anjuta_shell_get_ui (docman->shell, NULL); search_box->priv->popup_menu = gtk_ui_manager_get_widget (GTK_UI_MANAGER (ui), "/SearchboxPopup"); g_assert (search_box->priv->popup_menu != NULL && GTK_IS_MENU (search_box->priv->popup_menu)); search_box->priv->case_action = gtk_ui_manager_get_action (GTK_UI_MANAGER (ui), "/SearchboxPopup/CaseCheck"); search_box->priv->highlight_action = gtk_ui_manager_get_action (GTK_UI_MANAGER (ui), "/SearchboxPopup/HighlightAll"); search_box->priv->regex_action = gtk_ui_manager_get_action (GTK_UI_MANAGER (ui), "/SearchboxPopup/RegexSearch"); g_signal_connect (search_box->priv->popup_menu, "deactivate", G_CALLBACK (gtk_widget_hide), NULL); return GTK_WIDGET (search_box); }
void glade_gtk_menu_item_action_activate (GladeWidgetAdaptor * adaptor, GObject * object, const gchar * action_path) { GObject *obj = NULL, *shell = NULL; GladeWidget *w = glade_widget_get_from_gobject (object); while ((w = glade_widget_get_parent (w))) { obj = glade_widget_get_object (w); if (GTK_IS_MENU_SHELL (obj)) shell = obj; } if (strcmp (action_path, "launch_editor") == 0) { if (shell) object = shell; if (GTK_IS_MENU_BAR (object)) glade_gtk_menu_shell_launch_editor (object, _("Edit Menu Bar")); else if (GTK_IS_MENU (object)) glade_gtk_menu_shell_launch_editor (object, _("Edit Menu")); } else GWA_GET_CLASS (GTK_TYPE_CONTAINER)->action_activate (adaptor, object, action_path); if (shell) gtk_menu_shell_deactivate (GTK_MENU_SHELL (shell)); }
/** * eel_pop_up_context_menu: * * Pop up a context menu under the mouse. * The menu is sunk after use, so it will be destroyed unless the * caller first ref'ed it. * * This function is more of a helper function than a gtk extension, * so perhaps it belongs in a different file. * * @menu: The menu to pop up under the mouse. * @offset_x: Ignored. * @offset_y: Ignored. * @event: The event that invoked this popup menu, or #NULL if there * is no event available. This is used to get the timestamp for the menu's popup. * In case no event is provided, gtk_get_current_event_time() will be used automatically. **/ void eel_pop_up_context_menu (GtkMenu *menu, GdkEventButton *event) { int button; g_return_if_fail (GTK_IS_MENU (menu)); /* The event button needs to be 0 if we're popping up this menu from * a button release, else a 2nd click outside the menu with any button * other than the one that invoked the menu will be ignored (instead * of dismissing the menu). This is a subtle fragility of the GTK menu code. */ if (event) { button = event->type == GDK_BUTTON_RELEASE ? 0 : event->button; } else { button = 0; } gtk_menu_popup (menu, /* menu */ NULL, /* parent_menu_shell */ NULL, /* parent_menu_item */ NULL, /* popup_position_func */ NULL, /* popup_position_data */ button, /* button */ event ? event->time : gtk_get_current_event_time ()); /* activate_time */ g_object_ref_sink (menu); g_object_unref (menu); }
static void clearlooks_style_draw_check (DRAW_ARGS) { ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); WidgetParameters params; CheckboxParameters checkbox; cairo_t *cr; CHECK_ARGS SANITIZE_SIZE cr = ge_gdk_drawable_to_cairo (window, area); clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); params.corners = CR_CORNER_ALL; checkbox.shadow_type = shadow_type; checkbox.in_cell = DETAIL("cellcheck"); checkbox.in_menu = (widget && widget->parent && GTK_IS_MENU(widget->parent)); STYLE_FUNCTION(draw_checkbox) (cr, &clearlooks_style->colors, ¶ms, &checkbox, x, y, width, height); cairo_destroy (cr); }
/** Returns a widget from a name in a component, usually created by Glade. * Call it with the toplevel widget in the component (i.e. a window/dialog), * or alternatively any widget in the component, and the name of the widget * you want returned. * @param widget Widget with the @a widget_name property set. * @param widget_name Name to lookup. * @return The widget found. * @see ui_hookup_widget(). * */ GtkWidget *ui_lookup_widget(GtkWidget *widget, const gchar *widget_name) { GtkWidget *parent, *found_widget; g_return_val_if_fail(widget != NULL, NULL); g_return_val_if_fail(widget_name != NULL, NULL); for (;;) { if (GTK_IS_MENU(widget)) parent = gtk_menu_get_attach_widget(GTK_MENU(widget)); else parent = gtk_widget_get_parent(widget); if (parent == NULL) parent = (GtkWidget*) g_object_get_data(G_OBJECT(widget), "GladeParentKey"); if (parent == NULL) break; widget = parent; } found_widget = (GtkWidget*) g_object_get_data(G_OBJECT(widget), widget_name); if (G_UNLIKELY(found_widget == NULL)) g_warning("Widget not found: %s", widget_name); return found_widget; }
static gint menu_item_remove_gtk (GtkContainer *container, GtkWidget *widget) { GtkWidget *parent_widget; AtkObject *atk_parent; AtkObject *atk_child; GtkContainerAccessible *container_accessible; gint index; gint list_length; g_return_val_if_fail (GTK_IS_MENU (container), 1); parent_widget = gtk_menu_get_attach_widget (GTK_MENU (container)); if (GTK_IS_MENU_ITEM (parent_widget)) { atk_parent = gtk_widget_get_accessible (parent_widget); atk_child = gtk_widget_get_accessible (widget); g_object_notify (G_OBJECT (atk_child), "accessible-parent"); container_accessible = GTK_CONTAINER_ACCESSIBLE (atk_parent); index = g_list_index (container_accessible->children, widget); list_length = g_list_length (container_accessible->children); g_list_free (container_accessible->children); container_accessible->children = gtk_container_get_children (container); if (index >= 0 && index <= list_length) g_signal_emit_by_name (atk_parent, "children-changed::remove", index, atk_child, NULL); } return 1; }
static void clearlooks_style_draw_option (DRAW_ARGS) { const ClearlooksColors *colors; WidgetParameters params; CheckboxParameters checkbox; cairo_t *cr; ClearlooksStyle *clearlooks_style = CLEARLOOKS_STYLE (style); (void) detail; CHECK_ARGS SANITIZE_SIZE cr = ge_gdk_drawable_to_cairo (window, area); colors = &clearlooks_style->colors; checkbox.shadow_type = shadow_type; checkbox.in_menu = (widget && GTK_IS_MENU(widget->parent)); clearlooks_set_widget_parameters (widget, style, state_type, ¶ms); STYLE_FUNCTION(draw_radiobutton) (cr, colors, ¶ms, &checkbox, x, y, width, height); cairo_destroy (cr); }
GtkWidget* lookup_widget (GtkWidget *widget, const gchar *widget_name) { GtkWidget *parent, *found_widget; for (;;) { if (GTK_IS_MENU (widget)) parent = gtk_menu_get_attach_widget (GTK_MENU (widget)); else parent = widget->parent; if (!parent) parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey"); if (parent == NULL) break; widget = parent; } found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget), widget_name); if (!found_widget) g_warning ("Widget not found: %s", widget_name); return found_widget; }
static gboolean qtcMenuShellLeave(GtkWidget *widget, GdkEventCrossing *event, void *data) { QTC_UNUSED(data); QTC_UNUSED(event); if (GTK_IS_MENU_SHELL(widget) && GTK_IS_CONTAINER(widget)) { GList *children = gtk_container_get_children(GTK_CONTAINER(widget)); for (GList *child = children;child;child = g_list_next(child)) { if ((child->data) && GTK_IS_MENU_ITEM(child->data) && (gtk_widget_get_state(GTK_WIDGET(child->data)) != GTK_STATE_INSENSITIVE)) { GtkWidget *submenu = gtk_menu_item_get_submenu(GTK_MENU_ITEM(child->data)); GtkWidget *topLevel = submenu ? gtk_widget_get_toplevel(submenu) : NULL; if (submenu && ((!GTK_IS_MENU(submenu)) || (!(gtk_widget_get_realized(submenu) && gtk_widget_get_visible(submenu) && gtk_widget_get_realized(topLevel) && gtk_widget_get_visible(topLevel))))) { gtk_widget_set_state(GTK_WIDGET(child->data), GTK_STATE_NORMAL); } } } if (children) { g_list_free(children); } } return false; }
static void on_license_textview_populate_popup (GtkTextView *text_view, GtkWidget *popup, GladeProjectProperties *properties) { if (!GTK_IS_MENU (popup)) return; gpp_append_new_item (properties, popup, _("Clear text"), G_CALLBACK (on_clear_text_activate)); gpp_append_new_item (properties, popup, NULL, NULL); gpp_append_new_item (properties, popup, _("Insert GPL v2"), G_CALLBACK (on_gplv2_activate)); gpp_append_new_item (properties, popup, _("Insert GPL v3"), G_CALLBACK (on_gplv3_activate)); gpp_append_new_item (properties, popup, _("Insert LGPL v2.1"), G_CALLBACK (on_lgplv2_activate)); gpp_append_new_item (properties, popup, _("Insert LGPL v3"), G_CALLBACK (on_lgplv3_activate)); gpp_append_new_item (properties, popup, _("Insert BSD 2-clause"), G_CALLBACK (on_bsd2c_activate)); gpp_append_new_item (properties, popup, _("Insert BSD 3-clause"), G_CALLBACK (on_bsd3c_activate)); }
/***************************************************************************** * Useful function to retrieve p_intf ****************************************************************************/ void * E_(__GtkGetIntf)( GtkWidget * widget ) { void *p_data; if( GTK_IS_MENU_ITEM( widget ) ) { /* Look for a GTK_MENU */ while( widget->parent && !GTK_IS_MENU( widget ) ) { widget = widget->parent; } /* Maybe this one has the data */ p_data = gtk_object_get_data( GTK_OBJECT( widget ), "p_intf" ); if( p_data ) { return p_data; } /* Otherwise, the parent widget has it */ widget = gtk_menu_get_attach_widget( GTK_MENU( widget ) ); } /* We look for the top widget */ widget = gtk_widget_get_toplevel( GTK_WIDGET( widget ) ); p_data = gtk_object_get_data( GTK_OBJECT( widget ), "p_intf" ); return p_data; }
static gint my_popup_handler (GtkWidget *widget, GdkEvent *event) { GtkMenu *menu; GdkEventButton *event_button; g_return_val_if_fail (widget != NULL, FALSE); g_return_val_if_fail (GTK_IS_MENU (widget), FALSE); g_return_val_if_fail (event != NULL, FALSE); /* The "widget" is the menu that was supplied when * * g_signal_connect_swapped() was called. * */ menu = GTK_MENU (widget); if (event->type == GDK_BUTTON_PRESS) { event_button = (GdkEventButton *) event; if (event_button->button == 3) { gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event_button->button, event_button->time); return TRUE; } } return FALSE; }
gboolean glade_gtk_menu_tool_button_add_verify (GladeWidgetAdaptor *adaptor, GtkWidget *container, GtkWidget *child, gboolean user_feedback) { if (!GTK_IS_MENU (child)) { if (user_feedback) { GladeWidgetAdaptor *menu_adaptor = glade_widget_adaptor_get_by_type (GTK_TYPE_MENU); glade_util_ui_message (glade_app_get_window (), GLADE_UI_INFO, NULL, ONLY_THIS_GOES_IN_THAT_MSG, glade_widget_adaptor_get_title (menu_adaptor), glade_widget_adaptor_get_title (adaptor)); } return FALSE; } return TRUE; }
static void kill_popup_menu (GtkWidget *widget, GtkMenu *menu) { g_return_if_fail (menu != NULL); g_return_if_fail (GTK_IS_MENU (menu)); g_object_unref (G_OBJECT (menu)); }
static void gail_map_submenu_cb (GtkWidget *widget) { if (GTK_IS_MENU (widget)) { if (GTK_MENU (widget)->parent_menu_item) gail_finish_select (GTK_MENU (widget)->parent_menu_item); } }
void gb_menu_item_add_child (GtkWidget * widget, GtkWidget * child, GbWidgetSetArgData *data) { if (GTK_IS_MENU (child)) { MSG ("Trying to add a menu to a menu item"); gtk_menu_item_set_submenu (GTK_MENU_ITEM (widget), child); } }
static GtkWidget * action_ancestor (GtkWidget *widget) { if (GTK_IS_MENU (widget)) return gtk_menu_get_attach_widget (GTK_MENU (widget)); else if (GTK_IS_POPOVER (widget)) return gtk_popover_get_relative_to (GTK_POPOVER (widget)); else return gtk_widget_get_parent (widget); }
static void gb_option_menu_add_child (GtkWidget *widget, GtkWidget *child, GbWidgetSetArgData *data) { if (GTK_IS_MENU (child)) gtk_option_menu_set_menu (GTK_OPTION_MENU (widget), child); else g_warning (_("Cannot add a %s to a GtkOptionMenu."), g_type_name (G_OBJECT_TYPE (child))); }