1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.AboutDialog;
26 
27 private import gdk.PaintableIF;
28 private import glib.ConstructionException;
29 private import glib.Str;
30 private import glib.c.functions;
31 private import gobject.ObjectG;
32 private import gobject.Signals;
33 private import gtk.Widget;
34 private import gtk.Window;
35 private import gtk.c.functions;
36 public  import gtk.c.types;
37 private import std.algorithm;
38 
39 
40 /**
41  * The `GtkAboutDialog` offers a simple way to display information about
42  * a program.
43  * 
44  * The shown information includes the programs' logo, name, copyright,
45  * website and license. It is also possible to give credits to the authors,
46  * documenters, translators and artists who have worked on the program.
47  * 
48  * An about dialog is typically opened when the user selects the `About`
49  * option from the `Help` menu. All parts of the dialog are optional.
50  * 
51  * ![An example GtkAboutDialog](aboutdialog.png)
52  * 
53  * About dialogs often contain links and email addresses. `GtkAboutDialog`
54  * displays these as clickable links. By default, it calls [func@Gtk.show_uri]
55  * when a user clicks one. The behaviour can be overridden with the
56  * [signal@Gtk.AboutDialog::activate-link] signal.
57  * 
58  * To specify a person with an email address, use a string like
59  * `Edgar Allan Poe <edgar@poe.com>`. To specify a website with a title,
60  * use a string like `GTK team https://www.gtk.org`.
61  * 
62  * To make constructing a `GtkAboutDialog` as convenient as possible, you can
63  * use the function [func@Gtk.show_about_dialog] which constructs and shows
64  * a dialog and keeps it around so that it can be shown again.
65  * 
66  * Note that GTK sets a default title of `_("About %s")` on the dialog
67  * window (where `%s` is replaced by the name of the application, but in
68  * order to ensure proper translation of the title, applications should
69  * set the title property explicitly when constructing a `GtkAboutDialog`,
70  * as shown in the following example:
71  * 
72  * ```c
73  * GFile *logo_file = g_file_new_for_path ("./logo.png");
74  * GdkTexture *example_logo = gdk_texture_new_from_file (logo_file, NULL);
75  * g_object_unref (logo_file);
76  * 
77  * gtk_show_about_dialog (NULL,
78  * "program-name", "ExampleCode",
79  * "logo", example_logo,
80  * "title", _("About ExampleCode"),
81  * NULL);
82  * ```
83  * 
84  * ## CSS nodes
85  * 
86  * `GtkAboutDialog` has a single CSS node with the name `window` and style
87  * class `.aboutdialog`.
88  */
89 public class AboutDialog : Window
90 {
91 	/** the main Gtk struct */
92 	protected GtkAboutDialog* gtkAboutDialog;
93 
94 	/** Get the main Gtk struct */
95 	public GtkAboutDialog* getAboutDialogStruct(bool transferOwnership = false)
96 	{
97 		if (transferOwnership)
98 			ownedRef = false;
99 		return gtkAboutDialog;
100 	}
101 
102 	/** the main Gtk struct as a void* */
103 	protected override void* getStruct()
104 	{
105 		return cast(void*)gtkAboutDialog;
106 	}
107 
108 	/**
109 	 * Sets our main struct and passes it to the parent class.
110 	 */
111 	public this (GtkAboutDialog* gtkAboutDialog, bool ownedRef = false)
112 	{
113 		this.gtkAboutDialog = gtkAboutDialog;
114 		super(cast(GtkWindow*)gtkAboutDialog, ownedRef);
115 	}
116 
117 
118 	/** */
119 	public static GType getType()
120 	{
121 		return gtk_about_dialog_get_type();
122 	}
123 
124 	/**
125 	 * Creates a new `GtkAboutDialog`.
126 	 *
127 	 * Returns: a newly created `GtkAboutDialog`
128 	 *
129 	 * Throws: ConstructionException GTK+ fails to create the object.
130 	 */
131 	public this()
132 	{
133 		auto __p = gtk_about_dialog_new();
134 
135 		if(__p is null)
136 		{
137 			throw new ConstructionException("null returned by new");
138 		}
139 
140 		this(cast(GtkAboutDialog*) __p);
141 	}
142 
143 	/**
144 	 * Creates a new section in the "Credits" page.
145 	 *
146 	 * Params:
147 	 *     sectionName = The name of the section
148 	 *     people = The people who belong to that section
149 	 */
150 	public void addCreditSection(string sectionName, string[] people)
151 	{
152 		gtk_about_dialog_add_credit_section(gtkAboutDialog, Str.toStringz(sectionName), Str.toStringzArray(people));
153 	}
154 
155 	/**
156 	 * Returns the string which are displayed in the "Artists" tab
157 	 * of the secondary credits dialog.
158 	 *
159 	 * Returns: A
160 	 *     `NULL`-terminated string array containing the artists. The array is
161 	 *     owned by the about dialog and must not be modified.
162 	 */
163 	public string[] getArtists()
164 	{
165 		return Str.toStringArray(gtk_about_dialog_get_artists(gtkAboutDialog));
166 	}
167 
168 	/**
169 	 * Returns the string which are displayed in the authors tab
170 	 * of the secondary credits dialog.
171 	 *
172 	 * Returns: A
173 	 *     `NULL`-terminated string array containing the authors. The array is
174 	 *     owned by the about dialog and must not be modified.
175 	 */
176 	public string[] getAuthors()
177 	{
178 		return Str.toStringArray(gtk_about_dialog_get_authors(gtkAboutDialog));
179 	}
180 
181 	/**
182 	 * Returns the comments string.
183 	 *
184 	 * Returns: The comments. The string is owned by the about
185 	 *     dialog and must not be modified.
186 	 */
187 	public string getComments()
188 	{
189 		return Str.toString(gtk_about_dialog_get_comments(gtkAboutDialog));
190 	}
191 
192 	/**
193 	 * Returns the copyright string.
194 	 *
195 	 * Returns: The copyright string. The string is owned by the about
196 	 *     dialog and must not be modified.
197 	 */
198 	public string getCopyright()
199 	{
200 		return Str.toString(gtk_about_dialog_get_copyright(gtkAboutDialog));
201 	}
202 
203 	/**
204 	 * Returns the string which are displayed in the "Documenters"
205 	 * tab of the secondary credits dialog.
206 	 *
207 	 * Returns: A
208 	 *     `NULL`-terminated string array containing the documenters. The
209 	 *     array is owned by the about dialog and must not be modified.
210 	 */
211 	public string[] getDocumenters()
212 	{
213 		return Str.toStringArray(gtk_about_dialog_get_documenters(gtkAboutDialog));
214 	}
215 
216 	/**
217 	 * Returns the license information.
218 	 *
219 	 * Returns: The license information. The string is owned by the about
220 	 *     dialog and must not be modified.
221 	 */
222 	public string getLicense()
223 	{
224 		return Str.toString(gtk_about_dialog_get_license(gtkAboutDialog));
225 	}
226 
227 	/**
228 	 * Retrieves the license type.
229 	 *
230 	 * Returns: a [enum@Gtk.License] value
231 	 */
232 	public GtkLicense getLicenseType()
233 	{
234 		return gtk_about_dialog_get_license_type(gtkAboutDialog);
235 	}
236 
237 	/**
238 	 * Returns the paintable displayed as logo in the about dialog.
239 	 *
240 	 * Returns: the paintable displayed as
241 	 *     logo or `NULL` if the logo is unset or has been set via
242 	 *     [method@Gtk.AboutDialog.set_logo_icon_name]. The
243 	 *     paintable is owned by the about dialog.
244 	 */
245 	public PaintableIF getLogo()
246 	{
247 		auto __p = gtk_about_dialog_get_logo(gtkAboutDialog);
248 
249 		if(__p is null)
250 		{
251 			return null;
252 		}
253 
254 		return ObjectG.getDObject!(PaintableIF)(cast(GdkPaintable*) __p);
255 	}
256 
257 	/**
258 	 * Returns the icon name displayed as logo in the about dialog.
259 	 *
260 	 * Returns: the icon name displayed as logo,
261 	 *     or `NULL` if the logo has been set via [method@Gtk.AboutDialog.set_logo].
262 	 *     The string is owned by the dialog.
263 	 */
264 	public string getLogoIconName()
265 	{
266 		return Str.toString(gtk_about_dialog_get_logo_icon_name(gtkAboutDialog));
267 	}
268 
269 	/**
270 	 * Returns the program name displayed in the about dialog.
271 	 *
272 	 * Returns: The program name. The string is owned by the about
273 	 *     dialog and must not be modified.
274 	 */
275 	public string getProgramName()
276 	{
277 		return Str.toString(gtk_about_dialog_get_program_name(gtkAboutDialog));
278 	}
279 
280 	/**
281 	 * Returns the system information that is shown in the about dialog.
282 	 *
283 	 * Returns: the system information
284 	 */
285 	public string getSystemInformation()
286 	{
287 		return Str.toString(gtk_about_dialog_get_system_information(gtkAboutDialog));
288 	}
289 
290 	/**
291 	 * Returns the translator credits string which is displayed
292 	 * in the translators tab of the secondary credits dialog.
293 	 *
294 	 * Returns: The translator credits string.
295 	 */
296 	public string getTranslatorCredits()
297 	{
298 		return Str.toString(gtk_about_dialog_get_translator_credits(gtkAboutDialog));
299 	}
300 
301 	/**
302 	 * Returns the version string.
303 	 *
304 	 * Returns: The version string. The string is owned by the about
305 	 *     dialog and must not be modified.
306 	 */
307 	public string getVersion()
308 	{
309 		return Str.toString(gtk_about_dialog_get_version(gtkAboutDialog));
310 	}
311 
312 	/**
313 	 * Returns the website URL.
314 	 *
315 	 * Returns: The website URL
316 	 */
317 	public string getWebsite()
318 	{
319 		return Str.toString(gtk_about_dialog_get_website(gtkAboutDialog));
320 	}
321 
322 	/**
323 	 * Returns the label used for the website link.
324 	 *
325 	 * Returns: The label used for the website link.
326 	 */
327 	public string getWebsiteLabel()
328 	{
329 		return Str.toString(gtk_about_dialog_get_website_label(gtkAboutDialog));
330 	}
331 
332 	/**
333 	 * Returns whether the license text in the about dialog is
334 	 * automatically wrapped.
335 	 *
336 	 * Returns: `TRUE` if the license text is wrapped
337 	 */
338 	public bool getWrapLicense()
339 	{
340 		return gtk_about_dialog_get_wrap_license(gtkAboutDialog) != 0;
341 	}
342 
343 	/**
344 	 * Sets the strings which are displayed in the "Artists" tab
345 	 * of the secondary credits dialog.
346 	 *
347 	 * Params:
348 	 *     artists = the authors of the artwork
349 	 *         of the application
350 	 */
351 	public void setArtists(string[] artists)
352 	{
353 		gtk_about_dialog_set_artists(gtkAboutDialog, Str.toStringzArray(artists));
354 	}
355 
356 	/**
357 	 * Sets the strings which are displayed in the "Authors" tab
358 	 * of the secondary credits dialog.
359 	 *
360 	 * Params:
361 	 *     authors = the authors of the application
362 	 */
363 	public void setAuthors(string[] authors)
364 	{
365 		gtk_about_dialog_set_authors(gtkAboutDialog, Str.toStringzArray(authors));
366 	}
367 
368 	/**
369 	 * Sets the comments string to display in the about dialog.
370 	 *
371 	 * This should be a short string of one or two lines.
372 	 *
373 	 * Params:
374 	 *     comments = a comments string
375 	 */
376 	public void setComments(string comments)
377 	{
378 		gtk_about_dialog_set_comments(gtkAboutDialog, Str.toStringz(comments));
379 	}
380 
381 	/**
382 	 * Sets the copyright string to display in the about dialog.
383 	 *
384 	 * This should be a short string of one or two lines.
385 	 *
386 	 * Params:
387 	 *     copyright = the copyright string
388 	 */
389 	public void setCopyright(string copyright)
390 	{
391 		gtk_about_dialog_set_copyright(gtkAboutDialog, Str.toStringz(copyright));
392 	}
393 
394 	/**
395 	 * Sets the strings which are displayed in the "Documenters" tab
396 	 * of the credits dialog.
397 	 *
398 	 * Params:
399 	 *     documenters = the authors of the documentation
400 	 *         of the application
401 	 */
402 	public void setDocumenters(string[] documenters)
403 	{
404 		gtk_about_dialog_set_documenters(gtkAboutDialog, Str.toStringzArray(documenters));
405 	}
406 
407 	/**
408 	 * Sets the license information to be displayed in the secondary
409 	 * license dialog.
410 	 *
411 	 * If `license` is `NULL`, the license button is hidden.
412 	 *
413 	 * Params:
414 	 *     license = the license information
415 	 */
416 	public void setLicense(string license)
417 	{
418 		gtk_about_dialog_set_license(gtkAboutDialog, Str.toStringz(license));
419 	}
420 
421 	/**
422 	 * Sets the license of the application showing the about dialog from a
423 	 * list of known licenses.
424 	 *
425 	 * This function overrides the license set using
426 	 * [method@Gtk.AboutDialog.set_license].
427 	 *
428 	 * Params:
429 	 *     licenseType = the type of license
430 	 */
431 	public void setLicenseType(GtkLicense licenseType)
432 	{
433 		gtk_about_dialog_set_license_type(gtkAboutDialog, licenseType);
434 	}
435 
436 	/**
437 	 * Sets the logo in the about dialog.
438 	 *
439 	 * Params:
440 	 *     logo = a `GdkPaintable`
441 	 */
442 	public void setLogo(PaintableIF logo)
443 	{
444 		gtk_about_dialog_set_logo(gtkAboutDialog, (logo is null) ? null : logo.getPaintableStruct());
445 	}
446 
447 	/**
448 	 * Sets the icon name to be displayed as logo in the about dialog.
449 	 *
450 	 * Params:
451 	 *     iconName = an icon name
452 	 */
453 	public void setLogoIconName(string iconName)
454 	{
455 		gtk_about_dialog_set_logo_icon_name(gtkAboutDialog, Str.toStringz(iconName));
456 	}
457 
458 	/**
459 	 * Sets the name to display in the about dialog.
460 	 *
461 	 * If `name` is not set, it defaults to `g_get_application_name()`.
462 	 *
463 	 * Params:
464 	 *     name = the program name
465 	 */
466 	public void setProgramName(string name)
467 	{
468 		gtk_about_dialog_set_program_name(gtkAboutDialog, Str.toStringz(name));
469 	}
470 
471 	/**
472 	 * Sets the system information to be displayed in the about
473 	 * dialog.
474 	 *
475 	 * If `system_information` is `NULL`, the system information
476 	 * tab is hidden.
477 	 *
478 	 * See [property@Gtk.AboutDialog:system-information].
479 	 *
480 	 * Params:
481 	 *     systemInformation = system information
482 	 */
483 	public void setSystemInformation(string systemInformation)
484 	{
485 		gtk_about_dialog_set_system_information(gtkAboutDialog, Str.toStringz(systemInformation));
486 	}
487 
488 	/**
489 	 * Sets the translator credits string which is displayed in
490 	 * the translators tab of the secondary credits dialog.
491 	 *
492 	 * The intended use for this string is to display the translator
493 	 * of the language which is currently used in the user interface.
494 	 * Using `gettext()`, a simple way to achieve that is to mark the
495 	 * string for translation:
496 	 *
497 	 * ```c
498 	 * GtkWidget *about = gtk_about_dialog_new ();
499 	 * gtk_about_dialog_set_translator_credits (GTK_ABOUT_DIALOG (about),
500 	 * _("translator-credits"));
501 	 * ```
502 	 *
503 	 * It is a good idea to use the customary `msgid` “translator-credits” for this
504 	 * purpose, since translators will already know the purpose of that `msgid`, and
505 	 * since `GtkAboutDialog` will detect if “translator-credits” is untranslated
506 	 * and hide the tab.
507 	 *
508 	 * Params:
509 	 *     translatorCredits = the translator credits
510 	 */
511 	public void setTranslatorCredits(string translatorCredits)
512 	{
513 		gtk_about_dialog_set_translator_credits(gtkAboutDialog, Str.toStringz(translatorCredits));
514 	}
515 
516 	/**
517 	 * Sets the version string to display in the about dialog.
518 	 *
519 	 * Params:
520 	 *     version_ = the version string
521 	 */
522 	public void setVersion(string version_)
523 	{
524 		gtk_about_dialog_set_version(gtkAboutDialog, Str.toStringz(version_));
525 	}
526 
527 	/**
528 	 * Sets the URL to use for the website link.
529 	 *
530 	 * Params:
531 	 *     website = a URL string starting with `http://`
532 	 */
533 	public void setWebsite(string website)
534 	{
535 		gtk_about_dialog_set_website(gtkAboutDialog, Str.toStringz(website));
536 	}
537 
538 	/**
539 	 * Sets the label to be used for the website link.
540 	 *
541 	 * Params:
542 	 *     websiteLabel = the label used for the website link
543 	 */
544 	public void setWebsiteLabel(string websiteLabel)
545 	{
546 		gtk_about_dialog_set_website_label(gtkAboutDialog, Str.toStringz(websiteLabel));
547 	}
548 
549 	/**
550 	 * Sets whether the license text in the about dialog should be
551 	 * automatically wrapped.
552 	 *
553 	 * Params:
554 	 *     wrapLicense = whether to wrap the license
555 	 */
556 	public void setWrapLicense(bool wrapLicense)
557 	{
558 		gtk_about_dialog_set_wrap_license(gtkAboutDialog, wrapLicense);
559 	}
560 
561 	/**
562 	 * Emitted every time a URL is activated.
563 	 *
564 	 * Applications may connect to it to override the default behaviour,
565 	 * which is to call [func@Gtk.show_uri].
566 	 *
567 	 * Params:
568 	 *     uri = the URI that is activated
569 	 *
570 	 * Returns: `TRUE` if the link has been activated
571 	 */
572 	gulong addOnActivateLink(bool delegate(string, AboutDialog) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
573 	{
574 		return Signals.connect(this, "activate-link", dlg, connectFlags ^ ConnectFlags.SWAPPED);
575 	}
576 }