Sync current work

This commit is contained in:
Heliguy
2024-08-25 23:19:46 -04:00
parent bb1a374db3
commit 485a845b5e
8 changed files with 51 additions and 17 deletions

View File

@@ -13,6 +13,12 @@
<key name="is-fullscreen" type="b"> <key name="is-fullscreen" type="b">
<default>false</default> <default>false</default>
</key> </key>
<key name="sidebar-shown" type="b">
<default>true</default>
</key>
<key name="page-shown" type="s">
<default>"packages"</default>
</key>
</schema> </schema>
<schema id="io.github.flattool.Warehouse.filter" path="/io/github/flattool/Warehouse/filter/"> <schema id="io.github.flattool.Warehouse.filter" path="/io/github/flattool/Warehouse/filter/">
<key name="show-apps" type="b"> <key name="show-apps" type="b">
@@ -28,4 +34,12 @@
<default>"all"</default> <default>"all"</default>
</key> </key>
</schema> </schema>
<schema id="io.github.flattool.Warehouse.data_page" path="/io/github/flattool/Warehouse/data_page/">
<key name="sort-ascend" type="b">
<default>false</default>
</key>
<key name="sort-mode" type="s">
<default>"size"</default>
</key>
</schema>
</schemalist> </schemalist>

View File

@@ -17,6 +17,7 @@ class InstallPage(Adw.BreakpointBin):
# It is used to determine if a new page should be made or not # It is used to determine if a new page should be made or not
# This must be set to the created object from within the class's __init__ method # This must be set to the created object from within the class's __init__ method
instance = None instance = None
page_name = "install"
current_installation = "" current_installation = ""
current_remote = None current_remote = None

View File

@@ -55,13 +55,6 @@ class WarehouseWindow(Adw.ApplicationWindow):
# if keyval == Gdk.KEY_Escape: # if keyval == Gdk.KEY_Escape:
# self.batch_mode_button.set_active(False) # self.batch_mode_button.set_active(False)
def navigation_handler(self, _, row, hide_sidebar=True):
row = row.get_child()
page = self.pages[row]
self.stack.set_visible_child(page)
if self.main_split.get_collapsed():
self.main_split.set_show_sidebar(False)
def start_loading(self, *args): def start_loading(self, *args):
for _, page in self.pages.items(): for _, page in self.pages.items():
if page.instance: if page.instance:
@@ -78,6 +71,14 @@ class WarehouseWindow(Adw.ApplicationWindow):
self.refresh_button.set_sensitive(False) self.refresh_button.set_sensitive(False)
HostInfo.get_flatpaks(callback=self.end_loading) HostInfo.get_flatpaks(callback=self.end_loading)
def navigation_handler(self, _, row):
row = row.get_child()
page = self.pages[row]
self.stack.set_visible_child(page)
self.settings.set_string("page-shown", page.page_name)
if self.main_split.get_collapsed():
self.main_split.set_show_sidebar(False)
def activate_row(self, nav_row): def activate_row(self, nav_row):
idx = 0 idx = 0
while row := self.navigation_row_listbox.get_row_at_index(idx): while row := self.navigation_row_listbox.get_row_at_index(idx):
@@ -85,7 +86,12 @@ class WarehouseWindow(Adw.ApplicationWindow):
if row.get_child() is nav_row: if row.get_child() is nav_row:
row.activate() row.activate()
nav_row.grab_focus() nav_row.grab_focus()
return break
def save_sidebar_state(self, *args):
state = self.main_split.get_show_sidebar()
self.settings.set_boolean("sidebar-shown", state)
print(self.settings.get_boolean("sidebar-shown"))
def __init__(self, **kwargs): def __init__(self, **kwargs):
super().__init__(**kwargs) super().__init__(**kwargs)
@@ -104,8 +110,14 @@ class WarehouseWindow(Adw.ApplicationWindow):
self.install_row: InstallPage(main_window=self), self.install_row: InstallPage(main_window=self),
} }
for _, page in self.pages.items(): self.navigation_row_listbox.connect("row-activated", self.navigation_handler)
page_to_show = self.settings.get_string("page-shown")
print(page_to_show)
for row, page in self.pages.items():
self.stack.add_child(page) self.stack.add_child(page)
if page_to_show == page.page_name:
self.activate_row(row)
# Apply # Apply
self.settings.bind("window-width", self, "default-width", Gio.SettingsBindFlags.DEFAULT) self.settings.bind("window-width", self, "default-width", Gio.SettingsBindFlags.DEFAULT)
@@ -120,12 +132,14 @@ class WarehouseWindow(Adw.ApplicationWindow):
# Connections # Connections
event_controller.connect("key-pressed", self.key_handler) event_controller.connect("key-pressed", self.key_handler)
self.navigation_row_listbox.connect("row-activated", self.navigation_handler)
# file_drop.connect("drop", self.drop_callback) # file_drop.connect("drop", self.drop_callback)
self.refresh_button.connect("clicked", self.refresh_handler) self.refresh_button.connect("clicked", self.refresh_handler)
self.activate_row(self.install_row) # self.activate_row(self.user_data_row)
self.main_split.set_show_sidebar(True) # self.main_split.set_show_sidebar(self.settings.get_boolean("sidebar-shown"))
# GLib.idle_add(lambda *_: self.main_split.set_show_sidebar(False))
# print(self.settings.get_boolean("sidebar-shown"))
# self.main_split.connect("notify::show-sidebar", self.save_sidebar_state)
self.start_loading() self.start_loading()
HostInfo.get_flatpaks(callback=self.end_loading) HostInfo.get_flatpaks(callback=self.end_loading)

View File

@@ -17,7 +17,7 @@ class AppRow(Adw.ActionRow):
self.image.add_css_class("icon-dropshadow") self.image.add_css_class("icon-dropshadow")
self.image.set_from_file(self.package.icon_path) self.image.set_from_file(self.package.icon_path)
def gest(self, *args): def gesture_handler(self, *args):
self.on_long_press(self) self.on_long_press(self)
def __init__(self, package, on_long_press=None, **kwargs): def __init__(self, package, on_long_press=None, **kwargs):
@@ -26,16 +26,16 @@ class AppRow(Adw.ActionRow):
# Extra Object Creation # Extra Object Creation
self.package = package self.package = package
self.on_long_press = on_long_press self.on_long_press = on_long_press
self.rclick_gesture = Gtk.GestureClick() self.rclick_gesture = Gtk.GestureClick(button=3)
self.long_press_gesture = Gtk.GestureLongPress() self.long_press_gesture = Gtk.GestureLongPress()
# Apply # Apply
GLib.idle_add(lambda *_: self.set_title(package.info["name"])) GLib.idle_add(lambda *_: self.set_title(package.info["name"]))
GLib.idle_add(lambda *_: self.set_subtitle(package.info["id"])) GLib.idle_add(lambda *_: self.set_subtitle(package.info["id"]))
GLib.idle_add(lambda *_: self.idle_stuff()) GLib.idle_add(lambda *_: self.idle_stuff())
self.rclick_gesture.set_button(3)
self.add_controller(self.rclick_gesture) self.add_controller(self.rclick_gesture)
self.add_controller(self.long_press_gesture)
# Connections # Connections
self.rclick_gesture.connect("released", self.gest) self.rclick_gesture.connect("released", self.gesture_handler)
self.long_press_gesture.connect("pressed", self.gest) self.long_press_gesture.connect("pressed", self.gesture_handler)

View File

@@ -42,6 +42,7 @@ class PackagesPage(Adw.BreakpointBin):
# It is used to determine if a new page should be made or not # It is used to determine if a new page should be made or not
# This must be set to the created object from within the class's __init__ method # This must be set to the created object from within the class's __init__ method
instance = None instance = None
page_name = "packages"
def set_status(self, to_set): def set_status(self, to_set):

View File

@@ -95,6 +95,7 @@ class RemotesPage(Adw.NavigationPage):
# It is used to determine if a new page should be made or not # It is used to determine if a new page should be made or not
# This must be set to the created object from within the class's __init__ method # This must be set to the created object from within the class's __init__ method
instance = None instance = None
page_name = "remotes"
def start_loading(self): def start_loading(self):
self.stack.set_visible_child(self.loading_remotes) self.stack.set_visible_child(self.loading_remotes)

View File

@@ -46,6 +46,8 @@ class SnapshotPage(Adw.BreakpointBin):
# It is used to determine if a new page should be made or not # It is used to determine if a new page should be made or not
# This must be set to the created object from within the class's __init__ method # This must be set to the created object from within the class's __init__ method
instance = None instance = None
page_name = "snapshots"
snapshots_path = f"{HostInfo.home}/.var/app/io.github.flattool.Warehouse/data/Snapshots/" snapshots_path = f"{HostInfo.home}/.var/app/io.github.flattool.Warehouse/data/Snapshots/"
def sort_snapshots(self, *args): def sort_snapshots(self, *args):

View File

@@ -38,6 +38,7 @@ class UserDataPage(Adw.BreakpointBin):
# It is used to determine if a new page should be made or not # It is used to determine if a new page should be made or not
# This must be set to the created object from within the class's __init__ method # This must be set to the created object from within the class's __init__ method
instance = None instance = None
page_name = "user-data"
def sort_data(self, *args): def sort_data(self, *args):
self.data_flatpaks.clear() self.data_flatpaks.clear()