Added history preference panel

This commit is contained in:
Jesse van den Kieboom 2012-07-18 17:36:24 +02:00
parent 9b3ec06aea
commit acf00552e0
7 changed files with 457 additions and 1 deletions

View file

@ -297,6 +297,7 @@ tests/Makefile
plugins/Makefile
plugins/dash/Makefile
plugins/history/Makefile
plugins/history/org.gnome.gitg.history.gschema.xml.in
plugins/diff/Makefile
plugins/diff/icons/Makefile
plugins/files/Makefile

View file

@ -6,6 +6,11 @@ INCLUDES = \
-DDATADIR=\""$(datadir)"\" \
-DLIBDIR=\""$(libdir)"\"
gsettings_SCHEMAS = org.gnome.gitg.history.gschema.xml
@INTLTOOL_XML_NOMERGE_RULE@
@GSETTINGS_RULES@
plugindir = $(GITG_PLUGIN_LIBDIR)
plugin_LTLIBRARIES = libhistory.la
plugin_DATA = history.plugin
@ -14,7 +19,8 @@ VALAFLAGS = $(GITG_PLUGIN_VALAFLAGS)
VALA_SOURCES = \
gitg-history.vala \
gitg-history-navigation.vala \
gitg-history-command-line.vala
gitg-history-command-line.vala \
gitg-history-preferences.vala
libhistory_la_LDFLAGS = $(GITG_PLUGIN_LIBTOOL_FLAGS)
libhistory_la_LIBADD = $(GITG_PLUGIN_LIBS)

View file

@ -0,0 +1,141 @@
/*
* 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 GitgHistory
{
public class Preferences : Object, GitgExt.Preferences
{
// Do this to pull in config.h before glib.h (for gettext...)
private const string version = Gitg.Config.VERSION;
private Gtk.Widget? d_widget;
private bool d_block;
private void bind_check(Settings settings, string setting, Object obj)
{
settings.bind(setting,
obj,
"active",
SettingsBindFlags.GET |
SettingsBindFlags.SET);
}
private static int round_val(double val)
{
int ival = (int)val;
return ival + (int)(val - ival > 0.5);
}
private Gtk.Widget build_ui()
{
if (d_widget != null)
{
return d_widget;
}
var settings = new Settings("org.gnome.gitg.history.preferences");
var ret = GitgExt.UI.from_builder("history/preferences.ui",
"main",
"collapse_inactive_lanes_enabled",
"collapse_inactive_lanes",
"topological_order",
"show_stash",
"show_staged",
"show_unstaged");
d_widget = ret["main"] as Gtk.Widget;
bind_check(settings,
"collapse-inactive-lanes-enabled",
ret["collapse_inactive_lanes_enabled"]);
bind_check(settings, "topological-order", ret["topological_order"]);
bind_check(settings, "show-stash", ret["show_stash"]);
bind_check(settings, "show-staged", ret["show_staged"]);
bind_check(settings, "show-unstaged", ret["show_unstaged"]);
var collapse = ret["collapse_inactive_lanes"] as Gtk.Scale;
collapse.get_adjustment().value_changed.connect((adj) => {
if (d_block)
{
return;
}
var nval = round_val(adj.get_value());
var val = settings.get_int("collapse-inactive-lanes");
if (val != nval)
{
settings.set_int("collapse-inactive-lanes", nval);
}
d_block = true;
adj.set_value(nval);
d_block = false;
});
var monsig = settings.changed["collapse-inactive-lanes"].connect((s, k) => {
d_block = true;
update_collapse_inactive_lanes(settings, collapse);
d_block = false;
});
d_widget.destroy.connect((w) => {
settings.disconnect(monsig);
});
update_collapse_inactive_lanes(settings, collapse);
return d_widget;
}
private static void update_collapse_inactive_lanes(Settings settings, Gtk.Scale collapse)
{
var val = round_val(collapse.get_value());
var nval = settings.get_int("collapse-inactive-lanes");
if (val != nval)
{
collapse.set_value((double)nval);
}
}
public Gtk.Widget widget
{
owned get
{
return build_ui();
}
}
public string id
{
owned get { return "/org/gnome/gitg/Preferences/History"; }
}
public string display_name
{
owned get { return _("History"); }
}
}
}
// vi:ts=4

View file

@ -251,6 +251,9 @@ public void peas_register_types(TypeModule module)
mod.register_extension_type(typeof(GitgExt.CommandLine),
typeof(GitgHistory.CommandLine));
mod.register_extension_type(typeof(GitgExt.Preferences),
typeof(GitgHistory.Preferences));
}
// ex: ts=4 noet

View file

@ -0,0 +1,52 @@
<schemalist>
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gitg.history" path="/org/gnome/gitg/history/">
<child name="preferences" schema="org.gnome.gitg.history.preferences" />
</schema>
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gitg.history.preferences" path="/org/gnome/gitg/history/preferences/">
<key name="collapse-inactive-lanes" type="i">
<default>2</default>
<_summary>When to Collapse Inactive Lanes</_summary>
<_description>
Setting that indicates when an inactive lane should be collapsed.
Valid values are 0 - 4, where 0 indicates 'early' and 4 indicates 'late'.
</_description>
</key>
<key name="collapse-inactive-lanes-enabled" type="b">
<default>true</default>
<_description>
Setting that indicates whether to collapse history lanes which do not
show activity. Enabling this can provide a cleaner history view when
there is a lot of parallel development. See collapse-inactive-lanes
to control when lanes should be collapsed.
</_description>
</key>
<key name="topological-order" type="b">
<default>false</default>
<_summary>Show History in Topological Order</_summary>
<_description>
Setting that indicates whether to show the history in topological order.
</_description>
</key>
<key name="show-stash" type="b">
<default>true</default>
<_description>
Setting that indicates whether to show items for the stash in the
history.
</_description>
</key>
<key name="show-staged" type="b">
<default>true</default>
<_description>
Setting that indicates whether to show a virtual item for the currently
staged changes in the history.
</_description>
</key>
<key name="show-unstaged" type="b">
<default>true</default>
<_description>
Setting that indicates whether to show a virtual item for the currently
unstaged changes in the history.
</_description>
</key>
</schema>
</schemalist>

View file

@ -0,0 +1,252 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkAdjustment" id="adjustment_collapse">
<property name="upper">5</property>
<property name="value">2</property>
<property name="lower">0</property>
<property name="step_increment">1</property>
<property name="page_increment">1</property>
<property name="page_size">1</property>
</object>
<object class="GtkGrid" id="main">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="border_width">12</property>
<property name="row_spacing">18</property>
<property name="column_spacing">18</property>
<child>
<object class="GtkGrid" id="grid2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="row_spacing">6</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Commits&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="grid3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes"> </property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="grid4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="row_spacing">6</property>
<child>
<object class="GtkCheckButton" id="collapse_inactive_lanes_enabled">
<property name="label" translatable="yes">Collapse inactive lanes</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="show_stash">
<property name="label" translatable="yes">Show stash in history</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="show_staged">
<property name="label" translatable="yes">Show staged changes in history</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="show_unstaged">
<property name="label" translatable="yes">Show unstaged changes in history</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="topological_order">
<property name="label" translatable="yes">Show history in topological order</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="xalign">0</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="grid5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes"> </property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">2</property>
</packing>
</child>
<child>
<object class="GtkScale" id="collapse_inactive_lanes">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="adjustment">adjustment_collapse</property>
<property name="round_digits">1</property>
<property name="digits">0</property>
<property name="draw_value">False</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="width">2</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Early</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Late</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
<property name="width">1</property>
<property name="height">1</property>
</packing>
</child>
</object>
</interface>

View file

@ -2,6 +2,7 @@
<gresources>
<gresource prefix="/org/gnome/gitg/history">
<file>view-history.ui</file>
<file>preferences.ui</file>
</gresource>
</gresources>