From 2f6fc89b0ea962e6bb34810a9596b07fb92840e8 Mon Sep 17 00:00:00 2001 From: DYefremov Date: Wed, 18 Oct 2017 00:54:09 +0300 Subject: [PATCH] skeleton of popup menus for views --- main/ui/main_app_window.py | 25 ++++++----- main/ui/main_window.glade | 87 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 10 deletions(-) diff --git a/main/ui/main_app_window.py b/main/ui/main_app_window.py index 9a4fa5b8..e3cb29f4 100644 --- a/main/ui/main_app_window.py +++ b/main/ui/main_app_window.py @@ -49,7 +49,8 @@ def get_handlers(): "on_delete": on_delete, "on_services_tree_view_drag_data_get": on_services_tree_view_drag_data_get, "on_fav_tree_view_drag_data_get": on_fav_tree_view_drag_data_get, - "on_fav_tree_view_drag_data_received": on_fav_tree_view_drag_data_received + "on_fav_tree_view_drag_data_received": on_fav_tree_view_drag_data_received, + "on_view_popup_menu": on_view_popup_menu } @@ -76,19 +77,17 @@ def on_paste(item): def on_delete(item): """ Delete selected items from views """ for view in [__services_view, __fav_view, __bouquets_view]: - selection = view.get_selection() - model, paths = selection.get_selected_rows() - itrs = [model.get_iter(path) for path in paths] - for itr in itrs: - model.remove(itr) + if view.is_focus(): + selection = view.get_selection() + model, paths = selection.get_selected_rows() + itrs = [model.get_iter(path) for path in paths] + for itr in itrs: + model.remove(itr) def on_services_tree_view_drag_data_get(view, drag_context, data, info, time): """ DnD """ - # rows = [model.get(itr, *[x for x in range(view.get_n_columns())]) for itr in itrs] - text = get_dnd_selection(view) - # print(text) - data.set_text(text, -1) + data.set_text(get_dnd_selection(view), -1) def on_fav_tree_view_drag_data_get(view, drag_context, data, info, time): @@ -137,6 +136,12 @@ def on_fav_tree_view_drag_data_received(view, drag_context, x, y, data, info, ti __status_bar.push(1, getattr(e, "message", repr(e))) +def on_view_popup_menu(menu, event): + """ Shows popup menu for any view """ + if event.get_event_type() == Gdk.EventType.BUTTON_PRESS and event.button == Gdk.BUTTON_SECONDARY: + menu.popup(None, None, None, None, event.button, event.time) + + def on_satellite_editor_show(model): """ Shows satellites editor dialog """ show_satellites_dialog(__main_window, __options["data_dir_path"]) diff --git a/main/ui/main_window.glade b/main/ui/main_window.glade index a4bed9fe..24fdabde 100644 --- a/main/ui/main_window.glade +++ b/main/ui/main_window.glade @@ -2,6 +2,29 @@ + + True + False + + + gtk-add + True + False + True + True + + + + + gtk-remove + True + False + True + True + + + + @@ -20,6 +43,44 @@ + + True + False + + + gtk-cut + True + False + True + True + + + + + gtk-paste + True + False + True + True + + + + + True + False + + + + + gtk-remove + True + False + True + True + + + + True False @@ -554,6 +615,7 @@ services_list_store both True + @@ -770,6 +832,7 @@ fav_list_store both True + @@ -847,6 +910,7 @@ bouquets_tree_store False True + @@ -979,4 +1043,27 @@ + + True + False + + + gtk-go-forward + True + False + True + True + + + + + gtk-remove + True + False + True + True + + + +