Changeset 88912 in webkit


Ignore:
Timestamp:
Jun 15, 2011 12:51:35 AM (13 years ago)
Author:
Carlos Garcia Campos
Message:

2011-06-15 Carlos Garcia Campos <cgarcia@igalia.com>

Reviewed by Martin Robinson.

[GTK] Add a statusbar to MiniBrowser
https://bugs.webkit.org/show_bug.cgi?id=62634

It shows the url of the current hovered link.

  • MiniBrowser/gtk/BrowserWindow.c: (browserWindowConstructed): Create the GtkSatusbar. (mouseDidMoveOverElement): Update statusbar text. (browserWindowUIClientInit): Add implementation for mouseDidMoveOverElement().
  • MiniBrowser/gtk/GNUmakefile.am: Add new files to compilation.
  • MiniBrowser/gtk/WebBundle/WebBundleMain.c: Added. (mouseDidMoveOverElement): Pass the url of the current hovered link to the UI process. (didCreatePage): Set the UI client adding an implementation for mouseDidMoveOverElement(). (WKBundleInitialize):
  • MiniBrowser/gtk/main.c: (createWKContextWithInjectedBundle): Create a global context with the injected bundle. (loadURI): Use the global context. (main):
Location:
trunk/Tools
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r88857 r88912  
     12011-06-15  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        Reviewed by Martin Robinson.
     4
     5        [GTK] Add a statusbar to MiniBrowser
     6        https://bugs.webkit.org/show_bug.cgi?id=62634
     7
     8        It shows the url of the current hovered link.
     9
     10        * MiniBrowser/gtk/BrowserWindow.c:
     11        (browserWindowConstructed): Create the GtkSatusbar.
     12        (mouseDidMoveOverElement): Update statusbar text.
     13        (browserWindowUIClientInit): Add implementation for
     14        mouseDidMoveOverElement().
     15        * MiniBrowser/gtk/GNUmakefile.am: Add new files to compilation.
     16        * MiniBrowser/gtk/WebBundle/WebBundleMain.c: Added.
     17        (mouseDidMoveOverElement): Pass the url of the current hovered
     18        link to the UI process.
     19        (didCreatePage): Set the UI client adding an implementation for
     20        mouseDidMoveOverElement().
     21        (WKBundleInitialize):
     22        * MiniBrowser/gtk/main.c:
     23        (createWKContextWithInjectedBundle): Create a global context with
     24        the injected bundle.
     25        (loadURI): Use the global context.
     26        (main):
     27
    1282011-06-14  Lucas Forschler  <lforschler@apple.com>
    229
  • trunk/Tools/MiniBrowser/gtk/BrowserWindow.c

    r87690 r88912  
    3737    GtkWindow parent;
    3838
    39     GtkWidget* mainBox;
    40     GtkWidget* uriEntry;
     39    GtkWidget *mainBox;
     40    GtkWidget *uriEntry;
     41    GtkWidget *statusBar;
    4142    WKViewRef webView;
    4243
    43     gchar* title;
     44    guint statusBarContextId;
     45
     46    gchar *title;
    4447    gdouble loadProgress;
    4548};
     
    164167    gtk_box_pack_start(GTK_BOX(window->mainBox), GTK_WIDGET(window->webView), TRUE, TRUE, 0);
    165168    gtk_widget_show(GTK_WIDGET(window->webView));
     169
     170    window->statusBar = gtk_statusbar_new();
     171    window->statusBarContextId = gtk_statusbar_get_context_id(GTK_STATUSBAR(window->statusBar), "Link Hover");
     172    gtk_box_pack_start(GTK_BOX(window->mainBox), window->statusBar, FALSE, FALSE, 0);
     173    gtk_widget_show(window->statusBar);
    166174
    167175    browserWindowLoaderClientInit(window);
     
    464472}
    465473
     474static void mouseDidMoveOverElement(WKPageRef page, WKEventModifiers modifiers, WKTypeRef userData, const void *clientInfo)
     475{
     476    BrowserWindow *window = BROWSER_WINDOW(clientInfo);
     477    gtk_statusbar_pop(GTK_STATUSBAR(window->statusBar), window->statusBarContextId);
     478
     479    if (!userData)
     480        return;
     481
     482    if (WKGetTypeID(userData) != WKURLGetTypeID())
     483        return;
     484
     485    gchar *link = WKURLGetCString((WKURLRef)userData);
     486    gtk_statusbar_push(GTK_STATUSBAR(window->statusBar), window->statusBarContextId, link);
     487    g_free(link);
     488}
     489
    466490static void browserWindowUIClientInit(BrowserWindow *window)
    467491{
     
    479503        runJavaScriptPrompt,
    480504        0,      /* setStatusText */
    481         0,      /* mouseDidMoveOverElement */
     505        mouseDidMoveOverElement,
    482506        0,      /* missingPluginButtonClicked */
    483507        0,      /* didNotHandleKeyEvent */
  • trunk/Tools/MiniBrowser/gtk/GNUmakefile.am

    r85311 r88912  
    3434CLEANFILES += \
    3535        $(top_builddir)/Programs/MiniBrowser
     36
     37# Injected bundle
     38noinst_LTLIBRARIES += Libraries/libMiniBrowserWebBundle.la
     39Libraries_libMiniBrowserWebBundle_la_SOURCES = \
     40        Tools/MiniBrowser/gtk/WebBundle/WebBundleMain.c
     41
     42Libraries_libMiniBrowserWebBundle_la_LDFLAGS = \
     43        -rpath ${shell pwd}/$(top_builddir)/../unix/TestNetscapePlugin/.libs \
     44        $(no_undefined) \
     45        -avoid-version \
     46        -module
     47
     48Libraries_libMiniBrowserWebBundle_la_CPPFLAGS = \
     49        -I$(top_builddir)/DerivedSources/InjectedBundle \
     50        -I$(top_builddir)/DerivedSources/WebKit2/include \
     51        $(global_cppflags) \
     52        $(javascriptcore_cppflags) \
     53        $(GLIB_CFLAGS)
  • trunk/Tools/MiniBrowser/gtk/main.c

    r85583 r88912  
    3232static const gchar **uriArguments = NULL;
    3333
     34static WKContextRef createWKContextWithInjectedBundle()
     35{
     36    WKStringRef bundlePath = WKStringCreateWithUTF8CString("Libraries/.libs/libMiniBrowserWebBundle.so");
     37    WKContextRef processContext = WKContextCreateWithInjectedBundlePath(bundlePath);
     38    WKContextInjectedBundleClient bundleClient = {
     39            0, /* version */
     40            0, /* clientInfo */
     41            0, /* didRecieveMessageFromInjectedBundle,*/
     42            0
     43    };
     44    WKContextSetInjectedBundleClient(processContext, &bundleClient);
     45    WKRelease(bundlePath);
     46
     47    return processContext;
     48}
     49
    3450static gchar *argumentToURL(const char *filename)
    3551{
     
    4157}
    4258
    43 static void loadURI(const gchar *uri)
     59static void loadURI(const gchar *uri, WKContextRef processContext)
    4460{
    45     WKViewRef webView = WKViewCreate(WKContextGetSharedProcessContext(), 0);
     61    WKViewRef webView = WKViewCreate(processContext, 0);
    4662    GtkWidget *mainWindow = browser_window_new(webView);
    4763    gchar *url = argumentToURL(uri);
     
    7894    g_option_context_free (context);
    7995
     96    WKContextRef processContext = createWKContextWithInjectedBundle();
     97
    8098    if (uriArguments) {
    8199        int i;
    82100
    83101        for (i = 0; uriArguments[i]; i++)
    84             loadURI(uriArguments[i]);
     102            loadURI(uriArguments[i], processContext);
    85103    } else
    86         loadURI("http://www.webkitgtk.org/");
     104        loadURI("http://www.webkitgtk.org/", processContext);
    87105
    88106    gtk_main();
Note: See TracChangeset for help on using the changeset viewer.