svnno****@sourc*****
svnno****@sourc*****
Fri Apr 13 18:37:50 JST 2007
Revision: 3180 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=3180 Author: kous Date: 2007-04-13 18:37:50 +0900 (Fri, 13 Apr 2007) Log Message: ----------- supported thumbnail creation signal. * src/kz-marshalers.list: added VOID:STRING,ENUM. * src/net/Makefile.am (INCLUDES): added -I$(top_srcdir)/src/libegg/pixbufthumbnail. * src/Makefile.am (INCLUDES): added -I$(top_builddir)/src/libegg/pixbufthumbnail. * src/widget/kz-thumbnail.c: connected kz-app:thumbnail-created signal to reflect recent thumbnail creation. * src/kz-tab-label.c (cb_location_changed): added. * module/embed/gecko/MozillaPrivate.cpp (MozillaPrivate::CreateThumbnail), module/embed/gecko/kz-gecko-embed.cpp (kz_gecko_embed_create_thumbnail): used KZ_CREATE_THUMBNAIL(). * src/kazehakase.h: added KZ_CREATE_THUMBNAIL(). * src/kz-app.[ch]: added kz_app_create_thumbnail(). * src/kz-app.c: added thumbnail-created signal. Modified Paths: -------------- kazehakase/trunk/ChangeLog kazehakase/trunk/module/embed/gecko/MozillaPrivate.cpp kazehakase/trunk/module/embed/gecko/kz-gecko-embed.cpp kazehakase/trunk/src/Makefile.am kazehakase/trunk/src/kazehakase.h kazehakase/trunk/src/kz-app.c kazehakase/trunk/src/kz-app.h kazehakase/trunk/src/kz-marshalers.list kazehakase/trunk/src/kz-popup-tablist.c kazehakase/trunk/src/kz-tab-label.c kazehakase/trunk/src/net/Makefile.am kazehakase/trunk/src/widget/kz-thumbnail.c Modified: kazehakase/trunk/ChangeLog =================================================================== --- kazehakase/trunk/ChangeLog 2007-04-13 07:48:34 UTC (rev 3179) +++ kazehakase/trunk/ChangeLog 2007-04-13 09:37:50 UTC (rev 3180) @@ -1,3 +1,29 @@ +2007-04-13 Kouhei Sutou <kou****@cozmi*****> + + * src/kz-marshalers.list: added VOID:STRING,ENUM. + + * src/net/Makefile.am (INCLUDES): added + -I$(top_srcdir)/src/libegg/pixbufthumbnail. + + * src/Makefile.am (INCLUDES): added + -I$(top_builddir)/src/libegg/pixbufthumbnail. + + * src/widget/kz-thumbnail.c: connected kz-app:thumbnail-created + signal to reflect recent thumbnail creation. + + * src/kz-tab-label.c (cb_location_changed): added. + + * module/embed/gecko/MozillaPrivate.cpp + (MozillaPrivate::CreateThumbnail), + module/embed/gecko/kz-gecko-embed.cpp + (kz_gecko_embed_create_thumbnail): used KZ_CREATE_THUMBNAIL(). + + * src/kazehakase.h: added KZ_CREATE_THUMBNAIL(). + + * src/kz-app.[ch]: added kz_app_create_thumbnail(). + + * src/kz-app.c: added thumbnail-created signal. + 2007-04-13 Takuro Ashie <ashie****@homa*****> * configure.ac: Modified: kazehakase/trunk/module/embed/gecko/MozillaPrivate.cpp =================================================================== --- kazehakase/trunk/module/embed/gecko/MozillaPrivate.cpp 2007-04-13 07:48:34 UTC (rev 3179) +++ kazehakase/trunk/module/embed/gecko/MozillaPrivate.cpp 2007-04-13 09:37:50 UTC (rev 3180) @@ -319,7 +319,6 @@ } #ifdef MOZ_NSICANVASRENDERINGCONTEXTINTERNAL_HAVE_GETINPUTSTREAM_ -#include "egg-pixbuf-thumbnail.h" #define KZ_CANVAS_WIDTH 1024 #define KZ_CANVAS_HEIGHT 800 gboolean @@ -394,11 +393,8 @@ if (!thumbnail) return FALSE; - egg_pixbuf_add_thumbnail_data(thumbnail, - uri, - last_modified, - size); - egg_pixbuf_save_thumbnail(thumbnail, NULL, NULL); + KZ_CREATE_THUMBNAIL(thumbnail, uri, last_modified, size); + g_object_unref(thumbnail); g_free(imgData); Modified: kazehakase/trunk/module/embed/gecko/kz-gecko-embed.cpp =================================================================== --- kazehakase/trunk/module/embed/gecko/kz-gecko-embed.cpp 2007-04-13 07:48:34 UTC (rev 3179) +++ kazehakase/trunk/module/embed/gecko/kz-gecko-embed.cpp 2007-04-13 09:37:50 UTC (rev 3180) @@ -2979,11 +2979,7 @@ if (!thumbnail) return; - egg_pixbuf_add_thumbnail_data(thumbnail, - uri, - last_modified, - size); - egg_pixbuf_save_thumbnail(thumbnail, NULL, NULL); + KZ_CREATE_THUMBNAIL(thumbnail, uri, last_modified, size); g_object_unref(thumbnail); #endif Modified: kazehakase/trunk/src/Makefile.am =================================================================== --- kazehakase/trunk/src/Makefile.am 2007-04-13 07:48:34 UTC (rev 3179) +++ kazehakase/trunk/src/Makefile.am 2007-04-13 09:37:50 UTC (rev 3180) @@ -23,17 +23,18 @@ -DG_LOG_DOMAIN=\"Kazehakase\" \ -DG_DISABLE_DEPRECATED=1 -INCLUDES = \ - $(GTK_CFLAGS) \ - $(LIBGNUTLS_CFLAGS) \ - -I$(top_srcdir)/src/actions \ - -I$(top_srcdir)/src/bookmarks \ - -I$(top_srcdir)/src/libegg/pixbufthumbnail \ - -I$(top_srcdir)/src/libegg/md5 \ - -I$(top_srcdir)/src/net \ - -I$(top_srcdir)/src/sidebar \ - -I$(top_srcdir)/src/utils \ - -I$(top_srcdir)/src/widget +INCLUDES = \ + $(GTK_CFLAGS) \ + $(LIBGNUTLS_CFLAGS) \ + -I$(top_srcdir)/src/actions \ + -I$(top_srcdir)/src/bookmarks \ + -I$(top_srcdir)/src/libegg/pixbufthumbnail \ + -I$(top_srcdir)/src/libegg/md5 \ + -I$(top_srcdir)/src/net \ + -I$(top_srcdir)/src/sidebar \ + -I$(top_srcdir)/src/utils \ + -I$(top_srcdir)/src/widget \ + -I$(top_builddir)/src/libegg/pixbufthumbnail EXTRA_DIST = \ kz-marshalers.list Modified: kazehakase/trunk/src/kazehakase.h =================================================================== --- kazehakase/trunk/src/kazehakase.h 2007-04-13 07:48:34 UTC (rev 3179) +++ kazehakase/trunk/src/kazehakase.h 2007-04-13 09:37:50 UTC (rev 3180) @@ -96,6 +96,8 @@ #define KZ_SET_SEARCH(engine_name) kz_app_set_search(kz_app, engine_name) +#define KZ_CREATE_THUMBNAIL(pixbuf, uri, mtime, size) \ + kz_app_create_thumbnail(kz_app, pixbuf, uri, mtime, size) G_END_DECLS Modified: kazehakase/trunk/src/kz-app.c =================================================================== --- kazehakase/trunk/src/kz-app.c 2007-04-13 07:48:34 UTC (rev 3179) +++ kazehakase/trunk/src/kz-app.c 2007-04-13 09:37:50 UTC (rev 3180) @@ -53,10 +53,18 @@ #include "kz-tab-label.h" #include "kz-window.h" #include "kz-history-utils.h" +#include "kz-marshalers.h" #include "glib-utils.h" #include "utils.h" +#include "egg-pixbuf-thumbnail-type-builtins.h" + enum { + THUMBNAIL_CREATED_SIGNAL, + LAST_SIGNAL +}; + +enum { PROP_0, PROP_ARGC, PROP_ARGV @@ -133,6 +141,8 @@ G_DEFINE_TYPE(KzApp, kz_app, G_TYPE_OBJECT) +static gint kz_app_signals[LAST_SIGNAL] = {0}; + static void kz_app_class_init (KzAppClass *klass) { @@ -145,7 +155,19 @@ object_class->dispose = dispose; object_class->set_property = set_property; object_class->get_property = get_property; - + + klass->thumbnail_created = NULL; + + kz_app_signals[THUMBNAIL_CREATED_SIGNAL] + = g_signal_new("thumbnail-created", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (KzAppClass, thumbnail_created), + NULL, NULL, + _kz_marshal_VOID__STRING_ENUM, + G_TYPE_NONE, 2, + G_TYPE_STRING, EGG_TYPE_PIXBUF_THUMB_SIZE); + g_object_class_install_property( object_class, PROP_ARGC, @@ -955,6 +977,38 @@ } #endif +gboolean +kz_app_create_thumbnail (KzApp *app, + GdkPixbuf *pixbuf, + const gchar *uri, + time_t mtime, + EggPixbufThumbSize size) +{ + GError *error = NULL; + + if (!uri) + return FALSE; + + if (uri[0] == '\0') + return FALSE; + + if (!egg_pixbuf_add_thumbnail_data(pixbuf, uri, mtime, size)) + return FALSE; + + if (!egg_pixbuf_save_thumbnail(pixbuf, &error, NULL)) + { + g_warning("create_thumbnail: %s", error->message); + g_error_free(error); + return FALSE; + } + + g_signal_emit(app, kz_app_signals[THUMBNAIL_CREATED_SIGNAL], 0, + uri, size); + + return TRUE; +} + + #ifdef HAVE_LIBSM /* these codes are taken from libgnomeui.*/ Modified: kazehakase/trunk/src/kz-app.h =================================================================== --- kazehakase/trunk/src/kz-app.h 2007-04-13 07:48:34 UTC (rev 3179) +++ kazehakase/trunk/src/kz-app.h 2007-04-13 09:37:50 UTC (rev 3180) @@ -29,6 +29,8 @@ #include "kz-root-bookmark.h" #include "kz-migemo.h" +#include "egg-pixbuf-thumbnail.h" + G_BEGIN_DECLS #define KZ_TYPE_APP (kz_app_get_type ()) @@ -49,6 +51,11 @@ struct _KzAppClass { GObjectClass parent_class; + + /* -- signals -- */ + void (*thumbnail_created) (KzApp *app, + const gchar *uri, + EggPixbufThumbSize size); }; GType kz_app_get_type (void) G_GNUC_CONST; @@ -112,6 +119,12 @@ KzMigemo *kz_app_get_migemo (KzApp *app); #endif +gboolean kz_app_create_thumbnail (KzApp *app, + GdkPixbuf *pixbuf, + const gchar *uri, + time_t mtime, + EggPixbufThumbSize size); + G_END_DECLS #endif /* __KZ_APP_H__ */ Modified: kazehakase/trunk/src/kz-marshalers.list =================================================================== --- kazehakase/trunk/src/kz-marshalers.list 2007-04-13 07:48:34 UTC (rev 3179) +++ kazehakase/trunk/src/kz-marshalers.list 2007-04-13 09:37:50 UTC (rev 3180) @@ -1,5 +1,6 @@ VOID:UINT,STRING VOID:INT,INT +VOID:STRING,ENUM VOID:STRING,INT,INT VOID:STRING,INT,UINT VOID:STRING,STRING Modified: kazehakase/trunk/src/kz-popup-tablist.c =================================================================== --- kazehakase/trunk/src/kz-popup-tablist.c 2007-04-13 07:48:34 UTC (rev 3179) +++ kazehakase/trunk/src/kz-popup-tablist.c 2007-04-13 09:37:50 UTC (rev 3180) @@ -193,7 +193,7 @@ GtkWidget * kz_popup_tablist_new (KzWindow *kz) { - return g_object_new (KZ_TYPE_POPUP_TABLIST, + return g_object_new (KZ_TYPE_POPUP_TABLIST, "type", GTK_WINDOW_POPUP, "kz-window", kz, NULL); @@ -207,14 +207,16 @@ GList *list; gint length, width; - if(priv->now_shown) + if (priv->now_shown) return; + view = kz_thumbnails_view_new(); - kz_thumbnails_view_set_mode(KZ_THUMBNAILS_VIEW(view), KZ_THUMBNAILS_VIEW_PLANE); + kz_thumbnails_view_set_mode(KZ_THUMBNAILS_VIEW(view), + KZ_THUMBNAILS_VIEW_PLANE); gtk_widget_show(view); - if(priv->view) + if (priv->view) { gtk_container_remove(GTK_CONTAINER(priv->popup_frame), priv->view); Modified: kazehakase/trunk/src/kz-tab-label.c =================================================================== --- kazehakase/trunk/src/kz-tab-label.c 2007-04-13 07:48:34 UTC (rev 3179) +++ kazehakase/trunk/src/kz-tab-label.c 2007-04-13 09:37:50 UTC (rev 3180) @@ -119,6 +119,7 @@ /* callbacks for embed */ static void cb_title_changed (KzEmbed *embed, KzTabLabel *kztab); +static void cb_location_changed (KzEmbed *embed, KzTabLabel *kztab); static void cb_net_start (KzEmbed *embed, KzTabLabel *kztab); static void cb_net_stop (KzEmbed *embed, KzTabLabel *kztab); static void cb_progress (KzEmbed *embed, KzTabLabel *kztab); @@ -323,6 +324,8 @@ /* set signals */ g_signal_connect(kztab->kzembed, "kz-title", G_CALLBACK(cb_title_changed), kztab); + g_signal_connect(kztab->kzembed, "kz-location", + G_CALLBACK(cb_location_changed), kztab); g_signal_connect(kztab->kzembed, "kz-net-start", G_CALLBACK(cb_net_start), kztab); g_signal_connect(kztab->kzembed, "kz-net-stop", @@ -363,6 +366,8 @@ g_signal_handlers_disconnect_by_func(kztab->kzembed, cb_title_changed, kztab); g_signal_handlers_disconnect_by_func(kztab->kzembed, + cb_location_changed, kztab); + g_signal_handlers_disconnect_by_func(kztab->kzembed, cb_progress, kztab); g_signal_handlers_disconnect_by_func(kztab->kzembed, cb_destroy, kztab); @@ -1050,6 +1055,24 @@ } static void +cb_location_changed (KzEmbed *embed, KzTabLabel *kztab) +{ + KzBookmark *bookmark = NULL; + guint cur; + GList *children; + + g_return_if_fail(KZ_IS_TAB_LABEL(kztab)); + + cur = kz_bookmark_get_current(kztab->history); + children = kz_bookmark_get_children(kztab->history); + bookmark = KZ_BOOKMARK(g_list_nth_data(children, cur)); + g_list_free(children); + + if (bookmark) + kz_bookmark_set_link(bookmark, kz_embed_get_location(embed)); +} + +static void cb_net_start (KzEmbed *embed, KzTabLabel *kztab) { g_return_if_fail(KZ_IS_TAB_LABEL(kztab)); Modified: kazehakase/trunk/src/net/Makefile.am =================================================================== --- kazehakase/trunk/src/net/Makefile.am 2007-04-13 07:48:34 UTC (rev 3179) +++ kazehakase/trunk/src/net/Makefile.am 2007-04-13 09:37:50 UTC (rev 3180) @@ -2,15 +2,16 @@ noinst_LTLIBRARIES = libkznet.la -INCLUDES = \ - -I$(top_builddir)/src \ - -I$(top_srcdir)/src \ - -I$(top_srcdir)/src/bookmarks \ - -I$(top_srcdir)/src/dialogs \ - -I$(top_srcdir)/src/libegg/md5 \ - -I$(top_srcdir)/src/utils \ - -I$(top_srcdir)/src/missing \ - $(GTK_CFLAGS) \ +INCLUDES = \ + -I$(top_builddir)/src \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/src/bookmarks \ + -I$(top_srcdir)/src/dialogs \ + -I$(top_srcdir)/src/libegg/md5 \ + -I$(top_srcdir)/src/utils \ + -I$(top_srcdir)/src/missing \ + -I$(top_srcdir)/src/libegg/pixbufthumbnail \ + $(GTK_CFLAGS) \ $(LIBGNUTLS_CFLAGS) AM_CPPFLAGS= \ Modified: kazehakase/trunk/src/widget/kz-thumbnail.c =================================================================== --- kazehakase/trunk/src/widget/kz-thumbnail.c 2007-04-13 07:48:34 UTC (rev 3179) +++ kazehakase/trunk/src/widget/kz-thumbnail.c 2007-04-13 09:37:50 UTC (rev 3180) @@ -27,33 +27,99 @@ #include "egg-pixbuf-thumbnail.h" /* object class */ +typedef struct _KzThumbnailPrivate KzThumbnailPrivate; +struct _KzThumbnailPrivate +{ + gchar *uri; + gulong handler_id; +}; +#define KZ_THUMBNAIL_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), KZ_TYPE_THUMBNAIL, KzThumbnailPrivate)) + +static void dispose (GObject *object); + G_DEFINE_TYPE(KzThumbnail, kz_thumbnail, GTK_TYPE_EVENT_BOX) static void kz_thumbnail_class_init (KzThumbnailClass *klass) { + GObjectClass *object_class; + + object_class = (GObjectClass *)klass; + + object_class->dispose = dispose; + + g_type_class_add_private(object_class, sizeof(KzThumbnailPrivate)); } - static void kz_thumbnail_init (KzThumbnail *thumbnail) { + KzThumbnailPrivate *priv = KZ_THUMBNAIL_GET_PRIVATE(thumbnail); + + priv->uri = NULL; + priv->handler_id = 0; + thumbnail->image = gtk_image_new(); gtk_container_add(GTK_CONTAINER(thumbnail), thumbnail->image); gtk_widget_show(thumbnail->image); } +static void +dispose (GObject *object) +{ + KzThumbnailPrivate *priv = KZ_THUMBNAIL_GET_PRIVATE(object); + if (priv->uri) + g_free(priv->uri); + if (priv->handler_id) + g_signal_handler_disconnect(kz_app, priv->handler_id); + + priv->uri = NULL; + priv->handler_id = 0; + + if (G_OBJECT_CLASS (kz_thumbnail_parent_class)->dispose) + G_OBJECT_CLASS (kz_thumbnail_parent_class)->dispose(object); +} + +static void +cb_thumbnail_created (KzApp *app, const gchar *uri, EggPixbufThumbSize size, + gpointer data) +{ + KzThumbnail *thumbnail = data; + KzThumbnailPrivate *priv; + + g_return_if_fail(KZ_IS_THUMBNAIL(thumbnail)); + + if (size != EGG_PIXBUF_THUMB_LARGE) + return; + + priv = KZ_THUMBNAIL_GET_PRIVATE(thumbnail); + if (!priv->uri) + return; + + if (strcmp(priv->uri, uri) != 0) + return; + + kz_thumbnail_set_thumbnail_from_uri(thumbnail, uri); + gtk_widget_queue_draw(GTK_WIDGET(thumbnail)); +} + GtkWidget * kz_thumbnail_new (void) { KzThumbnail *thumbnail; + KzThumbnailPrivate *priv; - thumbnail = g_object_new (KZ_TYPE_THUMBNAIL, + thumbnail = g_object_new (KZ_TYPE_THUMBNAIL, "visible-window", FALSE, NULL); + priv = KZ_THUMBNAIL_GET_PRIVATE(thumbnail); + priv->handler_id = g_signal_connect(kz_app, "thumbnail-created", + G_CALLBACK(cb_thumbnail_created), + thumbnail); + return GTK_WIDGET (thumbnail); } @@ -64,6 +130,25 @@ gtk_image_set_from_pixbuf (GTK_IMAGE(thumbnail->image), pixbuf); } +static void +kz_thumbnail_set_uri (KzThumbnail *thumbnail, const gchar *uri) +{ + KzThumbnailPrivate *priv; + + priv = KZ_THUMBNAIL_GET_PRIVATE(thumbnail); + + if (priv->uri && uri && strcmp(priv->uri, uri) == 0) + return; + + if (priv->uri) + g_free(priv->uri); + + if (uri) + priv->uri = g_strdup(uri); + else + priv->uri = NULL; +} + void kz_thumbnail_set_thumbnail_from_uri (KzThumbnail *thumbnail, const gchar *uri) @@ -71,7 +156,11 @@ GdkPixbuf *pixbuf = NULL; gchar *filename; - if (uri && strlen(uri)) + g_return_if_fail(KZ_IS_THUMBNAIL(thumbnail)); + + kz_thumbnail_set_uri(thumbnail, uri); + + if (uri && uri[0] != '\0') { filename = egg_pixbuf_get_thumb_filename(uri, EGG_PIXBUF_THUMB_LARGE);