File: about.c

package info (click to toggle)
ladish 1%2Bdfsg0-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 3,940 kB
  • sloc: ansic: 36,406; python: 11,237; cpp: 705; makefile: 22; ruby: 20; sh: 17
file content (114 lines) | stat: -rw-r--r-- 3,240 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* -*- Mode: C ; c-basic-offset: 2 -*- */
/*
 * LADI Session Handler (ladish)
 *
 * Copyright (C) 2010 Nedko Arnaudov <nedko@arnaudov.name>
 *
 **************************************************************************
 * This file contains the code that implements the about dialog
 **************************************************************************
 *
 * LADI Session Handler is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * LADI Session Handler is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
 * or write to the Free Software Foundation, Inc.,
 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>

#include "about.h"
#include "pixbuf.h"
#include "gtk_builder.h"
#include "version.h"

#include "../common/file.h"
#include "../common/catdup.h"

#define ABOUT_DIALOG_LOGO     "ladish-logo-128x128.png"

void show_about(void)
{
  GtkWidget * dialog;
  GdkPixbuf * pixbuf;
  const char * authors[] =
    {
      _("Nedko Arnaudov"),
      _("Nikita Zlobin"),
      _("Filipe Alexandre Lopes Coelho"),
      NULL
    };
  const char * artists[] =
    {
      _("Lapo Calamandrei"),
      _("Nadejda Pancheva-Arnaudova"),
      NULL
    };
  const char * translators_array[] =
    {
      _("Nikita Zlobin"),
      _("Alexandre Prokoudine"),
      _("Olivier Humbert"),
      _("Frank Kober"),
      _("Maxim Kachur"),
      _("Jof Thibaut"),
      NULL,
    };
  char * translators;
  char * license;
  struct stat st;
  char timestamp_str[26];
  char built_str[200];

  pixbuf =  load_pixbuf(ABOUT_DIALOG_LOGO);
  license = read_file_contents(DATA_DIR "/COPYING");

  dialog = get_gtk_builder_widget("about_win");

  st.st_mtime = 0;
  stat("/proc/self/exe", &st);
  ctime_r(&st.st_mtime, timestamp_str);
  timestamp_str[24] = 0;

  sprintf(built_str, _("gladish is built on %s from %s"), timestamp_str, GIT_VERSION);

  gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(dialog), PACKAGE_VERSION);
  gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(dialog), built_str);

  if (pixbuf != NULL)
  {
    gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(dialog), pixbuf);
    g_object_unref(pixbuf);
  }

  if (license != NULL)
  {
    gtk_about_dialog_set_license(GTK_ABOUT_DIALOG(dialog), license);
    free(license);
  }

  gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(dialog), authors);
  gtk_about_dialog_set_artists(GTK_ABOUT_DIALOG(dialog), artists);

  translators = catdup_array(translators_array, "\n");
  if (translators != NULL)
  {
    gtk_about_dialog_set_translator_credits(GTK_ABOUT_DIALOG(dialog), translators);
  }

  gtk_widget_show(dialog);
  gtk_dialog_run(GTK_DIALOG(dialog));
  gtk_widget_hide(dialog);
}