[gthumb] Fix display on multiple edit of tags and improve gth-monitor



commit ef59e7fdf2125260b0ef9825f5812c51a8393cdf
Author: Marc Pavot <marc pavot gmail com>
Date:   Tue May 26 08:21:44 2009 -0400

    Fix display on multiple edit of tags and improve gth-monitor
    
    The gth-monitor files have moved from src/ to libgthumb/.
---
 libgthumb/Makefile.am               |    2 +
 libgthumb/comments.c                |  166 +++------------------------------
 libgthumb/comments.h                |    2 -
 libgthumb/file-data.c               |   21 +++--
 libgthumb/file-data.h               |    5 +-
 libgthumb/gth-filter.c              |   31 +++---
 {src => libgthumb}/gth-monitor.c    |  114 +++++++++++------------
 {src => libgthumb}/gth-monitor.h    |   42 +++-----
 libgthumb/gth-utils.c               |   86 +++++++++++++++++
 libgthumb/gth-utils.h               |    5 +-
 src/Makefile.am                     |    2 -
 src/catalog-png-exporter.c          |    7 +-
 src/catalog-web-exporter.c          |    1 +
 src/dlg-bookmarks.c                 |   10 +-
 src/dlg-catalog.c                   |    6 +-
 src/dlg-change-date.c               |    6 +-
 src/dlg-comment.c                   |    1 -
 src/dlg-convert.c                   |    8 +-
 src/dlg-file-utils.c                |   34 ++++----
 src/dlg-jpegtran.c                  |   10 +-
 src/dlg-photo-importer.c            |    6 +-
 src/dlg-reset-exif.c                |    8 +-
 src/gth-batch-op.c                  |    8 +-
 src/gth-browser-actions-callbacks.c |   20 ++--
 src/gth-browser.c                   |   20 +++--
 src/gth-fullscreen.c                |    3 +-
 src/gth-viewer.c                    |    3 +-
 src/gth-window-utils.c              |    4 +-
 src/main.c                          |  175 +----------------------------------
 src/main.h                          |   29 ------
 30 files changed, 294 insertions(+), 541 deletions(-)

diff --git a/libgthumb/Makefile.am b/libgthumb/Makefile.am
index 97ded52..2bcfab5 100644
--- a/libgthumb/Makefile.am
+++ b/libgthumb/Makefile.am
@@ -50,6 +50,7 @@ HEADER_FILES =				\
 	gth-pixbuf-op.h			\
 	gth-sort-utils.h		\
 	gth-utils.h			\
+	gth-monitor.h			\
 	gthumb-error.h			\
 	gthumb-histogram.h		\
 	gthumb-init.h			\
@@ -110,6 +111,7 @@ libgthumb_la_SOURCES =			\
 	gth-nav-window.c		\
 	gth-sort-utils.c		\
 	gth-utils.c			\
+	gth-monitor.c			\
 	gthumb-error.c			\
 	gthumb-histogram.c		\
 	gthumb-init.c			\
diff --git a/libgthumb/comments.c b/libgthumb/comments.c
index f6ccc63..d2a8a23 100644
--- a/libgthumb/comments.c
+++ b/libgthumb/comments.c
@@ -29,7 +29,6 @@
 #include <dirent.h>
 #include <string.h>
 #include <strings.h>
-#include <ctype.h>
 #include <time.h>
 
 #include <glib/gi18n.h>
@@ -44,6 +43,7 @@
 #include "glib-utils.h"
 #include "gtk-utils.h"
 #include "gth-exif-utils.h"
+#include "gth-monitor.h"
 
 #define COMMENT_TAG  ((xmlChar *)"Comment")
 #define PLACE_TAG    ((xmlChar *)"Place")
@@ -394,20 +394,6 @@ load_comment_from_metadata (const char *uri)
 	return data;
 }
 
-static char*
-get_keywords_str (CommentData *data)
-{
-        GString   *keywords_str;
-        GSList    *tmp;
-
-        keywords_str = g_string_new (NULL);
-        for (tmp = data->keywords; tmp; tmp = g_slist_next (tmp)) {
-                keywords_str = g_string_append (keywords_str, g_strdup (tmp->data));
-                if (g_slist_next (tmp))
-                        keywords_str = g_string_append_c (keywords_str, ',');
-        }
-        return g_string_free (keywords_str, FALSE);
-}
 
 static void
 save_comment_to_metadata (const char  *uri,
@@ -436,7 +422,7 @@ save_comment_to_metadata (const char  *uri,
         add_metadata = simple_add_metadata (add_metadata, TAG_NAME_SETS[COMMENT_DATE_TAG_NAMES][0], buf);
 
         add_metadata = clear_metadata_tagset (add_metadata, TAG_NAME_SETS[KEYWORD_TAG_NAMES]);
-        keywords_str = get_keywords_str (data);
+        keywords_str = comments_get_tags_as_string (data, ",");
 	add_metadata = simple_add_metadata (add_metadata, TAG_NAME_SETS[KEYWORD_TAG_NAMES][0], keywords_str);
         g_free (keywords_str);
 
@@ -537,7 +523,7 @@ save_comment (const char  *uri,
 	/* Convert data to strings. */
 
 	time_str = g_strdup_printf ("%ld", data->time);
-        keywords_str = get_keywords_str (data);
+        keywords_str = comments_get_tags_as_string (data, ",");
 
 	/* Escape text */
 
@@ -659,6 +645,7 @@ comments_save_comment (const char  *uri,
 
 	save_comment (uri, new_data, TRUE);
 	comment_data_free (new_data);
+        gth_monitor_notify_update_metadata (uri);
 }
 
 
@@ -730,6 +717,7 @@ comments_save_tags (const char  *uri,
 
 	save_comment (uri, new_data, TRUE);
 	comment_data_free (new_data);
+        gth_monitor_notify_update_metadata (uri);
 }
 
 
@@ -813,113 +801,10 @@ comment_text_is_void (CommentData *data)
 }
 
 
-/* based on glib/glib/gmarkup.c (Copyright 2000, 2003 Red Hat, Inc.)
- * This version does not escape ' and ''. Needed  because IE does not recognize
- * &apos; and &quot; */
-static void
-_append_escaped_text_for_html (GString     *str,
-			       const gchar *text,
-			       gssize       length)
-{
-	const gchar *p;
-	const gchar *end;
-	gunichar     ch;
-	int          state = 0;
-
-	p = text;
-	end = text + length;
-
-	while (p != end) {
-		const gchar *next;
-		next = g_utf8_next_char (p);
-		ch = g_utf8_get_char (p);
-
-		switch (state) {
-		    case 1: /* escaped */
-			if ((ch > 127) ||  !isprint((char)ch))
-				g_string_append_printf (str, "\\&#%d;", ch);
-			else
-				g_string_append_unichar (str, ch);
-			state = 0;
-			break;
-
-		    default: /* not escaped */
-			switch (*p) {
-			    case '\\':
-				state = 1; /* next character is escaped */
-				break;
-
-			    case '&':
-				g_string_append (str, "&amp;");
-				break;
-
-			    case '<':
-				g_string_append (str, "&lt;");
-				break;
-
-			    case '>':
-				g_string_append (str, "&gt;");
-				break;
-
-			    case '\n':
-				g_string_append (str, "<br />");
-				break;
-
-			    default:
-				if ((ch > 127) ||  !isprint((char)ch))
-					g_string_append_printf (str, "&#%d;", ch);
-				else
-					g_string_append_unichar (str, ch);
-				state = 0;
-				break;
-			}
-		}
-
-		p = next;
-	}
-}
-
-
-char*
-_g_escape_text_for_html (const gchar *text,
-			 gssize       length)
-{
-	GString *str;
-
-	g_return_val_if_fail (text != NULL, NULL);
-
-	if (length < 0)
-		length = strlen (text);
-
-	/* prealloc at least as long as original text */
-	str = g_string_sized_new (length);
-	_append_escaped_text_for_html (str, text, length);
-
-	return g_string_free (str, FALSE);
-}
-
-
-static void
-_string_append (GString    *str,
-		const char *a,
-		gboolean    markup_escape)
-{
-	if (a == NULL)
-		return;
-
- 	if (markup_escape)
-		_append_escaped_text_for_html (str, a, strlen (a));
-	else
-		g_string_append (str, a);
-}
-
-
-/* Note: separators are not escaped */
-static char *
-_get_comment_as_string_common (CommentData *data,
-			       char        *sep1,
-			       char        *sep2,
-			       gboolean     markup_escape)
+char *
+comments_get_comment_as_string (CommentData *data,
+				char        *sep1,
+				char        *sep2)
 {
 	char      *as_string = NULL;
 	char       time_txt[50] = "";
@@ -943,8 +828,6 @@ _get_comment_as_string_common (CommentData *data,
 	    && (data->time == 0)) {
 		if (data->keywords)
 			as_string = NULL;
-		else if (markup_escape)
-			as_string = g_markup_escape_text (_("(No Comment)"), -1);
 		else
 			as_string = g_strdup (_("(No Comment)"));
 
@@ -954,20 +837,20 @@ _get_comment_as_string_common (CommentData *data,
 		comment = g_string_new ("");
 
 		if (data->comment != NULL)
-			_string_append (comment, data->comment, markup_escape);
+			g_string_append (comment, data->comment);
 
 		if ((data->comment != NULL)
 		    && ((data->place != NULL) || (*time_txt != 0)))
 			g_string_append (comment, sep1);
 
 		if (data->place != NULL)
-			_string_append (comment, data->place, markup_escape);
+			g_string_append (comment, data->place);
 
 		if ((data->place != NULL) && (*time_txt != 0))
 			g_string_append (comment, sep2);
 
 		if (utf8_time_txt != NULL)
-			_string_append (comment, utf8_time_txt, markup_escape);
+			g_string_append (comment, utf8_time_txt);
 
 		as_string = comment->str;
 		g_string_free (comment, FALSE);
@@ -976,13 +859,13 @@ _get_comment_as_string_common (CommentData *data,
 	g_free (utf8_time_txt);
 
 	return as_string;
+
 }
 
 
-/* Note: separators are not escaped */
-static char *
-_get_tags_as_string_common (CommentData *data,
-                                  char        *sep)
+char *
+comments_get_tags_as_string (CommentData *data,
+                             char        *sep)
 {
         GString *tags;
         GSList  *tmp;
@@ -1003,20 +886,3 @@ _get_tags_as_string_common (CommentData *data,
 
         return g_string_free (tags, FALSE);
 }
-
-
-char *
-comments_get_comment_as_string (CommentData *data,
-				char        *sep1,
-				char        *sep2)
-{
-	return _get_comment_as_string_common (data, sep1, sep2, FALSE);
-}
-
-char *
-comments_get_tags_as_string (CommentData *data,
-                                   char        *sep)
-{
-	return _get_tags_as_string_common (data, sep);
-}
-
diff --git a/libgthumb/comments.h b/libgthumb/comments.h
index 64a57a7..724b6d9 100644
--- a/libgthumb/comments.h
+++ b/libgthumb/comments.h
@@ -75,8 +75,6 @@ char *         comments_get_comment_as_string      (CommentData *data,
 						    char        *sep2);
 char *         comments_get_tags_as_string         (CommentData *data,
 						    char        *sep);
-char*          _g_escape_text_for_html             (const gchar *text,
-						    gssize       length);
 
 
 #endif /* COMMENTS_H */
diff --git a/libgthumb/file-data.c b/libgthumb/file-data.c
index f7f3d88..f26b988 100644
--- a/libgthumb/file-data.c
+++ b/libgthumb/file-data.c
@@ -270,15 +270,6 @@ file_data_set_path (FileData   *fd,
 	file_data_update (fd);
 }
 
-void
-file_data_load_comment_data (FileData *fd)
-{
-	g_return_if_fail (fd != NULL);
-
-	if (fd->comment_data != NULL)
-		return;
-	fd->comment_data = comments_load_comment (fd->path, FALSE);
-}
 
 void
 file_data_update_comment (FileData *fd)
@@ -402,3 +393,15 @@ file_data_has_local_path (FileData  *fd,
 		return TRUE;
 	}
 }
+
+CommentData *
+file_data_get_comment (FileData *fd)
+{
+	g_return_val_if_fail (fd != NULL, NULL);
+
+	if (!fd->comment_data)
+                fd->comment_data = comments_load_comment (fd->path, FALSE);
+
+        return fd->comment_data;
+}
+
diff --git a/libgthumb/file-data.h b/libgthumb/file-data.h
index f562757..254a3f2 100644
--- a/libgthumb/file-data.h
+++ b/libgthumb/file-data.h
@@ -57,7 +57,8 @@ typedef struct {
 
 	char               *comment;
 	char               *tags;
-	CommentData        *comment_data;
+	CommentData        *comment_data;      /* Do not access this directly. Use
+                                                  file_data_get_comment (fd) instead. */
 	
 	GList              *metadata;
 } FileData;
@@ -76,8 +77,8 @@ void         file_data_update_mime_type    (FileData         *fd,
 					    gboolean          fast_mime_type);
 void         file_data_update_all          (FileData         *fd,
 					    gboolean          fast_mime_type);				    
-void         file_data_load_comment_data   (FileData         *fd);
 void         file_data_update_comment      (FileData         *fd);
+CommentData* file_data_get_comment         (FileData         *fd);
 
 GList*       file_data_list_from_uri_list  (GList            *list);
 GList*       uri_list_from_file_data_list  (GList            *list);
diff --git a/libgthumb/gth-filter.c b/libgthumb/gth-filter.c
index 55ae2de..7f3e5e1 100644
--- a/libgthumb/gth-filter.c
+++ b/libgthumb/gth-filter.c
@@ -310,6 +310,7 @@ gth_test_match (GthTest  *test,
 		FileData *fdata)
 {
 	gboolean result = FALSE;
+        CommentData *cdata;
 
 	switch (test->scope) {
 	case GTH_TEST_SCOPE_FILENAME:
@@ -317,27 +318,27 @@ gth_test_match (GthTest  *test,
 		break;
 
 	case GTH_TEST_SCOPE_COMMENT:
-		file_data_load_comment_data (fdata);
-		if (fdata->comment_data != NULL)
-			result = test_string (test, fdata->comment_data->comment);
+                cdata = file_data_get_comment (fdata);
+		if (cdata)
+			result = test_string (test, cdata->comment);
 		else
 			result = test->negative;
 		break;
 
 	case GTH_TEST_SCOPE_PLACE:
-		file_data_load_comment_data (fdata);
-		if (fdata->comment_data != NULL)
-			result = test_string (test, fdata->comment_data->place);
+                cdata = file_data_get_comment (fdata);
+		if (cdata != NULL)
+			result = test_string (test, cdata->place);
 		break;
 
 	case GTH_TEST_SCOPE_ALL:
-		file_data_load_comment_data (fdata);
-		if (fdata->comment_data != NULL) {
+                cdata = file_data_get_comment (fdata);
+		if (cdata != NULL) {
 			result = (test_string (test, fdata->utf8_name)
-		        	  || test_string (test, fdata->comment_data->comment)
-		          	  || test_string (test, fdata->comment_data->place));
-		        if (! result && (fdata->comment_data != NULL))
-				result = test_keywords (test, fdata->comment_data->keywords);
+		        	  || test_string (test, cdata->comment)
+		          	  || test_string (test, cdata->place));
+		        if (! result && (cdata != NULL))
+				result = test_keywords (test, cdata->keywords);
 		} else
 			result = test->negative;
 		break;
@@ -347,9 +348,9 @@ gth_test_match (GthTest  *test,
 		break;
 
 	case GTH_TEST_SCOPE_KEYWORDS:
-		file_data_load_comment_data (fdata);
-		if (fdata->comment_data != NULL)
-			result = test_keywords (test, fdata->comment_data->keywords);
+                cdata = file_data_get_comment (fdata);
+		if (cdata != NULL)
+			result = test_keywords (test, cdata->keywords);
 		else
 			result = test->negative;
 		break;
diff --git a/src/gth-monitor.c b/libgthumb/gth-monitor.c
similarity index 85%
rename from src/gth-monitor.c
rename to libgthumb/gth-monitor.c
index 7a8e5bc..58bf022 100644
--- a/src/gth-monitor.c
+++ b/libgthumb/gth-monitor.c
@@ -30,7 +30,6 @@
 #include "gstringlist.h"
 #include "gthumb-marshal.h"
 #include "gth-monitor.h"
-#include "main.h"
 
 #define UPDATE_DIR_DELAY 500
 
@@ -64,6 +63,7 @@ typedef struct {
 	int ref;
 } MonitorHandle;
 
+static GthMonitor *instance = NULL;
 
 MonitorHandle *
 monitor_handle_new (GFileMonitor *monitor_handle,
@@ -236,7 +236,7 @@ proc_monitor_events (gpointer data)
 		if (name[0] == '.')
 			continue;
 
-		all_windows_notify_directory_new (path);
+                gth_monitor_notify_update_directory (path, GTH_MONITOR_EVENT_CREATED);
 	}
 	path_list_free (dir_created_list);
 
@@ -244,24 +244,24 @@ proc_monitor_events (gpointer data)
 
 	for (scan = dir_deleted_list; scan; scan = scan->next) {
 		char *path = scan->data;
-		all_windows_notify_directory_delete (path);
+		gth_monitor_notify_update_directory (path, GTH_MONITOR_EVENT_DELETED);
 	}
 	path_list_free (dir_deleted_list);
 
 	/**/
 
 	if (file_created_list != NULL) {
-		all_windows_notify_files_created (file_created_list);
+		gth_monitor_notify_update_files (GTH_MONITOR_EVENT_CREATED, file_created_list);
 		path_list_free (file_created_list);
 	}
 
 	if (file_deleted_list != NULL) {
-		all_windows_notify_files_deleted (file_deleted_list);
+		gth_monitor_notify_update_files (GTH_MONITOR_EVENT_DELETED, file_deleted_list);
 		path_list_free (file_deleted_list);
 	}
 
 	if (file_changed_list != NULL) {
-		all_windows_notify_files_changed (file_changed_list);
+		gth_monitor_notify_update_files (GTH_MONITOR_EVENT_CHANGED, file_changed_list);
 		path_list_free (file_changed_list);
 	}
 
@@ -386,10 +386,9 @@ directory_changed (GFileMonitor      *handle,
 
 
 void
-gth_monitor_add_uri (GthMonitor *monitor,
-		     const char *uri)
+gth_monitor_add_uri (const char *uri)
 {
-	GthMonitorPrivateData *priv = monitor->priv;
+	GthMonitorPrivateData *priv = instance->priv;
 	GFileMonitor          *monitor_handle;
 	GList                 *item;
 	GFile		      *gfile;
@@ -417,7 +416,7 @@ gth_monitor_add_uri (GthMonitor *monitor,
 	        g_signal_connect (G_OBJECT (monitor_handle),
                           "changed",
                           G_CALLBACK (directory_changed),
-                          monitor);
+                          instance);
 	}
 
 	priv->monitor_enabled = TRUE;
@@ -425,10 +424,9 @@ gth_monitor_add_uri (GthMonitor *monitor,
 
 
 void
-gth_monitor_remove_uri (GthMonitor *monitor,
-			const char *uri)
+gth_monitor_remove_uri (const char *uri)
 {
-	GthMonitorPrivateData *priv = monitor->priv;
+	GthMonitorPrivateData *priv = instance->priv;
 	GList                 *item;
 	MonitorHandle         *mh;
 
@@ -447,60 +445,61 @@ gth_monitor_remove_uri (GthMonitor *monitor,
 	monitor_handle_unref (mh);
 }
 
-
 GthMonitor *
-gth_monitor_new (void)
+gth_monitor_get_instance (void)
 {
-	return (GthMonitor*) g_object_new (GTH_TYPE_MONITOR, NULL);
+        if (!instance) {
+                instance = GTH_MONITOR (g_object_new (GTH_TYPE_MONITOR, NULL));
+        }
+	return instance;
 }
 
 
 void
-gth_monitor_pause (GthMonitor *monitor)
+gth_monitor_pause (void)
 {
-	monitor->priv->monitor_enabled = FALSE;
+	instance->priv->monitor_enabled = FALSE;
 }
 
 
 void
-gth_monitor_resume (GthMonitor *monitor)
+gth_monitor_resume (void)
 {
-	monitor->priv->monitor_enabled = TRUE;
+	instance->priv->monitor_enabled = TRUE;
 }
 
 
 void
-gth_monitor_notify_update_icon_theme (GthMonitor *monitor)
+gth_monitor_notify_update_icon_theme (void)
 {
-	g_return_if_fail (GTH_IS_MONITOR (monitor));
-	g_signal_emit (G_OBJECT (monitor),
+	g_return_if_fail (GTH_IS_MONITOR (instance));
+	g_signal_emit (G_OBJECT (instance),
 		       monitor_signals[UPDATE_ICON_THEME],
 		       0);
 }
 
 
 void
-gth_monitor_notify_update_bookmarks (GthMonitor *monitor)
+gth_monitor_notify_update_bookmarks (void)
 {
-	g_return_if_fail (GTH_IS_MONITOR (monitor));
-	g_signal_emit (G_OBJECT (monitor),
+	g_return_if_fail (GTH_IS_MONITOR (instance));
+	g_signal_emit (G_OBJECT (instance),
 		       monitor_signals[UPDATE_BOOKMARKS],
 		       0);
 }
 
 
 void
-gth_monitor_notify_update_cat_files (GthMonitor      *monitor,
-				     const char      *catalog_path,
+gth_monitor_notify_update_cat_files (const char      *catalog_path,
 				     GthMonitorEvent  event,
 				     GList           *list)
 {
-	g_return_if_fail (GTH_IS_MONITOR (monitor));
+	g_return_if_fail (GTH_IS_MONITOR (instance));
 
 	if (list == NULL)
 		return;
 
-	g_signal_emit (G_OBJECT (monitor),
+	g_signal_emit (G_OBJECT (instance),
 		       monitor_signals[UPDATE_CAT_FILES],
 		       0,
 		       catalog_path,
@@ -510,16 +509,15 @@ gth_monitor_notify_update_cat_files (GthMonitor      *monitor,
 
 
 void
-gth_monitor_notify_update_files (GthMonitor      *monitor,
-				 GthMonitorEvent  event,
+gth_monitor_notify_update_files (GthMonitorEvent  event,
 				 GList           *list)
 {
-	g_return_if_fail (GTH_IS_MONITOR (monitor));
+	g_return_if_fail (GTH_IS_MONITOR (instance));
 
 	if (list == NULL)
 		return;
 
-	g_signal_emit (G_OBJECT (monitor),
+	g_signal_emit (G_OBJECT (instance),
 		       monitor_signals[UPDATE_FILES],
 		       0,
 		       event,
@@ -528,12 +526,11 @@ gth_monitor_notify_update_files (GthMonitor      *monitor,
 
 
 void
-gth_monitor_notify_update_directory (GthMonitor      *monitor,
-				     const char      *dir_path,
+gth_monitor_notify_update_directory (const char      *dir_path,
 				     GthMonitorEvent  event)
 {
-	g_return_if_fail (GTH_IS_MONITOR (monitor));
-	g_signal_emit (G_OBJECT (monitor),
+	g_return_if_fail (GTH_IS_MONITOR (instance));
+	g_signal_emit (G_OBJECT (instance),
 		       monitor_signals[UPDATE_DIRECTORY],
 		       0,
 		       dir_path,
@@ -542,12 +539,11 @@ gth_monitor_notify_update_directory (GthMonitor      *monitor,
 
 
 void
-gth_monitor_notify_update_catalog (GthMonitor      *monitor,
-				   const char      *catalog_path,
+gth_monitor_notify_update_catalog (const char      *catalog_path,
 				   GthMonitorEvent  event)
 {
-	g_return_if_fail (GTH_IS_MONITOR (monitor));
-	g_signal_emit (G_OBJECT (monitor),
+	g_return_if_fail (GTH_IS_MONITOR (instance));
+	g_signal_emit (G_OBJECT (instance),
 		       monitor_signals[UPDATE_CATALOG],
 		       0,
 		       catalog_path,
@@ -556,11 +552,10 @@ gth_monitor_notify_update_catalog (GthMonitor      *monitor,
 
 
 void
-gth_monitor_notify_update_metadata (GthMonitor      *monitor,
-				    const char      *path)
+gth_monitor_notify_update_metadata (const char      *path)
 {
-	g_return_if_fail (GTH_IS_MONITOR (monitor));
-	g_signal_emit (G_OBJECT (monitor),
+	g_return_if_fail (GTH_IS_MONITOR (instance));
+	g_signal_emit (G_OBJECT (instance),
 		       monitor_signals[UPDATE_METADATA],
 		       0,
 		       path);
@@ -568,12 +563,11 @@ gth_monitor_notify_update_metadata (GthMonitor      *monitor,
 
 
 void
-gth_monitor_notify_file_renamed (GthMonitor      *monitor,
-				 const char      *old_name,
+gth_monitor_notify_file_renamed (const char      *old_name,
 				 const char      *new_name)
 {
-	g_return_if_fail (GTH_IS_MONITOR (monitor));
-	g_signal_emit (G_OBJECT (monitor),
+	g_return_if_fail (GTH_IS_MONITOR (instance));
+	g_signal_emit (G_OBJECT (instance),
 		       monitor_signals[FILE_RENAMED],
 		       0,
 		       old_name,
@@ -582,12 +576,11 @@ gth_monitor_notify_file_renamed (GthMonitor      *monitor,
 
 
 void
-gth_monitor_notify_directory_renamed (GthMonitor      *monitor,
-				      const char      *old_name,
+gth_monitor_notify_directory_renamed (const char      *old_name,
 				      const char      *new_name)
 {
-	g_return_if_fail (GTH_IS_MONITOR (monitor));
-	g_signal_emit (G_OBJECT (monitor),
+	g_return_if_fail (GTH_IS_MONITOR (instance));
+	g_signal_emit (G_OBJECT (instance),
 		       monitor_signals[DIRECTORY_RENAMED],
 		       0,
 		       old_name,
@@ -596,12 +589,11 @@ gth_monitor_notify_directory_renamed (GthMonitor      *monitor,
 
 
 void
-gth_monitor_notify_catalog_renamed (GthMonitor      *monitor,
-				    const char      *old_name,
+gth_monitor_notify_catalog_renamed (const char      *old_name,
 				    const char      *new_name)
 {
-	g_return_if_fail (GTH_IS_MONITOR (monitor));
-	g_signal_emit (G_OBJECT (monitor),
+	g_return_if_fail (GTH_IS_MONITOR (instance));
+	g_signal_emit (G_OBJECT (instance),
 		       monitor_signals[CATALOG_RENAMED],
 		       0,
 		       old_name,
@@ -610,10 +602,10 @@ gth_monitor_notify_catalog_renamed (GthMonitor      *monitor,
 
 
 void
-gth_monitor_notify_reload_catalogs (GthMonitor *monitor)
+gth_monitor_notify_reload_catalogs (void)
 {
-	g_return_if_fail (GTH_IS_MONITOR (monitor));
-	g_signal_emit (G_OBJECT (monitor),
+	g_return_if_fail (GTH_IS_MONITOR (instance));
+	g_signal_emit (G_OBJECT (instance),
 		       monitor_signals[RELOAD_CATALOGS],
 		       0);
 }
diff --git a/src/gth-monitor.h b/libgthumb/gth-monitor.h
similarity index 69%
rename from src/gth-monitor.h
rename to libgthumb/gth-monitor.h
index 6569d6e..f75af6c 100644
--- a/src/gth-monitor.h
+++ b/libgthumb/gth-monitor.h
@@ -78,39 +78,29 @@ struct _GthMonitorClass
 };
 
 GType        gth_monitor_get_type                    (void);
-GthMonitor*  gth_monitor_new                         (void);
-void         gth_monitor_add_uri                     (GthMonitor *monitor,
-						      const char *uri);
-void         gth_monitor_remove_uri                  (GthMonitor *monitor,
-						      const char *uri);
-void         gth_monitor_pause                       (GthMonitor      *monitor);
-void         gth_monitor_resume                      (GthMonitor      *monitor);
-void         gth_monitor_notify_update_icon_theme    (GthMonitor      *monitor);
-void         gth_monitor_notify_update_bookmarks     (GthMonitor      *monitor);
-void         gth_monitor_notify_update_cat_files     (GthMonitor      *monitor,
-						      const char      *catalog_path,
+GthMonitor*  gth_monitor_get_instance                (void);
+void         gth_monitor_add_uri                     (const char *uri);
+void         gth_monitor_remove_uri                  (const char *uri);
+void         gth_monitor_pause                       (void);
+void         gth_monitor_resume                      (void);
+void         gth_monitor_notify_update_icon_theme    (void);
+void         gth_monitor_notify_update_bookmarks     (void);
+void         gth_monitor_notify_update_cat_files     (const char      *catalog_path,
 						      GthMonitorEvent  event,
 						      GList           *list);
-void         gth_monitor_notify_update_files         (GthMonitor      *monitor,
-						      GthMonitorEvent  event,
+void         gth_monitor_notify_update_files         (GthMonitorEvent  event,
 						      GList           *list);
-void         gth_monitor_notify_update_directory     (GthMonitor      *monitor,
-						      const char      *dir_path,
+void         gth_monitor_notify_update_directory     (const char      *dir_path,
 						      GthMonitorEvent  event);
-void         gth_monitor_notify_update_catalog       (GthMonitor      *monitor,
-						      const char      *catalog_path,
+void         gth_monitor_notify_update_catalog       (const char      *catalog_path,
 						      GthMonitorEvent  event);
-void         gth_monitor_notify_update_metadata      (GthMonitor      *monitor,
-						      const char      *path);
-void         gth_monitor_notify_file_renamed         (GthMonitor      *monitor,
-						      const char      *old_name,
+void         gth_monitor_notify_update_metadata      (const char      *path);
+void         gth_monitor_notify_file_renamed         (const char      *old_name,
 						      const char      *new_name);
-void         gth_monitor_notify_directory_renamed    (GthMonitor      *monitor,
-						      const char      *old_name,
+void         gth_monitor_notify_directory_renamed    (const char      *old_name,
 						      const char      *new_name);
-void         gth_monitor_notify_catalog_renamed      (GthMonitor      *monitor,
-						      const char      *old_name,
+void         gth_monitor_notify_catalog_renamed      (const char      *old_name,
 						      const char      *new_name);
-void         gth_monitor_notify_reload_catalogs      (GthMonitor      *monitor);
+void         gth_monitor_notify_reload_catalogs      (void);
 
 #endif /* GTH_MONITOR_H */
diff --git a/libgthumb/gth-utils.c b/libgthumb/gth-utils.c
index dacc65b..eddae8e 100644
--- a/libgthumb/gth-utils.c
+++ b/libgthumb/gth-utils.c
@@ -22,6 +22,7 @@
 
 #include <config.h>
 #include <string.h>
+#include <ctype.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
 #include <libgnome/libgnome.h>
@@ -60,3 +61,88 @@ gthumb_display_help (GtkWindow  *window,
 	}
 }
 
+
+/* based on glib/glib/gmarkup.c (Copyright 2000, 2003 Red Hat, Inc.)
+ * This version does not escape ' and ''. Needed  because IE does not recognize
+ * &apos; and &quot; */
+static void
+_append_escaped_text_for_html (GString     *str,
+			       const gchar *text,
+			       gssize       length)
+{
+	const gchar *p;
+	const gchar *end;
+	gunichar     ch;
+	int          state = 0;
+
+	p = text;
+	end = text + length;
+
+	while (p != end) {
+		const gchar *next;
+		next = g_utf8_next_char (p);
+		ch = g_utf8_get_char (p);
+
+		switch (state) {
+		    case 1: /* escaped */
+			if ((ch > 127) ||  !isprint((char)ch))
+				g_string_append_printf (str, "\\&#%d;", ch);
+			else
+				g_string_append_unichar (str, ch);
+			state = 0;
+			break;
+
+		    default: /* not escaped */
+			switch (*p) {
+			    case '\\':
+				state = 1; /* next character is escaped */
+				break;
+
+			    case '&':
+				g_string_append (str, "&amp;");
+				break;
+
+			    case '<':
+				g_string_append (str, "&lt;");
+				break;
+
+			    case '>':
+				g_string_append (str, "&gt;");
+				break;
+
+			    case '\n':
+				g_string_append (str, "<br />");
+				break;
+
+			    default:
+				if ((ch > 127) ||  !isprint((char)ch))
+					g_string_append_printf (str, "&#%d;", ch);
+				else
+					g_string_append_unichar (str, ch);
+				state = 0;
+				break;
+			}
+		}
+
+		p = next;
+	}
+}
+
+
+char*
+_g_escape_text_for_html (const gchar *text,
+			 gssize       length)
+{
+	GString *str;
+
+	g_return_val_if_fail (text != NULL, NULL);
+
+	if (length < 0)
+		length = strlen (text);
+
+	/* prealloc at least as long as original text */
+	str = g_string_sized_new (length);
+	_append_escaped_text_for_html (str, text, length);
+
+	return g_string_free (str, FALSE);
+}
diff --git a/libgthumb/gth-utils.h b/libgthumb/gth-utils.h
index 9e025b6..c8bcb1a 100644
--- a/libgthumb/gth-utils.h
+++ b/libgthumb/gth-utils.h
@@ -25,7 +25,10 @@
 
 #include <gtk/gtk.h>
 
-void        gthumb_display_help (GtkWindow  *window, const char *section);
+void        gthumb_display_help         (GtkWindow  *window, const char *section);
+
+char*       _g_escape_text_for_html     (const gchar *text,
+                                         gssize       length);
 
 #endif /* _GTH_UTILS_H */
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 2e6d44a..f1b49b9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -114,8 +114,6 @@ gthumb_SOURCES = 				\
 	gth-image-selector.h			\
 	gth-location.c				\
 	gth-location.h				\
-	gth-monitor.c				\
-	gth-monitor.h				\
 	gth-viewer.c				\
 	gth-viewer.h				\
 	gth-viewer-actions-entries.h		\
diff --git a/src/catalog-png-exporter.c b/src/catalog-png-exporter.c
index abd8ae2..12b3818 100644
--- a/src/catalog-png-exporter.c
+++ b/src/catalog-png-exporter.c
@@ -32,6 +32,7 @@
 #include "catalog-png-exporter.h"
 #include "comments.h"
 #include "file-utils.h"
+#include "gth-utils.h"
 #include "gthumb-init.h"
 #include "gthumb-marshal.h"
 #include "pixbuf-utils.h"
@@ -1501,9 +1502,9 @@ static void
 end_export (CatalogPngExporter *ce)
 {	
 	if (ce->created_files != NULL) {
-		all_windows_remove_monitor ();
-		all_windows_notify_files_created (ce->created_files);
-		all_windows_add_monitor ();
+		gth_monitor_pause ();
+		gth_monitor_notify_update_files (GTH_MONITOR_EVENT_CREATED, ce->created_files);
+		gth_monitor_resume ();
 		path_list_free (ce->created_files);
 		ce->created_files = NULL;
 	}
diff --git a/src/catalog-web-exporter.c b/src/catalog-web-exporter.c
index 7b3e68d..77ab1c5 100644
--- a/src/catalog-web-exporter.c
+++ b/src/catalog-web-exporter.c
@@ -34,6 +34,7 @@
 
 #include "catalog-web-exporter.h"
 #include "comments.h"
+#include "gth-utils.h"
 #include "gfile-utils.h"
 #include "file-utils.h"
 #include "gconf-utils.h"
diff --git a/src/dlg-bookmarks.c b/src/dlg-bookmarks.c
index 8992134..f582c70 100644
--- a/src/dlg-bookmarks.c
+++ b/src/dlg-bookmarks.c
@@ -89,7 +89,7 @@ remove_cb (GtkWidget *widget,
 	bookmark_list_set (data->book_list, data->bookmarks->list);
 
 	data->do_not_update = TRUE;
-	all_windows_notify_update_bookmarks ();
+	gth_monitor_notify_update_bookmarks ();
 }
 
 
@@ -133,7 +133,7 @@ move_up_cb (GtkWidget *widget,
 	bookmark_list_select_item (data->book_list, g_list_index (list, ldata));
 
 	data->do_not_update = TRUE;
-	all_windows_notify_update_bookmarks ();
+	gth_monitor_notify_update_bookmarks ();
 }
 
 
@@ -179,7 +179,7 @@ move_down_cb (GtkWidget *widget,
 	bookmark_list_select_item (data->book_list, g_list_index (list, ldata));
 
 	data->do_not_update = TRUE;
-	all_windows_notify_update_bookmarks ();
+	gth_monitor_notify_update_bookmarks ();
 }
 
 
@@ -217,7 +217,7 @@ move_top_cb (GtkWidget *widget,
 	bookmark_list_select_item (data->book_list, g_list_index (list, ldata));
 
 	data->do_not_update = TRUE;
-	all_windows_notify_update_bookmarks ();
+	gth_monitor_notify_update_bookmarks ();
 }
 
 
@@ -255,7 +255,7 @@ move_bottom_cb (GtkWidget *widget,
 	bookmark_list_select_item (data->book_list, g_list_index (list, ldata));
 
 	data->do_not_update = TRUE;
-	all_windows_notify_update_bookmarks ();
+	gth_monitor_notify_update_bookmarks ();
 }
 
 
diff --git a/src/dlg-catalog.c b/src/dlg-catalog.c
index a926a98..ea60605 100644
--- a/src/dlg-catalog.c
+++ b/src/dlg-catalog.c
@@ -183,7 +183,9 @@ add_to_catalog__ok_cb (GtkWidget *widget,
 	if (! catalog_write_to_disk (catalog, &gerror))
 		_gtk_error_dialog_from_gerror_run (GTK_WINDOW (data->dialog), &gerror);
 	else
-		all_windows_notify_cat_files_created (cat_path, data->data.list);
+                gth_monitor_notify_update_cat_files (cat_path,   
+                                                     GTH_MONITOR_EVENT_CREATED,
+                                                     data->data.list);
 
 	eel_gconf_set_path (PREF_ADD_TO_CATALOG_LAST_CATALOG, cat_path);
 	if (data->can_view_catalog) {
@@ -422,7 +424,7 @@ move_to_catalog_dir__ok_cb (GtkWidget  *widget,
 	g_free (new_path);
 	g_free (new_dir);
 
-	all_windows_update_catalog_list ();
+	gth_monitor_notify_reload_catalogs ();
 	gtk_widget_destroy (data->dialog);
 }
 
diff --git a/src/dlg-change-date.c b/src/dlg-change-date.c
index 72f48ad..b76a489 100644
--- a/src/dlg-change-date.c
+++ b/src/dlg-change-date.c
@@ -115,7 +115,7 @@ ok_clicked (GtkWidget  *button,
 		comment_time = mtime;
 	}
 	
-	all_windows_remove_monitor ();
+	gth_monitor_pause ();
 
 	for (scan = data->file_list; scan; scan = scan->next) {
 		FileData *fdata = scan->data;
@@ -193,10 +193,10 @@ ok_clicked (GtkWidget  *button,
 		file_list = g_list_prepend (file_list, fdata->path);
 	}
 
-	all_windows_notify_files_changed (file_list);
+	gth_monitor_notify_update_files (GTH_MONITOR_EVENT_CHANGED, file_list);
 	g_list_free (file_list);
 
-	all_windows_add_monitor ();
+	gth_monitor_resume ();
 	
 	gtk_widget_destroy (data->dialog);
 }
diff --git a/src/dlg-comment.c b/src/dlg-comment.c
index 58dc36a..78628d3 100644
--- a/src/dlg-comment.c
+++ b/src/dlg-comment.c
@@ -266,7 +266,6 @@ save_clicked_cb (GtkWidget  *widget,
 			comments_save_comment_non_null (filename, cdata);
 		else
 			comments_save_comment (filename, cdata);
-		all_windows_notify_update_metadata (filename); 
 	}
 
 	gth_window_update_current_image_metadata (data->window);
diff --git a/src/dlg-convert.c b/src/dlg-convert.c
index 36c9731..9c274e3 100644
--- a/src/dlg-convert.c
+++ b/src/dlg-convert.c
@@ -138,9 +138,9 @@ load_next_image (DialogData *data)
 static void
 stop_operation (DialogData *data)
 {
-	all_windows_notify_files_created (data->saved_list);
-	all_windows_notify_files_deleted (data->deleted_list);
-	all_windows_add_monitor ();
+	gth_monitor_notify_update_files (GTH_MONITOR_EVENT_CREATED, data->saved_list);
+	gth_monitor_notify_update_files (GTH_MONITOR_EVENT_DELETED, data->deleted_list);
+	gth_monitor_resume ();
 	gtk_widget_destroy (data->dialog);
 }
 
@@ -385,7 +385,7 @@ static void
 ok_cb (GtkWidget  *widget,
        DialogData *data)
 {
-	all_windows_remove_monitor ();
+	gth_monitor_pause ();
 
 	data->loader = IMAGE_LOADER (image_loader_new (FALSE));
 
diff --git a/src/dlg-file-utils.c b/src/dlg-file-utils.c
index e51099d..bd2805d 100644
--- a/src/dlg-file-utils.c
+++ b/src/dlg-file-utils.c
@@ -965,7 +965,7 @@ dlg_file_rename_series (GthWindow *window,
 	GList          *files_created = NULL;
 	char	       *last_error_message;
 
-	all_windows_remove_monitor ();
+	gth_monitor_pause ();
 
 	last_error_message = g_strdup (_("Unknown error"));
 
@@ -1054,9 +1054,9 @@ dlg_file_rename_series (GthWindow *window,
 		n_scan = n_scan->next;
 	}
 
-	all_windows_notify_files_deleted (files_deleted);
-	all_windows_notify_files_created (files_created);
-	all_windows_add_monitor ();
+	gth_monitor_notify_update_files (GTH_MONITOR_EVENT_DELETED, files_deleted);
+	gth_monitor_notify_update_files (GTH_MONITOR_EVENT_CREATED, files_created);
+	gth_monitor_resume ();
 
 	if (error) {
 		const char *msg;
@@ -1254,9 +1254,9 @@ static void
 files_copy__done (FileCopyData *fcdata)
 {
 	if (fcdata->remove_source)
-		all_windows_notify_files_deleted (fcdata->copied_list);
-	all_windows_notify_files_created (fcdata->created_list);
-	all_windows_add_monitor ();
+		gth_monitor_notify_update_files (GTH_MONITOR_EVENT_DELETED, fcdata->copied_list);
+	gth_monitor_notify_update_files (GTH_MONITOR_EVENT_CREATED, fcdata->created_list);
+	gth_monitor_resume ();
 
 	if (fcdata->done_func != NULL)
 		(*fcdata->done_func) (fcdata->error, fcdata->done_data);
@@ -1692,7 +1692,7 @@ dlg_files_copy (GthWindow      *window,
 					    file_copy__display_progress_dialog,
 					    fcdata);
 
-	all_windows_remove_monitor ();
+	gth_monitor_pause ();
 
 	copy_current_file (fcdata);
 }
@@ -1810,11 +1810,11 @@ static void
 files_delete__done (FileDeleteData *fddata)
 {
 	if (fddata->error == NULL)
-		all_windows_notify_files_deleted (fddata->file_list);
+		gth_monitor_notify_update_files (GTH_MONITOR_EVENT_DELETED, fddata->file_list);
 	else
-		all_windows_notify_files_changed (fddata->file_list);
+		gth_monitor_notify_update_files (GTH_MONITOR_EVENT_CHANGED, fddata->file_list);
 
-	/*all_windows_add_monitor (); FIXME*/
+	/*gth_monitor_resume (); FIXME*/
 
 	if (fddata->done_func != NULL)
 		(*fddata->done_func) (fddata->error, fddata->done_data);
@@ -1948,7 +1948,7 @@ dlg_files_delete (GthWindow      *window,
 
 	/**/
 
-	/*all_windows_remove_monitor (); FIXME*/
+	/*gth_monitor_pause (); FIXME*/
 
 	for (scan = fddata->file_list; scan; scan = scan->next) {
 		const char  *path = scan->data;
@@ -2037,7 +2037,7 @@ destroy_progress_dialog (FolderCopyData *fcdata)
 static void
 folder_copy_data_free (FolderCopyData *fcdata)
 {
-	all_windows_add_monitor ();
+	gth_monitor_resume ();
 
 	if (fcdata == NULL)
 		return;
@@ -2093,13 +2093,13 @@ folder_progress_update_cb (GnomeVFSAsyncHandle      *handle,
 
 		if (fcdata->error == NULL) {
 			if (fcdata->file_op == FILE_OP_COPY)
-				all_windows_notify_directory_new (fcdata->destination);
+                                gth_monitor_notify_update_directory (fcdata->destination, GTH_MONITOR_EVENT_CREATED);
 
 			else if (fcdata->file_op == FILE_OP_MOVE)
-				all_windows_notify_directory_rename (fcdata->source,
+				gth_monitor_notify_directory_renamed (fcdata->source,
 								     fcdata->destination);
 			else if (fcdata->file_op == FILE_OP_DELETE)
-				all_windows_notify_directory_delete (fcdata->source);
+				gth_monitor_notify_update_directory (fcdata->source, GTH_MONITOR_EVENT_DELETED);
 		}
 
 		destroy_progress_dialog (fcdata);
@@ -2261,7 +2261,7 @@ folder_copy (GthWindow      *window,
 
 	/**/
 
-	all_windows_remove_monitor ();
+	gth_monitor_pause ();
 
 	src_list = g_list_append (src_list, new_uri_from_path (src_path));
 
diff --git a/src/dlg-jpegtran.c b/src/dlg-jpegtran.c
index 8fd4771..55d3f68 100644
--- a/src/dlg-jpegtran.c
+++ b/src/dlg-jpegtran.c
@@ -79,12 +79,12 @@ static void
 dialog_data_free (DialogData *data)
 {
 	if (data->files_changed_list != NULL) {
-		all_windows_notify_files_changed (data->files_changed_list);
+		gth_monitor_notify_update_files (GTH_MONITOR_EVENT_CHANGED, data->files_changed_list);
 		path_list_free (data->files_changed_list);
 		data->files_changed_list = NULL;
 	}
 
-	g_idle_add ((GSourceFunc)all_windows_add_monitor, NULL);
+	g_idle_add ((GSourceFunc)gth_monitor_resume, NULL);
 
 	file_data_list_free (data->file_list);
 	if (data->loader != NULL)
@@ -228,7 +228,7 @@ notify_file_changed (DialogData *data,
 {
 	if (notify_soon) {
 		GList *list = g_list_prepend (NULL, (char*) filename);
-		all_windows_notify_files_changed (list);
+		gth_monitor_notify_update_files (GTH_MONITOR_EVENT_CHANGED, list);
 		g_list_free (list);
 	} 
 	else
@@ -705,7 +705,7 @@ dlg_jpegtran (GthWindow *window)
 
 	/* Run dialog. */
 
-	all_windows_remove_monitor ();
+	gth_monitor_pause ();
 
 	gtk_window_set_transient_for (GTK_WINDOW (data->dialog), GTK_WINDOW (window));
 	gtk_window_set_modal (GTK_WINDOW (data->dialog), TRUE);
@@ -728,7 +728,7 @@ dlg_apply_jpegtran (GthWindow    *window,
 		return;
 	}
 
-	all_windows_remove_monitor ();
+	gth_monitor_pause ();
 
 	data = g_new0 (DialogData, 1);
 	data->window = window;
diff --git a/src/dlg-photo-importer.c b/src/dlg-photo-importer.c
index 6d6d89b..eb47e02 100644
--- a/src/dlg-photo-importer.c
+++ b/src/dlg-photo-importer.c
@@ -1428,12 +1428,12 @@ notify_file_creation_cb (gpointer cb_data)
 	data->idle_id = 0;
 
 	if (data->saved_images_list != NULL) {
-		all_windows_notify_files_created (data->saved_images_list);
+		gth_monitor_notify_update_files (GTH_MONITOR_EVENT_CREATED, data->saved_images_list);
 		path_list_free (data->saved_images_list);
 		data->saved_images_list = NULL;
 	}
 
-	all_windows_add_monitor ();
+	gth_monitor_resume ();
 
 	return FALSE;
 }
@@ -1501,7 +1501,7 @@ static void
 save_images__init (AsyncOperationData *aodata,
 		   DialogData         *data)
 {
-	all_windows_remove_monitor ();
+	gth_monitor_pause ();
 
 	data->image_n = 1;
 	data->renamed_files = FALSE;
diff --git a/src/dlg-reset-exif.c b/src/dlg-reset-exif.c
index 6f34418..97462e1 100644
--- a/src/dlg-reset-exif.c
+++ b/src/dlg-reset-exif.c
@@ -59,12 +59,12 @@ static void
 dialog_data_free (DialogData *data)
 {
 	if (data->files_changed_list != NULL) {
-		all_windows_notify_files_changed (data->files_changed_list);
+		gth_monitor_notify_update_files (GTH_MONITOR_EVENT_CHANGED, data->files_changed_list);
 		path_list_free (data->files_changed_list);
 		data->files_changed_list = NULL;
 	}
 
-	all_windows_add_monitor ();
+	gth_monitor_resume ();
 
 	file_data_list_free (data->file_list);
 	if (data->gui != NULL)
@@ -262,7 +262,7 @@ dlg_reset_exif (GthWindow *window)
 
 	/* Run dialog. */
 
-	all_windows_remove_monitor ();
+	gth_monitor_pause ();
 
 	gtk_window_set_transient_for (GTK_WINDOW (data->dialog), GTK_WINDOW (window));
 	gtk_window_set_modal (GTK_WINDOW (data->dialog), TRUE); 
@@ -282,7 +282,7 @@ dlg_apply_reset_exif (GthWindow *window)
 		return;
 	}
 
-	all_windows_remove_monitor ();
+	gth_monitor_pause ();
 
 	data = g_new0 (DialogData, 1);
 	data->window = window;
diff --git a/src/gth-batch-op.c b/src/gth-batch-op.c
index 8044b6d..73785f5 100644
--- a/src/gth-batch-op.c
+++ b/src/gth-batch-op.c
@@ -345,10 +345,10 @@ static void
 notify_termination (GthBatchOp *bop)
 {
 	if (PD(bop)->deleted_list != NULL)
-		all_windows_notify_files_deleted (PD(bop)->deleted_list);
+		gth_monitor_notify_update_files (GTH_MONITOR_EVENT_DELETED, PD(bop)->deleted_list);
 	if (PD(bop)->saved_list != NULL)
-		all_windows_notify_files_created (PD(bop)->saved_list);
-	all_windows_add_monitor ();
+		gth_monitor_notify_update_files (GTH_MONITOR_EVENT_CREATED, PD(bop)->saved_list);
+	gth_monitor_resume ();
 
 	g_signal_emit (G_OBJECT (bop),
 		       gth_batch_op_signals[BOP_DONE],
@@ -650,7 +650,7 @@ gth_batch_op_start (GthBatchOp       *bop,
 
 	PD(bop)->parent = window;
 
-	all_windows_remove_monitor ();
+	gth_monitor_pause ();
 	PD(bop)->loader = IMAGE_LOADER (image_loader_new (FALSE));
 	g_signal_connect (G_OBJECT (PD(bop)->loader),
 			  "image_done",
diff --git a/src/gth-browser-actions-callbacks.c b/src/gth-browser-actions-callbacks.c
index cb78657..b067ecd 100644
--- a/src/gth-browser-actions-callbacks.c
+++ b/src/gth-browser-actions-callbacks.c
@@ -497,7 +497,7 @@ catalog_rename (GthBrowser *browser,
 				       _("The name \"%s\" is already used. " "Please use a different name."), new_fd->utf8_name);
 	} 
 	else if (file_move (old_fd->path,new_fd->path, FALSE, NULL)) {
-		all_windows_notify_catalog_rename (old_fd->path,new_fd->path);
+		gth_monitor_notify_catalog_renamed (old_fd->path,new_fd->path);
 	} 
 	else {
 		_gtk_error_dialog_run (GTK_WINDOW (browser),
@@ -540,7 +540,7 @@ real_catalog_delete (GthBrowser *browser)
 	if (error)
 		_gtk_error_dialog_from_gerror_run (GTK_WINDOW (browser), &error);
 
-	all_windows_notify_catalog_delete (catalog_path);
+        gth_monitor_notify_update_catalog (catalog_path, GTH_MONITOR_EVENT_DELETED);
 	g_free (catalog_path);
 }
 
@@ -687,8 +687,8 @@ gth_browser_activate_action_edit_current_catalog_new (GtkAction  *action,
 		_gtk_error_dialog_run (GTK_WINDOW (browser),
 				       _("The name \"%s\" is already used. " "Please use a different name."), fd->utf8_name);
 	} else if ((handle = g_file_create (gfile, G_FILE_CREATE_PRIVATE, NULL, &error)) != NULL) {
-		all_windows_notify_catalog_new (fd->utf8_path);
-		all_windows_update_catalog_list ();
+		gth_monitor_notify_update_catalog (fd->utf8_path, GTH_MONITOR_EVENT_CREATED);
+		gth_monitor_notify_reload_catalogs ();
 		g_object_unref (handle);
 	} else {
 		_gtk_error_dialog_run (GTK_WINDOW (browser),
@@ -760,7 +760,7 @@ create_new_folder_or_library (GthBrowser *browser,
 				       fd->utf8_name);
 	} 
 	else
-		all_windows_notify_directory_new (fd->utf8_path);
+                gth_monitor_notify_update_directory (fd->utf8_path, GTH_MONITOR_EVENT_CREATED);
 
 	file_data_unref (fd);
 }
@@ -947,7 +947,7 @@ folder_rename (GtkWindow  *window,
 	new_fd = file_data_new (new_path);
 	g_free (new_path);
 
-	all_windows_remove_monitor ();
+	gth_monitor_pause ();
 
 	if (same_uri (old_fd->utf8_path, new_fd->utf8_path)) {
 		_gtk_error_dialog_run (window,
@@ -966,7 +966,7 @@ folder_rename (GtkWindow  *window,
 		result = file_move (old_fd->path, new_fd->utf8_path, FALSE, NULL);
 		if (result) {
 			comment_move (old_path, new_path);
-			all_windows_notify_directory_rename (old_fd->path, new_fd->path);
+			gth_monitor_notify_directory_renamed (old_fd->path, new_fd->path);
 		} 
 		else {
 			_gtk_error_dialog_run (window,
@@ -975,7 +975,7 @@ folder_rename (GtkWindow  *window,
 		}
 	}
 
-	all_windows_add_monitor ();
+	gth_monitor_resume ();
 
 	file_data_unref (old_fd);
 	file_data_unref (new_fd);
@@ -1257,7 +1257,7 @@ folder_copy__response_cb (GObject *object,
 			file_move (old_folder_comment, new_folder_comment, TRUE, NULL);
 			g_free (new_folder_comment);
 
-			all_windows_notify_directory_rename (old_path, new_path);
+			gth_monitor_notify_directory_renamed (old_path, new_path);
 
 			if (gth_folder_selection_get_goto_destination (GTH_FOLDER_SELECTION (file_sel)))
 				gth_browser_go_to_directory (GTH_BROWSER (window), new_path);
@@ -1695,7 +1695,7 @@ gth_browser_activate_action_bookmarks_add (GtkAction  *action,
 	bookmarks_write_to_disk (preferences.bookmarks);
 	g_free (path);
 
-	all_windows_notify_update_bookmarks ();
+	gth_monitor_notify_update_bookmarks ();
 }
 
 
diff --git a/src/gth-browser.c b/src/gth-browser.c
index d27204d..09730db 100644
--- a/src/gth-browser.c
+++ b/src/gth-browser.c
@@ -1673,9 +1673,9 @@ save_pixbuf__image_saved_cb (FileData *file,
 		
 			file_list = g_list_prepend (NULL, (char*) file->path);
 			if (gth_file_list_pos_from_path (browser->priv->file_list, file->path) != -1)
-				all_windows_notify_files_changed (file_list);
+				gth_monitor_notify_update_files (GTH_MONITOR_EVENT_CHANGED, file_list);
 			else
-				all_windows_notify_files_created (file_list);
+				gth_monitor_notify_update_files (GTH_MONITOR_EVENT_CREATED, file_list);
 			g_list_free (file_list);
 		}
 	}
@@ -3753,7 +3753,9 @@ add_image_list_to_catalog (GthBrowser *browser,
 		if (! catalog_write_to_disk (catalog, &gerror))
 			_gtk_error_dialog_from_gerror_run (GTK_WINDOW (browser), &gerror);
 		else
-			all_windows_notify_cat_files_created (catalog_path, files_added);
+                        gth_monitor_notify_update_cat_files (catalog_path,   
+                                                             GTH_MONITOR_EVENT_CREATED,
+                                                             files_added);
 
 		g_list_free (files_added);
 	}
@@ -3799,7 +3801,7 @@ reorder_current_catalog (GthBrowser *browser,
 		catalog->sort_method = GTH_SORT_METHOD_MANUAL;
 		catalog_set_path (catalog, priv->catalog_path);
 		if (catalog_write_to_disk (catalog, NULL))
-			all_windows_notify_catalog_reordered (priv->catalog_path);
+			gth_monitor_notify_update_catalog (priv->catalog_path, GTH_MONITOR_EVENT_CHANGED);
 		else {
 			/* FIXME: error dialog? */
 		}
@@ -4299,7 +4301,7 @@ gth_browser_remove_monitor (GthBrowser *browser)
 	if (priv->monitor_uri == NULL)
 		return;
 
-	gth_monitor_remove_uri (gth_monitor, priv->monitor_uri);
+	gth_monitor_remove_uri (priv->monitor_uri);
 	g_free (priv->monitor_uri);
 	priv->monitor_uri = NULL;
 }
@@ -4322,7 +4324,7 @@ gth_browser_add_monitor (GthBrowser *browser)
 		priv->monitor_uri = add_scheme_if_absent (priv->dir_list->path);
 	else
 		priv->monitor_uri = g_strdup (priv->dir_list->path);
-	gth_monitor_add_uri (gth_monitor, priv->monitor_uri);
+	gth_monitor_add_uri (priv->monitor_uri);
 }
 
 
@@ -6273,6 +6275,7 @@ gth_browser_construct (GthBrowser  *browser,
 	GtkUIManager          *ui;
 	GError                *error = NULL;
 	GtkWidget             *toolbar;
+        GthMonitor            *gth_monitor = gth_monitor_get_instance ();
 
 	gtk_window_set_default_size (GTK_WINDOW (browser),
 				     eel_gconf_get_integer (PREF_UI_WINDOW_WIDTH, DEF_WIN_WIDTH),
@@ -7171,12 +7174,12 @@ gth_browser_new (const char *uri)
 {
 	GthBrowser *browser;
 
-	browser = (GthBrowser*) g_object_new (GTH_TYPE_BROWSER, NULL);
+	browser = GTH_BROWSER (g_object_new (GTH_TYPE_BROWSER, NULL));
 	gth_browser_construct (browser, uri);
 
 	browser_list = g_list_prepend (browser_list, browser);
 
-	return (GtkWidget*) browser;
+	return GTK_WIDGET (browser);
 }
 
 
@@ -7204,6 +7207,7 @@ close__step6 (FileData *file,
 	gboolean               last_window;
 	GdkWindowState         state;
 	gboolean               maximized;
+        GthMonitor            *gth_monitor = gth_monitor_get_instance ();
 
 	browser_list = g_list_remove (browser_list, browser);
 	last_window = gth_window_get_n_windows () == 1;
diff --git a/src/gth-fullscreen.c b/src/gth-fullscreen.c
index d6a3712..51e9adf 100644
--- a/src/gth-fullscreen.c
+++ b/src/gth-fullscreen.c
@@ -112,7 +112,7 @@ gth_fullscreen_finalize (GObject *object)
 	if (fullscreen->priv != NULL) {
 		GthFullscreenPrivateData *priv = fullscreen->priv;
 
-		g_signal_handlers_disconnect_by_data (G_OBJECT (gth_monitor), fullscreen);
+		g_signal_handlers_disconnect_by_data (G_OBJECT (gth_monitor_get_instance ()), fullscreen);
 
 		if (priv->slideshow_timeout != 0) {
 			g_source_remove (priv->slideshow_timeout);
@@ -1572,6 +1572,7 @@ gth_fullscreen_construct (GthFullscreen *fullscreen,
 	GdkScreen                *screen;
 	GthZoomChange             zoom_change;
 	GdkRectangle              screen_geom;
+        GthMonitor               *gth_monitor = gth_monitor_get_instance ();
 
 	zoom_change = pref_get_zoom_change ();
 	
diff --git a/src/gth-viewer.c b/src/gth-viewer.c
index 65a29db..85ea0a6 100644
--- a/src/gth-viewer.c
+++ b/src/gth-viewer.c
@@ -1337,6 +1337,7 @@ gth_viewer_construct (GthViewer   *viewer,
 	GtkUIManager         *ui;
 	GError               *error = NULL;
 	int                   i;
+        GthMonitor           *gth_monitor = gth_monitor_get_instance ();
 
 	/* Create the widgets. */
 
@@ -1800,7 +1801,7 @@ gth_viewer_close (GthWindow *window)
 
 	priv->closing = TRUE;
 
-	g_signal_handlers_disconnect_by_data (G_OBJECT (gth_monitor), viewer);
+	g_signal_handlers_disconnect_by_data (G_OBJECT (gth_monitor_get_instance ()), viewer);
 
 	if (priv->fullscreen != NULL)
 		g_signal_handlers_disconnect_by_data (G_OBJECT (priv->fullscreen),
diff --git a/src/gth-window-utils.c b/src/gth-window-utils.c
index f55b7b9..a20351f 100644
--- a/src/gth-window-utils.c
+++ b/src/gth-window-utils.c
@@ -61,7 +61,9 @@ remove_files_from_catalog (GthWindow  *window,
 		return;
 	}
 
-	all_windows_notify_cat_files_deleted (catalog_path, list);
+        gth_monitor_notify_update_cat_files (catalog_path,
+                                             GTH_MONITOR_EVENT_DELETED,
+                                             list);
 
 	path_list_free (list);
 	catalog_free (catalog);
diff --git a/src/main.c b/src/main.c
index 62aa196..d204066 100644
--- a/src/main.c
+++ b/src/main.c
@@ -62,7 +62,6 @@ static char*icon_mime_name[ICON_NAMES] = { "gnome-fs-directory",
 					   "gnome-fs-home",
 					   "gnome-fs-desktop" };
 
-GthMonitor    *gth_monitor = NULL;
 GList         *file_urls = NULL, *dir_urls = NULL;
 int            n_file_urls, n_dir_urls;
 int            StartInFullscreen = FALSE;
@@ -135,7 +134,7 @@ theme_changed_cb (GtkIconTheme *theme,
 		  gpointer        data)
 {
 	free_icon_pixbufs ();
-	all_windows_notify_update_icon_theme ();
+	gth_monitor_notify_update_icon_theme ();
 }
 
 
@@ -421,7 +420,7 @@ initialize_data (void)
 
 	eel_gconf_monitor_add ("/apps/gthumb");
 
-	gth_monitor = gth_monitor_new ();
+	gth_monitor_get_instance ();
 
 	/* Icon theme */
 
@@ -527,10 +526,7 @@ release_data (void)
                 	
 	free_icon_pixbufs ();
 
-	if (gth_monitor != NULL) {
-		g_object_unref (gth_monitor);
-		gth_monitor = NULL;
-	}
+        g_object_unref (gth_monitor_get_instance ());
 
 	gthumb_release ();
 	eel_global_client_free ();
@@ -750,171 +746,6 @@ main (int   argc,
 /**/
 
 
-void
-all_windows_update_catalog_list (void)
-{
-	gth_monitor_notify_reload_catalogs (gth_monitor);
-}
-
-
-void
-all_windows_notify_update_bookmarks (void)
-{
-	gth_monitor_notify_update_bookmarks (gth_monitor);
-}
-
-
-void
-all_windows_notify_cat_files_created (const char *catalog_path,
-				      GList      *list)
-{
-	gth_monitor_notify_update_cat_files (gth_monitor,
-					     catalog_path,
-					     GTH_MONITOR_EVENT_CREATED,
-					     list);
-}
-
-
-void
-all_windows_notify_cat_files_deleted (const char *catalog_path,
-				      GList      *list)
-{
-	gth_monitor_notify_update_cat_files (gth_monitor,
-					     catalog_path,
-					     GTH_MONITOR_EVENT_DELETED,
-					     list);
-}
-
-
-void
-all_windows_notify_files_created (GList *list)
-{
-	gth_monitor_notify_update_files (gth_monitor, GTH_MONITOR_EVENT_CREATED, list);
-}
-
-
-void
-all_windows_notify_files_deleted (GList *list)
-{
-	gth_monitor_notify_update_files (gth_monitor, GTH_MONITOR_EVENT_DELETED, list);
-}
-
-
-void
-all_windows_notify_files_changed (GList *list)
-{
-	gth_monitor_notify_update_files (gth_monitor, GTH_MONITOR_EVENT_CHANGED, list);
-}
-
-
-void
-all_windows_notify_file_rename (const gchar *old_name,
-				const gchar *new_name)
-{
-	gth_monitor_notify_file_renamed (gth_monitor, old_name, new_name);
-}
-
-
-void
-all_windows_notify_files_rename (GList *old_names,
-				 GList *new_names)
-{
-	GList *o_scan, *n_scan;
-
-	for (o_scan = old_names, n_scan = new_names; o_scan && n_scan;) {
-		const char *old_name = o_scan->data;
-		const char *new_name = n_scan->data;
-
-		gth_monitor_notify_file_renamed (gth_monitor, old_name, new_name);
-		all_windows_notify_file_rename (old_name, new_name);
-
-		o_scan = o_scan->next;
-		n_scan = n_scan->next;
-	}
-}
-
-
-void
-all_windows_notify_directory_rename (const gchar *old_name,
-				     const gchar *new_name)
-{
-	gth_monitor_notify_directory_renamed (gth_monitor, old_name, new_name);
-}
-
-
-void
-all_windows_notify_directory_delete (const char *path)
-{
-	gth_monitor_notify_update_directory (gth_monitor, path, GTH_MONITOR_EVENT_DELETED);
-}
-
-
-void
-all_windows_notify_directory_new (const char *path)
-{
-	gth_monitor_notify_update_directory (gth_monitor, path, GTH_MONITOR_EVENT_CREATED);
-}
-
-
-void
-all_windows_notify_catalog_rename (const char *old_name,
-				   const char *new_name)
-{
-	gth_monitor_notify_catalog_renamed (gth_monitor, old_name, new_name);
-}
-
-
-void
-all_windows_notify_catalog_new (const gchar *path)
-{
-	gth_monitor_notify_update_catalog (gth_monitor, path, GTH_MONITOR_EVENT_CREATED);
-}
-
-
-void
-all_windows_notify_catalog_delete (const gchar *path)
-{
-	gth_monitor_notify_update_catalog (gth_monitor, path, GTH_MONITOR_EVENT_DELETED);
-}
-
-
-void
-all_windows_notify_catalog_reordered (const gchar *path)
-{
-	gth_monitor_notify_update_catalog (gth_monitor, path, GTH_MONITOR_EVENT_CHANGED);
-}
-
-
-void
-all_windows_notify_update_metadata (const gchar *filename)
-{
-	gth_monitor_notify_update_metadata (gth_monitor, filename);
-}
-
-
-void
-all_windows_notify_update_icon_theme (void)
-{
-	gth_monitor_notify_update_icon_theme (gth_monitor);
-}
-
-
-gboolean
-all_windows_remove_monitor (void)
-{
-	gth_monitor_pause (gth_monitor);
-	return FALSE;
-}
-
-
-gboolean
-all_windows_add_monitor (void)
-{
-	gth_monitor_resume (gth_monitor);
-	return FALSE;
-}
-
-
 static GdkPixbuf *
 get_fs_icon (IconName icon_name,
 	     double   icon_size)
diff --git a/src/main.h b/src/main.h
index 6c2e776..f41ff9e 100644
--- a/src/main.h
+++ b/src/main.h
@@ -29,7 +29,6 @@
 #include "preferences.h"
 
 extern GthWindow        *current_window;
-extern GthMonitor       *gth_monitor;
 extern Preferences       preferences;
 
 extern gboolean          StartInFullscreen;
@@ -45,34 +44,6 @@ extern gboolean          UseViewer;
 #define MENU_ICON_SIZE 20.0
 #define LIST_ICON_SIZE 20.0
 
-void       all_windows_notify_update_icon_theme  (void);
-void       all_windows_notify_update_bookmarks   (void);
-void       all_windows_notify_cat_files_created  (const char *catalog_path,
-						  GList      *list);
-void       all_windows_notify_cat_files_deleted  (const char *catalog_path,
-						  GList      *list);
-void       all_windows_notify_files_created      (GList      *list);
-void       all_windows_notify_files_deleted      (GList      *list);
-void       all_windows_notify_files_changed      (GList      *list);
-void       all_windows_notify_file_rename        (const char *oldname,
-						  const char *newname);
-void       all_windows_notify_files_rename       (GList      *old_names,
-						  GList      *new_names);
-void       all_windows_notify_directory_rename   (const char *oldname,
-						  const char *newname);
-void       all_windows_notify_directory_delete   (const char *path);
-void       all_windows_notify_directory_new      (const char *path);
-void       all_windows_notify_catalog_rename     (const char *oldname,
-						  const char *newname);
-void       all_windows_notify_catalog_new        (const char *path);
-void       all_windows_notify_catalog_delete     (const char *path);
-void       all_windows_notify_catalog_reordered  (const char *path);
-void       all_windows_notify_update_metadata    (const char *filename);
-void       all_windows_update_catalog_list       (void);
-
-gboolean   all_windows_remove_monitor            (void);
-gboolean   all_windows_add_monitor               (void);
-
 int        get_folder_pixbuf_size_for_list       (GtkWidget  *widget);
 int        get_folder_pixbuf_size_for_menu       (GtkWidget  *widget);
 GdkPixbuf *get_folder_pixbuf                     (double      icon_size);



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