@@ -1,127 +0,0 @@
1−/*
2− * Copyright (C) 2006, 2007 Apple Inc.
3− * Copyright (C) 2007 Alp Toker <alp@atoker.com>
4− *
5− * Copyright (C) 2009 Michael Snoyman <michael@snoyman.com>
6− *
7− * Redistribution and use in source and binary forms, with or without
8− * modification, are permitted provided that the following conditions
9− * are met:
10− * 1. Redistributions of source code must retain the above copyright
11− * notice, this list of conditions and the following disclaimer.
12− * 2. Redistributions in binary form must reproduce the above copyright
13− * notice, this list of conditions and the following disclaimer in the
14− * documentation and/or other materials provided with the distribution.
15− *
16− * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
17− * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18− * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19− * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
20− * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21− * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22− * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23− * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24− * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25− * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26− * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27− */
28−
29−#include <gtk/gtk.h>
30−#include <webkit/webkit.h>
31−
32−static GtkWidget* main_window;
33−static WebKitWebView* web_view;
34−static gchar* main_title;
35−
36−static void
37−update_title (GtkWindow* window)
38−{
39− GString* string = g_string_new (main_title);
40− gchar* title = g_string_free (string, FALSE);
41− gtk_window_set_title (window, title);
42− g_free (title);
43−}
44−
45−static void
46−title_change_cb (WebKitWebView* web_view, WebKitWebFrame* web_frame, const gchar* title, gpointer data)
47−{
48− if (main_title)
49− g_free (main_title);
50− main_title = g_strdup (title);
51− update_title (GTK_WINDOW (main_window));
52−}
53−
54−/*
55− static void
56− notify_load_status_cb (WebKitWebView* web_view, GParamSpec* pspec, gpointer data)
57− {
58− if (webkit_web_view_get_load_status (web_view) == WEBKIT_LOAD_COMMITTED) {
59− WebKitWebFrame* frame = webkit_web_view_get_main_frame (web_view);
60− const gchar* uri = webkit_web_frame_get_uri (frame);
61− if (uri)
62− gtk_entry_set_text (GTK_ENTRY (uri_entry), uri);
63− }
64− }
65− */
66−
67−/*static void
68− notify_progress_cb (WebKitWebView* web_view, GParamSpec* pspec, gpointer data)
69− {
70− load_progress = webkit_web_view_get_progress (web_view) * 100;
71− update_title (GTK_WINDOW (main_window));
72− }
73− */
74−
75−static void
76−destroy_cb (GtkWidget* widget, gpointer data)
77−{
78− gtk_main_quit ();
79−}
80−
81−static GtkWidget*
82−create_browser ()
83−{
84− GtkWidget* scrolled_window = gtk_scrolled_window_new (NULL, NULL);
85− gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
86−
87− web_view = WEBKIT_WEB_VIEW (webkit_web_view_new ());
88− gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (web_view));
89−
90− g_signal_connect (web_view, "title-changed", G_CALLBACK (title_change_cb), web_view);
91−
92− return scrolled_window;
93−}
94−
95−static GtkWidget*
96−create_window ()
97−{
98− GtkWidget* window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
99− gtk_window_set_default_size (GTK_WINDOW (window), 800, 600);
100− gtk_widget_set_name (window, "GtkLauncher");
101− g_signal_connect (window, "destroy", G_CALLBACK (destroy_cb), NULL);
102−
103− return window;
104−}
105−
106−void start_browser(void)
107−{
108− int argc = 0;
109− char *argv0 = "";
110− char **argv = &argv0;
111− gtk_init (&argc, &argv);
112− if (!g_thread_supported ())
113− g_thread_init (NULL);
114−
115− GtkWidget* vbox = gtk_vbox_new (FALSE, 0);
116− gtk_box_pack_start (GTK_BOX (vbox), create_browser (), TRUE, TRUE, 0);
117−
118− main_window = create_window ();
119− gtk_container_add (GTK_CONTAINER (main_window), vbox);
120−
121− gchar* uri = (gchar*) ("http://localhost:3000");
122− webkit_web_view_open (web_view, uri);
123−
124− gtk_widget_grab_focus (GTK_WIDGET (web_view));
125− gtk_widget_show_all (main_window);
126− gtk_main ();
127−}