aboutsummaryrefslogtreecommitdiffstats
path: root/src/bookmarks
diff options
context:
space:
mode:
authorPeter Harvey <peter.a.harvey@gmail.com>2006-02-21 21:32:36 +0800
committerPeter Anthony Harvey <paharvey@src.gnome.org>2006-02-21 21:32:36 +0800
commit6dd4bf1e1ebfee184ebfa38781ab6418c42e652a (patch)
tree7a859d92f81c146e9eac5b60e1fd790f95c5cd5b /src/bookmarks
parent4aae60264b269b3eff4d5ba7b6a6403358fb0330 (diff)
downloadgsoc2013-epiphany-6dd4bf1e1ebfee184ebfa38781ab6418c42e652a.tar
gsoc2013-epiphany-6dd4bf1e1ebfee184ebfa38781ab6418c42e652a.tar.gz
gsoc2013-epiphany-6dd4bf1e1ebfee184ebfa38781ab6418c42e652a.tar.bz2
gsoc2013-epiphany-6dd4bf1e1ebfee184ebfa38781ab6418c42e652a.tar.lz
gsoc2013-epiphany-6dd4bf1e1ebfee184ebfa38781ab6418c42e652a.tar.xz
gsoc2013-epiphany-6dd4bf1e1ebfee184ebfa38781ab6418c42e652a.tar.zst
gsoc2013-epiphany-6dd4bf1e1ebfee184ebfa38781ab6418c42e652a.zip
src/bookmarks/ephy-bookmarks-menu.c src/bookmarks/ephy-nodes-cover.c
2006-02-21 Peter Harvey <peter.a.harvey@gmail.com> * src/bookmarks/ephy-bookmarks-menu.c * src/bookmarks/ephy-nodes-cover.c Minor tweaks to improve menu generation.
Diffstat (limited to 'src/bookmarks')
-rw-r--r--src/bookmarks/ephy-bookmarks-menu.c2
-rw-r--r--src/bookmarks/ephy-nodes-cover.c24
2 files changed, 21 insertions, 5 deletions
diff --git a/src/bookmarks/ephy-bookmarks-menu.c b/src/bookmarks/ephy-bookmarks-menu.c
index 0ef14dfd3..52d5da4e9 100644
--- a/src/bookmarks/ephy-bookmarks-menu.c
+++ b/src/bookmarks/ephy-bookmarks-menu.c
@@ -37,7 +37,7 @@
#include <string.h>
-#define MIN_MENU_SIZE 7
+#define MIN_MENU_SIZE 3
#define MAX_MENU_SIZE 21
enum
diff --git a/src/bookmarks/ephy-nodes-cover.c b/src/bookmarks/ephy-nodes-cover.c
index 6954cc13c..25fdbedae 100644
--- a/src/bookmarks/ephy-nodes-cover.c
+++ b/src/bookmarks/ephy-nodes-cover.c
@@ -119,6 +119,12 @@ ephy_nodes_covered (EphyNode *parent, const GPtrArray *children)
return TRUE;
}
+static gint
+compare_chosen (const guint *a, const guint *b, guint *count_c)
+{
+ return (count_c[*b] - count_c[*a]);
+}
+
/* Returns the subset of parents which provide a covering of children.
* Arguments other than parents and children arguments are only used if non-null.
* Uses the _covering array to store the subset of parents.
@@ -130,12 +136,13 @@ ephy_nodes_get_covering (const GPtrArray *parents, const GPtrArray *children,
{
GPtrArray *uncovered = _uncovered?_uncovered:g_ptr_array_sized_new (children->len);
GPtrArray *covering = _covering?_covering:g_ptr_array_sized_new (parents->len);
+ GArray *chosen = g_array_sized_new (FALSE, FALSE, sizeof(guint), parents->len);
GArray *sizes = _sizes;
/* Create arrays to store the number of children each parent has which
* are currently not covered, and the number of children it has total. */
- int *count_u = g_malloc (sizeof(int) * parents->len);
- int *count_c = g_malloc (sizeof(int) * parents->len);
+ guint *count_u = g_malloc (sizeof(guint) * parents->len);
+ guint *count_c = g_malloc (sizeof(guint) * parents->len);
EphyNode *parent;
guint i, p;
@@ -168,8 +175,7 @@ ephy_nodes_get_covering (const GPtrArray *parents, const GPtrArray *children,
/* Update the arrays of uncovered bookmarks and covering topics. */
parent = g_ptr_array_index (parents, p);
ephy_nodes_remove_covered (parent, uncovered);
- g_ptr_array_add (covering, parent);
- if (sizes) g_array_append_val (sizes, count_c[p]);
+ g_array_append_val (chosen, p);
/* Find the next most suitable topic. */
count_u[p] = 0;
@@ -189,7 +195,17 @@ ephy_nodes_get_covering (const GPtrArray *parents, const GPtrArray *children,
}
}
+ g_array_sort_with_data (chosen, (GCompareDataFunc)compare_chosen, count_c);
+
+ for (i = 0; i < chosen->len; i++)
+ {
+ p = g_array_index (chosen, guint, i);
+ g_ptr_array_add (covering, g_ptr_array_index (parents, p));
+ if (sizes) g_array_append_val (sizes, count_c[p]);
+ }
+
if (_uncovered != uncovered) g_ptr_array_free (uncovered, TRUE);
+ g_array_free (chosen, TRUE);
g_free (count_u);
g_free (count_c);