2008-01-09 Luca Bruno <lethalman88@gmail.com>
authoralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Jan 2008 20:26:47 +0000 (20:26 +0000)
committeralp@webkit.org <alp@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Jan 2008 20:26:47 +0000 (20:26 +0000)
        Reviewed by Alp Toker.

        http://bugs.webkit.org/show_bug.cgi?id=16802
        [GTK] Missing gtk properties

        Add missing properties to WebKitViewFrame and WebKitWebView.

        * WebView/webkitprivate.h: add some useful defines for param specs
        * WebView/webkitwebframe.cpp:
        (webkit_web_frame_get_property): added
        (webkit_web_frame_class_init): add name, title and uri read-only properties
        * WebView/webkitwebview.cpp:
        (webkit_web_view_get_property): add editable property read
        (webkit_web_view_set_property): added for editable property write
        (webkit_web_view_class_init): add read-write editable property

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@29341 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/gtk/ChangeLog
WebKit/gtk/WebView/webkitprivate.h
WebKit/gtk/WebView/webkitwebframe.cpp
WebKit/gtk/WebView/webkitwebview.cpp

index 39e315aa6da62947c015c5a8e69a2f8cd7f49335..d748009cd8a2e2cfcfc6d4510a3d045c6199085a 100644 (file)
@@ -1,3 +1,21 @@
+2008-01-09  Luca Bruno  <lethalman88@gmail.com>
+
+        Reviewed by Alp Toker.
+
+        http://bugs.webkit.org/show_bug.cgi?id=16802
+        [GTK] Missing gtk properties
+        
+        Add missing properties to WebKitViewFrame and WebKitWebView.
+        
+        * WebView/webkitprivate.h: add some useful defines for param specs
+        * WebView/webkitwebframe.cpp:
+        (webkit_web_frame_get_property): added
+        (webkit_web_frame_class_init): add name, title and uri read-only properties
+        * WebView/webkitwebview.cpp:
+        (webkit_web_view_get_property): add editable property read
+        (webkit_web_view_set_property): added for editable property write
+        (webkit_web_view_class_init): add read-write editable property
+
 2008-01-03  Xan Lopez  <xan@gnome.org>
 
         Reviewed by Alp Toker.
index 14328bc24de1c581640ca3ebbf7a64e16beb6854..611ae0897a1cb82e0b9a2bb6b9f1c4714034549b 100644 (file)
@@ -51,6 +51,9 @@ namespace WebKit {
 extern "C" {
     void webkit_init();
 
+#define WEBKIT_PARAM_READABLE ((GParamFlags)(G_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB))
+#define WEBKIT_PARAM_READWRITE ((GParamFlags)(G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB))
+
     #define WEBKIT_WEB_VIEW_GET_PRIVATE(obj)    (G_TYPE_INSTANCE_GET_PRIVATE((obj), WEBKIT_TYPE_WEB_VIEW, WebKitWebViewPrivate))
     typedef struct _WebKitWebViewPrivate WebKitWebViewPrivate;
     struct _WebKitWebViewPrivate {
index 990e5f4d6fe665de6a30ef167a73eb4c3e86edf9..b3a9d72d96e8cdd0755af3d4857ebd8613921c8d 100644 (file)
@@ -54,10 +54,38 @@ enum {
     LAST_SIGNAL
 };
 
+enum {
+    PROP_0,
+
+    PROP_NAME,
+    PROP_TITLE,
+    PROP_URI
+};
+
 static guint webkit_web_frame_signals[LAST_SIGNAL] = { 0, };
 
 G_DEFINE_TYPE(WebKitWebFrame, webkit_web_frame, G_TYPE_OBJECT)
 
+static void webkit_web_frame_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
+{
+    WebKitWebFrame* frame = WEBKIT_WEB_FRAME(object);
+
+    switch(prop_id) {
+    case PROP_NAME:
+        g_value_set_string(value, webkit_web_frame_get_name(frame));
+        break;
+    case PROP_TITLE:
+        g_value_set_string(value, webkit_web_frame_get_title(frame));
+        break;
+    case PROP_URI:
+        g_value_set_string(value, webkit_web_frame_get_uri(frame));
+        break;
+    default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+        break;
+    }
+}
+
 static void webkit_web_frame_finalize(GObject* object)
 {
     WebKitWebFramePrivate* privateData = WEBKIT_WEB_FRAME_GET_PRIVATE(WEBKIT_WEB_FRAME(object));
@@ -110,7 +138,7 @@ static void webkit_web_frame_class_init(WebKitWebFrameClass* frameClass)
     webkit_web_frame_signals[TITLE_CHANGED] = g_signal_new("title-changed",
             G_TYPE_FROM_CLASS(frameClass),
             (GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
-            0,                                               
+            0,
             NULL,
             NULL,
             webkit_marshal_VOID__STRING,
@@ -130,7 +158,33 @@ static void webkit_web_frame_class_init(WebKitWebFrameClass* frameClass)
     /*
      * implementations of virtual methods
      */
-    G_OBJECT_CLASS(frameClass)->finalize = webkit_web_frame_finalize;
+    GObjectClass* objectClass = G_OBJECT_CLASS(frameClass);
+    objectClass->finalize = webkit_web_frame_finalize;
+    objectClass->get_property = webkit_web_frame_get_property;
+
+    /*
+     * properties
+     */
+    g_object_class_install_property(objectClass, PROP_NAME,
+                                    g_param_spec_string("name",
+                                                        "Name",
+                                                        "The name of the frame",
+                                                        NULL,
+                                                        WEBKIT_PARAM_READABLE));
+
+    g_object_class_install_property(objectClass, PROP_TITLE,
+                                    g_param_spec_string("title",
+                                                        "Title",
+                                                        "The document title of the frame",
+                                                        NULL,
+                                                        WEBKIT_PARAM_READABLE));
+
+    g_object_class_install_property(objectClass, PROP_URI,
+                                    g_param_spec_string("uri",
+                                                        "URI",
+                                                        "The current URI of the contents displayed by the frame",
+                                                        NULL,
+                                                        WEBKIT_PARAM_READABLE));
 }
 
 static void webkit_web_frame_init(WebKitWebFrame* frame)
@@ -190,6 +244,14 @@ WebKitWebFrame* webkit_web_frame_init_with_web_view(WebKitWebView* webView, HTML
     return frame;
 }
 
+/**
+ * webkit_web_frame_get_title:
+ * @frame: a #WebKitWebFrame
+ *
+ * Returns the @frame's document title
+ *
+ * Return value: the title of @frame
+ */
 const gchar* webkit_web_frame_get_title(WebKitWebFrame* frame)
 {
     g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL);
@@ -198,6 +260,14 @@ const gchar* webkit_web_frame_get_title(WebKitWebFrame* frame)
     return frameData->title;
 }
 
+/**
+ * webkit_web_frame_get_uri:
+ * @frame: a #WebKitWebFrame
+ *
+ * Returns the current URI of the contents displayed by the @frame
+ *
+ * Return value: the URI of @frame
+ */
 const gchar* webkit_web_frame_get_uri(WebKitWebFrame* frame)
 {
     g_return_val_if_fail(WEBKIT_IS_WEB_FRAME(frame), NULL);
index 6e6e580e06c78559c7ca194ba48185e3a83f276e..8fac70fddc77789c4c512d4eab1754955e9c8285 100644 (file)
@@ -84,7 +84,8 @@ enum {
     PROP_0,
 
     PROP_COPY_TARGET_LIST,
-    PROP_PASTE_TARGET_LIST
+    PROP_PASTE_TARGET_LIST,
+    PROP_EDITABLE
 };
 
 static guint webkit_web_view_signals[LAST_SIGNAL] = { 0, };
@@ -177,7 +178,8 @@ static gboolean webkit_web_view_popup_menu_handler(GtkWidget* widget)
     return webkit_web_view_forward_context_menu_event(WEBKIT_WEB_VIEW(widget), event);
 }
 
-static void webkit_web_view_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) {
+static void webkit_web_view_get_property(GObject* object, guint prop_id, GValue* value, GParamSpec* pspec)
+{
     WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
 
     switch(prop_id) {
@@ -187,7 +189,25 @@ static void webkit_web_view_get_property(GObject *object, guint prop_id, GValue
     case PROP_PASTE_TARGET_LIST:
         g_value_set_boxed(value, webkit_web_view_get_paste_target_list(webView));
         break;
+    case PROP_EDITABLE:
+        g_value_set_boolean(value, webkit_web_view_get_editable(webView));
+        break;
     default:
+        G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+        break;
+    }
+}
+
+static void webkit_web_view_set_property(GObject* object, guint prop_id, const GValue* value, GParamSpec *pspec)
+{
+    WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
+
+    switch(prop_id) {
+    case PROP_EDITABLE:
+        webkit_web_view_set_editable(webView, g_value_get_boolean(value));
+        break;
+    default:
+        g_assert_not_reached();
         break;
     }
 }
@@ -893,10 +913,10 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
     webViewClass->copy_clipboard = webkit_web_view_real_copy_clipboard;
     webViewClass->paste_clipboard = webkit_web_view_real_paste_clipboard;
 
-    G_OBJECT_CLASS(webViewClass)->finalize = webkit_web_view_finalize;
-
     GObjectClass* objectClass = G_OBJECT_CLASS(webViewClass);
+    objectClass->finalize = webkit_web_view_finalize;
     objectClass->get_property = webkit_web_view_get_property;
+    objectClass->set_property = webkit_web_view_set_property;
 
     GtkWidgetClass* widgetClass = GTK_WIDGET_CLASS(webViewClass);
     widgetClass->realize = webkit_web_view_realize;
@@ -953,21 +973,29 @@ static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
     gtk_binding_entry_add_signal(binding_set, GDK_Insert, GDK_SHIFT_MASK,
                                  "paste_clipboard", 0);
 
-    /* Properties */
-    GParamFlags flags = (GParamFlags)(G_PARAM_READABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB);
+    /*
+     * properties
+     */
     g_object_class_install_property(objectClass, PROP_COPY_TARGET_LIST,
                                     g_param_spec_boxed("copy-target-list",
                                                        "Target list",
                                                        "The list of targets this Web view supports for copying to the clipboard",
                                                        GTK_TYPE_TARGET_LIST,
-                                                       flags));
+                                                       WEBKIT_PARAM_READABLE));
 
     g_object_class_install_property(objectClass, PROP_PASTE_TARGET_LIST,
                                     g_param_spec_boxed("paste-target-list",
                                                        "Target list",
                                                        "The list of targets this Web view supports for pasting to the clipboard",
                                                        GTK_TYPE_TARGET_LIST,
-                                                       flags));
+                                                       WEBKIT_PARAM_READABLE));
+
+    g_object_class_install_property(objectClass, PROP_EDITABLE,
+                                    g_param_spec_boolean("editable",
+                                                         "Editable",
+                                                         "Whether content can be modified by the user",
+                                                         FALSE,
+                                                         WEBKIT_PARAM_READWRITE));
 }
 
 static void webkit_web_view_init(WebKitWebView* webView)