svnno****@sourc*****
svnno****@sourc*****
Mon Oct 15 19:38:28 JST 2007
Revision: 3281 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=3281 Author: ikezoe Date: 2007-10-15 19:38:28 +0900 (Mon, 15 Oct 2007) Log Message: ----------- * module/embed/ie/kz-ie.cpp: Implement some fundamental functions. Modified Paths: -------------- kazehakase/trunk/ChangeLog kazehakase/trunk/module/embed/ie/kz-ie.cpp Modified: kazehakase/trunk/ChangeLog =================================================================== --- kazehakase/trunk/ChangeLog 2007-10-15 10:13:59 UTC (rev 3280) +++ kazehakase/trunk/ChangeLog 2007-10-15 10:38:28 UTC (rev 3281) @@ -6,6 +6,7 @@ * configure.ac: gtk-ie-embed -> gtkieembed. * module/embed/ie/Makefile.am: Add GTKIEEMBED_CFLGAGS. * module/embed/ie/kz-ie.cpp: Parent class is GtkIEEmbed. + * module/embed/ie/kz-ie.cpp: Implement some fundamental functions. 2007-10-15 Kouhei Sutou <kou****@cozmi*****> Modified: kazehakase/trunk/module/embed/ie/kz-ie.cpp =================================================================== --- kazehakase/trunk/module/embed/ie/kz-ie.cpp 2007-10-15 10:13:59 UTC (rev 3280) +++ kazehakase/trunk/module/embed/ie/kz-ie.cpp 2007-10-15 10:38:28 UTC (rev 3281) @@ -33,7 +33,8 @@ typedef struct _KzIEPrivate KzIEPrivate; struct _KzIEPrivate { - gint dummy; + gchar *location; + gchar *title; }; #define KZ_IE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), KZ_TYPE_IE, KzIEPrivate)) @@ -46,9 +47,31 @@ static void kz_ie_init (KzIE *ie); static void kz_ie_dispose (GObject *object); +/* GtkIEEmbed signals */ +static void kz_ie_embed_location (GtkIEEmbed *ieembed, + const gchar *location); +static void kz_ie_embed_title (GtkIEEmbed *ieembed, + const gchar *title); +static void kz_ie_embed_progress (GtkIEEmbed *ieembed, + glong current_progress, + glong max_progress); +static void kz_ie_embed_net_start (GtkIEEmbed *ieembed); +static void kz_ie_embed_net_stop (GtkIEEmbed *ieembed); + /* embed iface */ -/* no functions is implemented yet */ +static void kz_ie_load_url (KzEmbed *kzembed, + const gchar *url); +static const gchar *kz_ie_get_title (KzEmbed *kzembed); +static const gchar *kz_ie_get_location (KzEmbed *kzembed); +static void kz_ie_reload (KzEmbed *kzembed, + KzEmbedReloadFlag flags); +static void kz_ie_stop_load (KzEmbed *kzembed); +static void kz_ie_go_back (KzEmbed *kzembed); +static void kz_ie_go_forward (KzEmbed *kzembed); +static gboolean kz_ie_can_go_back (KzEmbed *kzembed); +static gboolean kz_ie_can_go_forward (KzEmbed *kzembed); + /* KzEmbedPrefs interfaces */ /* no functions is implemented yet */ static void kz_ie_prefs_iface_init (KzEmbedPrefsIFace *iface); @@ -111,14 +134,22 @@ { GObjectClass *object_class; GtkWidgetClass *widget_class; + GtkIEEmbedClass *ie_class; - kz_ie_parent_class = (GtkIEEmbedClass *)g_type_class_peek_parent (klass); - object_class = (GObjectClass *) klass; - widget_class = (GtkWidgetClass *) klass; + kz_ie_parent_class = GTK_IE_EMBED_CLASS(g_type_class_peek_parent(klass)); + object_class = G_OBJECT_CLASS(klass); + widget_class = GTK_WIDGET_CLASS(klass); + ie_class = GTK_IE_EMBED_CLASS(klass); - object_class->dispose = kz_ie_dispose; + object_class->dispose = kz_ie_dispose; - g_type_class_add_private (object_class, sizeof(KzIEPrivate)); + ie_class->location = kz_ie_embed_location; + ie_class->title = kz_ie_embed_title; + ie_class->net_start = kz_ie_embed_net_start; + ie_class->net_stop = kz_ie_embed_net_stop; + ie_class->progress = kz_ie_embed_progress; + + g_type_class_add_private(object_class, sizeof(KzIEPrivate)); } @@ -239,7 +270,8 @@ { KzIEPrivate *priv = KZ_IE_GET_PRIVATE (ie); - priv->dummy = 0; + priv->location = NULL; + priv->title = NULL; } static void @@ -247,6 +279,13 @@ { KzIEPrivate *priv = KZ_IE_GET_PRIVATE(object); + if (priv->location) + g_free(priv->location); + if (priv->title) + g_free(priv->title); + priv->location = NULL; + priv->title = NULL; + if (G_OBJECT_CLASS(kz_ie_parent_class)->dispose) G_OBJECT_CLASS(kz_ie_parent_class)->dispose(object); } @@ -256,3 +295,122 @@ { return GTK_WIDGET(g_object_new(KZ_TYPE_IE, NULL)); } + +static void +kz_ie_embed_location (GtkIEEmbed *ieembed, const gchar *location) +{ + KzIEPrivate *priv = KZ_IE_GET_PRIVATE(ieembed); + + if (priv->location) + g_free(priv->location); + priv->location = g_strdup(location); + g_signal_emit_by_name(ieembed, "kz-location"); +} + +static void +kz_ie_embed_title (GtkIEEmbed *ieembed, const gchar *title) +{ + KzIEPrivate *priv = KZ_IE_GET_PRIVATE(ieembed); + + if (priv->title) + g_free(priv->title); + priv->title = g_strdup(title); + g_signal_emit_by_name(ieembed, "kz-title"); +} + +static void +kz_ie_embed_progress (GtkIEEmbed *ieembed, + glong current_progress, + glong max_progress) +{ + g_signal_emit_by_name(ieembed, "kz-progress"); +} + +static void +kz_ie_embed_net_start (GtkIEEmbed *ieembed) +{ + g_signal_emit_by_name(ieembed, "kz-net-start"); +} + +static void +kz_ie_embed_net_stop (GtkIEEmbed *ieembed) +{ + g_signal_emit_by_name(ieembed, "kz-net-stop"); +} + +static void +kz_ie_load_url (KzEmbed *kzembed, const gchar *url) +{ + g_return_if_fail(KZ_IS_IE(kzembed)); + + gtk_ie_embed_load_url(GTK_IE_EMBED(kzembed), url); +} + +static const gchar * +kz_gtk_ie_embed_get_title (KzEmbed *kzembed) +{ + g_return_val_if_fail(KZ_IS_IE(kzembed), NULL); + + return KZ_IE_GET_PRIVATE(kzembed)->title; +} + +static const gchar * +kz_gtk_ie_embed_get_location (KzEmbed *kzembed) +{ + g_return_val_if_fail(KZ_IS_IE(kzembed), NULL); + + return KZ_IE_GET_PRIVATE(kzembed)->location; +} + +static void +kz_ie_reload (KzEmbed *kzembed, KzEmbedReloadFlag flags) +{ + g_return_if_fail(KZ_IS_IE(kzembed)); + + gtk_ie_embed_reload(GTK_IE_EMBED(kzembed), GTK_IE_EMBED_RELOAD_NORMAL); +} + + +static void +kz_ie_stop_load (KzEmbed *kzembed) +{ + g_return_if_fail(KZ_IS_IE(kzembed)); + + gtk_ie_embed_stop(GTK_IE_EMBED(kzembed)); +} + + +static void +kz_ie_go_back (KzEmbed *kzembed) +{ + g_return_if_fail(KZ_IS_IE(kzembed)); + + gtk_ie_embed_go_back(GTK_IE_EMBED(kzembed)); +} + + +static void +kz_ie_go_forward (KzEmbed *kzembed) +{ + g_return_if_fail(KZ_IS_IE(kzembed)); + + gtk_ie_embed_go_forward(GTK_IE_EMBED(kzembed)); +} + + +static gboolean +kz_ie_can_go_back (KzEmbed *kzembed) +{ + g_return_val_if_fail(KZ_IS_IE(kzembed), FALSE); + + return gtk_ie_embed_can_go_back(GTK_IE_EMBED(kzembed)); +} + + +static gboolean +kz_ie_can_go_forward (KzEmbed *kzembed) +{ + g_return_val_if_fail(KZ_IS_IE(kzembed), FALSE); + + return gtk_ie_embed_can_go_forward(GTK_IE_EMBED(kzembed)); +}