[libgit2-glib] Add GgitDiffFormatEmailOptions



commit 493add042c7cf017201b6b4b4c61883c9ad0bd94
Author: Jesse van den Kieboom <jessevdk gnome org>
Date:   Sun Jul 20 21:37:15 2014 +0300

    Add GgitDiffFormatEmailOptions

 libgit2-glib/Makefile.am                      |  224 ++++++------
 libgit2-glib/ggit-diff-format-email-options.c |  463 +++++++++++++++++++++++++
 libgit2-glib/ggit-diff-format-email-options.h |  104 ++++++
 libgit2-glib/ggit-types.c                     |    3 +
 libgit2-glib/ggit-types.h                     |   13 +
 5 files changed, 696 insertions(+), 111 deletions(-)
---
diff --git a/libgit2-glib/Makefile.am b/libgit2-glib/Makefile.am
index e065255..c497ac8 100644
--- a/libgit2-glib/Makefile.am
+++ b/libgit2-glib/Makefile.am
@@ -17,123 +17,125 @@ libgit2_glib_1_0_la_LDFLAGS =                             \
 
 libgit2_glib_1_0_la_LIBADD = $(LIBGIT2_GLIB_LIBS)
 
-INST_H_FILES =                         \
-       ggit-blame.h                    \
-       ggit-blame-options.h            \
-       ggit-blob.h                     \
-       ggit-blob-output-stream.h       \
-       ggit-branch.h                   \
-       ggit-branch-enumerator.h        \
-       ggit-checkout-options.h         \
-       ggit-clone-options.h            \
-       ggit-commit.h                   \
-       ggit-config.h                   \
-       ggit-config-entry.h             \
-       ggit-cred.h                     \
-       ggit-cred-plaintext.h           \
-       ggit-diff.h                     \
-       ggit-diff-delta.h               \
-       ggit-diff-file.h                \
-       ggit-diff-find-options.h        \
-       ggit-diff-hunk.h                \
-       ggit-diff-line.h                \
-       ggit-diff-options.h             \
-       ggit-diff-similarity-metric.h   \
-       ggit-error.h                    \
-       ggit-index.h                    \
-       ggit-index-entry.h              \
-       ggit-index-entry-resolve-undo.h \
-       ggit-main.h                     \
-       ggit-message.h                  \
-       ggit-merge-options.h    \
-       ggit-native.h                   \
-       ggit-object.h                   \
-       ggit-object-factory.h           \
-       ggit-object-factory-base.h      \
-       ggit-oid.h                      \
-       ggit-patch.h                    \
-       ggit-push.h                     \
-       ggit-push-progress.h            \
-       ggit-ref.h                      \
-       ggit-ref-spec.h                 \
-       ggit-reflog.h                   \
-       ggit-reflog-entry.h             \
-       ggit-remote.h                   \
-       ggit-remote-callbacks.h         \
-       ggit-repository.h               \
-       ggit-revert-options.h           \
-       ggit-revision-walker.h          \
-       ggit-signature.h                \
-       ggit-status-options.h           \
-       ggit-submodule.h                \
-       ggit-tag.h                      \
-       ggit-transfer-progress.h        \
-       ggit-tree.h                     \
-       ggit-tree-builder.h             \
-       ggit-tree-entry.h               \
-       ggit-types.h                    \
+INST_H_FILES =                                 \
+       ggit-blame.h                            \
+       ggit-blame-options.h                    \
+       ggit-blob.h                             \
+       ggit-blob-output-stream.h               \
+       ggit-branch.h                           \
+       ggit-branch-enumerator.h                \
+       ggit-checkout-options.h                 \
+       ggit-clone-options.h                    \
+       ggit-commit.h                           \
+       ggit-config.h                           \
+       ggit-config-entry.h                     \
+       ggit-cred.h                             \
+       ggit-cred-plaintext.h                   \
+       ggit-diff.h                             \
+       ggit-diff-delta.h                       \
+       ggit-diff-file.h                        \
+       ggit-diff-find-options.h                \
+       ggit-diff-format-email-options.h        \
+       ggit-diff-hunk.h                        \
+       ggit-diff-line.h                        \
+       ggit-diff-options.h                     \
+       ggit-diff-similarity-metric.h           \
+       ggit-error.h                            \
+       ggit-index.h                            \
+       ggit-index-entry.h                      \
+       ggit-index-entry-resolve-undo.h         \
+       ggit-main.h                             \
+       ggit-message.h                          \
+       ggit-merge-options.h                    \
+       ggit-native.h                           \
+       ggit-object.h                           \
+       ggit-object-factory.h                   \
+       ggit-object-factory-base.h              \
+       ggit-oid.h                              \
+       ggit-patch.h                            \
+       ggit-push.h                             \
+       ggit-push-progress.h                    \
+       ggit-ref.h                              \
+       ggit-ref-spec.h                         \
+       ggit-reflog.h                           \
+       ggit-reflog-entry.h                     \
+       ggit-remote.h                           \
+       ggit-remote-callbacks.h                 \
+       ggit-repository.h                       \
+       ggit-revert-options.h                   \
+       ggit-revision-walker.h                  \
+       ggit-signature.h                        \
+       ggit-status-options.h                   \
+       ggit-submodule.h                        \
+       ggit-tag.h                              \
+       ggit-transfer-progress.h                \
+       ggit-tree.h                             \
+       ggit-tree-builder.h                     \
+       ggit-tree-entry.h                       \
+       ggit-types.h                            \
        ggit.h
 
 NOINST_H_FILES =                       \
        ggit-convert.h                  \
        ggit-utils.h
 
-C_FILES =                              \
-       ggit-blame.c                    \
-       ggit-blame-options.c            \
-       ggit-blob.c                     \
-       ggit-blob-output-stream.c       \
-       ggit-branch.c                   \
-       ggit-branch-enumerator.c        \
-       ggit-checkout-options.c         \
-       ggit-clone-options.c            \
-       ggit-commit.c                   \
-       ggit-config.c                   \
-       ggit-config-entry.c             \
-       ggit-convert.c                  \
-       ggit-cred.c                     \
-       ggit-cred-plaintext.c           \
-       ggit-diff.c                     \
-       ggit-diff-delta.c               \
-       ggit-diff-file.c                \
-       ggit-diff-find-options.c        \
-       ggit-diff-hunk.c                \
-       ggit-diff-line.c                \
-       ggit-diff-options.c             \
-       ggit-diff-similarity-metric.c   \
-       ggit-error.c                    \
-       ggit-index.c                    \
-       ggit-index-entry.c              \
-       ggit-index-entry-resolve-undo.c \
-       ggit-main.c                     \
-       ggit-message.c                  \
-       ggit-merge-options.c    \
-       ggit-native.c                   \
-       ggit-object.c                   \
-       ggit-object-factory.c           \
-       ggit-object-factory-base.c      \
-       ggit-oid.c                      \
-       ggit-patch.c                    \
-       ggit-push.c                     \
-       ggit-push-progress.c            \
-       ggit-ref.c                      \
-       ggit-ref-spec.c                 \
-       ggit-reflog.c                   \
-       ggit-reflog-entry.c             \
-       ggit-remote.c                   \
-       ggit-remote-callbacks.c         \
-       ggit-repository.c               \
-       ggit-revert-options.c           \
-       ggit-revision-walker.c          \
-       ggit-signature.c                \
-       ggit-status-options.c           \
-       ggit-submodule.c                \
-       ggit-tag.c                      \
-       ggit-transfer-progress.c        \
-       ggit-tree.c                     \
-       ggit-tree-builder.c             \
-       ggit-tree-entry.c               \
-       ggit-types.c                    \
+C_FILES =                                      \
+       ggit-blame.c                            \
+       ggit-blame-options.c                    \
+       ggit-blob.c                             \
+       ggit-blob-output-stream.c               \
+       ggit-branch.c                           \
+       ggit-branch-enumerator.c                \
+       ggit-checkout-options.c                 \
+       ggit-clone-options.c                    \
+       ggit-commit.c                           \
+       ggit-config.c                           \
+       ggit-config-entry.c                     \
+       ggit-convert.c                          \
+       ggit-cred.c                             \
+       ggit-cred-plaintext.c                   \
+       ggit-diff.c                             \
+       ggit-diff-delta.c                       \
+       ggit-diff-file.c                        \
+       ggit-diff-find-options.c                \
+       ggit-diff-format-email-options.c        \
+       ggit-diff-hunk.c                        \
+       ggit-diff-line.c                        \
+       ggit-diff-options.c                     \
+       ggit-diff-similarity-metric.c           \
+       ggit-error.c                            \
+       ggit-index.c                            \
+       ggit-index-entry.c                      \
+       ggit-index-entry-resolve-undo.c         \
+       ggit-main.c                             \
+       ggit-message.c                          \
+       ggit-merge-options.c                    \
+       ggit-native.c                           \
+       ggit-object.c                           \
+       ggit-object-factory.c                   \
+       ggit-object-factory-base.c              \
+       ggit-oid.c                              \
+       ggit-patch.c                            \
+       ggit-push.c                             \
+       ggit-push-progress.c                    \
+       ggit-ref.c                              \
+       ggit-ref-spec.c                         \
+       ggit-reflog.c                           \
+       ggit-reflog-entry.c                     \
+       ggit-remote.c                           \
+       ggit-remote-callbacks.c                 \
+       ggit-repository.c                       \
+       ggit-revert-options.c                   \
+       ggit-revision-walker.c                  \
+       ggit-signature.c                        \
+       ggit-status-options.c                   \
+       ggit-submodule.c                        \
+       ggit-tag.c                              \
+       ggit-transfer-progress.c                \
+       ggit-tree.c                             \
+       ggit-tree-builder.c                     \
+       ggit-tree-entry.c                       \
+       ggit-types.c                            \
        ggit-utils.c
 
 if GIT_SSH
diff --git a/libgit2-glib/ggit-diff-format-email-options.c b/libgit2-glib/ggit-diff-format-email-options.c
new file mode 100644
index 0000000..548a611
--- /dev/null
+++ b/libgit2-glib/ggit-diff-format-email-options.c
@@ -0,0 +1,463 @@
+#include "ggit-diff-format-email-options.h"
+#include "ggit-enum-types.h"
+#include "ggit-signature.h"
+#include "ggit-oid.h"
+
+#define GGIT_DIFF_FORMAT_EMAIL_OPTIONS_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE((object), 
GGIT_TYPE_DIFF_FORMAT_EMAIL_OPTIONS, GgitDiffFormatEmailOptionsPrivate))
+
+struct _GgitDiffFormatEmailOptionsPrivate
+{
+       git_diff_format_email_options options;
+
+       GgitOId *id;
+       gchar *summary;
+       GgitSignature *author;
+};
+
+G_DEFINE_TYPE (GgitDiffFormatEmailOptions, ggit_diff_format_email_options, G_TYPE_OBJECT)
+
+enum
+{
+       PROP_0,
+       PROP_FLAGS,
+       PROP_PATCH_NUMBER,
+       PROP_TOTAL_PATCHES,
+       PROP_ID,
+       PROP_SUMMARY,
+       PROP_AUTHOR
+};
+
+static void
+ggit_diff_format_email_options_finalize (GObject *object)
+{
+       GgitDiffFormatEmailOptions *options;
+
+       options = GGIT_DIFF_FORMAT_EMAIL_OPTIONS (object);
+
+       if (options->priv->id)
+       {
+               ggit_oid_free (options->priv->id);
+       }
+
+       g_free (options->priv->summary);
+       g_clear_object (&options->priv->author);
+
+       G_OBJECT_CLASS (ggit_diff_format_email_options_parent_class)->finalize (object);
+}
+
+static void
+ggit_diff_format_email_options_set_property (GObject      *object,
+                                             guint         prop_id,
+                                             const GValue *value,
+                                             GParamSpec   *pspec)
+{
+       GgitDiffFormatEmailOptions *self = GGIT_DIFF_FORMAT_EMAIL_OPTIONS (object);
+
+       switch (prop_id)
+       {
+       case PROP_FLAGS:
+               self->priv->options.flags = g_value_get_flags (value);
+               break;
+       case PROP_PATCH_NUMBER:
+               self->priv->options.patch_no = g_value_get_uint64 (value);
+               break;
+       case PROP_TOTAL_PATCHES:
+               self->priv->options.total_patches = g_value_get_uint64 (value);
+               break;
+       case PROP_ID:
+               ggit_diff_format_email_options_set_id (self, g_value_get_boxed (value));
+               break;
+       case PROP_SUMMARY:
+               ggit_diff_format_email_options_set_summary (self, g_value_get_string (value));
+               break;
+       case PROP_AUTHOR:
+               ggit_diff_format_email_options_set_author (self, g_value_get_object (value));
+               break;
+       default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+               break;
+       }
+}
+
+static void
+ggit_diff_format_email_options_get_property (GObject    *object,
+                                             guint       prop_id,
+                                             GValue     *value,
+                                             GParamSpec *pspec)
+{
+       GgitDiffFormatEmailOptions *self = GGIT_DIFF_FORMAT_EMAIL_OPTIONS (object);
+
+       switch (prop_id)
+       {
+       case PROP_FLAGS:
+               g_value_set_flags (value, self->priv->options.flags);
+               break;
+       case PROP_PATCH_NUMBER:
+               g_value_set_uint64 (value, self->priv->options.patch_no);
+               break;
+       case PROP_TOTAL_PATCHES:
+               g_value_set_uint64 (value, self->priv->options.total_patches);
+               break;
+       case PROP_ID:
+               g_value_set_boxed (value, self->priv->id);
+               break;
+       case PROP_SUMMARY:
+               g_value_set_string (value, self->priv->summary);
+               break;
+       case PROP_AUTHOR:
+               g_value_set_object (value, self->priv->author);
+               break;
+       default:
+               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+               break;
+       }
+}
+
+static void
+ggit_diff_format_email_options_class_init (GgitDiffFormatEmailOptionsClass *klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+       git_diff_format_email_options defopts = GIT_DIFF_FORMAT_EMAIL_OPTIONS_INIT;
+
+       object_class->finalize = ggit_diff_format_email_options_finalize;
+
+       object_class->get_property = ggit_diff_format_email_options_get_property;
+       object_class->set_property = ggit_diff_format_email_options_set_property;
+
+
+       g_type_class_add_private (object_class, sizeof (GgitDiffFormatEmailOptionsPrivate));
+
+       g_object_class_install_property (object_class,
+                                        PROP_FLAGS,
+                                        g_param_spec_flags ("flags",
+                                                            "Flags",
+                                                            "Flags",
+                                                            GGIT_TYPE_DIFF_FORMAT_EMAIL_FLAGS,
+                                                            defopts.flags,
+                                                            G_PARAM_READWRITE |
+                                                            G_PARAM_STATIC_STRINGS));
+
+       g_object_class_install_property (object_class,
+                                        PROP_PATCH_NUMBER,
+                                        g_param_spec_uint64 ("patch-number",
+                                                             "Patch Number",
+                                                             "Patch number",
+                                                             0,
+                                                             G_MAXUINT64,
+                                                             defopts.patch_no,
+                                                             G_PARAM_READWRITE |
+                                                             G_PARAM_STATIC_STRINGS));
+
+       g_object_class_install_property (object_class,
+                                        PROP_TOTAL_PATCHES,
+                                        g_param_spec_uint64 ("total-patches",
+                                                             "Total Patches",
+                                                             "Total patches",
+                                                             0,
+                                                             G_MAXUINT64,
+                                                             defopts.total_patches,
+                                                             G_PARAM_READWRITE |
+                                                             G_PARAM_STATIC_STRINGS));
+
+       g_object_class_install_property (object_class,
+                                        PROP_ID,
+                                        g_param_spec_boxed ("id",
+                                                            "Id",
+                                                            "Id",
+                                                            GGIT_TYPE_OID,
+                                                            G_PARAM_READWRITE |
+                                                            G_PARAM_STATIC_STRINGS));
+
+       g_object_class_install_property (object_class,
+                                        PROP_SUMMARY,
+                                        g_param_spec_string ("summary",
+                                                             "Summary",
+                                                             "Summary",
+                                                             NULL,
+                                                             G_PARAM_READWRITE |
+                                                             G_PARAM_STATIC_STRINGS));
+
+       g_object_class_install_property (object_class,
+                                        PROP_AUTHOR,
+                                        g_param_spec_object ("author",
+                                                             "Author",
+                                                             "Author",
+                                                             GGIT_TYPE_SIGNATURE,
+                                                             G_PARAM_READWRITE |
+                                                             G_PARAM_STATIC_STRINGS));
+}
+
+static void
+ggit_diff_format_email_options_init (GgitDiffFormatEmailOptions *self)
+{
+       self->priv = GGIT_DIFF_FORMAT_EMAIL_OPTIONS_GET_PRIVATE (self);
+
+       git_diff_format_email_init_options (&self->priv->options,
+                                           GIT_DIFF_FORMAT_EMAIL_OPTIONS_VERSION);
+}
+
+/**
+ * ggit_diff_format_email_options_new:
+ *
+ * Create a new checkout options object.
+ *
+ * Returns: a #GgitDiffFormatEmailOptions.
+ *
+ **/
+GgitDiffFormatEmailOptions *
+ggit_diff_format_email_options_new ()
+{
+       return g_object_new (GGIT_TYPE_DIFF_FORMAT_EMAIL_OPTIONS, NULL);
+}
+
+const git_diff_format_email_options *
+_ggit_diff_format_email_options_get_diff_format_email_options (GgitDiffFormatEmailOptions *options)
+{
+       if (options != NULL)
+       {
+               return &options->priv->options;
+       }
+       else
+       {
+               return NULL;
+       }
+}
+
+/**
+ * ggit_diff_format_email_options_get_flags:
+ * @options: a #GgitDiffFormatEmailOptions.
+ *
+ * Get the flags.
+ *
+ * Returns: a #GgitDiffFormatEmailFlags.
+ *
+ **/
+GgitDiffFormatEmailFlags
+ggit_diff_format_email_options_get_flags (GgitDiffFormatEmailOptions *options)
+{
+       g_return_val_if_fail (GGIT_IS_DIFF_FORMAT_EMAIL_OPTIONS (options), 0);
+
+       return (GgitDiffFormatEmailFlags)options->priv->options.flags;
+}
+
+/**
+ * ggit_diff_format_email_options_set_flags:
+ * @options: a #GgitDiffFormatEmailOptions.
+ * @flags: a #GgitDiffFormatEmailFlags.
+ *
+ * Set the flags.
+ *
+ **/
+void
+ggit_diff_format_email_options_set_flags (GgitDiffFormatEmailOptions *options,
+                                          GgitDiffFormatEmailFlags    flags)
+{
+       g_return_if_fail (GGIT_IS_DIFF_FORMAT_EMAIL_OPTIONS (options));
+
+       options->priv->options.flags = (git_diff_format_email_flags_t)flags;
+       g_object_notify (G_OBJECT (options), "flags");
+}
+
+/**
+ * ggit_diff_format_email_options_get_patch_number:
+ * @options: a #GgitDiffFormatEmailOptions.
+ *
+ * Get the patch number.
+ *
+ * Returns: the patch number.
+ *
+ **/
+gsize
+ggit_diff_format_email_options_get_patch_number (GgitDiffFormatEmailOptions *options)
+{
+       g_return_val_if_fail (GGIT_IS_DIFF_FORMAT_EMAIL_OPTIONS (options), 0);
+
+       return options->priv->options.patch_no;
+}
+
+/**
+ * ggit_diff_format_email_options_set_patch_number:
+ * @options: a #GgitDiffFormatEmailOptions.
+ * @number: the patch number.
+ *
+ * Set the patch number.
+ *
+ **/
+void
+ggit_diff_format_email_options_set_patch_number (GgitDiffFormatEmailOptions *options,
+                                                 gsize                       number)
+{
+       g_return_if_fail (GGIT_IS_DIFF_FORMAT_EMAIL_OPTIONS (options));
+
+       options->priv->options.patch_no = number;
+       g_object_notify (G_OBJECT (options), "patch-number");
+}
+
+/**
+ * ggit_diff_format_email_options_get_total_patches:
+ * @options: a #GgitDiffFormatEmailOptions.
+ *
+ * Get the total number of patches.
+ *
+ * Returns: the total number of patches.
+ *
+ **/
+gsize
+ggit_diff_format_email_options_get_total_patches (GgitDiffFormatEmailOptions *options)
+{
+       g_return_val_if_fail (GGIT_IS_DIFF_FORMAT_EMAIL_OPTIONS (options), 0);
+
+       return options->priv->options.total_patches;
+}
+
+/**
+ * ggit_diff_format_email_options_set_total_patches:
+ * @options: a #GgitDiffFormatEmailOptions.
+ * @patches: the total number of patches.
+ *
+ * Set the total number of patches.
+ *
+ **/
+void
+ggit_diff_format_email_options_set_total_patches (GgitDiffFormatEmailOptions *options,
+                                                  gsize                       patches)
+{
+       g_return_if_fail (GGIT_IS_DIFF_FORMAT_EMAIL_OPTIONS (options));
+
+       options->priv->options.total_patches = patches;
+       g_object_notify (G_OBJECT (options), "total-patches");
+}
+
+/**
+ * ggit_diff_format_email_options_get_id:
+ * @options: a #GgitDiffFormatEmailOptions.
+ *
+ * Get the object id.
+ *
+ * Returns: (transfer none): a #GgitOId.
+ *
+ **/
+GgitOId *
+ggit_diff_format_email_options_get_id (GgitDiffFormatEmailOptions *options)
+{
+       g_return_val_if_fail (GGIT_IS_DIFF_FORMAT_EMAIL_OPTIONS (options), NULL);
+
+       return options->priv->id;
+}
+
+/**
+ * ggit_diff_format_email_options_set_id:
+ * @options: a #GgitDiffFormatEmailOptions.
+ * @id: (allow-none): a #GgitOId.
+ *
+ * Set the object id.
+ *
+ **/
+void
+ggit_diff_format_email_options_set_id (GgitDiffFormatEmailOptions *options,
+                                       GgitOId                    *id)
+{
+       g_return_if_fail (GGIT_IS_DIFF_FORMAT_EMAIL_OPTIONS (options));
+
+       if (options->priv->id)
+       {
+               ggit_oid_free (options->priv->id);
+               options->priv->id = NULL;
+               options->priv->options.id = NULL;
+       }
+
+       if (id != NULL)
+       {
+               options->priv->id = ggit_oid_copy (id);
+               options->priv->options.id = _ggit_oid_get_oid (options->priv->id);
+       }
+
+       g_object_notify (G_OBJECT (options), "id");
+}
+
+/**
+ * ggit_diff_format_email_options_get_summary:
+ * @options: a #GgitDiffFormatEmailOptions.
+ *
+ * Get the summary.
+ *
+ * Returns: the summary.
+ *
+ **/
+const gchar *
+ggit_diff_format_email_options_get_summary (GgitDiffFormatEmailOptions *options)
+{
+       g_return_val_if_fail (GGIT_IS_DIFF_FORMAT_EMAIL_OPTIONS (options), NULL);
+
+       return options->priv->summary;
+}
+
+/**
+ * ggit_diff_format_email_options_set_summary:
+ * @options: a #GgitDiffFormatEmailOptions.
+ * @summary: (allow-none): the summary.
+ *
+ * Set the summary.
+ *
+ **/
+void
+ggit_diff_format_email_options_set_summary (GgitDiffFormatEmailOptions *options,
+                                            const gchar                *summary)
+{
+       g_return_if_fail (GGIT_IS_DIFF_FORMAT_EMAIL_OPTIONS (options));
+
+       g_free (options->priv->summary);
+       options->priv->summary = g_strdup (summary);
+
+       options->priv->options.summary = options->priv->summary;
+       g_object_notify (G_OBJECT (options), "summary");
+}
+
+/**
+ * ggit_diff_format_email_options_get_author:
+ * @options: a #GgitDiffFormatEmailOptions.
+ *
+ * Get the author.
+ *
+ * Returns: (transfer none): a #GgitSignature.
+ *
+ **/
+GgitSignature *
+ggit_diff_format_email_options_get_author (GgitDiffFormatEmailOptions *options)
+{
+       g_return_val_if_fail (GGIT_IS_DIFF_FORMAT_EMAIL_OPTIONS (options), NULL);
+
+       return options->priv->author;
+}
+
+/**
+ * ggit_diff_format_email_options_set_author:
+ * @options: a #GgitDiffFormatEmailOptions.
+ * @author: (allow-none): a #GgitSignature.
+ *
+ * Set the author.
+ *
+ **/
+void
+ggit_diff_format_email_options_set_author (GgitDiffFormatEmailOptions *options,
+                                           GgitSignature              *author)
+{
+       g_return_if_fail (GGIT_IS_DIFF_FORMAT_EMAIL_OPTIONS (options));
+       g_return_if_fail (author == NULL || GGIT_IS_SIGNATURE (author));
+
+       if (options->priv->author)
+       {
+               g_object_unref (options->priv->author);
+               options->priv->author = NULL;
+               options->priv->options.author = NULL;
+       }
+
+       if (author)
+       {
+               options->priv->author = ggit_signature_copy (author);
+               options->priv->options.author = _ggit_native_get (author);
+       }
+
+       g_object_notify (G_OBJECT (options), "author");
+}
+
diff --git a/libgit2-glib/ggit-diff-format-email-options.h b/libgit2-glib/ggit-diff-format-email-options.h
new file mode 100644
index 0000000..fdf6403
--- /dev/null
+++ b/libgit2-glib/ggit-diff-format-email-options.h
@@ -0,0 +1,104 @@
+/*
+ * ggit-diff_format_email-options.h
+ * This file is part of libgit2-glib
+ *
+ * Copyright (C) 2013 - Ignacio Casal Quinteiro
+ *
+ * libgit2-glib is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * libgit2-glib 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with libgit2-glib. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GGIT_DIFF_FORMAT_EMAIL_OPTIONS_H__
+#define __GGIT_DIFF_FORMAT_EMAIL_OPTIONS_H__
+
+#include <glib-object.h>
+#include <git2.h>
+
+#include "ggit-types.h"
+
+G_BEGIN_DECLS
+
+#define GGIT_TYPE_DIFF_FORMAT_EMAIL_OPTIONS            (ggit_diff_format_email_options_get_type ())
+#define GGIT_DIFF_FORMAT_EMAIL_OPTIONS(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GGIT_TYPE_DIFF_FORMAT_EMAIL_OPTIONS, GgitDiffFormatEmailOptions))
+#define GGIT_DIFF_FORMAT_EMAIL_OPTIONS_CONST(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), 
GGIT_TYPE_DIFF_FORMAT_EMAIL_OPTIONS, GgitDiffFormatEmailOptions const))
+#define GGIT_DIFF_FORMAT_EMAIL_OPTIONS_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), 
GGIT_TYPE_DIFF_FORMAT_EMAIL_OPTIONS, GgitDiffFormatEmailOptionsClass))
+#define GGIT_IS_DIFF_FORMAT_EMAIL_OPTIONS(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
GGIT_TYPE_DIFF_FORMAT_EMAIL_OPTIONS))
+#define GGIT_IS_DIFF_FORMAT_EMAIL_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), 
GGIT_TYPE_DIFF_FORMAT_EMAIL_OPTIONS))
+#define GGIT_DIFF_FORMAT_EMAIL_OPTIONS_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), 
GGIT_TYPE_DIFF_FORMAT_EMAIL_OPTIONS, GgitDiffFormatEmailOptionsClass))
+
+typedef struct _GgitDiffFormatEmailOptionsClass        GgitDiffFormatEmailOptionsClass;
+typedef struct _GgitDiffFormatEmailOptionsPrivate      GgitDiffFormatEmailOptionsPrivate;
+
+struct _GgitDiffFormatEmailOptions
+{
+       GObject parent;
+
+       GgitDiffFormatEmailOptionsPrivate *priv;
+};
+
+struct _GgitDiffFormatEmailOptionsClass
+{
+       GObjectClass parent_class;
+};
+
+GType                  ggit_diff_format_email_options_get_type (void) G_GNUC_CONST;
+
+const git_diff_format_email_options *
+              _ggit_diff_format_email_options_get_diff_format_email_options (
+                                         GgitDiffFormatEmailOptions *options);
+
+GgitDiffFormatEmailOptions *
+               ggit_diff_format_email_options_new        (void);
+
+GgitDiffFormatEmailFlags
+               ggit_diff_format_email_options_get_flags  (
+                                         GgitDiffFormatEmailOptions  *options);
+void           ggit_diff_format_email_options_set_flags  (
+                                         GgitDiffFormatEmailOptions  *options,
+                                         GgitDiffFormatEmailFlags     flags);
+
+gsize          ggit_diff_format_email_options_get_patch_number (
+                                         GgitDiffFormatEmailOptions  *options);
+void           ggit_diff_format_email_options_set_patch_number (
+                                         GgitDiffFormatEmailOptions  *options,
+                                         gsize                        number);
+
+gsize          ggit_diff_format_email_options_get_total_patches (
+                                         GgitDiffFormatEmailOptions  *options);
+void           ggit_diff_format_email_options_set_total_patches (
+                                         GgitDiffFormatEmailOptions  *options,
+                                         gsize                        patches);
+
+GgitOId       *ggit_diff_format_email_options_get_id (
+                                         GgitDiffFormatEmailOptions  *options);
+void           ggit_diff_format_email_options_set_id (
+                                         GgitDiffFormatEmailOptions  *options,
+                                         GgitOId                     *id);
+
+const gchar   *ggit_diff_format_email_options_get_summary (
+                                         GgitDiffFormatEmailOptions  *options);
+void           ggit_diff_format_email_options_set_summary (
+                                         GgitDiffFormatEmailOptions  *options,
+                                         const gchar                 *summary);
+
+GgitSignature *ggit_diff_format_email_options_get_author (
+                                         GgitDiffFormatEmailOptions  *options);
+void           ggit_diff_format_email_options_set_author (
+                                         GgitDiffFormatEmailOptions  *options,
+                                         GgitSignature               *author);
+
+G_END_DECLS
+
+#endif /* __GGIT_DIFF_FORMAT_EMAIL_OPTIONS_H__ */
+
+/* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-types.c b/libgit2-glib/ggit-types.c
index 9fd31f5..d771cc1 100644
--- a/libgit2-glib/ggit-types.c
+++ b/libgit2-glib/ggit-types.c
@@ -262,4 +262,7 @@ ASSERT_ENUM (GGIT_DIFF_FIND_EXACT_MATCH_ONLY,           GIT_DIFF_FIND_EXACT_MATC
 ASSERT_ENUM (GGIT_DIFF_BREAK_REWRITES_FOR_RENAMES_ONLY, GIT_DIFF_BREAK_REWRITES_FOR_RENAMES_ONLY);
 ASSERT_ENUM (GGIT_DIFF_FIND_REMOVE_UNMODIFIED,          GIT_DIFF_FIND_REMOVE_UNMODIFIED);
 
+ASSERT_ENUM (GGIT_DIFF_FORMAT_EMAIL_NONE, GIT_DIFF_FORMAT_EMAIL_NONE);
+ASSERT_ENUM (GGIT_DIFF_FORMAT_EMAIL_EXCLUDE_SUBJECT_PATCH_MARKER, 
GIT_DIFF_FORMAT_EMAIL_EXCLUDE_SUBJECT_PATCH_MARKER);
+
 /* ex:set ts=8 noet: */
diff --git a/libgit2-glib/ggit-types.h b/libgit2-glib/ggit-types.h
index 770b846..f8029bf 100644
--- a/libgit2-glib/ggit-types.h
+++ b/libgit2-glib/ggit-types.h
@@ -426,6 +426,13 @@ typedef struct _GgitCheckoutOptions GgitCheckoutOptions;
 typedef struct _GgitRevertOptions GgitRevertOptions;
 
 /**
+ * GgitFormatEmailOptions:
+ *
+ * Represents the options used when formatting a diff for e-mail.
+ */
+typedef struct _GgitDiffFormatEmailOptions GgitDiffFormatEmailOptions;
+
+/**
  * GgitBranchType:
  * @GGIT_BRANCH_LOCAL: specifies a local branch.
  * @GGIT_BRANCH_REMOTE: specifies a remote branch.
@@ -1050,6 +1057,12 @@ typedef enum {
        GGIT_DIFF_FIND_REMOVE_UNMODIFIED          = (1u << 16),
 } GgitDiffFindFlags;
 
+typedef enum
+{
+       GGIT_DIFF_FORMAT_EMAIL_NONE                         = 0,
+       GGIT_DIFF_FORMAT_EMAIL_EXCLUDE_SUBJECT_PATCH_MARKER = (1 << 0)
+} GgitDiffFormatEmailFlags;
+
 /**
  * GgitConfigCallback:
  * @entry: a #GgitConfigEntry.


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