]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/aboutdlg.cpp
rebaked with aboutdlg.* files
[wxWidgets.git] / src / gtk / aboutdlg.cpp
CommitLineData
a11a0ead
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: src/gtk/aboutdlg.cpp
3// Purpose: native GTK+ wxAboutBox() implementation
4// Author: Vadim Zeitlin
5// Created: 2006-10-08
6// RCS-ID: $Id$
7// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
8// Licence: wxWindows licence
9///////////////////////////////////////////////////////////////////////////////
10
11// ============================================================================
12// declarations
13// ============================================================================
14
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
19// for compilers that support precompilation, includes "wx.h".
20#include "wx/wxprec.h"
21
22#if wxUSE_ABOUTDLG && defined(__WXGTK26__)
23
24#ifndef WX_PRECOMP
25#endif //WX_PRECOMP
26
27#include "wx/aboutdlg.h"
28#include "wx/generic/aboutdlgg.h"
29
30#include "wx/gtk/private.h"
31
32// ----------------------------------------------------------------------------
33// GtkArray: temporary array of GTK strings
34// ----------------------------------------------------------------------------
35
36class GtkArray
37{
38public:
39 GtkArray(const wxArrayString& a)
40 {
41 m_count = a.size();
42 m_strings = new const gchar *[m_count + 1];
43 for ( size_t n = 0; n < m_count; n++ )
44 m_strings[n] = wxGTK_CONV_SYS(a[n]).release();
45
46 // array must be NULL-terminated
47 m_strings[m_count] = NULL;
48 }
49
50 operator const gchar **() const { return m_strings; }
51
52 ~GtkArray()
53 {
54 for ( size_t n = 0; n < m_count; n++ )
55 free(wx_const_cast(gchar *, m_strings[n]));
56
57 delete [] m_strings;
58 }
59
60private:
61 const gchar **m_strings;
62 size_t m_count;
63
64 DECLARE_NO_COPY_CLASS(GtkArray)
65};
66
67// ============================================================================
68// implementation
69// ============================================================================
70
71void wxAboutBox(const wxAboutDialogInfo& info)
72{
73 if ( !gtk_check_version(2,6,0) )
74 {
75 GtkAboutDialog * const dlg = GTK_ABOUT_DIALOG(gtk_about_dialog_new());
76 gtk_about_dialog_set_name(dlg, info.GetName());
77 if ( info.HasVersion() )
78 gtk_about_dialog_set_version(dlg, info.GetVersion());
79 if ( info.HasCopyright() )
80 gtk_about_dialog_set_copyright(dlg, info.GetCopyright());
81 if ( info.HasDescription() )
82 gtk_about_dialog_set_comments(dlg, info.GetDescription());
83 if ( info.HasLicence() )
84 gtk_about_dialog_set_license(dlg, info.GetLicence());
85
86 wxIcon icon = info.GetIcon();
87 if ( icon.Ok() )
88 gtk_about_dialog_set_logo(dlg, info.GetIcon().GetPixbuf());
89
90 if ( info.HasWebSite() )
91 {
92 gtk_about_dialog_set_website(dlg, info.GetWebSiteURL());
93 gtk_about_dialog_set_website_label(dlg, info.GetWebSiteDescription());
94 }
95
96 if ( info.HasDevelopers() )
97 gtk_about_dialog_set_authors(dlg, GtkArray(info.GetDevelopers()));
98 if ( info.HasDocWriters() )
99 gtk_about_dialog_set_documenters(dlg, GtkArray(info.GetDocWriters()));
100 if ( info.HasArtists() )
101 gtk_about_dialog_set_artists(dlg, GtkArray(info.GetArtists()));
102 if ( info.HasTranslators() )
103 gtk_about_dialog_set_translator_credits(dlg, _("translator-credits"));
104
105 gtk_widget_show(GTK_WIDGET(dlg));
106 return;
107 }
108
109 // native about dialog not available, fall back to the generic one
110 wxGenericAboutBox(info);
111}
112
113#endif // wxUSE_ABOUTDLG && GTK+ 2.6+