[gitg/wip/actions: 7/26] Implement GitgExt.Action interface



commit 3818eacb09c8c5f4136e07fe95949e1d8be635c2
Author: Jesse van den Kieboom <jessevdk gmail com>
Date:   Sat Jan 18 13:21:39 2014 +0100

    Implement GitgExt.Action interface

 gitg/gitg-ref-action-delete.vala |   27 ++++++++++++++++++++++++---
 gitg/gitg-ref-action-rename.vala |   23 +++++++++++++++++++----
 2 files changed, 43 insertions(+), 7 deletions(-)
---
diff --git a/gitg/gitg-ref-action-delete.vala b/gitg/gitg-ref-action-delete.vala
index a892f38..cbc961e 100644
--- a/gitg/gitg-ref-action-delete.vala
+++ b/gitg/gitg-ref-action-delete.vala
@@ -22,20 +22,41 @@ namespace Gitg
 
 class RefActionDelete : GitgExt.Action, GitgExt.RefAction, Object
 {
-       public Ggit.Ref reference { get; construct set; }
+       // Do this to pull in config.h before glib.h (for gettext...)
+       private const string version = Gitg.Config.VERSION;
+
        public GitgExt.ActionInterface action_interface { get; construct set; }
+       public Ggit.Ref reference { get; construct set; }
+
+       public RefActionDelete(GitgExt.ActionInterface action_interface, Ggit.Ref reference)
+       {
+               Object(action_interface: action_interface, reference: reference);
+       }
 
        public string label
        {
-               get { return "Delete"; }
+               get { return _("Delete"); }
        }
 
        public bool enabled
        {
+               get
+               {
+                       var r = reference as Gitg.Ref;
+                       var rtype = r.parsed_name.rtype;
+
+                       return    rtype == RefType.BRANCH
+                              || rtype == RefType.TAG
+                              || rtype == RefType.REMOTE;
+               }
+       }
+
+       public bool visible
+       {
                get { return true; }
        }
 
-       public void activate()
+       public void activated()
        {
        }
 }
diff --git a/gitg/gitg-ref-action-rename.vala b/gitg/gitg-ref-action-rename.vala
index f914021..a83e19c 100644
--- a/gitg/gitg-ref-action-rename.vala
+++ b/gitg/gitg-ref-action-rename.vala
@@ -22,21 +22,36 @@ namespace Gitg
 
 class RefActionRename : GitgExt.Action, GitgExt.RefAction, Object
 {
-       public Ggit.Ref reference { get; construct set; }
+       // Do this to pull in config.h before glib.h (for gettext...)
+       private const string version = Gitg.Config.VERSION;
+
        public GitgExt.ActionInterface action_interface { get; construct set; }
+       public Ggit.Ref reference { get; construct set; }
+
+       public RefActionRename(GitgExt.ActionInterface action_interface, Ggit.Ref reference)
+       {
+               Object(action_interface: action_interface, reference: reference);
+       }
 
        public string label
        {
-               get { return "Rename"; }
+               get { return _("Rename"); }
        }
 
-       public bool enabled
+       public bool visible
        {
                get { return true; }
        }
 
-       public void activate()
+       public bool enabled
        {
+               get
+               {
+                       var r = reference as Gitg.Ref;
+                       var rtype = r.parsed_name.rtype;
+
+                       return rtype == RefType.BRANCH || rtype == RefType.TAG;
+               }
        }
 }
 


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