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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user