add icon files (from thorwil)
[ardour.git] / gtk2_ardour / editor_region_list.cc
index 09a56e9af577921a62cc149a62c9e27d98b9a2df..fdb8ca9dd394319be1633f0a724327cf3c622491 100644 (file)
@@ -48,22 +48,27 @@ using namespace Glib;
 using namespace Editing;
 
 void
-Editor::handle_audio_region_removed (boost::shared_ptr<AudioRegion> region)
+Editor::handle_audio_region_removed (boost::weak_ptr<AudioRegion> wregion)
 {
-       ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::handle_audio_region_removed), region));
+       ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::handle_audio_region_removed), wregion));
        redisplay_regions ();
 }
 
 void
-Editor::handle_new_audio_region (boost::shared_ptr<AudioRegion> region)
+Editor::handle_new_audio_region (boost::weak_ptr<AudioRegion> wregion)
 {
-       ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::handle_new_audio_region), region));
+       ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::handle_new_audio_region), wregion));
 
        /* don't copy region - the one we are being notified
           about belongs to the session, and so it will
           never be edited.
        */
-       add_audio_region_to_region_display (region);
+
+       boost::shared_ptr<AudioRegion> region (wregion.lock());
+       
+       if (region) {
+               add_audio_region_to_region_display (region);
+       }
 }
 
 void
@@ -120,11 +125,11 @@ Editor::add_audio_region_to_region_display (boost::shared_ptr<AudioRegion> regio
                set_color(c, rgba_from_style ("RegionListWholeFile", 0xff, 0, 0, 0, "fg", Gtk::STATE_NORMAL, false ));
                row[region_list_columns.color_] = c;
 
-               if (region->source().name()[0] == '/') { // external file
+               if (region->source()->name()[0] == '/') { // external file
 
                        if (region->whole_file()) {
                                str = ".../";
-                               str += PBD::basename_nosuffix (region->source().name());
+                               str += PBD::basename_nosuffix (region->source()->name());
                                
                        } else {
                                str = region->name();
@@ -235,6 +240,7 @@ Editor::redisplay_regions ()
                for (list<boost::shared_ptr<AudioRegion> >::iterator r = tmp_audio_region_list.begin(); r != tmp_audio_region_list.end(); ++r) {
                        add_audio_region_to_region_display (*r);
                }
+               tmp_audio_region_list.clear();
                
                region_list_display.set_model (region_list_model);
        }
@@ -336,20 +342,15 @@ Editor::region_list_display_button_press (GdkEventButton *ev)
                }
        }
 
-       if (region == 0) {
-               return false;
-       }
-
-       if (Keyboard::is_delete_event (ev)) {
-               session->remove_region_from_region_list (region);
-               return true;
-       }
-
        if (Keyboard::is_context_menu_event (ev)) {
                show_region_list_display_context_menu (ev->button, ev->time);
                return true;
        }
 
+       if (region == 0) {
+               return false;
+       }
+
        switch (ev->button) {
        case 1:
                /* audition on double click */
@@ -467,7 +468,7 @@ Editor::region_list_sorter (TreeModel::iterator a, TreeModel::iterator b)
                break;
                
        case ByTimestamp:
-               cmp = region1->source().timestamp() - region2->source().timestamp();
+               cmp = region1->source()->timestamp() - region2->source()->timestamp();
                break;
        
        case ByStartInFile:
@@ -479,22 +480,22 @@ Editor::region_list_sorter (TreeModel::iterator a, TreeModel::iterator b)
                break;
                
        case BySourceFileName:
-               cmp = strcasecmp (region1->source().name().c_str(), region2->source().name().c_str());
+               cmp = strcasecmp (region1->source()->name().c_str(), region2->source()->name().c_str());
                break;
 
        case BySourceFileLength:
-               cmp = region1->source().length() - region2->source().length();
+               cmp = region1->source()->length() - region2->source()->length();
                break;
                
        case BySourceFileCreationDate:
-               cmp = region1->source().timestamp() - region2->source().timestamp();
+               cmp = region1->source()->timestamp() - region2->source()->timestamp();
                break;
 
        case BySourceFileFS:
-               if (region1->source().name() == region2->source().name()) {
+               if (region1->source()->name() == region2->source()->name()) {
                        cmp = strcasecmp (region1->name().c_str(),  region2->name().c_str());
                } else {
-                       cmp = strcasecmp (region1->source().name().c_str(),  region2->source().name().c_str());
+                       cmp = strcasecmp (region1->source()->name().c_str(),  region2->source()->name().c_str());
                }
                break;
        }
@@ -582,7 +583,7 @@ Editor::region_list_display_drag_data_received (const RefPtr<Gdk::DragContext>&
        vector<ustring> paths;
 
        if (convert_drop_to_paths (paths, context, x, y, data, info, time) == 0) {
-               jack_nframes_t pos = 0;
+               nframes_t pos = 0;
                do_embed (paths, false, ImportAsRegion, 0, pos, true);
                context->drag_finish (true, false, time);
        }