~ubuntu-branches/ubuntu/utopic/thunar/utopic-proposed

« back to all changes in this revision

Viewing changes to debian/patches/xubuntu_fix-duplicate-volumes.patch

  • Committer: Package Import Robot
  • Author(s): Lionel Le Folgoc
  • Date: 2012-10-29 11:59:41 UTC
  • Revision ID: package-import@ubuntu.com-20121029115941-i88a2b2kv8tvzqd1
Tags: 1.4.0-1ubuntu3
* debian/patches:
  - xubuntu_fix-duplicate-volumes.patch: fix duplicate volumes appearing
    randomly in the side pane. lp: #1039375

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Description: Fix duplicate volumes in the side pane
 
2
 Avoid duplicate volumes appearing in the side pane in case GIO sends extra
 
3
 'volume-added' signals for volumes already present in the list returned by
 
4
 g_volume_monitor_get_volumes ().
 
5
Author: Lionel Le Folgoc <mrpouit@ubuntu.com>
 
6
Bug-Ubuntu: https://launchpad.net/bugs/1039375
 
7
Forwarded: no, do not forward, only reproducible on Ubuntu
 
8
 
 
9
--- thunar-1.4.0.orig/thunar/thunar-tree-model.c
 
10
+++ thunar-1.4.0/thunar/thunar-tree-model.c
 
11
@@ -1127,13 +1127,21 @@ thunar_tree_model_volume_added (GVolumeM
 
12
                                 GVolume                *volume,
 
13
                                 ThunarTreeModel        *model)
 
14
 {
 
15
+  GNode    *node;
 
16
+  gboolean  found = FALSE;
 
17
+
 
18
   _thunar_return_if_fail (G_IS_VOLUME_MONITOR (volume_monitor));
 
19
   _thunar_return_if_fail (model->volume_monitor == volume_monitor);
 
20
   _thunar_return_if_fail (G_IS_VOLUME (volume));
 
21
   _thunar_return_if_fail (THUNAR_IS_TREE_MODEL (model));
 
22
 
 
23
-  /* place the volume on the hidden list */
 
24
-  model->hidden_volumes = g_list_prepend (model->hidden_volumes, g_object_ref (volume));
 
25
+  /* lookup the node for the volume */
 
26
+  for (node = model->root->children; !found && node != NULL; node = node->next)
 
27
+    found = THUNAR_TREE_MODEL_ITEM (node->data)->volume == volume;
 
28
+
 
29
+  /* place the volume on the hidden list if necessary */
 
30
+  if (!found && (g_list_find (model->hidden_volumes, volume) == NULL))
 
31
+    model->hidden_volumes = g_list_prepend (model->hidden_volumes, g_object_ref (volume));
 
32
 
 
33
   /* and let the "volume-changed" handler place the volume where appropriate */
 
34
   thunar_tree_model_volume_changed (volume_monitor, volume, model);
 
35
--- thunar-1.4.0.orig/thunar/thunar-shortcuts-model.c
 
36
+++ thunar-1.4.0/thunar/thunar-shortcuts-model.c
 
37
@@ -289,6 +289,12 @@ thunar_shortcuts_model_init (ThunarShort
 
38
 
 
39
   g_list_free (system_paths);
 
40
 
 
41
+  /* prepend the row separator */
 
42
+  shortcut = g_slice_new0 (ThunarShortcut);
 
43
+  shortcut->type = THUNAR_SHORTCUT_SEPARATOR;
 
44
+  thunar_shortcuts_model_add_shortcut (model, shortcut, path);
 
45
+  gtk_tree_path_next (path);
 
46
+
 
47
   /* prepend the removable media volumes */
 
48
   volumes = g_volume_monitor_get_volumes (model->volume_monitor);
 
49
   for (lp = volumes; lp != NULL; lp = lp->next)
 
50
@@ -296,35 +302,13 @@ thunar_shortcuts_model_init (ThunarShort
 
51
       /* monitor the volume for changes */
 
52
       volume = G_VOLUME (lp->data);
 
53
 
 
54
-      /* we list only present, removable devices here */
 
55
-      if (thunar_g_volume_is_removable (volume) && thunar_g_volume_is_present (volume))
 
56
-        {
 
57
-          /* generate the shortcut (w/o a file, else we might
 
58
-           * prevent the volume from being unmounted)
 
59
-           */
 
60
-          shortcut = g_slice_new0 (ThunarShortcut);
 
61
-          shortcut->type = THUNAR_SHORTCUT_REMOVABLE_MEDIA;
 
62
-          shortcut->volume = volume;
 
63
-
 
64
-          /* link the shortcut to the list */
 
65
-          thunar_shortcuts_model_add_shortcut (model, shortcut, path);
 
66
-          gtk_tree_path_next (path);
 
67
-        }
 
68
-      else
 
69
-        {
 
70
-          /* schedule the volume for later checking, not removable or 
 
71
-           * there's no medium present */
 
72
-          model->hidden_volumes = g_list_prepend (model->hidden_volumes, volume);
 
73
-        }
 
74
+      thunar_shortcuts_model_volume_added (model->volume_monitor,
 
75
+                                           volume,
 
76
+                                           model);
 
77
+      g_object_unref (volume);
 
78
     }
 
79
   g_list_free (volumes);
 
80
 
 
81
-  /* prepend the row separator */
 
82
-  shortcut = g_slice_new0 (ThunarShortcut);
 
83
-  shortcut->type = THUNAR_SHORTCUT_SEPARATOR;
 
84
-  thunar_shortcuts_model_add_shortcut (model, shortcut, path);
 
85
-  gtk_tree_path_next (path);
 
86
-
 
87
   /* determine the URI to the Gtk+ bookmarks file */
 
88
   bookmarks = g_file_resolve_relative_path (home, ".gtk-bookmarks");
 
89
 
 
90
@@ -1221,13 +1205,21 @@ thunar_shortcuts_model_volume_added (GVo
 
91
                                      GVolume              *volume,
 
92
                                      ThunarShortcutsModel *model)
 
93
 {
 
94
+  GList    *lp;
 
95
+  gboolean  found = FALSE;
 
96
+
 
97
   _thunar_return_if_fail (G_IS_VOLUME_MONITOR (volume_monitor));
 
98
   _thunar_return_if_fail (model->volume_monitor == volume_monitor);
 
99
   _thunar_return_if_fail (G_IS_VOLUME (volume));
 
100
   _thunar_return_if_fail (THUNAR_IS_SHORTCUTS_MODEL (model));
 
101
 
 
102
-  /* place the volume on the hidden list */
 
103
-  model->hidden_volumes = g_list_prepend (model->hidden_volumes, g_object_ref (volume));
 
104
+  /* lookup the shortcut that contains the given volume */
 
105
+  for (lp = model->shortcuts; !found && lp != NULL; lp = lp->next)
 
106
+    found = THUNAR_SHORTCUT (lp->data)->volume == volume;
 
107
+
 
108
+  /* place the volume on the hidden list if necessary */
 
109
+  if (!found && (g_list_find (model->hidden_volumes, volume) == NULL))
 
110
+    model->hidden_volumes = g_list_prepend (model->hidden_volumes, g_object_ref (volume));
 
111
 
 
112
   /* let the "changed" handler place the volume where appropriate */
 
113
   thunar_shortcuts_model_volume_changed (volume_monitor, volume, model);