Remove useless get_group method and group_changed signal of EekLayout.
This commit is contained in:
@ -33,56 +33,11 @@
|
||||
#include "eek-layout.h"
|
||||
#include "eek-keyboard.h"
|
||||
|
||||
enum {
|
||||
GROUP_CHANGED,
|
||||
CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
static guint signals[LAST_SIGNAL] = { 0, };
|
||||
|
||||
G_DEFINE_TYPE (EekLayout, eek_layout, G_TYPE_OBJECT);
|
||||
|
||||
static void
|
||||
eek_layout_class_init (EekLayoutClass *klass)
|
||||
{
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
/**
|
||||
* EekLayout::group-changed:
|
||||
* @layout: an #EekLayout that received the signal
|
||||
* @group: group index
|
||||
*
|
||||
* The ::group-changed signal is emitted each time group
|
||||
* configuration of @layout changed.
|
||||
*/
|
||||
signals[GROUP_CHANGED] =
|
||||
g_signal_new ("group-changed",
|
||||
G_TYPE_FROM_CLASS(gobject_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET(EekLayoutClass, group_changed),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__INT,
|
||||
G_TYPE_NONE, 1,
|
||||
G_TYPE_INT);
|
||||
|
||||
/**
|
||||
* EekLayout::changed:
|
||||
* @layout: an #EekLayout that received the signal
|
||||
*
|
||||
* The ::changed signal is emitted each time @layout changed
|
||||
* and re-layout of #EekKeyboard is needed.
|
||||
*/
|
||||
signals[CHANGED] =
|
||||
g_signal_new ("changed",
|
||||
G_TYPE_FROM_CLASS(gobject_class),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET(EekLayoutClass, changed),
|
||||
NULL,
|
||||
NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
void
|
||||
@ -110,20 +65,3 @@ eek_keyboard_new (EekLayout *layout,
|
||||
initial_width,
|
||||
initial_height);
|
||||
}
|
||||
|
||||
/**
|
||||
* eek_layout_get_group:
|
||||
* @layout: an #EekLayout
|
||||
*
|
||||
* Get the group index from the @layout. This function normally
|
||||
* called after #EekLayout::group-changed signal to change group index
|
||||
* of all the keys in #EekKeyboard at a time.
|
||||
*/
|
||||
gint
|
||||
eek_layout_get_group (EekLayout *layout)
|
||||
{
|
||||
g_assert (EEK_IS_LAYOUT(layout));
|
||||
g_assert (EEK_LAYOUT_GET_CLASS(layout)->get_group);
|
||||
|
||||
return EEK_LAYOUT_GET_CLASS(layout)->get_group (layout);
|
||||
}
|
||||
|
||||
@ -45,10 +45,6 @@ struct _EekLayout
|
||||
/**
|
||||
* EekLayoutClass:
|
||||
* @create_keyboard: virtual function for creating a keyboard
|
||||
* @get_group: virtual function for getting the current group setting
|
||||
* of the layout
|
||||
* @group_changed: class handler for #EekLayout::group-changed signal
|
||||
* @changed: class handler for #EekLayout::changed signal
|
||||
*/
|
||||
struct _EekLayoutClass
|
||||
{
|
||||
@ -59,12 +55,6 @@ struct _EekLayoutClass
|
||||
EekKeyboard* (* create_keyboard) (EekLayout *self,
|
||||
gdouble initial_width,
|
||||
gdouble initial_height);
|
||||
gint (* get_group) (EekLayout *self);
|
||||
|
||||
/* signals */
|
||||
void (* group_changed) (EekLayout *self,
|
||||
gint group);
|
||||
void (* changed) (EekLayout *self);
|
||||
|
||||
/*< private >*/
|
||||
/* padding */
|
||||
@ -75,7 +65,6 @@ GType eek_layout_get_type (void) G_GNUC_CONST;
|
||||
EekKeyboard *eek_layout_new (EekLayout *layout,
|
||||
gdouble initial_width,
|
||||
gdouble initial_height);
|
||||
gint eek_layout_get_group (EekLayout *layout);
|
||||
|
||||
G_END_DECLS
|
||||
#endif /* EEK_LAYOUT_H */
|
||||
|
||||
@ -336,19 +336,6 @@ eek_xkb_layout_real_create_keyboard (EekLayout *self,
|
||||
return keyboard;
|
||||
}
|
||||
|
||||
static gint
|
||||
compare_component_name (gchar *name0, gchar *name1)
|
||||
{
|
||||
if (name0 && name1)
|
||||
return g_strcmp0 (name0, name1);
|
||||
else if (!name0 && name1)
|
||||
return -1;
|
||||
else if (name0 && !name1)
|
||||
return 1;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
eek_xkb_layout_finalize (GObject *object)
|
||||
{
|
||||
@ -423,17 +410,6 @@ eek_xkb_layout_get_property (GObject *object,
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
eek_xkb_layout_real_get_group (EekLayout *self)
|
||||
{
|
||||
EekXkbLayoutPrivate *priv = EEK_XKB_LAYOUT_GET_PRIVATE (self);
|
||||
XkbStateRec state;
|
||||
|
||||
g_return_val_if_fail (XkbGetState (priv->display, XkbUseCoreKbd, &state),
|
||||
-1);
|
||||
return state.group;
|
||||
}
|
||||
|
||||
static void
|
||||
eek_xkb_layout_class_init (EekXkbLayoutClass *klass)
|
||||
{
|
||||
@ -444,7 +420,6 @@ eek_xkb_layout_class_init (EekXkbLayoutClass *klass)
|
||||
g_type_class_add_private (gobject_class, sizeof (EekXkbLayoutPrivate));
|
||||
|
||||
layout_class->create_keyboard = eek_xkb_layout_real_create_keyboard;
|
||||
layout_class->get_group = eek_xkb_layout_real_get_group;
|
||||
|
||||
gobject_class->finalize = eek_xkb_layout_finalize;
|
||||
gobject_class->set_property = eek_xkb_layout_set_property;
|
||||
@ -578,42 +553,38 @@ eek_xkb_layout_new (void)
|
||||
* @names: XKB component names
|
||||
*
|
||||
* Set the XKB component names to @layout.
|
||||
* Returns: %TRUE if the component name is successfully set, %FALSE otherwise
|
||||
* Returns: %TRUE if any of the component names changed, %FALSE otherwise
|
||||
*/
|
||||
gboolean
|
||||
eek_xkb_layout_set_names (EekXkbLayout *layout, XkbComponentNamesRec *names)
|
||||
{
|
||||
EekXkbLayoutPrivate *priv = EEK_XKB_LAYOUT_GET_PRIVATE (layout);
|
||||
gboolean is_changed;
|
||||
gboolean retval;
|
||||
|
||||
g_return_val_if_fail (priv, FALSE);
|
||||
|
||||
/* keycodes */
|
||||
if (compare_component_name (names->keycodes, priv->names.keycodes) != 0)
|
||||
is_changed = TRUE;
|
||||
g_free (priv->names.keycodes);
|
||||
priv->names.keycodes = g_strdup (names->keycodes);
|
||||
if (g_strcmp0 (names->keycodes, priv->names.keycodes)) {
|
||||
g_free (priv->names.keycodes);
|
||||
priv->names.keycodes = g_strdup (names->keycodes);
|
||||
retval = TRUE;
|
||||
}
|
||||
|
||||
/* geometry */
|
||||
if (compare_component_name (names->geometry, priv->names.geometry) != 0)
|
||||
is_changed = TRUE;
|
||||
g_free (priv->names.geometry);
|
||||
priv->names.geometry = g_strdup (names->geometry);
|
||||
if (g_strcmp0 (names->geometry, priv->names.geometry)) {
|
||||
g_free (priv->names.geometry);
|
||||
priv->names.geometry = g_strdup (names->geometry);
|
||||
retval = TRUE;
|
||||
}
|
||||
|
||||
/* symbols */
|
||||
if (compare_component_name (names->symbols, priv->names.symbols) != 0)
|
||||
is_changed = TRUE;
|
||||
g_free (priv->names.symbols);
|
||||
priv->names.symbols = g_strdup (names->symbols);
|
||||
if (g_strcmp0 (names->symbols, priv->names.symbols)) {
|
||||
g_free (priv->names.symbols);
|
||||
priv->names.symbols = g_strdup (names->symbols);
|
||||
retval = TRUE;
|
||||
}
|
||||
|
||||
get_keyboard (layout);
|
||||
if (!priv->xkb)
|
||||
return FALSE;
|
||||
g_assert (priv->xkb);
|
||||
|
||||
if (is_changed)
|
||||
g_signal_emit_by_name (layout, "changed");
|
||||
|
||||
return TRUE;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -74,17 +74,6 @@ extern void xkl_xkb_config_native_cleanup (XklEngine * engine,
|
||||
static gboolean set_xkb_component_names (EekXklLayout *layout,
|
||||
XklConfigRec *config);
|
||||
|
||||
static gint
|
||||
eek_xkl_layout_real_get_group (EekLayout *self)
|
||||
{
|
||||
EekXklLayoutPrivate *priv = EEK_XKL_LAYOUT_GET_PRIVATE (self);
|
||||
XklState *state;
|
||||
|
||||
state = xkl_engine_get_current_state (priv->engine);
|
||||
g_return_val_if_fail (state, -1);
|
||||
return state->group;
|
||||
}
|
||||
|
||||
static void
|
||||
eek_xkl_layout_dispose (GObject *object)
|
||||
{
|
||||
@ -174,14 +163,11 @@ eek_xkl_layout_get_property (GObject *object,
|
||||
static void
|
||||
eek_xkl_layout_class_init (EekXklLayoutClass *klass)
|
||||
{
|
||||
EekLayoutClass *layout_class = EEK_LAYOUT_CLASS (klass);
|
||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||
GParamSpec *pspec;
|
||||
|
||||
g_type_class_add_private (gobject_class, sizeof (EekXklLayoutPrivate));
|
||||
|
||||
layout_class->get_group = eek_xkl_layout_real_get_group;
|
||||
|
||||
gobject_class->dispose = eek_xkl_layout_dispose;
|
||||
gobject_class->set_property = eek_xkl_layout_set_property;
|
||||
gobject_class->get_property = eek_xkl_layout_get_property;
|
||||
@ -290,7 +276,7 @@ merge_xkl_config_rec (XklConfigRec *dst, XklConfigRec *src)
|
||||
* @config: Libxklavier configuration
|
||||
*
|
||||
* Reconfigure @layout with @config.
|
||||
* Returns: %TRUE if the component name is successfully set, %FALSE otherwise
|
||||
* Returns: %TRUE if the current layout changed, %FALSE otherwise
|
||||
*/
|
||||
gboolean
|
||||
eek_xkl_layout_set_config (EekXklLayout *layout,
|
||||
@ -298,18 +284,16 @@ eek_xkl_layout_set_config (EekXklLayout *layout,
|
||||
{
|
||||
EekXklLayoutPrivate *priv = EEK_XKL_LAYOUT_GET_PRIVATE (layout);
|
||||
XklConfigRec *c;
|
||||
gboolean retval;
|
||||
|
||||
g_return_val_if_fail (priv, FALSE);
|
||||
c = xkl_config_rec_new ();
|
||||
merge_xkl_config_rec (c, priv->config);
|
||||
merge_xkl_config_rec (c, config);
|
||||
if (set_xkb_component_names (layout, c)) {
|
||||
g_object_unref (c);
|
||||
merge_xkl_config_rec (priv->config, config);
|
||||
return TRUE;
|
||||
}
|
||||
retval = set_xkb_component_names (layout, c);
|
||||
g_object_unref (c);
|
||||
return FALSE;
|
||||
merge_xkl_config_rec (priv->config, config);
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -326,7 +310,7 @@ eek_xkl_layout_set_config (EekXklLayout *layout,
|
||||
* XklConfigRec, which is not currently available in the
|
||||
* gobject-introspection repository.
|
||||
*
|
||||
* Returns: %TRUE if the component name is successfully set, %FALSE otherwise
|
||||
* Returns: %TRUE if the current layout changed, %FALSE otherwise
|
||||
* Since: 0.0.2
|
||||
*/
|
||||
gboolean
|
||||
@ -337,16 +321,16 @@ eek_xkl_layout_set_config_full (EekXklLayout *layout,
|
||||
gchar **options)
|
||||
{
|
||||
XklConfigRec *config;
|
||||
gboolean success;
|
||||
gboolean retval;
|
||||
|
||||
config = xkl_config_rec_new ();
|
||||
config->model = g_strdup (model);
|
||||
config->layouts = g_strdupv (layouts);
|
||||
config->variants = g_strdupv (variants);
|
||||
config->options = g_strdupv (options);
|
||||
success = eek_xkl_layout_set_config (layout, config);
|
||||
retval = eek_xkl_layout_set_config (layout, config);
|
||||
g_object_unref (config);
|
||||
return success;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -355,7 +339,7 @@ eek_xkl_layout_set_config_full (EekXklLayout *layout,
|
||||
* @model: model name
|
||||
*
|
||||
* Set the model name of @layout configuration (in the Libxklavier terminology).
|
||||
* Returns: %TRUE if the component name is successfully set, %FALSE otherwise
|
||||
* Returns: %TRUE if the current layout changed, %FALSE otherwise
|
||||
*/
|
||||
gboolean
|
||||
eek_xkl_layout_set_model (EekXklLayout *layout,
|
||||
@ -363,7 +347,7 @@ eek_xkl_layout_set_model (EekXklLayout *layout,
|
||||
{
|
||||
EekXklLayoutPrivate *priv = EEK_XKL_LAYOUT_GET_PRIVATE (layout);
|
||||
XklConfigRec *config;
|
||||
gboolean success;
|
||||
gboolean retval;
|
||||
|
||||
g_return_val_if_fail (priv, FALSE);
|
||||
config = xkl_config_rec_new ();
|
||||
@ -372,9 +356,9 @@ eek_xkl_layout_set_model (EekXklLayout *layout,
|
||||
config->model = g_strdup (model);
|
||||
else
|
||||
config->model = NULL;
|
||||
success = eek_xkl_layout_set_config (layout, config);
|
||||
retval = eek_xkl_layout_set_config (layout, config);
|
||||
g_object_unref (config);
|
||||
return success;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -383,7 +367,7 @@ eek_xkl_layout_set_model (EekXklLayout *layout,
|
||||
* @layouts: layout names
|
||||
*
|
||||
* Set the layout names of @layout (in the Libxklavier terminology).
|
||||
* Returns: %TRUE if the component name is successfully set, %FALSE otherwise
|
||||
* Returns: %TRUE if the current layout changed, %FALSE otherwise
|
||||
*/
|
||||
gboolean
|
||||
eek_xkl_layout_set_layouts (EekXklLayout *layout,
|
||||
@ -391,7 +375,7 @@ eek_xkl_layout_set_layouts (EekXklLayout *layout,
|
||||
{
|
||||
EekXklLayoutPrivate *priv = EEK_XKL_LAYOUT_GET_PRIVATE (layout);
|
||||
XklConfigRec *config;
|
||||
gboolean success;
|
||||
gboolean retval;
|
||||
|
||||
g_return_val_if_fail (priv, FALSE);
|
||||
config = xkl_config_rec_new ();
|
||||
@ -400,9 +384,9 @@ eek_xkl_layout_set_layouts (EekXklLayout *layout,
|
||||
config->layouts = g_strdupv (layouts);
|
||||
else
|
||||
config->layouts = layouts;
|
||||
success = eek_xkl_layout_set_config (layout, config);
|
||||
retval = eek_xkl_layout_set_config (layout, config);
|
||||
g_object_unref (config);
|
||||
return success;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -411,7 +395,7 @@ eek_xkl_layout_set_layouts (EekXklLayout *layout,
|
||||
* @variants: variant names
|
||||
*
|
||||
* Set the variant names of @layout (in the Libxklavier terminology).
|
||||
* Returns: %TRUE if the component name is successfully set, %FALSE otherwise
|
||||
* Returns: %TRUE if the current layout changed, %FALSE otherwise
|
||||
*/
|
||||
gboolean
|
||||
eek_xkl_layout_set_variants (EekXklLayout *layout,
|
||||
@ -419,7 +403,7 @@ eek_xkl_layout_set_variants (EekXklLayout *layout,
|
||||
{
|
||||
EekXklLayoutPrivate *priv = EEK_XKL_LAYOUT_GET_PRIVATE (layout);
|
||||
XklConfigRec *config;
|
||||
gboolean success;
|
||||
gboolean retval;
|
||||
|
||||
g_return_val_if_fail (priv, FALSE);
|
||||
config = xkl_config_rec_new ();
|
||||
@ -428,9 +412,9 @@ eek_xkl_layout_set_variants (EekXklLayout *layout,
|
||||
config->variants = g_strdupv (variants);
|
||||
else
|
||||
config->variants = NULL;
|
||||
success = eek_xkl_layout_set_config (layout, config);
|
||||
retval = eek_xkl_layout_set_config (layout, config);
|
||||
g_object_unref (config);
|
||||
return success;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -439,7 +423,7 @@ eek_xkl_layout_set_variants (EekXklLayout *layout,
|
||||
* @options: option names
|
||||
*
|
||||
* Set the option names of @layout (in the Libxklavier terminology).
|
||||
* Returns: %TRUE if the component name is successfully set, %FALSE otherwise
|
||||
* Returns: %TRUE if the current layout changed, %FALSE otherwise
|
||||
*/
|
||||
gboolean
|
||||
eek_xkl_layout_set_options (EekXklLayout *layout,
|
||||
@ -447,7 +431,7 @@ eek_xkl_layout_set_options (EekXklLayout *layout,
|
||||
{
|
||||
EekXklLayoutPrivate *priv = EEK_XKL_LAYOUT_GET_PRIVATE (layout);
|
||||
XklConfigRec *config;
|
||||
gboolean success;
|
||||
gboolean retval;
|
||||
|
||||
g_return_val_if_fail (priv, FALSE);
|
||||
config = xkl_config_rec_new ();
|
||||
@ -456,9 +440,9 @@ eek_xkl_layout_set_options (EekXklLayout *layout,
|
||||
config->options = options;
|
||||
else
|
||||
config->options = NULL;
|
||||
success = eek_xkl_layout_set_config (layout, config);
|
||||
retval = eek_xkl_layout_set_config (layout, config);
|
||||
g_object_unref (config);
|
||||
return success;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -467,7 +451,7 @@ eek_xkl_layout_set_options (EekXklLayout *layout,
|
||||
* @option: option name
|
||||
*
|
||||
* Set the option of @layout (in the Libxklavier terminology).
|
||||
* Returns: %TRUE if the option is successfully set, %FALSE otherwise
|
||||
* Returns: %TRUE if the current layout changed, %FALSE otherwise
|
||||
*/
|
||||
gboolean
|
||||
eek_xkl_layout_enable_option (EekXklLayout *layout,
|
||||
@ -494,7 +478,7 @@ eek_xkl_layout_enable_option (EekXklLayout *layout,
|
||||
* @option: option name
|
||||
*
|
||||
* Unset the option of @layout (in the Libxklavier terminology).
|
||||
* Returns: %TRUE if the option is successfully unset, %FALSE otherwise
|
||||
* Returns: %TRUE if the current layout changed, %FALSE otherwise
|
||||
*/
|
||||
gboolean
|
||||
eek_xkl_layout_disable_option (EekXklLayout *layout,
|
||||
@ -588,7 +572,7 @@ set_xkb_component_names (EekXklLayout *layout, XklConfigRec *config)
|
||||
{
|
||||
EekXklLayoutPrivate *priv = layout->priv;
|
||||
XkbComponentNamesRec names;
|
||||
gboolean success = FALSE;
|
||||
gboolean retval = FALSE;
|
||||
|
||||
#if DEBUG
|
||||
if (config->layouts) {
|
||||
@ -620,16 +604,11 @@ set_xkb_component_names (EekXklLayout *layout, XklConfigRec *config)
|
||||
fprintf (stderr, "options = NULL\n");
|
||||
#endif
|
||||
|
||||
/* Disabled since the current EekXklLayout implementation does not
|
||||
change the server setting. */
|
||||
#if 0
|
||||
xkl_config_rec_activate (priv->engine, config);
|
||||
#endif
|
||||
if (xkl_xkb_config_native_prepare (priv->engine, config, &names)) {
|
||||
success = eek_xkb_layout_set_names (EEK_XKB_LAYOUT(layout), &names);
|
||||
retval = eek_xkb_layout_set_names (EEK_XKB_LAYOUT(layout), &names);
|
||||
xkl_xkb_config_native_cleanup (priv->engine, &names);
|
||||
}
|
||||
return success;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
170
src/eekboard.c
170
src/eekboard.c
@ -79,7 +79,6 @@ struct _Eekboard {
|
||||
GConfClient *gconfc;
|
||||
Accessible *acc;
|
||||
GtkWidget *widget, *window, *combo;
|
||||
gint width, height;
|
||||
XklEngine *engine;
|
||||
XklConfigRegistry *registry;
|
||||
GtkUIManager *ui_manager;
|
||||
@ -103,7 +102,6 @@ struct _Eekboard {
|
||||
GtkActionGroup *options_action_group;
|
||||
|
||||
EekKeyboard *keyboard;
|
||||
EekLayout *layout; /* FIXME: eek_keyboard_get_layout() */
|
||||
};
|
||||
typedef struct _Eekboard Eekboard;
|
||||
|
||||
@ -126,24 +124,23 @@ struct _LayoutVariant {
|
||||
};
|
||||
typedef struct _LayoutVariant LayoutVariant;
|
||||
|
||||
static void on_countries_menu (GtkAction *action,
|
||||
GtkWidget *widget);
|
||||
static void on_languages_menu (GtkAction *action,
|
||||
GtkWidget *widget);
|
||||
static void on_models_menu (GtkAction *action,
|
||||
GtkWidget *window);
|
||||
static void on_layouts_menu (GtkAction *action,
|
||||
GtkWidget *window);
|
||||
static void on_options_menu (GtkAction *action,
|
||||
GtkWidget *window);
|
||||
static void on_about (GtkAction *action,
|
||||
GtkWidget *window);
|
||||
static void on_quit_from_menu (GtkAction * action,
|
||||
GtkWidget *window);
|
||||
static void eekboard_free (Eekboard *eekboard);
|
||||
static GtkWidget *create_widget (Eekboard *eekboard,
|
||||
gint initial_width,
|
||||
gint initial_height);
|
||||
static void on_countries_menu (GtkAction *action,
|
||||
GtkWidget *widget);
|
||||
static void on_languages_menu (GtkAction *action,
|
||||
GtkWidget *widget);
|
||||
static void on_models_menu (GtkAction *action,
|
||||
GtkWidget *window);
|
||||
static void on_layouts_menu (GtkAction *action,
|
||||
GtkWidget *window);
|
||||
static void on_options_menu (GtkAction *action,
|
||||
GtkWidget *window);
|
||||
static void on_about (GtkAction *action,
|
||||
GtkWidget *window);
|
||||
static void on_quit_from_menu (GtkAction * action,
|
||||
GtkWidget *window);
|
||||
static void eekboard_free (Eekboard *eekboard);
|
||||
static void create_widget (Eekboard *eekboard);
|
||||
static void update_widget (Eekboard *eekboard);
|
||||
|
||||
static const char ui_description[] =
|
||||
"<ui>"
|
||||
@ -458,11 +455,12 @@ on_key_released (EekKeyboard *keyboard,
|
||||
|
||||
static void
|
||||
on_config_activate (GtkAction *action,
|
||||
gpointer user_data)
|
||||
gpointer user_data)
|
||||
{
|
||||
SetConfigCallbackData *data = user_data;
|
||||
eek_xkl_layout_set_config (EEK_XKL_LAYOUT(data->eekboard->layout),
|
||||
data->config);
|
||||
EekLayout *layout = eek_keyboard_get_layout (data->eekboard->keyboard);
|
||||
if (eek_xkl_layout_set_config (EEK_XKL_LAYOUT(layout), data->config))
|
||||
update_widget (data->eekboard);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -470,29 +468,41 @@ on_option_toggled (GtkToggleAction *action,
|
||||
gpointer user_data)
|
||||
{
|
||||
SetConfigCallbackData *data = user_data;
|
||||
if (gtk_toggle_action_get_active (action))
|
||||
eek_xkl_layout_enable_option (EEK_XKL_LAYOUT(data->eekboard->layout),
|
||||
data->config->options[0]);
|
||||
else
|
||||
eek_xkl_layout_disable_option (EEK_XKL_LAYOUT(data->eekboard->layout),
|
||||
data->config->options[0]);
|
||||
EekLayout *layout = eek_keyboard_get_layout (data->eekboard->keyboard);
|
||||
|
||||
if (gtk_toggle_action_get_active (action)) {
|
||||
if (eek_xkl_layout_enable_option (EEK_XKL_LAYOUT(layout),
|
||||
data->config->options[0]))
|
||||
update_widget (data->eekboard);
|
||||
} else {
|
||||
if (eek_xkl_layout_disable_option (EEK_XKL_LAYOUT(layout),
|
||||
data->config->options[0]))
|
||||
update_widget (data->eekboard);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
on_changed (EekLayout *layout, gpointer user_data)
|
||||
update_widget (Eekboard *eekboard)
|
||||
{
|
||||
Eekboard *eekboard = user_data;
|
||||
GtkWidget *vbox, *widget;
|
||||
GtkWidget *vbox;
|
||||
GtkAllocation allocation;
|
||||
EekLayout *layout;
|
||||
EekKeyboard *keyboard;
|
||||
|
||||
gtk_widget_get_allocation (GTK_WIDGET (eekboard->widget), &allocation);
|
||||
vbox = gtk_widget_get_parent (eekboard->widget);
|
||||
/* gtk_widget_destroy() seems not usable for GtkClutterEmbed */
|
||||
gtk_container_remove (GTK_CONTAINER(vbox), eekboard->widget);
|
||||
|
||||
layout = eek_keyboard_get_layout (eekboard->keyboard);
|
||||
keyboard = eek_keyboard_new (layout, allocation.width, allocation.height);
|
||||
eek_keyboard_set_modifier_behavior (keyboard,
|
||||
EEK_MODIFIER_BEHAVIOR_LATCH);
|
||||
g_object_unref (eekboard->keyboard);
|
||||
widget = create_widget (eekboard, allocation.width, allocation.height);
|
||||
gtk_container_add (GTK_CONTAINER(vbox), widget);
|
||||
eekboard->keyboard = keyboard;
|
||||
|
||||
create_widget (eekboard);
|
||||
gtk_container_add (GTK_CONTAINER(vbox), eekboard->widget);
|
||||
gtk_widget_show_all (vbox);
|
||||
}
|
||||
|
||||
@ -1027,26 +1037,8 @@ on_allocation_changed (ClutterActor *stage,
|
||||
}
|
||||
#endif
|
||||
|
||||
static EekKeyboard *
|
||||
create_keyboard (Eekboard *eekboard,
|
||||
gint initial_width,
|
||||
gint initial_height)
|
||||
{
|
||||
EekKeyboard *keyboard;
|
||||
|
||||
keyboard = eek_keyboard_new (eekboard->layout,
|
||||
initial_width,
|
||||
initial_height);
|
||||
eek_keyboard_set_modifier_behavior (keyboard,
|
||||
EEK_MODIFIER_BEHAVIOR_LATCH);
|
||||
|
||||
return keyboard;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
create_widget (Eekboard *eekboard,
|
||||
gint initial_width,
|
||||
gint initial_height)
|
||||
static void
|
||||
create_widget (Eekboard *eekboard)
|
||||
{
|
||||
#if HAVE_CLUTTER_GTK
|
||||
ClutterActor *stage;
|
||||
@ -1054,9 +1046,6 @@ create_widget (Eekboard *eekboard,
|
||||
#endif
|
||||
EekBounds bounds;
|
||||
|
||||
eekboard->keyboard = create_keyboard (eekboard,
|
||||
initial_width,
|
||||
initial_height);
|
||||
eekboard->on_key_pressed_id =
|
||||
g_signal_connect (eekboard->keyboard, "key-pressed",
|
||||
G_CALLBACK(on_key_pressed), eekboard);
|
||||
@ -1085,9 +1074,7 @@ create_widget (Eekboard *eekboard,
|
||||
eekboard->widget = eek_gtk_keyboard_new (eekboard->keyboard);
|
||||
#endif
|
||||
|
||||
eekboard->width = bounds.width;
|
||||
eekboard->height = bounds.height;
|
||||
return eekboard->widget;
|
||||
gtk_widget_set_size_request (eekboard->widget, bounds.width, bounds.height);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1140,16 +1127,13 @@ on_xkl_state_changed (XklEngine *xklengine,
|
||||
gboolean restore,
|
||||
gpointer user_data)
|
||||
{
|
||||
Eekboard *eekboard = user_data;
|
||||
|
||||
if (type == GROUP_CHANGED)
|
||||
g_signal_emit_by_name (eekboard->layout, "group_changed", value);
|
||||
}
|
||||
|
||||
Eekboard *
|
||||
eekboard_new (gboolean accessibility_enabled)
|
||||
{
|
||||
Eekboard *eekboard;
|
||||
EekLayout *layout;
|
||||
|
||||
eekboard = g_slice_new0 (Eekboard);
|
||||
eekboard->accessibility_enabled = accessibility_enabled;
|
||||
@ -1168,44 +1152,33 @@ eekboard_new (gboolean accessibility_enabled)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
eekboard->layout = eek_xkl_layout_new ();
|
||||
if (!eekboard->layout) {
|
||||
layout = eek_xkl_layout_new ();
|
||||
if (!layout) {
|
||||
g_slice_free (Eekboard, eekboard);
|
||||
g_warning ("Can't create layout");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (opt_model)
|
||||
eek_xkl_layout_set_model (EEK_XKL_LAYOUT(eekboard->layout), opt_model);
|
||||
eek_xkl_layout_set_model (EEK_XKL_LAYOUT(layout), opt_model);
|
||||
if (opt_layouts) {
|
||||
XklConfigRec *rec = xkl_config_rec_new ();
|
||||
|
||||
parse_layouts (rec, opt_layouts);
|
||||
eek_xkl_layout_set_layouts (EEK_XKL_LAYOUT(eekboard->layout),
|
||||
rec->layouts);
|
||||
eek_xkl_layout_set_variants (EEK_XKL_LAYOUT(eekboard->layout),
|
||||
rec->variants);
|
||||
eek_xkl_layout_set_layouts (EEK_XKL_LAYOUT(layout), rec->layouts);
|
||||
eek_xkl_layout_set_variants (EEK_XKL_LAYOUT(layout), rec->variants);
|
||||
g_object_unref (rec);
|
||||
}
|
||||
if (opt_options) {
|
||||
gchar **options;
|
||||
options = g_strsplit (opt_options, ",", -1);
|
||||
eek_xkl_layout_set_options (EEK_XKL_LAYOUT(eekboard->layout), options);
|
||||
eek_xkl_layout_set_options (EEK_XKL_LAYOUT(layout), options);
|
||||
g_strfreev (options);
|
||||
}
|
||||
if (opt_xml) {
|
||||
EekKeyboard *keyboard;
|
||||
GString *output;
|
||||
|
||||
output = g_string_sized_new (BUFSIZ);
|
||||
keyboard = create_keyboard (eekboard, CSW, CSH);
|
||||
eek_keyboard_output (keyboard, output, 0);
|
||||
fwrite (output->str, output->len, 1, stdout);
|
||||
g_string_free (output, TRUE);
|
||||
|
||||
exit (0);
|
||||
}
|
||||
g_signal_connect (eekboard->layout, "changed",
|
||||
G_CALLBACK(on_changed), eekboard);
|
||||
eekboard->keyboard = eek_keyboard_new (layout, CSW, CSH);
|
||||
eek_keyboard_set_modifier_behavior (eekboard->keyboard,
|
||||
EEK_MODIFIER_BEHAVIOR_LATCH);
|
||||
|
||||
eekboard->ui_manager = gtk_ui_manager_new ();
|
||||
eekboard->engine = xkl_engine_get_instance (eekboard->display);
|
||||
@ -1230,12 +1203,8 @@ eekboard_new (gboolean accessibility_enabled)
|
||||
static void
|
||||
eekboard_free (Eekboard *eekboard)
|
||||
{
|
||||
if (eekboard->layout)
|
||||
g_object_unref (eekboard->layout);
|
||||
#if 0
|
||||
if (eekboard->keyboard)
|
||||
g_object_unref (eekboard->keyboard);
|
||||
#endif
|
||||
if (eekboard->registry)
|
||||
g_object_unref (eekboard->registry);
|
||||
if (eekboard->engine)
|
||||
@ -1333,33 +1302,34 @@ on_layout_changed (GtkComboBox *combo,
|
||||
|
||||
if (eekboard->active_config != active) {
|
||||
XklConfigRec *config, *config_base = eekboard->config[active]->rec;
|
||||
EekLayout *layout;
|
||||
|
||||
layout = eek_keyboard_get_layout (eekboard->keyboard);
|
||||
config = xkl_config_rec_new ();
|
||||
if (config_base->model)
|
||||
config->model = g_strdup (config_base->model);
|
||||
else
|
||||
config->model =
|
||||
eek_xkl_layout_get_model (EEK_XKL_LAYOUT(eekboard->layout));
|
||||
config->model = eek_xkl_layout_get_model (EEK_XKL_LAYOUT(layout));
|
||||
|
||||
if (config_base->layouts)
|
||||
config->layouts = g_strdupv (config_base->layouts);
|
||||
else
|
||||
config->layouts =
|
||||
eek_xkl_layout_get_layouts (EEK_XKL_LAYOUT(eekboard->layout));
|
||||
eek_xkl_layout_get_layouts (EEK_XKL_LAYOUT(layout));
|
||||
|
||||
if (config_base->variants)
|
||||
config->variants = g_strdupv (config_base->variants);
|
||||
else
|
||||
config->variants =
|
||||
eek_xkl_layout_get_variants (EEK_XKL_LAYOUT(eekboard->layout));
|
||||
eek_xkl_layout_get_variants (EEK_XKL_LAYOUT(layout));
|
||||
|
||||
if (config_base->options)
|
||||
config->options = g_strdupv (config_base->options);
|
||||
else
|
||||
config->options =
|
||||
eek_xkl_layout_get_options (EEK_XKL_LAYOUT(eekboard->layout));
|
||||
eek_xkl_layout_get_options (EEK_XKL_LAYOUT(layout));
|
||||
|
||||
eek_xkl_layout_set_config (EEK_XKL_LAYOUT(eekboard->layout), config);
|
||||
eek_xkl_layout_set_config (EEK_XKL_LAYOUT(layout), config);
|
||||
g_object_unref (config);
|
||||
|
||||
eekboard->active_config = active;
|
||||
@ -1445,7 +1415,7 @@ main (int argc, char *argv[])
|
||||
{
|
||||
gboolean accessibility_enabled = FALSE;
|
||||
Eekboard *eekboard;
|
||||
GtkWidget *widget, *vbox, *menubar, *window, *combo = NULL;
|
||||
GtkWidget *vbox, *menubar, *window, *combo = NULL;
|
||||
GOptionContext *context;
|
||||
GConfClient *gconfc;
|
||||
GError *error;
|
||||
@ -1585,7 +1555,8 @@ main (int argc, char *argv[])
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
|
||||
g_object_set_data (G_OBJECT(window), "eekboard", eekboard);
|
||||
widget = create_widget (eekboard, CSW, CSH);
|
||||
|
||||
create_widget (eekboard);
|
||||
|
||||
if (!opt_popup) {
|
||||
create_menus (eekboard, window);
|
||||
@ -1618,12 +1589,11 @@ main (int argc, char *argv[])
|
||||
eekboard);
|
||||
}
|
||||
|
||||
gtk_container_add (GTK_CONTAINER(vbox), widget);
|
||||
gtk_container_add (GTK_CONTAINER(vbox), eekboard->widget);
|
||||
gtk_container_add (GTK_CONTAINER(window), vbox);
|
||||
|
||||
gtk_widget_set_size_request (widget, eekboard->width, eekboard->height);
|
||||
gtk_widget_show_all (window);
|
||||
gtk_widget_set_size_request (widget, -1, -1);
|
||||
gtk_widget_set_size_request (eekboard->widget, -1, -1);
|
||||
|
||||
notify_init ("eekboard");
|
||||
eekboard->window = window;
|
||||
|
||||
Reference in New Issue
Block a user