Update Icelandic translation
[yelp.git] / tests / test-view.c
blob284b1468a692b5afaf1744701faacba6e758b250
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /*
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>
21 #include <gtk/gtk.h>
22 #include <webkit2/webkit2.h>
24 #include "yelp-view.h"
25 #include "yelp-uri.h"
26 #include "yelp-simple-document.h"
28 static void
29 activate_cb (GtkEntry *entry,
30 YelpView *view)
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));
39 static void
40 state_cb (YelpView *view,
41 GParamSpec *spec,
42 GtkWindow *window)
44 YelpViewState state;
45 g_object_get (view, "state", &state, NULL);
46 printf ("STATE: %i\n", (int)state);
49 static void
50 title_cb (YelpView *view,
51 GParamSpec *spec,
52 GtkWindow *window)
54 gchar *title;
55 g_object_get (view, "page-title", &title, NULL);
56 gtk_window_set_title (window, title);
57 g_free (title);
60 int
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),
81 GTK_POLICY_AUTOMATIC,
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);
95 if (argc >= 2) {
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));
105 gtk_main ();
107 return 0;