comparison audacious/prefswin.c @ 1352:8b249765fdd1 trunk

[svn] - GList cannot handle circular queues, so I integrated one into CategoryQueueEntry. No fuss, no muss.
author nenolod
date Wed, 28 Jun 2006 15:32:15 -0700
parents 35dc5d2a1675
children 0c41255487ee
comparison
equal deleted inserted replaced
1351:fbb38017d144 1352:8b249765fdd1
117 { N_("Year") , "%y" }, 117 { N_("Year") , "%y" },
118 { N_("Comment") , "%c" } 118 { N_("Comment") , "%c" }
119 }; 119 };
120 120
121 typedef struct { 121 typedef struct {
122 void *next;
122 GtkWidget *container; 123 GtkWidget *container;
123 char *pg_name; 124 char *pg_name;
124 char *img_url; 125 char *img_url;
125 } CategoryQueueEntry; 126 } CategoryQueueEntry;
126 127
127 static GList *category_queue = NULL; 128 CategoryQueueEntry *category_queue = NULL;
128 129
129 static const guint n_title_field_tags = G_N_ELEMENTS(title_field_tags); 130 static const guint n_title_field_tags = G_N_ELEMENTS(title_field_tags);
130 131
131 /* GLib 2.6 compatibility */ 132 /* GLib 2.6 compatibility */
132 #if (! ((GLIB_MAJOR_VERSION > 2) || ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION >= 8)))) 133 #if (! ((GLIB_MAJOR_VERSION > 2) || ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION >= 8))))
1775 GtkCellRenderer *renderer; 1776 GtkCellRenderer *renderer;
1776 GtkTreeViewColumn *column; 1777 GtkTreeViewColumn *column;
1777 GtkTreeSelection *selection; 1778 GtkTreeSelection *selection;
1778 GtkTreeIter iter; 1779 GtkTreeIter iter;
1779 GdkPixbuf *img; 1780 GdkPixbuf *img;
1780 GList *qlist; 1781 CategoryQueueEntry *qlist;
1781 gint i; 1782 gint i;
1782 1783
1783 column = gtk_tree_view_column_new(); 1784 column = gtk_tree_view_column_new();
1784 gtk_tree_view_column_set_title(column, _("Category")); 1785 gtk_tree_view_column_set_title(column, _("Category"));
1785 gtk_tree_view_append_column(treeview, column); 1786 gtk_tree_view_append_column(treeview, column);
1814 G_CALLBACK(change_category), notebook); 1815 G_CALLBACK(change_category), notebook);
1815 1816
1816 /* mark the treeview widget as available to third party plugins */ 1817 /* mark the treeview widget as available to third party plugins */
1817 category_treeview = GTK_WIDGET(treeview); 1818 category_treeview = GTK_WIDGET(treeview);
1818 1819
1819 for (qlist = category_queue; qlist != NULL && qlist->data; qlist = g_list_next(qlist)) 1820 /* prefswin_page_queue_destroy already pops the queue forward for us. */
1821 for (qlist = category_queue; qlist != NULL; qlist = category_queue)
1820 { 1822 {
1821 CategoryQueueEntry *ent = (CategoryQueueEntry *) qlist->data; 1823 CategoryQueueEntry *ent = (CategoryQueueEntry *) qlist;
1822 1824
1823 prefswin_page_new(ent->container, ent->pg_name, ent->img_url); 1825 prefswin_page_new(ent->container, ent->pg_name, ent->img_url);
1824 prefswin_page_queue_destroy(ent); 1826 prefswin_page_queue_destroy(ent);
1825 } 1827 }
1826 } 1828 }
2299 } 2301 }
2300 2302
2301 static void 2303 static void
2302 prefswin_page_queue_new(GtkWidget *container, gchar *name, gchar *imgurl) 2304 prefswin_page_queue_new(GtkWidget *container, gchar *name, gchar *imgurl)
2303 { 2305 {
2304 CategoryQueueEntry *ent = g_new0(CategoryQueueEntry, 1); 2306 CategoryQueueEntry *ent = g_malloc0(sizeof(CategoryQueueEntry));
2305 2307
2306 ent->container = container; 2308 ent->container = container;
2307 ent->pg_name = name; 2309 ent->pg_name = name;
2308 ent->img_url = imgurl; 2310 ent->img_url = imgurl;
2309 category_queue = g_list_append(category_queue, ent); 2311
2312 if (category_queue)
2313 ent->next = category_queue;
2314
2315 category_queue = ent;
2310 } 2316 }
2311 2317
2312 static void 2318 static void
2313 prefswin_page_queue_destroy(CategoryQueueEntry *ent) 2319 prefswin_page_queue_destroy(CategoryQueueEntry *ent)
2314 { 2320 {
2315 category_queue = g_list_remove(category_queue, ent); 2321 category_queue = ent->next;
2316 g_free(ent); 2322 g_free(ent);
2317 } 2323 }
2318 2324
2319 /* 2325 /*
2320 * Public APIs for adding new pages to the prefs window. 2326 * Public APIs for adding new pages to the prefs window.
2334 GtkTreeIter iter; 2340 GtkTreeIter iter;
2335 GdkPixbuf *img = NULL; 2341 GdkPixbuf *img = NULL;
2336 GtkTreeView *treeview = GTK_TREE_VIEW(category_treeview); 2342 GtkTreeView *treeview = GTK_TREE_VIEW(category_treeview);
2337 gint id; 2343 gint id;
2338 2344
2339 if (treeview == NULL || container == NULL || category_notebook == NULL) 2345 if (treeview == NULL || category_notebook == NULL)
2340 { 2346 {
2341 prefswin_page_queue_new(container, name, imgurl); 2347 prefswin_page_queue_new(container, name, imgurl);
2342 return -1; 2348 return -1;
2343 } 2349 }
2344 2350