context: Moved keymap setting together with its generation
This commit is contained in:
		@ -139,14 +139,8 @@ eekboard_context_service_set_property (GObject      *object,
 | 
				
			|||||||
                                       const GValue *value,
 | 
					                                       const GValue *value,
 | 
				
			||||||
                                       GParamSpec   *pspec)
 | 
					                                       GParamSpec   *pspec)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    EekboardContextService *context = EEKBOARD_CONTEXT_SERVICE(object);
 | 
					    (void)value;
 | 
				
			||||||
 | 
					 | 
				
			||||||
    switch (prop_id) {
 | 
					    switch (prop_id) {
 | 
				
			||||||
    case PROP_KEYBOARD:
 | 
					 | 
				
			||||||
        if (context->priv->keyboard)
 | 
					 | 
				
			||||||
            g_object_unref (context->priv->keyboard);
 | 
					 | 
				
			||||||
        context->priv->keyboard = g_value_get_object (value);
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
    default:
 | 
					    default:
 | 
				
			||||||
        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 | 
					        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
@ -231,6 +225,11 @@ eekboard_context_service_update_layout(EekboardContextService *context, enum squ
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    g_object_notify (G_OBJECT(context), "keyboard");
 | 
					    g_object_notify (G_OBJECT(context), "keyboard");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // The keymap will get set even if the window is hidden.
 | 
				
			||||||
 | 
					    // It's not perfect,
 | 
				
			||||||
 | 
					    // but simpler than adding a check in the window showing procedure
 | 
				
			||||||
 | 
					    eekboard_context_service_set_keymap(context, keyboard);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // replacing the keyboard above will cause the previous keyboard to get destroyed from the UI side (eek_gtk_keyboard_dispose)
 | 
					    // replacing the keyboard above will cause the previous keyboard to get destroyed from the UI side (eek_gtk_keyboard_dispose)
 | 
				
			||||||
    if (previous_keyboard) {
 | 
					    if (previous_keyboard) {
 | 
				
			||||||
        level_keyboard_free(previous_keyboard);
 | 
					        level_keyboard_free(previous_keyboard);
 | 
				
			||||||
@ -338,7 +337,7 @@ eekboard_context_service_class_init (EekboardContextServiceClass *klass)
 | 
				
			|||||||
    pspec = g_param_spec_pointer("keyboard",
 | 
					    pspec = g_param_spec_pointer("keyboard",
 | 
				
			||||||
                                 "Keyboard",
 | 
					                                 "Keyboard",
 | 
				
			||||||
                                 "Keyboard",
 | 
					                                 "Keyboard",
 | 
				
			||||||
                                 G_PARAM_READWRITE);
 | 
					                                 G_PARAM_READABLE);
 | 
				
			||||||
    g_object_class_install_property (gobject_class,
 | 
					    g_object_class_install_property (gobject_class,
 | 
				
			||||||
                                     PROP_KEYBOARD,
 | 
					                                     PROP_KEYBOARD,
 | 
				
			||||||
                                     pspec);
 | 
					                                     pspec);
 | 
				
			||||||
 | 
				
			|||||||
@ -78,17 +78,6 @@ on_notify_keyboard (GObject              *object,
 | 
				
			|||||||
                    GParamSpec           *spec,
 | 
					                    GParamSpec           *spec,
 | 
				
			||||||
                    ServerContextService *context)
 | 
					                    ServerContextService *context)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    const LevelKeyboard *keyboard = eekboard_context_service_get_keyboard (EEKBOARD_CONTEXT_SERVICE(context));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (!keyboard)
 | 
					 | 
				
			||||||
        g_error("Programmer error: keyboard layout was unset!");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // The keymap will get set even if the window is hidden.
 | 
					 | 
				
			||||||
    // It's not perfect,
 | 
					 | 
				
			||||||
    // but simpler than adding a check in the window showing procedure
 | 
					 | 
				
			||||||
    eekboard_context_service_set_keymap(EEKBOARD_CONTEXT_SERVICE(context),
 | 
					 | 
				
			||||||
                                        keyboard);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /* Recreate the keyboard widget to keep in sync with the keymap. */
 | 
					    /* Recreate the keyboard widget to keep in sync with the keymap. */
 | 
				
			||||||
    if (context->window)
 | 
					    if (context->window)
 | 
				
			||||||
        make_widget(context);
 | 
					        make_widget(context);
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user