Debian Codegraph @

gtk/gtkimcontextbroadway.c

raw symbols SCIP
1 /*
2 * gtkimmodulebroadway
3 * Copyright (C) 2013 Alexander Larsson
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library 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 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
17 *
18 * $Id:$
19 */
20
21 #include "config.h"
22 #include <string.h>
23
24 #include "gtk/gtkimcontextbroadway.h"
25 #include "gtk/gtkimmoduleprivate.h"
26
27 #include "gdk/broadway/gdkbroadway.h"
28
29 G_GNUC_BEGIN_IGNORE_DEPRECATIONS
30
31 #define GTK_TYPE_IM_CONTEXT_BROADWAY (gtk_im_context_broadway_get_type ())
32 #define GTK_IM_CONTEXT_BROADWAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_IM_CONTEXT_BROADWAY, GtkIMContextBroadway))
33 #define GTK_IM_CONTEXT_BROADWAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GTK_TYPE_IM_CONTEXT_BROADWAY, GtkIMContextBroadwayClass))
34
35 typedef struct _GtkIMContextBroadway
36 {
37 GtkIMContextSimple parent;
38 GtkWidget *client_widget;
39 } GtkIMContextBroadway;
40
41 typedef struct _GtkIMContextBroadwayClass
42 {
43 GtkIMContextSimpleClass parent_class;
44 } GtkIMContextBroadwayClass;
45
46 G_DEFINE_TYPE_WITH_CODE (GtkIMContextBroadway, gtk_im_context_broadway, GTK_TYPE_IM_CONTEXT_SIMPLE,
47 gtk_im_module_ensure_extension_point ();
48 g_io_extension_point_implement (GTK_IM_MODULE_EXTENSION_POINT_NAME,
49 g_define_type_id,
50 "broadway",
51 0))
52
53 static void
54 broadway_set_client_widget (GtkIMContext *context, GtkWidget *widget)
55 {
56 GtkIMContextBroadway *bw = GTK_IM_CONTEXT_BROADWAY (context);
57
58 bw->client_widget = widget;
59 }
60
61 static void
62 broadway_focus_in (GtkIMContext *context)
63 {
64 GtkIMContextBroadway *bw = GTK_IM_CONTEXT_BROADWAY (context);
65 GdkDisplay *display;
66
67 if (bw->client_widget)
68 {
69 display = gtk_widget_get_display (bw->client_widget);
70 gdk_broadway_display_show_keyboard (GDK_BROADWAY_DISPLAY (display));
71 }
72 }
73
74 static void
75 broadway_focus_out (GtkIMContext *context)
76 {
77 GtkIMContextBroadway *bw = GTK_IM_CONTEXT_BROADWAY (context);
78 GdkDisplay *display;
79
80 if (bw->client_widget)
81 {
82 display = gtk_widget_get_display (bw->client_widget);
83 gdk_broadway_display_hide_keyboard (GDK_BROADWAY_DISPLAY (display));
84 }
85 }
86
87 static void
88 gtk_im_context_broadway_class_init (GtkIMContextBroadwayClass *class)
89 {
90 GtkIMContextClass *klass = GTK_IM_CONTEXT_CLASS (class);
91
92 klass->focus_in = broadway_focus_in;
93 klass->focus_out = broadway_focus_out;
94 klass->set_client_widget = broadway_set_client_widget;
95 }
96
97 static void
98 gtk_im_context_broadway_init (GtkIMContextBroadway *im_context)
99 {
100 }