Updated key bindingfs, fixed closing tabs, added keybinding

This commit is contained in:
itdominator 2021-11-20 22:51:08 -06:00
parent e4ac63e01d
commit 15aa17a046
4 changed files with 624 additions and 16 deletions

View File

@ -0,0 +1,592 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkImage" id="tggl_notebook_1_img">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="stock">gtk-apply</property>
<property name="icon_size">3</property>
</object>
<object class="GtkImage" id="tggl_notebook_2_img">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="stock">gtk-apply</property>
<property name="icon_size">3</property>
</object>
<object class="GtkImage" id="tggl_notebook_3_img">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="stock">gtk-apply</property>
<property name="icon_size">3</property>
</object>
<object class="GtkImage" id="tggl_notebook_4_img">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="stock">gtk-apply</property>
<property name="icon_size">3</property>
</object>
<object class="GtkApplicationWindow" id="Main_Window">
<property name="width-request">800</property>
<property name="height-request">600</property>
<property name="can-focus">False</property>
<property name="window-position">center</property>
<property name="default-width">1670</property>
<property name="default-height">830</property>
<property name="icon">pyfm.png</property>
<property name="gravity">center</property>
<signal name="key-press-event" handler="global_key_press_controller" swapped="no"/>
<signal name="key-release-event" handler="global_key_release_controller" swapped="no"/>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="baseline-position">top</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkMenuBar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">_File</property>
<property name="use-underline">True</property>
<child type="submenu">
<object class="GtkMenu">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-new</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-open</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-save</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-save-as</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-quit</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">_Edit</property>
<property name="use-underline">True</property>
<child type="submenu">
<object class="GtkMenu">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-cut</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-copy</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
<signal name="button-release-event" handler="menu_bar_copy" swapped="no"/>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-paste</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-delete</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">_View</property>
<property name="use-underline">True</property>
</object>
</child>
<child>
<object class="GtkMenuItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">_Help</property>
<property name="use-underline">True</property>
<child type="submenu">
<object class="GtkMenu">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkImageMenuItem">
<property name="label">gtk-about</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="use-underline">True</property>
<property name="use-stock">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButtonBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="spacing">5</property>
<property name="layout-style">start</property>
<child>
<object class="GtkToggleButton" id="tggl_notebook_1">
<property name="name">tggl_notebook_1</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">tggl_notebook_1_img</property>
<property name="always-show-image">True</property>
<signal name="released" handler="toggle_notebook_pane" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkToggleButton" id="tggl_notebook_2">
<property name="name">tggl_notebook_2</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">tggl_notebook_2_img</property>
<property name="always-show-image">True</property>
<signal name="released" handler="toggle_notebook_pane" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkToggleButton" id="tggl_notebook_3">
<property name="name">tggl_notebook_3</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">tggl_notebook_3_img</property>
<property name="always-show-image">True</property>
<signal name="released" handler="toggle_notebook_pane" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkToggleButton" id="tggl_notebook_4">
<property name="name">tggl_notebook_4</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">tggl_notebook_4_img</property>
<property name="always-show-image">True</property>
<signal name="released" handler="toggle_notebook_pane" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label" translatable="yes"> </property>
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can-focus">False</property>
<property name="focus-on-click">False</property>
<property name="receives-default">False</property>
<property name="double-buffered">False</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</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="GtkButton" id="go_home">
<property name="label">gtk-home</property>
<property name="name">go_home</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="use-stock">True</property>
<property name="always-show-image">True</property>
<signal name="released" handler="do_action_from_bar_controls" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="refresh_view">
<property name="label">gtk-refresh</property>
<property name="name">refresh_view</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="use-stock">True</property>
<property name="always-show-image">True</property>
<signal name="released" handler="do_action_from_bar_controls" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="go_up">
<property name="label">gtk-go-up</property>
<property name="name">go_up</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="use-stock">True</property>
<property name="always-show-image">True</property>
<signal name="released" handler="do_action_from_bar_controls" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="path_entry">
<property name="name">path_entry</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="placeholder-text" translatable="yes">Path...</property>
<signal name="key-release-event" handler="do_action_from_bar_controls" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkButton" id="create_tab">
<property name="label">gtk-add</property>
<property name="name">create_tab</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="use-stock">True</property>
<property name="always-show-image">True</property>
<signal name="released" handler="do_action_from_bar_controls" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkPaned" id="pane_master">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<property name="wide-handle">True</property>
<child>
<object class="GtkPaned" id="pane_top">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-bottom">5</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="wide-handle">True</property>
<child>
<object class="GtkNotebook" id="window_1">
<property name="name">notebook1</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="has-focus">True</property>
<property name="margin-left">5</property>
<property name="margin-right">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="show-border">False</property>
<property name="scrollable">True</property>
<signal name="switch-page" handler="on_tab_switch_update" swapped="no"/>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child>
<child>
<object class="GtkNotebook" id="window_2">
<property name="name">notebook2</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-left">5</property>
<property name="margin-right">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="show-border">False</property>
<property name="scrollable">True</property>
<signal name="switch-page" handler="on_tab_switch_update" swapped="no"/>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child>
<child>
<object class="GtkPaned" id="pane_bottom">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-top">5</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="wide-handle">True</property>
<child>
<object class="GtkNotebook" id="window_3">
<property name="name">notebook3</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-left">5</property>
<property name="margin-right">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="show-border">False</property>
<property name="scrollable">True</property>
<signal name="switch-page" handler="on_tab_switch_update" swapped="no"/>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child>
<child>
<object class="GtkNotebook" id="window_4">
<property name="name">notebook4</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-right">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="show-border">False</property>
<property name="scrollable">True</property>
<signal name="switch-page" handler="on_tab_switch_update" swapped="no"/>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child>
</object>
<packing>
<property name="resize">True</property>
<property name="shrink">True</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@ -106,7 +106,7 @@ class Signals(PaneMixin, WindowMixin):
if "alt" in keyname:
self.altDown = False
if (self.ctrlDown and keyname == "h") or keyname == "home":
if (self.ctrlDown and keyname == "slash") or keyname == "home":
self.builder.get_object("go_home").released()
if self.ctrlDown and keyname == "r":
self.builder.get_object("refresh_view").released()
@ -117,16 +117,12 @@ class Signals(PaneMixin, WindowMixin):
if self.ctrlDown and keyname == "t":
self.builder.get_object("create_tab").released()
if self.ctrlDown and keyname == "w":
print("[close tab] stub...")
self.keyboard_close_tab()
if self.ctrlDown and keyname == "period":
wid, tid = self.window_controller.get_active_data()
view = self.get_fm_window(wid).get_view_by_id(tid)
view.hide_hidden = not view.hide_hidden
view.load_directory()
self.builder.get_object("refresh_view").released()
if self.ctrlDown and keyname == "h":
self.show_hide_hidden_files()
if self.ctrlDown and keyname == "c":
print("[copy] stub...")
self.copy_file()
if self.ctrlDown and keyname == "v":
print("[paste] stub...")

View File

@ -31,11 +31,12 @@ class TabMixin(WidgetMixin):
self.load_store(view, store)
self.set_window_title()
def close_tab(self, widget, eve):
notebook = widget.get_parent().get_parent()
page = notebook.get_current_page()
tid = self.get_tab_id_from_tab_box(widget.get_parent())
def close_tab(self, button, eve=None):
notebook = button.get_parent().get_parent()
tid = self.get_tab_id_from_tab_box(button.get_parent())
wid = int(notebook.get_name()[-1])
scroll = self.builder.get_object(f"{wid}|{tid}")
page = notebook.page_num(scroll)
self.get_fm_window(wid).delete_view_by_id(tid)
notebook.remove_page(page)
@ -55,6 +56,9 @@ class TabMixin(WidgetMixin):
def get_tab_label(self, notebook, iconview):
return notebook.get_tab_label(iconview.get_parent()).get_children()[0]
def get_tab_close(self, notebook, iconview):
return notebook.get_tab_label(iconview.get_parent()).get_children()[1]
def get_tab_iconview_from_notebook(self, notebook):
return notebook.get_children()[1].get_children()[0]
@ -91,8 +95,22 @@ class TabMixin(WidgetMixin):
tab_label.set_label(view.get_end_of_path())
self.set_window_title()
def keyboard_close_tab(self):
wid, tid = self.window_controller.get_active_data()
notebook = self.builder.get_object(f"window_{wid}")
iconview = self.get_tab_iconview_from_notebook(notebook)
close = self.get_tab_close(notebook, iconview)
close.released()
# File control events
def show_hide_hidden_files(self):
wid, tid = self.window_controller.get_active_data()
view = self.get_fm_window(wid).get_view_by_id(tid)
view.hide_hidden = not view.hide_hidden
view.load_directory()
self.builder.get_object("refresh_view").released()
def get_uris(self, store, treePaths=None):
uris = []
@ -138,7 +156,7 @@ class TabMixin(WidgetMixin):
for path in treePaths:
itr = store.get_iter(path)
file = store.get(itr, 1)[0]
# print(file)
print(file)
# uris = self.get_uris(store, treePaths)
# print(uris)

View File

@ -86,7 +86,7 @@ class WidgetMixin:
tab = Gtk.Box()
label = Gtk.Label()
tid = Gtk.Label()
close = Gtk.EventBox()
close = Gtk.Button()
icon = Gtk.Image(stock=Gtk.STOCK_CLOSE)
label.set_label(f"{view.get_end_of_path()}")
@ -100,7 +100,7 @@ class WidgetMixin:
tab.add(close)
tab.add(tid)
close.connect("button_release_event", self.close_tab)
close.connect("released", self.close_tab)
tab.show_all()
tid.hide()
return tab
@ -140,6 +140,7 @@ class WidgetMixin:
grid.show_all()
scroll.add(grid)
grid.set_name(f"{wid}|{view.id}")
self.builder.expose_object(f"{wid}|{view.id}", scroll)
return scroll, store
def create_grid_treeview_widget(self, view, wid):
@ -187,6 +188,7 @@ class WidgetMixin:
scroll.add(grid)
grid.set_name(f"{wid}|{view.id}")
grid.columns_autosize()
self.builder.expose_object(f"{wid}|{view.id}", scroll)
return scroll, store