Showing and hiding

This commit is contained in:
Dorota Czaplejewicz
2019-04-05 18:36:25 +00:00
parent b065b16bf1
commit 862cfdb55d
2 changed files with 48 additions and 41 deletions

View File

@ -250,12 +250,12 @@ eekboard_context_service_set_property (GObject *object,
context->priv->keyboard = g_value_get_object (value);
break;
case PROP_VISIBLE:
if (context->priv->keyboard) {
/*if (context->priv->keyboard) {
if (g_value_get_boolean (value))
eekboard_context_service_show_keyboard (context);
else
eekboard_context_service_hide_keyboard (context);
}
}*/
break;
case PROP_FULLSCREEN:
context->priv->fullscreen = g_value_get_boolean (value);

View File

@ -251,8 +251,6 @@ set_geometry (ServerContextService *context)
gtk_window_set_decorated (GTK_WINDOW(context->window), FALSE);
gtk_window_set_resizable (GTK_WINDOW(context->window), FALSE);
gtk_window_set_opacity (GTK_WINDOW(context->window), 0.8);
g_signal_connect_after (context->window, "realize",
G_CALLBACK(on_realize_set_dock),
context);
@ -273,33 +271,11 @@ set_geometry (ServerContextService *context)
}
static void
update_widget (ServerContextService *context)
{
EekKeyboard *keyboard;
const gchar *client_name;
EekBounds bounds;
gchar *theme_path;
EekTheme *theme;
if (context->widget) {
gtk_widget_destroy (context->widget);
context->widget = NULL;
make_window (ServerContextService *context) {
if (context->window) {
g_error("Window already present");
return;
}
theme_path = g_build_filename (THEMESDIR, "default.css", NULL);
theme = eek_theme_new (theme_path, NULL, NULL);
g_free (theme_path);
keyboard = eekboard_context_service_get_keyboard (EEKBOARD_CONTEXT_SERVICE(context));
eek_element_get_bounds (EEK_ELEMENT(keyboard), &bounds);
context->widget = eek_gtk_keyboard_new (keyboard);
eek_gtk_keyboard_set_theme (EEK_GTK_KEYBOARD(context->widget), theme);
g_object_unref (theme);
gtk_widget_set_has_tooltip (context->widget, TRUE);
if (!context->window) {
context->window = GTK_WIDGET(g_object_new (
PHOSH_TYPE_LAYER_SURFACE,
"layer-shell", squeak_wayland->layer_shell,
@ -322,12 +298,44 @@ update_widget (ServerContextService *context)
gtk_widget_set_can_focus (context->window, FALSE);
g_object_set (G_OBJECT(context->window), "accept_focus", FALSE, NULL);
client_name = eekboard_context_service_get_client_name (EEKBOARD_CONTEXT_SERVICE(context));
const gchar *client_name = eekboard_context_service_get_client_name (EEKBOARD_CONTEXT_SERVICE(context));
gtk_window_set_title (GTK_WINDOW(context->window),
client_name ? client_name : _("Keyboard"));
gtk_window_set_icon_name (GTK_WINDOW(context->window), "eekboard");
gtk_window_set_keep_above (GTK_WINDOW(context->window), TRUE);
}
static void
destroy_window (ServerContextService *context) {
context->window = NULL;
}
static void
update_widget (ServerContextService *context)
{
EekKeyboard *keyboard;
EekBounds bounds;
gchar *theme_path;
EekTheme *theme;
if (context->widget) {
gtk_widget_destroy (context->widget);
context->widget = NULL;
}
theme_path = g_build_filename (THEMESDIR, "default.css", NULL);
theme = eek_theme_new (theme_path, NULL, NULL);
g_free (theme_path);
keyboard = eekboard_context_service_get_keyboard (EEKBOARD_CONTEXT_SERVICE(context));
eek_element_get_bounds (EEK_ELEMENT(keyboard), &bounds);
context->widget = eek_gtk_keyboard_new (keyboard);
eek_gtk_keyboard_set_theme (EEK_GTK_KEYBOARD(context->widget), theme);
g_object_unref (theme);
gtk_widget_set_has_tooltip (context->widget, TRUE);
gtk_container_add (GTK_CONTAINER(context->window), context->widget);
set_geometry (context);
}
@ -337,10 +345,8 @@ server_context_service_real_show_keyboard (EekboardContextService *_context)
{
ServerContextService *context = SERVER_CONTEXT_SERVICE(_context);
if (!context->window)
make_window (context);
update_widget (context);
g_assert (context->window);
gtk_widget_show_all (context->window);
EEKBOARD_CONTEXT_SERVICE_CLASS (server_context_service_parent_class)->
show_keyboard (_context);
@ -351,8 +357,9 @@ server_context_service_real_hide_keyboard (EekboardContextService *_context)
{
ServerContextService *context = SERVER_CONTEXT_SERVICE(_context);
if (context->window)
gtk_widget_hide (context->window);
gtk_container_remove(GTK_CONTAINER(context->window), context->widget);
destroy_window (context);
EEKBOARD_CONTEXT_SERVICE_CLASS (server_context_service_parent_class)->
hide_keyboard (_context);