messenger-gtk

Gtk+3 graphical user interfaces for GNUnet Messenger
Log | Files | Refs | Submodules | README | LICENSE

commit abc3ef82f55602aed73834880141723f745ad2d2
parent e06b57b58d500c09986b69180ed539ef8290cda0
Author: TheJackiMonster <thejackimonster@gmail.com>
Date:   Sun, 13 Feb 2022 21:09:40 +0100

Implemented creation of new accounts with automatic selection

Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>

Diffstat:
Mresources/ui/new_profile.ui | 1+
Msrc/event.c | 2+-
Msrc/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 @@ -53,6 +53,7 @@ Author: Tobias Frisch <child> <object class="GtkButton" id="confirm_button"> <property name="label" translatable="yes">Confirm</property> + <property name="visible">True</property> <property name="can-focus">True</property> <property name="receives-default">True</property> </object> diff --git 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 @@ -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 @@ -27,6 +27,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)); }