Put all of the UI utility functions into the "git" namespace.
[anjuta-git-plugin.git] / plugins / git / git-pull-dialog.c
blob0962a7c415782bfcb301e82c1ed926465fe2f559
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * anjuta
4 * Copyright (C) James Liggett 2008 <jrliggett@cox.net>
5 *
6 * anjuta is free software.
7 *
8 * You may redistribute it and/or modify it under the terms of the
9 * GNU General Public License, as published by the Free Software
10 * Foundation; either version 2 of the License, or (at your option)
11 * any later version.
13 * anjuta is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with anjuta. If not, write to:
20 * The Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor
22 * Boston, MA 02110-1301, USA.
25 #include "git-pull-dialog.h"
27 static void
28 on_pull_command_finished (AnjutaCommand *command, guint return_code,
29 Git *plugin)
31 AnjutaStatus *status;
33 status = anjuta_shell_get_status (ANJUTA_PLUGIN (plugin)->shell,
34 NULL);
36 anjuta_status (status, _("Git: Pull complete."), 5);
38 git_report_errors (command, return_code);
40 g_object_unref (command);
44 static void
45 on_pull_dialog_response (GtkDialog *dialog, gint response_id,
46 GitUIData *data)
48 GtkWidget *pull_url_entry;
49 GtkWidget *pull_no_commit_check;
50 GtkWidget *pull_squash_check;
51 GtkWidget *pull_fast_forward_commit_check;
52 GtkWidget *pull_append_fetch_data_check;
53 GtkWidget *pull_force_check;
54 GtkWidget *pull_no_follow_tags_check;
55 gchar *url;
56 GitPullCommand *pull_command;
58 if (response_id == GTK_RESPONSE_OK)
60 pull_url_entry = glade_xml_get_widget (data->gxml, "pull_url_entry");
61 pull_no_commit_check = glade_xml_get_widget (data->gxml,
62 "pull_no_commit_check");
63 pull_squash_check = glade_xml_get_widget (data->gxml,
64 "pull_squash_check");
65 pull_fast_forward_commit_check = glade_xml_get_widget (data->gxml,
66 "pull_fast_forward_commit_check");
67 pull_append_fetch_data_check = glade_xml_get_widget (data->gxml,
68 "pull_append_fetch_data_check");
69 pull_force_check = glade_xml_get_widget (data->gxml,
70 "pull_force_check");
71 pull_no_follow_tags_check = glade_xml_get_widget (data->gxml,
72 "pull_no_follow_tags_check");
74 url = gtk_editable_get_chars (GTK_EDITABLE (pull_url_entry), 0, -1);
76 if (!git_check_input (GTK_WIDGET (dialog), pull_url_entry, url,
77 _("Please enter the URL of the repository to pull"
78 " from.")))
80 g_free (url);
81 return;
86 pull_command = git_pull_command_new (data->plugin->project_root_directory,
87 url,
88 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pull_no_commit_check)),
89 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pull_squash_check)),
90 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pull_fast_forward_commit_check)),
91 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pull_append_fetch_data_check)),
92 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pull_force_check)),
93 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (pull_no_follow_tags_check)));
95 g_free (url);
97 git_create_message_view (data->plugin);
99 g_signal_connect (G_OBJECT (pull_command), "command-finished",
100 G_CALLBACK (on_pull_command_finished),
101 data->plugin);
103 g_signal_connect (G_OBJECT (pull_command), "data-arrived",
104 G_CALLBACK (on_git_command_info_arrived),
105 data->plugin);
107 anjuta_command_start (ANJUTA_COMMAND (pull_command));
110 gtk_widget_destroy (GTK_WIDGET (dialog));
111 git_ui_data_free (data);
114 static void
115 pull_dialog (Git *plugin)
117 GladeXML *gxml;
118 GtkWidget *dialog;
119 GitUIData *data;
121 gxml = glade_xml_new (GLADE_FILE, "pull_dialog", NULL);
122 dialog = glade_xml_get_widget (gxml, "pull_dialog");
123 data = git_ui_data_new (plugin, gxml);
125 g_signal_connect (G_OBJECT (dialog), "response",
126 G_CALLBACK (on_pull_dialog_response),
127 data);
129 gtk_widget_show_all (dialog);
132 void
133 on_menu_git_pull (GtkAction *action, Git *plugin)
135 pull_dialog (plugin);