aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks/ephy-topic-action.c
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-07-22 18:53:24 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-07-22 18:53:24 +0800
commit636ab900c0cd1f0bc0842d53ff26bb735dfb86ff (patch)
treecef54408d8b219617ce693c1eb44bac3e66f37a2 /src/bookmarks/ephy-topic-action.c
parent53fbea9a0dfa5f3345c618bc33e1abcd65f5cde7 (diff)
downloadgsoc2013-epiphany-636ab900c0cd1f0bc0842d53ff26bb735dfb86ff.tar
gsoc2013-epiphany-636ab900c0cd1f0bc0842d53ff26bb735dfb86ff.tar.gz
gsoc2013-epiphany-636ab900c0cd1f0bc0842d53ff26bb735dfb86ff.tar.bz2
gsoc2013-epiphany-636ab900c0cd1f0bc0842d53ff26bb735dfb86ff.tar.lz
gsoc2013-epiphany-636ab900c0cd1f0bc0842d53ff26bb735dfb86ff.tar.xz
gsoc2013-epiphany-636ab900c0cd1f0bc0842d53ff26bb735dfb86ff.tar.zst
gsoc2013-epiphany-636ab900c0cd1f0bc0842d53ff26bb735dfb86ff.zip
Fix incosistency between all topic and bookmarks menu.
2003-07-22 Marco Pesenti Gritti <marco@it.gnome.org> * src/bookmarks/ephy-topic-action.c: (sort_bookmarks), (append_bookmarks_menu), (build_bookmarks_menu), (sort_topics), (build_topics_menu): Fix incosistency between all topic and bookmarks menu.
Diffstat (limited to 'src/bookmarks/ephy-topic-action.c')
-rw-r--r--src/bookmarks/ephy-topic-action.c105
1 files changed, 49 insertions, 56 deletions
diff --git a/src/bookmarks/ephy-topic-action.c b/src/bookmarks/ephy-topic-action.c
index e2cb0adfa..cc522b967 100644
--- a/src/bookmarks/ephy-topic-action.c
+++ b/src/bookmarks/ephy-topic-action.c
@@ -185,21 +185,19 @@ sort_bookmarks (gconstpointer a, gconstpointer b)
retval = g_utf8_collate (str_a, str_b);
g_free (str_a);
g_free (str_b);
-
+
return retval;
}
#define MAX_LENGTH 32
-static GtkWidget *
-build_bookmarks_menu (EphyTopicAction *action, EphyNode *node)
+static void
+append_bookmarks_menu (EphyTopicAction *action, GtkWidget *menu, EphyNode *node)
{
EphyFaviconCache *cache;
- GtkWidget *menu, *item;
+ GtkWidget *item;
GPtrArray *children;
- menu = gtk_menu_new ();
-
cache = EPHY_FAVICON_CACHE
(ephy_embed_shell_get_favicon_cache (EPHY_EMBED_SHELL (ephy_shell)));
@@ -216,24 +214,24 @@ build_bookmarks_menu (EphyTopicAction *action, EphyNode *node)
{
GList *node_list = NULL, *l;
int i;
-
+
for (i = 0; i < children->len; ++i)
{
node_list = g_list_prepend (node_list,
g_ptr_array_index (children, i));
}
-
+
node_list = g_list_sort (node_list, (GCompareFunc)sort_bookmarks);
-
+
for (l = g_list_first (node_list); l != NULL; l = g_list_next (l))
{
EphyNode *kid;
- const char *icon_location;
+ const char *icon_location;
const char *title;
char *title_short;
-
+
kid = (EphyNode*)l->data;
-
+
icon_location = ephy_node_get_property_string
(kid, EPHY_NODE_BMK_PROP_ICON);
title = ephy_node_get_property_string
@@ -241,13 +239,13 @@ build_bookmarks_menu (EphyTopicAction *action, EphyNode *node)
if (title == NULL) continue;
title_short = ephy_string_shorten (title, MAX_LENGTH);
LOG ("Create menu for bookmark %s", title_short)
-
+
item = gtk_image_menu_item_new_with_label (title_short);
if (icon_location)
{
GdkPixbuf *icon;
GtkWidget *image;
-
+
icon = ephy_favicon_cache_get (cache, icon_location);
if (icon != NULL)
{
@@ -270,8 +268,18 @@ build_bookmarks_menu (EphyTopicAction *action, EphyNode *node)
g_list_free (node_list);
}
-
+
ephy_node_thaw (node);
+}
+
+static GtkWidget *
+build_bookmarks_menu (EphyTopicAction *action, EphyNode *node)
+{
+ GtkWidget *menu;
+
+ menu = gtk_menu_new ();
+
+ append_bookmarks_menu (action, menu, node);
return menu;
}
@@ -286,28 +294,16 @@ sort_topics (gconstpointer a, gconstpointer b)
char *str_b = NULL;
int retval;
- priority_a = ephy_node_get_property_int (node_a, EPHY_NODE_KEYWORD_PROP_PRIORITY);
- priority_b = ephy_node_get_property_int (node_b, EPHY_NODE_KEYWORD_PROP_PRIORITY);
+ priority_a = ephy_node_get_property_int (node_a, EPHY_NODE_KEYWORD_PROP_PRIORITY);
+ priority_b = ephy_node_get_property_int (node_b, EPHY_NODE_KEYWORD_PROP_PRIORITY);
+ str_a = g_utf8_casefold (ephy_node_get_property_string (node_a, EPHY_NODE_KEYWORD_PROP_NAME),
+ -1);
+ str_b = g_utf8_casefold (ephy_node_get_property_string (node_b, EPHY_NODE_KEYWORD_PROP_NAME),
+ -1);
+ retval = g_utf8_collate (str_a, str_b);
+ g_free (str_a);
+ g_free (str_b);
- if (priority_a < priority_b)
- {
- retval = -1;
- }
- else if (priority_a > priority_b)
- {
- retval = 1;
- }
- else
- {
- str_a = g_utf8_casefold (ephy_node_get_property_string (node_a, EPHY_NODE_KEYWORD_PROP_NAME),
- -1);
- str_b = g_utf8_casefold (ephy_node_get_property_string (node_b, EPHY_NODE_KEYWORD_PROP_NAME),
- -1);
- retval = g_utf8_collate (str_a, str_b);
- g_free (str_a);
- g_free (str_b);
- }
-
return retval;
}
@@ -318,9 +314,8 @@ build_topics_menu (EphyTopicAction *action, EphyNode *node)
GPtrArray *children;
int i;
EphyBookmarks *bookmarks;
- EphyNode *all;
+ EphyNode *all, *uncategorized;
EphyNodePriority priority;
- char *markup_title = NULL;
GList *node_list = NULL, *l = NULL;
bookmarks = ephy_shell_get_bookmarks (ephy_shell);
@@ -329,15 +324,22 @@ build_topics_menu (EphyTopicAction *action, EphyNode *node)
menu = gtk_menu_new ();
children = ephy_node_get_children (node);
-
+
for (i = 0; i < children->len; ++i)
{
- node_list = g_list_prepend (node_list,
- g_ptr_array_index (children, i));
+ EphyNode *kid;
+
+ kid = g_ptr_array_index (children, i);
+ priority = ephy_node_get_property_int
+ (kid, EPHY_NODE_KEYWORD_PROP_PRIORITY);
+ if (priority == EPHY_NODE_NORMAL_PRIORITY)
+ {
+ node_list = g_list_prepend (node_list, kid);
+ }
}
-
+
node_list = g_list_sort (node_list, (GCompareFunc)sort_topics);
-
+
for (l = g_list_first (node_list); l != NULL; l = g_list_next (l))
{
EphyNode *kid;
@@ -349,21 +351,9 @@ build_topics_menu (EphyTopicAction *action, EphyNode *node)
title = ephy_node_get_property_string
(kid, EPHY_NODE_KEYWORD_PROP_NAME);
- priority = ephy_node_get_property_int
- (kid, EPHY_NODE_KEYWORD_PROP_PRIORITY);
LOG ("Create menu for topic %s", title);
- if (priority == EPHY_NODE_ALL_PRIORITY ||
- priority == EPHY_NODE_SPECIAL_PRIORITY)
- {
- markup_title = g_strconcat ("<b>", title, "</b>", NULL);
- }
- else
- {
- markup_title = g_strdup (title);
- }
- item = gtk_image_menu_item_new_with_label (markup_title);
- g_free (markup_title);
+ item = gtk_image_menu_item_new_with_label (title);
label = gtk_bin_get_child (GTK_BIN (item));
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
@@ -378,6 +368,9 @@ build_topics_menu (EphyTopicAction *action, EphyNode *node)
ephy_node_thaw (node);
g_list_free (node_list);
+ uncategorized = ephy_bookmarks_get_not_categorized (bookmarks);
+ append_bookmarks_menu (action, menu, uncategorized);
+
return menu;
}