gitg/libgitg/gitg-commit.vala

121 lines
2.2 KiB
Vala
Raw Normal View History

/*
* This file is part of gitg
*
* Copyright (C) 2012 - 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/>.
*/
2012-04-14 11:46:39 +00:00
namespace Gitg
{
public class Commit : Ggit.Commit
{
2012-04-22 13:11:43 +00:00
public LaneTag tag { get; set; }
private uint d_mylane;
2012-04-24 22:01:27 +00:00
private SList<Lane> d_lanes;
2012-04-14 11:46:39 +00:00
2012-04-24 22:01:27 +00:00
public unowned SList<Lane> get_lanes()
{
return d_lanes;
}
2012-04-14 11:46:39 +00:00
2012-04-22 13:11:43 +00:00
public uint mylane
2012-04-14 11:46:39 +00:00
{
get { return d_mylane; }
set
{
d_mylane = value;
update_lane_tag();
}
}
2012-04-22 13:11:43 +00:00
public Lane lane
2012-04-14 11:46:39 +00:00
{
2012-04-24 22:01:27 +00:00
get { return d_lanes.nth_data(d_mylane); }
}
public unowned SList<Lane> insert_lane(Lane lane, int idx)
{
d_lanes.insert(lane, idx);
return d_lanes;
2012-04-14 11:46:39 +00:00
}
public unowned SList<Lane> remove_lane(Lane lane)
{
2012-04-24 22:01:27 +00:00
d_lanes.remove(lane);
return d_lanes;
2012-04-14 11:46:39 +00:00
}
private void update_lane_tag()
{
2012-04-24 22:01:27 +00:00
unowned Lane? lane = d_lanes.nth_data(d_mylane);
2012-04-14 11:46:39 +00:00
if (lane == null)
{
return;
}
2012-04-22 13:11:43 +00:00
lane.tag &= ~(LaneTag.SIGN_STASH |
LaneTag.SIGN_STAGED |
LaneTag.SIGN_UNSTAGED) | tag;
2012-04-14 11:46:39 +00:00
}
2012-04-22 13:11:43 +00:00
public void update_lanes(owned SList<Lane> lanes, int mylane)
2012-04-14 11:46:39 +00:00
{
2012-04-24 22:01:27 +00:00
d_lanes = (owned)lanes;
2012-04-14 11:46:39 +00:00
if (mylane >= 0)
{
d_mylane = (ushort)mylane;
}
update_lane_tag();
}
public string format_patch_name
{
owned get
{
return get_subject().replace(" ", "-").replace("/", "-");;
}
}
private string date_for_display(DateTime dt)
{
return dt.format("%c");
}
public string committer_date_for_display
{
owned get
{
return date_for_display(get_committer().get_time());
}
}
public string author_date_for_display
{
owned get
{
return date_for_display(get_author().get_time());
}
}
}
}
// ex:set ts=4 noet