Skip to content

Commit

Permalink
Sync current work
Browse files Browse the repository at this point in the history
  • Loading branch information
heliguy4599 committed Aug 26, 2024
1 parent bb1a374 commit 485a845
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 17 deletions.
14 changes: 14 additions & 0 deletions data/io.github.flattool.Warehouse.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand All @@ -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>
1 change: 1 addition & 0 deletions src/install_page/install_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
38 changes: 26 additions & 12 deletions src/main_window/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ def key_handler(self, controller, keyval, keycode, state):
# 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:
Expand All @@ -78,14 +71,27 @@ def refresh_handler(self, *args):
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):
idx += 1
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)
Expand All @@ -104,8 +110,14 @@ def __init__(self, **kwargs):
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)
Expand All @@ -120,12 +132,14 @@ def __init__(self, **kwargs):

# 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)
10 changes: 5 additions & 5 deletions src/packages_page/app_row.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def idle_stuff(self):
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):
Expand All @@ -26,16 +26,16 @@ def __init__(self, package, on_long_press=None, **kwargs):
# 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)
1 change: 1 addition & 0 deletions src/packages_page/packages_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
1 change: 1 addition & 0 deletions src/remotes_page/remotes_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/snapshot_page/snapshot_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions src/user_data_page/user_data_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 485a845

Please sign in to comment.