Add an about dialog

This commit is contained in:
Pierre Pronchery 2016-01-25 02:29:45 +01:00
parent e1e1ccd3bd
commit 4bc3b6c878

View File

@ -1,30 +1,31 @@
/* $Id$ */
/* Copyright (c) 2016 Pierre Pronchery <khorben@defora.org> */
static char const _flashlightwindow_copyright[] =
"Copyright © 2016 Pierre Pronchery <khorben@defora.org>";
/* This file is part of DeforaOS Desktop Flashlight */
/* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. 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. */
/* All rights reserved. */
static char const _flashlightwindow_license[] =
"Redistribution and use in source and binary forms, with or without\n"
"modification, are permitted provided that the following conditions are\n"
"met:\n"
"\n"
"1. Redistributions of source code must retain the above copyright\n"
" notice, this list of conditions and the following disclaimer.\n"
"\n"
"2. Redistributions in binary form must reproduce the above copyright\n"
" notice, this list of conditions and the following disclaimer in the\n"
" documentation and/or other materials provided with the distribution.\n"
"\n"
"THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS\n"
"IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\n"
"TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A\n"
"PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n"
"HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n"
"SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\n"
"TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n"
"PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n"
"LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n"
"NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n"
"SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n";
@ -46,8 +47,17 @@ struct _FlashlightWindow
};
/* constants */
static char const * _flashlightwindow_authors[] =
{
"Pierre Pronchery <khorben@defora.org>",
NULL
};
/* prototypes */
/* callbacks */
static void _flashlightwindow_on_about(gpointer data);
static gboolean _flashlightwindow_on_closex(void);
static gboolean _flashlightwindow_on_idle(gpointer data);
@ -60,6 +70,7 @@ FlashlightWindow * flashlightwindow_new(void)
const int width = 300;
const int height = 400;
FlashlightWindow * window;
GtkWidget * box;
GtkWidget * widget;
GtkOrientation orientation = (height >= width)
? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL;
@ -81,8 +92,14 @@ FlashlightWindow * flashlightwindow_new(void)
flashlightwindow_delete(window);
return NULL;
}
box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
widget = flashlight_get_widget(window->flashlight);
gtk_container_add(GTK_CONTAINER(window->window), widget);
gtk_box_pack_start(GTK_BOX(box), widget, TRUE, TRUE, 0);
widget = gtk_button_new_from_stock(GTK_STOCK_ABOUT);
g_signal_connect_swapped(widget, "clicked", G_CALLBACK(
_flashlightwindow_on_about), window);
gtk_box_pack_start(GTK_BOX(box), widget, FALSE, TRUE, 0);
gtk_container_add(GTK_CONTAINER(window->window), box);
gtk_widget_show_all(window->window);
window->source = g_idle_add(_flashlightwindow_on_idle, window);
return window;
@ -103,6 +120,27 @@ void flashlightwindow_delete(FlashlightWindow * window)
/* prototypes */
/* callbacks */
/* flashlightwindow_on_about */
static void _flashlightwindow_on_about(gpointer data)
{
FlashlightWindow * window = data;
GtkWidget * dialog;
dialog = desktop_about_dialog_new();
gtk_window_set_transient_for(GTK_WINDOW(dialog), window->window);
desktop_about_dialog_set_authors(dialog, _flashlightwindow_authors);
desktop_about_dialog_set_comments(dialog,
"Flashlight application for the DeforaOS desktop");
desktop_about_dialog_set_copyright(dialog, _flashlightwindow_copyright);
desktop_about_dialog_set_license(dialog, _flashlightwindow_license);
desktop_about_dialog_set_logo_icon_name(dialog, "gtk-dialog-info");
desktop_about_dialog_set_program_name(dialog, PACKAGE);
desktop_about_dialog_set_version(dialog, VERSION);
desktop_about_dialog_set_website(dialog, "http://www.defora.org/");
gtk_dialog_run(GTK_DIALOG(dialog));
}
/* flashlightwindow_on_closex */
static gboolean _flashlightwindow_on_closex(void)
{