[anjuta] git: Add support for git checkout -f



commit 9ca931fce8db524a434bf7e109286a9b13f18082
Author: James Liggett <jrliggett cox net>
Date:   Mon Jul 13 18:11:12 2009 -0700

    git: Add support for git checkout -f

 plugins/git/anjuta-git.ui                |   34 +++++++++++++++++++++++++++++
 plugins/git/git-checkout-files-command.c |   11 +++++++-
 plugins/git/git-checkout-files-command.h |    3 +-
 plugins/git/git-checkout-files-dialog.c  |   35 +++++++++++++++++++++++++++++-
 4 files changed, 79 insertions(+), 4 deletions(-)
---
diff --git a/plugins/git/anjuta-git.ui b/plugins/git/anjuta-git.ui
index cbccd30..6bb082f 100644
--- a/plugins/git/anjuta-git.ui
+++ b/plugins/git/anjuta-git.ui
@@ -1896,6 +1896,40 @@
                 <property name="position">2</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkFrame" id="frame53">
+                <property name="visible">True</property>
+                <property name="label_xalign">0</property>
+                <property name="shadow_type">none</property>
+                <child>
+                  <object class="GtkAlignment" id="alignment53">
+                    <property name="visible">True</property>
+                    <property name="left_padding">12</property>
+                    <child>
+                      <object class="GtkCheckButton" id="checkout_all_check">
+                        <property name="label" translatable="yes">Check out all local changes</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="draw_indicator">True</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+                <child type="label">
+                  <object class="GtkLabel" id="label64">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">&lt;b&gt;Options&lt;/b&gt;</property>
+                    <property name="use_markup">True</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">3</property>
+              </packing>
+            </child>
           </object>
           <packing>
             <property name="position">1</property>
diff --git a/plugins/git/git-checkout-files-command.c b/plugins/git/git-checkout-files-command.c
index c198969..2d90298 100644
--- a/plugins/git/git-checkout-files-command.c
+++ b/plugins/git/git-checkout-files-command.c
@@ -27,6 +27,7 @@
 struct _GitCheckoutFilesCommandPriv
 {
 	GList *paths;
+	gboolean checkout_all;
 };
 
 G_DEFINE_TYPE (GitCheckoutFilesCommand, git_checkout_files_command, GIT_TYPE_COMMAND);
@@ -39,7 +40,11 @@ git_checkout_files_command_run (AnjutaCommand *command)
 	self = GIT_CHECKOUT_FILES_COMMAND (command);
 	
 	git_command_add_arg (GIT_COMMAND (self), "checkout");
-	git_command_add_list_to_args (GIT_COMMAND (self), self->priv->paths);
+
+	if (self->priv->checkout_all)
+		git_command_add_arg (GIT_COMMAND (self), "-f");
+	else
+		git_command_add_list_to_args (GIT_COMMAND (self), self->priv->paths);
 	
 	return 0;
 }
@@ -77,7 +82,8 @@ git_checkout_files_command_class_init (GitCheckoutFilesCommandClass *klass)
 
 
 GitCheckoutFilesCommand *
-git_checkout_files_command_new (const gchar *working_directory, GList *paths)
+git_checkout_files_command_new (const gchar *working_directory, GList *paths,
+								gboolean checkout_all)
 {
 	GitCheckoutFilesCommand *self;
 	
@@ -86,6 +92,7 @@ git_checkout_files_command_new (const gchar *working_directory, GList *paths)
 						 NULL);
 	
 	self->priv->paths = git_command_copy_string_list (paths);
+	self->priv->checkout_all = checkout_all;
 	
 	return self;
 }
diff --git a/plugins/git/git-checkout-files-command.h b/plugins/git/git-checkout-files-command.h
index e859359..d9e2b70 100644
--- a/plugins/git/git-checkout-files-command.h
+++ b/plugins/git/git-checkout-files-command.h
@@ -55,7 +55,8 @@ struct _GitCheckoutFilesCommand
 
 GType git_checkout_files_command_get_type (void) G_GNUC_CONST;
 GitCheckoutFilesCommand *git_checkout_files_command_new (const gchar *working_directory,
-														 GList *paths);
+														 GList *paths,
+														 gboolean checkout_all);
 										  
 
 G_END_DECLS
diff --git a/plugins/git/git-checkout-files-dialog.c b/plugins/git/git-checkout-files-dialog.c
index 050a21c..97b6e02 100644
--- a/plugins/git/git-checkout-files-dialog.c
+++ b/plugins/git/git-checkout-files-dialog.c
@@ -46,15 +46,19 @@ on_checkout_files_dialog_response (GtkDialog *dialog, gint response_id,
 								   GitUIData *data)
 {
 	GtkWidget *checkout_status_view;
+	GtkWidget *checkout_all_check;
 	GList *selected_paths;
 	GitCheckoutFilesCommand *checkout_files_command;
 	
 	if (response_id == GTK_RESPONSE_OK)
 	{	
 		checkout_status_view = GTK_WIDGET (gtk_builder_get_object (data->bxml, "checkout_status_view"));
+		checkout_all_check = GTK_WIDGET (gtk_builder_get_object (data->bxml, 
+																 "checkout_all_check"));
 		selected_paths = anjuta_vcs_status_tree_view_get_selected (ANJUTA_VCS_STATUS_TREE_VIEW (checkout_status_view));
 		checkout_files_command = git_checkout_files_command_new (data->plugin->project_root_directory,
-																 selected_paths);
+																 selected_paths,
+																 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (checkout_all_check)));
 		
 		git_command_free_string_list (selected_paths);
 		
@@ -70,6 +74,28 @@ on_checkout_files_dialog_response (GtkDialog *dialog, gint response_id,
 }
 
 static void
+on_checkout_all_check_toggled (GtkToggleButton *toggle_button,
+							   GitUIData *data)
+{
+	GtkWidget *checkout_select_all_button;
+	GtkWidget *checkout_clear_button;
+	GtkWidget *checkout_status_view;
+	gboolean active;
+
+	checkout_select_all_button = GTK_WIDGET (gtk_builder_get_object (data->bxml, 
+																	 "checkout_select_all_button"));
+	checkout_clear_button = GTK_WIDGET (gtk_builder_get_object (data->bxml, 
+																"checkout_clear_button"));
+	checkout_status_view = GTK_WIDGET (gtk_builder_get_object (data->bxml, 
+									   "checkout_status_view"));
+	active = gtk_toggle_button_get_active (toggle_button);
+
+	gtk_widget_set_sensitive (checkout_select_all_button, !active);
+	gtk_widget_set_sensitive (checkout_clear_button, !active);
+	gtk_widget_set_sensitive (checkout_status_view, !active);
+}
+
+static void
 checkout_files_dialog (Git *plugin)
 {
 	GtkBuilder *bxml;
@@ -80,6 +106,7 @@ checkout_files_dialog (Git *plugin)
 	GtkWidget *checkout_clear_button;
 	GtkWidget *checkout_status_view;
 	GtkWidget *checkout_status_progress_bar;
+	GtkWidget *checkout_all_check;
 	GitStatusCommand *status_command;
 	GitUIData *data;
 	
@@ -98,6 +125,8 @@ checkout_files_dialog (Git *plugin)
 	checkout_clear_button = GTK_WIDGET (gtk_builder_get_object (bxml, "checkout_clear_button"));
 	checkout_status_view = GTK_WIDGET (gtk_builder_get_object (bxml, "checkout_status_view"));
 	checkout_status_progress_bar = GTK_WIDGET (gtk_builder_get_object (bxml, "checkout_status_progress_bar"));
+	checkout_all_check = GTK_WIDGET (gtk_builder_get_object (bxml, 
+															 "checkout_all_check"));
 	
 	status_command = git_status_command_new (plugin->project_root_directory,
 											 GIT_STATUS_SECTION_NOT_UPDATED);
@@ -135,6 +164,10 @@ checkout_files_dialog (Git *plugin)
 	anjuta_command_start (ANJUTA_COMMAND (status_command));
 	
 	data = git_ui_data_new (plugin, bxml);
+
+	g_signal_connect (G_OBJECT (checkout_all_check), "toggled",
+					  G_CALLBACK (on_checkout_all_check_toggled),
+					  data);
 	
 	g_signal_connect(G_OBJECT (dialog), "response", 
 					 G_CALLBACK (on_checkout_files_dialog_response), 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]