Put all of the UI utility functions into the "git" namespace.
[anjuta-git-plugin.git] / plugins / git / git-unstage-dialog.c
blobcd48c49d6b8be3a4b1222dca042990c77cf1e890
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-unstage-dialog.h"
27 static void
28 on_reset_files_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: Files unstaged."), 5);
38 git_report_errors (command, return_code);
40 g_object_unref (command);
44 static void
45 on_unstage_dialog_response (GtkDialog *dialog, gint response_id,
46 GitUIData *data)
48 GtkWidget *unstage_status_view;
49 GList *selected_paths;
50 GitResetFilesCommand *reset_files_command;
52 if (response_id == GTK_RESPONSE_OK)
54 unstage_status_view = glade_xml_get_widget (data->gxml, "unstage_status_view");
55 selected_paths = anjuta_vcs_status_tree_view_get_selected (ANJUTA_VCS_STATUS_TREE_VIEW (unstage_status_view));
56 reset_files_command = git_reset_files_command_new (data->plugin->project_root_directory,
57 GIT_RESET_FILES_HEAD,
58 selected_paths);
60 git_command_free_path_list (selected_paths);
62 g_signal_connect (G_OBJECT (reset_files_command), "command-finished",
63 G_CALLBACK (on_reset_files_command_finished),
64 data->plugin);
66 anjuta_command_start (ANJUTA_COMMAND (reset_files_command));
69 gtk_widget_destroy (GTK_WIDGET (dialog));
70 git_ui_data_free (data);
73 static void
74 unstage_dialog (Git *plugin)
76 GladeXML *gxml;
77 GtkWidget *dialog;
78 GtkWidget *unstage_select_all_button;
79 GtkWidget *unstage_clear_button;
80 GtkWidget *unstage_status_view;
81 GtkWidget *unstage_status_progress_bar;
82 GitStatusCommand *status_command;
83 GitUIData *data;
85 gxml = glade_xml_new (GLADE_FILE, "unstage_dialog", NULL);
87 dialog = glade_xml_get_widget (gxml, "unstage_dialog");
88 unstage_select_all_button = glade_xml_get_widget (gxml, "unstage_select_all_button");
89 unstage_clear_button = glade_xml_get_widget (gxml, "unstage_clear_button");
90 unstage_status_view = glade_xml_get_widget (gxml, "unstage_status_view");
91 unstage_status_progress_bar = glade_xml_get_widget (gxml, "unstage_status_progress_bar");
93 status_command = git_status_command_new (plugin->project_root_directory,
94 GIT_STATUS_SECTION_COMMIT);
96 g_signal_connect (G_OBJECT (unstage_select_all_button), "clicked",
97 G_CALLBACK (git_select_all_status_items),
98 unstage_status_view);
100 g_signal_connect (G_OBJECT (unstage_clear_button), "clicked",
101 G_CALLBACK (git_clear_all_status_selections),
102 unstage_status_view);
104 git_pulse_progress_bar (GTK_PROGRESS_BAR (unstage_status_progress_bar));
106 g_signal_connect (G_OBJECT (status_command), "command-finished",
107 G_CALLBACK (git_cancel_data_arrived_signal_disconnect),
108 unstage_status_view);
110 g_signal_connect (G_OBJECT (status_command), "command-finished",
111 G_CALLBACK (git_hide_pulse_progress_bar),
112 unstage_status_progress_bar);
114 g_signal_connect (G_OBJECT (status_command), "command-finished",
115 G_CALLBACK (on_git_command_finished),
116 NULL);
118 g_signal_connect (G_OBJECT (status_command), "data-arrived",
119 G_CALLBACK (on_git_status_command_data_arrived),
120 unstage_status_view);
122 g_object_weak_ref (G_OBJECT (unstage_status_view),
123 (GWeakNotify) git_disconnect_data_arrived_signals,
124 status_command);
126 anjuta_command_start (ANJUTA_COMMAND (status_command));
128 data = git_ui_data_new (plugin, gxml);
130 g_signal_connect(G_OBJECT (dialog), "response",
131 G_CALLBACK (on_unstage_dialog_response),
132 data);
134 gtk_widget_show_all (dialog);
137 void
138 on_menu_git_unstage (GtkAction *action, Git *plugin)
140 unstage_dialog (plugin);