From f175f52c0bd43678eb90c5a452feb8fb92709bc0 Mon Sep 17 00:00:00 2001 From: sezanzeb Date: Thu, 12 Nov 2020 23:09:22 +0100 Subject: [PATCH] highlights changes --- data/style.css | 16 ++++++---------- keymapper/gtk/row.py | 25 ++++++++++++++++--------- keymapper/linux.py | 3 +++ 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/data/style.css b/data/style.css index e8947905..2f1d893c 100644 --- a/data/style.css +++ b/data/style.css @@ -1,3 +1,7 @@ +.changed { + background: @selected_bg_color; +} + list entry { background-color: transparent; border-radius: 4px; @@ -5,20 +9,12 @@ list entry { list button:not(:focus) { border-color: transparent; - background-color: transparent; + background: transparent; + box-shadow: none; } list button { border-color: transparent; } -.button_container { - padding: 5px; - background-color: @content_view_bg; -} - -.button_container > * { - background-color: transparent; -} - /* @theme_bg_color, @theme_fg_color */ \ No newline at end of file diff --git a/keymapper/gtk/row.py b/keymapper/gtk/row.py index e97c2672..31d57161 100644 --- a/keymapper/gtk/row.py +++ b/keymapper/gtk/row.py @@ -92,7 +92,6 @@ class Row: logger.info(msg) self.window.get('status_bar').push(CTX_KEYCODE, msg) return - # it's legal to display the keycode self.window.get('status_bar').remove_all(CTX_KEYCODE) self.keycode.set_label(str(new_keycode)) @@ -100,6 +99,7 @@ class Row: # that would overwrite the key with the mouse-button key if # the current device is a mouse self.window.window.set_focus(self.character_input) + self.highlight() # the character is empty and therefore the mapping is not complete if character is None: @@ -108,10 +108,16 @@ class Row: # else, the keycode has changed, the character is set, all good custom_mapping.change(previous_keycode, new_keycode, character) + def highlight(self): + """Mark this row as changed.""" + self.widget.get_style_context().add_class('changed') + def on_character_input_change(self, entry): keycode = self.get_keycode() character = self.get_character() + self.highlight() + if keycode is not None: custom_mapping.change(None, keycode, character) @@ -154,16 +160,17 @@ class Row: self.on_character_input_change ) - row = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) - row.set_homogeneous(True) - row.set_spacing(2) - row.pack_start(keycode_input, expand=True, fill=True, padding=0) - row.pack_start(character_input, expand=True, fill=True, padding=0) - row.pack_start(delete_button, expand=True, fill=False, padding=0) + box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL) + box.set_homogeneous(True) + box.set_spacing(2) + box.pack_start(keycode_input, expand=True, fill=True, padding=0) + box.pack_start(character_input, expand=True, fill=True, padding=0) + box.pack_start(delete_button, expand=True, fill=False, padding=0) + box.show_all() + row = Gtk.ListBoxRow() + row.add(box) row.show_all() - # in order to get this object when iterating over the listbox - row.logic = self self.widget = row self.character_input = character_input diff --git a/keymapper/linux.py b/keymapper/linux.py index 8359e307..f8d64c62 100644 --- a/keymapper/linux.py +++ b/keymapper/linux.py @@ -96,6 +96,9 @@ class KeycodeReader: # value: 1 for down, 0 for up, 2 for hold. # this happens to report key codes that are 8 lower # than the ones reported by xev + # TODO check if 280 and above works on wayland and + # if not, prevent anything > 255. adjust + # the maximum of keycodes before trying newest_keycode = event.code + 8 return newest_keycode