tracker r2195 - in branches/indexer-split: . data/dbus src/libtracker-db src/tracker-applet src/trackerd



Author: mr
Date: Thu Sep  4 16:57:02 2008
New Revision: 2195
URL: http://svn.gnome.org/viewvc/tracker?rev=2195&view=rev

Log:
	* data/dbus/tracker-daemon.xml:
	* src/tracker-applet/Makefile.am:
	* src/tracker-applet/tracker-applet-marshallers.[ch]: 
	* src/trackerd/tracker-marshal.list:
	* src/trackerd/tracker-daemon.c: Include the elapsed time in
	seconds in the index-progress signal. 

	* src/tracker-applet/tracker-applet.c: Refactored the code a
	little and improved the status tooltip to include estimated time
	and elapsed time.

	* data/dbus/tracker-daemon.xml:
	* src/trackerd/tracker-daemon.c: Changed the signal name
	'state-change' to 'service-statistics-updated' so it is clearer
	what it means.


Modified:
   branches/indexer-split/ChangeLog
   branches/indexer-split/data/dbus/tracker-daemon.xml
   branches/indexer-split/src/libtracker-db/tracker-db-dbus.c
   branches/indexer-split/src/tracker-applet/Makefile.am
   branches/indexer-split/src/tracker-applet/tracker-applet-marshallers.c
   branches/indexer-split/src/tracker-applet/tracker-applet-marshallers.h
   branches/indexer-split/src/tracker-applet/tracker-applet.c
   branches/indexer-split/src/trackerd/tracker-daemon.c
   branches/indexer-split/src/trackerd/tracker-marshal.list
   branches/indexer-split/src/trackerd/tracker-processor.c
   branches/indexer-split/src/trackerd/tracker-processor.h

Modified: branches/indexer-split/data/dbus/tracker-daemon.xml
==============================================================================
--- branches/indexer-split/data/dbus/tracker-daemon.xml	(original)
+++ branches/indexer-split/data/dbus/tracker-daemon.xml	Thu Sep  4 16:57:02 2008
@@ -163,7 +163,7 @@
     
     <!-- Signal when index has completed.  -->
     <signal name="IndexFinished">
-      <arg type="i" name="time_taken"/>
+      <arg type="d" name="seconds_elapsed"/>
     </signal>
     
     <!-- Signal progress of indexing, returns current service
@@ -173,17 +173,18 @@
       -->
     <signal name="IndexProgress">
       <arg type="s" name="service"/>
-      <arg type="s" name="current_uri" />
+      <arg type="s" name="current_uri"/>
       <arg type="i" name="items_done"/>
       <arg type="i" name="items_remaining"/>
       <arg type="i" name="items_total"/>
+      <arg type="d" name="seconds_elapsed"/>
     </signal>
 
     <!-- Signal whenever the count of a category changed. Look at GetStats for
 	 the format of service_stats. 
       -->
-    <signal name="StatsChanged">
-      <arg type="aas" name="service_stats"/>
+    <signal name="ServiceStatisticsUpdated">
+      <arg type="aas" name="statistics"/>
     </signal>
   </interface>
 </node>

Modified: branches/indexer-split/src/libtracker-db/tracker-db-dbus.c
==============================================================================
--- branches/indexer-split/src/libtracker-db/tracker-db-dbus.c	(original)
+++ branches/indexer-split/src/libtracker-db/tracker-db-dbus.c	Thu Sep  4 16:57:02 2008
@@ -23,7 +23,6 @@
 
 #include "tracker-db-dbus.h"
 
-
 static gchar **
 dbus_query_result_to_strv (TrackerDBResultSet *result_set, 
 			   gint                column,
@@ -47,7 +46,6 @@
 		strv = g_new (gchar*, rows + 1);
 		
 		while (valid) {
-
 			if (numeric) {
 				tracker_db_result_set_get (result_set, column, &value, -1);
 				str = g_strdup_printf ("%d", value);
@@ -60,7 +58,6 @@
 				continue;
 			}
 			
-
 			if (!g_utf8_validate (str, -1, NULL)) {
 				g_warning ("Could not add string:'%s' to GStrv, invalid UTF-8", str);
 				g_free (str);

Modified: branches/indexer-split/src/tracker-applet/Makefile.am
==============================================================================
--- branches/indexer-split/src/tracker-applet/Makefile.am	(original)
+++ branches/indexer-split/src/tracker-applet/Makefile.am	Thu Sep  4 16:57:02 2008
@@ -1,3 +1,31 @@
+INCLUDES =								\
+	-DSHAREDIR=\""$(datadir)"\"					\
+	-DLOCALEDIR=\""$(localedir)"\" 					\
+	-I$(top_srcdir)/src						\
+	$(TRACKERAPPLET_CFLAGS)						\
+	$(LIBGLADE_CFLAGS)
+
+bin_PROGRAMS = tracker-applet
+
+tracker_applet_LDADD = 							\
+	$(top_builddir)/src/libtracker/libtrackerclient.la 		\
+	$(top_builddir)/src/libtracker-common/libtracker-common.la 	\
+	$(TRACKERAPPLET_LIBS)						\
+	$(LIBGLADE_LIBS)
+
+tracker_applet_SOURCES = 						\
+	tracker-applet.c 						\
+	tracker-applet.h 						\
+	tracker-applet-marshallers.c 					\
+	tracker-applet-marshallers.h
+
+icondir = $(datadir)/tracker/icons
+
+icon_DATA = 								\
+	tracker-applet-default.png 					\
+	tracker-applet-indexing1.png 					\
+	tracker-applet-indexing2.png 					\
+	tracker-applet-paused.png
 
 @INTLTOOL_DESKTOP_RULE@
 
@@ -7,33 +35,6 @@
 
 pkgdata_DATA = tracker-applet-prefs.glade
 
-icondir = $(datadir)/tracker/icons
-
-INCLUDES = \
-	-DTRACKER_LOCALEDIR=\""$(localedir)"\" \
-	-DTRACKER_DATADIR=\""$(datadir)"\" \
-	-I$(top_srcdir)/src/libtracker \
-	$(LIBGLADE_CFLAGS) \
-	$(TRACKERAPPLET_CFLAGS)
-
-bin_PROGRAMS = tracker-applet
-
-tracker_applet_LDADD = \
-	$(top_builddir)/src/libtracker/libtrackerclient.la \
-	$(LIBGLADE_LIBS) \
-	$(TRACKERAPPLET_LIBS)
-
-tracker_applet_SOURCES = \
-	tracker-applet.c \
-	tracker-applet.h \
-	tracker-applet-marshallers.c \
-	tracker-applet-marshallers.h
-
-icon_DATA = \
-	tracker-applet-default.png \
-	tracker-applet-indexing1.png \
-	tracker-applet-indexing2.png \
-	tracker-applet-paused.png
 
 EXTRA_DIST = $(icon_DATA) $(pkgdata_DATA)
 

Modified: branches/indexer-split/src/tracker-applet/tracker-applet-marshallers.c
==============================================================================
--- branches/indexer-split/src/tracker-applet/tracker-applet-marshallers.c	(original)
+++ branches/indexer-split/src/tracker-applet/tracker-applet-marshallers.c	Thu Sep  4 16:57:02 2008
@@ -1,4 +1,4 @@
-#include	<glib-object.h>
+#include <glib-object.h>
 #include "tracker-applet-marshallers.h"
 
 
@@ -96,27 +96,28 @@
 
 /* VOID:INT (/dev/stdin:2) */
 
-/* VOID:STRING,STRING,INT,INT,INT (/dev/stdin:3) */
+/* VOID:STRING,STRING,INT,INT,INT,DOUBLE (/dev/stdin:3) */
 void
-tracker_VOID__STRING_STRING_INT_INT_INT (GClosure     *closure,
-                                         GValue       *return_value,
-                                         guint         n_param_values,
-                                         const GValue *param_values,
-                                         gpointer      invocation_hint,
-                                         gpointer      marshal_data)
+tracker_VOID__STRING_STRING_INT_INT_INT_DOUBLE (GClosure     *closure,
+                                                GValue       *return_value,
+                                                guint         n_param_values,
+                                                const GValue *param_values,
+                                                gpointer      invocation_hint,
+                                                gpointer      marshal_data)
 {
-  typedef void (*GMarshalFunc_VOID__STRING_STRING_INT_INT_INT) (gpointer     data1,
-                                                                gpointer     arg_1,
-                                                                gpointer     arg_2,
-                                                                gint         arg_3,
-                                                                gint         arg_4,
-                                                                gint         arg_5,
-                                                                gpointer     data2);
-  register GMarshalFunc_VOID__STRING_STRING_INT_INT_INT callback;
+  typedef void (*GMarshalFunc_VOID__STRING_STRING_INT_INT_INT_DOUBLE) (gpointer     data1,
+                                                                       gpointer     arg_1,
+                                                                       gpointer     arg_2,
+                                                                       gint         arg_3,
+                                                                       gint         arg_4,
+                                                                       gint         arg_5,
+                                                                       gdouble      arg_6,
+                                                                       gpointer     data2);
+  register GMarshalFunc_VOID__STRING_STRING_INT_INT_INT_DOUBLE callback;
   register GCClosure *cc = (GCClosure*) closure;
   register gpointer data1, data2;
 
-  g_return_if_fail (n_param_values == 6);
+  g_return_if_fail (n_param_values == 7);
 
   if (G_CCLOSURE_SWAP_DATA (closure))
     {
@@ -128,7 +129,7 @@
       data1 = g_value_peek_pointer (param_values + 0);
       data2 = closure->data;
     }
-  callback = (GMarshalFunc_VOID__STRING_STRING_INT_INT_INT) (marshal_data ? marshal_data : cc->callback);
+  callback = (GMarshalFunc_VOID__STRING_STRING_INT_INT_INT_DOUBLE) (marshal_data ? marshal_data : cc->callback);
 
   callback (data1,
             g_marshal_value_peek_string (param_values + 1),
@@ -136,6 +137,7 @@
             g_marshal_value_peek_int (param_values + 3),
             g_marshal_value_peek_int (param_values + 4),
             g_marshal_value_peek_int (param_values + 5),
+            g_marshal_value_peek_double (param_values + 6),
             data2);
 }
 

Modified: branches/indexer-split/src/tracker-applet/tracker-applet-marshallers.h
==============================================================================
--- branches/indexer-split/src/tracker-applet/tracker-applet-marshallers.h	(original)
+++ branches/indexer-split/src/tracker-applet/tracker-applet-marshallers.h	Thu Sep  4 16:57:02 2008
@@ -1,8 +1,7 @@
-
 #ifndef __tracker_MARSHAL_H__
 #define __tracker_MARSHAL_H__
 
-#include	<glib-object.h>
+#include <glib-object.h>
 
 G_BEGIN_DECLS
 
@@ -18,12 +17,12 @@
 #define tracker_VOID__INT	g_cclosure_marshal_VOID__INT
 
 /* VOID:STRING,STRING,INT,INT,INT (/dev/stdin:3) */
-extern void tracker_VOID__STRING_STRING_INT_INT_INT (GClosure     *closure,
-                                                     GValue       *return_value,
-                                                     guint         n_param_values,
-                                                     const GValue *param_values,
-                                                     gpointer      invocation_hint,
-                                                     gpointer      marshal_data);
+extern void tracker_VOID__STRING_STRING_INT_INT_INT_DOUBLE (GClosure     *closure,
+                                                            GValue       *return_value,
+                                                            guint         n_param_values,
+                                                            const GValue *param_values,
+                                                            gpointer      invocation_hint,
+                                                            gpointer      marshal_data);
 
 G_END_DECLS
 

Modified: branches/indexer-split/src/tracker-applet/tracker-applet.c
==============================================================================
--- branches/indexer-split/src/tracker-applet/tracker-applet.c	(original)
+++ branches/indexer-split/src/tracker-applet/tracker-applet.c	Thu Sep  4 16:57:02 2008
@@ -2,6 +2,7 @@
  *
  * Copyright (C) 2007, Saleem Abdulrasool <compnerd gentoo org>
  * Copyright (C) 2007, Jamie McCracken <jamiemcc blueyonder co uk>
+ * Copyright (C) 2008, Nokia
  *
  * Portions derived from xscreensaver and gnome-screensaver
  * Copyright (c) 1991-2004 Jamie Zawinski <jwz jwz org>
@@ -46,8 +47,11 @@
 
 #include <glade/glade.h>
 
+#include <libtracker/tracker.h>
+
+#include <libtracker-common/tracker-utils.h>
+
 #include "tracker-applet.h"
-#include "tracker.h"
 #include "tracker-applet-marshallers.h"
 
 #define PROGRAM                 "tracker-applet"
@@ -62,12 +66,6 @@
 
 #define TRAY_ICON_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), TYPE_TRAY_ICON, TrayIconPrivate))
 
-#define TRACKER_ICON            "tracker-applet-default.png"
-#define TRACKER_ICON_PAUSED     "tracker-applet-paused.png"
-#define TRACKER_ICON_INDEX1     "tracker-applet-indexing1.png"
-#define TRACKER_ICON_INDEX2     "tracker-applet-indexing2.png"
-
-
 typedef enum {
 	ICON_DEFAULT,
 	ICON_PAUSED,
@@ -76,57 +74,50 @@
 } IndexIcon;
 
 typedef enum {
+	INDEX_INITIALIZING,
 	INDEX_IDLE,
 	INDEX_BUSY,
 	INDEX_MERGING
 } IndexStateEnum;
 
-
 typedef enum {
 	PAUSE_NONE,
 	PAUSE_INTERNAL,
 	PAUSE_BATTERY
 } PauseStateEnum;
 
-
 typedef enum {
 	AUTO_PAUSE_NONE,
 	AUTO_PAUSE_INDEXING,
 	AUTO_PAUSE_MERGING
 } AutoPauseEnum;
 
-
-static char *index_icons[4] =
-{
-   TRACKER_ICON,
-   TRACKER_ICON_PAUSED,
-   TRACKER_ICON_INDEX1,
-   TRACKER_ICON_INDEX2
-};
-
+typedef struct {
+	gchar *name;
+	gchar *label;
+	GtkWidget *stat_label;
+} Stat_Info;
 
 typedef struct _TrayIconPrivate {
 	GtkStatusIcon *icon;
 	GKeyFile *keyfile;
-	char *filename;
+	gchar *filename;
 
-	/* settings */
+	/* Settings */
 	gboolean auto_hide;
 	gboolean disabled;
 	gboolean show_animation;
 	gboolean reindex;
 	AutoPauseEnum auto_pause_setting;
 
-
-
-	/* auto pause vars */
+	/* Auto pause vars */
 	gboolean auto_pause_timer_active;
 	time_t auto_pause_last_time_event;
 
 	gboolean user_pause;
 	gboolean auto_pause;
 
-	/* states */
+	/* States */
 	IndexStateEnum index_state;
 	PauseStateEnum pause_state;
 	IndexIcon index_icon;
@@ -136,24 +127,25 @@
 	gboolean email_indexing;
 	gboolean indexer_stopped;
 
-	/* status hints */
+	/* Status hints */
 	gint items_done;
 	gint items_remaining;
 	gint items_total;
+	gdouble seconds_elapsed;
 
-	/* main window */
+	/* Main window */
 	GtkMenu *menu;
 
 	gboolean initial_index_msg_shown;
 
-	/* tracker connection */
+	/* Tracker connection */
 	TrackerClient *tracker;
 
-	/* stats window table shown */
+	/* Stats window table shown */
 	gboolean stat_window_active;
 	gboolean stat_request_pending;
 
-	/* prefs window */
+	/* Prefs window */
 	GtkWidget *prefs_window;
 	GtkWidget *chk_animate;
 	GtkWidget *chk_show_icon;
@@ -161,32 +153,24 @@
 	GtkWidget *opt_pause_index;
 	GtkWidget *opt_pause_merge;
 	GtkWidget *btn_close;
-
 } TrayIconPrivate;
 
-static TrayIcon *main_icon;
-
-/* translatable strings */
-
-
+static void set_auto_pause (TrayIcon *icon, 
+                            gboolean  pause);
 
-static char *initial_index_1;
-static char *initial_index_2;
+static TrayIcon *main_icon;
 
-static char *end_index_initial_msg;
-static char *end_index_hours_msg;
-static char *end_index_minutes_msg;
-static char *end_index_seconds_msg;
-static char *end_index_final_msg;
+static gchar *initial_index_1;
+static gchar *initial_index_2;
 
-typedef struct {
-	char *name;
-	char *label;
-	GtkWidget *stat_label;
-} Stat_Info;
+static gchar *index_icons[4] = {
+        "tracker-applet-default.png",
+        "tracker-applet-paused.png",
+        "tracker-applet-indexing1.png",
+        "tracker-applet-indexing2.png"
+};
 
 static Stat_Info stat_info[13] = {
-
 	{"Files", NULL, NULL},
 	{"Folders", NULL, NULL},
 	{"Documents", NULL, NULL},
@@ -202,6 +186,15 @@
 	{NULL, NULL, NULL},
 };
 
+static gboolean disable_daemon_start;
+
+static GOptionEntry entries[] = {
+	{ "disable-daemon-start", 'd', 0, G_OPTION_ARG_NONE, &disable_daemon_start, 
+          NULL,
+          NULL
+        },
+	{ NULL }
+};
 
 static gboolean
 query_pointer_timeout (Window window)
@@ -226,80 +219,101 @@
 }
 
 static void
-set_status_hint (TrayIcon * icon)
+set_status_hint (TrayIcon *icon)
 {
-	/* Tracker : indexing 10/120 folders */
-
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
-
+	TrayIconPrivate *priv;
 	const char *status = NULL;
 	GString *hint;
 
-	/* Translators: this will appear like "Tracker : Idle" */
-	hint = g_string_new (_("Tracker : "));
+        priv = TRAY_ICON_GET_PRIVATE (icon);
+        
+        hint = g_string_new ("Tracker");
 
 	switch (priv->index_state) {
+	case INDEX_INITIALIZING:
+		status = _("Initializing");
+		break;
 	case INDEX_IDLE:
 		status = _("Idle");
 		break;
-
 	case INDEX_BUSY:
 		status = _("Indexing");
 		break;
-
 	case INDEX_MERGING:
 		status = _("Merging");
 		break;
 	}
 
-
-	g_string_append (hint, status);
-
+        if (status) {
+                g_string_append (hint, " : ");
+                g_string_append (hint, status);
+        }
 
 	if (priv->user_pause) {
-		status = _(" (paused by user)");
+		status = _("paused by user");
 	} else if (priv->auto_pause) {
-		status = _(" (paused by system)");
-
+		status = _("paused by system");
 	} else {
-
 		switch (priv->pause_state) {
-
-		case PAUSE_NONE:
-			status = g_strdup ("");
-			break;
-
 		case PAUSE_INTERNAL:
-			status = _(" (paused by system)");
+			status = _("paused by system");
 			break;
-
+#if 0
 		case PAUSE_BATTERY:
-			status = _(" (paused by battery)");
+                        /* FIXME: We need to check if we are on the
+                         * battery first, this state purely means we
+                         * WILL pause on battery.
+                         */
+			status = _("paused by battery");
+			break;
+#endif
+                default:
+		case PAUSE_NONE:
+			status = NULL;
 			break;
-
 		}
 	}
 
-	g_string_append (hint, status);
-
-
+        if (status) {
+                g_string_append_printf (hint, " (%s)", status);
+        }
 
 	if (priv->index_state == INDEX_BUSY) {
+                gchar *str1;
+                gchar *str2;
 
-		if (!priv->email_indexing) {
-			status = _("files");
-		} else {
-			status = _("mailboxes");
-		}
-
-		g_string_append_printf (hint, " %d/%d %s",
-					priv->items_done,
-					priv->items_total, 
-                                        status);
+                str1 = tracker_seconds_estimate_to_string (priv->seconds_elapsed, 
+                                                           FALSE,
+                                                           priv->items_done, 
+                                                           priv->items_remaining);
+                str2 = tracker_seconds_to_string (priv->seconds_elapsed, FALSE);
+
+                if (str1) {
+                        str1[0] = g_ascii_toupper (str1[0]);
+                }
+
+                if (str2) {
+                        str2[0] = g_ascii_toupper (str2[0]);
+                }
+
+                g_string_append_printf (hint,
+                                        "\n"
+                                        "\n"
+                                        "%s : %d of %d\n"
+                                        "%s : %s\n"
+                                        "%s : %s", 
+                                        _("Done"),
+                                        priv->items_done,
+                                        priv->items_total,
+                                        _("Estimated"),
+                                        str1,
+                                        _("Elapsed"),
+                                        str2);
 
+                g_free (str2);
+                g_free (str1);
 	}
 
-
 	if (priv->index_state == INDEX_MERGING) {
 		g_string_append_printf (hint, " %d/%d indexes being merged",
 					priv->items_done,
@@ -309,64 +323,62 @@
 	tray_icon_set_tooltip (icon, hint->str);
 
 	g_string_free (hint, TRUE);
-
 }
 
 static gboolean
-can_auto_pause (TrayIcon * icon)
+can_auto_pause (TrayIcon *icon)
 {
+	TrayIconPrivate *priv;
 
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
+        priv = TRAY_ICON_GET_PRIVATE (icon);
 
-	if (priv->user_pause || priv->pause_state == PAUSE_BATTERY
-	    || priv->disabled || priv->indexer_stopped)
+	if (priv->user_pause || 
+            priv->pause_state == PAUSE_BATTERY ||
+	    priv->disabled || 
+            priv->indexer_stopped) {
 		return FALSE;
-
+        }
 
 	switch (priv->auto_pause_setting) {
-
 	case AUTO_PAUSE_NONE:
 		return FALSE;
-
 	case AUTO_PAUSE_INDEXING:
-		return (priv->index_state != INDEX_IDLE);
-
+		return priv->index_state != INDEX_IDLE;
 	case AUTO_PAUSE_MERGING:
-		return (priv->index_state == INDEX_MERGING);
-
+		return priv->index_state == INDEX_MERGING;
 	}
 
 	return TRUE;
-
 }
 
 static void
-set_tracker_icon (TrayIconPrivate * priv)
+set_tracker_icon (TrayIconPrivate *priv)
 {
-	char *path;
-	const char *name;
+	const gchar *name;
+	gchar *path;
 
 	name = index_icons[priv->index_icon];
-
-	path = g_build_filename (TRACKER_DATADIR "/tracker/icons", name,
-				 NULL);
+	path = g_build_filename (SHAREDIR, 
+                                 "tracker", 
+                                 "icons", 
+                                 name, 
+                                 NULL);
 
 	if (g_file_test (path, G_FILE_TEST_EXISTS)) {
-		gtk_status_icon_set_from_file (priv->icon, path);
-	}
+                gtk_status_icon_set_from_file (priv->icon, path);
+	} else {
+                g_critical ("Could not find icon:'%s'", path);
+        }
 
 	g_free (path);
-
 }
 
 static gboolean
-set_icon (TrayIconPrivate * priv)
+set_icon (TrayIconPrivate *priv)
 {
-
 	if (!priv->user_pause) {
-
-		if (priv->index_state == INDEX_IDLE) {
-
+		if (priv->index_state == INDEX_INITIALIZING ||
+                    priv->index_state == INDEX_IDLE) {
 			priv->animated = FALSE;
 			priv->animated_timer_active = FALSE;
 
@@ -377,14 +389,11 @@
 
 			return FALSE;
 		}
-
 	}
 
-
-	if (priv->user_pause || priv->auto_pause
-	    || priv->pause_state != PAUSE_NONE) {
-
-
+	if (priv->user_pause || 
+            priv->auto_pause || 
+            priv->pause_state != PAUSE_NONE) {
 		if (priv->index_icon != ICON_PAUSED) {
 			priv->index_icon = ICON_PAUSED;
 			set_tracker_icon (priv);
@@ -392,12 +401,12 @@
 
 		priv->animated = FALSE;
 		priv->animated_timer_active = FALSE;
-		return FALSE;
 
+		return FALSE;
 	}
 
-	if (priv->index_state != INDEX_IDLE) {
-
+	if (priv->index_state != INDEX_INITIALIZING &&
+            priv->index_state != INDEX_IDLE) {
 		if (priv->index_icon == ICON_INDEX2 || !priv->show_animation) {
 			priv->index_icon = ICON_DEFAULT;
 		} else if (priv->index_icon != ICON_INDEX1) {
@@ -411,22 +420,49 @@
 		return TRUE;
 	}
 
-
-
 	return FALSE;
-
 }
 
 static gboolean
-auto_pause_timeout (TrayIcon * icon);
+auto_pause_timeout (gpointer data)
+{
+        TrayIcon *icon;
+	TrayIconPrivate *priv;
+        time_t t;
+
+        icon = data;
+        priv = TRAY_ICON_GET_PRIVATE (icon);
+
+	t = time (NULL);
+
+	if (priv->indexer_stopped) {
+		return FALSE;
+        }
+
+	if (t >= priv->auto_pause_last_time_event + 2) {
+		set_auto_pause (icon, FALSE);
+		return FALSE;
+	}
+
+	dbus_g_proxy_begin_call (priv->tracker->proxy, 
+                                 "PromptIndexSignals",
+				 NULL, 
+                                 NULL, 
+                                 NULL, 
+                                 G_TYPE_INVALID);
+
+	return TRUE;
+}
 
 static void
-set_auto_pause (TrayIcon * icon, gboolean pause)
+set_auto_pause (TrayIcon *icon, 
+                gboolean  pause)
 {
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
-	GError *error = NULL;
+	TrayIconPrivate *priv;
+
+        priv = TRAY_ICON_GET_PRIVATE (icon);
 
-	/* do not pause/unpause if in user pause  */
+	/* Do not pause/unpause if in user pause  */
 	if (priv->user_pause) {
 		priv->auto_pause_timer_active = FALSE;
 		priv->auto_pause = FALSE;
@@ -436,103 +472,61 @@
 	priv->auto_pause = pause;
 
 	if (pause) {
-
 		priv->auto_pause_last_time_event = time (NULL);
 
 		if (!priv->auto_pause_timer_active) {
-
-			g_timeout_add_seconds (2,
-					       (GSourceFunc)
-					       auto_pause_timeout, icon);
+			g_timeout_add_seconds (2, auto_pause_timeout, icon);
 
 			priv->auto_pause_timer_active = TRUE;
-
-			tracker_set_bool_option (priv->tracker, "Pause", TRUE,
-						 &error);
-
+			tracker_set_bool_option (priv->tracker, "Pause", TRUE, NULL);
 		}
 
 		priv->animated = FALSE;
-
-
 	} else {
-
 		priv->auto_pause_timer_active = FALSE;
 		priv->auto_pause = FALSE;
 
-		tracker_set_bool_option (priv->tracker, "Pause", FALSE,
-					 &error);
-
-
+		tracker_set_bool_option (priv->tracker, "Pause", FALSE,  NULL);
 	}
 
 	set_icon (priv);
-
-}
-
-static gboolean
-auto_pause_timeout (TrayIcon * icon)
-{
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
-
-	time_t t = time (NULL);
-
-	if (priv->indexer_stopped)
-		return FALSE;
-
-	if ((t >= (priv->auto_pause_last_time_event + 2))) {
-		set_auto_pause (icon, FALSE);
-		return FALSE;
-	}
-
-	dbus_g_proxy_begin_call (priv->tracker->proxy, "PromptIndexSignals",
-				 NULL, NULL, NULL, G_TYPE_INVALID);
-
-	return TRUE;
 }
 
 static void
-start_auto_pause_timer (TrayIcon * icon)
+start_auto_pause_timer (TrayIcon *icon)
 {
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
+	TrayIconPrivate *priv;
 
-	if (!can_auto_pause (icon))
+        priv = TRAY_ICON_GET_PRIVATE (icon);
+
+	if (!can_auto_pause (icon)) {
 		return;
+        }
 
 	priv->auto_pause_last_time_event = time (NULL);
 
 	if (!priv->auto_pause_timer_active) {
-		g_timeout_add_seconds (2, (GSourceFunc) auto_pause_timeout,
-				       icon);
+		g_timeout_add_seconds (2, auto_pause_timeout, icon);
 		set_auto_pause (icon, TRUE);
-
 	}
-
 }
 
 static void
-set_user_pause (TrayIcon * icon, gboolean pause)
+set_user_pause (TrayIcon *icon, 
+                gboolean  pause)
 {
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
-	GError *error = NULL;
+	TrayIconPrivate *priv;
 
+        priv = TRAY_ICON_GET_PRIVATE (icon);
 	priv->user_pause = pause;
 
-
-	if (pause) {
-		tracker_set_bool_option (priv->tracker, "Pause", TRUE,
-					 &error);
-
-	} else {
-		tracker_set_bool_option (priv->tracker, "Pause", FALSE,
-					 &error);
-	}
-
-
+        tracker_set_bool_option (priv->tracker, "Pause", pause, NULL);
 }
 
 static void
-notice_events_inner (Window window, gboolean enable, gboolean top)
+notice_events_inner (Window   window, 
+                     gboolean enable,
+                     gboolean top)
 {
 	XWindowAttributes attrs;
 	unsigned long events;
@@ -544,19 +538,24 @@
 	GdkWindow *gwindow;
 
 	gwindow = gdk_window_lookup (window);
-	if (gwindow != NULL && (window != GDK_ROOT_WINDOW ())) {
+	if (gwindow != NULL && window != GDK_ROOT_WINDOW ()) {
 		/* If it's one of ours, don't mess up its event mask. */
 		return;
 	}
 
 	kids = NULL;
-	status = XQueryTree (GDK_DISPLAY (), window, &root, &parent, &kids,
+	status = XQueryTree (GDK_DISPLAY (), 
+                             window, 
+                             &root, 
+                             &parent, 
+                             &kids,
 			     &nkids);
 
 	if (status == 0) {
 		if (kids != NULL) {
 			XFree (kids);
 		}
+
 		return;
 	}
 
@@ -564,7 +563,6 @@
 		top = FALSE;
 	}
 
-
 	memset (&attrs, 0, sizeof (attrs));
 	XGetWindowAttributes (GDK_DISPLAY (), window, &attrs);
 
@@ -620,13 +618,11 @@
 	 * systems that have it.  Oh, if it's a PS/2 mouse, not serial or USB.
 	 * This sucks!
 	 */
-
 	XSelectInput (GDK_DISPLAY (), window, events);
 
 	if (top && (events & KeyPressMask)) {
 		/* Only mention one window per tree */
 		top = FALSE;
-
 	}
 
 	if (kids != NULL) {
@@ -639,7 +635,8 @@
 }
 
 static void
-notice_events (Window window, gboolean enable)
+notice_events (Window   window, 
+               gboolean enable)
 {
 	gdk_error_trap_push ();
 
@@ -656,15 +653,16 @@
 }
 
 static GdkFilterReturn
-filter_x_events (GdkXEvent * xevent, GdkEvent * event, gpointer data)
+filter_x_events (GdkXEvent *xevent, 
+                 GdkEvent  *event,
+                 gpointer   data)
 {
 	XEvent *ev;
+	TrayIcon *icon;
 
+        icon = data;
 	ev = xevent;
 
-	TrayIcon *icon = data;
-
-
 	switch (ev->xany.type) {
 	case KeyPress:
 	case KeyRelease:
@@ -674,18 +672,19 @@
 		break;
 
 	case PropertyNotify:
-		if (ev->xproperty.atom ==
-		    gdk_x11_get_xatom_by_name ("_NET_WM_USER_TIME")) {
+		if (ev->xproperty.atom == gdk_x11_get_xatom_by_name ("_NET_WM_USER_TIME")) {
 			start_auto_pause_timer (icon);
 		}
 		break;
 
-	case CreateNotify:
-		{
-			Window window = ev->xcreatewindow.window;
-			start_notice_events (window);
-		}
+	case CreateNotify: {
+                Window window;
+                
+                window = ev->xcreatewindow.window;
+                start_notice_events (window);
+
 		break;
+        }
 
 	case MotionNotify:
 		if (ev->xmotion.is_hint) {
@@ -702,10 +701,7 @@
 		break;
 	}
 
-
 	return GDK_FILTER_CONTINUE;
-
-
 }
 
 static inline void
@@ -715,13 +711,15 @@
 }
 
 static void
-start_watching_events (TrayIcon * icon)
+start_watching_events (TrayIcon *icon)
 {
+	TrayIconPrivate *priv;
 
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
+        priv = TRAY_ICON_GET_PRIVATE (icon);
 
-	if (priv->is_watching_events)
+	if (priv->is_watching_events) {
 		return;
+        }
 
 	gdk_window_add_filter (NULL, (GdkFilterFunc) filter_x_events, icon);
 	start_notice_events (DefaultRootWindow (GDK_DISPLAY ()));
@@ -729,97 +727,112 @@
 }
 
 static void
-stop_watching_events (TrayIcon * icon)
+stop_watching_events (TrayIcon *icon)
 {
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
+	TrayIconPrivate *priv;
+
+        priv = TRAY_ICON_GET_PRIVATE (icon);
 
-	if (!priv->is_watching_events)
+	if (!priv->is_watching_events) {
 		return;
+        }
 
 	stop_notice_events (DefaultRootWindow (GDK_DISPLAY ()));
-	gdk_window_remove_filter (NULL, (GdkFilterFunc) filter_x_events,
-				  icon);
+	gdk_window_remove_filter (NULL, (GdkFilterFunc) filter_x_events, icon);
 	priv->is_watching_events = FALSE;
-
 }
 
 static void
-tray_icon_class_init (TrayIconClass * klass)
+tray_icon_class_init (TrayIconClass *klass)
 {
 	g_type_class_add_private (klass, sizeof (TrayIconPrivate));
 }
 
 static void
-activate_icon (GtkStatusIcon * icon, gpointer data)
+activate_icon (GtkStatusIcon *icon,
+               gpointer       data)
 {
+        GError *error = NULL;
 	const gchar *command = "tracker-search-tool";
 
-	if (!g_spawn_command_line_async (command, NULL))
-		g_warning ("Unable to execute command: %s", command);
+        g_print ("Spawning command:'%s'\n", command);
+
+        if (!g_spawn_command_line_async (command, &error)) {
+                g_warning ("Unable to execute command:'%s', %s",
+                           command, 
+                           error->message);
+                g_error_free (error);
+        }
 }
 
 static void
-search_menu_activated (GtkMenuItem * item, gpointer data)
+search_menu_activated (GtkMenuItem *item,
+                       gpointer     data)
 {
 	activate_icon (NULL, NULL);
 }
 
 static void
-pause_menu_toggled (GtkCheckMenuItem * item, gpointer data)
+pause_menu_toggled (GtkCheckMenuItem *item,
+                    gpointer          data)
 {
-	TrayIcon *icon = TRAY_ICON (data);
+	TrayIcon *icon;
+
+        icon = TRAY_ICON (data);
 
 	set_user_pause (icon,
-			gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM
-							(item)));
+			gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (item)));
 }
 
 static inline void
-set_auto_pause_setting (TrayIcon * icon, AutoPauseEnum auto_pause)
+set_auto_pause_setting (TrayIcon      *icon, 
+                        AutoPauseEnum  auto_pause)
 {
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
+	TrayIconPrivate *priv;
+
+        priv = TRAY_ICON_GET_PRIVATE (icon);
 
 	priv->auto_pause_setting = auto_pause;
 }
 
 static void
-save_options (TrayIcon * icon)
+save_options (TrayIcon *icon)
 {
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
+	TrayIconPrivate *priv;
+	GError *error = NULL;
+	guint length;
+	gchar *contents;
+
+        priv = TRAY_ICON_GET_PRIVATE (icon);
 
-	g_key_file_set_boolean (priv->keyfile, "Applet",
-				"AnimateWhenIndexing",
-				gtk_toggle_button_get_active
-				(GTK_TOGGLE_BUTTON (priv->chk_animate)));
-	g_key_file_set_boolean (priv->keyfile, "Applet", "AutoHideIcon",
-				gtk_toggle_button_get_active
-				(GTK_TOGGLE_BUTTON (priv->chk_show_icon)));
+	g_key_file_set_boolean (priv->keyfile, 
+                                "Applet", "AnimateWhenIndexing",
+				gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->chk_animate)));
+	g_key_file_set_boolean (priv->keyfile, 
+                                "Applet", "AutoHideIcon",
+				gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->chk_show_icon)));
 	g_key_file_set_integer (priv->keyfile, "Applet", "SmartPause",
 				priv->auto_pause_setting);
 
-
-	GError *error = NULL;
-	guint length = 0;
-	char *contents = g_key_file_to_data (priv->keyfile, &length, &error);
+        contents = g_key_file_to_data (priv->keyfile, &length, &error);
 
 	if (error) {
 		g_error ("failed: g_key_file_to_data(): %s\n",
 			 error->message);
-
 		return;
 	}
 
-
 	g_file_set_contents (priv->filename, contents, -1, NULL);
-
 	g_free (contents);
-
 }
 
 static void
-prefs_closed (GtkWidget * widget, gpointer data)
+prefs_closed (GtkWidget *widget, 
+              gpointer   data)
 {
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (data);
+	TrayIconPrivate *priv;
+
+        priv = TRAY_ICON_GET_PRIVATE (data);
 
 	save_options (data);
 
@@ -827,18 +840,20 @@
 }
 
 static void
-opt_pause_off_group_changed_cb (GtkToggleButton * check_button,
-				gpointer user_data)
+opt_pause_off_group_changed_cb (GtkToggleButton *check_button,
+				gpointer         user_data)
 {
-	if (!gtk_toggle_button_get_active (check_button))
-		return;
-
+	TrayIcon *icon;
+	TrayIconPrivate *priv;
+	const gchar *name;
 
+	if (!gtk_toggle_button_get_active (check_button)) {
+		return;
+        }
 
-	TrayIcon *icon = user_data;
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
-
-	const char *name = gtk_widget_get_name (GTK_WIDGET (check_button));
+	icon = user_data;
+	priv = TRAY_ICON_GET_PRIVATE (icon);
+	name = gtk_widget_get_name (GTK_WIDGET (check_button));
 
 	if (g_str_equal (name, "opt_pause_off")) {
 		priv->auto_pause_setting = AUTO_PAUSE_NONE;
@@ -848,7 +863,6 @@
 	}
 
 	if (g_str_equal (name, "opt_pause_index")) {
-
 		priv->auto_pause_setting = AUTO_PAUSE_INDEXING;
 
 		if (can_auto_pause (icon)) {
@@ -856,82 +870,92 @@
 		} else {
 			stop_watching_events (icon);
 		}
+
 		return;
 	}
 
-
 	if (g_str_equal (name, "opt_pause_merge")) {
-
 		priv->auto_pause_setting = AUTO_PAUSE_MERGING;
+
 		if (can_auto_pause (icon)) {
 			start_watching_events (icon);
 		} else {
 			stop_watching_events (icon);
 		}
+
 		return;
 	}
-
-
-
 }
 
 static void
-chk_animate_toggled_cb (GtkToggleButton * check_button, gpointer user_data)
+chk_animate_toggled_cb (GtkToggleButton *check_button, 
+                        gpointer         user_data)
 {
-	TrayIcon *icon = user_data;
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
+	TrayIcon *icon;
+	TrayIconPrivate *priv;
+
+        icon = user_data;
+        priv = TRAY_ICON_GET_PRIVATE (icon);
 
 	priv->show_animation = gtk_toggle_button_get_active (check_button);
 }
 
 static void
-chk_show_icon_toggled_cb (GtkToggleButton * check_button, gpointer user_data)
+chk_show_icon_toggled_cb (GtkToggleButton *check_button, 
+                          gpointer         user_data)
 {
-	TrayIcon *icon = user_data;
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
+	TrayIcon *icon;
+	TrayIconPrivate *priv;
+
+        icon = user_data;
+        priv = TRAY_ICON_GET_PRIVATE (icon);
 
 	if (gtk_toggle_button_get_active (check_button)) {
 		priv->auto_hide = TRUE;
 		gtk_status_icon_set_visible (priv->icon, FALSE);
 	} else {
 		priv->auto_hide = FALSE;
-		if (!priv->disabled)
+		if (!priv->disabled) {
 			gtk_status_icon_set_visible (priv->icon, TRUE);
+                }
 	}
-
 }
 
 static void
-create_prefs (TrayIcon * icon)
+create_prefs (TrayIcon *icon)
 {
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
+	TrayIconPrivate *priv;
+	GladeXML *glade;
+        gchar *filename;
 
-	GladeXML *gxml =
-		glade_xml_new (TRACKER_DATADIR
-			       "/tracker/tracker-applet-prefs.glade", NULL,
-			       NULL);
+        priv = TRAY_ICON_GET_PRIVATE (icon);
+        filename = g_build_filename (SHAREDIR, 
+                                     "tracker", 
+                                     "tracker-applet-prefs.glade",
+                                     NULL);
+        glade = glade_xml_new (filename, NULL, NULL);
 
-	if (gxml == NULL) {
-		g_error ("Unable to find locate tracker-applet-prefs.glade");
+	if (!glade) {
+		g_error ("Unable to find locate '%s'", filename);
+                g_free (filename);
 		priv->prefs_window = NULL;
 		return;
 	}
 
+        g_free (filename);
 
-
-	priv->prefs_window = glade_xml_get_widget (gxml, "wnd_prefs");
+	priv->prefs_window = glade_xml_get_widget (glade, "wnd_prefs");
 	gtk_widget_hide (priv->prefs_window);
 	gtk_window_set_deletable (GTK_WINDOW (priv->prefs_window), FALSE);
 
-	priv->chk_animate = glade_xml_get_widget (gxml, "chk_animate");
-	priv->chk_show_icon = glade_xml_get_widget (gxml, "chk_show_icon");
-	priv->opt_pause_off = glade_xml_get_widget (gxml, "opt_pause_off");
+	priv->chk_animate = glade_xml_get_widget (glade, "chk_animate");
+	priv->chk_show_icon = glade_xml_get_widget (glade, "chk_show_icon");
+	priv->opt_pause_off = glade_xml_get_widget (glade, "opt_pause_off");
 	priv->opt_pause_index =
-		glade_xml_get_widget (gxml, "opt_pause_index");
+		glade_xml_get_widget (glade, "opt_pause_index");
 	priv->opt_pause_merge =
-		glade_xml_get_widget (gxml, "opt_pause_merge");
-	priv->btn_close = glade_xml_get_widget (gxml, "btn_close");
-
+		glade_xml_get_widget (glade, "opt_pause_merge");
+	priv->btn_close = glade_xml_get_widget (glade, "btn_close");
 
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->chk_animate),
 				      priv->show_animation);
@@ -939,33 +963,23 @@
 				      priv->auto_hide);
 
 	switch (priv->auto_pause_setting) {
-
 	case AUTO_PAUSE_NONE:
 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
 					      (priv->opt_pause_off), TRUE);
-
 		break;
 
 	case AUTO_PAUSE_INDEXING:
 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
 					      (priv->opt_pause_index), TRUE);
-
-
-		break;
+                break;
 
 	case AUTO_PAUSE_MERGING:
 		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
 					      (priv->opt_pause_merge), TRUE);
-
-
-
-		break;
-
+                break;
 	}
 
-
 	/* connect signal handlers */
-
 	g_signal_connect (GTK_TOGGLE_BUTTON (priv->chk_animate), "toggled",
 			  G_CALLBACK (chk_animate_toggled_cb), main_icon);
 	g_signal_connect (GTK_TOGGLE_BUTTON (priv->chk_show_icon), "toggled",
@@ -983,21 +997,21 @@
 			  main_icon);
 	g_signal_connect (priv->btn_close, "clicked",
 			  G_CALLBACK (prefs_closed), main_icon);
-
-
 }
 
 static void
-restart_tracker (GtkDialog * dialog, gint response, TrayIcon * icon)
+restart_tracker (GtkDialog *dialog, 
+                 gint       response, 
+                 TrayIcon  *icon)
 {
 	gtk_widget_destroy (GTK_WIDGET (dialog));
 
 	if (response == GTK_RESPONSE_YES) {
+		TrayIconPrivate *priv;
 
-		g_print ("attempting to restart tracker\n");
-
-		TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
+		g_print ("Attempting to restart tracker\n");
 
+                priv = TRAY_ICON_GET_PRIVATE (icon);
 		priv->reindex = TRUE;
 
 		dbus_g_proxy_begin_call (priv->tracker->proxy,
@@ -1007,22 +1021,21 @@
 					 NULL,
 					 G_TYPE_BOOLEAN,
 					 TRUE, G_TYPE_INVALID);
-
-	}
+        }
 }
 
 static void
-reindex (GtkMenuItem * item, TrayIcon * icon)
+reindex (GtkMenuItem *item, 
+         TrayIcon    *icon)
 {
 	GtkWidget *dialog;
-	gchar *primary;
-	gchar *secondary;
+	gchar     *primary;
+	gchar     *secondary;
 
 	primary = g_strdup (_("Re-index your system?"));
 	secondary =
-		g_strdup (_
-			  ("Indexing can take a long time. Are you sure you want to re-index?"));
-
+		g_strdup (_("Indexing can take a long time. "
+                            "Are you sure you want to re-index?"));
 
 	dialog = gtk_message_dialog_new (NULL,
 					 GTK_DIALOG_MODAL,
@@ -1035,7 +1048,6 @@
 	g_free (primary);
 	g_free (secondary);
 
-
 	gtk_window_set_title (GTK_WINDOW (dialog), "");
 	gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
 	gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 14);
@@ -1047,9 +1059,12 @@
 }
 
 static void
-applet_preferences_menu_activated (GtkMenuItem * item, gpointer data)
+applet_preferences_menu_activated (GtkMenuItem *item, 
+                                   gpointer     data)
 {
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (data);
+	TrayIconPrivate *priv;
+
+        priv = TRAY_ICON_GET_PRIVATE (data);
 
 	create_prefs (data);
 
@@ -1057,19 +1072,32 @@
 }
 
 static void
-preferences_menu_activated (GtkMenuItem * item, gpointer data)
+preferences_menu_activated (GtkMenuItem *item, 
+                            gpointer     data)
 {
+        GError *error = NULL;
 	const gchar *command = "tracker-preferences";
 
-	if (!g_spawn_command_line_async (command, NULL))
-		g_warning ("Unable to execute command: %s", command);
+        g_print ("Spawning command:'%s'\n", command);
+
+        if (!g_spawn_command_line_async (command, &error)) {
+                g_warning ("Unable to execute command:'%s', %s",
+                           command, 
+                           error->message);
+                g_error_free (error);
+        }
 }
 
 static void
-stat_window_free (GtkWidget * widget, gint arg, gpointer data)
+stat_window_free (GtkWidget *widget, 
+                  gint       arg, 
+                  gpointer   data)
 {
-	TrayIcon *icon = TRAY_ICON (data);
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
+	TrayIcon *icon;
+	TrayIconPrivate *priv;
+
+        icon = data;
+        priv = TRAY_ICON_GET_PRIVATE (icon);
 
 	priv->stat_window_active = FALSE;
 
@@ -1077,13 +1105,13 @@
 }
 
 static gchar *
-get_stat_value (gchar *** stat_array, const gchar * stat)
+get_stat_value (gchar       ***stat_array, 
+                const gchar   *stat)
 {
 	gchar **array;
 	gint i = 0;
 
 	while (stat_array[i][0]) {
-
 		array = stat_array[i];
 
 		if (array[0] && strcasecmp (stat, array[0]) == 0) {
@@ -1097,13 +1125,21 @@
 }
 
 static void
-update_stats (GPtrArray * array, GError * error, gpointer data)
-{
-	TrayIcon *icon = TRAY_ICON (data);
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
+update_stats (GPtrArray *array, 
+              GError    *error, 
+              gpointer   data)
+{
+	TrayIcon *icon;
+	TrayIconPrivate *priv;
+        gchar ***pdata;
+        guint i;
+
+        icon = data;
+        priv = TRAY_ICON_GET_PRIVATE (icon);
 
 	if (error) {
-		g_warning ("an error has occured: %s", error->message);
+		g_warning ("Could not update statistics, %s",
+                           error->message);
 		g_error_free (error);
 		priv->stat_request_pending = FALSE;
 		return;
@@ -1113,33 +1149,31 @@
 		return;
 	}
 
-	guint i = array->len;
-
+	i = array->len;
 
 	if (i < 1 || !priv->stat_window_active) {
 		g_ptr_array_free (array, TRUE);
 		return;
 	}
 
-	gchar ***pdata = (gchar ***) array->pdata;
+	pdata = (gchar ***) array->pdata;
 
 	for (i = 0; i < 12; i++) {
 		gtk_label_set_text (GTK_LABEL (stat_info[i].stat_label),
-				    get_stat_value (pdata,
-						    stat_info[i].name));
+				    get_stat_value (pdata, stat_info[i].name));
 	}
 
 	g_ptr_array_free (array, TRUE);
 
 	priv->stat_request_pending = FALSE;
-
 }
 
 static void
-refresh_stats (TrayIcon * icon)
+refresh_stats (TrayIcon *icon)
 {
-
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
+	TrayIconPrivate *priv;
+        
+        priv = TRAY_ICON_GET_PRIVATE (icon);
 
 	if (!priv->stat_window_active || priv->stat_request_pending) {
 		return;
@@ -1148,25 +1182,35 @@
 	priv->stat_request_pending = TRUE;
 
 	tracker_get_stats_async (priv->tracker,
-				 (TrackerGPtrArrayReply) update_stats, icon);
-
+				 (TrackerGPtrArrayReply) update_stats, 
+                                 icon);
 }
 
 static void
-statistics_menu_activated (GtkMenuItem * item, gpointer data)
+statistics_menu_activated (GtkMenuItem *item, 
+                           gpointer     data)
 {
-	TrayIcon *icon = TRAY_ICON (data);
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
-	int i;
-
-	GtkWidget *dialog = gtk_dialog_new_with_buttons (_("Statistics"),
-							 NULL,
-							 GTK_DIALOG_NO_SEPARATOR
-							 |
-							 GTK_DIALOG_DESTROY_WITH_PARENT,
-							 GTK_STOCK_CLOSE,
-							 GTK_RESPONSE_CLOSE,
-							 NULL);
+	TrayIcon *icon;
+	TrayIconPrivate *priv;
+	GtkWidget *dialog;
+        GtkWidget *table;
+        GtkWidget *title_label;
+        GtkWidget *label_to_add;
+        GtkWidget *dialog_hbox;
+        GtkWidget *info_icon;
+	gint i;
+
+        icon = data;
+        priv = TRAY_ICON_GET_PRIVATE (icon);
+
+        dialog = gtk_dialog_new_with_buttons (_("Statistics"),
+                                              NULL,
+                                              GTK_DIALOG_NO_SEPARATOR
+                                              |
+                                              GTK_DIALOG_DESTROY_WITH_PARENT,
+                                              GTK_STOCK_CLOSE,
+                                              GTK_RESPONSE_CLOSE,
+                                              NULL);
 
 	gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
 	gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
@@ -1175,24 +1219,20 @@
 				  GDK_WINDOW_TYPE_HINT_DIALOG);
 	gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
 
-
-
-	GtkWidget *table = gtk_table_new (13, 2, TRUE);
+	table = gtk_table_new (13, 2, TRUE);
 	gtk_table_set_row_spacings (GTK_TABLE (table), 4);
 	gtk_table_set_col_spacings (GTK_TABLE (table), 65);
 	gtk_container_set_border_width (GTK_CONTAINER (table), 8);
 
-	GtkWidget *title_label = gtk_label_new (NULL);
+	title_label = gtk_label_new (NULL);
 	gtk_label_set_markup (GTK_LABEL (title_label),
-			      _
-			      ("<span weight=\"bold\" size=\"larger\">Index statistics</span>"));
+			      _("<span weight=\"bold\" size=\"larger\">Index statistics</span>"));
 	gtk_misc_set_alignment (GTK_MISC (title_label), 0, 0);
 	gtk_table_attach_defaults (GTK_TABLE (table), title_label, 0, 2, 0,
 				   1);
 
 	for (i = 0; i < 12; i++) {
-
-		GtkWidget *label_to_add = gtk_label_new (stat_info[i].label);
+		label_to_add = gtk_label_new (stat_info[i].label);
 
 		gtk_label_set_selectable (GTK_LABEL (label_to_add), TRUE);
 		gtk_misc_set_alignment (GTK_MISC (label_to_add), 0, 0);
@@ -1208,17 +1248,15 @@
 		gtk_table_attach_defaults (GTK_TABLE (table),
 					   stat_info[i].stat_label, 1, 2,
 					   i + 1, i + 2);
-
 	}
 
 	priv->stat_window_active = TRUE;
 
 	refresh_stats (icon);
 
-	GtkWidget *dialog_hbox = gtk_hbox_new (FALSE, 12);
-	GtkWidget *info_icon =
-		gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO,
-					  GTK_ICON_SIZE_DIALOG);
+	dialog_hbox = gtk_hbox_new (FALSE, 12);
+	info_icon = gtk_image_new_from_stock (GTK_STOCK_DIALOG_INFO,
+                                              GTK_ICON_SIZE_DIALOG);
 	gtk_misc_set_alignment (GTK_MISC (info_icon), 0, 0);
 	gtk_container_add (GTK_CONTAINER (dialog_hbox), info_icon);
 	gtk_container_add (GTK_CONTAINER (dialog_hbox), table);
@@ -1226,14 +1264,16 @@
 	gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
 			   dialog_hbox);
 
-	g_signal_connect (G_OBJECT (dialog),
-			  "response", G_CALLBACK (stat_window_free), icon);
+	g_signal_connect (G_OBJECT (dialog), "response", 
+                          G_CALLBACK (stat_window_free),
+                          icon);
 
 	gtk_widget_show_all (dialog);
 }
 
 static void
-open_uri (GtkWindow * parent, const char *uri)
+open_uri (GtkWindow  *parent, 
+          const char *uri)
 {
 	GtkWidget *dialog;
 	GdkScreen *screen;
@@ -1244,8 +1284,7 @@
 
 	cmdline = g_strconcat ("xdg-open ", uri, NULL);
 
-	if (gdk_spawn_command_line_on_screen (screen, cmdline, &error) ==
-	    FALSE) {
+	if (gdk_spawn_command_line_on_screen (screen, cmdline, &error) == FALSE) {
 		dialog = gtk_message_dialog_new (parent,
 						 GTK_DIALOG_DESTROY_WITH_PARENT,
 						 GTK_MESSAGE_ERROR,
@@ -1260,13 +1299,17 @@
 }
 
 static void
-about_url_hook (GtkAboutDialog * dialog, const gchar * url, gpointer data)
+about_url_hook (GtkAboutDialog *dialog, 
+                const gchar    *url, 
+                gpointer        data)
 {
 	open_uri (GTK_WINDOW (dialog), url);
 }
 
 static void
-about_email_hook (GtkAboutDialog * dialog, const gchar * email, gpointer data)
+about_email_hook (GtkAboutDialog *dialog, 
+                  const gchar    *email, 
+                  gpointer        data)
 {
 	gchar *uri;
 
@@ -1278,7 +1321,6 @@
 static void
 about_menu_activated (GtkMenuItem * item, gpointer data)
 {
-
 	const gchar *authors[] = {
 		"Jamie McCracken <jamiemcc at gnome.org>",
 		"Saleem Abdulrasool <compnerd at compnerd.org>"
@@ -1306,14 +1348,17 @@
 		"Christoph Laimburg <christoph laimburg at rolmail net>",
 		NULL
 	};
+
 	const gchar *documenters[] = {
 		NULL
 	};
+
 	const gchar *license[] = {
 		N_("Tracker is free software; you can redistribute it and/or modify " "it under the terms of the GNU General Public License as published by " "the Free Software Foundation; either version 2 of the License, or " "(at your option) any later version."),
 		N_("Tracker is distributed in the hope that it will be useful, " "but WITHOUT ANY WARRANTY; without even the implied warranty of " "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the " "GNU General Public License for more details."),
 		N_("You should have received a copy of the GNU General Public License " "along with Tracker; if not, write to the Free Software Foundation, Inc., " "59 Temple Place, Suite 330, Boston, MA  02111-1307  USA")
 	};
+
 	gchar *license_trans;
 
 	license_trans = g_strjoin ("\n\n", _(license[0]), _(license[1]),
@@ -1346,21 +1391,22 @@
 }
 
 static void
-quit_menu_activated (GtkMenuItem * item, gpointer data)
+quit_menu_activated (GtkMenuItem *item, 
+                     gpointer     data)
 {
 	gtk_main_quit ();
 }
 
 static void
-create_context_menu (TrayIcon * icon)
+create_context_menu (TrayIcon *icon)
 {
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
-	GtkWidget *item = NULL, *image = NULL;
+	TrayIconPrivate *priv;
+	GtkWidget *item, *image;
+
+        priv = TRAY_ICON_GET_PRIVATE (icon);
 	priv->menu = (GtkMenu *) gtk_menu_new ();
 
-	item = (GtkWidget *)
-		gtk_check_menu_item_new_with_mnemonic (_
-						       ("_Pause All Indexing"));
+	item = gtk_check_menu_item_new_with_mnemonic (_("_Pause All Indexing"));
 	gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), FALSE);
 	g_signal_connect (G_OBJECT (item), "toggled",
 			  G_CALLBACK (pause_menu_toggled), icon);
@@ -1370,8 +1416,7 @@
 	gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), item);
 
 
-	item = (GtkWidget *)
-		gtk_image_menu_item_new_with_mnemonic (_("_Search"));
+	item = gtk_image_menu_item_new_with_mnemonic (_("_Search"));
 	image = gtk_image_new_from_icon_name (GTK_STOCK_FIND,
 					      GTK_ICON_SIZE_MENU);
 	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
@@ -1380,8 +1425,7 @@
 	gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), item);
 
 
-	item = (GtkWidget *)
-		gtk_image_menu_item_new_with_mnemonic (_("_Re-index"));
+	item = gtk_image_menu_item_new_with_mnemonic (_("_Re-index"));
 	image = gtk_image_new_from_icon_name (GTK_STOCK_FIND,
 					      GTK_ICON_SIZE_MENU);
 	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
@@ -1389,8 +1433,7 @@
 			  icon);
 	gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), item);
 
-	item = (GtkWidget *)
-		gtk_image_menu_item_new_with_mnemonic (_("_Preferences"));
+	item = gtk_image_menu_item_new_with_mnemonic (_("_Preferences"));
 	image = gtk_image_new_from_icon_name (GTK_STOCK_PREFERENCES,
 					      GTK_ICON_SIZE_MENU);
 	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
@@ -1399,9 +1442,7 @@
 			  icon);
 	gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), item);
 
-	item = (GtkWidget *)
-		gtk_image_menu_item_new_with_mnemonic (_
-						       ("_Indexer Preferences"));
+	item = gtk_image_menu_item_new_with_mnemonic (_("_Indexer Preferences"));
 	image = gtk_image_new_from_icon_name (GTK_STOCK_PREFERENCES,
 					      GTK_ICON_SIZE_MENU);
 	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
@@ -1409,8 +1450,7 @@
 			  G_CALLBACK (preferences_menu_activated), icon);
 	gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), item);
 
-	item = (GtkWidget *)
-		gtk_image_menu_item_new_with_mnemonic (_("S_tatistics"));
+	item = gtk_image_menu_item_new_with_mnemonic (_("S_tatistics"));
 	image = gtk_image_new_from_icon_name (GTK_STOCK_INFO,
 					      GTK_ICON_SIZE_MENU);
 	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
@@ -1418,8 +1458,7 @@
 			  G_CALLBACK (statistics_menu_activated), icon);
 	gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), item);
 
-	item = (GtkWidget *)
-		gtk_image_menu_item_new_with_mnemonic (_("_About"));
+	item = gtk_image_menu_item_new_with_mnemonic (_("_About"));
 	image = gtk_image_new_from_icon_name (GTK_STOCK_ABOUT,
 					      GTK_ICON_SIZE_MENU);
 	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
@@ -1430,8 +1469,7 @@
 	item = gtk_separator_menu_item_new ();
 	gtk_menu_shell_append (GTK_MENU_SHELL (priv->menu), item);
 
-	item = (GtkWidget *)
-		gtk_image_menu_item_new_with_mnemonic (_("_Quit"));
+	item = gtk_image_menu_item_new_with_mnemonic (_("_Quit"));
 	image = gtk_image_new_from_icon_name (GTK_STOCK_QUIT,
 					      GTK_ICON_SIZE_MENU);
 	gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item), image);
@@ -1443,52 +1481,48 @@
 }
 
 static void
-index_finished (DBusGProxy * proxy, int time_taken, TrayIcon * icon)
-{
-	char *format;
-
-	int hours = time_taken / 3600;
-
-	int minutes = (time_taken / 60 - (hours * 60));
-
-	int seconds = (time_taken - ((minutes * 60) + (hours * 3600)));
-
-	if (hours > 0) {
-		format = g_strdup_printf (end_index_hours_msg, hours,
-					  minutes);
-	} else if (minutes > 0) {
-		format = g_strdup_printf (end_index_minutes_msg, minutes,
-					  seconds);
-	} else {
-		format = g_strdup_printf (end_index_seconds_msg, seconds);
-	}
-
-	tray_icon_show_message (icon, "%s%s\n\n%s", end_index_initial_msg,
-				format, end_index_final_msg);
-	g_free (format);
+index_finished (DBusGProxy *proxy, 
+                gdouble     seconds_elapsed, 
+                TrayIcon   *icon)
+{
+        gchar *str;
+
+	str = tracker_seconds_to_string (seconds_elapsed, FALSE);
+	tray_icon_show_message (icon, 
+                                "%s in %s.\n"
+                                "\n"
+                                "%s", 
+                                _("Tracker has finished indexing your system"),
+				str, 
+                                _("You can now perform searches by clicking here"));
+	g_free (str);
 
 	stop_watching_events (icon);
-
 }
 
 static void
-index_state_changed (DBusGProxy * proxy, const gchar * state,
-		     gboolean initial_index, gboolean in_merge,
-		     gboolean is_manual_paused, gboolean is_battery_paused,
-		     gboolean is_io_paused, gboolean is_indexing_enabled,
-		     TrayIcon * icon)
+index_state_changed (DBusGProxy  *proxy, 
+                     const gchar *state,
+		     gboolean     initial_index, 
+                     gboolean     in_merge,
+		     gboolean     is_manual_paused, 
+                     gboolean     is_battery_paused,
+		     gboolean     is_io_paused, 
+                     gboolean     is_indexing_enabled,
+		     TrayIcon    *icon)
 {
+	TrayIconPrivate *priv;
+        gboolean paused;
 
-	if (!state)
+	if (!state) {
 		return;
+        }
 
-
-
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
-	gboolean paused = FALSE;
-
+        priv = TRAY_ICON_GET_PRIVATE (icon);
 	priv->indexer_stopped = FALSE;
 
+	paused = FALSE;
+
 	if (!is_indexing_enabled) {
 		priv->disabled = TRUE;
 		gtk_status_icon_set_visible (priv->icon, FALSE);
@@ -1500,22 +1534,22 @@
 		}
 	}
 
-
 	if (!priv->initial_index_msg_shown && initial_index) {
 		priv->initial_index_msg_shown = TRUE;
-		g_usleep (100000);
-		tray_icon_show_message (icon, "%s\n\n%s\n", initial_index_1,
+		g_usleep (G_USEC_PER_SEC / 10);
+		tray_icon_show_message (icon, 
+                                        "%s\n"
+                                        "\n"
+                                        "%s\n",
+                                        initial_index_1,
 					initial_index_2);
-
 	}
 
 	priv->animated = FALSE;
 	priv->pause_state = PAUSE_NONE;
 
-
-	/* set pause states if applicable */
+	/* Set pause states if applicable */
 	if (is_manual_paused) {
-
 		stop_watching_events (icon);
 
 		if (!priv->auto_pause) {
@@ -1523,45 +1557,32 @@
 		}
 
 		paused = TRUE;
-
 	} else if (is_battery_paused) {
-
 		priv->pause_state = PAUSE_BATTERY;
 		paused = TRUE;
-
 	} else if (is_io_paused) {
 		paused = TRUE;
 		priv->pause_state = PAUSE_INTERNAL;
-
 	}
 
-
 	if (in_merge) {
-
 		priv->index_state = INDEX_MERGING;
 		priv->animated = TRUE;
-
-
-	} else if (strcasecmp (state, "Idle") == 0) {
-
+	} else if (g_ascii_strcasecmp (state, "Initializing") == 0) {
+		priv->index_state = INDEX_INITIALIZING;
+	} else if (g_ascii_strcasecmp (state, "Idle") == 0) {
 		priv->index_state = INDEX_IDLE;
-
 	} else {
-
 		priv->index_state = INDEX_BUSY;
 		priv->animated = TRUE;
-
 	}
 
 	set_icon (priv);
 
-	/* should we animate? */
-
+	/* Should we animate? */
 	if (!paused && priv->animated && priv->show_animation) {
-
 		if (!priv->animated_timer_active) {
 			priv->animated_timer_active = TRUE;
-			//g_timeout_add_seconds (2, (GSourceFunc) set_icon, priv);
 		}
 	}
 
@@ -1572,7 +1593,6 @@
 	} else {
 		stop_watching_events (icon);
 	}
-
 }
 
 static void
@@ -1582,32 +1602,40 @@
                         gint         items_done,
 			gint         items_remaining, 
                         gint         items_total,
+                        gdouble      seconds_elapsed,
 			TrayIcon    *icon)
 {
+	TrayIconPrivate *priv;
 
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
+        priv = TRAY_ICON_GET_PRIVATE (icon);
 
 	priv->items_done = items_done;
+	priv->items_remaining = items_remaining;
 	priv->items_total = items_total;
+	priv->seconds_elapsed = seconds_elapsed;
 
-	priv->email_indexing = (strcmp (service, "Emails") == 0);
+	priv->email_indexing = strcmp (service, "Emails") == 0;
 
-	set_status_hint (icon);
+        g_print ("Indexed %d/%d, seconds elapsed:%f\n", 
+                 items_done, 
+                 items_total,
+                 seconds_elapsed);
 
+	set_status_hint (icon);
 	set_icon (priv);
 
-	/* update stat window if its active */
+	/* Update stat window if its active */
 	refresh_stats (icon);
-
 }
 
 static void
-init_settings (TrayIcon * icon)
+init_settings (TrayIcon *icon)
 {
+	TrayIconPrivate *priv;
 
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
+        priv = TRAY_ICON_GET_PRIVATE (icon);
 
-	priv->index_state = INDEX_IDLE;
+	priv->index_state = INDEX_INITIALIZING;
 	priv->pause_state = PAUSE_NONE;
 	priv->auto_pause_setting = AUTO_PAUSE_MERGING;
 	priv->index_icon = ICON_DEFAULT;
@@ -1629,68 +1657,99 @@
 }
 
 static void
-name_owner_changed (DBusGProxy * proxy, const gchar * name,
-		    const gchar * prev_owner, const gchar * new_owner,
-		    gpointer data)
+name_owner_changed (DBusGProxy  *proxy, 
+                    const gchar *name,
+		    const gchar *prev_owner, 
+                    const gchar *new_owner,
+		    gpointer     data)
 {
-
-
-	if (!g_str_equal (name, DBUS_SERVICE_TRACKER))
+	if (!g_str_equal (name, DBUS_SERVICE_TRACKER)) {
 		return;
+        }
 
 	if (g_str_equal (new_owner, "")) {
+		TrayIconPrivate *priv;
+
+                priv = TRAY_ICON_GET_PRIVATE (data);
+
+		/* Tracker has exited so reset status and make
+                 * invisible until trackerd relaunched.
+                 */
+		index_state_changed (proxy, 
+                                     "Idle", 
+                                     FALSE, 
+                                     FALSE, 
+                                     FALSE,
+				     FALSE,
+                                     FALSE, 
+                                     FALSE, 
+                                     data);
 
-		TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (data);
-		/* tracker has exited so reset status and make invisible until trackerd relaunched */
-		index_state_changed (proxy, "Idle", FALSE, FALSE, FALSE,
-				     FALSE, TRUE, FALSE, data);
 		init_settings (data);
 		gtk_status_icon_set_visible (priv->icon, FALSE);
 		priv->indexer_stopped = TRUE;
-		g_print ("tracker has exited (reindex = %d)\n",
-			 priv->reindex);
 
+		g_print ("The Tracker daemon has exited (%s)\n",
+			 priv->reindex ? "reindexing" : "not reindexing");
 
 		if (priv->reindex) {
-			priv->reindex = FALSE;
+                        GError *error = NULL;
 			const gchar *command = "trackerd";
 
-			g_print ("restarting trackerd\n");
-			g_usleep (1000000);
-			if (!g_spawn_command_line_async (command, NULL))
-				g_warning ("Unable to execute command: %s",
-					   command);
+			priv->reindex = FALSE;
 
-		}
+ 			g_print ("Restarting Tracker daemon in 1 second\n");
+			g_usleep (G_USEC_PER_SEC);
 
+                        g_print ("Spawning command:'%s'\n", command);
 
+			if (!g_spawn_command_line_async (command, &error)) {
+				g_warning ("Unable to execute command:'%s', %s",
+					   command, 
+                                           error->message);
+                                g_error_free (error);
+                        }
+		}
 	}
 }
 
 static gboolean
-setup_dbus_connection (TrayIcon * icon)
+setup_dbus_connection (TrayIcon *icon)
 {
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
+	TrayIconPrivate *priv;
+	DBusGConnection *connection;
+	DBusGProxy *dbus_proxy;
+        
+        priv = TRAY_ICON_GET_PRIVATE (icon);
 
 	priv->tracker = tracker_connect (FALSE);
 
 	if (!priv->tracker) {
-		g_print ("Could not initialize Tracker\n");
-		exit (1);
+		g_printerr ("Could not connect to the Tracker daemon\n");
+		exit (EXIT_FAILURE);
 	}
 
-
-	/* set signal handlers */
-	dbus_g_object_register_marshaller
-		(tracker_VOID__STRING_BOOLEAN_BOOLEAN_BOOLEAN_BOOLEAN_BOOLEAN,
-		 G_TYPE_NONE, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
-		 G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN,
-		 G_TYPE_BOOLEAN, G_TYPE_INVALID);
-
-	dbus_g_object_register_marshaller
-		(tracker_VOID__STRING_STRING_INT_INT_INT, G_TYPE_NONE,
-		 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT,
-		 G_TYPE_INT, G_TYPE_INVALID);
+	/* Set signal handlers */
+	dbus_g_object_register_marshaller (tracker_VOID__STRING_BOOLEAN_BOOLEAN_BOOLEAN_BOOLEAN_BOOLEAN,
+                                           G_TYPE_NONE, 
+                                           G_TYPE_STRING, 
+                                           G_TYPE_BOOLEAN, 
+                                           G_TYPE_BOOLEAN,
+                                           G_TYPE_BOOLEAN, 
+                                           G_TYPE_BOOLEAN, 
+                                           G_TYPE_BOOLEAN,
+                                           G_TYPE_BOOLEAN, 
+                                           G_TYPE_INVALID);
+
+	dbus_g_object_register_marshaller (tracker_VOID__STRING_STRING_INT_INT_INT_DOUBLE, 
+                                           G_TYPE_NONE,
+                                           G_TYPE_STRING, 
+                                           G_TYPE_STRING, 
+                                           G_TYPE_INT, 
+                                           G_TYPE_INT,
+                                           G_TYPE_INT,
+                                           G_TYPE_DOUBLE,
+                                           G_TYPE_INVALID);
 
 	dbus_g_proxy_add_signal (priv->tracker->proxy,
 				 "IndexStateChange",
@@ -1700,34 +1759,41 @@
 				 G_TYPE_BOOLEAN,
 				 G_TYPE_BOOLEAN,
 				 G_TYPE_BOOLEAN,
-				 G_TYPE_BOOLEAN, G_TYPE_INVALID);
+				 G_TYPE_BOOLEAN, 
+                                 G_TYPE_INVALID);
 
 	dbus_g_proxy_add_signal (priv->tracker->proxy,
 				 "IndexProgress",
 				 G_TYPE_STRING,
 				 G_TYPE_STRING,
 				 G_TYPE_INT,
-				 G_TYPE_INT, G_TYPE_INT, G_TYPE_INVALID);
+				 G_TYPE_INT, 
+                                 G_TYPE_INT, 
+                                 G_TYPE_DOUBLE,
+                                 G_TYPE_INVALID);
 
 	dbus_g_proxy_add_signal (priv->tracker->proxy,
-				 "IndexFinished", G_TYPE_INT, G_TYPE_INVALID);
+				 "IndexFinished",
+                                 G_TYPE_DOUBLE,
+                                 G_TYPE_INVALID);
 
 	dbus_g_proxy_connect_signal (priv->tracker->proxy,
 				     "IndexStateChange",
 				     G_CALLBACK (index_state_changed),
-				     icon, NULL);
+				     icon,
+                                     NULL);
 
 	dbus_g_proxy_connect_signal (priv->tracker->proxy,
 				     "IndexProgress",
 				     G_CALLBACK (index_progress_changed),
-				     icon, NULL);
+				     icon, 
+                                     NULL);
 
 	dbus_g_proxy_connect_signal (priv->tracker->proxy,
 				     "IndexFinished",
-				     G_CALLBACK (index_finished), icon, NULL);
-
-	DBusGConnection *connection;
-	DBusGProxy *dbus_proxy;
+				     G_CALLBACK (index_finished), 
+                                     icon, 
+                                     NULL);
 
 	connection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
 	dbus_proxy = dbus_g_proxy_new_for_name (connection,
@@ -1746,32 +1812,46 @@
 				     G_CALLBACK (name_owner_changed),
 				     icon, NULL);
 
-
-	/* prompt for updated signals */
-	dbus_g_proxy_begin_call (priv->tracker->proxy, "PromptIndexSignals",
-				 NULL, NULL, NULL, G_TYPE_INVALID);
+	/* Prompt for updated signals */
+	dbus_g_proxy_begin_call (priv->tracker->proxy, 
+                                 "PromptIndexSignals",
+				 NULL, 
+                                 NULL, 
+                                 NULL, 
+                                 G_TYPE_INVALID);
 
 	return FALSE;
 }
 
 static void
-tray_icon_clicked (GtkStatusIcon * icon, guint button, guint timestamp,
-		   gpointer data)
-{
-	TrayIcon *self = TRAY_ICON (data);
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (self);
-
-
-	gtk_menu_popup (GTK_MENU (priv->menu), NULL, NULL,
-			gtk_status_icon_position_menu, icon, button,
+tray_icon_clicked (GtkStatusIcon *status_icon, 
+                   guint          button, 
+                   guint          timestamp,
+		   gpointer       data)
+{
+	TrayIcon *icon;
+	TrayIconPrivate *priv;
+
+	icon = TRAY_ICON (data);
+	priv = TRAY_ICON_GET_PRIVATE (icon);
+
+	gtk_menu_popup (GTK_MENU (priv->menu), 
+                        NULL, NULL,
+			gtk_status_icon_position_menu,
+                        status_icon, 
+                        button,
 			timestamp);
 }
 
 static void
-tray_icon_init (GTypeInstance * instance, gpointer g_class)
+tray_icon_init (GTypeInstance *instance,
+                gpointer       klass)
 {
-	TrayIcon *icon = TRAY_ICON (instance);
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
+	TrayIcon *icon;
+	TrayIconPrivate *priv;
+
+	icon = TRAY_ICON (instance);
+	priv = TRAY_ICON_GET_PRIVATE (icon);
 
 	priv->icon = gtk_status_icon_new ();
 
@@ -1780,28 +1860,31 @@
 	priv->reindex = FALSE;
 
 	g_signal_connect (G_OBJECT (priv->icon), "activate",
-			  G_CALLBACK (activate_icon), instance);
+			  G_CALLBACK (activate_icon), 
+                          instance);
 	g_signal_connect (G_OBJECT (priv->icon), "popup-menu",
-			  G_CALLBACK (tray_icon_clicked), instance);
-
+			  G_CALLBACK (tray_icon_clicked), 
+                          instance);
 
-	/* build context menu */
+	/* Build context menu */
 	create_context_menu (icon);
 
 	gtk_status_icon_set_visible (priv->icon, FALSE);
 
 	setup_dbus_connection (icon);
-
 }
 
 void
-tray_icon_set_tooltip (TrayIcon * icon, const gchar * format, ...)
+tray_icon_set_tooltip (TrayIcon    *icon, 
+                       const gchar *format, 
+                       ...)
 {
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
-
+	TrayIconPrivate *priv;
 	gchar *tooltip = NULL;
 	va_list args;
 
+        priv = TRAY_ICON_GET_PRIVATE (icon);
+
 	va_start (args, format);
 	tooltip = g_strdup_vprintf (format, args);
 	va_end (args);
@@ -1812,35 +1895,41 @@
 }
 
 void
-tray_icon_show_message (TrayIcon * icon, const char *message, ...)
+tray_icon_show_message (TrayIcon    *icon,
+                        const gchar *message, 
+                        ...)
 {
-	va_list args;
+	TrayIconPrivate *priv;
+	NotifyNotification *notification;
 	gchar *msg = NULL;
-	NotifyNotification *notification = NULL;
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
+	va_list args;
+        
+        priv = TRAY_ICON_GET_PRIVATE (icon);
 
 	va_start (args, message);
 	msg = g_strdup_vprintf (message, args);
 	va_end (args);
 
-	if (priv->disabled)
+	if (priv->disabled) {
 		return;
+        }
 
-	if (!priv->auto_hide && !gtk_status_icon_get_visible (priv->icon))
+	if (!priv->auto_hide && !gtk_status_icon_get_visible (priv->icon)) {
 		gtk_status_icon_set_visible (priv->icon, TRUE);
+        }
 
 	notification =
-		notify_notification_new_with_status_icon ("Tracker", msg,
-							  NULL, priv->icon);
+		notify_notification_new_with_status_icon ("Tracker", 
+                                                          msg,
+							  NULL, 
+                                                          priv->icon);
 
 	notify_notification_set_urgency (notification, NOTIFY_URGENCY_NORMAL);
-
 	notify_notification_show (notification, NULL);
 
 	g_object_unref (notification);
 
 	g_free (msg);
-
 }
 
 GType
@@ -1851,170 +1940,185 @@
 	if (type == 0) {
 		static const GTypeInfo info = {
 			sizeof (TrayIconClass),
-			NULL,	/* base_init */
-			NULL,	/* base_finalize */
-			(GClassInitFunc) tray_icon_class_init,	/* class_init */
-			NULL,	/* class_finalize */
-			NULL,	/* class_data */
+			NULL,	
+			NULL,	
+			(GClassInitFunc) tray_icon_class_init,
+			NULL,	
+			NULL,	
 			sizeof (TrayIcon),
-			0,	/* n_preallocs */
-			tray_icon_init	/* instance_init */
+			0,	
+			tray_icon_init	
 		};
 
-		type = g_type_register_static (G_TYPE_OBJECT, "TrayIconType",
-					       &info, 0);
+		type = g_type_register_static (G_TYPE_OBJECT, 
+                                               "TrayIconType",
+					       &info,
+                                               0);
 	}
 
 	return type;
 }
 
-static void
-load_options (TrayIcon * icon)
+static gboolean
+load_options (TrayIcon *icon)
 {
+	TrayIconPrivate *priv;
 	GError *error = NULL;
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (icon);
+
+        priv = TRAY_ICON_GET_PRIVATE (icon);
 
 	if (!priv->keyfile) {
 		priv->keyfile = g_key_file_new ();
 	}
 
 	if (!g_file_test (priv->filename, G_FILE_TEST_EXISTS)) {
+		gchar *tracker_dir;
+                gchar *contents;
 
+                tracker_dir = g_build_path (g_get_user_config_dir (), 
+                                            "tracker", 
+                                            NULL);
 
-
-		gchar *tracker_dir =
-			g_build_filename (g_get_user_config_dir (),
-					  "/tracker", NULL);
-
-		if (!g_file_test (tracker_dir, G_FILE_TEST_EXISTS)) {
+		if (!g_file_test (tracker_dir, G_FILE_TEST_EXISTS)) {      
 			g_mkdir_with_parents (tracker_dir, 0700);
 		}
 
 		g_free (tracker_dir);
 
-
-		char *contents = g_strconcat ("[Applet]\n",
-					      "AnimateWhenIndexing=true\n\n",
-					      "AutoHideIcon=false\n\n",
-					      "SmartPause=2\n", NULL);
-
-		g_file_set_contents (priv->filename, contents,
-				     strlen (contents), NULL);
+		contents = g_strconcat ("[Applet]\n",
+                                        "AnimateWhenIndexing=true\n"
+                                        "\n",
+                                        "AutoHideIcon=false\n"
+                                        "\n",
+                                        "SmartPause=2\n", 
+                                        NULL);
+
+		g_file_set_contents (priv->filename,
+                                     contents,
+				     strlen (contents), 
+                                     NULL);
 		g_free (contents);
-
-
 	}
 
-	if (!g_key_file_load_from_file
-	    (priv->keyfile, priv->filename, G_KEY_FILE_KEEP_COMMENTS, &error)
-	    || error) {
-		if (error)
-			g_error ("failed: g_key_file_load_from_file(): %s\n",
-				 error->message);
+	if (!g_key_file_load_from_file (priv->keyfile, 
+                                        priv->filename, 
+                                        G_KEY_FILE_KEEP_COMMENTS, 
+                                        &error) || error) {
+		if (error) {
+			g_warning ("Call to g_key_file_load_from_file() failed for filename:'%s', %s\n",
+                                   priv->filename,
+                                   error->message);
+                }
+
 		priv->show_animation = TRUE;
 		priv->auto_hide = FALSE;
 		priv->auto_pause_setting = AUTO_PAUSE_MERGING;
 
-		return;
+		return FALSE;
 	}
 
-	if (g_key_file_has_key
-	    (priv->keyfile, "Applet", "AnimateWhenIndexing", NULL)) {
-		priv->show_animation =
-			g_key_file_get_boolean (priv->keyfile, "Applet",
-						"AnimateWhenIndexing", NULL);
+	if (g_key_file_has_key (priv->keyfile, 
+                                "Applet", 
+                                "AnimateWhenIndexing", 
+                                NULL)) {
+		priv->show_animation = g_key_file_get_boolean (priv->keyfile, 
+                                                               "Applet",
+                                                               "AnimateWhenIndexing", 
+                                                               NULL);
 	} else {
 		priv->show_animation = TRUE;
 	}
 
-	if (g_key_file_has_key
-	    (priv->keyfile, "Applet", "AutoHideIcon", NULL)) {
-		priv->auto_hide =
-			g_key_file_get_boolean (priv->keyfile, "Applet",
-						"AutoHideIcon", NULL);
+	if (g_key_file_has_key (priv->keyfile, 
+                                "Applet", 
+                                "AutoHideIcon", 
+                                NULL)) {
+		priv->auto_hide = g_key_file_get_boolean (priv->keyfile, 
+                                                          "Applet",
+                                                          "AutoHideIcon", 
+                                                          NULL);
 	} else {
 		priv->auto_hide = FALSE;
 	}
 
-	if (g_key_file_has_key (priv->keyfile, "Applet", "SmartPause", NULL)) {
-		priv->auto_pause_setting =
-			g_key_file_get_integer (priv->keyfile, "Applet",
-						"SmartPause", NULL);
+	if (g_key_file_has_key (priv->keyfile, 
+                                "Applet", 
+                                "SmartPause", 
+                                NULL)) {
+		priv->auto_pause_setting = g_key_file_get_integer (priv->keyfile, 
+                                                                   "Applet",
+                                                                   "SmartPause", 
+                                                                   NULL);
 	} else {
 		priv->auto_pause_setting = AUTO_PAUSE_MERGING;
 	}
 
 	switch (priv->auto_pause_setting) {
-
 	case AUTO_PAUSE_NONE:
-
 		priv->auto_pause_setting = AUTO_PAUSE_NONE;
 		priv->auto_pause = FALSE;
 		stop_watching_events (icon);
-
 		break;
-
 	case AUTO_PAUSE_INDEXING:
-
 		if (can_auto_pause (icon)) {
 			start_watching_events (icon);
 		} else {
 			stop_watching_events (icon);
 		}
-
 		break;
-
 	case AUTO_PAUSE_MERGING:
-
 		if (can_auto_pause (icon)) {
 			start_watching_events (icon);
 		} else {
 			stop_watching_events (icon);
 		}
-
 		break;
-
 	}
 
+        return TRUE;
 }
 
 int
 main (int argc, char *argv[])
 {
+        TrayIconPrivate *priv;
+        GOptionContext *context;
 
-	bindtextdomain (GETTEXT_PACKAGE, TRACKER_LOCALEDIR);
+	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
 	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
 	textdomain (GETTEXT_PACKAGE);
 
-	gtk_init (&argc, &argv);
+	context = g_option_context_new (_("- Tracker applet for quick control of "
+                                          "your desktop search tools"));
 
-	if (!notify_is_initted () && !notify_init (PROGRAM_NAME)) {
-		g_warning ("failed: notify_init()\n");
-		return EXIT_FAILURE;
-	}
-	gtk_window_set_default_icon_name ("tracker");
+	g_option_context_add_main_entries (context, entries, NULL);
+	g_option_context_parse (context, &argc, &argv, NULL);
+	g_option_context_free (context);
 
-	g_set_application_name (_("Tracker"));
+        g_print ("Initializing GTK+\n");
 
+	gtk_init (&argc, &argv);
 
-	/* set translatable strings here */
+        g_print ("Initializing libnotify\n");
 
-	initial_index_1 =
-		_
-		("Your computer is about to be indexed so you can perform fast searches of your files and emails");
-	initial_index_2 =
-		_
-		("You can pause indexing at any time and configure index settings by right clicking here");
-
-	end_index_initial_msg =
-		_("Tracker has finished indexing your system");
-	end_index_hours_msg = _(" in %d hours and %d minutes");
-	end_index_minutes_msg = _(" in %d minutes and %d seconds");
-	end_index_seconds_msg = _(" in %d seconds");
-	end_index_final_msg =
-		_("You can now perform searches by clicking here");
+	if (!notify_is_initted () && 
+            !notify_init (PROGRAM_NAME)) {
+		g_warning ("Call to notify_init() failed\n");
+		return EXIT_FAILURE;
+	}
+
+        g_print ("Initializing strings\n");
 
+	gtk_window_set_default_icon_name ("tracker");
+	g_set_application_name (_("Tracker"));
 
+	initial_index_1 = 
+                _("Your computer is about to be indexed so "
+                  "you can perform fast searches of your files and emails");
+	initial_index_2 = 
+                _("You can pause indexing at any time and "
+                  "configure index settings by right clicking here");
+        
 	stat_info[0].label = _("Files:");
 	stat_info[1].label = _("    Folders:");
 	stat_info[2].label = _("    Documents:");
@@ -2028,20 +2132,30 @@
 	stat_info[10].label = _("Conversations:");
 	stat_info[11].label = _("Emails:");
 
+        g_print ("Initializing tray icon\n");
+
 	main_icon = g_object_new (TYPE_TRAY_ICON, NULL);
-	TrayIconPrivate *priv = TRAY_ICON_GET_PRIVATE (main_icon);
 
-	priv->keyfile = NULL;
+	priv = TRAY_ICON_GET_PRIVATE (main_icon);
 
-	priv->filename =
-		g_build_filename (g_strdup (g_get_user_config_dir ()),
-				  "/tracker/tracker-applet.cfg", NULL);
+        g_print ("Initializing config\n");
 
-	load_options (main_icon);
+	priv->keyfile = NULL;
+	priv->filename = g_build_filename (g_get_user_config_dir (),
+                                           "tracker"
+                                           "tracker-applet.cfg", 
+                                           NULL);
+
+	if (!load_options (main_icon)) {
+                return EXIT_FAILURE;
+        }
 
+        g_print ("Starting main loop\n");
 
 	gtk_main ();
 
+        g_print ("Shutting down\n");
+
 	notify_uninit ();
 
 	return EXIT_SUCCESS;

Modified: branches/indexer-split/src/trackerd/tracker-daemon.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-daemon.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-daemon.c	Thu Sep  4 16:57:02 2008
@@ -51,10 +51,10 @@
 } TrackerDaemonPrivate;
 
 enum {
-        DAEMON_INDEX_STATE_CHANGE,
-        DAEMON_INDEX_FINISHED,
-	DAEMON_INDEX_PROGRESS,
-	DAEMON_STATS_CHANGED,
+        INDEX_STATE_CHANGE,
+        INDEX_FINISHED,
+	INDEX_PROGRESS,
+	SERVICE_STATISTICS_UPDATED,
         LAST_SIGNAL
 };
 
@@ -85,7 +85,7 @@
 
 	object_class->finalize = tracker_daemon_finalize;
 
-        signals[DAEMON_INDEX_STATE_CHANGE] =
+        signals[INDEX_STATE_CHANGE] =
                 g_signal_new ("index-state-change",
                               G_TYPE_FROM_CLASS (klass),
                               G_SIGNAL_RUN_LAST,
@@ -101,32 +101,33 @@
 			      G_TYPE_BOOLEAN,
 			      G_TYPE_BOOLEAN,
 			      G_TYPE_BOOLEAN);
-        signals[DAEMON_INDEX_FINISHED] =
+        signals[INDEX_FINISHED] =
                 g_signal_new ("index-finished",
                               G_TYPE_FROM_CLASS (klass),
                               G_SIGNAL_RUN_LAST,
                               0,
                               NULL, NULL,
-                              g_cclosure_marshal_VOID__INT,
+                              g_cclosure_marshal_VOID__DOUBLE,
                               G_TYPE_NONE,
                               1,
-			      G_TYPE_INT);
-        signals[DAEMON_INDEX_PROGRESS] =
+			      G_TYPE_DOUBLE);
+        signals[INDEX_PROGRESS] =
                 g_signal_new ("index-progress",
                               G_TYPE_FROM_CLASS (klass),
                               G_SIGNAL_RUN_LAST,
                               0,
                               NULL, NULL,
-                              tracker_marshal_VOID__STRING_STRING_INT_INT_INT,
+                              tracker_marshal_VOID__STRING_STRING_INT_INT_INT_DOUBLE,
                               G_TYPE_NONE,
-                              5,
+                              6,
 			      G_TYPE_STRING,
 			      G_TYPE_STRING,
 			      G_TYPE_INT,
 			      G_TYPE_INT,
-			      G_TYPE_INT);
-        signals[DAEMON_STATS_CHANGED] =
-                g_signal_new ("stats-changed",
+			      G_TYPE_INT,
+			      G_TYPE_DOUBLE);
+        signals[SERVICE_STATISTICS_UPDATED] =
+                g_signal_new ("service-statistics-updated",
                               G_TYPE_FROM_CLASS (klass),
                               G_SIGNAL_RUN_LAST,
                               0,
@@ -135,11 +136,13 @@
                               G_TYPE_NONE,
                               1,
 			      G_TYPE_STRV);
+
 	g_type_class_add_private (object_class, sizeof (TrackerDaemonPrivate));
 }
 
 static void
-clean_last_stats (TrackerDaemonPrivate *priv) {
+clean_last_stats (TrackerDaemonPrivate *priv) 
+{
 	if (priv->last_stats) {
 		g_ptr_array_foreach (priv->last_stats, (GFunc) g_strfreev, NULL);
 		g_ptr_array_free (priv->last_stats, TRUE);
@@ -159,42 +162,54 @@
 	TrackerDBResultSet   *result_set;
 	GPtrArray            *values = NULL;
 	GPtrArray            *new_stats;
-	GStrv                 ret;
+	GStrv                 strv;
 	guint                 i;
 
 	daemon = tracker_dbus_get_object (TRACKER_TYPE_DAEMON);
 	priv = TRACKER_DAEMON_GET_PRIVATE (daemon);
 	iface = tracker_db_manager_get_db_interface_by_service (TRACKER_DB_FOR_FILE_SERVICE);
 
-	/* GetStats has asc in its query. Therefore we don't have to lookup the
-	 * in a to compare in b, just compare index based. Maybe we want to
-	 * change this nonetheless later? */
-
+	/* GetStats has asc in its query. Therefore we don't have to
+	 * lookup the in a to compare in b, just compare index based.
+	 * Maybe we want to change this nonetheless later? 
+	 */
 	result_set = tracker_db_exec_proc (iface, "GetStats", 0);
 	new_stats = tracker_dbus_query_result_to_ptr_array (result_set);
 
-	if (result_set)
+	if (result_set) {
 		g_object_unref (result_set);
+	}
 
 	if (priv->last_stats && new_stats) {
 		for (i = 0; i < priv->last_stats->len && i < new_stats->len; i++) {
-			GStrv str1 = g_ptr_array_index (priv->last_stats, i);
-			GStrv str2 = g_ptr_array_index (new_stats, i);
+			GStrv str1;
+			GStrv str2;
+
+			str1 = g_ptr_array_index (priv->last_stats, i);
+			str2 = g_ptr_array_index (new_stats, i);
 
-			if (!str1[0] || !str1[1] || !str2[1])
+			if (!str1[0] || !str1[1] || !str2[1]) {
 				continue;
+			}
 
 			if (strcmp (str1[1], str2[1]) != 0) {
-				if (!values)
+				if (!values) {
 					values = g_ptr_array_new ();
+				}
+
 				g_ptr_array_add (values, g_strdup (str1[0]));
 			}
 		}
 	} else if (new_stats) {
 		for (i = 0; i < new_stats->len; i++) {
-			GStrv str = g_ptr_array_index (new_stats, i);
-			if (!str[0])
+			GStrv str;
+
+			str = g_ptr_array_index (new_stats, i);
+
+			if (!str[0]) {
 				continue;
+			}
+
 			g_ptr_array_add (values, g_strdup (str[0]));
 		}
 	}
@@ -203,16 +218,21 @@
 	priv->last_stats = new_stats;
 
 	if (values && values->len > 0) {
-		ret = (GStrv) g_malloc0 (sizeof (gchar*) * (values->len + 2));
-		for (i = 0 ; i < values->len; i++)
-			ret[i] = g_ptr_array_index (values, i);
-		g_ptr_array_free (values, TRUE);
-	} else
-		ret = (GStrv) g_malloc0 (sizeof (gchar*) * 1);
+		strv = g_new0 (gchar*, values->len + 1);
 
-	g_signal_emit (daemon, signals[DAEMON_STATS_CHANGED], 0, ret);
+		for (i = 0 ; i < values->len; i++) {
+			strv[i] = g_ptr_array_index (values, i);
+		}
 
-	g_strfreev (ret);
+		g_ptr_array_free (values, TRUE);
+		strv[i] = NULL;
+	} else {
+		strv = g_new0 (gchar*, 1);
+		strv[0] = NULL;
+	}
+
+	g_signal_emit (daemon, signals[SERVICE_STATISTICS_UPDATED], 0, strv);
+	g_strfreev (strv);
 }
 
 static void
@@ -246,11 +266,11 @@
 	result_set = tracker_db_exec_proc (iface, "GetStats", 0);
 	priv->last_stats = tracker_dbus_query_result_to_ptr_array (result_set);
 
-	if (result_set)
+	if (result_set) {
 		g_object_unref (result_set);
+	}
 }
 
-
 static void
 tracker_daemon_finalize (GObject *object)
 {
@@ -685,7 +705,8 @@
                                "",
                                tracker_processor_get_files_total (priv->processor),
                                tracker_processor_get_directories_found (priv->processor),
-                               tracker_processor_get_directories_total (priv->processor));
+                               tracker_processor_get_directories_total (priv->processor),
+			       tracker_processor_get_seconds_elapsed (priv->processor));
 
 #if 1
 	/* FIXME: We need a way of knowing WHAT service we have a
@@ -695,9 +716,10 @@
 			       "index-progress",
                                "Emails",
                                "",
-                               0,  /*priv->tracker->index_count,*/
-                               0,  /*priv->tracker->mbox_processed,*/
-                               0); /*priv->tracker->mbox_count);*/
+                               0,  /* priv->tracker->index_count, */
+                               0,  /* priv->tracker->mbox_processed, */
+                               0,  /* priv->tracker->mbox_count); */
+			       0); /* seconds elapsed */
 #endif
 
 	dbus_g_method_return (context);

Modified: branches/indexer-split/src/trackerd/tracker-marshal.list
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-marshal.list	(original)
+++ branches/indexer-split/src/trackerd/tracker-marshal.list	Thu Sep  4 16:57:02 2008
@@ -1,5 +1,5 @@
 VOID:STRING,UINT,UINT,UINT,UINT
-VOID:STRING,STRING,INT,INT,INT
+VOID:STRING,STRING,INT,INT,INT,DOUBLE
 VOID:STRING,STRING,STRING
 VOID:STRING,BOOLEAN,BOOLEAN,BOOLEAN,BOOLEAN,BOOLEAN,BOOLEAN
 VOID:STRING,OBJECT,BOOLEAN

Modified: branches/indexer-split/src/trackerd/tracker-processor.c
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-processor.c	(original)
+++ branches/indexer-split/src/trackerd/tracker-processor.c	Thu Sep  4 16:57:02 2008
@@ -96,6 +96,8 @@
 
 	guint           items_done;
 	guint           items_remaining;
+
+	gdouble         seconds_elapsed;
 };
 
 enum {
@@ -1005,8 +1007,10 @@
 
 	processor = user_data;
 
+	/* Update our local copy */
 	processor->private->items_done = items_done; 
 	processor->private->items_remaining = items_remaining; 
+	processor->private->seconds_elapsed = seconds_elapsed;
 
 	if (items_remaining < 1 ||
 	    current_module_name == NULL || 
@@ -1025,9 +1029,10 @@
 			       "index-progress",
 			       tracker_module_config_get_index_service (current_module_name),
 			       path ? path : "",
-			       processor->private->items_done,                          /* files */
-			       processor->private->items_remaining,                     /* files */
-			       processor->private->items_done + processor->private->items_remaining); /* files */
+			       items_done,
+			       items_remaining,
+			       items_done + items_remaining,
+			       seconds_elapsed);
 	g_free (path);
 
 	/* Tell the index that it can reload, really we should do
@@ -1067,18 +1072,25 @@
 {
 	TrackerProcessor *processor;
 	TrackerDBIndex   *index;
+	GObject          *object;
 	gchar            *str;
 
 	processor = user_data;
+	object = tracker_dbus_get_object (TRACKER_TYPE_DAEMON);
+
+	processor->private->items_done = items_done;
+	processor->private->items_remaining = 0;
+	processor->private->seconds_elapsed = seconds_elapsed;
 
 	/* Signal to any applications */
-	g_signal_emit_by_name (tracker_dbus_get_object (TRACKER_TYPE_DAEMON),
+	g_signal_emit_by_name (object,
 			       "index-progress",
 			       "", /* Service */
 			       "", /* Path */
-			       processor->private->items_done,                          /* files */
-			       processor->private->items_remaining,                     /* files */
-			       processor->private->items_done + processor->private->items_remaining); /* files */
+			       items_done,
+			       0,
+			       items_done,
+			       seconds_elapsed);
 
 	/* Tell the index that it can reload, really we should do
 	 * module_name->index type so we don't do this for both
@@ -1104,6 +1116,11 @@
 	/* Now the indexer is done, we can signal our status as IDLE */ 
 	tracker_status_set_and_signal (TRACKER_STATUS_IDLE);
 
+	/* Signal to the applet we are finished */
+	g_signal_emit_by_name (object,
+			       "index-finished",
+			       seconds_elapsed);
+
 	/* Signal the processor is now finished */
 	processor->private->finished = TRUE;
 	g_signal_emit (processor, signals[FINISHED], 0);
@@ -1680,3 +1697,11 @@
 	
 	return processor->private->files_found + processor->private->files_ignored;
 }
+
+gdouble 
+tracker_processor_get_seconds_elapsed (TrackerProcessor *processor)
+{
+	g_return_val_if_fail (TRACKER_IS_PROCESSOR (processor), 0);
+	
+	return processor->private->seconds_elapsed;
+}

Modified: branches/indexer-split/src/trackerd/tracker-processor.h
==============================================================================
--- branches/indexer-split/src/trackerd/tracker-processor.h	(original)
+++ branches/indexer-split/src/trackerd/tracker-processor.h	Thu Sep  4 16:57:02 2008
@@ -84,6 +84,7 @@
 guint             tracker_processor_get_files_found         (TrackerProcessor *processor);
 guint             tracker_processor_get_files_ignored       (TrackerProcessor *processor);
 guint             tracker_processor_get_files_total         (TrackerProcessor *processor);
+gdouble           tracker_processor_get_seconds_elapsed     (TrackerProcessor *processor);
 
 G_END_DECLS
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]