From 512efe70c6c7feb2998da4abbd810bc89451a3e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Date: Thu, 8 Apr 2021 13:02:41 +0100 Subject: [PATCH] src: initialize actions during instance init MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently the GActionMap is registered during the application startup. This takes place after the command line args are processed, so prevents the CLI processing from using actions. Signed-off-by: Daniel P. Berrangé --- src/virt-viewer-app.c | 74 +++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c index cc9b555..44204f3 100644 --- a/src/virt-viewer-app.c +++ b/src/virt-viewer-app.c @@ -2144,38 +2144,6 @@ title_maybe_changed(VirtViewerApp *self, GParamSpec* pspec G_GNUC_UNUSED, gpoint virt_viewer_app_set_all_window_subtitles(self); } -static void -virt_viewer_app_init(VirtViewerApp *self) -{ - VirtViewerAppPrivate *priv = virt_viewer_app_get_instance_private(self); - GError *error = NULL; - priv = virt_viewer_app_get_instance_private(self); - - gtk_window_set_default_icon_name("virt-viewer"); - -#ifndef G_OS_WIN32 - g_unix_signal_add (SIGINT, sigint_cb, self); -#endif - - priv->displays = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_object_unref); - priv->config = g_key_file_new(); - priv->config_file = g_build_filename(g_get_user_config_dir(), - "virt-viewer", "settings", NULL); - g_key_file_load_from_file(priv->config, priv->config_file, - G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS, &error); - - if (g_error_matches(error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) - g_debug("No configuration file %s", priv->config_file); - else if (error) - g_warning("Couldn't load configuration: %s", error->message); - - g_clear_error(&error); - - g_signal_connect(self, "notify::guest-name", G_CALLBACK(title_maybe_changed), NULL); - g_signal_connect(self, "notify::title", G_CALLBACK(title_maybe_changed), NULL); - g_signal_connect(self, "notify::guri", G_CALLBACK(title_maybe_changed), NULL); -} - static void virt_viewer_update_smartcard_accels(VirtViewerApp *self) { @@ -2439,11 +2407,6 @@ virt_viewer_app_on_application_startup(GApplication *app) G_APPLICATION_CLASS(virt_viewer_app_parent_class)->startup(app); - g_action_map_add_action_entries(G_ACTION_MAP(self), - actions, - G_N_ELEMENTS(actions), - self); - #ifndef G_OS_WIN32 gtk_settings = gtk_settings_get_default(); g_object_set(G_OBJECT(gtk_settings), @@ -2712,6 +2675,43 @@ virt_viewer_app_class_init (VirtViewerAppClass *klass) G_PARAM_STATIC_STRINGS)); } +static void +virt_viewer_app_init(VirtViewerApp *self) +{ + VirtViewerAppPrivate *priv = virt_viewer_app_get_instance_private(self); + GError *error = NULL; + priv = virt_viewer_app_get_instance_private(self); + + gtk_window_set_default_icon_name("virt-viewer"); + +#ifndef G_OS_WIN32 + g_unix_signal_add (SIGINT, sigint_cb, self); +#endif + + priv->displays = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_object_unref); + priv->config = g_key_file_new(); + priv->config_file = g_build_filename(g_get_user_config_dir(), + "virt-viewer", "settings", NULL); + g_key_file_load_from_file(priv->config, priv->config_file, + G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS, &error); + + if (g_error_matches(error, G_FILE_ERROR, G_FILE_ERROR_NOENT)) + g_debug("No configuration file %s", priv->config_file); + else if (error) + g_warning("Couldn't load configuration: %s", error->message); + + g_clear_error(&error); + + g_signal_connect(self, "notify::guest-name", G_CALLBACK(title_maybe_changed), NULL); + g_signal_connect(self, "notify::title", G_CALLBACK(title_maybe_changed), NULL); + g_signal_connect(self, "notify::guri", G_CALLBACK(title_maybe_changed), NULL); + + g_action_map_add_action_entries(G_ACTION_MAP(self), + actions, + G_N_ELEMENTS(actions), + self); +} + void virt_viewer_app_set_direct(VirtViewerApp *self, gboolean direct) {