/* * gpe-conf * * Copyright (C) 2005, 2006 Florian Boor * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * * GPE external keyboard configuration module. * */ #include #include #include #include #include #include #include #include #define _(x) gettext(x) #include #include #include #include #include "../applets.h" #include "../serial.h" #include "../device.h" #define N_(_x) (_x) /* --- local types and constants --- */ /* this is from apps/kbdd/kbd.c */ #define KBD_TYPE_NONE 0 #define KBD_TYPE_FOLDABLE 1 #define KBD_TYPE_SNAPNTYPE 2 #define KBD_TYPE_STOWAWAY 3 #define KBD_TYPE_STOWAWAYXT 4 #define KBD_TYPE_HPSLIM 5 #define KBD_TYPE_SMARTBT 6 #define KBD_TYPE_LIRC 7 #define KBD_TYPE_BELKINIR 8 #define KBD_TYPE_FLEXIS 9 #define KBD_TYPE_BENQ_GAMEPAD 10 #define KBD_TYPE_POCKETVIK 11 #define KBD_TYPE_MICRO_FOLDAWAY 12 #define KBD_TYPE_MICRO_DATAPAD 13 #define KBD_TYPE_MAX 14 #define DEFAULT_TTS "/dev/ttyS0" #define KBDD_CONFIG "/etc/kbdd.conf" #define KBDD_CMD PREFIX "/bin/kbdd" typedef struct { gchar *idstr; gint type; gchar *name; }t_keyboard; /* --- module global variables --- */ gint keyboard_type = KBD_TYPE_NONE; gchar keyboard_port[PATH_MAX] = "none"; static GtkWidget *cbPort; /* TRANSLATORS: Keyboard names below are brand names, please check local names or keep original names */ t_keyboard ktable[] = { {"none", KBD_TYPE_NONE, N_("none")}, {"foldable", KBD_TYPE_FOLDABLE, N_("Foldable")}, {"snapntype", KBD_TYPE_SNAPNTYPE, N_("SnapNType")}, {"stowaway", KBD_TYPE_STOWAWAY, N_("Stowaway")}, {"stowawayxt", KBD_TYPE_STOWAWAYXT, N_("StowawayXT")}, {"hpslim", KBD_TYPE_HPSLIM, N_("HP Slim")}, {"smartbt", KBD_TYPE_SMARTBT, N_("Smart BT")}, {"lirc", KBD_TYPE_LIRC, N_("LIRC")}, {"belkinir", KBD_TYPE_BELKINIR, N_("Belkin IR")}, {"flexis", KBD_TYPE_FLEXIS, N_("Flexis")}, {"g250", KBD_TYPE_BENQ_GAMEPAD, N_("Benq Gamepad")}, {"pocketvik", KBD_TYPE_POCKETVIK, N_("Pocketvik")}, {"microfold", KBD_TYPE_MICRO_FOLDAWAY, N_("Micro Foldaway")}, {"micropad", KBD_TYPE_MICRO_DATAPAD, N_("Micro Datapad")}, {"--dummy--", KBD_TYPE_MAX} }; /* --- local intelligence --- */ void keyboard_get_config(const gchar **model, const gchar **port) { const gchar *text; gint i; const gchar* kport = NULL; text = gtk_entry_get_text (GTK_ENTRY(GTK_COMBO(cbPort)->entry)); for (i=0; ientry)); snprintf(keyboard_port, PATH_MAX, "%s", kport); *model = ktable[keyboard_type].idstr; *port = keyboard_port; } gint find_kbd_type(const gchar *ktype) { gint i; for (i=0; i%s", _("External Keyboard Port")); gtk_label_set_markup (GTK_LABEL (label), buf); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_table_attach (GTK_TABLE (table), label, 0, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0); gtk_tooltips_set_tip (tooltips, label, _("Here you may select your external keyboard model."), NULL); /* port selector */ for (i=0; ientry), keyboard_port); for (i=0; ientry), portlist[i][0]); } /* keyboard selection */ label = gtk_label_new (NULL); snprintf (buf, 100, "%s", _("External Keyboard Type")); gtk_label_set_markup (GTK_LABEL (label), buf); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_table_attach (GTK_TABLE (table), label, 0, 2, 2, 3, GTK_FILL, GTK_FILL, 0, 0); cbAny = gtk_combo_new(); for (i = 0; i < KBD_TYPE_MAX; i++) { keyboards = g_slist_append(keyboards, ktable[i].name); if (keyboard_type == ktable[i].type) gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(cbAny)->entry), ktable[i].name); } gtk_combo_set_popdown_strings(GTK_COMBO(cbAny), (GList *)keyboards); gtk_combo_set_value_in_list(GTK_COMBO(cbAny), TRUE, FALSE); g_signal_connect_after(G_OBJECT(GTK_COMBO(cbAny)->entry), "changed", G_CALLBACK(keyboard_selected), NULL); gtk_table_attach (GTK_TABLE (table), cbAny, 0, 2, 4, 5, GTK_FILL, GTK_FILL, 0, 0); g_free(buf); return sw; }