[nautilus-actions] na_updater_are_preferences_locked(): New function
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] na_updater_are_preferences_locked(): New function
- Date: Thu, 3 Feb 2011 00:51:25 +0000 (UTC)
commit 5169e5736a3a071be8808b7c3737cfd4eeea8782
Author: Pierre Wieser <pwieser trychlos org>
Date: Wed Feb 2 21:09:59 2011 +0100
na_updater_are_preferences_locked(): New function
ChangeLog | 3 +++
src/core/na-updater.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
src/core/na-updater.h | 1 +
3 files changed, 48 insertions(+), 1 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b4cf3cb..3d8a00b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2011-02-02 Pierre Wieser <pwieser trychlos org>
+ * src/core/na-updater.c:
+ * src/core/na-updater.h (na_updater_are_preferences_locked): New function.
+
Homogeneize marshalling
* src/core/na-marshal: Renamed as src/core/na-marshal.def
diff --git a/src/core/na-updater.c b/src/core/na-updater.c
index a86d1fc..686e831 100644
--- a/src/core/na-updater.c
+++ b/src/core/na-updater.c
@@ -50,6 +50,7 @@ struct _NAUpdaterClassPrivate {
*/
struct _NAUpdaterPrivate {
gboolean dispose_has_run;
+ gboolean are_preferences_locked;
gboolean is_level_zero_writable;
};
@@ -61,6 +62,7 @@ static void instance_init( GTypeInstance *instance, gpointer klass );
static void instance_dispose( GObject *object );
static void instance_finalize( GObject *object );
+static gboolean are_preferences_locked( const NAUpdater *updater );
static gboolean is_level_zero_writable( const NAUpdater *updater );
static void set_writability_status( NAObjectItem *item, const NAUpdater *updater );
@@ -194,12 +196,37 @@ na_updater_new( void )
updater = g_object_new( NA_UPDATER_TYPE, NULL );
+ updater->private->are_preferences_locked = are_preferences_locked( updater );
updater->private->is_level_zero_writable = is_level_zero_writable( updater );
return( updater );
}
/*
+ * na_updater_are_preferences_locked:
+ * @updater: the #NAUpdater application object.
+ *
+ * Returns: %TRUE if preferences have been globally locked down by an
+ * admin, %FALSE else.
+ */
+gboolean
+na_updater_are_preferences_locked( const NAUpdater *updater )
+{
+ gboolean are_locked;
+
+ g_return_val_if_fail( NA_IS_UPDATER( updater ), TRUE );
+
+ are_locked = TRUE;
+
+ if( !updater->private->dispose_has_run ){
+
+ are_locked = updater->private->are_preferences_locked;
+ }
+
+ return( are_locked );
+}
+
+/*
* na_updater_is_item_writable:
* @updater: this #NAUpdater object.
* @item: the #NAObjectItem to be written.
@@ -282,6 +309,9 @@ na_updater_is_item_writable( const NAUpdater *updater, const NAObjectItem *item,
* @updater: the #NAUpdater application object.
*
* As of 3.1.0, level-zero order is written as a user preference.
+ * This function so considers if the level_zero is a mandatory
+ * preference, and to be writable, if preferences are globally
+ * locked.
*
* This function only considers the case of the level zero itself.
* It does not take into account whether the i/o provider (if any)
@@ -301,13 +331,26 @@ na_updater_is_level_zero_writable( const NAUpdater *updater )
if( !updater->private->dispose_has_run ){
- is_writable = updater->private->is_level_zero_writable;
+ is_writable =
+ updater->private->is_level_zero_writable && !updater->private->are_preferences_locked;
}
return( is_writable );
}
static gboolean
+are_preferences_locked( const NAUpdater *updater )
+{
+ gboolean are_locked;
+ NASettings *settings;
+
+ settings = na_pivot_get_settings( NA_PIVOT( updater ));
+ are_locked = na_settings_get_boolean( settings, NA_IPREFS_ADMIN_PREFERENCES_LOCKED, NULL, NULL );
+
+ return( are_locked );
+}
+
+static gboolean
is_level_zero_writable( const NAUpdater *updater )
{
GSList *level_zero;
diff --git a/src/core/na-updater.h b/src/core/na-updater.h
index 0c1bb44..795b143 100644
--- a/src/core/na-updater.h
+++ b/src/core/na-updater.h
@@ -74,6 +74,7 @@ NAUpdater *na_updater_new( void );
/* writability status
*/
+gboolean na_updater_are_preferences_locked( const NAUpdater *updater );
gboolean na_updater_is_item_writable ( const NAUpdater *updater, const NAObjectItem *item, guint *reason );
gboolean na_updater_is_level_zero_writable( const NAUpdater *updater );
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]