[anjuta] git: Only show the selection checkboxes in the Branches pane when needed



commit 47e556fd9781553ea5edbf5ea97cf69fd6f993b6
Author: James Liggett <jrliggett cox net>
Date:   Sun Jan 22 01:36:49 2012 -0800

    git: Only show the selection checkboxes in the Branches pane when needed
    
    Delete branches is the only command that uses those checkboxes, and having them
    visible all the time created confusion about how they are supposed to be used
    (see bgo #641079).
    
    The checkboxes are now shown only after the user clicks the Delete Branches
    button on the command bar. They disappear again once the Delete Branches
    dialog pane is dismissed, with any selections cleared.

 plugins/git/anjuta-git.ui              |    1 +
 plugins/git/git-branches-pane.c        |   38 ++++++++++++++++++++++++++++++++
 plugins/git/git-branches-pane.h        |    2 +
 plugins/git/git-delete-branches-pane.c |   29 +++++++++++++++++++++++-
 plugins/git/plugin.c                   |    4 +-
 5 files changed, 71 insertions(+), 3 deletions(-)
---
diff --git a/plugins/git/anjuta-git.ui b/plugins/git/anjuta-git.ui
index 70e6385..5de2b7b 100644
--- a/plugins/git/anjuta-git.ui
+++ b/plugins/git/anjuta-git.ui
@@ -468,6 +468,7 @@
                     <child>
                       <object class="GtkTreeViewColumn" id="branch_selected_column">
                         <property name="title">column</property>
+                        <property name="visible">False</property>
                         <child>
                           <object class="GtkCellRendererToggle" id="branch_selected_renderer"/>
                           <attributes>
diff --git a/plugins/git/git-branches-pane.c b/plugins/git/git-branches-pane.c
index 450f6ff..b0a78b6 100644
--- a/plugins/git/git-branches-pane.c
+++ b/plugins/git/git-branches-pane.c
@@ -470,3 +470,41 @@ git_branches_pane_get_selected_branch (GitBranchesPane *self)
 	return selected_branch;
 }
 
+static gboolean
+clear_branch_selections (GtkTreeModel *model, GtkTreePath *path, 
+                         GtkTreeIter *iter, gpointer data)
+{
+	gtk_list_store_set (GTK_LIST_STORE (model), iter, COL_SELECTED, FALSE, -1);
+	
+	return FALSE;
+}
+
+void
+git_branches_pane_set_select_column_visible (GitBranchesPane *self,
+                                             gboolean visible)
+{
+	GtkTreeViewColumn *branch_selected_column;
+	GtkTreeModel *branches_list_model;
+
+	branch_selected_column = GTK_TREE_VIEW_COLUMN (gtk_builder_get_object (self->priv->builder,
+	                                                                       "branch_selected_column"));
+
+	gtk_tree_view_column_set_visible (branch_selected_column, visible);
+
+	/* Clear branch selections when the column becomes invisible again, because
+	 * selections have no meaning once an operation that needs these selections
+	 * has either been completed or cancelled */
+	if (!visible)
+	{
+		branches_list_model = GTK_TREE_MODEL (gtk_builder_get_object (self->priv->builder,
+		                                                              "branches_list_model"));
+
+		gtk_tree_model_foreach (branches_list_model,
+		                        (GtkTreeModelForeachFunc) clear_branch_selections,
+		                        NULL);
+
+		g_hash_table_remove_all (self->priv->selected_local_branches);
+		g_hash_table_remove_all (self->priv->selected_remote_branches);
+	}
+}
+
diff --git a/plugins/git/git-branches-pane.h b/plugins/git/git-branches-pane.h
index a9af306..fc4641f 100644
--- a/plugins/git/git-branches-pane.h
+++ b/plugins/git/git-branches-pane.h
@@ -53,6 +53,8 @@ GList *git_branches_pane_get_selected_local_branches (GitBranchesPane *self);
 GList *git_branches_pane_get_selected_remote_branches (GitBranchesPane *self);
 gsize git_branches_pane_count_selected_items (GitBranchesPane *self);
 gchar *git_branches_pane_get_selected_branch (GitBranchesPane *self);
+void git_branches_pane_set_select_column_visible (GitBranchesPane *self, 
+                                                  gboolean visible);
 
 G_END_DECLS
 
diff --git a/plugins/git/git-delete-branches-pane.c b/plugins/git/git-delete-branches-pane.c
index 8116def..079e687 100644
--- a/plugins/git/git-delete-branches-pane.c
+++ b/plugins/git/git-delete-branches-pane.c
@@ -109,6 +109,18 @@ on_ok_button_clicked (GtkButton *button, GitDeleteBranchesPane *self)
 }
 
 static void
+on_delete_branches_pane_map (GtkWidget *widget, GitBranchesPane *branches_pane)
+{
+	git_branches_pane_set_select_column_visible (branches_pane, TRUE);
+}
+
+static void
+on_delete_branches_pane_unmap (GtkWidget *widget, GitBranchesPane *branches_pane)
+{
+	git_branches_pane_set_select_column_visible (branches_pane, FALSE);
+}
+
+static void
 git_delete_branches_pane_init (GitDeleteBranchesPane *self)
 {
 	gchar *objects[] = {"delete_branches_pane",
@@ -181,7 +193,22 @@ git_delete_branches_pane_class_init (GitDeleteBranchesPaneClass *klass)
 AnjutaDockPane *
 git_delete_branches_pane_new (Git *plugin)
 {
-	return g_object_new (GIT_TYPE_DELETE_BRANCHES_PANE, "plugin", plugin, NULL);
+	GitDeleteBranchesPane *self;
+	GtkWidget *delete_branches_pane;
+	
+	self = g_object_new (GIT_TYPE_DELETE_BRANCHES_PANE, "plugin", plugin, NULL);
+	delete_branches_pane = GTK_WIDGET (gtk_builder_get_object (self->priv->builder,
+	                                                           "delete_branches_pane"));
+
+	g_signal_connect (G_OBJECT (delete_branches_pane), "map",
+	                  G_CALLBACK (on_delete_branches_pane_map),
+	                  plugin->branches_pane);
+
+	g_signal_connect (G_OBJECT (delete_branches_pane), "unmap",
+	                  G_CALLBACK (on_delete_branches_pane_unmap),
+	                  plugin->branches_pane);
+
+	return ANJUTA_DOCK_PANE (self);
 }
 
 void
diff --git a/plugins/git/plugin.c b/plugins/git/plugin.c
index 966a03d..6660ca5 100644
--- a/plugins/git/plugin.c
+++ b/plugins/git/plugin.c
@@ -78,8 +78,8 @@ AnjutaCommandBarEntry branch_entries[] =
 	{
 		ANJUTA_COMMAND_BAR_ENTRY_BUTTON,
 		"DeleteBranches",
-		N_("Delete selected branches"),
-		N_("Delete selected branches"),
+		N_("Delete branches"),
+		N_("Delete branches"),
 		GTK_STOCK_DELETE,
 		G_CALLBACK (on_delete_branches_button_clicked)
 	},



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