[gnome-color-manager] Allow the user to double click a profile to make it default



commit 3f87def563c344d6cae203a7710b901fd2c8b410
Author: Richard Hughes <richard hughsie com>
Date:   Sat May 29 14:29:25 2010 +0100

    Allow the user to double click a profile to make it default

 src/gcm-prefs.c |   65 +++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 49 insertions(+), 16 deletions(-)
---
diff --git a/src/gcm-prefs.c b/src/gcm-prefs.c
index daece76..95c17f0 100644
--- a/src/gcm-prefs.c
+++ b/src/gcm-prefs.c
@@ -1223,23 +1223,13 @@ out:
 }
 
 /**
- * gcm_prefs_assign_make_default_cb:
+ * gcm_prefs_assign_make_default_internal:
  **/
 static void
-gcm_prefs_assign_make_default_cb (GtkWidget *widget, gpointer data)
+gcm_prefs_assign_make_default_internal (GtkTreeModel *model, GtkTreeIter *iter_selected)
 {
 	GtkTreeIter iter;
-	GtkTreeIter iter_selected;
-	GtkTreeModel *model;
-	GtkTreeSelection *selection;
-
-	/* get the selected row */
-	widget = GTK_WIDGET (gtk_builder_get_object (builder, "treeview_assign"));
-	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
-	if (!gtk_tree_selection_get_selected (selection, &model, &iter_selected)) {
-		egg_debug ("no row selected");
-		goto out;
-	}
+	GtkWidget *widget;
 
 	/* make none of the devices default */
 	gtk_tree_model_get_iter_first (model, &iter);
@@ -1251,7 +1241,7 @@ gcm_prefs_assign_make_default_cb (GtkWidget *widget, gpointer data)
 	} while (gtk_tree_model_iter_next (model, &iter));
 
 	/* make the selected device default */
-	gtk_list_store_set (list_store_assign, &iter_selected,
+	gtk_list_store_set (list_store_assign, iter_selected,
 			    GCM_ASSIGN_COLUMN_IS_DEFAULT, TRUE,
 			    GCM_ASSIGN_COLUMN_SORT, "0",
 			    -1);
@@ -1262,8 +1252,28 @@ gcm_prefs_assign_make_default_cb (GtkWidget *widget, gpointer data)
 
 	/* save device */
 	gcm_prefs_assign_save_profiles_for_device (current_device);
-out:
-	return;
+}
+
+/**
+ * gcm_prefs_assign_make_default_cb:
+ **/
+static void
+gcm_prefs_assign_make_default_cb (GtkWidget *widget, gpointer data)
+{
+	GtkTreeIter iter;
+	GtkTreeModel *model;
+	GtkTreeSelection *selection;
+
+	/* get the selected row */
+	widget = GTK_WIDGET (gtk_builder_get_object (builder, "treeview_assign"));
+	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
+	if (!gtk_tree_selection_get_selected (selection, &model, &iter)) {
+		egg_debug ("no row selected");
+		return;
+	}
+
+	/* make this profile the default */
+	gcm_prefs_assign_make_default_internal (model, &iter);
 }
 
 /**
@@ -1916,6 +1926,27 @@ gcm_prefs_profile_colorspace_to_string (GcmColorspace colorspace)
 }
 
 /**
+ * gcm_prefs_assign_treeview_row_activated_cb:
+ **/
+static void
+gcm_prefs_assign_treeview_row_activated_cb (GtkTreeView *tree_view, GtkTreePath *path,
+					    GtkTreeViewColumn *column, gpointer userdata)
+{
+	GtkTreeModel *model;
+	GtkTreeIter iter;
+	gboolean ret;
+
+	/* get the iter */
+	model = GTK_TREE_MODEL (list_store_assign);
+	ret = gtk_tree_model_get_iter (model, &iter, path);
+	if (!ret)
+		return;
+
+	/* make this profile the default */
+	gcm_prefs_assign_make_default_internal (model, &iter);
+}
+
+/**
  * gcm_prefs_assign_treeview_clicked_cb:
  **/
 static void
@@ -3193,6 +3224,8 @@ main (int argc, char **argv)
 	widget = GTK_WIDGET (gtk_builder_get_object (builder, "treeview_assign"));
 	gtk_tree_view_set_model (GTK_TREE_VIEW (widget),
 				 GTK_TREE_MODEL (list_store_assign));
+	g_signal_connect (GTK_TREE_VIEW (widget), "row-activated",
+			  G_CALLBACK (gcm_prefs_assign_treeview_row_activated_cb), NULL);
 	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
 	g_signal_connect (selection, "changed",
 			  G_CALLBACK (gcm_prefs_assign_treeview_clicked_cb), NULL);



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