fix +/- button after refactor broke it, update package search code and report get_kind() in libflatpak_query
This commit is contained in:
parent
36b84d5eb8
commit
8df2f78bf0
2 changed files with 57 additions and 22 deletions
|
|
@ -50,6 +50,8 @@ import os
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
|
from enum import Enum
|
||||||
|
|
||||||
|
|
||||||
# Set up logging
|
# Set up logging
|
||||||
logging.basicConfig(level=logging.INFO)
|
logging.basicConfig(level=logging.INFO)
|
||||||
|
|
@ -106,6 +108,11 @@ class AppStreamPackage:
|
||||||
return version
|
return version
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def kind(self) -> str:
|
||||||
|
return str(self.component.get_kind())
|
||||||
|
|
||||||
|
|
||||||
def _get_icon_url(self) -> str:
|
def _get_icon_url(self) -> str:
|
||||||
"""Get the remote icon URL from the component"""
|
"""Get the remote icon URL from the component"""
|
||||||
icons = self.component.get_icons()
|
icons = self.component.get_icons()
|
||||||
|
|
@ -172,6 +179,7 @@ class AppStreamPackage:
|
||||||
return {
|
return {
|
||||||
"name": self.name,
|
"name": self.name,
|
||||||
"id": self.id,
|
"id": self.id,
|
||||||
|
"kind": self.kind,
|
||||||
"summary": self.summary,
|
"summary": self.summary,
|
||||||
"description": self.description,
|
"description": self.description,
|
||||||
"version": self.version,
|
"version": self.version,
|
||||||
|
|
@ -259,16 +267,26 @@ class AppstreamSearcher:
|
||||||
def search_flatpak_repo(self, keyword: str, repo_name: str) -> list[AppStreamPackage]:
|
def search_flatpak_repo(self, keyword: str, repo_name: str) -> list[AppStreamPackage]:
|
||||||
search_results = []
|
search_results = []
|
||||||
packages = self.remotes[repo_name]
|
packages = self.remotes[repo_name]
|
||||||
|
found = None
|
||||||
for package in packages:
|
for package in packages:
|
||||||
# Try matching exact ID first
|
# Try matching exact ID first
|
||||||
if keyword is package.id:
|
if keyword is package.id:
|
||||||
search_results.append(package)
|
found = package
|
||||||
|
break
|
||||||
|
# Next try matching exact name
|
||||||
|
elif keyword.lower() is package.name.lower():
|
||||||
|
found = package
|
||||||
|
break
|
||||||
# Try matching case insensitive ID next
|
# Try matching case insensitive ID next
|
||||||
elif keyword.lower() is package.id.lower():
|
elif keyword.lower() is package.id.lower():
|
||||||
search_results.append(package)
|
found = package
|
||||||
|
break
|
||||||
# General keyword search
|
# General keyword search
|
||||||
elif keyword.lower() in str(package).lower():
|
elif keyword.lower() in str(package).lower():
|
||||||
search_results.append(package)
|
found = package
|
||||||
|
break
|
||||||
|
if found:
|
||||||
|
search_results.append(found)
|
||||||
return search_results
|
return search_results
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -999,6 +1017,7 @@ def handle_search(args, searcher):
|
||||||
details = package.get_details()
|
details = package.get_details()
|
||||||
print(f"Name: {details['name']}")
|
print(f"Name: {details['name']}")
|
||||||
print(f"ID: {details['id']}")
|
print(f"ID: {details['id']}")
|
||||||
|
print(f"Kind: {details['kind']}")
|
||||||
print(f"Summary: {details['summary']}")
|
print(f"Summary: {details['summary']}")
|
||||||
print(f"Description: {details['description']}")
|
print(f"Description: {details['description']}")
|
||||||
print(f"Version: {details['version']}")
|
print(f"Version: {details['version']}")
|
||||||
|
|
|
||||||
54
main.py
54
main.py
|
|
@ -529,8 +529,16 @@ class MainWindow(Gtk.Window):
|
||||||
for app_id, app_data in apps_by_id.items():
|
for app_id, app_data in apps_by_id.items():
|
||||||
app = app_data['app']
|
app = app_data['app']
|
||||||
details = app.get_details()
|
details = app.get_details()
|
||||||
is_installed = details['id'] in self.installed_results
|
is_installed = False
|
||||||
is_updatable = details['id'] in self.updates_results
|
for package in self.installed_results:
|
||||||
|
if details['id'] == package.id:
|
||||||
|
is_installed = True
|
||||||
|
break
|
||||||
|
is_updatable = False
|
||||||
|
for package in self.updates_results:
|
||||||
|
if details['id'] == package.id:
|
||||||
|
is_updatable = True
|
||||||
|
break
|
||||||
|
|
||||||
# Create application container
|
# Create application container
|
||||||
app_container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
app_container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
||||||
|
|
@ -543,7 +551,7 @@ class MainWindow(Gtk.Window):
|
||||||
icon_box.set_size_request(148, -1)
|
icon_box.set_size_request(148, -1)
|
||||||
|
|
||||||
# Create and add the icon
|
# Create and add the icon
|
||||||
icon = Gtk.Image.new_from_file(f"{details['icon_path_64']}/{details['icon_filename']}")
|
icon = Gtk.Image.new_from_file(f"{details['icon_path_128']}/{details['icon_filename']}")
|
||||||
icon.set_size_request(48, 48)
|
icon.set_size_request(48, 48)
|
||||||
icon_box.pack_start(icon, True, True, 0)
|
icon_box.pack_start(icon, True, True, 0)
|
||||||
|
|
||||||
|
|
@ -596,10 +604,8 @@ class MainWindow(Gtk.Window):
|
||||||
None,
|
None,
|
||||||
condition=lambda x: True
|
condition=lambda x: True
|
||||||
)
|
)
|
||||||
if button:
|
add_rm_icon = "list-remove"
|
||||||
remove_icon = Gio.Icon.new_for_string('list-remove')
|
add_rm_style = "dark-remove-buton"
|
||||||
button.set_image(Gtk.Image.new_from_gicon(remove_icon, Gtk.IconSize.BUTTON))
|
|
||||||
button.get_style_context().add_class("dark-remove-button")
|
|
||||||
else:
|
else:
|
||||||
button = self.create_button(
|
button = self.create_button(
|
||||||
self.on_install_clicked,
|
self.on_install_clicked,
|
||||||
|
|
@ -607,10 +613,13 @@ class MainWindow(Gtk.Window):
|
||||||
None,
|
None,
|
||||||
condition=lambda x: True
|
condition=lambda x: True
|
||||||
)
|
)
|
||||||
if button:
|
add_rm_icon = "list-add"
|
||||||
install_icon = Gio.Icon.new_for_string('list-add')
|
add_rm_style = "dark-install-buton"
|
||||||
button.set_image(Gtk.Image.new_from_gicon(install_icon, Gtk.IconSize.BUTTON))
|
|
||||||
button.get_style_context().add_class("dark-install-button")
|
if button:
|
||||||
|
use_icon = Gio.Icon.new_for_string(add_rm_icon)
|
||||||
|
button.set_image(Gtk.Image.new_from_gicon(use_icon, Gtk.IconSize.BUTTON))
|
||||||
|
button.get_style_context().add_class(add_rm_style)
|
||||||
buttons_box.pack_end(button, False, False, 0)
|
buttons_box.pack_end(button, False, False, 0)
|
||||||
|
|
||||||
# Add Update button if available
|
# Add Update button if available
|
||||||
|
|
@ -939,8 +948,16 @@ class MainWindow(Gtk.Window):
|
||||||
for app_id, app_data in apps_by_id.items():
|
for app_id, app_data in apps_by_id.items():
|
||||||
app = app_data['app']
|
app = app_data['app']
|
||||||
details = app.get_details()
|
details = app.get_details()
|
||||||
is_installed = details['id'] in self.installed_results
|
is_installed = False
|
||||||
is_updatable = details['id'] in self.updates_results
|
for package in self.installed_results:
|
||||||
|
if details['id'] == package.id:
|
||||||
|
is_installed = True
|
||||||
|
break
|
||||||
|
is_updatable = False
|
||||||
|
for package in self.updates_results:
|
||||||
|
if details['id'] == package.id:
|
||||||
|
is_updatable = True
|
||||||
|
break
|
||||||
|
|
||||||
# Create application container
|
# Create application container
|
||||||
app_container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
app_container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
||||||
|
|
@ -953,7 +970,7 @@ class MainWindow(Gtk.Window):
|
||||||
icon_box.set_size_request(148, -1)
|
icon_box.set_size_request(148, -1)
|
||||||
|
|
||||||
# Create and add the icon
|
# Create and add the icon
|
||||||
icon = Gtk.Image.new_from_file(f"{details['icon_path_64']}/{details['icon_filename']}")
|
icon = Gtk.Image.new_from_file(f"{details['icon_path_128']}/{details['icon_filename']}")
|
||||||
icon.set_size_request(48, 48)
|
icon.set_size_request(48, 48)
|
||||||
icon_box.pack_start(icon, True, True, 0)
|
icon_box.pack_start(icon, True, True, 0)
|
||||||
|
|
||||||
|
|
@ -1153,9 +1170,9 @@ class MainWindow(Gtk.Window):
|
||||||
# Perform installation
|
# Perform installation
|
||||||
# Get selected values
|
# Get selected values
|
||||||
if self.system_mode is False:
|
if self.system_mode is False:
|
||||||
print(f"Installing {details['name']} for User from {selected_repo}")
|
print(f"Installing {details['name']} for User")
|
||||||
else:
|
else:
|
||||||
print(f"Installing {details['name']} for System from {selected_repo}")
|
print(f"Installing {details['name']} for System")
|
||||||
success, message = libflatpak_query.install_flatpak(app, selected_repo, self.system_mode)
|
success, message = libflatpak_query.install_flatpak(app, selected_repo, self.system_mode)
|
||||||
message_type=Gtk.MessageType.INFO
|
message_type=Gtk.MessageType.INFO
|
||||||
if not success:
|
if not success:
|
||||||
|
|
@ -1170,10 +1187,9 @@ class MainWindow(Gtk.Window):
|
||||||
text=message
|
text=message
|
||||||
)
|
)
|
||||||
self.refresh_local()
|
self.refresh_local()
|
||||||
|
self.refresh_current_page()
|
||||||
finished_dialog.run()
|
finished_dialog.run()
|
||||||
finished_dialog.destroy()
|
finished_dialog.destroy()
|
||||||
|
|
||||||
self.refresh_current_page()
|
|
||||||
dialog.destroy()
|
dialog.destroy()
|
||||||
|
|
||||||
def on_remove_clicked(self, button, app):
|
def on_remove_clicked(self, button, app):
|
||||||
|
|
@ -1224,9 +1240,9 @@ class MainWindow(Gtk.Window):
|
||||||
text=message
|
text=message
|
||||||
)
|
)
|
||||||
self.refresh_local()
|
self.refresh_local()
|
||||||
|
self.refresh_current_page()
|
||||||
finished_dialog.run()
|
finished_dialog.run()
|
||||||
finished_dialog.destroy()
|
finished_dialog.destroy()
|
||||||
self.refresh_current_page()
|
|
||||||
dialog.destroy()
|
dialog.destroy()
|
||||||
|
|
||||||
def on_update_clicked(self, button, app):
|
def on_update_clicked(self, button, app):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue