1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
3 * Copyright (C) 2003-2009 Shaun McCance <shaunm@gnome.org>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, see <http://www.gnu.org/licenses/>.
18 * Author: Shaun McCance <shaunm@gnome.org>
22 #include <webkit2/webkit2.h>
24 #include "yelp-view.h"
26 #include "yelp-simple-document.h"
29 activate_cb (GtkEntry
*entry
,
32 /* I put in the double-load to test some race condition bugs.
33 * I decided to leave it in.
35 yelp_view_load (view
, gtk_entry_get_text (entry
));
36 yelp_view_load (view
, gtk_entry_get_text (entry
));
40 state_cb (YelpView
*view
,
45 g_object_get (view
, "state", &state
, NULL
);
46 printf ("STATE: %i\n", (int)state
);
50 title_cb (YelpView
*view
,
55 g_object_get (view
, "page-title", &title
, NULL
);
56 gtk_window_set_title (window
, title
);
61 main (int argc
, char **argv
)
63 GtkWidget
*window
, *vbox
, *entry
, *scroll
, *view
;
65 gtk_init (&argc
, &argv
);
67 window
= gtk_window_new (GTK_WINDOW_TOPLEVEL
);
68 gtk_window_set_type_hint ((GtkWindow
*) window
,
69 GDK_WINDOW_TYPE_HINT_UTILITY
);
70 gtk_window_set_default_size (GTK_WINDOW (window
), 520, 580);
71 g_signal_connect (window
, "destroy", G_CALLBACK (gtk_main_quit
), NULL
);
73 vbox
= gtk_box_new (GTK_ORIENTATION_VERTICAL
, 0);
74 gtk_container_add (GTK_CONTAINER (window
), vbox
);
76 entry
= gtk_entry_new ();
77 gtk_box_pack_start (GTK_BOX (vbox
), entry
, FALSE
, FALSE
, 0);
79 scroll
= gtk_scrolled_window_new (NULL
, NULL
);
80 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll
),
82 GTK_POLICY_AUTOMATIC
);
83 gtk_box_pack_start (GTK_BOX (vbox
), scroll
, TRUE
, TRUE
, 0);
85 view
= yelp_view_new ();
86 g_signal_connect (view
, "notify::state",
87 G_CALLBACK (state_cb
), window
);
88 g_signal_connect (view
, "notify::title",
89 G_CALLBACK (title_cb
), window
);
90 gtk_container_add (GTK_CONTAINER (scroll
), view
);
93 g_signal_connect (entry
, "activate", G_CALLBACK (activate_cb
), view
);
96 /* I put in the double-load to test some race condition bugs.
97 * I decided to leave it in.
99 yelp_view_load (YELP_VIEW (view
), argv
[1]);
100 yelp_view_load (YELP_VIEW (view
), argv
[1]);
103 gtk_widget_show_all (GTK_WIDGET (window
));