From abc3ef82f55602aed73834880141723f745ad2d2 Mon Sep 17 00:00:00 2001 From: TheJackiMonster Date: Sun, 13 Feb 2022 21:09:40 +0100 Subject: Implemented creation of new accounts with automatic selection Signed-off-by: TheJackiMonster --- resources/ui/new_profile.ui | 1 + src/event.c | 2 +- src/ui/new_profile.c | 22 +++++++++++++++++++--- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/resources/ui/new_profile.ui b/resources/ui/new_profile.ui index e7c7c06..3cc568a 100644 --- a/resources/ui/new_profile.ui +++ b/resources/ui/new_profile.ui @@ -53,6 +53,7 @@ Author: Tobias Frisch Confirm + True True True diff --git a/src/event.c b/src/event.c index 5409d7b..24b7771 100644 --- a/src/event.c +++ b/src/event.c @@ -115,7 +115,7 @@ _iterate_accounts(void *cls, if ((account == GNUNET_CHAT_get_connected(handle)) || ((app->chat.identity) && (0 == g_strcmp0(app->chat.identity, name)))) - gtk_list_box_select_row(ui->accounts_listbox, row); + gtk_widget_activate(GTK_WIDGET(row)); ui_profile_entry_delete(profile); return GNUNET_YES; diff --git a/src/ui/new_profile.c b/src/ui/new_profile.c index d1d0274..cc615f5 100644 --- a/src/ui/new_profile.c +++ b/src/ui/new_profile.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2021 GNUnet e.V. + Copyright (C) 2021--2022 GNUnet e.V. GNUnet is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published @@ -26,6 +26,22 @@ #include "../application.h" +static void +_open_new_profile(GtkEntry *entry, MESSENGER_Application *app) +{ + const gchar *name = gtk_entry_get_text(entry); + + if (GNUNET_OK != GNUNET_CHAT_account_create(app->chat.messenger.handle, name)) + return; + + gtk_list_box_unselect_all(app->ui.messenger.accounts_listbox); + + if (app->chat.identity) + GNUNET_free(app->chat.identity); + + app->chat.identity = GNUNET_strdup(name); +} + static void handle_profile_entry_changed(GtkEditable *editable, gpointer user_data) @@ -42,7 +58,7 @@ handle_profile_entry_activate(UNUSED GtkEntry *entry, { MESSENGER_Application *app = (MESSENGER_Application*) user_data; - // TODO: create new profile and switch to it + _open_new_profile(app->ui.new_profile.profile_entry, app); gtk_window_close(GTK_WINDOW(app->ui.new_profile.dialog)); } @@ -61,7 +77,7 @@ handle_confirm_button_click(UNUSED GtkButton *button, { MESSENGER_Application *app = (MESSENGER_Application*) user_data; - // TODO: create new profile and switch to it + _open_new_profile(app->ui.new_profile.profile_entry, app); gtk_window_close(GTK_WINDOW(app->ui.new_profile.dialog)); } -- cgit v1.2.3