[gnome-software] trivial: Move some code around
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] trivial: Move some code around
- Date: Wed, 27 Jan 2016 14:35:01 +0000 (UTC)
commit a6b10ce040334695ab49bf97a7eccd4d4b8f0320
Author: Richard Hughes <richard hughsie com>
Date: Wed Jan 27 13:41:34 2016 +0000
trivial: Move some code around
No functional changes.
src/gs-application.c | 4 ++--
src/gs-offline-updates.c | 26 --------------------------
src/gs-offline-updates.h | 6 +-----
src/gs-shell-updates.c | 10 +++++-----
src/gs-shell.c | 8 ++++----
src/gs-update-monitor.c | 26 ++++++++++++++++++++++++++
src/gs-update-monitor.h | 2 ++
7 files changed, 40 insertions(+), 42 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index 157d500..98beeb5 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -117,7 +117,7 @@ download_updates_setting_changed (GSettings *settings,
const gchar *key,
GsApplication *app)
{
- if (!gs_updates_are_managed () &&
+ if (!gs_update_monitor_is_managed () &&
g_settings_get_boolean (settings, key)) {
g_debug ("Enabling update monitor");
app->update_monitor = gs_update_monitor_new (app);
@@ -143,7 +143,7 @@ gs_application_monitor_permission (GsApplication *app)
{
GPermission *permission;
- permission = gs_offline_updates_permission_get ();
+ permission = gs_update_monitor_permission_get ();
g_signal_connect (permission, "notify",
G_CALLBACK (on_permission_changed), app);
}
diff --git a/src/gs-offline-updates.c b/src/gs-offline-updates.c
index 5fbdab4..4a5dada 100644
--- a/src/gs-offline-updates.c
+++ b/src/gs-offline-updates.c
@@ -300,30 +300,4 @@ gs_offline_updates_show_error (GsShell *shell)
gtk_widget_show (dialog);
}
-GPermission *
-gs_offline_updates_permission_get (void)
-{
- static GPermission *permission;
-
- if (!permission)
- permission = polkit_permission_new_sync ("org.freedesktop.packagekit.trigger-offline-update",
- NULL, NULL, NULL);
-
- return permission;
-}
-
-gboolean
-gs_updates_are_managed (void)
-{
- GPermission *permission;
- gboolean managed;
-
- permission = gs_offline_updates_permission_get ();
- managed = !g_permission_get_allowed (permission) &&
- !g_permission_get_can_acquire (permission);
-
- return managed;
-}
-
-
/* vim: set noexpandtab: */
diff --git a/src/gs-offline-updates.h b/src/gs-offline-updates.h
index 30ec348..ff9afa5 100644
--- a/src/gs-offline-updates.h
+++ b/src/gs-offline-updates.h
@@ -28,11 +28,7 @@
G_BEGIN_DECLS
-void gs_offline_updates_show_error (GsShell *shell);
-
-GPermission *gs_offline_updates_permission_get (void);
-gboolean gs_updates_are_managed (void);
-
+void gs_offline_updates_show_error (GsShell *shell);
G_END_DECLS
diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c
index 5139185..478a714 100644
--- a/src/gs-shell-updates.c
+++ b/src/gs-shell-updates.c
@@ -27,12 +27,12 @@
#include "gs-shell.h"
#include "gs-shell-updates.h"
#include "gs-utils.h"
-#include "gs-offline-updates.h"
#include "gs-app.h"
#include "gs-app-row.h"
#include "gs-markdown.h"
#include "gs-update-dialog.h"
#include "gs-update-list.h"
+#include "gs-update-monitor.h"
#include "gs-application.h"
#include <gdesktop-enums.h>
@@ -400,7 +400,7 @@ gs_shell_updates_set_state (GsShellUpdates *self,
GsShellUpdatesState state)
{
self->state = state;
- if (gs_updates_are_managed ())
+ if (gs_update_monitor_is_managed ())
self->state = GS_SHELL_UPDATES_STATE_MANAGED;
gs_shell_updates_update_ui_state (self);
}
@@ -439,7 +439,7 @@ gs_shell_updates_get_updates_cb (GsPluginLoader *plugin_loader,
}
widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "button_updates_counter"));
- if (list != NULL && !gs_updates_are_managed ()) {
+ if (list != NULL && !gs_update_monitor_is_managed ()) {
g_autofree gchar *text = NULL;
text = g_strdup_printf ("%d", g_list_length (list));
gtk_label_set_label (GTK_LABEL (widget), text);
@@ -867,7 +867,7 @@ on_permission_changed (GPermission *permission,
{
GsShellUpdates *self = data;
- if (gs_updates_are_managed()) {
+ if (gs_update_monitor_is_managed()) {
gs_shell_updates_set_state (self, GS_SHELL_UPDATES_STATE_MANAGED);
}
else if (self->state == GS_SHELL_UPDATES_STATE_MANAGED) {
@@ -880,7 +880,7 @@ gs_shell_updates_monitor_permission (GsShellUpdates *self)
{
GPermission *permission;
- permission = gs_offline_updates_permission_get ();
+ permission = gs_update_monitor_permission_get ();
g_signal_connect (permission, "notify",
G_CALLBACK (on_permission_changed), self);
}
diff --git a/src/gs-shell.c b/src/gs-shell.c
index c1dff9e..c2ae9f2 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -36,7 +36,7 @@
#include "gs-shell-extras.h"
#include "gs-sources-dialog.h"
#include "gs-update-dialog.h"
-#include "gs-offline-updates.h"
+#include "gs-update-monitor.h"
static const gchar *page_name[] = {
"overview",
@@ -172,7 +172,7 @@ gs_shell_change_mode (GsShell *shell,
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_updates"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), mode == GS_SHELL_MODE_UPDATES);
- gtk_widget_set_visible (widget, !gs_updates_are_managed() || mode == GS_SHELL_MODE_UPDATES);
+ gtk_widget_set_visible (widget, !gs_update_monitor_is_managed() || mode == GS_SHELL_MODE_UPDATES);
priv->ignore_primary_buttons = FALSE;
@@ -547,7 +547,7 @@ on_permission_changed (GPermission *permission,
GtkWidget *widget;
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "button_updates"));
- gtk_widget_set_visible (widget, !gs_updates_are_managed() || priv->mode == GS_SHELL_MODE_UPDATES);
+ gtk_widget_set_visible (widget, !gs_update_monitor_is_managed() || priv->mode ==
GS_SHELL_MODE_UPDATES);
}
static void
@@ -555,7 +555,7 @@ gs_shell_monitor_permission (GsShell *shell)
{
GPermission *permission;
- permission = gs_offline_updates_permission_get ();
+ permission = gs_update_monitor_permission_get ();
g_signal_connect (permission, "notify",
G_CALLBACK (on_permission_changed), shell);
}
diff --git a/src/gs-update-monitor.c b/src/gs-update-monitor.c
index a99ed21..8f8b311 100644
--- a/src/gs-update-monitor.c
+++ b/src/gs-update-monitor.c
@@ -24,6 +24,7 @@
#include <string.h>
#include <glib/gi18n.h>
+#include <polkit/polkit.h>
#include <gsettings-desktop-schemas/gdesktop-enums.h>
#include "gs-update-monitor.h"
@@ -565,4 +566,29 @@ gs_update_monitor_new (GsApplication *application)
return monitor;
}
+GPermission *
+gs_update_monitor_permission_get (void)
+{
+ static GPermission *permission;
+
+ if (!permission)
+ permission = polkit_permission_new_sync ("org.freedesktop.packagekit.trigger-offline-update",
+ NULL, NULL, NULL);
+
+ return permission;
+}
+
+gboolean
+gs_update_monitor_is_managed (void)
+{
+ GPermission *permission;
+ gboolean managed;
+
+ permission = gs_update_monitor_permission_get ();
+ managed = !g_permission_get_allowed (permission) &&
+ !g_permission_get_can_acquire (permission);
+
+ return managed;
+}
+
/* vim: set noexpandtab: */
diff --git a/src/gs-update-monitor.h b/src/gs-update-monitor.h
index ab03213..bc9ce8a 100644
--- a/src/gs-update-monitor.h
+++ b/src/gs-update-monitor.h
@@ -32,6 +32,8 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GsUpdateMonitor, gs_update_monitor, GS, UPDATE_MONITOR, GObject)
GsUpdateMonitor *gs_update_monitor_new (GsApplication *app);
+GPermission *gs_update_monitor_permission_get (void);
+gboolean gs_update_monitor_is_managed (void);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]