]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/aboutdlg.cpp
added empty virtual dtors to silence gcc warnings
[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
6225e6e1 25 #include "wx/utils.h" // for wxLaunchDefaultBrowser()
a11a0ead
VZ
26#endif //WX_PRECOMP
27
28#include "wx/aboutdlg.h"
29#include "wx/generic/aboutdlgg.h"
30
31#include "wx/gtk/private.h"
32
9b82d31b
VZ
33// ----------------------------------------------------------------------------
34// GtkStr: temporary GTK string
35// ----------------------------------------------------------------------------
36
37class GtkStr : public wxGtkString
38{
39public:
40 GtkStr(const wxString& s)
36183141 41 : wxGtkString(wx_const_cast(char *, wxGTK_CONV_SYS(s).release()))
9b82d31b
VZ
42 {
43 }
44};
45
a11a0ead
VZ
46// ----------------------------------------------------------------------------
47// GtkArray: temporary array of GTK strings
48// ----------------------------------------------------------------------------
49
50class GtkArray
51{
52public:
53 GtkArray(const wxArrayString& a)
54 {
55 m_count = a.size();
56 m_strings = new const gchar *[m_count + 1];
57 for ( size_t n = 0; n < m_count; n++ )
58 m_strings[n] = wxGTK_CONV_SYS(a[n]).release();
59
60 // array must be NULL-terminated
61 m_strings[m_count] = NULL;
62 }
63
64 operator const gchar **() const { return m_strings; }
65
66 ~GtkArray()
67 {
68 for ( size_t n = 0; n < m_count; n++ )
69 free(wx_const_cast(gchar *, m_strings[n]));
70
71 delete [] m_strings;
72 }
73
74private:
75 const gchar **m_strings;
76 size_t m_count;
77
78 DECLARE_NO_COPY_CLASS(GtkArray)
79};
80
81// ============================================================================
82// implementation
83// ============================================================================
84
6225e6e1
VZ
85extern "C" void
86wxGtkAboutDialogOnLink(GtkAboutDialog * WXUNUSED(about),
87 const gchar *link,
88 gpointer WXUNUSED(data))
89{
90 wxLaunchDefaultBrowser(wxGTK_CONV_BACK(link));
91}
92
a11a0ead
VZ
93void wxAboutBox(const wxAboutDialogInfo& info)
94{
95 if ( !gtk_check_version(2,6,0) )
96 {
97 GtkAboutDialog * const dlg = GTK_ABOUT_DIALOG(gtk_about_dialog_new());
9b82d31b 98 gtk_about_dialog_set_name(dlg, GtkStr(info.GetName()));
a11a0ead 99 if ( info.HasVersion() )
9b82d31b 100 gtk_about_dialog_set_version(dlg, GtkStr(info.GetVersion()));
a11a0ead 101 if ( info.HasCopyright() )
9b82d31b 102 gtk_about_dialog_set_copyright(dlg, GtkStr(info.GetCopyright()));
a11a0ead 103 if ( info.HasDescription() )
9b82d31b 104 gtk_about_dialog_set_comments(dlg, GtkStr(info.GetDescription()));
a11a0ead 105 if ( info.HasLicence() )
9b82d31b 106 gtk_about_dialog_set_license(dlg, GtkStr(info.GetLicence()));
a11a0ead
VZ
107
108 wxIcon icon = info.GetIcon();
109 if ( icon.Ok() )
110 gtk_about_dialog_set_logo(dlg, info.GetIcon().GetPixbuf());
111
112 if ( info.HasWebSite() )
113 {
6225e6e1
VZ
114 // NB: must be called before gtk_about_dialog_set_website() as
115 // otherwise it has no effect (although GTK+ docs don't mention
116 // this...)
117 gtk_about_dialog_set_url_hook(wxGtkAboutDialogOnLink, NULL, NULL);
118
9b82d31b
VZ
119 gtk_about_dialog_set_website(dlg, GtkStr(info.GetWebSiteURL()));
120 gtk_about_dialog_set_website_label
121 (
122 dlg,
123 GtkStr(info.GetWebSiteDescription())
124 );
a11a0ead
VZ
125 }
126
127 if ( info.HasDevelopers() )
128 gtk_about_dialog_set_authors(dlg, GtkArray(info.GetDevelopers()));
129 if ( info.HasDocWriters() )
130 gtk_about_dialog_set_documenters(dlg, GtkArray(info.GetDocWriters()));
131 if ( info.HasArtists() )
132 gtk_about_dialog_set_artists(dlg, GtkArray(info.GetArtists()));
fb4f85bf
VZ
133
134 wxString transCredits;
a11a0ead 135 if ( info.HasTranslators() )
9b82d31b 136 {
fb4f85bf
VZ
137 const wxArrayString& translators = info.GetTranslators();
138 const size_t count = translators.size();
139 for ( size_t n = 0; n < count; n++ )
140 {
141 transCredits << translators[n] << _T('\n');
142 }
9b82d31b 143 }
fb4f85bf
VZ
144 else // no translators explicitely specified
145 {
146 // maybe we have translator credits in the message catalog?
147 transCredits = _("translator-credits");
148 }
149
150 gtk_about_dialog_set_translator_credits(dlg, GtkStr(transCredits));
a11a0ead
VZ
151
152 gtk_widget_show(GTK_WIDGET(dlg));
153 return;
154 }
155
156 // native about dialog not available, fall back to the generic one
157 wxGenericAboutBox(info);
158}
159
160#endif // wxUSE_ABOUTDLG && GTK+ 2.6+