[nautilus-actions] Manage locked and mandatory preferences in schemes and i/o providers lists



commit fbecf394be9ac255da80a6d782bdd31f250585c6
Author: Pierre Wieser <pwieser trychlos org>
Date:   Wed Jan 19 00:43:14 2011 +0100

    Manage locked and mandatory preferences in schemes and i/o providers lists

 src/nact/nact-preferences-editor.c |    4 ++--
 src/nact/nact-providers-list.c     |   19 +++++++++++--------
 src/nact/nact-providers-list.h     |    4 ++--
 src/nact/nact-schemes-list.c       |    6 ++++++
 4 files changed, 21 insertions(+), 12 deletions(-)
---
diff --git a/src/nact/nact-preferences-editor.c b/src/nact/nact-preferences-editor.c
index 226dfe1..79646e7 100644
--- a/src/nact/nact-preferences-editor.c
+++ b/src/nact/nact-preferences-editor.c
@@ -370,7 +370,7 @@ on_base_initial_load_dialog( NactPreferencesEditor *editor, gpointer user_data )
 	nact_schemes_list_create_model( listview, SCHEMES_LIST_FOR_PREFERENCES );
 
 	listview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( editor ), "ProvidersTreeView" ));
-	nact_providers_list_create_model( listview );
+	nact_providers_list_create_model( BASE_WINDOW( editor ), listview );
 }
 
 static void
@@ -424,7 +424,7 @@ on_base_runtime_init_dialog( NactPreferencesEditor *editor, gpointer user_data )
 	/* sixth tab: I/O providers priorities
 	 */
 	listview = GTK_TREE_VIEW( base_window_get_widget( BASE_WINDOW( editor ), "ProvidersTreeView" ));
-	nact_providers_list_init_view( listview, BASE_WINDOW( editor ));
+	nact_providers_list_init_view( BASE_WINDOW( editor ), listview );
 
 	/* dialog buttons
 	 */
diff --git a/src/nact/nact-providers-list.c b/src/nact/nact-providers-list.c
index ea22373..d2f21f2 100644
--- a/src/nact/nact-providers-list.c
+++ b/src/nact/nact-providers-list.c
@@ -83,7 +83,7 @@ static void       on_up_clicked( GtkButton *button, BaseWindow *window );
 static void       on_down_clicked( GtkButton *button, BaseWindow *window );
 
 static gboolean   are_preferences_locked( BaseWindow *window );
-static void       display_label( GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, GtkTreeView *treeview );
+static void       display_label( GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, BaseWindow *window );
 static GtkButton *get_up_button( BaseWindow *window );
 static GtkButton *get_down_button( BaseWindow *window );
 
@@ -95,7 +95,7 @@ static GtkButton *get_down_button( BaseWindow *window );
  * the UI manager.
  */
 void
-nact_providers_list_create_model( GtkTreeView *treeview )
+nact_providers_list_create_model( BaseWindow *window, GtkTreeView *treeview )
 {
 	static const char *thisfn = "nact_providers_list_create_model";
 	GtkListStore *model;
@@ -147,7 +147,7 @@ nact_providers_list_create_model( GtkTreeView *treeview )
 			text_cell,
 			"text", PROVIDER_LIBELLE_COLUMN,
 			NULL );
-	gtk_tree_view_column_set_cell_data_func( column, text_cell, ( GtkTreeCellDataFunc ) display_label, treeview, NULL );
+	gtk_tree_view_column_set_cell_data_func( column, text_cell, ( GtkTreeCellDataFunc ) display_label, window, NULL );
 	gtk_tree_view_append_column( treeview, column );
 
 	/* id */
@@ -168,14 +168,14 @@ nact_providers_list_create_model( GtkTreeView *treeview )
 
 /**
  * nact_providers_list_init_view:
- * @treeview: the #GtkTreeView.
  * @window: the parent #BaseWindow which embeds the view.
+ * @treeview: the #GtkTreeView.
  *
  * Connects signals at runtime initialization of the widget, and setup
  * current default values.
  */
 void
-nact_providers_list_init_view( GtkTreeView *treeview, BaseWindow *window )
+nact_providers_list_init_view( BaseWindow *window, GtkTreeView *treeview )
 {
 	static const gchar *thisfn = "nact_providers_list_init_view";
 
@@ -606,7 +606,7 @@ are_preferences_locked( BaseWindow *window )
  * unavailable provider: italic grey
  */
 static void
-display_label( GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, GtkTreeView *treeview )
+display_label( GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, BaseWindow *window )
 {
 	NAIOProvider *provider;
 	gchar *name;
@@ -617,15 +617,18 @@ display_label( GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *m
 	g_object_set( cell, "foreground-set", FALSE, NULL );
 
 	if( !na_io_provider_is_available( provider )){
-
 		g_object_set( cell, "style", PANGO_STYLE_ITALIC, "style-set", TRUE, NULL );
 		g_object_set( cell, "foreground", "grey", "foreground-set", TRUE, NULL );
-
 	}
 
 	g_object_unref( provider );
 
 	g_object_set( cell, "text", name, NULL );
+
+	if( are_preferences_locked( window )){
+		g_object_set( cell, "foreground", "grey", "foreground-set", TRUE, NULL );
+	}
+
 	g_free( name );
 }
 
diff --git a/src/nact/nact-providers-list.h b/src/nact/nact-providers-list.h
index b2d0615..342e83d 100644
--- a/src/nact/nact-providers-list.h
+++ b/src/nact/nact-providers-list.h
@@ -37,8 +37,8 @@
 
 G_BEGIN_DECLS
 
-void    nact_providers_list_create_model( GtkTreeView *treeview );
-void    nact_providers_list_init_view( GtkTreeView *treeview, BaseWindow *window );
+void    nact_providers_list_create_model( BaseWindow *window, GtkTreeView *treeview );
+void    nact_providers_list_init_view( BaseWindow *window, GtkTreeView *treeview );
 void    nact_providers_list_save( BaseWindow *window );
 void    nact_providers_list_dispose( BaseWindow *window );
 
diff --git a/src/nact/nact-schemes-list.c b/src/nact/nact-schemes-list.c
index 8bd4d04..e7966a3 100644
--- a/src/nact/nact-schemes-list.c
+++ b/src/nact/nact-schemes-list.c
@@ -779,6 +779,7 @@ static void
 display_label( GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, SchemesListData *data, guint column_id )
 {
 	gboolean used;
+	gboolean are_locked;
 
 	gtk_tree_model_get( model, iter, SCHEMES_ALREADY_USED_COLUMN, &used, -1 );
 	g_object_set( cell, "style-set", FALSE, NULL );
@@ -786,6 +787,11 @@ display_label( GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *m
 	if( used ){
 		g_object_set( cell, "style", PANGO_STYLE_ITALIC, "style-set", TRUE, NULL );
 	}
+
+	are_locked = are_preferences_locked( data->window );
+	if( are_locked ){
+		g_object_set( cell, "foreground", "Grey", "foreground-set", TRUE, NULL );
+	}
 }
 
 static gboolean



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