[gnome-software] Use gsettings to enable/disable the 'sources' action
- From: Joaquim Manuel Pereira Rocha <jrocha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Use gsettings to enable/disable the 'sources' action
- Date: Thu, 31 Mar 2016 15:11:32 +0000 (UTC)
commit 043f89e94bc08b088b979eaf75b40e2f30e21d7e
Author: Joaquim Rocha <jrocha endlessm com>
Date: Thu Mar 31 14:47:11 2016 +0200
Use gsettings to enable/disable the 'sources' action
This is useful for vendors who prefer not to have the software sources
dialog enabled by default.
data/org.gnome.software.gschema.xml | 4 ++++
src/gs-application.c | 34 +++++++++++++++++++++++++++++++++-
2 files changed, 37 insertions(+), 1 deletions(-)
---
diff --git a/data/org.gnome.software.gschema.xml b/data/org.gnome.software.gschema.xml
index 6b6e8eb..ac6a0c6 100644
--- a/data/org.gnome.software.gschema.xml
+++ b/data/org.gnome.software.gschema.xml
@@ -62,5 +62,9 @@
<default>true</default>
<summary>Show the folder management UI</summary>
</key>
+ <key name="enable-software-sources" type="b">
+ <default>true</default>
+ <summary>Allow access to the Software Sources dialog</summary>
+ </key>
</schema>
</schemalist>
diff --git a/src/gs-application.c b/src/gs-application.c
index bffb138..098f6d2 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -46,6 +46,7 @@
#include "gs-folders.h"
#include "gs-utils.h"
+#define ENABLE_SOFTWARE_SOURCES_CONF_KEY "enable-software-sources"
struct _GsApplication {
GtkApplication parent;
@@ -656,8 +657,32 @@ static GActionEntry actions[] = {
};
static void
+gs_application_update_software_sources_presence (GApplication *self)
+{
+ GSimpleAction *action;
+ gboolean enable_sources;
+
+ action = G_SIMPLE_ACTION (g_action_map_lookup_action (G_ACTION_MAP (self),
+ "sources"));
+ enable_sources = g_settings_get_boolean (GS_APPLICATION (self)->settings,
+ ENABLE_SOFTWARE_SOURCES_CONF_KEY);
+ g_simple_action_set_enabled (action, enable_sources);
+}
+
+static void
+gs_application_settings_changed_cb (GApplication *self,
+ const gchar *key,
+ gpointer data)
+{
+ if (g_strcmp0 (key, ENABLE_SOFTWARE_SOURCES_CONF_KEY) == 0) {
+ gs_application_update_software_sources_presence (self);
+ }
+}
+
+static void
gs_application_startup (GApplication *application)
{
+ GSettings *settings;
G_APPLICATION_CLASS (gs_application_parent_class)->startup (application);
g_action_map_add_action_entries (G_ACTION_MAP (application),
@@ -667,11 +692,18 @@ gs_application_startup (GApplication *application)
#ifdef HAVE_PACKAGEKIT
GS_APPLICATION (application)->dbus_helper = gs_dbus_helper_new ();
#endif
- GS_APPLICATION (application)->settings = g_settings_new ("org.gnome.software");
+ settings = g_settings_new ("org.gnome.software");
+ GS_APPLICATION (application)->settings = settings;
+ g_signal_connect_swapped (settings, "changed",
+ G_CALLBACK (gs_application_settings_changed_cb),
+ application);
+
gs_application_monitor_permission (GS_APPLICATION (application));
gs_application_monitor_updates (GS_APPLICATION (application));
gs_application_monitor_network (GS_APPLICATION (application));
gs_folders_convert ();
+
+ gs_application_update_software_sources_presence (application);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]