Skip to content

Commit

Permalink
Merge pull request #3101 from koplo199/32bits-dependencies
Browse files Browse the repository at this point in the history
Allow dependencies to be installed in 32 bits bottle
  • Loading branch information
mirkobrombin authored Nov 30, 2023
2 parents 3c89288 + d123087 commit 065c66a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 25 deletions.
4 changes: 4 additions & 0 deletions bottles/backend/managers/dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ def install(self, config: BottleConfig, dependency: list) -> Result:
Here we execute all steps in the manifest.
Steps are the actions performed to install the dependency.
"""
arch = step.get("for", "win64_win32")
if config.Arch not in arch:
continue

res = self.__perform_steps(config, step)
if not res.ok:
TaskManager.remove(task_id)
Expand Down
18 changes: 7 additions & 11 deletions bottles/frontend/views/bottle_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
from bottles.frontend.widgets.dependency import DependencyEntry


@Gtk.Template(resource_path='/com/usebottles/bottles/details-dependencies.ui')
@Gtk.Template(resource_path="/com/usebottles/bottles/details-dependencies.ui")
class DependenciesView(Adw.Bin):
__gtype_name__ = 'DetailsDependencies'
__gtype_name__ = "DetailsDependencies"
__registry = []

# region Widgets
Expand Down Expand Up @@ -63,7 +63,7 @@ def __init__(self, details, config: BottleConfig, **kwargs):
self.btn_report.connect("clicked", open_doc_url, "contribute/missing-dependencies")
self.btn_help.connect("clicked", open_doc_url, "bottles/dependencies")

if self.manager.utils_conn.status == False:
if not self.manager.utils_conn.status:
self.stack.set_visible_child_name("page_offline")

self.spinner_loading.start()
Expand All @@ -89,7 +89,7 @@ def empty_list(self):
r.get_parent().remove(r)
self.__registry = []

def update(self, widget=False, config: Optional[BottleConfig] = None):
def update(self, _widget=False, config: Optional[BottleConfig] = None):
"""
This function update the dependencies list with the
supported by the manager.
Expand All @@ -99,7 +99,7 @@ def update(self, widget=False, config: Optional[BottleConfig] = None):
self.config = config

# Not sure if it's the best place to make this check
if self.manager.utils_conn.status == False:
if not self.manager.utils_conn.status:
return

self.stack.set_visible_child_name("page_loading")
Expand All @@ -115,7 +115,7 @@ def new_dependency(dependency, plain=False):
self.list_dependencies.append(entry)

@GtkUtils.run_in_main_loop
def callback(result, error=False):
def callback(_result, _error=False):
self.stack.set_visible_child_name("page_deps")

def process_dependencies():
Expand All @@ -128,11 +128,7 @@ def process_dependencies():
if len(dependencies.keys()) > 0:
for dep in dependencies.items():
if dep[0] in self.config.Installed_Dependencies:
continue # Do not list already installed dependencies'

if dep[1].get("Arch", "win64") != self.config.Arch:
# NOTE: avoid listing dependencies not supported by the bottle arch
continue
continue # Do not list already installed dependencies

GLib.idle_add(new_dependency, dep)

Expand Down
36 changes: 22 additions & 14 deletions bottles/frontend/widgets/dependency.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
from bottles.frontend.windows.generic import SourceDialog


@Gtk.Template(resource_path='/com/usebottles/bottles/dependency-entry.ui')
@Gtk.Template(resource_path="/com/usebottles/bottles/dependency-entry.ui")
class DependencyEntry(Adw.ActionRow):
__gtype_name__ = 'DependencyEntry'
__gtype_name__ = "DependencyEntry"

# region Widgets
label_category = Gtk.Template.Child()
Expand All @@ -56,17 +56,24 @@ def __init__(self, window, config: BottleConfig, dependency, plain=False, **kwar
self.queue = window.page_details.queue

if plain:
'''
"""
If the dependency is plain, treat it as a placeholder, it
can be used to display "fake" elements on the list
'''
"""
self.set_title(dependency)
self.set_subtitle("")
self.btn_install.set_visible(False)
self.btn_remove.set_visible(False)
self.btn_reinstall.set_visible(True)
return

if self.config.Arch not in dependency[1].get("Arch", "win64_win32"):
self.btn_install.set_visible(False)
self.btn_remove.set_visible(False)
self.btn_reinstall.set_visible(False)
self.btn_err.set_visible(True)
self.btn_err.set_tooltip_text(_("This dependency is not compatible with this bottle architecture."))

# populate widgets
self.set_title(dependency[0])
self.set_subtitle(dependency[1].get("Description"))
Expand All @@ -80,24 +87,24 @@ def __init__(self, window, config: BottleConfig, dependency, plain=False, **kwar
self.btn_license.connect("clicked", self.open_license)

if dependency[0] in self.config.Installed_Dependencies:
'''
"""
If the dependency is installed, hide the btn_install
button and show the btn_remove button
'''
"""
self.btn_install.set_visible(False)
self.btn_remove.set_visible(True)
self.btn_reinstall.set_visible(True)

if dependency[0] in self.config.Uninstallers.keys():
'''
"""
If the dependency has no uninstaller, disable the
btn_remove button
'''
"""
uninstaller = self.config.Uninstallers[dependency[0]]
if uninstaller in [False, "NO_UNINSTALLER"]:
self.btn_remove.set_sensitive(False)

def open_manifest(self, widget):
def open_manifest(self, _widget):
"""
This function pop up a dialog with the manifest
of the dependency
Expand All @@ -111,7 +118,7 @@ def open_manifest(self, widget):
)
).present()

def open_license(self, widget):
def open_license(self, _widget):
"""
This function pop up a dialog with the license
of the dependency
Expand All @@ -121,7 +128,7 @@ def open_license(self, widget):
)
webbrowser.open(manifest["License_url"])

def install_dependency(self, widget):
def install_dependency(self, _widget):
"""
This function install the dependency in the bottle, it
will also prevent user from installing other dependencies
Expand All @@ -142,12 +149,12 @@ def install_dependency(self, widget):
dependency=self.dependency,
)

def remove_dependency(self, widget):
def remove_dependency(self, _widget):
"""
This function remove the dependency from the bottle
configuration
"""
widget.set_sensitive(False)
_widget.set_sensitive(False)
RunAsync(
task_func=self.manager.remove_dependency,
callback=self.set_install_status,
Expand All @@ -172,7 +179,8 @@ def set_install_status(self, result: Result, error=None):
self.window.show_toast(_("\"{0}\" uninstalled").format(self.dependency[0]))
else:
self.window.show_toast(_("\"{0}\" installed").format(self.dependency[0]))
return self.set_installed(uninstaller, removed)
self.set_installed(uninstaller, removed)
return
self.set_err()

def set_err(self):
Expand Down

0 comments on commit 065c66a

Please sign in to comment.