[anjuta] Add support for applying patches from mailbox files in Git.



commit 9e5688434cd478d2312cb3f45222cf4f7c1c207d
Author: James Liggett <jrliggett cox net>
Date:   Sat May 9 21:37:13 2009 -0700

    Add support for applying patches from mailbox files in Git.
    
    This makes committers' lives easier by automatically creating commits that have the author's
    information in them, so it doesn't have to be put in manually.
---
 plugins/git/Makefile.am                          |    8 +-
 plugins/git/anjuta-git.glade                     |  136 ++++++++++++++++++++++
 plugins/git/anjuta-git.ui                        |   18 +++-
 plugins/git/git-apply-mailbox-command.c          |  101 ++++++++++++++++
 plugins/git/git-apply-mailbox-command.h          |   63 ++++++++++
 plugins/git/git-apply-mailbox-continue-command.c |  106 +++++++++++++++++
 plugins/git/git-apply-mailbox-continue-command.h |   69 +++++++++++
 plugins/git/git-apply-mailbox-dialog.c           |  136 ++++++++++++++++++++++
 plugins/git/git-apply-mailbox-dialog.h           |   37 ++++++
 plugins/git/plugin.c                             |   50 ++++++++
 10 files changed, 721 insertions(+), 3 deletions(-)

diff --git a/plugins/git/Makefile.am b/plugins/git/Makefile.am
index a6e7272..7d6b322 100644
--- a/plugins/git/Makefile.am
+++ b/plugins/git/Makefile.am
@@ -185,7 +185,13 @@ libanjuta_git_la_SOURCES = \
 	git-push-command.c \
 	git-push-command.h \
 	git-push-dialog.c \
-	git-push-dialog.h
+	git-push-dialog.h \
+	git-apply-mailbox-command.c \
+	git-apply-mailbox-command.h \
+	git-apply-mailbox-continue-command.c \
+	git-apply-mailbox-continue-command.h \
+	git-apply-mailbox-dialog.c \
+	git-apply-mailbox-dialog.h
 
 libanjuta_git_la_LDFLAGS = $(ANJUTA_PLUGIN_LDFLAGS)
 
diff --git a/plugins/git/anjuta-git.glade b/plugins/git/anjuta-git.glade
index 9f4c0a0..cd61525 100644
--- a/plugins/git/anjuta-git.glade
+++ b/plugins/git/anjuta-git.glade
@@ -4174,4 +4174,140 @@
       </widget>
     </child>
   </widget>
+  <widget class="GtkDialog" id="apply_mailbox_dialog">
+    <property name="border_width">5</property>
+    <property name="title" translatable="yes">Apply mailbox files</property>
+    <property name="window_position">center</property>
+    <property name="type_hint">normal</property>
+    <property name="has_separator">False</property>
+    <child internal-child="vbox">
+      <widget class="GtkVBox" id="dialog-vbox22">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">2</property>
+        <child>
+          <widget class="GtkVBox" id="vbox1">
+            <property name="visible">True</property>
+            <property name="orientation">vertical</property>
+            <child>
+              <widget class="GtkFrame" id="frame1">
+                <property name="visible">True</property>
+                <property name="label_xalign">0</property>
+                <property name="shadow_type">none</property>
+                <child>
+                  <widget class="GtkAlignment" id="alignment1">
+                    <property name="visible">True</property>
+                    <property name="left_padding">12</property>
+                    <child>
+                      <widget class="GtkFileChooserButton" id="apply_mailbox_file_chooser_button">
+                        <property name="width_request">400</property>
+                        <property name="visible">True</property>
+                        <property name="title" translatable="yes">Select Mailbox File</property>
+                      </widget>
+                    </child>
+                  </widget>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label1">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">&lt;b&gt;Mailbox file containing patches:&lt;/b&gt;</property>
+                    <property name="use_markup">True</property>
+                  </widget>
+                  <packing>
+                    <property name="type">label_item</property>
+                  </packing>
+                </child>
+              </widget>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkFrame" id="frame2">
+                <property name="visible">True</property>
+                <property name="label_xalign">0</property>
+                <property name="shadow_type">none</property>
+                <child>
+                  <widget class="GtkAlignment" id="alignment2">
+                    <property name="visible">True</property>
+                    <property name="left_padding">12</property>
+                    <child>
+                      <widget class="GtkCheckButton" id="apply_mailbox_signoff_check">
+                        <property name="label" translatable="yes">Add signed off by line</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="draw_indicator">True</property>
+                      </widget>
+                    </child>
+                  </widget>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label2">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">&lt;b&gt;Options&lt;/b&gt;</property>
+                    <property name="use_markup">True</property>
+                  </widget>
+                  <packing>
+                    <property name="type">label_item</property>
+                  </packing>
+                </child>
+              </widget>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <widget class="GtkHButtonBox" id="dialog-action_area22">
+            <property name="visible">True</property>
+            <property name="layout_style">end</property>
+            <child>
+              <widget class="GtkButton" id="button1">
+                <property name="label" translatable="yes">gtk-cancel</property>
+                <property name="response_id">-6</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </widget>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkButton" id="button2">
+                <property name="label" translatable="yes">gtk-ok</property>
+                <property name="response_id">-5</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="use_stock">True</property>
+              </widget>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
 </glade-interface>
diff --git a/plugins/git/anjuta-git.ui b/plugins/git/anjuta-git.ui
index c57fd17..d4af9e2 100644
--- a/plugins/git/anjuta-git.ui
+++ b/plugins/git/anjuta-git.ui
@@ -17,8 +17,22 @@
   				</placeholder>
   				<menuitem name="Push..." action="ActionGitPush" />
   				<menuitem name="Pull..." action="ActionGitPull" />
-				<menuitem name="Create patch series..." action="ActionGitCreatePatchSeries" />
-				<menuitem name="Diff uncommitted changes" action="ActionGitDiffUncommitted" />
+  				<menuitem name="Diff uncommitted changes" action="ActionGitDiffUncommitted" />
+  				<separator />
+  				<placeholder name="PlaceholderPatchMenu">
+  					<menu name="Patches" action="ActionMenuGitPatches">
+  						<menuitem name="Create patch series..." action="ActionGitCreatePatchSeries" />
+  						<placeholder name="PlaceholderApplyMailboxMenu">
+  							<menu name="Apply from mailbox files" action="ActionMenuGitApplyMailboxFiles">
+  								<menuitem name="Apply" action="ActionGitApplyMailboxApply" />
+  								<separator />
+  								<menuitem name="Continue with resolved conflicts" action="ActionGitApplyMailboxContinue" />
+  								<menuitem name="Skip current patch" action="ActionGitApplyMailboxSkip" />
+  								<menuitem name="Abort" action="ActionGitApplyMailboxAbort" />
+  							</menu> 
+  						</placeholder>
+  					</menu>
+  				</placeholder>
 				<separator />
 				<placeholder name="PlaceholderBranches">
 					<menu name="BranchesMenu" action="ActionMenuGitBranches">
diff --git a/plugins/git/git-apply-mailbox-command.c b/plugins/git/git-apply-mailbox-command.c
new file mode 100644
index 0000000..67db456
--- /dev/null
+++ b/plugins/git/git-apply-mailbox-command.c
@@ -0,0 +1,101 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) James Liggett 2008 <jrliggett cox net>
+ * 
+ * anjuta is free software.
+ * 
+ * You may redistribute it and/or modify it under the terms of the
+ * GNU General Public License, as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ * 
+ * anjuta is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with anjuta.  If not, write to:
+ * 	The Free Software Foundation, Inc.,
+ * 	51 Franklin Street, Fifth Floor
+ * 	Boston, MA  02110-1301, USA.
+ */
+
+#include "git-apply-mailbox-command.h"
+
+struct _GitApplyMailboxCommandPriv
+{
+	gchar *path;
+	gboolean add_signoff;
+};
+
+G_DEFINE_TYPE (GitApplyMailboxCommand, git_apply_mailbox_command, 
+			   GIT_TYPE_COMMAND);
+
+static void
+git_apply_mailbox_command_init (GitApplyMailboxCommand *self)
+{
+	self->priv = g_new0 (GitApplyMailboxCommandPriv, 1);
+}
+
+static void
+git_apply_mailbox_command_finalize (GObject *object)
+{
+	GitApplyMailboxCommand *self;
+	
+	self = GIT_APPLY_MAILBOX_COMMAND (object);
+	
+	g_free (self->priv->path);
+	g_free (self->priv);
+
+	G_OBJECT_CLASS (git_apply_mailbox_command_parent_class)->finalize (object);
+}
+
+static guint
+git_apply_mailbox_command_run (AnjutaCommand *command)
+{
+	GitApplyMailboxCommand *self;
+	
+	self = GIT_APPLY_MAILBOX_COMMAND (command);
+	
+	git_command_add_arg (GIT_COMMAND (command), "am");
+	
+	if (self->priv->add_signoff)
+		git_command_add_arg (GIT_COMMAND (command), "--signoff");
+
+	git_command_add_arg (GIT_COMMAND (command), self->priv->path);
+	
+	return 0;
+}
+
+static void
+git_apply_mailbox_command_class_init (GitApplyMailboxCommandClass *klass)
+{
+	GObjectClass* object_class = G_OBJECT_CLASS (klass);
+	GitCommandClass* parent_class = GIT_COMMAND_CLASS (klass);
+	AnjutaCommandClass* command_class = ANJUTA_COMMAND_CLASS (klass);
+
+	object_class->finalize = git_apply_mailbox_command_finalize;
+	parent_class->output_handler = git_command_send_output_to_info;
+	command_class->run = git_apply_mailbox_command_run;
+}
+
+
+GitApplyMailboxCommand *
+git_apply_mailbox_command_new (const gchar *working_directory, 
+							  const gchar *path,
+							  gboolean add_signoff)
+{
+	GitApplyMailboxCommand *self;
+	
+	self = g_object_new (GIT_TYPE_APPLY_MAILBOX_COMMAND, 
+						 "working-directory", working_directory,
+						 "single-line-output", TRUE,
+						 NULL);
+	
+	self->priv->path = g_strdup (path);
+	self->priv->add_signoff = add_signoff;
+	
+	return self;
+}
diff --git a/plugins/git/git-apply-mailbox-command.h b/plugins/git/git-apply-mailbox-command.h
new file mode 100644
index 0000000..408f5f7
--- /dev/null
+++ b/plugins/git/git-apply-mailbox-command.h
@@ -0,0 +1,63 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) James Liggett 2008 <jrliggett cox net>
+ * 
+ * anjuta is free software.
+ * 
+ * You may redistribute it and/or modify it under the terms of the
+ * GNU General Public License, as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ * 
+ * anjuta is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with anjuta.  If not, write to:
+ * 	The Free Software Foundation, Inc.,
+ * 	51 Franklin Street, Fifth Floor
+ * 	Boston, MA  02110-1301, USA.
+ */
+
+#ifndef _GIT_APPLY_MAILBOX_COMMAND_H_
+#define _GIT_APPLY_MAILBOX_COMMAND_H_
+
+#include <glib-object.h>
+#include "git-command.h"
+
+G_BEGIN_DECLS
+
+#define GIT_TYPE_APPLY_MAILBOX_COMMAND             (git_apply_mailbox_command_get_type ())
+#define GIT_APPLY_MAILBOX_COMMAND(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIT_TYPE_APPLY_MAILBOX_COMMAND, GitApplyMailboxCommand))
+#define GIT_APPLY_MAILBOX_COMMAND_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GIT_TYPE_APPLY_MAILBOX_COMMAND, GitApplyMailboxCommandClass))
+#define GIT_IS_APPLY_MAILBOX_COMMAND(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIT_TYPE_APPLY_MAILBOX_COMMAND))
+#define GIT_IS_APPLY_MAILBOX_COMMAND_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GIT_TYPE_APPLY_MAILBOX_COMMAND))
+#define GIT_APPLY_MAILBOX_COMMAND_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GIT_TYPE_APPLY_MAILBOX_COMMAND, GitApplyMailboxCommandClass))
+
+typedef struct _GitApplyMailboxCommandClass GitApplyMailboxCommandClass;
+typedef struct _GitApplyMailboxCommand GitApplyMailboxCommand;
+typedef struct _GitApplyMailboxCommandPriv GitApplyMailboxCommandPriv;
+
+struct _GitApplyMailboxCommandClass
+{
+	GitCommandClass parent_class;
+};
+
+struct _GitApplyMailboxCommand
+{
+	GitCommand parent_instance;
+	
+	GitApplyMailboxCommandPriv *priv;
+};
+
+GType git_apply_mailbox_command_get_type (void) G_GNUC_CONST;
+GitApplyMailboxCommand *git_apply_mailbox_command_new (const gchar *working_directory, 
+													   const gchar *path, 
+													   gboolean add_signoff);
+
+G_END_DECLS
+
+#endif /* _GIT_APPLY_MAILBOX_COMMAND_H_ */
diff --git a/plugins/git/git-apply-mailbox-continue-command.c b/plugins/git/git-apply-mailbox-continue-command.c
new file mode 100644
index 0000000..20ce7cc
--- /dev/null
+++ b/plugins/git/git-apply-mailbox-continue-command.c
@@ -0,0 +1,106 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) James Liggett 2008 <jrliggett cox net>
+ * 
+ * anjuta is free software.
+ * 
+ * You may redistribute it and/or modify it under the terms of the
+ * GNU General Public License, as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ * 
+ * anjuta is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with anjuta.  If not, write to:
+ * 	The Free Software Foundation, Inc.,
+ * 	51 Franklin Street, Fifth Floor
+ * 	Boston, MA  02110-1301, USA.
+ */
+
+#include "git-apply-mailbox-continue-command.h"
+
+struct _GitApplyMailboxContinueCommandPriv
+{
+	GitApplyMailboxContinueAction action;
+};
+
+G_DEFINE_TYPE (GitApplyMailboxContinueCommand, git_apply_mailbox_continue_command, 
+			   GIT_TYPE_COMMAND);
+
+static void
+git_apply_mailbox_continue_command_init (GitApplyMailboxContinueCommand *self)
+{
+	self->priv = g_new0 (GitApplyMailboxContinueCommandPriv, 1);
+}
+
+static void
+git_apply_mailbox_continue_command_finalize (GObject *object)
+{
+	GitApplyMailboxContinueCommand *self;
+	
+	self = GIT_APPLY_MAILBOX_CONTINUE_COMMAND (object);
+	
+	g_free (self->priv);
+
+	G_OBJECT_CLASS (git_apply_mailbox_continue_command_parent_class)->finalize (object);
+}
+
+static guint
+git_apply_mailbox_continue_command_run (AnjutaCommand *command)
+{
+	GitApplyMailboxContinueCommand *self;
+	
+	self = GIT_APPLY_MAILBOX_CONTINUE_COMMAND (command);
+	
+	git_command_add_arg (GIT_COMMAND (command), "am");
+	
+	switch (self->priv->action)
+	{
+		case GIT_APPLY_MAILBOX_CONTINUE_ACTION_RESOLVED:
+			git_command_add_arg (GIT_COMMAND (command), "--resolved");
+			break;
+		case GIT_APPLY_MAILBOX_CONTINUE_ACTION_SKIP:
+			git_command_add_arg (GIT_COMMAND (command), "--skip");
+			break;
+		case GIT_APPLY_MAILBOX_CONTINUE_ACTION_ABORT:
+			git_command_add_arg (GIT_COMMAND (command), "--abort");
+			break;
+		default:
+			break;
+	}
+	
+	return 0;
+}
+
+static void
+git_apply_mailbox_continue_command_class_init (GitApplyMailboxContinueCommandClass *klass)
+{
+	GObjectClass* object_class = G_OBJECT_CLASS (klass);
+	GitCommandClass* parent_class = GIT_COMMAND_CLASS (klass);
+	AnjutaCommandClass* command_class = ANJUTA_COMMAND_CLASS (klass);
+
+	object_class->finalize = git_apply_mailbox_continue_command_finalize;
+	parent_class->output_handler = git_command_send_output_to_info;
+	command_class->run = git_apply_mailbox_continue_command_run;
+}
+
+GitApplyMailboxContinueCommand *
+git_apply_mailbox_continue_command_new (const gchar *working_directory, 
+								 GitApplyMailboxContinueAction action)
+{
+	GitApplyMailboxContinueCommand *self;
+	
+	self = g_object_new (GIT_TYPE_APPLY_MAILBOX_CONTINUE_COMMAND,
+						 "working-directory", working_directory,
+						 "single-line-output", TRUE,
+						 NULL);
+	
+	self->priv->action = action;
+	
+	return self;
+}
diff --git a/plugins/git/git-apply-mailbox-continue-command.h b/plugins/git/git-apply-mailbox-continue-command.h
new file mode 100644
index 0000000..413fb01
--- /dev/null
+++ b/plugins/git/git-apply-mailbox-continue-command.h
@@ -0,0 +1,69 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) James Liggett 2008 <jrliggett cox net>
+ * 
+ * anjuta is free software.
+ * 
+ * You may redistribute it and/or modify it under the terms of the
+ * GNU General Public License, as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ * 
+ * anjuta is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with anjuta.  If not, write to:
+ * 	The Free Software Foundation, Inc.,
+ * 	51 Franklin Street, Fifth Floor
+ * 	Boston, MA  02110-1301, USA.
+ */
+
+#ifndef _GIT_APPLY_MAILBOX_CONTINUE_COMMAND_H_
+#define _GIT_APPLY_MAILBOX_CONTINUE_COMMAND_H_
+
+#include <glib-object.h>
+#include "git-command.h"
+
+G_BEGIN_DECLS
+
+#define GIT_TYPE_APPLY_MAILBOX_CONTINUE_COMMAND             (git_apply_mailbox_continue_command_get_type ())
+#define GIT_APPLY_MAILBOX_CONTINUE_COMMAND(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIT_TYPE_APPLY_MAILBOX_CONTINUE_COMMAND, GitApplyMailboxContinueCommand))
+#define GIT_APPLY_MAILBOX_CONTINUE_COMMAND_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GIT_TYPE_APPLY_MAILBOX_CONTINUE_COMMAND, GitApplyMailboxContinueCommandClass))
+#define GIT_IS_APPLY_MAILBOX_CONTINUE_COMMAND(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIT_TYPE_APPLY_MAILBOX_CONTINUE_COMMAND))
+#define GIT_IS_APPLY_MAILBOX_CONTINUE_COMMAND_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GIT_TYPE_APPLY_MAILBOX_CONTINUE_COMMAND))
+#define GIT_APPLY_MAILBOX_CONTINUE_COMMAND_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GIT_TYPE_APPLY_MAILBOX_CONTINUE_COMMAND, GitApplyMailboxContinueCommandClass))
+
+typedef struct _GitApplyMailboxContinueCommandClass GitApplyMailboxContinueCommandClass;
+typedef struct _GitApplyMailboxContinueCommand GitApplyMailboxContinueCommand;
+typedef struct _GitApplyMailboxContinueCommandPriv GitApplyMailboxContinueCommandPriv;
+
+struct _GitApplyMailboxContinueCommandClass
+{
+	GitCommandClass parent_class;
+};
+
+struct _GitApplyMailboxContinueCommand
+{
+	GitCommand parent_instance;
+	
+	GitApplyMailboxContinueCommandPriv *priv;
+};
+
+typedef enum
+{
+	GIT_APPLY_MAILBOX_CONTINUE_ACTION_RESOLVED,
+	GIT_APPLY_MAILBOX_CONTINUE_ACTION_SKIP,
+	GIT_APPLY_MAILBOX_CONTINUE_ACTION_ABORT
+} GitApplyMailboxContinueAction;
+
+GType git_apply_mailbox_continue_command_get_type (void) G_GNUC_CONST;
+GitApplyMailboxContinueCommand *git_apply_mailbox_continue_command_new (const gchar *working_directory, 
+																		GitApplyMailboxContinueAction action);
+
+G_END_DECLS
+
+#endif /* _GIT_REBASE_CONTINUE_COMMAND_H_ */
diff --git a/plugins/git/git-apply-mailbox-dialog.c b/plugins/git/git-apply-mailbox-dialog.c
new file mode 100644
index 0000000..593f489
--- /dev/null
+++ b/plugins/git/git-apply-mailbox-dialog.c
@@ -0,0 +1,136 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) James Liggett 2008 <jrliggett cox net>
+ * 
+ * anjuta is free software.
+ * 
+ * You may redistribute it and/or modify it under the terms of the
+ * GNU General Public License, as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ * 
+ * anjuta is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with anjuta.  If not, write to:
+ * 	The Free Software Foundation, Inc.,
+ * 	51 Franklin Street, Fifth Floor
+ * 	Boston, MA  02110-1301, USA.
+ */
+
+#include "git-apply-mailbox-dialog.h"
+
+static void
+on_apply_mailbox_dialog_response (GtkDialog *dialog, gint response_id, 
+								  GitUIData *data)
+{
+	GtkWidget *apply_mailbox_file_chooser_button;
+	GtkWidget *apply_mailbox_signoff_check;
+	gchar *path;
+	GitApplyMailboxCommand *apply_mailbox_command;
+	
+	if (response_id == GTK_RESPONSE_OK)
+	{
+		apply_mailbox_file_chooser_button = glade_xml_get_widget (data->gxml,
+		                                                          "apply_mailbox_file_chooser_button");
+		apply_mailbox_signoff_check = glade_xml_get_widget (data->gxml,
+		                                                    "apply_mailbox_signoff_check");
+		path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (apply_mailbox_file_chooser_button));
+
+		if (git_check_input (GTK_WIDGET (dialog), apply_mailbox_file_chooser_button, path, 
+							 _("Please select a mailbox file.")))
+		{
+
+			apply_mailbox_command = git_apply_mailbox_command_new (data->plugin->project_root_directory,
+			                                                       path,
+			                                                       gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (apply_mailbox_signoff_check)));
+
+			g_free (path);
+
+			git_create_message_view (data->plugin);
+
+			g_signal_connect (G_OBJECT (apply_mailbox_command), "command-finished",
+			                  G_CALLBACK (on_git_command_finished),
+			                  data->plugin);
+
+			g_signal_connect (G_OBJECT (apply_mailbox_command), "data-arrived",
+			                  G_CALLBACK (on_git_command_info_arrived),
+			                  data->plugin);
+
+			anjuta_command_start (ANJUTA_COMMAND (apply_mailbox_command));
+		}
+		else
+			return;
+	}
+	
+	gtk_widget_destroy (GTK_WIDGET (dialog));
+	git_ui_data_free (data);
+}
+
+static void
+apply_mailbox_dialog (Git *plugin)
+{
+	GladeXML *gxml;
+	GtkWidget *dialog;
+	GitUIData *data;
+	
+	gxml = glade_xml_new (GLADE_FILE, "apply_mailbox_dialog", NULL);
+	data = git_ui_data_new (plugin, gxml);
+	
+	dialog = glade_xml_get_widget (gxml, "apply_mailbox_dialog");
+	
+	g_signal_connect (G_OBJECT (dialog), "response", 
+					  G_CALLBACK (on_apply_mailbox_dialog_response), 
+					  data);
+	
+	gtk_widget_show_all (dialog);
+}
+
+static void
+apply_mailbox_continue (Git *plugin, GitApplyMailboxContinueAction action)
+{
+	GitApplyMailboxContinueCommand *apply_mailbox_command;
+	
+	git_create_message_view (plugin);
+	
+	apply_mailbox_command = git_apply_mailbox_continue_command_new (plugin->project_root_directory,
+																	action);
+	
+	g_signal_connect (G_OBJECT (apply_mailbox_command), "command-finished",
+					  G_CALLBACK (on_git_command_finished),
+					  plugin);
+	
+	g_signal_connect (G_OBJECT (apply_mailbox_command), "data-arrived",
+					  G_CALLBACK (on_git_command_info_arrived),
+					  plugin);
+	
+	anjuta_command_start (ANJUTA_COMMAND (apply_mailbox_command));
+}
+
+void
+on_menu_git_apply_mailbox_apply (GtkAction *action, Git *plugin)
+{
+	apply_mailbox_dialog (plugin);
+}
+
+void 
+on_menu_git_apply_mailbox_resolved (GtkAction *action, Git *plugin)
+{
+	apply_mailbox_continue (plugin, GIT_APPLY_MAILBOX_CONTINUE_ACTION_RESOLVED);
+}
+
+void 
+on_menu_git_apply_mailbox_skip (GtkAction *action, Git *plugin)
+{
+	apply_mailbox_continue (plugin, GIT_APPLY_MAILBOX_CONTINUE_ACTION_SKIP);
+}
+
+void 
+on_menu_git_apply_mailbox_abort (GtkAction *action, Git *plugin)
+{
+	apply_mailbox_continue (plugin, GIT_APPLY_MAILBOX_CONTINUE_ACTION_ABORT);
+}
diff --git a/plugins/git/git-apply-mailbox-dialog.h b/plugins/git/git-apply-mailbox-dialog.h
new file mode 100644
index 0000000..c6c359d
--- /dev/null
+++ b/plugins/git/git-apply-mailbox-dialog.h
@@ -0,0 +1,37 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * anjuta
+ * Copyright (C) James Liggett 2008 <jrliggett cox net>
+ * 
+ * anjuta is free software.
+ * 
+ * You may redistribute it and/or modify it under the terms of the
+ * GNU General Public License, as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ * 
+ * anjuta is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with anjuta.  If not, write to:
+ * 	The Free Software Foundation, Inc.,
+ * 	51 Franklin Street, Fifth Floor
+ * 	Boston, MA  02110-1301, USA.
+ */
+
+#ifndef _GIT_APPLY_MAILBOX_DIALOG_H
+#define _GIT_APPLY_MAILBOX_DIALOG_H
+
+#include "git-apply-mailbox-command.h"
+#include "git-apply-mailbox-continue-command.h"
+#include "git-ui-utils.h"
+
+void on_menu_git_apply_mailbox_apply (GtkAction *action, Git *plugin);
+void on_menu_git_apply_mailbox_resolved (GtkAction *action, Git *plugin);
+void on_menu_git_apply_mailbox_skip (GtkAction *action, Git *plugin);
+void on_menu_git_apply_mailbox_abort (GtkAction *action, Git *plugin);
+
+#endif
diff --git a/plugins/git/plugin.c b/plugins/git/plugin.c
index 8e44c36..005f9c7 100644
--- a/plugins/git/plugin.c
+++ b/plugins/git/plugin.c
@@ -46,6 +46,7 @@
 #include "git-pull-dialog.h"
 #include "git-cat-file-menu.h"
 #include "git-push-dialog.h"
+#include "git-apply-mailbox-dialog.h"
 
 #define UI_FILE PACKAGE_DATA_DIR"/ui/anjuta-git.ui"
 
@@ -333,6 +334,55 @@ static GtkActionEntry actions_git[] =
 		NULL,                                     /* short-cut */
 		NULL,                      /* Tooltip */
 		G_CALLBACK (on_menu_git_push)    /* action callback */
+	},
+	{
+		"ActionMenuGitPatches",                       /* Action name */
+		NULL,                            /* Stock icon, if any */
+		N_("Patches"),                     /* Display label */
+		NULL,                                     /* short-cut */
+		NULL,                      /* Tooltip */
+		NULL    /* action callback */
+	},
+	{
+		"ActionMenuGitApplyMailboxFiles",                       /* Action name */
+		NULL,                            /* Stock icon, if any */
+		N_("Apply mailbox files"),                     /* Display label */
+		NULL,                                     /* short-cut */
+		NULL,                      /* Tooltip */
+		NULL    /* action callback */
+	},
+	
+	{
+		"ActionGitApplyMailboxApply",                       /* Action name */
+		NULL,                            /* Stock icon, if any */
+		N_("_Apply..."),                     /* Display label */
+		NULL,                                     /* short-cut */
+		NULL,                      /* Tooltip */
+		G_CALLBACK (on_menu_git_apply_mailbox_apply)    /* action callback */
+	},
+	{
+		"ActionGitApplyMailboxContinue",                       /* Action name */
+		NULL,                            /* Stock icon, if any */
+		N_("_Continue with resolved conflicts"),                     /* Display label */
+		NULL,                                     /* short-cut */
+		NULL,                      /* Tooltip */
+		G_CALLBACK (on_menu_git_apply_mailbox_resolved)    /* action callback */
+	},
+	{
+		"ActionGitApplyMailboxSkip",                       /* Action name */
+		NULL,                            /* Stock icon, if any */
+		N_("_Skip current patch"),                     /* Display label */
+		NULL,                                     /* short-cut */
+		NULL,                      /* Tooltip */
+		G_CALLBACK (on_menu_git_apply_mailbox_skip)    /* action callback */
+	},
+	{
+		"ActionGitApplyMailboxAbort",                       /* Action name */
+		NULL,                            /* Stock icon, if any */
+		N_("_Abort"),                     /* Display label */
+		NULL,                                     /* short-cut */
+		NULL,                      /* Tooltip */
+		G_CALLBACK (on_menu_git_apply_mailbox_abort)    /* action callback */
 	}
 };
 



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