~gero-bare/noise/bug-983435-drag-on-leftpanel

« back to all changes in this revision

Viewing changes to src/LibraryWindow.vala

  • Committer: Geronimo Bareiro
  • Date: 2014-10-23 03:14:33 UTC
  • Revision ID: gero.bare@gmail.com-20141023031433-q9tgs0k04ht0314n
Fix style issues.

Show diffs side-by-side

added added

removed removed

Lines of Context:
151
151
        }*/
152
152
    }
153
153
 
154
 
    private Gtk.Box create_drop_playlist_box(){
 
154
    private Gtk.Box create_drop_playlist_box () {
155
155
        Gtk.Box playlist_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
156
156
        Gtk.Image image = new Gtk. Image.from_stock ("gtk-new", Gtk.IconSize.DIALOG);
157
 
        playlist_box.pack_start(image, true, true, 0);
158
 
        Gtk.Label  label = new Gtk.Label(_("<b>New Play List</b>"));
 
157
        playlist_box.pack_start (image, true, true, 0);
 
158
        Gtk.Label label = new Gtk.Label (_("<b>New Play List</b>"));
159
159
        label.set_use_markup (true);
160
 
        playlist_box.pack_end(label,false, false, 0);
161
 
        playlist_box.show_all();
 
160
        playlist_box.pack_end (label, false, false, 0);
 
161
        playlist_box.show_all ();
162
162
        return playlist_box;
163
163
        
164
164
    }
333
333
        view_container        = new ViewContainer ();
334
334
        source_list_view      = new SourceListView ();
335
335
        left_panel            = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
336
 
        drop_playlist_box     = create_drop_playlist_box();
 
336
        drop_playlist_box     = create_drop_playlist_box ();
337
337
 
338
338
        // Set properties of various controls
339
339
        var saved_state = Settings.SavedState.get_default ();
344
344
        view_container_hpaned.pack1 (view_container, true, false);
345
345
        view_container_hpaned.pack2 (info_panel, false, false);
346
346
 
347
 
        left_panel.pack_start(source_list_view,true, true, 0);
348
 
        left_panel.pack_end(drop_playlist_box,false, false, 0);
 
347
        left_panel.pack_start(source_list_view, true, true, 0);
 
348
        left_panel.pack_end(drop_playlist_box, false, false, 0);
349
349
 
350
350
        main_hpaned.pack1 (left_panel, false, false);
351
351
        main_hpaned.pack2 (view_container_hpaned, true, false);
365
365
        Gtk.TargetEntry uri_list_entry = { "text/uri-list", Gtk.TargetFlags.SAME_APP, 0 };
366
366
        Gtk.drag_dest_set (drop_playlist_box,Gtk.DestDefaults.ALL, { uri_list_entry }, Gdk.DragAction.COPY);
367
367
 
368
 
        drop_playlist_box.drag_data_received.connect(on_drop_playlist_box);
369
 
 
370
 
        this.hide_drop_playlist_box.connect( () =>{
371
 
            if(drop_playlist_box.is_visible()){
372
 
                drop_playlist_box.hide();
373
 
            }
374
 
        });
375
 
 
376
 
        this.show_drop_playlist_box.connect( () =>{
377
 
            if(!drop_playlist_box.is_visible()){
378
 
                drop_playlist_box.show();
379
 
            }
380
 
        });
381
 
 
382
 
        drop_playlist_box.hide(); //default hiden
 
368
        drop_playlist_box.drag_data_received.connect (on_drop_playlist_box);
 
369
 
 
370
        this.hide_drop_playlist_box.connect ( () => {
 
371
            if ( drop_playlist_box.is_visible () ) {
 
372
                drop_playlist_box.hide ();
 
373
            }
 
374
        });
 
375
 
 
376
        this.show_drop_playlist_box.connect ( () => {
 
377
            if( !drop_playlist_box.is_visible () ) {
 
378
                drop_playlist_box.show ();
 
379
            }
 
380
        });
 
381
 
 
382
        drop_playlist_box.hide (); //default hiden
383
383
 
384
384
        debug ("Done with main widgets");
385
385
    }
386
386
 
387
387
    public void on_drop_playlist_box (Gdk.DragContext context, int x, int y, Gtk.SelectionData data) {
388
388
        var p = new StaticPlaylist ();
389
 
        var uri_list = data.get_uris();
 
389
        var uri_list = data.get_uris ();
390
390
        var to_add = new Gee.LinkedList<Media> ();
391
391
        foreach (string uri in uri_list ){
392
392
                Media m =  new Media (uri);
393
 
                to_add.add(m);
 
393
                to_add.add (m);
394
394
        }
395
395
        p.add_medias (to_add);
396
396
        p.name = PlaylistsUtils.get_new_playlist_name (library_manager.get_playlists ());