[Buoh-dev] CVS commit to /cvsroot/buoh/buoh/src by carlosgc
- From: noreply at forge.novell.com (noreply forge novell com)
- Subject: [Buoh-dev] CVS commit to /cvsroot/buoh/buoh/src by carlosgc
- Date: Tue Aug 15 09:42:53 2006
CVS commit to /cvsroot/buoh/buoh/src by carlosgc
Modified Files:
Makefile.am buoh-comic-list.c buoh-comic-loader.c buoh-comic.c
buoh-properties-dialog.c buoh-view-comic.c buoh-window.c
buoh.c buoh.h
Added Files:
buoh-comic-cache.c buoh-comic-cache.h
Log Message:
2005-11-15 Carlos Garcia Campos <carlosgc gnome org>
* src/Makefile.am: Add cache files
* src/buoh-comic-cache.[ch]:
* src/buoh-comic.c: Cache use for pixbuf property
* src/buoh.c: Create cache dir on startup if not exists
Cache system to reduce and limit the buoh memory usage.
* src/buoh-comic-list.c:
* src/buoh-comic-loader.c:
* src/buoh-properties-dialog.c:
* src/buoh-view-comic.c:
* src/buoh-window.c:
* src/buoh.c:
Many leaks fixed
===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh-comic-cache.c,v
rcsdiff: /cvsroot/buoh/buoh/src/buoh-comic-cache.c,v: Symbolic name `NONE' is undefined.
===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh-comic-cache.h,v
rcsdiff: /cvsroot/buoh/buoh/src/buoh-comic-cache.h,v: Symbolic name `NONE' is undefined.
===================================================================
RCS file: /cvsroot/buoh/buoh/src/Makefile.am,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- /cvsroot/buoh/buoh/src/Makefile.am 2005/09/13 12:18:57 1.11
+++ /cvsroot/buoh/buoh/src/Makefile.am 2005/11/15 13:02:12 1.12
@@ -18,21 +18,9 @@
buoh-add-comic-dialog.h buoh-add-comic-dialog.c \
buoh-comic-manager-date.h buoh-comic-manager-date.c \
buoh-comic-manager.h buoh-comic-manager.c \
+ buoh-comic-cache.h buoh-comic-cache.c \
buoh.h buoh.c \
main.c
buoh_LDADD = $(BUOH_LIBS)
-#EXTRA_DIST = buoh.desktop.in
-
-#DISTCLEANFILES = \
-# buoh.desktop \
-# *.bak
-
-#Applicationsdir = $(datadir)/applications
-#Applications_in_files = buoh.desktop.in
-#Applications_DATA = $(Applications_in_files:.desktop.in=.desktop)
-# INTLTOOL_DESKTOP_RULE@
-
-#install-data-local:
-# @$(NORMAL_INSTALL)
===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh-comic-list.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- /cvsroot/buoh/buoh/src/buoh-comic-list.c 2005/09/30 16:13:46 1.11
+++ /cvsroot/buoh/buoh/src/buoh-comic-list.c 2005/11/15 13:02:12 1.12
@@ -95,7 +95,8 @@
comic_list->priv->comic_manager = BUOH_COMIC_MANAGER (comic_manager);
comic = buoh_comic_manager_get_current (comic_list->priv->comic_manager);
-
+ g_object_unref (comic_manager);
+
buoh_view_set_comic (comic_list->priv->view, comic);
buoh_debug ("selection changed: set comic");
} else {
===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh-comic-loader.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- /cvsroot/buoh/buoh/src/buoh-comic-loader.c 2005/09/21 12:15:00 1.9
+++ /cvsroot/buoh/buoh/src/buoh-comic-loader.c 2005/11/15 13:02:12 1.10
@@ -288,7 +288,7 @@
g_mutex_lock (loader->pixbuf_mutex);
pixbuf = gdk_pixbuf_loader_get_pixbuf (pixbuf_loader);
- loader->pixbuf = GDK_IS_PIXBUF (pixbuf) ? g_object_ref (pixbuf) : NULL;
+ loader->pixbuf = pixbuf;
g_mutex_unlock (loader->pixbuf_mutex);
}
@@ -365,7 +365,7 @@
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->pixbuf = GDK_IS_PIXBUF (pixbuf) ? g_object_ref (pixbuf) : NULL;
g_mutex_unlock (loader->pixbuf_mutex);
g_object_unref (loader->priv->pixbuf_loader);
===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh-comic.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- /cvsroot/buoh/buoh/src/buoh-comic.c 2005/11/08 00:42:57 1.8
+++ /cvsroot/buoh/buoh/src/buoh-comic.c 2005/11/15 13:02:12 1.9
@@ -24,7 +24,9 @@
#include <glib.h>
#include <glib/gi18n.h>
+#include "buoh.h"
#include "buoh-comic.h"
+#include "buoh-comic-cache.h"
enum {
PROP_0,
@@ -35,10 +37,11 @@
};
struct _BuohComicPrivate {
- gchar *id;
- gchar *uri;
- GdkPixbuf *pixbuf;
- GDate *date;
+ gchar *id;
+ gchar *uri;
+ GDate *date;
+
+ BuohComicCache *cache;
};
#define BUOH_COMIC_GET_PRIVATE(object) \
@@ -91,8 +94,9 @@
buoh_comic->priv->id = NULL;
buoh_comic->priv->uri = NULL;
- buoh_comic->priv->pixbuf = NULL;
buoh_comic->priv->date = NULL;
+
+ buoh_comic->priv->cache = buoh_comic_cache_new ();
}
static void
@@ -123,11 +127,10 @@
G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_PIXBUF,
- g_param_spec_object ("pixbuf",
- "Pixbuf",
- "Pixbuf of the comic",
- GDK_TYPE_PIXBUF,
- G_PARAM_READWRITE));
+ g_param_spec_pointer ("pixbuf",
+ "Pixbuf",
+ "Pixbuf of the comic",
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_DATE,
g_param_spec_pointer ("date",
@@ -145,20 +148,22 @@
g_return_if_fail (BUOH_IS_COMIC (comic));
+ buoh_debug ("buoh-comic-finalize");
+
if (comic->priv->id) {
g_free (comic->priv->id);
comic->priv->id = NULL;
}
- if (comic->priv->pixbuf) {
- g_object_unref (comic->priv->pixbuf);
- comic->priv->pixbuf = NULL;
- }
-
if (comic->priv->date) {
g_date_free (comic->priv->date);
comic->priv->date = NULL;
}
+
+ if (comic->priv->cache) {
+ g_object_unref (comic->priv->cache);
+ comic->priv->cache = NULL;
+ }
if (G_OBJECT_CLASS (parent_class)->finalize)
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
@@ -209,12 +214,13 @@
comic->priv->uri = g_value_dup_string (value);
break;
- case PROP_PIXBUF:
- if (comic->priv->pixbuf) {
- g_object_unref (comic->priv->pixbuf);
- }
- comic->priv->pixbuf = GDK_PIXBUF (g_value_dup_object (value));
-
+ case PROP_PIXBUF: {
+ GdkPixbuf *pixbuf;
+
+ pixbuf = GDK_PIXBUF (g_value_get_pointer (value));
+ buoh_comic_cache_set_pixbuf (comic->priv->cache,
+ comic->priv->uri, pixbuf);
+ }
break;
case PROP_DATE:
if (comic->priv->date) {
@@ -248,9 +254,13 @@
g_value_set_string (value, comic->priv->uri);
break;
- case PROP_PIXBUF:
- g_value_set_object (value, comic->priv->pixbuf);
-
+ case PROP_PIXBUF: {
+ GdkPixbuf *pixbuf;
+
+ pixbuf = buoh_comic_cache_get_pixbuf (comic->priv->cache,
+ comic->priv->uri);
+ g_value_set_pointer (value, pixbuf);
+ }
break;
case PROP_DATE:
g_value_set_pointer (value, comic->priv->date);
@@ -294,10 +304,7 @@
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
- if (pixbuf) {
- buoh_comic_set_pixbuf (comic, pixbuf);
- g_object_unref (pixbuf);
- }
+ buoh_comic_set_pixbuf (comic, pixbuf);
}
gchar *
@@ -356,7 +363,7 @@
gint c_width, c_height;
gint d_width, d_height;
- pixbuf = comic->priv->pixbuf;
+ g_object_get (G_OBJECT (comic), "pixbuf", &pixbuf, NULL);
if (pixbuf) {
c_width = gdk_pixbuf_get_width (pixbuf);
===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh-properties-dialog.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- /cvsroot/buoh/buoh/src/buoh-properties-dialog.c 2005/11/08 00:42:57 1.14
+++ /cvsroot/buoh/buoh/src/buoh-properties-dialog.c 2005/11/15 13:02:12 1.15
@@ -98,7 +98,7 @@
void
buoh_properties_dialog_set_comic_manager (BuohPropertiesDialog *dialog,
- BuohComicManager *comic_manager)
+ BuohComicManager *comic_manager)
{
GtkWidget *table;
GtkWidget *label_title, *label_title_val;
@@ -125,6 +125,7 @@
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,
@@ -132,7 +133,6 @@
"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);
@@ -266,7 +266,7 @@
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
table, TRUE, TRUE, 0);
- gtk_widget_show (table);
+ gtk_widget_show (table);
}
BuohComicManager *
===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh-view-comic.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- /cvsroot/buoh/buoh/src/buoh-view-comic.c 2005/09/30 16:13:46 1.11
+++ /cvsroot/buoh/buoh/src/buoh-view-comic.c 2005/11/15 13:02:12 1.12
@@ -179,11 +179,10 @@
/* Properties */
g_object_class_install_property (object_class,
PROP_COMIC,
- g_param_spec_object ("comic",
- "Comic",
- "The current comic",
- BUOH_TYPE_COMIC,
- G_PARAM_READWRITE));
+ g_param_spec_pointer ("comic",
+ "Comic",
+ "The current comic",
+ G_PARAM_READWRITE));
g_object_class_install_property (object_class,
PROP_SCALE,
g_param_spec_double ("scale",
@@ -211,11 +210,6 @@
c_view->priv->load_monitor = 0;
}
- if (c_view->priv->comic) {
- g_object_unref (c_view->priv->comic);
- c_view->priv->comic = NULL;
- }
-
if (c_view->priv->comic_loader) {
g_object_unref (c_view->priv->comic_loader);
c_view->priv->comic_loader = NULL;
@@ -235,11 +229,7 @@
switch (prop_id) {
case PROP_COMIC:
- if (c_view->priv->comic) {
- g_object_unref (c_view->priv->comic);
- }
-
- c_view->priv->comic = BUOH_COMIC (g_value_dup_object (value));
+ c_view->priv->comic = BUOH_COMIC (g_value_get_pointer (value));
break;
case PROP_SCALE:
@@ -261,7 +251,7 @@
switch (prop_id) {
case PROP_COMIC:
- g_value_set_object (value, c_view->priv->comic);
+ g_value_set_pointer (value, c_view->priv->comic);
break;
case PROP_SCALE:
@@ -414,7 +404,7 @@
gtk_adjustment_set_value (hadjustment, 0.0);
gtk_adjustment_set_value (vadjustment, 0.0);
-
+
gtk_image_clear (GTK_IMAGE (c_view->priv->image));
}
@@ -424,7 +414,7 @@
BuohViewComic *c_view = BUOH_VIEW_COMIC (object);
buoh_view_comic_prepare_load (c_view);
-
+
buoh_view_comic_load (c_view);
}
@@ -458,7 +448,6 @@
GDK_INTERP_BILINEAR);
gtk_image_set_from_pixbuf (GTK_IMAGE (c_view->priv->image), new_pixbuf);
-
g_object_unref (new_pixbuf);
} else {
gtk_image_set_from_pixbuf (GTK_IMAGE (c_view->priv->image), pixbuf);
@@ -472,7 +461,7 @@
{
BuohViewComic *c_view = BUOH_VIEW_COMIC (gdata);
static GdkCursor *cursor = NULL;
- static GdkPixbuf *pixbuf = NULL;
+ static gint height = 0;
switch (c_view->priv->comic_loader->status) {
case LOADER_STATE_READY:
@@ -487,14 +476,15 @@
}
if (GDK_IS_PIXBUF (c_view->priv->comic_loader->pixbuf)) {
- if (c_view->priv->comic_loader->pixbuf != 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);
buoh_view_comic_set_image_from_pixbuf (
c_view,
c_view->priv->comic_loader->pixbuf);
- g_object_unref (c_view->priv->comic_loader->pixbuf);
- pixbuf = c_view->priv->comic_loader->pixbuf;
g_mutex_unlock (c_view->priv->comic_loader->pixbuf_mutex);
+ height = new_height;
}
}
@@ -522,6 +512,8 @@
buoh_debug ("Monitor exit (stopping/finished)");
+ height = 0;
+
return FALSE;
case LOADER_STATE_FAILED:
if (cursor) {
@@ -552,10 +544,14 @@
buoh_debug ("Monitor exit (failed)");
+ height = 0;
+
return FALSE;
default:
buoh_debug ("Monitor exit (unknown)");
+ height = 0;
+
return FALSE;
}
}
@@ -577,7 +573,6 @@
pixbuf = buoh_comic_get_pixbuf (c_view->priv->comic);
if (pixbuf) {
buoh_view_comic_set_image_from_pixbuf (c_view, pixbuf);
- g_object_unref (pixbuf);
g_object_set (G_OBJECT (c_view->priv->view),
"status", STATE_COMIC_LOADED,
NULL);
@@ -619,7 +614,6 @@
pixbuf = buoh_comic_get_pixbuf (c_view->priv->comic);
if (pixbuf) {
buoh_view_comic_set_image_from_pixbuf (c_view, pixbuf);
- g_object_unref (pixbuf);
}
}
===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh-window.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- /cvsroot/buoh/buoh/src/buoh-window.c 2005/11/08 00:42:57 1.27
+++ /cvsroot/buoh/buoh/src/buoh-window.c 2005/11/15 13:02:12 1.28
@@ -518,6 +518,7 @@
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);
@@ -653,6 +654,8 @@
{
BuohWindow *window = BUOH_WINDOW (gdata);
+ buoh_debug ("porperties-dialog destroyed");
+
window->priv->properties = g_list_remove (window->priv->properties, dialog);
}
===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- /cvsroot/buoh/buoh/src/buoh.c 2005/09/30 09:17:33 1.23
+++ /cvsroot/buoh/buoh/src/buoh.c 2005/11/15 13:02:12 1.24
@@ -185,7 +185,7 @@
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
- G_TYPE_POINTER,
+ G_TYPE_OBJECT,
-1);
node = root->xmlChildrenNode;
@@ -257,7 +257,7 @@
g_free (language);
g_free (uri);
g_free (class);
-
+ g_object_unref (comic_manager);
}
node = node->next;
@@ -320,6 +320,7 @@
COMIC_LIST_COMIC_MANAGER,
&comic_manager, -1);
id = buoh_comic_manager_get_id (comic_manager);
+ g_object_unref (comic_manager);
xmlTextWriterStartElement (writer, BAD_CAST "comic");
xmlTextWriterWriteAttribute (writer,
@@ -343,6 +344,7 @@
buoh_create_user_dir (Buoh *buoh)
{
gchar *filename;
+ gchar *cache_dir;
const gchar *contents = "<?xml version=\"1.0\"?>\n<comic_list>\n</comic_list>\n";
if (!g_file_test (buoh->priv->datadir, G_FILE_TEST_IS_DIR)) {
@@ -353,7 +355,7 @@
}
filename = g_build_filename (buoh->priv->datadir, "comics.xml", NULL);
-
+
if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {
buoh_debug ("User comics file doesn't exist, creating it ...");
if (!g_file_set_contents (filename, contents, -1, NULL)) {
@@ -361,8 +363,19 @@
g_error ("Cannot create user's comics list file");
}
}
-
+
g_free (filename);
+
+ cache_dir = g_build_filename (buoh->priv->datadir, "cache", NULL);
+
+ if (!g_file_test (cache_dir, G_FILE_TEST_IS_DIR)) {
+ buoh_debug ("Cache directory doesn't exist, creating it ...");
+ if (g_mkdir (cache_dir, 0755) != 0) {
+ g_error ("Cannot create cache directory");
+ }
+ }
+
+ g_free (cache_dir);
}
static void
@@ -461,3 +474,8 @@
return buoh->priv->comic_list;
}
+const gchar *
+buoh_get_datadir (Buoh *buoh)
+{
+ return buoh->priv->datadir;
+}
===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- /cvsroot/buoh/buoh/src/buoh.h 2005/09/13 12:18:57 1.6
+++ /cvsroot/buoh/buoh/src/buoh.h 2005/11/15 13:02:12 1.7
@@ -63,6 +63,7 @@
void buoh_create_main_window (Buoh *buoh);
GtkTreeModel *buoh_get_comics_model (Buoh *buoh);
+const gchar *buoh_get_datadir (Buoh *buoh);
void buoh_debug (const gchar *format,
...);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]