[Xfce4-commits] [panel-plugins/xfce4-mount-plugin] 02/06: Reformatted popup information with more columns and nicer alignment. Fixes somehow feature request from bug 14670.

noreply at xfce.org noreply at xfce.org
Mon Oct 1 20:34:44 CEST 2018


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

t   i   m   y   s   t   e   r   y       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository panel-plugins/xfce4-mount-plugin.

commit 535f290c09b7a60d3d57ef54d3a29f4b58bfb8c9
Author: Fabian <timystery at arcor.de>
Date:   Sat Sep 29 16:42:33 2018 +0200

    Reformatted popup information with more columns and nicer alignment. Fixes somehow feature request from bug 14670.
---
 panel-plugin/mount-plugin.c | 77 ++++++++++++++++++++++++++++++---------------
 panel-plugin/mount-plugin.h |  2 ++
 2 files changed, 54 insertions(+), 25 deletions(-)

diff --git a/panel-plugin/mount-plugin.c b/panel-plugin/mount-plugin.c
index cc9cbc4..8792a04 100644
--- a/panel-plugin/mount-plugin.c
+++ b/panel-plugin/mount-plugin.c
@@ -111,24 +111,40 @@ format_LVM_name (const char *disk_device, gchar **formatted_diskname)
 static void
 disk_display_set_sizes (GPtrArray *array)
 {
-    unsigned int i, max_width_label_disk=0, max_width_label_mount_info=0, tmp;
+    unsigned int i, max_width_label_disk=0, max_width_label_mount_point=0, max_width_label_mount_info=0, tmp;
     t_disk_display *disk_display;
+    gboolean exclude_devicenames = FALSE;
 
     for (i=0; i<array->len; i++) {
         disk_display= g_ptr_array_index (array, i); /* get the disk */
+
         tmp = strlen(gtk_label_get_text(GTK_LABEL(disk_display->label_mount_info)));
         if (tmp>max_width_label_mount_info)
             max_width_label_mount_info = tmp;
 
-        tmp = strlen(gtk_label_get_text(GTK_LABEL(disk_display->label_disk)));
-        if (tmp>max_width_label_disk)
-            max_width_label_disk = tmp;
+        tmp = strlen(gtk_label_get_text(GTK_LABEL(disk_display->label_mount_point)));
+        if (tmp>max_width_label_mount_point)
+            max_width_label_mount_point = tmp;
+
+        if (disk_display->label_disk != NULL)
+        {
+            tmp = strlen(gtk_label_get_text(GTK_LABEL(disk_display->label_disk)));
+            if (tmp>max_width_label_disk)
+                max_width_label_disk = tmp;
+        }
     }
 
     for (i=0; i<array->len; i++) {
         disk_display = g_ptr_array_index (array, i); /* get the disk */
-        gtk_label_set_width_chars(GTK_LABEL(disk_display->label_disk), max_width_label_disk);
+
         gtk_label_set_width_chars(GTK_LABEL(disk_display->label_mount_info), max_width_label_mount_info);
+
+        gtk_label_set_width_chars(GTK_LABEL(disk_display->label_mount_point), max_width_label_mount_point);
+
+        if (disk_display->label_disk != NULL)
+        {
+            gtk_label_set_width_chars(GTK_LABEL(disk_display->label_disk), max_width_label_disk);
+        }
     }
 
 }
@@ -158,42 +174,53 @@ disk_display_new (t_disk *disk, t_mounter *mounter)
 
         if (mounter->trim_devicenames)
         {
-          if (g_str_has_prefix(disk->device, "/dev/mapper/"))
-            format_LVM_name (disk->device_short, &formatted_diskname);
-          else
-            formatted_diskname = g_strdup(disk->device_short);
+            if (g_str_has_prefix(disk->device, "/dev/mapper/"))
+                format_LVM_name (disk->device_short, &formatted_diskname);
+            else
+                formatted_diskname = g_strdup(disk->device_short);
         }
         else
         {
-          if (g_str_has_prefix(disk->device, "/dev/mapper/"))
-            format_LVM_name (disk->device, &formatted_diskname);
-          else
-            formatted_diskname = g_strdup(disk->device);
+            if (g_str_has_prefix(disk->device, "/dev/mapper/"))
+                format_LVM_name (disk->device, &formatted_diskname);
+            else
+                formatted_diskname = g_strdup(disk->device);
         }
 
         if (mounter->exclude_devicenames)
-            dd->label_disk = gtk_label_new (disk->mount_point);
+        {
+            dd->label_disk = NULL;
+            dd->label_mount_array = NULL;
+        }
         else
-            dd->label_disk = gtk_label_new (g_strconcat(formatted_diskname, _(" -> "),
-                                        disk->mount_point, NULL));
+        {
+            dd->label_disk = gtk_label_new (formatted_diskname);
+            dd->label_mount_array = gtk_label_new (_(" -> "));
+
+            /*change to uniform label size*/
+            /*gtk_label_set_width_chars(GTK_LABEL(dd->label_disk), 32); */
+            gtk_label_set_xalign(GTK_LABEL(dd->label_disk), 1.0);
+            gtk_widget_set_valign(dd->label_disk,GTK_ALIGN_CENTER);
+            gtk_widget_set_valign(dd->label_mount_array,GTK_ALIGN_CENTER);
 
+            gtk_box_pack_start(GTK_BOX(dd->hbox),dd->label_disk,FALSE,TRUE,0);
+            gtk_box_pack_start(GTK_BOX(dd->hbox),dd->label_mount_array,FALSE,TRUE,0);
+        }
         g_free (formatted_diskname);
 
-        /*change to uniform label size*/
-        /*gtk_label_set_width_chars(GTK_LABEL(dd->label_disk), 32); */
-        /* gtk_label_set_justify(GTK_LABEL(dd->label_disk),GTK_JUSTIFY_LEFT); */
-        gtk_widget_set_valign(dd->label_disk,GTK_ALIGN_CENTER);
-        gtk_box_pack_start(GTK_BOX(dd->hbox),dd->label_disk,FALSE,TRUE,0);
+        dd->label_mount_point = gtk_label_new (disk->mount_point);
+        gtk_label_set_xalign(GTK_LABEL(dd->label_mount_point), 0.0);
+        gtk_widget_set_valign(dd->label_mount_point,GTK_ALIGN_CENTER);
+        gtk_box_pack_start(GTK_BOX(dd->hbox),dd->label_mount_point,FALSE,TRUE,0);
 
         dd->label_mount_info = gtk_label_new("");
         /*change to uniform label size*/
         /* gtk_label_set_width_chars(GTK_LABEL(dd->label_mount_info),25); */
         gtk_label_set_use_markup(GTK_LABEL(dd->label_mount_info),TRUE);
-        /* gtk_label_set_justify (GTK_LABEL(dd->label_mount_info),
-                               GTK_JUSTIFY_RIGHT); */
-        gtk_widget_set_halign((dd->label_mount_info),GTK_ALIGN_END);
+        gtk_label_set_xalign (GTK_LABEL(dd->label_mount_info),
+                               1.0);
         gtk_widget_set_valign((dd->label_mount_info),GTK_ALIGN_CENTER);
-        gtk_box_pack_start(GTK_BOX(dd->hbox),dd->label_mount_info,TRUE,TRUE,0);
+        gtk_box_pack_start(GTK_BOX(dd->hbox),dd->label_mount_info,FALSE,TRUE,0);
 
         dd->progress_bar = gtk_progress_bar_new();
         gtk_box_pack_start(GTK_BOX(dd->hbox),dd->progress_bar,TRUE,TRUE,0);
diff --git a/panel-plugin/mount-plugin.h b/panel-plugin/mount-plugin.h
index b306b48..7de0d74 100644
--- a/panel-plugin/mount-plugin.h
+++ b/panel-plugin/mount-plugin.h
@@ -81,6 +81,8 @@ typedef struct
     GtkWidget * menu_item;
     GtkWidget * hbox;
     GtkWidget * label_disk;
+    GtkWidget * label_mount_array;
+    GtkWidget * label_mount_point;
     GtkWidget * label_mount_info;
     GtkWidget * progress_bar;
     t_disk *disk; /* People, learn to program in an object-oriented way! */

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


More information about the Xfce4-commits mailing list