[gitg/add-ref-actions: 3/3] Added reference action to create patch
- From: Alberto Fanjul <albfan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg/add-ref-actions: 3/3] Added reference action to create patch
- Date: Sat, 29 Jan 2022 09:52:10 +0000 (UTC)
commit 49080e960d01c993740aac6bbf9fe2325e0ede24
Author: Adwait Rawat <adwait rawat gmail com>
Date: Sun Jun 16 18:18:54 2019 +0900
Added reference action to create patch
gitg/gitg-commit-action-create-patch.vala | 6 +--
gitg/gitg-ref-action-create-patch.vala | 68 +++++++++++++++++++++++++++++++
gitg/history/gitg-history.vala | 1 +
gitg/meson.build | 1 +
4 files changed, 73 insertions(+), 3 deletions(-)
---
diff --git a/gitg/gitg-commit-action-create-patch.vala b/gitg/gitg-commit-action-create-patch.vala
index 4dc4a347..d6564135 100644
--- a/gitg/gitg-commit-action-create-patch.vala
+++ b/gitg/gitg-commit-action-create-patch.vala
@@ -53,7 +53,7 @@ class CommitActionCreatePatch : GitgExt.UIElement, GitgExt.Action, GitgExt.Commi
commit: commit);
}
- public string id
+ public virtual string id
{
owned get { return "/org/gnome/gitg/commit-actions/create-patch"; }
}
@@ -63,7 +63,7 @@ class CommitActionCreatePatch : GitgExt.UIElement, GitgExt.Action, GitgExt.Commi
owned get { return _("Create patch"); }
}
- public string description
+ public virtual string description
{
owned get { return _("Create a patch from the selected commit"); }
}
@@ -147,7 +147,7 @@ class CommitActionCreatePatch : GitgExt.UIElement, GitgExt.Action, GitgExt.Commi
null);
}
- public void activate()
+ public virtual void activate()
{
var chooser = new Gtk.FileChooserDialog(_("Save Patch File"), null,
Gtk.FileChooserAction.SAVE,
diff --git a/gitg/gitg-ref-action-create-patch.vala b/gitg/gitg-ref-action-create-patch.vala
new file mode 100644
index 00000000..6bd9c7b1
--- /dev/null
+++ b/gitg/gitg-ref-action-create-patch.vala
@@ -0,0 +1,68 @@
+/*
+ * This file is part of gitg
+ *
+ * Copyright (C) 2022 - Adwait Rawat
+ *
+ * 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 RefActionCreatePatch : CommitActionCreatePatch, GitgExt.RefAction
+{
+ // Do this to pull in config.h before glib.h (for gettext...)
+ private const string version = Gitg.Config.VERSION;
+
+ public Gitg.Ref reference { get; construct set; }
+
+ public RefActionCreatePatch(GitgExt.Application application,
+ GitgExt.RefActionInterface action_interface,
+ Gitg.Ref reference)
+ {
+ Object(application: application,
+ action_interface: action_interface,
+ reference: reference);
+ }
+
+ public override string id
+ {
+ owned get { return "/org/gnome/gitg/ref-actions/create-patch"; }
+ }
+
+ public override string description
+ {
+ owned get { return _("Create a patch from the selected reference"); }
+ }
+
+ public override void activate()
+ {
+ try
+ {
+ commit = reference.resolve().lookup() as Gitg.Commit;
+ base.activate();
+ }
+ catch (Error e)
+ {
+ application.show_infobar (_("Failed to lookup reference"),
+ e.message,
+ Gtk.MessageType.ERROR);
+ return;
+ }
+ }
+}
+
+}
+
+// ex:set ts=4 noet
diff --git a/gitg/history/gitg-history.vala b/gitg/history/gitg-history.vala
index 36ba19a8..d2af7867 100644
--- a/gitg/history/gitg-history.vala
+++ b/gitg/history/gitg-history.vala
@@ -868,6 +868,7 @@ namespace GitgHistory
add_ref_action(actions, new Gitg.RefActionCreateBranch(application, af, reference));
add_ref_action(actions, new Gitg.RefActionCreateTag(application, af, reference));
+ add_ref_action(actions, new Gitg.RefActionCreatePatch(application, af, reference));
add_ref_action(actions, new Gitg.RefActionCheckout(application, af, reference));
add_ref_action(actions, new Gitg.RefActionRename(application, af, reference));
add_ref_action(actions, new Gitg.RefActionDelete(application, af, reference));
diff --git a/gitg/meson.build b/gitg/meson.build
index ef6f66da..ad551c6f 100644
--- a/gitg/meson.build
+++ b/gitg/meson.build
@@ -45,6 +45,7 @@ sources = gitg_sources + files(
'gitg-recursive-scanner.vala',
'gitg-ref-action-copy-name.vala',
'gitg-ref-action-create-branch.vala',
+ 'gitg-ref-action-create-patch.vala',
'gitg-ref-action-create-tag.vala',
'gitg-ref-action-delete.vala',
'gitg-ref-action-fetch.vala',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]