Merge lp:~psusi/ubuntu/saucy/brasero/fix-drive-selector into lp:ubuntu/saucy/brasero
- Saucy (13.10)
- fix-drive-selector
- Merge into saucy
Proposed by
Phillip Susi
Status: | Needs review | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~psusi/ubuntu/saucy/brasero/fix-drive-selector | ||||
Merge into: | lp:ubuntu/saucy/brasero | ||||
Diff against target: |
793 lines (+731/-2) 6 files modified
.pc/05_populate-tree-model-after-construction.patch/libbrasero-media/brasero-drive-selection.c (+671/-0) .pc/applied-patches (+1/-0) debian/changelog (+8/-0) debian/patches/05_populate-tree-model-after-construction.patch (+42/-0) debian/patches/series (+1/-0) libbrasero-media/brasero-drive-selection.c (+8/-2) |
||||
To merge this branch: | bzr merge lp:~psusi/ubuntu/saucy/brasero/fix-drive-selector | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Timo Aaltonen | Approve | ||
Review via email: mp+190014@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Unmerged revisions
- 111. By Phillip Susi
-
debian/
patches/ 05_populate- tree-model- after-construct ion.patch:
backport upstream commit to fix drive selection not showing
up correctly (LP: #1237169).
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory '.pc/05_populate-tree-model-after-construction.patch' | |||
2 | === added directory '.pc/05_populate-tree-model-after-construction.patch/libbrasero-media' | |||
3 | === added file '.pc/05_populate-tree-model-after-construction.patch/libbrasero-media/brasero-drive-selection.c' | |||
4 | --- .pc/05_populate-tree-model-after-construction.patch/libbrasero-media/brasero-drive-selection.c 1970-01-01 00:00:00 +0000 | |||
5 | +++ .pc/05_populate-tree-model-after-construction.patch/libbrasero-media/brasero-drive-selection.c 2013-10-09 02:24:44 +0000 | |||
6 | @@ -0,0 +1,671 @@ | |||
7 | 1 | /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ | ||
8 | 2 | /* | ||
9 | 3 | * Libbrasero-media | ||
10 | 4 | * Copyright (C) Philippe Rouquier 2005-2009 <bonfire-app@wanadoo.fr> | ||
11 | 5 | * | ||
12 | 6 | * Libbrasero-media is free software; you can redistribute it and/or modify | ||
13 | 7 | * it under the terms of the GNU General Public License as published by | ||
14 | 8 | * the Free Software Foundation; either version 2 of the License, or | ||
15 | 9 | * (at your option) any later version. | ||
16 | 10 | * | ||
17 | 11 | * The Libbrasero-media authors hereby grant permission for non-GPL compatible | ||
18 | 12 | * GStreamer plugins to be used and distributed together with GStreamer | ||
19 | 13 | * and Libbrasero-media. This permission is above and beyond the permissions granted | ||
20 | 14 | * by the GPL license by which Libbrasero-media is covered. If you modify this code | ||
21 | 15 | * you may extend this exception to your version of the code, but you are not | ||
22 | 16 | * obligated to do so. If you do not wish to do so, delete this exception | ||
23 | 17 | * statement from your version. | ||
24 | 18 | * | ||
25 | 19 | * Libbrasero-media is distributed in the hope that it will be useful, | ||
26 | 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
27 | 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
28 | 22 | * GNU Library General Public License for more details. | ||
29 | 23 | * | ||
30 | 24 | * You should have received a copy of the GNU General Public License | ||
31 | 25 | * along with this program; if not, write to: | ||
32 | 26 | * The Free Software Foundation, Inc., | ||
33 | 27 | * 51 Franklin Street, Fifth Floor | ||
34 | 28 | * Boston, MA 02110-1301, USA. | ||
35 | 29 | */ | ||
36 | 30 | |||
37 | 31 | #ifdef HAVE_CONFIG_H | ||
38 | 32 | # include <config.h> | ||
39 | 33 | #endif | ||
40 | 34 | |||
41 | 35 | #include <glib.h> | ||
42 | 36 | #include <glib-object.h> | ||
43 | 37 | #include <glib/gi18n-lib.h> | ||
44 | 38 | |||
45 | 39 | #include <gtk/gtk.h> | ||
46 | 40 | |||
47 | 41 | #include "brasero-drive-selection.h" | ||
48 | 42 | #include "brasero-medium-monitor.h" | ||
49 | 43 | #include "brasero-drive.h" | ||
50 | 44 | #include "brasero-units.h" | ||
51 | 45 | |||
52 | 46 | typedef struct _BraseroDriveSelectionPrivate BraseroDriveSelectionPrivate; | ||
53 | 47 | struct _BraseroDriveSelectionPrivate | ||
54 | 48 | { | ||
55 | 49 | BraseroDrive *active; | ||
56 | 50 | |||
57 | 51 | BraseroDriveType type; | ||
58 | 52 | gulong added_sig; | ||
59 | 53 | gulong removed_sig; | ||
60 | 54 | }; | ||
61 | 55 | |||
62 | 56 | #define BRASERO_DRIVE_SELECTION_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_DRIVE_SELECTION, BraseroDriveSelectionPrivate)) | ||
63 | 57 | |||
64 | 58 | typedef enum { | ||
65 | 59 | CHANGED_SIGNAL, | ||
66 | 60 | LAST_SIGNAL | ||
67 | 61 | } BraseroDriveSelectionSignalType; | ||
68 | 62 | |||
69 | 63 | /* GtkBuildable */ | ||
70 | 64 | static GtkBuildableIface *parent_buildable_iface; | ||
71 | 65 | |||
72 | 66 | static guint brasero_drive_selection_signals [LAST_SIGNAL] = { 0 }; | ||
73 | 67 | |||
74 | 68 | enum { | ||
75 | 69 | PROP_0, | ||
76 | 70 | PROP_DRIVE, | ||
77 | 71 | PROP_DRIVE_TYPE | ||
78 | 72 | }; | ||
79 | 73 | |||
80 | 74 | enum { | ||
81 | 75 | DRIVE_COL, | ||
82 | 76 | NAME_COL, | ||
83 | 77 | ICON_COL, | ||
84 | 78 | NUM_COL | ||
85 | 79 | }; | ||
86 | 80 | |||
87 | 81 | |||
88 | 82 | static void | ||
89 | 83 | brasero_drive_selection_buildable_init (GtkBuildableIface *iface) | ||
90 | 84 | { | ||
91 | 85 | parent_buildable_iface = g_type_interface_peek_parent (iface); | ||
92 | 86 | } | ||
93 | 87 | |||
94 | 88 | G_DEFINE_TYPE_WITH_CODE (BraseroDriveSelection, brasero_drive_selection, GTK_TYPE_COMBO_BOX, G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, brasero_drive_selection_buildable_init)); | ||
95 | 89 | |||
96 | 90 | static void | ||
97 | 91 | brasero_drive_selection_set_current_drive (BraseroDriveSelection *self, | ||
98 | 92 | GtkTreeIter *iter) | ||
99 | 93 | { | ||
100 | 94 | BraseroDriveSelectionPrivate *priv; | ||
101 | 95 | BraseroDrive *drive; | ||
102 | 96 | GtkTreeModel *model; | ||
103 | 97 | |||
104 | 98 | priv = BRASERO_DRIVE_SELECTION_PRIVATE (self); | ||
105 | 99 | |||
106 | 100 | model = gtk_combo_box_get_model (GTK_COMBO_BOX (self)); | ||
107 | 101 | gtk_tree_model_get (model, iter, | ||
108 | 102 | DRIVE_COL, &drive, | ||
109 | 103 | -1); | ||
110 | 104 | |||
111 | 105 | if (drive) | ||
112 | 106 | gtk_widget_set_sensitive (GTK_WIDGET (self), TRUE); | ||
113 | 107 | else | ||
114 | 108 | gtk_widget_set_sensitive (GTK_WIDGET (self), FALSE); | ||
115 | 109 | |||
116 | 110 | if (priv->active == drive) | ||
117 | 111 | return; | ||
118 | 112 | |||
119 | 113 | if (priv->active) | ||
120 | 114 | g_object_unref (priv->active); | ||
121 | 115 | |||
122 | 116 | priv->active = drive; | ||
123 | 117 | |||
124 | 118 | if (priv->active) | ||
125 | 119 | g_object_ref (priv->active); | ||
126 | 120 | |||
127 | 121 | g_signal_emit (self, | ||
128 | 122 | brasero_drive_selection_signals [CHANGED_SIGNAL], | ||
129 | 123 | 0, | ||
130 | 124 | priv->active); | ||
131 | 125 | } | ||
132 | 126 | |||
133 | 127 | static void | ||
134 | 128 | brasero_drive_selection_changed (GtkComboBox *combo) | ||
135 | 129 | { | ||
136 | 130 | GtkTreeIter iter; | ||
137 | 131 | |||
138 | 132 | if (!gtk_combo_box_get_active_iter (combo, &iter)) | ||
139 | 133 | return; | ||
140 | 134 | |||
141 | 135 | brasero_drive_selection_set_current_drive (BRASERO_DRIVE_SELECTION (combo), &iter); | ||
142 | 136 | } | ||
143 | 137 | |||
144 | 138 | /** | ||
145 | 139 | * brasero_drive_selection_set_active: | ||
146 | 140 | * @selector: a #BraseroDriveSelection | ||
147 | 141 | * @drive: a #BraseroDrive to set as the active one in the selector | ||
148 | 142 | * | ||
149 | 143 | * Sets the active drive. Emits the ::drive-changed signal. | ||
150 | 144 | * | ||
151 | 145 | * Return value: a #gboolean. TRUE if it succeeded, FALSE otherwise. | ||
152 | 146 | **/ | ||
153 | 147 | gboolean | ||
154 | 148 | brasero_drive_selection_set_active (BraseroDriveSelection *selector, | ||
155 | 149 | BraseroDrive *drive) | ||
156 | 150 | { | ||
157 | 151 | BraseroDriveSelectionPrivate *priv; | ||
158 | 152 | gboolean result = FALSE; | ||
159 | 153 | GtkTreeModel *model; | ||
160 | 154 | GtkTreeIter iter; | ||
161 | 155 | |||
162 | 156 | g_return_val_if_fail (selector != NULL, FALSE); | ||
163 | 157 | g_return_val_if_fail (BRASERO_IS_DRIVE_SELECTION (selector), FALSE); | ||
164 | 158 | |||
165 | 159 | priv = BRASERO_DRIVE_SELECTION_PRIVATE (selector); | ||
166 | 160 | |||
167 | 161 | if (priv->active == drive) | ||
168 | 162 | return TRUE; | ||
169 | 163 | |||
170 | 164 | model = gtk_combo_box_get_model (GTK_COMBO_BOX (selector)); | ||
171 | 165 | if (!gtk_tree_model_get_iter_first (model, &iter)) | ||
172 | 166 | return FALSE; | ||
173 | 167 | |||
174 | 168 | do { | ||
175 | 169 | BraseroDrive *iter_drive; | ||
176 | 170 | |||
177 | 171 | gtk_tree_model_get (model, &iter, | ||
178 | 172 | DRIVE_COL, &iter_drive, | ||
179 | 173 | -1); | ||
180 | 174 | |||
181 | 175 | if (drive == iter_drive) { | ||
182 | 176 | if (iter_drive) | ||
183 | 177 | g_object_unref (iter_drive); | ||
184 | 178 | |||
185 | 179 | gtk_combo_box_set_active_iter (GTK_COMBO_BOX (selector), &iter); | ||
186 | 180 | brasero_drive_selection_set_current_drive (selector, &iter); | ||
187 | 181 | result = TRUE; | ||
188 | 182 | break; | ||
189 | 183 | } | ||
190 | 184 | |||
191 | 185 | g_object_unref (iter_drive); | ||
192 | 186 | } while (gtk_tree_model_iter_next (model, &iter)); | ||
193 | 187 | |||
194 | 188 | return result; | ||
195 | 189 | } | ||
196 | 190 | |||
197 | 191 | /** | ||
198 | 192 | * brasero_drive_selection_get_active: | ||
199 | 193 | * @selector: a #BraseroDriveSelection | ||
200 | 194 | * | ||
201 | 195 | * Gets the active drive. | ||
202 | 196 | * | ||
203 | 197 | * Return value: a #BraseroDrive or NULL. Unref when it is not needed anymore. | ||
204 | 198 | **/ | ||
205 | 199 | BraseroDrive * | ||
206 | 200 | brasero_drive_selection_get_active (BraseroDriveSelection *selector) | ||
207 | 201 | { | ||
208 | 202 | BraseroDriveSelectionPrivate *priv; | ||
209 | 203 | |||
210 | 204 | g_return_val_if_fail (selector != NULL, NULL); | ||
211 | 205 | g_return_val_if_fail (BRASERO_IS_DRIVE_SELECTION (selector), NULL); | ||
212 | 206 | |||
213 | 207 | priv = BRASERO_DRIVE_SELECTION_PRIVATE (selector); | ||
214 | 208 | if (!priv->active) | ||
215 | 209 | return NULL; | ||
216 | 210 | |||
217 | 211 | return g_object_ref (priv->active); | ||
218 | 212 | } | ||
219 | 213 | |||
220 | 214 | static void | ||
221 | 215 | brasero_drive_selection_update_no_disc_entry (BraseroDriveSelection *self, | ||
222 | 216 | GtkTreeModel *model, | ||
223 | 217 | GtkTreeIter *iter) | ||
224 | 218 | { | ||
225 | 219 | GIcon *icon; | ||
226 | 220 | |||
227 | 221 | icon = g_themed_icon_new_with_default_fallbacks ("drive-optical"); | ||
228 | 222 | |||
229 | 223 | /* FIXME: that needs a string */ | ||
230 | 224 | gtk_list_store_set (GTK_LIST_STORE (model), iter, | ||
231 | 225 | NAME_COL, NULL, | ||
232 | 226 | ICON_COL, NULL, | ||
233 | 227 | -1); | ||
234 | 228 | |||
235 | 229 | g_object_unref (icon); | ||
236 | 230 | |||
237 | 231 | gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self), iter); | ||
238 | 232 | brasero_drive_selection_set_current_drive (self, iter); | ||
239 | 233 | } | ||
240 | 234 | |||
241 | 235 | static void | ||
242 | 236 | brasero_drive_selection_add_no_disc_entry (BraseroDriveSelection *self) | ||
243 | 237 | { | ||
244 | 238 | GtkTreeIter iter; | ||
245 | 239 | GtkTreeModel *model; | ||
246 | 240 | |||
247 | 241 | /* Nothing's available. Say it. Two cases here, either we're | ||
248 | 242 | * still probing drives or there isn't actually any available | ||
249 | 243 | * drive. */ | ||
250 | 244 | model = gtk_combo_box_get_model (GTK_COMBO_BOX (self)); | ||
251 | 245 | gtk_list_store_append (GTK_LIST_STORE (model), &iter); | ||
252 | 246 | brasero_drive_selection_update_no_disc_entry (self, model, &iter); | ||
253 | 247 | } | ||
254 | 248 | |||
255 | 249 | /** | ||
256 | 250 | * brasero_drive_selection_show_type: | ||
257 | 251 | * @selector: a #BraseroDriveSelection | ||
258 | 252 | * @type: a #BraseroDriveType | ||
259 | 253 | * | ||
260 | 254 | * Filters and displays drive corresponding to @type. | ||
261 | 255 | * | ||
262 | 256 | **/ | ||
263 | 257 | void | ||
264 | 258 | brasero_drive_selection_show_type (BraseroDriveSelection *selector, | ||
265 | 259 | BraseroDriveType type) | ||
266 | 260 | { | ||
267 | 261 | BraseroDriveSelectionPrivate *priv; | ||
268 | 262 | BraseroMediumMonitor *monitor; | ||
269 | 263 | GtkTreeModel *model; | ||
270 | 264 | GtkTreeIter iter; | ||
271 | 265 | GSList *list; | ||
272 | 266 | GSList *item; | ||
273 | 267 | |||
274 | 268 | g_return_if_fail (selector != NULL); | ||
275 | 269 | g_return_if_fail (BRASERO_IS_DRIVE_SELECTION (selector)); | ||
276 | 270 | |||
277 | 271 | priv = BRASERO_DRIVE_SELECTION_PRIVATE (selector); | ||
278 | 272 | |||
279 | 273 | priv->type = type; | ||
280 | 274 | |||
281 | 275 | monitor = brasero_medium_monitor_get_default (); | ||
282 | 276 | list = brasero_medium_monitor_get_drives (monitor, type); | ||
283 | 277 | g_object_unref (monitor); | ||
284 | 278 | |||
285 | 279 | model = gtk_combo_box_get_model (GTK_COMBO_BOX (selector)); | ||
286 | 280 | if (gtk_tree_model_get_iter_first (model, &iter)) { | ||
287 | 281 | /* First filter */ | ||
288 | 282 | do { | ||
289 | 283 | GSList *node; | ||
290 | 284 | BraseroDrive *drive; | ||
291 | 285 | |||
292 | 286 | gtk_tree_model_get (model, &iter, | ||
293 | 287 | DRIVE_COL, &drive, | ||
294 | 288 | -1); | ||
295 | 289 | |||
296 | 290 | if (!drive) { | ||
297 | 291 | /* That's the dummy line saying there isn't any | ||
298 | 292 | * available drive for whatever action it is */ | ||
299 | 293 | gtk_list_store_remove (GTK_LIST_STORE (model), &iter); | ||
300 | 294 | break; | ||
301 | 295 | } | ||
302 | 296 | |||
303 | 297 | node = g_slist_find (list, drive); | ||
304 | 298 | g_object_unref (drive); | ||
305 | 299 | |||
306 | 300 | if (!node) { | ||
307 | 301 | if (gtk_list_store_remove (GTK_LIST_STORE (model), &iter)) | ||
308 | 302 | continue; | ||
309 | 303 | |||
310 | 304 | /* no more iter in the tree get out */ | ||
311 | 305 | break; | ||
312 | 306 | } | ||
313 | 307 | |||
314 | 308 | g_object_unref (node->data); | ||
315 | 309 | list = g_slist_delete_link (list, node); | ||
316 | 310 | } while (gtk_tree_model_iter_next (model, &iter)); | ||
317 | 311 | } | ||
318 | 312 | |||
319 | 313 | if (list) { | ||
320 | 314 | /* add remaining drive */ | ||
321 | 315 | for (item = list; item; item = item->next) { | ||
322 | 316 | gchar *drive_name; | ||
323 | 317 | BraseroDrive *drive; | ||
324 | 318 | GIcon *drive_icon = NULL; | ||
325 | 319 | |||
326 | 320 | drive = item->data; | ||
327 | 321 | |||
328 | 322 | drive_name = brasero_drive_get_display_name (drive); | ||
329 | 323 | |||
330 | 324 | if (!brasero_drive_is_fake (drive)) { | ||
331 | 325 | GDrive *gdrive; | ||
332 | 326 | |||
333 | 327 | gdrive = brasero_drive_get_gdrive (drive); | ||
334 | 328 | if (gdrive) { | ||
335 | 329 | drive_icon = g_drive_get_icon (gdrive); | ||
336 | 330 | g_object_unref (gdrive); | ||
337 | 331 | } | ||
338 | 332 | else | ||
339 | 333 | drive_icon = g_themed_icon_new_with_default_fallbacks ("drive-optical"); | ||
340 | 334 | } | ||
341 | 335 | else | ||
342 | 336 | drive_icon = g_themed_icon_new_with_default_fallbacks ("iso-image-new"); | ||
343 | 337 | |||
344 | 338 | gtk_list_store_append (GTK_LIST_STORE (model), &iter); | ||
345 | 339 | gtk_list_store_set (GTK_LIST_STORE (model), &iter, | ||
346 | 340 | DRIVE_COL, drive, | ||
347 | 341 | NAME_COL, drive_name?drive_name:_("Unnamed CD/DVD Drive"), | ||
348 | 342 | ICON_COL, drive_icon, | ||
349 | 343 | -1); | ||
350 | 344 | g_free (drive_name); | ||
351 | 345 | g_object_unref (drive_icon); | ||
352 | 346 | } | ||
353 | 347 | g_slist_foreach (list, (GFunc) g_object_unref, NULL); | ||
354 | 348 | g_slist_free (list); | ||
355 | 349 | } | ||
356 | 350 | |||
357 | 351 | if (!gtk_tree_model_get_iter_first (model, &iter)) { | ||
358 | 352 | brasero_drive_selection_add_no_disc_entry (selector); | ||
359 | 353 | return; | ||
360 | 354 | } | ||
361 | 355 | |||
362 | 356 | gtk_widget_set_sensitive (GTK_WIDGET (selector), TRUE); | ||
363 | 357 | if (gtk_combo_box_get_active (GTK_COMBO_BOX (selector)) == -1) { | ||
364 | 358 | gtk_combo_box_set_active_iter (GTK_COMBO_BOX (selector), &iter); | ||
365 | 359 | brasero_drive_selection_set_current_drive (selector, &iter); | ||
366 | 360 | } | ||
367 | 361 | } | ||
368 | 362 | |||
369 | 363 | static void | ||
370 | 364 | brasero_drive_selection_drive_added_cb (BraseroMediumMonitor *monitor, | ||
371 | 365 | BraseroDrive *drive, | ||
372 | 366 | BraseroDriveSelection *self) | ||
373 | 367 | { | ||
374 | 368 | BraseroDriveSelectionPrivate *priv; | ||
375 | 369 | gchar *drive_name = NULL; | ||
376 | 370 | gboolean add = FALSE; | ||
377 | 371 | GtkTreeModel *model; | ||
378 | 372 | GIcon *drive_icon; | ||
379 | 373 | GtkTreeIter iter; | ||
380 | 374 | |||
381 | 375 | priv = BRASERO_DRIVE_SELECTION_PRIVATE (self); | ||
382 | 376 | |||
383 | 377 | if ((priv->type & BRASERO_DRIVE_TYPE_WRITER) | ||
384 | 378 | && (brasero_drive_can_write (drive))) | ||
385 | 379 | add = TRUE; | ||
386 | 380 | else if (priv->type & BRASERO_DRIVE_TYPE_READER) | ||
387 | 381 | add = TRUE; | ||
388 | 382 | |||
389 | 383 | model = gtk_combo_box_get_model (GTK_COMBO_BOX (self)); | ||
390 | 384 | |||
391 | 385 | if (!add) { | ||
392 | 386 | /* Try to get the first iter (it shouldn't fail) */ | ||
393 | 387 | if (!gtk_tree_model_get_iter_first (model, &iter)) { | ||
394 | 388 | brasero_drive_selection_add_no_disc_entry (self); | ||
395 | 389 | return; | ||
396 | 390 | } | ||
397 | 391 | |||
398 | 392 | /* See if that's a real drive or not; if so, return. */ | ||
399 | 393 | drive = NULL; | ||
400 | 394 | gtk_tree_model_get (model, &iter, | ||
401 | 395 | DRIVE_COL, &drive, | ||
402 | 396 | -1); | ||
403 | 397 | if (drive) | ||
404 | 398 | return; | ||
405 | 399 | |||
406 | 400 | brasero_drive_selection_update_no_disc_entry (self, model, &iter); | ||
407 | 401 | return; | ||
408 | 402 | } | ||
409 | 403 | |||
410 | 404 | /* remove warning message */ | ||
411 | 405 | if (gtk_tree_model_get_iter_first (model, &iter)) { | ||
412 | 406 | BraseroDrive *tmp; | ||
413 | 407 | |||
414 | 408 | gtk_tree_model_get (model, &iter, | ||
415 | 409 | DRIVE_COL, &tmp, | ||
416 | 410 | -1); | ||
417 | 411 | if (!tmp) | ||
418 | 412 | gtk_list_store_remove (GTK_LIST_STORE (model), &iter); | ||
419 | 413 | else | ||
420 | 414 | g_object_unref (tmp); | ||
421 | 415 | } | ||
422 | 416 | |||
423 | 417 | if (!brasero_drive_is_fake (drive)) { | ||
424 | 418 | GDrive *gdrive; | ||
425 | 419 | |||
426 | 420 | gdrive = brasero_drive_get_gdrive (drive); | ||
427 | 421 | if (gdrive) { | ||
428 | 422 | drive_icon = g_drive_get_icon (gdrive); | ||
429 | 423 | g_object_unref (gdrive); | ||
430 | 424 | } | ||
431 | 425 | else | ||
432 | 426 | drive_icon = g_themed_icon_new_with_default_fallbacks ("drive-optical"); | ||
433 | 427 | } | ||
434 | 428 | else | ||
435 | 429 | drive_icon = g_themed_icon_new_with_default_fallbacks ("iso-image-new"); | ||
436 | 430 | |||
437 | 431 | drive_name = brasero_drive_get_display_name (drive); | ||
438 | 432 | |||
439 | 433 | gtk_list_store_append (GTK_LIST_STORE (model), &iter); | ||
440 | 434 | gtk_list_store_set (GTK_LIST_STORE (model), &iter, | ||
441 | 435 | DRIVE_COL, drive, | ||
442 | 436 | NAME_COL, drive_name?drive_name:_("Unnamed CD/DVD Drive"), | ||
443 | 437 | ICON_COL, drive_icon, | ||
444 | 438 | -1); | ||
445 | 439 | g_free (drive_name); | ||
446 | 440 | g_object_unref (drive_icon); | ||
447 | 441 | |||
448 | 442 | gtk_widget_set_sensitive (GTK_WIDGET (self), TRUE); | ||
449 | 443 | if (gtk_combo_box_get_active (GTK_COMBO_BOX (self)) == -1) { | ||
450 | 444 | gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self), &iter); | ||
451 | 445 | brasero_drive_selection_set_current_drive (self, &iter); | ||
452 | 446 | } | ||
453 | 447 | } | ||
454 | 448 | |||
455 | 449 | static void | ||
456 | 450 | brasero_drive_selection_drive_removed_cb (BraseroMediumMonitor *monitor, | ||
457 | 451 | BraseroDrive *drive, | ||
458 | 452 | BraseroDriveSelection *self) | ||
459 | 453 | { | ||
460 | 454 | GtkTreeModel *model; | ||
461 | 455 | GtkTreeIter iter; | ||
462 | 456 | |||
463 | 457 | model = gtk_combo_box_get_model (GTK_COMBO_BOX (self)); | ||
464 | 458 | if (!gtk_tree_model_get_iter_first (model, &iter)) | ||
465 | 459 | return; | ||
466 | 460 | |||
467 | 461 | do { | ||
468 | 462 | BraseroDrive *iter_drive; | ||
469 | 463 | |||
470 | 464 | gtk_tree_model_get (model, &iter, | ||
471 | 465 | DRIVE_COL, &iter_drive, | ||
472 | 466 | -1); | ||
473 | 467 | |||
474 | 468 | if (drive == iter_drive) { | ||
475 | 469 | g_object_unref (iter_drive); | ||
476 | 470 | gtk_list_store_remove (GTK_LIST_STORE (model), &iter); | ||
477 | 471 | break; | ||
478 | 472 | } | ||
479 | 473 | |||
480 | 474 | /* Could be NULL if a message "there is no drive ..." is on */ | ||
481 | 475 | if (iter_drive) | ||
482 | 476 | g_object_unref (iter_drive); | ||
483 | 477 | |||
484 | 478 | } while (gtk_tree_model_iter_next (model, &iter)); | ||
485 | 479 | |||
486 | 480 | if (!gtk_tree_model_get_iter_first (model, &iter)) { | ||
487 | 481 | brasero_drive_selection_add_no_disc_entry (self); | ||
488 | 482 | return; | ||
489 | 483 | } | ||
490 | 484 | |||
491 | 485 | if (gtk_combo_box_get_active (GTK_COMBO_BOX (self)) == -1) { | ||
492 | 486 | gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self), &iter); | ||
493 | 487 | brasero_drive_selection_set_current_drive (self, &iter); | ||
494 | 488 | } | ||
495 | 489 | } | ||
496 | 490 | |||
497 | 491 | static void | ||
498 | 492 | brasero_drive_selection_init (BraseroDriveSelection *object) | ||
499 | 493 | { | ||
500 | 494 | GtkListStore *model; | ||
501 | 495 | GtkCellRenderer *renderer; | ||
502 | 496 | BraseroMediumMonitor *monitor; | ||
503 | 497 | BraseroDriveSelectionPrivate *priv; | ||
504 | 498 | |||
505 | 499 | priv = BRASERO_DRIVE_SELECTION_PRIVATE (object); | ||
506 | 500 | |||
507 | 501 | monitor = brasero_medium_monitor_get_default (); | ||
508 | 502 | priv->added_sig = g_signal_connect (monitor, | ||
509 | 503 | "drive-added", | ||
510 | 504 | G_CALLBACK (brasero_drive_selection_drive_added_cb), | ||
511 | 505 | object); | ||
512 | 506 | priv->removed_sig = g_signal_connect (monitor, | ||
513 | 507 | "drive-removed", | ||
514 | 508 | G_CALLBACK (brasero_drive_selection_drive_removed_cb), | ||
515 | 509 | object); | ||
516 | 510 | |||
517 | 511 | g_object_unref (monitor); | ||
518 | 512 | |||
519 | 513 | /* get the list and fill the model */ | ||
520 | 514 | model = gtk_list_store_new (NUM_COL, | ||
521 | 515 | G_TYPE_OBJECT, | ||
522 | 516 | G_TYPE_STRING, | ||
523 | 517 | G_TYPE_ICON); | ||
524 | 518 | |||
525 | 519 | gtk_combo_box_set_model (GTK_COMBO_BOX (object), GTK_TREE_MODEL (model)); | ||
526 | 520 | g_object_unref (model); | ||
527 | 521 | |||
528 | 522 | renderer = gtk_cell_renderer_pixbuf_new (); | ||
529 | 523 | g_object_set (renderer, "follow-state", TRUE, NULL); | ||
530 | 524 | gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (object), renderer, FALSE); | ||
531 | 525 | gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object), renderer, | ||
532 | 526 | "gicon", ICON_COL, | ||
533 | 527 | NULL); | ||
534 | 528 | |||
535 | 529 | renderer = gtk_cell_renderer_text_new (); | ||
536 | 530 | g_object_set (renderer, "xpad", 8, NULL); | ||
537 | 531 | gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (object), renderer, TRUE); | ||
538 | 532 | gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object), renderer, | ||
539 | 533 | "markup", NAME_COL, | ||
540 | 534 | NULL); | ||
541 | 535 | |||
542 | 536 | brasero_drive_selection_show_type (BRASERO_DRIVE_SELECTION (object), | ||
543 | 537 | BRASERO_DRIVE_TYPE_ALL_BUT_FILE); | ||
544 | 538 | |||
545 | 539 | } | ||
546 | 540 | |||
547 | 541 | static void | ||
548 | 542 | brasero_drive_selection_finalize (GObject *object) | ||
549 | 543 | { | ||
550 | 544 | BraseroDriveSelectionPrivate *priv; | ||
551 | 545 | BraseroMediumMonitor *monitor; | ||
552 | 546 | |||
553 | 547 | priv = BRASERO_DRIVE_SELECTION_PRIVATE (object); | ||
554 | 548 | |||
555 | 549 | monitor = brasero_medium_monitor_get_default (); | ||
556 | 550 | |||
557 | 551 | g_signal_handler_disconnect (monitor, priv->added_sig); | ||
558 | 552 | g_signal_handler_disconnect (monitor, priv->removed_sig); | ||
559 | 553 | priv->removed_sig = 0; | ||
560 | 554 | priv->added_sig = 0; | ||
561 | 555 | |||
562 | 556 | g_object_unref (monitor); | ||
563 | 557 | |||
564 | 558 | G_OBJECT_CLASS (brasero_drive_selection_parent_class)->finalize (object); | ||
565 | 559 | } | ||
566 | 560 | |||
567 | 561 | static void | ||
568 | 562 | brasero_drive_selection_set_property (GObject *object, | ||
569 | 563 | guint prop_id, | ||
570 | 564 | const GValue *value, | ||
571 | 565 | GParamSpec *pspec) | ||
572 | 566 | { | ||
573 | 567 | g_return_if_fail (BRASERO_IS_DRIVE_SELECTION (object)); | ||
574 | 568 | |||
575 | 569 | switch (prop_id) | ||
576 | 570 | { | ||
577 | 571 | case PROP_DRIVE_TYPE: | ||
578 | 572 | brasero_drive_selection_show_type (BRASERO_DRIVE_SELECTION (object), | ||
579 | 573 | g_value_get_uint (value)); | ||
580 | 574 | break; | ||
581 | 575 | case PROP_DRIVE: | ||
582 | 576 | brasero_drive_selection_set_active (BRASERO_DRIVE_SELECTION (object), | ||
583 | 577 | BRASERO_DRIVE (g_value_get_object (value))); | ||
584 | 578 | break; | ||
585 | 579 | default: | ||
586 | 580 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | ||
587 | 581 | break; | ||
588 | 582 | } | ||
589 | 583 | } | ||
590 | 584 | |||
591 | 585 | static void | ||
592 | 586 | brasero_drive_selection_get_property (GObject *object, | ||
593 | 587 | guint prop_id, | ||
594 | 588 | GValue *value, | ||
595 | 589 | GParamSpec *pspec) | ||
596 | 590 | { | ||
597 | 591 | BraseroDriveSelectionPrivate *priv; | ||
598 | 592 | |||
599 | 593 | g_return_if_fail (BRASERO_IS_DRIVE_SELECTION (object)); | ||
600 | 594 | |||
601 | 595 | priv = BRASERO_DRIVE_SELECTION_PRIVATE (object); | ||
602 | 596 | |||
603 | 597 | switch (prop_id) | ||
604 | 598 | { | ||
605 | 599 | case PROP_DRIVE_TYPE: | ||
606 | 600 | g_value_set_uint (value, priv->type); | ||
607 | 601 | break; | ||
608 | 602 | case PROP_DRIVE: | ||
609 | 603 | g_value_set_object (value, brasero_drive_selection_get_active (BRASERO_DRIVE_SELECTION (object))); | ||
610 | 604 | break; | ||
611 | 605 | default: | ||
612 | 606 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); | ||
613 | 607 | break; | ||
614 | 608 | } | ||
615 | 609 | } | ||
616 | 610 | |||
617 | 611 | static void | ||
618 | 612 | brasero_drive_selection_class_init (BraseroDriveSelectionClass *klass) | ||
619 | 613 | { | ||
620 | 614 | GObjectClass* object_class = G_OBJECT_CLASS (klass); | ||
621 | 615 | GtkComboBoxClass *combo_class = GTK_COMBO_BOX_CLASS (klass); | ||
622 | 616 | |||
623 | 617 | g_type_class_add_private (klass, sizeof (BraseroDriveSelectionPrivate)); | ||
624 | 618 | |||
625 | 619 | object_class->finalize = brasero_drive_selection_finalize; | ||
626 | 620 | object_class->set_property = brasero_drive_selection_set_property; | ||
627 | 621 | object_class->get_property = brasero_drive_selection_get_property; | ||
628 | 622 | |||
629 | 623 | combo_class->changed = brasero_drive_selection_changed; | ||
630 | 624 | |||
631 | 625 | g_object_class_install_property (object_class, PROP_DRIVE, | ||
632 | 626 | g_param_spec_object ("Drive", | ||
633 | 627 | "Selected drive", | ||
634 | 628 | "The currently selected drive", | ||
635 | 629 | BRASERO_TYPE_DRIVE, G_PARAM_READWRITE)); | ||
636 | 630 | |||
637 | 631 | g_object_class_install_property (object_class, PROP_DRIVE_TYPE, | ||
638 | 632 | g_param_spec_uint ("drive-type", | ||
639 | 633 | "The type of drives", | ||
640 | 634 | "The type of drives displayed", | ||
641 | 635 | 0, BRASERO_DRIVE_TYPE_ALL, | ||
642 | 636 | BRASERO_DRIVE_TYPE_ALL_BUT_FILE, | ||
643 | 637 | G_PARAM_READWRITE)); | ||
644 | 638 | /** | ||
645 | 639 | * BraseroDriveSelection::drive-changed: | ||
646 | 640 | * @selector: the object which received the signal | ||
647 | 641 | * @drive: the drive which is now selected | ||
648 | 642 | * | ||
649 | 643 | * This signal gets emitted when the selected medium has changed | ||
650 | 644 | * | ||
651 | 645 | */ | ||
652 | 646 | brasero_drive_selection_signals [CHANGED_SIGNAL] = | ||
653 | 647 | g_signal_new ("drive_changed", | ||
654 | 648 | BRASERO_TYPE_DRIVE_SELECTION, | ||
655 | 649 | G_SIGNAL_RUN_FIRST|G_SIGNAL_ACTION|G_SIGNAL_NO_RECURSE, | ||
656 | 650 | G_STRUCT_OFFSET (BraseroDriveSelectionClass, drive_changed), | ||
657 | 651 | NULL, | ||
658 | 652 | NULL, | ||
659 | 653 | g_cclosure_marshal_VOID__OBJECT, | ||
660 | 654 | G_TYPE_NONE, | ||
661 | 655 | 1, | ||
662 | 656 | BRASERO_TYPE_DRIVE); | ||
663 | 657 | } | ||
664 | 658 | |||
665 | 659 | /** | ||
666 | 660 | * brasero_drive_selection_new: | ||
667 | 661 | * | ||
668 | 662 | * Creates a new #BraseroDriveSelection object | ||
669 | 663 | * | ||
670 | 664 | * Return value: a #GtkWidget. Unref when it is not needed anymore. | ||
671 | 665 | **/ | ||
672 | 666 | |||
673 | 667 | GtkWidget * | ||
674 | 668 | brasero_drive_selection_new (void) | ||
675 | 669 | { | ||
676 | 670 | return g_object_new (BRASERO_TYPE_DRIVE_SELECTION, NULL); | ||
677 | 671 | } | ||
678 | 0 | 672 | ||
679 | === modified file '.pc/applied-patches' | |||
680 | --- .pc/applied-patches 2013-06-05 21:22:12 +0000 | |||
681 | +++ .pc/applied-patches 2013-10-09 02:24:44 +0000 | |||
682 | @@ -1,5 +1,6 @@ | |||
683 | 1 | 01_grafted_folders.patch | 1 | 01_grafted_folders.patch |
684 | 2 | 03_cue-invalid-frame-75.patch | 2 | 03_cue-invalid-frame-75.patch |
685 | 3 | 04_tracker-0.16.patch | 3 | 04_tracker-0.16.patch |
686 | 4 | 05_populate-tree-model-after-construction.patch | ||
687 | 4 | 012_appindicator.patch | 5 | 012_appindicator.patch |
688 | 5 | 013_unity_launcher_progress.patch | 6 | 013_unity_launcher_progress.patch |
689 | 6 | 7 | ||
690 | === modified file 'debian/changelog' | |||
691 | --- debian/changelog 2013-06-05 21:44:05 +0000 | |||
692 | +++ debian/changelog 2013-10-09 02:24:44 +0000 | |||
693 | @@ -1,3 +1,11 @@ | |||
694 | 1 | brasero (3.8.0-1ubuntu3) UNRELEASED; urgency=low | ||
695 | 2 | |||
696 | 3 | * debian/patches/05_populate-tree-model-after-construction.patch: | ||
697 | 4 | backport upstream commit to fix drive selection not showing | ||
698 | 5 | up correctly (LP: #1237169). | ||
699 | 6 | |||
700 | 7 | -- Phillip Susi <psusi@ubuntu.com> Tue, 08 Oct 2013 21:51:54 -0400 | ||
701 | 8 | |||
702 | 1 | brasero (3.8.0-1ubuntu2) saucy; urgency=low | 9 | brasero (3.8.0-1ubuntu2) saucy; urgency=low |
703 | 2 | 10 | ||
704 | 3 | * Fix configure flags from last upload | 11 | * Fix configure flags from last upload |
705 | 4 | 12 | ||
706 | === added file 'debian/patches/05_populate-tree-model-after-construction.patch' | |||
707 | --- debian/patches/05_populate-tree-model-after-construction.patch 1970-01-01 00:00:00 +0000 | |||
708 | +++ debian/patches/05_populate-tree-model-after-construction.patch 2013-10-09 02:24:44 +0000 | |||
709 | @@ -0,0 +1,42 @@ | |||
710 | 1 | From 4cdec3b2aa5e726714d34fff003480403ae6ae77 Mon Sep 17 00:00:00 2001 | ||
711 | 2 | From: Jonh Wendell <jonh.wendell@intel.com> | ||
712 | 3 | Date: Wed, 19 Jun 2013 15:19:29 +0000 | ||
713 | 4 | Subject: brasero-drive-selection: populate the tree model after construction | ||
714 | 5 | |||
715 | 6 | Having it in the init was leading to an issue in the draw. | ||
716 | 7 | Postpone it to constructed phase fixes it. | ||
717 | 8 | --- | ||
718 | 9 | diff --git a/libbrasero-media/brasero-drive-selection.c b/libbrasero-media/brasero-drive-selection.c | ||
719 | 10 | index 0e4bad6..7aa8275 100644 | ||
720 | 11 | --- a/libbrasero-media/brasero-drive-selection.c | ||
721 | 12 | +++ b/libbrasero-media/brasero-drive-selection.c | ||
722 | 13 | @@ -532,12 +532,17 @@ brasero_drive_selection_init (BraseroDriveSelection *object) | ||
723 | 14 | gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object), renderer, | ||
724 | 15 | "markup", NAME_COL, | ||
725 | 16 | NULL); | ||
726 | 17 | +} | ||
727 | 18 | + | ||
728 | 19 | +static void | ||
729 | 20 | +brasero_drive_selection_constructed (GObject *object) | ||
730 | 21 | +{ | ||
731 | 22 | + G_OBJECT_CLASS (brasero_drive_selection_parent_class)->constructed (object); | ||
732 | 23 | |||
733 | 24 | brasero_drive_selection_show_type (BRASERO_DRIVE_SELECTION (object), | ||
734 | 25 | BRASERO_DRIVE_TYPE_ALL_BUT_FILE); | ||
735 | 26 | - | ||
736 | 27 | } | ||
737 | 28 | - | ||
738 | 29 | + | ||
739 | 30 | static void | ||
740 | 31 | brasero_drive_selection_finalize (GObject *object) | ||
741 | 32 | { | ||
742 | 33 | @@ -619,6 +624,7 @@ brasero_drive_selection_class_init (BraseroDriveSelectionClass *klass) | ||
743 | 34 | object_class->finalize = brasero_drive_selection_finalize; | ||
744 | 35 | object_class->set_property = brasero_drive_selection_set_property; | ||
745 | 36 | object_class->get_property = brasero_drive_selection_get_property; | ||
746 | 37 | + object_class->constructed = brasero_drive_selection_constructed; | ||
747 | 38 | |||
748 | 39 | combo_class->changed = brasero_drive_selection_changed; | ||
749 | 40 | |||
750 | 41 | -- | ||
751 | 42 | cgit v0.9.2 | ||
752 | 0 | 43 | ||
753 | === modified file 'debian/patches/series' | |||
754 | --- debian/patches/series 2013-06-05 21:22:12 +0000 | |||
755 | +++ debian/patches/series 2013-10-09 02:24:44 +0000 | |||
756 | @@ -1,5 +1,6 @@ | |||
757 | 1 | 01_grafted_folders.patch | 1 | 01_grafted_folders.patch |
758 | 2 | 03_cue-invalid-frame-75.patch | 2 | 03_cue-invalid-frame-75.patch |
759 | 3 | 04_tracker-0.16.patch | 3 | 04_tracker-0.16.patch |
760 | 4 | 05_populate-tree-model-after-construction.patch | ||
761 | 4 | 012_appindicator.patch | 5 | 012_appindicator.patch |
762 | 5 | 013_unity_launcher_progress.patch | 6 | 013_unity_launcher_progress.patch |
763 | 6 | 7 | ||
764 | === modified file 'libbrasero-media/brasero-drive-selection.c' | |||
765 | --- libbrasero-media/brasero-drive-selection.c 2011-05-18 17:53:39 +0000 | |||
766 | +++ libbrasero-media/brasero-drive-selection.c 2013-10-09 02:24:44 +0000 | |||
767 | @@ -532,12 +532,17 @@ | |||
768 | 532 | gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object), renderer, | 532 | gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (object), renderer, |
769 | 533 | "markup", NAME_COL, | 533 | "markup", NAME_COL, |
770 | 534 | NULL); | 534 | NULL); |
771 | 535 | } | ||
772 | 536 | |||
773 | 537 | static void | ||
774 | 538 | brasero_drive_selection_constructed (GObject *object) | ||
775 | 539 | { | ||
776 | 540 | G_OBJECT_CLASS (brasero_drive_selection_parent_class)->constructed (object); | ||
777 | 535 | 541 | ||
778 | 536 | brasero_drive_selection_show_type (BRASERO_DRIVE_SELECTION (object), | 542 | brasero_drive_selection_show_type (BRASERO_DRIVE_SELECTION (object), |
779 | 537 | BRASERO_DRIVE_TYPE_ALL_BUT_FILE); | 543 | BRASERO_DRIVE_TYPE_ALL_BUT_FILE); |
780 | 538 | |||
781 | 539 | } | 544 | } |
783 | 540 | 545 | ||
784 | 541 | static void | 546 | static void |
785 | 542 | brasero_drive_selection_finalize (GObject *object) | 547 | brasero_drive_selection_finalize (GObject *object) |
786 | 543 | { | 548 | { |
787 | @@ -619,6 +624,7 @@ | |||
788 | 619 | object_class->finalize = brasero_drive_selection_finalize; | 624 | object_class->finalize = brasero_drive_selection_finalize; |
789 | 620 | object_class->set_property = brasero_drive_selection_set_property; | 625 | object_class->set_property = brasero_drive_selection_set_property; |
790 | 621 | object_class->get_property = brasero_drive_selection_get_property; | 626 | object_class->get_property = brasero_drive_selection_get_property; |
791 | 627 | object_class->constructed = brasero_drive_selection_constructed; | ||
792 | 622 | 628 | ||
793 | 623 | combo_class->changed = brasero_drive_selection_changed; | 629 | combo_class->changed = brasero_drive_selection_changed; |
794 | 624 | 630 |