* 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
* bug#9451: GTK3 toolbar style
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
0 siblings, 1 reply; 4+ messages in thread
From: Jan Djärv @ 2011-09-06 20:12 UTC (permalink / raw)
To: Stefano Facchini; +Cc: 9451
Stefano Facchini skrev 2011-09-06 18:11:
> 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".
>
The GtkEventBox is there to make tooltips work on disabled buttons. Any patch
made must preserve that.
Jan D.
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#9451: GTK3 toolbar style
2011-09-06 20:12 ` Jan Djärv
@ 2011-12-20 11:01 ` Stefano Facchini
2012-07-15 14:22 ` Chong Yidong
0 siblings, 1 reply; 4+ messages in thread
From: Stefano Facchini @ 2011-12-20 11:01 UTC (permalink / raw)
To: Jan Djärv; +Cc: 9451
[-- Attachment #1: Type: text/plain, Size: 910 bytes --]
Il giorno mar, 06/09/2011 alle 22.12 +0200, Jan Djärv ha scritto:
>
> Stefano Facchini skrev 2011-09-06 18:11:
> > 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".
> >
>
> The GtkEventBox is there to make tooltips work on disabled buttons. Any patch
> made must preserve that.
>
> Jan D.
>
Since Gtk+ 3.3.6 it is possible to make transparent the background of a
widget. This allows to solve the GtkEventBox issue when using a primary
toolbar style. A patch is attached.
[-- Attachment #2: gtk3primarytoolbar.patch --]
[-- Type: text/x-patch, Size: 1533 bytes --]
=== modified file 'src/gtkutil.c'
--- src/gtkutil.c 2011-11-27 18:33:17 +0000
+++ src/gtkutil.c 2011-12-20 10:45:52 +0000
@@ -4175,6 +4175,9 @@
xg_create_tool_bar (FRAME_PTR f)
{
struct x_output *x = f->output_data.x;
+#if (defined HAVE_GTK3) && GTK_CHECK_VERSION (3, 3, 6)
+ GtkStyleContext *gsty;
+#endif
x->toolbar_widget = gtk_toolbar_new ();
x->toolbar_detached = 0;
@@ -4183,6 +4186,10 @@
gtk_toolbar_set_style (GTK_TOOLBAR (x->toolbar_widget), GTK_TOOLBAR_ICONS);
toolbar_set_orientation (x->toolbar_widget, GTK_ORIENTATION_HORIZONTAL);
+#if (defined HAVE_GTK3) && GTK_CHECK_VERSION (3, 3, 6)
+ gsty = gtk_widget_get_style_context (x->toolbar_widget);
+ gtk_style_context_add_class (gsty, "primary-toolbar");
+#endif
}
@@ -4231,6 +4238,22 @@
GtkWidget *wb = gtk_button_new ();
/* The eventbox is here so we can have tooltips on disabled items. */
GtkWidget *weventbox = gtk_event_box_new ();
+#if (defined HAVE_GTK3) && GTK_CHECK_VERSION (3, 3, 6)
+ GtkCssProvider *css_prov = gtk_css_provider_new ();
+ GtkStyleContext *gsty;
+
+ gtk_css_provider_load_from_data (css_prov,
+ "GtkEventBox {"
+ " background-color: transparent;"
+ "}",
+ -1, NULL);
+
+ gsty = gtk_widget_get_style_context (weventbox);
+ gtk_style_context_add_provider (gsty,
+ GTK_STYLE_PROVIDER (css_prov),
+ GTK_STYLE_PROVIDER_PRIORITY_USER);
+ g_object_unref (css_prov);
+#endif
if (wimage && !text_image)
gtk_box_pack_start (GTK_BOX (vb), wimage, TRUE, TRUE, 0);
^ permalink raw reply [flat|nested] 4+ messages in thread
* bug#9451: GTK3 toolbar style
2011-12-20 11:01 ` Stefano Facchini
@ 2012-07-15 14:22 ` Chong Yidong
0 siblings, 0 replies; 4+ messages in thread
From: Chong Yidong @ 2012-07-15 14:22 UTC (permalink / raw)
To: Stefano Facchini; +Cc: 9451
Stefano Facchini <stefano.facchini@gmail.com> writes:
> Since Gtk+ 3.3.6 it is possible to make transparent the background of a
> widget. This allows to solve the GtkEventBox issue when using a primary
> toolbar style. A patch is attached.
Thanks, committed to trunk.
^ 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).