[gitg/wip/format-patch] Add "Get Patch" button to Diff View



commit e7bcf6f3f2183d0db5d1a9959a41c3c90ad41c67
Author: Sindhu S <sindhus live in>
Date:   Wed Aug 21 00:20:06 2013 +0530

    Add "Get Patch" button to Diff View

 libgitg/Makefile.am                       |    1 +
 libgitg/gitg-diff-view-request-patch.c    | 1110 +++++++++++++++++++++++++++++
 libgitg/gitg-diff-view-request-patch.vala |  108 +++
 libgitg/gitg-diff-view-request.vala       |    5 +
 libgitg/gitg-diff-view.vala               |    2 +
 libgitg/resources/diff-view.css           |    7 +
 libgitg/resources/diff-view.html          |    1 +
 libgitg/resources/diff-view.js            |    6 +
 8 files changed, 1240 insertions(+), 0 deletions(-)
---
diff --git a/libgitg/Makefile.am b/libgitg/Makefile.am
index cf6b892..277482f 100644
--- a/libgitg/Makefile.am
+++ b/libgitg/Makefile.am
@@ -58,6 +58,7 @@ VALA_FILES =                                  \
        gitg-diff-view.vala                     \
        gitg-diff-view-request.vala             \
        gitg-diff-view-request-resource.vala    \
+       gitg-diff-view-request-patch.vala       \
        gitg-diff-view-request-diff.vala        \
        gitg-repository-list-box.vala           \
        gitg-when-mapped.vala                   \
diff --git a/libgitg/gitg-diff-view-request-patch.c b/libgitg/gitg-diff-view-request-patch.c
new file mode 100644
index 0000000..2226386
--- /dev/null
+++ b/libgitg/gitg-diff-view-request-patch.c
@@ -0,0 +1,1110 @@
+/* gitg-diff-view-request-patch.c generated by valac 0.21.1.8-8f10-dirty, the Vala compiler
+ * generated from gitg-diff-view-request-patch.vala, do not modify */
+
+/*
+ * This file is part of gitg
+ *
+ * Copyright (C) 2012 - Sindhu S
+ *
+ * gitg is free software; you can 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.
+ *
+ * gitg 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 gitg. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gio/gio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <webkit2/webkit2.h>
+#include <libsoup/soup.h>
+#include <libgit2-glib/ggit.h>
+#include <glib/gstdio.h>
+#include <stdio.h>
+#include <gtk/gtk.h>
+
+
+#define GITG_TYPE_DIFF_VIEW_REQUEST (gitg_diff_view_request_get_type ())
+#define GITG_DIFF_VIEW_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GITG_TYPE_DIFF_VIEW_REQUEST, 
GitgDiffViewRequest))
+#define GITG_DIFF_VIEW_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GITG_TYPE_DIFF_VIEW_REQUEST, 
GitgDiffViewRequestClass))
+#define GITG_IS_DIFF_VIEW_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GITG_TYPE_DIFF_VIEW_REQUEST))
+#define GITG_IS_DIFF_VIEW_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), 
GITG_TYPE_DIFF_VIEW_REQUEST))
+#define GITG_DIFF_VIEW_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), 
GITG_TYPE_DIFF_VIEW_REQUEST, GitgDiffViewRequestClass))
+
+typedef struct _GitgDiffViewRequest GitgDiffViewRequest;
+typedef struct _GitgDiffViewRequestClass GitgDiffViewRequestClass;
+typedef struct _GitgDiffViewRequestPrivate GitgDiffViewRequestPrivate;
+
+#define GITG_TYPE_DIFF_VIEW (gitg_diff_view_get_type ())
+#define GITG_DIFF_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GITG_TYPE_DIFF_VIEW, GitgDiffView))
+#define GITG_DIFF_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GITG_TYPE_DIFF_VIEW, 
GitgDiffViewClass))
+#define GITG_IS_DIFF_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GITG_TYPE_DIFF_VIEW))
+#define GITG_IS_DIFF_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GITG_TYPE_DIFF_VIEW))
+#define GITG_DIFF_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GITG_TYPE_DIFF_VIEW, 
GitgDiffViewClass))
+
+typedef struct _GitgDiffView GitgDiffView;
+typedef struct _GitgDiffViewClass GitgDiffViewClass;
+
+#define GITG_TYPE_DIFF_VIEW_REQUEST_PATCH (gitg_diff_view_request_patch_get_type ())
+#define GITG_DIFF_VIEW_REQUEST_PATCH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GITG_TYPE_DIFF_VIEW_REQUEST_PATCH, GitgDiffViewRequestPatch))
+#define GITG_DIFF_VIEW_REQUEST_PATCH_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), 
GITG_TYPE_DIFF_VIEW_REQUEST_PATCH, GitgDiffViewRequestPatchClass))
+#define GITG_IS_DIFF_VIEW_REQUEST_PATCH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
GITG_TYPE_DIFF_VIEW_REQUEST_PATCH))
+#define GITG_IS_DIFF_VIEW_REQUEST_PATCH_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), 
GITG_TYPE_DIFF_VIEW_REQUEST_PATCH))
+#define GITG_DIFF_VIEW_REQUEST_PATCH_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), 
GITG_TYPE_DIFF_VIEW_REQUEST_PATCH, GitgDiffViewRequestPatchClass))
+
+typedef struct _GitgDiffViewRequestPatch GitgDiffViewRequestPatch;
+typedef struct _GitgDiffViewRequestPatchClass GitgDiffViewRequestPatchClass;
+typedef struct _GitgDiffViewRequestPatchPrivate GitgDiffViewRequestPatchPrivate;
+#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
+
+#define GITG_TYPE_COMMIT (gitg_commit_get_type ())
+#define GITG_COMMIT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GITG_TYPE_COMMIT, GitgCommit))
+#define GITG_COMMIT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GITG_TYPE_COMMIT, GitgCommitClass))
+#define GITG_IS_COMMIT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GITG_TYPE_COMMIT))
+#define GITG_IS_COMMIT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GITG_TYPE_COMMIT))
+#define GITG_COMMIT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GITG_TYPE_COMMIT, GitgCommitClass))
+
+typedef struct _GitgCommit GitgCommit;
+typedef struct _GitgCommitClass GitgCommitClass;
+#define __vala_GgitOId_free0(var) ((var == NULL) ? NULL : (var = (_vala_GgitOId_free (var), NULL)))
+#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
+#define _g_free0(var) (var = (g_free (var), NULL))
+#define __vala_GgitDiffPatch_free0(var) ((var == NULL) ? NULL : (var = (_vala_GgitDiffPatch_free (var), 
NULL)))
+#define __vala_GgitDiffDelta_free0(var) ((var == NULL) ? NULL : (var = (_vala_GgitDiffDelta_free (var), 
NULL)))
+#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
+typedef struct _Block6Data Block6Data;
+#define _gitg_diff_view_request_unref0(var) ((var == NULL) ? NULL : (var = (gitg_diff_view_request_unref 
(var), NULL)))
+#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
+
+struct _GitgDiffViewRequest {
+       GTypeInstance parent_instance;
+       volatile int ref_count;
+       GitgDiffViewRequestPrivate * priv;
+       GitgDiffView* d_view;
+       SoupURI* d_uri;
+       gchar* d_mimetype;
+       gint64 d_size;
+       WebKitURISchemeRequest* d_request;
+       gboolean d_hasView;
+};
+
+struct _GitgDiffViewRequestClass {
+       GTypeClass parent_class;
+       void (*finalize) (GitgDiffViewRequest *self);
+       GInputStream* (*run_async) (GitgDiffViewRequest* self, GCancellable* cancellable, GError** error);
+       void (*run_after_async) (GitgDiffViewRequest* self);
+       gint64 (*get_content_length) (GitgDiffViewRequest* self);
+       gchar* (*get_content_type) (GitgDiffViewRequest* self);
+};
+
+struct _GitgDiffViewRequestPatch {
+       GitgDiffViewRequest parent_instance;
+       GitgDiffViewRequestPatchPrivate * priv;
+};
+
+struct _GitgDiffViewRequestPatchClass {
+       GitgDiffViewRequestClass parent_class;
+};
+
+struct _GitgDiffViewRequestPatchPrivate {
+       GgitCommit* d_commit;
+};
+
+struct _Block6Data {
+       int _ref_count_;
+       GitgDiffViewRequestPatch * self;
+       GitgCommit* selected_commit;
+       GtkFileChooserDialog* chooser;
+};
+
+
+static gpointer gitg_diff_view_request_patch_parent_class = NULL;
+
+gpointer gitg_diff_view_request_ref (gpointer instance);
+void gitg_diff_view_request_unref (gpointer instance);
+GParamSpec* gitg_param_spec_diff_view_request (const gchar* name, const gchar* nick, const gchar* blurb, 
GType object_type, GParamFlags flags);
+void gitg_value_set_diff_view_request (GValue* value, gpointer v_object);
+void gitg_value_take_diff_view_request (GValue* value, gpointer v_object);
+gpointer gitg_value_get_diff_view_request (const GValue* value);
+GType gitg_diff_view_request_get_type (void) G_GNUC_CONST;
+GType gitg_diff_view_get_type (void) G_GNUC_CONST;
+GType gitg_diff_view_request_patch_get_type (void) G_GNUC_CONST;
+#define GITG_DIFF_VIEW_REQUEST_PATCH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), 
GITG_TYPE_DIFF_VIEW_REQUEST_PATCH, GitgDiffViewRequestPatchPrivate))
+enum  {
+       GITG_DIFF_VIEW_REQUEST_PATCH_DUMMY_PROPERTY
+};
+GitgDiffViewRequestPatch* gitg_diff_view_request_patch_new (GitgDiffView* view, WebKitURISchemeRequest* 
request, SoupURI* uri);
+GitgDiffViewRequestPatch* gitg_diff_view_request_patch_construct (GType object_type, GitgDiffView* view, 
WebKitURISchemeRequest* request, SoupURI* uri);
+GitgDiffViewRequest* gitg_diff_view_request_new (GitgDiffView* view, WebKitURISchemeRequest* request, 
SoupURI* uri);
+GitgDiffViewRequest* gitg_diff_view_request_construct (GType object_type, GitgDiffView* view, 
WebKitURISchemeRequest* request, SoupURI* uri);
+gboolean gitg_diff_view_request_get_has_view (GitgDiffViewRequest* self);
+GType gitg_commit_get_type (void) G_GNUC_CONST;
+GitgCommit* gitg_diff_view_get_commit (GitgDiffView* self);
+static void gitg_diff_view_request_patch_create_patch (GitgDiffViewRequestPatch* self, GitgCommit* 
selected_commit, GFile* file);
+static void _vala_GgitOId_free (GgitOId* self);
+GgitDiffList* gitg_commit_get_diff (GitgCommit* self, GgitDiffOptions* options);
+static void _vala_GgitDiffPatch_free (GgitDiffPatch* self);
+static void _vala_GgitDiffDelta_free (GgitDiffDelta* self);
+static void gitg_diff_view_request_patch_real_run_after_async (GitgDiffViewRequest* base);
+static Block6Data* block6_data_ref (Block6Data* _data6_);
+static void block6_data_unref (void * _userdata_);
+static void __lambda31_ (Block6Data* _data6_, GtkDialog* dialog, gint id);
+static void ___lambda31__gtk_dialog_response (GtkDialog* _sender, gint response_id, gpointer self);
+static void gitg_diff_view_request_patch_finalize (GitgDiffViewRequest* obj);
+
+
+static gpointer _g_object_ref0 (gpointer self) {
+#line 32 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       return self ? g_object_ref (self) : NULL;
+#line 169 "gitg-diff-view-request-patch.c"
+}
+
+
+GitgDiffViewRequestPatch* gitg_diff_view_request_patch_construct (GType object_type, GitgDiffView* view, 
WebKitURISchemeRequest* request, SoupURI* uri) {
+       GitgDiffViewRequestPatch* self = NULL;
+       GitgDiffView* _tmp0_ = NULL;
+       WebKitURISchemeRequest* _tmp1_ = NULL;
+       SoupURI* _tmp2_ = NULL;
+       gboolean _tmp3_ = FALSE;
+       gboolean _tmp4_ = FALSE;
+#line 26 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       g_return_val_if_fail (request != NULL, NULL);
+#line 26 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       g_return_val_if_fail (uri != NULL, NULL);
+#line 28 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp0_ = view;
+#line 28 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp1_ = request;
+#line 28 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp2_ = uri;
+#line 28 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       self = (GitgDiffViewRequestPatch*) gitg_diff_view_request_construct (object_type, _tmp0_, _tmp1_, 
_tmp2_);
+#line 30 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp3_ = gitg_diff_view_request_get_has_view ((GitgDiffViewRequest*) self);
+#line 30 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp4_ = _tmp3_;
+#line 30 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       if (_tmp4_) {
+#line 198 "gitg-diff-view-request-patch.c"
+               GitgDiffView* _tmp5_ = NULL;
+               GitgCommit* _tmp6_ = NULL;
+               GitgCommit* _tmp7_ = NULL;
+               GgitCommit* _tmp8_ = NULL;
+#line 32 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp5_ = view;
+#line 32 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp6_ = gitg_diff_view_get_commit (_tmp5_);
+#line 32 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp7_ = _tmp6_;
+#line 32 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp8_ = _g_object_ref0 ((GgitCommit*) _tmp7_);
+#line 32 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_object_unref0 (self->priv->d_commit);
+#line 32 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               self->priv->d_commit = _tmp8_;
+#line 35 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_object_unref0 (((GitgDiffViewRequest*) self)->d_view);
+#line 35 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               ((GitgDiffViewRequest*) self)->d_view = NULL;
+#line 36 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               ((GitgDiffViewRequest*) self)->d_hasView = FALSE;
+#line 221 "gitg-diff-view-request-patch.c"
+       }
+#line 26 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       return self;
+#line 225 "gitg-diff-view-request-patch.c"
+}
+
+
+GitgDiffViewRequestPatch* gitg_diff_view_request_patch_new (GitgDiffView* view, WebKitURISchemeRequest* 
request, SoupURI* uri) {
+#line 26 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       return gitg_diff_view_request_patch_construct (GITG_TYPE_DIFF_VIEW_REQUEST_PATCH, view, request, uri);
+#line 232 "gitg-diff-view-request-patch.c"
+}
+
+
+static void _vala_GgitOId_free (GgitOId* self) {
+#line 43 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       g_boxed_free (ggit_oid_get_type (), self);
+#line 239 "gitg-diff-view-request-patch.c"
+}
+
+
+static void _vala_GgitDiffPatch_free (GgitDiffPatch* self) {
+#line 62 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       g_boxed_free (ggit_diff_patch_get_type (), self);
+#line 246 "gitg-diff-view-request-patch.c"
+}
+
+
+static void _vala_GgitDiffDelta_free (GgitDiffDelta* self) {
+#line 62 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       g_boxed_free (ggit_diff_delta_get_type (), self);
+#line 253 "gitg-diff-view-request-patch.c"
+}
+
+
+static void gitg_diff_view_request_patch_create_patch (GitgDiffViewRequestPatch* self, GitgCommit* 
selected_commit, GFile* file) {
+       gchar* commit_message = NULL;
+       GitgCommit* _tmp0_ = NULL;
+       const gchar* _tmp1_ = NULL;
+       gchar* _tmp2_ = NULL;
+       gchar* sha1 = NULL;
+       GitgCommit* _tmp3_ = NULL;
+       GgitOId* _tmp4_ = NULL;
+       GgitOId* _tmp5_ = NULL;
+       gchar* _tmp6_ = NULL;
+       gchar* _tmp7_ = NULL;
+       gchar* legacydate = NULL;
+       gchar* _tmp8_ = NULL;
+       gchar* author = NULL;
+       GitgCommit* _tmp9_ = NULL;
+       GgitSignature* _tmp10_ = NULL;
+       GgitSignature* _tmp11_ = NULL;
+       const gchar* _tmp12_ = NULL;
+       gchar* _tmp13_ = NULL;
+       gchar* _tmp14_ = NULL;
+       gchar* author_email = NULL;
+       GitgCommit* _tmp15_ = NULL;
+       GgitSignature* _tmp16_ = NULL;
+       GgitSignature* _tmp17_ = NULL;
+       const gchar* _tmp18_ = NULL;
+       gchar* _tmp19_ = NULL;
+       gchar* _tmp20_ = NULL;
+       gchar* datetime = NULL;
+       GitgCommit* _tmp21_ = NULL;
+       GgitSignature* _tmp22_ = NULL;
+       GgitSignature* _tmp23_ = NULL;
+       GDateTime* _tmp24_ = NULL;
+       GDateTime* _tmp25_ = NULL;
+       gchar* _tmp26_ = NULL;
+       gchar* _tmp27_ = NULL;
+       gchar* patch_content = NULL;
+       gchar* _tmp28_ = NULL;
+       GError * _inner_error_ = NULL;
+#line 40 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       g_return_if_fail (self != NULL);
+#line 40 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       g_return_if_fail (selected_commit != NULL);
+#line 40 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       g_return_if_fail (file != NULL);
+#line 42 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp0_ = selected_commit;
+#line 42 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp1_ = ggit_commit_get_message ((GgitCommit*) _tmp0_);
+#line 42 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp2_ = g_strdup (_tmp1_);
+#line 42 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       commit_message = _tmp2_;
+#line 43 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp3_ = selected_commit;
+#line 43 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp4_ = ggit_object_get_id ((GgitObject*) _tmp3_);
+#line 43 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp5_ = _tmp4_;
+#line 43 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp6_ = ggit_oid_to_string (_tmp5_);
+#line 43 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp7_ = _tmp6_;
+#line 43 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       __vala_GgitOId_free0 (_tmp5_);
+#line 43 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       sha1 = _tmp7_;
+#line 44 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp8_ = g_strdup ("Mon Sep 17 00:00:00 2001");
+#line 44 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       legacydate = _tmp8_;
+#line 45 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp9_ = selected_commit;
+#line 45 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp10_ = ggit_commit_get_author ((GgitCommit*) _tmp9_);
+#line 45 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp11_ = _tmp10_;
+#line 45 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp12_ = ggit_signature_get_name (_tmp11_);
+#line 45 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp13_ = g_strdup (_tmp12_);
+#line 45 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp14_ = _tmp13_;
+#line 45 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _g_object_unref0 (_tmp11_);
+#line 45 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       author = _tmp14_;
+#line 46 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp15_ = selected_commit;
+#line 46 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp16_ = ggit_commit_get_author ((GgitCommit*) _tmp15_);
+#line 46 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp17_ = _tmp16_;
+#line 46 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp18_ = ggit_signature_get_email (_tmp17_);
+#line 46 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp19_ = g_strdup (_tmp18_);
+#line 46 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp20_ = _tmp19_;
+#line 46 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _g_object_unref0 (_tmp17_);
+#line 46 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       author_email = _tmp20_;
+#line 47 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp21_ = selected_commit;
+#line 47 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp22_ = ggit_commit_get_author ((GgitCommit*) _tmp21_);
+#line 47 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp23_ = _tmp22_;
+#line 47 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp24_ = ggit_signature_get_time (_tmp23_);
+#line 47 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp25_ = _tmp24_;
+#line 47 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp26_ = g_date_time_format (_tmp25_, "%a, %e %b %Y %T %z");
+#line 47 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp27_ = _tmp26_;
+#line 47 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _g_date_time_unref0 (_tmp25_);
+#line 47 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _g_object_unref0 (_tmp23_);
+#line 47 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       datetime = _tmp27_;
+#line 48 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp28_ = g_strdup ("");
+#line 48 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       patch_content = _tmp28_;
+#line 383 "gitg-diff-view-request-patch.c"
+       {
+               GgitDiffList* diff = NULL;
+               GitgCommit* _tmp29_ = NULL;
+               GgitDiffList* _tmp30_ = NULL;
+               GgitDiffPatch* patch = NULL;
+               GgitDiffDelta* delta = NULL;
+               gint number_of_deltas = 0;
+               GgitDiffList* _tmp31_ = NULL;
+               gint _tmp32_ = 0;
+               const gchar* _tmp33_ = NULL;
+               const gchar* _tmp34_ = NULL;
+               const gchar* _tmp35_ = NULL;
+               gchar* _tmp36_ = NULL;
+               gchar* _tmp37_ = NULL;
+               gchar* _tmp38_ = NULL;
+               const gchar* _tmp39_ = NULL;
+               const gchar* _tmp40_ = NULL;
+               const gchar* _tmp41_ = NULL;
+               gchar* _tmp42_ = NULL;
+               gchar* _tmp43_ = NULL;
+               gchar* _tmp44_ = NULL;
+               const gchar* _tmp45_ = NULL;
+               const gchar* _tmp46_ = NULL;
+               gchar* _tmp47_ = NULL;
+               gchar* _tmp48_ = NULL;
+               gchar* _tmp49_ = NULL;
+               const gchar* _tmp50_ = NULL;
+               const gchar* _tmp51_ = NULL;
+               gchar* _tmp52_ = NULL;
+               gchar* _tmp53_ = NULL;
+               gchar* _tmp54_ = NULL;
+               const gchar* _tmp70_ = NULL;
+               gchar* _tmp71_ = NULL;
+               const gchar* _tmp72_ = NULL;
+               gchar* _tmp73_ = NULL;
+               GFile* _tmp74_ = NULL;
+               gchar* _tmp75_ = NULL;
+               gchar* _tmp76_ = NULL;
+               const gchar* _tmp77_ = NULL;
+#line 51 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp29_ = selected_commit;
+#line 51 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp30_ = gitg_commit_get_diff (_tmp29_, NULL);
+#line 51 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               diff = _tmp30_;
+#line 54 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp31_ = diff;
+#line 54 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp32_ = ggit_diff_list_get_num_deltas (_tmp31_);
+#line 54 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               number_of_deltas = _tmp32_;
+#line 57 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp33_ = patch_content;
+#line 57 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp34_ = sha1;
+#line 57 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp35_ = legacydate;
+#line 57 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp36_ = g_strdup_printf ("From %s %s", _tmp34_, _tmp35_);
+#line 57 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp37_ = _tmp36_;
+#line 57 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp38_ = g_strconcat (_tmp33_, _tmp37_, NULL);
+#line 57 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_free0 (patch_content);
+#line 57 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               patch_content = _tmp38_;
+#line 57 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_free0 (_tmp37_);
+#line 58 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp39_ = patch_content;
+#line 58 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp40_ = author;
+#line 58 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp41_ = author_email;
+#line 58 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp42_ = g_strdup_printf ("\nFrom: %s <%s>", _tmp40_, _tmp41_);
+#line 58 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp43_ = _tmp42_;
+#line 58 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp44_ = g_strconcat (_tmp39_, _tmp43_, NULL);
+#line 58 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_free0 (patch_content);
+#line 58 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               patch_content = _tmp44_;
+#line 58 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_free0 (_tmp43_);
+#line 59 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp45_ = patch_content;
+#line 59 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp46_ = datetime;
+#line 59 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp47_ = g_strdup_printf ("\nDate: %s", _tmp46_);
+#line 59 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp48_ = _tmp47_;
+#line 59 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp49_ = g_strconcat (_tmp45_, _tmp48_, NULL);
+#line 59 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_free0 (patch_content);
+#line 59 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               patch_content = _tmp49_;
+#line 59 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_free0 (_tmp48_);
+#line 60 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp50_ = patch_content;
+#line 60 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp51_ = commit_message;
+#line 60 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp52_ = g_strdup_printf ("\nSubject: [PATCH] %s\n\n", _tmp51_);
+#line 60 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp53_ = _tmp52_;
+#line 60 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp54_ = g_strconcat (_tmp50_, _tmp53_, NULL);
+#line 60 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_free0 (patch_content);
+#line 60 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               patch_content = _tmp54_;
+#line 60 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_free0 (_tmp53_);
+#line 503 "gitg-diff-view-request-patch.c"
+               {
+                       gint i = 0;
+#line 61 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                       i = 0;
+#line 508 "gitg-diff-view-request-patch.c"
+                       {
+                               gboolean _tmp55_ = FALSE;
+#line 61 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                               _tmp55_ = TRUE;
+#line 61 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                               while (TRUE) {
+#line 515 "gitg-diff-view-request-patch.c"
+                                       gboolean _tmp56_ = FALSE;
+                                       gint _tmp58_ = 0;
+                                       gint _tmp59_ = 0;
+                                       GgitDiffList* _tmp60_ = NULL;
+                                       gint _tmp61_ = 0;
+                                       GgitDiffPatch* _tmp62_ = NULL;
+                                       GgitDiffDelta* _tmp63_ = NULL;
+                                       gchar* _tmp64_ = NULL;
+                                       GgitDiffPatch* _tmp65_ = NULL;
+                                       gchar* _tmp66_ = NULL;
+                                       const gchar* _tmp67_ = NULL;
+                                       gchar* _tmp68_ = NULL;
+                                       gchar* _tmp69_ = NULL;
+#line 61 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       _tmp56_ = _tmp55_;
+#line 61 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       if (!_tmp56_) {
+#line 533 "gitg-diff-view-request-patch.c"
+                                               gint _tmp57_ = 0;
+#line 61 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                               _tmp57_ = i;
+#line 61 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                               i = _tmp57_ + 1;
+#line 539 "gitg-diff-view-request-patch.c"
+                                       }
+#line 61 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       _tmp55_ = FALSE;
+#line 61 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       _tmp58_ = i;
+#line 61 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       _tmp59_ = number_of_deltas;
+#line 61 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       if (!(_tmp58_ < _tmp59_)) {
+#line 61 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                               break;
+#line 551 "gitg-diff-view-request-patch.c"
+                                       }
+#line 62 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       _tmp60_ = diff;
+#line 62 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       _tmp61_ = i;
+#line 62 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       ggit_diff_list_get_patch (_tmp60_, (gsize) _tmp61_, &_tmp62_, 
&_tmp63_, &_inner_error_);
+#line 62 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       __vala_GgitDiffPatch_free0 (patch);
+#line 62 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       patch = _tmp62_;
+#line 62 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       __vala_GgitDiffDelta_free0 (delta);
+#line 62 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       delta = _tmp63_;
+#line 62 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       if (_inner_error_ != NULL) {
+#line 62 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                               __vala_GgitDiffDelta_free0 (delta);
+#line 62 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                               __vala_GgitDiffPatch_free0 (patch);
+#line 62 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                               _g_object_unref0 (diff);
+#line 575 "gitg-diff-view-request-patch.c"
+                                               goto __catch27_g_error;
+                                       }
+#line 63 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       _tmp65_ = patch;
+#line 63 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       _tmp66_ = ggit_diff_patch_to_string (_tmp65_, &_inner_error_);
+#line 63 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       _tmp64_ = _tmp66_;
+#line 63 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       if (_inner_error_ != NULL) {
+#line 63 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                               __vala_GgitDiffDelta_free0 (delta);
+#line 63 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                               __vala_GgitDiffPatch_free0 (patch);
+#line 63 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                               _g_object_unref0 (diff);
+#line 592 "gitg-diff-view-request-patch.c"
+                                               goto __catch27_g_error;
+                                       }
+#line 63 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       _tmp67_ = patch_content;
+#line 63 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       _tmp68_ = _tmp64_;
+#line 63 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       _tmp69_ = g_strconcat (_tmp67_, _tmp68_, NULL);
+#line 63 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       _g_free0 (patch_content);
+#line 63 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       patch_content = _tmp69_;
+#line 63 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                                       _g_free0 (_tmp68_);
+#line 607 "gitg-diff-view-request-patch.c"
+                               }
+                       }
+               }
+#line 65 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp70_ = patch_content;
+#line 65 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp71_ = g_strconcat (_tmp70_, "--\n", NULL);
+#line 65 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_free0 (patch_content);
+#line 65 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               patch_content = _tmp71_;
+#line 66 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp72_ = patch_content;
+#line 66 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp73_ = g_strconcat (_tmp72_, "Gitg\n\n", NULL);
+#line 66 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_free0 (patch_content);
+#line 66 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               patch_content = _tmp73_;
+#line 68 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp74_ = file;
+#line 68 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp75_ = g_file_get_path (_tmp74_);
+#line 68 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp76_ = _tmp75_;
+#line 68 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp77_ = patch_content;
+#line 68 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               g_file_set_contents (_tmp76_, _tmp77_, (gssize) (-1), &_inner_error_);
+#line 68 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_free0 (_tmp76_);
+#line 68 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               if (_inner_error_ != NULL) {
+#line 68 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                       __vala_GgitDiffDelta_free0 (delta);
+#line 68 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                       __vala_GgitDiffPatch_free0 (patch);
+#line 68 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+                       _g_object_unref0 (diff);
+#line 647 "gitg-diff-view-request-patch.c"
+                       goto __catch27_g_error;
+               }
+#line 49 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               __vala_GgitDiffDelta_free0 (delta);
+#line 49 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               __vala_GgitDiffPatch_free0 (patch);
+#line 49 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_object_unref0 (diff);
+#line 656 "gitg-diff-view-request-patch.c"
+       }
+       goto __finally27;
+       __catch27_g_error:
+       {
+               GError* e = NULL;
+               FILE* _tmp78_ = NULL;
+               GError* _tmp79_ = NULL;
+               const gchar* _tmp80_ = NULL;
+               gchar* _tmp81_ = NULL;
+               gchar* _tmp82_ = NULL;
+#line 49 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               e = _inner_error_;
+#line 49 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _inner_error_ = NULL;
+#line 73 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp78_ = stdout;
+#line 73 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp79_ = e;
+#line 73 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp80_ = _tmp79_->message;
+#line 73 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp81_ = g_strdup_printf ("Failed: %s", _tmp80_);
+#line 73 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp82_ = _tmp81_;
+#line 73 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               fprintf (_tmp78_, "%s", _tmp82_);
+#line 73 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_free0 (_tmp82_);
+#line 49 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_error_free0 (e);
+#line 687 "gitg-diff-view-request-patch.c"
+       }
+       __finally27:
+#line 49 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       if (_inner_error_ != NULL) {
+#line 49 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_free0 (patch_content);
+#line 49 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_free0 (datetime);
+#line 49 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_free0 (author_email);
+#line 49 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_free0 (author);
+#line 49 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_free0 (legacydate);
+#line 49 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_free0 (sha1);
+#line 49 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_free0 (commit_message);
+#line 49 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, 
_inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
+#line 49 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               g_clear_error (&_inner_error_);
+#line 49 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               return;
+#line 712 "gitg-diff-view-request-patch.c"
+       }
+#line 40 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _g_free0 (patch_content);
+#line 40 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _g_free0 (datetime);
+#line 40 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _g_free0 (author_email);
+#line 40 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _g_free0 (author);
+#line 40 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _g_free0 (legacydate);
+#line 40 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _g_free0 (sha1);
+#line 40 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _g_free0 (commit_message);
+#line 728 "gitg-diff-view-request-patch.c"
+}
+
+
+static Block6Data* block6_data_ref (Block6Data* _data6_) {
+#line 77 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       g_atomic_int_inc (&_data6_->_ref_count_);
+#line 77 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       return _data6_;
+#line 737 "gitg-diff-view-request-patch.c"
+}
+
+
+static void block6_data_unref (void * _userdata_) {
+       Block6Data* _data6_;
+       _data6_ = (Block6Data*) _userdata_;
+#line 77 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       if (g_atomic_int_dec_and_test (&_data6_->_ref_count_)) {
+#line 746 "gitg-diff-view-request-patch.c"
+               GitgDiffViewRequestPatch * self;
+#line 77 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               self = _data6_->self;
+#line 77 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_object_unref0 (_data6_->chooser);
+#line 77 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_object_unref0 (_data6_->selected_commit);
+#line 77 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _gitg_diff_view_request_unref0 (self);
+#line 77 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               g_slice_free (Block6Data, _data6_);
+#line 758 "gitg-diff-view-request-patch.c"
+       }
+}
+
+
+static gchar* string_replace (const gchar* self, const gchar* old, const gchar* replacement) {
+       gchar* result = NULL;
+       GError * _inner_error_ = NULL;
+#line 1242 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+       g_return_val_if_fail (self != NULL, NULL);
+#line 1242 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+       g_return_val_if_fail (old != NULL, NULL);
+#line 1242 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+       g_return_val_if_fail (replacement != NULL, NULL);
+#line 772 "gitg-diff-view-request-patch.c"
+       {
+               GRegex* regex = NULL;
+               const gchar* _tmp0_ = NULL;
+               gchar* _tmp1_ = NULL;
+               gchar* _tmp2_ = NULL;
+               GRegex* _tmp3_ = NULL;
+               GRegex* _tmp4_ = NULL;
+               gchar* _tmp5_ = NULL;
+               GRegex* _tmp6_ = NULL;
+               const gchar* _tmp7_ = NULL;
+               gchar* _tmp8_ = NULL;
+#line 1244 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+               _tmp0_ = old;
+#line 1244 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+               _tmp1_ = g_regex_escape_string (_tmp0_, -1);
+#line 1244 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+               _tmp2_ = _tmp1_;
+#line 1244 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+               _tmp3_ = g_regex_new (_tmp2_, 0, 0, &_inner_error_);
+#line 1244 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+               _tmp4_ = _tmp3_;
+#line 1244 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+               _g_free0 (_tmp2_);
+#line 1244 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+               regex = _tmp4_;
+#line 1244 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+               if (_inner_error_ != NULL) {
+#line 1244 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+                       if (_inner_error_->domain == G_REGEX_ERROR) {
+#line 802 "gitg-diff-view-request-patch.c"
+                               goto __catch28_g_regex_error;
+                       }
+#line 1244 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+                       g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, 
_inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
+#line 1244 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+                       g_clear_error (&_inner_error_);
+#line 1244 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+                       return NULL;
+#line 811 "gitg-diff-view-request-patch.c"
+               }
+#line 1245 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+               _tmp6_ = regex;
+#line 1245 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+               _tmp7_ = replacement;
+#line 1245 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+               _tmp8_ = g_regex_replace_literal (_tmp6_, self, (gssize) (-1), 0, _tmp7_, 0, &_inner_error_);
+#line 1245 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+               _tmp5_ = _tmp8_;
+#line 1245 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+               if (_inner_error_ != NULL) {
+#line 1245 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+                       _g_regex_unref0 (regex);
+#line 1245 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+                       if (_inner_error_->domain == G_REGEX_ERROR) {
+#line 827 "gitg-diff-view-request-patch.c"
+                               goto __catch28_g_regex_error;
+                       }
+#line 1245 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+                       _g_regex_unref0 (regex);
+#line 1245 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+                       g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, 
_inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
+#line 1245 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+                       g_clear_error (&_inner_error_);
+#line 1245 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+                       return NULL;
+#line 838 "gitg-diff-view-request-patch.c"
+               }
+#line 1245 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+               result = _tmp5_;
+#line 1245 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+               _g_regex_unref0 (regex);
+#line 1245 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+               return result;
+#line 846 "gitg-diff-view-request-patch.c"
+       }
+       goto __finally28;
+       __catch28_g_regex_error:
+       {
+               GError* e = NULL;
+#line 1243 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+               e = _inner_error_;
+#line 1243 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+               _inner_error_ = NULL;
+#line 1247 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+               g_assert_not_reached ();
+#line 1243 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+               _g_error_free0 (e);
+#line 860 "gitg-diff-view-request-patch.c"
+       }
+       __finally28:
+#line 1243 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+       if (_inner_error_ != NULL) {
+#line 1243 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+               g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, 
_inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
+#line 1243 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+               g_clear_error (&_inner_error_);
+#line 1243 "/opt/gnome/share/vala-0.22/vapi/glib-2.0.vapi"
+               return NULL;
+#line 871 "gitg-diff-view-request-patch.c"
+       }
+}
+
+
+static void __lambda31_ (Block6Data* _data6_, GtkDialog* dialog, gint id) {
+       GitgDiffViewRequestPatch * self;
+       gint _tmp0_ = 0;
+       GtkFileChooserDialog* _tmp4_ = NULL;
+#line 98 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       self = _data6_->self;
+#line 98 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       g_return_if_fail (dialog != NULL);
+#line 99 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp0_ = id;
+#line 99 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       if (_tmp0_ != (-6)) {
+#line 888 "gitg-diff-view-request-patch.c"
+               GitgCommit* _tmp1_ = NULL;
+               GtkFileChooserDialog* _tmp2_ = NULL;
+               GFile* _tmp3_ = NULL;
+#line 100 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp1_ = _data6_->selected_commit;
+#line 100 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp2_ = _data6_->chooser;
+#line 100 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _tmp3_ = gtk_file_chooser_get_file ((GtkFileChooser*) _tmp2_);
+#line 100 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               gitg_diff_view_request_patch_create_patch (self, _tmp1_, _tmp3_);
+#line 900 "gitg-diff-view-request-patch.c"
+       }
+#line 102 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp4_ = _data6_->chooser;
+#line 102 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       gtk_widget_destroy ((GtkWidget*) _tmp4_);
+#line 906 "gitg-diff-view-request-patch.c"
+}
+
+
+static void ___lambda31__gtk_dialog_response (GtkDialog* _sender, gint response_id, gpointer self) {
+#line 98 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       __lambda31_ (self, _sender, response_id);
+#line 913 "gitg-diff-view-request-patch.c"
+}
+
+
+static void gitg_diff_view_request_patch_real_run_after_async (GitgDiffViewRequest* base) {
+       GitgDiffViewRequestPatch * self;
+       Block6Data* _data6_;
+       GgitCommit* _tmp0_ = NULL;
+       GitgCommit* _tmp1_ = NULL;
+       GRegex* subject_regex = NULL;
+       GRegex* _tmp2_ = NULL;
+       gchar* commit_subject = NULL;
+       GitgCommit* _tmp3_ = NULL;
+       const gchar* _tmp4_ = NULL;
+       gchar* _tmp5_ = NULL;
+       gchar* _tmp6_ = NULL;
+       GRegex* _tmp7_ = NULL;
+       const gchar* _tmp8_ = NULL;
+       const gchar* _tmp9_ = NULL;
+       gint _tmp10_ = 0;
+       gint _tmp11_ = 0;
+       gchar* _tmp12_ = NULL;
+       const gchar* _tmp13_ = NULL;
+       gchar* _tmp14_ = NULL;
+       GtkFileChooserDialog* _tmp15_ = NULL;
+       GtkFileChooserDialog* _tmp16_ = NULL;
+       const gchar* _tmp17_ = NULL;
+       gchar* _tmp18_ = NULL;
+       gchar* _tmp19_ = NULL;
+       GtkFileChooserDialog* _tmp20_ = NULL;
+       GtkFileChooserDialog* _tmp21_ = NULL;
+       GError * _inner_error_ = NULL;
+#line 77 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       self = (GitgDiffViewRequestPatch*) base;
+#line 77 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _data6_ = g_slice_new0 (Block6Data);
+#line 77 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _data6_->_ref_count_ = 1;
+#line 77 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _data6_->self = gitg_diff_view_request_ref (self);
+#line 79 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp0_ = self->priv->d_commit;
+#line 79 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GITG_TYPE_COMMIT, GitgCommit));
+#line 79 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _data6_->selected_commit = _tmp1_;
+#line 80 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp2_ = g_regex_new ("[^\\d\\w\\s\\_\\-]", 0, 0, &_inner_error_);
+#line 80 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       subject_regex = _tmp2_;
+#line 80 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       if (_inner_error_ != NULL) {
+#line 80 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               block6_data_unref (_data6_);
+#line 80 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _data6_ = NULL;
+#line 80 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, 
_inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
+#line 80 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               g_clear_error (&_inner_error_);
+#line 80 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               return;
+#line 975 "gitg-diff-view-request-patch.c"
+       }
+#line 81 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp3_ = _data6_->selected_commit;
+#line 81 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp4_ = ggit_commit_get_subject ((GgitCommit*) _tmp3_);
+#line 81 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp5_ = g_strdup (_tmp4_);
+#line 81 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       commit_subject = _tmp5_;
+#line 84 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp7_ = subject_regex;
+#line 84 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp8_ = commit_subject;
+#line 84 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp9_ = commit_subject;
+#line 84 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp10_ = strlen (_tmp9_);
+#line 84 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp11_ = _tmp10_;
+#line 84 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp12_ = g_regex_replace (_tmp7_, _tmp8_, (gssize) _tmp11_, 0, "", 0, &_inner_error_);
+#line 84 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp6_ = _tmp12_;
+#line 84 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       if (_inner_error_ != NULL) {
+#line 84 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_free0 (commit_subject);
+#line 84 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _g_regex_unref0 (subject_regex);
+#line 84 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               block6_data_unref (_data6_);
+#line 84 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               _data6_ = NULL;
+#line 84 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, 
_inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
+#line 84 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               g_clear_error (&_inner_error_);
+#line 84 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+               return;
+#line 1015 "gitg-diff-view-request-patch.c"
+       }
+#line 84 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _g_free0 (commit_subject);
+#line 84 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       commit_subject = _tmp6_;
+#line 86 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp13_ = commit_subject;
+#line 86 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp14_ = string_replace (_tmp13_, " ", "-");
+#line 86 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _g_free0 (commit_subject);
+#line 86 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       commit_subject = _tmp14_;
+#line 89 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp15_ = (GtkFileChooserDialog*) gtk_file_chooser_dialog_new ("Save Patch File", NULL, 
GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_OK, NULL);
+#line 89 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       g_object_ref_sink (_tmp15_);
+#line 89 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _data6_->chooser = _tmp15_;
+#line 95 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp16_ = _data6_->chooser;
+#line 95 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp17_ = commit_subject;
+#line 95 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp18_ = g_strconcat (_tmp17_, ".patch", NULL);
+#line 95 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp19_ = _tmp18_;
+#line 95 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       gtk_file_chooser_set_current_name ((GtkFileChooser*) _tmp16_, _tmp19_);
+#line 95 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _g_free0 (_tmp19_);
+#line 97 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp20_ = _data6_->chooser;
+#line 97 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       gtk_widget_show ((GtkWidget*) _tmp20_);
+#line 98 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _tmp21_ = _data6_->chooser;
+#line 98 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       g_signal_connect_data ((GtkDialog*) _tmp21_, "response", (GCallback) 
___lambda31__gtk_dialog_response, block6_data_ref (_data6_), (GClosureNotify) block6_data_unref, 0);
+#line 77 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _g_free0 (commit_subject);
+#line 77 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _g_regex_unref0 (subject_regex);
+#line 77 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       block6_data_unref (_data6_);
+#line 77 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _data6_ = NULL;
+#line 1063 "gitg-diff-view-request-patch.c"
+}
+
+
+static void gitg_diff_view_request_patch_class_init (GitgDiffViewRequestPatchClass * klass) {
+#line 22 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       gitg_diff_view_request_patch_parent_class = g_type_class_peek_parent (klass);
+#line 22 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       GITG_DIFF_VIEW_REQUEST_CLASS (klass)->finalize = gitg_diff_view_request_patch_finalize;
+#line 22 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       g_type_class_add_private (klass, sizeof (GitgDiffViewRequestPatchPrivate));
+#line 22 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       GITG_DIFF_VIEW_REQUEST_CLASS (klass)->run_after_async = 
gitg_diff_view_request_patch_real_run_after_async;
+#line 1076 "gitg-diff-view-request-patch.c"
+}
+
+
+static void gitg_diff_view_request_patch_instance_init (GitgDiffViewRequestPatch * self) {
+#line 22 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       self->priv = GITG_DIFF_VIEW_REQUEST_PATCH_GET_PRIVATE (self);
+#line 1083 "gitg-diff-view-request-patch.c"
+}
+
+
+static void gitg_diff_view_request_patch_finalize (GitgDiffViewRequest* obj) {
+       GitgDiffViewRequestPatch * self;
+#line 22 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       self = G_TYPE_CHECK_INSTANCE_CAST (obj, GITG_TYPE_DIFF_VIEW_REQUEST_PATCH, GitgDiffViewRequestPatch);
+#line 24 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       _g_object_unref0 (self->priv->d_commit);
+#line 22 "/home/sindhus/checkout/gnome/gitg/libgitg/gitg-diff-view-request-patch.vala"
+       GITG_DIFF_VIEW_REQUEST_CLASS (gitg_diff_view_request_patch_parent_class)->finalize (obj);
+#line 1095 "gitg-diff-view-request-patch.c"
+}
+
+
+GType gitg_diff_view_request_patch_get_type (void) {
+       static volatile gsize gitg_diff_view_request_patch_type_id__volatile = 0;
+       if (g_once_init_enter (&gitg_diff_view_request_patch_type_id__volatile)) {
+               static const GTypeInfo g_define_type_info = { sizeof (GitgDiffViewRequestPatchClass), 
(GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gitg_diff_view_request_patch_class_init, 
(GClassFinalizeFunc) NULL, NULL, sizeof (GitgDiffViewRequestPatch), 0, (GInstanceInitFunc) 
gitg_diff_view_request_patch_instance_init, NULL };
+               GType gitg_diff_view_request_patch_type_id;
+               gitg_diff_view_request_patch_type_id = g_type_register_static (GITG_TYPE_DIFF_VIEW_REQUEST, 
"GitgDiffViewRequestPatch", &g_define_type_info, 0);
+               g_once_init_leave (&gitg_diff_view_request_patch_type_id__volatile, 
gitg_diff_view_request_patch_type_id);
+       }
+       return gitg_diff_view_request_patch_type_id__volatile;
+}
+
+
+
diff --git a/libgitg/gitg-diff-view-request-patch.vala b/libgitg/gitg-diff-view-request-patch.vala
new file mode 100644
index 0000000..4c3b440
--- /dev/null
+++ b/libgitg/gitg-diff-view-request-patch.vala
@@ -0,0 +1,108 @@
+/*
+ * This file is part of gitg
+ *
+ * Copyright (C) 2012 - Sindhu S
+ *
+ * gitg is free software; you can 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.
+ *
+ * gitg 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 gitg. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+namespace Gitg
+{
+       class DiffViewRequestPatch : DiffViewRequest
+       {
+               private Ggit.Commit? d_commit;
+
+               public DiffViewRequestPatch (DiffView? view, WebKit.URISchemeRequest request, Soup.URI uri)
+               {
+                       base(view, request, uri);
+
+                       if (has_view)
+                       {
+                               d_commit = view.commit;
+                               
+                               // set the view to null else it won't run the request 
+                               d_view = null;
+                               d_hasView = false;
+                       }
+               }
+
+               private void create_patch (Gitg.Commit selected_commit, File file)
+               {
+                       string commit_message = selected_commit.get_message();
+                       string sha1 = selected_commit.get_id().to_string();
+                       string legacydate = "Mon Sep 17 00:00:00 2001";
+                       string author = selected_commit.get_author().get_name();
+                       string author_email = selected_commit.get_author().get_email();
+                       string datetime = selected_commit.get_author().get_time().format("%a, %e %b %Y %T 
%z");
+                       string patch_content = "";
+                       try
+                       {
+                               Ggit.DiffList diff = selected_commit.get_diff(null);
+                               Ggit.DiffPatch patch;
+                               Ggit.DiffDelta delta;
+                               var number_of_deltas = diff.get_num_deltas();
+                               
+                               
+                               patch_content += "From %s %s".printf(sha1, legacydate);
+                               patch_content += "\nFrom: %s <%s>".printf(author, author_email);
+                               patch_content += "\nDate: %s".printf(datetime);
+                               patch_content += "\nSubject: [PATCH] %s\n\n".printf(commit_message);
+                               for(var i = 0; i < number_of_deltas; i++) {
+                                       diff.get_patch(i, out patch, out delta);
+                                       patch_content += patch.to_string();
+                               }
+                               patch_content += "--\n";
+                               patch_content += "Gitg\n\n";
+
+                               FileUtils.set_contents(file.get_path(), patch_content);
+                       }
+                       catch (Error e)
+                       {
+                               // TODO: Route error message to Infobar?
+                               stdout.printf("Failed: %s".printf(e.message));
+                       }
+               }
+
+               public override void run_after_async()
+               {
+                       var selected_commit = (Gitg.Commit) d_commit;
+                       var subject_regex = new Regex("[^\\d\\w\\s\\_\\-]");
+                       string commit_subject = selected_commit.get_subject();
+                       
+                       // replace anything that's not alphanumeric with an empty string
+                       commit_subject = subject_regex.replace(commit_subject, commit_subject.length, 0, "");
+                       // replace spaces with hyphens
+                       commit_subject = commit_subject.replace(" ", "-");
+
+                       
+                       Gtk.FileChooserDialog chooser = new Gtk.FileChooserDialog ("Save Patch File", null,
+                                                                                                        
Gtk.FileChooserAction.SAVE,
+                                                     Gtk.Stock.CANCEL,
+                                                     Gtk.ResponseType.CANCEL,
+                                                     Gtk.Stock.SAVE,
+                                                     Gtk.ResponseType.OK);
+                       chooser.set_current_name(commit_subject + ".patch");
+
+                       chooser.show();
+                       chooser.response.connect((dialog, id) => {
+                               if(id != -6) {
+                                       create_patch (selected_commit, chooser.get_file());
+                               }
+                               chooser.destroy();
+                       });
+               }
+       }
+}
+
+// ex:ts=4 noet
diff --git a/libgitg/gitg-diff-view-request.vala b/libgitg/gitg-diff-view-request.vala
index c70d671..86d174e 100644
--- a/libgitg/gitg-diff-view-request.vala
+++ b/libgitg/gitg-diff-view-request.vala
@@ -86,6 +86,9 @@ namespace Gitg
                        return null;
                }
 
+               protected virtual void run_after_async()
+               {}
+
                private async InputStream? run_impl(Cancellable? cancellable) throws GLib.Error
                {
                        SourceFunc callback = run_impl.callback;
@@ -104,6 +107,8 @@ namespace Gitg
                                return null;
                        });
 
+                       run_after_async();
+
                        // Wait for it to finish, yield to caller
                        yield;
 
diff --git a/libgitg/gitg-diff-view.vala b/libgitg/gitg-diff-view.vala
index bd076e9..a4fc903 100644
--- a/libgitg/gitg-diff-view.vala
+++ b/libgitg/gitg-diff-view.vala
@@ -138,6 +138,8 @@ namespace Gitg
                                        return new DiffViewRequestResource(view, request, uri);
                                case "diff":
                                        return new DiffViewRequestDiff(view, request, uri);
+                               case "patch":
+                                       return new DiffViewRequestPatch(view, request, uri);
                        }
 
                        return null;
diff --git a/libgitg/resources/diff-view.css b/libgitg/resources/diff-view.css
index c4f755f..fec4d25 100644
--- a/libgitg/resources/diff-view.css
+++ b/libgitg/resources/diff-view.css
@@ -244,4 +244,11 @@ span.hunk_header, span.file_path {
   vertical-align: middle;
 }
 
+.format_patch_button {
+  float:right;
+  margin-top:13px;
+  padding: 7px;
+  margin-right: 3px;
+}
+
 /* vi:ts=2:et */
diff --git a/libgitg/resources/diff-view.html b/libgitg/resources/diff-view.html
index 82f92e7..4758b26 100644
--- a/libgitg/resources/diff-view.html
+++ b/libgitg/resources/diff-view.html
@@ -9,6 +9,7 @@
     <div id="templates">
       <!-- Commit template -->
       <div class="commit">
+        <button class="format_patch_button">Get Patch</button>
         <img class="avatar"/>
         <p>
           <span class="author"></span><br/>
diff --git a/libgitg/resources/diff-view.js b/libgitg/resources/diff-view.js
index ec989e3..7694be9 100644
--- a/libgitg/resources/diff-view.js
+++ b/libgitg/resources/diff-view.js
@@ -231,6 +231,12 @@ function update_diff(id, lsettings)
                if ('commit' in j)
                {
                        $('#diff_header').html(write_commit(j.commit));
+                       $(".format_patch_button").click(function()
+                       {
+                               var r = new XMLHttpRequest();
+                               r.open("GET", "gitg-diff:/patch/?id=" + j.commit.id + "&viewid=" + 
params.viewid);
+                               r.send();
+                       });
                }
        }
 


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