diff finch/libgnt/gntwm.c @ 18216:af7b944374ba

g_hash_table_find is glib 2.4
author Richard Nelson <wabz@pidgin.im>
date Wed, 20 Jun 2007 23:40:10 +0000
parents 16bfad2597fb
children d359e5f3ee87 1cb69ea47a6e
line wrap: on
line diff
--- a/finch/libgnt/gntwm.c	Wed Jun 20 23:33:32 2007 +0000
+++ b/finch/libgnt/gntwm.c	Wed Jun 20 23:40:10 2007 +0000
@@ -1464,12 +1464,39 @@
 	return FALSE;
 }
 
+#if !GLIB_CHECK_VERSION(2,4,0)
+typedef struct
+{
+	GntWM *wm;
+	GntWS *ret;
+	gchar *title;
+} title_search;
+
+static void match_title_search(gpointer key, gpointer value, gpointer search)
+{
+	title_search *s = search;
+	if (s->ret)
+		return;
+	if (match_title(key, NULL, s->title))
+		s->ret = g_hash_table_lookup(s->wm->title_places, key);
+}
+#endif
+
 static GntWS *
 new_widget_find_workspace(GntWM *wm, GntWidget *widget, gchar *wid_title)
 {
 	GntWS *ret;
 	const gchar *name;
+#if GLIB_CHECK_VERSION(2,4,0)
 	ret = g_hash_table_find(wm->title_places, match_title, wid_title);
+#else
+	title_search *s = NULL;
+	s = g_new0(title_search, 1);
+	s->wm = wm;
+	s->title = wid_title;
+	g_hash_table_foreach(wm->title_places, match_title_search, s);
+	ret = s->ret;
+#endif
 	if (ret)
 		return ret;
 	name = gnt_widget_get_name(widget);