showing the current keycode, better loading indicator

xkb
sezanzeb 4 years ago committed by sezanzeb
parent cee8af2af6
commit 8f0db825fd

@ -256,6 +256,7 @@
<property name="title" translatable="yes">Key Mapper</property> <property name="title" translatable="yes">Key Mapper</property>
<property name="icon_name">mouse</property> <property name="icon_name">mouse</property>
<signal name="delete-event" handler="on_close" swapped="no"/> <signal name="delete-event" handler="on_close" swapped="no"/>
<signal name="key-press-event" handler="on_window_key_press_event" swapped="no"/>
<child> <child>
<object class="GtkBox" id="wrapper"> <object class="GtkBox" id="wrapper">
<property name="visible">True</property> <property name="visible">True</property>
@ -558,6 +559,7 @@
<object class="GtkLabel" id="keycode"> <object class="GtkLabel" id="keycode">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">This is the keycode you just pressed, and that you see in the mappings to the right.</property>
<property name="margin_start">10</property> <property name="margin_start">10</property>
<property name="margin_end">10</property> <property name="margin_end">10</property>
<property name="width_chars">4</property> <property name="width_chars">4</property>
@ -705,24 +707,20 @@ Control_R</property>
<placeholder/> <placeholder/>
</child> </child>
</object> </object>
<object class="GtkDialog" id="loading"> <object class="GtkMessageDialog" id="loading">
<property name="can_focus">False</property> <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="type_hint">dialog</property>
<property name="urgency_hint">True</property> <property name="decorated">False</property>
<property name="text" translatable="yes">Loading...</property>
<child internal-child="vbox"> <child internal-child="vbox">
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area"> <child internal-child="action_area">
<object class="GtkButtonBox"> <object class="GtkButtonBox">
<property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="halign">center</property> <property name="homogeneous">True</property>
<property name="layout_style">end</property> <property name="layout_style">end</property>
<child> <child>
<placeholder/> <placeholder/>
@ -733,58 +731,10 @@ Control_R</property>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">True</property> <property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage" id="error-image2">
<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_label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">10</property>
<property name="margin_right">10</property>
<property name="margin_start">10</property>
<property name="margin_end">10</property>
<property name="ypad">6</property>
<property name="label" translatable="yes">Loading...</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> </object>
</child> </child>
<child type="titlebar"> <child type="titlebar">

@ -38,8 +38,9 @@ class LoadingDialog:
builder = Gtk.Builder() builder = Gtk.Builder()
builder.add_from_file(gladefile) builder.add_from_file(gladefile)
dialog = builder.get_object('loading') dialog = builder.get_object('loading')
dialog.show() dialog.show_all()
self.dialog = dialog self.dialog = dialog
def close(self): def destroy(self):
"""Destroy this dialog."""
self.dialog.destroy() self.dialog.destroy()

@ -116,7 +116,7 @@ class Window:
window.set_sensitive(True) window.set_sensitive(True)
self.get('wrapper').set_opacity(1) self.get('wrapper').set_opacity(1)
loading.close() loading.destroy()
def get(self, name): def get(self, name):
"""Get a widget from the window""" """Get a widget from the window"""
@ -190,6 +190,13 @@ class Window:
key_list = self.get('key_list') key_list = self.get('key_list')
key_list.forall(lambda row: row.unhighlight()) key_list.forall(lambda row: row.unhighlight())
def on_window_key_press_event(self, window, event):
"""Write down the pressed key on the UI.
Helps to understand what the numbers in the mapping are about.
"""
self.get('keycode').set_text(str(event.get_keycode()[1]))
def on_apply_system_layout_clicked(self, button): def on_apply_system_layout_clicked(self, button):
"""Load the mapping.""" """Load the mapping."""
setxkbmap(self.selected_device, None) setxkbmap(self.selected_device, None)

Loading…
Cancel
Save