[Xfce4-commits] [xfce/xfdesktop] 01/06: Improve style changes for the desktop

noreply at xfce.org noreply at xfce.org
Fri Mar 14 18:51:24 CET 2014


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

eric pushed a commit to branch master
in repository xfce/xfdesktop.

commit 81e3969103a4b2fc705322bd9afee4e415934f80
Author: Eric Koegel <eric.koegel at gmail.com>
Date:   Wed Mar 12 08:40:16 2014 +0300

    Improve style changes for the desktop
    
    This patch changes how style-set events are handled. Instead of
    re-creating the icon view to deal with XSettings manager changes,
    we now reset all the styles on the icon view and let it re-set them
    to what it needs to. This stops the icon view from destroying and
    recreating all the icons which should make startup a little faster.
---
 src/xfce-desktop.c |   55 ++++++++++++++++++++++++----------------------------
 1 file changed, 25 insertions(+), 30 deletions(-)

diff --git a/src/xfce-desktop.c b/src/xfce-desktop.c
index 85ea597..a030f3f 100644
--- a/src/xfce-desktop.c
+++ b/src/xfce-desktop.c
@@ -114,7 +114,6 @@ struct _XfceDesktopPriv
     gboolean icons_font_size_set;
     guint icons_font_size;
     guint icons_size;
-    gint  style_refresh_timer;
     GtkWidget *icon_view;
     gdouble system_font_size;
 #endif
@@ -899,9 +898,6 @@ xfce_desktop_finalize(GObject *object)
     g_object_unref(G_OBJECT(desktop->priv->channel));
     g_free(desktop->priv->property_prefix);
 
-    if(desktop->priv->style_refresh_timer != 0)
-        g_source_remove(desktop->priv->style_refresh_timer);
-
     G_OBJECT_CLASS(xfce_desktop_parent_class)->finalize(object);
 }
 
@@ -1259,45 +1255,44 @@ xfce_desktop_delete_event(GtkWidget *w,
     return TRUE;
 }
 
-static gboolean
-style_refresh_cb(gpointer *w)
+static void
+xfce_desktop_style_set(GtkWidget *w, GtkStyle *old_style)
 {
     XfceDesktop *desktop = XFCE_DESKTOP(w);
+#ifdef ENABLE_DESKTOP_ICONS
+    gdouble old_font_size;
+#endif
 
     TRACE("entering");
 
-    desktop->priv->style_refresh_timer = 0;
-
-    g_return_val_if_fail(XFCE_IS_DESKTOP(desktop), FALSE);
+    g_return_if_fail(XFCE_IS_DESKTOP(desktop));
 
     if(!gtk_widget_get_realized(GTK_WIDGET(desktop)))
-        return FALSE;
+        return;
 
-    if(desktop->priv->workspaces == NULL) {
-        return FALSE;
-    }
+    if(desktop->priv->workspaces == NULL)
+        return;
 
-#ifdef ENABLE_DESKTOP_ICONS
-    /* reload icon view */
-    if(desktop->priv->icon_view) {
-        gtk_widget_destroy(desktop->priv->icon_view);
-        desktop->priv->icon_view = NULL;
-    }
-    xfce_desktop_setup_icon_view(desktop);
-#endif
+    if(GDK_IS_WINDOW(desktop->priv->bg_pixmap))
+        gdk_window_set_back_pixmap(gtk_widget_get_window(GTK_WIDGET(desktop)), desktop->priv->bg_pixmap, FALSE);
 
-    return FALSE;
-}
+    gtk_widget_queue_draw(GTK_WIDGET(desktop));
 
-static void
-xfce_desktop_style_set(GtkWidget *w, GtkStyle *old_style)
-{
-    XfceDesktop *desktop = XFCE_DESKTOP(w);
+#ifdef ENABLE_DESKTOP_ICONS
+    if(!desktop->priv->icon_view || !XFDESKTOP_IS_ICON_VIEW(desktop->priv->icon_view))
+        return;
 
-    if(desktop->priv->style_refresh_timer != 0)
-        g_source_remove(desktop->priv->style_refresh_timer);
+    /* reset the icon view style */
+    gtk_widget_set_style(desktop->priv->icon_view, NULL);
 
-    desktop->priv->style_refresh_timer = g_timeout_add_seconds(1, (GSourceFunc)style_refresh_cb, w);
+    old_font_size = desktop->priv->system_font_size;
+    if(xfce_desktop_ensure_system_font_size(desktop) != old_font_size
+       && desktop->priv->icon_view && !desktop->priv->icons_font_size_set)
+    {
+        xfdesktop_icon_view_set_font_size(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view),
+                                          desktop->priv->system_font_size);
+    }
+#endif
 }
 
 static void

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


More information about the Xfce4-commits mailing list