Skip to content

Commit

Permalink
Enable keyboard navigation through the title bar
Browse files Browse the repository at this point in the history
This also enables to leave the Icon View through
either Tab or Shift-Tab.
  • Loading branch information
Valentin Villenave authored and jeromerobert committed Oct 15, 2021
1 parent ab0de3e commit 89afe1f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 29 deletions.
28 changes: 0 additions & 28 deletions data/pdfarranger.ui
Expand Up @@ -21,31 +21,26 @@ along with PDF Arranger. If not, see <http://www.gnu.org/licenses/>.
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkApplicationWindow" id="main_window">
<property name="can_focus">False</property>
<property name="show_menubar">False</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="header_bar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">4</property>
<property name="show_close_button">True</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="focus_on_click">False</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Open a file and append it to the current document</property>
<property name="action_name">win.import</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">insert-image-symbolic</property>
<property name="use_fallback">True</property>
</object>
Expand All @@ -60,14 +55,12 @@ along with PDF Arranger. If not, see <http://www.gnu.org/licenses/>.
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Save</property>
<property name="action_name">win.save</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">document-save-symbolic</property>
</object>
</child>
Expand All @@ -81,14 +74,12 @@ along with PDF Arranger. If not, see <http://www.gnu.org/licenses/>.
<child>
<object class="GtkButton" id="save_as_bar_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Save As</property>
<property name="action_name">win.save-as</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">document-save-as-symbolic</property>
</object>
</child>
Expand All @@ -108,7 +99,6 @@ along with PDF Arranger. If not, see <http://www.gnu.org/licenses/>.
<object class="GtkEntry" id="num_pages">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="editable">False</property>
<property name="width_chars">3</property>
<property name="text">0</property>
Expand All @@ -123,14 +113,12 @@ along with PDF Arranger. If not, see <http://www.gnu.org/licenses/>.
<child>
<object class="GtkMenuButton" id="main_menu_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">False</property>
<property name="use_popover">False</property>
<property name="tooltip_text" translatable="yes">Main Menu</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">open-menu-symbolic</property>
</object>
</child>
Expand All @@ -143,12 +131,10 @@ along with PDF Arranger. If not, see <http://www.gnu.org/licenses/>.
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="focus_on_click">False</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Zoom In</property>
Expand All @@ -157,7 +143,6 @@ along with PDF Arranger. If not, see <http://www.gnu.org/licenses/>.
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">zoom-in-symbolic</property>
</object>
</child>
Expand All @@ -174,7 +159,6 @@ along with PDF Arranger. If not, see <http://www.gnu.org/licenses/>.
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="focus_on_click">False</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Zoom Out</property>
Expand All @@ -183,7 +167,6 @@ along with PDF Arranger. If not, see <http://www.gnu.org/licenses/>.
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">zoom-out-symbolic</property>
</object>
</child>
Expand All @@ -209,12 +192,10 @@ along with PDF Arranger. If not, see <http://www.gnu.org/licenses/>.
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="focus_on_click">False</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Rotate Left</property>
Expand All @@ -223,7 +204,6 @@ along with PDF Arranger. If not, see <http://www.gnu.org/licenses/>.
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">object-rotate-left-symbolic</property>
</object>
</child>
Expand All @@ -240,7 +220,6 @@ along with PDF Arranger. If not, see <http://www.gnu.org/licenses/>.
<child>
<object class="GtkButton">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="focus_on_click">False</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Rotate Right</property>
Expand All @@ -249,7 +228,6 @@ along with PDF Arranger. If not, see <http://www.gnu.org/licenses/>.
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">object-rotate-right-symbolic</property>
</object>
</child>
Expand Down Expand Up @@ -277,12 +255,10 @@ along with PDF Arranger. If not, see <http://www.gnu.org/licenses/>.
<child>
<object class="GtkBox" id="main_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<placeholder/>
</child>
Expand All @@ -296,7 +272,6 @@ along with PDF Arranger. If not, see <http://www.gnu.org/licenses/>.
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
Expand All @@ -308,12 +283,10 @@ along with PDF Arranger. If not, see <http://www.gnu.org/licenses/>.
<!-- n-columns=2 n-rows=1 -->
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_spacing">10</property>
<child>
<object class="GtkStatusbar" id="statusbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_right">183</property>
<property name="margin_start">4</property>
<property name="margin_end">4</property>
Expand All @@ -331,7 +304,6 @@ along with PDF Arranger. If not, see <http://www.gnu.org/licenses/>.
<child>
<object class="GtkStatusbar" id="statusbar2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">end</property>
<property name="margin_right">4</property>
<property name="margin_start">4</property>
Expand Down
6 changes: 5 additions & 1 deletion pdfarranger/pdfarranger.py
Expand Up @@ -1715,7 +1715,11 @@ def iv_key_press_event(self, iconview, event):
sw_vadj.set_value(min(sw_vpos_up, last_cell_y + self.vp_css_margin - 6))
else:
sw_vadj.set_value(min(sw_vpos_down, last_cell_y + self.vp_css_margin - 6))
return True # Prevent propagation

# Let Tab and Shift-Tab go through for keyboard navigation.
elif event.keyval in [Gdk.KEY_Tab, Gdk.KEY_KP_Tab, Gdk.KEY_ISO_Left_Tab]:
return False
return True

def iv_selection_changed_event(self, _iconview=None, move_cursor_event=False):
selection = self.iconview.get_selected_items()
Expand Down

0 comments on commit 89afe1f

Please sign in to comment.