[gitg] Add setting for default selection in history view
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Add setting for default selection in history view
- Date: Sat, 8 Aug 2015 07:50:37 +0000 (UTC)
commit ec91e397c7a63199095588e260ed056709029b24
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Sat Aug 8 09:48:29 2015 +0200
Add setting for default selection in history view
https://bugzilla.gnome.org/show_bug.cgi?id=648228
data/org.gnome.gitg.gschema.xml.in.in | 13 +++
gitg/history/gitg-history-refs-list.vala | 23 ++++-
gitg/history/gitg-history.vala | 7 ++
gitg/preferences/gitg-preferences-history.vala | 63 ++++++++++++
gitg/resources/ui/gitg-preferences-history.ui | 128 +++++++++++++++---------
5 files changed, 185 insertions(+), 49 deletions(-)
---
diff --git a/data/org.gnome.gitg.gschema.xml.in.in b/data/org.gnome.gitg.gschema.xml.in.in
index 95a9c55..4ec1439 100644
--- a/data/org.gnome.gitg.gschema.xml.in.in
+++ b/data/org.gnome.gitg.gschema.xml.in.in
@@ -4,6 +4,12 @@
<value nick="vertical" value="1"/>
</enum>
+ <enum id="org.gnome.gitg.history.DefaultSelection">
+ <value nick="current-branch" value="0"/>
+ <value nick="all-branches" value="1"/>
+ <value nick="all-commits" value="2"/>
+ </enum>
+
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gitg.preferences"
path="/org/gnome/gitg/preferences/">
<child name="main" schema="org.gnome.gitg.preferences.main" />
<child name="history" schema="org.gnome.gitg.preferences.history" />
@@ -100,6 +106,13 @@
history for the current HEAD.
</_description>
</key>
+ <key name="default-selection" enum="org.gnome.gitg.history.DefaultSelection">
+ <default>'current-branch'</default>
+ <_summary>Default selection of the history activity</_summary>
+ <_description>
+ Setting that determines the default selection on startup of the history activity.
+ </_description>
+ </key>
</schema>
<schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gitg.preferences.commit"
path="/org/gnome/gitg/preferences/commit/">
<child name="message" schema="org.gnome.gitg.preferences.commit.message" />
diff --git a/gitg/history/gitg-history-refs-list.vala b/gitg/history/gitg-history-refs-list.vala
index 7691809..3a8d1f0 100644
--- a/gitg/history/gitg-history-refs-list.vala
+++ b/gitg/history/gitg-history-refs-list.vala
@@ -943,14 +943,31 @@ public class RefsList : Gtk.ListBox
if (sel == null)
{
- if (head != null)
+ var settings = new Settings("org.gnome.gitg.preferences.history");
+ var default_selection = (DefaultSelection)settings.get_enum("default-selection");
+ Gtk.ListBoxRow? srow = null;
+
+ switch (default_selection)
+ {
+ case DefaultSelection.CURRENT_BRANCH:
+ srow = head;
+ break;
+ case DefaultSelection.ALL_BRANCHES:
+ srow = d_all_branches;
+ break;
+ case DefaultSelection.ALL_COMMITS:
+ srow = d_all_commits;
+ break;
+ }
+
+ if (srow != null)
{
// Select default
- select_row(head);
+ select_row(srow);
}
else
{
- // Select all
+ // Fall back to selecting all commits
select_row(d_all_commits);
}
}
diff --git a/gitg/history/gitg-history.vala b/gitg/history/gitg-history.vala
index 474b76c..cf9a5de 100644
--- a/gitg/history/gitg-history.vala
+++ b/gitg/history/gitg-history.vala
@@ -19,6 +19,13 @@
namespace GitgHistory
{
+ public enum DefaultSelection
+ {
+ CURRENT_BRANCH,
+ ALL_BRANCHES,
+ ALL_COMMITS
+ }
+
/* The main history view. This view shows the equivalent of git log, but
* in a nice way with lanes, merges, ref labels etc.
*/
diff --git a/gitg/preferences/gitg-preferences-history.vala b/gitg/preferences/gitg-preferences-history.vala
index 0bf43c8..e32b73a 100644
--- a/gitg/preferences/gitg-preferences-history.vala
+++ b/gitg/preferences/gitg-preferences-history.vala
@@ -41,6 +41,18 @@ public class PreferencesHistory : Gtk.Grid, GitgExt.Preferences
[GtkChild (name = "mainline_head")]
private Gtk.CheckButton d_mainline_head;
+ [GtkChild (name = "select_current_branch" )]
+ private Gtk.RadioButton d_select_current_branch;
+
+ [GtkChild (name = "select_all_branches" )]
+ private Gtk.RadioButton d_select_all_branches;
+
+ [GtkChild (name = "select_all_commits" )]
+ private Gtk.RadioButton d_select_all_commits;
+
+ private Gtk.RadioButton[] d_select_buttons;
+ private string[] d_select_names;
+
private static int round_val(double val)
{
int ival = (int)val;
@@ -97,6 +109,57 @@ public class PreferencesHistory : Gtk.Grid, GitgExt.Preferences
});
update_collapse_inactive_lanes(settings);
+
+ d_select_buttons = new Gtk.RadioButton[] {
+ d_select_current_branch,
+ d_select_all_branches,
+ d_select_all_commits
+ };
+
+ d_select_names = new string[] {
+ "current-branch",
+ "all-branches",
+ "all-commits"
+ };
+
+ settings.bind("default-selection",
+ this,
+ "default-selection",
+ SettingsBindFlags.GET | SettingsBindFlags.SET);
+
+ for (var i = 0; i < d_select_buttons.length; i++) {
+ d_select_buttons[i].notify["active"].connect(() => {
+ notify_property("default-selection");
+ });
+ }
+ }
+
+ public string default_selection
+ {
+ get
+ {
+ for (var i = 0; i < d_select_buttons.length; i++)
+ {
+ if (d_select_buttons[i].active)
+ {
+ return d_select_names[i];
+ }
+ }
+
+ return d_select_names[0];
+ }
+
+ set
+ {
+ for (var i = 0; i < d_select_buttons.length; i++)
+ {
+ if (d_select_names[i] == value)
+ {
+ d_select_buttons[i].active = true;
+ return;
+ }
+ }
+ }
}
private void update_collapse_inactive_lanes(Settings settings)
diff --git a/gitg/resources/ui/gitg-preferences-history.ui b/gitg/resources/ui/gitg-preferences-history.ui
index 495655f..e2d4391 100644
--- a/gitg/resources/ui/gitg-preferences-history.ui
+++ b/gitg/resources/ui/gitg-preferences-history.ui
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.3 -->
<interface>
- <!-- interface-requires gtk+ 3.12 -->
+ <requires lib="gtk+" version="3.12"/>
<object class="GtkAdjustment" id="adjustment_collapse">
<property name="upper">5</property>
<property name="value">2</property>
@@ -11,8 +12,6 @@
<template class="GitgPreferencesHistory" parent="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="has_focus">False</property>
- <property name="is_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="border_width">12</property>
@@ -22,16 +21,12 @@
<object class="GtkGrid" id="grid2">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="has_focus">False</property>
- <property name="is_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="has_focus">False</property>
- <property name="is_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Commits</property>
<attributes>
@@ -40,29 +35,22 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
+ <property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="grid4">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="has_focus">False</property>
- <property name="is_focus">False</property>
+ <property name="margin_start">12</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
- <property name="row_spacing">6</property>
- <property name="margin_start">12</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="has_focus">False</property>
- <property name="is_focus">False</property>
<property name="receives_default">False</property>
<property name="halign">start</property>
<property name="draw_indicator">True</property>
@@ -70,24 +58,20 @@
<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="grid5">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="has_focus">False</property>
- <property name="is_focus">False</property>
- <property name="hexpand">True</property>
<property name="margin_start">12</property>
+ <property name="margin_top">6</property>
+ <property name="margin_bottom">12</property>
+ <property name="hexpand">True</property>
<child>
<object class="GtkScale" id="collapse_inactive_lanes">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="has_focus">False</property>
- <property name="is_focus">False</property>
<property name="hexpand">True</property>
<property name="adjustment">adjustment_collapse</property>
<property name="digits">0</property>
@@ -97,47 +81,36 @@
<property name="left_attach">0</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="has_focus">False</property>
- <property name="is_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Early</property>
</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>
<child>
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="has_focus">False</property>
- <property name="is_focus">False</property>
<property name="halign">end</property>
<property name="label" translatable="yes">Late</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>
</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>
<child>
@@ -146,8 +119,6 @@
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="has_focus">False</property>
- <property name="is_focus">False</property>
<property name="receives_default">False</property>
<property name="halign">start</property>
<property name="draw_indicator">True</property>
@@ -155,8 +126,6 @@
<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>
@@ -165,8 +134,6 @@
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="has_focus">False</property>
- <property name="is_focus">False</property>
<property name="receives_default">False</property>
<property name="halign">start</property>
<property name="draw_indicator">True</property>
@@ -174,24 +141,93 @@
<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>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes">Default selection</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkGrid" id="grid1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_start">12</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <child>
+ <object class="GtkRadioButton" id="select_current_branch">
+ <property name="label" translatable="yes">Current branch</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="select_all_branches">
+ <property name="label" translatable="yes">All branches</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">select_current_branch</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="select_all_commits">
+ <property name="label" translatable="yes">All commits</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="halign">start</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">select_current_branch</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</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>
</template>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]