glade: Fix make file some files were not installed
[anjuta.git] / plugins / subversion / subversion-diff-dialog.c
blobd663b0e8280235e398bdd290388f2d6bad142eaa
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>
6 * Portions based on the original Subversion plugin
7 * Copyright (C) Johannes Schmid 2005
8 *
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)
14 * any later version.
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-diff-dialog.h"
30 #define BROWSE_BUTTON_DIFF_DIALOG "browse_button_diff_dialog"
32 static void
33 subversion_show_diff (const gchar *path, gboolean recursive,
34 gboolean save_files, Subversion *plugin)
36 IAnjutaDocumentManager *docman;
37 gchar *filename;
38 gchar *editor_name;
39 IAnjutaEditor *editor;
40 SvnDiffCommand *diff_command;
41 guint pulse_timer_id;
43 docman = anjuta_shell_get_interface (ANJUTA_PLUGIN (plugin)->shell,
44 IAnjutaDocumentManager, NULL);
45 filename = get_filename_from_full_path ((gchar *) path);
46 editor_name = g_strdup_printf ("%s %s.diff", _("[Head/Working Copy]"),
47 filename);
48 editor = ianjuta_document_manager_add_buffer(docman, editor_name,
49 "", NULL);
51 g_free (filename);
52 g_free (editor_name);
54 diff_command = svn_diff_command_new ((gchar *) path,
55 SVN_DIFF_REVISION_NONE,
56 SVN_DIFF_REVISION_NONE,
57 plugin->project_root_dir,
58 recursive);
60 pulse_timer_id = status_bar_progress_pulse (plugin,
61 _("Subversion: "
62 "Retrieving "
63 "diff…"));
65 g_signal_connect (G_OBJECT (diff_command), "command-finished",
66 G_CALLBACK (stop_status_bar_progress_pulse),
67 GUINT_TO_POINTER (pulse_timer_id));
70 g_signal_connect (G_OBJECT (diff_command), "command-finished",
71 G_CALLBACK (on_diff_command_finished),
72 plugin);
74 g_signal_connect (G_OBJECT (diff_command), "data-arrived",
75 G_CALLBACK (send_diff_command_output_to_editor),
76 editor);
78 g_object_weak_ref (G_OBJECT (editor),
79 (GWeakNotify) disconnect_data_arrived_signals,
80 diff_command);
82 if (save_files)
83 ianjuta_file_savable_save (IANJUTA_FILE_SAVABLE (docman), NULL);
85 anjuta_command_start (ANJUTA_COMMAND (diff_command));
88 static void
89 on_subversion_diff_response(GtkDialog* dialog, gint response, SubversionData* data)
91 GtkWidget *diff_path_entry;
92 GtkWidget *diff_no_recursive_check;
93 GtkWidget *diff_revision_entry;
94 GtkWidget *diff_save_open_files_check;
95 const gchar *path;
96 const gchar *revision_text;
97 glong revision;
99 switch (response)
101 case GTK_RESPONSE_OK:
103 diff_path_entry = GTK_WIDGET (gtk_builder_get_object (data->bxml,
104 "diff_path_entry"));
105 diff_no_recursive_check = GTK_WIDGET (gtk_builder_get_object (data->bxml,
106 "diff_no_recursive_check"));
107 diff_revision_entry = GTK_WIDGET (gtk_builder_get_object (data->bxml,
108 "diff_revision_entry"));
109 diff_save_open_files_check = GTK_WIDGET (gtk_builder_get_object (data->bxml,
110 "diff_save_open_files_check"));
111 path = g_strdup (gtk_entry_get_text (GTK_ENTRY (diff_path_entry)));
112 revision_text = gtk_entry_get_text (GTK_ENTRY (diff_revision_entry));
113 revision = atol (revision_text);
115 if (!check_input (GTK_WIDGET (dialog), diff_path_entry,
116 _("Please enter a path.")))
118 break;
121 subversion_show_diff (path,
122 !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (diff_no_recursive_check)),
123 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (diff_save_open_files_check)),
124 data->plugin);
126 subversion_data_free(data);
127 gtk_widget_destroy(GTK_WIDGET(dialog));
128 break;
130 default:
132 gtk_widget_destroy(GTK_WIDGET(dialog));
133 subversion_data_free(data);
134 break;
139 static void
140 subversion_diff_dialog (GtkAction *action, Subversion *plugin, gchar *filename)
142 GtkBuilder *bxml = gtk_builder_new ();
143 GtkWidget *subversion_diff;
144 GtkWidget *diff_path_entry;
145 GtkWidget *diff_whole_project_check;
146 GtkWidget *button;
147 SubversionData *data;
148 GError* error = NULL;
150 if (!gtk_builder_add_from_file (bxml, GLADE_FILE, &error))
152 g_warning ("Couldn't load builder file: %s", error->message);
153 g_error_free (error);
156 subversion_diff = GTK_WIDGET (gtk_builder_get_object (bxml, "subversion_diff"));
157 diff_path_entry = GTK_WIDGET (gtk_builder_get_object (bxml, "diff_path_entry"));
158 diff_whole_project_check = GTK_WIDGET (gtk_builder_get_object (bxml,
159 "diff_whole_project_check"));
160 data = subversion_data_new (plugin, bxml);
162 g_object_set_data (G_OBJECT (diff_whole_project_check), "fileentry",
163 diff_path_entry);
165 if (filename)
166 gtk_entry_set_text (GTK_ENTRY (diff_path_entry), filename);
169 g_signal_connect(G_OBJECT (diff_whole_project_check), "toggled",
170 G_CALLBACK (on_whole_project_toggled),
171 plugin);
172 init_whole_project (plugin, diff_whole_project_check, !filename);
174 button = GTK_WIDGET (gtk_builder_get_object (bxml, BROWSE_BUTTON_DIFF_DIALOG));
175 g_signal_connect(G_OBJECT(button), "clicked",
176 G_CALLBACK(on_subversion_browse_button_clicked), diff_path_entry);
178 g_signal_connect (G_OBJECT (subversion_diff), "response",
179 G_CALLBACK (on_subversion_diff_response),
180 data);
182 gtk_widget_show (subversion_diff);
185 void
186 on_menu_subversion_diff (GtkAction* action, Subversion* plugin)
188 subversion_diff_dialog (action, plugin, NULL);
191 void
192 on_fm_subversion_diff (GtkAction *action, Subversion *plugin)
194 subversion_show_diff (plugin->fm_current_filename, TRUE, FALSE, plugin);