Merge lp:~elementary-apps/noise/tabs-to-spaces into lp:~elementary-apps/noise/trunk

Proposed by Danielle Foré
Status: Merged
Approved by: David Gomes
Approved revision: 1581
Merged at revision: 1578
Proposed branch: lp:~elementary-apps/noise/tabs-to-spaces
Merge into: lp:~elementary-apps/noise/trunk
Diff against target: 1699 lines (+820/-825)
5 files modified
src/Dialogs/FileNotFoundDialog.vala (+152/-153)
src/Dialogs/InstallGstreamerPluginsDialog.vala (+69/-70)
src/Dialogs/NotImportedWindow.vala (+204/-205)
src/Dialogs/SetMusicFolderConfirmation.vala (+125/-125)
src/Dialogs/TransferFromDeviceDialog.vala (+270/-272)
To merge this branch: bzr merge lp:~elementary-apps/noise/tabs-to-spaces
Reviewer Review Type Date Requested Status
David Gomes (community) Approve
Review via email: mp+216553@code.launchpad.net

Commit message

Convert tabs to spaces in Dialogs

Description of the change

Convert tabs to spaces in Dialogs

To post a comment you must log in.
Revision history for this message
David Gomes (davidgomes) wrote :

Are you doing any more or can I merge? Builds and runs for me.

review: Approve
Revision history for this message
Danielle Foré (danrabbit) wrote :

Yeah let's merge. I want to come back and do other branches for dialogs but it's not directly related.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Dialogs/FileNotFoundDialog.vala'
2--- src/Dialogs/FileNotFoundDialog.vala 2014-04-19 22:03:29 +0000
3+++ src/Dialogs/FileNotFoundDialog.vala 2014-04-20 17:31:49 +0000
4@@ -30,158 +30,157 @@
5 */
6
7 public class Noise.FileNotFoundDialog : Gtk.Window {
8- Gee.LinkedList<Media> media_list;
9-
10- private Gtk.Box content;
11- private Gtk.Box padding;
12-
13- Gtk.Button removeMedia;
14- Gtk.Button locateMedia;
15- Gtk.Button rescanLibrary;
16- Gtk.Button doNothing;
17-
18- public FileNotFoundDialog (Gee.LinkedList<Media> media_list) {
19- this.media_list = media_list;
20-
21- // set the size based on saved gconf settings
22- //this.window_position = WindowPosition.CENTER;
23- this.type_hint = Gdk.WindowTypeHint.DIALOG;
24- this.title = ((Noise.App) GLib.Application.get_default ()).get_name ();
25- this.set_modal (true);
26- this.set_transient_for (App.main_window);
27- this.destroy_with_parent = true;
28-
29- set_default_size(475, -1);
30- resizable = false;
31-
32- content = new Gtk.Box (Gtk.Orientation.VERTICAL, 10);
33- padding = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 20);
34-
35- // initialize controls
36- Gtk.Image warning = new Gtk.Image.from_icon_name ("dialog-error", Gtk.IconSize.DIALOG);
37- Gtk.Label title = new Gtk.Label("");
38- Gtk.Label info = new Gtk.Label("");
39- removeMedia = new Gtk.Button.with_label(_("Remove Media"));
40- locateMedia = new Gtk.Button.with_label(_("Locate Media"));
41- rescanLibrary = new Gtk.Button.with_label(_("Rescan Library"));
42- doNothing = new Gtk.Button.with_label(_("Do Nothing"));
43-
44- // pretty up labels
45-
46- // be a bit explicit to make translations better
47- var MARKUP_TEMPLATE = "<span weight=\"bold\" size=\"larger\">%s</span>";
48- var title_string = MARKUP_TEMPLATE.printf (String.escape (_("Could not find media file")));
49- title.set_markup (title_string);
50- title.xalign = 0.0f; //FIXME: deprecated
51-
52- info.set_line_wrap (true);
53- info.xalign = 0.0f; //FIXME: deprecated
54-
55- if (media_list.size == 1) {
56- var s = media_list.get (0);
57- info.set_markup (_("The music file for $NAME by $ARTIST could not be found. What would you like to do?").replace ("$NAME", s.title.escape ("")).replace ("$ARTIST", s.artist.escape ("")));
58- }
59- else {
60- info.set_text (_("%i media files could not be found. What would you like to do?").printf (media_list.size));
61- }
62-
63-
64-
65- rescanLibrary.set_sensitive(!libraries_manager.local_library.doing_file_operations());
66-
67- /* set up controls layout */
68- var information = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
69- var information_text = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
70- information.pack_start(warning, false, false, 10);
71- information_text.pack_start(title, false, true, 10);
72- information_text.pack_start(info, false, true, 0);
73- information.pack_start(information_text, true, true, 10);
74-
75- var bottomButtons = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL);
76- bottomButtons.set_layout(Gtk.ButtonBoxStyle.END);
77- bottomButtons.pack_end(removeMedia, false, false, 0);
78- bottomButtons.pack_end(rescanLibrary, false, false, 0);
79- bottomButtons.pack_end(locateMedia, false, false, 0);
80- bottomButtons.pack_end(doNothing, false, false, 10);
81- bottomButtons.set_spacing(10);
82-
83- content.pack_start(information, false, true, 0);
84- content.pack_start(bottomButtons, false, true, 10);
85-
86- padding.pack_start(content, true, true, 10);
87-
88- removeMedia.clicked.connect(removeMediaClicked);
89- locateMedia.clicked.connect(locateMediaClicked);
90- rescanLibrary.clicked.connect(rescanLibraryClicked);
91- doNothing.clicked.connect( () => {
92- this.destroy();
93- });
94-
95- libraries_manager.local_library.file_operations_started.connect(file_operations_started);
96- libraries_manager.local_library.file_operations_done.connect(file_operations_done);
97-
98- add(padding);
99- show_all();
100- }
101-
102- void removeMediaClicked() {
103- libraries_manager.local_library.remove_medias (media_list, false);
104-
105- this.destroy();
106- }
107-
108- void locateMediaClicked() {
109- Media m = media_list.get(0);
110- int media_id = m.rowid;
111-
112- string file = "";
113- var file_chooser = new Gtk.FileChooserDialog (_("Choose Music Folder"), this,
114- Gtk.FileChooserAction.OPEN,
115- _(STRING_CANCEL), Gtk.ResponseType.CANCEL,
116- _(STRING_OPEN), Gtk.ResponseType.ACCEPT);
117-
118- // try and help user by setting a sane default folder
119- var invalid_file = File.new_for_uri(libraries_manager.local_library.media_from_id(media_id).uri);
120- var music_folder = Settings.Main.get_default ().music_folder;
121- if(invalid_file.get_parent().query_exists())
122- file_chooser.set_current_folder(invalid_file.get_parent().get_path());
123- else if(invalid_file.get_parent().get_parent().query_exists() &&
124- invalid_file.get_parent ().get_parent ().get_path ().contains (music_folder))
125- file_chooser.set_current_folder(invalid_file.get_parent().get_parent().get_path());
126- else if(File.new_for_path (music_folder).query_exists ())
127- file_chooser.set_current_folder (music_folder);
128- else
129- file_chooser.set_current_folder(Environment.get_home_dir());
130-
131- if (file_chooser.run () == Gtk.ResponseType.ACCEPT) {
132- file = file_chooser.get_filename();
133- }
134-
135- file_chooser.destroy ();
136-
137- if(file != "" && File.new_for_path(file).query_exists()) {
138- m.uri = File.new_for_path(file).get_uri();
139- m.location_unknown = false;
140- m.unique_status_image = null;
141- // TODO: lm.lw.media_found(m.rowid);
142- libraries_manager.local_library.update_media (m, false, false);
143-
144- this.destroy();
145- }
146- }
147-
148- void rescanLibraryClicked() {
149+ Gee.LinkedList<Media> media_list;
150+
151+ private Gtk.Box content;
152+ private Gtk.Box padding;
153+
154+ Gtk.Button removeMedia;
155+ Gtk.Button locateMedia;
156+ Gtk.Button rescanLibrary;
157+ Gtk.Button doNothing;
158+
159+ public FileNotFoundDialog (Gee.LinkedList<Media> media_list) {
160+ this.media_list = media_list;
161+
162+ // set the size based on saved gconf settings
163+ //this.window_position = WindowPosition.CENTER;
164+ this.type_hint = Gdk.WindowTypeHint.DIALOG;
165+ this.title = ((Noise.App) GLib.Application.get_default ()).get_name ();
166+ this.set_modal (true);
167+ this.set_transient_for (App.main_window);
168+ this.destroy_with_parent = true;
169+
170+ set_default_size(475, -1);
171+ resizable = false;
172+
173+ content = new Gtk.Box (Gtk.Orientation.VERTICAL, 10);
174+ padding = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 20);
175+
176+ // initialize controls
177+ Gtk.Image warning = new Gtk.Image.from_icon_name ("dialog-error", Gtk.IconSize.DIALOG);
178+ Gtk.Label title = new Gtk.Label("");
179+ Gtk.Label info = new Gtk.Label("");
180+ removeMedia = new Gtk.Button.with_label(_("Remove Media"));
181+ locateMedia = new Gtk.Button.with_label(_("Locate Media"));
182+ rescanLibrary = new Gtk.Button.with_label(_("Rescan Library"));
183+ doNothing = new Gtk.Button.with_label(_("Do Nothing"));
184+
185+ // pretty up labels
186+
187+ // be a bit explicit to make translations better
188+ var MARKUP_TEMPLATE = "<span weight=\"bold\" size=\"larger\">%s</span>";
189+ var title_string = MARKUP_TEMPLATE.printf (String.escape (_("Could not find media file")));
190+ title.set_markup (title_string);
191+ title.xalign = 0.0f; //FIXME: deprecated
192+
193+ info.set_line_wrap (true);
194+ info.xalign = 0.0f; //FIXME: deprecated
195+
196+ if (media_list.size == 1) {
197+ var s = media_list.get (0);
198+ info.set_markup (_("The music file for $NAME by $ARTIST could not be found. What would you like to do?").replace ("$NAME", s.title.escape ("")).replace ("$ARTIST", s.artist.escape ("")));
199+ } else {
200+ info.set_text (_("%i media files could not be found. What would you like to do?").printf (media_list.size));
201+ }
202+
203+
204+
205+ rescanLibrary.set_sensitive(!libraries_manager.local_library.doing_file_operations());
206+
207+ /* set up controls layout */
208+ var information = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
209+ var information_text = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
210+ information.pack_start(warning, false, false, 10);
211+ information_text.pack_start(title, false, true, 10);
212+ information_text.pack_start(info, false, true, 0);
213+ information.pack_start(information_text, true, true, 10);
214+
215+ var bottomButtons = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL);
216+ bottomButtons.set_layout(Gtk.ButtonBoxStyle.END);
217+ bottomButtons.pack_end(removeMedia, false, false, 0);
218+ bottomButtons.pack_end(rescanLibrary, false, false, 0);
219+ bottomButtons.pack_end(locateMedia, false, false, 0);
220+ bottomButtons.pack_end(doNothing, false, false, 10);
221+ bottomButtons.set_spacing(10);
222+
223+ content.pack_start(information, false, true, 0);
224+ content.pack_start(bottomButtons, false, true, 10);
225+
226+ padding.pack_start(content, true, true, 10);
227+
228+ removeMedia.clicked.connect(removeMediaClicked);
229+ locateMedia.clicked.connect(locateMediaClicked);
230+ rescanLibrary.clicked.connect(rescanLibraryClicked);
231+ doNothing.clicked.connect( () => {
232+ this.destroy();
233+ });
234+
235+ libraries_manager.local_library.file_operations_started.connect(file_operations_started);
236+ libraries_manager.local_library.file_operations_done.connect(file_operations_done);
237+
238+ add(padding);
239+ show_all();
240+ }
241+
242+ void removeMediaClicked() {
243+ libraries_manager.local_library.remove_medias (media_list, false);
244+
245+ this.destroy();
246+ }
247+
248+ void locateMediaClicked() {
249+ Media m = media_list.get(0);
250+ int media_id = m.rowid;
251+
252+ string file = "";
253+ var file_chooser = new Gtk.FileChooserDialog (_("Choose Music Folder"), this,
254+ Gtk.FileChooserAction.OPEN,
255+ _(STRING_CANCEL), Gtk.ResponseType.CANCEL,
256+ _(STRING_OPEN), Gtk.ResponseType.ACCEPT);
257+
258+ // try and help user by setting a sane default folder
259+ var invalid_file = File.new_for_uri(libraries_manager.local_library.media_from_id(media_id).uri);
260+ var music_folder = Settings.Main.get_default ().music_folder;
261+ if(invalid_file.get_parent().query_exists())
262+ file_chooser.set_current_folder(invalid_file.get_parent().get_path());
263+ else if(invalid_file.get_parent().get_parent().query_exists() &&
264+ invalid_file.get_parent ().get_parent ().get_path ().contains (music_folder))
265+ file_chooser.set_current_folder(invalid_file.get_parent().get_parent().get_path());
266+ else if(File.new_for_path (music_folder).query_exists ())
267+ file_chooser.set_current_folder (music_folder);
268+ else
269+ file_chooser.set_current_folder(Environment.get_home_dir());
270+
271+ if (file_chooser.run () == Gtk.ResponseType.ACCEPT) {
272+ file = file_chooser.get_filename();
273+ }
274+
275+ file_chooser.destroy ();
276+
277+ if(file != "" && File.new_for_path(file).query_exists()) {
278+ m.uri = File.new_for_path(file).get_uri();
279+ m.location_unknown = false;
280+ m.unique_status_image = null;
281+ // TODO: lm.lw.media_found(m.rowid);
282+ libraries_manager.local_library.update_media (m, false, false);
283+
284+ this.destroy();
285+ }
286+ }
287+
288+ void rescanLibraryClicked() {
289 ((LocalLibrary)libraries_manager.local_library).rescan_music_folder ();
290-
291- this.destroy();
292- }
293-
294- void file_operations_done() {
295- rescanLibrary.set_sensitive(true);
296- }
297-
298- void file_operations_started() {
299- rescanLibrary.set_sensitive(false);
300- }
301-
302+
303+ this.destroy();
304+ }
305+
306+ void file_operations_done() {
307+ rescanLibrary.set_sensitive(true);
308+ }
309+
310+ void file_operations_started() {
311+ rescanLibrary.set_sensitive(false);
312+ }
313+
314 }
315\ No newline at end of file
316
317=== modified file 'src/Dialogs/InstallGstreamerPluginsDialog.vala'
318--- src/Dialogs/InstallGstreamerPluginsDialog.vala 2014-04-19 22:03:29 +0000
319+++ src/Dialogs/InstallGstreamerPluginsDialog.vala 2014-04-20 17:31:49 +0000
320@@ -21,75 +21,75 @@
321 */
322
323 public class Noise.InstallGstreamerPluginsDialog : Gtk.Window {
324- Gst.Message message;
325- string detail;
326-
327- private Gtk.Box content;
328- private Gtk.Box padding;
329-
330- Gtk.Button installPlugin;
331- Gtk.Button doNothing;
332-
333- public InstallGstreamerPluginsDialog(Gst.Message message) {
334- this.message = message;
335- this.detail = Gst.PbUtils.missing_plugin_message_get_description (message);
336-
337- // set the size based on saved gconf settings
338- //this.window_position = WindowPosition.CENTER;
339- this.type_hint = Gdk.WindowTypeHint.DIALOG;
340- this.set_modal(true);
341- this.set_transient_for(App.main_window);
342- this.destroy_with_parent = true;
343-
344- set_default_size(475, -1);
345- resizable = false;
346-
347- content = new Gtk.Box (Gtk.Orientation.VERTICAL, 10);
348- padding = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 20);
349-
350- // initialize controls
351- Gtk.Image warning = new Gtk.Image.from_icon_name ("dialog-error", Gtk.IconSize.DIALOG);
352- Gtk.Label title = new Gtk.Label("");
353- Gtk.Label info = new Gtk.Label("");
354- installPlugin = new Gtk.Button.with_label(_("Install Plugin"));
355- doNothing = new Gtk.Button.from_stock ("dialog-cancel");
356-
357- // pretty up labels
358- title.xalign = 0.0f;
359- title.set_markup("<span weight=\"bold\" size=\"larger\">" + String.escape (_("Required GStreamer plugin not installed")) + "</span>");
360- info.xalign = 0.0f;
361- info.set_line_wrap(true);
362- info.set_markup(_("The plugin for media type %s is not installed.\nWhat would you like to do?").printf ("<b>" + String.escape (detail) + "</b>"));
363-
364-
365- /* set up controls layout */
366- var information = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
367- var information_text = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
368- information.pack_start(warning, false, false, 10);
369- information_text.pack_start(title, false, true, 10);
370- information_text.pack_start(info, false, true, 0);
371- information.pack_start(information_text, true, true, 10);
372-
373- var bottomButtons = new Gtk.ButtonBox(Gtk.Orientation.HORIZONTAL);
374- bottomButtons.set_layout(Gtk.ButtonBoxStyle.END);
375- bottomButtons.pack_end(installPlugin, false, false, 0);
376- bottomButtons.pack_end(doNothing, false, false, 10);
377- bottomButtons.set_spacing(10);
378-
379- content.pack_start(information, false, true, 0);
380- content.pack_start(bottomButtons, false, true, 10);
381-
382- padding.pack_start(content, true, true, 10);
383-
384- installPlugin.clicked.connect(installPluginClicked);
385-
386- doNothing.clicked.connect ( () => {
387- this.destroy ();
388- });
389- add(padding);
390- show_all();
391- }
392-
393+ Gst.Message message;
394+ string detail;
395+
396+ private Gtk.Box content;
397+ private Gtk.Box padding;
398+
399+ Gtk.Button installPlugin;
400+ Gtk.Button doNothing;
401+
402+ public InstallGstreamerPluginsDialog(Gst.Message message) {
403+ this.message = message;
404+ this.detail = Gst.PbUtils.missing_plugin_message_get_description (message);
405+
406+ // set the size based on saved gconf settings
407+ //this.window_position = WindowPosition.CENTER;
408+ this.type_hint = Gdk.WindowTypeHint.DIALOG;
409+ this.set_modal(true);
410+ this.set_transient_for(App.main_window);
411+ this.destroy_with_parent = true;
412+
413+ set_default_size(475, -1);
414+ resizable = false;
415+
416+ content = new Gtk.Box (Gtk.Orientation.VERTICAL, 10);
417+ padding = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 20);
418+
419+ // initialize controls
420+ Gtk.Image warning = new Gtk.Image.from_icon_name ("dialog-error", Gtk.IconSize.DIALOG);
421+ Gtk.Label title = new Gtk.Label("");
422+ Gtk.Label info = new Gtk.Label("");
423+ installPlugin = new Gtk.Button.with_label(_("Install Plugin"));
424+ doNothing = new Gtk.Button.from_stock ("dialog-cancel");
425+
426+ // pretty up labels
427+ title.xalign = 0.0f;
428+ title.set_markup("<span weight=\"bold\" size=\"larger\">" + String.escape (_("Required GStreamer plugin not installed")) + "</span>");
429+ info.xalign = 0.0f;
430+ info.set_line_wrap(true);
431+ info.set_markup(_("The plugin for media type %s is not installed.\nWhat would you like to do?").printf ("<b>" + String.escape (detail) + "</b>"));
432+
433+
434+ /* set up controls layout */
435+ var information = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0);
436+ var information_text = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
437+ information.pack_start(warning, false, false, 10);
438+ information_text.pack_start(title, false, true, 10);
439+ information_text.pack_start(info, false, true, 0);
440+ information.pack_start(information_text, true, true, 10);
441+
442+ var bottomButtons = new Gtk.ButtonBox(Gtk.Orientation.HORIZONTAL);
443+ bottomButtons.set_layout(Gtk.ButtonBoxStyle.END);
444+ bottomButtons.pack_end(installPlugin, false, false, 0);
445+ bottomButtons.pack_end(doNothing, false, false, 10);
446+ bottomButtons.set_spacing(10);
447+
448+ content.pack_start(information, false, true, 0);
449+ content.pack_start(bottomButtons, false, true, 10);
450+
451+ padding.pack_start(content, true, true, 10);
452+
453+ installPlugin.clicked.connect(installPluginClicked);
454+
455+ doNothing.clicked.connect ( () => {
456+ this.destroy ();
457+ });
458+ add(padding);
459+ show_all();
460+ }
461+
462 public void installPluginClicked() {
463 var installer = Gst.PbUtils.missing_plugin_message_get_installer_detail (message);
464 var context = new Gst.PbUtils.InstallPluginsContext ();
465@@ -121,4 +121,3 @@
466 return true;
467 }
468 }
469-
470
471=== modified file 'src/Dialogs/NotImportedWindow.vala'
472--- src/Dialogs/NotImportedWindow.vala 2014-04-19 22:03:29 +0000
473+++ src/Dialogs/NotImportedWindow.vala 2014-04-20 17:31:49 +0000
474@@ -26,208 +26,207 @@
475 using Gtk;
476
477 public class Noise.NotImportedWindow : Window{
478- Gee.LinkedList<string> _files;
479- string music_folder;
480-
481- //for padding around notebook mostly
482- private Gtk.Box content;
483- private Gtk.Box padding;
484-
485- CheckButton trashAll;
486- ScrolledWindow filesScroll;
487- TreeView filesView;
488- ListStore filesModel;
489- Button moveToTrash;
490-
491- public NotImportedWindow(Gee.Collection<string> files, string music) {
492- _files = new Gee.LinkedList<string> ();
493- _files.add_all (files);
494- this.music_folder = music;
495-
496- this.set_title(_("Not Imported Files"));
497-
498- // set the size based on saved gconf settings
499- //this.window_position = WindowPosition.CENTER;
500- this.type_hint = Gdk.WindowTypeHint.DIALOG;
501- this.set_modal (true);
502- this.set_transient_for (App.main_window);
503- this.destroy_with_parent = true;
504-
505- set_default_size(475, -1);
506- resizable = false;
507-
508- content = new Gtk.Box (Gtk.Orientation.VERTICAL, 10);
509- padding = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 20);
510-
511- // initialize controls
512- var warning = new Image.from_icon_name ("dialog-error", Gtk.IconSize.DIALOG);
513- var title = new Label(_("Unable to import %d items from %s").printf (files.size, music_folder));
514- var info = new Label(_("%s was unable to import %d items. The files may be damaged.").printf (((Noise.App) GLib.Application.get_default ()).get_name (), files.size));
515- trashAll = new CheckButton.with_label(_("Move all corrupted files to trash"));
516- filesScroll = new ScrolledWindow(null, null);
517- filesView = new TreeView();
518- filesModel = new ListStore(2, typeof(bool), typeof(string));
519- filesView.set_model(filesModel);
520- moveToTrash = new Button.with_label(_("Move to Trash"));
521- Button okButton = new Button.with_label(_("Ignore"));
522-
523- // pretty up labels
524- title.xalign = 0.0f;
525- title.set_markup("<span weight=\"bold\" size=\"larger\">" + Markup.escape_text (_("Unable to import %d items from %s").printf (files.size, music_folder), -1) + "</span>");
526- info.xalign = 0.0f;
527- info.set_line_wrap(false);
528-
529- /* add cellrenderers to columns and columns to treeview */
530- var toggle = new CellRendererToggle ();
531- toggle.toggled.connect ((toggle, path) => {
532- var tree_path = new TreePath.from_string (path);
533- TreeIter iter;
534- filesModel.get_iter (out iter, tree_path);
535- filesModel.set (iter, 0, !toggle.active);
536-
537- moveToTrash.set_sensitive(false);
538- filesModel.foreach(updateMoveToTrashSensetivity);
539- });
540-
541- var column = new TreeViewColumn ();
542- column.title = _("del");
543- column.pack_start (toggle, false);
544- column.add_attribute (toggle, "active", 0);
545- filesView.append_column (column);
546-
547- filesView.insert_column_with_attributes(-1, _("File Location"), new CellRendererText(), "text", 1, null);
548- filesView.headers_visible = false;
549-
550- /* fill the treeview */
551- foreach(string file in files) {
552- TreeIter item;
553- filesModel.append(out item);
554-
555- filesModel.set(item, 0, false, 1, file.replace(music_folder, ""));
556- }
557-
558- filesScroll.add(filesView);
559- filesScroll.set_policy(PolicyType.AUTOMATIC, PolicyType.AUTOMATIC);
560-
561- moveToTrash.set_sensitive(false);
562-
563- /* set up controls layout */
564- var information = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
565- var information_text = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
566- information.pack_start(warning, false, false, 10);
567- information_text.pack_start(title, false, true, 10);
568- information_text.pack_start(info, false, true, 0);
569- information.pack_start(information_text, true, true, 10);
570-
571- var listBox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
572- listBox.pack_start(filesScroll, true, true, 5);
573-
574- Expander exp = new Expander(_("Select individual files to move to trash:"));
575- exp.add(listBox);
576- exp.expanded = false;
577-
578- var bottomButtons = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL);
579- bottomButtons.set_layout(ButtonBoxStyle.END);
580- bottomButtons.pack_end(moveToTrash, false, false, 0);
581- bottomButtons.pack_end(okButton, false, false, 10);
582- bottomButtons.set_spacing(10);
583-
584- content.pack_start(information, false, true, 0);
585- content.pack_start(UI.wrap_alignment (trashAll, 5, 0, 0, 75), false, true, 0);
586- content.pack_start(UI.wrap_alignment (exp, 0, 0, 0, 75), true, true, 0);
587- content.pack_start(bottomButtons, false, true, 10);
588-
589- padding.pack_start(content, true, true, 10);
590-
591- moveToTrash.clicked.connect(moveToTrashClick);
592- trashAll.toggled.connect(trashAllToggled);
593- okButton.clicked.connect( () => { this.destroy(); });
594- exp.activate.connect( () => {
595- if(exp.get_expanded()) {
596- resizable = true;
597- set_size_request(475, 180);
598- resize(475, 180);
599- resizable = false;
600- }
601- else
602- set_size_request(475, 350);
603- });
604-
605- add(padding);
606- show_all();
607- }
608-
609- public bool updateMoveToTrashSensetivity(TreeModel model, TreePath path, TreeIter iter) {
610- bool sel = false;
611- model.get(iter, 0, out sel);
612-
613- if(sel) {
614- moveToTrash.set_sensitive(true);
615- return true;
616- }
617-
618- return false;
619- }
620-
621- public bool selectAll(TreeModel model, TreePath path, TreeIter iter) {
622- filesModel.set(iter, 0, true);
623-
624- return false;
625- }
626-
627- public bool unselectAll(TreeModel model, TreePath path, TreeIter iter) {
628- filesModel.set(iter, 0, false);
629-
630- return false;
631- }
632-
633- public virtual void trashAllToggled() {
634- if(trashAll.active) {
635- filesModel.foreach(selectAll);
636- filesView.set_sensitive(false);
637- moveToTrash.set_sensitive(true);
638- }
639- else {
640- filesModel.foreach(unselectAll);
641- filesView.set_sensitive(true);
642- moveToTrash.set_sensitive(false);
643- }
644- }
645-
646- public bool deleteSelectedItems(TreeModel model, TreePath path, TreeIter iter) {
647- bool selected;
648- string location;
649- filesModel.get(iter, 0, out selected);
650- filesModel.get(iter, 1, out location);
651-
652- if(selected) {
653- try {
654- var file = File.new_for_path(music_folder + location);
655- file.trash();
656- }
657- catch(GLib.Error err) {
658- warning ("Could not move file %s to recycle: %s\n", location, err.message);
659- }
660- /*else {
661- try {
662- var file = File.new_for_path (location);
663- file.delete();
664- }
665- catch(GLib.Error err) {
666- warning ("Could not delete file %s: %s\n", location, err.message);
667- }
668- }*/
669- }
670-
671- return false;
672- }
673-
674- public virtual void moveToTrashClick() {
675- filesModel.foreach(deleteSelectedItems);
676- this.destroy();
677- }
678-
679- public virtual void ignoreClick() {
680- this.destroy();
681- }
682-}
683+ Gee.LinkedList<string> _files;
684+ string music_folder;
685+
686+ //for padding around notebook mostly
687+ private Gtk.Box content;
688+ private Gtk.Box padding;
689+
690+ CheckButton trashAll;
691+ ScrolledWindow filesScroll;
692+ TreeView filesView;
693+ ListStore filesModel;
694+ Button moveToTrash;
695+
696+ public NotImportedWindow(Gee.Collection<string> files, string music) {
697+ _files = new Gee.LinkedList<string> ();
698+ _files.add_all (files);
699+ this.music_folder = music;
700+
701+ this.set_title(_("Not Imported Files"));
702+
703+ // set the size based on saved gconf settings
704+ //this.window_position = WindowPosition.CENTER;
705+ this.type_hint = Gdk.WindowTypeHint.DIALOG;
706+ this.set_modal (true);
707+ this.set_transient_for (App.main_window);
708+ this.destroy_with_parent = true;
709+
710+ set_default_size(475, -1);
711+ resizable = false;
712+
713+ content = new Gtk.Box (Gtk.Orientation.VERTICAL, 10);
714+ padding = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 20);
715+
716+ // initialize controls
717+ var warning = new Image.from_icon_name ("dialog-error", Gtk.IconSize.DIALOG);
718+ var title = new Label(_("Unable to import %d items from %s").printf (files.size, music_folder));
719+ var info = new Label(_("%s was unable to import %d items. The files may be damaged.").printf (((Noise.App) GLib.Application.get_default ()).get_name (), files.size));
720+ trashAll = new CheckButton.with_label(_("Move all corrupted files to trash"));
721+ filesScroll = new ScrolledWindow(null, null);
722+ filesView = new TreeView();
723+ filesModel = new ListStore(2, typeof(bool), typeof(string));
724+ filesView.set_model(filesModel);
725+ moveToTrash = new Button.with_label(_("Move to Trash"));
726+ Button okButton = new Button.with_label(_("Ignore"));
727+
728+ // pretty up labels
729+ title.xalign = 0.0f;
730+ title.set_markup("<span weight=\"bold\" size=\"larger\">" + Markup.escape_text (_("Unable to import %d items from %s").printf (files.size, music_folder), -1) + "</span>");
731+ info.xalign = 0.0f;
732+ info.set_line_wrap(false);
733+
734+ /* add cellrenderers to columns and columns to treeview */
735+ var toggle = new CellRendererToggle ();
736+ toggle.toggled.connect ((toggle, path) => {
737+ var tree_path = new TreePath.from_string (path);
738+ TreeIter iter;
739+ filesModel.get_iter (out iter, tree_path);
740+ filesModel.set (iter, 0, !toggle.active);
741+
742+ moveToTrash.set_sensitive(false);
743+ filesModel.foreach(updateMoveToTrashSensetivity);
744+ });
745+
746+ var column = new TreeViewColumn ();
747+ column.title = _("del");
748+ column.pack_start (toggle, false);
749+ column.add_attribute (toggle, "active", 0);
750+ filesView.append_column (column);
751+
752+ filesView.insert_column_with_attributes(-1, _("File Location"), new CellRendererText(), "text", 1, null);
753+ filesView.headers_visible = false;
754+
755+ /* fill the treeview */
756+ foreach(string file in files) {
757+ TreeIter item;
758+ filesModel.append(out item);
759+
760+ filesModel.set(item, 0, false, 1, file.replace(music_folder, ""));
761+ }
762+
763+ filesScroll.add(filesView);
764+ filesScroll.set_policy(PolicyType.AUTOMATIC, PolicyType.AUTOMATIC);
765+
766+ moveToTrash.set_sensitive(false);
767+
768+ /* set up controls layout */
769+ var information = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
770+ var information_text = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
771+ information.pack_start(warning, false, false, 10);
772+ information_text.pack_start(title, false, true, 10);
773+ information_text.pack_start(info, false, true, 0);
774+ information.pack_start(information_text, true, true, 10);
775+
776+ var listBox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
777+ listBox.pack_start(filesScroll, true, true, 5);
778+
779+ Expander exp = new Expander(_("Select individual files to move to trash:"));
780+ exp.add(listBox);
781+ exp.expanded = false;
782+
783+ var bottomButtons = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL);
784+ bottomButtons.set_layout(ButtonBoxStyle.END);
785+ bottomButtons.pack_end(moveToTrash, false, false, 0);
786+ bottomButtons.pack_end(okButton, false, false, 10);
787+ bottomButtons.set_spacing(10);
788+
789+ content.pack_start(information, false, true, 0);
790+ content.pack_start(UI.wrap_alignment (trashAll, 5, 0, 0, 75), false, true, 0);
791+ content.pack_start(UI.wrap_alignment (exp, 0, 0, 0, 75), true, true, 0);
792+ content.pack_start(bottomButtons, false, true, 10);
793+
794+ padding.pack_start(content, true, true, 10);
795+
796+ moveToTrash.clicked.connect(moveToTrashClick);
797+ trashAll.toggled.connect(trashAllToggled);
798+ okButton.clicked.connect( () => { this.destroy(); });
799+ exp.activate.connect( () => {
800+ if(exp.get_expanded()) {
801+ resizable = true;
802+ set_size_request(475, 180);
803+ resize(475, 180);
804+ resizable = false;
805+ }
806+ else
807+ set_size_request(475, 350);
808+ });
809+
810+ add(padding);
811+ show_all();
812+ }
813+
814+ public bool updateMoveToTrashSensetivity(TreeModel model, TreePath path, TreeIter iter) {
815+ bool sel = false;
816+ model.get(iter, 0, out sel);
817+
818+ if(sel) {
819+ moveToTrash.set_sensitive(true);
820+ return true;
821+ }
822+
823+ return false;
824+ }
825+
826+ public bool selectAll(TreeModel model, TreePath path, TreeIter iter) {
827+ filesModel.set(iter, 0, true);
828+
829+ return false;
830+ }
831+
832+ public bool unselectAll(TreeModel model, TreePath path, TreeIter iter) {
833+ filesModel.set(iter, 0, false);
834+
835+ return false;
836+ }
837+
838+ public virtual void trashAllToggled() {
839+ if(trashAll.active) {
840+ filesModel.foreach(selectAll);
841+ filesView.set_sensitive(false);
842+ moveToTrash.set_sensitive(true);
843+ } else {
844+ filesModel.foreach(unselectAll);
845+ filesView.set_sensitive(true);
846+ moveToTrash.set_sensitive(false);
847+ }
848+ }
849+
850+ public bool deleteSelectedItems(TreeModel model, TreePath path, TreeIter iter) {
851+ bool selected;
852+ string location;
853+ filesModel.get(iter, 0, out selected);
854+ filesModel.get(iter, 1, out location);
855+
856+ if(selected) {
857+ try {
858+ var file = File.new_for_path(music_folder + location);
859+ file.trash();
860+ }
861+ catch(GLib.Error err) {
862+ warning ("Could not move file %s to recycle: %s\n", location, err.message);
863+ }
864+ /*else {
865+ try {
866+ var file = File.new_for_path (location);
867+ file.delete();
868+ }
869+ catch(GLib.Error err) {
870+ warning ("Could not delete file %s: %s\n", location, err.message);
871+ }
872+ }*/
873+ }
874+
875+ return false;
876+ }
877+
878+ public virtual void moveToTrashClick() {
879+ filesModel.foreach(deleteSelectedItems);
880+ this.destroy();
881+ }
882+
883+ public virtual void ignoreClick() {
884+ this.destroy();
885+ }
886+}
887\ No newline at end of file
888
889=== modified file 'src/Dialogs/SetMusicFolderConfirmation.vala'
890--- src/Dialogs/SetMusicFolderConfirmation.vala 2014-04-19 22:03:29 +0000
891+++ src/Dialogs/SetMusicFolderConfirmation.vala 2014-04-20 17:31:49 +0000
892@@ -21,129 +21,129 @@
893 */
894
895 public class Noise.SetMusicFolderConfirmation : Gtk.Window {
896- string folder_path;
897-
898- private Gtk.Grid content;
899-
900- Gtk.Button savePlaylists;
901- Gtk.Button ok;
902- Gtk.Button cancel;
903-
904- Gtk.Image is_finished;
905- Gtk.Spinner is_working;
906-
907- public signal void finished(bool response);
908-
909- public SetMusicFolderConfirmation(string path) {
910- folder_path = path;
911-
912- // set the size based on saved gconf settings
913- //this.window_position = WindowPosition.CENTER;
914- this.type_hint = Gdk.WindowTypeHint.DIALOG;
915- this.set_modal (true);
916- this.set_transient_for (App.main_window);
917- this.destroy_with_parent = true;
918-
919- //set_default_size(250, -1);
920- resizable = false;
921-
922- content = new Gtk.Grid ();
923- content.margin = 12;
924- content.column_spacing = 12;
925- content.row_spacing = 6;
926-
927- // initialize controls
928- Gtk.Image warning = new Gtk.Image.from_icon_name ("dialog-warning", Gtk.IconSize.DIALOG);
929- Gtk.Label title = new Gtk.Label("");
930- Gtk.Label info = new Gtk.Label("");
931- savePlaylists = new Gtk.Button.with_label(_("Export Playlists"));
932- ok = new Gtk.Button.with_label(_("Set Music Folder"));
933- cancel = new Gtk.Button.with_label (_(STRING_CANCEL));
934- is_finished = new Gtk.Image();
935- is_working = new Gtk.Spinner();
936-
937- // pretty up labels
938- title.xalign = 0.0f;
939- title.set_markup("<span weight=\"bold\" size=\"larger\">%s</span>".printf(String.escape (_("Set Music Folder?"))));
940- info.xalign = 0.0f;
941- info.set_line_wrap (true);
942- info.set_markup (_("Are you sure you want to set the music folder to %s? This will reset your library and remove your playlists.").printf ("<b>" + String.escape (path) + "</b>"));
943-
944- // save playlist hbox
945- var playlistBox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 6);
946- playlistBox.pack_start(savePlaylists, true, true, 0);
947- playlistBox.pack_end(is_finished, false, false, 0);
948- playlistBox.pack_end(is_working, false, false, 0);
949-
950- var bottomButtons = new Gtk.ButtonBox(Gtk.Orientation.HORIZONTAL);
951- bottomButtons.set_layout(Gtk.ButtonBoxStyle.END);
952- bottomButtons.pack_start(playlistBox, false, false, 0);
953- bottomButtons.pack_end(cancel, false, false, 0);
954- bottomButtons.pack_end(ok, false, false, 0);
955- bottomButtons.set_spacing(10);
956-
957- ((Gtk.ButtonBox)bottomButtons).set_child_secondary(playlistBox, true);
958-
959- content.attach (warning, 0, 0, 1, 2);
960- content.attach (title, 1, 0, 1, 1);
961- content.attach (info, 1, 1, 1, 1);
962- content.attach (bottomButtons, 0, 2, 2, 1);
963-
964- var local_library = libraries_manager.local_library;
965- savePlaylists.set_sensitive(!local_library.get_medias ().is_empty && local_library.playlist_count_without_read_only () > 0);
966-
967- savePlaylists.clicked.connect(savePlaylistsClicked);
968- cancel.clicked.connect(cancel_clicked);
969- ok.clicked.connect(ok_clicked);
970-
971- add (content);
972- show_all();
973-
974- is_working.hide();
975- }
976-
977- public void savePlaylistsClicked() {
978- string folder = "";
979- var file_chooser = new Gtk.FileChooserDialog (_("Choose Music Folder"), this,
980- Gtk.FileChooserAction.SELECT_FOLDER,
981- _(STRING_CANCEL), Gtk.ResponseType.CANCEL,
982- _(STRING_OPEN), Gtk.ResponseType.ACCEPT);
983- if (file_chooser.run () == Gtk.ResponseType.ACCEPT) {
984- folder = file_chooser.get_filename();
985- }
986-
987- file_chooser.destroy ();
988-
989- if(folder != "") {
990- is_working.show();
991- is_finished.hide();
992-
993- // foreach playlist in lm.playlists(), save to (p.name).m3u
994- var success = true;
995- foreach(var p in libraries_manager.local_library.get_playlists()) {
996- if(!Noise.PlaylistsUtils.save_playlist_m3u(p, folder, ""))
997- success = false;
998- }
999-
1000- is_working.hide();
1001- is_finished.show();
1002-
1003- var process_completed_icon = Icons.PROCESS_COMPLETED.render (Gtk.IconSize.MENU);
1004- var process_error_icon = Icons.PROCESS_ERROR.render (Gtk.IconSize.MENU);
1005-
1006- is_finished.set_from_pixbuf(success ? process_completed_icon : process_error_icon);
1007- }
1008- }
1009-
1010- public void cancel_clicked() {
1011- finished(false);
1012-
1013- this.destroy();
1014- }
1015-
1016- public void ok_clicked() {
1017- finished(true);
1018-
1019- this.destroy();
1020- }
1021+ string folder_path;
1022+
1023+ private Gtk.Grid content;
1024+
1025+ Gtk.Button savePlaylists;
1026+ Gtk.Button ok;
1027+ Gtk.Button cancel;
1028+
1029+ Gtk.Image is_finished;
1030+ Gtk.Spinner is_working;
1031+
1032+ public signal void finished(bool response);
1033+
1034+ public SetMusicFolderConfirmation(string path) {
1035+ folder_path = path;
1036+
1037+ // set the size based on saved gconf settings
1038+ //this.window_position = WindowPosition.CENTER;
1039+ this.type_hint = Gdk.WindowTypeHint.DIALOG;
1040+ this.set_modal (true);
1041+ this.set_transient_for (App.main_window);
1042+ this.destroy_with_parent = true;
1043+
1044+ //set_default_size(250, -1);
1045+ resizable = false;
1046+
1047+ content = new Gtk.Grid ();
1048+ content.margin = 12;
1049+ content.column_spacing = 12;
1050+ content.row_spacing = 6;
1051+
1052+ // initialize controls
1053+ Gtk.Image warning = new Gtk.Image.from_icon_name ("dialog-warning", Gtk.IconSize.DIALOG);
1054+ Gtk.Label title = new Gtk.Label("");
1055+ Gtk.Label info = new Gtk.Label("");
1056+ savePlaylists = new Gtk.Button.with_label(_("Export Playlists"));
1057+ ok = new Gtk.Button.with_label(_("Set Music Folder"));
1058+ cancel = new Gtk.Button.with_label (_(STRING_CANCEL));
1059+ is_finished = new Gtk.Image();
1060+ is_working = new Gtk.Spinner();
1061+
1062+ // pretty up labels
1063+ title.xalign = 0.0f;
1064+ title.set_markup("<span weight=\"bold\" size=\"larger\">%s</span>".printf(String.escape (_("Set Music Folder?"))));
1065+ info.xalign = 0.0f;
1066+ info.set_line_wrap (true);
1067+ info.set_markup (_("Are you sure you want to set the music folder to %s? This will reset your library and remove your playlists.").printf ("<b>" + String.escape (path) + "</b>"));
1068+
1069+ // save playlist hbox
1070+ var playlistBox = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 6);
1071+ playlistBox.pack_start(savePlaylists, true, true, 0);
1072+ playlistBox.pack_end(is_finished, false, false, 0);
1073+ playlistBox.pack_end(is_working, false, false, 0);
1074+
1075+ var bottomButtons = new Gtk.ButtonBox(Gtk.Orientation.HORIZONTAL);
1076+ bottomButtons.set_layout(Gtk.ButtonBoxStyle.END);
1077+ bottomButtons.pack_start(playlistBox, false, false, 0);
1078+ bottomButtons.pack_end(cancel, false, false, 0);
1079+ bottomButtons.pack_end(ok, false, false, 0);
1080+ bottomButtons.set_spacing(10);
1081+
1082+ ((Gtk.ButtonBox)bottomButtons).set_child_secondary(playlistBox, true);
1083+
1084+ content.attach (warning, 0, 0, 1, 2);
1085+ content.attach (title, 1, 0, 1, 1);
1086+ content.attach (info, 1, 1, 1, 1);
1087+ content.attach (bottomButtons, 0, 2, 2, 1);
1088+
1089+ var local_library = libraries_manager.local_library;
1090+ savePlaylists.set_sensitive(!local_library.get_medias ().is_empty && local_library.playlist_count_without_read_only () > 0);
1091+
1092+ savePlaylists.clicked.connect(savePlaylistsClicked);
1093+ cancel.clicked.connect(cancel_clicked);
1094+ ok.clicked.connect(ok_clicked);
1095+
1096+ add (content);
1097+ show_all();
1098+
1099+ is_working.hide();
1100+ }
1101+
1102+ public void savePlaylistsClicked() {
1103+ string folder = "";
1104+ var file_chooser = new Gtk.FileChooserDialog (_("Choose Music Folder"), this,
1105+ Gtk.FileChooserAction.SELECT_FOLDER,
1106+ _(STRING_CANCEL), Gtk.ResponseType.CANCEL,
1107+ _(STRING_OPEN), Gtk.ResponseType.ACCEPT);
1108+ if (file_chooser.run () == Gtk.ResponseType.ACCEPT) {
1109+ folder = file_chooser.get_filename();
1110+ }
1111+
1112+ file_chooser.destroy ();
1113+
1114+ if(folder != "") {
1115+ is_working.show();
1116+ is_finished.hide();
1117+
1118+ // foreach playlist in lm.playlists(), save to (p.name).m3u
1119+ var success = true;
1120+ foreach(var p in libraries_manager.local_library.get_playlists()) {
1121+ if(!Noise.PlaylistsUtils.save_playlist_m3u(p, folder, ""))
1122+ success = false;
1123+ }
1124+
1125+ is_working.hide();
1126+ is_finished.show();
1127+
1128+ var process_completed_icon = Icons.PROCESS_COMPLETED.render (Gtk.IconSize.MENU);
1129+ var process_error_icon = Icons.PROCESS_ERROR.render (Gtk.IconSize.MENU);
1130+
1131+ is_finished.set_from_pixbuf(success ? process_completed_icon : process_error_icon);
1132+ }
1133+ }
1134+
1135+ public void cancel_clicked() {
1136+ finished(false);
1137+
1138+ this.destroy();
1139+ }
1140+
1141+ public void ok_clicked() {
1142+ finished(true);
1143+
1144+ this.destroy();
1145+ }
1146 }
1147\ No newline at end of file
1148
1149=== modified file 'src/Dialogs/TransferFromDeviceDialog.vala'
1150--- src/Dialogs/TransferFromDeviceDialog.vala 2014-04-19 22:03:29 +0000
1151+++ src/Dialogs/TransferFromDeviceDialog.vala 2014-04-20 17:31:49 +0000
1152@@ -26,276 +26,274 @@
1153 using Gtk;
1154
1155 public class Noise.TransferFromDeviceDialog : Window {
1156- Gee.LinkedList<Media> medias;
1157- Device d;
1158-
1159- //for padding around notebook mostly
1160- private Gtk.Box content;
1161- private Gtk.Box padding;
1162-
1163- Gtk.CheckButton transferAll;
1164- Gtk.ScrolledWindow mediasScroll;
1165- Gtk.TreeView mediasView;
1166- Gtk.ListStore mediasModel;
1167- Gtk.Button transfer;
1168-
1169- Gtk.Menu viewMenu;
1170- Gtk.MenuItem selectItem;
1171- Gtk.MenuItem selectAlbum;
1172- Gtk.MenuItem selectArtist;
1173-
1174- Gee.LinkedList<Media> to_transfer;
1175-
1176- public TransferFromDeviceDialog(Device d, Gee.LinkedList<Media> medias) {
1177- this.medias = medias;
1178- this.d = d;
1179-
1180- to_transfer = new Gee.LinkedList<Media>();
1181-
1182- this.set_title(_("Import from Device"));
1183-
1184- // set the size based on saved gconf settings
1185- //this.window_position = WindowPosition.CENTER;
1186- this.type_hint = Gdk.WindowTypeHint.DIALOG;
1187- this.set_modal(true);
1188- this.set_transient_for (App.main_window);
1189- this.destroy_with_parent = true;
1190-
1191- set_default_size (550, -1);
1192- resizable = false;
1193-
1194- content = new Gtk.Box (Gtk.Orientation.VERTICAL, 10);
1195- padding = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 20);
1196-
1197- // initialize controls
1198- var warning = new Gtk.Image.from_stock ("dialog-question", Gtk.IconSize.DIALOG);
1199- var title = new Gtk.Label (_("Import media from %s").printf (d.getDisplayName ()));
1200- var info = new Gtk.Label (_("The following files were found on %s, but are not in your library. Check all the files you would like to import.").printf (d.getDisplayName ()));
1201- transferAll = new Gtk.CheckButton.with_label (_("Import all media"));
1202- mediasScroll = new Gtk.ScrolledWindow (null, null);
1203- mediasView = new Gtk.TreeView ();
1204- mediasModel = new ListStore(5, typeof(bool), typeof(int), typeof(string), typeof(string), typeof(string));
1205- mediasView.set_model(mediasModel);
1206- transfer = new Button.with_label(_("Import"));
1207- Button cancel = new Button.with_label(_("Don't Import"));
1208-
1209- // pretty up labels
1210- title.xalign = 0.0f;
1211-
1212- // be a bit explicit to make translations better
1213- string title_text = "";
1214- if (medias.size > 1) {
1215- title_text = _("Import %i items from %s").printf (medias.size, d.getDisplayName ());
1216- }
1217- else {
1218- var m = medias.get (0);
1219- title_text = _("Import %s from %s").printf (m.title, d.getDisplayName ());
1220- }
1221-
1222- string MARKUP_TEMPLATE = "<span weight=\"bold\" size=\"larger\">%s</span>";
1223- var title_string = MARKUP_TEMPLATE.printf (String.escape (title_text));
1224- title.set_markup (title_string);
1225-
1226- info.xalign = 0.0f;
1227- info.set_line_wrap(true);
1228-
1229- /* add cellrenderers to columns and columns to treeview */
1230- var toggle = new CellRendererToggle ();
1231- toggle.toggled.connect ((toggle, path) => {
1232- var tree_path = new TreePath.from_string (path);
1233- TreeIter iter;
1234- mediasModel.get_iter (out iter, tree_path);
1235- mediasModel.set (iter, 0, !toggle.active);
1236-
1237- transfer.set_sensitive(false);
1238- mediasModel.foreach(updateTransferSensetivity);
1239- });
1240-
1241- var column = new TreeViewColumn ();
1242- column.title = "";
1243- column.pack_start (toggle, false);
1244- column.add_attribute (toggle, "active", 0);
1245- mediasView.append_column(column);
1246-
1247- mediasView.insert_column_with_attributes(-1, _("ID"), new CellRendererText(), "text", 1, null);
1248- mediasView.insert_column_with_attributes(-1, _("Title"), new CellRendererText(), "text", 2, null);
1249- mediasView.insert_column_with_attributes(-1, _("Artist"), new CellRendererText(), "text", 3, null);
1250- mediasView.insert_column_with_attributes(-1, _("Album"), new CellRendererText(), "text", 4, null);
1251- mediasView.headers_visible = true;
1252-
1253- for(int i = 0; i < 5; ++i) {
1254- mediasView.get_column(i).sizing = Gtk.TreeViewColumnSizing.FIXED;
1255- mediasView.get_column(i).resizable = true;
1256- mediasView.get_column(i).reorderable = false;
1257- mediasView.get_column(i).clickable = false;
1258- }
1259-
1260- mediasView.get_column(1).visible = false;
1261-
1262- mediasView.get_column(0).fixed_width = 25;
1263- mediasView.get_column(1).fixed_width = 10;
1264- mediasView.get_column(2).fixed_width = 300;
1265- mediasView.get_column(3).fixed_width = 125;
1266- mediasView.get_column(4).fixed_width = 125;
1267-
1268- //view.get_selection().set_mode(SelectionMode.MULTIPLE);
1269-
1270- /* fill the treeview */
1271- var medias_sorted = new Gee.LinkedList<Media>();
1272- foreach(var m in medias)
1273- medias_sorted.add(m);
1274- medias_sorted.sort(mediaCompareFunc);
1275-
1276- foreach(var s in medias_sorted) {
1277- TreeIter item;
1278- mediasModel.append(out item);
1279-
1280- mediasModel.set(item, 0, false, 1, s.rowid, 2, s.title, 3, s.artist, 4, s.album);
1281- }
1282-
1283- mediasScroll.add(mediasView);
1284- mediasScroll.set_policy(PolicyType.AUTOMATIC, PolicyType.AUTOMATIC);
1285-
1286- transfer.set_sensitive(false);
1287-
1288- /* set up controls layout */
1289- var information = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
1290- var information_text = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
1291- information.pack_start(warning, false, false, 10);
1292- information_text.pack_start(title, false, true, 10);
1293- information_text.pack_start(info, false, true, 0);
1294- information.pack_start(information_text, true, true, 10);
1295-
1296- var listBox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
1297- listBox.pack_start(mediasScroll, true, true, 5);
1298-
1299- Expander exp = new Expander(_("Select individual media to import:"));
1300- exp.add(listBox);
1301- exp.expanded = false;
1302-
1303- var bottomButtons = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL);
1304- bottomButtons.set_layout (Gtk.ButtonBoxStyle.END);
1305- bottomButtons.pack_end (cancel, false, false, 10);
1306- bottomButtons.pack_end (transfer, false, false, 0);
1307- bottomButtons.set_spacing (10);
1308-
1309- content.pack_start(information, false, true, 0);
1310- content.pack_start(UI.wrap_alignment (transferAll, 5, 0, 0, 75), false, true, 0);
1311- content.pack_start(UI.wrap_alignment (exp, 0, 0, 0, 75), true, true, 0);
1312- content.pack_start(bottomButtons, false, true, 10);
1313-
1314- padding.pack_start(content, true, true, 10);
1315-
1316- viewMenu = new Gtk.Menu();
1317- selectItem = new Gtk.MenuItem.with_label(_("Check Item"));
1318- selectAlbum = new Gtk.MenuItem.with_label(_("Check Album"));
1319- selectArtist = new Gtk.MenuItem.with_label(_("Check Artist"));
1320-
1321- transfer.clicked.connect(transferClick);
1322- transferAll.toggled.connect(transferAllToggled);
1323- //mediasView.button_press_event.connect(mediasViewClick);
1324- cancel.clicked.connect( () => { this.destroy(); });
1325- exp.activate.connect( () => {
1326- if(exp.get_expanded()) {
1327- resizable = true;
1328- set_size_request(550, 180);
1329- resize(475, 180);
1330- resizable = false;
1331- }
1332- else
1333- set_size_request(550, 500);
1334- });
1335-
1336- add(padding);
1337- show_all();
1338- }
1339-
1340- public static int mediaCompareFunc(Media a, Media b) {
1341- if(a.artist == b.artist) {
1342- if(a.album == b.album)
1343- return (int)a.track - (int)b.track;
1344- else
1345- return (a.album > b.album) ? 1 : -1;
1346-
1347- }
1348- else
1349- return (a.artist > b.artist) ? 1 : -1;
1350- }
1351-
1352- public static Gtk.Alignment wrap_alignment (Gtk.Widget widget, int top, int right, int bottom, int left) {
1353- var alignment = new Gtk.Alignment(0.0f, 0.0f, 1.0f, 1.0f);
1354- alignment.top_padding = top;
1355- alignment.right_padding = right;
1356- alignment.bottom_padding = bottom;
1357- alignment.left_padding = left;
1358-
1359- alignment.add(widget);
1360- return alignment;
1361- }
1362-
1363- public bool updateTransferSensetivity(TreeModel model, TreePath path, TreeIter iter) {
1364- bool sel = false;
1365- model.get(iter, 0, out sel);
1366-
1367- if(sel) {
1368- transfer.set_sensitive(true);
1369- return true;
1370- }
1371-
1372- return false;
1373- }
1374-
1375- public bool selectAll(TreeModel model, TreePath path, TreeIter iter) {
1376- mediasModel.set(iter, 0, true);
1377-
1378- return false;
1379- }
1380-
1381- public bool unselectAll(TreeModel model, TreePath path, TreeIter iter) {
1382- mediasModel.set(iter, 0, false);
1383-
1384- return false;
1385- }
1386-
1387- public virtual void transferAllToggled() {
1388- if(transferAll.active) {
1389- mediasModel.foreach(selectAll);
1390- mediasView.set_sensitive(false);
1391- transfer.set_sensitive(true);
1392- }
1393- else {
1394- mediasModel.foreach(unselectAll);
1395- mediasView.set_sensitive(true);
1396- transfer.set_sensitive(false);
1397- }
1398- }
1399-
1400- public bool createTransferList(TreeModel model, TreePath path, TreeIter iter) {
1401- Media? m = null;
1402- bool selected = false;
1403- mediasModel.get(iter, 0, out selected, 1, out m);
1404-
1405- if(m != null && selected) {
1406- to_transfer.add(m);
1407- }
1408-
1409- return false;
1410- }
1411-
1412- public virtual void transferClick() {
1413- to_transfer.clear();
1414- mediasModel.foreach(createTransferList);
1415-
1416- if(libraries_manager.local_library.doing_file_operations()) {
1417- NotificationManager.get_default ().doAlertNotification (_("Cannot Import"), _("Noise is already doing file operations. Please wait until those finish to import from %d").printf( d.getDisplayName()));
1418- }
1419- else {
1420- libraries_manager.transfer_to_local_library (to_transfer);
1421- this.destroy();
1422- }
1423- }
1424-
1425- public virtual void cancelClick() {
1426- this.destroy();
1427- }
1428+ Gee.LinkedList<Media> medias;
1429+ Device d;
1430+
1431+ //for padding around notebook mostly
1432+ private Gtk.Box content;
1433+ private Gtk.Box padding;
1434+
1435+ Gtk.CheckButton transferAll;
1436+ Gtk.ScrolledWindow mediasScroll;
1437+ Gtk.TreeView mediasView;
1438+ Gtk.ListStore mediasModel;
1439+ Gtk.Button transfer;
1440+
1441+ Gtk.Menu viewMenu;
1442+ Gtk.MenuItem selectItem;
1443+ Gtk.MenuItem selectAlbum;
1444+ Gtk.MenuItem selectArtist;
1445+
1446+ Gee.LinkedList<Media> to_transfer;
1447+
1448+ public TransferFromDeviceDialog(Device d, Gee.LinkedList<Media> medias) {
1449+ this.medias = medias;
1450+ this.d = d;
1451+
1452+ to_transfer = new Gee.LinkedList<Media>();
1453+
1454+ this.set_title(_("Import from Device"));
1455+
1456+ // set the size based on saved gconf settings
1457+ //this.window_position = WindowPosition.CENTER;
1458+ this.type_hint = Gdk.WindowTypeHint.DIALOG;
1459+ this.set_modal(true);
1460+ this.set_transient_for (App.main_window);
1461+ this.destroy_with_parent = true;
1462+
1463+ set_default_size (550, -1);
1464+ resizable = false;
1465+
1466+ content = new Gtk.Box (Gtk.Orientation.VERTICAL, 10);
1467+ padding = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 20);
1468+
1469+ // initialize controls
1470+ var warning = new Gtk.Image.from_stock ("dialog-question", Gtk.IconSize.DIALOG);
1471+ var title = new Gtk.Label (_("Import media from %s").printf (d.getDisplayName ()));
1472+ var info = new Gtk.Label (_("The following files were found on %s, but are not in your library. Check all the files you would like to import.").printf (d.getDisplayName ()));
1473+ transferAll = new Gtk.CheckButton.with_label (_("Import all media"));
1474+ mediasScroll = new Gtk.ScrolledWindow (null, null);
1475+ mediasView = new Gtk.TreeView ();
1476+ mediasModel = new ListStore(5, typeof(bool), typeof(int), typeof(string), typeof(string), typeof(string));
1477+ mediasView.set_model(mediasModel);
1478+ transfer = new Button.with_label(_("Import"));
1479+ Button cancel = new Button.with_label(_("Don't Import"));
1480+
1481+ // pretty up labels
1482+ title.xalign = 0.0f;
1483+
1484+ // be a bit explicit to make translations better
1485+ string title_text = "";
1486+ if (medias.size > 1) {
1487+ title_text = _("Import %i items from %s").printf (medias.size, d.getDisplayName ());
1488+ }
1489+ else {
1490+ var m = medias.get (0);
1491+ title_text = _("Import %s from %s").printf (m.title, d.getDisplayName ());
1492+ }
1493+
1494+ string MARKUP_TEMPLATE = "<span weight=\"bold\" size=\"larger\">%s</span>";
1495+ var title_string = MARKUP_TEMPLATE.printf (String.escape (title_text));
1496+ title.set_markup (title_string);
1497+
1498+ info.xalign = 0.0f;
1499+ info.set_line_wrap(true);
1500+
1501+ /* add cellrenderers to columns and columns to treeview */
1502+ var toggle = new CellRendererToggle ();
1503+ toggle.toggled.connect ((toggle, path) => {
1504+ var tree_path = new TreePath.from_string (path);
1505+ TreeIter iter;
1506+ mediasModel.get_iter (out iter, tree_path);
1507+ mediasModel.set (iter, 0, !toggle.active);
1508+
1509+ transfer.set_sensitive(false);
1510+ mediasModel.foreach(updateTransferSensetivity);
1511+ });
1512+
1513+ var column = new TreeViewColumn ();
1514+ column.title = "";
1515+ column.pack_start (toggle, false);
1516+ column.add_attribute (toggle, "active", 0);
1517+ mediasView.append_column(column);
1518+
1519+ mediasView.insert_column_with_attributes(-1, _("ID"), new CellRendererText(), "text", 1, null);
1520+ mediasView.insert_column_with_attributes(-1, _("Title"), new CellRendererText(), "text", 2, null);
1521+ mediasView.insert_column_with_attributes(-1, _("Artist"), new CellRendererText(), "text", 3, null);
1522+ mediasView.insert_column_with_attributes(-1, _("Album"), new CellRendererText(), "text", 4, null);
1523+ mediasView.headers_visible = true;
1524+
1525+ for(int i = 0; i < 5; ++i) {
1526+ mediasView.get_column(i).sizing = Gtk.TreeViewColumnSizing.FIXED;
1527+ mediasView.get_column(i).resizable = true;
1528+ mediasView.get_column(i).reorderable = false;
1529+ mediasView.get_column(i).clickable = false;
1530+ }
1531+
1532+ mediasView.get_column(1).visible = false;
1533+
1534+ mediasView.get_column(0).fixed_width = 25;
1535+ mediasView.get_column(1).fixed_width = 10;
1536+ mediasView.get_column(2).fixed_width = 300;
1537+ mediasView.get_column(3).fixed_width = 125;
1538+ mediasView.get_column(4).fixed_width = 125;
1539+
1540+ //view.get_selection().set_mode(SelectionMode.MULTIPLE);
1541+
1542+ /* fill the treeview */
1543+ var medias_sorted = new Gee.LinkedList<Media>();
1544+ foreach(var m in medias)
1545+ medias_sorted.add(m);
1546+ medias_sorted.sort(mediaCompareFunc);
1547+
1548+ foreach(var s in medias_sorted) {
1549+ TreeIter item;
1550+ mediasModel.append(out item);
1551+
1552+ mediasModel.set(item, 0, false, 1, s.rowid, 2, s.title, 3, s.artist, 4, s.album);
1553+ }
1554+
1555+ mediasScroll.add(mediasView);
1556+ mediasScroll.set_policy(PolicyType.AUTOMATIC, PolicyType.AUTOMATIC);
1557+
1558+ transfer.set_sensitive(false);
1559+
1560+ /* set up controls layout */
1561+ var information = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
1562+ var information_text = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
1563+ information.pack_start(warning, false, false, 10);
1564+ information_text.pack_start(title, false, true, 10);
1565+ information_text.pack_start(info, false, true, 0);
1566+ information.pack_start(information_text, true, true, 10);
1567+
1568+ var listBox = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
1569+ listBox.pack_start(mediasScroll, true, true, 5);
1570+
1571+ Expander exp = new Expander(_("Select individual media to import:"));
1572+ exp.add(listBox);
1573+ exp.expanded = false;
1574+
1575+ var bottomButtons = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL);
1576+ bottomButtons.set_layout (Gtk.ButtonBoxStyle.END);
1577+ bottomButtons.pack_end (cancel, false, false, 10);
1578+ bottomButtons.pack_end (transfer, false, false, 0);
1579+ bottomButtons.set_spacing (10);
1580+
1581+ content.pack_start(information, false, true, 0);
1582+ content.pack_start(UI.wrap_alignment (transferAll, 5, 0, 0, 75), false, true, 0);
1583+ content.pack_start(UI.wrap_alignment (exp, 0, 0, 0, 75), true, true, 0);
1584+ content.pack_start(bottomButtons, false, true, 10);
1585+
1586+ padding.pack_start(content, true, true, 10);
1587+
1588+ viewMenu = new Gtk.Menu();
1589+ selectItem = new Gtk.MenuItem.with_label(_("Check Item"));
1590+ selectAlbum = new Gtk.MenuItem.with_label(_("Check Album"));
1591+ selectArtist = new Gtk.MenuItem.with_label(_("Check Artist"));
1592+
1593+ transfer.clicked.connect(transferClick);
1594+ transferAll.toggled.connect(transferAllToggled);
1595+ //mediasView.button_press_event.connect(mediasViewClick);
1596+ cancel.clicked.connect( () => { this.destroy(); });
1597+ exp.activate.connect( () => {
1598+ if(exp.get_expanded()) {
1599+ resizable = true;
1600+ set_size_request(550, 180);
1601+ resize(475, 180);
1602+ resizable = false;
1603+ }
1604+ else
1605+ set_size_request(550, 500);
1606+ });
1607+
1608+ add(padding);
1609+ show_all();
1610+ }
1611+
1612+ public static int mediaCompareFunc(Media a, Media b) {
1613+ if(a.artist == b.artist) {
1614+ if(a.album == b.album)
1615+ return (int)a.track - (int)b.track;
1616+ else
1617+ return (a.album > b.album) ? 1 : -1;
1618+
1619+ }
1620+ else
1621+ return (a.artist > b.artist) ? 1 : -1;
1622+ }
1623+
1624+ public static Gtk.Alignment wrap_alignment (Gtk.Widget widget, int top, int right, int bottom, int left) {
1625+ var alignment = new Gtk.Alignment(0.0f, 0.0f, 1.0f, 1.0f);
1626+ alignment.top_padding = top;
1627+ alignment.right_padding = right;
1628+ alignment.bottom_padding = bottom;
1629+ alignment.left_padding = left;
1630+
1631+ alignment.add(widget);
1632+ return alignment;
1633+ }
1634+
1635+ public bool updateTransferSensetivity(TreeModel model, TreePath path, TreeIter iter) {
1636+ bool sel = false;
1637+ model.get(iter, 0, out sel);
1638+
1639+ if(sel) {
1640+ transfer.set_sensitive(true);
1641+ return true;
1642+ }
1643+
1644+ return false;
1645+ }
1646+
1647+ public bool selectAll(TreeModel model, TreePath path, TreeIter iter) {
1648+ mediasModel.set(iter, 0, true);
1649+
1650+ return false;
1651+ }
1652+
1653+ public bool unselectAll(TreeModel model, TreePath path, TreeIter iter) {
1654+ mediasModel.set(iter, 0, false);
1655+
1656+ return false;
1657+ }
1658+
1659+ public virtual void transferAllToggled() {
1660+ if(transferAll.active) {
1661+ mediasModel.foreach(selectAll);
1662+ mediasView.set_sensitive(false);
1663+ transfer.set_sensitive(true);
1664+ } else {
1665+ mediasModel.foreach(unselectAll);
1666+ mediasView.set_sensitive(true);
1667+ transfer.set_sensitive(false);
1668+ }
1669+ }
1670+
1671+ public bool createTransferList(TreeModel model, TreePath path, TreeIter iter) {
1672+ Media? m = null;
1673+ bool selected = false;
1674+ mediasModel.get(iter, 0, out selected, 1, out m);
1675+
1676+ if(m != null && selected) {
1677+ to_transfer.add(m);
1678+ }
1679+
1680+ return false;
1681+ }
1682+
1683+ public virtual void transferClick() {
1684+ to_transfer.clear();
1685+ mediasModel.foreach(createTransferList);
1686+
1687+ if(libraries_manager.local_library.doing_file_operations()) {
1688+ NotificationManager.get_default ().doAlertNotification (_("Cannot Import"), _("Noise is already doing file operations. Please wait until those finish to import from %d").printf( d.getDisplayName()));
1689+ } else {
1690+ libraries_manager.transfer_to_local_library (to_transfer);
1691+ this.destroy();
1692+ }
1693+ }
1694+
1695+ public virtual void cancelClick() {
1696+ this.destroy();
1697+ }
1698 }
1699\ No newline at end of file

Subscribers

People subscribed via source and target branches