1
/* * This file is part of Maliit framework *
3
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
6
* Contact: maliit-discuss@lists.maliit.org
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
* License version 2.1 as published by the Free Software Foundation
11
* and appearing in the file LICENSE.LGPL included in the packaging
17
#include <maliit-glib/maliitinputmethod.h>
20
show_button_clicked(GtkButton *button G_GNUC_UNUSED,
23
MaliitInputMethod *input_method = MALIIT_INPUT_METHOD(user_data);
25
maliit_input_method_show(input_method);
29
hide_button_clicked(GtkButton *button G_GNUC_UNUSED,
32
MaliitInputMethod *input_method = MALIIT_INPUT_METHOD(user_data);
34
maliit_input_method_hide(input_method);
38
input_method_area_changed(MaliitInputMethod *input_method G_GNUC_UNUSED,
39
int x, int y, int width, int height,
42
GtkLabel *label = GTK_LABEL(user_data);
43
gchar *formatted_string;
45
if (width == 0 || height == 0)
46
formatted_string = g_strdup("Empty Input Method area");
48
formatted_string = g_strdup_printf("Input Method area: [%d, %d, %d, %d]", x, y, width, height);
50
gtk_label_set_text(label, formatted_string);
52
g_free(formatted_string);
59
GtkWidget *window, *vbox;
60
GtkWidget *show_button, *hide_button, *entry, *text_view, *label;
61
MaliitInputMethod *input_method;
63
gtk_init(&argc, &argv);
65
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
66
gtk_window_set_title(GTK_WINDOW(window), "Maliit GTK+ example");
68
input_method = maliit_input_method_new();
70
show_button = gtk_button_new_with_label("Show keyboard");
71
g_signal_connect(show_button, "clicked",
72
G_CALLBACK(show_button_clicked), input_method);
73
hide_button = gtk_button_new_with_label("Hide keyboard");
74
g_signal_connect(hide_button, "clicked",
75
G_CALLBACK(hide_button_clicked), input_method);
76
entry = gtk_entry_new();
77
text_view = gtk_text_view_new();
78
gtk_widget_set_size_request(text_view, 150, 200);
80
label = gtk_label_new("Empty Input Method area");
81
g_signal_connect(input_method, "area-changed",
82
G_CALLBACK(input_method_area_changed), label);
84
#if GTK_MAJOR_VERSION >= 3
85
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
87
vbox = gtk_vbox_new(FALSE, 10);
90
gtk_box_pack_start(GTK_BOX(vbox), show_button, FALSE, FALSE, 0);
91
gtk_box_pack_start(GTK_BOX(vbox), hide_button, FALSE, FALSE, 0);
92
gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0);
93
gtk_box_pack_start(GTK_BOX(vbox), text_view, TRUE, TRUE, 0); /* Expands */
94
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
95
gtk_container_add(GTK_CONTAINER(window), vbox);
97
g_signal_connect(G_OBJECT(window), "delete-event",
98
G_CALLBACK(gtk_main_quit), window);
99
gtk_widget_show_all(window);
103
g_object_unref(input_method);