[Xfce4-commits] <xfce4-notifyd:master> Add more border style properties.

Jérôme Guelfucci noreply at xfce.org
Sun Mar 17 11:36:02 CET 2013


Updating branch refs/heads/master
         to 41847681d21e0cfa9534bfda13646fa9838b9e7a (commit)
       from 0c3b3034a66fa7d2cea0d82379771277f3979283 (commit)

commit 41847681d21e0cfa9534bfda13646fa9838b9e7a
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date:   Sun Mar 17 11:33:23 2013 +0100

    Add more border style properties.
    
    It is now possible to tweak the border in normal and in hovered state
    with different widths and colors.

 xfce4-notifyd/xfce-notify-window.c |   56 +++++++++++++++++++++++++----------
 1 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/xfce4-notifyd/xfce-notify-window.c b/xfce4-notifyd/xfce-notify-window.c
index 4aedc5c..4a79d2d 100644
--- a/xfce4-notifyd/xfce-notify-window.c
+++ b/xfce4-notifyd/xfce-notify-window.c
@@ -163,6 +163,13 @@ xfce_notify_window_class_init(XfceNotifyWindowClass *klass)
                                                                G_PARAM_READABLE));
 
     gtk_widget_class_install_style_property(widget_class,
+                                            g_param_spec_boxed("border-color-hover",
+                                                               "border color hover",
+                                                               "the color of the border when hovering the notification",
+                                                               GDK_TYPE_COLOR,
+                                                               G_PARAM_READABLE));
+
+    gtk_widget_class_install_style_property(widget_class,
                                             g_param_spec_double("border-radius",
                                                                 "border radius",
                                                                 "the radius of the window border's curved corners",
@@ -177,6 +184,13 @@ xfce_notify_window_class_init(XfceNotifyWindowClass *klass)
                                                                 DEFAULT_BORDER_WIDTH,
                                                                 G_PARAM_READABLE));
     gtk_widget_class_install_style_property(widget_class,
+                                            g_param_spec_double("border-width-hover",
+                                                                "border width hover",
+                                                                "the width of the border when hovering the notification",
+                                                                0.0, 8.0,
+                                                                DEFAULT_BORDER_WIDTH,
+                                                                G_PARAM_READABLE));
+    gtk_widget_class_install_style_property(widget_class,
                                             g_param_spec_double("padding",
                                                                 "padding",
                                                                 "the padding of the text/icon to the notification's border",
@@ -411,10 +425,17 @@ xfce_notify_window_ensure_bg_path(XfceNotifyWindow *window,
 
     gtk_widget_size_request(GTK_WIDGET(window), &req);
 
-    gtk_widget_style_get(widget,
-                         "border-radius", &radius,
-                         "border-width", &border_width,
-                         NULL);
+    if (!window->mouse_hover) {
+        gtk_widget_style_get(widget,
+                             "border-radius", &radius,
+                             "border-width", &border_width,
+                             NULL);
+    } else {
+        gtk_widget_style_get(widget,
+                             "border-radius", &radius,
+                             "border-width-hover", &border_width,
+                             NULL);
+    }
 
     border_padding = border_width / 2.0;
 
@@ -477,6 +498,8 @@ xfce_notify_window_expose(GtkWidget *widget,
     cairo_t *cr;
     GList *children, *l;
     cairo_path_t *bg_path;
+    GdkColor *border_color = NULL;
+    gdouble border_width = DEFAULT_BORDER_WIDTH;
 
     if(evt->count != 0)
         return FALSE;
@@ -512,24 +535,25 @@ xfce_notify_window_expose(GtkWidget *widget,
     }
 
     if(window->mouse_hover) {
-        GdkColor *border_color = NULL;
-        gdouble border_width = DEFAULT_BORDER_WIDTH;
-
+        gtk_widget_style_get(widget,
+                             "border-color-hover", &border_color,
+                             "border-width-hover", &border_width,
+                             NULL);
+    } else {
         gtk_widget_style_get(widget,
                              "border-color", &border_color,
                              "border-width", &border_width,
                              NULL);
-
-        cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
-        if(border_color)
-            gdk_cairo_set_source_color(cr, border_color);
-        else
-            cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
-        cairo_set_line_width(cr, border_width);
-
-        cairo_stroke(cr);
     }
 
+    cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
+    if(border_color)
+        gdk_cairo_set_source_color(cr, border_color);
+    else
+        cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
+    cairo_set_line_width(cr, border_width);
+
+    cairo_stroke(cr);
     cairo_destroy(cr);
 
     children = gtk_container_get_children(GTK_CONTAINER(widget));


More information about the Xfce4-commits mailing list