2012-07-17 07:55:09 +00:00
|
|
|
/*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace GitgDiff
|
|
|
|
{
|
2013-07-01 08:15:25 +00:00
|
|
|
public class Panel : Object, GitgExt.UIElement, GitgExt.HistoryPanel
|
2012-07-17 07:55:09 +00:00
|
|
|
{
|
2012-07-17 08:59:28 +00:00
|
|
|
// Do this to pull in config.h before glib.h (for gettext...)
|
|
|
|
private const string version = Gitg.Config.VERSION;
|
|
|
|
|
2012-07-17 07:55:09 +00:00
|
|
|
public GitgExt.Application? application { owned get; construct set; }
|
2013-07-01 08:15:25 +00:00
|
|
|
public GitgExt.History? history { owned get; construct set; }
|
|
|
|
|
2013-02-18 12:53:39 +00:00
|
|
|
private Gtk.ScrolledWindow d_sw;
|
2013-06-23 12:40:04 +00:00
|
|
|
private Gitg.DiffView d_diff;
|
|
|
|
private Gitg.WhenMapped d_whenMapped;
|
2012-07-17 07:55:09 +00:00
|
|
|
|
|
|
|
construct
|
|
|
|
{
|
2013-02-18 12:53:39 +00:00
|
|
|
d_sw = new Gtk.ScrolledWindow(null, null);
|
|
|
|
d_sw.show();
|
2013-07-01 08:15:25 +00:00
|
|
|
|
2013-07-03 16:23:53 +00:00
|
|
|
d_diff = new Gitg.DiffView();
|
2014-06-30 21:02:30 +00:00
|
|
|
|
2014-07-09 19:42:55 +00:00
|
|
|
var settings = new Settings("org.gnome.gitg.preferences.diff");
|
2014-06-30 21:02:30 +00:00
|
|
|
|
|
|
|
settings.bind("ignore-whitespace",
|
|
|
|
d_diff,
|
|
|
|
"ignore-whitespace",
|
|
|
|
SettingsBindFlags.GET |
|
|
|
|
SettingsBindFlags.SET);
|
|
|
|
|
2014-07-09 19:42:55 +00:00
|
|
|
settings.bind("changes-inline",
|
|
|
|
d_diff,
|
|
|
|
"changes-inline",
|
|
|
|
SettingsBindFlags.GET |
|
|
|
|
SettingsBindFlags.SET);
|
|
|
|
|
|
|
|
settings.bind("context-lines",
|
|
|
|
d_diff,
|
|
|
|
"context-lines",
|
|
|
|
SettingsBindFlags.GET |
|
|
|
|
SettingsBindFlags.SET);
|
|
|
|
|
2012-07-17 07:55:09 +00:00
|
|
|
d_diff.show();
|
2013-07-01 08:15:25 +00:00
|
|
|
|
2013-02-18 12:53:39 +00:00
|
|
|
d_sw.add(d_diff);
|
2012-07-17 07:55:09 +00:00
|
|
|
|
2013-06-23 12:40:04 +00:00
|
|
|
d_whenMapped = new Gitg.WhenMapped(d_sw);
|
2013-03-01 15:11:06 +00:00
|
|
|
|
2013-07-01 08:15:25 +00:00
|
|
|
history.selection_changed.connect(on_selection_changed);
|
|
|
|
on_selection_changed(history);
|
2012-07-17 07:55:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public string id
|
|
|
|
{
|
|
|
|
owned get { return "/org/gnome/gitg/Panels/Diff"; }
|
|
|
|
}
|
|
|
|
|
2012-07-17 20:52:06 +00:00
|
|
|
public bool available
|
2012-07-17 07:55:09 +00:00
|
|
|
{
|
2013-07-01 08:15:25 +00:00
|
|
|
get { return true; }
|
2012-07-17 07:55:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public string display_name
|
|
|
|
{
|
2012-07-17 08:59:28 +00:00
|
|
|
owned get { return _("Diff"); }
|
2012-07-17 07:55:09 +00:00
|
|
|
}
|
|
|
|
|
2014-07-01 15:49:43 +00:00
|
|
|
public string description
|
|
|
|
{
|
|
|
|
owned get { return _("Show the changes introduced by the selected commit"); }
|
|
|
|
}
|
|
|
|
|
2013-02-25 20:57:52 +00:00
|
|
|
public string? icon
|
2012-07-17 07:55:09 +00:00
|
|
|
{
|
2013-02-25 20:57:52 +00:00
|
|
|
owned get { return "diff-symbolic"; }
|
2012-07-17 07:55:09 +00:00
|
|
|
}
|
|
|
|
|
2013-07-01 08:15:25 +00:00
|
|
|
private void on_selection_changed(GitgExt.History history)
|
2013-05-23 16:35:43 +00:00
|
|
|
{
|
2013-07-01 08:15:25 +00:00
|
|
|
history.foreach_selected((commit) => {
|
2013-02-25 20:57:52 +00:00
|
|
|
var c = commit as Gitg.Commit;
|
2012-07-17 07:55:09 +00:00
|
|
|
|
|
|
|
if (c != null)
|
|
|
|
{
|
2013-03-01 15:11:06 +00:00
|
|
|
d_whenMapped.update(() => {
|
|
|
|
d_diff.commit = c;
|
|
|
|
}, this);
|
|
|
|
|
2012-07-17 07:55:09 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public Gtk.Widget? widget
|
|
|
|
{
|
2013-07-01 08:15:25 +00:00
|
|
|
owned get { return d_sw; }
|
2012-07-17 07:55:09 +00:00
|
|
|
}
|
|
|
|
|
2012-07-17 20:52:06 +00:00
|
|
|
public bool enabled
|
2012-07-17 07:55:09 +00:00
|
|
|
{
|
2013-07-01 08:15:25 +00:00
|
|
|
get { return true; }
|
2012-07-17 07:55:09 +00:00
|
|
|
}
|
2012-07-17 20:52:27 +00:00
|
|
|
|
|
|
|
public int negotiate_order(GitgExt.UIElement other)
|
|
|
|
{
|
|
|
|
// Should appear before the files
|
2012-07-18 07:35:28 +00:00
|
|
|
if (other.id == "/org/gnome/gitg/Panels/Files")
|
2012-07-17 20:52:27 +00:00
|
|
|
{
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2012-07-17 07:55:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[ModuleInit]
|
|
|
|
public void peas_register_types(TypeModule module)
|
|
|
|
{
|
|
|
|
Peas.ObjectModule mod = module as Peas.ObjectModule;
|
|
|
|
|
2013-07-01 08:15:25 +00:00
|
|
|
mod.register_extension_type(typeof(GitgExt.HistoryPanel),
|
2012-07-17 07:55:09 +00:00
|
|
|
typeof(GitgDiff.Panel));
|
|
|
|
}
|
|
|
|
|
|
|
|
// ex: ts=4 noet
|