From 373713ba5446d759da23fe4dec433516f1527def Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Wed, 17 Jul 2019 17:12:23 +0200 Subject: [PATCH] ServerContextService: Don't destroy widget all the time This avoids icon theme lookups and lots of other stuff down the road. Closes: #60 --- src/server-context-service.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/server-context-service.c b/src/server-context-service.c index f8dd8ae5..c9ed3edf 100644 --- a/src/server-context-service.c +++ b/src/server-context-service.c @@ -55,7 +55,6 @@ struct _ServerContextServiceClass { G_DEFINE_TYPE (ServerContextService, server_context_service, EEKBOARD_TYPE_CONTEXT_SERVICE); -static void update_widget (ServerContextService *context); static void set_geometry (ServerContextService *context); static void @@ -223,16 +222,12 @@ destroy_window (ServerContextService *context) } static void -update_widget (ServerContextService *context) +make_widget (ServerContextService *context) { EekKeyboard *keyboard; EekTheme *theme; - if (context->widget) { - gtk_widget_destroy (context->widget); - context->widget = NULL; - } - + g_return_if_fail (!context->widget); theme = eek_theme_new ("resource:///sm/puri/squeekboard/style.css", NULL, NULL); @@ -257,7 +252,8 @@ server_context_service_real_show_keyboard (EekboardContextService *_context) if (!context->window) make_window (context); - update_widget (context); + if (!context->widget) + make_widget (context); EEKBOARD_CONTEXT_SERVICE_CLASS (server_context_service_parent_class)-> show_keyboard (_context); @@ -270,7 +266,6 @@ server_context_service_real_hide_keyboard (EekboardContextService *_context) ServerContextService *context = SERVER_CONTEXT_SERVICE(_context); gtk_widget_hide (context->window); - g_clear_pointer (&context->widget, gtk_widget_destroy); EEKBOARD_CONTEXT_SERVICE_CLASS (server_context_service_parent_class)-> hide_keyboard (_context);