[anjuta] git: Add a remote picklist to the Pull dialog
- From: James Liggett <jrliggett src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [anjuta] git: Add a remote picklist to the Pull dialog
- Date: Mon, 3 Aug 2009 20:59:27 +0000 (UTC)
commit 122b22ad32c7f119bf451d7a877c90b7497546fb
Author: James Liggett <jrliggett cox net>
Date: Mon Aug 3 13:58:33 2009 -0700
git: Add a remote picklist to the Pull dialog
plugins/git/anjuta-git.ui | 112 ++++++++++++++++++++++++++++++++++++--
plugins/git/git-pull-dialog.c | 121 +++++++++++++++++++++++++++++++++++++----
plugins/git/git-pull-dialog.h | 1 +
plugins/git/git-push-dialog.c | 84 +++++++----------------------
plugins/git/git-ui-utils.c | 47 ++++++++++++++++
plugins/git/git-ui-utils.h | 5 ++-
6 files changed, 289 insertions(+), 81 deletions(-)
---
diff --git a/plugins/git/anjuta-git.ui b/plugins/git/anjuta-git.ui
index 9c7de90..abc4716 100644
--- a/plugins/git/anjuta-git.ui
+++ b/plugins/git/anjuta-git.ui
@@ -4157,12 +4157,115 @@
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
- <object class="GtkEntry" id="pull_url_entry">
+ <object class="GtkVBox" id="pull_repository_vbox">
<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">60</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkHBox" id="hbox7">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkRadioButton" id="pull_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>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="pull_url_toggle">
+ <property name="label" translatable="yes">URL</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">pull_remote_toggle</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkNotebook" id="pull_repository_notebook">
+ <property name="visible">True</property>
+ <property name="show_tabs">False</property>
+ <property name="show_border">False</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow16">
+ <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="pull_remote_view">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="model">remote_list_model</property>
+ <property name="headers_visible">False</property>
+ <property name="headers_clickable">False</property>
+ <property name="search_column">0</property>
+ <child>
+ <object class="GtkTreeViewColumn" id="treeviewcolumn13">
+ <property name="title">column</property>
+ <child>
+ <object class="GtkCellRendererText" id="pull_remote_view_name_renderer"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label73">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">page 1</property>
+ </object>
+ <packing>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="pull_url_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ <property name="width_chars">60</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label74">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">page 2</property>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="position">0</property>
@@ -4174,7 +4277,6 @@
<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>
</object>
<packing>
diff --git a/plugins/git/git-pull-dialog.c b/plugins/git/git-pull-dialog.c
index 87900f5..5d016cf 100644
--- a/plugins/git/git-pull-dialog.c
+++ b/plugins/git/git-pull-dialog.c
@@ -40,11 +40,39 @@ on_pull_command_finished (AnjutaCommand *command, guint return_code,
g_object_unref (command);
}
+static void
+on_remote_list_command_finished (AnjutaCommand *command, guint return_code,
+ GitUIData *data)
+{
+ GtkWidget *pull_origin_check;
+ gboolean sensitive;
+
+ pull_origin_check = GTK_WIDGET (gtk_builder_get_object (data->bxml,
+ "pull_origin_check"));
+
+ g_object_get (G_OBJECT (pull_origin_check), "sensitive", &sensitive, NULL);
+
+ /* The repository origin check should be on by default, but since we're
+ * trying to intelligently detect if there is even an origin to be used,
+ * don't try to make it active if if will be disabled anyway. */
+ if (sensitive)
+ {
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (pull_origin_check),
+ TRUE);
+ }
+
+ git_report_errors (command, return_code);
+
+ g_object_unref (command);
+}
static void
on_pull_dialog_response (GtkDialog *dialog, gint response_id,
GitUIData *data)
{
+ GtkWidget *pull_remote_toggle;
+ GtkWidget *pull_url_toggle;
+ GtkWidget *pull_remote_view;
GtkWidget *pull_origin_check;
GtkWidget *pull_rebase_check;
GtkWidget *pull_url_entry;
@@ -54,11 +82,22 @@ on_pull_dialog_response (GtkDialog *dialog, gint response_id,
GtkWidget *pull_append_fetch_data_check;
GtkWidget *pull_force_check;
GtkWidget *pull_no_follow_tags_check;
+ GtkTreeModel *remote_list_model;
+ GtkWidget *input_widget;
+ const gchar *input_error;
gchar *url;
+ GtkTreeSelection *selection;
+ GtkTreeIter iter;
GitPullCommand *pull_command;
if (response_id == GTK_RESPONSE_OK)
{
+ pull_remote_toggle = GTK_WIDGET (gtk_builder_get_object (data->bxml,
+ "pull_remote_toggle"));
+ pull_url_toggle = GTK_WIDGET (gtk_builder_get_object (data->bxml,
+ "pull_url_toggle"));
+ pull_remote_view = GTK_WIDGET (gtk_builder_get_object (data->bxml,
+ "pull_remote_view"));
pull_origin_check = GTK_WIDGET (gtk_builder_get_object (data->bxml,
"pull_origin_check"));
pull_rebase_check = GTK_WIDGET (gtk_builder_get_object (data->bxml,
@@ -77,15 +116,34 @@ on_pull_dialog_response (GtkDialog *dialog, gint response_id,
"pull_force_check"));
pull_no_follow_tags_check = GTK_WIDGET (gtk_builder_get_object (data->bxml,
"pull_no_follow_tags_check"));
+ remote_list_model = GTK_TREE_MODEL (gtk_builder_get_object (data->bxml,
+ "remote_list_model"));
+ /* The "input widget" is the widget that should receive focus if the
+ * user does not properly enter anything */
+ input_error = _("Please select a remote to pull from.");
+ input_widget = pull_remote_view;
+
+ url = NULL;
+
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pull_origin_check)))
- url = g_strdup ("origin");
- else
- url = gtk_editable_get_chars (GTK_EDITABLE (pull_url_entry), 0, -1);
+ url = g_strdup ("origin");
+ else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pull_remote_toggle)))
+ {
+ selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (pull_remote_view));
+
+ if (gtk_tree_selection_get_selected (selection, NULL, &iter))
+ gtk_tree_model_get (remote_list_model, &iter, 0, &url, -1);
+ }
+ else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pull_url_toggle)))
+ {
+ url = gtk_editable_get_chars (GTK_EDITABLE (pull_url_entry), 0, -1);
+ input_widget = pull_url_entry;
+ input_error = _("Please enter the URL of the repository to pull from.");
+ }
- if (!git_check_input (GTK_WIDGET (dialog), pull_url_entry, url,
- _("Please enter the URL of the repository to pull"
- " from.")))
+ if (!git_check_input (GTK_WIDGET (dialog), input_widget, url,
+ input_error))
{
g_free (url);
return;
@@ -124,12 +182,17 @@ static void
pull_dialog (Git *plugin)
{
GtkBuilder *bxml;
- gchar *objects[] = {"pull_dialog", NULL};
+ gchar *objects[] = {"pull_dialog", "remote_list_model", NULL};
GError *error;
GtkWidget *dialog;
+ GtkWidget *pull_repository_vbox;
+ GtkWidget *pull_remote_toggle;
+ GtkWidget *pull_url_toggle;
+ GtkWidget *pull_repository_notebook;
GtkWidget *pull_origin_check;
- GtkWidget *pull_url_entry;
+ GtkListStore *remote_list_model;
GitUIData *data;
+ GitRemoteListCommand *remote_list_command;
bxml = gtk_builder_new ();
error = NULL;
@@ -142,19 +205,55 @@ pull_dialog (Git *plugin)
}
dialog = GTK_WIDGET (gtk_builder_get_object (bxml, "pull_dialog"));
+ pull_repository_vbox = GTK_WIDGET (gtk_builder_get_object (bxml,
+ "pull_repository_vbox"));
+ pull_remote_toggle = GTK_WIDGET (gtk_builder_get_object (bxml,
+ "pull_remote_toggle"));
+ pull_url_toggle = GTK_WIDGET (gtk_builder_get_object (bxml,
+ "pull_url_toggle"));
+ pull_repository_notebook = GTK_WIDGET (gtk_builder_get_object (bxml,
+ "pull_repository_notebook"));
pull_origin_check = GTK_WIDGET (gtk_builder_get_object (bxml,
"pull_origin_check"));
- pull_url_entry = GTK_WIDGET (gtk_builder_get_object (bxml,
- "pull_url_entry"));
+ remote_list_model = GTK_LIST_STORE (gtk_builder_get_object (bxml,
+ "remote_list_model"));
data = git_ui_data_new (plugin, bxml);
+
+ remote_list_command = git_remote_list_command_new (plugin->project_root_directory);
+
+ g_object_set_data (G_OBJECT (remote_list_command), "origin-check",
+ pull_origin_check);
+
+ g_signal_connect (G_OBJECT (remote_list_command), "data-arrived",
+ G_CALLBACK (on_git_remote_list_command_data_arrived),
+ remote_list_model);
+
+ g_signal_connect (G_OBJECT (remote_list_command), "command-finished",
+ G_CALLBACK (on_remote_list_command_finished),
+ data);
+
+ anjuta_command_start (ANJUTA_COMMAND (remote_list_command));
g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK (on_pull_dialog_response),
data);
+ g_object_set_data (G_OBJECT (pull_remote_toggle), "tab-index",
+ GINT_TO_POINTER (0));
+ g_object_set_data (G_OBJECT (pull_url_toggle), "tab-index",
+ GINT_TO_POINTER (1));
+
+ g_signal_connect (G_OBJECT (pull_remote_toggle), "toggled",
+ G_CALLBACK (on_git_notebook_button_toggled),
+ pull_repository_notebook);
+
+ g_signal_connect (G_OBJECT (pull_url_toggle), "toggled",
+ G_CALLBACK (on_git_notebook_button_toggled),
+ pull_repository_notebook);
+
g_signal_connect (G_OBJECT (pull_origin_check), "toggled",
G_CALLBACK (on_git_origin_check_toggled),
- pull_url_entry);
+ pull_repository_vbox);
gtk_widget_show_all (dialog);
}
diff --git a/plugins/git/git-pull-dialog.h b/plugins/git/git-pull-dialog.h
index 4c4ff14..8fbf34f 100644
--- a/plugins/git/git-pull-dialog.h
+++ b/plugins/git/git-pull-dialog.h
@@ -26,6 +26,7 @@
#define _GIT_PULL_DIALOG_H
#include "git-pull-command.h"
+#include "git-remote-list-command.h"
#include "git-ui-utils.h"
void on_menu_git_pull (GtkAction *action, Git *plugin);
diff --git a/plugins/git/git-push-dialog.c b/plugins/git/git-push-dialog.c
index 65996d9..1b44ca9 100644
--- a/plugins/git/git-push-dialog.c
+++ b/plugins/git/git-push-dialog.c
@@ -89,59 +89,6 @@ on_push_all_check_toggled (GtkToggleButton *toggle_button,
}
static void
-on_remote_list_command_data_arrived (AnjutaCommand *command, GitUIData *data)
-{
- GtkListStore *remote_list_model;
- GtkWidget *push_origin_check;
- GQueue *output_queue;
- gchar *remote_name;
- GtkTreeIter iter;
-
- remote_list_model = GTK_LIST_STORE (gtk_builder_get_object (data->bxml,
- "remote_list_model"));
- push_origin_check = GTK_WIDGET (gtk_builder_get_object (data->bxml,
- "push_origin_check"));
- output_queue = git_raw_output_command_get_output (GIT_RAW_OUTPUT_COMMAND (command));
-
- while (g_queue_peek_head (output_queue))
- {
- remote_name = g_queue_pop_head (output_queue);
-
- /* Don't show the origin branch in the list. Origin is specified by
- * enabling the origin checkbox. As use of origin is such a common
- * operation, give access to it in one click. Keep the checkbox disabled
- * if no origin branch exists. */
- if (strcmp (remote_name, "origin") != 0)
- {
- gtk_list_store_append (remote_list_model, &iter);
- gtk_list_store_set (remote_list_model, &iter, 0, remote_name, -1);
- }
- else
- gtk_widget_set_sensitive (push_origin_check, TRUE);
-
- g_free (remote_name);
- }
-}
-
-static void
-on_notebook_button_toggled (GtkToggleButton *toggle_button, GitUIData *data)
-{
- GtkWidget *push_repository_notebook;
- gint tab_index;
-
- if (gtk_toggle_button_get_active (toggle_button))
- {
- push_repository_notebook = GTK_WIDGET (gtk_builder_get_object (data->bxml,
- "push_repository_notebook"));
- tab_index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (toggle_button),
- "tab-index"));
-
- gtk_notebook_set_current_page (GTK_NOTEBOOK (push_repository_notebook),
- tab_index);
- }
-}
-
-static void
on_push_dialog_response (GtkDialog *dialog, gint response_id,
GitUIData *data)
{
@@ -155,7 +102,7 @@ on_push_dialog_response (GtkDialog *dialog, gint response_id,
GtkTreeModel *remote_list_model;
GtkTreeModel *branch_list_model;
GtkTreeModel *tag_list_model;
- GtkWidget *focus_widget;
+ GtkWidget *input_widget;
const gchar *input_error;
GtkTreeSelection *selection;
GtkTreeIter iter;
@@ -189,10 +136,10 @@ on_push_dialog_response (GtkDialog *dialog, gint response_id,
tag_list_model = GTK_TREE_MODEL (gtk_builder_get_object (data->bxml,
"tag_list_model"));
- /* The "focus widget" is the widget that should receive focus if the
+ /* The "input widget" is the widget that should receive focus if the
* user does not properly enter anything */
input_error = _("Please select a remote to push to.");
- focus_widget = push_remote_view;
+ input_widget = push_remote_view;
url = NULL;
@@ -208,11 +155,11 @@ on_push_dialog_response (GtkDialog *dialog, gint response_id,
else if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (push_url_toggle)))
{
url = gtk_editable_get_chars (GTK_EDITABLE (push_url_entry), 0, -1);
- focus_widget = push_url_entry;
+ input_widget = push_url_entry;
input_error = _("Please enter the URL of the repository to push to.");
}
- if (!git_check_input (GTK_WIDGET (dialog), focus_widget, url,
+ if (!git_check_input (GTK_WIDGET (dialog), input_widget, url,
input_error))
{
g_free (url);
@@ -282,12 +229,14 @@ push_dialog (Git *plugin)
"tag_list_model", NULL};
GError *error;
GtkWidget *dialog;
+ GtkWidget *push_repository_notebook;
GtkWidget *push_remote_toggle;
GtkWidget *push_url_toggle;
GtkWidget *push_origin_check;
GtkWidget *push_repository_vbox;
GtkWidget *push_tags_check;
GtkWidget *push_all_check;
+ GtkListStore *remote_list_model;
GtkListStore *branch_list_model;
GtkListStore *tag_list_model;
GtkCellRenderer *push_branches_view_selected_renderer;
@@ -309,6 +258,8 @@ push_dialog (Git *plugin)
}
dialog = GTK_WIDGET (gtk_builder_get_object (bxml, "push_dialog"));
+ push_repository_notebook = GTK_WIDGET (gtk_builder_get_object (bxml,
+ "push_repository_notebook"));
push_remote_toggle = GTK_WIDGET (gtk_builder_get_object (bxml,
"push_remote_toggle"));
push_url_toggle = GTK_WIDGET (gtk_builder_get_object (bxml,
@@ -321,6 +272,8 @@ push_dialog (Git *plugin)
"push_all_check"));
push_tags_check = GTK_WIDGET (gtk_builder_get_object (bxml,
"push_tags_check"));
+ remote_list_model = GTK_LIST_STORE (gtk_builder_get_object (bxml,
+ "remote_list_model"));
branch_list_model = GTK_LIST_STORE (gtk_builder_get_object (bxml,
"branch_list_model"));
tag_list_model = GTK_LIST_STORE (gtk_builder_get_object (bxml,
@@ -338,9 +291,12 @@ push_dialog (Git *plugin)
GIT_BRANCH_TYPE_LOCAL);
tag_list_command = git_tag_list_command_new (plugin->project_root_directory);
+ g_object_set_data (G_OBJECT (remote_list_command), "origin-check",
+ push_origin_check);
+
g_signal_connect (G_OBJECT (remote_list_command), "data-arrived",
- G_CALLBACK (on_remote_list_command_data_arrived),
- data);
+ G_CALLBACK (on_git_remote_list_command_data_arrived),
+ remote_list_model);
g_signal_connect (G_OBJECT (remote_list_command), "command-finished",
G_CALLBACK (on_git_command_finished),
@@ -377,12 +333,12 @@ push_dialog (Git *plugin)
GINT_TO_POINTER (1));
g_signal_connect (G_OBJECT (push_remote_toggle), "toggled",
- G_CALLBACK (on_notebook_button_toggled),
- data);
+ G_CALLBACK (on_git_notebook_button_toggled),
+ push_repository_notebook);
g_signal_connect (G_OBJECT (push_url_toggle), "toggled",
- G_CALLBACK (on_notebook_button_toggled),
- data);
+ G_CALLBACK (on_git_notebook_button_toggled),
+ push_repository_notebook);
g_signal_connect (G_OBJECT (push_origin_check), "toggled",
G_CALLBACK (on_git_origin_check_toggled),
diff --git a/plugins/git/git-ui-utils.c b/plugins/git/git-ui-utils.c
index 4475397..348836c 100644
--- a/plugins/git/git-ui-utils.c
+++ b/plugins/git/git-ui-utils.c
@@ -554,6 +554,53 @@ on_git_stash_apply_command_finished (AnjutaCommand *command, guint return_code,
}
void
+on_git_remote_list_command_data_arrived (AnjutaCommand *command,
+ GtkListStore *remote_list_model)
+{
+ GtkWidget *origin_check;
+ GQueue *output_queue;
+ gchar *remote_name;
+ GtkTreeIter iter;
+
+ origin_check = g_object_get_data (G_OBJECT (command), "origin-check");
+ output_queue = git_raw_output_command_get_output (GIT_RAW_OUTPUT_COMMAND (command));
+
+ while (g_queue_peek_head (output_queue))
+ {
+ remote_name = g_queue_pop_head (output_queue);
+
+ /* Don't show the origin branch in the list. Origin is specified by
+ * enabling the origin checkbox. As use of origin is such a common
+ * operation, give access to it in one click. Keep the checkbox disabled
+ * if no origin branch exists. */
+ if (strcmp (remote_name, "origin") != 0)
+ {
+ gtk_list_store_append (remote_list_model, &iter);
+ gtk_list_store_set (remote_list_model, &iter, 0, remote_name, -1);
+ }
+ else
+ gtk_widget_set_sensitive (origin_check, TRUE);
+
+ g_free (remote_name);
+ }
+}
+
+void
+on_git_notebook_button_toggled (GtkToggleButton *toggle_button,
+ GtkNotebook *notebook)
+{
+ gint tab_index;
+
+ if (gtk_toggle_button_get_active (toggle_button))
+ {
+ tab_index = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (toggle_button),
+ "tab-index"));
+
+ gtk_notebook_set_current_page (notebook, tab_index);
+ }
+}
+
+void
git_select_all_status_items (GtkButton *select_all_button,
AnjutaVcsStatusTreeView *tree_view)
{
diff --git a/plugins/git/git-ui-utils.h b/plugins/git/git-ui-utils.h
index 79e9357..40dbca1 100644
--- a/plugins/git/git-ui-utils.h
+++ b/plugins/git/git-ui-utils.h
@@ -89,12 +89,15 @@ void on_git_stash_save_command_finished (AnjutaCommand *command,
guint return_code, Git *plugin);
void on_git_stash_apply_command_finished (AnjutaCommand *command,
guint return_code, Git *plugin);
+void on_git_remote_list_command_data_arrived (AnjutaCommand *command,
+ GtkListStore *remote_list_model);
+void on_git_notebook_button_toggled (GtkToggleButton *toggle_button,
+ GtkNotebook *notebook);
void git_select_all_status_items (GtkButton *select_all_button,
AnjutaVcsStatusTreeView *tree_view);
void git_clear_all_status_selections (GtkButton *clear_button,
AnjutaVcsStatusTreeView *tree_view);
void on_git_origin_check_toggled (GtkToggleButton *button, GtkWidget *widget);
-
void git_init_whole_project (Git *plugin, GtkWidget* project,
gboolean active);
void on_git_whole_project_toggled (GtkToggleButton* project, Git *plugin);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]