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
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
13
ThunarTreeModel *model)
16
+ gboolean found = FALSE;
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));
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;
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));
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
39
g_list_free (system_paths);
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);
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);
54
- /* we list only present, removable devices here */
55
- if (thunar_g_volume_is_removable (volume) && thunar_g_volume_is_present (volume))
57
- /* generate the shortcut (w/o a file, else we might
58
- * prevent the volume from being unmounted)
60
- shortcut = g_slice_new0 (ThunarShortcut);
61
- shortcut->type = THUNAR_SHORTCUT_REMOVABLE_MEDIA;
62
- shortcut->volume = volume;
64
- /* link the shortcut to the list */
65
- thunar_shortcuts_model_add_shortcut (model, shortcut, path);
66
- gtk_tree_path_next (path);
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);
74
+ thunar_shortcuts_model_volume_added (model->volume_monitor,
77
+ g_object_unref (volume);
79
g_list_free (volumes);
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);
87
/* determine the URI to the Gtk+ bookmarks file */
88
bookmarks = g_file_resolve_relative_path (home, ".gtk-bookmarks");
90
@@ -1221,13 +1205,21 @@ thunar_shortcuts_model_volume_added (GVo
92
ThunarShortcutsModel *model)
95
+ gboolean found = FALSE;
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));
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;
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));
112
/* let the "changed" handler place the volume where appropriate */
113
thunar_shortcuts_model_volume_changed (volume_monitor, volume, model);