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.ShortcutsSection;
26 
27 private import gobject.Signals;
28 private import gtk.Box;
29 private import gtk.c.functions;
30 public  import gtk.c.types;
31 public  import gtkc.gtktypes;
32 private import std.algorithm;
33 
34 
35 /**
36  * A GtkShortcutsSection collects all the keyboard shortcuts and gestures
37  * for a major application mode. If your application needs multiple sections,
38  * you should give each section a unique #GtkShortcutsSection:section-name and
39  * a #GtkShortcutsSection:title that can be shown in the section selector of
40  * the GtkShortcutsWindow.
41  * 
42  * The #GtkShortcutsSection:max-height property can be used to influence how
43  * the groups in the section are distributed over pages and columns.
44  * 
45  * This widget is only meant to be used with #GtkShortcutsWindow.
46  */
47 public class ShortcutsSection : Box
48 {
49 	/** the main Gtk struct */
50 	protected GtkShortcutsSection* gtkShortcutsSection;
51 
52 	/** Get the main Gtk struct */
53 	public GtkShortcutsSection* getShortcutsSectionStruct(bool transferOwnership = false)
54 	{
55 		if (transferOwnership)
56 			ownedRef = false;
57 		return gtkShortcutsSection;
58 	}
59 
60 	/** the main Gtk struct as a void* */
61 	protected override void* getStruct()
62 	{
63 		return cast(void*)gtkShortcutsSection;
64 	}
65 
66 	protected override void setStruct(GObject* obj)
67 	{
68 		gtkShortcutsSection = cast(GtkShortcutsSection*)obj;
69 		super.setStruct(obj);
70 	}
71 
72 	/**
73 	 * Sets our main struct and passes it to the parent class.
74 	 */
75 	public this (GtkShortcutsSection* gtkShortcutsSection, bool ownedRef = false)
76 	{
77 		this.gtkShortcutsSection = gtkShortcutsSection;
78 		super(cast(GtkBox*)gtkShortcutsSection, ownedRef);
79 	}
80 
81 
82 	/** */
83 	public static GType getType()
84 	{
85 		return gtk_shortcuts_section_get_type();
86 	}
87 
88 	protected class OnChangeCurrentPageDelegateWrapper
89 	{
90 		bool delegate(int, ShortcutsSection) dlg;
91 		gulong handlerId;
92 
93 		this(bool delegate(int, ShortcutsSection) dlg)
94 		{
95 			this.dlg = dlg;
96 			onChangeCurrentPageListeners ~= this;
97 		}
98 
99 		void remove(OnChangeCurrentPageDelegateWrapper source)
100 		{
101 			foreach(index, wrapper; onChangeCurrentPageListeners)
102 			{
103 				if (wrapper.handlerId == source.handlerId)
104 				{
105 					onChangeCurrentPageListeners[index] = null;
106 					onChangeCurrentPageListeners = std.algorithm.remove(onChangeCurrentPageListeners, index);
107 					break;
108 				}
109 			}
110 		}
111 	}
112 	OnChangeCurrentPageDelegateWrapper[] onChangeCurrentPageListeners;
113 
114 	/** */
115 	gulong addOnChangeCurrentPage(bool delegate(int, ShortcutsSection) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
116 	{
117 		auto wrapper = new OnChangeCurrentPageDelegateWrapper(dlg);
118 		wrapper.handlerId = Signals.connectData(
119 			this,
120 			"change-current-page",
121 			cast(GCallback)&callBackChangeCurrentPage,
122 			cast(void*)wrapper,
123 			cast(GClosureNotify)&callBackChangeCurrentPageDestroy,
124 			connectFlags);
125 		return wrapper.handlerId;
126 	}
127 
128 	extern(C) static int callBackChangeCurrentPage(GtkShortcutsSection* shortcutssectionStruct, int object, OnChangeCurrentPageDelegateWrapper wrapper)
129 	{
130 		return wrapper.dlg(object, wrapper.outer);
131 	}
132 
133 	extern(C) static void callBackChangeCurrentPageDestroy(OnChangeCurrentPageDelegateWrapper wrapper, GClosure* closure)
134 	{
135 		wrapper.remove(wrapper);
136 	}
137 }