Add RefActionFetch

This commit is contained in:
Jesse van den Kieboom 2014-12-21 22:01:06 +01:00
parent c8d19f3f66
commit 0bdd143e50
3 changed files with 100 additions and 0 deletions

View file

@ -63,6 +63,7 @@ gitg_gitg_VALASOURCES = \
gitg/gitg-ref-action-rename.vala \
gitg/gitg-ref-action-delete.vala \
gitg/gitg-ref-action-copy-name.vala \
gitg/gitg-ref-action-fetch.vala \
gitg/gitg-commit-action-create-branch.vala \
gitg/gitg-create-branch-dialog.vala \
gitg/gitg-commit-action-create-tag.vala \

View file

@ -0,0 +1,94 @@
/*
* This file is part of gitg
*
* Copyright (C) 2014 - Jesse van den Kieboom
*
* 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 RefActionFetch : GitgExt.UIElement, GitgExt.Action, GitgExt.RefAction, Object
{
// Do this to pull in config.h before glib.h (for gettext...)
private const string version = Gitg.Config.VERSION;
public GitgExt.Application? application { owned get; construct set; }
public GitgExt.RefActionInterface action_interface { get; construct set; }
public Gitg.Ref reference { get; construct set; }
private Gitg.Ref? d_remote;
public RefActionFetch(GitgExt.Application application,
GitgExt.RefActionInterface action_interface,
Gitg.Ref reference)
{
Object(application: application,
action_interface: action_interface,
reference: reference);
var branch = reference as Ggit.Branch;
if (branch != null)
{
try
{
d_remote = branch.get_upstream() as Gitg.Ref;
} catch {}
}
else if (reference.parsed_name.remote_name != null)
{
d_remote = reference;
}
}
public string id
{
owned get { return "/org/gnome/gitg/ref-actions/fetch"; }
}
public string display_name
{
owned get
{
if (d_remote != null)
{
return _("Fetch from %s").printf(d_remote.parsed_name.remote_name);
}
else
{
return "";
}
}
}
public string description
{
owned get { return _("Fetch remote objects from %s").printf(d_remote.parsed_name.remote_name); }
}
public bool available
{
get { return d_remote != null; }
}
public void activate()
{
// TODO
}
}
}
// ex:set ts=4 noet

View file

@ -551,6 +551,7 @@ namespace GitgHistory
add_ref_action(actions, new Gitg.RefActionRename(application, af, reference));
add_ref_action(actions, new Gitg.RefActionDelete(application, af, reference));
add_ref_action(actions, new Gitg.RefActionCopyName(application, af, reference));
add_ref_action(actions, new Gitg.RefActionFetch(application, af, reference));
var exts = new Peas.ExtensionSet(Gitg.PluginsEngine.get_default(),
typeof(GitgExt.RefAction),
@ -577,6 +578,10 @@ namespace GitgHistory
ac.populate_menu(menu);
}
var sep = new Gtk.SeparatorMenuItem();
sep.show();
menu.append(sep);
var item = new Gtk.CheckMenuItem.with_label(_("Mainline"));
int pos = 0;