Bug 98063 - [GTK] [WK2] Add favicon support to the MiniBrowser
Summary: [GTK] [WK2] Add favicon support to the MiniBrowser
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Minor
Assignee: Nobody
URL:
Keywords:
Depends on: 98153
Blocks:
  Show dependency treegraph
 
Reported: 2012-10-01 13:52 PDT by Alberto Garcia
Modified: 2012-10-03 06:54 PDT (History)
2 users (show)

See Also:


Attachments
Patch (3.84 KB, patch)
2012-10-02 00:57 PDT, Alberto Garcia
no flags Details | Formatted Diff | Diff
Patch v2 (3.86 KB, patch)
2012-10-02 04:49 PDT, Alberto Garcia
cgarcia: review-
Details | Formatted Diff | Diff
Patch v3 (3.76 KB, patch)
2012-10-03 06:32 PDT, Alberto Garcia
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alberto Garcia 2012-10-01 13:52:16 PDT
Since r129994 there's API to get the favicon of a web view, so it
would be nice to use it in the MiniBrowser.
Comment 1 Alberto Garcia 2012-10-02 00:57:57 PDT
Created attachment 166631 [details]
Patch
Comment 2 Carlos Garcia Campos 2012-10-02 01:19:38 PDT
Comment on attachment 166631 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=166631&action=review

I guess you should also unref the favicon pixbuf in finalize().

> Tools/MiniBrowser/gtk/BrowserWindow.c:375
> +    cairo_surface_t *surface;
> +
> +    surface = webkit_web_view_get_favicon(window->webView);

Use a single line here:

cairo_surface_t *surface = webkit_web_view_get_favicon(window->webView);

> Tools/MiniBrowser/gtk/BrowserWindow.c:445
> +    g_signal_connect(window->uriEntry, "notify::text", G_CALLBACK(uriEntryTextChanged), (gpointer)window);

Don't use the gpointer cast, it's not needed, I know there are several there already, but that's old code copied from GtkLauncher, I think.
Comment 3 Sergio Villar Senin 2012-10-02 01:46:34 PDT
Comment on attachment 166631 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=166631&action=review

> Tools/MiniBrowser/gtk/BrowserWindow.c:367
> +    }

Just a small nit. WebKit coding style prefers early returns for these cases. So better 

if (!window->favicon)
    return;
Comment 4 Alberto Garcia 2012-10-02 02:32:59 PDT
(In reply to comment #3)

> Just a small nit. WebKit coding style prefers early returns for these cases. So better 
> 
> if (!window->favicon)
>     return;

If you're talking about faviconChanged(), there we want to clear the
favicon if it's NULL, not just return.
Comment 5 Alberto Garcia 2012-10-02 04:49:53 PDT
Created attachment 166669 [details]
Patch v2

(In reply to comment #2)
> I guess you should also unref the favicon pixbuf in finalize().

> Use a single line here:
> cairo_surface_t *surface = webkit_web_view_get_favicon(window->webView);

> > +    g_signal_connect(window->uriEntry, "notify::text", G_CALLBACK(uriEntryTextChanged), (gpointer)window);
> Don't use the gpointer cast, it's not needed

Ok, here's the new patch with these three changes.

I also decided not to clear the icon when the URI entry is changed. So
for this to work correctly, WebKitWebView has to emit notify::favicon
also when a new page is loaded and it has no favicon.

The emission of that signal need anyway to be changed since it's not
being emitted in most cases at the moment, but it should not affect
the MiniBrowser code.
Comment 6 Mario Sanchez Prada 2012-10-02 06:44:17 PDT
Comment on attachment 166669 [details]
Patch v2

View in context: https://bugs.webkit.org/attachment.cgi?id=166669&action=review

Thanks for taking care of this, Berto. The patch looks good to me in general, I've just have a couple of really minor comments

> Tools/ChangeLog:18
> +        (browserWindowConstructed):

You should provide a brief description for each of these functions

> Tools/MiniBrowser/gtk/BrowserWindow.c:397
> +        window->favicon = NULL;

You could use g_clear_object() here
Comment 7 Carlos Garcia Campos 2012-10-02 08:17:27 PDT
(In reply to comment #6)
> (From update of attachment 166669 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=166669&action=review
> 
> Thanks for taking care of this, Berto. The patch looks good to me in general, I've just have a couple of really minor comments
> 
> > Tools/ChangeLog:18
> > +        (browserWindowConstructed):
> 
> You should provide a brief description for each of these functions
> 
> > Tools/MiniBrowser/gtk/BrowserWindow.c:397
> > +        window->favicon = NULL;
> 
> You could use g_clear_object() here

Make sure we depend on a recent enough glib to use g_clear_object
Comment 8 Carlos Garcia Campos 2012-10-03 06:10:56 PDT
Comment on attachment 166669 [details]
Patch v2

View in context: https://bugs.webkit.org/attachment.cgi?id=166669&action=review

> Tools/MiniBrowser/gtk/BrowserWindow.c:370
> +        cairo_surface_destroy(surface);

webkit_web_view_get_favicon() now returns transfer none, so you shouldn't destroy the surface.
Comment 9 Alberto Garcia 2012-10-03 06:32:34 PDT
Created attachment 166882 [details]
Patch v3

Here's the updated patch after the API changes in WebKitWebView.
Comment 10 Carlos Garcia Campos 2012-10-03 06:35:45 PDT
Comment on attachment 166882 [details]
Patch v3

Excellent
Comment 11 WebKit Review Bot 2012-10-03 06:54:30 PDT
Comment on attachment 166882 [details]
Patch v3

Clearing flags on attachment: 166882

Committed r130282: <http://trac.webkit.org/changeset/130282>
Comment 12 WebKit Review Bot 2012-10-03 06:54:34 PDT
All reviewed patches have been landed.  Closing bug.