[Kazehakase-cvs] kazehakase-svn [3044] * src/actions/Makefile.am, src/bookmarks/Makefile.am,

Back to archive index

svnno****@sourc***** svnno****@sourc*****
Tue Mar 27 13:43:38 JST 2007


Revision: 3044
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=3044
Author:   kous
Date:     2007-03-27 13:43:37 +0900 (Tue, 27 Mar 2007)

Log Message:
-----------
* src/actions/Makefile.am, src/bookmarks/Makefile.am,
src/dialogs/Makefile.am: added -Isrc/libegg/pixbufthumbnail.

* module/embed/gecko/kz-mozthumbnailprogress.{cpp,h},
  module/embed/gecko/kz-mozthumbnailcreator.cpp: used
egg-pixbuf-thumbnail.

* src/utils/utils.[ch]: made kz_utils_save_ps_as_thumbnail()
instead of convert_image().

* src/kz-app.c, src/utils.[ch]: removed make_thumbnails_dir().

Modified Paths:
--------------
    kazehakase/trunk/ChangeLog
    kazehakase/trunk/module/embed/gecko/kz-mozthumbnailcreator.cpp
    kazehakase/trunk/module/embed/gecko/kz-mozthumbnailprogress.cpp
    kazehakase/trunk/module/embed/gecko/kz-mozthumbnailprogress.h
    kazehakase/trunk/src/actions/Makefile.am
    kazehakase/trunk/src/bookmarks/Makefile.am
    kazehakase/trunk/src/dialogs/Makefile.am
    kazehakase/trunk/src/kz-app.c
    kazehakase/trunk/src/utils/utils.c
    kazehakase/trunk/src/utils/utils.h

Modified: kazehakase/trunk/ChangeLog
===================================================================
--- kazehakase/trunk/ChangeLog	2007-03-27 04:23:31 UTC (rev 3043)
+++ kazehakase/trunk/ChangeLog	2007-03-27 04:43:37 UTC (rev 3044)
@@ -1,3 +1,17 @@
+2007-03-27  Kouhei Sutou  <kou****@cozmi*****>
+
+	* src/actions/Makefile.am, src/bookmarks/Makefile.am,
+	src/dialogs/Makefile.am: added -Isrc/libegg/pixbufthumbnail.
+
+	* module/embed/gecko/kz-mozthumbnailprogress.{cpp,h},
+	  module/embed/gecko/kz-mozthumbnailcreator.cpp: used
+	egg-pixbuf-thumbnail.
+
+	* src/utils/utils.[ch]: made kz_utils_save_ps_as_thumbnail()
+	instead of convert_image().
+
+	* src/kz-app.c, src/utils.[ch]: removed make_thumbnails_dir().
+
 2007-03-27  Hiroyuki Ikezoe  <poinc****@ikezo*****>
 
 	* module/embed/gtk-webcore/kz-gtk-webcore.cpp: Set proxy.

Modified: kazehakase/trunk/module/embed/gecko/kz-mozthumbnailcreator.cpp
===================================================================
--- kazehakase/trunk/module/embed/gecko/kz-mozthumbnailcreator.cpp	2007-03-27 04:23:31 UTC (rev 3043)
+++ kazehakase/trunk/module/embed/gecko/kz-mozthumbnailcreator.cpp	2007-03-27 04:43:37 UTC (rev 3044)
@@ -19,6 +19,10 @@
 //  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>
@@ -32,6 +36,10 @@
 #include "kz-mozutils.h"
 #include "MozillaPrivate.h"
 
+#ifdef HAVE_UNISTD_H
+#  include <unistd.h>
+#endif
+
 #include <nsCOMPtr.h>
 #include <nsIInterfaceRequestor.h>
 #include <nsIInterfaceRequestorUtils.h>
@@ -286,14 +294,14 @@
 		priv->is_creating = FALSE;
 		return;
 	}
-	
-	gchar *thumb_filename;
-	thumb_filename = egg_pixbuf_get_thumb_filename(uri,
-						       EGG_PIXBUF_THUMB_LARGE);
-	gchar *ps_name;	
-	ps_name = g_strconcat(thumb_filename, ".ps", NULL);
-	g_free(thumb_filename);
 
+	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);
@@ -318,11 +326,11 @@
 	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->SetPrintToFile(PR_TRUE);
 	options->SetPrintInColor(PR_TRUE);
 	options->SetOrientation(nsIPrintSettings::kLandscapeOrientation);
 	options->SetPrintBGImages(PR_TRUE);
@@ -333,11 +341,16 @@
 	options->SetNumCopies(1);
 	options->SetPrintSilent(PR_TRUE);
 
+	GTimeVal now;
+	g_get_current_time(&now);
+	KzMozThumbnailProgressListener *aProgress =
+		new KzMozThumbnailProgressListener(ps_name, uri,
+						   (time_t)now.tv_sec,
+						   EGG_PIXBUF_THUMB_LARGE,
+						   creator);
+	g_free(ps_name);
+
 	PRBool printing = PR_TRUE;
-
-	KzMozThumbnailProgressListener *aProgress = new KzMozThumbnailProgressListener(ps_name, creator);
-	g_free(ps_name);
-	
 //	print->ExitPrintPreview();
 	/* it is dangerous. */
 	while (printing)

Modified: kazehakase/trunk/module/embed/gecko/kz-mozthumbnailprogress.cpp
===================================================================
--- kazehakase/trunk/module/embed/gecko/kz-mozthumbnailprogress.cpp	2007-03-27 04:23:31 UTC (rev 3043)
+++ kazehakase/trunk/module/embed/gecko/kz-mozthumbnailprogress.cpp	2007-03-27 04:43:37 UTC (rev 3044)
@@ -23,10 +23,17 @@
 
 NS_IMPL_ISUPPORTS1(KzMozThumbnailProgressListener, nsIWebProgressListener)
 
-KzMozThumbnailProgressListener::KzMozThumbnailProgressListener(const char *filename, KzMozThumbnailCreator *creator)
+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;
 }
 
@@ -36,16 +43,14 @@
 	kz_moz_thumbnail_creator_create_next(mCreator);
 	mCreator = NULL;
 
-	gchar *thumb_name;
-	thumb_name = g_strndup(mFilename, strlen(mFilename) - 3);
+	if (mURI && mFilename)
+		kz_utils_save_ps_as_thumbnail(mFilename, mURI, mMtime, mSize);
 
-	convert_image(mFilename, thumb_name);
-	g_free(thumb_name);
+	g_free(mURI);
+	g_free(mFilename);
 
-	if (mFilename)
-		g_free(mFilename);
+	mURI = NULL;
 	mFilename = NULL;
-
 }
 
 

Modified: kazehakase/trunk/module/embed/gecko/kz-mozthumbnailprogress.h
===================================================================
--- kazehakase/trunk/module/embed/gecko/kz-mozthumbnailprogress.h	2007-03-27 04:23:31 UTC (rev 3043)
+++ kazehakase/trunk/module/embed/gecko/kz-mozthumbnailprogress.h	2007-03-27 04:43:37 UTC (rev 3044)
@@ -21,6 +21,8 @@
 #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"
 
@@ -30,7 +32,10 @@
 class KzMozThumbnailProgressListener : public nsIWebProgressListener
 {
  public:
-	KzMozThumbnailProgressListener (const char *filename,
+	KzMozThumbnailProgressListener (const gchar *filename,
+					const gchar *uri,
+					time_t mtime,
+					EggPixbufThumbSize size,
 					KzMozThumbnailCreator *creator);
 	virtual ~KzMozThumbnailProgressListener ();
 
@@ -38,7 +43,10 @@
 	NS_DECL_NSIWEBPROGRESSLISTENER
 
  private:
-	char *mFilename;
+	gchar *mFilename;
+	gchar *mURI;
+	time_t mMtime;
+	EggPixbufThumbSize mSize;
 	KzMozThumbnailCreator *mCreator;
 };
 

Modified: kazehakase/trunk/src/actions/Makefile.am
===================================================================
--- kazehakase/trunk/src/actions/Makefile.am	2007-03-27 04:23:31 UTC (rev 3043)
+++ kazehakase/trunk/src/actions/Makefile.am	2007-03-27 04:43:37 UTC (rev 3044)
@@ -10,14 +10,15 @@
 	-DG_LOG_DOMAIN=\"Kazehakase-Actions\" \
 	-DG_DISABLE_DEPRECATED=1
 
-INCLUDES = \
-	$(GTK_CFLAGS) \
-	-I$(top_srcdir)/src/dialogs \
-	-I$(top_srcdir)/src/utils \
-	-I$(top_srcdir)/src/net \
-	-I$(top_srcdir)/src/bookmarks \
-	-I$(top_srcdir)/src/widget \
-	-I$(top_srcdir)/src/libegg/dropdowntoolbutton \
+INCLUDES =						\
+	$(GTK_CFLAGS)					\
+	-I$(top_srcdir)/src/dialogs			\
+	-I$(top_srcdir)/src/utils			\
+	-I$(top_srcdir)/src/net				\
+	-I$(top_srcdir)/src/bookmarks			\
+	-I$(top_srcdir)/src/widget			\
+	-I$(top_srcdir)/src/libegg/dropdowntoolbutton	\
+	-I$(top_srcdir)/src/libegg/pixbufthumbnail	\
 	-I$(top_srcdir)/src
 
 libkzactions_public_h_sources = \

Modified: kazehakase/trunk/src/bookmarks/Makefile.am
===================================================================
--- kazehakase/trunk/src/bookmarks/Makefile.am	2007-03-27 04:23:31 UTC (rev 3043)
+++ kazehakase/trunk/src/bookmarks/Makefile.am	2007-03-27 04:43:37 UTC (rev 3044)
@@ -2,14 +2,15 @@
 
 noinst_LTLIBRARIES = libkzbookmarks.la
 
-INCLUDES = \
-	$(GTK_CFLAGS) \
-	-I$(top_builddir)/src \
-	-I$(top_srcdir)/src/actions \
-	-I$(top_srcdir)/src/utils \
-	-I$(top_srcdir)/src/missing \
-	-I$(top_srcdir)/src/net \
-	-I$(top_srcdir)/src/widget \
+INCLUDES =						\
+	$(GTK_CFLAGS)					\
+	-I$(top_builddir)/src				\
+	-I$(top_srcdir)/src/actions			\
+	-I$(top_srcdir)/src/utils			\
+	-I$(top_srcdir)/src/missing			\
+	-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/dialogs/Makefile.am
===================================================================
--- kazehakase/trunk/src/dialogs/Makefile.am	2007-03-27 04:23:31 UTC (rev 3043)
+++ kazehakase/trunk/src/dialogs/Makefile.am	2007-03-27 04:43:37 UTC (rev 3044)
@@ -2,13 +2,14 @@
 
 noinst_LTLIBRARIES = libkzdialogs.la
 
-INCLUDES = \
-	$(GTK_CFLAGS) \
-	-I$(top_srcdir)/src/actions \
-	-I$(top_srcdir)/src/bookmarks \
-	-I$(top_srcdir)/src/gtk24backports \
-	-I$(top_srcdir)/src/utils \
-	-I$(top_srcdir)/src/widget \
+INCLUDES =						\
+	$(GTK_CFLAGS)					\
+	-I$(top_srcdir)/src/actions			\
+	-I$(top_srcdir)/src/bookmarks			\
+	-I$(top_srcdir)/src/gtk24backports		\
+	-I$(top_srcdir)/src/utils			\
+	-I$(top_srcdir)/src/widget			\
+	-I$(top_srcdir)/src/libegg/pixbufthumbnail	\
 	-I$(top_srcdir)/src
 
 AM_CPPFLAGS= \

Modified: kazehakase/trunk/src/kz-app.c
===================================================================
--- kazehakase/trunk/src/kz-app.c	2007-03-27 04:23:31 UTC (rev 3043)
+++ kazehakase/trunk/src/kz-app.c	2007-03-27 04:43:37 UTC (rev 3044)
@@ -222,9 +222,6 @@
 static void
 prepare_dir (void)
 {
-	/* for thumbnails */
-	make_thumbnails_dir();
-	
 	/* for favicon */
 	make_dir("favicon");
 

Modified: kazehakase/trunk/src/utils/utils.c
===================================================================
--- kazehakase/trunk/src/utils/utils.c	2007-03-27 04:23:31 UTC (rev 3043)
+++ kazehakase/trunk/src/utils/utils.c	2007-03-27 04:43:37 UTC (rev 3044)
@@ -38,7 +38,6 @@
 #include "config.h"
 #include "kazehakase.h"
 #include "kz-search.h"
-#include "egg-pixbuf-thumbnail.h"
 
 #define BUFFER_SIZE 1024
 
@@ -76,26 +75,6 @@
 }
 
 
-void
-make_thumbnails_dir (void)
-{
-	gchar *temp;
-	temp = g_strdup_printf("%s/.thumbnails", g_get_home_dir());
-	if (!g_file_test(temp, G_FILE_TEST_IS_DIR))
-	{
-		g_mkdir(temp, 0711);
-	}
-	g_free(temp);	
-	
-	temp = g_strdup_printf("%s/.thumbnails/large", g_get_home_dir());
-	if (!g_file_test(temp, G_FILE_TEST_IS_DIR))
-	{
-		g_mkdir(temp, 0711);
-	}
-	g_free(temp);	
-}
-
-
 gboolean
 key_seems_sequential (const gchar *key, const gchar *prefix)
 {
@@ -824,19 +803,23 @@
 		return 0;
 }
 
+#ifndef MOZ_NSICANVASRENDERINGCONTEXTINTERNAL_HAVE_GETINPUTSTREAM_
 typedef struct _KzPixbufConverter
 {
 	GdkPixbufLoader *loader;
+	gchar *uri;
 	gchar *filename;
+	time_t mtime;
+	EggPixbufThumbSize size;
 } KzPixbufConverter;
 
 
-#ifndef MOZ_NSICANVASRENDERINGCONTEXTINTERNAL_HAVE_GETINPUTSTREAM_
 static gboolean
 idle_dispose_converter(gpointer data)
 {
 	KzPixbufConverter *converter = data;
 
+	g_free(converter->uri);
 	g_free(converter->filename);
 	g_free(converter);
 
@@ -851,7 +834,7 @@
 	gsize bytes_read;
 	gchar buffer[BUFFER_SIZE];
 	KzPixbufConverter *converter = data;
-	
+
 	if (condition & G_IO_ERR)
 	{
 		g_idle_add(idle_dispose_converter, converter);
@@ -859,7 +842,7 @@
 	}
 
 	/* Read the data into our buffer */
-	iostatus = g_io_channel_read_chars(iochannel, buffer, 
+	iostatus = g_io_channel_read_chars(iochannel, buffer,
 					   sizeof(buffer),
 					   &bytes_read,
 					   NULL);
@@ -874,18 +857,19 @@
 	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, EGG_PIXBUF_THUMB_LARGE,
+			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);
@@ -893,19 +877,18 @@
 			/* save image */
 			if (rotate)
 			{
-				gchar *png_file;
-				png_file = g_strndup(converter->filename,
-						     strlen(converter->filename) - 3);
-				gdk_pixbuf_save(rotate, 
-						png_file, "png", NULL, NULL);
+				egg_pixbuf_add_thumbnail_data(rotate,
+							      converter->uri,
+							      converter->mtime,
+							      converter->size);
+				egg_pixbuf_save_thumbnail(rotate, NULL, NULL);
 				g_object_unref(rotate);
-				g_free(png_file);
 			}
 		}
-		gdk_pixbuf_loader_close(converter->loader, NULL);	
+		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:
@@ -918,9 +901,11 @@
 
 
 void
-convert_image (const gchar *ps_file, const gchar *png_file)
+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";
+	const gchar *gs =
+		"gs -q -dNOPAUSE -dBATCH -r24 -sDEVICE=ppmraw -sOutputFile=- %s";
 	gchar *command;
 	gint argc, out;
 	gchar **argv = NULL;
@@ -930,7 +915,7 @@
 	GdkPixbufLoader *loader;
 	KzPixbufConverter *converter;
 
-	command = g_strdup_printf(gs, ps_file);	
+	command = g_strdup_printf(gs, ps_file);
 
 	g_shell_parse_argv(command,
 			   &argc,
@@ -938,7 +923,7 @@
 			   NULL);
 
         /* Check whether ghostscript is installed or not */
-	if(g_find_program_in_path (argv[0]) == NULL)
+	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]);
@@ -966,8 +951,11 @@
 	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);

Modified: kazehakase/trunk/src/utils/utils.h
===================================================================
--- kazehakase/trunk/src/utils/utils.h	2007-03-27 04:23:31 UTC (rev 3043)
+++ kazehakase/trunk/src/utils/utils.h	2007-03-27 04:43:37 UTC (rev 3044)
@@ -24,10 +24,11 @@
 #include <gtk/gtk.h>
 #include <time.h>
 
+#include "egg-pixbuf-thumbnail.h"
+
 G_BEGIN_DECLS
 
 void     make_dir                    (const gchar *dirname);
-void     make_thumbnails_dir         (void);
 gboolean key_seems_sequential        (const gchar *key,
 				      const gchar *prefix);
 gchar   *remove_tag                  (const gchar *string, gsize len);
@@ -64,8 +65,10 @@
 void     kz_utils_purge_files_by_time_stamp	(const gchar	*target_dir,
 						 const gchar	*time_stamp_path,
 						 time_t		 limit_seconds);
-void	 convert_image		     (const gchar *ps_file,
-				      const gchar *png_file);
+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,




More information about the Kazehakase-cvs mailing list
Back to archive index