Re: gtktoolbar - packed with invisible widgets ...



Hi Soeren,

On Tue, 2004-02-17 at 21:05, Soeren Sandmann wrote:
> The item_area *is* offset by x/ythickness. And if the bug was as you
> said, _no_ items at all would ever show up, which clearly isn't the
> case.

	You're quite right; now I compile / look at the code the real problem
is the preferred_width/height properties which are so important.
Currently I'm having to have this large mess that does:

	if (!toolbar->got_size) {
		gboolean show_arrow;

		toolbar->got_size = TRUE;

		show_arrow = gtk_toolbar_get_show_arrow (toolbar);
		if (show_arrow) /* Not an elegant approach, sigh. */
			g_object_set (toolbar, "show_arrow",
				      FALSE, NULL);
		gtk_widget_size_request (GTK_WIDGET (toolbar),
					 &toolbar->full_size);

		if (show_arrow)
			g_object_set(toolbar, "show_arrow", TRUE, NULL);
	}

	Which is just lovely. This is for the reasons stated previously; that
with 2 toolbars in a dock band we have to have true-width data to lay
them out correctly.

> If you aren't using CVS HEAD, and libbonoboui is still calling
> gtk_container_set_border_width() on the toolbars, then you are seeing

	No; using CVS HEAD, just relying on a rather misleading description of
the bug and a rather too quick code-read.

	While questing for the reason why when I set my GtkToolItem insensitive
- the popup/menu item remains sensitive (urk), I read the toggletool and
toolbutton item's _create_menu_proxy code which is depressingly
cut/paste - I guess unavoidably so.

	Anyhow - I was wondering, is gtk_tool_item_set_proxy_menu_item the
right place to sort out state-synchronization wrt. insensitivity from
toolitem -> menuitem ? and/or how about other state synchronisation.
And/or may I commit this ? Also, may I commit the testtoolbar changes
that add an insensitive item and split down the large options hbox
making it difficult to test the pop-down ?

	Thanks,

		Michael.

-- 
 michael ximian com  <><, Pseudo Engineer, itinerant idiot
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gtk+/ChangeLog,v
retrieving revision 1.4968
diff -u -p -u -r1.4968 ChangeLog
--- ChangeLog	20 Feb 2004 07:52:52 -0000	1.4968
+++ ChangeLog	20 Feb 2004 12:03:11 -0000
@@ -1,3 +1,9 @@
+2004-02-20  Michael Meeks  <michael ximian com>
+
+	* gtk/gtktoolitem.c (sync_sensitive): transfer sensitivity.
+	(gtk_tool_item_set_proxy_menu_item): connect to sensitive property
+	notifications.
+
 2004-02-20  Alexander Larsson  <alexl redhat com>
 
 	* gtk/gtkfilechooserdefault.c: (shortcuts_append_desktop):
Index: gtk/gtktoolitem.c
===================================================================
RCS file: /cvs/gnome/gtk+/gtk/gtktoolitem.c,v
retrieving revision 1.19
diff -u -p -u -r1.19 gtktoolitem.c
--- gtk/gtktoolitem.c	17 Jan 2004 11:58:24 -0000	1.19
+++ gtk/gtktoolitem.c	20 Feb 2004 12:03:12 -0000
@@ -1024,6 +1024,16 @@ gtk_tool_item_get_proxy_menu_item (GtkTo
   return NULL;
 }
 
+static void
+sync_sensitive (GtkWidget  *tool_item,
+		GParamSpec *pspec,
+		GtkWidget  *menu_item)
+{
+  gtk_widget_set_sensitive (menu_item,
+			    GTK_WIDGET_SENSITIVE (tool_item));
+}
+
+
 /**
  * gtk_tool_item_set_proxy_menu_item:
  * @tool_item: a #GtkToolItem:
@@ -1059,6 +1069,10 @@ gtk_tool_item_set_proxy_menu_item (GtkTo
 	{
 	  g_object_ref (menu_item);
 	  gtk_object_sink (GTK_OBJECT (menu_item));
+
+	  sync_sensitive (GTK_WIDGET (tool_item), NULL, menu_item);
+	  g_signal_connect_object (tool_item, "notify:sensitive",
+				   G_CALLBACK (sync_sensitive), menu_item, 0);
 	}
       
       tool_item->priv->menu_item = menu_item;
Index: tests/testtoolbar.c
===================================================================
RCS file: /cvs/gnome/gtk+/tests/testtoolbar.c,v
retrieving revision 1.12
diff -u -p -u -r1.12 testtoolbar.c
--- tests/testtoolbar.c	31 Oct 2003 02:10:03 -0000	1.12
+++ tests/testtoolbar.c	20 Feb 2004 12:21:07 -0000
@@ -479,7 +479,7 @@ gint
 main (gint argc, gchar **argv)
 {
   GtkWidget *window, *toolbar, *table, *treeview, *scrolled_window;
-  GtkWidget *hbox, *checkbox, *option_menu, *menu;
+  GtkWidget *hbox, *hbox1, *hbox2, *checkbox, *option_menu, *menu;
   gint i;
   static const gchar *toolbar_styles[] = { "icons", "text", "both (vertical)",
 					   "both (horizontal)" };
@@ -504,25 +504,30 @@ main (gint argc, gchar **argv)
   gtk_table_attach (GTK_TABLE (table), toolbar,
 		    0,2, 0,1, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
 
-  hbox = gtk_hbox_new (FALSE, 5);
-  gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
-  gtk_table_attach (GTK_TABLE (table), hbox,
+  hbox1 = gtk_hbox_new (FALSE, 3);
+  gtk_container_set_border_width (GTK_CONTAINER (hbox1), 5);
+  gtk_table_attach (GTK_TABLE (table), hbox1,
 		    1,2, 1,2, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
 
+  hbox2 = gtk_hbox_new (FALSE, 2);
+  gtk_container_set_border_width (GTK_CONTAINER (hbox2), 5);
+  gtk_table_attach (GTK_TABLE (table), hbox2,
+		    1,2, 2,3, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
+
   checkbox = gtk_check_button_new_with_mnemonic("_Vertical");
-  gtk_box_pack_start (GTK_BOX (hbox), checkbox, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (hbox1), checkbox, FALSE, FALSE, 0);
   g_signal_connect (checkbox, "toggled",
 		    G_CALLBACK (change_orientation), toolbar);
 
   checkbox = gtk_check_button_new_with_mnemonic("_Show Arrow");
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (checkbox), TRUE);
-  gtk_box_pack_start (GTK_BOX (hbox), checkbox, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (hbox1), checkbox, FALSE, FALSE, 0);
   g_signal_connect (checkbox, "toggled",
 		    G_CALLBACK (change_show_arrow), toolbar);
 
   checkbox = gtk_check_button_new_with_mnemonic("_Set Toolbar Style:");
   g_signal_connect (checkbox, "toggled", G_CALLBACK (set_toolbar_style_toggled), toolbar);
-  gtk_box_pack_start (GTK_BOX (hbox), checkbox, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (hbox1), checkbox, FALSE, FALSE, 0);
   
   option_menu = gtk_option_menu_new();
   gtk_widget_set_sensitive (option_menu, FALSE);  
@@ -540,13 +545,13 @@ main (gint argc, gchar **argv)
   gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
   gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu),
 			       GTK_TOOLBAR (toolbar)->style);
-  gtk_box_pack_start (GTK_BOX (hbox), option_menu, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (hbox2), option_menu, FALSE, FALSE, 0);
   g_signal_connect (option_menu, "changed",
 		    G_CALLBACK (change_toolbar_style), toolbar);
 
   checkbox = gtk_check_button_new_with_mnemonic("_Set Icon Size:"); 
   g_signal_connect (checkbox, "toggled", G_CALLBACK (set_icon_size_toggled), toolbar);
-  gtk_box_pack_start (GTK_BOX (hbox), checkbox, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (hbox2), checkbox, FALSE, FALSE, 0);
 
   option_menu = gtk_option_menu_new();
   g_object_set_data (G_OBJECT (checkbox), "option-menu", option_menu);
@@ -563,7 +568,7 @@ main (gint argc, gchar **argv)
   gtk_widget_show (menuitem);
 
   gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu);
-  gtk_box_pack_start (GTK_BOX (hbox), option_menu, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (hbox2), option_menu, FALSE, FALSE, 0);
   g_signal_connect (option_menu, "changed",
 		    G_CALLBACK (icon_size_history_changed), toolbar);
   
@@ -571,7 +576,7 @@ main (gint argc, gchar **argv)
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
 				  GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
   gtk_table_attach (GTK_TABLE (table), scrolled_window,
-		    1,2, 2,3, GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0, 0);
+		    1,2, 3,4, GTK_FILL|GTK_EXPAND, GTK_FILL|GTK_EXPAND, 0, 0);
 
   store = create_items_list (&treeview);
   gtk_container_add (GTK_CONTAINER (scrolled_window), treeview);
@@ -619,6 +624,7 @@ main (gint argc, gchar **argv)
   g_signal_connect (item, "toggled", G_CALLBACK (bold_toggled), NULL);
   add_item_to_list (store, item, "Bold");  
   gtk_toolbar_insert (GTK_TOOLBAR (toolbar), item, -1);
+  gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
 
   item = gtk_separator_tool_item_new ();
   add_item_to_list (store, item, "-----");  
@@ -652,7 +658,7 @@ main (gint argc, gchar **argv)
   hbox = gtk_hbox_new (FALSE, 5);
   gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
   gtk_table_attach (GTK_TABLE (table), hbox,
-		    1,2, 3,4, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
+		    1,2, 4,5, GTK_FILL|GTK_EXPAND, GTK_FILL, 0, 0);
 
   button = gtk_button_new_with_label ("Drag me to the toolbar");
   gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]