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 gdkpixbuf.Pixbuf;
28 private import glib.ConstructionException;
29 private import glib.Str;
30 private import gobject.ObjectG;
31 private import gobject.Signals;
32 private import gtk.Dialog;
33 private import gtk.Widget;
34 private import gtk.Window;
35 public  import gtkc.gdktypes;
36 private import gtkc.gtk;
37 public  import gtkc.gtktypes;
38 
39 
40 /**
41  * The GtkAboutDialog offers a simple way to display information about
42  * a program like its logo, name, copyright, website and license. It is
43  * also possible to give credits to the authors, documenters, translators
44  * and artists who have worked on the program. An about dialog is typically
45  * opened when the user selects the `About` option from the `Help` menu.
46  * All parts of the dialog are optional.
47  * 
48  * About dialogs often contain links and email addresses. GtkAboutDialog
49  * displays these as clickable links. By default, it calls gtk_show_uri()
50  * when a user clicks one. The behaviour can be overridden with the
51  * #GtkAboutDialog::activate-link signal.
52  * 
53  * To specify a person with an email address, use a string like
54  * "Edgar Allan Poe <edgar@poe.com>". To specify a website with a title,
55  * use a string like "GTK+ team http://www.gtk.org".
56  * 
57  * To make constructing a GtkAboutDialog as convenient as possible, you can
58  * use the function gtk_show_about_dialog() which constructs and shows a dialog
59  * and keeps it around so that it can be shown again.
60  * 
61  * Note that GTK+ sets a default title of `_("About %s")` on the dialog
62  * window (where \%s is replaced by the name of the application, but in
63  * order to ensure proper translation of the title, applications should
64  * set the title property explicitly when constructing a GtkAboutDialog,
65  * as shown in the following example:
66  * |[<!-- language="C" -->
67  * gtk_show_about_dialog (NULL,
68  * "program-name", "ExampleCode",
69  * "logo", example_logo,
70  * "title" _("About ExampleCode"),
71  * NULL);
72  * ]|
73  * 
74  * It is also possible to show a #GtkAboutDialog like any other #GtkDialog,
75  * e.g. using gtk_dialog_run(). In this case, you might need to know that
76  * the “Close” button returns the #GTK_RESPONSE_CANCEL response id.
77  */
78 public class AboutDialog : Dialog
79 {
80 	/** the main Gtk struct */
81 	protected GtkAboutDialog* gtkAboutDialog;
82 
83 	/** Get the main Gtk struct */
84 	public GtkAboutDialog* getAboutDialogStruct()
85 	{
86 		return gtkAboutDialog;
87 	}
88 
89 	/** the main Gtk struct as a void* */
90 	protected override void* getStruct()
91 	{
92 		return cast(void*)gtkAboutDialog;
93 	}
94 
95 	protected override void setStruct(GObject* obj)
96 	{
97 		gtkAboutDialog = cast(GtkAboutDialog*)obj;
98 		super.setStruct(obj);
99 	}
100 
101 	/**
102 	 * Sets our main struct and passes it to the parent class.
103 	 */
104 	public this (GtkAboutDialog* gtkAboutDialog, bool ownedRef = false)
105 	{
106 		this.gtkAboutDialog = gtkAboutDialog;
107 		super(cast(GtkDialog*)gtkAboutDialog, ownedRef);
108 	}
109 
110 
111 	/** */
112 	public static GType getType()
113 	{
114 		return gtk_about_dialog_get_type();
115 	}
116 
117 	/**
118 	 * Creates a new #GtkAboutDialog.
119 	 *
120 	 * Return: a newly created #GtkAboutDialog
121 	 *
122 	 * Since: 2.6
123 	 *
124 	 * Throws: ConstructionException GTK+ fails to create the object.
125 	 */
126 	public this()
127 	{
128 		auto p = gtk_about_dialog_new();
129 		
130 		if(p is null)
131 		{
132 			throw new ConstructionException("null returned by new");
133 		}
134 		
135 		this(cast(GtkAboutDialog*) p);
136 	}
137 
138 	/**
139 	 * Creates a new section in the Credits page.
140 	 *
141 	 * Params:
142 	 *     sectionName = The name of the section
143 	 *     people = The people who belong to that section
144 	 *
145 	 * Since: 3.4
146 	 */
147 	public void addCreditSection(string sectionName, string[] people)
148 	{
149 		gtk_about_dialog_add_credit_section(gtkAboutDialog, Str.toStringz(sectionName), Str.toStringzArray(people));
150 	}
151 
152 	/**
153 	 * Returns the string which are displayed in the artists tab
154 	 * of the secondary credits dialog.
155 	 *
156 	 * Return: A
157 	 *     %NULL-terminated string array containing the artists. The array is
158 	 *     owned by the about dialog and must not be modified.
159 	 *
160 	 * Since: 2.6
161 	 */
162 	public string[] getArtists()
163 	{
164 		return Str.toStringArray(gtk_about_dialog_get_artists(gtkAboutDialog));
165 	}
166 
167 	/**
168 	 * Returns the string which are displayed in the authors tab
169 	 * of the secondary credits dialog.
170 	 *
171 	 * Return: A
172 	 *     %NULL-terminated string array containing the authors. The array is
173 	 *     owned by the about dialog and must not be modified.
174 	 *
175 	 * Since: 2.6
176 	 */
177 	public string[] getAuthors()
178 	{
179 		return Str.toStringArray(gtk_about_dialog_get_authors(gtkAboutDialog));
180 	}
181 
182 	/**
183 	 * Returns the comments string.
184 	 *
185 	 * Return: The comments. The string is owned by the about
186 	 *     dialog and must not be modified.
187 	 *
188 	 * Since: 2.6
189 	 */
190 	public string getComments()
191 	{
192 		return Str.toString(gtk_about_dialog_get_comments(gtkAboutDialog));
193 	}
194 
195 	/**
196 	 * Returns the copyright string.
197 	 *
198 	 * Return: The copyright string. The string is owned by the about
199 	 *     dialog and must not be modified.
200 	 *
201 	 * Since: 2.6
202 	 */
203 	public string getCopyright()
204 	{
205 		return Str.toString(gtk_about_dialog_get_copyright(gtkAboutDialog));
206 	}
207 
208 	/**
209 	 * Returns the string which are displayed in the documenters
210 	 * tab of the secondary credits dialog.
211 	 *
212 	 * Return: A
213 	 *     %NULL-terminated string array containing the documenters. The
214 	 *     array is owned by the about dialog and must not be modified.
215 	 *
216 	 * Since: 2.6
217 	 */
218 	public string[] getDocumenters()
219 	{
220 		return Str.toStringArray(gtk_about_dialog_get_documenters(gtkAboutDialog));
221 	}
222 
223 	/**
224 	 * Returns the license information.
225 	 *
226 	 * Return: The license information. The string is owned by the about
227 	 *     dialog and must not be modified.
228 	 *
229 	 * Since: 2.6
230 	 */
231 	public string getLicense()
232 	{
233 		return Str.toString(gtk_about_dialog_get_license(gtkAboutDialog));
234 	}
235 
236 	/**
237 	 * Retrieves the license set using gtk_about_dialog_set_license_type()
238 	 *
239 	 * Return: a #GtkLicense value
240 	 *
241 	 * Since: 3.0
242 	 */
243 	public GtkLicense getLicenseType()
244 	{
245 		return gtk_about_dialog_get_license_type(gtkAboutDialog);
246 	}
247 
248 	/**
249 	 * Returns the pixbuf displayed as logo in the about dialog.
250 	 *
251 	 * Return: the pixbuf displayed as logo. The
252 	 *     pixbuf is owned by the about dialog. If you want to keep a
253 	 *     reference to it, you have to call g_object_ref() on it.
254 	 *
255 	 * Since: 2.6
256 	 */
257 	public Pixbuf getLogo()
258 	{
259 		auto p = gtk_about_dialog_get_logo(gtkAboutDialog);
260 		
261 		if(p is null)
262 		{
263 			return null;
264 		}
265 		
266 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p);
267 	}
268 
269 	/**
270 	 * Returns the icon name displayed as logo in the about dialog.
271 	 *
272 	 * Return: the icon name displayed as logo. The string is
273 	 *     owned by the dialog. If you want to keep a reference
274 	 *     to it, you have to call g_strdup() on it.
275 	 *
276 	 * Since: 2.6
277 	 */
278 	public string getLogoIconName()
279 	{
280 		return Str.toString(gtk_about_dialog_get_logo_icon_name(gtkAboutDialog));
281 	}
282 
283 	/**
284 	 * Returns the program name displayed in the about dialog.
285 	 *
286 	 * Return: The program name. The string is owned by the about
287 	 *     dialog and must not be modified.
288 	 *
289 	 * Since: 2.12
290 	 */
291 	public string getProgramName()
292 	{
293 		return Str.toString(gtk_about_dialog_get_program_name(gtkAboutDialog));
294 	}
295 
296 	/**
297 	 * Returns the translator credits string which is displayed
298 	 * in the translators tab of the secondary credits dialog.
299 	 *
300 	 * Return: The translator credits string. The string is
301 	 *     owned by the about dialog and must not be modified.
302 	 *
303 	 * Since: 2.6
304 	 */
305 	public string getTranslatorCredits()
306 	{
307 		return Str.toString(gtk_about_dialog_get_translator_credits(gtkAboutDialog));
308 	}
309 
310 	/**
311 	 * Returns the version string.
312 	 *
313 	 * Return: The version string. The string is owned by the about
314 	 *     dialog and must not be modified.
315 	 *
316 	 * Since: 2.6
317 	 */
318 	public string getVersion()
319 	{
320 		return Str.toString(gtk_about_dialog_get_version(gtkAboutDialog));
321 	}
322 
323 	/**
324 	 * Returns the website URL.
325 	 *
326 	 * Return: The website URL. The string is owned by the about
327 	 *     dialog and must not be modified.
328 	 *
329 	 * Since: 2.6
330 	 */
331 	public string getWebsite()
332 	{
333 		return Str.toString(gtk_about_dialog_get_website(gtkAboutDialog));
334 	}
335 
336 	/**
337 	 * Returns the label used for the website link.
338 	 *
339 	 * Return: The label used for the website link. The string is
340 	 *     owned by the about dialog and must not be modified.
341 	 *
342 	 * Since: 2.6
343 	 */
344 	public string getWebsiteLabel()
345 	{
346 		return Str.toString(gtk_about_dialog_get_website_label(gtkAboutDialog));
347 	}
348 
349 	/**
350 	 * Returns whether the license text in @about is
351 	 * automatically wrapped.
352 	 *
353 	 * Return: %TRUE if the license text is wrapped
354 	 *
355 	 * Since: 2.8
356 	 */
357 	public bool getWrapLicense()
358 	{
359 		return gtk_about_dialog_get_wrap_license(gtkAboutDialog) != 0;
360 	}
361 
362 	/**
363 	 * Sets the strings which are displayed in the artists tab
364 	 * of the secondary credits dialog.
365 	 *
366 	 * Params:
367 	 *     artists = a %NULL-terminated array of strings
368 	 *
369 	 * Since: 2.6
370 	 */
371 	public void setArtists(string[] artists)
372 	{
373 		gtk_about_dialog_set_artists(gtkAboutDialog, Str.toStringzArray(artists));
374 	}
375 
376 	/**
377 	 * Sets the strings which are displayed in the authors tab
378 	 * of the secondary credits dialog.
379 	 *
380 	 * Params:
381 	 *     authors = a %NULL-terminated array of strings
382 	 *
383 	 * Since: 2.6
384 	 */
385 	public void setAuthors(string[] authors)
386 	{
387 		gtk_about_dialog_set_authors(gtkAboutDialog, Str.toStringzArray(authors));
388 	}
389 
390 	/**
391 	 * Sets the comments string to display in the about dialog.
392 	 * This should be a short string of one or two lines.
393 	 *
394 	 * Params:
395 	 *     comments = a comments string
396 	 *
397 	 * Since: 2.6
398 	 */
399 	public void setComments(string comments)
400 	{
401 		gtk_about_dialog_set_comments(gtkAboutDialog, Str.toStringz(comments));
402 	}
403 
404 	/**
405 	 * Sets the copyright string to display in the about dialog.
406 	 * This should be a short string of one or two lines.
407 	 *
408 	 * Params:
409 	 *     copyright = the copyright string
410 	 *
411 	 * Since: 2.6
412 	 */
413 	public void setCopyright(string copyright)
414 	{
415 		gtk_about_dialog_set_copyright(gtkAboutDialog, Str.toStringz(copyright));
416 	}
417 
418 	/**
419 	 * Sets the strings which are displayed in the documenters tab
420 	 * of the secondary credits dialog.
421 	 *
422 	 * Params:
423 	 *     documenters = a %NULL-terminated array of strings
424 	 *
425 	 * Since: 2.6
426 	 */
427 	public void setDocumenters(string[] documenters)
428 	{
429 		gtk_about_dialog_set_documenters(gtkAboutDialog, Str.toStringzArray(documenters));
430 	}
431 
432 	/**
433 	 * Sets the license information to be displayed in the secondary
434 	 * license dialog. If @license is %NULL, the license button is
435 	 * hidden.
436 	 *
437 	 * Params:
438 	 *     license = the license information or %NULL
439 	 *
440 	 * Since: 2.6
441 	 */
442 	public void setLicense(string license)
443 	{
444 		gtk_about_dialog_set_license(gtkAboutDialog, Str.toStringz(license));
445 	}
446 
447 	/**
448 	 * Sets the license of the application showing the @about dialog from a
449 	 * list of known licenses.
450 	 *
451 	 * This function overrides the license set using
452 	 * gtk_about_dialog_set_license().
453 	 *
454 	 * Params:
455 	 *     licenseType = the type of license
456 	 *
457 	 * Since: 3.0
458 	 */
459 	public void setLicenseType(GtkLicense licenseType)
460 	{
461 		gtk_about_dialog_set_license_type(gtkAboutDialog, licenseType);
462 	}
463 
464 	/**
465 	 * Sets the pixbuf to be displayed as logo in the about dialog.
466 	 * If it is %NULL, the default window icon set with
467 	 * gtk_window_set_default_icon() will be used.
468 	 *
469 	 * Params:
470 	 *     logo = a #GdkPixbuf, or %NULL
471 	 *
472 	 * Since: 2.6
473 	 */
474 	public void setLogo(Pixbuf logo)
475 	{
476 		gtk_about_dialog_set_logo(gtkAboutDialog, (logo is null) ? null : logo.getPixbufStruct());
477 	}
478 
479 	/**
480 	 * Sets the pixbuf to be displayed as logo in the about dialog.
481 	 * If it is %NULL, the default window icon set with
482 	 * gtk_window_set_default_icon() will be used.
483 	 *
484 	 * Params:
485 	 *     iconName = an icon name, or %NULL
486 	 *
487 	 * Since: 2.6
488 	 */
489 	public void setLogoIconName(string iconName)
490 	{
491 		gtk_about_dialog_set_logo_icon_name(gtkAboutDialog, Str.toStringz(iconName));
492 	}
493 
494 	/**
495 	 * Sets the name to display in the about dialog.
496 	 * If this is not set, it defaults to g_get_application_name().
497 	 *
498 	 * Params:
499 	 *     name = the program name
500 	 *
501 	 * Since: 2.12
502 	 */
503 	public void setProgramName(string name)
504 	{
505 		gtk_about_dialog_set_program_name(gtkAboutDialog, Str.toStringz(name));
506 	}
507 
508 	/**
509 	 * Sets the translator credits string which is displayed in
510 	 * the translators tab of the secondary credits dialog.
511 	 *
512 	 * The intended use for this string is to display the translator
513 	 * of the language which is currently used in the user interface.
514 	 * Using gettext(), a simple way to achieve that is to mark the
515 	 * string for translation:
516 	 * |[<!-- language="C" -->
517 	 * gtk_about_dialog_set_translator_credits (about,
518 	 * _("translator-credits"));
519 	 * ]|
520 	 * It is a good idea to use the customary msgid “translator-credits” for this
521 	 * purpose, since translators will already know the purpose of that msgid, and
522 	 * since #GtkAboutDialog will detect if “translator-credits” is untranslated
523 	 * and hide the tab.
524 	 *
525 	 * Params:
526 	 *     translatorCredits = the translator credits
527 	 *
528 	 * Since: 2.6
529 	 */
530 	public void setTranslatorCredits(string translatorCredits)
531 	{
532 		gtk_about_dialog_set_translator_credits(gtkAboutDialog, Str.toStringz(translatorCredits));
533 	}
534 
535 	/**
536 	 * Sets the version string to display in the about dialog.
537 	 *
538 	 * Params:
539 	 *     versio = the version string
540 	 *
541 	 * Since: 2.6
542 	 */
543 	public void setVersion(string versio)
544 	{
545 		gtk_about_dialog_set_version(gtkAboutDialog, Str.toStringz(versio));
546 	}
547 
548 	/**
549 	 * Sets the URL to use for the website link.
550 	 *
551 	 * Params:
552 	 *     website = a URL string starting with "http://"
553 	 *
554 	 * Since: 2.6
555 	 */
556 	public void setWebsite(string website)
557 	{
558 		gtk_about_dialog_set_website(gtkAboutDialog, Str.toStringz(website));
559 	}
560 
561 	/**
562 	 * Sets the label to be used for the website link.
563 	 *
564 	 * Params:
565 	 *     websiteLabel = the label used for the website link
566 	 *
567 	 * Since: 2.6
568 	 */
569 	public void setWebsiteLabel(string websiteLabel)
570 	{
571 		gtk_about_dialog_set_website_label(gtkAboutDialog, Str.toStringz(websiteLabel));
572 	}
573 
574 	/**
575 	 * Sets whether the license text in @about is
576 	 * automatically wrapped.
577 	 *
578 	 * Params:
579 	 *     wrapLicense = whether to wrap the license
580 	 *
581 	 * Since: 2.8
582 	 */
583 	public void setWrapLicense(bool wrapLicense)
584 	{
585 		gtk_about_dialog_set_wrap_license(gtkAboutDialog, wrapLicense);
586 	}
587 
588 	int[string] connectedSignals;
589 
590 	bool delegate(string, AboutDialog)[] onActivateLinkListeners;
591 	/**
592 	 * The signal which gets emitted to activate a URI.
593 	 * Applications may connect to it to override the default behaviour,
594 	 * which is to call gtk_show_uri().
595 	 *
596 	 * Params:
597 	 *     uri = the URI that is activated
598 	 *
599 	 * Return: %TRUE if the link has been activated
600 	 *
601 	 * Since: 2.24
602 	 */
603 	void addOnActivateLink(bool delegate(string, AboutDialog) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
604 	{
605 		if ( "activate-link" !in connectedSignals )
606 		{
607 			Signals.connectData(
608 				this,
609 				"activate-link",
610 				cast(GCallback)&callBackActivateLink,
611 				cast(void*)this,
612 				null,
613 				connectFlags);
614 			connectedSignals["activate-link"] = 1;
615 		}
616 		onActivateLinkListeners ~= dlg;
617 	}
618 	extern(C) static int callBackActivateLink(GtkAboutDialog* aboutdialogStruct, char* uri, AboutDialog _aboutdialog)
619 	{
620 		foreach ( bool delegate(string, AboutDialog) dlg; _aboutdialog.onActivateLinkListeners )
621 		{
622 			if ( dlg(Str.toString(uri), _aboutdialog) )
623 			{
624 				return 1;
625 			}
626 		}
627 		
628 		return 0;
629 	}
630 }