[gitg/add-ref-actions: 1/3] Added reference action to create branch
- From: Alberto Fanjul <albfan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg/add-ref-actions: 1/3] Added reference action to create branch
- Date: Sat, 29 Jan 2022 09:52:10 +0000 (UTC)
commit 6359ee3eec0c9c0a8286e91ab93d63b70a5be544
Author: Adwait Rawat <adwait rawat gmail com>
Date: Sun Jun 16 18:12:21 2019 +0900
Added reference action to create branch
gitg/gitg-commit-action-create-branch.vala | 6 +--
gitg/gitg-ref-action-create-branch.vala | 68 ++++++++++++++++++++++++++++++
gitg/history/gitg-history.vala | 1 +
gitg/meson.build | 1 +
libgitg-ext/gitg-ext-ref-action.vala | 1 +
5 files changed, 74 insertions(+), 3 deletions(-)
---
diff --git a/gitg/gitg-commit-action-create-branch.vala b/gitg/gitg-commit-action-create-branch.vala
index ff30f522..8a6a93dd 100644
--- a/gitg/gitg-commit-action-create-branch.vala
+++ b/gitg/gitg-commit-action-create-branch.vala
@@ -38,7 +38,7 @@ class CommitActionCreateBranch : GitgExt.UIElement, GitgExt.Action, GitgExt.Comm
commit: commit);
}
- public string id
+ public virtual string id
{
owned get { return "/org/gnome/gitg/commit-actions/create-branch"; }
}
@@ -48,12 +48,12 @@ class CommitActionCreateBranch : GitgExt.UIElement, GitgExt.Action, GitgExt.Comm
owned get { return _("Create branch"); }
}
- public string description
+ public virtual string description
{
owned get { return _("Create a new branch at the selected commit"); }
}
- public void activate()
+ public virtual void activate()
{
var dlg = new CreateBranchDialog((Gtk.Window)application);
diff --git a/gitg/gitg-ref-action-create-branch.vala b/gitg/gitg-ref-action-create-branch.vala
new file mode 100644
index 00000000..d34bb2f8
--- /dev/null
+++ b/gitg/gitg-ref-action-create-branch.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 RefActionCreateBranch : CommitActionCreateBranch, 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 RefActionCreateBranch(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-branch"; }
+ }
+
+ public override string description
+ {
+ owned get { return _("Create a new branch 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 e8933f67..a4dddf0d 100644
--- a/gitg/history/gitg-history.vala
+++ b/gitg/history/gitg-history.vala
@@ -866,6 +866,7 @@ namespace GitgHistory
d_ignore_external = true;
});
+ add_ref_action(actions, new Gitg.RefActionCreateBranch(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 8ebe490d..1bc5de60 100644
--- a/gitg/meson.build
+++ b/gitg/meson.build
@@ -44,6 +44,7 @@ sources = gitg_sources + files(
'gitg-recursive-monitor.vala',
'gitg-recursive-scanner.vala',
'gitg-ref-action-copy-name.vala',
+ 'gitg-ref-action-create-branch.vala',
'gitg-ref-action-delete.vala',
'gitg-ref-action-fetch.vala',
'gitg-ref-action-push.vala',
diff --git a/libgitg-ext/gitg-ext-ref-action.vala b/libgitg-ext/gitg-ext-ref-action.vala
index 7ed09f4a..97986ac7 100644
--- a/libgitg-ext/gitg-ext-ref-action.vala
+++ b/libgitg-ext/gitg-ext-ref-action.vala
@@ -24,6 +24,7 @@ public interface RefAction : Action
{
public abstract RefActionInterface action_interface { get; construct set; }
public abstract Gitg.Ref reference { get; construct set; }
+ public signal void finished();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]