[rs-commit] r37 - in /redwax-signtext/trunk/src/linux: message.c signtext.c signtext.h
rs-commit at redwax.eu
rs-commit at redwax.eu
Mon Sep 5 17:37:28 CEST 2022
Author: minfrin at redwax.eu
Date: Mon Sep 5 17:37:27 2022
New Revision: 37
Log:
Send a cancel error on cancel.
Modified:
redwax-signtext/trunk/src/linux/message.c
redwax-signtext/trunk/src/linux/signtext.c
redwax-signtext/trunk/src/linux/signtext.h
Modified: redwax-signtext/trunk/src/linux/message.c
==============================================================================
--- redwax-signtext/trunk/src/linux/message.c (original)
+++ redwax-signtext/trunk/src/linux/message.c Mon Sep 5 17:37:27 2022
@@ -25,6 +25,47 @@
#include "crypto.h"
#include "message.h"
#include "config.h"
+
+void message_cancel_clicked(GtkButton *button,
+ gpointer user_data)
+{
+ SignTextInstance *instance = user_data;
+ JsonBuilder *builder;
+ JsonNode *root;
+ GList *pages;
+
+ g_printerr("message_cancel_clicked\n");
+
+ /*
+ * Send an error to show we cancelled.
+ */
+ builder = json_builder_new_immutable();
+ json_builder_begin_object(builder);
+ json_builder_set_member_name(builder, "uuid");
+ json_builder_add_string_value(builder, instance->uuid);
+ json_builder_set_member_name(builder, "id");
+ json_builder_add_int_value(builder, instance->id);
+ json_builder_set_member_name(builder, "error");
+ json_builder_add_string_value(builder, "error:cancelled");
+ json_builder_end_object(builder);
+
+ root = json_builder_get_root(builder);
+
+ message_send(instance->signtext, root);
+
+ gtk_container_remove(GTK_CONTAINER(instance->stack), GTK_WIDGET(instance->box));
+
+ g_object_steal_data(G_OBJECT (instance->signtext->stack), instance->uuid);
+
+ pages = gtk_container_get_children(GTK_CONTAINER(instance->stack));
+ if (!g_list_length(pages)) {
+ gtk_widget_destroy(instance->signtext->window);
+ }
+ g_list_free(pages);
+
+ signtext_instance_free(instance);
+
+}
/*
* After receiving a parsed JSON message read from stdin, we end up here in the main UI
@@ -101,7 +142,7 @@
}
else {
- instance = signtext_instance_new(id, uuid, uri);
+ instance = signtext_instance_new(signtext, id, uuid, uri);
instance->box = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 6));
@@ -172,6 +213,10 @@
gtk_stack_add_titled(signtext->stack, GTK_WIDGET (instance->box), instance->uuid, g_uri_get_host(instance->uri));
+ instance->stack = signtext->stack;
+
+ g_signal_connect(instance->cancel, "clicked", (GCallback)message_cancel_clicked, instance);
+
gtk_widget_show_all (GTK_WIDGET(instance->box));
Modified: redwax-signtext/trunk/src/linux/signtext.c
==============================================================================
--- redwax-signtext/trunk/src/linux/signtext.c (original)
+++ redwax-signtext/trunk/src/linux/signtext.c Mon Sep 5 17:37:27 2022
@@ -65,9 +65,13 @@
g_free(signtext_token);
}
-SignTextInstance *signtext_instance_new(gint64 id, const gchar *uuid, GUri *uri)
+SignTextInstance *signtext_instance_new(SignTextData *signtext, gint64 id, const gchar *uuid, GUri *uri)
{
SignTextInstance *instance = g_new (SignTextInstance, 1);
+
+ memset(instance, 0, sizeof(SignTextInstance));
+
+ instance->signtext = signtext;
g_uri_ref(uri);
@@ -124,15 +128,16 @@
if (instance) {
if (instance->uuid) g_free(instance->uuid);
if (instance->uri) g_uri_unref(instance->uri);
- if (instance->label) g_object_unref(instance->label);
+// if (instance->label) g_object_unref(instance->label);
if (instance->label_text) g_free(instance->label_text);
- if (instance->textview) g_object_unref(instance->textview);
- if (instance->label_agree) g_object_unref(instance->label_agree);
- if (instance->buffer) g_object_unref(instance->buffer);
- if (instance->pin) g_object_unref(instance->pin);
- if (instance->buttons) g_object_unref(instance->buttons);
- if (instance->cancel) g_object_unref(instance->cancel);
- if (instance->sign) g_object_unref(instance->sign);
+// if (instance->textview) g_object_unref(instance->textview);
+// if (instance->label_agree) g_object_unref(instance->label_agree);
+// if (instance->buffer) g_object_unref(instance->buffer);
+// if (instance->pin) g_object_unref(instance->pin);
+// if (instance->buttons) g_object_unref(instance->buttons);
+// if (instance->cancel) g_object_unref(instance->cancel);
+// if (instance->sign) g_object_unref(instance->sign);
+ if (instance->box) g_object_unref(instance->box);
}
g_free(instance);
}
Modified: redwax-signtext/trunk/src/linux/signtext.h
==============================================================================
--- redwax-signtext/trunk/src/linux/signtext.h (original)
+++ redwax-signtext/trunk/src/linux/signtext.h Mon Sep 5 17:37:27 2022
@@ -67,10 +67,12 @@
};
typedef struct SignTextInstance {
+ SignTextData *signtext;
GUri *uri;
gchar *uuid;
gint64 id;
+ GtkStack *stack;
GtkLabel *label;
gchar *label_text;
GtkBox *box;
@@ -91,7 +93,7 @@
SignTextToken *signtext_token_new();
void signtext_token_free(SignTextToken *data);
-SignTextInstance *signtext_instance_new(gint64 id, const gchar *uuid, GUri *uri);
+SignTextInstance *signtext_instance_new(SignTextData *signtext, gint64 id, const gchar *uuid, GUri *uri);
void signtext_instance_free(SignTextInstance *instance);
#endif
More information about the rs-commit
mailing list