[anjuta] git: Support deleting remote tracking branches
- From: James Liggett <jrliggett src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [anjuta] git: Support deleting remote tracking branches
- Date: Fri, 14 Aug 2009 20:17:53 +0000 (UTC)
commit d32cb3e443cf0a13a08dc3c90da8b670d844497f
Author: James Liggett <jrliggett cox net>
Date: Fri Aug 14 13:17:22 2009 -0700
git: Support deleting remote tracking branches
plugins/git/anjuta-git.ui | 103 +++++++++++++++++++++++--------
plugins/git/git-branch-delete-command.c | 8 ++-
plugins/git/git-branch-delete-command.h | 1 +
plugins/git/git-delete-branch-dialog.c | 96 ++++++++++++++++++++++++-----
4 files changed, 167 insertions(+), 41 deletions(-)
---
diff --git a/plugins/git/anjuta-git.ui b/plugins/git/anjuta-git.ui
index 7ba31fe..ad0fcac 100644
--- a/plugins/git/anjuta-git.ui
+++ b/plugins/git/anjuta-git.ui
@@ -51,6 +51,14 @@
<column type="gchararray"/>
</columns>
</object>
+ <object class="GtkListStore" id="remote_branch_list_model">
+ <columns>
+ <!-- column-name selected -->
+ <column type="gboolean"/>
+ <!-- column-name name -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
<object class="GtkDialog" id="commit_dialog">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">5</property>
@@ -1548,43 +1556,88 @@
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow2">
+ <object class="GtkVBox" id="vbox37">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">automatic</property>
- <property name="vscrollbar_policy">automatic</property>
- <property name="shadow_type">in</property>
+ <property name="orientation">vertical</property>
<child>
- <object class="GtkTreeView" id="delete_branch_view">
- <property name="height_request">200</property>
+ <object class="GtkHBox" id="hbox8">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="model">branch_list_model</property>
- <property name="headers_visible">False</property>
- <property name="search_column">1</property>
<child>
- <object class="GtkTreeViewColumn" id="treeviewcolumn1">
- <property name="title">column</property>
- <child>
- <object class="GtkCellRendererToggle" id="delete_branch_selected_renderer"/>
- <attributes>
- <attribute name="active">0</attribute>
- </attributes>
- </child>
+ <object class="GtkRadioButton" id="delete_branch_local_toggle">
+ <property name="label" translatable="yes">Local</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">False</property>
</object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
</child>
<child>
- <object class="GtkTreeViewColumn" id="treeviewcolumn2">
- <property name="title">column</property>
+ <object class="GtkRadioButton" id="delete_branch_remote_toggle">
+ <property name="label" translatable="yes">Remote</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">False</property>
+ <property name="group">delete_branch_local_toggle</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow2">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView" id="delete_branch_view">
+ <property name="height_request">200</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="model">branch_list_model</property>
+ <property name="headers_visible">False</property>
+ <property name="headers_clickable">False</property>
+ <property name="search_column">1</property>
<child>
- <object class="GtkCellRendererText" id="delete_branch_name_renderer"/>
- <attributes>
- <attribute name="text">1</attribute>
- </attributes>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn1">
+ <property name="title">column</property>
+ <child>
+ <object class="GtkCellRendererToggle" id="delete_branch_selected_renderer"/>
+ <attributes>
+ <attribute name="active">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn2">
+ <property name="title">column</property>
+ <child>
+ <object class="GtkCellRendererText" id="delete_branch_name_renderer"/>
+ <attributes>
+ <attribute name="text">1</attribute>
+ </attributes>
+ </child>
+ </object>
</child>
</object>
</child>
</object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
</child>
diff --git a/plugins/git/git-branch-delete-command.c b/plugins/git/git-branch-delete-command.c
index 0995f69..b917c4a 100644
--- a/plugins/git/git-branch-delete-command.c
+++ b/plugins/git/git-branch-delete-command.c
@@ -27,6 +27,7 @@
struct _GitBranchDeleteCommandPriv
{
GList *branches;
+ gboolean remote;
gboolean require_merged;
};
@@ -59,6 +60,9 @@ git_branch_delete_command_run (AnjutaCommand *command)
self = GIT_BRANCH_DELETE_COMMAND (command);
git_command_add_arg (GIT_COMMAND (command), "branch");
+
+ if (self->priv->remote)
+ git_command_add_arg (GIT_COMMAND (command), "-r");
if (self->priv->require_merged)
git_command_add_arg (GIT_COMMAND (command), "-d");
@@ -85,7 +89,8 @@ git_branch_delete_command_class_init (GitBranchDeleteCommandClass *klass)
GitBranchDeleteCommand *
git_branch_delete_command_new (const gchar *working_directory,
- GList *branches,
+ GList *branches,
+ gboolean remote,
gboolean require_merged)
{
GitBranchDeleteCommand *self;
@@ -96,6 +101,7 @@ git_branch_delete_command_new (const gchar *working_directory,
NULL);
self->priv->branches = git_command_copy_string_list (branches);
+ self->priv->remote = remote;
self->priv->require_merged = require_merged;
return self;
diff --git a/plugins/git/git-branch-delete-command.h b/plugins/git/git-branch-delete-command.h
index 2489583..86220bd 100644
--- a/plugins/git/git-branch-delete-command.h
+++ b/plugins/git/git-branch-delete-command.h
@@ -56,6 +56,7 @@ struct _GitBranchDeleteCommand
GType git_branch_delete_command_get_type (void) G_GNUC_CONST;
GitBranchDeleteCommand *git_branch_delete_command_new (const gchar *working_directory,
GList *branches,
+ gboolean remote,
gboolean require_merged);
G_END_DECLS
diff --git a/plugins/git/git-delete-branch-dialog.c b/plugins/git/git-delete-branch-dialog.c
index 23c6a1c..4392dfc 100644
--- a/plugins/git/git-delete-branch-dialog.c
+++ b/plugins/git/git-delete-branch-dialog.c
@@ -73,28 +73,31 @@ static void
on_delete_branch_dialog_response (GtkDialog *dialog, gint response_id,
GitUIData *data)
{
+ GtkWidget *delete_branch_remote_toggle;
GtkWidget *delete_branch_view;
GtkWidget *require_merged_check;
- GtkTreeModel *branch_list_model;
+ GtkTreeModel *model;
GList *selected_branches;
GitBranchDeleteCommand *delete_command;
if (response_id == GTK_RESPONSE_OK)
{
+ delete_branch_remote_toggle = GTK_WIDGET (gtk_builder_get_object (data->bxml,
+ "delete_branch_remote_toggle"));
delete_branch_view = GTK_WIDGET (gtk_builder_get_object (data->bxml,
"delete_branch_view"));
require_merged_check = GTK_WIDGET (gtk_builder_get_object (data->bxml,
"require_merged_check"));
- branch_list_model = GTK_TREE_MODEL (gtk_builder_get_object (data->bxml,
- "branch_list_model"));
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (delete_branch_view));
selected_branches = NULL;
- gtk_tree_model_foreach (branch_list_model,
- (GtkTreeModelForeachFunc) git_get_selected_refs,
- &selected_branches);
+ gtk_tree_model_foreach (model,
+ (GtkTreeModelForeachFunc) git_get_selected_refs,
+ &selected_branches);
delete_command = git_branch_delete_command_new (data->plugin->project_root_directory,
selected_branches,
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (delete_branch_remote_toggle)),
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (require_merged_check)));
git_command_free_string_list (selected_branches);
@@ -117,17 +120,50 @@ on_delete_branch_dialog_response (GtkDialog *dialog, gint response_id,
}
static void
+on_branch_type_toggle_toggled (GtkToggleButton *toggle_button,
+ GitUIData *data)
+{
+ GtkWidget *delete_branch_view;
+ GtkTreeModel *old_model;
+ GtkTreeModel *new_model;
+ GtkCellRenderer *delete_branch_selected_renderer;
+
+ delete_branch_view = GTK_WIDGET (gtk_builder_get_object (data->bxml,
+ "delete_branch_view"));
+ old_model = gtk_tree_view_get_model (GTK_TREE_VIEW (delete_branch_view));
+ new_model = g_object_get_data (G_OBJECT (toggle_button), "model");
+ delete_branch_selected_renderer = GTK_CELL_RENDERER (gtk_builder_get_object (data->bxml,
+ "delete_branch_selected_renderer"));
+ /* Disconnect the toggled signal on the cell render and then reconnect it
+ * with the new model */
+ g_signal_handlers_disconnect_by_func (delete_branch_selected_renderer,
+ on_git_selected_column_toggled,
+ old_model);
+
+ gtk_tree_view_set_model (GTK_TREE_VIEW (delete_branch_view), new_model);
+
+ g_signal_connect (G_OBJECT (delete_branch_selected_renderer), "toggled",
+ G_CALLBACK (on_git_selected_column_toggled),
+ new_model);
+}
+
+static void
delete_branch_dialog (Git *plugin)
{
GtkBuilder *bxml;
- gchar *objects[] = {"delete_branch_dialog", "branch_list_model", NULL};
+ gchar *objects[] = {"delete_branch_dialog", "branch_list_model",
+ "remote_branch_list_model", NULL};
GError *error;
GtkWidget *dialog;
+ GtkWidget *delete_branch_local_toggle;
+ GtkWidget *delete_branch_remote_toggle;
GtkWidget *delete_branch_view;
GtkListStore *branch_list_model;
+ GtkListStore *remote_branch_list_model;
GtkCellRenderer *delete_branch_selected_renderer;
GitUIData *data;
- GitBranchListCommand *list_command;
+ GitBranchListCommand *local_list_command;
+ GitBranchListCommand *remote_list_command;
bxml = gtk_builder_new ();
error = NULL;
@@ -140,26 +176,43 @@ delete_branch_dialog (Git *plugin)
}
dialog = GTK_WIDGET (gtk_builder_get_object (bxml, "delete_branch_dialog"));
+ delete_branch_local_toggle = GTK_WIDGET (gtk_builder_get_object (bxml,
+ "delete_branch_local_toggle"));
+ delete_branch_remote_toggle = GTK_WIDGET (gtk_builder_get_object (bxml,
+ "delete_branch_remote_toggle"));
delete_branch_view = GTK_WIDGET (gtk_builder_get_object (bxml, "delete_branch_view"));
branch_list_model = GTK_LIST_STORE (gtk_builder_get_object (bxml,
"branch_list_model"));
+ remote_branch_list_model = GTK_LIST_STORE (gtk_builder_get_object (bxml,
+ "remote_branch_list_model"));
delete_branch_selected_renderer = GTK_CELL_RENDERER (gtk_builder_get_object (bxml,
- "delete_branch_selected_renderer")),
+ "delete_branch_selected_renderer"));
data = git_ui_data_new (plugin, bxml);
-
- list_command = git_branch_list_command_new (plugin->project_root_directory,
- GIT_BRANCH_TYPE_LOCAL);
+
+ local_list_command = git_branch_list_command_new (plugin->project_root_directory,
+ GIT_BRANCH_TYPE_LOCAL);
+ remote_list_command = git_branch_list_command_new (plugin->project_root_directory,
+ GIT_BRANCH_TYPE_REMOTE);
- g_signal_connect (G_OBJECT (list_command), "data-arrived",
+ g_signal_connect (G_OBJECT (local_list_command), "data-arrived",
G_CALLBACK (on_list_branch_command_data_arrived),
branch_list_model);
- g_signal_connect (G_OBJECT (list_command), "command-finished",
+ g_signal_connect (G_OBJECT (local_list_command), "command-finished",
G_CALLBACK (on_git_command_finished),
NULL);
+
+ g_signal_connect (G_OBJECT (remote_list_command), "data-arrived",
+ G_CALLBACK (on_list_branch_command_data_arrived),
+ remote_branch_list_model);
- anjuta_command_start (ANJUTA_COMMAND (list_command));
+ g_signal_connect (G_OBJECT (remote_list_command), "command-finished",
+ G_CALLBACK (on_git_command_finished),
+ NULL);
+
+ anjuta_command_start (ANJUTA_COMMAND (local_list_command));
+ anjuta_command_start (ANJUTA_COMMAND (remote_list_command));
g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK (on_delete_branch_dialog_response),
@@ -168,6 +221,19 @@ delete_branch_dialog (Git *plugin)
g_signal_connect (G_OBJECT (delete_branch_selected_renderer), "toggled",
G_CALLBACK (on_git_selected_column_toggled),
branch_list_model);
+
+ g_object_set_data (G_OBJECT (delete_branch_local_toggle), "model",
+ branch_list_model);
+ g_object_set_data (G_OBJECT (delete_branch_remote_toggle), "model",
+ remote_branch_list_model);
+
+ g_signal_connect (G_OBJECT (delete_branch_local_toggle), "toggled",
+ G_CALLBACK (on_branch_type_toggle_toggled),
+ data);
+
+ g_signal_connect (G_OBJECT (delete_branch_remote_toggle), "toggled",
+ G_CALLBACK (on_branch_type_toggle_toggled),
+ data);
gtk_widget_show_all (dialog);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]