[Kazehakase-cvs] kazehakase-svn [2964] * module/embed/gecko/mozilla.[ch],

Back to archive index

svnno****@sourc***** svnno****@sourc*****
Fri Mar 23 09:50:44 JST 2007


Revision: 2964
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=2964
Author:   ikezoe
Date:     2007-03-23 09:50:43 +0900 (Fri, 23 Mar 2007)

Log Message:
-----------
* module/embed/gecko/mozilla.[ch],
module/embed/gecko/kz-gecko-single.cpp: Some functions were moved in
KzGeckoSingle.

Modified Paths:
--------------
    kazehakase/trunk/ChangeLog
    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-22 23:45:42 UTC (rev 2963)
+++ kazehakase/trunk/ChangeLog	2007-03-23 00:50:43 UTC (rev 2964)
@@ -3,6 +3,9 @@
 	* src/prefs_ui/prefs_general.c: Removed kz_embed_prefs codes.
 	* module/embed/gecko/mozilla.cpp,
 	module/embed/gecko/mozilla-prefs.cpp: Set User-Agent in mozilla.cpp.
+	* module/embed/gecko/mozilla.[ch],
+	module/embed/gecko/kz-gecko-single.cpp: Some functions were moved in
+	KzGeckoSingle.
 
 2007-03-22  Kouhei Sutou  <kou****@cozmi*****>
 

Modified: kazehakase/trunk/module/embed/gecko/kz-gecko-single.cpp
===================================================================
--- kazehakase/trunk/module/embed/gecko/kz-gecko-single.cpp	2007-03-22 23:45:42 UTC (rev 2963)
+++ kazehakase/trunk/module/embed/gecko/kz-gecko-single.cpp	2007-03-23 00:50:43 UTC (rev 2964)
@@ -22,10 +22,13 @@
 #  include "config.h"
 #endif /* HAVE_CONFIG_H */
 
+#include <nsBuildID.h>
+#include <sys/utsname.h>
 #include <glib/gi18n.h>
 #include "kz-gecko-single.h"
 #include "kz-app.h"
 #include "mozilla.h"
+#include "mozilla-prefs.h"
 
 enum
 {
@@ -54,6 +57,18 @@
                               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_profile_changed (KzProfile *profile,
+				const gchar *section,
+				const gchar *key,
+				const gchar *old_value,
+				gpointer data);
+
 static KzGeckoSingle    *the_kz_gecko_single = NULL;
 
 G_DEFINE_TYPE(KzGeckoSingle, kz_gecko_single, G_TYPE_OBJECT)
@@ -62,6 +77,7 @@
 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;
@@ -70,6 +86,8 @@
 	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,
@@ -92,13 +110,29 @@
 	if (!the_kz_gecko_single) 
 	{
 		KzGeckoSinglePrivate *priv;
+		KzProfile *profile;
 		GObjectClass *klass = G_OBJECT_CLASS(kz_gecko_single_parent_class);
 		object = klass->constructor(type, n_props, props);
 
 		the_kz_gecko_single = KZ_GECKO_SINGLE(object);
 
 		priv = KZ_GECKO_SINGLE_GET_PRIVATE(object);
-		mozilla_init(kz_app_get_profile(priv->kz_app));
+		
+		profile = kz_app_get_profile(priv->kz_app);
+
+		mozilla_prefs_init();
+
+		gtk_moz_embed_set_comp_path(MOZILLA_HOME);
+
+		gtk_moz_embed_push_startup();
+
+		mozilla_prefs_set(profile);
+		set_user_agent(profile);
+
+		g_signal_connect(profile, "changed::Global",
+				G_CALLBACK(cb_profile_changed), NULL);
+
+		mozilla_register_components();
 	}
 	else
 	{
@@ -163,7 +197,7 @@
 
 	if (priv->kz_app)
 	{
-		mozilla_exit();
+		gtk_moz_embed_pop_startup();
 		g_object_unref(priv->kz_app);
 	}
 
@@ -177,10 +211,115 @@
 KzGeckoSingle *
 kz_gecko_single_new (KzApp *kz_app)
 {
-	KzGeckoSingle *single = KZ_GECKO_SINGLE(g_object_new(KZ_TYPE_GECKO_SINGLE,
+	return KZ_GECKO_SINGLE(g_object_new(KZ_TYPE_GECKO_SINGLE,
 				    "kz-app", kz_app,
 				    NULL));
+}
 
-	return single;
+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_profile_changed (KzProfile *profile,
+		    const gchar *section,
+		    const gchar *key,
+		    const gchar *old_value,
+		    gpointer data)
+{
+	gchar tmp_string[1024];
+	gboolean value = FALSE;
+
+	switch (key[0])
+	{
+	case 'o': // override_user_agent
+		if (strcmp(key, "override_user_agent") == 0)
+		{
+			set_user_agent(profile);
+		}
+		break;
+	case 'p':
+		if (strcmp(key, "proxy_name") == 0 &&
+		    KZ_CONF_GET(section, key, tmp_string, STRING))
+		{
+			KzProxyItem *item = kz_proxy_find(tmp_string);
+			if (item) {
+				mozilla_prefs_set_proxy(item);
+				g_object_unref(G_OBJECT(item));
+			}
+		}
+		break;
+	case 'u': // user_agent or use_proxy
+		if (strcmp(key, "use_proxy") == 0 &&
+		    KZ_CONF_GET(section, key, value, BOOL))
+		{
+			mozilla_prefs_set_use_proxy(value);
+		}
+		else if (strcmp(key, "user_agent") == 0)
+		{
+			set_user_agent(profile);
+		}
+		break;
+	}
+}
+
+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-22 23:45:42 UTC (rev 2963)
+++ kazehakase/trunk/module/embed/gecko/mozilla.cpp	2007-03-23 00:50:43 UTC (rev 2964)
@@ -23,7 +23,6 @@
 #	include "config.h"
 #endif
 
-#include <gtkmozembed.h>
 #include <nsCOMPtr.h>
 #include <nsXPCOM.h>
 #include <nsIGenericFactory.h>
@@ -37,8 +36,6 @@
 #include <nsIPassword.h>
 #endif
 #include <nsIIDNService.h>
-#include <nsBuildID.h>
-#include <sys/utsname.h>
 
 #include "mozilla.h"
 #include "mozilla-prefs.h"
@@ -155,7 +152,7 @@
 }
 #endif
 
-static gboolean
+gboolean
 mozilla_register_components (void)
 {
 	gboolean ret = TRUE;
@@ -196,159 +193,6 @@
 }
 
 
-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);
-}
-
-
-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_profile_changed (KzProfile *profile,
-		    const gchar *section,
-		    const gchar *key,
-		    const gchar *old_value,
-		    gpointer data)
-{
-	gchar tmp_string[1024];
-	gboolean value = FALSE;
-
-	switch (key[0])
-	{
-	case 'o': // override_user_agent
-		if (strcmp(key, "override_user_agent") == 0)
-		{
-			set_user_agent(profile);
-		}
-		break;
-	case 'p':
-		if (strcmp(key, "proxy_name") == 0 &&
-		    KZ_CONF_GET(section, key, tmp_string, STRING))
-		{
-			KzProxyItem *item = kz_proxy_find(tmp_string);
-			if (item) {
-				mozilla_prefs_set_proxy(item);
-				g_object_unref(G_OBJECT(item));
-			}
-		}
-		break;
-	case 'u': // user_agent or use_proxy
-		if (strcmp(key, "use_proxy") == 0 &&
-		    KZ_CONF_GET(section, key, value, BOOL))
-		{
-			mozilla_prefs_set_use_proxy(value);
-		}
-		else if (strcmp(key, "user_agent") == 0)
-		{
-			set_user_agent(profile);
-		}
-		break;
-	}
-}
-
-
-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);
-	set_user_agent(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);
-
-	g_signal_connect(profile, "changed::Global",
-			 G_CALLBACK(cb_profile_changed), NULL);
-
-
-	mozilla_register_components();
-}
-
-
-void
-mozilla_exit (void)
-{
-	gtk_moz_embed_pop_startup();
-}
-
-
 gboolean
 mozilla_get_passwords (GList **passwords)
 {

Modified: kazehakase/trunk/module/embed/gecko/mozilla.h
===================================================================
--- kazehakase/trunk/module/embed/gecko/mozilla.h	2007-03-22 23:45:42 UTC (rev 2963)
+++ kazehakase/trunk/module/embed/gecko/mozilla.h	2007-03-23 00:50:43 UTC (rev 2964)
@@ -21,14 +21,11 @@
 #ifndef __MOZILLA_H__
 #define __MOZILLA_H__
 
-#include <gtk/gtk.h>
-#include "kz-profile.h"
+#include <glib.h>
 
 G_BEGIN_DECLS
 
-void      mozilla_init                 (KzProfile *profile);
-void      mozilla_exit                 (void);
-
+gboolean  mozilla_register_components  (void);
 gboolean  mozilla_get_passwords        (GList **passwords);
 gboolean  mozilla_remove_passwords     (GList *passwords);
 




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