mirror of
https://github.com/morgan9e/warehouse
synced 2026-04-14 00:04:08 +09:00
Sync current work
This commit is contained in:
@@ -13,6 +13,12 @@
|
||||
<key name="is-fullscreen" type="b">
|
||||
<default>false</default>
|
||||
</key>
|
||||
<key name="sidebar-shown" type="b">
|
||||
<default>true</default>
|
||||
</key>
|
||||
<key name="page-shown" type="s">
|
||||
<default>"packages"</default>
|
||||
</key>
|
||||
</schema>
|
||||
<schema id="io.github.flattool.Warehouse.filter" path="/io/github/flattool/Warehouse/filter/">
|
||||
<key name="show-apps" type="b">
|
||||
@@ -28,4 +34,12 @@
|
||||
<default>"all"</default>
|
||||
</key>
|
||||
</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>
|
||||
|
||||
@@ -17,6 +17,7 @@ class InstallPage(Adw.BreakpointBin):
|
||||
# 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
|
||||
instance = None
|
||||
page_name = "install"
|
||||
|
||||
current_installation = ""
|
||||
current_remote = None
|
||||
|
||||
@@ -55,13 +55,6 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
# if keyval == Gdk.KEY_Escape:
|
||||
# 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):
|
||||
for _, page in self.pages.items():
|
||||
if page.instance:
|
||||
@@ -78,6 +71,14 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
self.refresh_button.set_sensitive(False)
|
||||
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):
|
||||
idx = 0
|
||||
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:
|
||||
row.activate()
|
||||
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):
|
||||
super().__init__(**kwargs)
|
||||
@@ -104,8 +110,14 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
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)
|
||||
if page_to_show == page.page_name:
|
||||
self.activate_row(row)
|
||||
|
||||
# Apply
|
||||
self.settings.bind("window-width", self, "default-width", Gio.SettingsBindFlags.DEFAULT)
|
||||
@@ -120,12 +132,14 @@ class WarehouseWindow(Adw.ApplicationWindow):
|
||||
|
||||
# Connections
|
||||
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)
|
||||
self.refresh_button.connect("clicked", self.refresh_handler)
|
||||
|
||||
self.activate_row(self.install_row)
|
||||
self.main_split.set_show_sidebar(True)
|
||||
# self.activate_row(self.user_data_row)
|
||||
# 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()
|
||||
HostInfo.get_flatpaks(callback=self.end_loading)
|
||||
|
||||
@@ -17,7 +17,7 @@ class AppRow(Adw.ActionRow):
|
||||
self.image.add_css_class("icon-dropshadow")
|
||||
self.image.set_from_file(self.package.icon_path)
|
||||
|
||||
def gest(self, *args):
|
||||
def gesture_handler(self, *args):
|
||||
self.on_long_press(self)
|
||||
|
||||
def __init__(self, package, on_long_press=None, **kwargs):
|
||||
@@ -26,16 +26,16 @@ class AppRow(Adw.ActionRow):
|
||||
# Extra Object Creation
|
||||
self.package = package
|
||||
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()
|
||||
|
||||
# Apply
|
||||
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.idle_stuff())
|
||||
self.rclick_gesture.set_button(3)
|
||||
self.add_controller(self.rclick_gesture)
|
||||
self.add_controller(self.long_press_gesture)
|
||||
|
||||
# Connections
|
||||
self.rclick_gesture.connect("released", self.gest)
|
||||
self.long_press_gesture.connect("pressed", self.gest)
|
||||
self.rclick_gesture.connect("released", self.gesture_handler)
|
||||
self.long_press_gesture.connect("pressed", self.gesture_handler)
|
||||
@@ -42,6 +42,7 @@ class PackagesPage(Adw.BreakpointBin):
|
||||
# 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
|
||||
instance = None
|
||||
page_name = "packages"
|
||||
|
||||
def set_status(self, to_set):
|
||||
|
||||
|
||||
@@ -95,6 +95,7 @@ class RemotesPage(Adw.NavigationPage):
|
||||
# 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
|
||||
instance = None
|
||||
page_name = "remotes"
|
||||
|
||||
def start_loading(self):
|
||||
self.stack.set_visible_child(self.loading_remotes)
|
||||
|
||||
@@ -46,6 +46,8 @@ class SnapshotPage(Adw.BreakpointBin):
|
||||
# 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
|
||||
instance = None
|
||||
page_name = "snapshots"
|
||||
|
||||
snapshots_path = f"{HostInfo.home}/.var/app/io.github.flattool.Warehouse/data/Snapshots/"
|
||||
|
||||
def sort_snapshots(self, *args):
|
||||
|
||||
@@ -38,6 +38,7 @@ class UserDataPage(Adw.BreakpointBin):
|
||||
# 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
|
||||
instance = None
|
||||
page_name = "user-data"
|
||||
|
||||
def sort_data(self, *args):
|
||||
self.data_flatpaks.clear()
|
||||
|
||||
Reference in New Issue
Block a user