mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-10-01 05:33:49 +00:00
Add RefActionFetch
This commit is contained in:
parent
c8d19f3f66
commit
0bdd143e50
|
@ -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 \
|
||||
|
|
94
gitg/gitg-ref-action-fetch.vala
Normal file
94
gitg/gitg-ref-action-fetch.vala
Normal 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
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue