Add an about dialog
This commit is contained in:
parent
e1e1ccd3bd
commit
4bc3b6c878
90
src/window.c
90
src/window.c
|
@ -1,30 +1,31 @@
|
||||||
/* $Id$ */
|
/* $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 */
|
/* This file is part of DeforaOS Desktop Flashlight */
|
||||||
/* All rights reserved.
|
/* All rights reserved. */
|
||||||
*
|
static char const _flashlightwindow_license[] =
|
||||||
* Redistribution and use in source and binary forms, with or without
|
"Redistribution and use in source and binary forms, with or without\n"
|
||||||
* modification, are permitted provided that the following conditions are
|
"modification, are permitted provided that the following conditions are\n"
|
||||||
* met:
|
"met:\n"
|
||||||
*
|
"\n"
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
"1. Redistributions of source code must retain the above copyright\n"
|
||||||
* notice, this list of conditions and the following disclaimer.
|
" notice, this list of conditions and the following disclaimer.\n"
|
||||||
*
|
"\n"
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
"2. Redistributions in binary form must reproduce the above copyright\n"
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
" notice, this list of conditions and the following disclaimer in the\n"
|
||||||
* documentation and/or other materials provided with the distribution.
|
" documentation and/or other materials provided with the distribution.\n"
|
||||||
*
|
"\n"
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
"THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS\n"
|
||||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
"IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\n"
|
||||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
"TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A\n"
|
||||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
"PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n"
|
||||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
"HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n"
|
||||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
"SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED\n"
|
||||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
"TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n"
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
"PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n"
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
"LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n"
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
"NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n"
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
|
"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 */
|
/* prototypes */
|
||||||
/* callbacks */
|
/* callbacks */
|
||||||
|
static void _flashlightwindow_on_about(gpointer data);
|
||||||
static gboolean _flashlightwindow_on_closex(void);
|
static gboolean _flashlightwindow_on_closex(void);
|
||||||
static gboolean _flashlightwindow_on_idle(gpointer data);
|
static gboolean _flashlightwindow_on_idle(gpointer data);
|
||||||
|
|
||||||
|
@ -60,6 +70,7 @@ FlashlightWindow * flashlightwindow_new(void)
|
||||||
const int width = 300;
|
const int width = 300;
|
||||||
const int height = 400;
|
const int height = 400;
|
||||||
FlashlightWindow * window;
|
FlashlightWindow * window;
|
||||||
|
GtkWidget * box;
|
||||||
GtkWidget * widget;
|
GtkWidget * widget;
|
||||||
GtkOrientation orientation = (height >= width)
|
GtkOrientation orientation = (height >= width)
|
||||||
? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL;
|
? GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL;
|
||||||
|
@ -81,8 +92,14 @@ FlashlightWindow * flashlightwindow_new(void)
|
||||||
flashlightwindow_delete(window);
|
flashlightwindow_delete(window);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
|
||||||
widget = flashlight_get_widget(window->flashlight);
|
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);
|
gtk_widget_show_all(window->window);
|
||||||
window->source = g_idle_add(_flashlightwindow_on_idle, window);
|
window->source = g_idle_add(_flashlightwindow_on_idle, window);
|
||||||
return window;
|
return window;
|
||||||
|
@ -103,6 +120,27 @@ void flashlightwindow_delete(FlashlightWindow * window)
|
||||||
|
|
||||||
/* prototypes */
|
/* prototypes */
|
||||||
/* callbacks */
|
/* 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 */
|
/* flashlightwindow_on_closex */
|
||||||
static gboolean _flashlightwindow_on_closex(void)
|
static gboolean _flashlightwindow_on_closex(void)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user