[Xfce4-commits] [panel-plugins/xfce4-mount-plugin] 02/02: cared for feature request 9400

noreply at xfce.org noreply at xfce.org
Fri Apr 25 02:36:20 CEST 2014


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

timystery pushed a commit to branch master
in repository panel-plugins/xfce4-mount-plugin.

commit 73291798ff71455d1ff511f60125b2917ec59574
Author: Fabian <timystery at arcor.de>
Date:   Fri Apr 25 02:35:15 2014 +0200

    cared for feature request 9400
---
 panel-plugin/devices.c      |   77 +++++++++++++++++++++++++++++++++++--------
 panel-plugin/mount-plugin.c |    4 ++-
 2 files changed, 66 insertions(+), 15 deletions(-)

diff --git a/panel-plugin/devices.c b/panel-plugin/devices.c
index 44ffd38..125a120 100644
--- a/panel-plugin/devices.c
+++ b/panel-plugin/devices.c
@@ -480,18 +480,34 @@ disks_remove_device (GPtrArray * pdisks, char *device)
 {
     unsigned int i;
     gpointer p=NULL;
+    gboolean removedEntries = FALSE;
+    char *exclude_device;
+    size_t device_len;
 
     for (i=0; i < pdisks->len ; i++)
     {
-        if ( strcmp ( ((t_disk *) g_ptr_array_index(pdisks, i))->device,
+        exclude_device = ((t_disk *) g_ptr_array_index(pdisks, i))->device;
+        if ( strcmp ( exclude_device,
             device )==0 )
+        {
+            p = g_ptr_array_remove_index(pdisks, i);
+              if (p!=NULL)
+                removedEntries = TRUE;
+        }
+        
+        device_len = strlen(device);
+        
+        if ( device[device_len-1]=='*' && 
+        strncmp ( exclude_device,
+            device, device_len-1 )==0 )
+        {
             p = g_ptr_array_remove_index(pdisks, i);
+              if (p!=NULL)
+                removedEntries = TRUE;
+        }
     }
 
-    if (p==NULL)
-        return FALSE;
-    else
-        return TRUE;
+    return removedEntries;
 }
 
 
@@ -502,20 +518,39 @@ disks_remove_device (GPtrArray * pdisks, char *device)
 gboolean
 disks_remove_mountpoint (GPtrArray * pdisks, char *mountp)
 {
+    gboolean removedEntries = FALSE;
     unsigned int i;
     gpointer p=NULL;
+    char *exclude_mp;
+    size_t mountp_len;
 
     for (i=0; i < pdisks->len ; i++)
     {
-        if (strcmp ( ((t_disk *) g_ptr_array_index(pdisks, i))->mount_point,
+        exclude_mp = ((t_disk *) g_ptr_array_index(pdisks, i))->mount_point;
+      
+        if (strcmp ( exclude_mp,
             mountp)==0)
+        {
+          DBG("REMOVED %s @ %i %s", mountp, i, exclude_mp);
             p = g_ptr_array_remove_index(pdisks, i);
+            if (p!=NULL)
+                removedEntries = TRUE;
+        }
+        
+        mountp_len = strlen(mountp);
+        
+        if ( mountp[mountp_len-1]=='*' && 
+        strncmp ( exclude_mp,
+            mountp, mountp_len-1 )==0 )
+        {
+          DBG("removed %s @ %i %s", mountp, i, exclude_mp);
+            p = g_ptr_array_remove_index(pdisks, i);
+            if (p!=NULL)
+                removedEntries = TRUE;
+        }
     }
 
-    if (p==NULL)
-        return FALSE;
-    else
-        return TRUE;
+    return removedEntries;
 }
 
 
@@ -559,12 +594,14 @@ disks_free_mount_info(GPtrArray * pdisks)
 
 
 /**
- * Searches array for device and mounpoint. Returns TRUE if found.
+ * Searches array for device and mountpoint. Returns TRUE if found.
  */
 gboolean
 exclude_filesystem (GPtrArray *excluded_FSs, gchar *mountpoint, gchar *device)
 {
     unsigned int i;
+    gchar *excluded_FS_i; 
+    size_t excluded_FS_i_len = 0;
 
     TRACE("Entering exclude_filesystems");
 
@@ -572,14 +609,26 @@ exclude_filesystem (GPtrArray *excluded_FSs, gchar *mountpoint, gchar *device)
 
     for (i=0; i < excluded_FSs->len; i++)
     {
-        DBG("Comparing %s and %s to %s", mountpoint, device, (gchar *) g_ptr_array_index(excluded_FSs, i));
+        excluded_FS_i = (gchar *) g_ptr_array_index(excluded_FSs, i);
+        DBG("Comparing %s and %s to %s", mountpoint, device, excluded_FS_i);
         if (g_ascii_strcasecmp (
-                (gchar *) g_ptr_array_index(excluded_FSs, i), mountpoint)==0
+                excluded_FS_i, mountpoint)==0
             ||
             g_ascii_strcasecmp (
-                (gchar *) g_ptr_array_index(excluded_FSs, i), device)==0
+                excluded_FS_i, device)==0
             )
             return TRUE;
+            
+        excluded_FS_i_len = strlen(excluded_FS_i);
+        
+        if ((excluded_FS_i[excluded_FS_i_len-1]=='*') && 
+            (g_ascii_strncasecmp (
+                excluded_FS_i, mountpoint, excluded_FS_i_len-1)==0
+            ||
+            g_ascii_strncasecmp (
+                excluded_FS_i, device, excluded_FS_i_len-1)==0
+            ))
+            return TRUE;
     }
 
     TRACE("Leaving exclude_filesystems with FALSE");
diff --git a/panel-plugin/mount-plugin.c b/panel-plugin/mount-plugin.c
index df32a50..32e7232 100644
--- a/panel-plugin/mount-plugin.c
+++ b/panel-plugin/mount-plugin.c
@@ -996,7 +996,9 @@ mounter_create_options (XfcePanelPlugin *plugin, t_mounter *mt)
     gtk_tooltips_set_tip ( GTK_TOOLTIPS(tip), _eventbox,
         _("Exclude the following file systems from the menu.\n"
         "The list is separated by simple spaces.\n"
-        "It is up to you to specify correct devices or mount points."),
+        "It is up to you to specify correct devices or mount points.\n"
+        "An asterisk (*) can be used as a placeholder at the end of\n"
+        "a path, e.g., \"/mnt/*\" to exclude any mountpoints below \"/mnt\".\n"),
         NULL );
 
     _vbox2 = gtk_vbox_new (FALSE, BORDER);

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


More information about the Xfce4-commits mailing list