[Xfce4-commits] [apps/xfce4-notifyd] 10/29: Correctly set the GtkStyleProvider on a newly created notification and propagates it to children widgets.

noreply at xfce.org noreply at xfce.org
Wed Jun 29 23:20:00 CEST 2016


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

ochosi pushed a commit to branch master
in repository apps/xfce4-notifyd.

commit 90ceaed6dec5c972d18a2ebbec60f7c08c39df38
Author: Ali Abdallah <aliovx at gmail.com>
Date:   Tue Oct 13 14:37:48 2015 +0200

    Correctly set the GtkStyleProvider on a newly created
    notification and propagates it to children widgets.
---
 Makefile.am                        |  6 ++--
 xfce4-notifyd/main.c               |  4 +--
 xfce4-notifyd/xfce-notify-daemon.c | 66 +++++++++++---------------------------
 xfce4-notifyd/xfce-notify-window.c |  3 +-
 4 files changed, 26 insertions(+), 53 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 344de0d..7456a0c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -102,13 +102,13 @@ dist_icons48_DATA = icons/48x48/xfce4-notifyd.png
 theme_dir = $(datadir)/themes
 
 defaultthemedir = $(theme_dir)/Default/xfce-notify-4.0
-dist_defaulttheme_DATA = themes/Default/gtkrc
+dist_defaulttheme_DATA = themes/Default/gtk.css
 
 smokethemedir = $(theme_dir)/Smoke/xfce-notify-4.0
-dist_smoketheme_DATA = themes/Smoke/gtkrc
+dist_smoketheme_DATA = themes/Smoke/gtk.css
 
 zomgponiesthemedir = $(theme_dir)/ZOMG-PONIES!/xfce-notify-4.0
-dist_zomgponiestheme_DATA = themes/ZOMG-PONIES!/gtkrc
+dist_zomgponiestheme_DATA = themes/ZOMG-PONIES!/gtk.css
 
 built_xfce4_notifyd = \
 	xfce4-notifyd/xfce-notify-gbus.c \
diff --git a/xfce4-notifyd/main.c b/xfce4-notifyd/main.c
index 8869530..e1b860f 100644
--- a/xfce4-notifyd/main.c
+++ b/xfce4-notifyd/main.c
@@ -61,10 +61,10 @@ main(int argc,
     xndaemon = xfce_notify_daemon_new_unique(&error);
     if(!xndaemon) {
         xfce_message_dialog(NULL, _("Xfce Notify Daemon"),
-                            GTK_STOCK_DIALOG_ERROR,
+                            "dialog-error",
                             _("Unable to start notification daemon"),
                             error->message,
-                            GTK_STOCK_QUIT, GTK_RESPONSE_ACCEPT,
+                            "application-exit", GTK_RESPONSE_ACCEPT,
                             NULL);
         g_error_free(error);
         return 1;
diff --git a/xfce4-notifyd/xfce-notify-daemon.c b/xfce4-notifyd/xfce-notify-daemon.c
index 006cef2..c78713a 100644
--- a/xfce4-notifyd/xfce-notify-daemon.c
+++ b/xfce4-notifyd/xfce-notify-daemon.c
@@ -59,7 +59,6 @@ struct _XfceNotifyDaemon
     GtkCornerType notify_location;
     
     GtkCssProvider *css_provider;
-    gboolean css_parsed;
     
     XfconfChannel *settings;
 
@@ -373,17 +372,19 @@ static void xfce_notify_daemon_constructed (GObject *obj)
 static void
 xfce_notify_daemon_init(XfceNotifyDaemon *xndaemon)
 {	
+    GtkWidgetPath *widget_path;	
+    
     xndaemon->active_notifications = g_tree_new_full(xfce_direct_compare,
                                                    	 NULL, NULL,
                                                    	 (GDestroyNotify)gtk_widget_destroy);
 		
     xndaemon->last_notification_id = 1;
-
     xndaemon->reserved_rectangles = NULL;
     xndaemon->monitors_workarea = NULL;
-    xndaemon->css_provider = NULL;
-    xndaemon->css_parsed = FALSE;
-
+    
+    /* CSS Styling provider  */
+    xndaemon->css_provider = gtk_css_provider_new ();
+    
     xndaemon->close_timeout =
         g_timeout_add_seconds(600, (GSourceFunc) xfce_notify_daemon_close_timeout,
                               xndaemon);
@@ -411,8 +412,6 @@ xfce_notify_daemon_finalize(GObject *obj)
     	g_dbus_interface_skeleton_unexport (G_DBUS_INTERFACE_SKELETON(xndaemon->xfce_iface_skeleton));
 	}
 	
-	if (xndaemon->css_provider)
-	    g_object_unref (xndaemon->css_provider);
 
     if(xndaemon->reserved_rectangles && xndaemon->monitors_workarea) {
       gint nscreen, i, j;
@@ -441,6 +440,8 @@ xfce_notify_daemon_finalize(GObject *obj)
 
     g_tree_destroy(xndaemon->active_notifications);
 
+    g_object_unref (xndaemon->css_provider);
+
     if(xndaemon->settings)
         g_object_unref(xndaemon->settings);
 
@@ -938,31 +939,11 @@ notify_show_window (gpointer window)
 }
 
 static void
-apply_css (GtkWidget *widget, GtkStyleProvider *provider)
-{
-  gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
-  if (GTK_IS_CONTAINER (widget))
-    gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) apply_css, provider);
-}
-
-
-static void
-xfce_notify_daemon_active_css_theme (XfceNotifyDaemon *xndaemon)
+add_and_propagate_css_provider (GtkWidget *widget, GtkStyleProvider *provider)
 {
-    
-    GdkScreen *screen;
-    
-    g_return_if_fail(xndaemon->css_provider != NULL);
-    g_return_if_fail(xndaemon->css_parsed == TRUE);
-
-    screen = gdk_display_get_default_screen (gdk_display_get_default());
- 
-    gtk_style_context_add_provider_for_screen 
-        (screen,
-		 GTK_STYLE_PROVIDER (xndaemon->css_provider),
-		 GTK_STYLE_PROVIDER_PRIORITY_APPLICATION
-        ); 
-    gtk_style_context_reset_widgets (gdk_screen_get_default ());
+    gtk_style_context_add_provider (gtk_widget_get_style_context (widget), provider, G_MAXUINT);
+    if (GTK_IS_CONTAINER (widget))
+        gtk_container_forall (GTK_CONTAINER (widget), (GtkCallback) add_and_propagate_css_provider, provider);
 }
 
 
@@ -1075,6 +1056,8 @@ static gboolean notify_notify (XfceNotifyGBus *skeleton,
                          xndaemon);
 
         gtk_widget_realize(GTK_WIDGET(window));
+        
+        add_and_propagate_css_provider (GTK_WIDGET(window), GTK_STYLE_PROVIDER(xndaemon->css_provider));
         g_idle_add(notify_show_window, window);
     }
 
@@ -1257,7 +1240,7 @@ xfce_notify_daemon_set_theme(XfceNotifyDaemon *xndaemon,
 {
     GError *error = NULL;
     gchar  *file, **files;
-
+    
     DBG("New theme: %s", theme);
     
     file = g_strconcat("themes/", theme, "/xfce-notify-4.0/gtk.css", NULL);
@@ -1267,27 +1250,16 @@ xfce_notify_daemon_set_theme(XfceNotifyDaemon *xndaemon,
     if (files && files[0])
     {
         gboolean css_parsed;
-        if (xndaemon->css_provider)
-            g_object_unref (xndaemon->css_provider);
-    
-        xndaemon->css_provider = gtk_css_provider_new();
-        xndaemon->css_parsed = 
+        
+        css_parsed = 
             gtk_css_provider_load_from_path (xndaemon->css_provider, 
                                              files[0],
                                              &error);
-        if (xndaemon->css_parsed)
-        {
-            g_print ("Settings css theme %s\n", theme);
-            xfce_notify_daemon_active_css_theme (xndaemon);
-        }
-        else
+        if (!css_parsed)
         {
             g_warning ("Faild to parse css file : %s\n", error->message);
             g_error_free (error);
-            g_object_unref (xndaemon->css_provider);
-            xndaemon->css_provider = NULL;
-        }   
-        
+        }
         g_strfreev(files);
     }
     else
diff --git a/xfce4-notifyd/xfce-notify-window.c b/xfce4-notifyd/xfce-notify-window.c
index 899db7b..404ca33 100644
--- a/xfce4-notifyd/xfce-notify-window.c
+++ b/xfce4-notifyd/xfce-notify-window.c
@@ -1016,7 +1016,8 @@ xfce_notify_window_set_gauge_value(XfceNotifyWindow *window,
 
         box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
         gtk_widget_show(box);
-        g_object_set(box, "margin-top", 2, NULL);
+        
+        g_object_set(box, "valign", GTK_ALIGN_CENTER, NULL);
         gtk_box_pack_start(GTK_BOX(window->content_box), box, TRUE, TRUE, 0);
 
         window->gauge = gtk_progress_bar_new();

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


More information about the Xfce4-commits mailing list