Skip to content

Commit 89985cb

Browse files
authored
Revert "SettingsSideBar: Fix selection of the correct row (#336)" (#340)
This reverts commit 054ab20.
1 parent f91e555 commit 89985cb

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

lib/SettingsSidebar.vala

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,32 @@ public class Switchboard.SettingsSidebar : Gtk.Widget {
2424
public bool show_title_buttons { get; set;}
2525

2626
/**
27-
* The name of the currently visible {@link SettingsPage}.
28-
* Beware this is the name of the page as set via {@link Gtk.Stack.add_named}
29-
* and not the title of the page.
27+
* The name of the currently visible Granite.SettingsPage
3028
*/
3129
public string? visible_child_name {
3230
get {
33-
return stack.visible_child_name;
31+
var selected_row = listbox.get_selected_row ();
32+
33+
if (selected_row == null) {
34+
return null;
35+
} else {
36+
return ((SettingsSidebarRow) selected_row).page.title;
37+
}
3438
}
3539
set {
36-
for (unowned var child = listbox.get_first_child (); child != null; child = child.get_next_sibling ()) {
37-
if (!(child is SettingsSidebarRow)) {
40+
weak Gtk.Widget listbox_child = listbox.get_first_child ();
41+
while (listbox_child != null) {
42+
if (!(listbox_child is SettingsSidebarRow)) {
43+
listbox_child = listbox_child.get_next_sibling ();
3844
continue;
3945
}
4046

41-
if (((SettingsSidebarRow) child).page_name == value) {
42-
listbox.select_row ((Gtk.ListBoxRow) child);
47+
if (((SettingsSidebarRow) listbox_child).page.title == value) {
48+
listbox.select_row ((Gtk.ListBoxRow) listbox_child);
4349
break;
4450
}
51+
52+
listbox_child = listbox_child.get_next_sibling ();
4553
}
4654
}
4755
}
@@ -126,7 +134,7 @@ public class Switchboard.SettingsSidebar : Gtk.Widget {
126134
private Gtk.Widget create_widget_func (Object object) {
127135
unowned var stack_page = (Gtk.StackPage) object;
128136
unowned var page = (SettingsPage) stack_page.child;
129-
var row = new SettingsSidebarRow (stack_page.name, page);
137+
var row = new SettingsSidebarRow (page);
130138

131139
return row;
132140
}

lib/SettingsSidebarRow.vala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
*/
55

66
private class Switchboard.SettingsSidebarRow : Gtk.ListBoxRow {
7-
public string page_name { get; construct; }
8-
97
public SettingsPage.StatusType status_type {
108
set {
119
switch (value) {
@@ -59,9 +57,8 @@ private class Switchboard.SettingsSidebarRow : Gtk.ListBoxRow {
5957
private Gtk.Label title_label;
6058
private string _title;
6159

62-
public SettingsSidebarRow (string page_name, SettingsPage page) {
60+
public SettingsSidebarRow (SettingsPage page) {
6361
Object (
64-
page_name: page_name,
6562
page: page
6663
);
6764
}

0 commit comments

Comments
 (0)