Add Nikita to AUTHORS and the gladish about dialog
[ladish.git] / gui / about.c
blobfdd2947541a72d02d35abd309d3e343f51bfcf8b
1 /* -*- Mode: C ; c-basic-offset: 2 -*- */
2 /*
3 * LADI Session Handler (ladish)
5 * Copyright (C) 2010 Nedko Arnaudov <nedko@arnaudov.name>
7 **************************************************************************
8 * This file contains the code that implements the about dialog
9 **************************************************************************
11 * LADI Session Handler is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * LADI Session Handler is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
23 * or write to the Free Software Foundation, Inc.,
24 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include <sys/types.h>
28 #include <sys/stat.h>
29 #include <unistd.h>
30 #include <fcntl.h>
32 #include "about.h"
33 #include "pixbuf.h"
34 #include "gtk_builder.h"
36 #define ABOUT_DIALOG_LOGO "ladish-logo-128x128.png"
38 static char * read_file_contents(const char * filename)
40 int fd;
41 struct stat st;
42 char * buffer;
44 if (stat(filename, &st) != 0)
46 return NULL;
49 fd = open(filename, O_RDONLY);
50 if (fd == -1)
52 return NULL;
55 buffer = malloc(st.st_size + 1);
56 if (buffer == NULL)
58 close(fd);
59 return NULL;
62 if (read(fd, buffer, (size_t)st.st_size) != (ssize_t)st.st_size)
64 free(buffer);
65 buffer = NULL;
67 else
69 buffer[st.st_size] = 0;
72 close(fd);
74 return buffer;
77 void show_about(void)
79 GtkWidget * dialog;
80 GdkPixbuf * pixbuf;
81 const char * authors[] = {"Nedko Arnaudov", "Nikita Zlobin", NULL};
82 const char * artists[] = {"Lapo Calamandrei", "Nadejda Pancheva-Arnaudova", NULL};
83 char * license;
85 pixbuf = load_pixbuf(ABOUT_DIALOG_LOGO);
86 license = read_file_contents(DATA_DIR "/COPYING");
88 dialog = get_gtk_builder_widget("about_win");
89 gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(dialog), PACKAGE_VERSION);
91 if (pixbuf != NULL)
93 gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(dialog), pixbuf);
94 g_object_unref(pixbuf);
97 if (license != NULL)
99 gtk_about_dialog_set_license(GTK_ABOUT_DIALOG(dialog), license);
100 free(license);
103 gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(dialog), authors);
104 gtk_about_dialog_set_artists(GTK_ABOUT_DIALOG(dialog), artists);
106 gtk_widget_show(dialog);
107 gtk_dialog_run(GTK_DIALOG(dialog));
108 gtk_widget_hide(dialog);