diff options
author | Niels De Graef <nielsdegraef@gmail.com> | 2022-08-07 23:00:18 +0200 |
---|---|---|
committer | Niels De Graef <nielsdegraef@gmail.com> | 2022-09-04 12:50:58 +0000 |
commit | 3f36be1fd09e90d7b472cee24f5b4cb9eb12b76b (patch) | |
tree | 4b6d6572cc918b96c5481d4951daa00b4b4783cb /gcr-gtk3/gcr-certificate-widget.c | |
parent | 4ec1071ea3070bdc85fd1c1cfe61af2349a8b39c (diff) | |
download | gcr-3f36be1fd09e90d7b472cee24f5b4cb9eb12b76b.tar.gz |
Drop gcr-gtk3 and gcr-gtk4
gcr historically consisted of 2 high-level parts: `gcr-base` and
`gcr-ui`. `gcr-base` contains the core classes and interfaces to deal
with crypto-related items (e.g. `GcrCertificate`), while `gcr-ui`
contained GTK widgets to show those items (e.g. `GcrCertificateWidget`).
Now: with the move to gcr4, it's becoming more and more clear to that this isn't really a path forward:
On one hand, GTK4 has transitioned from a platform toolkit (usually
GNOME was the primary target) to one that allows you to build your
platform on top (e.g. libadwaita, libgranite, or your very own). Kepeing
that in mind, having "GTK-based" widgets for use in general purpose
doesn't really make sense, since it will always look out touch on
platforms
On the other hand, widgets are usually more faster-moving targets in
both looks as well as API than an actual library, so in practice gcr-ui
has a different lifecycle than gcr-base.
Finally, @tintou has been doing an awesome effort to implement an API
that allows consumers to write their own widgets, without having to deal
with asn1 decoding etc. At this point, I think the certificate widget is
likely the only widget we're seeing interest in.
As such, this commit drops gcr-gtk3 and gcr-gtk4 as libraries. There's
still a gcr-viewer debugging tool as a troubleshooting/debugging tool,
that's it.
See https://gitlab.gnome.org/GNOME/gcr/-/issues/100 for the related
discussion.
Diffstat (limited to 'gcr-gtk3/gcr-certificate-widget.c')
-rw-r--r-- | gcr-gtk3/gcr-certificate-widget.c | 200 |
1 files changed, 0 insertions, 200 deletions
diff --git a/gcr-gtk3/gcr-certificate-widget.c b/gcr-gtk3/gcr-certificate-widget.c deleted file mode 100644 index 0ea05f8..0000000 --- a/gcr-gtk3/gcr-certificate-widget.c +++ /dev/null @@ -1,200 +0,0 @@ -/* - * Copyright 2021 Collabora Ltd. - * Copyright Corentin Noël <corentin.noel@collabora.com> - * SPDX-License-Identifier: LGPL-2.1-or-later - */ - -#include "config.h" - -#include "gcr-certificate-widget.h" -#include "gcr-section.h" - -struct _GcrCertificateWidget -{ - GtkBox parent_instance; - - GcrCertificate *certificate; - GtkWidget *reveal_button; - GtkWidget *revealer; - GtkWidget *primary_info; - GtkWidget *secondary_info; - GtkSizeGroup *size_group; -}; - -G_DEFINE_TYPE (GcrCertificateWidget, gcr_certificate_widget, GTK_TYPE_BOX) - -enum { - PROP_CERTIFICATE = 1, - N_PROPERTIES -}; - -static GParamSpec *obj_properties[N_PROPERTIES] = { NULL, }; - -static void -gcr_certificate_widget_finalize (GObject *object) -{ - GcrCertificateWidget *self = (GcrCertificateWidget *)object; - - g_clear_object (&self->size_group); - - G_OBJECT_CLASS (gcr_certificate_widget_parent_class)->finalize (object); -} - -static void -gcr_certificate_widget_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - GcrCertificateWidget *self = GCR_CERTIFICATE_WIDGET (object); - - switch (prop_id) - { - case PROP_CERTIFICATE: - g_value_set_object (value, gcr_certificate_widget_get_certificate (self)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -gcr_certificate_widget_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - GcrCertificateWidget *self = GCR_CERTIFICATE_WIDGET (object); - - switch (prop_id) - { - case PROP_CERTIFICATE: - gcr_certificate_widget_set_certificate (self, g_value_get_object (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - } -} - -static void -gcr_certificate_widget_class_init (GcrCertificateWidgetClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->finalize = gcr_certificate_widget_finalize; - object_class->get_property = gcr_certificate_widget_get_property; - object_class->set_property = gcr_certificate_widget_set_property; - - obj_properties[PROP_CERTIFICATE] = - g_param_spec_object ("certificate", - "Certificate", - "Certificate to display.", - GCR_TYPE_CERTIFICATE, - G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - - g_object_class_install_properties (object_class, - N_PROPERTIES, - obj_properties); -} - -static void -on_reveal_button_clicked (GtkWidget *button, - GcrCertificateWidget *self) -{ - g_assert (GCR_IS_CERTIFICATE_WIDGET (self)); - gtk_widget_hide (button); - gtk_revealer_set_reveal_child (GTK_REVEALER (self->revealer), TRUE); -} - -static void -gcr_certificate_widget_init (GcrCertificateWidget *self) -{ - gtk_orientable_set_orientation (GTK_ORIENTABLE (self), GTK_ORIENTATION_VERTICAL); - self->reveal_button = gtk_button_new_with_label ("…"); - gtk_widget_set_halign (self->reveal_button, GTK_ALIGN_CENTER); - gtk_box_pack_end (GTK_BOX (self), self->reveal_button, FALSE, TRUE, 0); - self->primary_info = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); - self->secondary_info = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); - gtk_box_pack_start (GTK_BOX (self), self->primary_info, FALSE, TRUE, 0); - self->revealer = g_object_new (GTK_TYPE_REVEALER, - "child", self->secondary_info, - "transition-type", GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN, - NULL); - gtk_box_pack_end (GTK_BOX (self), self->revealer, FALSE, TRUE, 0); - g_signal_connect (self->reveal_button, "clicked", G_CALLBACK (on_reveal_button_clicked), self); - self->size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); -} - -/** - * gcr_certificate_widget_new: - * @certificate: (nullable): certificate to display, or %NULL - * - * Create a new certificate widget which displays a given certificate. - * - * Returns: (transfer full): a newly allocated #GcrCertificateWidget, which - * should be freed with g_object_unref() - */ -GtkWidget * -gcr_certificate_widget_new (GcrCertificate *certificate) -{ - return g_object_new (GCR_TYPE_CERTIFICATE_WIDGET, "certificate", certificate, NULL); -} - -/** - * gcr_certificate_widget_get_certificate: - * @self: The certificate widget - * - * Get the certificate displayed in the widget. - * - * Returns: (nullable) (transfer none): the certificate - */ -GcrCertificate * -gcr_certificate_widget_get_certificate (GcrCertificateWidget *self) -{ - g_return_val_if_fail (GCR_IS_CERTIFICATE_WIDGET (self), NULL); - return self->certificate; -} - -/** - * gcr_certificate_widget_set_certificate: - * @self: The certificate widget - * @certificate: (nullable): the certificate to display - * - * Set the certificate displayed in the widget - */ -void -gcr_certificate_widget_set_certificate (GcrCertificateWidget *self, GcrCertificate *certificate) -{ - GList* elements, *l, *children; - - g_return_if_fail (GCR_IS_CERTIFICATE_WIDGET (self)); - - children = gtk_container_get_children (GTK_CONTAINER (self->secondary_info)); - for (l = children; l != NULL; l = l->next) { - gtk_widget_destroy (GTK_WIDGET (l->data)); - } - - g_list_free (children); - - g_set_object (&self->certificate, certificate); - if (!certificate) { - return; - } - - elements = gcr_certificate_get_interface_elements (certificate); - for (l = elements; l != NULL; l = l->next) { - GcrCertificateSection *section = l->data; - GtkWidget *widget; - - widget = gcr_section_new (section); - - gtk_size_group_add_widget (self->size_group, widget); - if (gcr_certificate_section_get_flags (section) & GCR_CERTIFICATE_SECTION_IMPORTANT) - gtk_box_pack_start (GTK_BOX (self->primary_info), widget, FALSE, FALSE, 0); - else - gtk_box_pack_start (GTK_BOX (self->secondary_info), widget, FALSE, FALSE, 0); - } - - g_list_free_full (elements, (GDestroyNotify) g_object_unref); -} |