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 
113 	public static GType getType()
114 	{
115 		return gtk_about_dialog_get_type();
116 	}
117 
118 	/**
119 	 * Creates a new #GtkAboutDialog.
120 	 *
121 	 * Return: a newly created #GtkAboutDialog
122 	 *
123 	 * Since: 2.6
124 	 *
125 	 * Throws: ConstructionException GTK+ fails to create the object.
126 	 */
127 	public this()
128 	{
129 		auto p = gtk_about_dialog_new();
130 		
131 		if(p is null)
132 		{
133 			throw new ConstructionException("null returned by new");
134 		}
135 		
136 		this(cast(GtkAboutDialog*) p);
137 	}
138 
139 	/**
140 	 * Creates a new section in the Credits page.
141 	 *
142 	 * Params:
143 	 *     sectionName = The name of the section
144 	 *     people = The people who belong to that section
145 	 *
146 	 * Since: 3.4
147 	 */
148 	public void addCreditSection(string sectionName, string[] people)
149 	{
150 		gtk_about_dialog_add_credit_section(gtkAboutDialog, Str.toStringz(sectionName), Str.toStringzArray(people));
151 	}
152 
153 	/**
154 	 * Returns the string which are displayed in the artists tab
155 	 * of the secondary credits dialog.
156 	 *
157 	 * Return: A
158 	 *     %NULL-terminated string array containing the artists. The array is
159 	 *     owned by the about dialog and must not be modified.
160 	 *
161 	 * Since: 2.6
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 	 * Return: 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 	 * Since: 2.6
177 	 */
178 	public string[] getAuthors()
179 	{
180 		return Str.toStringArray(gtk_about_dialog_get_authors(gtkAboutDialog));
181 	}
182 
183 	/**
184 	 * Returns the comments string.
185 	 *
186 	 * Return: The comments. The string is owned by the about
187 	 *     dialog and must not be modified.
188 	 *
189 	 * Since: 2.6
190 	 */
191 	public string getComments()
192 	{
193 		return Str.toString(gtk_about_dialog_get_comments(gtkAboutDialog));
194 	}
195 
196 	/**
197 	 * Returns the copyright string.
198 	 *
199 	 * Return: The copyright string. The string is owned by the about
200 	 *     dialog and must not be modified.
201 	 *
202 	 * Since: 2.6
203 	 */
204 	public string getCopyright()
205 	{
206 		return Str.toString(gtk_about_dialog_get_copyright(gtkAboutDialog));
207 	}
208 
209 	/**
210 	 * Returns the string which are displayed in the documenters
211 	 * tab of the secondary credits dialog.
212 	 *
213 	 * Return: A
214 	 *     %NULL-terminated string array containing the documenters. The
215 	 *     array is owned by the about dialog and must not be modified.
216 	 *
217 	 * Since: 2.6
218 	 */
219 	public string[] getDocumenters()
220 	{
221 		return Str.toStringArray(gtk_about_dialog_get_documenters(gtkAboutDialog));
222 	}
223 
224 	/**
225 	 * Returns the license information.
226 	 *
227 	 * Return: The license information. The string is owned by the about
228 	 *     dialog and must not be modified.
229 	 *
230 	 * Since: 2.6
231 	 */
232 	public string getLicense()
233 	{
234 		return Str.toString(gtk_about_dialog_get_license(gtkAboutDialog));
235 	}
236 
237 	/**
238 	 * Retrieves the license set using gtk_about_dialog_set_license_type()
239 	 *
240 	 * Return: a #GtkLicense value
241 	 *
242 	 * Since: 3.0
243 	 */
244 	public GtkLicense getLicenseType()
245 	{
246 		return gtk_about_dialog_get_license_type(gtkAboutDialog);
247 	}
248 
249 	/**
250 	 * Returns the pixbuf displayed as logo in the about dialog.
251 	 *
252 	 * Return: the pixbuf displayed as logo. The
253 	 *     pixbuf is owned by the about dialog. If you want to keep a
254 	 *     reference to it, you have to call g_object_ref() on it.
255 	 *
256 	 * Since: 2.6
257 	 */
258 	public Pixbuf getLogo()
259 	{
260 		auto p = gtk_about_dialog_get_logo(gtkAboutDialog);
261 		
262 		if(p is null)
263 		{
264 			return null;
265 		}
266 		
267 		return ObjectG.getDObject!(Pixbuf)(cast(GdkPixbuf*) p);
268 	}
269 
270 	/**
271 	 * Returns the icon name displayed as logo in the about dialog.
272 	 *
273 	 * Return: the icon name displayed as logo. The string is
274 	 *     owned by the dialog. If you want to keep a reference
275 	 *     to it, you have to call g_strdup() on it.
276 	 *
277 	 * Since: 2.6
278 	 */
279 	public string getLogoIconName()
280 	{
281 		return Str.toString(gtk_about_dialog_get_logo_icon_name(gtkAboutDialog));
282 	}
283 
284 	/**
285 	 * Returns the program name displayed in the about dialog.
286 	 *
287 	 * Return: The program name. The string is owned by the about
288 	 *     dialog and must not be modified.
289 	 *
290 	 * Since: 2.12
291 	 */
292 	public string getProgramName()
293 	{
294 		return Str.toString(gtk_about_dialog_get_program_name(gtkAboutDialog));
295 	}
296 
297 	/**
298 	 * Returns the translator credits string which is displayed
299 	 * in the translators tab of the secondary credits dialog.
300 	 *
301 	 * Return: The translator credits string. The string is
302 	 *     owned by the about dialog and must not be modified.
303 	 *
304 	 * Since: 2.6
305 	 */
306 	public string getTranslatorCredits()
307 	{
308 		return Str.toString(gtk_about_dialog_get_translator_credits(gtkAboutDialog));
309 	}
310 
311 	/**
312 	 * Returns the version string.
313 	 *
314 	 * Return: The version string. The string is owned by the about
315 	 *     dialog and must not be modified.
316 	 *
317 	 * Since: 2.6
318 	 */
319 	public string getVersion()
320 	{
321 		return Str.toString(gtk_about_dialog_get_version(gtkAboutDialog));
322 	}
323 
324 	/**
325 	 * Returns the website URL.
326 	 *
327 	 * Return: The website URL. The string is owned by the about
328 	 *     dialog and must not be modified.
329 	 *
330 	 * Since: 2.6
331 	 */
332 	public string getWebsite()
333 	{
334 		return Str.toString(gtk_about_dialog_get_website(gtkAboutDialog));
335 	}
336 
337 	/**
338 	 * Returns the label used for the website link.
339 	 *
340 	 * Return: The label used for the website link. The string is
341 	 *     owned by the about dialog and must not be modified.
342 	 *
343 	 * Since: 2.6
344 	 */
345 	public string getWebsiteLabel()
346 	{
347 		return Str.toString(gtk_about_dialog_get_website_label(gtkAboutDialog));
348 	}
349 
350 	/**
351 	 * Returns whether the license text in @about is
352 	 * automatically wrapped.
353 	 *
354 	 * Return: %TRUE if the license text is wrapped
355 	 *
356 	 * Since: 2.8
357 	 */
358 	public bool getWrapLicense()
359 	{
360 		return gtk_about_dialog_get_wrap_license(gtkAboutDialog) != 0;
361 	}
362 
363 	/**
364 	 * Sets the strings which are displayed in the artists tab
365 	 * of the secondary credits dialog.
366 	 *
367 	 * Params:
368 	 *     artists = a %NULL-terminated array of strings
369 	 *
370 	 * Since: 2.6
371 	 */
372 	public void setArtists(string[] artists)
373 	{
374 		gtk_about_dialog_set_artists(gtkAboutDialog, Str.toStringzArray(artists));
375 	}
376 
377 	/**
378 	 * Sets the strings which are displayed in the authors tab
379 	 * of the secondary credits dialog.
380 	 *
381 	 * Params:
382 	 *     authors = a %NULL-terminated array of strings
383 	 *
384 	 * Since: 2.6
385 	 */
386 	public void setAuthors(string[] authors)
387 	{
388 		gtk_about_dialog_set_authors(gtkAboutDialog, Str.toStringzArray(authors));
389 	}
390 
391 	/**
392 	 * Sets the comments string to display in the about dialog.
393 	 * This should be a short string of one or two lines.
394 	 *
395 	 * Params:
396 	 *     comments = a comments string
397 	 *
398 	 * Since: 2.6
399 	 */
400 	public void setComments(string comments)
401 	{
402 		gtk_about_dialog_set_comments(gtkAboutDialog, Str.toStringz(comments));
403 	}
404 
405 	/**
406 	 * Sets the copyright string to display in the about dialog.
407 	 * This should be a short string of one or two lines.
408 	 *
409 	 * Params:
410 	 *     copyright = the copyright string
411 	 *
412 	 * Since: 2.6
413 	 */
414 	public void setCopyright(string copyright)
415 	{
416 		gtk_about_dialog_set_copyright(gtkAboutDialog, Str.toStringz(copyright));
417 	}
418 
419 	/**
420 	 * Sets the strings which are displayed in the documenters tab
421 	 * of the secondary credits dialog.
422 	 *
423 	 * Params:
424 	 *     documenters = a %NULL-terminated array of strings
425 	 *
426 	 * Since: 2.6
427 	 */
428 	public void setDocumenters(string[] documenters)
429 	{
430 		gtk_about_dialog_set_documenters(gtkAboutDialog, Str.toStringzArray(documenters));
431 	}
432 
433 	/**
434 	 * Sets the license information to be displayed in the secondary
435 	 * license dialog. If @license is %NULL, the license button is
436 	 * hidden.
437 	 *
438 	 * Params:
439 	 *     license = the license information or %NULL
440 	 *
441 	 * Since: 2.6
442 	 */
443 	public void setLicense(string license)
444 	{
445 		gtk_about_dialog_set_license(gtkAboutDialog, Str.toStringz(license));
446 	}
447 
448 	/**
449 	 * Sets the license of the application showing the @about dialog from a
450 	 * list of known licenses.
451 	 *
452 	 * This function overrides the license set using
453 	 * gtk_about_dialog_set_license().
454 	 *
455 	 * Params:
456 	 *     licenseType = the type of license
457 	 *
458 	 * Since: 3.0
459 	 */
460 	public void setLicenseType(GtkLicense licenseType)
461 	{
462 		gtk_about_dialog_set_license_type(gtkAboutDialog, licenseType);
463 	}
464 
465 	/**
466 	 * Sets the pixbuf to be displayed as logo in the about dialog.
467 	 * If it is %NULL, the default window icon set with
468 	 * gtk_window_set_default_icon() will be used.
469 	 *
470 	 * Params:
471 	 *     logo = a #GdkPixbuf, or %NULL
472 	 *
473 	 * Since: 2.6
474 	 */
475 	public void setLogo(Pixbuf logo)
476 	{
477 		gtk_about_dialog_set_logo(gtkAboutDialog, (logo is null) ? null : logo.getPixbufStruct());
478 	}
479 
480 	/**
481 	 * Sets the pixbuf to be displayed as logo in the about dialog.
482 	 * If it is %NULL, the default window icon set with
483 	 * gtk_window_set_default_icon() will be used.
484 	 *
485 	 * Params:
486 	 *     iconName = an icon name, or %NULL
487 	 *
488 	 * Since: 2.6
489 	 */
490 	public void setLogoIconName(string iconName)
491 	{
492 		gtk_about_dialog_set_logo_icon_name(gtkAboutDialog, Str.toStringz(iconName));
493 	}
494 
495 	/**
496 	 * Sets the name to display in the about dialog.
497 	 * If this is not set, it defaults to g_get_application_name().
498 	 *
499 	 * Params:
500 	 *     name = the program name
501 	 *
502 	 * Since: 2.12
503 	 */
504 	public void setProgramName(string name)
505 	{
506 		gtk_about_dialog_set_program_name(gtkAboutDialog, Str.toStringz(name));
507 	}
508 
509 	/**
510 	 * Sets the translator credits string which is displayed in
511 	 * the translators tab of the secondary credits dialog.
512 	 *
513 	 * The intended use for this string is to display the translator
514 	 * of the language which is currently used in the user interface.
515 	 * Using gettext(), a simple way to achieve that is to mark the
516 	 * string for translation:
517 	 * |[<!-- language="C" -->
518 	 * gtk_about_dialog_set_translator_credits (about,
519 	 * _("translator-credits"));
520 	 * ]|
521 	 * It is a good idea to use the customary msgid “translator-credits” for this
522 	 * purpose, since translators will already know the purpose of that msgid, and
523 	 * since #GtkAboutDialog will detect if “translator-credits” is untranslated
524 	 * and hide the tab.
525 	 *
526 	 * Params:
527 	 *     translatorCredits = the translator credits
528 	 *
529 	 * Since: 2.6
530 	 */
531 	public void setTranslatorCredits(string translatorCredits)
532 	{
533 		gtk_about_dialog_set_translator_credits(gtkAboutDialog, Str.toStringz(translatorCredits));
534 	}
535 
536 	/**
537 	 * Sets the version string to display in the about dialog.
538 	 *
539 	 * Params:
540 	 *     versio = the version string
541 	 *
542 	 * Since: 2.6
543 	 */
544 	public void setVersion(string versio)
545 	{
546 		gtk_about_dialog_set_version(gtkAboutDialog, Str.toStringz(versio));
547 	}
548 
549 	/**
550 	 * Sets the URL to use for the website link.
551 	 *
552 	 * Params:
553 	 *     website = a URL string starting with "http://"
554 	 *
555 	 * Since: 2.6
556 	 */
557 	public void setWebsite(string website)
558 	{
559 		gtk_about_dialog_set_website(gtkAboutDialog, Str.toStringz(website));
560 	}
561 
562 	/**
563 	 * Sets the label to be used for the website link.
564 	 *
565 	 * Params:
566 	 *     websiteLabel = the label used for the website link
567 	 *
568 	 * Since: 2.6
569 	 */
570 	public void setWebsiteLabel(string websiteLabel)
571 	{
572 		gtk_about_dialog_set_website_label(gtkAboutDialog, Str.toStringz(websiteLabel));
573 	}
574 
575 	/**
576 	 * Sets whether the license text in @about is
577 	 * automatically wrapped.
578 	 *
579 	 * Params:
580 	 *     wrapLicense = whether to wrap the license
581 	 *
582 	 * Since: 2.8
583 	 */
584 	public void setWrapLicense(bool wrapLicense)
585 	{
586 		gtk_about_dialog_set_wrap_license(gtkAboutDialog, wrapLicense);
587 	}
588 
589 	int[string] connectedSignals;
590 
591 	bool delegate(string, AboutDialog)[] onActivateLinkListeners;
592 	/**
593 	 * The signal which gets emitted to activate a URI.
594 	 * Applications may connect to it to override the default behaviour,
595 	 * which is to call gtk_show_uri().
596 	 *
597 	 * Params:
598 	 *     uri = the URI that is activated
599 	 *
600 	 * Return: %TRUE if the link has been activated
601 	 *
602 	 * Since: 2.24
603 	 */
604 	void addOnActivateLink(bool delegate(string, AboutDialog) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
605 	{
606 		if ( "activate-link" !in connectedSignals )
607 		{
608 			Signals.connectData(
609 				this,
610 				"activate-link",
611 				cast(GCallback)&callBackActivateLink,
612 				cast(void*)this,
613 				null,
614 				connectFlags);
615 			connectedSignals["activate-link"] = 1;
616 		}
617 		onActivateLinkListeners ~= dlg;
618 	}
619 	extern(C) static int callBackActivateLink(GtkAboutDialog* aboutdialogStruct, char* uri, AboutDialog _aboutdialog)
620 	{
621 		foreach ( bool delegate(string, AboutDialog) dlg; _aboutdialog.onActivateLinkListeners )
622 		{
623 			if ( dlg(Str.toString(uri), _aboutdialog) )
624 			{
625 				return 1;
626 			}
627 		}
628 		
629 		return 0;
630 	}
631 }