Tracking tab shifts

This commit is contained in:
itdominator 2021-11-22 21:18:14 -06:00
parent 4fcfa156eb
commit 67b209e57b
3 changed files with 272 additions and 250 deletions

View File

@ -382,256 +382,6 @@ PyFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspecti
</object>
</child>
</object>
<object class="GtkDialog" id="context_menu">
<property name="can-focus">False</property>
<property name="window-position">mouse</property>
<property name="type-hint">splashscreen</property>
<property name="gravity">south</property>
<signal name="focus-out-event" handler="hide_context_menu" swapped="no"/>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="width-request">500</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="iconsButtonBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child type="center">
<object class="GtkButton">
<property name="label">gtk-delete</property>
<property name="name">delete</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Delete...</property>
<property name="use-stock">True</property>
<property name="always-show-image">True</property>
<signal name="button-release-event" handler="do_action_from_menu_controls" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label">gtk-cut</property>
<property name="name">cut</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Cut...</property>
<property name="use-stock">True</property>
<property name="always-show-image">True</property>
<signal name="button-release-event" handler="do_action_from_menu_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">
<property name="label">gtk-copy</property>
<property name="name">copy</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Copy...</property>
<property name="use-stock">True</property>
<property name="always-show-image">True</property>
<signal name="button-release-event" handler="do_action_from_menu_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">
<property name="label" translatable="yes">Trash</property>
<property name="name">trash</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Move to Trash...</property>
<property name="image">trashImage</property>
<property name="always-show-image">True</property>
<signal name="button-release-event" handler="do_action_from_menu_controls" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack-type">end</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label">gtk-paste</property>
<property name="name">paste</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Paste...</property>
<property name="margin-bottom">20</property>
<property name="use-stock">True</property>
<property name="always-show-image">True</property>
<signal name="button-release-event" handler="do_action_from_menu_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">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="context_menu_fname">
<property name="width-request">500</property>
<property name="height-request">26</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-top">20</property>
<property name="primary-icon-stock">gtk-edit</property>
<property name="placeholder-text" translatable="yes">New File/Dir Name...</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="menuButtonBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-top">15</property>
<property name="label" translatable="yes">Folder</property>
<attributes>
<attribute name="size" value="12000"/>
</attributes>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-top">15</property>
<property name="label" translatable="yes">File</property>
<attributes>
<attribute name="size" value="12000"/>
</attributes>
</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="position">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="context_menu_type_toggle">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="tooltip-text" translatable="yes">File/Folder</property>
<property name="active">True</property>
</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">Create</property>
<property name="name">create</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Create File/Folder...</property>
<property name="image">createImage</property>
<property name="always-show-image">True</property>
<signal name="button-release-event" handler="do_action_from_menu_controls" swapped="no"/>
</object>
<packing>
<property name="expand">False</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">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkImage" id="createImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
@ -1045,6 +795,7 @@ PyFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspecti
<property name="margin-bottom">5</property>
<property name="show-border">False</property>
<property name="scrollable">True</property>
<signal name="page-reordered" handler="on_tab_reorder" swapped="no"/>
<signal name="switch-page" handler="on_tab_switch_update" swapped="no"/>
<child>
<placeholder/>
@ -1081,6 +832,7 @@ PyFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspecti
<property name="margin-bottom">5</property>
<property name="show-border">False</property>
<property name="scrollable">True</property>
<signal name="page-reordered" handler="on_tab_reorder" swapped="no"/>
<signal name="switch-page" handler="on_tab_switch_update" swapped="no"/>
<child>
<placeholder/>
@ -1131,6 +883,7 @@ PyFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspecti
<property name="margin-bottom">5</property>
<property name="show-border">False</property>
<property name="scrollable">True</property>
<signal name="page-reordered" handler="on_tab_reorder" swapped="no"/>
<signal name="switch-page" handler="on_tab_switch_update" swapped="no"/>
<child>
<placeholder/>
@ -1166,6 +919,7 @@ PyFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspecti
<property name="margin-bottom">5</property>
<property name="show-border">False</property>
<property name="scrollable">True</property>
<signal name="page-reordered" handler="on_tab_reorder" swapped="no"/>
<signal name="switch-page" handler="on_tab_switch_update" swapped="no"/>
<child>
<placeholder/>
@ -1212,4 +966,254 @@ PyFM is developed on Atom, git, and using Python 3+ with Gtk GObject introspecti
<property name="can-focus">False</property>
<property name="pixbuf">icons/trash.png</property>
</object>
<object class="GtkDialog" id="context_menu">
<property name="can-focus">False</property>
<property name="window-position">mouse</property>
<property name="type-hint">splashscreen</property>
<property name="gravity">south</property>
<signal name="focus-out-event" handler="hide_context_menu" swapped="no"/>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="width-request">500</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="iconsButtonBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child type="center">
<object class="GtkButton">
<property name="label">gtk-delete</property>
<property name="name">delete</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Delete...</property>
<property name="use-stock">True</property>
<property name="always-show-image">True</property>
<signal name="button-release-event" handler="do_action_from_menu_controls" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label">gtk-cut</property>
<property name="name">cut</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Cut...</property>
<property name="use-stock">True</property>
<property name="always-show-image">True</property>
<signal name="button-release-event" handler="do_action_from_menu_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">
<property name="label">gtk-copy</property>
<property name="name">copy</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Copy...</property>
<property name="use-stock">True</property>
<property name="always-show-image">True</property>
<signal name="button-release-event" handler="do_action_from_menu_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">
<property name="label" translatable="yes">Trash</property>
<property name="name">trash</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Move to Trash...</property>
<property name="image">trashImage</property>
<property name="always-show-image">True</property>
<signal name="button-release-event" handler="do_action_from_menu_controls" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack-type">end</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkButton">
<property name="label">gtk-paste</property>
<property name="name">paste</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Paste...</property>
<property name="margin-bottom">20</property>
<property name="use-stock">True</property>
<property name="always-show-image">True</property>
<signal name="button-release-event" handler="do_action_from_menu_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">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="context_menu_fname">
<property name="width-request">500</property>
<property name="height-request">26</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-top">20</property>
<property name="primary-icon-stock">gtk-edit</property>
<property name="placeholder-text" translatable="yes">New File/Dir Name...</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox" id="menuButtonBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-top">15</property>
<property name="label" translatable="yes">Folder</property>
<attributes>
<attribute name="size" value="12000"/>
</attributes>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-top">15</property>
<property name="label" translatable="yes">File</property>
<attributes>
<attribute name="size" value="12000"/>
</attributes>
</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="position">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="context_menu_type_toggle">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="tooltip-text" translatable="yes">File/Folder</property>
<property name="active">True</property>
</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">Create</property>
<property name="name">create</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="tooltip-text" translatable="yes">Create File/Folder...</property>
<property name="image">createImage</property>
<property name="always-show-image">True</property>
<signal name="button-release-event" handler="do_action_from_menu_controls" swapped="no"/>
</object>
<packing>
<property name="expand">False</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">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@ -51,6 +51,22 @@ class TabMixin(WidgetMixin):
self.window_controller.save_state()
self.set_window_title()
def on_tab_reorder(self, child, page_num, new_index):
wid, tid = page_num.get_name().split("|")
window = self.get_fm_window(wid)
view = None
for i, view in enumerate(window.views):
if view.id == tid:
_view = window.get_view_by_id(tid)
watcher = _view.get_dir_watcher()
watcher.cancel()
window.views.insert(new_index, window.views.pop(i))
view = window.get_view_by_id(tid)
self.set_file_watcher(view)
self.window_controller.save_state()
def on_tab_switch_update(self, notebook, content=None, index=None):
self.selected_files.clear()
wid, tid = content.get_children()[0].get_name().split("|")

View File

@ -141,6 +141,7 @@ class WidgetMixin:
grid.show_all()
scroll.add(grid)
grid.set_name(f"{wid}|{view.id}")
scroll.set_name(f"{wid}|{view.id}")
self.builder.expose_object(f"{wid}|{view.id}|iconview", grid)
self.builder.expose_object(f"{wid}|{view.id}", scroll)
return scroll, store
@ -189,6 +190,7 @@ class WidgetMixin:
grid.show_all()
scroll.add(grid)
grid.set_name(f"{wid}|{view.id}")
scroll.set_name(f"{wid}|{view.id}")
grid.columns_autosize()
self.builder.expose_object(f"{wid}|{view.id}", scroll)
return scroll, store