[Xfce4-commits] [xfce/xfce4-panel] 01/03: Re-implement border drawing
noreply at xfce.org
noreply at xfce.org
Tue Mar 7 00:13:56 CET 2017
This is an automated email from the git hooks/post-receive script.
ochosi pushed a commit to branch master
in repository xfce/xfce4-panel.
commit f248bb0a497239e1fd392a1e5f2da920d0f8bae5
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date: Mon Mar 6 23:55:26 2017 +0100
Re-implement border drawing
As with Gtk2 this only works when the Gtk+ theme's system colors
are in use. In theory this could also be added to custom background
colors.
---
panel/panel-base-window.c | 42 ++++++++++++++++++++++++++++++++++++------
1 file changed, 36 insertions(+), 6 deletions(-)
diff --git a/panel/panel-base-window.c b/panel/panel-base-window.c
index 9c570fe..2b58bb0 100644
--- a/panel/panel-base-window.c
+++ b/panel/panel-base-window.c
@@ -37,7 +37,8 @@
-#define PANEL_BASE_CSS ".xfce4-panel.background button { background: transparent; padding: 0; }"\
+#define PANEL_BASE_CSS ".xfce4-panel.background { border-style: solid; }"\
+ ".xfce4-panel.background button { background: transparent; padding: 0; }"\
".xfce4-panel.background.marching-ants { border: 1px dashed #ff0000; }"
@@ -605,8 +606,9 @@ static void
panel_base_window_set_background_color_css (PanelBaseWindow *window) {
gchar *css_string;
panel_return_if_fail (window->background_rgba != NULL);
- css_string = g_strdup_printf (".xfce4-panel.background { background-image: none; background-color: %s; } %s",
- gdk_rgba_to_string (window->background_rgba), PANEL_BASE_CSS);
+ css_string = g_strdup_printf (".xfce4-panel.background { background-color: %s; } %s",
+ gdk_rgba_to_string (window->background_rgba),
+ PANEL_BASE_CSS);
panel_base_window_set_background_css (window, css_string);
}
@@ -641,14 +643,39 @@ panel_base_window_set_background_css (PanelBaseWindow *window, gchar *css_string
static void
panel_base_window_reset_background_css (PanelBaseWindow *window) {
- GtkStyleContext *context;
+ PanelBaseWindowPrivate *priv = window->priv;
+ GtkStyleContext *context;
+ GdkRGBA *background_rgba;
+ gchar *border_side = NULL;
+ gchar *base_css;
context = gtk_widget_get_style_context (GTK_WIDGET (window));
- gtk_style_context_remove_provider (context, GTK_STYLE_PROVIDER (window->priv->css_provider));
- gtk_css_provider_load_from_data (window->priv->css_provider, PANEL_BASE_CSS, -1, NULL);
+ gtk_style_context_remove_provider (context,
+ GTK_STYLE_PROVIDER (window->priv->css_provider));
+ /* Get the background color of the panel to draw the border */
+ gtk_style_context_get (context, GTK_STATE_FLAG_NORMAL,
+ GTK_STYLE_PROPERTY_BACKGROUND_COLOR,
+ &background_rgba, NULL);
+ if (PANEL_HAS_FLAG (priv->borders, PANEL_BORDER_BOTTOM))
+ border_side = "bottom";
+ else if (PANEL_HAS_FLAG (priv->borders, PANEL_BORDER_TOP))
+ border_side = "top";
+ else if (PANEL_HAS_FLAG (priv->borders, PANEL_BORDER_LEFT))
+ border_side = "left";
+ else if (PANEL_HAS_FLAG (priv->borders, PANEL_BORDER_RIGHT))
+ border_side = "right";
+
+ if (border_side) {
+ base_css = g_strdup_printf ("%s .xfce4-panel.background { border-%s: 1px solid shade(%s, 0.7); }",
+ PANEL_BASE_CSS, border_side, gdk_rgba_to_string (background_rgba));
+ gtk_css_provider_load_from_data (window->priv->css_provider, base_css, -1, NULL);
+ }
+ else
+ gtk_css_provider_load_from_data (window->priv->css_provider, PANEL_BASE_CSS, -1, NULL);
gtk_style_context_add_provider (context,
GTK_STYLE_PROVIDER (window->priv->css_provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ gdk_rgba_free (background_rgba);
}
@@ -727,6 +754,9 @@ panel_base_window_set_borders (PanelBaseWindow *window,
{
priv->borders = borders;
gtk_widget_queue_resize (GTK_WIDGET (window));
+ /* Re-draw the borders if system colors are being used */
+ if (window->background_style == PANEL_BG_STYLE_NONE)
+ panel_base_window_reset_background_css (window);
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list