svnno****@sourc*****
svnno****@sourc*****
Fri Mar 30 12:10:33 JST 2007
Revision: 3101 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=3101 Author: ikezoe Date: 2007-03-30 12:10:33 +0900 (Fri, 30 Mar 2007) Log Message: ----------- * module/embd/gecko/kz-moz-single.cpp, module/embed/gecko/mozilla.[cpp|h], module/embed/gecko/gtkmozembed.h: Partially revert rev.2964 to prevent unpredictable crash. Modified Paths: -------------- kazehakase/trunk/ChangeLog kazehakase/trunk/module/embed/gecko/gtkmozembed.h kazehakase/trunk/module/embed/gecko/kz-gecko-single.cpp kazehakase/trunk/module/embed/gecko/mozilla.cpp kazehakase/trunk/module/embed/gecko/mozilla.h Modified: kazehakase/trunk/ChangeLog =================================================================== --- kazehakase/trunk/ChangeLog 2007-03-30 00:14:13 UTC (rev 3100) +++ kazehakase/trunk/ChangeLog 2007-03-30 03:10:33 UTC (rev 3101) @@ -1,3 +1,9 @@ +2007-03-30 Hiroyuki Ikezoe <poinc****@ikezo*****> + + * module/embd/gecko/kz-moz-single.cpp, + module/embed/gecko/mozilla.[cpp|h], module/embed/gecko/gtkmozembed.h: + Partially revert rev.2964 to prevent unpredictable crash. + 2007-03-30 Kouhei Sutou <kou****@cozmi*****> * src/kz-xml.c (kz_xml_node_insert_before): ref and ... Modified: kazehakase/trunk/module/embed/gecko/gtkmozembed.h =================================================================== --- kazehakase/trunk/module/embed/gecko/gtkmozembed.h 2007-03-30 00:14:13 UTC (rev 3100) +++ kazehakase/trunk/module/embed/gecko/gtkmozembed.h 2007-03-30 03:10:33 UTC (rev 3101) @@ -226,6 +226,9 @@ GtkMozEmbedSingle * gtk_moz_embed_single_get(void) G_GNUC_CONST; +#define GTK_TYPE_MOZ_EMBED_SINGLE (gtk_moz_embed_single_get_type()) +GType gtk_moz_embed_single_get_type(void); + G_END_DECLS #endif /* gtkmozembed_h */ Modified: kazehakase/trunk/module/embed/gecko/kz-gecko-single.cpp =================================================================== --- kazehakase/trunk/module/embed/gecko/kz-gecko-single.cpp 2007-03-30 00:14:13 UTC (rev 3100) +++ kazehakase/trunk/module/embed/gecko/kz-gecko-single.cpp 2007-03-30 03:10:33 UTC (rev 3101) @@ -58,12 +58,7 @@ GValue *value, GParamSpec *pspec); -static void new_window_orphan (GtkMozEmbedSingle *embed, - GtkMozEmbed **retval, - guint chromemask); -static void set_user_agent (KzProfile *profile); - static void cb_global_profile_changed (KzProfile *profile, const gchar *section, const gchar *key, @@ -93,7 +88,6 @@ kz_gecko_single_class_init (KzGeckoSingleClass *klass) { GObjectClass *object_class; - GtkMozEmbedSingleClass *mozembed_single_class; kz_gecko_single_parent_class = g_type_class_peek_parent (klass); object_class = (GObjectClass *) klass; @@ -102,8 +96,6 @@ object_class->dispose = dispose; object_class->set_property = set_property; object_class->get_property = get_property; -#warning FIXME! - mozembed_single_class->new_window_orphan = NULL; //new_window_orphan; g_object_class_install_property( object_class, @@ -138,13 +130,8 @@ mozilla_prefs_init(); - gtk_moz_embed_set_comp_path(MOZILLA_HOME); + mozilla_init(profile); - gtk_moz_embed_push_startup(); - - mozilla_prefs_set(profile); - set_user_agent(profile); - g_signal_connect(profile, "changed::Global", G_CALLBACK(cb_global_profile_changed), NULL); g_signal_connect(profile, "changed::Font", @@ -153,8 +140,6 @@ G_CALLBACK(cb_lang_profile_changed), NULL); g_signal_connect(profile, "changed::Privacy", G_CALLBACK(cb_privacy_profile_changed), NULL); - - mozilla_register_components(); } else { @@ -238,51 +223,7 @@ NULL)); } -static void -build_user_agent (gchar *user_agent, gint size) -{ - struct utsname name; - gchar *system; - if (uname (&name) >= 0) - { - system = g_strdup_printf ("%s %s", - name.sysname, - name.machine); - } - else - { - system = g_strdup ("Unknown"); - } - - g_snprintf(user_agent, size, - "Mozilla/5.0 (X11; %s; U;) Gecko/%d Kazehakase/" VERSION, - system, - NS_BUILD_ID/100); - g_free (system); -} - -static void -set_user_agent (KzProfile *profile) -{ - gchar tmp_string[1024]; - gboolean value = FALSE; - kz_profile_get_value(profile, "Global", "override_user_agent", - &value, sizeof(gboolean), - KZ_PROFILE_VALUE_TYPE_BOOL); - if (value) - { - value = kz_profile_get_value(profile, "Global", "user_agent", - &tmp_string, G_N_ELEMENTS(tmp_string), - KZ_PROFILE_VALUE_TYPE_STRING); - } - else /* set default */ - { - build_user_agent(tmp_string, G_N_ELEMENTS(tmp_string)); - } - mozilla_prefs_set_string("general.useragent.override", tmp_string); -} - static gchar * convert_preference_name (const gchar *prefix, const gchar *key) { @@ -363,6 +304,51 @@ } static void +build_user_agent (gchar *user_agent, gint size) +{ + struct utsname name; + gchar *system; + + if (uname (&name) >= 0) + { + system = g_strdup_printf ("%s %s", + name.sysname, + name.machine); + } + else + { + system = g_strdup ("Unknown"); + } + + g_snprintf(user_agent, size, + "Mozilla/5.0 (X11; %s; U;) Gecko/%d Kazehakase/" VERSION, + system, + NS_BUILD_ID/100); + g_free (system); +} + +static void +set_user_agent (KzProfile *profile) +{ + gchar tmp_string[1024]; + gboolean value = FALSE; + kz_profile_get_value(profile, "Global", "override_user_agent", + &value, sizeof(gboolean), + KZ_PROFILE_VALUE_TYPE_BOOL); + if (value) + { + value = kz_profile_get_value(profile, "Global", "user_agent", + &tmp_string, G_N_ELEMENTS(tmp_string), + KZ_PROFILE_VALUE_TYPE_STRING); + } + else /* set default */ + { + build_user_agent(tmp_string, G_N_ELEMENTS(tmp_string)); + } + mozilla_prefs_set_string("general.useragent.override", tmp_string); +} + +static void cb_global_profile_changed (KzProfile *profile, const gchar *section, const gchar *key, @@ -501,22 +487,3 @@ } } -static void -destroy_browser_cb (GtkMozEmbed *embed, GtkWidget *transient_window) -{ - gtk_widget_destroy(GTK_WIDGET(transient_window)); -} - - -static void -new_window_orphan (GtkMozEmbedSingle *embed, GtkMozEmbed **retval, guint chromemask) -{ - // FIXME! but I don't have any nice idea... - GtkWidget *newWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); - GtkMozEmbed *newBrowser = GTK_MOZ_EMBED(gtk_moz_embed_new()); - - gtk_container_add(GTK_CONTAINER(newWindow), GTK_WIDGET(newBrowser)); - g_signal_connect(newBrowser,"destroy_browser", - G_CALLBACK(destroy_browser_cb),newWindow); - *retval = GTK_MOZ_EMBED(newBrowser); -} Modified: kazehakase/trunk/module/embed/gecko/mozilla.cpp =================================================================== --- kazehakase/trunk/module/embed/gecko/mozilla.cpp 2007-03-30 00:14:13 UTC (rev 3100) +++ kazehakase/trunk/module/embed/gecko/mozilla.cpp 2007-03-30 03:10:33 UTC (rev 3101) @@ -23,6 +23,7 @@ # include "config.h" #endif +#include <gtkmozembed.h> #include <nsCOMPtr.h> #include <nsXPCOM.h> #include <nsIGenericFactory.h> @@ -30,8 +31,11 @@ #define MOZILLA_INTERNAL_API #include <nsIServiceManager.h> #undef MOZILLA_INTERNAL_API +#include <nsBuildID.h> +#include <sys/utsname.h> #include "mozilla.h" +#include "mozilla-prefs.h" #include "kz-mozfilepicker.h" #include "kz-mozlauncher.h" #include "kz-mozprogresslistener.h" @@ -142,7 +146,7 @@ } #endif -gboolean +static gboolean mozilla_register_components (void) { gboolean ret = TRUE; @@ -182,3 +186,60 @@ return ret; } +static void +destroy_browser_cb (GtkMozEmbed *embed, GtkWidget *transient_window) +{ + gtk_widget_destroy(GTK_WIDGET(transient_window)); +} + + +static void +new_window_orphan_cb (GtkMozEmbedSingle *embed, GtkMozEmbed **retval, + guint chromemask, gpointer data) +{ + // FIXME! but I don't have any nice idea... + GtkWidget *newWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); + GtkMozEmbed *newBrowser = GTK_MOZ_EMBED(gtk_moz_embed_new()); + + gtk_container_add(GTK_CONTAINER(newWindow), GTK_WIDGET(newBrowser)); + g_signal_connect(newBrowser,"destroy_browser", + G_CALLBACK(destroy_browser_cb),newWindow); + *retval = GTK_MOZ_EMBED(newBrowser); +} + +void +mozilla_init (KzProfile *profile) +{ + GtkMozEmbedSingle *single = NULL; + + mozilla_prefs_init(); + + gtk_moz_embed_set_comp_path(MOZILLA_HOME); + + gtk_moz_embed_push_startup(); +#warning FIXME! + mozilla_prefs_set(profile); + + // + // get the singleton object and hook up to its new window callback + // so we can create orphaned windows. + // + single = gtk_moz_embed_single_get(); + if (!single) { + g_error("Failed to get singleton embed object!"); + return; + } + + g_signal_connect(single, "new_window_orphan", + G_CALLBACK(new_window_orphan_cb), NULL); + + mozilla_register_components(); +} + + +void +mozilla_exit (void) +{ + gtk_moz_embed_pop_startup(); +} + Modified: kazehakase/trunk/module/embed/gecko/mozilla.h =================================================================== --- kazehakase/trunk/module/embed/gecko/mozilla.h 2007-03-30 00:14:13 UTC (rev 3100) +++ kazehakase/trunk/module/embed/gecko/mozilla.h 2007-03-30 03:10:33 UTC (rev 3101) @@ -22,10 +22,12 @@ #define __MOZILLA_H__ #include <glib.h> +#include "kz-profile.h" G_BEGIN_DECLS -gboolean mozilla_register_components (void); +void mozilla_init (KzProfile *profile); +void mozilla_exit (void); G_END_DECLS