summaryrefslogtreecommitdiff
path: root/gtk2_ardour
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-11-30 11:07:37 +0100
committerRobin Gareus <robin@gareus.org>2016-11-30 11:07:37 +0100
commit02ded9061898aebc31c9131880627ae79e2c3f5b (patch)
tree724e2998ea9dc6000be4ec3ccda25f1c3048c8c8 /gtk2_ardour
parentaebd22cbe60818b5413e0cadef6b9bf8dc17ecac (diff)
allow to remove a session from the recent list
Diffstat (limited to 'gtk2_ardour')
-rw-r--r--gtk2_ardour/session_dialog.cc60
-rw-r--r--gtk2_ardour/session_dialog.h7
2 files changed, 65 insertions, 2 deletions
diff --git a/gtk2_ardour/session_dialog.cc b/gtk2_ardour/session_dialog.cc
index 6cb28f99b0..f94074f718 100644
--- a/gtk2_ardour/session_dialog.cc
+++ b/gtk2_ardour/session_dialog.cc
@@ -324,6 +324,7 @@ SessionDialog::setup_recent_sessions ()
recent_session_display.show();
recent_session_display.signal_row_activated().connect (sigc::mem_fun (*this, &SessionDialog::recent_row_activated));
+ recent_session_display.signal_button_press_event().connect (sigc::mem_fun (*this, &SessionDialog::recent_button_press), false);
}
void
@@ -1178,6 +1179,65 @@ SessionDialog::recent_row_activated (const Gtk::TreePath&, Gtk::TreeViewColumn*)
response (RESPONSE_ACCEPT);
}
+bool
+SessionDialog::recent_button_press (GdkEventButton* ev)
+{
+ if ((ev->type == GDK_BUTTON_PRESS) && (ev->button == 3) ) {
+
+ TreeModel::Path path;
+ TreeViewColumn* column;
+ int cellx, celly;
+ if (recent_session_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
+ Glib::RefPtr<Gtk::TreeView::Selection> selection = recent_session_display.get_selection();
+ if (selection) {
+ selection->unselect_all();
+ selection->select(path);
+ }
+ }
+
+ if (recent_session_display.get_selection()->count_selected_rows() > 0) {
+ recent_context_mennu (ev);
+ }
+ }
+ return false;
+}
+
+void
+SessionDialog::recent_context_mennu (GdkEventButton *ev)
+{
+ using namespace Gtk::Menu_Helpers;
+
+ TreeIter iter = recent_session_display.get_selection()->get_selected();
+ assert (iter);
+ string s = (*iter)[recent_session_columns.fullpath];
+ if (Glib::file_test (s, Glib::FILE_TEST_IS_REGULAR)) {
+ s = Glib::path_get_dirname (s);
+ }
+ if (!Glib::file_test (s, Glib::FILE_TEST_IS_DIR)) {
+ return;
+ }
+
+ Gtk::Menu* m = manage (new Menu);
+ MenuList& items = m->items ();
+ items.push_back (MenuElem (s));
+ items.push_back (SeparatorElem());
+ items.push_back (MenuElem (_("Remove from recent"), sigc::mem_fun (*this, &SessionDialog::recent_remove_selected)));
+ m->popup (ev->button, ev->time);
+}
+
+void
+SessionDialog::recent_remove_selected ()
+{
+ TreeIter iter = recent_session_display.get_selection()->get_selected();
+ assert (iter);
+ string s = (*iter)[recent_session_columns.fullpath];
+ if (Glib::file_test (s, Glib::FILE_TEST_IS_REGULAR)) {
+ s = Glib::path_get_dirname (s);
+ }
+ ARDOUR::remove_recent_sessions (s);
+ redisplay_recent_sessions ();
+}
+
void
SessionDialog::disable_plugins_clicked ()
{
diff --git a/gtk2_ardour/session_dialog.h b/gtk2_ardour/session_dialog.h
index 98bdd6b788..a464e5a5ef 100644
--- a/gtk2_ardour/session_dialog.h
+++ b/gtk2_ardour/session_dialog.h
@@ -139,15 +139,18 @@ class SessionDialog : public ArdourDialog {
Gtk::TreeView recent_session_display;
Glib::RefPtr<Gtk::TreeStore> recent_session_model;
Gtk::ScrolledWindow recent_scroller;
- Gtk::Label recent_label;
+ Gtk::Label recent_label;
Gtk::FileChooserButton existing_session_chooser;
int redisplay_recent_sessions ();
void recent_session_row_selected ();
void recent_session_sort_changed ();
void recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
+ bool recent_button_press (GdkEventButton*);
+ void recent_context_mennu (GdkEventButton*);
+ void recent_remove_selected ();
void existing_session_selected ();
- void session_selected ();
+ void session_selected ();
/* new sessions */