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