[Xfce4-commits] [xfce/xfdesktop] 01/06: Add a xfconf settings to center the text on xfdesktop icons.

noreply at xfce.org noreply at xfce.org
Sun Mar 15 13:27:09 CET 2015


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

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

commit 57f33bd2082ff9ee84e9d6c644e20806b9583ab1
Author: Matias De lellis <mati86dl at gmail.com>
Date:   Sat Feb 14 11:26:26 2015 -0300

    Add a xfconf settings to center the text on xfdesktop icons.
    
    This is enabled by default, but done optionally to fix RTL languages.
    
    Signed-off-by: Eric Koegel <eric.koegel at gmail.com>
---
 src/xfce-desktop.c        |   41 +++++++++++++++++++++++++++++++++++++++++
 src/xfce-desktop.h        |    3 +++
 src/xfdesktop-icon-view.c |   21 +++++++++++++++++++++
 src/xfdesktop-icon-view.h |    2 ++
 4 files changed, 67 insertions(+)

diff --git a/src/xfce-desktop.c b/src/xfce-desktop.c
index 516d76c..f6cbc60 100644
--- a/src/xfce-desktop.c
+++ b/src/xfce-desktop.c
@@ -114,6 +114,7 @@ struct _XfceDesktopPriv
     gboolean icons_font_size_set;
     guint icons_font_size;
     guint icons_size;
+    gboolean icons_center_text;
     gint  style_refresh_timer;
     GtkWidget *icon_view;
     gdouble system_font_size;
@@ -135,6 +136,7 @@ enum
     PROP_ICON_SIZE,
     PROP_ICON_FONT_SIZE,
     PROP_ICON_FONT_SIZE_SET,
+    PROP_ICON_CENTER_TEXT,
 #endif
     PROP_SINGLE_WORKSPACE_MODE,
     PROP_SINGLE_WORKSPACE_NUMBER,
@@ -261,6 +263,9 @@ xfce_desktop_setup_icon_view(XfceDesktop *desktop)
             xfdesktop_icon_view_set_icon_size(XFDESKTOP_ICON_VIEW(desktop->priv->icon_view),
                                               desktop->priv->icons_size);
         }
+        xfdesktop_icon_view_set_center_text (XFDESKTOP_ICON_VIEW(desktop->priv->icon_view),
+                                             desktop->priv->icons_center_text);
+
         gtk_widget_show(desktop->priv->icon_view);
         gtk_container_add(GTK_CONTAINER(desktop), desktop->priv->icon_view);
 
@@ -861,6 +866,13 @@ xfce_desktop_class_init(XfceDesktopClass *klass)
                                                          FALSE,
                                                          XFDESKTOP_PARAM_FLAGS));
 
+    g_object_class_install_property(gobject_class, PROP_ICON_CENTER_TEXT,
+                                    g_param_spec_boolean("icon-center-text",
+                                                         "icon center text",
+                                                         "icon center text",
+                                                         TRUE,
+                                                         XFDESKTOP_PARAM_FLAGS));
+
 #endif /* ENABLE_DESKTOP_ICONS */
 
     g_object_class_install_property(gobject_class, PROP_SINGLE_WORKSPACE_MODE,
@@ -941,6 +953,11 @@ xfce_desktop_set_property(GObject *object,
                                                 g_value_get_boolean(value));
             break;
 
+        case PROP_ICON_CENTER_TEXT:
+            xfce_desktop_set_center_text(desktop,
+                                         g_value_get_boolean(value));
+            break;
+
 #endif
         case PROP_SINGLE_WORKSPACE_MODE:
             xfce_desktop_set_single_workspace_mode(desktop,
@@ -984,6 +1001,10 @@ xfce_desktop_get_property(GObject *object,
             g_value_set_boolean(value, desktop->priv->icons_font_size_set);
             break;
 
+        case PROP_ICON_CENTER_TEXT:
+            g_value_set_boolean(value, desktop->priv->icons_center_text);
+            break;
+
 #endif
         case PROP_SINGLE_WORKSPACE_MODE:
             g_value_set_boolean(value, desktop->priv->single_workspace_mode);
@@ -1345,6 +1366,9 @@ xfce_desktop_connect_settings(XfceDesktop *desktop)
     xfconf_g_property_bind(channel, ICONS_PREFIX "use-custom-font-size",
                            G_TYPE_BOOLEAN,
                            G_OBJECT(desktop), "icon-font-size-set");
+    xfconf_g_property_bind(channel, ICONS_PREFIX "center-text",
+                           G_TYPE_BOOLEAN,
+                           G_OBJECT(desktop), "icon-center-text");
 
     xfce_desktop_thaw_updates(desktop);
 #undef ICONS_PREFIX
@@ -1589,6 +1613,23 @@ xfce_desktop_set_use_icon_font_size(XfceDesktop *desktop,
 #endif
 }
 
+void
+xfce_desktop_set_center_text (XfceDesktop *desktop,
+                              gboolean center_text)
+{
+    g_return_if_fail(XFCE_IS_DESKTOP(desktop));
+    
+#ifdef ENABLE_DESKTOP_ICONS
+    if(center_text == desktop->priv->icons_center_text)
+        return;
+
+    desktop->priv->icons_center_text = center_text;
+    if(desktop->priv->icon_view) {
+        xfdesktop_icon_view_set_center_text (XFDESKTOP_ICON_VIEW(desktop->priv->icon_view), center_text);
+    }
+#endif
+}
+
 static void
 xfce_desktop_set_single_workspace_mode(XfceDesktop *desktop,
                                        gboolean single_workspace)
diff --git a/src/xfce-desktop.h b/src/xfce-desktop.h
index 638aa03..640b778 100644
--- a/src/xfce-desktop.h
+++ b/src/xfce-desktop.h
@@ -94,6 +94,9 @@ void xfce_desktop_set_use_icon_font_size(XfceDesktop *desktop,
 void xfce_desktop_set_icon_font_size(XfceDesktop *desktop,
                                      guint font_size_points);
 
+void xfce_desktop_set_center_text(XfceDesktop *desktop,
+                                  gboolean center_text);
+
 void xfce_desktop_set_session_logout_func(XfceDesktop *desktop,
                                           SessionLogoutFunc logout_func);
 
diff --git a/src/xfdesktop-icon-view.c b/src/xfdesktop-icon-view.c
index 224457d..bd5b4dd 100644
--- a/src/xfdesktop-icon-view.c
+++ b/src/xfdesktop-icon-view.c
@@ -116,6 +116,7 @@ struct _XfdesktopIconViewPrivate
     
     guint icon_size;
     gdouble font_size;
+    gboolean center_text;
     
     WnckScreen *wnck_screen;
     PangoLayout *playout;
@@ -2934,6 +2935,10 @@ xfdesktop_icon_view_setup_pango_layout(XfdesktopIconView *icon_view,
     pango_layout_set_ellipsize(playout, PANGO_ELLIPSIZE_NONE);
     pango_layout_set_wrap(playout, PANGO_WRAP_WORD_CHAR);
     pango_layout_set_width(playout, TEXT_WIDTH * PANGO_SCALE);
+    if (icon_view->priv->center_text)
+        pango_layout_set_alignment(playout, PANGO_ALIGN_CENTER);
+    else
+        pango_layout_set_alignment(playout, PANGO_ALIGN_LEFT);
     pango_layout_set_text(playout, label, -1);
 
     if(!xfdesktop_icon_view_is_icon_selected(icon_view, icon)
@@ -4287,6 +4292,22 @@ xfdesktop_icon_view_get_font_size(XfdesktopIconView *icon_view)
     return icon_view->priv->font_size;
 }
 
+void
+xfdesktop_icon_view_set_center_text (XfdesktopIconView *icon_view,
+                                     gboolean center_text)
+{
+    g_return_if_fail(XFDESKTOP_IS_ICON_VIEW(icon_view));
+    
+    if (center_text == icon_view->priv->center_text)
+        return;
+    
+    icon_view->priv->center_text = center_text;
+    
+    if(gtk_widget_get_realized(GTK_WIDGET(icon_view))) {
+        gtk_widget_queue_draw(GTK_WIDGET(icon_view));
+    }
+}
+
 GtkWidget *
 xfdesktop_icon_view_get_window_widget(XfdesktopIconView *icon_view)
 {
diff --git a/src/xfdesktop-icon-view.h b/src/xfdesktop-icon-view.h
index ee35b26..41e9d26 100644
--- a/src/xfdesktop-icon-view.h
+++ b/src/xfdesktop-icon-view.h
@@ -117,6 +117,8 @@ guint xfdesktop_icon_view_get_icon_size(XfdesktopIconView *icon_view);
 void xfdesktop_icon_view_set_font_size(XfdesktopIconView *icon_view,
                                        gdouble font_size_points);
 gdouble xfdesktop_icon_view_get_font_size(XfdesktopIconView *icon_view);
+void xfdesktop_icon_view_set_center_text (XfdesktopIconView *icon_view,
+                                          gboolean center_text);
 
 GtkWidget *xfdesktop_icon_view_get_window_widget(XfdesktopIconView *icon_view);
 

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


More information about the Xfce4-commits mailing list