svnno****@sourc*****
svnno****@sourc*****
Sun Mar 25 10:06:09 JST 2007
Revision: 2995 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=2995 Author: ikezoe Date: 2007-03-25 10:06:08 +0900 (Sun, 25 Mar 2007) Log Message: ----------- * module/embed/khtml/kz-khtml.c: Handle req-new-window and close-window signals. Modified Paths: -------------- kazehakase/trunk/ChangeLog kazehakase/trunk/module/embed/khtml/kz-khtml.c Modified: kazehakase/trunk/ChangeLog =================================================================== --- kazehakase/trunk/ChangeLog 2007-03-25 01:05:05 UTC (rev 2994) +++ kazehakase/trunk/ChangeLog 2007-03-25 01:06:08 UTC (rev 2995) @@ -1,3 +1,8 @@ +2007-03-25 Hiroyuki Ikezoe <poinc****@ikezo*****> + + * module/embed/khtml/kz-khtml.c: Handle req-new-window and + close-window signals. + 2007-03-24 Kouhei Sutou <kou****@cozmi*****> * src/dialogs/kz-prompt-dialog.c (set_property): checked Modified: kazehakase/trunk/module/embed/khtml/kz-khtml.c =================================================================== --- kazehakase/trunk/module/embed/khtml/kz-khtml.c 2007-03-25 01:05:05 UTC (rev 2994) +++ kazehakase/trunk/module/embed/khtml/kz-khtml.c 2007-03-25 01:06:08 UTC (rev 2995) @@ -35,6 +35,7 @@ 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)) @@ -66,14 +67,21 @@ WebiPromptArgs* args); static void kz_khtml_req_auth_prompt (Webi *khtml, WebiAuthArgs* args); -static gboolean kz_khtml_req_new_window (Webi *khtml, - Webi *newkhtml); +static Webi *kz_khtml_req_new_window (Webi *khtml); +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); @@ -239,8 +247,12 @@ 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)); } @@ -367,6 +379,8 @@ priv->total_requests = 0; priv->link_message = NULL; + priv->button_press_time = 0; + gtk_widget_show_all(GTK_WIDGET(khtml)); } @@ -507,16 +521,49 @@ } -static gboolean -kz_khtml_req_new_window (Webi *khtml, Webi *newkhtml) +static Webi * +kz_khtml_req_new_window (Webi *khtml) { - g_return_val_if_fail(KZ_IS_KHTML(khtml), FALSE); + Webi *newkhtml = NULL; + g_return_val_if_fail(KZ_IS_KHTML(khtml), NULL); - g_signal_emit_by_name(khtml, "kz-new-window", newkhtml); - return TRUE; + 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, @@ -525,26 +572,12 @@ { KzEmbedEventMouse *kzevent; gint ret = FALSE; - GdkModifierType state = (GdkModifierType)0; - gint x, y; KzKHTMLPrivate *priv; g_return_if_fail(KZ_IS_KHTML(khtml)); priv = KZ_KHTML_GET_PRIVATE(khtml); - kzevent = (KzEmbedEventMouse *) kz_embed_event_new(KZ_EMBED_EVENT_MOUSE); - gdk_window_get_pointer(NULL, &x, &y, &state); - kzevent->x = x; - kzevent->y = y; - if (state & GDK_SHIFT_MASK) - kzevent->modifier |= KZ_SHIFT_KEY; - if (state & GDK_CONTROL_MASK) - kzevent->modifier |= KZ_CTRL_KEY; - if (state & GDK_MOD1_MASK) - kzevent->modifier |= KZ_ALT_KEY; - if (state & GDK_META_MASK) - kzevent->modifier |= KZ_META_KEY; + get_mouse_event_info(&kzevent); - if (!link_url) { if (priv->link_message) @@ -574,7 +607,68 @@ 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);