Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace bottle view entry with bottle row #3628

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 button_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
96 changes: 23 additions & 73 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()
button_run = 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,48 +60,28 @@ 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:
self.runner_type = "proton"

# 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)
self.button_run.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"""
self.button_run.set_tooltip_text(_(f"Run executable in “{self.config.Name}”"))

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

Expand All @@ -118,7 +90,7 @@ def set_path(_dialog, response):
return

self.window.show_toast(
_('Launching "{0}" in "{1}"…').format(
_("Launching {0} in {1}”…").format(
dialog.get_file().get_basename(), self.config.Name
)
)
Expand Down Expand Up @@ -183,12 +155,12 @@ def __init__(self, window, arg_bottle=None, **kwargs):

# backend signals
SignalManager.connect(
Signals.ManagerLocalBottlesLoaded, self.backend_local_bottle_loaded
Signals.ManagerLocalBottlesLoaded, self.update_bottles_list
)

self.bottle_status.set_icon_name(f"{APP_ID}-symbolic")
self.bottle_status.set_icon_name(APP_ID)

self.update_bottles()
self.update_bottles_list()

def __search_bottles(self, widget, event=None, data=None):
"""
Expand All @@ -202,11 +174,9 @@ 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):
def update_bottles_list(self, *args) -> None:
self.__bottles = {}
while self.list_bottles.get_first_child():
self.list_bottles.remove(self.list_bottles.get_first_child())
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 All @@ -239,26 +206,9 @@ def idle_update_bottles(self, show=False):
self.group_steam.set_visible(True)
self.group_bottles.set_title(_("Your Bottles"))

if (
self.arg_bottle is not None and self.arg_bottle in local_bottles.keys()
) or (show is not None and show in local_bottles.keys()):
_config = None
if self.arg_bottle:
_config = local_bottles[self.arg_bottle]
if show:
_config = local_bottles[show]
if not _config:
raise NotImplementedError("neither 'arg_bottle' nor 'show' are set")

self.window.page_details.view_preferences.update_combo_components()
self.window.show_details_view(config=_config)
self.arg_bottle = None

def backend_local_bottle_loaded(self, _: Result):
self.update_bottles()

def update_bottles(self, show=False):
GLib.idle_add(self.idle_update_bottles, show)
def show_page(self, page: str) -> None:
if config := self.window.manager.local_bottles.get(page):
self.window.show_details_view(config=config)

def disable_bottle(self, config):
self.__bottles[config.Path].disable()
3 changes: 2 additions & 1 deletion bottles/frontend/views/new.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ def send_notification(notification: Gio.Notification) -> None:
# Ask the manager to check for new bottles,
# then update the user bottles' list.
self.manager.check_bottles()
self.window.page_list.update_bottles(show=result.data.get("config").get("Path"))
self.window.page_list.update_bottles_list()
self.window.page_list.show_page(self.new_bottle_config.get("Path"))

def __radio_get_active(self) -> str:
# TODO: Remove this ugly zig zag and find a better way to set the environment
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
Loading