[gitg/add-ref-actions: 2/3] Added reference action to add tags




commit 24bd752450ba77c1b4baa18af0ea10427dff4450
Author: Adwait Rawat <adwait rawat gmail com>
Date:   Sun Jun 16 18:17:26 2019 +0900

    Added reference action to add tags

 gitg/gitg-commit-action-create-tag.vala |  6 +--
 gitg/gitg-ref-action-create-tag.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-tag.vala b/gitg/gitg-commit-action-create-tag.vala
index 4866d821..4aa82696 100644
--- a/gitg/gitg-commit-action-create-tag.vala
+++ b/gitg/gitg-commit-action-create-tag.vala
@@ -38,7 +38,7 @@ class CommitActionCreateTag : GitgExt.UIElement, GitgExt.Action, GitgExt.CommitA
                       commit:           commit);
        }
 
-       public string id
+       public virtual string id
        {
                owned get { return "/org/gnome/gitg/commit-actions/create-tag"; }
        }
@@ -48,12 +48,12 @@ class CommitActionCreateTag : GitgExt.UIElement, GitgExt.Action, GitgExt.CommitA
                owned get { return _("Create tag"); }
        }
 
-       public string description
+       public virtual string description
        {
                owned get { return _("Create a new tag at the selected commit"); }
        }
 
-       public void activate()
+       public virtual void activate()
        {
                var dlg = new CreateTagDialog((Gtk.Window)application);
 
diff --git a/gitg/gitg-ref-action-create-tag.vala b/gitg/gitg-ref-action-create-tag.vala
new file mode 100644
index 00000000..d4cee457
--- /dev/null
+++ b/gitg/gitg-ref-action-create-tag.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 RefActionCreateTag : CommitActionCreateTag, 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 RefActionCreateTag(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-tag"; }
+       }
+
+       public override string description
+       {
+               owned get { return _("Create a new tag at 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 a4dddf0d..36ba19a8 100644
--- a/gitg/history/gitg-history.vala
+++ b/gitg/history/gitg-history.vala
@@ -867,6 +867,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.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 1bc5de60..ef6f66da 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-tag.vala',
   'gitg-ref-action-delete.vala',
   'gitg-ref-action-fetch.vala',
   'gitg-ref-action-push.vala',


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