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