r2810 - in trunk/src/target/OM-2007.2/applications/openmoko-today2: . src

chris at sita.openmoko.org chris at sita.openmoko.org
Thu Aug 23 12:44:13 CEST 2007


Author: chris
Date: 2007-08-23 12:44:11 +0200 (Thu, 23 Aug 2007)
New Revision: 2810

Modified:
   trunk/src/target/OM-2007.2/applications/openmoko-today2/ChangeLog
   trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-launcher.c
Log:
Load .desktop files asynchronously (sort of)


Modified: trunk/src/target/OM-2007.2/applications/openmoko-today2/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-today2/ChangeLog	2007-08-23 08:35:55 UTC (rev 2809)
+++ trunk/src/target/OM-2007.2/applications/openmoko-today2/ChangeLog	2007-08-23 10:44:11 UTC (rev 2810)
@@ -1,3 +1,8 @@
+2007-08-23  Chris Lord,,,  <chris at openedhand.com>
+
+	* src/today-launcher.c: (load_desktop_cb), (load_data_dir):
+	Load .desktop files asynchronously (sort of)
+
 2007-08-21  Chris Lord,,,  <chris at openedhand.com>
 
 	* src/today-events-store.c: (today_events_store_cal_opened_cb),

Modified: trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-launcher.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-launcher.c	2007-08-23 08:35:55 UTC (rev 2809)
+++ trunk/src/target/OM-2007.2/applications/openmoko-today2/src/today-launcher.c	2007-08-23 10:44:11 UTC (rev 2810)
@@ -132,6 +132,45 @@
     taku_launcher_tile_add_group (tile, fallback_category);
 }
 
+typedef struct {
+	gchar *name;
+	gchar *directory;
+	TakuTable *table;
+	GList *categories;
+	TakuLauncherCategory *fallback_category;
+} LoadDesktopData;
+
+static gboolean
+load_desktop_cb (LoadDesktopData *data)
+{
+	gchar *filename;
+	GtkWidget *tile;
+
+	if (!g_str_has_suffix (data->name, ".desktop")) goto not_desktop;
+
+	filename = g_build_filename (data->directory, data->name, NULL);
+
+	/* TODO: load launcher data, probe that, and then create a tile */
+
+	tile = taku_launcher_tile_for_desktop_file (filename);
+	if (!tile) goto done;
+
+	set_groups (TAKU_LAUNCHER_TILE (tile), data->categories,
+		data->fallback_category);
+
+	gtk_container_add (GTK_CONTAINER (data->table), tile);
+	gtk_widget_show (tile);
+
+done:
+	g_free (filename);
+not_desktop:
+	g_free (data->name);
+	g_free (data->directory);
+	g_free (data);
+	
+	return FALSE;
+}
+
 /*
  * Load all .desktop files in @datadir/applications/, and add them to @table.
  */
@@ -163,27 +202,13 @@
   }
 
   while ((name = g_dir_read_name (dir)) != NULL) {
-    char *filename;
-    GtkWidget *tile;
-  
-    if (! g_str_has_suffix (name, ".desktop"))
-      continue;
-
-    filename = g_build_filename (directory, name, NULL);
-
-    /* TODO: load launcher data, probe that, and then create a tile */
-
-    tile = taku_launcher_tile_for_desktop_file (filename);
-    if (!tile)
-      goto done;
-
-    set_groups (TAKU_LAUNCHER_TILE (tile), categories, fallback_category);
-
-    gtk_container_add (GTK_CONTAINER (table), tile);
-    gtk_widget_show (tile);
-
-  done:
-    g_free (filename);
+	LoadDesktopData *data = g_new (LoadDesktopData, 1);
+	data->name = g_strdup (name);
+	data->directory = g_strdup (directory);
+	data->table = table;
+	data->categories = categories;
+	data->fallback_category = fallback_category;
+	g_idle_add ((GSourceFunc)load_desktop_cb, data);
   }
 
   g_free (directory);





More information about the commitlog mailing list