unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#9451: GTK3 toolbar style
@ 2011-09-06 16:11 Stefano Facchini
  2011-09-06 20:12 ` Jan Djärv
  0 siblings, 1 reply; 4+ messages in thread
From: Stefano Facchini @ 2011-09-06 16:11 UTC (permalink / raw)
  To: 9451

[-- Attachment #1: Type: text/plain, Size: 532 bytes --]

When compiling with GTK3 the toolbar style should be set to
"primary-toolbar" to match the new theme. However, simply setting the
style in this way makes the toolbar looks bad because of the GtkEventBox
wrapped around every GtkButton.

It seems that the GtkEventBox is only used in connecting signals which
can be connected directly to the GtkButton itself. In the attached patch
the event box is removed and the toolbar style set to "primary-toolbar".

Feedback/comments welcome


-- 
Stefano Facchini <stefano.facchini@gmail.com>

[-- Attachment #2: gtk3toolbar.patch --]
[-- Type: text/x-patch, Size: 2923 bytes --]

=== modified file 'src/gtkutil.c'
--- src/gtkutil.c	2011-08-29 20:57:42 +0000
+++ src/gtkutil.c	2011-09-06 15:47:54 +0000
@@ -3855,7 +3855,7 @@
 static gboolean
 xg_tool_bar_menu_proxy (GtkToolItem *toolitem, gpointer user_data)
 {
-  GtkButton *wbutton = GTK_BUTTON (XG_BIN_CHILD (XG_BIN_CHILD (toolitem)));
+  GtkButton *wbutton = GTK_BUTTON (XG_BIN_CHILD (toolitem));
   GtkWidget *vb = XG_BIN_CHILD (wbutton);
   GtkWidget *c1;
   GtkLabel *wlbl = GTK_LABEL (xg_get_tool_bar_widgets (vb, &c1));
@@ -4165,6 +4165,9 @@
 xg_create_tool_bar (FRAME_PTR f)
 {
   struct x_output *x = f->output_data.x;
+#ifdef HAVE_GTK3
+  GtkStyleContext *gsty;
+#endif
 
   x->toolbar_widget = gtk_toolbar_new ();
   x->toolbar_detached = 0;
@@ -4173,6 +4176,10 @@
 
   gtk_toolbar_set_style (GTK_TOOLBAR (x->toolbar_widget), GTK_TOOLBAR_ICONS);
   toolbar_set_orientation (x->toolbar_widget, GTK_ORIENTATION_HORIZONTAL);
+#ifdef HAVE_GTK3
+  gsty = gtk_widget_get_style_context (x->toolbar_widget);
+  gtk_style_context_add_class (gsty, "primary-toolbar");
+#endif
 }
 
 
@@ -4219,7 +4226,6 @@
   GtkToolItem *ti = gtk_tool_item_new ();
   GtkWidget *vb = horiz ? gtk_hbox_new (FALSE, 0) : gtk_vbox_new (FALSE, 0);
   GtkWidget *wb = gtk_button_new ();
-  GtkWidget *weventbox = gtk_event_box_new ();
 
   if (wimage && !text_image)
     gtk_box_pack_start (GTK_BOX (vb), wimage, TRUE, TRUE, 0);
@@ -4231,8 +4237,7 @@
   gtk_button_set_focus_on_click (GTK_BUTTON (wb), FALSE);
   gtk_button_set_relief (GTK_BUTTON (wb), GTK_RELIEF_NONE);
   gtk_container_add (GTK_CONTAINER (wb), vb);
-  gtk_container_add (GTK_CONTAINER (weventbox), wb);
-  gtk_container_add (GTK_CONTAINER (ti), weventbox);
+  gtk_container_add (GTK_CONTAINER (ti), wb);
 
   if (wimage)
     {
@@ -4247,7 +4252,6 @@
                         G_CALLBACK (xg_tool_bar_callback),
                         gi);
 
-      g_object_set_data (G_OBJECT (weventbox), XG_FRAME_DATA, (gpointer)f);
 
 #ifndef HAVE_GTK3
       /* Catch expose events to overcome an annoying redraw bug, see
@@ -4273,11 +4277,11 @@
          "leave", so we can have only one callback.  The event
          will tell us what kind of event it is.  */
       /* The EMACS_INT cast avoids a warning. */
-      g_signal_connect (G_OBJECT (weventbox),
+      g_signal_connect (G_OBJECT (wb),
                         "enter-notify-event",
                         G_CALLBACK (xg_tool_bar_help_callback),
                         gi);
-      g_signal_connect (G_OBJECT (weventbox),
+      g_signal_connect (G_OBJECT (wb),
                         "leave-notify-event",
                         G_CALLBACK (xg_tool_bar_help_callback),
                         gi);
@@ -4480,7 +4484,7 @@
 	  ti = NULL;
 	}
 
-      if (ti) wbutton = XG_BIN_CHILD (XG_BIN_CHILD (ti));
+      if (ti) wbutton = XG_BIN_CHILD (ti);
 
       /* Ignore invalid image specifications.  */
       image = PROP (TOOL_BAR_ITEM_IMAGES);


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-07-15 14:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-06 16:11 bug#9451: GTK3 toolbar style Stefano Facchini
2011-09-06 20:12 ` Jan Djärv
2011-12-20 11:01   ` Stefano Facchini
2012-07-15 14:22     ` Chong Yidong

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).