1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/aboutdlg.cpp
3 // Purpose: native GTK+ wxAboutBox() implementation
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
22 #if wxUSE_ABOUTDLG && defined(__WXGTK26__)
25 #include "wx/utils.h" // for wxLaunchDefaultBrowser()
28 #include "wx/aboutdlg.h"
29 #include "wx/generic/aboutdlgg.h"
31 #include "wx/gtk/private.h"
33 // ----------------------------------------------------------------------------
34 // GtkArray: temporary array of GTK strings
35 // ----------------------------------------------------------------------------
40 // Create GtkArray from wxArrayString. Note that the created object is
41 // only valid as long as 'a' is!
42 GtkArray(const wxArrayString
& a
)
45 m_strings
= new const gchar
*[m_count
+ 1];
47 for ( size_t n
= 0; n
< m_count
; n
++ )
49 #if wxUSE_UNICODE_UTF8
50 m_strings
[n
] = a
[n
].utf8_str();
52 m_strings
[n
] = wxGTK_CONV_SYS(a
[n
]).release();
56 // array must be NULL-terminated
57 m_strings
[m_count
] = NULL
;
60 operator const gchar
**() const { return m_strings
; }
64 #if !wxUSE_UNICODE_UTF8
65 for ( size_t n
= 0; n
< m_count
; n
++ )
66 free(wx_const_cast(gchar
*, m_strings
[n
]));
73 const gchar
**m_strings
;
76 DECLARE_NO_COPY_CLASS(GtkArray
)
79 // ============================================================================
81 // ============================================================================
84 wxGtkAboutDialogOnClose(GtkAboutDialog
*about
)
86 gtk_widget_destroy(GTK_WIDGET(about
));
90 wxGtkAboutDialogOnLink(GtkAboutDialog
* WXUNUSED(about
),
92 gpointer
WXUNUSED(data
))
94 wxLaunchDefaultBrowser(wxGTK_CONV_BACK_SYS(link
));
97 void wxAboutBox(const wxAboutDialogInfo
& info
)
99 if ( !gtk_check_version(2,6,0) )
101 GtkAboutDialog
* const dlg
= GTK_ABOUT_DIALOG(gtk_about_dialog_new());
102 gtk_about_dialog_set_name(dlg
, wxGTK_CONV(info
.GetName()));
103 if ( info
.HasVersion() )
104 gtk_about_dialog_set_version(dlg
, wxGTK_CONV(info
.GetVersion()));
105 if ( info
.HasCopyright() )
106 gtk_about_dialog_set_copyright(dlg
, wxGTK_CONV(info
.GetCopyright()));
107 if ( info
.HasDescription() )
108 gtk_about_dialog_set_comments(dlg
, wxGTK_CONV(info
.GetDescription()));
109 if ( info
.HasLicence() )
110 gtk_about_dialog_set_license(dlg
, wxGTK_CONV(info
.GetLicence()));
112 wxIcon icon
= info
.GetIcon();
114 gtk_about_dialog_set_logo(dlg
, info
.GetIcon().GetPixbuf());
116 if ( info
.HasWebSite() )
118 // NB: must be called before gtk_about_dialog_set_website() as
119 // otherwise it has no effect (although GTK+ docs don't mention
121 gtk_about_dialog_set_url_hook(wxGtkAboutDialogOnLink
, NULL
, NULL
);
123 gtk_about_dialog_set_website(dlg
, wxGTK_CONV(info
.GetWebSiteURL()));
124 gtk_about_dialog_set_website_label
127 wxGTK_CONV(info
.GetWebSiteDescription())
131 if ( info
.HasDevelopers() )
132 gtk_about_dialog_set_authors(dlg
, GtkArray(info
.GetDevelopers()));
133 if ( info
.HasDocWriters() )
134 gtk_about_dialog_set_documenters(dlg
, GtkArray(info
.GetDocWriters()));
135 if ( info
.HasArtists() )
136 gtk_about_dialog_set_artists(dlg
, GtkArray(info
.GetArtists()));
138 wxString transCredits
;
139 if ( info
.HasTranslators() )
141 const wxArrayString
& translators
= info
.GetTranslators();
142 const size_t count
= translators
.size();
143 for ( size_t n
= 0; n
< count
; n
++ )
145 transCredits
<< translators
[n
] << _T('\n');
148 else // no translators explicitely specified
150 // maybe we have translator credits in the message catalog?
151 wxString translator
= _("translator-credits");
153 // gtk_about_dialog_set_translator_credits() is smart enough to
154 // detect if "translator-credits" is untranslated and hide the
155 // translators tab in that case, however it will still show the
156 // "credits" button, (at least GTK 2.10.6) even if there are no
157 // credits informations at all, so we still need to do the check
159 if ( translator
!= wxT("translator-credits") ) // untranslated!
160 transCredits
= translator
;
163 if ( !transCredits
.empty() )
164 gtk_about_dialog_set_translator_credits(dlg
, wxGTK_CONV(transCredits
));
166 g_signal_connect(dlg
, "response",
167 G_CALLBACK(wxGtkAboutDialogOnClose
), NULL
);
169 gtk_widget_show(GTK_WIDGET(dlg
));
173 // native about dialog not available, fall back to the generic one
174 wxGenericAboutBox(info
);
177 #endif // wxUSE_ABOUTDLG && GTK+ 2.6+