Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 1 | /* |
Stepan Salenikovich | be87d2c | 2016-01-25 14:14:34 -0500 | [diff] [blame] | 2 | * Copyright (C) 2015-2016 Savoir-faire Linux Inc. |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 3 | * Author: Stepan Salenikovich <stepan.salenikovich@savoirfairelinux.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | */ |
| 19 | |
| 20 | #include "ringwelcomeview.h" |
| 21 | |
| 22 | #include <gtk/gtk.h> |
| 23 | #include <glib/gi18n.h> |
| 24 | #include "utils/accounts.h" |
| 25 | #include <account.h> |
| 26 | #include <accountmodel.h> |
aviau | dd355ba | 2016-04-08 14:23:09 -0400 | [diff] [blame] | 27 | #include <qrencode.h> |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 28 | |
| 29 | struct _RingWelcomeView |
| 30 | { |
Stepan Salenikovich | ab0f5be | 2016-02-05 15:16:35 -0500 | [diff] [blame] | 31 | GtkScrolledWindow parent; |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 32 | }; |
| 33 | |
| 34 | struct _RingWelcomeViewClass |
| 35 | { |
Stepan Salenikovich | ab0f5be | 2016-02-05 15:16:35 -0500 | [diff] [blame] | 36 | GtkScrolledWindowClass parent_class; |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 37 | }; |
| 38 | |
| 39 | typedef struct _RingWelcomeViewPrivate RingWelcomeViewPrivate; |
| 40 | |
| 41 | struct _RingWelcomeViewPrivate |
| 42 | { |
Stepan Salenikovich | 3e2851a | 2016-09-15 12:08:13 -0400 | [diff] [blame] | 43 | GtkWidget *box_overlay; |
Stepan Salenikovich | 64d446c | 2016-09-15 10:56:55 -0400 | [diff] [blame] | 44 | GtkWidget *label_ringid; |
| 45 | GtkWidget *label_explanation; |
| 46 | GtkWidget *button_qrcode; |
Stepan Salenikovich | 3e2851a | 2016-09-15 12:08:13 -0400 | [diff] [blame] | 47 | GtkWidget *revealer_qrcode; |
Stepan Salenikovich | 64d446c | 2016-09-15 10:56:55 -0400 | [diff] [blame] | 48 | |
aviau | df1f97b | 2016-10-24 12:34:14 -0400 | [diff] [blame] | 49 | QMetaObject::Connection account_model_data_changed; |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 50 | }; |
| 51 | |
Stepan Salenikovich | ab0f5be | 2016-02-05 15:16:35 -0500 | [diff] [blame] | 52 | G_DEFINE_TYPE_WITH_PRIVATE(RingWelcomeView, ring_welcome_view, GTK_TYPE_SCROLLED_WINDOW); |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 53 | |
| 54 | #define RING_WELCOME_VIEW_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), RING_WELCOME_VIEW_TYPE, RingWelcomeViewPrivate)) |
| 55 | |
aviau | dd355ba | 2016-04-08 14:23:09 -0400 | [diff] [blame] | 56 | static gboolean draw_qrcode(GtkWidget*,cairo_t*,gpointer); |
Stepan Salenikovich | 3e2851a | 2016-09-15 12:08:13 -0400 | [diff] [blame] | 57 | static void switch_qrcode(RingWelcomeView* self); |
aviau | dd355ba | 2016-04-08 14:23:09 -0400 | [diff] [blame] | 58 | |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 59 | static void |
Stepan Salenikovich | 64d446c | 2016-09-15 10:56:55 -0400 | [diff] [blame] | 60 | update_view(RingWelcomeView *self) { |
| 61 | auto priv = RING_WELCOME_VIEW_GET_PRIVATE(self); |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 62 | |
Stepan Salenikovich | 64d446c | 2016-09-15 10:56:55 -0400 | [diff] [blame] | 63 | auto account = get_active_ring_account(); |
| 64 | if (account != nullptr) { |
| 65 | gchar *ring_id = nullptr; |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 66 | if (!account->username().isEmpty()) { |
Stepan Salenikovich | 64d446c | 2016-09-15 10:56:55 -0400 | [diff] [blame] | 67 | ring_id = g_markup_printf_escaped("<span fgcolor=\"black\">%s</span>", |
| 68 | account->username().toUtf8().constData()); |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 69 | } else { |
Stepan Salenikovich | 64d446c | 2016-09-15 10:56:55 -0400 | [diff] [blame] | 70 | ring_id = g_markup_printf_escaped("<span fgcolor=\"gray\">%s</span>", |
| 71 | _("fetching RingID...")); |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 72 | } |
Stepan Salenikovich | 64d446c | 2016-09-15 10:56:55 -0400 | [diff] [blame] | 73 | gtk_label_set_markup(GTK_LABEL(priv->label_ringid), ring_id); |
| 74 | g_free(ring_id); |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 75 | } |
Stepan Salenikovich | 64d446c | 2016-09-15 10:56:55 -0400 | [diff] [blame] | 76 | |
| 77 | gtk_widget_set_visible(priv->label_ringid, account != nullptr); |
| 78 | gtk_widget_set_visible(priv->label_explanation, account != nullptr); |
| 79 | gtk_widget_set_visible(priv->button_qrcode, account != nullptr); |
Stepan Salenikovich | 3e2851a | 2016-09-15 12:08:13 -0400 | [diff] [blame] | 80 | gtk_widget_set_visible(priv->revealer_qrcode, account != nullptr); |
Stepan Salenikovich | 64d446c | 2016-09-15 10:56:55 -0400 | [diff] [blame] | 81 | |
Stepan Salenikovich | 3e2851a | 2016-09-15 12:08:13 -0400 | [diff] [blame] | 82 | if (!account) { |
| 83 | gtk_revealer_set_reveal_child(GTK_REVEALER(priv->revealer_qrcode), FALSE); |
| 84 | gtk_widget_set_opacity(priv->box_overlay, 1.0); |
| 85 | } |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | static void |
| 89 | ring_welcome_view_init(RingWelcomeView *self) |
| 90 | { |
| 91 | RingWelcomeViewPrivate *priv = RING_WELCOME_VIEW_GET_PRIVATE(self); |
| 92 | |
Stepan Salenikovich | ab0f5be | 2016-02-05 15:16:35 -0500 | [diff] [blame] | 93 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(self), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); |
| 94 | |
Stepan Salenikovich | 3e2851a | 2016-09-15 12:08:13 -0400 | [diff] [blame] | 95 | auto box_main = gtk_box_new(GTK_ORIENTATION_VERTICAL, 15); |
| 96 | gtk_container_add(GTK_CONTAINER(self), box_main); |
| 97 | gtk_box_set_baseline_position(GTK_BOX(box_main), GTK_BASELINE_POSITION_CENTER); |
| 98 | gtk_widget_set_vexpand(GTK_WIDGET(box_main), TRUE); |
| 99 | gtk_widget_set_hexpand(GTK_WIDGET(box_main), FALSE); |
| 100 | gtk_widget_set_valign(GTK_WIDGET(box_main), GTK_ALIGN_CENTER); |
| 101 | gtk_widget_set_halign(GTK_WIDGET(box_main), GTK_ALIGN_CENTER); |
| 102 | gtk_widget_set_visible(GTK_WIDGET(box_main), TRUE); |
| 103 | |
| 104 | /* overlay to show hide the qr code over the stuff in it */ |
| 105 | auto overlay_qrcode = gtk_overlay_new(); |
| 106 | gtk_box_pack_start(GTK_BOX(box_main), overlay_qrcode, FALSE, TRUE, 0); |
| 107 | |
| 108 | /* box which will be in the overaly so that we can display the QR code over the stuff in this box */ |
| 109 | priv->box_overlay = gtk_box_new(GTK_ORIENTATION_VERTICAL, 15); |
| 110 | gtk_container_add(GTK_CONTAINER(overlay_qrcode), priv->box_overlay); |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 111 | |
| 112 | /* get logo */ |
| 113 | GError *error = NULL; |
| 114 | GdkPixbuf* logo = gdk_pixbuf_new_from_resource_at_scale("/cx/ring/RingGnome/ring-logo-blue", |
| 115 | 350, -1, TRUE, &error); |
| 116 | if (logo == NULL) { |
| 117 | g_debug("Could not load logo: %s", error->message); |
| 118 | g_clear_error(&error); |
| 119 | } else { |
| 120 | auto image_ring_logo = gtk_image_new_from_pixbuf(logo); |
Stepan Salenikovich | 3e2851a | 2016-09-15 12:08:13 -0400 | [diff] [blame] | 121 | gtk_box_pack_start(GTK_BOX(priv->box_overlay), image_ring_logo, FALSE, TRUE, 0); |
aviau | dd355ba | 2016-04-08 14:23:09 -0400 | [diff] [blame] | 122 | gtk_widget_set_visible(GTK_WIDGET(image_ring_logo), TRUE); |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | /* welcome text */ |
Stepan Salenikovich | d4d19d6 | 2016-11-03 11:12:22 -0400 | [diff] [blame] | 126 | auto label_welcome_text = gtk_label_new(_("Ring is free software for universal communication which respects the freedoms and privacy of its users.")); |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 127 | gtk_label_set_justify(GTK_LABEL(label_welcome_text), GTK_JUSTIFY_CENTER); |
| 128 | gtk_widget_override_font(label_welcome_text, pango_font_description_from_string("12")); |
| 129 | gtk_label_set_line_wrap(GTK_LABEL(label_welcome_text), TRUE); |
| 130 | /* the max width chars is to limit how much the text expands */ |
| 131 | gtk_label_set_max_width_chars(GTK_LABEL(label_welcome_text), 50); |
| 132 | gtk_label_set_selectable(GTK_LABEL(label_welcome_text), TRUE); |
Stepan Salenikovich | 3e2851a | 2016-09-15 12:08:13 -0400 | [diff] [blame] | 133 | gtk_box_pack_start(GTK_BOX(priv->box_overlay), label_welcome_text, FALSE, TRUE, 0); |
aviau | dd355ba | 2016-04-08 14:23:09 -0400 | [diff] [blame] | 134 | gtk_widget_set_visible(GTK_WIDGET(label_welcome_text), TRUE); |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 135 | |
| 136 | /* RingID explanation */ |
Stepan Salenikovich | 64d446c | 2016-09-15 10:56:55 -0400 | [diff] [blame] | 137 | priv->label_explanation = gtk_label_new(C_("Do not translate \"RingID\"", "This is your RingID.\nCopy and share it with your friends!")); |
| 138 | auto context = gtk_widget_get_style_context(priv->label_explanation); |
Stepan Salenikovich | cebc592 | 2015-10-22 15:43:09 -0400 | [diff] [blame] | 139 | gtk_style_context_add_class(context, GTK_STYLE_CLASS_DIM_LABEL); |
Stepan Salenikovich | 64d446c | 2016-09-15 10:56:55 -0400 | [diff] [blame] | 140 | gtk_label_set_justify(GTK_LABEL(priv->label_explanation), GTK_JUSTIFY_CENTER); |
| 141 | gtk_label_set_selectable(GTK_LABEL(priv->label_explanation), TRUE); |
| 142 | gtk_widget_set_margin_top(priv->label_explanation, 20); |
| 143 | gtk_widget_set_no_show_all(priv->label_explanation, TRUE); |
Stepan Salenikovich | 3e2851a | 2016-09-15 12:08:13 -0400 | [diff] [blame] | 144 | gtk_box_pack_start(GTK_BOX(priv->box_overlay), priv->label_explanation, FALSE, TRUE, 0); |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 145 | |
| 146 | /* RingID label */ |
Stepan Salenikovich | 64d446c | 2016-09-15 10:56:55 -0400 | [diff] [blame] | 147 | priv->label_ringid = gtk_label_new(NULL); |
| 148 | gtk_label_set_selectable(GTK_LABEL(priv->label_ringid), TRUE); |
| 149 | gtk_widget_override_font(priv->label_ringid, pango_font_description_from_string("monospace 12")); |
| 150 | gtk_widget_set_no_show_all(priv->label_ringid, TRUE); |
Stepan Salenikovich | 3e2851a | 2016-09-15 12:08:13 -0400 | [diff] [blame] | 151 | gtk_box_pack_start(GTK_BOX(box_main), priv->label_ringid, FALSE, TRUE, 0); |
Stepan Salenikovich | 64d446c | 2016-09-15 10:56:55 -0400 | [diff] [blame] | 152 | gtk_label_set_ellipsize(GTK_LABEL(priv->label_ringid), PANGO_ELLIPSIZE_END); |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 153 | |
aviau | dd355ba | 2016-04-08 14:23:09 -0400 | [diff] [blame] | 154 | /* QR drawing area */ |
Stepan Salenikovich | 3e2851a | 2016-09-15 12:08:13 -0400 | [diff] [blame] | 155 | auto drawingarea_qrcode = gtk_drawing_area_new(); |
aviau | dd355ba | 2016-04-08 14:23:09 -0400 | [diff] [blame] | 156 | auto qrsize = 200; |
Stepan Salenikovich | 3e2851a | 2016-09-15 12:08:13 -0400 | [diff] [blame] | 157 | gtk_widget_set_size_request(drawingarea_qrcode, qrsize, qrsize); |
| 158 | g_signal_connect(drawingarea_qrcode, "draw", G_CALLBACK(draw_qrcode), NULL); |
| 159 | gtk_widget_set_visible(drawingarea_qrcode, TRUE); |
| 160 | |
| 161 | /* revealer which will show the qr code */ |
| 162 | priv->revealer_qrcode = gtk_revealer_new(); |
| 163 | gtk_container_add(GTK_CONTAINER(priv->revealer_qrcode), drawingarea_qrcode); |
| 164 | gtk_revealer_set_transition_type(GTK_REVEALER(priv->revealer_qrcode), GTK_REVEALER_TRANSITION_TYPE_CROSSFADE); //GTK_REVEALER_TRANSITION_TYPE_SLIDE_UP); |
| 165 | gtk_widget_set_halign(priv->revealer_qrcode, GTK_ALIGN_CENTER); |
| 166 | gtk_widget_set_valign(priv->revealer_qrcode, GTK_ALIGN_CENTER); |
| 167 | gtk_overlay_add_overlay(GTK_OVERLAY(overlay_qrcode), priv->revealer_qrcode); |
| 168 | gtk_widget_set_no_show_all(priv->revealer_qrcode, TRUE); |
| 169 | gtk_widget_set_visible(priv->revealer_qrcode, FALSE); |
aviau | dd355ba | 2016-04-08 14:23:09 -0400 | [diff] [blame] | 170 | |
| 171 | /* QR code button */ |
Stepan Salenikovich | 64d446c | 2016-09-15 10:56:55 -0400 | [diff] [blame] | 172 | priv->button_qrcode = gtk_button_new_with_label("QR code"); |
| 173 | gtk_widget_set_hexpand(priv->button_qrcode, FALSE); |
| 174 | gtk_widget_set_size_request(priv->button_qrcode,10,10); |
Stepan Salenikovich | 3e2851a | 2016-09-15 12:08:13 -0400 | [diff] [blame] | 175 | g_signal_connect_swapped(priv->button_qrcode, "clicked", G_CALLBACK(switch_qrcode), self); |
Stepan Salenikovich | 64d446c | 2016-09-15 10:56:55 -0400 | [diff] [blame] | 176 | gtk_widget_set_no_show_all(priv->button_qrcode, TRUE); |
| 177 | gtk_widget_set_visible(priv->button_qrcode, FALSE); |
Stepan Salenikovich | 3e2851a | 2016-09-15 12:08:13 -0400 | [diff] [blame] | 178 | gtk_box_pack_start(GTK_BOX(box_main), priv->button_qrcode, TRUE, TRUE, 0); |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 179 | |
Stepan Salenikovich | 64d446c | 2016-09-15 10:56:55 -0400 | [diff] [blame] | 180 | update_view(self); |
| 181 | |
aviau | df1f97b | 2016-10-24 12:34:14 -0400 | [diff] [blame] | 182 | priv->account_model_data_changed = QObject::connect( |
Guillaume Roguez | 5d1514b | 2015-10-22 15:55:31 -0400 | [diff] [blame] | 183 | &AccountModel::instance(), |
aviau | df1f97b | 2016-10-24 12:34:14 -0400 | [diff] [blame] | 184 | &AccountModel::dataChanged, |
| 185 | [self] (const QModelIndex&, const QModelIndex&) { update_view(self); } |
Stepan Salenikovich | 64d446c | 2016-09-15 10:56:55 -0400 | [diff] [blame] | 186 | ); |
| 187 | |
| 188 | gtk_widget_show_all(GTK_WIDGET(self)); |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | static void |
| 192 | ring_welcome_view_dispose(GObject *object) |
| 193 | { |
| 194 | RingWelcomeView *self = RING_WELCOME_VIEW(object); |
| 195 | RingWelcomeViewPrivate *priv = RING_WELCOME_VIEW_GET_PRIVATE(self); |
| 196 | |
aviau | df1f97b | 2016-10-24 12:34:14 -0400 | [diff] [blame] | 197 | QObject::disconnect(priv->account_model_data_changed); |
Stepan Salenikovich | 2cde761 | 2015-09-25 10:44:01 -0400 | [diff] [blame] | 198 | |
| 199 | G_OBJECT_CLASS(ring_welcome_view_parent_class)->dispose(object); |
| 200 | } |
| 201 | |
| 202 | static void |
| 203 | ring_welcome_view_finalize(GObject *object) |
| 204 | { |
| 205 | G_OBJECT_CLASS(ring_welcome_view_parent_class)->finalize(object); |
| 206 | } |
| 207 | |
| 208 | static void |
| 209 | ring_welcome_view_class_init(RingWelcomeViewClass *klass) |
| 210 | { |
| 211 | G_OBJECT_CLASS(klass)->finalize = ring_welcome_view_finalize; |
| 212 | G_OBJECT_CLASS(klass)->dispose = ring_welcome_view_dispose; |
| 213 | } |
| 214 | |
| 215 | GtkWidget * |
| 216 | ring_welcome_view_new() |
| 217 | { |
| 218 | gpointer self = g_object_new(RING_WELCOME_VIEW_TYPE, NULL); |
| 219 | |
| 220 | return (GtkWidget *)self; |
| 221 | } |
aviau | dd355ba | 2016-04-08 14:23:09 -0400 | [diff] [blame] | 222 | |
| 223 | static gboolean |
Stepan Salenikovich | 635258c | 2016-05-17 14:41:20 -0400 | [diff] [blame] | 224 | draw_qrcode(G_GNUC_UNUSED GtkWidget* diese, |
aviau | dd355ba | 2016-04-08 14:23:09 -0400 | [diff] [blame] | 225 | cairo_t* cr, |
Stepan Salenikovich | 635258c | 2016-05-17 14:41:20 -0400 | [diff] [blame] | 226 | G_GNUC_UNUSED gpointer data) |
aviau | dd355ba | 2016-04-08 14:23:09 -0400 | [diff] [blame] | 227 | { |
Stepan Salenikovich | 3e2851a | 2016-09-15 12:08:13 -0400 | [diff] [blame] | 228 | auto account = get_active_ring_account(); |
| 229 | if (!account) |
| 230 | return TRUE; |
| 231 | |
| 232 | auto rcode = QRcode_encodeString(account->username().toStdString().c_str(), |
aviau | dd355ba | 2016-04-08 14:23:09 -0400 | [diff] [blame] | 233 | 0, //Let the version be decided by libqrencode |
| 234 | QR_ECLEVEL_L, // Lowest level of error correction |
| 235 | QR_MODE_8, // 8-bit data mode |
| 236 | 1); |
| 237 | |
| 238 | if (!rcode) { // no rcode, no draw |
| 239 | g_warning("Failed to generate QR code"); |
| 240 | return TRUE; |
| 241 | } |
| 242 | |
| 243 | auto margin = 5; |
| 244 | auto qrsize = 200; |
| 245 | int qrwidth = rcode->width + margin * 2; |
| 246 | |
| 247 | /* scaling */ |
| 248 | auto scale = qrsize/qrwidth; |
| 249 | cairo_scale(cr, scale, scale); |
| 250 | |
| 251 | /* fill the background in white */ |
| 252 | cairo_set_source_rgb(cr, 1, 1, 1); |
| 253 | cairo_rectangle(cr, 0, 0, qrwidth, qrwidth); |
| 254 | cairo_fill (cr); |
| 255 | |
| 256 | unsigned char *row, *p; |
| 257 | p = rcode->data; |
| 258 | cairo_set_source_rgb(cr, 0, 0, 0); // back in black |
| 259 | for(int y = 0; y < rcode->width; y++) { |
| 260 | row = (p + (y * rcode->width)); |
| 261 | for(int x = 0; x < rcode->width; x++) { |
| 262 | if(*(row + x) & 0x1) { |
| 263 | cairo_rectangle(cr, margin + x, margin + y, 1, 1); |
| 264 | cairo_fill(cr); |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | } |
| 269 | |
| 270 | QRcode_free(rcode); |
| 271 | return TRUE; |
| 272 | |
| 273 | } |
| 274 | |
| 275 | static void |
Stepan Salenikovich | 3e2851a | 2016-09-15 12:08:13 -0400 | [diff] [blame] | 276 | switch_qrcode(RingWelcomeView* self) |
aviau | dd355ba | 2016-04-08 14:23:09 -0400 | [diff] [blame] | 277 | { |
Stepan Salenikovich | 3e2851a | 2016-09-15 12:08:13 -0400 | [diff] [blame] | 278 | auto priv = RING_WELCOME_VIEW_GET_PRIVATE(self); |
| 279 | |
| 280 | auto to_reveal = !gtk_revealer_get_reveal_child(GTK_REVEALER(priv->revealer_qrcode)); |
| 281 | gtk_revealer_set_reveal_child(GTK_REVEALER(priv->revealer_qrcode), to_reveal); |
| 282 | gtk_widget_set_opacity(priv->box_overlay, to_reveal ? 0.25 : 1.0); |
aviau | dd355ba | 2016-04-08 14:23:09 -0400 | [diff] [blame] | 283 | } |