Hello community, here is the log from the commit of package package-update-indicator for openSUSE:Factory checked in at 2019-09-05 12:34:47 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/package-update-indicator (Old) and /work/SRC/openSUSE:Factory/.package-update-indicator.new.7948 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "package-update-indicator" Thu Sep 5 12:34:47 2019 rev:5 rq:728044 version:5 Changes: -------- --- /work/SRC/openSUSE:Factory/package-update-indicator/package-update-indicator.changes 2019-07-29 17:29:13.606239235 +0200 +++ /work/SRC/openSUSE:Factory/.package-update-indicator.new.7948/package-update-indicator.changes 2019-09-05 12:34:50.891567090 +0200 @@ -1,0 +2,10 @@ +Sun Sep 1 14:25:56 UTC 2019 - Stefan Seyfried <seife+...@b1-systems.com> + +- update to version 5: + * Reduce delay before checking for updates after an "updates- + changed" signal + * Fix continuos loop of update checks if the refresh cache + interval is 0 + * Add fallback icons for KDE-based themes + +------------------------------------------------------------------- Old: ---- package-update-indicator-4.tar.gz New: ---- package-update-indicator-5.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ package-update-indicator.spec ++++++ --- /var/tmp/diff_new_pack.bYIFqe/_old 2019-09-05 12:34:51.483566974 +0200 +++ /var/tmp/diff_new_pack.bYIFqe/_new 2019-09-05 12:34:51.487566973 +0200 @@ -18,7 +18,7 @@ Name: package-update-indicator -Version: 4 +Version: 5 Release: 0 Summary: Package update status notification applet License: MIT ++++++ package-update-indicator-4.tar.gz -> package-update-indicator-5.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/package-update-indicator-4/Makefile new/package-update-indicator-5/Makefile --- old/package-update-indicator-4/Makefile 2019-07-24 16:29:14.000000000 +0200 +++ new/package-update-indicator-5/Makefile 2019-08-30 13:34:56.000000000 +0200 @@ -24,7 +24,7 @@ PACKAGE = package-update-indicator APPLICATION_ID = org.guido-berhoerster.code.package-update-indicator PREFS_APPLICATION_ID = org.guido-berhoerster.code.package-update-indicator.preferences -VERSION = 4 +VERSION = 5 DISTNAME = $(PACKAGE)-$(VERSION) AUTHOR = Guido Berhoerster BUG_ADDRESS = guido+...@berhoerster.name diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/package-update-indicator-4/NEWS new/package-update-indicator-5/NEWS --- old/package-update-indicator-4/NEWS 2019-07-24 16:29:14.000000000 +0200 +++ new/package-update-indicator-5/NEWS 2019-08-30 13:34:56.000000000 +0200 @@ -1,6 +1,13 @@ News ==== +package-update-indicator 5 (2019-08-30T13:32:52+02:00) +------------------------------------------------------ + +- Reduce delay before checking for updates after an "updates-changed" signal +- Fix continuos loop of update checks if the refresh cache interval is 0 +- Add fallback icons for KDE-based themes + package-update-indicator 4 (2019-07-24T16:27:25+02:00) ------------------------------------------------------ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/package-update-indicator-4/pui-application.c new/package-update-indicator-5/pui-application.c --- old/package-update-indicator-4/pui-application.c 2019-07-24 16:29:14.000000000 +0200 +++ new/package-update-indicator-5/pui-application.c 2019-08-30 13:34:56.000000000 +0200 @@ -62,14 +62,19 @@ static GParamSpec *properties[PROP_LAST] = { NULL }; -static const gchar *icon_names[PUI_STATE_LAST] = { - [PUI_STATE_INITIAL] = "system-software-update", - [PUI_STATE_UP_TO_DATE] = "system-software-update", - [PUI_STATE_NORMAL_UPDATES_AVAILABLE] = "software-update-available", - [PUI_STATE_IMPORTANT_UPDATES_AVAILABLE] = "software-update-urgent", - [PUI_STATE_SESSION_RESTART_REQUIRED] = "system-log-out", - [PUI_STATE_SYSTEM_RESTART_REQUIRED] = "system-reboot", - [PUI_STATE_ERROR] = "dialog-warning" +static gchar *icon_names[PUI_STATE_LAST][2] = { + [PUI_STATE_INITIAL] = { "system-software-update", "update-none" }, + [PUI_STATE_UP_TO_DATE] = { "system-software-update", "update-none" }, + [PUI_STATE_NORMAL_UPDATES_AVAILABLE] = { "software-update-available", + "update-medium" }, + [PUI_STATE_IMPORTANT_UPDATES_AVAILABLE] = { "software-update-urgent", + "update-high" }, + [PUI_STATE_SESSION_RESTART_REQUIRED] = { "system-log-out", + "system-log-out" }, + [PUI_STATE_SYSTEM_RESTART_REQUIRED] = { "system-reboot", + "system-reboot" }, + [PUI_STATE_ERROR] = { "dialog-warning", + "dialog-warning" } }; static const GOptionEntry cmd_options[] = { @@ -196,6 +201,9 @@ guint normal_updates = 0; gchar *title = NULL; gchar *body = NULL; + GtkIconTheme *icon_theme; + const gchar * const *icon_namep; + const gchar *icon_name; GApplication *application = G_APPLICATION(self); GNotification *notification = NULL; @@ -301,8 +309,18 @@ APP_INDICATOR_STATUS_ACTIVE); break; } - app_indicator_set_icon_full(self->indicator, icon_names[self->state], - title); + + /* determine icon name using fallbacks if necessary */ + icon_theme = gtk_icon_theme_get_default(); + for (icon_namep = + g_themed_icon_get_names(G_THEMED_ICON(self->icons[self->state])), + icon_name = *icon_namep; *icon_namep != NULL; icon_namep++) { + if (gtk_icon_theme_has_icon(icon_theme, *icon_namep)) { + icon_name = *icon_namep; + break; + } + } + app_indicator_set_icon_full(self->indicator, icon_name, title); /* notification */ switch (self->state) { @@ -338,7 +356,7 @@ } g_debug("indicator icon: %s, notification title: \"%s\", " - "notification body: \"%s\"", icon_names[self->state], title, body); + "notification body: \"%s\"", icon_name, title, body); g_free(body); g_free(title); @@ -475,7 +493,7 @@ /* load icons */ for (i = 0; i < G_N_ELEMENTS(self->icons); i++) { - self->icons[i] = g_themed_icon_new(icon_names[i]); + self->icons[i] = g_themed_icon_new_from_names(icon_names[i], 2); } /* create settings */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/package-update-indicator-4/pui-backend.c new/package-update-indicator-5/pui-backend.c --- old/package-update-indicator-4/pui-backend.c 2019-07-24 16:29:14.000000000 +0200 +++ new/package-update-indicator-5/pui-backend.c 2019-08-30 13:34:56.000000000 +0200 @@ -36,7 +36,8 @@ #include "pui-get-updates.h" #include "pui-types.h" -#define LOW_BATTERY_THRESHOLD 10.0 +#define LOW_BATTERY_THRESHOLD 10.0 /* % */ +#define UPDATES_CHANGED_UNBLOCK_DELAY 4 /* s */ struct _PuiBackend { GObject parent_instance; @@ -56,7 +57,8 @@ PkNetworkEnum network_state; gboolean inhibited; gboolean is_battery_low; - guint periodic_check_id; + guint check_id; + guint unblock_updates_changed_id; guint refresh_interval; gboolean use_mobile_connection; guint important_updates; @@ -90,6 +92,7 @@ static GParamSpec *properties[PROP_LAST] = { NULL }; static gboolean periodic_check(gpointer); +static void on_updates_changed(PkControl *, gpointer); GQuark pui_backend_error_quark(void) @@ -120,6 +123,18 @@ } } +static gboolean +unblock_updates_changed(gpointer user_data) +{ + PuiBackend *self = user_data; + + g_signal_handlers_unblock_by_func(self->pk_control, on_updates_changed, + self); + self->unblock_updates_changed_id = 0; + + return (G_SOURCE_REMOVE); +} + static void on_get_updates_finished(GObject *source_object, GAsyncResult *async_result, gpointer user_data) @@ -172,16 +187,55 @@ /* reschedule periodic check */ if (!self->inhibited) { - self->periodic_check_id = + self->check_id = g_timeout_add_seconds(PUI_CHECK_UPDATES_INTERVAL, periodic_check, self); } + /* handle get-updates signals again after a short delay */ + self->unblock_updates_changed_id = + g_timeout_add_seconds(UPDATES_CHANGED_UNBLOCK_DELAY, + unblock_updates_changed, self); + if (package_list != NULL) { g_ptr_array_unref(package_list); } } +static void +run_check(PuiBackend *self, gboolean refresh_cache) +{ + /* block any get-updates signals emitted when refreshing the cache */ + if (self->unblock_updates_changed_id != 0) { + /* still blocked */ + g_source_remove(self->unblock_updates_changed_id); + self->unblock_updates_changed_id = 0; + } else { + g_signal_handlers_block_by_func(self->pk_control, + G_CALLBACK(on_updates_changed), self); + } + + self->cancellable = g_cancellable_new(); + pui_get_updates_async(self->pk_control, + refresh_cache ? self->refresh_interval : G_MAXUINT, + self->cancellable, on_get_updates_finished, self); + + /* next periodic check will be scheduled after completion */ + self->check_id = 0; +} + +static gboolean +irregular_check(gpointer user_data) +{ + PuiBackend *self = user_data; + + g_debug("running check"); + + run_check(self, FALSE); + + return (G_SOURCE_REMOVE); +} + static gboolean periodic_check(gpointer user_data) { @@ -189,12 +243,7 @@ g_debug("running periodic check"); - self->cancellable = g_cancellable_new(); - pui_get_updates_async(self->pk_control, self->refresh_interval, - self->cancellable, on_get_updates_finished, self); - - /* next periodic check will be scheduled after completion */ - self->periodic_check_id = 0; + run_check(self, TRUE); return (G_SOURCE_REMOVE); } @@ -217,8 +266,8 @@ self->inhibited = inhibited; if (inhibited) { /* cancel periodic checks */ - if (self->periodic_check_id != 0) { - g_source_remove(self->periodic_check_id); + if (self->check_id != 0) { + g_source_remove(self->check_id); } /* cancel running operation */ @@ -239,7 +288,7 @@ remaining_time = (elapsed_time < PUI_CHECK_UPDATES_INTERVAL) ? PUI_CHECK_UPDATES_INTERVAL - elapsed_time : PUI_STARTUP_DELAY; - self->periodic_check_id = g_timeout_add_seconds(remaining_time, + self->check_id = g_timeout_add_seconds(remaining_time, periodic_check, self); } } @@ -301,9 +350,14 @@ { PuiBackend *self = PUI_BACKEND(object); - if (self->periodic_check_id != 0) { - g_source_remove(self->periodic_check_id); - self->periodic_check_id = 0; + if (self->check_id != 0) { + g_source_remove(self->check_id); + self->check_id = 0; + } + + if (self->unblock_updates_changed_id != 0) { + g_source_remove(self->unblock_updates_changed_id); + self->unblock_updates_changed_id = 0; } if (self->transaction_list != NULL) { @@ -493,19 +547,19 @@ { PuiBackend *self = user_data; - g_debug("number of updates changed"); + g_debug("package metatdata cache invalidated"); /* * schedule a check after a short delay so that a rapid succession of * signals is coalesced */ if (!self->inhibited) { - if (self->periodic_check_id != 0) { - g_source_remove(self->periodic_check_id); + if (self->check_id != 0) { + g_source_remove(self->check_id); } - self->periodic_check_id = - g_timeout_add_seconds(PUI_STARTUP_DELAY, periodic_check, - self); + self->check_id = + g_timeout_add_seconds(PUI_UPDATES_CHANGED_DELAY, + irregular_check, self); } } @@ -639,7 +693,7 @@ /* get notification when the network state changes */ g_signal_connect(self->pk_control, "notify::network-state", G_CALLBACK(on_notify_network_state), self); - /* get notifications when the available package updates change */ + /* get notifications when the package metatdata cache is invalidated */ g_signal_connect(self->pk_control, "updates-changed", G_CALLBACK(on_updates_changed), self); /* get notifications when an application restart is required */ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/package-update-indicator-4/pui-common.h new/package-update-indicator-5/pui-common.h --- old/package-update-indicator-4/pui-common.h 2019-07-24 16:29:14.000000000 +0200 +++ new/package-update-indicator-5/pui-common.h 2019-08-30 13:34:56.000000000 +0200 @@ -30,6 +30,10 @@ #define PUI_STARTUP_DELAY (3 * 60) #endif /* !PUI_STARTUP_DELAY */ +#ifndef PUI_UPDATES_CHANGED_DELAY +#define PUI_UPDATES_CHANGED_DELAY (30) +#endif /* !PUI_UPDATES_CHANGED_DELAY */ + #ifndef PUI_CHECK_UPDATES_INTERVAL #define PUI_CHECK_UPDATES_INTERVAL (60 * 60) #endif /* !PUI_CHECK_UPDATES_INTERVAL */