[anjuta] git: Add branch selector to the Create Branch dialog.
- From: James Liggett <jrliggett src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjuta] git: Add branch selector to the Create Branch dialog.
- Date: Wed, 8 Jul 2009 00:48:28 +0000 (UTC)
commit bf4830f53608baf5184f14e1ee1d1d53ad27e007
Author: James Liggett <jrliggett cox net>
Date: Tue Jul 7 17:34:00 2009 -0700
git: Add branch selector to the Create Branch dialog.
This should make it slightly easier to make branches from other branches and to create remote
tracking branches.
plugins/git/anjuta-git.ui | 90 +++++++++++++++++++++-----------
plugins/git/git-create-branch-dialog.c | 64 +++++++++++++++++++----
2 files changed, 112 insertions(+), 42 deletions(-)
---
diff --git a/plugins/git/anjuta-git.ui b/plugins/git/anjuta-git.ui
index d06774d..333d54d 100644
--- a/plugins/git/anjuta-git.ui
+++ b/plugins/git/anjuta-git.ui
@@ -1253,8 +1253,11 @@
<property name="visible">True</property>
<property name="left_padding">12</property>
<child>
- <object class="GtkVBox" id="vbox8">
+ <object class="GtkTable" id="table5">
<property name="visible">True</property>
+ <property name="n_rows">3</property>
+ <property name="n_columns">2</property>
+ <property name="row_spacing">2</property>
<child>
<object class="GtkRadioButton" id="branch_head_radio">
<property name="label" translatable="yes">Head</property>
@@ -1265,44 +1268,69 @@
<property name="draw_indicator">True</property>
</object>
<packing>
- <property name="position">0</property>
+ <property name="right_attach">2</property>
</packing>
</child>
<child>
- <object class="GtkHBox" id="hbox3">
+ <object class="GtkRadioButton" id="branch_revision_radio">
+ <property name="label" translatable="yes">Revision/Tag:</property>
<property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">branch_head_radio</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="branch_revision_entry">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ <property name="width_chars">40</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="branch_branch_radio">
+ <property name="label" translatable="yes">Branch:</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">branch_revision_radio</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="branch_branch_combo">
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="model">branch_combo_model</property>
<child>
- <object class="GtkRadioButton" id="branch_revision_radio">
- <property name="label" translatable="yes">Revision/Tag:</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">True</property>
- <property name="group">branch_head_radio</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry" id="branch_revision_entry">
- <property name="visible">True</property>
- <property name="sensitive">False</property>
- <property name="can_focus">True</property>
- <property name="width_chars">40</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
+ <object class="GtkCellRendererText" id="branch_branch_name_renderer"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
</child>
</object>
<packing>
- <property name="position">1</property>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
</packing>
</child>
</object>
diff --git a/plugins/git/git-create-branch-dialog.c b/plugins/git/git-create-branch-dialog.c
index 19a2933..f01cbf8 100644
--- a/plugins/git/git-create-branch-dialog.c
+++ b/plugins/git/git-create-branch-dialog.c
@@ -62,8 +62,12 @@ on_create_branch_dialog_response (GtkDialog *dialog, gint response_id,
GtkWidget *branch_checkout_check;
GtkWidget *branch_revision_radio;
GtkWidget *branch_revision_entry;
+ GtkWidget *branch_branch_radio;
+ GtkWidget *branch_branch_combo;
+ GtkTreeModel *branch_combo_model;
gchar *branch_name;
gchar *revision;
+ GtkTreeIter iter;
gboolean checkout;
GitBranchCreateCommand *create_command;
@@ -77,6 +81,12 @@ on_create_branch_dialog_response (GtkDialog *dialog, gint response_id,
"branch_revision_radio"));
branch_revision_entry = GTK_WIDGET (gtk_builder_get_object (data->bxml,
"branch_revision_entry"));
+ branch_branch_radio = GTK_WIDGET (gtk_builder_get_object (data->bxml,
+ "branch_branch_radio"));
+ branch_branch_combo = GTK_WIDGET (gtk_builder_get_object (data->bxml,
+ "branch_branch_combo"));
+ branch_combo_model = GTK_TREE_MODEL (gtk_builder_get_object (data->bxml,
+ "branch_combo_model"));
branch_name = gtk_editable_get_chars (GTK_EDITABLE (branch_name_entry),
0, -1);
revision = NULL;
@@ -93,6 +103,15 @@ on_create_branch_dialog_response (GtkDialog *dialog, gint response_id,
return;
}
}
+ else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (branch_branch_radio)))
+ {
+ if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (branch_branch_combo),
+ &iter))
+ {
+ gtk_tree_model_get (branch_combo_model, &iter, 0, &revision,
+ -1);
+ }
+ }
if (!git_check_input (GTK_WIDGET (dialog), branch_revision_entry,
branch_name, _("Please enter a branch name.")))
@@ -132,24 +151,20 @@ on_create_branch_dialog_response (GtkDialog *dialog, gint response_id,
static void
on_branch_revision_radio_toggled (GtkToggleButton *toggle_button,
- GitUIData *data)
+ GtkWidget *widget)
{
GtkWidget *create_branch_dialog;
- GtkWidget *branch_revision_entry;
gboolean active;
- create_branch_dialog = GTK_WIDGET (gtk_builder_get_object (data->bxml,
- "create_branch_dialog"));
- branch_revision_entry = GTK_WIDGET (gtk_builder_get_object (data->bxml,
- "branch_revision_entry"));
+ create_branch_dialog = gtk_widget_get_toplevel (GTK_WIDGET (toggle_button));
active = gtk_toggle_button_get_active (toggle_button);
- gtk_widget_set_sensitive (branch_revision_entry, active);
+ gtk_widget_set_sensitive (widget, active);
- if (active)
+ if (active && GTK_WIDGET_CAN_FOCUS (widget))
{
gtk_window_set_focus (GTK_WINDOW (create_branch_dialog),
- branch_revision_entry);
+ widget);
}
}
@@ -158,12 +173,16 @@ static void
create_branch_dialog (Git *plugin, const gchar *revision)
{
GtkBuilder *bxml;
- gchar *objects[] = {"create_branch_dialog", NULL};
+ gchar *objects[] = {"create_branch_dialog", "branch_combo_model", NULL};
GError *error;
GtkWidget *dialog;
GtkWidget *branch_revision_radio;
GtkWidget *branch_revision_entry;
+ GtkWidget *branch_branch_radio;
+ GtkWidget *branch_branch_combo;
+ GtkListStore *branch_combo_model;
GitUIData *data;
+ GitBranchListCommand *branch_list_command;
bxml = gtk_builder_new ();
error = NULL;
@@ -180,7 +199,26 @@ create_branch_dialog (Git *plugin, const gchar *revision)
"branch_revision_radio"));
branch_revision_entry = GTK_WIDGET (gtk_builder_get_object (bxml,
"branch_revision_entry"));
+ branch_branch_radio = GTK_WIDGET (gtk_builder_get_object (bxml,
+ "branch_branch_radio"));
+ branch_branch_combo = GTK_WIDGET (gtk_builder_get_object (bxml,
+ "branch_branch_combo"));
+ branch_combo_model = GTK_LIST_STORE (gtk_builder_get_object (bxml,
+ "branch_combo_model"));
data = git_ui_data_new (plugin, bxml);
+
+ branch_list_command = git_branch_list_command_new (plugin->project_root_directory,
+ GIT_BRANCH_TYPE_ALL);
+
+ g_signal_connect (G_OBJECT (branch_list_command), "data-arrived",
+ G_CALLBACK (on_git_list_branch_combo_command_data_arrived),
+ branch_combo_model);
+
+ g_signal_connect (G_OBJECT (branch_list_command), "command-finished",
+ G_CALLBACK (on_git_list_branch_combo_command_finished),
+ branch_branch_combo);
+
+ anjuta_command_start (ANJUTA_COMMAND (branch_list_command));
g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK (on_create_branch_dialog_response),
@@ -188,7 +226,11 @@ create_branch_dialog (Git *plugin, const gchar *revision)
g_signal_connect (G_OBJECT (branch_revision_radio), "toggled",
G_CALLBACK (on_branch_revision_radio_toggled),
- data);
+ branch_revision_entry);
+
+ g_signal_connect (G_OBJECT (branch_branch_radio), "toggled",
+ G_CALLBACK (on_branch_revision_radio_toggled),
+ branch_branch_combo);
if (revision)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]