From 5834bd4a0bac5cab4feb041e108082aa05b4e3be Mon Sep 17 00:00:00 2001 From: DYefremov Date: Sat, 9 Feb 2019 15:25:44 +0300 Subject: [PATCH] added selection with space key --- app/ui/import_dialog.glade | 77 +++++++++++++++++++------------------- app/ui/import_dialog.py | 19 ++++++++-- 2 files changed, 55 insertions(+), 41 deletions(-) diff --git a/app/ui/import_dialog.glade b/app/ui/import_dialog.glade index 8ef3befe..38677895 100644 --- a/app/ui/import_dialog.glade +++ b/app/ui/import_dialog.glade @@ -43,6 +43,43 @@ Author: Dmitriy Yefremov + + True + False + edit-undo + + + True + False + + + gtk-select-all + True + False + True + True + + + + + + Remove selection + True + False + remove_selection_image + False + + + + + + + + + + + + False True @@ -145,6 +182,7 @@ Author: Dmitriy Yefremov 0 + @@ -246,7 +284,7 @@ Author: Dmitriy Yefremov - Name + Service True 0.5 @@ -346,41 +384,4 @@ Author: Dmitriy Yefremov - - True - False - edit-undo - - - True - False - - - gtk-select-all - True - False - True - True - - - - - - Remove selection - True - False - remove_selection_image - False - - - - - - - - - - - - diff --git a/app/ui/import_dialog.py b/app/ui/import_dialog.py index f9b5905e..2c5539eb 100644 --- a/app/ui/import_dialog.py +++ b/app/ui/import_dialog.py @@ -3,9 +3,8 @@ from contextlib import suppress from app.commons import run_idle from app.eparser import get_bouquets, get_services from app.properties import Profile -from app.ui.dialogs import get_message from app.ui.main_helper import on_popup_menu -from .uicommons import Gtk, UI_RESOURCES_PATH +from .uicommons import Gtk, UI_RESOURCES_PATH, KeyboardKey class ImportDialog: @@ -17,7 +16,8 @@ class ImportDialog: "on_info_bar_close": self.on_info_bar_close, "on_select_all": self.on_select_all, "on_unselect_all": self.on_unselect_all, - "on_popup_menu": on_popup_menu} + "on_popup_menu": on_popup_menu, + "on_key_press": self.on_key_press} builder = Gtk.Builder() builder.set_translation_domain("demon-editor") @@ -131,6 +131,19 @@ class ImportDialog: def update_selection(self, view, select): view.get_model().foreach(lambda mod, path, itr: mod.set_value(itr, 2, select)) + def on_key_press(self, view, event): + """ Handling keystrokes """ + key_code = event.hardware_keycode + if not KeyboardKey.value_exist(key_code): + return + key = KeyboardKey(key_code) + + if key is KeyboardKey.SPACE: + path, column = view.get_cursor() + itr = self._main_model.get_iter(path) + selected = self._main_model.get_value(itr, 2) + self._main_model.set_value(itr, 2, not selected) + if __name__ == "__main__": pass