Bug 14812 - [gtk] [request] add webkit_gtk_frame_get_title() function
Summary: [gtk] [request] add webkit_gtk_frame_get_title() function
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit API (show other bugs)
Version: 523.x (Safari 3)
Hardware: PC OS X 10.4
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-30 01:44 PDT by Diego Escalante Urrelo
Modified: 2007-09-20 06:39 PDT (History)
3 users (show)

See Also:


Attachments
Initial proposal (1.24 KB, patch)
2007-07-30 01:47 PDT, Diego Escalante Urrelo
no flags Details | Formatted Diff | Diff
A better version (2.45 KB, patch)
2007-07-30 02:34 PDT, Diego Escalante Urrelo
mrowe: review-
Details | Formatted Diff | Diff
Updated. (3.10 KB, patch)
2007-08-02 06:46 PDT, Diego Escalante Urrelo
aroben: review-
Details | Formatted Diff | Diff
Updated to trunk and following naming comments (3.13 KB, patch)
2007-08-20 17:47 PDT, Diego Escalante Urrelo
mrowe: review-
Details | Formatted Diff | Diff
Updated with g_free() calls, and coding style fixes. (4.68 KB, patch)
2007-09-17 02:06 PDT, Cyril Brulebois
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Diego Escalante Urrelo 2007-07-30 01:44:48 PDT
In Epiphany there are certain times when we want to get the page title on demand, listening to title_changed isn't that much of a good idea in our case.
Attached patch is pretty dirty, so I'm asking for some guidance on how to do it correctly.
Comment 1 Diego Escalante Urrelo 2007-07-30 01:47:21 PDT
Created attachment 15739 [details]
Initial proposal

I guess there might be a better way of doing it. Adopted this idea after checking the forked gtk-webcore, they implement a signal listener to be between signals and  the app so you can ask for stuff like title on-demand.
Comment 2 Holger Freyther 2007-07-30 02:02:27 PDT
Well, if we start to cache the title in WebFrameGtk we might just add a default handler and avoid connecting to our own sginals.
Comment 3 Diego Escalante Urrelo 2007-07-30 02:34:26 PDT
Created attachment 15741 [details]
A better version

Following your suggestion of not abusing g_signal_connect :P
Comment 4 Diego Escalante Urrelo 2007-07-30 20:55:51 PDT
Also, can we have a get_location() function here too?. Btw, I was wondering if this should be here or in gtkpage.
Comment 5 Holger Freyther 2007-08-01 10:33:44 PDT
The easy bits:
   -Yes get_location makes sense (IMHO)
   -I think they belong into WebKitGtkFrame

Two style issues:
   -AFAIK you don't need a user_data in the signal signature. Please remove it
   -I would like to see another name for the closure, more similiar to the one in webkitgtkpage.cpp (or as in the pending patch for createFrame)
   -No new lines in the cb, I think they fit in one line on a display.

Comment 6 Mark Rowe (bdash) 2007-08-01 20:26:35 PDT
Comment on attachment 15741 [details]
A better version

r- based on Holger's comments.

There is also very inconsistent placement of the * next to types or variable names.  The WebKit style is for the * to be next to the type in C and C++ code.  The code related to the Gtk API seems to be very inconsistent in this regard, but we should be trying to improve the situation rather than adding to the problem.

+    g_debug("title_changed: title=%s, location=%s", title, location);

We don't typically commit debugging printf's such as this.
Comment 7 Diego Escalante Urrelo 2007-08-02 06:46:08 PDT
Created attachment 15806 [details]
Updated.

Ok, following your comments and including the webkitgtkprivate.h part that I forgot.
I didn't get this comment however:
   -I would like to see another name for the closure, more similiar to the one
in webkitgtkpage.cpp (or as in the pending patch for createFrame)

Can you explain it to me please?

PD: I couldn't try the patch, my webkit installation doesn't work anymore because of libWebKitGdk.so: undefined reference to `WebCore::Document::setDomain(WebCore::String const&, bool)'.
Anyway it should work, and for the moment we can at least discuss about it.
Comment 8 Holger Freyther 2007-08-09 17:55:01 PDT
(In reply to comment #7)
> Can you explain it to me please?

Gtk+ and WebKitGtk* prefix such handlers with the normal prefix. So title_changed_cb should probably be webkit_gtk_frame_real_title_changed or just webkit_gtk_frame_title_changed.


> 
> PD: I couldn't try the patch, my webkit installation doesn't work anymore
> because of libWebKitGdk.so: undefined reference to
> `WebCore::Document::setDomain(WebCore::String const&, bool)'.
> Anyway it should work, and for the moment we can at least discuss about it.
>
Sometimes qmake from Qt4.2 has issues tracking dependencies. Qt4.3 seems to do it better but we might need to set a couple more DEPENDPATH and HEADERS in the .pro file.

Comment 9 Juan A. Suarez 2007-08-17 08:46:58 PDT
This bug should have the Gtk keyword.
Comment 10 Adam Roben (:aroben) 2007-08-19 21:05:38 PDT
Comment on attachment 15806 [details]
Updated.

r- given Holger's comments.
Comment 11 Diego Escalante Urrelo 2007-08-20 17:47:18 PDT
Created attachment 16044 [details]
Updated to trunk and following naming comments

Updated.
Comment 12 Mark Rowe (bdash) 2007-08-27 03:30:16 PDT
Comment on attachment 16044 [details]
Updated to trunk and following naming comments

Inside webkit_gtk_frame_title_changed_cb g_strdup is called but I don't see any corresponding calls to free the memory.

There are some minor coding style issues present:
+gchar*
+webkit_gtk_frame_get_title (WebKitGtkFrame* frame)

should be one line, for example.

You should also include a ChangeLog entry.  You can use WebKitTools/Scripts/prepare-ChangeLog to generate a template which you can then fill in.
Comment 13 Cyril Brulebois 2007-09-17 02:06:45 PDT
Created attachment 16303 [details]
Updated with g_free() calls, and coding style fixes.

I added g_free on finalize() and on updating, and hopefully fixed coding style problems. I didn't include copyright information for webkitgtkframe.cpp since Diego might want to be added instead of me; waiting for a reply from him.
Comment 14 Holger Freyther 2007-09-17 05:23:53 PDT
(In reply to comment #13)
> Created an attachment (id=16303) [edit]
> Updated with g_free() calls, and coding style fixes.
> 

+static void webkit_gtk_frame_title_changed_cb(WebKitGtkFrame* frame, gchar* title, gchar* location)
+{
+    WebKitGtkFramePrivate* frame_data = WEBKIT_GTK_FRAME_GET_PRIVATE(frame);
+    g_free (frame_data->title);
+    g_free (frame_data->location);
+    frame_data->title = g_strdup(title);
+    frame_data->location = g_strdup(location);
+}

frame_data -> frameData and "g_free (" -> "g_free(". but the memory leak spotted by Mark should be fixed.
Comment 15 Holger Freyther 2007-09-17 08:05:15 PDT
Landed in r25593.
Comment 16 Holger Freyther 2007-09-20 06:39:01 PDT
Comment on attachment 16303 [details]
Updated with g_free() calls, and coding style fixes.

The patch was landed and does not need further review.