aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AptUrl/gtk/GtkUI.py51
-rw-r--r--AptUrl/gtk/aptdaemon.py126
-rw-r--r--debian/changelog6
-rw-r--r--debian/control4
-rwxr-xr-xsetup.py2
5 files changed, 159 insertions, 30 deletions
diff --git a/AptUrl/gtk/GtkUI.py b/AptUrl/gtk/GtkUI.py
index dcc905f..9174a32 100644
--- a/AptUrl/gtk/GtkUI.py
+++ b/AptUrl/gtk/GtkUI.py
@@ -1,30 +1,27 @@
+from .aptdaemon import APT
+from AptUrl.Helpers import _
+from AptUrl import Helpers
+from AptUrl.UI import AbstractUI
+import tempfile
+import subprocess
+import apt_pkg
+import sys
+import os
+from gi.repository import GObject
+from gi.repository import Gdk
+from gi.repository import Gtk
import gi
gi.require_version('Gtk', '3.0')
-gi.require_version('XApp', '1.0')
-from gi.repository import Gtk
-from gi.repository import Gdk
-from gi.repository import GObject
-from gi.repository import XApp
-GObject.threads_init()
-import os
-import sys
-import apt_pkg
-import subprocess
-import tempfile
-
-from AptUrl.UI import AbstractUI
-from AptUrl import Helpers
-from AptUrl.Helpers import _
+GObject.threads_init()
-import mintcommon.aptdaemon
APTURL_UI_FILE = os.environ.get(
# Set this envar to use a test .ui file.
'APTURL_UI_FILE',
# System file to use if the envar is not set.
'/usr/share/apturl/apturl-gtk.ui'
- )
+)
class GtkUI(AbstractUI):
@@ -51,7 +48,7 @@ class GtkUI(AbstractUI):
buttons=buttons)
d.set_title("")
d.set_markup("<big><b>%s</b></big>\n\n%s" % (summary, msg))
- XApp.set_window_icon_name(d, "package-x-generic")
+ d.set_icon_name("package-x-generic")
d.set_keep_above(True)
d.realize()
d.get_window().set_functions(Gdk.WMFunction.MOVE)
@@ -96,7 +93,7 @@ class GtkUI(AbstractUI):
desc = "%s\n\n%s" % (summary, Helpers.format_description(description))
tbuf.set_text(desc)
description_text_view.set_buffer(tbuf)
- XApp.set_window_icon_name(dia, "package-x-generic")
+ dia.set_icon_name("package-x-generic")
# check if another package manager is already running
# FIXME: just checking for the existance of the file is
@@ -104,14 +101,14 @@ class GtkUI(AbstractUI):
# be locked via apt_pkg.get_lock()
# - but that needs to run as root
# - a dbus helper might be the best answer here
- #args = (update_button_status, dia_xml.get_object("yes_button"),
+ # args = (update_button_status, dia_xml.get_object("yes_button"),
# dia_xml.get_object("infolabel"))
- #args[0](*args[1:])
- #timer_id = GObject.timeout_add(750, *args )
+ # args[0](*args[1:])
+ # timer_id = GObject.timeout_add(750, *args )
# show the dialog
res = dia.run()
- #GObject.source_remove(timer_id)
+ # GObject.source_remove(timer_id)
if res != Gtk.ResponseType.YES:
dia.hide()
return False
@@ -130,11 +127,12 @@ class GtkUI(AbstractUI):
self.install_packages(packages)
def install_packages(self, package_names):
- self.apt = mintcommon.aptdaemon.APT(None)
+ self.apt = APT(None)
self.package_names = package_names
self.busy = True
if self.require_update:
- self.apt.set_finished_callback(self.on_update_before_install_finished)
+ self.apt.set_finished_callback(
+ self.on_update_before_install_finished)
self.apt.update_cache()
else:
self.on_update_before_install_finished()
@@ -153,6 +151,7 @@ class GtkUI(AbstractUI):
self.busy = False
self.dia.exit()
+
if __name__ == "__main__":
ui = GtkUI()
- ui.error("foo","bar")
+ ui.error("foo", "bar")
diff --git a/AptUrl/gtk/aptdaemon.py b/AptUrl/gtk/aptdaemon.py
new file mode 100644
index 0000000..31e4b1f
--- /dev/null
+++ b/AptUrl/gtk/aptdaemon.py
@@ -0,0 +1,126 @@
+from aptdaemon.gtk3widgets import AptErrorDialog, AptProgressDialog, AptConfirmDialog
+import aptdaemon.errors
+import aptdaemon.enums
+import aptdaemon.client
+from gi.repository import Gtk
+__version__ = "1.0.0"
+
+import gi
+gi.require_version('Gtk', '3.0')
+gi.require_version('GdkX11', '3.0') # Needed to get xid
+
+
+class APT(object):
+
+ def __init__(self, parent_window=None):
+ self.parent_window = parent_window
+ self.progress_callback = None
+ self.finished_callback = None
+ self.error_callback = None
+ self.cancelled_callback = None
+
+ def set_progress_callback(self, progress_callback):
+ self.progress_callback = progress_callback
+
+ def set_finished_callback(self, finished_callback):
+ self.finished_callback = finished_callback
+
+ def set_error_callback(self, error_callback):
+ self.error_callback = error_callback
+
+ def set_cancelled_callback(self, cancelled_callback):
+ self.cancelled_callback = cancelled_callback
+
+ def update_cache(self):
+ aptdaemon_client = aptdaemon.client.AptClient()
+ update_transaction = aptdaemon_client.update_cache()
+ self._run_transaction(update_transaction)
+
+ def install_file(self, path):
+ aptdaemon_client = aptdaemon.client.AptClient()
+ aptdaemon_client.install_file(
+ path, force=True, wait=False, reply_handler=self._simulate_trans, error_handler=self._on_error)
+
+ def install_packages(self, packages):
+ aptdaemon_client = aptdaemon.client.AptClient()
+ aptdaemon_client.install_packages(
+ packages, reply_handler=self._simulate_trans, error_handler=self._on_error)
+
+ def remove_packages(self, packages):
+ aptdaemon_client = aptdaemon.client.AptClient()
+ aptdaemon_client.remove_packages(
+ packages, reply_handler=self._simulate_trans, error_handler=self._on_error)
+
+ def _run_transaction(self, transaction):
+ if self.progress_callback is None:
+ dia = AptProgressDialog(transaction, parent=self.parent_window)
+ dia.run(close_on_finished=True, show_error=True,
+ reply_handler=lambda: True, error_handler=self._on_error)
+ transaction.connect("finished", self._on_finish)
+ else:
+ AptDaemonTransaction(transaction, self.progress_callback,
+ self.finished_callback, self.error_callback, self.parent_window)
+
+ def _simulate_trans(self, trans):
+ trans.simulate(reply_handler=lambda: self._confirm_deps(
+ trans), error_handler=self._on_error)
+
+ def _confirm_deps(self, trans):
+ try:
+ if [pkgs for pkgs in trans.dependencies if pkgs]:
+ dia = AptConfirmDialog(trans, parent=self.parent_window)
+ res = dia.run()
+ dia.hide()
+ if res != Gtk.ResponseType.OK:
+ if self.cancelled_callback is not None:
+ self.cancelled_callback()
+ return
+ self._run_transaction(trans)
+ except Exception as e:
+ print(e)
+
+ def _on_error(self, error):
+ if isinstance(error, aptdaemon.errors.NotAuthorizedError):
+ if self.cancelled_callback != None:
+ self.cancelled_callback()
+ return
+ elif not isinstance(error, aptdaemon.errors.TransactionFailed):
+ # Catch internal errors of the client
+ error = aptdaemon.errors.TransactionFailed(
+ aptdaemon.enums.ERROR_UNKNOWN, str(error))
+ dia = AptErrorDialog(error)
+ dia.run()
+ dia.hide()
+
+ def _on_finish(self, transaction, exit_state):
+ if self.finished_callback is not None:
+ self.finished_callback(transaction, exit_state)
+
+
+class AptDaemonTransaction():
+
+ def __init__(self, transaction, progress_callback, finished_callback, error_callback, parent_window):
+ self.progress_callback = progress_callback
+ self.finished_callback = finished_callback
+ self.error_callback = error_callback
+ self.transaction = transaction
+ self.parent_window = parent_window
+ transaction.set_debconf_frontend("gnome")
+ transaction.connect("progress-changed", self.on_transaction_progress)
+ # transaction.connect("cancellable-changed", self.on_driver_changes_cancellable_changed)
+ transaction.connect("finished", self.on_transaction_finish)
+ transaction.connect("error", self.on_transaction_error)
+ transaction.run()
+
+ def on_transaction_progress(self, transaction, progress):
+ if self.progress_callback is not None:
+ self.progress_callback(progress)
+
+ def on_transaction_error(self, transaction, error_code, error_details):
+ if self.error_callback is not None:
+ self.error_callback(error_code, error_details)
+
+ def on_transaction_finish(self, transaction, exit_state):
+ if (exit_state == aptdaemon.enums.EXIT_SUCCESS):
+ if self.finished_callback is not None:
+ self.finished_callback(transaction, exit_state)
diff --git a/debian/changelog b/debian/changelog
index 86a49a5..8c41113 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+apturl (0.5.2+shopno1) shopno; urgency=medium
+
+ * Prune mint deps
+
+ -- Mubashshir <ahm@jadupc.com> Thu, 03 Aug 2023 17:35:01 +0600
+
apturl (0.5.2+linuxmint13) vanessa; urgency=medium
* bump - rebuild using XZ compression
diff --git a/debian/control b/debian/control
index ceb8245..72dcda9 100644
--- a/debian/control
+++ b/debian/control
@@ -14,8 +14,7 @@ Architecture: all
Depends: ${python3:Depends},
${shlibs:Depends},
${misc:Depends},
- python3-apt,
- mint-common
+ python3-apt
Description: install packages using the apt protocol - common data
AptUrl is a simple graphical application that takes an URL (which follows the
apt-protocol) as a command line option, parses it and carries out the
@@ -33,7 +32,6 @@ Depends: ${python3:Depends},
apturl-common (= ${binary:Version}),
python3-gi,
gir1.2-gtk-3.0,
- gir1.2-xapp-1.0
Description: install packages using the apt protocol - GTK+ frontend
AptUrl is a simple graphical application that takes an URL (which follows the
apt-protocol) as a command line option, parses it and carries out the
diff --git a/setup.py b/setup.py
index 6919a6e..e92818f 100755
--- a/setup.py
+++ b/setup.py
@@ -11,7 +11,7 @@ changelog = "debian/changelog"
if os.path.exists(changelog):
with open(changelog, encoding='utf-8') as fp:
head = fp.readline()
- match = re.compile(".*\(([0-9.]+)\+linuxmint.+\).*").match(head)
+ match = re.compile(".*\(([0-9.]+)\+(linuxmint|shopno).+\).*").match(head)
if match:
version = match.group(1)
with open("AptUrl/Version.py", "w") as fp: