Skip to content

Commit

Permalink
list: Replace BottleListEntry with BottlesBottleRow
Browse files Browse the repository at this point in the history
  • Loading branch information
TheEvilSkeleton committed Dec 23, 2024
1 parent 04a253e commit 64f02e4
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 162 deletions.
34 changes: 34 additions & 0 deletions bottles/frontend/ui/bottle-row.blp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Gtk 4.0;
using Adw 1;

template $BottlesBottleRow: Adw.ActionRow {
activatable: true;
use-markup: false;

Box {
spacing: 6;

Label label_env {
valign: center;

styles [
"tag",
"caption",
]
}
}

Button btn_run {
halign: center;
valign: center;
icon-name: "system-run-symbolic";

styles [
"flat",
]
}

Image {
icon-name: "go-next-symbolic";
}
}
2 changes: 1 addition & 1 deletion bottles/frontend/ui/bottles.gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<file preprocess="xml-stripblanks">new.ui</file>
<file preprocess="xml-stripblanks">list.ui</file>
<file preprocess="xml-stripblanks">loading.ui</file>
<file preprocess="xml-stripblanks">list-entry.ui</file>
<file preprocess="xml-stripblanks">bottle-row.ui</file>
<file preprocess="xml-stripblanks">task-entry.ui</file>
<file preprocess="xml-stripblanks">dependency-entry.ui</file>
<file preprocess="xml-stripblanks">program-entry.ui</file>
Expand Down
109 changes: 0 additions & 109 deletions bottles/frontend/ui/list-entry.blp

This file was deleted.

2 changes: 1 addition & 1 deletion bottles/frontend/ui/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ blueprints = custom_target('blueprints',
'installer-entry.blp',
'library-entry.blp',
'library.blp',
'list-entry.blp',
'bottle-row.blp',
'list.blp',
'loading.blp',
'local-resource-entry.blp',
Expand Down
5 changes: 0 additions & 5 deletions bottles/frontend/ui/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@
border-radius: 7px;
}

.list-entry {
padding: 10px;
border-bottom: 1px solid rgba(145, 145, 145, 0.1);
}

.current-state {
background-color: rgba(136, 84, 171, 0.1);
}
Expand Down
57 changes: 12 additions & 45 deletions bottles/frontend/views/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,15 @@
from bottles.frontend.params import APP_ID


@Gtk.Template(resource_path="/com/usebottles/bottles/list-entry.ui")
class BottleViewEntry(Adw.ActionRow):
__gtype_name__ = "BottleViewEntry"
@Gtk.Template(resource_path="/com/usebottles/bottles/bottle-row.ui")
class BottlesBottleRow(Adw.ActionRow):
__gtype_name__ = "BottlesBottleRow"

Adw.init()

# region Widgets
btn_run = Gtk.Template.Child()
btn_repair = Gtk.Template.Child()
btn_run_executable = Gtk.Template.Child()
details_image = Gtk.Template.Child()
label_env = Gtk.Template.Child()
label_state = Gtk.Template.Child()
icon_damaged = Gtk.Template.Child()
grid_versioning = Gtk.Template.Child()
spinner = Gtk.Template.Child()

# endregion

Expand All @@ -55,9 +48,8 @@ def __init__(self, window, config: BottleConfig, **kwargs):
self.window = window
self.manager = window.manager
self.config = config
self.label_env_context = self.label_env.get_style_context()

"""Format update date"""
# Format update date
update_date = _("N/A")
if self.config.Update_Date:
try:
Expand All @@ -68,7 +60,7 @@ def __init__(self, window, config: BottleConfig, **kwargs):
except ValueError:
update_date = _("N/A")

"""Check runner type by name"""
# Check runner type by name
if self.config.Runner.startswith("lutris"):
self.runner_type = "wine"
else:
Expand All @@ -77,39 +69,19 @@ def __init__(self, window, config: BottleConfig, **kwargs):
# connect signals
self.connect("activated", self.show_details)
self.btn_run.connect("clicked", self.run_executable)
self.btn_repair.connect("clicked", self.repair)
self.btn_run_executable.connect("clicked", self.run_executable)

# populate widgets
self.grid_versioning.set_visible(self.config.Versioning)
self.label_state.set_text(str(self.config.State))
self.set_title(self.config.Name)
if self.window.settings.get_boolean("update-date"):
self.set_subtitle(update_date)
self.label_env.set_text(_(self.config.Environment))
self.label_env_context.add_class("tag-%s" % self.config.Environment.lower())
self.label_env.add_css_class("tag-%s" % self.config.Environment.lower())

# Set tooltip text
self.btn_run.set_tooltip_text(_(f'Run executable in "{self.config.Name}"'))

"""If config is broken"""
if self.config.get("Broken"):
for w in [self.btn_repair, self.icon_damaged]:
w.set_visible(True)
w.set_sensitive(True)

self.btn_run.set_sensitive(False)
self.handler_block_by_func(self.show_details)

"""Repair bottle"""

def repair(self, widget):
self.disable()
RunAsync(task_func=self.manager.repair_bottle, config=self.config)

"""Display file dialog for executable"""

def run_executable(self, *_args):
"""Display file dialog for executable"""
if not Xdp.Portal.running_under_sandbox():
return

Expand Down Expand Up @@ -202,9 +174,7 @@ def __search_bottles(self, widget, event=None, data=None):
@staticmethod
def __filter_bottles(row, terms=None):
text = row.get_title().lower()
if terms.lower() in text:
return True
return False
return terms.lower() in text

def idle_update_bottles(self, show=False):
self.__bottles = {}
Expand All @@ -215,16 +185,13 @@ def idle_update_bottles(self, show=False):
self.list_steam.remove(self.list_steam.get_first_child())

local_bottles = self.window.manager.local_bottles
is_empty_local_bottles = len(local_bottles) == 0

if len(local_bottles) == 0:
self.pref_page.set_visible(False)
self.bottle_status.set_visible(True)
else:
self.pref_page.set_visible(True)
self.bottle_status.set_visible(False)
self.pref_page.set_visible(not is_empty_local_bottles)
self.bottle_status.set_visible(is_empty_local_bottles)

for name, config in local_bottles.items():
_entry = BottleViewEntry(self.window, config)
_entry = BottlesBottleRow(self.window, config)
self.__bottles[config.Path] = _entry

if config.Environment != "Steam":
Expand Down
2 changes: 1 addition & 1 deletion po/POTFILES
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ bottles/frontend/ui/importer.blp
bottles/frontend/ui/installer-entry.blp
bottles/frontend/ui/library-entry.blp
bottles/frontend/ui/library.blp
bottles/frontend/ui/list-entry.blp
bottles/frontend/ui/bottle-row.blp
bottles/frontend/ui/list.blp
bottles/frontend/ui/loading.blp
bottles/frontend/ui/local-resource-entry.blp
Expand Down

0 comments on commit 64f02e4

Please sign in to comment.