1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) James Liggett 2007 <jrliggett@cox.net>
6 * Portions based on the original Subversion plugin
7 * Copyright (C) Johannes Schmid 2005
9 * anjuta is free software.
11 * You may redistribute it and/or modify it under the terms of the
12 * GNU General Public License, as published by the Free Software
13 * Foundation; either version 2 of the License, or (at your option)
16 * anjuta is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 * See the GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with anjuta. If not, write to:
23 * The Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor
25 * Boston, MA 02110-1301, USA.
28 #include "subversion-remove-dialog.h"
31 on_remove_command_finished (AnjutaCommand
*command
, guint return_code
,
36 status
= anjuta_shell_get_status (ANJUTA_PLUGIN (plugin
)->shell
,
39 anjuta_status (status
, _("Subversion: File will be removed on next "
42 report_errors (command
, return_code
);
44 svn_remove_command_destroy (SVN_REMOVE_COMMAND (command
));
48 on_remove_path_browse_button_clicked (GtkButton
*button
,
51 GtkWidget
*subversion_remove
;
52 GtkWidget
*remove_path_entry
;
53 GtkWidget
*file_chooser_dialog
;
56 subversion_remove
= GTK_WIDGET (gtk_builder_get_object (data
->bxml
, "subversion_remove"));
57 remove_path_entry
= GTK_WIDGET (gtk_builder_get_object (data
->bxml
,
58 "remove_path_entry"));
59 file_chooser_dialog
= gtk_file_chooser_dialog_new ("Select file or folder",
60 GTK_WINDOW (subversion_remove
),
61 GTK_FILE_CHOOSER_ACTION_OPEN
,
68 if (gtk_dialog_run (GTK_DIALOG (file_chooser_dialog
)) == GTK_RESPONSE_ACCEPT
)
70 selected_path
= gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser_dialog
));
71 gtk_entry_set_text (GTK_ENTRY (remove_path_entry
), selected_path
);
72 g_free (selected_path
);
75 gtk_widget_destroy (GTK_WIDGET (file_chooser_dialog
));
79 on_subversion_remove_response(GtkDialog
* dialog
, gint response
,
86 GtkWidget
* fileentry
= GTK_WIDGET (gtk_builder_get_object (data
->bxml
, "remove_path_entry"));
87 GtkWidget
* force
= GTK_WIDGET (gtk_builder_get_object (data
->bxml
, "subversion_force"));
88 GtkWidget
*remove_log_view
;
89 const gchar
* filename
= gtk_entry_get_text(GTK_ENTRY(fileentry
));
91 SvnRemoveCommand
*remove_command
;
93 remove_log_view
= GTK_WIDGET (gtk_builder_get_object (data
->bxml
,
95 log
= get_log_from_textview (remove_log_view
);
97 if (!check_input (GTK_WIDGET (dialog
),
98 fileentry
, _("Please enter a path.")))
104 remove_command
= svn_remove_command_new_path ((gchar
*) filename
, log
,
105 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (force
)));
107 g_signal_connect (G_OBJECT (remove_command
), "command-finished",
108 G_CALLBACK (on_remove_command_finished
),
111 anjuta_command_start (ANJUTA_COMMAND (remove_command
));
113 subversion_data_free(data
);
114 gtk_widget_destroy (GTK_WIDGET(dialog
));
119 subversion_data_free(data
);
120 gtk_widget_destroy (GTK_WIDGET(dialog
));
126 subversion_remove_dialog(GtkAction
* action
, Subversion
* plugin
, gchar
*filename
)
128 GtkBuilder
* bxml
= gtk_builder_new ();
130 GtkWidget
* remove_path_entry
;
131 GtkWidget
*remove_path_browse_button
;
132 SubversionData
* data
;
133 GError
* error
= NULL
;
135 if (!gtk_builder_add_from_file (bxml
, GLADE_FILE
, &error
))
137 g_warning ("Couldn't load builder file: %s", error
->message
);
138 g_error_free (error
);
141 dialog
= GTK_WIDGET (gtk_builder_get_object (bxml
, "subversion_remove"));
142 remove_path_entry
= GTK_WIDGET (gtk_builder_get_object (bxml
, "remove_path_entry"));
143 remove_path_browse_button
= GTK_WIDGET (gtk_builder_get_object (bxml
,
144 "remove_path_browse_button"));
145 if (remove_path_entry
)
146 gtk_entry_set_text(GTK_ENTRY(remove_path_entry
), filename
);
148 data
= subversion_data_new(plugin
, bxml
);
149 g_signal_connect(G_OBJECT(dialog
), "response",
150 G_CALLBACK(on_subversion_remove_response
), data
);
152 g_signal_connect (G_OBJECT (remove_path_browse_button
), "clicked",
153 G_CALLBACK (on_remove_path_browse_button_clicked
),
156 gtk_widget_show(dialog
);
161 on_menu_subversion_remove (GtkAction
*action
, Subversion
*plugin
)
163 subversion_remove_dialog (action
, plugin
, plugin
->current_editor_filename
);
168 on_fm_subversion_remove (GtkAction
*action
, Subversion
*plugin
)
170 subversion_remove_dialog (action
, plugin
, plugin
->fm_current_filename
);