Add about dialog

This commit is contained in:
Lakindu Akash 2021-02-20 08:23:41 +05:30
parent 1e9c80681e
commit 4655603418
No known key found for this signature in database
GPG Key ID: 87D9889F7A634A38
7 changed files with 179 additions and 21 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ build
src/cmake-build-debug
src/ui/resources.c
wifih.ui~
about.glade~

55
src/ui/about_ui.c Normal file
View File

@ -0,0 +1,55 @@
//
// 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 <gtk/gtk.h>
#include "about_ui.h"
static GtkBuilder *builder;
static GError *error = NULL;
void show_info(GtkWidget *widget, gpointer root) {
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/about.glade",&error);
root = gtk_builder_get_object(builder, "about_dialog");
GtkAboutDialog* dialog= GTK_ABOUT_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);
}

11
src/ui/about_ui.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef WIHOTSPOT_UI_ABOUT
#define WIHOTSPOT_UI_ABOUT
#include <gtk/gtk.h>
void show_info(GtkWidget *widget, gpointer window);
#endif

79
src/ui/glade/about.glade Normal file
View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.2 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkAboutDialog" id="about_dialog">
<property name="can_focus">False</property>
<property name="window_position">center-on-parent</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">dialog</property>
<property name="gravity">center</property>
<property name="program_name">Linux Wifi Hotspot</property>
<property name="version">3.6.8</property>
<property name="copyright" translatable="yes">(c) lakinduakash 2021</property>
<property name="comments" translatable="yes">For more info visit
https://github.com/lakinduakash/linux-wifi-hotspot</property>
<property name="website">https://github.com/lakinduakash/linux-wifi-hotspot</property>
<property name="website_label" translatable="yes">Star on Github</property>
<property name="license" translatable="yes">Copyright (c) 2020, 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.
</property>
<property name="authors">Lakindu Akash
Oblique
Open source community</property>
<property name="artists">Freepik from www.flaticon.com</property>
<property name="logo_icon_name">wihotspot</property>
<property name="license_type">custom</property>
<child type="titlebar">
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</interface>

View File

@ -3,6 +3,11 @@
<gresource prefix="/org/gtk/wihotspot">
<file preprocess="xml-stripblanks">wifih.ui</file>
</gresource>
<gresource prefix="/org/gtk/wihotspot">
<file preprocess="xml-stripblanks">about.glade</file>
</gresource>
<gresource prefix="/css">
<file>style.css</file>
</gresource>

View File

@ -523,33 +523,16 @@
<property name="can_focus">False</property>
<property name="halign">end</property>
<child>
<object class="GtkLinkButton">
<property name="label" translatable="yes">Help?</property>
<object class="GtkButton" id="button_about">
<property name="label" translatable="yes">About</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="focus_on_click">False</property>
<property name="receives_default">True</property>
<property name="uri">https://github.com/lakinduakash/linux-wifi-hotspot</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">10</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button_stop_hp">
<property name="label" translatable="yes">Stop</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">end</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">10</property>
<property name="padding">48</property>
<property name="position">1</property>
</packing>
</child>
@ -569,6 +552,21 @@
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button_stop_hp">
<property name="label" translatable="yes">Stop</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">end</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">10</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>

View File

@ -39,6 +39,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "ui.h"
#include "read_config.h"
#include "util.h"
#include "about_ui.h"
#define BUFSIZE 512
#define AP_ENABLED "AP-ENABLED"
@ -55,6 +56,7 @@ GtkBuilder *builder;
GObject *window;
GtkButton *button_create_hp;
GtkButton *button_stop_hp;
GtkButton *button_about;
GtkEntry *entry_ssd;
GtkEntry *entry_pass;
@ -146,6 +148,11 @@ static void on_stop_hp_clicked(GtkWidget *widget, gpointer data) {
}
static void on_about_open_click(GtkWidget *widget, gpointer data){
show_info(widget,data);
}
static void loadStyles(){
provider = gtk_css_provider_new();
@ -352,6 +359,7 @@ int initUi(int argc, char *argv[]){
button_create_hp = (GtkButton *) gtk_builder_get_object(builder, "button_create_hp");
button_stop_hp = (GtkButton *) gtk_builder_get_object(builder, "button_stop_hp");
button_about = (GtkButton *) gtk_builder_get_object(builder, "button_about");
entry_ssd = (GtkEntry *) gtk_builder_get_object(builder, "entry_ssid");
entry_pass = (GtkEntry *) gtk_builder_get_object(builder, "entry_pass");
@ -394,6 +402,7 @@ int initUi(int argc, char *argv[]){
g_signal_connect (button_create_hp, "clicked", G_CALLBACK(on_create_hp_clicked), NULL);
g_signal_connect (button_stop_hp, "clicked", G_CALLBACK(on_stop_hp_clicked), NULL);
g_signal_connect (button_about, "clicked", G_CALLBACK(on_about_open_click), NULL);
g_signal_connect (entry_mac, "changed", G_CALLBACK(entry_mac_warn), NULL);
g_signal_connect (entry_ssd, "changed", G_CALLBACK(entry_ssid_warn), NULL);