aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2022-02-13 21:09:40 +0100
committerTheJackiMonster <thejackimonster@gmail.com>2022-02-13 21:09:40 +0100
commitabc3ef82f55602aed73834880141723f745ad2d2 (patch)
tree8a85d25c31a3e1b8613cd4ed447ff848f0c406f6
parente06b57b58d500c09986b69180ed539ef8290cda0 (diff)
downloadmessenger-gtk-abc3ef82f55602aed73834880141723f745ad2d2.tar.gz
messenger-gtk-abc3ef82f55602aed73834880141723f745ad2d2.zip
Implemented creation of new accounts with automatic selection
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rw-r--r--resources/ui/new_profile.ui1
-rw-r--r--src/event.c2
-rw-r--r--src/ui/new_profile.c22
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
53 <child> 53 <child>
54 <object class="GtkButton" id="confirm_button"> 54 <object class="GtkButton" id="confirm_button">
55 <property name="label" translatable="yes">Confirm</property> 55 <property name="label" translatable="yes">Confirm</property>
56 <property name="visible">True</property>
56 <property name="can-focus">True</property> 57 <property name="can-focus">True</property>
57 <property name="receives-default">True</property> 58 <property name="receives-default">True</property>
58 </object> 59 </object>
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,
115 115
116 if ((account == GNUNET_CHAT_get_connected(handle)) || 116 if ((account == GNUNET_CHAT_get_connected(handle)) ||
117 ((app->chat.identity) && (0 == g_strcmp0(app->chat.identity, name)))) 117 ((app->chat.identity) && (0 == g_strcmp0(app->chat.identity, name))))
118 gtk_list_box_select_row(ui->accounts_listbox, row); 118 gtk_widget_activate(GTK_WIDGET(row));
119 119
120 ui_profile_entry_delete(profile); 120 ui_profile_entry_delete(profile);
121 return GNUNET_YES; 121 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 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2021 GNUnet e.V. 3 Copyright (C) 2021--2022 GNUnet e.V.
4 4
5 GNUnet is free software: you can redistribute it and/or modify it 5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published 6 under the terms of the GNU Affero General Public License as published
@@ -27,6 +27,22 @@
27#include "../application.h" 27#include "../application.h"
28 28
29static void 29static void
30_open_new_profile(GtkEntry *entry, MESSENGER_Application *app)
31{
32 const gchar *name = gtk_entry_get_text(entry);
33
34 if (GNUNET_OK != GNUNET_CHAT_account_create(app->chat.messenger.handle, name))
35 return;
36
37 gtk_list_box_unselect_all(app->ui.messenger.accounts_listbox);
38
39 if (app->chat.identity)
40 GNUNET_free(app->chat.identity);
41
42 app->chat.identity = GNUNET_strdup(name);
43}
44
45static void
30handle_profile_entry_changed(GtkEditable *editable, 46handle_profile_entry_changed(GtkEditable *editable,
31 gpointer user_data) 47 gpointer user_data)
32{ 48{
@@ -42,7 +58,7 @@ handle_profile_entry_activate(UNUSED GtkEntry *entry,
42{ 58{
43 MESSENGER_Application *app = (MESSENGER_Application*) user_data; 59 MESSENGER_Application *app = (MESSENGER_Application*) user_data;
44 60
45 // TODO: create new profile and switch to it 61 _open_new_profile(app->ui.new_profile.profile_entry, app);
46 62
47 gtk_window_close(GTK_WINDOW(app->ui.new_profile.dialog)); 63 gtk_window_close(GTK_WINDOW(app->ui.new_profile.dialog));
48} 64}
@@ -61,7 +77,7 @@ handle_confirm_button_click(UNUSED GtkButton *button,
61{ 77{
62 MESSENGER_Application *app = (MESSENGER_Application*) user_data; 78 MESSENGER_Application *app = (MESSENGER_Application*) user_data;
63 79
64 // TODO: create new profile and switch to it 80 _open_new_profile(app->ui.new_profile.profile_entry, app);
65 81
66 gtk_window_close(GTK_WINDOW(app->ui.new_profile.dialog)); 82 gtk_window_close(GTK_WINDOW(app->ui.new_profile.dialog));
67} 83}