[gitg/wip/albfan/other-refs: 99/99] Hide unknown refs
- From: Alberto Fanjul <albfan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg/wip/albfan/other-refs: 99/99] Hide unknown refs
- Date: Tue, 19 Jul 2022 21:28:05 +0000 (UTC)
commit a1beac830393467bc8c9c4a5da2531810fa1e33d
Author: Alberto Fanjul <albertofanjul gmail com>
Date: Tue Jul 19 23:27:38 2022 +0200
Hide unknown refs
data/org.gnome.gitg.gschema.xml.in | 7 +++++++
gitg/history/gitg-history-refs-list.vala | 22 ++++++++++++++++++++++
gitg/preferences/gitg-preferences-history.vala | 8 ++++++++
gitg/resources/ui/gitg-preferences-history.ui | 20 ++++++++++++++++++--
4 files changed, 55 insertions(+), 2 deletions(-)
---
diff --git a/data/org.gnome.gitg.gschema.xml.in b/data/org.gnome.gitg.gschema.xml.in
index d10ab842..a53aad66 100644
--- a/data/org.gnome.gitg.gschema.xml.in
+++ b/data/org.gnome.gitg.gschema.xml.in
@@ -165,6 +165,13 @@
selecting a local branch in the history view.
</description>
</key>
+ <key name="filter-unknown-refs" type="b">
+ <default>false</default>
+ <summary>Filter unknown refs</summary>
+ <description>
+ Hide any ref different from refs/heads and refs/remotes.
+ </description>
+ </key>
</schema>
<schema gettext-domain="@GETTEXT_PACKAGE@" id="@APPLICATION_ID@.preferences.branch"
path="@SCHEMA_PATH@/preferences/branch/">
<key name="checkout-created-branch" type="b">
diff --git a/gitg/history/gitg-history-refs-list.vala b/gitg/history/gitg-history-refs-list.vala
index 32c67bd9..e68abee6 100644
--- a/gitg/history/gitg-history-refs-list.vala
+++ b/gitg/history/gitg-history-refs-list.vala
@@ -537,6 +537,7 @@ public class RefsList : Gtk.ListBox
private RefHeader? d_all_tags;
private RefRow.SortOrder d_ref_sort_order;
private HeaderState[] d_expanded;
+ private bool d_filter_unknown_refs = false;
public RefHeader? branches_header { get { return d_all_branches; } }
public RefHeader? remotes_header { get { return d_all_remotes; } }
public RefHeader? tags_header { get { return d_all_tags; } }
@@ -546,6 +547,7 @@ public class RefsList : Gtk.ListBox
public Gee.LinkedList<GitgExt.Action> branches_actions { get {return d_branches_actions;} set {
d_branches_actions = value; refresh();} }
public Gee.LinkedList<GitgExt.Action> remotes_actions { get {return d_remotes_actions;} set {
d_remotes_actions = value; refresh();} }
public Gee.LinkedList<GitgExt.Action> tags_actions { get {return d_tags_actions;} set {
d_tags_actions = value; refresh();} }
+ public bool filter_unknown_refs { get {return d_filter_unknown_refs;} set { d_filter_unknown_refs =
value; refresh();} }
public signal void changed();
@@ -605,6 +607,12 @@ public class RefsList : Gtk.ListBox
this,
"reference-sort-order",
SettingsBindFlags.GET | SettingsBindFlags.SET);
+
+ settings.bind("filter-unknown-refs",
+ this,
+ "filter-unknown-refs",
+ SettingsBindFlags.GET | SettingsBindFlags.SET);
+
}
public Gee.List<Gitg.Ref> references
@@ -1035,6 +1043,17 @@ public class RefsList : Gtk.ListBox
}
}
+ // Checks if the provided reference should be filtered.
+ private bool ref_is_filtered(Gitg.Ref reference)
+ {
+ if (reference.parsed_name.rtype != Gitg.RefType.REMOTE)
+ {
+ string name = reference.parsed_name.shortname;
+ return !(name.has_prefix("refs/heads") || name.has_prefix("refs/remotes"));
+ }
+ return false;
+ }
+
// Checks if the provided reference is a symbolic ref with the name HEAD.
private bool ref_is_a_symbolic_head(Gitg.Ref reference)
{
@@ -1225,6 +1244,9 @@ public class RefsList : Gtk.ListBox
{
return 0;
}
+ if (filter_unknown_refs && ref_is_filtered(r)) {
+ return 0;
+ }
var row = add_ref_internal(r);
diff --git a/gitg/preferences/gitg-preferences-history.vala b/gitg/preferences/gitg-preferences-history.vala
index c37e58d8..e5231322 100644
--- a/gitg/preferences/gitg-preferences-history.vala
+++ b/gitg/preferences/gitg-preferences-history.vala
@@ -56,6 +56,9 @@ public class PreferencesHistory : Gtk.Grid, GitgExt.Preferences
[GtkChild (name = "show_upstream_with_branch")]
private unowned Gtk.CheckButton d_show_upstream_with_branch;
+ [GtkChild (name = "filter_unknown_refs")]
+ private unowned Gtk.CheckButton d_filter_unknown_refs;
+
private Gtk.RadioButton[] d_select_buttons;
private string[] d_select_names;
@@ -159,6 +162,11 @@ public class PreferencesHistory : Gtk.Grid, GitgExt.Preferences
d_show_upstream_with_branch,
"active",
SettingsBindFlags.GET | SettingsBindFlags.SET);
+
+ settings.bind("filter-unknown-refs",
+ d_filter_unknown_refs,
+ "active",
+ SettingsBindFlags.GET | SettingsBindFlags.SET);
}
public string default_selection
diff --git a/gitg/resources/ui/gitg-preferences-history.ui b/gitg/resources/ui/gitg-preferences-history.ui
index 03a8c65b..b5f692c8 100644
--- a/gitg/resources/ui/gitg-preferences-history.ui
+++ b/gitg/resources/ui/gitg-preferences-history.ui
@@ -146,6 +146,22 @@
<property name="top_attach">4</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="filter_unknown_refs">
+ <property name="label" translatable="yes">Filter unknown refs</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="halign">start</property>
+ <property name="draw_indicator">True</property>
+ <property name="margin_start">12</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">5</property>
+ </packing>
+ </child>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
@@ -159,7 +175,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">5</property>
+ <property name="top_attach">6</property>
</packing>
</child>
<child>
@@ -270,7 +286,7 @@
</object>
<packing>
<property name="left_attach">0</property>
- <property name="top_attach">6</property>
+ <property name="top_attach">7</property>
</packing>
</child>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]