Commit bc9d4607 authored by Carlos Garcia Campos's avatar Carlos Garcia Campos

[shell] Migrate lockdown to gsettings

parent 4a54bbd9
......@@ -284,6 +284,13 @@ fi
AM_CONDITIONAL([ENABLE_DBUS], [test "$enable_dbus" = "yes"])
dnl ========= Check for Desktop Schemas
PKG_CHECK_MODULES([DESKTOP_SCHEMAS], [gsettings-desktop-schemas],
has_desktop_schemas=yes, has_desktop_schemas=no)
if test x$has_desktop_schemas = xyes; then
AC_DEFINE([HAVE_DESKTOP_SCHEMAS], [1], [Whether GSettings Desktop Schemas are available])
fi
dnl ========= Check for GConf
AC_MSG_CHECKING([whether GConf support is requested])
......@@ -347,8 +354,8 @@ BACKEND_LIBS="$BACKEND_LIBS -lm"
AC_SUBST(BACKEND_CFLAGS)
AC_SUBST(BACKEND_LIBS)
SHELL_CFLAGS="$SHELL_CORE_CFLAGS $KEYRING_CFLAGS $GCONF_CFLAGS -DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE $DEBUG_FLAGS"
SHELL_LIBS="$SHELL_CORE_LIBS $KEYRING_LIBS $GCONF_LIBS -lz -lm"
SHELL_CFLAGS="$SHELL_CORE_CFLAGS $KEYRING_CFLAGS -DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE $DEBUG_FLAGS"
SHELL_LIBS="$SHELL_CORE_LIBS $KEYRING_LIBS -lz -lm"
AC_SUBST(SHELL_CFLAGS)
AC_SUBST(SHELL_LIBS)
......
......@@ -41,10 +41,6 @@
#include <gio/gio.h>
#include <gtk/gtk.h>
#ifdef WITH_GCONF
#include <gconf/gconf-client.h>
#endif
#include "egg-editable-toolbar.h"
#include "egg-toolbar-editor.h"
#include "egg-toolbars-model.h"
......@@ -147,6 +143,7 @@ struct _EvWindowPrivate {
/* Settings */
GSettings *settings;
GSettings *last_settings;
GSettings *lockdown_settings;
/* Menubar accels */
guint menubar_accel_keyval;
......@@ -213,9 +210,7 @@ struct _EvWindowPrivate {
GtkPrintSettings *print_settings;
GtkPageSetup *print_page_setup;
gboolean close_after_print;
#ifdef WITH_GCONF
GConfClient *gconf_client;
#endif
#ifdef ENABLE_DBUS
/* DBus */
guint dbus_object_id;
......@@ -232,10 +227,10 @@ struct _EvWindowPrivate {
#define ZOOM_CONTROL_ACTION "ViewZoom"
#define NAVIGATION_ACTION "Navigation"
#define GCONF_LOCKDOWN_DIR "/desktop/gnome/lockdown"
#define GCONF_LOCKDOWN_SAVE "/desktop/gnome/lockdown/disable_save_to_disk"
#define GCONF_LOCKDOWN_PRINT "/desktop/gnome/lockdown/disable_printing"
#define GCONF_LOCKDOWN_PRINT_SETUP "/desktop/gnome/lockdown/disable_print_setup"
#define GS_LOCKDOWN_SCHEMA_NAME "org.gnome.desktop.lockdown"
#define GS_LOCKDOWN_SAVE "disable-save-to-disk"
#define GS_LOCKDOWN_PRINT "disable-printing"
#define GS_LOCKDOWN_PRINT_SETUP "disable-print-setup"
#ifdef ENABLE_DBUS
#define EV_WINDOW_DBUS_OBJECT_PATH "/org/gnome/evince/Window/%d"
......@@ -418,17 +413,15 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window)
if (has_document && !ev_print_operation_exists_for_document(document))
ok_to_print = FALSE;
#ifdef WITH_GCONF
if (has_document &&
gconf_client_get_bool (ev_window->priv->gconf_client, GCONF_LOCKDOWN_SAVE, NULL)) {
if (has_document && ev_window->priv->lockdown_settings &&
g_settings_get_boolean (ev_window->priv->lockdown_settings, GS_LOCKDOWN_SAVE)) {
ok_to_copy = FALSE;
}
if (has_document &&
gconf_client_get_bool (ev_window->priv->gconf_client, GCONF_LOCKDOWN_PRINT, NULL)) {
if (has_document && ev_window->priv->lockdown_settings &&
g_settings_get_boolean (ev_window->priv->lockdown_settings, GS_LOCKDOWN_PRINT)) {
ok_to_print = FALSE;
}
#endif
/* File menu */
ev_window_set_action_sensitive (ev_window, "FileOpenCopy", has_document);
......@@ -1233,16 +1226,13 @@ override_restrictions_changed (GSettings *settings,
ev_window_setup_action_sensitivity (ev_window);
}
#ifdef WITH_GCONF
static void
lockdown_changed (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
lockdown_changed (GSettings *lockdown,
const gchar *key,
EvWindow *ev_window)
{
ev_window_setup_action_sensitivity (ev_window);
}
#endif /* WITH_GCONF */
static gboolean
ev_window_setup_document (EvWindow *ev_window)
......@@ -1265,18 +1255,13 @@ ev_window_setup_document (EvWindow *ev_window)
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 ();
gconf_client_add_dir (ev_window->priv->gconf_client,
GCONF_LOCKDOWN_DIR,
GCONF_CLIENT_PRELOAD_ONELEVEL,
NULL);
gconf_client_notify_add (ev_window->priv->gconf_client,
GCONF_LOCKDOWN_DIR,
(GConfClientNotifyFunc)lockdown_changed,
ev_window, NULL, NULL);
#endif /* WITH_GCONF */
#ifdef HAVE_DESKTOP_SCHEMAS
ev_window->priv->lockdown_settings = g_settings_new (GS_LOCKDOWN_SCHEMA_NAME);
g_signal_connect (ev_window->priv->lockdown_settings,
"changed",
G_CALLBACK (lockdown_changed),
ev_window);
#endif
ev_window_setup_action_sensitivity (ev_window);
......@@ -3166,6 +3151,7 @@ ev_window_print_range (EvWindow *ev_window,
GtkPageSetup *print_page_setup;
gint current_page;
gint document_last_page;
gboolean embed_page_setup;
g_return_if_fail (EV_IS_WINDOW (ev_window));
g_return_if_fail (ev_window->priv->document != NULL);
......@@ -3217,13 +3203,11 @@ ev_window_print_range (EvWindow *ev_window,
ev_print_operation_set_current_page (op, current_page);
ev_print_operation_set_print_settings (op, print_settings);
ev_print_operation_set_default_page_setup (op, print_page_setup);
#ifdef WITH_GCONF
ev_print_operation_set_embed_page_setup (op, !gconf_client_get_bool (ev_window->priv->gconf_client,
GCONF_LOCKDOWN_PRINT_SETUP,
NULL));
#else
ev_print_operation_set_embed_page_setup (op, TRUE);
#endif
embed_page_setup = ev_window->priv->lockdown_settings ?
!g_settings_get_boolean (ev_window->priv->lockdown_settings,
GS_LOCKDOWN_PRINT_SETUP) :
TRUE;
ev_print_operation_set_embed_page_setup (op, embed_page_setup);
g_object_unref (print_settings);
g_object_unref (print_page_setup);
......@@ -4916,13 +4900,6 @@ ev_window_dispose (GObject *object)
priv->setup_document_idle = 0;
}
#ifdef WITH_GCONF
if (priv->gconf_client) {
g_object_unref (priv->gconf_client);
priv->gconf_client = NULL;
}
#endif
if (priv->monitor) {
g_object_unref (priv->monitor);
priv->monitor = NULL;
......@@ -4976,6 +4953,11 @@ ev_window_dispose (GObject *object)
priv->last_settings = NULL;
}
if (priv->lockdown_settings) {
g_object_unref (priv->lockdown_settings);
priv->lockdown_settings = NULL;
}
priv->recent_ui_id = 0;
if (priv->model) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment