diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2025-02-10 22:45:51 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2025-02-10 22:45:51 (GMT) |
commit | fd2f458abac21ceefa55468e1cb072ed16224a8e (patch) | |
tree | c2e9560d21659c4771d31723fa891b7c7dfbe2ee | |
parent | 607cd5420f847618d4cad66e7e168b6955ab4b6a (diff) |
Track secret storage lock updates in the status bar.
-rw-r--r-- | data/images/locked-symbolic.svg | 62 | ||||
-rw-r--r-- | data/images/nolock-symbolic.svg | 70 | ||||
-rw-r--r-- | data/images/unlocked-symbolic.svg | 62 | ||||
-rw-r--r-- | src/glibext/secstorage-int.h | 4 | ||||
-rw-r--r-- | src/glibext/secstorage.c | 10 | ||||
-rw-r--r-- | src/gtkext/Makefile.am | 8 | ||||
-rw-r--r-- | src/gtkext/gresource.xml | 5 | ||||
-rw-r--r-- | src/gtkext/statusstack-int.h | 4 | ||||
-rw-r--r-- | src/gtkext/statusstack.c | 56 | ||||
-rw-r--r-- | src/gtkext/statusstack.ui | 15 | ||||
-rw-r--r-- | src/schemas/re.chrysalide.framework.gschema.xml | 38 |
11 files changed, 318 insertions, 16 deletions
diff --git a/data/images/locked-symbolic.svg b/data/images/locked-symbolic.svg new file mode 100644 index 0000000..1b24147 --- /dev/null +++ b/data/images/locked-symbolic.svg @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + width="300" + height="300" + viewBox="0 0 79.375 79.374998" + version="1.1" + id="svg341" + inkscape:version="1.2.2 (b0a8486541, 2022-12-01)" + sodipodi:docname="locked-symbolic.svg" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg"> + <sodipodi:namedview + id="namedview343" + pagecolor="#ffffff" + bordercolor="#000000" + borderopacity="0.25" + inkscape:showpageshadow="2" + inkscape:pageopacity="0.0" + inkscape:pagecheckerboard="0" + inkscape:deskcolor="#d1d1d1" + inkscape:document-units="px" + showgrid="true" + inkscape:zoom="2.3450501" + inkscape:cx="87.418175" + inkscape:cy="159.05844" + inkscape:window-width="1920" + inkscape:window-height="1011" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="1" + inkscape:current-layer="layer1" + showguides="false"> + <inkscape:grid + type="xygrid" + id="grid462" + originx="0" + originy="0" /> + </sodipodi:namedview> + <defs + id="defs338" /> + <g + inkscape:label="Calque 1" + inkscape:groupmode="layer" + id="layer1"> + <path + id="path1942" + style="fill:#000000;fill-opacity:1;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;paint-order:fill markers stroke" + d="M 39.687499 1.3229166 A 13.229166 13.229166 0 0 0 26.458333 14.552083 A 13.229166 13.229166 0 0 0 31.75 25.124564 L 31.75 14.552083 A 7.9375 7.9375 0 0 1 39.687499 6.6145832 A 7.9375 7.9375 0 0 1 47.624999 14.552083 L 47.624999 25.135416 A 13.229166 13.229166 0 0 0 52.916666 14.552083 A 13.229166 13.229166 0 0 0 39.687499 1.3229166 z " /> + <path + id="rect1950" + style="fill:#000000;fill-opacity:1;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;paint-order:fill markers stroke" + d="M 26.458333 14.552083 L 26.458333 39.687499 L 31.75 39.687499 L 31.75 14.552083 L 26.458333 14.552083 z M 47.624999 14.552083 L 47.624999 39.687499 L 52.916666 39.687499 L 52.916666 14.552083 L 47.624999 14.552083 z " /> + <path + id="rect2099" + style="fill:#000000;fill-opacity:1;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;paint-order:fill markers stroke" + d="M 18.520833 35.71875 C 14.123462 35.71875 10.583333 39.258879 10.583333 43.656249 L 10.583333 70.114582 C 10.583333 74.511953 14.123462 78.052082 18.520833 78.052082 L 60.854166 78.052082 C 65.251537 78.052082 68.791666 74.511953 68.791666 70.114582 L 68.791666 43.656249 C 68.791666 39.258879 65.251537 35.71875 60.854166 35.71875 L 18.520833 35.71875 z M 37.703125 52.916666 L 41.671874 52.916666 C 42.40477 52.916666 42.994791 53.506688 42.994791 54.239583 L 42.994791 70.114582 C 42.994791 70.847478 42.40477 71.437499 41.671874 71.437499 L 37.703125 71.437499 C 36.970229 71.437499 36.380208 70.847478 36.380208 70.114582 L 36.380208 54.239583 C 36.380208 53.506688 36.970229 52.916666 37.703125 52.916666 z " /> + </g> +</svg> diff --git a/data/images/nolock-symbolic.svg b/data/images/nolock-symbolic.svg new file mode 100644 index 0000000..ed59858 --- /dev/null +++ b/data/images/nolock-symbolic.svg @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + width="300" + height="300" + viewBox="0 0 79.375 79.374998" + version="1.1" + id="svg341" + inkscape:version="1.2.2 (b0a8486541, 2022-12-01)" + sodipodi:docname="nolock-symbolic.svg" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg"> + <sodipodi:namedview + id="namedview343" + pagecolor="#ffffff" + bordercolor="#000000" + borderopacity="0.25" + inkscape:showpageshadow="2" + inkscape:pageopacity="0.0" + inkscape:pagecheckerboard="0" + inkscape:deskcolor="#d1d1d1" + inkscape:document-units="px" + showgrid="true" + inkscape:zoom="2.3450501" + inkscape:cx="84.006734" + inkscape:cy="159.05844" + inkscape:window-width="1920" + inkscape:window-height="1011" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="1" + inkscape:current-layer="layer1" + showguides="true"> + <inkscape:grid + type="xygrid" + id="grid462" + originx="0" + originy="0" /> + </sodipodi:namedview> + <defs + id="defs338" /> + <g + inkscape:label="Calque 1" + inkscape:groupmode="layer" + id="layer1"> + <path + id="path1942" + style="fill:#000000;fill-opacity:1;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;paint-order:fill markers stroke" + d="M 39.687499 1.3229166 A 13.229166 13.229166 0 0 0 26.458333 14.552083 A 13.229166 13.229166 0 0 0 31.75 25.124564 L 31.75 14.552083 A 7.9375 7.9375 0 0 1 39.687499 6.6145832 A 7.9375 7.9375 0 0 1 47.624999 14.552083 L 47.624999 25.135416 A 13.229166 13.229166 0 0 0 52.916666 14.552083 A 13.229166 13.229166 0 0 0 39.687499 1.3229166 z " /> + <path + id="rect1950" + style="fill:#000000;fill-opacity:1;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;paint-order:fill markers stroke" + d="M 26.458333 14.552083 L 26.458333 39.687499 L 31.75 39.687499 L 31.75 14.552083 L 26.458333 14.552083 z M 47.624999 14.552083 L 47.624999 39.687499 L 52.916666 39.687499 L 52.916666 14.552083 L 47.624999 14.552083 z " /> + <path + id="rect2099" + style="fill:#000000;fill-opacity:1;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;paint-order:fill markers stroke" + d="M 18.520833 35.71875 C 14.123466 35.71875 10.583333 39.258884 10.583333 43.656249 L 10.583333 70.114582 C 10.583333 70.465451 10.608349 70.810037 10.652063 71.148628 L 36.380208 57.337585 L 36.380208 54.239583 C 36.380208 53.506688 36.970229 52.916666 37.703125 52.916666 L 41.671874 52.916666 C 42.259126 52.916666 42.753343 53.295986 42.927095 53.823587 L 68.065612 40.329321 C 66.811534 37.603321 64.061787 35.71875 60.854166 35.71875 L 18.520833 35.71875 z M 68.791666 47.447232 L 42.994791 61.294449 L 42.994791 70.114582 C 42.994791 70.847478 42.40477 71.437499 41.671874 71.437499 L 37.703125 71.437499 C 36.970229 71.437499 36.380208 70.847478 36.380208 70.114582 L 36.380208 64.845137 L 14.176912 76.763789 C 15.423753 77.577929 16.914362 78.052082 18.520833 78.052082 L 60.854166 78.052082 C 65.251533 78.052082 68.791666 74.511949 68.791666 70.114582 L 68.791666 47.447232 z " /> + <rect + style="fill:#000000;fill-opacity:1;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;paint-order:fill markers stroke" + id="rect3055" + width="79.375" + height="6.614583" + x="-30.998156" + y="61.111198" + transform="rotate(-28.226475)" /> + </g> +</svg> diff --git a/data/images/unlocked-symbolic.svg b/data/images/unlocked-symbolic.svg new file mode 100644 index 0000000..da7b6ac --- /dev/null +++ b/data/images/unlocked-symbolic.svg @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + width="300" + height="300" + viewBox="0 0 79.375 79.374998" + version="1.1" + id="svg341" + inkscape:version="1.2.2 (b0a8486541, 2022-12-01)" + sodipodi:docname="unlocked-symbolic.svg" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg"> + <sodipodi:namedview + id="namedview343" + pagecolor="#ffffff" + bordercolor="#000000" + borderopacity="0.25" + inkscape:showpageshadow="2" + inkscape:pageopacity="0.0" + inkscape:pagecheckerboard="0" + inkscape:deskcolor="#d1d1d1" + inkscape:document-units="px" + showgrid="true" + inkscape:zoom="2.3450501" + inkscape:cx="87.418175" + inkscape:cy="159.05844" + inkscape:window-width="1920" + inkscape:window-height="1011" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="1" + inkscape:current-layer="layer1" + showguides="false"> + <inkscape:grid + type="xygrid" + id="grid462" + originx="0" + originy="0" /> + </sodipodi:namedview> + <defs + id="defs338" /> + <g + inkscape:label="Calque 1" + inkscape:groupmode="layer" + id="layer1"> + <path + id="path1942" + style="display:none;fill:#000000;fill-opacity:1;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;paint-order:fill markers stroke" + d="M 39.687499,1.3229166 A 13.229166,13.229166 0 0 0 26.458333,14.552083 V 39.687499 H 31.75 V 25.124564 14.552083 a 7.9375,7.9375 0 0 1 7.937499,-7.9374998 7.9375,7.9375 0 0 1 7.9375,7.9374998 v 10.583333 14.552083 h 5.291667 V 14.552083 A 13.229166,13.229166 0 0 0 39.687499,1.3229166 Z" /> + <path + id="rect2099" + style="fill:#000000;fill-opacity:1;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;paint-order:fill markers stroke" + d="M 18.520833 35.71875 C 14.123462 35.71875 10.583333 39.258879 10.583333 43.656249 L 10.583333 70.114582 C 10.583333 74.511953 14.123462 78.052082 18.520833 78.052082 L 60.854166 78.052082 C 65.251537 78.052082 68.791666 74.511953 68.791666 70.114582 L 68.791666 43.656249 C 68.791666 39.258879 65.251537 35.71875 60.854166 35.71875 L 18.520833 35.71875 z M 37.703125 52.916666 L 41.671874 52.916666 C 42.40477 52.916666 42.994791 53.506688 42.994791 54.239583 L 42.994791 70.114582 C 42.994791 70.847478 42.40477 71.437499 41.671874 71.437499 L 37.703125 71.437499 C 36.970229 71.437499 36.380208 70.847478 36.380208 70.114582 L 36.380208 54.239583 C 36.380208 53.506688 36.970229 52.916666 37.703125 52.916666 z " /> + <path + id="path2191" + style="fill:#000000;fill-opacity:1;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;paint-order:fill markers stroke" + d="M 60.854166 1.3229166 A 13.229166 13.229166 0 0 0 47.624999 14.552083 L 47.624999 39.687499 L 52.916666 39.687499 L 52.916666 25.124564 L 52.916666 14.552083 A 7.9375 7.9375 0 0 1 60.854166 6.6145832 A 7.9375 7.9375 0 0 1 68.791666 14.552083 L 68.791666 25.135416 L 68.791666 25.24497 C 69.221772 25.173377 69.663543 25.135416 70.114582 25.135416 L 74.083332 25.135416 L 74.083332 14.552083 A 13.229166 13.229166 0 0 0 60.854166 1.3229166 z " /> + </g> +</svg> diff --git a/src/glibext/secstorage-int.h b/src/glibext/secstorage-int.h index 310fbbc..bbac133 100644 --- a/src/glibext/secstorage-int.h +++ b/src/glibext/secstorage-int.h @@ -45,6 +45,10 @@ struct _GSecretStorageClass { GObjectClass parent; /* A laisser en premier */ + /* Signaux */ + + void (* lock_update) (GSecretStorage *); + }; diff --git a/src/glibext/secstorage.c b/src/glibext/secstorage.c index 84fc10c..ed2e4e6 100644 --- a/src/glibext/secstorage.c +++ b/src/glibext/secstorage.c @@ -111,6 +111,14 @@ static void g_secret_storage_class_init(GSecretStorageClass *klass) object->dispose = g_secret_storage_dispose; object->finalize = g_secret_storage_finalize; + g_signal_new("lock-update", + G_TYPE_SECRET_STORAGE, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(GSecretStorageClass, lock_update), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + } @@ -237,7 +245,7 @@ bool g_secret_storage_create(GSecretStorage *storage, GSettings *settings) storage->settings = settings; } else - result = false; // TODO + storage->settings = g_settings_new("re.chrysalide.framework.secstorage"); return result; diff --git a/src/gtkext/Makefile.am b/src/gtkext/Makefile.am index 4590aa6..cf1f057 100644 --- a/src/gtkext/Makefile.am +++ b/src/gtkext/Makefile.am @@ -26,10 +26,16 @@ libgtkext_la_LIBADD = \ libgtkext_la_CFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) +IMG_PATH = ../../data/images + RES_FILES = \ hexview.css \ hexview.ui \ - statusstack.ui + statusstack.ui \ + $(IMG_PATH)/nolock-symbolic.svg \ + $(IMG_PATH)/locked-symbolic.svg \ + $(IMG_PATH)/unlocked-symbolic.svg \ + tweak.ui libgtkext4_la_SOURCES = \ area-int.h \ diff --git a/src/gtkext/gresource.xml b/src/gtkext/gresource.xml index 3bfd8c5..6de48f6 100644 --- a/src/gtkext/gresource.xml +++ b/src/gtkext/gresource.xml @@ -5,4 +5,9 @@ <file compressed="true">hexview.ui</file> <file compressed="true">statusstack.ui</file> </gresource> + <gresource prefix="/re/chrysalide/framework/gui/icons/scalable/actions"> + <file compressed="true" alias="nolock-symbolic.svg">../../data/images/nolock-symbolic.svg</file> + <file compressed="true" alias="locked-symbolic.svg">../../data/images/locked-symbolic.svg</file> + <file compressed="true" alias="unlocked-symbolic.svg">../../data/images/unlocked-symbolic.svg</file> + </gresource> </gresources> diff --git a/src/gtkext/statusstack-int.h b/src/gtkext/statusstack-int.h index facc5af..2a9e99e 100644 --- a/src/gtkext/statusstack-int.h +++ b/src/gtkext/statusstack-int.h @@ -26,6 +26,7 @@ #include "statusstack.h" +#include "../glibext/secstorage.h" @@ -70,6 +71,9 @@ struct _GtkStatusStack /* Tronc commun */ + GSecretStorage *storage; /* Stockage des secrets */ + GtkToggleButton *lock_update; /* Activation des accès */ + GtkLabel *net_recv_speed; /* Débit en réception */ GtkLabel *net_send_speed; /* Débit en émission */ diff --git a/src/gtkext/statusstack.c b/src/gtkext/statusstack.c index 0d8ef62..1b558ba 100644 --- a/src/gtkext/statusstack.c +++ b/src/gtkext/statusstack.c @@ -53,6 +53,9 @@ static void gtk_status_stack_dispose(GtkStatusStack *); /* Procède à la libération totale de la mémoire. */ static void gtk_status_stack_finalize(GtkStatusStack *); +/* Note le changement de verrouillage du stockage sécurisé. */ +static void gtk_status_stack_on_secret_storage_lock_update(GSecretStorage *, GtkStatusStack *); + /* Met à jour dans la barre les débits réseau observés. */ static gboolean gtk_status_stack_update_network_stats(GtkStatusStack *); @@ -190,6 +193,8 @@ static void gtk_status_stack_class_init(GtkStatusStackClass *class) gtk_widget_class_bind_template_child(widget, GtkStatusStack, activity_message); gtk_widget_class_bind_template_child(widget, GtkStatusStack, activity_progress); + gtk_widget_class_bind_template_child(widget, GtkStatusStack, lock_update); + gtk_widget_class_bind_template_child(widget, GtkStatusStack, net_recv_speed); gtk_widget_class_bind_template_child(widget, GtkStatusStack, net_send_speed); @@ -220,6 +225,17 @@ static void gtk_status_stack_init(GtkStatusStack *stack) stack->activity_info = calloc(1, sizeof(activity_info_t)); init_activity_info(stack->activity_info); + /* Suivi des évolutions relatives au stockage sécurisé */ + + stack->storage = get_secret_storage(); + + g_signal_connect(stack->storage, "lock-update", + G_CALLBACK(gtk_status_stack_on_secret_storage_lock_update), stack); + + gtk_status_stack_on_secret_storage_lock_update(stack->storage, stack); + + /* Suivi des débits de connexion */ + stack->next_index = 0; stack->network_update_tag = g_timeout_add(NETWORK_UPDATE_INTERVAL, @@ -242,6 +258,12 @@ static void gtk_status_stack_init(GtkStatusStack *stack) static void gtk_status_stack_dispose(GtkStatusStack *stack) { + if (stack->storage != NULL) + g_signal_handlers_disconnect_by_func(stack->storage, + gtk_status_stack_on_secret_storage_lock_update, stack); + + g_clear_object(&stack->storage); + g_source_remove(stack->network_update_tag); gtk_widget_dispose_template(GTK_WIDGET(stack), GTK_TYPE_STATUS_STACK); @@ -322,6 +344,40 @@ void gtk_status_stack_reset(GtkStatusStack *stack) /****************************************************************************** * * +* Paramètres : storage = gardien des secrets impliqué. * + window = fenêtre dont la barre de statut est à actualiser. * +* * +* Description : Note le changement de verrouillage du stockage sécurisé. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_status_stack_on_secret_storage_lock_update(GSecretStorage *storage, GtkStatusStack *stack) +{ + if (!g_secret_storage_has_key(stack->storage)) + { + gtk_widget_set_sensitive(GTK_WIDGET(stack->lock_update), false); + gtk_button_set_icon_name(GTK_BUTTON(stack->lock_update), "nolock-symbolic"); + } + else + { + gtk_widget_set_sensitive(GTK_WIDGET(stack->lock_update), true); + + if (g_secret_storage_is_locked(stack->storage)) + gtk_button_set_icon_name(GTK_BUTTON(stack->lock_update), "locked-symbolic"); + else + gtk_button_set_icon_name(GTK_BUTTON(stack->lock_update), "unlocked-symbolic"); + + } + +} + + +/****************************************************************************** +* * * Paramètres : stack = barre de statut à actualiser. * * * * Description : Met à jour dans la barre les débits réseau observés. * diff --git a/src/gtkext/statusstack.ui b/src/gtkext/statusstack.ui index 422f95d..8469e6e 100644 --- a/src/gtkext/statusstack.ui +++ b/src/gtkext/statusstack.ui @@ -1,3 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> <interface> <template class="GtkStatusStack" parent="GtkBox"> @@ -148,6 +149,20 @@ </child> <child> + <object class="GtkToggleButton" id="lock_update"> + <property name="sensitive">false</property> + <property name="has-frame">false</property> + <property name="icon-name">nolock-symbolic</property> + </object> + </child> + + <child> + <object class="GtkSeparator"> + <property name="orientation">vertical</property> + </object> + </child> + + <child> <object class="GtkImage"> <property name="margin-start">8</property> <property name="icon-name">pan-down-symbolic</property> diff --git a/src/schemas/re.chrysalide.framework.gschema.xml b/src/schemas/re.chrysalide.framework.gschema.xml index e8331ff..87088f7 100644 --- a/src/schemas/re.chrysalide.framework.gschema.xml +++ b/src/schemas/re.chrysalide.framework.gschema.xml @@ -1,19 +1,29 @@ <schemalist gettext-domain="chrysalide"> - <schema id="re.chrysalide.framework" path="/re/chrysalide/framework/"> - <child schema="re.chrysalide.framework.gui" name="gui"/> - </schema> + <schema id="re.chrysalide.framework" path="/re/chrysalide/framework/"> + <child schema="re.chrysalide.framework.gui" name="gui"/> + <child schema="re.chrysalide.framework.secstorage" name="secstorage"/> + </schema> - <schema id="re.chrysalide.framework.gui" path="/re/chrysalide/framework/gui/"> - <key name="window-width" type="i"> - <default>600</default> - </key> - <key name="window-height" type="i"> - <default>400</default> - </key> - <key name="window-maximized" type="b"> - <default>false</default> - </key> - </schema> + <schema id="re.chrysalide.framework.gui" path="/re/chrysalide/framework/gui/"> + <key name="window-width" type="i"> + <default>600</default> + </key> + <key name="window-height" type="i"> + <default>400</default> + </key> + <key name="window-maximized" type="b"> + <default>false</default> + </key> + </schema> + + <schema id="re.chrysalide.framework.secstorage" path="/re/chrysalide/framework/secstorage/"> + <key name="salt" type="ay"> + <default>[]</default> + </key> + <key name="master" type="ay"> + <default>[]</default> + </key> + </schema> </schemalist> |