Merge lp:~jassmith/netbook-remix-launcher/volumes into lp:netbook-remix-launcher

Proposed by Jason Smith
Status: Merged
Merged at revision: not available
Proposed branch: lp:~jassmith/netbook-remix-launcher/volumes
Merge into: lp:netbook-remix-launcher
Diff against target: None lines
To merge this branch: bzr merge lp:~jassmith/netbook-remix-launcher/volumes
Reviewer Review Type Date Requested Status
Neil J. Patel (community) Approve
Review via email: mp+11181@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jason Smith (jassmith) wrote :

Implements the fetching of volumes using code almost identical to how nautilus does it. This should bring our behavior to be more in line with theres. However we will need to perform additional work to match it directly. I have left in a commented block of code that represents part of our current deviation. Without this however, we will still hopefully be fixing bug #414787.

Revision history for this message
Neil J. Patel (njpatel) wrote :

This looks really good. Your right, we can leave the commented out code for later, it doesn't seem like it'll effect the majority of netbook owners. Approved.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/nl-volumes-source.c'
2--- src/nl-volumes-source.c 2009-08-11 13:34:04 +0000
3+++ src/nl-volumes-source.c 2009-09-04 05:37:08 +0000
4@@ -546,8 +546,12 @@
5 reload_volumes (NlVolumesSource *source)
6 {
7 NlVolumesSourcePrivate *priv;
8- GList *volumes, *v;
9- GList *children;
10+ GList *volumes, *v;
11+ GVolume *volume;
12+ GList *children;
13+ GList *drives, *d;
14+ GDrive *drive;
15+ NlIconTile *tile;
16
17 g_return_val_if_fail (NL_IS_VOLUMES_SOURCE (source), FALSE);
18 priv = source->priv;
19@@ -556,42 +560,109 @@
20 g_list_foreach (children, (GFunc)remove_child, priv->iconview);
21 g_list_free (children);
22
23- volumes = g_volume_monitor_get_volumes (priv->monitor);
24+ /* code that follows more or less stolen directly from nautilus GPL 2+*/
25
26- for (v = volumes; v; v = v->next)
27+ /* go through all our connected drives */
28+ drives = g_volume_monitor_get_connected_drives (priv->monitor);
29+ for (d = drives; d != NULL; d = d->next)
30 {
31- GVolume *volume = v->data;
32- NlIconTile *tile;
33-
34- if (volume_is_excluded (source, volume))
35+ drive = d->data;
36+
37+ volumes = g_drive_get_volumes (drive);
38+
39+ if (volumes != NULL)
40 {
41- g_object_unref (volume);
42- continue;
43+ for (v = volumes; v; v = v->next)
44+ {
45+ volume = v->data;
46+
47+ if (volume_is_excluded (source, volume))
48+ {
49+ g_object_unref (volume);
50+ continue;
51+ }
52+
53+ tile = make_tile_for_volume (source, volume);
54+ clutter_container_add_actor (CLUTTER_CONTAINER (priv->iconview),
55+ CLUTTER_ACTOR (tile));
56+
57+ update_emblem (tile, volume);
58+
59+ g_signal_connect (tile, "clicked", G_CALLBACK (on_volume_clicked), volume);
60+ g_signal_connect (tile, "show-context-menu",
61+ G_CALLBACK (show_menu), volume);
62+ g_signal_connect (tile, "emblem-clicked",
63+ G_CALLBACK (on_eject_clicked), volume);
64+
65+ g_signal_connect_swapped (volume, "changed",
66+ G_CALLBACK (update_emblem), tile);
67+ g_signal_connect_swapped (volume, "removed",
68+ G_CALLBACK (reload_volumes), source);
69+
70+ g_object_set_data (G_OBJECT (volume), "tile", tile);
71+ g_object_unref (volume);
72+ }
73+ g_list_free (volumes);
74 }
75-
76- tile = make_tile_for_volume (source, volume);
77- clutter_container_add_actor (CLUTTER_CONTAINER (priv->iconview),
78- CLUTTER_ACTOR (tile));
79-
80- update_emblem (tile, volume);
81-
82- g_signal_connect (tile, "clicked", G_CALLBACK (on_volume_clicked), volume);
83- g_signal_connect (tile, "show-context-menu",
84- G_CALLBACK (show_menu), volume);
85- g_signal_connect (tile, "emblem-clicked",
86- G_CALLBACK (on_eject_clicked), volume);
87-
88- g_signal_connect_swapped (volume, "changed",
89- G_CALLBACK (update_emblem), tile);
90- g_signal_connect_swapped (volume, "removed",
91- G_CALLBACK (reload_volumes), source);
92-
93- g_object_set_data (G_OBJECT (volume), "tile", tile);
94- g_object_unref (volume);
95+ /*else
96+ {
97+ if (g_drive_is_media_removable (drive) && !g_drive_is_media_check_automatic (drive))
98+ {
99+ * If the drive has no mountable volumes and we cannot detect media change.. we
100+ * display the drive in the sidebar so the user can manually poll the drive by
101+ * right clicking and selecting "Rescan..."
102+ *
103+ * This is mainly for drives like floppies where media detection doesn't
104+ * work.. but it's also for human beings who like to turn off media detection
105+ * in the OS to save battery juice.
106+ *
107+ icon = g_drive_get_icon (drive);
108+ name = g_drive_get_name (drive);
109+ last_iter = add_place (sidebar, PLACES_BUILT_IN,
110+ name, icon, NULL,
111+ drive, NULL, NULL, 0);
112+ g_object_unref (icon);
113+ g_free (name);
114+ }
115+ }*/
116+
117 }
118-
119- g_list_free (volumes);
120-
121+
122+ /* all volumes not associated with a drive */
123+ volumes = g_volume_monitor_get_volumes (priv->monitor);
124+ for (v = volumes; v != NULL; v = v->next)
125+ {
126+ volume = v->data;
127+ drive = g_volume_get_drive (volume);
128+ if (drive != NULL)
129+ {
130+ g_object_unref (volume);
131+ g_object_unref (drive);
132+ continue;
133+ }
134+
135+ tile = make_tile_for_volume (source, volume);
136+ clutter_container_add_actor (CLUTTER_CONTAINER (priv->iconview),
137+ CLUTTER_ACTOR (tile));
138+
139+ update_emblem (tile, volume);
140+
141+ g_signal_connect (tile, "clicked", G_CALLBACK (on_volume_clicked), volume);
142+ g_signal_connect (tile, "show-context-menu",
143+ G_CALLBACK (show_menu), volume);
144+ g_signal_connect (tile, "emblem-clicked",
145+ G_CALLBACK (on_eject_clicked), volume);
146+
147+ g_signal_connect_swapped (volume, "changed",
148+ G_CALLBACK (update_emblem), tile);
149+ g_signal_connect_swapped (volume, "removed",
150+ G_CALLBACK (reload_volumes), source);
151+
152+ g_object_set_data (G_OBJECT (volume), "tile", tile);
153+ g_object_unref (volume);
154+ }
155+ g_list_free (volumes);
156+
157 return FALSE;
158 }
159

Subscribers

People subscribed via source and target branches