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__)
27 #include "wx/aboutdlg.h"
28 #include "wx/generic/aboutdlgg.h"
30 #include "wx/gtk/private.h"
32 // ----------------------------------------------------------------------------
33 // GtkStr: temporary GTK string
34 // ----------------------------------------------------------------------------
36 class GtkStr
: public wxGtkString
39 GtkStr(const wxString
& s
)
40 : wxGtkString(wx_const_cast(char *, wxGTK_CONV_SYS(s
).data()))
45 // ----------------------------------------------------------------------------
46 // GtkArray: temporary array of GTK strings
47 // ----------------------------------------------------------------------------
52 GtkArray(const wxArrayString
& a
)
55 m_strings
= new const gchar
*[m_count
+ 1];
56 for ( size_t n
= 0; n
< m_count
; n
++ )
57 m_strings
[n
] = wxGTK_CONV_SYS(a
[n
]).release();
59 // array must be NULL-terminated
60 m_strings
[m_count
] = NULL
;
63 operator const gchar
**() const { return m_strings
; }
67 for ( size_t n
= 0; n
< m_count
; n
++ )
68 free(wx_const_cast(gchar
*, m_strings
[n
]));
74 const gchar
**m_strings
;
77 DECLARE_NO_COPY_CLASS(GtkArray
)
80 // ============================================================================
82 // ============================================================================
84 void wxAboutBox(const wxAboutDialogInfo
& info
)
86 if ( !gtk_check_version(2,6,0) )
88 GtkAboutDialog
* const dlg
= GTK_ABOUT_DIALOG(gtk_about_dialog_new());
89 gtk_about_dialog_set_name(dlg
, GtkStr(info
.GetName()));
90 if ( info
.HasVersion() )
91 gtk_about_dialog_set_version(dlg
, GtkStr(info
.GetVersion()));
92 if ( info
.HasCopyright() )
93 gtk_about_dialog_set_copyright(dlg
, GtkStr(info
.GetCopyright()));
94 if ( info
.HasDescription() )
95 gtk_about_dialog_set_comments(dlg
, GtkStr(info
.GetDescription()));
96 if ( info
.HasLicence() )
97 gtk_about_dialog_set_license(dlg
, GtkStr(info
.GetLicence()));
99 wxIcon icon
= info
.GetIcon();
101 gtk_about_dialog_set_logo(dlg
, info
.GetIcon().GetPixbuf());
103 if ( info
.HasWebSite() )
105 gtk_about_dialog_set_website(dlg
, GtkStr(info
.GetWebSiteURL()));
106 gtk_about_dialog_set_website_label
109 GtkStr(info
.GetWebSiteDescription())
113 if ( info
.HasDevelopers() )
114 gtk_about_dialog_set_authors(dlg
, GtkArray(info
.GetDevelopers()));
115 if ( info
.HasDocWriters() )
116 gtk_about_dialog_set_documenters(dlg
, GtkArray(info
.GetDocWriters()));
117 if ( info
.HasArtists() )
118 gtk_about_dialog_set_artists(dlg
, GtkArray(info
.GetArtists()));
119 if ( info
.HasTranslators() )
121 gtk_about_dialog_set_translator_credits
124 GtkStr(_("translator-credits"))
128 gtk_widget_show(GTK_WIDGET(dlg
));
132 // native about dialog not available, fall back to the generic one
133 wxGenericAboutBox(info
);
136 #endif // wxUSE_ABOUTDLG && GTK+ 2.6+