commit 157b21157fa1e4536073054b910a742b5a1579d0
parent 501d6bd381c9ce6e545a6468ab5f04fe26ed2b50
Author: Jacki <jacki@thejackimonster.de>
Date: Fri, 27 Sep 2024 20:52:34 +0200
Fix issue of identity selection via command line parameter
Signed-off-by: Jacki <jacki@thejackimonster.de>
Diffstat:
1 file changed, 28 insertions(+), 24 deletions(-)
diff --git a/src/application.c b/src/application.c
@@ -60,38 +60,34 @@ _load_ui_stylesheets(MESSENGER_Application *app)
}
static gboolean
-_application_accounts(gpointer user_data)
+_application_main_window(gpointer user_data)
{
g_assert(user_data);
MESSENGER_Application *app = (MESSENGER_Application*) user_data;
app->init = 0;
- app->ui.state = MESSENGER_STATE_ACCOUNTS;
-
- ui_accounts_dialog_init(app, &(app->ui.accounts));
- ui_accounts_dialog_refresh(app, &(app->ui.accounts));
+ app->ui.state = MESSENGER_STATE_MAIN_WINDOW;
- gtk_widget_show(GTK_WIDGET(app->ui.accounts.dialog));
+ application_show_window(app);
return FALSE;
}
-static enum GNUNET_GenericReturnValue
-_application_select_account(void *cls,
- struct GNUNET_CHAT_Handle *handle,
- struct GNUNET_CHAT_Account *account)
+static gboolean
+_application_accounts(gpointer user_data)
{
- g_assert((cls) && (account));
+ g_assert(user_data);
- MESSENGER_Application *app = (MESSENGER_Application*) cls;
+ MESSENGER_Application *app = (MESSENGER_Application*) user_data;
- const char *name = GNUNET_CHAT_account_get_name(account);
+ app->init = 0;
+ app->ui.state = MESSENGER_STATE_ACCOUNTS;
- if ((!name) || (0 != g_strcmp0(app->chat.identity, name)))
- return GNUNET_YES;
+ ui_accounts_dialog_init(app, &(app->ui.accounts));
+ ui_accounts_dialog_refresh(app, &(app->ui.accounts));
- GNUNET_CHAT_connect(app->chat.messenger.handle, account);
- return GNUNET_NO;
+ gtk_widget_show(GTK_WIDGET(app->ui.accounts.dialog));
+ return FALSE;
}
static void
@@ -108,20 +104,28 @@ _application_init(MESSENGER_Application *app)
app->parent = xdp_parent_new_gtk(GTK_WINDOW(app->ui.messenger.main_window));
#endif
+ GSourceFunc function = G_SOURCE_FUNC(_application_accounts);
+
if (app->chat.identity)
{
- app->ui.state = MESSENGER_STATE_MAIN_WINDOW;
+ struct GNUNET_CHAT_Account *account;
- GNUNET_CHAT_iterate_accounts(
+ application_chat_lock(app);
+ account = GNUNET_CHAT_find_account(
app->chat.messenger.handle,
- _application_select_account,
- app
+ app->chat.identity
);
- application_show_window(app);
+ if (account)
+ {
+ GNUNET_CHAT_connect(app->chat.messenger.handle, account);
+ function = G_SOURCE_FUNC(_application_main_window);
+ }
+
+ application_chat_unlock(app);
}
- else
- app->init = util_idle_add(G_SOURCE_FUNC(_application_accounts), app);
+
+ app->init = util_idle_add(function, app);
}
static void