svnno****@sourc*****
svnno****@sourc*****
Sun Mar 25 12:39:06 JST 2007
Revision: 2998 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=2998 Author: ikezoe Date: 2007-03-25 12:39:06 +0900 (Sun, 25 Mar 2007) Log Message: ----------- * module/embed/khtml/*, src/kz-window.c: Renamed. kz-ktml -> kt-gtk-webcore. Modified Paths: -------------- kazehakase/trunk/module/embed/khtml/Makefile.am kazehakase/trunk/src/kz-window.c Added Paths: ----------- kazehakase/trunk/module/embed/khtml/kz-gtk-webcore.c kazehakase/trunk/module/embed/khtml/kz-gtk-webcore.h Removed Paths: ------------- kazehakase/trunk/module/embed/khtml/kz-khtml.c kazehakase/trunk/module/embed/khtml/kz-khtml.h Modified: kazehakase/trunk/module/embed/khtml/Makefile.am =================================================================== --- kazehakase/trunk/module/embed/khtml/Makefile.am 2007-03-25 01:42:32 UTC (rev 2997) +++ kazehakase/trunk/module/embed/khtml/Makefile.am 2007-03-25 03:39:06 UTC (rev 2998) @@ -1,7 +1,7 @@ # -*- Mode: Makefile; tab-width: 8; indent-tabs-mode: t; -*- CLEANFILES = *~ *.bak -embed_LTLIBRARIES = khtml.la +embed_LTLIBRARIES = gtk-webcore.la INCLUDES = \ $(NRCIT_CFLAGS) \ @@ -18,15 +18,15 @@ -DGDK_DISABLE_DEPRECATED=1 \ -DG_DISABLE_DEPRECATED=1 -khtml_la_LDFLAGS = \ +gtk_webcore_la_LDFLAGS = \ -avoid-version \ -module \ -export-dynamic $(no_undefined) \ $(LIBTOOL_EXPORT_OPTIONS) -khtml_la_SOURCES = \ - kz-khtml.c kz-khtml.h +gtk_webcore_la_SOURCES = \ + kz-gtk-webcore.c kz-gtk-webcore.h -khtml_la_LIBADD = \ +gtk_webcore_la_LIBADD = \ $(GTK_LIBS) \ $(NRCIT_LIBS) Copied: kazehakase/trunk/module/embed/khtml/kz-gtk-webcore.c (from rev 2997, kazehakase/trunk/module/embed/khtml/kz-khtml.c) =================================================================== --- kazehakase/trunk/module/embed/khtml/kz-khtml.c 2007-03-25 01:42:32 UTC (rev 2997) +++ kazehakase/trunk/module/embed/khtml/kz-gtk-webcore.c 2007-03-25 03:39:06 UTC (rev 2998) @@ -0,0 +1,970 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/* + * Copyright (C) 2004 Takuro Ashie + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + */ + +#include <glib/gi18n.h> +#include <math.h> + +#include "kz-module-impl.h" +#include "kz-gtk-webcore.h" +#include "kz-embed-prefs.h" +#include "kz-embed.h" +#include "kz-prompt-dialog.h" +#include "gobject-utils.h" + +typedef struct _KzGtkWebcorePrivate KzGtkWebcorePrivate; +struct _KzGtkWebcorePrivate +{ + gint cur_requests; + gint total_requests; + gchar *link_message; + guint32 button_press_time; +}; +#define KZ_GTK_WEBCORE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), KZ_TYPE_GTK_WEBCORE, KzGtkWebcorePrivate)) + +static GType kz_type_gtk_webcore = 0; +static WebiClass *kz_gtk_webcore_parent_class; + +GtkWidget *kz_gtk_webcore_new (void); +static void kz_gtk_webcore_class_init (KzGtkWebcoreClass *klass); +static void kz_gtk_webcore_iface_init (KzEmbedIFace *iface); +static void kz_gtk_webcore_init (KzGtkWebcore *gtk_webcore); +static void kz_gtk_webcore_dispose (GObject *object); + +#if 0 +/* widget class */ +static gboolean button_press (GtkWidget *widget, + GdkEventButton *event); +static gboolean button_release (GtkWidget *widget, + GdkEventButton *event); +#endif + +/* gtk_webcore class */ +static void kz_gtk_webcore_status (Webi *gtk_webcore, + WebiLoadStatus *status); +static void kz_gtk_webcore_load_start (Webi *gtk_webcore); +static void kz_gtk_webcore_load_stop (Webi *gtk_webcore); +static void kz_gtk_webcore_location (Webi *gtk_webcore); +static void kz_gtk_webcore_title (Webi *gtk_webcore); +static void kz_gtk_webcore_req_js_prompt (Webi *gtk_webcore, + WebiPromptArgs* args); +static void kz_gtk_webcore_req_auth_prompt (Webi *gtk_webcore, + WebiAuthArgs* args); +static Webi *kz_gtk_webcore_req_new_window (Webi *gtk_webcore, + const gchar *url); +static void kz_gtk_webcore_close_window (Webi *gtk_webcore); +static void kz_gtk_webcore_mouse_over (Webi *gtk_webcore, + const gchar *link_title, + const gchar *link_label, + const gchar *link_url, + const gchar *link_target); +#if 0 +static gboolean kz_gtk_webcore_mouse_down (Webi *gtk_webcore, + const gchar *link_url, + guint button); +static gboolean kz_gtk_webcore_mouse_up (Webi *gtk_webcore, + const gchar *link_url, + guint button); +#endif +/* embed iface */ +static void kz_gtk_webcore_load_url (KzEmbed *kzembed, + const gchar *url); +static gboolean kz_gtk_webcore_is_loading (KzEmbed *kzembed); +static const gchar *kz_gtk_webcore_get_title (KzEmbed *kzembed); +static const gchar *kz_gtk_webcore_get_location (KzEmbed *kzembed); +static gchar *kz_gtk_webcore_ensure_title (KzEmbed *kzembed); +static gchar *kz_gtk_webcore_get_link_message (KzEmbed *kzembed); + +static void kz_gtk_webcore_reload (KzEmbed *kzembed, + KzEmbedReloadFlag flags); +static void kz_gtk_webcore_stop_load (KzEmbed *kzembed); +static void kz_gtk_webcore_go_back (KzEmbed *kzembed); +static void kz_gtk_webcore_go_forward (KzEmbed *kzembed); +static gboolean kz_gtk_webcore_can_go_back (KzEmbed *kzembed); +static gboolean kz_gtk_webcore_can_go_forward (KzEmbed *kzembed); +static gboolean kz_gtk_webcore_can_go_nav_link (KzEmbed *kzembed, + KzEmbedNavLink link); +static void kz_gtk_webcore_go_nav_link (KzEmbed *kzembed, + KzEmbedNavLink link); +static void kz_gtk_webcore_set_nth_nav_link (KzEmbed *kzembed, + KzEmbedNavLink link, + KzNavi *navi, + guint n); +static KzNavi *kz_gtk_webcore_get_nth_nav_link (KzEmbed *kzembed, + KzEmbedNavLink link, + guint n); +static GList *kz_gtk_webcore_get_nav_links (KzEmbed *kzembed, + KzEmbedNavLink link); + +static gboolean kz_gtk_webcore_can_cut_selection (KzEmbed *kzembed); +static gboolean kz_gtk_webcore_can_copy_selection (KzEmbed *kzembed); +static gboolean kz_gtk_webcore_can_paste (KzEmbed *kzembed); +static void kz_gtk_webcore_cut_selection (KzEmbed *kzembed); +static void kz_gtk_webcore_copy_selection (KzEmbed *kzembed); +static void kz_gtk_webcore_paste (KzEmbed *kzembed); +static void kz_gtk_webcore_select_all (KzEmbed *kzembed); + +static gdouble kz_gtk_webcore_get_progress (KzEmbed *kzembed); + +static gint kz_gtk_webcore_get_text_size (KzEmbed *kzembed); +static void kz_gtk_webcore_set_text_size (KzEmbed *kzembed, + gint zoom, + gboolean reflow); + +static gboolean kz_gtk_webcore_find (KzEmbed *kzembed, + const char *keyword, + gboolean backward); + +static gboolean kz_gtk_webcore_selection_is_collapsed (KzEmbed *kzembed); + +/* KzEmbedPrefs interfaces */ +static void kz_gtk_webcore_prefs_iface_init (KzEmbedPrefsIFace *iface); +#if 0 +static gboolean kz_gtk_webcore_prefs_init (KzEmbedPrefs *embed_prefs); +static gboolean kz_gtk_webcore_prefs_get_font_list (KzEmbedPrefs *embed_prefs, + const gchar *lang_group, + const gchar *font_type, + GList **font_list, + GList **all_font_list, + gchar **default_font); +static gboolean kz_gtk_webcore_prefs_get_passwords (KzEmbedPrefs *embed_prefs, + GList **passwords); +static gboolean kz_gtk_webcore_prefs_remove_passwords(KzEmbedPrefs *embed_prefs, + GList *passwords); +#endif +static void +kz_gtk_webcore_register_type (GTypeModule *module) +{ + static const GTypeInfo kz_gtk_webcore_info = + { + sizeof (KzGtkWebcoreClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) kz_gtk_webcore_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (KzGtkWebcore), + 0, /* n_preallocs */ + (GInstanceInitFunc) kz_gtk_webcore_init, + }; + + const GInterfaceInfo kz_embed_info = + { + (GInterfaceInitFunc) kz_gtk_webcore_iface_init, + NULL, + NULL + }; + + const GInterfaceInfo kz_embed_prefs_info = + { + (GInterfaceInitFunc) kz_gtk_webcore_prefs_iface_init, + NULL, + NULL + }; + + kz_type_gtk_webcore = g_type_module_register_type(module, + WEBI_TYPE_WEBI, + "KzGtkWebcore", + &kz_gtk_webcore_info, + (GTypeFlags)0); + + g_type_module_add_interface(module, + KZ_TYPE_GTK_WEBCORE, + KZ_TYPE_EMBED, + &kz_embed_info); + + g_type_module_add_interface(module, + KZ_TYPE_GTK_WEBCORE, + KZ_TYPE_EMBED_PREFS, + &kz_embed_prefs_info); +} + +G_MODULE_EXPORT void +KZ_MODULE_IMPL_INIT (GTypeModule *module) +{ + kz_gtk_webcore_register_type(module); +} + +G_MODULE_EXPORT void +KZ_MODULE_IMPL_EXIT (void) +{ +} + +G_MODULE_EXPORT GObject * +KZ_MODULE_IMPL_INSTANTIATE (const gchar *first_property, + va_list var_args) +{ + return g_object_new_valist(KZ_TYPE_GTK_WEBCORE, first_property, var_args); +} + +GType +kz_gtk_webcore_get_type (void) +{ + return kz_type_gtk_webcore; +} + +static void +kz_gtk_webcore_class_init (KzGtkWebcoreClass *klass) +{ + GObjectClass *object_class; + GtkWidgetClass *widget_class; + WebiClass *gtk_webcore_class; + + kz_gtk_webcore_parent_class = g_type_class_peek_parent (klass); + object_class = (GObjectClass *) klass; + widget_class = (GtkWidgetClass *) klass; + gtk_webcore_class = (WebiClass *) klass; + + object_class->dispose = kz_gtk_webcore_dispose; +#if 0 + widget_class->button_press_event = button_press; + widget_class->button_release_event = button_release; +#endif + gtk_webcore_class->status = kz_gtk_webcore_status; + gtk_webcore_class->load_start = kz_gtk_webcore_load_start; + gtk_webcore_class->load_stop = kz_gtk_webcore_load_stop; + gtk_webcore_class->location = kz_gtk_webcore_location; + gtk_webcore_class->title = kz_gtk_webcore_title; +#if 0 + gtk_webcore_class->progress = kz_gtk_webcore_progress; +#endif + gtk_webcore_class->req_js_prompt = kz_gtk_webcore_req_js_prompt; + gtk_webcore_class->req_auth_prompt = kz_gtk_webcore_req_auth_prompt; + gtk_webcore_class->req_new_window = kz_gtk_webcore_req_new_window; + gtk_webcore_class->close_window = kz_gtk_webcore_close_window; + gtk_webcore_class->mouse_over = kz_gtk_webcore_mouse_over; +#if 0 + gtk_webcore_class->mouse_down = kz_gtk_webcore_mouse_down; + gtk_webcore_class->mouse_up = kz_gtk_webcore_mouse_up; +#endif + g_type_class_add_private (object_class, sizeof(KzGtkWebcorePrivate)); +} + + +static void +kz_gtk_webcore_iface_init (KzEmbedIFace *iface) +{ + iface->load_url = kz_gtk_webcore_load_url; + iface->view_source = NULL; + iface->is_loading = kz_gtk_webcore_is_loading; + iface->get_title = kz_gtk_webcore_get_title; + iface->get_location = kz_gtk_webcore_get_location; + iface->ensure_title = kz_gtk_webcore_ensure_title; + iface->get_link_message = kz_gtk_webcore_get_link_message; + iface->get_progress = kz_gtk_webcore_get_progress; + iface->can_cut_selection = kz_gtk_webcore_can_cut_selection; + iface->can_copy_selection = kz_gtk_webcore_can_copy_selection; + iface->can_paste = kz_gtk_webcore_can_paste; + iface->cut_selection = kz_gtk_webcore_cut_selection; + iface->copy_selection = kz_gtk_webcore_copy_selection; + iface->paste = kz_gtk_webcore_paste; + iface->select_all = kz_gtk_webcore_select_all; + iface->get_selection_string = NULL; + iface->find = kz_gtk_webcore_find; + iface->incremental_search = kz_gtk_webcore_find; /* tentavie */ + iface->selection_is_collapsed = kz_gtk_webcore_selection_is_collapsed; + iface->get_links = NULL; + iface->copy_page = NULL; + iface->shistory_copy = NULL; + iface->shistory_get_pos = NULL; + iface->shistory_get_nth = NULL; + iface->reload = kz_gtk_webcore_reload; + iface->stop_load = kz_gtk_webcore_stop_load; + iface->go_back = kz_gtk_webcore_go_back; + iface->go_forward = kz_gtk_webcore_go_forward; + iface->can_go_back = kz_gtk_webcore_can_go_back; + iface->can_go_forward = kz_gtk_webcore_can_go_forward; + iface->can_go_nav_link = kz_gtk_webcore_can_go_nav_link; + iface->go_nav_link = kz_gtk_webcore_go_nav_link; + iface->append_nav_link = NULL; + iface->set_nav_link = NULL; + iface->set_nth_nav_link = kz_gtk_webcore_set_nth_nav_link; + iface->get_nav_link = NULL; + iface->get_nth_nav_link = kz_gtk_webcore_get_nth_nav_link; + iface->get_nav_links = kz_gtk_webcore_get_nav_links; + iface->go_history_index = NULL; + iface->do_command = NULL; + iface->can_do_command = NULL; + iface->get_lock = NULL; + iface->set_lock = NULL; + iface->get_body_text = NULL; +#if 0 + iface->get_selection_source = NULL; +#endif + iface->set_encoding = NULL; + iface->get_encoding = NULL; + iface->print = NULL; + iface->print_preview = NULL; + iface->get_printer_list = NULL; + iface->create_thumbnail = NULL; + iface->save_with_content = NULL; + iface->set_text_into_textarea = NULL; + iface->get_text_from_textarea = NULL; + iface->zoom_set = kz_gtk_webcore_set_text_size; /* tentative */ + iface->zoom_get = kz_gtk_webcore_get_text_size; /* tentative */ + iface->set_text_size = kz_gtk_webcore_set_text_size; + iface->get_text_size = kz_gtk_webcore_get_text_size; + iface->get_html_with_contents = NULL; + iface->set_history = NULL; + iface->get_history = NULL; + iface->get_last_modified = NULL; + iface->fine_scroll = NULL; + iface->page_up = NULL; + iface->page_down = NULL; + iface->get_allow_javascript = NULL; + iface->set_allow_javascript = NULL; + iface->get_allow_images = NULL; + iface->set_allow_images = NULL; +#if 0 + iface->set_edit_mode = NULL; + iface->set_view_mode = NULL; +#endif + + iface->link_message = NULL; + iface->js_status = NULL; + iface->location = NULL; + iface->title = NULL; + iface->progress = NULL; + iface->net_start = NULL; + iface->net_stop = NULL; + iface->new_window = NULL; + iface->open_uri = NULL; + iface->size_to = NULL; + iface->dom_key_down = NULL; + iface->dom_key_press = NULL; + iface->dom_key_up = NULL; + iface->dom_mouse_down = NULL; + iface->dom_mouse_up = NULL; + iface->dom_mouse_click = NULL; + iface->dom_mouse_dbl_click = NULL; + iface->dom_mouse_over = NULL; + iface->dom_mouse_out = NULL; + iface->security_change = NULL; + iface->status_change = NULL; +} + + +static void +kz_gtk_webcore_prefs_iface_init (KzEmbedPrefsIFace *iface) +{ + iface->init = NULL; /* kz_gtk_webcore_prefs_init;*/ + iface->get_font_list = NULL; /* kz_gtk_webcore_prefs_get_font_list; */ + iface->get_passwords = NULL; /* kz_gtk_webcore_prefs_get_passwords; */ + iface->remove_passwords = NULL; /* kz_gtk_webcore_prefs_remove_passwords; */ +} + +static void +kz_gtk_webcore_init (KzGtkWebcore *gtk_webcore) +{ + KzGtkWebcorePrivate *priv = KZ_GTK_WEBCORE_GET_PRIVATE (gtk_webcore); + + gtk_webcore->is_loading = FALSE; + priv->cur_requests = 0; + priv->total_requests = 0; + priv->link_message = NULL; + + priv->button_press_time = 0; + + gtk_widget_show_all(GTK_WIDGET(gtk_webcore)); +} + +static void +kz_gtk_webcore_dispose (GObject *object) +{ + KzGtkWebcorePrivate *priv = KZ_GTK_WEBCORE_GET_PRIVATE(object); + + if (priv->link_message) + g_free(priv->link_message); + priv->link_message = NULL; + + if (G_OBJECT_CLASS(kz_gtk_webcore_parent_class)->dispose) + G_OBJECT_CLASS(kz_gtk_webcore_parent_class)->dispose(object); +} + +#if 0 +static gboolean +button_press (GtkWidget *widget, GdkEventButton *event) +{ + if (GTK_WIDGET_CLASS(kz_gtk_webcore_parent_class)->button_press_event) + return GTK_WIDGET_CLASS(kz_gtk_webcore_parent_class)->button_press_event(widget, event); + + return FALSE; +} + +static gboolean +button_release (GtkWidget *widget, GdkEventButton *event) +{ + if (GTK_WIDGET_CLASS(kz_gtk_webcore_parent_class)->button_press_event) + return GTK_WIDGET_CLASS(kz_gtk_webcore_parent_class)->button_press_event(widget, event); + return FALSE; +} +#endif + +GtkWidget * +kz_gtk_webcore_new (void) +{ + return GTK_WIDGET(g_object_new(KZ_TYPE_GTK_WEBCORE, NULL)); +} + + +static void +kz_gtk_webcore_status (Webi *gtk_webcore, WebiLoadStatus *status) +{ + KzGtkWebcorePrivate *priv; + g_return_if_fail(KZ_IS_GTK_WEBCORE(gtk_webcore)); + g_return_if_fail(status); + + priv = KZ_GTK_WEBCORE_GET_PRIVATE (gtk_webcore); + + switch(status->status) { + case WEBI_LOADING_START: + KZ_GTK_WEBCORE(gtk_webcore)->is_loading = TRUE; + priv->cur_requests = 0; + priv->total_requests = 0; + g_signal_emit_by_name(gtk_webcore, "kz-net-start"); + break; + case WEBI_LOADING: + priv->cur_requests = status->totalReceived; + priv->total_requests = status->totalSize; + g_signal_emit_by_name(gtk_webcore, "kz-progress"); + break; + case WEBI_LOADING_COMPLETE: + case WEBI_LOADING_ERROR: + KZ_GTK_WEBCORE(gtk_webcore)->is_loading = FALSE; + priv->cur_requests = status->totalReceived; + priv->total_requests = status->totalSize; + g_signal_emit_by_name(gtk_webcore, "kz-net-stop"); + break; + default: + break; + } + + /* call parent method */ +} + + +static void +kz_gtk_webcore_load_start (Webi *gtk_webcore) +{ + g_return_if_fail(KZ_IS_GTK_WEBCORE(gtk_webcore)); + + KZ_GTK_WEBCORE(gtk_webcore)->is_loading = TRUE; + + g_signal_emit_by_name(gtk_webcore, "kz-net-start"); + + /* call parent method */ +} + + +static void +kz_gtk_webcore_load_stop (Webi *gtk_webcore) +{ + g_return_if_fail(KZ_IS_GTK_WEBCORE(gtk_webcore)); + + KZ_GTK_WEBCORE(gtk_webcore)->is_loading = FALSE; + + g_signal_emit_by_name(gtk_webcore, "kz-net-stop"); + + /* call parent method */ +} + + +static void +kz_gtk_webcore_location (Webi *gtk_webcore) +{ + g_return_if_fail(KZ_IS_GTK_WEBCORE(gtk_webcore)); + + g_signal_emit_by_name(gtk_webcore, "kz-location"); + + /* call parent method */ +} + + +static void +kz_gtk_webcore_title (Webi *gtk_webcore) +{ + g_return_if_fail(KZ_IS_GTK_WEBCORE(gtk_webcore)); + + g_signal_emit_by_name(gtk_webcore, "kz-title"); + + /* call parent method */ +} + + +static void +kz_gtk_webcore_req_js_prompt (Webi *gtk_webcore, WebiPromptArgs* args) +{ + g_return_if_fail(KZ_IS_GTK_WEBCORE(gtk_webcore)); +} + + +static void +kz_gtk_webcore_req_auth_prompt (Webi *gtk_webcore, WebiAuthArgs* args) +{ + KzPromptDialog *prompt; + + g_return_if_fail(KZ_IS_GTK_WEBCORE(gtk_webcore)); + + prompt= KZ_PROMPT_DIALOG(kz_prompt_dialog_new(TYPE_PROMPT_USER_PASS)); + + kz_prompt_dialog_set_title(prompt, _("Authentication")); + kz_prompt_dialog_run(prompt); + + args->out_ok_pressed = kz_prompt_dialog_get_confirm_value(prompt); + args->out_username = g_strdup(kz_prompt_dialog_get_user(prompt)); + args->out_password = g_strdup(kz_prompt_dialog_get_password(prompt)); + + gtk_widget_destroy(GTK_WIDGET(prompt)); +} + + +static Webi * +kz_gtk_webcore_req_new_window (Webi *gtk_webcore, const gchar *url) +{ + Webi *newgtk_webcore = NULL; + g_return_val_if_fail(KZ_IS_GTK_WEBCORE(gtk_webcore), NULL); + + g_signal_emit_by_name(gtk_webcore, "kz-new-window", &newgtk_webcore); + + return newgtk_webcore; +} + +static void +kz_gtk_webcore_close_window (Webi *gtk_webcore) +{ + g_return_if_fail(KZ_IS_GTK_WEBCORE(gtk_webcore)); + + gtk_widget_destroy(GTK_WIDGET(gtk_webcore)); +} + +static void +get_mouse_event_info(KzEmbedEventMouse **kzevent) +{ + GdkModifierType state = (GdkModifierType)0; + gint x, y; + KzEmbedEventMouse *ret; + + gdk_window_get_pointer(NULL, &x, &y, &state); + ret = (KzEmbedEventMouse *) kz_embed_event_new(KZ_EMBED_EVENT_MOUSE); + + ret->x = x; + ret->y = y; + if (state & GDK_SHIFT_MASK) + ret->modifier |= KZ_SHIFT_KEY; + if (state & GDK_CONTROL_MASK) + ret->modifier |= KZ_CTRL_KEY; + if (state & GDK_MOD1_MASK) + ret->modifier |= KZ_ALT_KEY; + if (state & GDK_META_MASK) + ret->modifier |= KZ_META_KEY; + + *kzevent = ret; +} + +static void +kz_gtk_webcore_mouse_over (Webi *gtk_webcore, + const gchar *link_title, + const gchar *link_label, + const gchar *link_url, + const gchar *link_target) +{ + KzEmbedEventMouse *kzevent; + gint ret = FALSE; + KzGtkWebcorePrivate *priv; + g_return_if_fail(KZ_IS_GTK_WEBCORE(gtk_webcore)); + + priv = KZ_GTK_WEBCORE_GET_PRIVATE(gtk_webcore); + get_mouse_event_info(&kzevent); + + if (!link_url) + { + if (priv->link_message) + { + g_free(priv->link_message); + priv->link_message = NULL; + g_signal_emit_by_name(gtk_webcore, "kz-link-message"); + } + } + else + { + KzEmbedEvent *info = (KzEmbedEvent *) kzevent; + info->context = KZ_CONTEXT_LINK; + info->link = g_strdup(link_url); + info->linktext = g_strdup(link_label); + + if (priv->link_message) + g_free(priv->link_message); + + priv->link_message = g_strdup(link_url); + + g_signal_emit_by_name(gtk_webcore, "kz-link-message"); + } + + g_signal_emit_by_name(gtk_webcore, "kz-dom-mouse-over", + kzevent, &ret); + kz_embed_event_free((KzEmbedEvent *) kzevent); +} + +#if 0 +static gboolean +kz_gtk_webcore_mouse_down (Webi *gtk_webcore, + const gchar *link_url, + guint button) +{ + KzEmbedEventMouse *kzevent; + gint ret = FALSE; + KzGtkWebcorePrivate *priv; + g_return_val_if_fail(KZ_IS_GTK_WEBCORE(gtk_webcore), FALSE); + + priv = KZ_GTK_WEBCORE_GET_PRIVATE(gtk_webcore); + priv->button_press_time = GDK_CURRENT_TIME; + + get_mouse_event_info(&kzevent); + kzevent->button = button - 1; + + g_signal_emit_by_name(gtk_webcore, "kz-dom-mouse-down", + kzevent, &ret); + kz_embed_event_free((KzEmbedEvent *) kzevent); + + return ret; +} + +static gboolean +kz_gtk_webcore_mouse_up (Webi *gtk_webcore, + const gchar *link_url, + guint button) +{ + KzEmbedEventMouse *kzevent; + gint ret = FALSE; + KzGtkWebcorePrivate *priv; + g_return_val_if_fail(KZ_IS_GTK_WEBCORE(gtk_webcore), FALSE); + + priv = KZ_GTK_WEBCORE_GET_PRIVATE(gtk_webcore); + + get_mouse_event_info(&kzevent); + kzevent->button = button - 1; + + g_signal_emit_by_name(gtk_webcore, "kz-dom-mouse-up", + kzevent, &ret); + + if (!ret && GDK_CURRENT_TIME < priv->button_press_time + 1000) + { + if (link_url) + { + ((KzEmbedEvent *)kzevent)->context = KZ_CONTEXT_LINK; + ((KzEmbedEvent *)kzevent)->link = g_strdup(link_url); + } + + g_signal_emit_by_name(gtk_webcore, "kz-dom-mouse-click", + kzevent, &ret); + } + priv->button_press_time = 0; + + kz_embed_event_free((KzEmbedEvent *) kzevent); + + return ret; +} +#endif + +static gboolean +kz_gtk_webcore_is_loading (KzEmbed *kzembed) +{ + g_return_val_if_fail(KZ_IS_GTK_WEBCORE(kzembed), FALSE); + + return KZ_GTK_WEBCORE(kzembed)->is_loading; +} + + +static void +kz_gtk_webcore_load_url (KzEmbed *kzembed, const gchar *url) +{ + g_return_if_fail(KZ_IS_GTK_WEBCORE(kzembed)); + + webi_load_url(WEBI(kzembed), url); +} + + +static const gchar * +kz_gtk_webcore_get_title (KzEmbed *kzembed) +{ + g_return_val_if_fail(KZ_IS_GTK_WEBCORE(kzembed), NULL); + + return webi_get_title(WEBI(kzembed)); +} + + +static const gchar * +kz_gtk_webcore_get_location (KzEmbed *kzembed) +{ + g_return_val_if_fail(KZ_IS_GTK_WEBCORE(kzembed), NULL); + + return webi_get_location(WEBI(kzembed)); +} + +static gchar * +kz_gtk_webcore_get_link_message (KzEmbed *kzembed) +{ + g_return_val_if_fail(KZ_IS_GTK_WEBCORE(kzembed), NULL); + + return g_strdup(KZ_GTK_WEBCORE_GET_PRIVATE(kzembed)->link_message); +} + +static gchar * +kz_gtk_webcore_ensure_title (KzEmbed *kzembed) +{ + const gchar *title; + + title = kz_gtk_webcore_get_title(kzembed); + if (title) + return g_strdup(title); + + title = kz_gtk_webcore_get_location(kzembed); + if (title) + return g_strdup(title); + + return g_strdup(_("No title")); +} + +static void +kz_gtk_webcore_reload (KzEmbed *kzembed, KzEmbedReloadFlag flags) +{ + g_return_if_fail(KZ_IS_GTK_WEBCORE(kzembed)); + + webi_refresh (WEBI(kzembed)); +} + + +static void +kz_gtk_webcore_stop_load (KzEmbed *kzembed) +{ + g_return_if_fail(KZ_IS_GTK_WEBCORE(kzembed)); + + webi_stop_load (WEBI(kzembed)); +} + + +static void +kz_gtk_webcore_go_back (KzEmbed *kzembed) +{ + g_return_if_fail(KZ_IS_GTK_WEBCORE(kzembed)); + + return webi_go_back (WEBI(kzembed)); +} + + +static void +kz_gtk_webcore_go_forward (KzEmbed *kzembed) +{ + g_return_if_fail(KZ_IS_GTK_WEBCORE(kzembed)); + + return webi_go_forward (WEBI(kzembed)); +} + + +static gboolean +kz_gtk_webcore_can_go_back (KzEmbed *kzembed) +{ + g_return_val_if_fail(KZ_IS_GTK_WEBCORE(kzembed), FALSE); + + return webi_can_go_back (WEBI(kzembed)); +} + + +static gboolean +kz_gtk_webcore_can_go_forward (KzEmbed *kzembed) +{ + g_return_val_if_fail(KZ_IS_GTK_WEBCORE(kzembed), FALSE); + + return webi_can_go_forward (WEBI(kzembed)); +} + + +static gboolean +kz_gtk_webcore_can_go_nav_link (KzEmbed *kzembed, KzEmbedNavLink link) +{ + g_return_val_if_fail(KZ_IS_GTK_WEBCORE(kzembed), FALSE); + + return FALSE; +} + +static void +kz_gtk_webcore_go_nav_link (KzEmbed *kzembed, KzEmbedNavLink link) +{ + g_return_if_fail(KZ_IS_GTK_WEBCORE(kzembed)); + + return; +} + +static void +kz_gtk_webcore_set_nth_nav_link (KzEmbed *kzembed, + KzEmbedNavLink link, + KzNavi *navi, + guint n) +{ + g_return_if_fail(KZ_IS_GTK_WEBCORE(kzembed)); + + return; +} + +static KzNavi * +kz_gtk_webcore_get_nth_nav_link (KzEmbed *kzembed, + KzEmbedNavLink link, + guint n) +{ + g_return_val_if_fail(KZ_IS_GTK_WEBCORE(kzembed), NULL); + + return NULL; +} + +static GList * +kz_gtk_webcore_get_nav_links (KzEmbed *kzembed, + KzEmbedNavLink link) +{ + g_return_val_if_fail(KZ_IS_GTK_WEBCORE(kzembed), NULL); + + return NULL; +} + +static gdouble +kz_gtk_webcore_get_progress (KzEmbed *kzembed) +{ + gdouble progress; + KzGtkWebcore *gtk_webcore; + KzGtkWebcorePrivate *priv; + + g_return_val_if_fail(KZ_IS_GTK_WEBCORE(kzembed), 0.0); + + priv = KZ_GTK_WEBCORE_GET_PRIVATE (kzembed); + + gtk_webcore = KZ_GTK_WEBCORE(kzembed); + if (priv->total_requests <= 0 || + priv->cur_requests <= 0) + { + return 0.0; + } + + progress = (gdouble) priv->cur_requests + / (gdouble) priv->total_requests; + + if (progress > 1.0) + return 1.0; + + return progress; +} + + +static gint +kz_gtk_webcore_get_text_size (KzEmbed *kzembed) +{ + gfloat multiplier; + + g_return_val_if_fail(KZ_IS_GTK_WEBCORE(kzembed), 100); + + multiplier = webi_get_text_multiplier (WEBI(kzembed)); + + if (multiplier == -1.0) return 100; + + return (gint) rint(multiplier * 100); +} + + +static void +kz_gtk_webcore_set_text_size (KzEmbed *kzembed, gint zoom, gboolean reflow) +{ + gfloat multiplier; + + g_return_if_fail(KZ_IS_GTK_WEBCORE(kzembed)); + + multiplier = (gfloat)(zoom) / 100; + + webi_set_text_multiplier (WEBI(kzembed), + multiplier); +} + + +static gboolean +kz_gtk_webcore_find (KzEmbed *kzembed, const char *keyword, gboolean backward) +{ + g_return_val_if_fail(KZ_IS_GTK_WEBCORE(kzembed), FALSE); + + return webi_find(WEBI(kzembed), keyword, FALSE, backward); +} + +static gboolean +kz_gtk_webcore_can_cut_selection (KzEmbed *kzembed) +{ + g_return_val_if_fail(KZ_IS_GTK_WEBCORE(kzembed), FALSE); + + /* not implemented yet */ + return FALSE; +} + +static gboolean +kz_gtk_webcore_can_copy_selection (KzEmbed *kzembed) +{ + g_return_val_if_fail(KZ_IS_GTK_WEBCORE(kzembed), FALSE); + /* not implemented yet */ + return FALSE; +} + +static gboolean +kz_gtk_webcore_can_paste (KzEmbed *kzembed) +{ + g_return_val_if_fail(KZ_IS_GTK_WEBCORE(kzembed), FALSE); + /* not implemented yet */ + return FALSE; +} + +static void +kz_gtk_webcore_cut_selection (KzEmbed *kzembed) +{ + /* not implemented yet */ + return; +} + +static void +kz_gtk_webcore_copy_selection (KzEmbed *kzembed) +{ + /* not implemented yet */ + return; +} + +static void +kz_gtk_webcore_paste (KzEmbed *kzembed) +{ + /* not implemented yet */ + return; +} + +static void +kz_gtk_webcore_select_all (KzEmbed *kzembed) +{ + /* not implemented yet */ + return; +} + +static gboolean +kz_gtk_webcore_selection_is_collapsed (KzEmbed *kzembed) +{ + /* not implemented yet */ + return FALSE; +} + Copied: kazehakase/trunk/module/embed/khtml/kz-gtk-webcore.h (from rev 2994, kazehakase/trunk/module/embed/khtml/kz-khtml.h) =================================================================== --- kazehakase/trunk/module/embed/khtml/kz-khtml.h 2007-03-25 01:05:05 UTC (rev 2994) +++ kazehakase/trunk/module/embed/khtml/kz-gtk-webcore.h 2007-03-25 03:39:06 UTC (rev 2998) @@ -0,0 +1,59 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +/* + * Copyright (C) 2004 Takuro Ashie + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ + */ + +#ifndef __KZ_GTK_WEBCORE_H__ +#define __KZ_GTK_WEBCORE_H__ + +#include <gtk/gtk.h> +#include <webi.h> + +G_BEGIN_DECLS + +#define KZ_TYPE_GTK_WEBCORE (kz_gtk_webcore_get_type ()) +#define KZ_GTK_WEBCORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KZ_TYPE_GTK_WEBCORE, KzGtkWebcore)) +#define KZ_GTK_WEBCORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KZ_TYPE_GTK_WEBCORE, KzGtkWebcoreClass)) +#define KZ_IS_GTK_WEBCORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KZ_TYPE_GTK_WEBCORE)) +#define KZ_IS_GTK_WEBCORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), KZ_TYPE_GTK_WEBCORE)) +#define KZ_GTK_WEBCORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KZ_TYPE_GTK_WEBCORE, KzGtkWebcoreClass)) + +typedef struct _KzGtkWebcore KzGtkWebcore; +typedef struct _KzGtkWebcoreClass KzGtkWebcoreClass; + +struct _KzGtkWebcore +{ + /* embedding widget */ + Webi parent; + + gboolean is_loading; +}; + +struct _KzGtkWebcoreClass +{ + WebiClass parent_class; +}; + + +GType kz_gtk_webcore_get_type (void) G_GNUC_CONST; + +G_END_DECLS + +#endif /* __KZ_GTK_WEBCORE_H__ */ Deleted: kazehakase/trunk/module/embed/khtml/kz-khtml.c =================================================================== --- kazehakase/trunk/module/embed/khtml/kz-khtml.c 2007-03-25 01:42:32 UTC (rev 2997) +++ kazehakase/trunk/module/embed/khtml/kz-khtml.c 2007-03-25 03:39:06 UTC (rev 2998) @@ -1,970 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Copyright (C) 2004 Takuro Ashie - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - */ - -#include <glib/gi18n.h> -#include <math.h> - -#include "kz-module-impl.h" -#include "kz-khtml.h" -#include "kz-embed-prefs.h" -#include "kz-embed.h" -#include "kz-prompt-dialog.h" -#include "gobject-utils.h" - -typedef struct _KzKHTMLPrivate KzKHTMLPrivate; -struct _KzKHTMLPrivate -{ - gint cur_requests; - gint total_requests; - gchar *link_message; - guint32 button_press_time; -}; -#define KZ_KHTML_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), KZ_TYPE_KHTML, KzKHTMLPrivate)) - -static GType kz_type_khtml = 0; -static WebiClass *kz_khtml_parent_class; - -GtkWidget *kz_khtml_new (void); -static void kz_khtml_class_init (KzKHTMLClass *klass); -static void kz_khtml_iface_init (KzEmbedIFace *iface); -static void kz_khtml_init (KzKHTML *khtml); -static void kz_khtml_dispose (GObject *object); - -#if 0 -/* widget class */ -static gboolean button_press (GtkWidget *widget, - GdkEventButton *event); -static gboolean button_release (GtkWidget *widget, - GdkEventButton *event); -#endif - -/* khtml class */ -static void kz_khtml_status (Webi *khtml, - WebiLoadStatus *status); -static void kz_khtml_load_start (Webi *khtml); -static void kz_khtml_load_stop (Webi *khtml); -static void kz_khtml_location (Webi *khtml); -static void kz_khtml_title (Webi *khtml); -static void kz_khtml_req_js_prompt (Webi *khtml, - WebiPromptArgs* args); -static void kz_khtml_req_auth_prompt (Webi *khtml, - WebiAuthArgs* args); -static Webi *kz_khtml_req_new_window (Webi *khtml, - const gchar *url); -static void kz_khtml_close_window (Webi *khtml); -static void kz_khtml_mouse_over (Webi *khtml, - const gchar *link_title, - const gchar *link_label, - const gchar *link_url, - const gchar *link_target); -#if 0 -static gboolean kz_khtml_mouse_down (Webi *khtml, - const gchar *link_url, - guint button); -static gboolean kz_khtml_mouse_up (Webi *khtml, - const gchar *link_url, - guint button); -#endif -/* embed iface */ -static void kz_khtml_load_url (KzEmbed *kzembed, - const gchar *url); -static gboolean kz_khtml_is_loading (KzEmbed *kzembed); -static const gchar *kz_khtml_get_title (KzEmbed *kzembed); -static const gchar *kz_khtml_get_location (KzEmbed *kzembed); -static gchar *kz_khtml_ensure_title (KzEmbed *kzembed); -static gchar *kz_khtml_get_link_message (KzEmbed *kzembed); - -static void kz_khtml_reload (KzEmbed *kzembed, - KzEmbedReloadFlag flags); -static void kz_khtml_stop_load (KzEmbed *kzembed); -static void kz_khtml_go_back (KzEmbed *kzembed); -static void kz_khtml_go_forward (KzEmbed *kzembed); -static gboolean kz_khtml_can_go_back (KzEmbed *kzembed); -static gboolean kz_khtml_can_go_forward (KzEmbed *kzembed); -static gboolean kz_khtml_can_go_nav_link (KzEmbed *kzembed, - KzEmbedNavLink link); -static void kz_khtml_go_nav_link (KzEmbed *kzembed, - KzEmbedNavLink link); -static void kz_khtml_set_nth_nav_link (KzEmbed *kzembed, - KzEmbedNavLink link, - KzNavi *navi, - guint n); -static KzNavi *kz_khtml_get_nth_nav_link (KzEmbed *kzembed, - KzEmbedNavLink link, - guint n); -static GList *kz_khtml_get_nav_links (KzEmbed *kzembed, - KzEmbedNavLink link); - -static gboolean kz_khtml_can_cut_selection (KzEmbed *kzembed); -static gboolean kz_khtml_can_copy_selection (KzEmbed *kzembed); -static gboolean kz_khtml_can_paste (KzEmbed *kzembed); -static void kz_khtml_cut_selection (KzEmbed *kzembed); -static void kz_khtml_copy_selection (KzEmbed *kzembed); -static void kz_khtml_paste (KzEmbed *kzembed); -static void kz_khtml_select_all (KzEmbed *kzembed); - -static gdouble kz_khtml_get_progress (KzEmbed *kzembed); - -static gint kz_khtml_get_text_size (KzEmbed *kzembed); -static void kz_khtml_set_text_size (KzEmbed *kzembed, - gint zoom, - gboolean reflow); - -static gboolean kz_khtml_find (KzEmbed *kzembed, - const char *keyword, - gboolean backward); - -static gboolean kz_khtml_selection_is_collapsed (KzEmbed *kzembed); - -/* KzEmbedPrefs interfaces */ -static void kz_khtml_prefs_iface_init (KzEmbedPrefsIFace *iface); -#if 0 -static gboolean kz_khtml_prefs_init (KzEmbedPrefs *embed_prefs); -static gboolean kz_khtml_prefs_get_font_list (KzEmbedPrefs *embed_prefs, - const gchar *lang_group, - const gchar *font_type, - GList **font_list, - GList **all_font_list, - gchar **default_font); -static gboolean kz_khtml_prefs_get_passwords (KzEmbedPrefs *embed_prefs, - GList **passwords); -static gboolean kz_khtml_prefs_remove_passwords(KzEmbedPrefs *embed_prefs, - GList *passwords); -#endif -static void -kz_khtml_register_type (GTypeModule *module) -{ - static const GTypeInfo kz_khtml_info = - { - sizeof (KzKHTMLClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) kz_khtml_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (KzKHTML), - 0, /* n_preallocs */ - (GInstanceInitFunc) kz_khtml_init, - }; - - const GInterfaceInfo kz_embed_info = - { - (GInterfaceInitFunc) kz_khtml_iface_init, - NULL, - NULL - }; - - const GInterfaceInfo kz_embed_prefs_info = - { - (GInterfaceInitFunc) kz_khtml_prefs_iface_init, - NULL, - NULL - }; - - kz_type_khtml = g_type_module_register_type(module, - WEBI_TYPE_WEBI, - "KzKHTML", - &kz_khtml_info, - (GTypeFlags)0); - - g_type_module_add_interface(module, - KZ_TYPE_KHTML, - KZ_TYPE_EMBED, - &kz_embed_info); - - g_type_module_add_interface(module, - KZ_TYPE_KHTML, - KZ_TYPE_EMBED_PREFS, - &kz_embed_prefs_info); -} - -G_MODULE_EXPORT void -KZ_MODULE_IMPL_INIT (GTypeModule *module) -{ - kz_khtml_register_type(module); -} - -G_MODULE_EXPORT void -KZ_MODULE_IMPL_EXIT (void) -{ -} - -G_MODULE_EXPORT GObject * -KZ_MODULE_IMPL_INSTANTIATE (const gchar *first_property, - va_list var_args) -{ - return g_object_new_valist(KZ_TYPE_KHTML, first_property, var_args); -} - -GType -kz_khtml_get_type (void) -{ - return kz_type_khtml; -} - -static void -kz_khtml_class_init (KzKHTMLClass *klass) -{ - GObjectClass *object_class; - GtkWidgetClass *widget_class; - WebiClass *khtml_class; - - kz_khtml_parent_class = g_type_class_peek_parent (klass); - object_class = (GObjectClass *) klass; - widget_class = (GtkWidgetClass *) klass; - khtml_class = (WebiClass *) klass; - - object_class->dispose = kz_khtml_dispose; -#if 0 - widget_class->button_press_event = button_press; - widget_class->button_release_event = button_release; -#endif - khtml_class->status = kz_khtml_status; - khtml_class->load_start = kz_khtml_load_start; - khtml_class->load_stop = kz_khtml_load_stop; - khtml_class->location = kz_khtml_location; - khtml_class->title = kz_khtml_title; -#if 0 - khtml_class->progress = kz_khtml_progress; -#endif - khtml_class->req_js_prompt = kz_khtml_req_js_prompt; - khtml_class->req_auth_prompt = kz_khtml_req_auth_prompt; - khtml_class->req_new_window = kz_khtml_req_new_window; - khtml_class->close_window = kz_khtml_close_window; - khtml_class->mouse_over = kz_khtml_mouse_over; -#if 0 - khtml_class->mouse_down = kz_khtml_mouse_down; - khtml_class->mouse_up = kz_khtml_mouse_up; -#endif - g_type_class_add_private (object_class, sizeof(KzKHTMLPrivate)); -} - - -static void -kz_khtml_iface_init (KzEmbedIFace *iface) -{ - iface->load_url = kz_khtml_load_url; - iface->view_source = NULL; - iface->is_loading = kz_khtml_is_loading; - iface->get_title = kz_khtml_get_title; - iface->get_location = kz_khtml_get_location; - iface->ensure_title = kz_khtml_ensure_title; - iface->get_link_message = kz_khtml_get_link_message; - iface->get_progress = kz_khtml_get_progress; - iface->can_cut_selection = kz_khtml_can_cut_selection; - iface->can_copy_selection = kz_khtml_can_copy_selection; - iface->can_paste = kz_khtml_can_paste; - iface->cut_selection = kz_khtml_cut_selection; - iface->copy_selection = kz_khtml_copy_selection; - iface->paste = kz_khtml_paste; - iface->select_all = kz_khtml_select_all; - iface->get_selection_string = NULL; - iface->find = kz_khtml_find; - iface->incremental_search = kz_khtml_find; /* tentavie */ - iface->selection_is_collapsed = kz_khtml_selection_is_collapsed; - iface->get_links = NULL; - iface->copy_page = NULL; - iface->shistory_copy = NULL; - iface->shistory_get_pos = NULL; - iface->shistory_get_nth = NULL; - iface->reload = kz_khtml_reload; - iface->stop_load = kz_khtml_stop_load; - iface->go_back = kz_khtml_go_back; - iface->go_forward = kz_khtml_go_forward; - iface->can_go_back = kz_khtml_can_go_back; - iface->can_go_forward = kz_khtml_can_go_forward; - iface->can_go_nav_link = kz_khtml_can_go_nav_link; - iface->go_nav_link = kz_khtml_go_nav_link; - iface->append_nav_link = NULL; - iface->set_nav_link = NULL; - iface->set_nth_nav_link = kz_khtml_set_nth_nav_link; - iface->get_nav_link = NULL; - iface->get_nth_nav_link = kz_khtml_get_nth_nav_link; - iface->get_nav_links = kz_khtml_get_nav_links; - iface->go_history_index = NULL; - iface->do_command = NULL; - iface->can_do_command = NULL; - iface->get_lock = NULL; - iface->set_lock = NULL; - iface->get_body_text = NULL; -#if 0 - iface->get_selection_source = NULL; -#endif - iface->set_encoding = NULL; - iface->get_encoding = NULL; - iface->print = NULL; - iface->print_preview = NULL; - iface->get_printer_list = NULL; - iface->create_thumbnail = NULL; - iface->save_with_content = NULL; - iface->set_text_into_textarea = NULL; - iface->get_text_from_textarea = NULL; - iface->zoom_set = kz_khtml_set_text_size; /* tentative */ - iface->zoom_get = kz_khtml_get_text_size; /* tentative */ - iface->set_text_size = kz_khtml_set_text_size; - iface->get_text_size = kz_khtml_get_text_size; - iface->get_html_with_contents = NULL; - iface->set_history = NULL; - iface->get_history = NULL; - iface->get_last_modified = NULL; - iface->fine_scroll = NULL; - iface->page_up = NULL; - iface->page_down = NULL; - iface->get_allow_javascript = NULL; - iface->set_allow_javascript = NULL; - iface->get_allow_images = NULL; - iface->set_allow_images = NULL; -#if 0 - iface->set_edit_mode = NULL; - iface->set_view_mode = NULL; -#endif - - iface->link_message = NULL; - iface->js_status = NULL; - iface->location = NULL; - iface->title = NULL; - iface->progress = NULL; - iface->net_start = NULL; - iface->net_stop = NULL; - iface->new_window = NULL; - iface->open_uri = NULL; - iface->size_to = NULL; - iface->dom_key_down = NULL; - iface->dom_key_press = NULL; - iface->dom_key_up = NULL; - iface->dom_mouse_down = NULL; - iface->dom_mouse_up = NULL; - iface->dom_mouse_click = NULL; - iface->dom_mouse_dbl_click = NULL; - iface->dom_mouse_over = NULL; - iface->dom_mouse_out = NULL; - iface->security_change = NULL; - iface->status_change = NULL; -} - - -static void -kz_khtml_prefs_iface_init (KzEmbedPrefsIFace *iface) -{ - iface->init = NULL; /* kz_khtml_prefs_init;*/ - iface->get_font_list = NULL; /* kz_khtml_prefs_get_font_list; */ - iface->get_passwords = NULL; /* kz_khtml_prefs_get_passwords; */ - iface->remove_passwords = NULL; /* kz_khtml_prefs_remove_passwords; */ -} - -static void -kz_khtml_init (KzKHTML *khtml) -{ - KzKHTMLPrivate *priv = KZ_KHTML_GET_PRIVATE (khtml); - - khtml->is_loading = FALSE; - priv->cur_requests = 0; - priv->total_requests = 0; - priv->link_message = NULL; - - priv->button_press_time = 0; - - gtk_widget_show_all(GTK_WIDGET(khtml)); -} - -static void -kz_khtml_dispose (GObject *object) -{ - KzKHTMLPrivate *priv = KZ_KHTML_GET_PRIVATE(object); - - if (priv->link_message) - g_free(priv->link_message); - priv->link_message = NULL; - - if (G_OBJECT_CLASS(kz_khtml_parent_class)->dispose) - G_OBJECT_CLASS(kz_khtml_parent_class)->dispose(object); -} - -#if 0 -static gboolean -button_press (GtkWidget *widget, GdkEventButton *event) -{ - if (GTK_WIDGET_CLASS(kz_khtml_parent_class)->button_press_event) - return GTK_WIDGET_CLASS(kz_khtml_parent_class)->button_press_event(widget, event); - - return FALSE; -} - -static gboolean -button_release (GtkWidget *widget, GdkEventButton *event) -{ - if (GTK_WIDGET_CLASS(kz_khtml_parent_class)->button_press_event) - return GTK_WIDGET_CLASS(kz_khtml_parent_class)->button_press_event(widget, event); - return FALSE; -} -#endif - -GtkWidget * -kz_khtml_new (void) -{ - return GTK_WIDGET(g_object_new(KZ_TYPE_KHTML, NULL)); -} - - -static void -kz_khtml_status (Webi *khtml, WebiLoadStatus *status) -{ - KzKHTMLPrivate *priv; - g_return_if_fail(KZ_IS_KHTML(khtml)); - g_return_if_fail(status); - - priv = KZ_KHTML_GET_PRIVATE (khtml); - - switch(status->status) { - case WEBI_LOADING_START: - KZ_KHTML(khtml)->is_loading = TRUE; - priv->cur_requests = 0; - priv->total_requests = 0; - g_signal_emit_by_name(khtml, "kz-net-start"); - break; - case WEBI_LOADING: - priv->cur_requests = status->totalReceived; - priv->total_requests = status->totalSize; - g_signal_emit_by_name(khtml, "kz-progress"); - break; - case WEBI_LOADING_COMPLETE: - case WEBI_LOADING_ERROR: - KZ_KHTML(khtml)->is_loading = FALSE; - priv->cur_requests = status->totalReceived; - priv->total_requests = status->totalSize; - g_signal_emit_by_name(khtml, "kz-net-stop"); - break; - default: - break; - } - - /* call parent method */ -} - - -static void -kz_khtml_load_start (Webi *khtml) -{ - g_return_if_fail(KZ_IS_KHTML(khtml)); - - KZ_KHTML(khtml)->is_loading = TRUE; - - g_signal_emit_by_name(khtml, "kz-net-start"); - - /* call parent method */ -} - - -static void -kz_khtml_load_stop (Webi *khtml) -{ - g_return_if_fail(KZ_IS_KHTML(khtml)); - - KZ_KHTML(khtml)->is_loading = FALSE; - - g_signal_emit_by_name(khtml, "kz-net-stop"); - - /* call parent method */ -} - - -static void -kz_khtml_location (Webi *khtml) -{ - g_return_if_fail(KZ_IS_KHTML(khtml)); - - g_signal_emit_by_name(khtml, "kz-location"); - - /* call parent method */ -} - - -static void -kz_khtml_title (Webi *khtml) -{ - g_return_if_fail(KZ_IS_KHTML(khtml)); - - g_signal_emit_by_name(khtml, "kz-title"); - - /* call parent method */ -} - - -static void -kz_khtml_req_js_prompt (Webi *khtml, WebiPromptArgs* args) -{ - g_return_if_fail(KZ_IS_KHTML(khtml)); -} - - -static void -kz_khtml_req_auth_prompt (Webi *khtml, WebiAuthArgs* args) -{ - KzPromptDialog *prompt; - - g_return_if_fail(KZ_IS_KHTML(khtml)); - - prompt= KZ_PROMPT_DIALOG(kz_prompt_dialog_new(TYPE_PROMPT_USER_PASS)); - - kz_prompt_dialog_set_title(prompt, _("Authentication")); - kz_prompt_dialog_run(prompt); - - args->out_ok_pressed = kz_prompt_dialog_get_confirm_value(prompt); - args->out_username = g_strdup(kz_prompt_dialog_get_user(prompt)); - args->out_password = g_strdup(kz_prompt_dialog_get_password(prompt)); - - gtk_widget_destroy(GTK_WIDGET(prompt)); -} - - -static Webi * -kz_khtml_req_new_window (Webi *khtml, const gchar *url) -{ - Webi *newkhtml = NULL; - g_return_val_if_fail(KZ_IS_KHTML(khtml), NULL); - - g_signal_emit_by_name(khtml, "kz-new-window", &newkhtml); - - return newkhtml; -} - -static void -kz_khtml_close_window (Webi *khtml) -{ - g_return_if_fail(KZ_IS_KHTML(khtml)); - - gtk_widget_destroy(GTK_WIDGET(khtml)); -} - -static void -get_mouse_event_info(KzEmbedEventMouse **kzevent) -{ - GdkModifierType state = (GdkModifierType)0; - gint x, y; - KzEmbedEventMouse *ret; - - gdk_window_get_pointer(NULL, &x, &y, &state); - ret = (KzEmbedEventMouse *) kz_embed_event_new(KZ_EMBED_EVENT_MOUSE); - - ret->x = x; - ret->y = y; - if (state & GDK_SHIFT_MASK) - ret->modifier |= KZ_SHIFT_KEY; - if (state & GDK_CONTROL_MASK) - ret->modifier |= KZ_CTRL_KEY; - if (state & GDK_MOD1_MASK) - ret->modifier |= KZ_ALT_KEY; - if (state & GDK_META_MASK) - ret->modifier |= KZ_META_KEY; - - *kzevent = ret; -} - -static void -kz_khtml_mouse_over (Webi *khtml, - const gchar *link_title, - const gchar *link_label, - const gchar *link_url, - const gchar *link_target) -{ - KzEmbedEventMouse *kzevent; - gint ret = FALSE; - KzKHTMLPrivate *priv; - g_return_if_fail(KZ_IS_KHTML(khtml)); - - priv = KZ_KHTML_GET_PRIVATE(khtml); - get_mouse_event_info(&kzevent); - - if (!link_url) - { - if (priv->link_message) - { - g_free(priv->link_message); - priv->link_message = NULL; - g_signal_emit_by_name(khtml, "kz-link-message"); - } - } - else - { - KzEmbedEvent *info = (KzEmbedEvent *) kzevent; - info->context = KZ_CONTEXT_LINK; - info->link = g_strdup(link_url); - info->linktext = g_strdup(link_label); - - if (priv->link_message) - g_free(priv->link_message); - - priv->link_message = g_strdup(link_url); - - g_signal_emit_by_name(khtml, "kz-link-message"); - } - - g_signal_emit_by_name(khtml, "kz-dom-mouse-over", - kzevent, &ret); - kz_embed_event_free((KzEmbedEvent *) kzevent); -} - -#if 0 -static gboolean -kz_khtml_mouse_down (Webi *khtml, - const gchar *link_url, - guint button) -{ - KzEmbedEventMouse *kzevent; - gint ret = FALSE; - KzKHTMLPrivate *priv; - g_return_val_if_fail(KZ_IS_KHTML(khtml), FALSE); - - priv = KZ_KHTML_GET_PRIVATE(khtml); - priv->button_press_time = GDK_CURRENT_TIME; - - get_mouse_event_info(&kzevent); - kzevent->button = button - 1; - - g_signal_emit_by_name(khtml, "kz-dom-mouse-down", - kzevent, &ret); - kz_embed_event_free((KzEmbedEvent *) kzevent); - - return ret; -} - -static gboolean -kz_khtml_mouse_up (Webi *khtml, - const gchar *link_url, - guint button) -{ - KzEmbedEventMouse *kzevent; - gint ret = FALSE; - KzKHTMLPrivate *priv; - g_return_val_if_fail(KZ_IS_KHTML(khtml), FALSE); - - priv = KZ_KHTML_GET_PRIVATE(khtml); - - get_mouse_event_info(&kzevent); - kzevent->button = button - 1; - - g_signal_emit_by_name(khtml, "kz-dom-mouse-up", - kzevent, &ret); - - if (!ret && GDK_CURRENT_TIME < priv->button_press_time + 1000) - { - if (link_url) - { - ((KzEmbedEvent *)kzevent)->context = KZ_CONTEXT_LINK; - ((KzEmbedEvent *)kzevent)->link = g_strdup(link_url); - } - - g_signal_emit_by_name(khtml, "kz-dom-mouse-click", - kzevent, &ret); - } - priv->button_press_time = 0; - - kz_embed_event_free((KzEmbedEvent *) kzevent); - - return ret; -} -#endif - -static gboolean -kz_khtml_is_loading (KzEmbed *kzembed) -{ - g_return_val_if_fail(KZ_IS_KHTML(kzembed), FALSE); - - return KZ_KHTML(kzembed)->is_loading; -} - - -static void -kz_khtml_load_url (KzEmbed *kzembed, const gchar *url) -{ - g_return_if_fail(KZ_IS_KHTML(kzembed)); - - webi_load_url(WEBI(kzembed), url); -} - - -static const gchar * -kz_khtml_get_title (KzEmbed *kzembed) -{ - g_return_val_if_fail(KZ_IS_KHTML(kzembed), NULL); - - return webi_get_title(WEBI(kzembed)); -} - - -static const gchar * -kz_khtml_get_location (KzEmbed *kzembed) -{ - g_return_val_if_fail(KZ_IS_KHTML(kzembed), NULL); - - return webi_get_location(WEBI(kzembed)); -} - -static gchar * -kz_khtml_get_link_message (KzEmbed *kzembed) -{ - g_return_val_if_fail(KZ_IS_KHTML(kzembed), NULL); - - return g_strdup(KZ_KHTML_GET_PRIVATE(kzembed)->link_message); -} - -static gchar * -kz_khtml_ensure_title (KzEmbed *kzembed) -{ - const gchar *title; - - title = kz_khtml_get_title(kzembed); - if (title) - return g_strdup(title); - - title = kz_khtml_get_location(kzembed); - if (title) - return g_strdup(title); - - return g_strdup(_("No title")); -} - -static void -kz_khtml_reload (KzEmbed *kzembed, KzEmbedReloadFlag flags) -{ - g_return_if_fail(KZ_IS_KHTML(kzembed)); - - webi_refresh (WEBI(kzembed)); -} - - -static void -kz_khtml_stop_load (KzEmbed *kzembed) -{ - g_return_if_fail(KZ_IS_KHTML(kzembed)); - - webi_stop_load (WEBI(kzembed)); -} - - -static void -kz_khtml_go_back (KzEmbed *kzembed) -{ - g_return_if_fail(KZ_IS_KHTML(kzembed)); - - return webi_go_back (WEBI(kzembed)); -} - - -static void -kz_khtml_go_forward (KzEmbed *kzembed) -{ - g_return_if_fail(KZ_IS_KHTML(kzembed)); - - return webi_go_forward (WEBI(kzembed)); -} - - -static gboolean -kz_khtml_can_go_back (KzEmbed *kzembed) -{ - g_return_val_if_fail(KZ_IS_KHTML(kzembed), FALSE); - - return webi_can_go_back (WEBI(kzembed)); -} - - -static gboolean -kz_khtml_can_go_forward (KzEmbed *kzembed) -{ - g_return_val_if_fail(KZ_IS_KHTML(kzembed), FALSE); - - return webi_can_go_forward (WEBI(kzembed)); -} - - -static gboolean -kz_khtml_can_go_nav_link (KzEmbed *kzembed, KzEmbedNavLink link) -{ - g_return_val_if_fail(KZ_IS_KHTML(kzembed), FALSE); - - return FALSE; -} - -static void -kz_khtml_go_nav_link (KzEmbed *kzembed, KzEmbedNavLink link) -{ - g_return_if_fail(KZ_IS_KHTML(kzembed)); - - return; -} - -static void -kz_khtml_set_nth_nav_link (KzEmbed *kzembed, - KzEmbedNavLink link, - KzNavi *navi, - guint n) -{ - g_return_if_fail(KZ_IS_KHTML(kzembed)); - - return; -} - -static KzNavi * -kz_khtml_get_nth_nav_link (KzEmbed *kzembed, - KzEmbedNavLink link, - guint n) -{ - g_return_val_if_fail(KZ_IS_KHTML(kzembed), NULL); - - return NULL; -} - -static GList * -kz_khtml_get_nav_links (KzEmbed *kzembed, - KzEmbedNavLink link) -{ - g_return_val_if_fail(KZ_IS_KHTML(kzembed), NULL); - - return NULL; -} - -static gdouble -kz_khtml_get_progress (KzEmbed *kzembed) -{ - gdouble progress; - KzKHTML *khtml; - KzKHTMLPrivate *priv; - - g_return_val_if_fail(KZ_IS_KHTML(kzembed), 0.0); - - priv = KZ_KHTML_GET_PRIVATE (kzembed); - - khtml = KZ_KHTML(kzembed); - if (priv->total_requests <= 0 || - priv->cur_requests <= 0) - { - return 0.0; - } - - progress = (gdouble) priv->cur_requests - / (gdouble) priv->total_requests; - - if (progress > 1.0) - return 1.0; - - return progress; -} - - -static gint -kz_khtml_get_text_size (KzEmbed *kzembed) -{ - gfloat multiplier; - - g_return_val_if_fail(KZ_IS_KHTML(kzembed), 100); - - multiplier = webi_get_text_multiplier (WEBI(kzembed)); - - if (multiplier == -1.0) return 100; - - return (gint) rint(multiplier * 100); -} - - -static void -kz_khtml_set_text_size (KzEmbed *kzembed, gint zoom, gboolean reflow) -{ - gfloat multiplier; - - g_return_if_fail(KZ_IS_KHTML(kzembed)); - - multiplier = (gfloat)(zoom) / 100; - - webi_set_text_multiplier (WEBI(kzembed), - multiplier); -} - - -static gboolean -kz_khtml_find (KzEmbed *kzembed, const char *keyword, gboolean backward) -{ - g_return_val_if_fail(KZ_IS_KHTML(kzembed), FALSE); - - return webi_find(WEBI(kzembed), keyword, FALSE, backward); -} - -static gboolean -kz_khtml_can_cut_selection (KzEmbed *kzembed) -{ - g_return_val_if_fail(KZ_IS_KHTML(kzembed), FALSE); - - /* not implemented yet */ - return FALSE; -} - -static gboolean -kz_khtml_can_copy_selection (KzEmbed *kzembed) -{ - g_return_val_if_fail(KZ_IS_KHTML(kzembed), FALSE); - /* not implemented yet */ - return FALSE; -} - -static gboolean -kz_khtml_can_paste (KzEmbed *kzembed) -{ - g_return_val_if_fail(KZ_IS_KHTML(kzembed), FALSE); - /* not implemented yet */ - return FALSE; -} - -static void -kz_khtml_cut_selection (KzEmbed *kzembed) -{ - /* not implemented yet */ - return; -} - -static void -kz_khtml_copy_selection (KzEmbed *kzembed) -{ - /* not implemented yet */ - return; -} - -static void -kz_khtml_paste (KzEmbed *kzembed) -{ - /* not implemented yet */ - return; -} - -static void -kz_khtml_select_all (KzEmbed *kzembed) -{ - /* not implemented yet */ - return; -} - -static gboolean -kz_khtml_selection_is_collapsed (KzEmbed *kzembed) -{ - /* not implemented yet */ - return FALSE; -} - Deleted: kazehakase/trunk/module/embed/khtml/kz-khtml.h =================================================================== --- kazehakase/trunk/module/embed/khtml/kz-khtml.h 2007-03-25 01:42:32 UTC (rev 2997) +++ kazehakase/trunk/module/embed/khtml/kz-khtml.h 2007-03-25 03:39:06 UTC (rev 2998) @@ -1,59 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Copyright (C) 2004 Takuro Ashie - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - */ - -#ifndef __KZ_KHTML_H__ -#define __KZ_KHTML_H__ - -#include <gtk/gtk.h> -#include <webi.h> - -G_BEGIN_DECLS - -#define KZ_TYPE_KHTML (kz_khtml_get_type ()) -#define KZ_KHTML(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), KZ_TYPE_KHTML, KzKHTML)) -#define KZ_KHTML_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), KZ_TYPE_KHTML, KzKHTMLClass)) -#define KZ_IS_KHTML(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), KZ_TYPE_KHTML)) -#define KZ_IS_KHTML_CLASS(klass)(G_TYPE_CHECK_CLASS_TYPE ((klass), KZ_TYPE_KHTML)) -#define KZ_KHTML_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), KZ_TYPE_KHTML, KzKHTMLClass)) - -typedef struct _KzKHTML KzKHTML; -typedef struct _KzKHTMLClass KzKHTMLClass; - -struct _KzKHTML -{ - /* embedding widget */ - Webi parent; - - gboolean is_loading; -}; - -struct _KzKHTMLClass -{ - WebiClass parent_class; -}; - - -GType kz_khtml_get_type (void) G_GNUC_CONST; - -G_END_DECLS - -#endif /* __KZ_KHTML_H__ */ Modified: kazehakase/trunk/src/kz-window.c =================================================================== --- kazehakase/trunk/src/kz-window.c 2007-03-25 01:42:32 UTC (rev 2997) +++ kazehakase/trunk/src/kz-window.c 2007-03-25 03:39:06 UTC (rev 2998) @@ -808,7 +808,7 @@ { if (!strcmp(engine, "gtk+-webcore")) { - kz_embed = KZ_EMBED(kz_embed_new("khtml")); + kz_embed = KZ_EMBED(kz_embed_new("gtk-webcore")); } else {