tagging release
[dasher.git] / Src / Gtk2 / dasher_action_keyboard_maemo.cpp
blob0bfcc973e953873e36002d41d59a515f99cfca6c
1 // TODO: Make inc lusion of this file in build conditional
2 #include "config.h"
3 #ifdef WITH_MAEMO
5 #include "dasher.h"
6 #include "dasher_maemo_helper.h"
7 #include "dasher_action_keyboard_maemo.h"
9 #include <gdk/gdkx.h>
11 static void dasher_action_keyboard_maemo_class_init(DasherActionKeyboardMaemoClass *pClass);
12 static void dasher_action_keyboard_maemo_init(DasherActionKeyboardMaemo *pActionKeyboardMaemo);
13 static void dasher_action_keyboard_maemo_destroy(GObject *pObject);
14 static gboolean dasher_action_keyboard_maemo_execute(DasherAction *pSelf, DasherEditor *pEditor, int iIdx);
15 static const gchar *dasher_action_keyboard_maemo_get_name(DasherAction *pSelf);
17 GType dasher_action_keyboard_maemo_get_type() {
19 static GType dasher_action_keyboard_maemo_type = 0;
21 if(!dasher_action_keyboard_maemo_type) {
22 static const GTypeInfo dasher_action_keyboard_maemo_info = {
23 sizeof(DasherActionKeyboardMaemoClass),
24 NULL,
25 NULL,
26 (GClassInitFunc) dasher_action_keyboard_maemo_class_init,
27 NULL,
28 NULL,
29 sizeof(DasherActionKeyboardMaemo),
31 (GInstanceInitFunc) dasher_action_keyboard_maemo_init,
32 NULL
35 dasher_action_keyboard_maemo_type = g_type_register_static(TYPE_DASHER_ACTION, "DasherActionKeyboardMaemo", &dasher_action_keyboard_maemo_info, static_cast < GTypeFlags > (0));
38 return dasher_action_keyboard_maemo_type;
41 static void dasher_action_keyboard_maemo_class_init(DasherActionKeyboardMaemoClass *pClass) {
42 GObjectClass *pObjectClass = (GObjectClass *) pClass;
43 pObjectClass->finalize = dasher_action_keyboard_maemo_destroy;
45 DasherActionClass *pDasherActionClass = (DasherActionClass *) pClass;
46 pDasherActionClass->execute = dasher_action_keyboard_maemo_execute;
47 pDasherActionClass->get_name = dasher_action_keyboard_maemo_get_name;
50 static void dasher_action_keyboard_maemo_init(DasherActionKeyboardMaemo *pDasherControl) {
51 // Probably a waste of time - we don't really need any private data here
52 pDasherControl->private_data = 0;
55 static void dasher_action_keyboard_maemo_destroy(GObject *pObject) {
56 // FIXME - I think we need to chain up through the finalize methods
57 // of the parent classes here...
60 DasherActionKeyboardMaemo *dasher_action_keyboard_maemo_new() {
61 DasherActionKeyboardMaemo *pDasherControl;
63 pDasherControl = (DasherActionKeyboardMaemo *)(g_object_new(dasher_action_keyboard_maemo_get_type(), NULL));
65 return pDasherControl;
68 static gboolean dasher_action_keyboard_maemo_execute(DasherAction *pSelf, DasherEditor *pEditor, int iIdx) {
70 const char *szData = dasher_editor_get_all_text(pEditor);
72 // TODO: Make this work properly with UTF-8
73 GdkEventClient sMyEvent;
75 for(int i(0); i < strlen(szData); ++i) {
76 sMyEvent.type = GDK_CLIENT_EVENT;
77 sMyEvent.window = g_pRandomWindow;
78 sMyEvent.send_event = true;
79 sMyEvent.message_type = gdk_atom_intern("_HILDON_IM_INSERT_UTF8", true);
80 sMyEvent.data_format = 8; // I know this is wrong...
81 sMyEvent.data.l[0] = 0;
82 sMyEvent.data.l[1] = szData[i];
83 sMyEvent.data.l[2] = 0;
84 sMyEvent.data.l[3] = 0;
85 sMyEvent.data.l[4] = 0;
87 gdk_event_send_client_message((GdkEvent *)(&sMyEvent), g_FRandomWindow);
90 return true;
93 static const gchar *dasher_action_keyboard_maemo_get_name(DasherAction *pSelf) {
94 return "Enter Text";
97 #endif