[gnome-control-center] printers: Honor "disable-print-setup" setting



commit bb577444b309741afb4029825112dec5c7de4340
Author: Marek Kasik <mkasik redhat com>
Date:   Wed Mar 23 15:44:47 2011 +0100

    printers: Honor "disable-print-setup" setting
    
    Make "Unlock" button and all widgets which depend on it
    insensitive if "disable-print-setup" setting is true (#645337).

 panels/printers/cc-printers-panel.c |   36 ++++++++++++++++++++++++++++++++++-
 1 files changed, 35 insertions(+), 1 deletions(-)
---
diff --git a/panels/printers/cc-printers-panel.c b/panels/printers/cc-printers-panel.c
index 7a17c76..bc8366f 100644
--- a/panels/printers/cc-printers-panel.c
+++ b/panels/printers/cc-printers-panel.c
@@ -73,6 +73,8 @@ struct _CcPrintersPanelPrivate
 
   GPermission *permission;
 
+  GSettings *lockdown_settings;
+
   PpNewPrinterDialog *pp_new_printer_dialog;
 
   gpointer dummy;
@@ -149,6 +151,12 @@ cc_printers_panel_dispose (GObject *object)
       priv->builder = NULL;
     }
 
+  if (priv->lockdown_settings)
+    {
+      g_object_unref (priv->lockdown_settings);
+      priv->lockdown_settings = NULL;
+    }
+
   G_OBJECT_CLASS (cc_printers_panel_parent_class)->dispose (object);
 }
 
@@ -2009,7 +2017,8 @@ on_permission_changed (GPermission *permission,
 
   priv = PRINTERS_PANEL_PRIVATE (self);
 
-  is_authorized = g_permission_get_allowed (G_PERMISSION (priv->permission));
+  is_authorized = g_permission_get_allowed (G_PERMISSION (priv->permission)) &&
+    !g_settings_get_boolean (priv->lockdown_settings, "disable-print-setup");
 
   widget = (GtkWidget*) gtk_builder_get_object (priv->builder, "printer-add-button");
   gtk_widget_set_sensitive (widget, is_authorized);
@@ -2034,6 +2043,25 @@ on_permission_changed (GPermission *permission,
 }
 
 static void
+on_lockdown_settings_changed (GSettings  *settings,
+                              const char *key,
+                              gpointer    user_data)
+{
+  CcPrintersPanelPrivate  *priv;
+  CcPrintersPanel         *self = (CcPrintersPanel*) user_data;
+
+  if (g_str_equal (key, "disable-print-setup") == FALSE)
+    return;
+
+  priv = PRINTERS_PANEL_PRIVATE (self);
+
+  gtk_widget_set_sensitive (priv->lock_button,
+    !g_settings_get_boolean (priv->lockdown_settings, "disable-print-setup"));
+
+  on_permission_changed (priv->permission, NULL, user_data);
+}
+
+static void
 go_back_cb (GtkButton *button,
             gpointer   user_data)
 {
@@ -2189,6 +2217,12 @@ cc_printers_panel_init (CcPrintersPanel *self)
     gtk_builder_get_object (priv->builder, "printer-options-button");
   g_signal_connect (widget, "clicked", G_CALLBACK (switch_to_options_cb), self);
 
+  priv->lockdown_settings = g_settings_new ("org.gnome.desktop.lockdown");
+  g_signal_connect (priv->lockdown_settings,
+                    "changed",
+                    G_CALLBACK (on_lockdown_settings_changed),
+                    self);
+
 
   /* Set junctions */
   widget = (GtkWidget*)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]