highlights changes

first
sezanzeb 4 years ago
parent e158245ff7
commit f175f52c0b

@ -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 */

@ -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

@ -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

Loading…
Cancel
Save