[brasero: 3/8] Display all plugins in the dialog but only non-core plugins can be modified



commit 426841b445f8f62191f2b0569088e0da15c42068
Author: Philippe Rouquier <bonfire-app wanadoo fr>
Date:   Thu Aug 6 15:05:00 2009 +0200

    Display all plugins in the dialog but only non-core plugins can be modified

 src/brasero-plugin-manager-ui.c |   44 ++++++++++++++++++++++++++++----------
 1 files changed, 32 insertions(+), 12 deletions(-)
---
diff --git a/src/brasero-plugin-manager-ui.c b/src/brasero-plugin-manager-ui.c
index a7877e5..d85ccf8 100644
--- a/src/brasero-plugin-manager-ui.c
+++ b/src/brasero-plugin-manager-ui.c
@@ -232,7 +232,7 @@ plugin_manager_ui_view_info_cell_cb (GtkTreeViewColumn *tree_column,
 
 	g_object_set (G_OBJECT (cell),
 		      "markup", text,
-		      "sensitive", brasero_plugin_get_gtype (plugin) != G_TYPE_NONE,
+		      "sensitive", brasero_plugin_get_gtype (plugin) != G_TYPE_NONE && !brasero_plugin_get_compulsory (plugin),
 		      NULL);
 
 	g_free (text);
@@ -245,12 +245,16 @@ plugin_manager_ui_view_icon_cell_cb (GtkTreeViewColumn *tree_column,
 				     GtkTreeIter       *iter,
 				     gpointer           data)
 {
+	BraseroPlugin *plugin;
 	
 	g_return_if_fail (tree_model != NULL);
 	g_return_if_fail (tree_column != NULL);
 
+	gtk_tree_model_get (tree_model, iter, PLUGIN_COLUMN, &plugin, -1);
+
 	g_object_set (G_OBJECT (cell),
 		      "visible", FALSE,
+		      "sensitive", brasero_plugin_get_gtype (plugin) != G_TYPE_NONE && !brasero_plugin_get_compulsory (plugin),
 		      NULL);
 	return;
 /*
@@ -293,7 +297,6 @@ active_toggled_cb (GtkCellRendererToggle *cell,
 	g_return_if_fail (model != NULL);
 
 	gtk_tree_model_get_iter (model, &iter, path);
-
 	if (&iter != NULL)
 		plugin_manager_ui_toggle_active (&iter, model);
 
@@ -358,14 +361,10 @@ plugin_manager_ui_populate_lists (BraseroPluginManagerUI *pm)
 	for (; plugins; plugins = plugins->next) {
 		plugin = plugins->data;
 
-		if (brasero_plugin_get_gtype (plugin) == G_TYPE_NONE
-		||  brasero_plugin_get_compulsory (plugin))
-			continue;
-
 		gtk_list_store_append (model, &iter);
 		gtk_list_store_set (model, &iter,
 				    ACTIVE_COLUMN, brasero_plugin_get_active (plugin),
-				    AVAILABLE_COLUMN, brasero_plugin_get_gtype (plugin) != G_TYPE_NONE,
+				    AVAILABLE_COLUMN, brasero_plugin_get_gtype (plugin) != G_TYPE_NONE && !brasero_plugin_get_compulsory (plugin),
 				    PLUGIN_COLUMN, plugin,
 				    -1);
 	}
@@ -408,13 +407,17 @@ plugin_manager_ui_set_active (GtkTreeIter  *iter,
 
 	g_return_val_if_fail (plugin != NULL, FALSE);
 
+	if (brasero_plugin_get_gtype (plugin) == G_TYPE_NONE
+	||  brasero_plugin_get_compulsory (plugin))
+		return FALSE;
+
 	brasero_plugin_set_active (plugin, active);
  
 	/* set new value */
 	gtk_list_store_set (GTK_LIST_STORE (model), 
 			    iter, 
 			    ACTIVE_COLUMN, brasero_plugin_get_active (plugin),
-			    AVAILABLE_COLUMN, brasero_plugin_get_gtype (plugin) != G_TYPE_NONE,
+			    AVAILABLE_COLUMN, brasero_plugin_get_gtype (plugin) != G_TYPE_NONE && !brasero_plugin_get_compulsory (plugin),
 			    -1);
 
 	/* search if this plugin appears under other categories
@@ -439,7 +442,7 @@ plugin_manager_ui_set_active (GtkTreeIter  *iter,
 			if (plugin == tmp_plugin) {
 				gtk_list_store_set (GTK_LIST_STORE (model), &child, 
 						    ACTIVE_COLUMN, active,
-						    AVAILABLE_COLUMN, brasero_plugin_get_gtype (plugin) != G_TYPE_NONE,
+						    AVAILABLE_COLUMN, brasero_plugin_get_gtype (plugin) != G_TYPE_NONE && !brasero_plugin_get_compulsory (plugin),
 						    -1);
 				break;
 			}
@@ -461,7 +464,8 @@ plugin_manager_ui_toggle_active (GtkTreeIter  *iter,
 
 	active ^= 1;
 
-	plugin_manager_ui_set_active (iter, model, active);
+	if (!plugin_manager_ui_set_active (iter, model, active))
+		return;
 }
 
 static void
@@ -600,7 +604,7 @@ create_tree_popup_menu (BraseroPluginManagerUI *pm)
 
 	item = gtk_check_menu_item_new_with_mnemonic (_("A_ctivate"));
 	gtk_widget_set_sensitive (item,
-				  brasero_plugin_get_gtype (plugin) != G_TYPE_NONE);	
+				  brasero_plugin_get_gtype (plugin) != G_TYPE_NONE && !brasero_plugin_get_compulsory (plugin));	
 	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
 					brasero_plugin_get_active (plugin));
 	g_signal_connect (item, "toggled",
@@ -795,10 +799,20 @@ model_name_sort_func (GtkTreeModel *model,
 		      gpointer      user_data)
 {
 	BraseroPlugin *plugin1, *plugin2;
+	gboolean active1, active2;
 	
 	gtk_tree_model_get (model, iter1, PLUGIN_COLUMN, &plugin1, -1);
 	gtk_tree_model_get (model, iter2, PLUGIN_COLUMN, &plugin2, -1);
 
+	active1 = brasero_plugin_get_gtype (plugin1) != G_TYPE_NONE && !brasero_plugin_get_compulsory (plugin1);
+	active2 = brasero_plugin_get_gtype (plugin2) != G_TYPE_NONE && !brasero_plugin_get_compulsory (plugin2);
+
+	if (active1 && !active2)
+		return -1;
+
+	if (active2 && !active1)
+		return 1;
+
 	/* Use the translated name for the plugins */
 	return g_utf8_collate (_(brasero_plugin_get_name (plugin1)),
 			       _(brasero_plugin_get_name (plugin2)));
@@ -835,12 +849,18 @@ plugin_manager_ui_construct_tree (BraseroPluginManagerUI *pm)
 	cell = gtk_cell_renderer_pixbuf_new ();
 	gtk_tree_view_column_pack_start (column, cell, FALSE);
 	g_object_set (cell, "stock-size", GTK_ICON_SIZE_SMALL_TOOLBAR, NULL);
+	gtk_tree_view_column_add_attribute (column,
+	                                    cell,
+	                                    "sensitive", AVAILABLE_COLUMN);
 	gtk_tree_view_column_set_cell_data_func (column, cell,
 						 plugin_manager_ui_view_icon_cell_cb,
 						 pm, NULL);
 	
 	cell = gtk_cell_renderer_text_new ();
 	gtk_tree_view_column_pack_start (column, cell, TRUE);
+	gtk_tree_view_column_add_attribute (column,
+	                                    cell,
+	                                    "sensitive", AVAILABLE_COLUMN);
 	g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
 	gtk_tree_view_column_set_cell_data_func (column, cell,
 						 plugin_manager_ui_view_info_cell_cb,
@@ -851,7 +871,6 @@ plugin_manager_ui_construct_tree (BraseroPluginManagerUI *pm)
 
 	/* Last column */
 	cell = gtk_cell_renderer_toggle_new ();
-	g_object_set (cell, "xpad", 6, NULL);
 	g_signal_connect (cell,
 			  "toggled",
 			  G_CALLBACK (active_toggled_cb),
@@ -866,6 +885,7 @@ plugin_manager_ui_construct_tree (BraseroPluginManagerUI *pm)
 	gtk_tree_view_column_set_title (column, PLUGIN_MANAGER_UI_ACTIVE_TITLE);
 	gtk_tree_view_column_set_expand (column, FALSE);
 	gtk_tree_view_append_column (GTK_TREE_VIEW (priv->tree), column);
+	g_object_set (cell, "xpad", 6, NULL);
 
 	/* Sort on the plugin names */
 	gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (model),



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