[yelp] Sort page types from a static list, instead of just strcmp
- From: Shaun McCance <shaunm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [yelp] Sort page types from a static list, instead of just strcmp
- Date: Fri, 30 Apr 2010 02:29:47 +0000 (UTC)
commit 24c0d9cd2a5c9c93e3192e738a779a680f3164d9
Author: Shaun McCance <shaunm gnome org>
Date: Thu Apr 29 21:29:21 2010 -0500
Sort page types from a static list, instead of just strcmp
libyelp/yelp-settings.c | 26 ++++++++++++++++++++++++++
libyelp/yelp-settings.h | 3 +++
src/yelp-window.c | 5 ++---
3 files changed, 31 insertions(+), 3 deletions(-)
---
diff --git a/libyelp/yelp-settings.c b/libyelp/yelp-settings.c
index bc60e11..7e3d4ab 100644
--- a/libyelp/yelp-settings.c
+++ b/libyelp/yelp-settings.c
@@ -936,6 +936,32 @@ icon_theme_changed (GtkIconTheme *theme,
g_signal_emit (settings, settings_signals[ICONS_CHANGED], 0);
}
+gint
+yelp_settings_cmp_icons (const gchar *icon1,
+ const gchar *icon2)
+{
+ static const gchar *icons[] = {
+ "yelp-page-task",
+ "yelp-page-video",
+ "yelp-page-tip",
+ "yelp-page-ui",
+ "help-contents",
+ NULL
+ };
+ gint i;
+ for (i = 0; icons[i] != NULL; i++) {
+ gboolean eq1 = g_str_equal (icon1, icons[i]);
+ gboolean eq2 = g_str_equal (icon2, icons[i]);
+ if (eq1 && eq2)
+ return 0;
+ else if (eq1)
+ return -1;
+ else if (eq2)
+ return 1;
+ }
+ return strcmp (icon1, icon2);
+}
+
/******************************************************************************/
static void
diff --git a/libyelp/yelp-settings.h b/libyelp/yelp-settings.h
index 0c8fbd0..bf6af53 100644
--- a/libyelp/yelp-settings.h
+++ b/libyelp/yelp-settings.h
@@ -126,6 +126,9 @@ gboolean yelp_settings_get_editor_mode (YelpSettings *sett
void yelp_settings_set_editor_mode (YelpSettings *settings,
gboolean editor_mode);
+gint yelp_settings_cmp_icons (const gchar *icon1,
+ const gchar *icon2);
+
G_END_DECLS
#endif /* __YELP_SETTINGS_H__ */
diff --git a/src/yelp-window.c b/src/yelp-window.c
index d8a985e..0455a91 100644
--- a/src/yelp-window.c
+++ b/src/yelp-window.c
@@ -626,9 +626,8 @@ struct _YelpMenuEntry {
static gint
entry_compare (YelpMenuEntry *a, YelpMenuEntry *b)
{
- /* FIXME: create a static ordering of types, put in libyelp */
- gint ret = strcmp (a->icon, b->icon);
- if (ret)
+ gint ret = yelp_settings_cmp_icons (a->icon, b->icon);
+ if (ret != 0)
return ret;
else
return g_utf8_collate (a->title, b->title);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]