[Buoh-dev] CVS commit to /cvsroot/buoh/buoh/src by carlosgc



CVS commit to /cvsroot/buoh/buoh/src by carlosgc

Modified Files:
	buoh-comic-loader.c buoh-comic-loader.h buoh-comic-manager.c 
	buoh-comic-manager.h buoh-comic.c buoh-comic.h 
	buoh-properties-dialog.c buoh-view-comic.c buoh-window.c 
	buoh.c buoh.h 
Log Message:
2006-09-24  Carlos Garcia Campos  <carlosgc gnome org>
	* src/buoh.c:
	* src/buoh-view-comic.c:
	* src/buoh-comic-loader.[ch]:
	Rework comic loader in order to make the process simpler and faster. 
	* src/buoh-comic-manager.[ch]:
	* src/buoh-comic.[ch]:
	* src/buoh-properties-dialog.c:
	* src/buoh-window.c:
	Constify some strings so that we avoid some allocs/deallocs. Some
	other minor fixes and cleanups. 

===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh-comic-loader.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- /cvsroot/buoh/buoh/src/buoh-comic-loader.c	2005/11/30 10:48:02	1.12
+++ /cvsroot/buoh/buoh/src/buoh-comic-loader.c	2006/09/24 18:31:42	1.13
@@ -16,62 +16,72 @@
  *  Authors : Carlos García Campos <carlosgc gnome org>
  */
 
-#include <string.h>
-#include <gconf/gconf-client.h>
+#include <libsoup/soup.h>
 
 #include "buoh.h"
 #include "buoh-comic-loader.h"
 
-struct _BuohComicLoaderPrivate {
-	GMainLoop       *loop;
-	GConfClient     *gconf_client;
-	SoupSession     *session;
-	SoupMessage     *msg;
+/* BuohComicLoaderJob */
+#define BUOH_TYPE_COMIC_LOADER_JOB          (buoh_comic_loader_job_get_type())
+#define BUOH_COMIC_LOADER_JOB(object)       (G_TYPE_CHECK_INSTANCE_CAST((object), BUOH_TYPE_COMIC_LOADER_JOB, BuohComicLoaderJob))
+#define BUOH_COMIC_LOADER_JOB_CLASS(klass)  (G_TYPE_CHECK_CLASS_CAST((klass), BUOH_TYPE_COMIC_LOADER_JOB, BuohComicLoaderJobClass))
+#define BUOH_COMIC_LOADER_IS_JOB(object)    (G_TYPE_CHECK_INSTANCE_TYPE((object), BUOH_TYPE_COMIC_LOADER_JOB))
+
+typedef struct _BuohComicLoaderJob      BuohComicLoaderJob;
+typedef struct _BuohComicLoaderJobClass BuohComicLoaderJobClass;
+
+struct _BuohComicLoaderJob {
+	GObject parent;
 
-	GString         *data;
+	gboolean         canceled;
 	
 	gchar           *uri;
-	gdouble          scale;
-	GdkPixbufLoader *pixbuf_loader;
+	BuohComicLoaderLoadFunc callback;
+	gpointer         callback_data;
+	
+	SoupSession     *session;
+
+	BuohComicLoader *loader;
+
+	GError          *error;
+};
+
+struct _BuohComicLoaderJobClass {
+	GObjectClass parent_class;
+};
+
+static GType buoh_comic_loader_job_get_type     (void);
+static void  buoh_comic_loader_job_init         (BuohComicLoaderJob      *job);
+static void  buoh_comic_loader_job_class_init   (BuohComicLoaderJobClass *klass);
+static void  buoh_comic_loader_job_finalize     (GObject                 *object);
+
+G_DEFINE_TYPE (BuohComicLoaderJob, buoh_comic_loader_job, G_TYPE_OBJECT)
+
+
+struct _BuohComicLoaderPrivate {
+	BuohComicLoaderJob *job;
+
+	GError             *error;
 };
 
 #define BUOH_COMIC_LOADER_GET_PRIVATE(object) \
         (G_TYPE_INSTANCE_GET_PRIVATE ((object), BUOH_TYPE_COMIC_LOADER, BuohComicLoaderPrivate))
 
-#define GCONF_HTTP_PROXY_DIR "/system/http_proxy"
-#define GCONF_USE_HTTP_PROXY "/system/http_proxy/use_http_proxy"
-#define	GCONF_HTTP_PROXY_HOST "/system/http_proxy/host"
-#define GCONF_HTTP_PROXY_PORT "/system/http_proxy/port"
-#define GCONF_HTTP_PROXY_USE_AUTHENTICATION "/system/http_proxy/use_authentication"
-#define GCONF_HTTP_PROXY_AUTHENTICATION_USER "/system/http_proxy/authentication_user"
-#define GCONF_HTTP_PROXY_AUTHENTICATION_PASSWORD "/system/http_proxy/authentication_password"
-
-#define DATA_SIZE 61440 /* 60K */
 
 static GObjectClass *parent_class = NULL;
 
+enum {
+	FINISHED,
+	LAST_SIGNAL
+};
+
+static guint buoh_comic_loader_signals[LAST_SIGNAL] = { 0 };
+
 static void     buoh_comic_loader_init          (BuohComicLoader      *loader);
 static void     buoh_comic_loader_class_init    (BuohComicLoaderClass *klass);
 static void     buoh_comic_loader_finalize      (GObject              *object);
 
-static SoupUri *buoh_comic_loader_get_proxy_uri (BuohComicLoader      *loader);
-static void     buoh_comic_loader_update_proxy  (GConfClient          *gconf_client,
-						 guint                 cnxn_id,
-						 GConfEntry           *entry,
-						 gpointer              gdata);
-static void     buoh_comic_loader_update        (GdkPixbufLoader      *pixbuf_loader,
-						 gint                  x,
-						 gint                  y,
-						 gint                  width,
-						 gint                  height,
-						 gpointer              gdata);
-static void     buoh_comic_loader_resolved      (SoupMessage          *msg,
-						 gpointer              gdata);
-static void     buoh_comic_loader_read_next     (SoupMessage          *msg,
-						 gpointer              gdata);
-static void     buoh_comic_loader_finished      (SoupMessage          *msg,
-						 gpointer              gdata);
-static gpointer buoh_comic_loader_run_thread    (gpointer              gdata);
+static void     buoh_comic_loader_clear         (BuohComicLoader      *loader);
 
 GType
 buoh_comic_loader_get_type (void)
@@ -112,45 +122,7 @@
 static void
 buoh_comic_loader_init (BuohComicLoader *loader)
 {
-	SoupUri *proxy_uri = NULL;
-	
 	loader->priv = BUOH_COMIC_LOADER_GET_PRIVATE (loader);
-
-	loader->priv->data = g_string_sized_new (DATA_SIZE);
-	loader->priv->uri = NULL;
-	loader->priv->pixbuf_loader = NULL;
-
-	loader->priv->loop = NULL;
-
-	loader->priv->gconf_client = gconf_client_get_default ();
-	proxy_uri = buoh_comic_loader_get_proxy_uri (loader);
-
-	loader->priv->session = (proxy_uri != NULL) ?
-		soup_session_async_new_with_options (SOUP_SESSION_PROXY_URI, proxy_uri, NULL) :
-		soup_session_async_new ();
-
-	if (proxy_uri)
-		soup_uri_free (proxy_uri);
-
-	gconf_client_add_dir (loader->priv->gconf_client,
-			      GCONF_HTTP_PROXY_DIR,
-			      GCONF_CLIENT_PRELOAD_NONE,
-			      NULL);
-	gconf_client_notify_add (loader->priv->gconf_client,
-				 GCONF_HTTP_PROXY_DIR,
-				 buoh_comic_loader_update_proxy,
-				 (gpointer) loader,
-				 NULL, NULL);
-	
-	loader->priv->msg = NULL;
-	
-	loader->thread_mutex = g_mutex_new ();
-	loader->pixbuf_mutex = g_mutex_new ();
-	loader->status_mutex = g_mutex_new ();
-	
-	loader->thread = NULL;
-	loader->status = LOADER_STATE_READY;
-	loader->error = NULL; 
 }
 
 static void
@@ -162,6 +134,15 @@
 
 	g_type_class_add_private (klass, sizeof (BuohComicLoaderPrivate));
 
+	buoh_comic_loader_signals [FINISHED] =
+		g_signal_new ("finished",
+			      BUOH_TYPE_COMIC_LOADER,
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (BuohComicLoaderClass, finished),
+			      NULL, NULL,
+			      g_cclosure_marshal_VOID__VOID,
+			      G_TYPE_NONE, 0);
+
 	object_class->finalize = buoh_comic_loader_finalize;
 }
 
@@ -172,60 +153,11 @@
 
 	buoh_debug ("comic-loader finalize");
 
-	switch (loader->status) {
-	case LOADER_STATE_RUNNING:
-		buoh_comic_loader_stop (loader);
-		/* Do not break! */
-	case LOADER_STATE_STOPPING:
-		g_thread_join (loader->thread);
-		break;
-	default:
-		break;
-	}
+	buoh_comic_loader_clear (loader);
 
-	if (loader->thread_mutex) {
-		g_mutex_free (loader->thread_mutex);
-		loader->thread_mutex = NULL;
-	}
-	
-	if (loader->pixbuf_mutex) {
-		g_mutex_free (loader->pixbuf_mutex);
-		loader->pixbuf_mutex = NULL;
-	}
-
-	if (loader->status_mutex) {
-		g_mutex_free (loader->status_mutex);
-		loader->status_mutex = NULL;
-	}
-
-	if (loader->error) {
-		g_error_free (loader->error);
-		loader->error = NULL;
-	}
-
-	if (loader->priv->gconf_client) {
-		g_object_unref (loader->priv->gconf_client);
-		loader->priv->gconf_client = NULL;
-	}
-
-	if (loader->priv->data) {
-		g_string_free (loader->priv->data, TRUE);
-		loader->priv->data = NULL;
-	}
-	
-	if (loader->priv->uri) {
-		g_free (loader->priv->uri);
-		loader->priv->uri = NULL;
-	}
-
-	if (loader->priv->session) {
-		g_object_unref (loader->priv->session);
-		loader->priv->session = NULL;
-	}
-
-	if (loader->priv->loop) {
-		g_main_loop_unref (loader->priv->loop);
-		loader->priv->loop = NULL;
+	if (loader->priv->error) {
+		g_error_free (loader->priv->error);
+		loader->priv->error = NULL;
 	}
 
 	if (G_OBJECT_CLASS (parent_class)->finalize)
@@ -242,320 +174,196 @@
 	return loader;
 }
 
-static SoupUri *
-buoh_comic_loader_get_proxy_uri (BuohComicLoader *loader)
+/* BuohComicLoaderJob */
+static void
+buoh_comic_loader_job_init (BuohComicLoaderJob *job)
 {
-	GConfClient *gconf_client = loader->priv->gconf_client;
-	SoupUri     *uri = NULL;
-	
-	if (gconf_client_get_bool (gconf_client, GCONF_USE_HTTP_PROXY, NULL)) {
-		uri = g_new0 (SoupUri, 1);
-		
-		uri->protocol = SOUP_PROTOCOL_HTTP;
-		
-		uri->host = gconf_client_get_string (gconf_client,
-						     GCONF_HTTP_PROXY_HOST,
-						     NULL);
-		uri->port = gconf_client_get_int (gconf_client,
-						  GCONF_HTTP_PROXY_PORT,
-						  NULL);
-		
-		if (gconf_client_get_bool (gconf_client, GCONF_HTTP_PROXY_USE_AUTHENTICATION, NULL)) {
-			uri->user = gconf_client_get_string (
-				gconf_client,
-				GCONF_HTTP_PROXY_AUTHENTICATION_USER,
-				NULL );
-			uri->passwd = gconf_client_get_string (
-				gconf_client,
-				GCONF_HTTP_PROXY_AUTHENTICATION_PASSWORD,
-				NULL);
-		}
-	}
-
-	return uri;
 }
 
 static void
-buoh_comic_loader_update_proxy (GConfClient *gconf_client, guint cnxn_id,
-				GConfEntry *entry, gpointer gdata)
+buoh_comic_loader_job_class_init (BuohComicLoaderJobClass *klass)
 {
-	BuohComicLoader *loader = BUOH_COMIC_LOADER (gdata);
-	SoupUri         *uri = NULL;
-
-	buoh_debug ("Proxy configuration changed");
-	
-	uri = buoh_comic_loader_get_proxy_uri (loader);
-	g_object_set (G_OBJECT (loader->priv->session),
-		      "proxy-uri", uri, NULL);
+	GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
 
-	if (uri)
-		soup_uri_free (uri);
+	gobject_class->finalize = buoh_comic_loader_job_finalize;
 }
 
 static void
-buoh_comic_loader_set_size (GdkPixbufLoader *pixbuf_loader,
-			    gint width, gint height, gpointer gdata)
+buoh_comic_loader_job_finalize (GObject *object)
 {
-	BuohComicLoader *loader = BUOH_COMIC_LOADER (gdata);
+	BuohComicLoaderJob *job = BUOH_COMIC_LOADER_JOB (object);
 
-	buoh_debug ("loader size-prepared");
-	gdk_pixbuf_loader_set_size (pixbuf_loader,
-				    width * loader->priv->scale,
-				    height * loader->priv->scale);
-}
+	buoh_debug ("comic-loader-job finalize");
 
-static void
-buoh_comic_loader_update (GdkPixbufLoader *pixbuf_loader, gint x, gint y,
-			  gint width, gint height, gpointer gdata)
-{
-	BuohComicLoader *loader = BUOH_COMIC_LOADER (gdata);
-	GdkPixbuf       *pixbuf = NULL;
+	if (job->uri) {
+		g_free (job->uri);
+		job->uri = NULL;
+	}
 
-	g_mutex_lock (loader->pixbuf_mutex);
-	pixbuf = gdk_pixbuf_loader_get_pixbuf (pixbuf_loader);
-	loader->pixbuf = pixbuf;
-	g_mutex_unlock (loader->pixbuf_mutex);
+	if (job->session) {
+		g_object_unref (job->session);
+		job->session = NULL;
+	}
+
+	if (job->error) {
+		g_error_free (job->error);
+		job->error = NULL;
+	}
+
+	if (G_OBJECT_CLASS (buoh_comic_loader_job_parent_class)->finalize)
+		(* G_OBJECT_CLASS (buoh_comic_loader_job_parent_class)->finalize) (object);
 }
 
-static void
-buoh_comic_loader_resolved (SoupMessage *msg, gpointer gdata)
+static BuohComicLoaderJob *
+buoh_comic_loader_job_new (const gchar             *uri,
+			   BuohComicLoaderLoadFunc  callback,
+			   gpointer                 gdata)
 {
-	BuohComicLoader *loader = BUOH_COMIC_LOADER (gdata);
+	const gchar        *proxy_uri;
+	BuohComicLoaderJob *job;
 
-	buoh_debug ("resolved");
+	job = g_object_new (BUOH_TYPE_COMIC_LOADER_JOB, NULL);
 
-	if (SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
-		loader->priv->pixbuf_loader = gdk_pixbuf_loader_new ();
-		
-		if (loader->priv->scale != 1.0) {
-			g_signal_connect (G_OBJECT (loader->priv->pixbuf_loader),
-					  "size_prepared",
-					  G_CALLBACK (buoh_comic_loader_set_size),
-					  (gpointer) loader);
-		}
+	job->uri = g_strdup (uri);
+	job->callback = callback;
+	job->callback_data = gdata;
+
+	proxy_uri = buoh_get_http_proxy_uri (BUOH);
+	if (proxy_uri) {
+		SoupUri *soup_uri = soup_uri_new (proxy_uri);
+
+		job->session = soup_session_sync_new_with_options (SOUP_SESSION_PROXY_URI, soup_uri, NULL);
 		
-		g_signal_connect (G_OBJECT (loader->priv->pixbuf_loader),
-				  "area-updated",
-				  G_CALLBACK (buoh_comic_loader_update),
-				  (gpointer) loader);
+		soup_uri_free (soup_uri);
 	} else {
-		g_clear_error (&(loader->error));
-		loader->error = g_error_new (BUOH_COMIC_LOADER_ERROR,
-					     (gint) msg->status_code,
-					     msg->reason_phrase);
-
-		g_mutex_lock (loader->status_mutex);
-		loader->status = LOADER_STATE_FAILED;
-		g_mutex_unlock (loader->status_mutex);
-
-		soup_message_set_status (msg, SOUP_STATUS_CANCELLED);
-		soup_session_cancel_message (loader->priv->session, msg);
+		job->session = soup_session_sync_new ();
 	}
+
+	return job;
 }
 
-static void
-buoh_comic_loader_read_next (SoupMessage *msg, gpointer gdata)
+static gpointer
+buoh_comic_loader_job_finished (BuohComicLoaderJob *job)
 {
-	BuohComicLoader *loader = BUOH_COMIC_LOADER (gdata);
-
-	if (loader->status == LOADER_STATE_STOPPING) {
-		buoh_debug ("Stopping loader");
-
-		return;
+	if (!job->canceled) {
+		if (job->loader->priv->error)
+			g_error_free (job->loader->priv->error);
+		job->loader->priv->error = NULL;
+		
+		if (job->error)
+			job->loader->priv->error = g_error_copy (job->error);
+		
+		g_signal_emit (job->loader, buoh_comic_loader_signals[FINISHED], 0);
 	}
+	
+	g_object_unref (job);
 
-	if (SOUP_STATUS_IS_SUCCESSFUL (msg->status_code)) {
-		loader->priv->data = g_string_append_len (loader->priv->data,
-							  msg->response.body,
-							  msg->response.length);
-		gdk_pixbuf_loader_write (loader->priv->pixbuf_loader,
-					 (guchar *) msg->response.body,
-					 msg->response.length, NULL);
-	} else {
-		g_clear_error (&(loader->error));
-		loader->error = g_error_new (BUOH_COMIC_LOADER_ERROR,
-					     (gint) msg->status_code,
-					     msg->reason_phrase);
-
-		g_mutex_lock (loader->status_mutex);
-		loader->status = LOADER_STATE_FAILED;
-		g_mutex_unlock (loader->status_mutex);
-
-		soup_message_set_status (msg, SOUP_STATUS_CANCELLED);
-		soup_session_cancel_message (loader->priv->session, msg);
-	}
+	return FALSE;
 }
 
 static void
-buoh_comic_loader_finished (SoupMessage *msg, gpointer gdata)
+buoh_comic_loader_job_read_next (SoupMessage        *msg,
+				 BuohComicLoaderJob *job)
 {
-	BuohComicLoader *loader = BUOH_COMIC_LOADER (gdata);
-	GdkPixbuf       *pixbuf = NULL;
-
-	buoh_debug ("loader finish");
+	gboolean success;
 
-	switch (loader->status) {
-	case LOADER_STATE_RUNNING:
-		if (loader->priv->pixbuf_loader) {
-			gdk_pixbuf_loader_close (loader->priv->pixbuf_loader, NULL);
-			
-			g_mutex_lock (loader->pixbuf_mutex);
-			pixbuf = gdk_pixbuf_loader_get_pixbuf (loader->priv->pixbuf_loader);
-			loader->pixbuf = GDK_IS_PIXBUF (pixbuf) ? g_object_ref (pixbuf) : NULL;
-			loader->image = g_new0 (BuohComicImage, 1);
-			loader->image->size = loader->priv->data->len;
-			loader->image->data = (guchar *) g_memdup (loader->priv->data->str,
-								   loader->priv->data->len);
-			g_mutex_unlock (loader->pixbuf_mutex);
-
-			loader->priv->data->len = 0;
-			
-			g_object_unref (loader->priv->pixbuf_loader);
-			loader->priv->pixbuf_loader = NULL;
+	buoh_debug ("read chunk");
+	
+	success = SOUP_STATUS_IS_SUCCESSFUL (msg->status_code);
+	
+	if (job->canceled || !success) {
+		if (!success) {
+			if (job->error)
+				g_error_free (job->error);
+			job->error = g_error_new (BUOH_COMIC_LOADER_ERROR,
+						  (gint) msg->status_code,
+						  msg->reason_phrase);
+			g_print ("DBG: error reading chunk\n");
 		}
 
-		g_mutex_lock (loader->status_mutex);
-		loader->status = LOADER_STATE_FINISHED;
-		g_mutex_unlock (loader->status_mutex);
-
-		break;
-	case LOADER_STATE_FAILED:
-		if (loader->priv->pixbuf_loader) {
-			gdk_pixbuf_loader_close (loader->priv->pixbuf_loader, NULL);
-
-			g_mutex_lock (loader->pixbuf_mutex);
-			if (GDK_IS_PIXBUF (loader->pixbuf))
-				g_object_unref (loader->pixbuf);
-			loader->pixbuf = NULL;
-			g_mutex_unlock (loader->pixbuf_mutex);
-
-			loader->priv->data->len = 0;
+		soup_message_set_status (msg, SOUP_STATUS_CANCELLED);
+		soup_session_cancel_message (job->session, msg);
 
-			g_object_unref (loader->priv->pixbuf_loader);
-			loader->priv->pixbuf_loader = NULL;
-		}
+		return;
+	}
 
-		break;
-	case LOADER_STATE_STOPPING:
-		if (loader->priv->pixbuf_loader) {
-			gdk_pixbuf_loader_close (loader->priv->pixbuf_loader, NULL);
-
-			g_mutex_lock (loader->pixbuf_mutex);
-			loader->pixbuf = NULL;
-			g_mutex_unlock (loader->pixbuf_mutex);
-
-			loader->priv->data->len = 0;
-			
-			g_object_unref (loader->priv->pixbuf_loader);
-			loader->priv->pixbuf_loader = NULL;
-		}
-		
-		g_mutex_lock (loader->status_mutex);
-		loader->status = LOADER_STATE_FINISHED;
-		g_mutex_unlock (loader->status_mutex);
-		
-		break;
-	default:
-		break;
+	if (job->callback) {
+		job->callback (msg->response.body,
+			       msg->response.length,
+			       job->callback_data);
 	}
-		
-	if (g_main_loop_is_running (loader->priv->loop))
-		g_main_loop_quit (loader->priv->loop);
 }
 
 static gpointer
-buoh_comic_loader_run_thread (gpointer gdata)
+buoh_comic_loader_job_run (BuohComicLoaderJob *job)
 {
-	BuohComicLoader  *loader = BUOH_COMIC_LOADER (gdata);
-	GMainContext     *context;
-
-	buoh_debug ("comic_load_thread");
+	SoupMessage *msg;
+	
+	buoh_debug ("comic_load_job");
 
-	context = g_main_context_new ();
-	loader->priv->loop = g_main_loop_new (context, TRUE);
-
-	loader->priv->msg = soup_message_new (SOUP_METHOD_GET, loader->priv->uri);
-	soup_message_set_flags (loader->priv->msg,
-				SOUP_MESSAGE_OVERWRITE_CHUNKS);
-	soup_message_add_handler (loader->priv->msg, SOUP_HANDLER_PRE_BODY,
-				  buoh_comic_loader_resolved,
-				  (gpointer) loader);
-	soup_message_add_handler (loader->priv->msg, SOUP_HANDLER_BODY_CHUNK,
-				  buoh_comic_loader_read_next,
-				  (gpointer) loader);
+	msg = soup_message_new (SOUP_METHOD_GET, job->uri);
 	
+	soup_message_set_flags (msg, SOUP_MESSAGE_OVERWRITE_CHUNKS);
+	soup_message_add_handler (msg, SOUP_HANDLER_BODY_CHUNK,
+				  (SoupMessageCallbackFn)buoh_comic_loader_job_read_next,
+				  (gpointer) job);
+
 	buoh_debug ("resolving . . .");
-	
-	soup_session_queue_message (loader->priv->session, loader->priv->msg,
-				    buoh_comic_loader_finished,
-				    (gpointer) loader);
-	g_free (loader->priv->uri);
-	loader->priv->uri = NULL;
-
-	if (g_main_loop_is_running (loader->priv->loop)) 
-		g_main_loop_run (loader->priv->loop);
-
-	g_main_loop_unref (loader->priv->loop);
-	loader->priv->loop = NULL;
-	g_main_context_unref (context);
 
-	buoh_debug ("thread died");
+	soup_session_send_message (job->session, msg);
 
-	g_mutex_unlock (loader->thread_mutex);
+	if (job->canceled) {
+		buoh_debug ("canceled . . .");
+		g_object_unref (job);
+	} else {
+		buoh_debug ("finished . . .");
+		
+		g_idle_add ((GSourceFunc)buoh_comic_loader_job_finished,
+			    (gpointer) job);
+	}
+
+	buoh_debug ("thread died");
 
 	return NULL;
 }
 
-void
-buoh_comic_loader_run (BuohComicLoader *loader, const gchar *uri, gdouble scale)
+static void
+buoh_comic_loader_clear (BuohComicLoader *loader)
 {
 	g_return_if_fail (BUOH_IS_COMIC_LOADER (loader));
-	g_return_if_fail (uri != NULL);
-
-	g_mutex_lock (loader->status_mutex);
-	loader->status = LOADER_STATE_READY;
-	g_mutex_unlock (loader->status_mutex);
-
-	g_mutex_lock (loader->pixbuf_mutex);
-	loader->pixbuf = NULL;
-	loader->image = NULL;
-	g_mutex_unlock (loader->pixbuf_mutex);
-
-	loader->priv->data->len = 0;
-	loader->priv->uri = g_strdup (uri);
-	loader->priv->scale = scale;
-
-	g_mutex_lock (loader->thread_mutex);
 
-	g_mutex_lock (loader->status_mutex);
-	loader->status = LOADER_STATE_RUNNING;
-	g_mutex_unlock (loader->status_mutex);
+	if (!loader->priv->job)
+		return;
 
-	g_clear_error (&(loader->error));
-	
-	loader->thread = g_thread_create (buoh_comic_loader_run_thread,
-					  (gpointer)loader, TRUE, NULL);
+	loader->priv->job->canceled = TRUE;
+	/* job unref is done by current thread */
+	loader->priv->job = NULL;
 }
 
 void
-buoh_comic_loader_stop (BuohComicLoader *loader)
+buoh_comic_loader_load_comic (BuohComicLoader *loader,
+			      BuohComic       *comic,
+			      BuohComicLoaderLoadFunc callback,
+			      gpointer         gdata)
 {
 	g_return_if_fail (BUOH_IS_COMIC_LOADER (loader));
+	g_return_if_fail (BUOH_IS_COMIC (comic));
 	
-	buoh_debug ("Stopping loader");
-
-	g_mutex_lock (loader->status_mutex);
-	loader->status = LOADER_STATE_STOPPING;
-	g_mutex_unlock (loader->status_mutex);
+	buoh_comic_loader_clear (loader);
+	
+	loader->priv->job = buoh_comic_loader_job_new (buoh_comic_get_uri (comic),
+						       callback, gdata);
+	loader->priv->job->loader = loader;
 
-	soup_message_set_status (loader->priv->msg, SOUP_STATUS_CANCELLED);
-	soup_session_cancel_message (loader->priv->session, loader->priv->msg);
+	g_thread_create ((GThreadFunc) buoh_comic_loader_job_run,
+			 loader->priv->job, FALSE, NULL);
 }
 
 void
-buoh_comic_loader_wait (BuohComicLoader *loader)
+buoh_comic_loader_get_error (BuohComicLoader *loader,
+			     GError         **error)
 {
-	g_return_if_fail (BUOH_IS_COMIC_LOADER (loader));
-
-	g_thread_join (loader->thread);
+	if (loader->priv->error)
+		*error = g_error_copy (loader->priv->error);
 }
+
===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh-comic-loader.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- /cvsroot/buoh/buoh/src/buoh-comic-loader.h	2005/11/30 10:48:02	1.7
+++ /cvsroot/buoh/buoh/src/buoh-comic-loader.h	2006/09/24 18:31:42	1.8
@@ -20,22 +20,11 @@
 #define BUOH_COMIC_LOADER_H
 
 #include <glib-object.h>
-#include <glib.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
-#include <libsoup/soup.h>
 
 #include "buoh-comic.h"
 
 G_BEGIN_DECLS
 
-enum {
-	LOADER_STATE_READY,
-	LOADER_STATE_RUNNING,
-	LOADER_STATE_FINISHED,
-	LOADER_STATE_STOPPING,
-	LOADER_STATE_FAILED
-};
-
 typedef struct _BuohComicLoader        BuohComicLoader;
 typedef struct _BuohComicLoaderClass   BuohComicLoaderClass;
 typedef struct _BuohComicLoaderPrivate BuohComicLoaderPrivate;
@@ -49,35 +38,32 @@
 
 #define BUOH_COMIC_LOADER_ERROR (buoh_comic_loader_error_quark())
 
+typedef void (*BuohComicLoaderLoadFunc) (const gchar *data,
+					 guint        len,
+					 gpointer     gdata);
+
 struct _BuohComicLoader {
 	GObject    parent;
 
-	GMutex         *thread_mutex;
-	GMutex         *pixbuf_mutex;
-	GMutex         *status_mutex;
-	
-	GThread        *thread;
-	GdkPixbuf      *pixbuf;
-	BuohComicImage *image;
-	guint           status;
-	GError         *error;
-
 	BuohComicLoaderPrivate *priv;
 };
 
 struct _BuohComicLoaderClass {
 	GObjectClass   parent_class;
+
+	void (* finished) (BuohComicLoader *loader);
 };
 
 GType            buoh_comic_loader_get_type    (void) G_GNUC_CONST;
 GQuark           buoh_comic_loader_error_quark (void);
 BuohComicLoader *buoh_comic_loader_new         (void);
 
-void             buoh_comic_loader_run         (BuohComicLoader *loader,
-						const gchar     *uri,
-						gdouble          scale);
-void             buoh_comic_loader_stop        (BuohComicLoader *loader);
-void             buoh_comic_loader_wait        (BuohComicLoader *loader);
+void             buoh_comic_loader_load_comic  (BuohComicLoader *loader,
+						BuohComic       *comic,
+						BuohComicLoaderLoadFunc callback,
+						gpointer         gdata);
+void             buoh_comic_loader_get_error   (BuohComicLoader *loader,
+						GError         **error);
 
 G_END_DECLS
 
===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh-comic-manager.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- /cvsroot/buoh/buoh/src/buoh-comic-manager.c	2005/11/16 20:29:28	1.8
+++ /cvsroot/buoh/buoh/src/buoh-comic-manager.c	2006/09/24 18:31:42	1.9
@@ -408,52 +408,36 @@
 		return FALSE;
 }
 
-gchar *
+const gchar *
 buoh_comic_manager_get_title (BuohComicManager *comic_manager)
 {
-	gchar *title = NULL;
-
 	g_return_val_if_fail (BUOH_IS_COMIC_MANAGER (comic_manager), NULL);
 
-	g_object_get (G_OBJECT (comic_manager), "title", &title, NULL);
-
-	return title;
+	return comic_manager->priv->title;
 }
 
-gchar *
+const gchar *
 buoh_comic_manager_get_author (BuohComicManager *comic_manager)
 {
-	gchar *author = NULL;
-	   
 	g_return_val_if_fail (BUOH_IS_COMIC_MANAGER (comic_manager), NULL);
 
-	g_object_get (G_OBJECT (comic_manager), "author", &author, NULL);
-
-	return author;
+	return comic_manager->priv->author;
 }
 
-gchar *
+const gchar *
 buoh_comic_manager_get_language (BuohComicManager *comic_manager)
 {
-	gchar *language = NULL;
-
 	g_return_val_if_fail (BUOH_IS_COMIC_MANAGER (comic_manager), NULL);
 
-	g_object_get (G_OBJECT (comic_manager), "language", &language, NULL);
-
-	return language;
+	return comic_manager->priv->language;
 }
 
-gchar *
+const gchar *
 buoh_comic_manager_get_id (BuohComicManager *comic_manager)
 {
-	gchar *id = NULL;
-	   
 	g_return_val_if_fail (BUOH_IS_COMIC_MANAGER (comic_manager), NULL);
 
-	g_object_get (G_OBJECT (comic_manager), "id", &id, NULL);
-
-	return id;
+	return comic_manager->priv->id;
 }
 
 gint
===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh-comic-manager.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- /cvsroot/buoh/buoh/src/buoh-comic-manager.h	2005/11/16 20:29:28	1.6
+++ /cvsroot/buoh/buoh/src/buoh-comic-manager.h	2006/09/24 18:31:42	1.7
@@ -62,24 +62,24 @@
 					     const gchar      *language,
 					     const gchar      *generic_uri);
 
-BuohComic  *buoh_comic_manager_get_next     (BuohComicManager *comic_manager);
-BuohComic  *buoh_comic_manager_get_previous (BuohComicManager *comic_manager);
-BuohComic  *buoh_comic_manager_get_current  (BuohComicManager *comic_manager);
-BuohComic  *buoh_comic_manager_get_last     (BuohComicManager *comic_manager);
-BuohComic  *buoh_comic_manager_get_first    (BuohComicManager *comic_manager);
-
-gboolean    buoh_comic_manager_is_the_last  (BuohComicManager *comic_manager);
-gboolean    buoh_comic_manager_is_the_first (BuohComicManager *comic_manager);
-
-gchar      *buoh_comic_manager_get_uri      (BuohComicManager *comic_manager);
-gchar      *buoh_comic_manager_get_title    (BuohComicManager *comic_manager);
-gchar      *buoh_comic_manager_get_author   (BuohComicManager *comic_manager);
-gchar      *buoh_comic_manager_get_language (BuohComicManager *comic_manager);
-gchar      *buoh_comic_manager_get_id       (BuohComicManager *comic_manager);
-gchar      *buoh_comic_manager_get_page     (BuohComicManager *comic_manager);
+BuohComic   *buoh_comic_manager_get_next     (BuohComicManager *comic_manager);
+BuohComic   *buoh_comic_manager_get_previous (BuohComicManager *comic_manager);
+BuohComic   *buoh_comic_manager_get_current  (BuohComicManager *comic_manager);
+BuohComic   *buoh_comic_manager_get_last     (BuohComicManager *comic_manager);
+BuohComic   *buoh_comic_manager_get_first    (BuohComicManager *comic_manager);
+
+gboolean     buoh_comic_manager_is_the_last  (BuohComicManager *comic_manager);
+gboolean     buoh_comic_manager_is_the_first (BuohComicManager *comic_manager);
+
+const gchar *buoh_comic_manager_get_uri      (BuohComicManager *comic_manager);
+const gchar *buoh_comic_manager_get_title    (BuohComicManager *comic_manager);
+const gchar *buoh_comic_manager_get_author   (BuohComicManager *comic_manager);
+const gchar *buoh_comic_manager_get_language (BuohComicManager *comic_manager);
+const gchar *buoh_comic_manager_get_id       (BuohComicManager *comic_manager);
+const gchar *buoh_comic_manager_get_page     (BuohComicManager *comic_manager);
 
-gint        buoh_comic_manager_compare      (gconstpointer     a,
-					     gconstpointer     b);
+gint         buoh_comic_manager_compare      (gconstpointer     a,
+					      gconstpointer     b);
 
 G_END_DECLS
 
===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh-comic.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- /cvsroot/buoh/buoh/src/buoh-comic.c	2005/12/01 21:55:27	1.12
+++ /cvsroot/buoh/buoh/src/buoh-comic.c	2006/09/24 18:31:42	1.13
@@ -350,28 +350,20 @@
 	buoh_comic_set_pixbuf (comic, pixbuf);
 }
 
-gchar *
+const gchar *
 buoh_comic_get_id (BuohComic *comic)
 {
-	gchar *id = NULL;
-	   
 	g_return_val_if_fail (BUOH_IS_COMIC (comic), NULL);
 
-	g_object_get (G_OBJECT (comic), "id", &id, NULL);
-
-	return id;
+	return comic->priv->id;
 }
 
-gchar *
+const gchar *
 buoh_comic_get_uri (BuohComic *comic)
 {
-	gchar *uri = NULL;
-	   
 	g_return_val_if_fail (BUOH_IS_COMIC (comic), NULL);
 
-	g_object_get (G_OBJECT (comic), "uri", &uri, NULL);
-
-	return uri;
+	return comic->priv->uri;
 }
 
 GdkPixbuf *
@@ -445,10 +437,10 @@
 gchar *
 buoh_comic_get_filename (BuohComic *comic)
 {
-	g_return_val_if_fail (BUOH_IS_COMIC (comic), NULL);
-	
 	gchar *filename;
 	
+	g_return_val_if_fail (BUOH_IS_COMIC (comic), NULL);
+	
 	filename = g_path_get_basename (comic->priv->uri);
 	
 	return filename;
===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh-comic.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- /cvsroot/buoh/buoh/src/buoh-comic.h	2005/12/01 21:55:27	1.8
+++ /cvsroot/buoh/buoh/src/buoh-comic.h	2006/09/24 18:31:42	1.9
@@ -52,37 +52,37 @@
 	GObjectClass      parent_class;
 };
 
-GType      buoh_comic_get_type             (void) G_GNUC_CONST; 
-BuohComic *buoh_comic_new                  (void);
-BuohComic *buoh_comic_new_with_info        (const gchar    *id,
-					    const gchar    *uri,
-					    const GDate    *date);
-
-void       buoh_comic_set_id               (BuohComic      *comic,
-					    const gchar    *id);
-void       buoh_comic_go_next              (BuohComic      *comic);
-void       buoh_comic_go_previous          (BuohComic      *comic);
-void       buoh_comic_set_pixbuf           (BuohComic      *comic,
-					    GdkPixbuf      *pixbuf);
-void       buoh_comic_set_image            (BuohComic      *comic,
-					    BuohComicImage *image);
-void	   buoh_comic_set_date             (BuohComic      *comic,
-					    GDate          *date);
-void       buoh_comic_set_pixbuf_from_file (BuohComic      *comic,
-					    const gchar    *filename);
-
-gchar     *buoh_comic_get_uri              (BuohComic      *comic);
-gchar     *buoh_comic_get_id               (BuohComic      *comic);
-GdkPixbuf *buoh_comic_get_pixbuf           (BuohComic      *comic);
-BuohComicImage *buoh_comic_get_image       (BuohComic      *comic);
-GDate     *buoh_comic_get_date             (BuohComic      *comic);
-GdkPixbuf *buoh_comic_get_thumbnail        (BuohComic      *comic);
-gchar     *buoh_comic_get_filename         (BuohComic      *comic);
-
-gboolean   buoh_comic_image_save           (BuohComicImage *image,
-					    const gchar    *path,
-					    GError        **error);
-void       buoh_comic_image_free           (BuohComicImage *image);
+GType           buoh_comic_get_type             (void) G_GNUC_CONST; 
+BuohComic      *buoh_comic_new                  (void);
+BuohComic      *buoh_comic_new_with_info        (const gchar    *id,
+						 const gchar    *uri,
+						 const GDate    *date);
+
+void            buoh_comic_set_id               (BuohComic      *comic,
+						 const gchar    *id);
+void            buoh_comic_go_next              (BuohComic      *comic);
+void            buoh_comic_go_previous          (BuohComic      *comic);
+void            buoh_comic_set_pixbuf           (BuohComic      *comic,
+						 GdkPixbuf      *pixbuf);
+void            buoh_comic_set_image            (BuohComic      *comic,
+						 BuohComicImage *image);
+void	        buoh_comic_set_date             (BuohComic      *comic,
+						 GDate          *date);
+void            buoh_comic_set_pixbuf_from_file (BuohComic      *comic,
+						 const gchar    *filename);
+
+const gchar    *buoh_comic_get_uri              (BuohComic      *comic);
+const gchar    *buoh_comic_get_id               (BuohComic      *comic);
+GdkPixbuf      *buoh_comic_get_pixbuf           (BuohComic      *comic);
+BuohComicImage *buoh_comic_get_image            (BuohComic      *comic);
+GDate          *buoh_comic_get_date             (BuohComic      *comic);
+GdkPixbuf      *buoh_comic_get_thumbnail        (BuohComic      *comic);
+gchar          *buoh_comic_get_filename         (BuohComic      *comic);
+
+gboolean        buoh_comic_image_save           (BuohComicImage *image,
+						 const gchar    *path,
+						 GError        **error);
+void            buoh_comic_image_free           (BuohComicImage *image);
 
 G_END_DECLS
 
===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh-properties-dialog.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- /cvsroot/buoh/buoh/src/buoh-properties-dialog.c	2005/11/16 20:29:28	1.16
+++ /cvsroot/buoh/buoh/src/buoh-properties-dialog.c	2006/09/24 18:31:42	1.17
@@ -109,7 +109,7 @@
 	GtkWidget *label_pub_days, *label_pub_days_val;
 	GtkWidget *image;
 	GDate     *comic_date;
-	gchar     *title, *author, *uri, *language, date[DATE_BUFFER];
+	gchar date[DATE_BUFFER];
 	gchar     *pub_days;
 	BuohComic *comic;
 	GdkPixbuf *thumbnail;
@@ -127,13 +127,9 @@
 	thumbnail = buoh_comic_get_thumbnail (comic);
 	image = gtk_image_new_from_pixbuf (thumbnail);
 	g_object_unref (thumbnail);
+	
 	gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0);
 
-	g_object_get (comic_manager,
-		      "title", &title,
-		      "author", &author,
-		      "language", &language, NULL);
-
 	str = g_strdup_printf ("<b>%s:</b>", _("Title"));
 	label_title = gtk_label_new (NULL);
 	gtk_label_set_markup (GTK_LABEL (label_title), str);
@@ -164,33 +160,23 @@
 	gtk_misc_set_alignment (GTK_MISC (label_date), 0, 0.5);
 	g_free (str);
 
-	g_object_get (comic_manager,
-		      "title", &title,
-		      "author", &author,
-		      "language", &language, NULL);
-
-	label_title_val = gtk_label_new (title);
+	label_title_val = gtk_label_new (buoh_comic_manager_get_title (comic_manager));
 	gtk_label_set_selectable (GTK_LABEL (label_title_val), TRUE);
 	gtk_misc_set_alignment (GTK_MISC (label_title_val), 0, 0.5);
-	g_free (title);
 	
-	label_author_val = gtk_label_new (author);
+	label_author_val = gtk_label_new (buoh_comic_manager_get_author (comic_manager));
 	gtk_label_set_selectable (GTK_LABEL (label_author_val), TRUE);
 	gtk_misc_set_alignment (GTK_MISC (label_author_val), 0, 0.5);
-	g_free (author);
 
-	uri = buoh_comic_get_uri (comic);
-	label_uri_val = gtk_label_new (uri);
+	label_uri_val = gtk_label_new (buoh_comic_get_uri (comic));
 	gtk_label_set_selectable (GTK_LABEL (label_uri_val), TRUE);
 	gtk_misc_set_alignment (GTK_MISC (label_uri_val), 0, 0.5);
 	gtk_label_set_width_chars (GTK_LABEL (label_uri_val), 35);
 	gtk_label_set_ellipsize (GTK_LABEL (label_uri_val), PANGO_ELLIPSIZE_END);	
-	g_free (uri);
 	
-	label_language_val = gtk_label_new (language);
+	label_language_val = gtk_label_new (buoh_comic_manager_get_language (comic_manager));
 	gtk_label_set_selectable (GTK_LABEL (label_language_val), TRUE);
 	gtk_misc_set_alignment (GTK_MISC (label_language_val), 0, 0.5);	
-	g_free (language);
 
 	comic_date = buoh_comic_get_date (comic);
 	if (g_date_strftime (date, DATE_BUFFER,
===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh-view-comic.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- /cvsroot/buoh/buoh/src/buoh-view-comic.c	2005/11/30 10:48:02	1.15
+++ /cvsroot/buoh/buoh/src/buoh-view-comic.c	2006/09/24 18:31:42	1.16
@@ -39,16 +39,16 @@
 struct _BuohViewComicPrivate {
 	BuohView        *view;
 	GtkWidget       *image;
-	GdkPixbuf       *current;
+	GString         *comic_data;
 
 	BuohComic       *comic;
 	gdouble          scale;
 
-	guint            load_monitor;
 	BuohComicLoader *comic_loader;
+	GdkPixbufLoader *pixbuf_loader;
 };
 
-static GtkTargetEntry targets[] = {
+static const GtkTargetEntry targets[] = {
 	{ "text/uri-list", 0, 0 },
 	{ "x-url/http",    0, 0 }
 };
@@ -62,11 +62,14 @@
 #define MIN_ZOOM_SCALE 0.6
 #define MAX_ZOOM_SCALE 2
 
+#define DATA_SIZE 61440 /* 60K */
+
 static GtkViewportClass *parent_class = NULL;
 
 static void     buoh_view_comic_init                  (BuohViewComic *m_view);
 static void     buoh_view_comic_class_init            (BuohViewComicClass *klass);
 static void     buoh_view_comic_finalize              (GObject          *object);
+static void     buoh_view_comic_dispose               (GObject          *object);
 static void     buoh_view_comic_set_property          (GObject          *object,
 						       guint             prop_id,
 						       const GValue     *value,
@@ -95,13 +98,9 @@
 						       GParamSpec       *arg,
 						       gpointer          gdata);
 static void     buoh_view_comic_prepare_load          (BuohViewComic    *c_view);
-static void     buoh_view_comic_set_image_from_pixbuf (BuohViewComic    *c_view,
-						       GdkPixbuf        *pixbuf);
-static gboolean buoh_view_comic_load_monitor          (gpointer          gdata);
+static void     buoh_view_comic_load_finished         (BuohViewComic    *c_view,
+						       gpointer          gdata);
 static void     buoh_view_comic_load                  (BuohViewComic    *c_view);
-static void     buoh_view_comic_zoom                  (BuohViewComic    *c_view,
-						       gdouble           factor,
-						       gboolean          relative);
 
 GType
 buoh_view_comic_get_type (void)
@@ -135,11 +134,9 @@
 	
 	c_view->priv = BUOH_VIEW_COMIC_GET_PRIVATE (c_view);
 
-	c_view->priv->view = NULL;
 	c_view->priv->scale = 1.0;
-	c_view->priv->comic = NULL;
-	c_view->priv->load_monitor = 0;
 	c_view->priv->comic_loader = buoh_comic_loader_new ();
+	c_view->priv->comic_data = g_string_sized_new (DATA_SIZE);
 	
 	c_view->priv->image = gtk_image_new ();
 	gtk_container_add (GTK_CONTAINER (c_view),
@@ -159,6 +156,11 @@
 			  "drag-data-get",
 			  G_CALLBACK (buoh_view_comic_drag_data_get),
 			  NULL);
+
+	g_signal_connect_swapped (G_OBJECT (c_view->priv->comic_loader),
+				  "finished",
+				  G_CALLBACK (buoh_view_comic_load_finished),
+				  (gpointer) c_view);
 	
 	gtk_widget_show (GTK_WIDGET (c_view));
 }
@@ -197,6 +199,7 @@
 	g_type_class_add_private (klass, sizeof (BuohViewComicPrivate));
 
 	object_class->finalize = buoh_view_comic_finalize;
+	object_class->dispose = buoh_view_comic_dispose;
 }
 
 static void
@@ -206,18 +209,36 @@
 
 	buoh_debug ("buoh-view-comic finalize");
 
-	if (c_view->priv->load_monitor > 0) {
-		g_source_remove (c_view->priv->load_monitor);
-		c_view->priv->load_monitor = 0;
+	if (c_view->priv->comic_data) {
+		g_string_free (c_view->priv->comic_data, TRUE);
+		c_view->priv->comic_data = NULL;
+	}
+	
+	if (c_view->priv->pixbuf_loader) {
+		gdk_pixbuf_loader_close (c_view->priv->pixbuf_loader, NULL);
+		g_object_unref (c_view->priv->pixbuf_loader);
+		c_view->priv->pixbuf_loader = NULL;
 	}
 
+	if (G_OBJECT_CLASS (parent_class)->finalize)
+		(* G_OBJECT_CLASS (parent_class)->finalize) (object);
+}
+
+static void
+buoh_view_comic_dispose (GObject *object)
+{
+	BuohViewComic *c_view = BUOH_VIEW_COMIC (object);
+
 	if (c_view->priv->comic_loader) {
+		g_signal_handlers_disconnect_by_func (c_view->priv->comic_loader,
+						      buoh_view_comic_load_finished,
+						      c_view);
 		g_object_unref (c_view->priv->comic_loader);
 		c_view->priv->comic_loader = NULL;
 	}
-	
-	if (G_OBJECT_CLASS (parent_class)->finalize)
-		(* G_OBJECT_CLASS (parent_class)->finalize) (object);
+
+	if (G_OBJECT_CLASS (parent_class)->dispose)
+		(* G_OBJECT_CLASS (parent_class)->dispose) (object);
 }
 
 static void
@@ -381,7 +402,7 @@
 			       gpointer gdata)
 {
 	BuohViewComic *c_view = BUOH_VIEW_COMIC (widget);
-	gchar         *uri = NULL;
+	const gchar   *uri;
 
 	uri = buoh_comic_get_uri (c_view->priv->comic);
 	if (uri) {
@@ -390,7 +411,6 @@
 					8,
 					(guchar *)uri,
 					strlen (uri));
-		g_free (uri);
 	}
 }
 
@@ -408,6 +428,14 @@
 	gtk_adjustment_set_value (hadjustment, 0.0);
 	gtk_adjustment_set_value (vadjustment, 0.0);
 
+	if (c_view->priv->pixbuf_loader) {
+		gdk_pixbuf_loader_close (c_view->priv->pixbuf_loader, NULL);
+		g_object_unref (c_view->priv->pixbuf_loader);
+	}
+	c_view->priv->pixbuf_loader = gdk_pixbuf_loader_new ();
+
+	c_view->priv->comic_data->len = 0;
+
 #if GTK_CHECK_VERSION(2,8,0)
 	gtk_image_clear (GTK_IMAGE (c_view->priv->image));
 #else 
@@ -415,8 +443,8 @@
 				  GTK_STOCK_MISSING_IMAGE,
 				  GTK_ICON_SIZE_DIALOG);
 #endif
-	
 }
+
 static void
 bouh_view_comic_changed_comic_cb (GObject *object, GParamSpec *arg, gpointer gdata)
 {
@@ -444,7 +472,8 @@
 }
 
 static void
-buoh_view_comic_set_image_from_pixbuf (BuohViewComic *c_view, GdkPixbuf *pixbuf)
+buoh_view_comic_set_image_from_pixbuf (BuohViewComic *c_view,
+				       GdkPixbuf     *pixbuf)
 {
 	GdkPixbuf *new_pixbuf;
 
@@ -461,136 +490,122 @@
 	} else {
 		gtk_image_set_from_pixbuf (GTK_IMAGE (c_view->priv->image), pixbuf);
 	}
-
-	gtk_widget_show (c_view->priv->image);
 }
 
-static gboolean
-buoh_view_comic_load_monitor (gpointer gdata)
+static void
+buoh_view_comic_load_finished (BuohViewComic *c_view,
+			       gpointer       gdata)
 {
-	BuohViewComic    *c_view = BUOH_VIEW_COMIC (gdata);
-	static GdkCursor *cursor = NULL;
-	static gint       height = 0;
-
-	switch (c_view->priv->comic_loader->status) {
-	case LOADER_STATE_READY:
-		return TRUE;
-	case LOADER_STATE_RUNNING:
-		/* Watch cursor */
-		if (!cursor) {
-			cursor = gdk_cursor_new (GDK_WATCH);
-			if (!GTK_WIDGET_REALIZED (c_view))
-				gtk_widget_realize (GTK_WIDGET (c_view));
-			gdk_window_set_cursor (GTK_WIDGET (c_view)->window, cursor);
-		}
-
-		if (GDK_IS_PIXBUF (c_view->priv->comic_loader->pixbuf)) {
-			gint new_height = gdk_pixbuf_get_height (c_view->priv->comic_loader->pixbuf);
-
-			if (new_height != height) {
-				g_mutex_lock (c_view->priv->comic_loader->pixbuf_mutex);
-				gtk_image_set_from_pixbuf (GTK_IMAGE (c_view->priv->image),
-							   c_view->priv->comic_loader->pixbuf);
-				g_mutex_unlock (c_view->priv->comic_loader->pixbuf_mutex);
-				
-				gtk_widget_show (c_view->priv->image);
-				height = new_height;
-			}
-		}
-
-		return TRUE;
-	case LOADER_STATE_FINISHED:
-		if (GDK_IS_PIXBUF (c_view->priv->comic_loader->pixbuf)) {
-			g_mutex_lock (c_view->priv->comic_loader->pixbuf_mutex);
-			gtk_image_set_from_pixbuf (GTK_IMAGE (c_view->priv->image),
-						   c_view->priv->comic_loader->pixbuf);
-			if (c_view->priv->scale == 1.0) {
-				/* We have both the compressed and uncompressed image.
-				 * Setting the pixbuf avoids the cache uncompressing
-				 * the image again and having a new pixbuf instead of a
-				 * reference.
-				 */
-				buoh_comic_set_pixbuf (c_view->priv->comic,
-						       c_view->priv->comic_loader->pixbuf);
-			}
-			buoh_comic_set_image (c_view->priv->comic,
-					      c_view->priv->comic_loader->image);
-			g_object_unref (c_view->priv->comic_loader->pixbuf);
-			g_mutex_unlock (c_view->priv->comic_loader->pixbuf_mutex);
-
-			gtk_widget_show (c_view->priv->image);
-			
-			g_object_set (G_OBJECT (c_view->priv->view),
-				      "status", STATE_COMIC_LOADED,
-				      NULL);
-		}
-	case LOADER_STATE_STOPPING:
-		if (cursor) {
-			gdk_window_set_cursor (GTK_WIDGET (c_view)->window, NULL);
-			gdk_cursor_unref (cursor);
-			cursor = NULL;
-		}
-
-		buoh_debug ("Monitor exit (stopping/finished)");
+	GError    *error = NULL;
+	GdkPixbuf *pixbuf;
 
-		height = 0;
+	buoh_debug ("buoh-view-comic-load finished");
 
-		return FALSE;
-	case LOADER_STATE_FAILED:
-		if (cursor) {
-			gdk_window_set_cursor (GTK_WIDGET (c_view)->window, NULL);
-			gdk_cursor_unref (cursor);
-			cursor = NULL;
-		}
+	gdk_pixbuf_loader_close (c_view->priv->pixbuf_loader, NULL);
 
+	gdk_window_set_cursor (GTK_WIDGET (c_view)->window, NULL);
+	
+	buoh_comic_loader_get_error (c_view->priv->comic_loader, &error);
+	if (error) {
 		buoh_view_set_message_title (BUOH_VIEW (c_view->priv->view),
 					     _("Error Loading Comic"));
 		
-		if (c_view->priv->comic_loader->error) {
-			buoh_view_set_message_text (BUOH_VIEW (c_view->priv->view),
-						    c_view->priv->comic_loader->error->message);
-		} else {
-			buoh_view_set_message_text (BUOH_VIEW (c_view->priv->view),
-						    _("There has been an error when loading the comic. "
-						      "It use to be due to an error on the remote server. "
-						      "Please, try again later."));
-		}
+		buoh_view_set_message_text (BUOH_VIEW (c_view->priv->view),
+					    error->message);
+		g_error_free (error);
 		
 		buoh_view_set_message_icon (BUOH_VIEW (c_view->priv->view),
 					    GTK_STOCK_DIALOG_ERROR);
-
+		
 		g_object_set (G_OBJECT (c_view->priv->view),
 			      "status", STATE_MESSAGE_ERROR,
 			      NULL);
 
-		buoh_debug ("Monitor exit (failed)");
+		g_object_unref (c_view->priv->pixbuf_loader);
+		c_view->priv->pixbuf_loader = NULL;
+		
+		return;
+	}
 
-		height = 0;
+	pixbuf = gdk_pixbuf_loader_get_pixbuf (c_view->priv->pixbuf_loader);
+	if (pixbuf) {
+		buoh_view_comic_set_image_from_pixbuf (c_view, pixbuf);
 		
-		return FALSE;
-	default:
-		buoh_debug ("Monitor exit (unknown)");
+		if (c_view->priv->scale == 1.0) {
+			/* We have both the compressed and uncompressed image.
+			 * By setting the pixbuf to cache we avoid uncompressing
+			 * the image again and having a new pixbuf instead of a
+			 * reference.
+			 */
+			buoh_comic_set_pixbuf (c_view->priv->comic, pixbuf);
+		}
 
-		height = 0;
+		g_object_set (G_OBJECT (c_view->priv->view),
+			      "status", STATE_COMIC_LOADED,
+			      NULL);
+	}
+
+	if (c_view->priv->comic_data->len > 0) {
+		BuohComicImage *comic_image;
+
+		comic_image = g_new0 (BuohComicImage, 1);
+
+		comic_image->size = c_view->priv->comic_data->len;
+		comic_image->data = (guchar *) g_memdup (c_view->priv->comic_data->str,
+							 c_view->priv->comic_data->len);
 		
-		return FALSE;
+		buoh_comic_set_image (c_view->priv->comic, comic_image);
+
+		c_view->priv->comic_data->len = 0;
 	}
+	
+	g_object_unref (c_view->priv->pixbuf_loader);
+	c_view->priv->pixbuf_loader = NULL;
 }
 
-static void
-buoh_view_comic_load (BuohViewComic *c_view)
+static gboolean
+buoh_view_comic_set_image_from_loader (BuohViewComic *c_view)
 {
 	GdkPixbuf *pixbuf;
-	gchar     *uri;
+	
+	pixbuf = gdk_pixbuf_loader_get_pixbuf (c_view->priv->pixbuf_loader);
+	if (pixbuf)
+		buoh_view_comic_set_image_from_pixbuf (c_view, pixbuf);
+
+	return FALSE;
+}
 
-	if (c_view->priv->comic_loader->status == LOADER_STATE_RUNNING) {
-		buoh_debug ("Load already running");
-		buoh_comic_loader_stop (c_view->priv->comic_loader);
-		buoh_debug ("waiting thread");
-		buoh_comic_loader_wait (c_view->priv->comic_loader);
-		buoh_debug ("died");
+static void
+buoh_view_comic_load_cb (const gchar   *data,
+			 guint          len,
+			 BuohViewComic *c_view)
+{
+	static guint id = 0;
+	GError *error = NULL;
+
+	gdk_pixbuf_loader_write (c_view->priv->pixbuf_loader,
+				 (guchar *)data, len, &error);
+
+	if (error) {
+		g_warning (error->message);
+		g_error_free (error);
+		return;
 	}
 
+	c_view->priv->comic_data = g_string_append_len (c_view->priv->comic_data,
+							data, len);
+
+	if (id > 0)
+		g_source_remove (id);
+	id = g_idle_add ((GSourceFunc) buoh_view_comic_set_image_from_loader,
+			 (gpointer) c_view);
+}
+
+static void
+buoh_view_comic_load (BuohViewComic *c_view)
+{
+	GdkPixbuf *pixbuf;
+
 	pixbuf = buoh_comic_get_pixbuf (c_view->priv->comic);
 	if (pixbuf) {
 		buoh_view_comic_set_image_from_pixbuf (c_view, pixbuf);
@@ -598,21 +613,20 @@
 			      "status", STATE_COMIC_LOADED,
 			      NULL);
 	} else {
+		GdkCursor *cursor;
+		
 		g_object_set (G_OBJECT (c_view->priv->view),
 			      "status", STATE_COMIC_LOADING,
 			      NULL);
-		uri = buoh_comic_get_uri (c_view->priv->comic);
-		buoh_comic_loader_run (c_view->priv->comic_loader,
-				       uri,
-				       c_view->priv->scale);
-		g_free (uri);
-
-		if (c_view->priv->load_monitor > 0)
-			g_source_remove (c_view->priv->load_monitor);
-		c_view->priv->load_monitor =
-			g_timeout_add (60,
-				       (GSourceFunc)buoh_view_comic_load_monitor,
-				       (gpointer)c_view);
+
+		cursor = gdk_cursor_new (GDK_WATCH);
+		gdk_window_set_cursor (GTK_WIDGET (c_view)->window, cursor);
+		gdk_cursor_unref (cursor);
+		
+		buoh_comic_loader_load_comic (c_view->priv->comic_loader,
+					      c_view->priv->comic,
+					      (BuohComicLoaderLoadFunc) buoh_view_comic_load_cb,
+					      (gpointer) c_view);
 	}
 }
 
===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh-window.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- /cvsroot/buoh/buoh/src/buoh-window.c	2005/12/01 21:55:27	1.31
+++ /cvsroot/buoh/buoh/src/buoh-window.c	2006/09/24 18:31:42	1.32
@@ -495,42 +495,40 @@
 static void
 buoh_window_cmd_comic_remove (GtkAction *action, gpointer gdata)
 {
-	BuohWindow             *window = BUOH_WINDOW (gdata);
-	GtkTreeModel           *model = buoh_get_comics_model (BUOH);
-	GtkTreeIter             iter;
-	BuohComicManager       *cm;
-	BuohComicManager       *current_cm;
-	gchar                  *current_cm_id, *cm_id;
-	gboolean                valid;
+	BuohWindow       *window = BUOH_WINDOW (gdata);
+	GtkTreeModel     *model = buoh_get_comics_model (BUOH);
+	GtkTreeIter       iter;
+	BuohComicManager *cm;
+	BuohComicManager *current_cm;
+	const gchar      *current_cm_id;
+	const gchar      *cm_id;
+	gboolean          valid;
 
 	current_cm = buoh_comic_list_get_selected (window->priv->comic_list);
 
-	if (current_cm) {
-		current_cm_id = buoh_comic_manager_get_id (current_cm);
+	if (!current_cm)
+		return;
 
-		valid = gtk_tree_model_get_iter_first (model, &iter);
-
-		while (valid) {
-			gtk_tree_model_get (model, &iter,
-					    COMIC_LIST_COMIC_MANAGER, &cm,
+	current_cm_id = buoh_comic_manager_get_id (current_cm);
+	
+	valid = gtk_tree_model_get_iter_first (model, &iter);
+	
+	while (valid) {
+		gtk_tree_model_get (model, &iter,
+				    COMIC_LIST_COMIC_MANAGER, &cm,
+				    -1);
+		cm_id = buoh_comic_manager_get_id (cm);
+		g_object_unref (cm);
+		
+		if (g_ascii_strcasecmp (current_cm_id, cm_id) == 0) {
+			buoh_comic_list_clear_selection (window->priv->comic_list);
+			gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+					    COMIC_LIST_VISIBLE, FALSE,
 					    -1);
-			cm_id = buoh_comic_manager_get_id (cm);
-			g_object_unref (cm);
-
-			if (g_ascii_strcasecmp (current_cm_id, cm_id) == 0) {
-				buoh_comic_list_clear_selection (window->priv->comic_list);
-				gtk_list_store_set (GTK_LIST_STORE (model), &iter,
-						    COMIC_LIST_VISIBLE, FALSE,
-						    -1);
-				valid = FALSE;
-			} else {
-				valid = gtk_tree_model_iter_next (model, &iter);
-			}
-
-			g_free (cm_id);
+			valid = FALSE;
+		} else {
+			valid = gtk_tree_model_iter_next (model, &iter);
 		}
-
-		g_free (current_cm_id);
 	}
 }
 
@@ -620,10 +618,10 @@
 {
 	BuohWindow *window = BUOH_WINDOW (gdata);
 	BuohComic  *comic = buoh_view_get_comic (window->priv->view);
-	gchar      *uri;
 
 	if (comic) {
-		uri = buoh_comic_get_uri (comic);
+		const gchar *uri = buoh_comic_get_uri (comic);
+
 		buoh_debug ("Copy %s to clipboard", uri);
 
 		gtk_clipboard_set_text (gtk_clipboard_get (GDK_NONE), uri,
@@ -631,8 +629,6 @@
 
 		gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_PRIMARY), uri,
 					g_utf8_strlen (uri, -1));
-
-		g_free (uri);
 	}
 }
 
@@ -653,42 +649,35 @@
 	BuohComicManager *cm  = buoh_comic_list_get_selected (window->priv->comic_list);
 	BuohComicManager *cm2 = NULL;
 	GtkWidget        *dialog;
-	gchar            *id1, *id2;
+	const gchar      *id1, *id2;
 	GList            *l = NULL;
 
-	if (cm) {
-		id1 = buoh_comic_manager_get_id (cm);
+	if (!cm)
+		return;
+	
+	id1 = buoh_comic_manager_get_id (cm);
+	
+	for (l = window->priv->properties; l; l = g_list_next (l)) {
+		cm2 = buoh_properties_dialog_get_comic_manager (
+			BUOH_PROPERTIES_DIALOG (l->data));
+		id2 = buoh_comic_manager_get_id (cm2);
 		
-		for (l = window->priv->properties; l; l = g_list_next (l)) {
-			cm2 = buoh_properties_dialog_get_comic_manager (
-				BUOH_PROPERTIES_DIALOG (l->data));
-			id2 = buoh_comic_manager_get_id (cm2);
-			
-			if (g_ascii_strcasecmp (id1, id2) == 0) {
-				gtk_window_present (GTK_WINDOW (l->data));
-				
-				g_free (id1);
-				g_free (id2);
-				
-				return;
-			}
-			
-			g_free (id2);
+		if (g_ascii_strcasecmp (id1, id2) == 0) {
+			gtk_window_present (GTK_WINDOW (l->data));
+			return;
 		}
-
-		g_free (id1);
-
-		dialog = buoh_properties_dialog_new ();
-		buoh_properties_dialog_set_comic_manager (BUOH_PROPERTIES_DIALOG (dialog), cm);
-		g_signal_connect (G_OBJECT (dialog), "destroy",
-				  G_CALLBACK (buoh_window_properties_dialog_destroyed),
-				  (gpointer) window);
-		gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
-		
-		gtk_widget_show (dialog);
-
-		window->priv->properties = g_list_append (window->priv->properties, dialog);
 	}
+	
+	dialog = buoh_properties_dialog_new ();
+	buoh_properties_dialog_set_comic_manager (BUOH_PROPERTIES_DIALOG (dialog), cm);
+	g_signal_connect (G_OBJECT (dialog), "destroy",
+			  G_CALLBACK (buoh_window_properties_dialog_destroyed),
+			  (gpointer) window);
+	gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window));
+	
+	gtk_widget_show (dialog);
+	
+	window->priv->properties = g_list_append (window->priv->properties, dialog);
 }
 
 static void
@@ -850,15 +839,13 @@
 buoh_window_update_title (BuohWindow *window)
 {
 	BuohComicManager *cm;
-	gchar            *cm_title;
-	gchar            *title;
+	gchar            *title = NULL;
 
 	cm = buoh_comic_list_get_selected (window->priv->comic_list);
 
 	if (cm) {
-		cm_title = buoh_comic_manager_get_title (cm);
-		title = g_strdup_printf ("%s - Buoh", cm_title);
-		g_free (cm_title);
+		title = g_strdup_printf ("%s - Buoh",
+					 buoh_comic_manager_get_title (cm));
 	} else {
 		title = g_strdup_printf ("Buoh");
 	}
@@ -1002,7 +989,6 @@
 	BuohComic        *comic = NULL;
 	BuohComicManager *cm;
 	GtkStatusbar     *statusbar = GTK_STATUSBAR (window->priv->statusbar);
-	gchar            *id, *title;
 	gchar            *message = NULL;
 
 	cm = buoh_comic_list_get_selected (window->priv->comic_list);
@@ -1029,11 +1015,9 @@
 	case STATE_COMIC_LOADED:
 		comic = buoh_view_get_comic (view);
 
-		id = buoh_comic_get_id (comic);
-		title = buoh_comic_manager_get_title (cm);
-		message = g_strdup_printf ("%s - %s", title, id);
-		g_free (id);
-		g_free (title);
+		message = g_strdup_printf ("%s - %s",
+					   buoh_comic_manager_get_title (cm),
+					   buoh_comic_get_id (comic));
 		
 		buoh_window_comic_actions_set_sensitive (window,
 							 (comic) ? TRUE : FALSE);
===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- /cvsroot/buoh/buoh/src/buoh.c	2005/12/16 14:11:13	1.29
+++ /cvsroot/buoh/buoh/src/buoh.c	2006/09/24 18:31:42	1.30
@@ -34,6 +34,7 @@
 #include <libxml/tree.h>
 #include <libxml/encoding.h>
 #include <libxml/xmlwriter.h>
+#include <gconf/gconf-client.h>
 
 #include "buoh.h"
 #include "buoh-window.h"
@@ -45,11 +46,22 @@
 	BuohWindow   *window;
 	GtkTreeModel *comic_list;
 	gchar        *datadir;
+	gchar        *proxy_uri;
+
+	GConfClient  *gconf_client;
 };
 
 #define BUOH_GET_PRIVATE(object) \
         (G_TYPE_INSTANCE_GET_PRIVATE ((object), BUOH_TYPE_BUOH, BuohPrivate))
 
+#define GCONF_HTTP_PROXY_DIR "/system/http_proxy"
+#define GCONF_USE_HTTP_PROXY "/system/http_proxy/use_http_proxy"
+#define GCONF_HTTP_PROXY_HOST "/system/http_proxy/host"
+#define GCONF_HTTP_PROXY_PORT "/system/http_proxy/port"
+#define GCONF_HTTP_PROXY_USE_AUTHENTICATION "/system/http_proxy/use_authentication"
+#define GCONF_HTTP_PROXY_AUTHENTICATION_USER "/system/http_proxy/authentication_user"
+#define GCONF_HTTP_PROXY_AUTHENTICATION_PASSWORD "/system/http_proxy/authentication_password"
+
 static GObjectClass *parent_class = NULL;
 
 static void          buoh_init                   (Buoh         *buoh);
@@ -308,7 +320,6 @@
 	GtkTreeIter       iter;
 	gboolean          valid;
 	BuohComicManager *comic_manager;
-	gchar            *id;
 	
 	buoh_debug ("Buoh comic model changed");
 
@@ -326,6 +337,8 @@
 
 	valid = gtk_tree_model_get_iter_first (filter, &iter);
 	while (valid) {
+		const gchar *id;
+		
 		gtk_tree_model_get (filter, &iter,
 				    COMIC_LIST_COMIC_MANAGER,
 				    &comic_manager, -1);
@@ -338,8 +351,6 @@
 					     BAD_CAST id);
 		xmlTextWriterEndElement (writer);
 		
-		g_free (id);
-
 		valid = gtk_tree_model_iter_next (filter, &iter);
 	}
 
@@ -424,6 +435,65 @@
 	g_free (cache_dir);
 }
 
+static gchar *
+buoh_get_http_proxy_uri_from_gconf (Buoh *buoh)
+{
+	GConfClient *gconf_client = buoh->priv->gconf_client;
+	gchar       *uri = NULL;
+
+	if (gconf_client_get_bool (gconf_client, GCONF_USE_HTTP_PROXY, NULL)) {
+		gchar *host = NULL;
+		gchar *port = NULL;
+		gchar *user = NULL;
+		gchar *pass = NULL;
+		guint  p = 0;
+			
+		host = gconf_client_get_string (gconf_client,
+						GCONF_HTTP_PROXY_HOST,
+						NULL);
+		p = gconf_client_get_int (gconf_client,
+					  GCONF_HTTP_PROXY_PORT,
+					  NULL);
+		if (p > 0)
+			port = g_strdup_printf ("%d", p);
+		
+		if (gconf_client_get_bool (gconf_client, GCONF_HTTP_PROXY_USE_AUTHENTICATION, NULL)) {
+			user = gconf_client_get_string (gconf_client,
+							GCONF_HTTP_PROXY_AUTHENTICATION_USER,
+							NULL);
+			pass = gconf_client_get_string (gconf_client,
+							GCONF_HTTP_PROXY_AUTHENTICATION_PASSWORD,
+							NULL);
+
+		}
+
+		/* http://user:pass host:port */
+		uri = g_strdup_printf ("http://%s%s%s%s%s%s%s";,
+				       (user) ? user : "",
+				       (user && pass) ? ":" : "",
+				       (user && pass) ? pass : "",
+				       (user) ? "@" : "",
+				       host,
+				       (port) ? ":" :  "",
+				       (port) ? port : "");
+	}
+
+	return uri;
+}
+
+static void
+buoh_update_http_proxy (GConfClient *gconf_client,
+			guint        cnxn_id,
+			GConfEntry  *entry,
+			Buoh        *buoh)
+{
+	buoh_debug ("Proxy configuration changed");
+
+	if (buoh->priv->proxy_uri)
+		g_free (buoh->priv->proxy_uri);
+	buoh->priv->proxy_uri = buoh_get_http_proxy_uri_from_gconf (buoh);
+}
+
 static void
 buoh_init (Buoh *buoh)
 {
@@ -438,6 +508,17 @@
 	g_signal_connect (G_OBJECT (buoh->priv->comic_list), "row-changed",
 			  G_CALLBACK (buoh_save_comic_list),
 			  (gpointer) buoh);
+
+	buoh->priv->gconf_client = gconf_client_get_default ();
+	gconf_client_add_dir (buoh->priv->gconf_client,
+			      GCONF_HTTP_PROXY_DIR,
+			      GCONF_CLIENT_PRELOAD_NONE,
+			      NULL);
+	gconf_client_notify_add (buoh->priv->gconf_client,
+				 GCONF_HTTP_PROXY_DIR,
+				 (GConfClientNotifyFunc)buoh_update_http_proxy,
+				 (gpointer) buoh,
+				 NULL, NULL);
 }
 
 static void
@@ -470,6 +551,11 @@
 		buoh->priv->comic_list = NULL;
 	}
 
+	if (buoh->priv->proxy_uri) {
+		g_free (buoh->priv->proxy_uri);
+		buoh->priv->proxy_uri = NULL;
+	}
+
 	if (G_OBJECT_CLASS (parent_class)->finalize)
 		(* G_OBJECT_CLASS (parent_class)->finalize) (object);
 }
@@ -531,3 +617,11 @@
 	
 	return buoh->priv->datadir;
 }
+
+const gchar *
+buoh_get_http_proxy_uri (Buoh *buoh)
+{
+	g_return_val_if_fail (BUOH_IS_BUOH (buoh), NULL);
+
+	return buoh->priv->proxy_uri;
+}
===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- /cvsroot/buoh/buoh/src/buoh.h	2005/11/16 20:29:28	1.8
+++ /cvsroot/buoh/buoh/src/buoh.h	2006/09/24 18:31:42	1.9
@@ -64,6 +64,7 @@
 void          buoh_create_main_window (Buoh        *buoh);
 GtkTreeModel *buoh_get_comics_model   (Buoh        *buoh);
 const gchar  *buoh_get_datadir        (Buoh        *buoh);
+const gchar  *buoh_get_http_proxy_uri (Buoh        *buoh);
 
 void          buoh_debug              (const gchar *format,
 				       ...);


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