From 545b40a1b306cf2603d2a845eda320624e901683 Mon Sep 17 00:00:00 2001 From: Soeren Sandmann Date: Fri, 29 Aug 2003 18:28:23 +0000 Subject: Only treat buttons as homogeneous when they are narrower than 13 time the Fri Aug 29 20:32:07 2003 Soeren Sandmann * gtk/gtktoolbar.c: Only treat buttons as homogeneous when they are narrower than 13 time the estimated character width of the font. (#107781, David Bordoley) * gtk/gtktoggletoolbutton.c (gtk_toggle_tool_button_init): Check here if the GtkToggleButton is active. This may be the case if it is a radio button. * gtk/gtktoolbar.c: Clarify documentation wrt. GtkSignalFunc vs. void (*) (GtkWidget, gpointer). (#107495, Mariano Suarez-Alvarez). * gtk/gtkcheckmenuitem.[ch]: new "draw_as_radio" property. (#111207, David Bordoley). * gtk/gtktoggletoolbutton.c (gtk_toggle_tool_button_create_menu_proxy): use new "draw_as_radio" property on the menu item when the item is a radio tool button * gtk/gtktoolbutton.c (gtk_tool_button_create_menu_proxy): Fixes to only pay attention to the "use_underline" property when the button label comes from the "label" property. --- gtk/gtktoggletoolbutton.c | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'gtk/gtktoggletoolbutton.c') diff --git a/gtk/gtktoggletoolbutton.c b/gtk/gtktoggletoolbutton.c index 81f7d61032..02c076feed 100644 --- a/gtk/gtktoggletoolbutton.c +++ b/gtk/gtktoggletoolbutton.c @@ -25,6 +25,7 @@ #include "gtktogglebutton.h" #include "gtkstock.h" #include "gtkintl.h" +#include "gtkradiotoolbutton.h" #define MENU_ID "gtk-toggle-tool-button-menu-id" @@ -115,9 +116,17 @@ gtk_toggle_tool_button_class_init (GtkToggleToolButtonClass *klass) static void gtk_toggle_tool_button_init (GtkToggleToolButton *button) { + GtkToolButton *tool_button = GTK_TOOL_BUTTON (button); + GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (_gtk_tool_button_get_button (tool_button)); + button->priv = GTK_TOGGLE_TOOL_BUTTON_GET_PRIVATE (button); - - g_signal_connect_object (_gtk_tool_button_get_button (GTK_TOOL_BUTTON (button)), + + /* If the real button is a radio button, it may have been + * active at the time it was created. + */ + button->priv->active = gtk_toggle_button_get_active (toggle_button); + + g_signal_connect_object (toggle_button, "toggled", G_CALLBACK (button_toggled), button, 0); } @@ -129,24 +138,30 @@ gtk_toggle_tool_button_create_menu_proxy (GtkToolItem *item) GtkWidget *menu_item = NULL; GtkStockItem stock_item; gboolean use_mnemonic = TRUE; - const char *label = ""; + const char *label; GtkWidget *label_widget = gtk_tool_button_get_label_widget (tool_button); const gchar *label_text = gtk_tool_button_get_label (tool_button); - gboolean use_underline = gtk_tool_button_get_use_underline (tool_button); const gchar *stock_id = gtk_tool_button_get_stock_id (tool_button); if (label_widget && GTK_IS_LABEL (label_widget)) { label = gtk_label_get_label (GTK_LABEL (label_widget)); + use_mnemonic = gtk_label_get_use_underline (GTK_LABEL (label_widget)); } else if (label_text) { label = label_text; - use_mnemonic = use_underline; + use_mnemonic = gtk_tool_button_get_use_underline (tool_button); } else if (stock_id && gtk_stock_lookup (stock_id, &stock_item)) - label = stock_item.label; + { + label = stock_item.label; + } + else + { + label = ""; + } if (use_mnemonic) menu_item = gtk_check_menu_item_new_with_mnemonic (label); @@ -156,6 +171,12 @@ gtk_toggle_tool_button_create_menu_proxy (GtkToolItem *item) gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), toggle_tool_button->priv->active); + if (GTK_IS_RADIO_TOOL_BUTTON (toggle_tool_button)) + { + gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (menu_item), + TRUE); + } + g_signal_connect_closure_by_id (menu_item, g_signal_lookup ("activate", G_OBJECT_TYPE (menu_item)), 0, g_cclosure_new_object (G_CALLBACK (menu_item_activated), -- cgit v1.2.1