[evince] [shell] Port override_restrictions gconf key to GSettings
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] [shell] Port override_restrictions gconf key to GSettings
- Date: Mon, 3 May 2010 12:40:11 +0000 (UTC)
commit b329a61d561198cd405721372580d05476c2240a
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Mon May 3 14:37:30 2010 +0200
[shell] Port override_restrictions gconf key to GSettings
configure.ac | 7 +++-
data/Makefile.am | 56 +++++++++-------------------------
data/evince.schemas.in | 15 ---------
data/org.gnome.Evince.gschema.xml.in | 9 +++++
shell/ev-window.c | 45 +++++++++++++++++++--------
shell/main.c | 5 +++
6 files changed, 65 insertions(+), 72 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 8f18357..3621326 100644
--- a/configure.ac
+++ b/configure.ac
@@ -85,6 +85,8 @@ m4_pattern_allow([AM_V_GEN])dnl Make autoconf not complain about the rule below
EV_INTLTOOL_EVINCE_BACKEND_RULE='%.evince-backend: %.evince-backend.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) ; $(AM_V_GEN) LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< [$]@'
AC_SUBST([EV_INTLTOOL_EVINCE_BACKEND_RULE])
+GLIB_GSETTINGS
+
# Check which platform to use
AC_MSG_CHECKING([for which platform to build])
@@ -122,8 +124,9 @@ AM_CONDITIONAL([PLATFORM_WIN32],[test "$with_platform" = "win32"])
dnl Specify required versions of dependencies
DBUS_GLIB_REQUIRED=0.70
GTK_REQUIRED=2.20.0
-GLIB_REQUIRED=2.18.0
+GLIB_REQUIRED=2.25.3
KEYRING_REQUIRED=2.22.0
+GCONF_REQUIRED=2.31.2
AC_SUBST([GLIB_REQUIRED])
AC_SUBST([GTK_REQUIRED])
@@ -312,7 +315,7 @@ AC_MSG_RESULT([$with_gconf])
AM_CONDITIONAL([WITH_GCONF],[test "$with_gconf" = "yes"])
if test "$with_gconf" = "yes"; then
- PKG_CHECK_MODULES([GCONF],[gconf-2.0])
+ PKG_CHECK_MODULES([GCONF],[gconf-2.0 >= $GCONF_REQUIRED])
AC_DEFINE([WITH_GCONF],[1],[Define if GConf support is enabled])
AM_GCONF_SOURCE_2
diff --git a/data/Makefile.am b/data/Makefile.am
index 7966025..feb5230 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,8 +1,7 @@
SUBDIRS = icons
NULL=
-install-data-local: install-schemas update-icon-cache
-uninstall-local: uninstall-schemas
+install-data-local: update-icon-cache
#
# man file
@@ -49,45 +48,20 @@ $(service_DATA): $(service_in_files) Makefile
endif
#
-# GConf schema
+# GSettings schema
#
-if WITH_GCONF
- INTLTOOL_SCHEMAS_RULE@
-
-schema_in_files = evince.schemas.in
-schemadir = $(GCONF_SCHEMA_FILE_DIR)
-schema_DATA = $(schema_in_files:.schemas.in=.schemas)
-
-install-schemas: $(schema_DATA)
-if GCONF_SCHEMAS_INSTALL
- if test -z "$(DESTDIR)" ; then \
- for p in $^ ; do \
- GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) \
- $(GCONFTOOL) \
- --makefile-install-rule \
- $(top_builddir)/data/$$p; \
- done \
- fi
-endif
-
-uninstall-schemas: $(schema_DATA)
-if GCONF_SCHEMAS_INSTALL
- if test -z "$(DESTDIR)" ; then \
- for p in $^ ; do \
- GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) \
- $(GCONFTOOL) \
- --makefile-uninstall-rule \
- $(top_builddir)/data/$$p; \
- done \
- fi
-endif
-
-else
-
-install-schemas:
-uninstall-schemas:
-
+# gsettingsschemadir and gschema_compile are defined by the GLIB_GSETTINGS
+# macro in configure.ac
+gsettingsschema_in_files = org.gnome.Evince.gschema.xml.in
+gsettingsschema_DATA = $(gsettingsschema_in_files:.xml.in=.xml)
+ INTLTOOL_XML_NOMERGE_RULE@
+# This rule will check your schemas for validity before installation
+# Uncomment when porting is done
+# GSETTINGS_CHECK_RULE
+if GSETTINGS_SCHEMAS_INSTALL
+install-data-hook:
+ $(AM_V_GEN) $(GLIB_COMPILE_SCHEMAS) --allow-any-name $(DESTDIR)$(gsettingsschemadir) --targetdir=$(DESTDIR)$(gsettingsschemadir)
endif
#
@@ -116,7 +90,7 @@ update-icon-cache:
EXTRA_DIST = \
$(ui_DATA) \
$(DESKTOP_IN_FILES) \
- $(schema_in_files) \
+ $(gsettingsschema_in_files) \
org.gnome.evince.Daemon.service.in \
$(man_MANS) \
evince.ico \
@@ -128,7 +102,7 @@ EXTRA_DIST = \
DISTCLEANFILES = \
$(DESKTOP_FILES) \
- $(schema_DATA) \
+ $(gsettingsschema_DATA) \
$(service_DATA)
-include $(top_srcdir)/git.mk
diff --git a/data/org.gnome.Evince.gschema.xml.in b/data/org.gnome.Evince.gschema.xml.in
new file mode 100644
index 0000000..dfccd85
--- /dev/null
+++ b/data/org.gnome.Evince.gschema.xml.in
@@ -0,0 +1,9 @@
+<schemalist>
+ <schema id="org.gnome.Evince" path="/apps/evince/" gettext-domain="evince">
+ <key name="override_restrictions" type="b">
+ <default>true</default>
+ <summary>Override document restrictions</summary>
+ <description>Override document restrictions, like restriction to copy or to print.</description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/shell/ev-window.c b/shell/ev-window.c
index dab2c5a..8c5d95f 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -140,6 +140,9 @@ struct _EvWindowPrivate {
GtkWidget *sidebar_attachments;
GtkWidget *sidebar_layers;
+ /* Settings */
+ GSettings *settings;
+
/* Menubar accels */
guint menubar_accel_keyval;
GdkModifierType menubar_accel_modifier;
@@ -224,6 +227,9 @@ struct _EvWindowPrivate {
#define GCONF_LOCKDOWN_PRINT "/desktop/gnome/lockdown/disable_printing"
#define GCONF_LOCKDOWN_PRINT_SETUP "/desktop/gnome/lockdown/disable_print_setup"
+#define GS_SCHEMA_NAME "org.gnome.Evince"
+#define GS_OVERRIDE_RESTRICTIONS "override_restrictions"
+
#define SIDEBAR_DEFAULT_SIZE 132
#define LINKS_SIDEBAR_ID "links"
#define THUMBNAILS_SIDEBAR_ID "thumbnails"
@@ -377,12 +383,12 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window)
can_find = TRUE;
}
-#ifdef WITH_GCONF
- if (has_document)
- override_restrictions = gconf_client_get_bool (ev_window->priv->gconf_client,
- GCONF_OVERRIDE_RESTRICTIONS,
- NULL);
-#endif
+ if (has_document && ev_window->priv->settings) {
+ override_restrictions =
+ g_settings_get_boolean (ev_window->priv->settings,
+ GS_OVERRIDE_RESTRICTIONS);
+ }
+
if (!override_restrictions && info && info->fields_mask & EV_DOCUMENT_INFO_PERMISSIONS) {
ok_to_print = (info->permissions & EV_DOCUMENT_PERMISSIONS_OK_TO_PRINT);
ok_to_copy = (info->permissions & EV_DOCUMENT_PERMISSIONS_OK_TO_COPY);
@@ -1190,6 +1196,14 @@ ev_window_refresh_window_thumbnail (EvWindow *ev_window)
ev_job_scheduler_push_job (ev_window->priv->thumbnail_job, EV_JOB_PRIORITY_NONE);
}
+static void
+override_restrictions_changed (GSettings *settings,
+ gchar *key,
+ EvWindow *ev_window)
+{
+ ev_window_setup_action_sensitivity (ev_window);
+}
+
#ifdef WITH_GCONF
static void
lockdown_changed (GConfClient *client,
@@ -1216,6 +1230,12 @@ ev_window_setup_document (EvWindow *ev_window)
ev_window_title_set_document (ev_window->priv->title, document);
ev_window_title_set_uri (ev_window->priv->title, ev_window->priv->uri);
+ ev_window->priv->settings = g_settings_new (GS_SCHEMA_NAME);
+ g_signal_connect (ev_window->priv->settings,
+ "changed::"GS_OVERRIDE_RESTRICTIONS,
+ G_CALLBACK (override_restrictions_changed),
+ ev_window);
+
#ifdef WITH_GCONF
if (!ev_window->priv->gconf_client)
ev_window->priv->gconf_client = gconf_client_get_default ();
@@ -1223,18 +1243,10 @@ ev_window_setup_document (EvWindow *ev_window)
GCONF_LOCKDOWN_DIR,
GCONF_CLIENT_PRELOAD_ONELEVEL,
NULL);
- gconf_client_add_dir (ev_window->priv->gconf_client,
- GCONF_OVERRIDE_RESTRICTIONS,
- GCONF_CLIENT_PRELOAD_NONE,
- NULL);
gconf_client_notify_add (ev_window->priv->gconf_client,
GCONF_LOCKDOWN_DIR,
(GConfClientNotifyFunc)lockdown_changed,
ev_window, NULL, NULL);
- gconf_client_notify_add (ev_window->priv->gconf_client,
- GCONF_OVERRIDE_RESTRICTIONS,
- (GConfClientNotifyFunc)lockdown_changed,
- ev_window, NULL, NULL);
#endif /* WITH_GCONF */
ev_window_setup_action_sensitivity (ev_window);
@@ -4840,6 +4852,11 @@ ev_window_dispose (GObject *object)
priv->recent_manager = NULL;
}
+ if (priv->settings) {
+ g_object_unref (priv->settings);
+ priv->settings = NULL;
+ }
+
priv->recent_ui_id = 0;
if (priv->model) {
diff --git a/shell/main.c b/shell/main.c
index dfe6a20..d7d6e15 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -216,6 +216,11 @@ main (int argc, char *argv[])
GOptionContext *context;
GError *error = NULL;
+#ifdef WITH_GCONF
+ /* Remove when porting is done */
+ g_setenv ("GSETTINGS_BACKEND", "gconf", FALSE);
+#endif
+
#ifdef G_OS_WIN32
if (fileno (stdout) != -1 &&
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]