~ubuntu-branches/ubuntu/trusty/libxfce4ui/trusty

« back to all changes in this revision

Viewing changes to xfce4-about/main.c

  • Committer: Package Import Robot
  • Author(s): Yves-Alexis Perez
  • Date: 2013-05-21 21:32:57 UTC
  • mfrom: (6.1.3 experimental)
  • Revision ID: package-import@ubuntu.com-20130521213257-q5nqhxkutb9ze4ld
Tags: 4.10.0-2
* Upload to unstable.
* debian/rules:
  - enable all hardening flags.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2010 Xfce Development Team
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2 of the License, or
 
7
 * (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License along
 
15
 * with this program; if not, write to the Free Software Foundation, Inc.,
 
16
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
17
 */
 
18
 
 
19
#ifdef HAVE_CONFIG_H
 
20
#include <config.h>
 
21
#endif
 
22
 
 
23
#ifdef HAVE_STDLIB_H
 
24
#include <stdlib.h>
 
25
#endif
 
26
 
 
27
#include <gtk/gtk.h>
 
28
#include <libxfce4util/libxfce4util.h>
 
29
#include <libxfce4ui/libxfce4ui.h>
 
30
 
 
31
#include "contributors.h"
 
32
#include "translators.h"
 
33
#include "about-dialog-ui.h"
 
34
 
 
35
#define MARGIN 20
 
36
 
 
37
 
 
38
 
 
39
typedef struct
 
40
{
 
41
  const gchar *name;
 
42
  const gchar *display_name;
 
43
  const gchar *description;
 
44
}
 
45
AboutModules;
 
46
 
 
47
 
 
48
 
 
49
static gboolean     opt_version = FALSE;
 
50
static GOptionEntry opt_entries[] =
 
51
{
 
52
  { "version", 'V', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &opt_version, N_("Version information"), NULL },
 
53
  { NULL }
 
54
};
 
55
 
 
56
 
 
57
 
 
58
static void
 
59
xfce_about_about (GtkTextBuffer *buffer)
 
60
{
 
61
  guint                i;
 
62
  AboutModules        *info;
 
63
  GtkTextTag          *bold;
 
64
  GtkTextTag          *indent;
 
65
  GtkTextIter          end;
 
66
  gchar               *str;
 
67
  static AboutModules  xfce_about_info[] =
 
68
    {
 
69
      { "xfwm4",
 
70
        N_("Window Manager"),
 
71
        N_("Handles the placement of windows on the screen.")
 
72
      },
 
73
      { "xfce4-panel",
 
74
        N_("Panel"),
 
75
        N_("Program launchers, window buttons, applications menu, "
 
76
           "workspace switcher and more.")
 
77
      },
 
78
      { "xfdesktop",
 
79
        N_("Desktop Manager"),
 
80
        N_("Sets the background color or image with optional application menu "
 
81
           "or icons for minimized applications or launchers, devices and folders.")
 
82
      },
 
83
      { "thunar",
 
84
        N_("File Manager "),
 
85
        N_("A modern file manager for the Unix/Linux desktop, aiming to "
 
86
           "be easy-to-use and fast.")
 
87
      },
 
88
      { "xfce4-session",
 
89
        N_("Session Manager"),
 
90
        N_("Restores your session on startup and allows you to shutdown "
 
91
           "the computer from Xfce.")
 
92
      },
 
93
      { "xfce4-settings",
 
94
        N_("Setting System"),
 
95
        N_("Configuration system to control various aspects of the desktop "
 
96
           "like appearance, display, keyboard and mouse settings.")
 
97
      },
 
98
      { "xfce4-appfinder",
 
99
        N_("Application Finder"),
 
100
        N_("Shows the applications installed on your system in categories, "
 
101
           "so you can quickly find and launch them.")
 
102
      },
 
103
      { "xfconf",
 
104
        N_("Settings Daemon"),
 
105
        N_("D-Bus-based configuration storage system.")
 
106
      }
 
107
    };
 
108
 
 
109
  g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
 
110
 
 
111
  gtk_text_buffer_insert_at_cursor (buffer,
 
112
      _("Xfce is a collection of programs that together provide a "
 
113
        "full-featured desktop environment. The following programs "
 
114
        "are part of the Xfce core:"), -1);
 
115
  gtk_text_buffer_get_end_iter (buffer, &end);
 
116
 
 
117
  bold = gtk_text_buffer_create_tag (buffer, "bold",
 
118
                                     "weight", PANGO_WEIGHT_BOLD, NULL);
 
119
 
 
120
  indent = gtk_text_buffer_create_tag (buffer, "indent",
 
121
                                       "left-margin", MARGIN, NULL);
 
122
 
 
123
  for (i = 0; i < G_N_ELEMENTS (xfce_about_info); i++)
 
124
    {
 
125
      info = xfce_about_info + i;
 
126
 
 
127
      str = g_strdup_printf ("\n\n%s (%s)\n", _(info->display_name), info->name);
 
128
      gtk_text_buffer_insert_with_tags (buffer, &end, str, -1, bold, NULL);
 
129
      g_free (str);
 
130
 
 
131
      gtk_text_buffer_insert_with_tags (buffer, &end, _(info->description), -1, indent, NULL);
 
132
    }
 
133
 
 
134
  gtk_text_buffer_insert (buffer, &end, "\n\n", -1);
 
135
  gtk_text_buffer_insert (buffer, &end,
 
136
      _("Xfce is also a development platform providing several libraries, "
 
137
        "that help programmers create applications that fit in well "
 
138
        "with the desktop environment."), -1);
 
139
 
 
140
  gtk_text_buffer_insert (buffer, &end, "\n\n", -1);
 
141
  gtk_text_buffer_insert (buffer, &end,
 
142
      _("Xfce components are licensed under free or open source "
 
143
        "licences; GPL or BSDL for applications and LGPL or BSDL for "
 
144
        "libraries. Look at the documentation, the source code or the "
 
145
        "Xfce website (http://www.xfce.org) for more information."), -1);
 
146
 
 
147
  gtk_text_buffer_insert (buffer, &end, "\n\n", -1);
 
148
  gtk_text_buffer_insert (buffer, &end,
 
149
      _("Thank you for your interest in Xfce."), -1);
 
150
 
 
151
  gtk_text_buffer_insert (buffer, &end, "\n\n\t- ", -1);
 
152
  gtk_text_buffer_insert (buffer, &end,
 
153
      _("The Xfce Development Team"), -1);
 
154
 
 
155
  gtk_text_buffer_insert (buffer, &end, "\n", -1);
 
156
}
 
157
 
 
158
 
 
159
 
 
160
static void
 
161
xfce_about_credits_translators (GtkTextBuffer *buffer,
 
162
                                GtkTextIter   *end,
 
163
                                GtkTextTag    *indent,
 
164
                                GtkTextTag    *email)
 
165
{
 
166
  guint                 i;
 
167
  GtkTextTag           *italic;
 
168
  const TranslatorInfo *member;
 
169
  const TranslatorTeam *team;
 
170
  gchar                *str;
 
171
  gboolean              has_member;
 
172
  GtkTextTag           *coordinator;
 
173
 
 
174
  coordinator = gtk_text_buffer_create_tag (buffer, "italic",
 
175
                                            "style", PANGO_STYLE_ITALIC, NULL);
 
176
 
 
177
  for (i = 0; i < G_N_ELEMENTS (xfce_translators); i++)
 
178
    {
 
179
      team = xfce_translators + i;
 
180
 
 
181
      str = g_strdup_printf ("%s [%s]: ", team->name, team->code);
 
182
      gtk_text_buffer_insert_with_tags (buffer, end, str, -1, indent, NULL);
 
183
      g_free (str);
 
184
 
 
185
      has_member = FALSE;
 
186
 
 
187
      for (member = team->members; member->name != NULL; member++)
 
188
        {
 
189
          if (has_member)
 
190
            gtk_text_buffer_insert (buffer, end, ", ", -1);
 
191
 
 
192
          italic = member->is_coordinator ? coordinator : NULL;
 
193
 
 
194
          gtk_text_buffer_insert_with_tags (buffer, end, member->name, -1, italic, NULL);
 
195
          gtk_text_buffer_insert_with_tags (buffer, end, " <", -1, italic, NULL);
 
196
          gtk_text_buffer_insert_with_tags (buffer, end, member->email, -1, email, italic, NULL);
 
197
          gtk_text_buffer_insert_with_tags (buffer, end, ">", -1, italic, NULL);
 
198
 
 
199
          has_member = TRUE;
 
200
        }
 
201
 
 
202
      gtk_text_buffer_insert (buffer, end, "\n", -1);
 
203
    }
 
204
}
 
205
 
 
206
 
 
207
 
 
208
static void
 
209
xfce_about_credits (GtkTextBuffer *buffer)
 
210
{
 
211
  guint                   i;
 
212
  GtkTextTag             *email;
 
213
  GtkTextTag             *title;
 
214
  GtkTextTag             *indent;
 
215
  GtkTextIter             end;
 
216
  const ContributorGroup *group;
 
217
  const ContributorInfo  *user;
 
218
 
 
219
  g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
 
220
 
 
221
  email = gtk_text_buffer_create_tag (buffer, "email",
 
222
                                      "foreground", "blue",
 
223
                                      "underline", PANGO_UNDERLINE_SINGLE, NULL);
 
224
 
 
225
  title = gtk_text_buffer_create_tag (buffer, "title",
 
226
                                      "scale", 1.1,
 
227
                                      "weight", PANGO_WEIGHT_BOLD, NULL);
 
228
 
 
229
  indent = gtk_text_buffer_create_tag (buffer, "indent",
 
230
                                       "left-margin", MARGIN,
 
231
                                       "indent", -MARGIN, NULL);
 
232
 
 
233
  gtk_text_buffer_get_end_iter (buffer, &end);
 
234
 
 
235
  for (i = 0; i < G_N_ELEMENTS (xfce_contributors); i++)
 
236
    {
 
237
      group = xfce_contributors + i;
 
238
 
 
239
      gtk_text_buffer_insert_with_tags (buffer, &end, _(group->name), -1, title, NULL);
 
240
      gtk_text_buffer_insert (buffer, &end, "\n", -1);
 
241
 
 
242
      if (group->contributors != NULL)
 
243
        {
 
244
          for (user = group->contributors; user->name != NULL; user++)
 
245
            {
 
246
              gtk_text_buffer_insert_with_tags (buffer, &end, user->name, -1, indent, NULL);
 
247
              gtk_text_buffer_insert (buffer, &end, " <", -1);
 
248
              gtk_text_buffer_insert_with_tags (buffer, &end, user->email, -1, email, NULL);
 
249
              gtk_text_buffer_insert (buffer, &end, ">\n", -1);
 
250
            }
 
251
        }
 
252
      else
 
253
        {
 
254
          /* add the translators */
 
255
          xfce_about_credits_translators (buffer, &end, indent, email);
 
256
        }
 
257
 
 
258
      gtk_text_buffer_insert (buffer, &end, "\n", -1);
 
259
    }
 
260
 
 
261
  gtk_text_buffer_insert (buffer, &end,
 
262
      _("If you know of anyone missing from this list; don't hesitate and "
 
263
        "file a bug on <http://bugzilla.xfce.org> ."), -1);
 
264
  gtk_text_buffer_insert (buffer, &end, "\n\n", -1);
 
265
  gtk_text_buffer_insert_with_tags (buffer, &end,
 
266
      _("Thanks to all who helped making this software available!"), -1, title, NULL);
 
267
 
 
268
  gtk_text_buffer_insert (buffer, &end, "\n", -1);
 
269
}
 
270
 
 
271
 
 
272
 
 
273
static void
 
274
xfce_about_copyright (GtkTextBuffer *buffer)
 
275
{
 
276
  GtkTextIter end;
 
277
 
 
278
  g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
 
279
 
 
280
  gtk_text_buffer_get_end_iter (buffer, &end);
 
281
 
 
282
  gtk_text_buffer_insert (buffer, &end,
 
283
      _("Xfce 4 is copyright Olivier Fourdan (fourdan@xfce.org). The different "
 
284
        "components are copyrighted by their respective authors."), -1);
 
285
 
 
286
  gtk_text_buffer_insert (buffer, &end, "\n\n", -1);
 
287
  gtk_text_buffer_insert (buffer, &end,
 
288
      _("The libxfce4ui, libxfcegui4, libxfce4util, thunar-vfs and exo packages are "
 
289
        "distributed under the terms of the GNU Library General Public License as "
 
290
        "published by the Free Software Foundation; either version 2 of the License, or "
 
291
        "(at your option) any later version."), -1);
 
292
 
 
293
  gtk_text_buffer_insert (buffer, &end, "\n\n", -1);
 
294
  gtk_text_buffer_insert (buffer, &end,
 
295
      _("The packages thunar, xfce4-appfinder, xfce4-panel, xfce4-session, "
 
296
        "xfce4-settings, xfce-utils, xfconf, xfdesktop and xfwm4 are "
 
297
        "distributed under the terms of the GNU General Public License as "
 
298
        "published by the Free Software Foundation; either version 2 of the "
 
299
        "License, or (at your option) any later version."), -1);
 
300
 
 
301
  gtk_text_buffer_insert (buffer, &end, "\n", -1);
 
302
}
 
303
 
 
304
 
 
305
 
 
306
#ifdef VENDOR_INFO
 
307
static void
 
308
xfce_about_vendor (GtkBuilder *builder)
 
309
{
 
310
  gchar   *contents;
 
311
  gchar   *filename;
 
312
  GObject *object;
 
313
  gsize    length;
 
314
 
 
315
  g_return_if_fail (GTK_IS_BUILDER (builder));
 
316
 
 
317
  filename = g_build_filename (DATADIR, "vendorinfo", NULL);
 
318
  if (g_file_get_contents (filename, &contents, &length, NULL))
 
319
    {
 
320
      if (length > 0)
 
321
        {
 
322
          if (g_utf8_validate(contents, length, NULL))
 
323
            {
 
324
              object = gtk_builder_get_object (builder, "vendor-buffer");
 
325
              gtk_text_buffer_set_text (GTK_TEXT_BUFFER (object), contents, length);
 
326
 
 
327
              object = gtk_builder_get_object (builder, "vendor-label");
 
328
              gtk_label_set_text (GTK_LABEL (object), VENDOR_INFO);
 
329
 
 
330
              object = gtk_builder_get_object (builder, "vendor-tab");
 
331
              gtk_widget_show (GTK_WIDGET (object));
 
332
            }
 
333
          else
 
334
            {
 
335
              g_critical ("\"%s\" is not UTF-8 valid", filename);
 
336
            }
 
337
        }
 
338
 
 
339
      g_free (contents);
 
340
    }
 
341
  else
 
342
    {
 
343
      g_message ("No vendor information found in \"%s\".", filename);
 
344
    }
 
345
 
 
346
  g_free (filename);
 
347
}
 
348
#endif
 
349
 
 
350
 
 
351
 
 
352
static void
 
353
xfce_about_license (GtkBuilder *builder,
 
354
                    GObject    *buffer)
 
355
{
 
356
  GObject         *dialog;
 
357
  GObject         *object;
 
358
  static gboolean  initial = TRUE;
 
359
 
 
360
  g_return_if_fail (GTK_IS_BUILDER (builder));
 
361
  g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
 
362
 
 
363
  object = gtk_builder_get_object (builder, "license-textview");
 
364
  gtk_text_view_set_buffer (GTK_TEXT_VIEW (object), GTK_TEXT_BUFFER (buffer));
 
365
 
 
366
  dialog = gtk_builder_get_object (builder, "license-dialog");
 
367
  if (initial)
 
368
    {
 
369
      g_signal_connect (G_OBJECT (dialog), "delete-event",
 
370
           G_CALLBACK (gtk_widget_hide_on_delete), NULL);
 
371
 
 
372
      object = gtk_builder_get_object (builder, "license-close-button");
 
373
      g_signal_connect_swapped (G_OBJECT (object), "clicked",
 
374
          G_CALLBACK (gtk_widget_hide), dialog);
 
375
 
 
376
      object = gtk_builder_get_object (builder, "window");
 
377
      gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (object));
 
378
 
 
379
      initial = FALSE;
 
380
    }
 
381
 
 
382
  gtk_widget_show (GTK_WIDGET (dialog));
 
383
}
 
384
 
 
385
 
 
386
 
 
387
static void
 
388
xfce_about_license_gpl (GtkBuilder *builder)
 
389
{
 
390
  xfce_about_license (builder,
 
391
      gtk_builder_get_object (builder, "gpl-buffer"));
 
392
}
 
393
 
 
394
 
 
395
 
 
396
static void
 
397
xfce_about_license_lgpl (GtkBuilder *builder)
 
398
{
 
399
  xfce_about_license (builder,
 
400
      gtk_builder_get_object (builder, "lgpl-buffer"));
 
401
}
 
402
 
 
403
 
 
404
 
 
405
static void
 
406
xfce_about_license_bsd (GtkBuilder *builder)
 
407
{
 
408
  xfce_about_license (builder,
 
409
      gtk_builder_get_object (builder, "bsd-buffer"));
 
410
}
 
411
 
 
412
 
 
413
 
 
414
static void
 
415
xfce_about_help (GtkWidget *button,
 
416
                 GtkWidget *dialog)
 
417
{
 
418
  g_return_if_fail (GTK_IS_BUTTON (button));
 
419
  xfce_dialog_show_help (GTK_WINDOW (dialog),
 
420
                         NULL, NULL, NULL);
 
421
}
 
422
 
 
423
 
 
424
 
 
425
gint
 
426
main (gint    argc,
 
427
      gchar **argv)
 
428
{
 
429
  GtkBuilder *builder;
 
430
  GError     *error = NULL;
 
431
  GObject    *dialog;
 
432
  GObject    *object;
 
433
  gchar      *version;
 
434
 
 
435
  xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
 
436
 
 
437
  if (G_UNLIKELY (!gtk_init_with_args (&argc, &argv, NULL, opt_entries, PACKAGE, &error)))
 
438
    {
 
439
      if (G_LIKELY (error != NULL))
 
440
        {
 
441
          g_print ("%s: %s.\n", G_LOG_DOMAIN, error->message);
 
442
          g_print (_("Type '%s --help' for usage information."), G_LOG_DOMAIN);
 
443
          g_print ("\n");
 
444
 
 
445
          g_error_free (error);
 
446
        }
 
447
      else
 
448
        g_error (_("Unable to initialize GTK+."));
 
449
 
 
450
      return EXIT_FAILURE;
 
451
    }
 
452
 
 
453
  if (G_UNLIKELY (opt_version))
 
454
    {
 
455
      g_print ("%s %s (Xfce %s)\n\n", G_LOG_DOMAIN, PACKAGE_VERSION, xfce_version_string ());
 
456
      g_print ("%s\n", "Copyright (c) 2008-2011");
 
457
      g_print ("\t%s\n\n", _("The Xfce development team. All rights reserved."));
 
458
      g_print (_("Please report bugs to <%s>."), PACKAGE_BUGREPORT);
 
459
      g_print ("\n");
 
460
      /* I18N: date/time the translators list was updated */
 
461
      g_print (_("Translators list from %s."), TRANSLATORS_H_STAMP);
 
462
      g_print ("\n");
 
463
 
 
464
      return EXIT_SUCCESS;
 
465
    }
 
466
 
 
467
  builder = gtk_builder_new ();
 
468
  if (!gtk_builder_add_from_string (builder, xfce_about_dialog_ui,
 
469
                                    xfce_about_dialog_ui_length, &error))
 
470
    {
 
471
      xfce_dialog_show_error (NULL, error, _("Failed to load interface"));
 
472
      g_error_free (error);
 
473
      g_object_unref (G_OBJECT (builder));
 
474
 
 
475
      return EXIT_FAILURE;
 
476
    }
 
477
 
 
478
  dialog = gtk_builder_get_object (builder, "window");
 
479
  g_signal_connect_swapped (G_OBJECT (dialog), "delete-event",
 
480
      G_CALLBACK (gtk_main_quit), NULL);
 
481
 
 
482
#ifdef VENDOR_INFO
 
483
  /* I18N: first %s will be replaced by the version, second by
 
484
   * the name of the distribution (--with-vendor-info=NAME) */
 
485
  version = g_strdup_printf (_("Version %s, distributed by %s"),
 
486
                             xfce_version_string (), VENDOR_INFO);
 
487
#else
 
488
  /* I18N: %s will be replaced by the Xfce version number */
 
489
  version = g_strdup_printf (_("Version %s"), xfce_version_string ());
 
490
#endif
 
491
  xfce_titled_dialog_set_subtitle (XFCE_TITLED_DIALOG (dialog), version);
 
492
  g_free (version);
 
493
 
 
494
  object = gtk_builder_get_object (builder, "about-buffer");
 
495
  xfce_about_about (GTK_TEXT_BUFFER (object));
 
496
 
 
497
  object = gtk_builder_get_object (builder, "credits-buffer");
 
498
  xfce_about_credits (GTK_TEXT_BUFFER (object));
 
499
 
 
500
  object = gtk_builder_get_object (builder, "copyright-buffer");
 
501
  xfce_about_copyright (GTK_TEXT_BUFFER (object));
 
502
 
 
503
#ifdef VENDOR_INFO
 
504
  xfce_about_vendor (builder);
 
505
#endif
 
506
 
 
507
  object = gtk_builder_get_object (builder, "gpl-button");
 
508
  g_signal_connect_swapped (G_OBJECT (object), "clicked",
 
509
      G_CALLBACK (xfce_about_license_gpl), builder);
 
510
 
 
511
  object = gtk_builder_get_object (builder, "lgpl-button");
 
512
  g_signal_connect_swapped (G_OBJECT (object), "clicked",
 
513
      G_CALLBACK (xfce_about_license_lgpl), builder);
 
514
 
 
515
  object = gtk_builder_get_object (builder, "bsd-button");
 
516
  g_signal_connect_swapped (G_OBJECT (object), "clicked",
 
517
      G_CALLBACK (xfce_about_license_bsd), builder);
 
518
 
 
519
  object = gtk_builder_get_object (builder, "help-button");
 
520
  g_signal_connect (G_OBJECT (object), "clicked",
 
521
      G_CALLBACK (xfce_about_help), dialog);
 
522
 
 
523
  object = gtk_builder_get_object (builder, "close-button");
 
524
  g_signal_connect_swapped (G_OBJECT (object), "clicked",
 
525
      G_CALLBACK (gtk_main_quit), NULL);
 
526
 
 
527
  gtk_widget_show (GTK_WIDGET (dialog));
 
528
 
 
529
  gtk_main ();
 
530
 
 
531
  g_object_unref (G_OBJECT (builder));
 
532
 
 
533
  return EXIT_SUCCESS;
 
534
}