Merging upstream version 0.7.0 (Closes: #493243, #510888, #567617, #699414, #709777...
[debian/lxpanel.git] / plugins / xkb / xkb.h
1 /*
2 //====================================================================
3 // xfce4-xkb-plugin - XFCE4 Xkb Layout Indicator panel plugin
4 // -------------------------------------------------------------------
5 // Alexander Iliev <sasoiliev@mamul.org>
6 // 20-Feb-04
7 // -------------------------------------------------------------------
8 // Parts of this code belong to Michael Glickman <wmalms@yahooo.com>
9 // and his program wmxkb.
10 // WARNING: DO NOT BOTHER Michael Glickman WITH QUESTIONS ABOUT THIS
11 // PROGRAM!!! SEND INSTEAD EMAILS TO <sasoiliev@mamul.org>
12 //====================================================================
13 */
14
15 /* Modified by Hong Jen Yee (PCMan) <pcman.tw@gmail.com> on 2008-04-06 for lxpanel */
16
17 /* Modified by Giuseppe Penone <giuspen@gmail.com> starting from 2012-07 and lxpanel 0.5.10 */
18
19 #ifndef _XKB_PLUGIN_H_
20 #define _XKB_PLUGIN_H_
21
22 #include <X11/Xlib.h>
23 #include <X11/XKBlib.h>
24 #include <gtk/gtk.h>
25 #include <glib.h>
26
27 #include "plugin.h"
28 #include "ev.h"
29
30 typedef enum {
31 DISP_TYPE_IMAGE=0,
32 DISP_TYPE_TEXT=1,
33 DISP_TYPE_IMAGE_CUST=2
34 } DisplayType;
35
36 typedef struct {
37
38 /* Plugin interface. */
39 LXPanel *panel; /* Back pointer to Panel */
40 config_setting_t *settings; /* Plugin settings */
41 GtkWidget *p_plugin; /* Back pointer to Plugin */
42 GtkWidget *p_label; /* Label containing country name */
43 GtkWidget *p_image; /* Image containing country flag */
44 int display_type; /* Display layout as image or text */
45 gboolean enable_perwin; /* Enable per window layout */
46 gboolean do_not_reset_opt; /* Do not reset options in setxkbmap */
47 gboolean keep_system_layouts; /* Keey system layouts, skip setxkbmap */
48 GtkWindow *p_dialog_config; /* Configuration dialog */
49 GtkListStore *p_liststore_layout;
50 GtkWidget *p_treeview_layout;
51 GtkTreeSelection *p_treeselection_layout;
52 GtkWidget *p_button_kbd_model;
53 GtkWidget *p_button_change_layout;
54 GtkWidget *p_button_rm_layout;
55 GtkWidget *p_frame_kbd_model, *p_frame_kbd_layouts, *p_frame_change_layout;
56 GtkWidget *p_entry_advanced_opt, *p_checkbutton_no_reset_opt;
57
58 /* Mechanism. */
59 int base_event_code; /* Result of initializing Xkb extension */
60 int base_error_code;
61 int current_group_xkb_no; /* Current layout */
62 int group_count; /* Count of groups as returned by Xkb */
63 char *group_names[XkbNumKbdGroups]; /* Group names as returned by Xkb */
64 char *symbol_names[XkbNumKbdGroups]; /* Symbol names as returned by Xkb */
65 GHashTable *p_hash_table_group; /* Hash table to correlate window with layout */
66 gchar *kbd_model;
67 gchar *kbd_layouts;
68 gchar *kbd_variants;
69 gchar *kbd_change_option;
70 gchar *kbd_advanced_options;
71 GString *p_gstring_layouts_partial;
72 GString *p_gstring_variants_partial;
73 GString *p_gstring_change_opt_partial;
74 gint flag_size;
75 int num_layouts;
76 gboolean cust_dir_exists;
77
78 } XkbPlugin;
79
80 #define MAX_MARKUP_LEN 64
81 #define MAX_ROW_LEN 64
82
83 extern void xkb_redraw(XkbPlugin * xkb);
84 extern void xkb_setxkbmap(XkbPlugin *p_xkb);
85
86 extern int xkb_get_current_group_xkb_no(XkbPlugin * xkb);
87 extern int xkb_get_group_count(XkbPlugin * xkb);
88 extern const char * xkb_get_symbol_name_by_res_no(XkbPlugin * xkb, int group_res_no);
89 extern const char * xkb_get_current_group_name(XkbPlugin * xkb);
90 extern const char * xkb_get_current_symbol_name(XkbPlugin * xkb);
91 extern const char * xkb_get_current_symbol_name_lowercase(XkbPlugin * xkb);
92 extern void xkb_mechanism_constructor(XkbPlugin * xkb);
93 extern void xkb_mechanism_destructor(XkbPlugin * xkb);
94 extern int xkb_change_group(XkbPlugin * xkb, int increment);
95 extern void xkb_active_window_changed(XkbPlugin * xkb, Window window);
96
97 #endif
98