glade: Fix make file some files were not installed
[anjuta.git] / plugins / subversion / subversion-revert-dialog.c
blob62d10bcf09c55104aa3621b19949dab31aaf0305
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * anjuta
4 * Copyright (C) James Liggett 2007 <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 "subversion-revert-dialog.h"
27 static void
28 on_revert_command_finished (AnjutaCommand *command, guint return_code,
29 Subversion *plugin)
31 AnjutaStatus *status;
33 status = anjuta_shell_get_status (ANJUTA_PLUGIN (plugin)->shell,
34 NULL);
36 anjuta_status (status, _("Subversion: Revert complete."), 5);
38 report_errors (command, return_code);
40 svn_revert_command_destroy (SVN_REVERT_COMMAND (command));
43 static void
44 on_subversion_revert_response (GtkDialog *dialog, gint response,
45 SubversionData *data)
47 SvnRevertCommand *revert_command;
48 GtkWidget *revert_status_view;
49 GList *selected_paths;
51 if (response == GTK_RESPONSE_OK)
53 revert_status_view = GTK_WIDGET (gtk_builder_get_object (data->bxml,
54 "revert_status_view"));
55 selected_paths = anjuta_vcs_status_tree_view_get_selected (ANJUTA_VCS_STATUS_TREE_VIEW (revert_status_view));
56 revert_command = svn_revert_command_new_list (selected_paths, TRUE);
58 svn_command_free_path_list (selected_paths);
60 g_signal_connect (G_OBJECT (revert_command), "data-arrived",
61 G_CALLBACK (on_command_info_arrived),
62 data->plugin);
64 g_signal_connect (G_OBJECT (revert_command), "command-finished",
65 G_CALLBACK (on_revert_command_finished),
66 data->plugin);
68 create_message_view (data->plugin);
70 anjuta_command_start (ANJUTA_COMMAND (revert_command));
73 subversion_data_free (data);
74 gtk_widget_destroy (GTK_WIDGET (dialog));
77 static void
78 subversion_revert_dialog (GtkAction *action, Subversion *plugin)
80 GtkBuilder *bxml = gtk_builder_new ();
81 GtkWidget *subversion_revert;
82 GtkWidget *revert_select_all_button;
83 GtkWidget *revert_clear_button;
84 GtkWidget *revert_status_view;
85 GtkWidget *revert_status_progress_bar;
86 SvnStatusCommand *status_command;
87 SubversionData *data;
88 GError* error = NULL;
90 if (!gtk_builder_add_from_file (bxml, GLADE_FILE, &error))
92 g_warning ("Couldn't load builder file: %s", error->message);
93 g_error_free (error);
96 subversion_revert = GTK_WIDGET (gtk_builder_get_object (bxml,
97 "subversion_revert"));
98 revert_select_all_button = GTK_WIDGET (gtk_builder_get_object (bxml,
99 "revert_select_all_button"));
100 revert_clear_button = GTK_WIDGET (gtk_builder_get_object (bxml,
101 "revert_clear_button"));
102 revert_status_view = GTK_WIDGET (gtk_builder_get_object (bxml,
103 "revert_status_view"));
104 revert_status_progress_bar = GTK_WIDGET (gtk_builder_get_object (bxml,
105 "revert_status_progress_bar"));
107 status_command = svn_status_command_new (plugin->project_root_dir, TRUE,
108 FALSE);
110 data = subversion_data_new (plugin, bxml);
112 g_signal_connect (G_OBJECT (subversion_revert), "response",
113 G_CALLBACK (on_subversion_revert_response),
114 data);
116 g_signal_connect (G_OBJECT (revert_select_all_button), "clicked",
117 G_CALLBACK (select_all_status_items),
118 revert_status_view);
120 g_signal_connect (G_OBJECT (revert_clear_button), "clicked",
121 G_CALLBACK (clear_all_status_selections),
122 revert_status_view);
124 g_signal_connect (G_OBJECT (status_command), "data-arrived",
125 G_CALLBACK (on_status_command_data_arrived),
126 revert_status_view);
128 pulse_progress_bar (GTK_PROGRESS_BAR (revert_status_progress_bar));
130 g_signal_connect (G_OBJECT (status_command), "command-finished",
131 G_CALLBACK (cancel_data_arrived_signal_disconnect),
132 revert_status_view);
134 g_signal_connect (G_OBJECT (status_command), "command-finished",
135 G_CALLBACK (hide_pulse_progress_bar),
136 revert_status_progress_bar);
138 g_signal_connect (G_OBJECT (status_command), "command-finished",
139 G_CALLBACK (on_status_command_finished),
140 revert_status_view);
142 g_object_weak_ref (G_OBJECT (revert_status_view),
143 (GWeakNotify) disconnect_data_arrived_signals,
144 status_command);
146 anjuta_command_start (ANJUTA_COMMAND (status_command));
148 gtk_dialog_run (GTK_DIALOG (subversion_revert));
151 void
152 on_menu_subversion_revert (GtkAction *action, Subversion *plugin)
154 subversion_revert_dialog (action, plugin);
157 void
158 on_fm_subversion_revert (GtkAction *action, Subversion *plugin)
160 SvnRevertCommand *revert_command;
162 revert_command = svn_revert_command_new_path (plugin->fm_current_filename, TRUE);
164 g_signal_connect (G_OBJECT (revert_command), "data-arrived",
165 G_CALLBACK (on_command_info_arrived),
166 plugin);
168 g_signal_connect (G_OBJECT (revert_command), "command-finished",
169 G_CALLBACK (on_revert_command_finished),
170 plugin);
172 create_message_view (plugin);
174 anjuta_command_start (ANJUTA_COMMAND (revert_command));