shell: Hardcode panel list order

Per the latest mockups [1], the panel list must be sorted
by the category, and then follow a manual predefined order.

This commit adds the hardcoded order to the the panel list.

[1] https://raw.githubusercontent.com/gnome-design-team/gnome-mockups/master/system-settings/shell/settings-organization.png
This commit is contained in:
Georges Basile Stavracas Neto 2017-08-12 11:03:17 -03:00
parent aae4dd842b
commit 5c4f2ff8a6
2 changed files with 64 additions and 2 deletions

View file

@ -8,7 +8,7 @@ Terminal=false
Type=Application
NoDisplay=true
StartupNotify=true
Categories=GNOME;GTK;Settings;HardwareSettings;X-GNOME-Settings-Panel;X-GNOME-ConnectivitySettings;
Categories=GNOME;GTK;Settings;HardwareSettings;X-GNOME-Settings-Panel;
OnlyShowIn=GNOME;Unity;
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=gnome-control-center

View file

@ -261,6 +261,54 @@ filter_func (GtkListBoxRow *row,
return retval;
}
static const gchar * const panel_order[] = {
/* Main page */
"wifi",
"mobile-broadband",
"bluetooth",
"background",
"notifications",
"search",
"region",
"universal-access",
"online-accounts",
"privacy",
"sharing",
"sound",
"power",
"network",
/* Devices page */
"printers",
"keyboard",
"mouse",
"display",
"removable-media",
"wacom",
"color",
/* Details page */
"info-overview",
"datetime",
"user-accounts",
"default-apps",
"reset-settings"
};
static guint
get_panel_id_index (const gchar *panel_id)
{
guint i;
for (i = 0; i < G_N_ELEMENTS (panel_order); i++)
{
if (g_str_equal (panel_order[i], panel_id))
return i;
}
return 0;
}
static gint
sort_function (GtkListBoxRow *a,
GtkListBoxRow *b,
@ -291,7 +339,7 @@ sort_function (GtkListBoxRow *a,
if (a_data->category != b_data->category)
return a_data->category - b_data->category;
return g_strcmp0 (a_data->name, b_data->name);
return get_panel_id_index (a_data->id) - get_panel_id_index (b_data->id);
}
static gint
@ -398,6 +446,10 @@ header_func (GtkListBoxRow *row,
gtk_list_box_row_set_header (row, separator);
}
else
{
gtk_list_box_row_set_header (row, NULL);
}
}
}
@ -663,6 +715,16 @@ cc_panel_list_init (CcPanelList *self)
self,
NULL);
gtk_list_box_set_sort_func (GTK_LIST_BOX (self->details_listbox),
sort_function,
self,
NULL);
gtk_list_box_set_sort_func (GTK_LIST_BOX (self->devices_listbox),
sort_function,
self,
NULL);
gtk_list_box_set_header_func (GTK_LIST_BOX (self->main_listbox),
header_func,
self,