svnno****@sourc*****
svnno****@sourc*****
Tue Apr 17 10:30:12 JST 2007
Revision: 3200 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=3200 Author: ikezoe Date: 2007-04-17 10:30:12 +0900 (Tue, 17 Apr 2007) Log Message: ----------- * module/embed/gtk-webcore/kz-gtk-webcore.cpp: We have our own WebiSettings. Modified Paths: -------------- kazehakase/trunk/ChangeLog kazehakase/trunk/module/embed/gtk-webcore/kz-gtk-webcore.cpp Modified: kazehakase/trunk/ChangeLog =================================================================== --- kazehakase/trunk/ChangeLog 2007-04-16 01:51:20 UTC (rev 3199) +++ kazehakase/trunk/ChangeLog 2007-04-17 01:30:12 UTC (rev 3200) @@ -1,3 +1,8 @@ +2007-04-17 Hiroyuki Ikezoe <poinc****@ikezo*****> + + * module/embed/gtk-webcore/kz-gtk-webcore.cpp: We have our own + WebiSettings. + 2007-04-16 Kouhei Sutou <kou****@cozmi*****> * configure.ac: defined GETTEXT_PACKAGE. Modified: kazehakase/trunk/module/embed/gtk-webcore/kz-gtk-webcore.cpp =================================================================== --- kazehakase/trunk/module/embed/gtk-webcore/kz-gtk-webcore.cpp 2007-04-16 01:51:20 UTC (rev 3199) +++ kazehakase/trunk/module/embed/gtk-webcore/kz-gtk-webcore.cpp 2007-04-17 01:30:12 UTC (rev 3200) @@ -47,6 +47,7 @@ gboolean is_loading; gboolean lock; + WebiSettings *settings; }; #define KZ_GTK_WEBCORE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), KZ_TYPE_GTK_WEBCORE, KzGtkWebcorePrivate)) @@ -157,9 +158,6 @@ static void kz_gtk_webcore_set_allow_images (KzEmbed *kzembed, gboolean allow); /* KzEmbedPrefs interfaces */ -static OSB::Preferences *get_osb_preferences (Webi *webi); -static OSB::Features *get_osb_features (Webi *webi); - static void kz_gtk_webcore_prefs_iface_init (KzEmbedPrefsIFace *iface); #if 0 static gboolean kz_gtk_webcore_prefs_init (KzEmbedPrefs *embed_prefs); @@ -376,8 +374,9 @@ } static void -set_font_preferences (KzProfile *profile, OSB::Preferences *preferences) +set_font_preferences (KzProfile *profile, KzGtkWebcore *gtk_webcore) { + WebiSettings *settings = KZ_GTK_WEBCORE_GET_PRIVATE(gtk_webcore)->settings; /* font settings */ GList *list, *node; gint i = 0; @@ -455,8 +454,8 @@ kz_profile_get_value(profile, "Font", key, &value, strlen(value)+1, KZ_PROFILE_VALUE_TYPE_STRING); - preferences->setSerifFontFamily(value); - preferences->setStandardFontFamily(value); + settings->serif_font_family = g_strdup(value); + settings->standard_font_family = g_strdup(value); } else if (!strcmp(key, sans_font)) { @@ -464,7 +463,7 @@ kz_profile_get_value(profile, "Font", key, &value, strlen(value)+1, KZ_PROFILE_VALUE_TYPE_STRING); - preferences->setSansSerifFontFamily(value); + settings->sans_serif_font_family = g_strdup(value); } else if (!strcmp(key, mono_font)) { @@ -472,7 +471,7 @@ kz_profile_get_value(profile, "Font", key, &value, strlen(value)+1, KZ_PROFILE_VALUE_TYPE_STRING); - preferences->setFixedFontFamily(value); + settings->fixed_font_family = g_strdup(value); } } g_list_free(list); @@ -481,13 +480,13 @@ g_free(mono_font); if (size_variable >= 0) - preferences->setDefaultFontSize((float)size_variable); + settings->default_font_size = (gfloat)size_variable; if (size_fixed >= 0) - preferences->setDefaultFixedFontSize((float)size_fixed); + settings->default_fixed_font_size = (gfloat)size_fixed; if (min_size_variable >= 0) - preferences->setMinimumLogicalFontSize((float)min_size_variable); + settings->minimum_font_size = (gfloat)min_size_variable; if (min_size_fixed >= 0) - preferences->setMinimumFontSize((float)min_size_fixed); + settings->minimum_font_size = (gfloat)min_size_fixed; } static void @@ -506,6 +505,7 @@ static void set_user_agent (KzProfile *profile, KzGtkWebcore *gtk_webcore) { + WebiSettings *settings = KZ_GTK_WEBCORE_GET_PRIVATE(gtk_webcore)->settings; gchar tmp_string[1024]; gboolean value = FALSE; kz_profile_get_value(profile, "Global", "override_user_agent", @@ -521,15 +521,14 @@ { build_user_agent(tmp_string, G_N_ELEMENTS(tmp_string)); } - OSB::Root *engine = 0; - engine = static_cast<OSB::Root*>(webi_get_internal(WEBI(gtk_webcore))); - engine->setUserAgentString(tmp_string); + settings->user_agent_string = g_strdup(tmp_string); } static void set_proxy (KzProfile *profile, KzGtkWebcore *gtk_webcore) { + WebiSettings *settings = KZ_GTK_WEBCORE_GET_PRIVATE(gtk_webcore)->settings; gchar tmp_string[1024]; gchar *http_host, *https_host, *ftp_host; guint http_port, https_port, ftp_port; @@ -576,25 +575,18 @@ NULL); } - OSB::Root *engine = 0; - OSB::ProtocolDelegate *delegate = 0; - engine = static_cast<OSB::Root*>(webi_get_internal(WEBI(gtk_webcore))); - /* proxy for HTTP protocol */ - delegate = engine->protocolDelegateForURL("http://"); - if (delegate && http_host) - delegate->setProxy(http_host); - + if (http_host) + settings->http_proxy = g_strdup(http_host); +#if 0 /* proxy for HTTPS protocol */ - delegate = engine->protocolDelegateForURL("https://"); - if (delegate && https_host) - delegate->setProxy(https_host); + if (https_host) + settings->https_proxy = g_strdup(https_host); /* proxy for FTP protocol */ - delegate = engine->protocolDelegateForURL("ftp://"); - if (delegate && ftp_host) - delegate->setProxy(ftp_host); - + if (ftp_host) + settings->ftp_proxy = g_strdup(ftp_host); +#endif if (http_host) g_free(http_host); if (https_host) @@ -606,28 +598,28 @@ static void set_default_preferences (KzGtkWebcore *gtk_webcore) { - KzProfile *profile; + KzGtkWebcorePrivate *priv = KZ_GTK_WEBCORE_GET_PRIVATE (gtk_webcore); + WebiSettings *settings = priv->settings; + KzProfile *profile = KZ_GET_GLOBAL_PROFILE; - OSB::Preferences *preferences = get_osb_preferences(WEBI(gtk_webcore)); - profile = KZ_GET_GLOBAL_PROFILE; - gchar value[1024]; if (kz_profile_get_value(profile, "Language", "charset_default", &value, G_N_ELEMENTS(value), KZ_PROFILE_VALUE_TYPE_STRING)) { - preferences->setDefaultTextEncoding(value); + settings->default_text_encoding = g_strdup(value); } set_user_agent(profile, gtk_webcore); - set_font_preferences (profile, preferences); + set_font_preferences (profile, gtk_webcore); set_proxy(profile, gtk_webcore); - preferences->setPluginsEnabled(TRUE); - + settings->plugins_enabled = TRUE; +#if 0 OSB::Features *features = get_osb_features(WEBI(gtk_webcore)); features->setToolbarsVisible(FALSE); features->setStatusBarVisible(FALSE); +#endif } static void @@ -642,12 +634,37 @@ priv->button_press_time = 0; + priv->settings = g_new0(WebiSettings, 1); + set_default_preferences(gtk_webcore); webi_set_emit_internal_status(WEBI(gtk_webcore), TRUE); gtk_widget_show(GTK_WIDGET(gtk_webcore)); } static void +free_webi_settings (WebiSettings *settings) +{ + if (settings->default_text_encoding) + g_free((gchar*)settings->default_text_encoding); + if (settings->serif_font_family) + g_free((gchar*)settings->serif_font_family); + if (settings->sans_serif_font_family) + g_free((gchar*)settings->sans_serif_font_family); + if (settings->fixed_font_family) + g_free((gchar*)settings->fixed_font_family); + if (settings->standard_font_family) + g_free((gchar*)settings->standard_font_family); + if (settings->cursive_font_family) + g_free((gchar*)settings->cursive_font_family); + if (settings->fantasy_font_family) + g_free((gchar*)settings->fantasy_font_family); + if (settings->user_agent_string) + g_free((gchar*)settings->user_agent_string); + if (settings->http_proxy) + g_free((gchar*)settings->http_proxy); +} + +static void kz_gtk_webcore_dispose (GObject *object) { KzGtkWebcorePrivate *priv = KZ_GTK_WEBCORE_GET_PRIVATE(object); @@ -656,6 +673,13 @@ g_free(priv->link_message); priv->link_message = NULL; + if (priv->settings) + { + free_webi_settings(priv->settings); + g_free(priv->settings); + } + priv->settings = NULL; + if (G_OBJECT_CLASS(kz_gtk_webcore_parent_class)->dispose) G_OBJECT_CLASS(kz_gtk_webcore_parent_class)->dispose(object); } @@ -1251,38 +1275,14 @@ return FALSE; } -static OSB::Preferences * -get_osb_preferences (Webi *webi) -{ - OSB::Root *engine = 0; - engine = static_cast<OSB::Root*>(webi_get_internal(webi)); - - OSB::Preferences *preferences = 0; - preferences = static_cast<OSB::Preferences*>(engine->preferences()); - - return preferences; -} - -static OSB::Features * -get_osb_features (Webi *webi) -{ - OSB::Root *engine = 0; - engine = static_cast<OSB::Root*>(webi_get_internal(webi)); - - OSB::Features *features = 0; - features = static_cast<OSB::Features*>(engine->features()); - - return features; -} - static gboolean kz_gtk_webcore_get_allow_javascript (KzEmbed *kzembed) { g_return_val_if_fail(KZ_IS_GTK_WEBCORE(kzembed), FALSE); - OSB::Preferences *preferences = get_osb_preferences(WEBI(kzembed)); + WebiSettings *settings = KZ_GTK_WEBCORE_GET_PRIVATE(kzembed)->settings; - return preferences->javaScriptEnabled() ? TRUE : FALSE; + return settings->javascript_enabled ? TRUE : FALSE; } static void @@ -1290,9 +1290,9 @@ { g_return_if_fail(KZ_IS_GTK_WEBCORE(kzembed)); - OSB::Preferences *preferences = get_osb_preferences(WEBI(kzembed)); + WebiSettings *settings = KZ_GTK_WEBCORE_GET_PRIVATE(kzembed)->settings; - preferences->setJavaScriptEnabled(allow ? true : false); + settings->javascript_enabled = allow; } static gboolean @@ -1300,9 +1300,9 @@ { g_return_val_if_fail(KZ_IS_GTK_WEBCORE(kzembed), FALSE); - OSB::Preferences *preferences = get_osb_preferences(WEBI(kzembed)); + WebiSettings *settings = KZ_GTK_WEBCORE_GET_PRIVATE(kzembed)->settings; - return preferences->willLoadImagesAutomatically() ? TRUE : FALSE; + return settings->autoload_images; } static void @@ -1310,9 +1310,9 @@ { g_return_if_fail(KZ_IS_GTK_WEBCORE(kzembed)); - OSB::Preferences *preferences = get_osb_preferences(WEBI(kzembed)); + WebiSettings *settings = KZ_GTK_WEBCORE_GET_PRIVATE(kzembed)->settings; - preferences->setWillLoadImagesAutomatically(allow ? true : false); + settings->autoload_images = allow; } static gboolean