[nautilus-actions] Monitor mandatory preferences
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Monitor mandatory preferences
- Date: Thu, 25 Mar 2010 00:04:45 +0000 (UTC)
commit 2ec27ab0896f157876fd35013fe696390a663851
Author: Pierre Wieser <pwieser trychlos org>
Date: Thu Mar 25 01:06:11 2010 +0100
Monitor mandatory preferences
ChangeLog | 11 +++++++++++
TODO | 3 +++
src/core/na-ipivot-consumer.c | 25 +++++++++++++++++++++++++
src/core/na-ipivot-consumer.h | 9 +++++++++
src/core/na-pivot.c | 34 ++++++++++++++++++++++++++++++++++
src/nact/nact-main-window.c | 1 +
src/plugin-menu/nautilus-actions.c | 1 +
7 files changed, 84 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1fb1fcc..0cb61b9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2009-03-24 Pierre Wieser <pwieser trychlos org>
+ * src/core/na-ipivot-consumer.c
+ (na_ipivot_consumer_notify_of_mandatory_prefs_changed) : New function.
+ (on_mandatory_prefs_changed): New interface API.
+
+ * src/core/na-pivot.c (monitor_runtime_preferences):
+ Monitor the mandatory preferences set by the admin.
+
+ * src/nact/nact-main-window.c (ipivot_consumer_iface_init):
+ * src/plugin-menu/nautilus-actions.c (ipivot_consumer_iface_init):
+ For now, only declare NULL implementations.
+
* src/nact/nact-preferences-editor.c (on_base_runtime_init_dialog):
* src/nact/nact-sort-buttons.c (nact_sort_buttons_runtime_init):
Forbid the modification of order mode is level zero is not writable.
diff --git a/TODO b/TODO
index 733def2..7ba2d94 100644
--- a/TODO
+++ b/TODO
@@ -137,3 +137,6 @@
properties/
conditions/
command/
+
+- enhancement.ui: implement on_mandatory_prefs_changed NAIPivotConsumer interface
+ to dynamically enable/disable order-mode buttons when admin changes them.
diff --git a/src/core/na-ipivot-consumer.c b/src/core/na-ipivot-consumer.c
index 241094e..761c889 100644
--- a/src/core/na-ipivot-consumer.c
+++ b/src/core/na-ipivot-consumer.c
@@ -186,6 +186,31 @@ void na_ipivot_consumer_notify_of_items_changed( NAIPivotConsumer *instance )
}
/**
+ * na_ipivot_consumer_notify_of_mandatory_prefs_changed:
+ * @instance: the #NAIPivotConsumer instance to be notified of the modifications.
+ *
+ * Notifies the consumers that a mandatory 'locked' preference has been changed.
+ */
+void na_ipivot_consumer_notify_of_mandatory_prefs_changed( NAIPivotConsumer *instance )
+{
+ static const gchar *thisfn = "na_ipivot_consumer_notify_of_mandatory_prefs_changed";
+
+ g_debug( "%s: instance=%p", thisfn, ( void * ) instance );
+
+ g_return_if_fail( NA_IS_IPIVOT_CONSUMER( instance ));
+
+ if( st_initialized && !st_finalized ){
+
+ if( is_notify_allowed( instance )){
+
+ if( NA_IPIVOT_CONSUMER_GET_INTERFACE( instance )->on_mandatory_prefs_changed ){
+ NA_IPIVOT_CONSUMER_GET_INTERFACE( instance )->on_mandatory_prefs_changed( instance );
+ }
+ }
+ }
+}
+
+/**
* na_ipivot_consumer_notify_of_create_root_menu_changed:
* @instance: the #NAIPivotConsumer instance to be notified of the end
* of the modifications.
diff --git a/src/core/na-ipivot-consumer.h b/src/core/na-ipivot-consumer.h
index 4b0cb3d..be5216e 100644
--- a/src/core/na-ipivot-consumer.h
+++ b/src/core/na-ipivot-consumer.h
@@ -103,6 +103,14 @@ typedef struct {
* is changed.
*/
void ( *on_display_order_changed ) ( NAIPivotConsumer *instance, gint order_mode );
+
+ /**
+ * on_mandatory_prefs_changed:
+ * @instance: the #NAIPivotConsumer instance which implements this interface.
+ *
+ * This function is triggered each time a mandatory 'locked' preference is changed.
+ */
+ void ( *on_mandatory_prefs_changed ) ( NAIPivotConsumer *instance );
}
NAIPivotConsumerInterface;
@@ -111,6 +119,7 @@ GType na_ipivot_consumer_get_type( void );
void na_ipivot_consumer_delay_notify( NAIPivotConsumer *instance );
void na_ipivot_consumer_notify_of_items_changed ( NAIPivotConsumer *instance );
+void na_ipivot_consumer_notify_of_mandatory_prefs_changed ( NAIPivotConsumer *instance );
void na_ipivot_consumer_notify_of_create_root_menu_changed( NAIPivotConsumer *instance, gboolean enabled );
void na_ipivot_consumer_notify_of_display_about_changed ( NAIPivotConsumer *instance, gboolean enabled );
void na_ipivot_consumer_notify_of_display_order_changed ( NAIPivotConsumer *instance, gint order_mode );
diff --git a/src/core/na-pivot.c b/src/core/na-pivot.c
index ad0c409..7414001 100644
--- a/src/core/na-pivot.c
+++ b/src/core/na-pivot.c
@@ -116,6 +116,7 @@ static gulong time_val_diff( const GTimeVal *recent, const GTimeVal *old
/* NAGConf runtime preferences management */
static void monitor_runtime_preferences( NAPivot *pivot );
+static void on_mandatory_prefs_changed( GConfClient *client, guint cnxn_id, GConfEntry *entry, NAPivot *pivot );
static void on_preferences_change( GConfClient *client, guint cnxn_id, GConfEntry *entry, NAPivot *pivot );
static void display_order_changed( NAPivot *pivot );
static void create_root_menu_changed( NAPivot *pivot );
@@ -874,6 +875,7 @@ monitor_runtime_preferences( NAPivot *pivot )
{
static const gchar *thisfn = "na_pivot_monitor_runtime_preferences";
GList *list = NULL;
+ gchar *path;
g_debug( "%s: pivot=%p", thisfn, ( void * ) pivot );
g_return_if_fail( NA_IS_PIVOT( pivot ));
@@ -885,10 +887,42 @@ monitor_runtime_preferences( NAPivot *pivot )
( GConfClientNotifyFunc ) on_preferences_change,
pivot ));
+ path = gconf_concat_dir_and_key( IPREFS_GCONF_BASEDIR, "mandatory" );
+ list = g_list_prepend( list,
+ na_gconf_monitor_new(
+ path,
+ ( GConfClientNotifyFunc ) on_mandatory_prefs_changed,
+ pivot ));
+ g_free( path );
+
pivot->private->monitors = list;
}
static void
+on_mandatory_prefs_changed( GConfClient *client, guint cnxn_id, GConfEntry *entry, NAPivot *pivot )
+{
+ const gchar *key;
+ gchar *key_entry;
+ GList *ic;
+
+ g_return_if_fail( NA_IS_PIVOT( pivot ));
+
+ if( !pivot->private->dispose_has_run ){
+
+ key = gconf_entry_get_key( entry );
+ key_entry = g_path_get_basename( key );
+
+ if( !strcmp( key_entry, "locked" )){
+ for( ic = pivot->private->consumers ; ic ; ic = ic->next ){
+ na_ipivot_consumer_notify_of_mandatory_prefs_changed( NA_IPIVOT_CONSUMER( ic->data ));
+ }
+ }
+
+ g_free( key_entry );
+ }
+}
+
+static void
on_preferences_change( GConfClient *client, guint cnxn_id, GConfEntry *entry, NAPivot *pivot )
{
/*static const gchar *thisfn = "na_pivot_on_preferences_change";*/
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index 05c1d7c..435fa59 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -550,6 +550,7 @@ ipivot_consumer_iface_init( NAIPivotConsumerInterface *iface )
iface->on_create_root_menu_changed = NULL;
iface->on_display_about_changed = NULL;
iface->on_display_order_changed = ipivot_consumer_on_display_order_changed;
+ iface->on_mandatory_prefs_changed = NULL;
}
static void
diff --git a/src/plugin-menu/nautilus-actions.c b/src/plugin-menu/nautilus-actions.c
index 21e5b2c..9f4fb4d 100644
--- a/src/plugin-menu/nautilus-actions.c
+++ b/src/plugin-menu/nautilus-actions.c
@@ -306,6 +306,7 @@ ipivot_consumer_iface_init( NAIPivotConsumerInterface *iface )
iface->on_create_root_menu_changed = ipivot_consumer_create_root_menu_changed;
iface->on_display_about_changed = ipivot_consumer_display_about_changed;
iface->on_display_order_changed = ipivot_consumer_display_order_changed;
+ iface->on_mandatory_prefs_changed = NULL;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]