From 5d0ec9dfae48f39fec2d62f86c8220a712b6be8c Mon Sep 17 00:00:00 2001 From: Lakindu Akash Date: Wed, 13 Oct 2021 05:59:40 +0530 Subject: [PATCH] Set qr image from file --- src/ui/qr_ui.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/ui/qr_ui.h | 11 ++++++++++ 2 files changed, 70 insertions(+) create mode 100644 src/ui/qr_ui.c create mode 100644 src/ui/qr_ui.h diff --git a/src/ui/qr_ui.c b/src/ui/qr_ui.c new file mode 100644 index 0000000..bacad6c --- /dev/null +++ b/src/ui/qr_ui.c @@ -0,0 +1,59 @@ +// +// Created by lakinduakash on 13/04/19. +// +/* +Copyright (c) 2021, lakinduaksh + All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + */ + + + +#include +#include "qr_ui.h" + +static GtkBuilder *builder; +static GError *error = NULL; + +void open_qr(GtkWidget *widget, gpointer root,char* image_path) { + + builder = gtk_builder_new(); + //Load ui description from built resource - need to generate compiled source with glib-compile-resource + gtk_builder_add_from_resource(builder,"/org/gtk/wihotspot/qr.glade",&error); + + root = gtk_builder_get_object(builder, "dialog_qr"); + + GtkImage* qr_image = (GtkImage *) gtk_builder_get_object(builder, "image_qr"); + + gtk_image_set_from_file(qr_image,image_path); + + GtkDialog* dialog= GTK_DIALOG(root); + + gtk_dialog_run(GTK_DIALOG(dialog)); + + gtk_widget_destroy(GTK_WIDGET( dialog)); + + g_signal_connect (dialog, "destroy", G_CALLBACK(gtk_main_quit), NULL); + +} \ No newline at end of file diff --git a/src/ui/qr_ui.h b/src/ui/qr_ui.h new file mode 100644 index 0000000..cfc8eda --- /dev/null +++ b/src/ui/qr_ui.h @@ -0,0 +1,11 @@ + +#ifndef WIHOTSPOT_UI_QR +#define WIHOTSPOT_UI_QR + + +#include + + +void open_qr(GtkWidget *widget, gpointer window,char* image_path); + +#endif \ No newline at end of file