[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-anastasis-gtk] branch master updated: towards secret names and ex
From: |
gnunet |
Subject: |
[taler-anastasis-gtk] branch master updated: towards secret names and expiration editing |
Date: |
Fri, 09 Jul 2021 14:24:33 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository anastasis-gtk.
The following commit(s) were added to refs/heads/master by this push:
new 444423f towards secret names and expiration editing
444423f is described below
commit 444423fbcb9efe6775127d43966344681c88d1bf
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Fri Jul 9 14:24:30 2021 +0200
towards secret names and expiration editing
---
contrib/anastasis_gtk_main_window.glade | 120 ++++++++++----------
src/anastasis/Makefile.am | 1 +
src/anastasis/anastasis-gtk_action.c | 123 +++++++++++++++++----
.../anastasis-gtk_handle-expiration-change.c | 52 +++++++++
...stasis-gtk_handle-main-window-forward-clicked.c | 10 +-
.../anastasis-gtk_handle-secret-buttons.c | 9 +-
6 files changed, 233 insertions(+), 82 deletions(-)
diff --git a/contrib/anastasis_gtk_main_window.glade
b/contrib/anastasis_gtk_main_window.glade
index 30552c8..60f2066 100644
--- a/contrib/anastasis_gtk_main_window.glade
+++ b/contrib/anastasis_gtk_main_window.glade
@@ -2666,7 +2666,6 @@ with funding from the European Commission.</property>
<property
name="hadjustment">secret_box_adjustmenth</property>
<property
name="vadjustment">secret_box_adjustmentv</property>
<property name="shadow-type">in</property>
- <property
name="min-content-height">800</property>
<property
name="propagate-natural-width">True</property>
<property
name="propagate-natural-height">True</property>
<child>
@@ -2688,62 +2687,6 @@ with funding from the European Commission.</property>
<property
name="orientation">vertical</property>
<property
name="spacing">5</property>
<property
name="baseline-position">top</property>
- <child>
- <object class="GtkBox"
id="secret_name_vbox">
- <property
name="visible">True</property>
- <property
name="can-focus">False</property>
- <property
name="orientation">vertical</property>
- <property
name="spacing">5</property>
- <child>
- <object class="GtkLabel">
- <property
name="visible">True</property>
- <property
name="can-focus">False</property>
- <property
name="halign">start</property>
- <property
name="valign">start</property>
- <property name="label"
translatable="yes">Secret's name</property>
- </object>
- <packing>
- <property
name="expand">False</property>
- <property
name="fill">True</property>
- <property
name="padding">5</property>
- <property
name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkEntry"
id="secret_name_entry">
- <property
name="visible">True</property>
- <property
name="can-focus">True</property>
- </object>
- <packing>
- <property
name="expand">True</property>
- <property
name="fill">True</property>
- <property
name="padding">5</property>
- <property
name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel"
id="secret_name_explanation_label">
- <property
name="visible">True</property>
- <property
name="can-focus">False</property>
- <property
name="halign">start</property>
- <property name="label"
translatable="yes">Names should be unique, so that you can easily
-identify your secret later.</property>
- </object>
- <packing>
- <property
name="expand">False</property>
- <property
name="fill">True</property>
- <property
name="padding">5</property>
- <property
name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property
name="expand">False</property>
- <property
name="fill">True</property>
- <property
name="padding">20</property>
- <property
name="position">0</property>
- </packing>
- </child>
<child>
<object class="GtkBox"
id="secret_entry_vbox">
<property
name="visible">True</property>
@@ -2754,7 +2697,7 @@ identify your secret later.</property>
<property
name="visible">True</property>
<property
name="can-focus">False</property>
<property
name="halign">start</property>
- <property name="label"
translatable="yes">Provide secret as text:</property>
+ <property name="label"
translatable="yes">Provide secret as text</property>
</object>
<packing>
<property
name="expand">False</property>
@@ -2836,6 +2779,63 @@ identify your secret later.</property>
<property
name="expand">True</property>
<property
name="fill">True</property>
<property
name="padding">20</property>
+ <property
name="pack-type">end</property>
+ <property
name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox"
id="secret_name_vbox">
+ <property
name="visible">True</property>
+ <property
name="can-focus">False</property>
+ <property
name="orientation">vertical</property>
+ <property
name="spacing">5</property>
+ <child>
+ <object class="GtkLabel">
+ <property
name="visible">True</property>
+ <property
name="can-focus">False</property>
+ <property
name="halign">start</property>
+ <property
name="valign">start</property>
+ <property name="label"
translatable="yes">Secret's name</property>
+ </object>
+ <packing>
+ <property
name="expand">False</property>
+ <property
name="fill">True</property>
+ <property
name="padding">5</property>
+ <property
name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry"
id="anastasis_gtk_secret_name_entry">
+ <property
name="visible">True</property>
+ <property
name="can-focus">True</property>
+ </object>
+ <packing>
+ <property
name="expand">True</property>
+ <property
name="fill">True</property>
+ <property
name="padding">5</property>
+ <property
name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel"
id="secret_name_explanation_label">
+ <property
name="visible">True</property>
+ <property
name="can-focus">False</property>
+ <property
name="halign">start</property>
+ <property name="label"
translatable="yes">Names should be unique, so that you can easily
+identify your secret later.</property>
+ </object>
+ <packing>
+ <property
name="expand">False</property>
+ <property
name="fill">True</property>
+ <property
name="padding">5</property>
+ <property
name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property
name="expand">False</property>
+ <property
name="fill">True</property>
+ <property
name="padding">20</property>
<property
name="position">1</property>
</packing>
</child>
@@ -2865,7 +2865,7 @@ identify your secret later.</property>
<property
name="visible">True</property>
<property
name="can-focus">False</property>
<child>
- <object class="GtkLabel"
id="expiration_date_without_year">
+ <object class="GtkLabel"
id="expiration_date_without_year_label">
<property
name="visible">True</property>
<property
name="can-focus">False</property>
<property
name="label">DYNAMICALLY SET</property>
@@ -2888,7 +2888,9 @@ identify your secret later.</property>
<property
name="max-width-chars">4</property>
<property
name="input-purpose">digits</property>
<property
name="adjustment">expiration_year_adjustment</property>
+ <property
name="numeric">True</property>
<property
name="value">9999</property>
+ <signal
name="value-changed" handler="expiration_year_spin_button_value_changed_cb"
swapped="no"/>
</object>
<packing>
<property
name="expand">False</property>
diff --git a/src/anastasis/Makefile.am b/src/anastasis/Makefile.am
index 3f71102..65dfd26 100644
--- a/src/anastasis/Makefile.am
+++ b/src/anastasis/Makefile.am
@@ -28,6 +28,7 @@ anastasis_gtk_SOURCES = \
anastasis-gtk_handle-country-unselected.c \
anastasis-gtk_handle-currency-changed.c \
anastasis-gtk_handle-core-secret-changed.c \
+ anastasis-gtk_handle-expiration-change.c \
anastasis-gtk_handle-identity-changed.c \
anastasis-gtk_handle-identity-changed.h \
anastasis-gtk_handle-recovery-button-clicked.c \
diff --git a/src/anastasis/anastasis-gtk_action.c
b/src/anastasis/anastasis-gtk_action.c
index 5be0c95..4b3e8dd 100644
--- a/src/anastasis/anastasis-gtk_action.c
+++ b/src/anastasis/anastasis-gtk_action.c
@@ -1039,32 +1039,115 @@ action_policies_reviewing (void)
static void
action_secret_editing (void)
{
- GtkEntry *entry;
- const char *secret;
- struct GNUNET_JSON_Specification spec[] = {
- GNUNET_JSON_spec_string ("core_secret",
- &secret),
- GNUNET_JSON_spec_end ()
- };
AG_hide_all_frames ();
- entry = GTK_ENTRY (GCG_get_main_window_object (
- "anastasis_gtk_enter_secret_entry"));
- if ( (GNUNET_OK ==
- GNUNET_JSON_parse (AG_redux_state,
- spec,
- NULL, NULL)) &&
- (0 < strlen (secret)) )
{
- gtk_entry_set_text (entry,
- secret);
- AG_sensitive ("anastasis_gtk_main_window_forward_button");
+ GtkLabel *fee_label;
+ struct TALER_Amount fee = {
+ .value = 0
+ };
+
+ fee_label = GTK_LABEL (GCG_get_main_window_object (
+ "backup_fee_value_label"));
+ GNUNET_break (0); // FIXME: get backup fee from model!
+ if ( (0 == fee.value) &&
+ (0 == fee.fraction) )
+ {
+ gtk_label_set_text (fee_label,
+ _ (/* in the sense of gratis */
+ "free"));
+ }
+ else
+ {
+ char *val;
+
+ GNUNET_asprintf (&val,
+ "%llu.%u %s",
+ (unsigned long long) fee.value,
+ (unsigned int) fee.fraction,
+ fee.currency);
+ gtk_label_set_text (fee_label,
+ val);
+ GNUNET_free (val);
+ }
}
- else
{
- AG_insensitive ("anastasis_gtk_main_window_forward_button");
+ GtkLabel *expiration_label;
+ struct GNUNET_TIME_Absolute exp_time;
+ char estr[128];
+ struct tm tv;
+ time_t t;
+
+ expiration_label = GTK_LABEL (GCG_get_main_window_object (
+ "expiration_date_without_year_label"));
+ // FIXME: get expiration from model!
+ exp_time = GNUNET_TIME_absolute_get ();
+ t = exp_time.abs_value_us / GNUNET_TIME_UNIT_SECONDS.rel_value_us;
+ GNUNET_assert (NULL !=
+ localtime_r (&t,
+ &tv));
+ GNUNET_assert (sizeof (estr) >
+ strftime (estr,
+ sizeof (estr),
+ "%a, %d %b",
+ &tv));
+ gtk_label_set_text (expiration_label,
+ estr);
+ }
+ {
+ GtkSpinButton *sb;
+ unsigned int this_year;
+ unsigned int exp_year;
+
+ sb = GTK_SPIN_BUTTON (GCG_get_main_window_object (
+ "expiration_year_spin_button"));
+ this_year = GNUNET_TIME_get_current_year ();
+ /* We allow at most 5 years into the future */
+ gtk_spin_button_set_range (sb,
+ this_year + 1,
+ this_year + 6);
+ GNUNET_break (0); // FIXME: obtain current expiration from model!
+ exp_year = this_year + 1;
+ gtk_spin_button_set_value (sb,
+ (double) exp_year);
+ }
+ {
+ GtkEntry *entry;
+ const char *name = "";
+ const char *secret;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_string ("core_secret",
+ &secret),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string ("secret_name",
+ &name)),
+ GNUNET_JSON_spec_end ()
+ };
+
+ entry = GTK_ENTRY (GCG_get_main_window_object (
+ "anastasis_gtk_enter_secret_entry"));
+ if ( (GNUNET_OK ==
+ GNUNET_JSON_parse (AG_redux_state,
+ spec,
+ NULL, NULL)) &&
+ (0 < strlen (secret)) )
+ {
+ gtk_entry_set_text (entry,
+ secret);
+ AG_sensitive ("anastasis_gtk_main_window_forward_button");
+ }
+ else
+ {
+ AG_insensitive ("anastasis_gtk_main_window_forward_button");
+ }
+
+ entry = GTK_ENTRY (GCG_get_main_window_object (
+ "anastasis_gtk_secret_name_entry"));
+ if (NULL != name)
+ gtk_entry_set_text (entry,
+ name);
+ GNUNET_JSON_parse_free (spec);
}
- GNUNET_JSON_parse_free (spec);
AG_sensitive ("anastasis_gtk_main_window_prev_button");
AG_show ("anastassis_gtk_progress_vbox");
AG_progress_update ();
diff --git a/src/anastasis/anastasis-gtk_handle-expiration-change.c
b/src/anastasis/anastasis-gtk_handle-expiration-change.c
new file mode 100644
index 0000000..59a58ba
--- /dev/null
+++ b/src/anastasis/anastasis-gtk_handle-expiration-change.c
@@ -0,0 +1,52 @@
+/*
+ This file is part of anastasis-gtk.
+ Copyright (C) 2021 Anastasis SARL
+
+ Anastasis is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your
+ option) any later version.
+
+ Anastasis is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Anastasis; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+/**
+ * @file src/anastasis/anastasis-gtk_handle-expiration-change.c
+ * @brief
+ * @author Christian Grothoff
+ */
+#include <gnunet/platform.h>
+#include <gnunet/gnunet_util_lib.h>
+#include "anastasis-gtk_helper.h"
+#include "anastasis-gtk_action.h"
+#include <jansson.h>
+
+
+/**
+ * Callback invoked if the user changed when the
+ * backup may expire. Update cost.
+ *
+ * @param spin_button the spin button that changed
+ * @param user_data NULL
+ */
+void
+expiration_year_spin_button_value_changed_cb (
+ GtkSpinButton *spin_button,
+ gpointer user_data)
+{
+ gint value;
+ json_t *arg;
+
+ value = gtk_spin_button_get_value_as_int (spin_button);
+ arg = json_pack ("s:I",
+ "expiration-year",
+ (json_int_t) value);
+ // FIXME: action to update expiration time!
+}
diff --git a/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c
b/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c
index 006eb22..d681f87 100644
--- a/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c
+++ b/src/anastasis/anastasis-gtk_handle-main-window-forward-clicked.c
@@ -1,6 +1,6 @@
/*
This file is part of anastasis-gtk.
- Copyright (C) 2020 Anastasis SARL
+ Copyright (C) 2020, 2021 Anastasis SARL
Anastasis is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
@@ -165,11 +165,17 @@ forward_secret_editing (void)
json_t *arguments;
GtkEntry *entry;
const char *str;
+ const char *name;
entry = GTK_ENTRY (GCG_get_main_window_object (
"anastasis_gtk_enter_secret_entry"));
str = gtk_entry_get_text (entry);
- arguments = json_pack ("{s:{s:o,s:s}}",
+ entry = GTK_ENTRY (GCG_get_main_window_object (
+ "anastasis_gtk_secret_name_entry"));
+ name = gtk_entry_get_text (entry);
+ arguments = json_pack ("{s:s?,s:{s:o,s:s}}",
+ "name",
+ name,
"secret",
"value",
GNUNET_JSON_from_data (str,
diff --git a/src/anastasis/anastasis-gtk_handle-secret-buttons.c
b/src/anastasis/anastasis-gtk_handle-secret-buttons.c
index 7b665aa..a96a002 100644
--- a/src/anastasis/anastasis-gtk_handle-secret-buttons.c
+++ b/src/anastasis/anastasis-gtk_handle-secret-buttons.c
@@ -54,6 +54,8 @@ open_secret_dialog_response_cb (GtkDialog *dialog,
size_t data_size;
void *data;
const char *mime;
+ GtkEntry *entry;
+ const char *name;
if (GTK_RESPONSE_OK != response_id)
{
@@ -120,13 +122,18 @@ open_secret_dialog_response_cb (GtkDialog *dialog,
GNUNET_DISK_file_close (fh);
}
GNUNET_free (filename);
+ entry = GTK_ENTRY (GCG_get_main_window_object (
+ "anastasis_gtk_secret_name_entry"));
+ name = gtk_entry_get_text (entry);
mime = magic_buffer (magic,
data,
data_size);
{
json_t *arguments;
- arguments = json_pack ("{s:{s:o,s:s?}}",
+ arguments = json_pack ("{s:s?,s:{s:o,s:s?}}",
+ "name",
+ name,
"secret",
"value",
GNUNET_JSON_from_data (data,
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-anastasis-gtk] branch master updated: towards secret names and expiration editing,
gnunet <=