svnno****@sourc*****
svnno****@sourc*****
Fri Apr 13 14:37:11 JST 2007
Revision: 3172 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=3172 Author: kous Date: 2007-04-13 14:37:11 +0900 (Fri, 13 Apr 2007) Log Message: ----------- fixed a crash bug on creating thumbnail with Gecko 1.7.x(?). * ext/ruby/kz-rb-embed.c (rb_kz_embed_create_thumbnail): followed kz_embed_create_thumbnail() API change. * src/sidebar/Makefile.am, src/prefs_ui/Makefile.am (INCLUDES): added -I$(top_srcdir)/src/libegg/pixbufthumbnail. * src/utils/utils.[ch]: removed kz-mozthumbnailcreator related codes. (thumbnail_get_last_modified): added thumbnail size. * src/kz-embed.[ch] (kz_embed_create_thumbnail): added thumbnail size. * src/kz-tab-label.c: created thumbnail when the tab is visited at first time. * module/embed/gecko/kz-mozthumbnailcreator.{cpp,h}, module/embed/gecko/kz-mozthumbnailprogress.{cpp,h}: removed. * module/embed/gecko/Makefile.am, module/embed/gecko/kz-gecko-embed.cpp: removed kz-mozthumbrailcreator related codes. * module/embed/gecko/kz-mozwrapper.{cpp,h}, module/embed/gecko/MozillaPrivate.{cpp,h}: passed URI and thumbnail size. Modified Paths: -------------- kazehakase/trunk/ChangeLog kazehakase/trunk/ext/ruby/kz-rb-embed.c kazehakase/trunk/module/embed/gecko/Makefile.am kazehakase/trunk/module/embed/gecko/MozillaPrivate.cpp kazehakase/trunk/module/embed/gecko/MozillaPrivate.h kazehakase/trunk/module/embed/gecko/kz-gecko-embed.cpp kazehakase/trunk/module/embed/gecko/kz-mozwrapper.cpp kazehakase/trunk/module/embed/gecko/kz-mozwrapper.h kazehakase/trunk/src/kz-embed.c kazehakase/trunk/src/kz-embed.h kazehakase/trunk/src/kz-notebook.c kazehakase/trunk/src/kz-tab-label.c kazehakase/trunk/src/prefs_ui/Makefile.am kazehakase/trunk/src/sidebar/Makefile.am kazehakase/trunk/src/utils/utils.c kazehakase/trunk/src/utils/utils.h Removed Paths: ------------- kazehakase/trunk/module/embed/gecko/kz-mozthumbnailcreator.cpp kazehakase/trunk/module/embed/gecko/kz-mozthumbnailcreator.h kazehakase/trunk/module/embed/gecko/kz-mozthumbnailprogress.cpp kazehakase/trunk/module/embed/gecko/kz-mozthumbnailprogress.h Modified: kazehakase/trunk/ChangeLog =================================================================== --- kazehakase/trunk/ChangeLog 2007-04-13 05:31:41 UTC (rev 3171) +++ kazehakase/trunk/ChangeLog 2007-04-13 05:37:11 UTC (rev 3172) @@ -1,3 +1,31 @@ +2007-04-13 Kouhei Sutou <kou****@cozmi*****> + + * ext/ruby/kz-rb-embed.c (rb_kz_embed_create_thumbnail): followed + kz_embed_create_thumbnail() API change. + + * src/sidebar/Makefile.am, src/prefs_ui/Makefile.am + (INCLUDES): added -I$(top_srcdir)/src/libegg/pixbufthumbnail. + + * src/utils/utils.[ch]: removed kz-mozthumbnailcreator related + codes. + (thumbnail_get_last_modified): added thumbnail size. + + * src/kz-embed.[ch] (kz_embed_create_thumbnail): added thumbnail size. + + * src/kz-tab-label.c: created thumbnail when the tab is visited at + first time. + + * module/embed/gecko/kz-mozthumbnailcreator.{cpp,h}, + module/embed/gecko/kz-mozthumbnailprogress.{cpp,h}: removed. + + * module/embed/gecko/Makefile.am, + module/embed/gecko/kz-gecko-embed.cpp: removed + kz-mozthumbrailcreator related codes. + + * module/embed/gecko/kz-mozwrapper.{cpp,h}, + module/embed/gecko/MozillaPrivate.{cpp,h}: passed URI and + thumbnail size. + 2007-04-13 Hiroyuki Ikezoe <poinc****@ikezo*****> * module/embed/gtk-webcore/kz-gtk-webcore.cpp: Set pluginsEnabled Modified: kazehakase/trunk/ext/ruby/kz-rb-embed.c =================================================================== --- kazehakase/trunk/ext/ruby/kz-rb-embed.c 2007-04-13 05:31:41 UTC (rev 3171) +++ kazehakase/trunk/ext/ruby/kz-rb-embed.c 2007-04-13 05:37:11 UTC (rev 3172) @@ -485,9 +485,17 @@ } static VALUE -rb_kz_embed_create_thumbnail(VALUE self) +rb_kz_embed_create_thumbnail(int argc, VALUE *argv, VALUE self) { - kz_embed_create_thumbnail(_SELF(self)); + EggPixbufThumbSize size; + VALUE rb_size; + + rb_scan_args(argc, argv, "01", &rb_size); + if (NIL_P(rb_size)) + size = EGG_PIXBUF_THUMB_LARGE; + else + size = NUM2INT(rb_size); /* FIXME */ + kz_embed_create_thumbnail(_SELF(self), size); return self; } @@ -723,7 +731,7 @@ rb_define_method(cKzEmbed, "get_printer_list", rb_kz_embed_get_printer_list, 0); rb_define_method(cKzEmbed, "create_thumbnail", - rb_kz_embed_create_thumbnail, 0); + rb_kz_embed_create_thumbnail, -1); rb_define_method(cKzEmbed, "save_with_content", rb_kz_embed_save_with_content, 1); rb_define_method(cKzEmbed, "zoom_set", rb_kz_embed_zoom_set, 2); Modified: kazehakase/trunk/module/embed/gecko/Makefile.am =================================================================== --- kazehakase/trunk/module/embed/gecko/Makefile.am 2007-04-13 05:31:41 UTC (rev 3171) +++ kazehakase/trunk/module/embed/gecko/Makefile.am 2007-04-13 05:37:11 UTC (rev 3172) @@ -84,12 +84,6 @@ $(PROFILEDIRSERVICE_SOURCES) endif -if MOZ_NO_NSICANVASRENDERINGCONTEXTINTERNAL_HAVE_GETINPUTSTREAM_ -LIBGSTHUMBNAIL_SOURCES= \ - kz-mozthumbnailcreator.cpp kz-mozthumbnailcreator.h \ - kz-mozthumbnailprogress.cpp kz-mozthumbnailprogress.h -endif - gecko_la_SOURCES = \ kz-gecko-embed-module.cpp \ kz-gecko-embed.cpp kz-gecko-embed.h \ @@ -109,7 +103,6 @@ kz-mozwrapper.cpp kz-mozwrapper.h \ kz-mozhistorysearch.cpp kz-mozhistorysearch.h \ $(LIBGTKMOZEMBED_SOURCES) \ - $(LIBGSTHUMBNAIL_SOURCES) \ MozillaPrivate.cpp MozillaPrivate.h gecko_la_LIBADD = \ Modified: kazehakase/trunk/module/embed/gecko/MozillaPrivate.cpp =================================================================== --- kazehakase/trunk/module/embed/gecko/MozillaPrivate.cpp 2007-04-13 05:31:41 UTC (rev 3171) +++ kazehakase/trunk/module/embed/gecko/MozillaPrivate.cpp 2007-04-13 05:37:11 UTC (rev 3172) @@ -323,7 +323,8 @@ #define KZ_CANVAS_WIDTH 1024 #define KZ_CANVAS_HEIGHT 800 gboolean -MozillaPrivate::CreateThumbnail(nsIDOMWindow *domWindow, const gchar *uri) +MozillaPrivate::CreateThumbnail(nsIDOMWindow *domWindow, const gchar *uri, + EggPixbufThumbSize size) { nsresult rv; nsCOMPtr<nsIDOMDocument> domDoc; @@ -336,14 +337,14 @@ if (NS_FAILED(rv) || !context) return FALSE; - context->SetDimensions(EGG_PIXBUF_THUMB_LARGE, KZ_THUMB_HEIGHT); + context->SetDimensions(size, KZ_THUMB_HEIGHT); context->SetCanvasElement(nsnull); nsCOMPtr<nsIDOMCanvasRenderingContext2D> domCanvas = do_QueryInterface(context, &rv); if (NS_FAILED(rv) || !domCanvas) return FALSE; float sx, sy; - sx = (float) EGG_PIXBUF_THUMB_LARGE / KZ_CANVAS_WIDTH; + sx = (float) size / KZ_CANVAS_WIDTH; sy = (float) KZ_THUMB_HEIGHT / KZ_CANVAS_HEIGHT; domCanvas->Scale(sx, sy); @@ -398,7 +399,7 @@ egg_pixbuf_add_thumbnail_data(thumbnail, uri, now.tv_sec, - EGG_PIXBUF_THUMB_LARGE); + size); egg_pixbuf_save_thumbnail(thumbnail, NULL, NULL); g_object_unref(thumbnail); Modified: kazehakase/trunk/module/embed/gecko/MozillaPrivate.h =================================================================== --- kazehakase/trunk/module/embed/gecko/MozillaPrivate.h 2007-04-13 05:31:41 UTC (rev 3171) +++ kazehakase/trunk/module/embed/gecko/MozillaPrivate.h 2007-04-13 05:37:11 UTC (rev 3172) @@ -52,7 +52,9 @@ gchar *GetURIForDOMWindow (nsIDOMWindow *aDOMWindow); const char *Unescape (const char *text); #ifdef MOZ_NSICANVASRENDERINGCONTEXTINTERNAL_HAVE_GETINPUTSTREAM_ - gboolean CreateThumbnail (nsIDOMWindow *domWindow, const gchar *uri); + gboolean CreateThumbnail (nsIDOMWindow *domWindow, + const gchar *uri, + EggPixbufThumbSize size); #endif } #endif /* __MOZILLA_PRIVATE_H__ */ Modified: kazehakase/trunk/module/embed/gecko/kz-gecko-embed.cpp =================================================================== --- kazehakase/trunk/module/embed/gecko/kz-gecko-embed.cpp 2007-04-13 05:31:41 UTC (rev 3171) +++ kazehakase/trunk/module/embed/gecko/kz-gecko-embed.cpp 2007-04-13 05:37:11 UTC (rev 3172) @@ -36,7 +36,6 @@ #include "kz-window.h" #include "kz-mozwrapper.h" #include "kz-mozprogresslistener.h" -#include "kz-mozthumbnailcreator.h" #include "kz-mozutils.h" #include "mozilla.h" #include "mozilla-prefs.h" @@ -308,7 +307,8 @@ static void kz_gecko_embed_print (KzEmbed *kzembed); static void kz_gecko_embed_print_preview (KzEmbed *kzembed); static GList *kz_gecko_embed_get_printer_list (KzEmbed *kzembed); -static void kz_gecko_embed_create_thumbnail (KzEmbed *kzembed); +static void kz_gecko_embed_create_thumbnail (KzEmbed *kzembed, + EggPixbufThumbSize size); static gboolean kz_gecko_embed_save_with_content (KzEmbed *kzembed, @@ -1069,8 +1069,7 @@ if (!priv->wrapper) return; - gboolean create_thumbnail = FALSE, store_cache = TRUE; - KZ_CONF_GET("Global", "create_thumbnail", create_thumbnail, BOOL); + gboolean store_cache = TRUE; KZ_CONF_GET("History", "store_cache", store_cache, BOOL); gchar *cache = g_strconcat("file://", KZ_GET_HISTORY_DIR, NULL); @@ -1105,12 +1104,6 @@ const gchar *uri = sURI.get(); rv = NewURI(getter_AddRefs(inURI), uri); - if (create_thumbnail && - (!last_modified || (thumbnail_get_last_modified(uri) < last_modified))) - { - kz_gecko_embed_create_thumbnail(KZ_EMBED(kzembed)); - } - if ((!last_modified || (history_get_last_modified(uri) < last_modified)) && !g_str_has_prefix(location, "history-search:")) { @@ -2915,65 +2908,70 @@ } -#ifndef MOZ_NSICANVASRENDERINGCONTEXTINTERNAL_HAVE_GETINPUTSTREAM_ -static KzMozThumbnailCreator * -kz_window_create_thumbnail_creator (KzWindow *kz) +static void +kz_gecko_embed_create_thumbnail (KzEmbed *kzembed, EggPixbufThumbSize size) { - KzMozThumbnailCreator *creator; + g_return_if_fail(KZ_IS_GECKO_EMBED(kzembed)); - creator = KZ_MOZ_THUMBNAIL_CREATOR(g_object_get_data(G_OBJECT(kz), - "KzGeckoEmbed::ThumbnailCreator")); - if (!creator) - { - creator = kz_moz_thumbnail_creator_new(); - gtk_widget_set_size_request(GTK_WIDGET(creator), 0, 0); - gtk_widget_show(GTK_WIDGET(creator)); + const gchar *uri; - gtk_box_pack_start(GTK_BOX(kz->statusbar), - GTK_WIDGET(creator), - FALSE, FALSE, 0); - g_object_set_data(G_OBJECT(kz), - "KzGeckoEmbed::ThumbnailCreator", - creator); - } + uri = kz_embed_get_location(kzembed); - return creator; -} -#endif + if (!uri) + return; -static void -kz_gecko_embed_create_thumbnail (KzEmbed *kzembed) -{ - g_return_if_fail(KZ_IS_GECKO_EMBED(kzembed)); + if (uri[0] == '\0') + return; - gboolean create_thumbnail = FALSE; - KZ_CONF_GET("Global", "create_thumbnail", create_thumbnail, BOOL); - if (!create_thumbnail) return; - +#ifdef MOZ_NSICANVASRENDERINGCONTEXTINTERNAL_HAVE_GETINPUTSTREAM_ KzGeckoEmbedPrivate *priv = KZ_GECKO_EMBED_GET_PRIVATE (kzembed); KzMozWrapper *wrapper = priv->wrapper; g_return_if_fail (wrapper != NULL); -#ifdef MOZ_NSICANVASRENDERINGCONTEXTINTERNAL_HAVE_GETINPUTSTREAM_ - wrapper->CreateThumbnail(); + wrapper->CreateThumbnail(uri, size); #else + nsresult rv; - int total, index; - rv = wrapper->GetSHInfo (&total, &index); + GdkDrawable *window; + gint width, height; + GdkPixbuf *pixbuf, *thumbnail; - nsCOMPtr<nsIHistoryEntry> he; - rv = wrapper->GetHistoryEntry(index, getter_AddRefs(he)); - if (NS_FAILED(rv)) return; + window = GTK_WIDGET(kzembed)->window; + if (!gdk_window_is_viewable(window)) + return; - GtkWidget *window = gtk_widget_get_toplevel(GTK_WIDGET(kzembed)); + gdk_drawable_get_size(window, &width, &height); + pixbuf = gdk_pixbuf_get_from_drawable(NULL, + window, + NULL, + 0, 0, 0, 0, + width, height); + if (!pixbuf) + return; - if (!KZ_IS_WINDOW(window)) return; + thumbnail = gdk_pixbuf_scale_simple(pixbuf, + size, size, + GDK_INTERP_HYPER); + g_object_unref(pixbuf); - KzWindow *kz = KZ_WINDOW(window); + if (!thumbnail) + return; - KzMozThumbnailCreator *creator; - creator = kz_window_create_thumbnail_creator(kz); - kz_moz_thumbnail_creator_append_queue(creator, he); + guint last_modified = kz_gecko_embed_get_last_modified(kzembed); + if (last_modified == 0) + { + GTimeVal now; + g_get_current_time(&now); + last_modified = now.tv_sec; + } + + egg_pixbuf_add_thumbnail_data(thumbnail, + uri, + last_modified, + size); + egg_pixbuf_save_thumbnail(thumbnail, NULL, NULL); + + g_object_unref(thumbnail); #endif } Deleted: kazehakase/trunk/module/embed/gecko/kz-mozthumbnailcreator.cpp =================================================================== --- kazehakase/trunk/module/embed/gecko/kz-mozthumbnailcreator.cpp 2007-04-13 05:31:41 UTC (rev 3171) +++ kazehakase/trunk/module/embed/gecko/kz-mozthumbnailcreator.cpp 2007-04-13 05:37:11 UTC (rev 3172) @@ -1,449 +0,0 @@ -// -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - -// -// Copyright (C) 2002-2004 Hiroyuki Ikezoe -// Copyright (C) 2003 Takuro Ashie -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation; either version 2, or (at your option) -// any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif /* HAVE_CONFIG_H */ - -#include "kz-mozthumbnailcreator.h" - -#include <gtkmozembed.h> -#include <gtkmozembed_internal.h> -#include <glib/gi18n.h> - -#include "kz-mozthumbnailprogress.h" -#include "mozilla.h" -#include "utils.h" -#include "egg-pixbuf-thumbnail.h" -#include "kz-mozutils.h" -#include "MozillaPrivate.h" - -#ifdef HAVE_UNISTD_H -# include <unistd.h> -#endif - -#include <nsCOMPtr.h> -#include <nsIInterfaceRequestor.h> -#include <nsIInterfaceRequestorUtils.h> -#define MOZILLA_STRICT_API -#include <nsEmbedString.h> -#undef MOZILLA_STRICT_API -#include <nsIDOMDocument.h> -#include <nsIDocumentViewer.h> -#include <nsIWebBrowser.h> -#include <dom/nsIDOMNSDocument.h> -#include <docshell/nsIDocShell.h> -#include <nsIDOMWindow.h> -#include <nsISHistory.h> -#include <nsIHistoryEntry.h> -#include <nsISHEntry.h> -#include <nsIWebNavigation.h> -#include <nsIWebBrowserPrint.h> -#include <nsIWebBrowserSetup.h> -#include <nsIPrintSettings.h> -#include <nsIPrintSettingsService.h> -#include <nsISHistoryInternal.h> -#include <docshell/nsIDocShellTreeItem.h> -#include <nsIDocShellTreeOwner.h> -#include <nsTime.h> -#include <nsCWebBrowser.h> -#include <nsIDOM3Node.h> - -typedef struct _KzMozThumbnailCreatorPrivate KzMozThumbnailCreatorPrivate; -struct _KzMozThumbnailCreatorPrivate -{ - nsCOMPtr<nsIWebBrowser> mWebBrowser; - nsCOMPtr<nsISHistory> mHistory; - gboolean is_creating; -}; -#define KZ_MOZ_THUMBNAIL_CREATOR_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), KZ_TYPE_MOZ_THUMBNAIL_CREATOR, KzMozThumbnailCreatorPrivate)) - -static void kz_moz_thumbnail_creator_destroy (GtkObject *object); -static void kz_moz_thumbnail_creator_realize (GtkWidget *widget); -static void kz_moz_thumbnail_creator_unrealize (GtkWidget *widget); -static void kz_moz_thumbnail_creator_net_stop (GtkMozEmbed *embed); - -static void kz_moz_thumbnail_creator_create_thumbnail (KzMozThumbnailCreator *kzembed, const gchar *uri); - -static KzMozThumbnailCreator *creator_single = NULL; - -G_DEFINE_TYPE(KzMozThumbnailCreator, kz_moz_thumbnail_creator, GTK_TYPE_MOZ_EMBED) - -static void -kz_moz_thumbnail_creator_class_init (KzMozThumbnailCreatorClass *klass) -{ - GObjectClass *gobject_class; - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GtkMozEmbedClass *moz_embed_class; - - gobject_class = (GObjectClass *) klass; - object_class = (GtkObjectClass *) klass; - widget_class = (GtkWidgetClass *) klass; - moz_embed_class = (GtkMozEmbedClass *) klass; - - // GtkObject signals - object_class->destroy = kz_moz_thumbnail_creator_destroy; - - // widget class - widget_class->realize = kz_moz_thumbnail_creator_realize; - widget_class->unrealize = kz_moz_thumbnail_creator_unrealize; - - moz_embed_class->net_stop = kz_moz_thumbnail_creator_net_stop; - g_type_class_add_private (gobject_class, sizeof(KzMozThumbnailCreatorPrivate)); -} - - -static void -kz_moz_thumbnail_creator_init (KzMozThumbnailCreator *creator) -{ - KzMozThumbnailCreatorPrivate *priv = KZ_MOZ_THUMBNAIL_CREATOR_GET_PRIVATE (creator); - priv->is_creating = FALSE; -} - -KzMozThumbnailCreator * -kz_moz_thumbnail_creator_new (void) -{ - KzMozThumbnailCreator *creator = KZ_MOZ_THUMBNAIL_CREATOR(g_object_new(KZ_TYPE_MOZ_THUMBNAIL_CREATOR, NULL)); - - gtk_moz_embed_load_url(GTK_MOZ_EMBED(creator), "about:blank"); - return creator; -} - -KzMozThumbnailCreator * -kz_moz_thumbnail_creator_get_instance (void) -{ - if (!creator_single) - creator_single = kz_moz_thumbnail_creator_new(); - else - g_object_ref(creator_single); - - return creator_single; -} - -static void -kz_moz_thumbnail_creator_destroy (GtkObject *object) -{ - if (GTK_OBJECT_CLASS(kz_moz_thumbnail_creator_parent_class)->destroy) - GTK_OBJECT_CLASS(kz_moz_thumbnail_creator_parent_class)->destroy(object); -} - - -static void -kz_moz_thumbnail_creator_realize (GtkWidget *widget) -{ - KzMozThumbnailCreator *creator = KZ_MOZ_THUMBNAIL_CREATOR(widget); - if (GTK_WIDGET_CLASS(kz_moz_thumbnail_creator_parent_class)->realize) - GTK_WIDGET_CLASS(kz_moz_thumbnail_creator_parent_class)->realize(widget); - - KzMozThumbnailCreatorPrivate *priv = KZ_MOZ_THUMBNAIL_CREATOR_GET_PRIVATE (creator); - gtk_moz_embed_get_nsIWebBrowser(GTK_MOZ_EMBED(widget), - getter_AddRefs(priv->mWebBrowser)); -#if 0 - nsCOMPtr<nsIWebBrowserSetup> setup; - setup = do_QueryInterface(creator->priv->mWebBrowser); - setup->SetProperty(nsIWebBrowserSetup::SETUP_ALLOW_PLUGINS, PR_FALSE); -#endif -} - - -static void -kz_moz_thumbnail_creator_unrealize (GtkWidget *widget) -{ - KzMozThumbnailCreator *creator = KZ_MOZ_THUMBNAIL_CREATOR(widget); - - if (GTK_WIDGET_CLASS(kz_moz_thumbnail_creator_parent_class)->unrealize) - GTK_WIDGET_CLASS(kz_moz_thumbnail_creator_parent_class)->unrealize(widget); -} - - -typedef struct _SiteInfo -{ - KzMozThumbnailCreator *creator; - gchar *uri; -} SiteInfo; - -static gboolean -idle_create_thumbnail (gpointer data) -{ - SiteInfo *info = (SiteInfo*)data; - - KzMozThumbnailCreator *creator = KZ_MOZ_THUMBNAIL_CREATOR(info->creator); - - kz_moz_thumbnail_creator_create_thumbnail(creator, - info->uri); - - g_free(info->uri); - g_free(info); - return FALSE; -} - -static void -net_stop_proccess (KzMozThumbnailCreator *creator) -{ - KzMozThumbnailCreatorPrivate *priv = KZ_MOZ_THUMBNAIL_CREATOR_GET_PRIVATE (creator); - - nsCOMPtr<nsIDocShellTreeItem> browserAsItem; - browserAsItem = do_QueryInterface(priv->mWebBrowser); - if (!browserAsItem) return; - - // get the owner for that item - nsCOMPtr<nsIDocShellTreeOwner> treeOwner; - browserAsItem->GetTreeOwner(getter_AddRefs(treeOwner)); - if (!treeOwner) return; - - // get the primary content shell as an item - nsCOMPtr<nsIDocShellTreeItem> contentItem; - treeOwner->GetPrimaryContentShell(getter_AddRefs(contentItem)); - if (!contentItem) return; - - // QI that back to a docshell - nsCOMPtr<nsIDocShell> DocShell; - DocShell = do_QueryInterface(contentItem); - - nsCOMPtr<nsIContentViewer> contentViewer; - nsresult rv = DocShell->GetContentViewer(getter_AddRefs(contentViewer)); - if (!NS_SUCCEEDED(rv) || !contentViewer) return; - - nsCOMPtr<nsIDOMDocument> domDoc; - contentViewer->GetDOMDocument(getter_AddRefs(domDoc)); - - //get the last modification time - nsCOMPtr<nsIDOMNSDocument> nsDoc = do_QueryInterface(domDoc); - nsEmbedString value; - nsDoc->GetLastModified(value); - nsEmbedCString cValue; - NS_UTF16ToCString(value, - NS_CSTRING_ENCODING_UTF8, cValue); - nsTime lm (cValue.get(), PR_TRUE); - GTime last_modified; - LL_DIV(last_modified, - NS_STATIC_CAST(PRTime, lm), PR_USEC_PER_SEC); - - nsCOMPtr<nsIDOM3Node> domnode = do_QueryInterface(domDoc); - if(!domnode) return; - - nsEmbedString spec; - domnode->GetBaseURI(spec); - - nsEmbedCString sURI; - NS_UTF16ToCString(spec, - NS_CSTRING_ENCODING_UTF8, sURI); - - if (!g_ascii_strcasecmp(sURI.get(), "about:blank")) - return; - - if ((!last_modified || (thumbnail_get_last_modified(sURI.get()) < last_modified))) - { - SiteInfo *info = g_new0(SiteInfo, 1); - info->creator = creator; - info->uri = g_strdup(sURI.get()); - g_idle_add(idle_create_thumbnail, (gpointer)info); - } -} - - -static void -kz_moz_thumbnail_creator_net_stop (GtkMozEmbed *embed) -{ - KzMozThumbnailCreator *creator = KZ_MOZ_THUMBNAIL_CREATOR(embed); - - g_return_if_fail(KZ_IS_MOZ_THUMBNAIL_CREATOR(creator)); - - if (((GtkMozEmbedClass *)kz_moz_thumbnail_creator_parent_class)->net_stop) - ((GtkMozEmbedClass *)kz_moz_thumbnail_creator_parent_class)->net_stop(embed); - - net_stop_proccess(creator); -} - -static void -kz_moz_thumbnail_creator_create_thumbnail (KzMozThumbnailCreator *creator, const gchar *uri) -{ - nsresult rv; - nsCOMPtr<nsIPrintSettings> options; - - KzMozThumbnailCreatorPrivate *priv = KZ_MOZ_THUMBNAIL_CREATOR_GET_PRIVATE (creator); - - nsCOMPtr<nsIWebBrowserPrint> print(do_GetInterface(priv->mWebBrowser, &rv)); - if (NS_FAILED(rv) || !print) - { - priv->is_creating = FALSE; - return; - } - - if (!MozillaPrivate::CreatePrintSettings(getter_AddRefs(options))) - { - priv->is_creating = FALSE; - return; - } - - gint fd; - gchar *ps_name; - fd = g_file_open_tmp("kzXXXXXX.ps", &ps_name, NULL); - if (fd == -1) - return; - close(fd); - - options->SetPrintRange(nsIPrintSettings::kRangeSpecifiedPageRange); - options->SetStartPageRange(1); - options->SetEndPageRange(1); - options->SetMarginTop(0.0); - options->SetMarginLeft(0.0); - options->SetMarginBottom(0.0); - options->SetMarginRight(0.0); - nsEmbedString printer; - NS_CStringToUTF16(nsEmbedCString("PostScript/default"), - NS_CSTRING_ENCODING_UTF8, printer); - options->SetPrinterName(printer.get()); - nsEmbedString tmp; - NS_CStringToUTF16(nsEmbedCString(""), NS_CSTRING_ENCODING_UTF8, tmp); - options->SetHeaderStrLeft(tmp.get()); - options->SetHeaderStrCenter(tmp.get()); - options->SetHeaderStrRight(tmp.get()); - options->SetFooterStrLeft(tmp.get()); - options->SetFooterStrCenter(tmp.get()); - options->SetFooterStrRight(tmp.get()); - options->SetPaperSize(nsIPrintSettings::kPaperSizeNativeData); - - NS_CStringToUTF16(nsEmbedCString("Letter"), - NS_CSTRING_ENCODING_UTF8, tmp); - options->SetPaperName(tmp.get()); - - NS_CStringToUTF16(nsEmbedCString(ps_name), - NS_CSTRING_ENCODING_UTF8, tmp); - options->SetToFileName(tmp.get()); - options->SetPrintToFile(PR_TRUE); - options->SetPrintInColor(PR_TRUE); - options->SetOrientation(nsIPrintSettings::kLandscapeOrientation); - options->SetPrintBGImages(PR_TRUE); - options->SetPrintBGColors(PR_TRUE); - options->SetPrintFrameType(nsIPrintSettings::kFramesAsIs); - options->SetShowPrintProgress(PR_FALSE); - options->SetShrinkToFit(PR_TRUE); - options->SetNumCopies(1); - options->SetPrintSilent(PR_TRUE); - - PRBool printing = PR_TRUE; -// print->ExitPrintPreview(); - /* it is dangerous. */ - while (printing) - { - if (print->GetDoingPrintPreview(&printing) != NS_OK) - break; - - if (!printing) - { - GTimeVal now; - g_get_current_time(&now); - KzMozThumbnailProgressListener *aProgress = - new KzMozThumbnailProgressListener(ps_name, - uri, - (time_t)now.tv_sec, - EGG_PIXBUF_THUMB_LARGE, - creator); - - if (print->Print(options, aProgress) != NS_OK) - delete aProgress; - break; - } - - while (gtk_events_pending()) - gtk_main_iteration(); - } - - g_free(ps_name); -} - -void -kz_moz_thumbnail_creator_create_next (KzMozThumbnailCreator *creator) -{ - g_return_if_fail(KZ_IS_MOZ_THUMBNAIL_CREATOR(creator)); - - KzMozThumbnailCreatorPrivate *priv = KZ_MOZ_THUMBNAIL_CREATOR_GET_PRIVATE (creator); - nsresult rv; - if (!priv->mWebBrowser) return; - - nsCOMPtr<nsIWebNavigation> ContentNav = do_QueryInterface (priv->mWebBrowser, - &rv); - if (!ContentNav) return; - - gtk_moz_embed_stop_load(GTK_MOZ_EMBED(creator)); - - nsCOMPtr<nsISHistory> SessionHistory; - rv = ContentNav->GetSessionHistory (getter_AddRefs (SessionHistory)); - - PRInt32 count, index; - SessionHistory->GetCount (&count); - SessionHistory->GetIndex (&index); - - // remove previous page - if (count > 2) - SessionHistory->PurgeHistory(index); - - PRBool exist_next; - ContentNav->GetCanGoForward(&exist_next); - - if (exist_next) - ContentNav->GoForward(); - else - { - priv->is_creating = FALSE; - gtk_moz_embed_load_url(GTK_MOZ_EMBED(creator), "about:blank"); - } -} - -void -kz_moz_thumbnail_creator_append_queue (KzMozThumbnailCreator *creator, - gpointer data) -{ - g_return_if_fail(KZ_IS_MOZ_THUMBNAIL_CREATOR(creator)); - nsresult rv; - KzMozThumbnailCreatorPrivate *priv = KZ_MOZ_THUMBNAIL_CREATOR_GET_PRIVATE (creator); - if (!priv->mWebBrowser) return; - - nsCOMPtr<nsIWebNavigation> ContentNav = do_QueryInterface (priv->mWebBrowser, - &rv); - if (!ContentNav) return; - - nsCOMPtr<nsISHistory> SessionHistory; - rv = ContentNav->GetSessionHistory (getter_AddRefs (SessionHistory)); - nsCOMPtr<nsISHistoryInternal> hi = do_QueryInterface (SessionHistory); - if (!hi) return; - - nsIHistoryEntry *he = (nsIHistoryEntry*) data; - nsCOMPtr<nsISHEntry> she = do_QueryInterface (he); - if (!she) return; - - nsCOMPtr<nsISHEntry> dest_she; - she->Clone(getter_AddRefs(dest_she)); - - rv = hi->AddEntry (dest_she, PR_TRUE); - if (NS_FAILED(rv)) return; - - if (priv->is_creating) return; - - priv->is_creating = TRUE; - - PRInt32 index; - SessionHistory->GetIndex (&index); - ContentNav->GotoIndex(index); -} - Deleted: kazehakase/trunk/module/embed/gecko/kz-mozthumbnailcreator.h =================================================================== --- kazehakase/trunk/module/embed/gecko/kz-mozthumbnailcreator.h 2007-04-13 05:31:41 UTC (rev 3171) +++ kazehakase/trunk/module/embed/gecko/kz-mozthumbnailcreator.h 2007-04-13 05:37:11 UTC (rev 3172) @@ -1,65 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Copyright (C) 2002-2004 Hiroyuki Ikezoe - * Copyright (C) 2003 Takuro Ashie - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef __KZ_MOZ_THUMBNAIL_CREATOR_H__ -#define __KZ_MOZ_THUMBNAIL_CREATOR_H__ - -#include <gtk/gtk.h> -#include <gtkmozembed.h> - -G_BEGIN_DECLS - -#define KZ_TYPE_MOZ_THUMBNAIL_CREATOR (kz_moz_thumbnail_creator_get_type ()) -#define KZ_MOZ_THUMBNAIL_CREATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KZ_TYPE_MOZ_THUMBNAIL_CREATOR, KzMozThumbnailCreator)) -#define KZ_MOZ_THUMBNAIL_CREATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KZ_TYPE_MOZ_THUMBNAIL_CREATOR, KzMozThumbnailCreatorClass)) -#define KZ_IS_MOZ_THUMBNAIL_CREATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KZ_TYPE_MOZ_THUMBNAIL_CREATOR)) -#define KZ_IS_MOZ_THUMBNAIL_CREATOR_CLASS(klass)(G_TYPE_CHECK_CLASS_TYPE ((klass), KZ_TYPE_MOZ_THUMBNAIL_CREATOR)) -#define KZ_MOZ_THUMBNAIL_CREATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KZ_TYPE_MOZ_THUMBNAIL_CREATOR, KzMozThumbnailCreatorClass)) - -typedef struct _KzMozThumbnailCreator KzMozThumbnailCreator; -typedef struct _KzMozThumbnailCreatorClass KzMozThumbnailCreatorClass; - -struct _KzMozThumbnailCreator -{ - /* embedding widget */ - GtkMozEmbed parent; -}; - -struct _KzMozThumbnailCreatorClass -{ - GtkMozEmbedClass parent_class; -}; - - -GtkType kz_moz_thumbnail_creator_get_type (void) G_GNUC_CONST; -KzMozThumbnailCreator - *kz_moz_thumbnail_creator_new (void); -KzMozThumbnailCreator - *kz_moz_thumbnail_creator_get_instance (void); - -void kz_moz_thumbnail_creator_create_next (KzMozThumbnailCreator *creator); - -void kz_moz_thumbnail_creator_append_queue (KzMozThumbnailCreator *creator, - gpointer data); - -G_END_DECLS - -#endif /* __KZ_MOZ_THUMBNAIL_CREATOR_H__ */ Deleted: kazehakase/trunk/module/embed/gecko/kz-mozthumbnailprogress.cpp =================================================================== --- kazehakase/trunk/module/embed/gecko/kz-mozthumbnailprogress.cpp 2007-04-13 05:31:41 UTC (rev 3171) +++ kazehakase/trunk/module/embed/gecko/kz-mozthumbnailprogress.cpp 2007-04-13 05:37:11 UTC (rev 3172) @@ -1,106 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Copyright (C) 2004 Hiroyuki Ikezoe - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#include "kz-mozthumbnailprogress.h" -#include "utils.h" - -NS_IMPL_ISUPPORTS1(KzMozThumbnailProgressListener, nsIWebProgressListener) - -KzMozThumbnailProgressListener::KzMozThumbnailProgressListener(const gchar *filename, - const gchar *uri, - time_t mtime, - EggPixbufThumbSize size, - KzMozThumbnailCreator *creator) -{ - NS_INIT_ISUPPORTS(); - mURI = g_strdup(uri); - mFilename = g_strdup(filename); - mMtime = mtime; - mSize = size; - mCreator = creator; -} - - -KzMozThumbnailProgressListener::~KzMozThumbnailProgressListener() -{ - kz_moz_thumbnail_creator_create_next(mCreator); - mCreator = NULL; - - if (mURI && mFilename) - kz_utils_save_ps_as_thumbnail(mFilename, mURI, mMtime, mSize); - - g_free(mURI); - g_free(mFilename); - - mURI = NULL; - mFilename = NULL; -} - - -NS_IMETHODIMP -KzMozThumbnailProgressListener::OnStateChange(nsIWebProgress *aWebProgress, - nsIRequest *aRequest, - PRUint32 aStateFlags, - nsresult aStatus) -{ - if (aStateFlags & nsIWebProgressListener::STATE_STOP) - { - /* emit signal */ - } - - return NS_OK; -} - -NS_IMETHODIMP -KzMozThumbnailProgressListener::OnProgressChange(nsIWebProgress *aWebProgress, - nsIRequest *aRequest, - PRInt32 aCurSelfProgress, - PRInt32 aMaxSelfProgress, - PRInt32 aCurTotalProgress, - PRInt32 aMaxTotalProgress) -{ - return NS_OK; -} - -NS_IMETHODIMP -KzMozThumbnailProgressListener::OnLocationChange(nsIWebProgress *aWebProgress, - nsIRequest *aRequest, - nsIURI *aLocation) -{ - return NS_OK; -} - -NS_IMETHODIMP -KzMozThumbnailProgressListener::OnStatusChange(nsIWebProgress *aWebProgress, - nsIRequest *aRequest, - nsresult aStatus, - const PRUnichar *aMessage) -{ - return NS_OK; -} - -NS_IMETHODIMP -KzMozThumbnailProgressListener::OnSecurityChange(nsIWebProgress *aWebProgress, - nsIRequest *aRequest, - PRUint32 aState) -{ - return NS_OK; -} - Deleted: kazehakase/trunk/module/embed/gecko/kz-mozthumbnailprogress.h =================================================================== --- kazehakase/trunk/module/embed/gecko/kz-mozthumbnailprogress.h 2007-04-13 05:31:41 UTC (rev 3171) +++ kazehakase/trunk/module/embed/gecko/kz-mozthumbnailprogress.h 2007-04-13 05:37:11 UTC (rev 3172) @@ -1,54 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Copyright (C) 2004 Hiroyuki Ikezoe - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -#ifndef __KZ_MOZ_THUMBNAIL_PROGRESS_LISTENER_H__ -#define __KZ_MOZ_THUMBNAIL_PROGRESS_LISTENER_H__ - -#include "egg-pixbuf-thumbnail.h" - -#include "kz-gecko-embed.h" -#include "kz-mozthumbnailcreator.h" - -#include <nsIWebProgressListener.h> - - -class KzMozThumbnailProgressListener : public nsIWebProgressListener -{ - public: - KzMozThumbnailProgressListener (const gchar *filename, - const gchar *uri, - time_t mtime, - EggPixbufThumbSize size, - KzMozThumbnailCreator *creator); - virtual ~KzMozThumbnailProgressListener (); - - NS_DECL_ISUPPORTS - NS_DECL_NSIWEBPROGRESSLISTENER - - private: - gchar *mFilename; - gchar *mURI; - time_t mMtime; - EggPixbufThumbSize mSize; - KzMozThumbnailCreator *mCreator; -}; - - -#endif /* __KZ_MOZ_THUMBNAIL_PROGRESS_LISTENER_H__ */ Modified: kazehakase/trunk/module/embed/gecko/kz-mozwrapper.cpp =================================================================== --- kazehakase/trunk/module/embed/gecko/kz-mozwrapper.cpp 2007-04-13 05:31:41 UTC (rev 3171) +++ kazehakase/trunk/module/embed/gecko/kz-mozwrapper.cpp 2007-04-13 05:37:11 UTC (rev 3172) @@ -2022,16 +2022,12 @@ #ifdef MOZ_NSICANVASRENDERINGCONTEXTINTERNAL_HAVE_GETINPUTSTREAM_ nsresult -KzMozWrapper::CreateThumbnail (void) +KzMozWrapper::CreateThumbnail (const gchar *uri, EggPixbufThumbSize size) { nsCOMPtr<nsIDOMWindow> domWindow; GetDOMWindow(getter_AddRefs(domWindow)); - - nsEmbedCString sURI; - GetDocumentUrl(sURI); - const gchar *uri = sURI.get(); - - if (!MozillaPrivate::CreateThumbnail(domWindow, uri)) + + if (!MozillaPrivate::CreateThumbnail(domWindow, uri, size)) return NS_ERROR_FAILURE; return NS_OK; Modified: kazehakase/trunk/module/embed/gecko/kz-mozwrapper.h =================================================================== --- kazehakase/trunk/module/embed/gecko/kz-mozwrapper.h 2007-04-13 05:31:41 UTC (rev 3171) +++ kazehakase/trunk/module/embed/gecko/kz-mozwrapper.h 2007-04-13 05:37:11 UTC (rev 3172) @@ -148,7 +148,8 @@ nsresult ShowPageCertificate (void); #ifdef MOZ_NSICANVASRENDERINGCONTEXTINTERNAL_HAVE_GETINPUTSTREAM_ - nsresult CreateThumbnail (void); + nsresult CreateThumbnail (const gchar *uri, + EggPixbufThumbSize size); #endif nsCOMPtr<nsIWebBrowser> mWebBrowser; Modified: kazehakase/trunk/src/kz-embed.c =================================================================== --- kazehakase/trunk/src/kz-embed.c 2007-04-13 05:31:41 UTC (rev 3171) +++ kazehakase/trunk/src/kz-embed.c 2007-04-13 05:37:11 UTC (rev 3172) @@ -987,12 +987,12 @@ void -kz_embed_create_thumbnail (KzEmbed *kzembed) +kz_embed_create_thumbnail (KzEmbed *kzembed, EggPixbufThumbSize size) { g_return_if_fail(KZ_IS_EMBED(kzembed)); - g_return_if_fail(KZ_EMBED_GET_IFACE(kzembed)->create_thumbnail); - KZ_EMBED_GET_IFACE(kzembed)->create_thumbnail(kzembed); + if (KZ_EMBED_GET_IFACE(kzembed)->create_thumbnail) + KZ_EMBED_GET_IFACE(kzembed)->create_thumbnail(kzembed, size); } Modified: kazehakase/trunk/src/kz-embed.h =================================================================== --- kazehakase/trunk/src/kz-embed.h 2007-04-13 05:31:41 UTC (rev 3171) +++ kazehakase/trunk/src/kz-embed.h 2007-04-13 05:37:11 UTC (rev 3172) @@ -23,6 +23,7 @@ #include "kazehakase.h" #include "kz-embed-event.h" #include "kz-navi.h" +#include "egg-pixbuf-thumbnail.h" #ifndef __KZ_EMBED_H__ #define __KZ_EMBED_H__ @@ -196,7 +197,8 @@ void (*print) (KzEmbed *kzembed); void (*print_preview) (KzEmbed *kzembed); GList *(*get_printer_list) (KzEmbed *kzembed); - void (*create_thumbnail) (KzEmbed *kzembed); + void (*create_thumbnail) (KzEmbed *kzembed, + EggPixbufThumbSize size); gboolean (*save_with_content) (KzEmbed *kzembed, @@ -419,7 +421,8 @@ void kz_embed_print (KzEmbed *kzembed); void kz_embed_print_preview (KzEmbed *kzembed); GList *kz_embed_get_printer_list (KzEmbed *kzembed); -void kz_embed_create_thumbnail (KzEmbed *kzembed); +void kz_embed_create_thumbnail (KzEmbed *kzembed, + EggPixbufThumbSize size); gboolean kz_embed_save_with_content (KzEmbed *kzembed, Modified: kazehakase/trunk/src/kz-notebook.c =================================================================== --- kazehakase/trunk/src/kz-notebook.c 2007-04-13 05:31:41 UTC (rev 3171) +++ kazehakase/trunk/src/kz-notebook.c 2007-04-13 05:37:11 UTC (rev 3172) @@ -336,7 +336,7 @@ tab = KZ_TAB_LABEL(gtk_notebook_get_tab_label(notebook, GTK_WIDGET(kzembed))); g_return_if_fail(tab); - if(kz_tab_label_get_state(tab) == KZ_TAB_LABEL_STATE_LOADED) + if (kz_tab_label_get_state(tab) == KZ_TAB_LABEL_STATE_LOADED) { const gchar *location; gboolean focus; Modified: kazehakase/trunk/src/kz-tab-label.c =================================================================== --- kazehakase/trunk/src/kz-tab-label.c 2007-04-13 05:31:41 UTC (rev 3171) +++ kazehakase/trunk/src/kz-tab-label.c 2007-04-13 05:37:11 UTC (rev 3172) @@ -22,6 +22,7 @@ #include <stdlib.h> #include <string.h> +#include <glib/gstdio.h> #include <glib/gi18n.h> #include "gtk-utils.h" #include "kazehakase.h" @@ -32,6 +33,8 @@ #include "kz-bookmark-file.h" #include "kz-notebook.h" +#include "utils.h" + enum { PROP_0, PROP_KZ_WINDOW, @@ -500,6 +503,45 @@ g_free(escaped); } +static gboolean +idle_create_thumbnail (gpointer data) +{ + KzTabLabel *kztab; + KzEmbed *embed; + EggPixbufThumbSize size = EGG_PIXBUF_THUMB_LARGE; + gboolean create_thumbnail = FALSE; + const gchar *uri; + guint last_modified; + + kztab = data; + g_return_val_if_fail(KZ_IS_TAB_LABEL(kztab), FALSE); + + KZ_CONF_GET("Global", "create_thumbnail", create_thumbnail, BOOL); + if (!create_thumbnail) + return FALSE; + + embed = kztab->kzembed; + uri = kz_embed_get_location(embed); + if (!uri) + return FALSE; + + if (uri[0] == '\0') + return FALSE; + + last_modified = kz_embed_get_last_modified(embed); + if (last_modified > 0) + { + GTime thumbnail_last_modified; + + thumbnail_last_modified = thumbnail_get_last_modified(uri, size); + if ((unsigned int)thumbnail_last_modified >= last_modified) + return FALSE; + } + + kz_embed_create_thumbnail(embed, size); + return FALSE; +} + void kz_tab_label_set_state (KzTabLabel *kztab, KzTabLabelState state) @@ -510,6 +552,10 @@ if (!GTK_WIDGET_REALIZED(kztab)) return; + if (kztab->state != KZ_TAB_LABEL_STATE_NORMAL && + state == KZ_TAB_LABEL_STATE_NORMAL) + g_idle_add(idle_create_thumbnail, kztab); + kztab->state = state; if (state == KZ_TAB_LABEL_STATE_NORMAL) { Modified: kazehakase/trunk/src/prefs_ui/Makefile.am =================================================================== --- kazehakase/trunk/src/prefs_ui/Makefile.am 2007-04-13 05:31:41 UTC (rev 3171) +++ kazehakase/trunk/src/prefs_ui/Makefile.am 2007-04-13 05:37:11 UTC (rev 3172) @@ -2,11 +2,12 @@ noinst_LTLIBRARIES = libkzprefsui.la -INCLUDES = \ - $(GTK_CFLAGS) \ - -I$(top_srcdir)/src/utils \ - -I$(top_srcdir)/src/widget \ - -I$(top_srcdir)/src/bookmarks \ +INCLUDES = \ + $(GTK_CFLAGS) \ + -I$(top_srcdir)/src/utils \ + -I$(top_srcdir)/src/widget \ + -I$(top_srcdir)/src/bookmarks \ + -I$(top_srcdir)/src/libegg/pixbufthumbnail \ -I$(top_srcdir)/src AM_CPPFLAGS = \ Modified: kazehakase/trunk/src/sidebar/Makefile.am =================================================================== --- kazehakase/trunk/src/sidebar/Makefile.am 2007-04-13 05:31:41 UTC (rev 3171) +++ kazehakase/trunk/src/sidebar/Makefile.am 2007-04-13 05:37:11 UTC (rev 3172) @@ -2,14 +2,15 @@ noinst_LTLIBRARIES = libkzsidebar.la -INCLUDES = \ - $(GTK_CFLAGS) \ - -I$(top_srcdir)/src/actions \ - -I$(top_srcdir)/src/utils \ - -I$(top_srcdir)/src/mozilla \ - -I$(top_srcdir)/src/bookmarks \ - -I$(top_srcdir)/src/net \ - -I$(top_srcdir)/src/widget \ +INCLUDES = \ + $(GTK_CFLAGS) \ + -I$(top_srcdir)/src/actions \ + -I$(top_srcdir)/src/utils \ + -I$(top_srcdir)/src/mozilla \ + -I$(top_srcdir)/src/bookmarks \ + -I$(top_srcdir)/src/net \ + -I$(top_srcdir)/src/widget \ + -I$(top_srcdir)/src/libegg/pixbufthumbnail \ -I$(top_srcdir)/src AM_CPPFLAGS= \ Modified: kazehakase/trunk/src/utils/utils.c =================================================================== --- kazehakase/trunk/src/utils/utils.c 2007-04-13 05:31:41 UTC (rev 3171) +++ kazehakase/trunk/src/utils/utils.c 2007-04-13 05:37:11 UTC (rev 3172) @@ -764,15 +764,14 @@ } GTime -thumbnail_get_last_modified (const gchar *uri) +thumbnail_get_last_modified (const gchar *uri, EggPixbufThumbSize size) { gchar *thumb_filename; struct stat st; int ret; - - thumb_filename = egg_pixbuf_get_thumb_filename(uri, - EGG_PIXBUF_THUMB_LARGE); - + + thumb_filename = egg_pixbuf_get_thumb_filename(uri, size); + ret = g_stat(thumb_filename, &st); g_free(thumb_filename); @@ -805,165 +804,6 @@ return 0; } -#ifndef MOZ_NSICANVASRENDERINGCONTEXTINTERNAL_HAVE_GETINPUTSTREAM_ -typedef struct _KzPixbufConverter -{ - GdkPixbufLoader *loader; - gchar *uri; - gchar *filename; - time_t mtime; - EggPixbufThumbSize size; -} KzPixbufConverter; - - -static gboolean -idle_dispose_converter(gpointer data) -{ - KzPixbufConverter *converter = data; - - g_free(converter->uri); - g_free(converter->filename); - g_free(converter); - - return FALSE; -} - -static gboolean -cb_io_in(GIOChannel *iochannel, GIOCondition condition, - gpointer data) -{ - GIOStatus iostatus; - gsize bytes_read; - gchar buffer[BUFFER_SIZE]; - KzPixbufConverter *converter = data; - - if (condition & G_IO_ERR) - { - g_idle_add(idle_dispose_converter, converter); - return FALSE; - } - - /* Read the data into our buffer */ - iostatus = g_io_channel_read_chars(iochannel, buffer, - sizeof(buffer), - &bytes_read, - NULL); - - if (bytes_read) - { - gdk_pixbuf_loader_write(converter->loader, - (const guchar*)buffer, bytes_read, - NULL); - } - - switch (iostatus) - { - case G_IO_STATUS_EOF: - { - GdkPixbuf *pixbuf; - pixbuf = gdk_pixbuf_loader_get_pixbuf(converter->loader); - if (pixbuf) - { - GdkPixbuf *rotate, *scale; - - /* scale */ - scale = gdk_pixbuf_scale_simple(pixbuf, - KZ_THUMB_HEIGHT, - converter->size, - GDK_INTERP_HYPER); - - /* rotate image */ - rotate = gdk_pixbuf_rotate_simple(scale, - GDK_PIXBUF_ROTATE_CLOCKWISE); - g_object_unref(scale); - /* save image */ - if (rotate) - { - egg_pixbuf_add_thumbnail_data(rotate, - converter->uri, - converter->mtime, - converter->size); - egg_pixbuf_save_thumbnail(rotate, NULL, NULL); - g_object_unref(rotate); - } - } - gdk_pixbuf_loader_close(converter->loader, NULL); - g_unlink(converter->filename); - g_idle_add(idle_dispose_converter, converter); - - return FALSE; - } - case G_IO_STATUS_NORMAL: - return TRUE; - default: - g_idle_add(idle_dispose_converter, converter); - return FALSE; - } -} - - -void -kz_utils_save_ps_as_thumbnail (const gchar *ps_file, const gchar *uri, - time_t mtime, EggPixbufThumbSize size) -{ - const gchar *gs = - "gs -q -dNOPAUSE -dBATCH -r24 -sDEVICE=ppmraw -sOutputFile=- %s"; - gchar *command; - gint argc, out; - gchar **argv = NULL; - GSpawnFlags flags; - GPid pid; - GIOChannel *io; - GdkPixbufLoader *loader; - KzPixbufConverter *converter; - - command = g_strdup_printf(gs, ps_file); - - g_shell_parse_argv(command, - &argc, - &argv, - NULL); - - /* Check whether ghostscript is installed or not */ - if (g_find_program_in_path(argv[0]) == NULL) - { - g_warning("Can't find %s in your PATH.\n" - "Currently kazehakase using gecko engine needs ghostscript to create thumbnails.\n", argv[0]); - return; - } - - flags = G_SPAWN_SEARCH_PATH; - g_spawn_async_with_pipes(NULL, - argv, - NULL, - flags, - NULL, - NULL, - &pid, - NULL, - &out, - NULL, - NULL); - g_strfreev(argv); - g_free(command); - - io = g_io_channel_unix_new(out); - g_io_channel_set_encoding(io, NULL, NULL); - - loader = gdk_pixbuf_loader_new_with_type("pnm", NULL); - converter = g_new0(KzPixbufConverter, 1); - converter->loader = loader; - converter->uri = g_strdup(uri); - converter->filename = g_strdup(ps_file); - converter->mtime = mtime; - converter->size = size; - - g_io_add_watch(io, - G_IO_IN | G_IO_PRI | G_IO_ERR | G_IO_HUP, - cb_io_in, converter); -} -#endif - gboolean str_isdigit (const gchar *str) { Modified: kazehakase/trunk/src/utils/utils.h =================================================================== --- kazehakase/trunk/src/utils/utils.h 2007-04-13 05:31:41 UTC (rev 3171) +++ kazehakase/trunk/src/utils/utils.h 2007-04-13 05:37:11 UTC (rev 3172) @@ -50,7 +50,7 @@ const gchar *encode, gboolean urlencode); -GTime thumbnail_get_last_modified (const gchar *uri); +GTime thumbnail_get_last_modified (const gchar *uri, EggPixbufThumbSize size); GTime history_get_last_modified (const gchar *uri); gchar *complement_scheme (const gchar *url); @@ -67,10 +67,6 @@ void kz_utils_purge_files_by_time_stamp (const gchar *target_dir, const gchar *time_stamp_path, time_t limit_seconds); -void kz_utils_save_ps_as_thumbnail (const gchar *ps_file, - const gchar *uri, - time_t mtime, - EggPixbufThumbSize size); gboolean str_isdigit (const gchar *str); GSList *find_file (const gchar *path,