Changeset 85313 in webkit
- Timestamp:
- Apr 29, 2011 2:55:51 AM (13 years ago)
- Location:
- trunk/Tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r85311 r85313 1 2011-04-29 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 Reviewed by Martin Robinson. 4 5 [GTK] Implement UI client in minibrowser 6 https://bugs.webkit.org/show_bug.cgi?id=58416 7 8 It also allows to open more than one minibrowser window from the 9 command line. 10 11 * MiniBrowser/gtk/BrowserWindow.c: 12 (browserWindowFinalize): 13 (browser_window_init): 14 (browserWindowConstructed): 15 (createNewPage): 16 (showPage): 17 (closePage): 18 (runJavaScriptAlert): 19 (browserWindowUIClientInit): 20 * MiniBrowser/gtk/main.c: 21 (loadURI): 22 (main): 23 1 24 2011-04-29 Carlos Garcia Campos <cgarcia@igalia.com> 2 25 -
trunk/Tools/MiniBrowser/gtk/BrowserWindow.c
r85311 r85313 50 50 51 51 static void browserWindowLoaderClientInit(BrowserWindow*); 52 static void browserWindowUIClientInit(BrowserWindow*); 53 54 static gint windowCount = 0; 52 55 53 56 G_DEFINE_TYPE(BrowserWindow, browser_window, GTK_TYPE_WINDOW) … … 76 79 77 80 G_OBJECT_CLASS(browser_window_parent_class)->finalize(gObject); 81 82 if (g_atomic_int_dec_and_test(&windowCount)) 83 gtk_main_quit(); 78 84 } 79 85 … … 106 112 static void browser_window_init(BrowserWindow* window) 107 113 { 114 g_atomic_int_inc(&windowCount); 115 108 116 gtk_window_set_default_size(GTK_WINDOW(window), 800, 600); 109 117 … … 158 166 159 167 browserWindowLoaderClientInit(window); 168 browserWindowUIClientInit(window); 160 169 } 161 170 … … 374 383 } 375 384 385 // UI Client. 386 static WKPageRef createNewPage(WKPageRef page, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton button, const void *clientInfo) 387 { 388 WKViewRef webView = WKViewCreate(WKPageGetContext(page), 0); 389 BrowserWindow* window = BROWSER_WINDOW(browser_window_new(webView)); 390 return WKRetain(WKViewGetPage(window->webView)); 391 } 392 393 static void showPage(WKPageRef page, const void *clientInfo) 394 { 395 gtk_widget_show(GTK_WIDGET(clientInfo)); 396 } 397 398 static void closePage(WKPageRef page, const void *clientInfo) 399 { 400 gtk_widget_destroy(GTK_WIDGET(clientInfo)); 401 } 402 403 static void runJavaScriptAlert(WKPageRef page, WKStringRef message, WKFrameRef frame, const void *clientInfo) 404 { 405 } 406 407 static void browserWindowUIClientInit(BrowserWindow *window) 408 { 409 WKPageUIClient uiClient = { 410 0, /* version */ 411 window, /* clientInfo */ 412 createNewPage, 413 showPage, 414 closePage, 415 0, /* takeFocus */ 416 0, /* focus */ 417 0, /* unfocus */ 418 runJavaScriptAlert, 419 0, /* runJavaScriptConfirm */ 420 0, /* runJavaScriptPrompt */ 421 0, /* setStatusText */ 422 0, /* mouseDidMoveOverElement */ 423 0, /* missingPluginButtonClicked */ 424 0, /* didNotHandleKeyEvent */ 425 0, /* toolbarsAreVisible */ 426 0, /* setToolbarsAreVisible */ 427 0, /* menuBarIsVisible */ 428 0, /* setMenuBarIsVisible */ 429 0, /* statusBarIsVisible */ 430 0, /* setStatusBarIsVisible */ 431 0, /* isResizable */ 432 0, /* setIsResizable */ 433 0, /* getWindowFrame */ 434 0, /* setWindowFrame */ 435 0, /* runBeforeUnloadConfirmPanel */ 436 0, /* didDraw */ 437 0, /* pageDidScroll */ 438 0, /* exceededDatabaseQuota */ 439 0, /* runOpenPanel */ 440 0, /* decidePolicyForGeolocationPermissionRequest */ 441 0, /* headerHeight */ 442 0, /* footerHeight */ 443 0, /* drawHeader */ 444 0, /* drawFooter */ 445 0, /* printFrame */ 446 0, /* runModal */ 447 0, /* didCompleteRubberBandForMainFrame */ 448 0, /* saveDataToFileInDownloadsFolder */ 449 0 /* shouldInterruptJavaScript */ 450 }; 451 WKPageSetPageUIClient(WKViewGetPage(window->webView), &uiClient); 452 } 453 376 454 // Public API. 377 455 GtkWidget* browser_window_new(WKViewRef view) -
trunk/Tools/MiniBrowser/gtk/main.c
r85311 r85313 30 30 #include <gtk/gtk.h> 31 31 32 static void destroyCallback(GtkWidget *widget, GtkWidget *window) 33 { 34 gtk_main_quit(); 35 } 36 37 static WKViewRef createWebView() 38 { 39 return WKViewCreate(WKContextGetSharedProcessContext(), 0); 40 } 41 42 static GtkWidget *createWindow(WKViewRef webView) 43 { 44 GtkWidget *window = browser_window_new(webView); 45 46 g_signal_connect(window, "destroy", G_CALLBACK(destroyCallback), NULL); 47 48 return window; 49 } 32 static const gchar **uriArguments = NULL; 50 33 51 34 static gchar *argumentToURL(const char *filename) … … 58 41 } 59 42 60 int main(int argc, char *argv[])43 static void loadURI(const gchar *uri) 61 44 { 62 gtk_init(&argc, &argv); 63 64 if (!g_thread_supported()) 65 g_thread_init(NULL); 66 67 WKViewRef webView = createWebView(); 68 GtkWidget *mainWindow = createWindow(webView); 69 70 gchar* url = argumentToURL(argc > 1 ? argv[1] : "http://www.webkitgtk.org/"); 45 WKViewRef webView = WKViewCreate(WKContextGetSharedProcessContext(), 0); 46 GtkWidget *mainWindow = browser_window_new(webView); 47 gchar *url = argumentToURL(uri); 71 48 WKPageLoadURL(WKViewGetPage(webView), WKURLCreateWithUTF8CString(url)); 72 49 g_free(url); 73 50 74 51 gtk_widget_grab_focus(GTK_WIDGET(webView)); 75 gtk_widget_show_all(mainWindow); 52 gtk_widget_show(mainWindow); 53 } 54 55 static const GOptionEntry commandLineOptions[] = 56 { 57 { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &uriArguments, 0, "[URL…]" }, 58 { 0 } 59 }; 60 61 int main(int argc, char *argv[]) 62 { 63 if (!g_thread_supported()) 64 g_thread_init(NULL); 65 66 GOptionContext *context = g_option_context_new(NULL); 67 g_option_context_add_main_entries(context, commandLineOptions, 0); 68 g_option_context_add_group(context, gtk_get_option_group(TRUE)); 69 70 GError *error = 0; 71 if (!g_option_context_parse(context, &argc, &argv, &error)) { 72 g_printerr("Cannot parse arguments: %s\n", error->message); 73 g_error_free(error); 74 g_option_context_free(context); 75 76 return 1; 77 } 78 g_option_context_free (context); 79 80 if (uriArguments) { 81 int i; 82 83 for (i = 0; uriArguments[i]; i++) 84 loadURI(uriArguments[i]); 85 } else 86 loadURI("http://www.webkitgtk.org/"); 87 76 88 gtk_main(); 77 89
Note: See TracChangeset
for help on using the changeset viewer.