From 979308aa7f42073e309737cd18da58731437bf3a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C5=99emysl=20Janouch?=
Date: Tue, 26 Oct 2010 16:18:15 +0200
Subject: Manage LdLibrary children in a GSList.
The previous method of containment, that is using GHashTable,
did not list children in any particular order.
Also names of children were duplicated. One copy has been
stored as a hash table index and another was present in the
child itself.
---
src/ld-window-main.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
(limited to 'src/ld-window-main.c')
diff --git a/src/ld-window-main.c b/src/ld-window-main.c
index 236e118..e5e7b83 100644
--- a/src/ld-window-main.c
+++ b/src/ld-window-main.c
@@ -69,7 +69,7 @@ static void
ld_window_main_finalize (GObject *gobject);
static void
-cb_load_category (gpointer key, gpointer value, gpointer user_data);
+cb_load_category (gpointer data, gpointer user_data);
static void
load_toolbar (LdWindowMain *self);
@@ -271,7 +271,7 @@ ld_window_main_finalize (GObject *gobject)
* A hashtable foreach callback for adding categories into the toolbar.
*/
static void
-cb_load_category (gpointer key, gpointer value, gpointer user_data)
+cb_load_category (gpointer data, gpointer user_data)
{
const gchar *name;
LdSymbolCategory *cat;
@@ -280,12 +280,13 @@ cb_load_category (gpointer key, gpointer value, gpointer user_data)
GtkWidget *img;
GtkToolItem *item;
- name = key;
- cat = value;
+ g_return_if_fail (LD_IS_WINDOW_MAIN (user_data));
self = user_data;
- g_return_if_fail (key != NULL);
- g_return_if_fail (LD_IS_SYMBOL_CATEGORY (cat));
+ g_return_if_fail (LD_IS_SYMBOL_CATEGORY (data));
+ cat = data;
+
+ name = ld_symbol_category_get_name (cat);
pbuf = gdk_pixbuf_new_from_file_at_size
(ld_symbol_category_get_image_path (cat), TOOLBAR_ICON_WIDTH, -1, NULL);
@@ -307,12 +308,14 @@ cb_load_category (gpointer key, gpointer value, gpointer user_data)
static void
load_toolbar (LdWindowMain *self)
{
+ GSList *categories;
+
/* Clear the toolbar first, if there was already something in it. */
gtk_container_foreach (GTK_CONTAINER (self->priv->toolbar),
(GtkCallback) gtk_widget_destroy, NULL);
- g_hash_table_foreach (self->priv->library->categories,
- cb_load_category, self);
+ categories = (GSList *) ld_library_get_children (self->priv->library);
+ g_slist_foreach (categories, cb_load_category, self);
}
/*
--
cgit v1.2.3