automatically switches to the keycode input

This commit is contained in:
sezanzeb 2020-11-12 21:36:40 +01:00
parent 3d3cc7f8e9
commit e158245ff7
3 changed files with 132 additions and 2 deletions

View File

@ -123,6 +123,127 @@
<placeholder/>
</child>
</object>
<object class="GtkImage" id="gtk-delete-icon">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">gtk-delete</property>
</object>
<object class="GtkImage" id="gtk-redo-icon">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-redo</property>
</object>
<object class="GtkDialog" id="unsaved_changes">
<property name="can_focus">False</property>
<property name="title" translatable="yes">Key Mapper</property>
<property name="modal">True</property>
<property name="window_position">center</property>
<property name="icon_name">mouse</property>
<property name="type_hint">dialog</property>
<property name="urgency_hint">True</property>
<child internal-child="vbox">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="go_back">
<property name="label">Continue</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="image">gtk-delete-icon</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="go_ahead">
<property name="label" translatable="yes">Go Back</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">gtk-redo-icon</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage" id="error-image1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="yalign">0</property>
<property name="xpad">12</property>
<property name="ypad">12</property>
<property name="icon_name">mouse</property>
<property name="icon_size">6</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="secondary_error_label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_start">10</property>
<property name="margin_end">10</property>
<property name="ypad">6</property>
<property name="label" translatable="yes">You have got unsaved changes!</property>
<property name="use_markup">True</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-7">go_back</action-widget>
</action-widgets>
<child type="titlebar">
<placeholder/>
</child>
</object>
<object class="GtkWindow" id="window">
<property name="width_request">450</property>
<property name="can_focus">False</property>
@ -418,8 +539,7 @@
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Click on a cell below and hit a key on your device. Use the tab
key if mouseclicks overwrite your input.</property>
<property name="tooltip_text" translatable="yes">Click on a cell below and hit a key on your device.</property>
<property name="margin_top">5</property>
<property name="margin_bottom">5</property>
<property name="label" translatable="yes">Key</property>

View File

@ -96,6 +96,10 @@ class Row:
# it's legal to display the keycode
self.window.get('status_bar').remove_all(CTX_KEYCODE)
self.keycode.set_label(str(new_keycode))
# switch to the character, don't require mouse input because
# 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)
# the character is empty and therefore the mapping is not complete
if character is None:

View File

@ -189,6 +189,8 @@ class Window:
def on_select_device(self, dropdown):
"""List all presets, create one if none exist yet."""
# TODO unsaved changes dialog
device = dropdown.get_active_text()
logger.debug('Selecting device "%s"', device)
@ -203,6 +205,8 @@ class Window:
def on_create_preset_clicked(self, button):
"""Create a new preset and select it."""
# TODO unsaved changes dialog
new_preset = create_preset(self.selected_device)
self.get('preset_selection').append(new_preset, new_preset)
self.get('preset_selection').set_active_id(new_preset)
@ -210,6 +214,8 @@ class Window:
def on_select_preset(self, dropdown):
"""Show the mappings of the preset."""
# TODO unsaved changes dialog
self.clear_mapping_table()
preset = dropdown.get_active_text()