[Xfce4-commits] [xfce/xfce4-panel] 03/03: Fix buttons with Adwaita

noreply at xfce.org noreply at xfce.org
Thu Mar 2 01:44:58 CET 2017


This is an automated email from the git hooks/post-receive script.

andrzejr pushed a commit to branch master
in repository xfce/xfce4-panel.

commit 21cd70ce1dcbdf51aaae4af71fedeafdc87d7e98
Author: Andrzej <ndrwrdck at gmail.com>
Date:   Thu Mar 2 00:44:42 2017 +0000

    Fix buttons with Adwaita
    
    Prevent the excessive padding from some
    themes to prevent proper rendering of the button.
---
 libxfce4panel/xfce-arrow-button.c      | 16 ++++++++++++++++
 libxfce4panel/xfce-panel-convenience.c | 33 ++++++++++++++++++++++++++++++++-
 2 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/libxfce4panel/xfce-arrow-button.c b/libxfce4panel/xfce-arrow-button.c
index 7fbe831..03e8e14 100644
--- a/libxfce4panel/xfce-arrow-button.c
+++ b/libxfce4panel/xfce-arrow-button.c
@@ -184,6 +184,11 @@ xfce_arrow_button_class_init (XfceArrowButtonClass * klass)
 static void
 xfce_arrow_button_init (XfceArrowButton *button)
 {
+#if GTK_CHECK_VERSION (3, 0, 0)
+  GtkStyleContext *context;
+  GtkCssProvider  *provider;
+#endif
+
   button->priv = G_TYPE_INSTANCE_GET_PRIVATE (button, XFCE_TYPE_ARROW_BUTTON, XfceArrowButtonPrivate);
 
   /* initialize button values */
@@ -197,6 +202,17 @@ xfce_arrow_button_init (XfceArrowButton *button)
   gtk_widget_set_can_default (GTK_WIDGET (button), FALSE);
   gtk_widget_set_can_focus (GTK_WIDGET (button), FALSE);
   gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
+
+#if GTK_CHECK_VERSION (3, 0, 0)
+  /* Make sure themes like Adwaita, which set excessive padding, don't cause the
+     launcher buttons to overlap when panels have a fairly normal size */
+  context = gtk_widget_get_style_context (GTK_WIDGET (button));
+  provider = gtk_css_provider_new ();
+  gtk_css_provider_load_from_data (provider, ".xfce4-panel button { padding: 0; }", -1, NULL);
+  gtk_style_context_add_provider (context,
+                                  GTK_STYLE_PROVIDER (provider),
+                                  GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+#endif
 }
 
 
diff --git a/libxfce4panel/xfce-panel-convenience.c b/libxfce4panel/xfce-panel-convenience.c
index efcaf6f..66d24e7 100644
--- a/libxfce4panel/xfce-panel-convenience.c
+++ b/libxfce4panel/xfce-panel-convenience.c
@@ -55,7 +55,11 @@
 GtkWidget *
 xfce_panel_create_button (void)
 {
-  GtkWidget *button = gtk_button_new ();
+  GtkWidget       *button = gtk_button_new ();
+#if GTK_CHECK_VERSION (3, 0, 0)
+  GtkStyleContext *context;
+  GtkCssProvider  *provider;
+#endif
 
   gtk_widget_set_can_default (GTK_WIDGET (button), FALSE);
   gtk_widget_set_can_focus (GTK_WIDGET (button), FALSE);
@@ -67,6 +71,17 @@ xfce_panel_create_button (void)
 #endif
   gtk_widget_set_name (button, "xfce-panel-button");
 
+#if GTK_CHECK_VERSION (3, 0, 0)
+  /* Make sure themes like Adwaita, which set excessive padding, don't cause the
+     launcher buttons to overlap when panels have a fairly normal size */
+  context = gtk_widget_get_style_context (GTK_WIDGET (button));
+  provider = gtk_css_provider_new ();
+  gtk_css_provider_load_from_data (provider, ".xfce4-panel button { padding: 0; }", -1, NULL);
+  gtk_style_context_add_provider (context,
+                                  GTK_STYLE_PROVIDER (provider),
+                                  GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+#endif
+
   return button;
 }
 
@@ -83,6 +98,11 @@ xfce_panel_create_button (void)
 GtkWidget *
 xfce_panel_create_toggle_button (void)
 {
+#if GTK_CHECK_VERSION (3, 0, 0)
+  GtkStyleContext *context;
+  GtkCssProvider  *provider;
+#endif
+
   GtkWidget *button = gtk_toggle_button_new ();
 
   gtk_widget_set_can_default (GTK_WIDGET (button), FALSE);
@@ -95,6 +115,17 @@ xfce_panel_create_toggle_button (void)
 #endif
   gtk_widget_set_name (button, "xfce-panel-toggle-button");
 
+#if GTK_CHECK_VERSION (3, 0, 0)
+  /* Make sure themes like Adwaita, which set excessive padding, don't cause the
+     launcher buttons to overlap when panels have a fairly normal size */
+  context = gtk_widget_get_style_context (GTK_WIDGET (button));
+  provider = gtk_css_provider_new ();
+  gtk_css_provider_load_from_data (provider, ".xfce4-panel button { padding: 0; }", -1, NULL);
+  gtk_style_context_add_provider (context,
+                                  GTK_STYLE_PROVIDER (provider),
+                                  GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+#endif
+
   return button;
 }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list