CoreGTK 3.18.0 CoreGTK is an Objective-C language binding for the GTK+ widget toolkit

- Main Page
- Classes
- Files

- File List

CGTKMenu.m
1 /*
2 * CGTKMenu.m
3 * This file is part of CoreGTK
4 *
5 * Copyright (C) 2016 - Tyler Burton
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22 /*
23 * Modified by the CoreGTK Team, 2016. See the AUTHORS file for a
24 * list of people on the CoreGTK Team.
25 * See the ChangeLog files for a list of changes.
26 *
27 */
28
29 /*
30 * Objective-C imports
31 */
32 #import "CoreGTK/CGTKMenu.h"
33
34 @implementation CGTKMenu
35
36 +(GList*)getForAttachWidget:(CGTKWidget*) widget
37 {
38 return gtk_menu_get_for_attach_widget([widget WIDGET]);
39 }
40
41 -(id)init
42 {
43 self = [super initWithGObject:(GObject *)gtk_menu_new()];
44
45 if(self)
46 {
47 //Do nothing
48 }
49
50 return self;
51 }
52
53 -(id)initFromModel:(GMenuModel*) model
54 {
55 self = [super initWithGObject:(GObject *)gtk_menu_new_from_model(model)];
56
57 if(self)
58 {
59 //Do nothing
60 }
61
62 return self;
63 }
64
65 -(GtkMenu*)MENU
66 {
67 return GTK_MENU([self GOBJECT]);
68 }
69
70 -(void)attachWithChild:(CGTKWidget*) child andLeftAttach:(guint) leftAttach andRightAttach:(guint) rightAttach andTopAttach:(guint) topAttach andBottomAttach:(guint) bottomAttach
71 {
72 gtk_menu_attach(GTK_MENU([self GOBJECT]), [child WIDGET], leftAttach, rightAttach, topAttach, bottomAttach);
73 }
74
75 -(void)attachToWidgetWithAttachWidget:(CGTKWidget*) attachWidget andDetacher:(GtkMenuDetachFunc) detacher
76 {
77 gtk_menu_attach_to_widget(GTK_MENU([self GOBJECT]), [attachWidget WIDGET], detacher);
78 }
79
80 -(void)detach
81 {
82 gtk_menu_detach(GTK_MENU([self GOBJECT]));
83 }
84
85 -(GtkAccelGroup*)getAccelGroup
86 {
87 return gtk_menu_get_accel_group(GTK_MENU([self GOBJECT]));
88 }
89
90 -(NSString*)getAccelPath
91 {
92 return [NSString stringWithUTF8String:gtk_menu_get_accel_path(GTK_MENU([self GOBJECT]))];
93 }
94
95 -(CGTKWidget*)getActive
96 {
97 return [[CGTKWidget alloc] initWithGObject:(GObject *)gtk_menu_get_active(GTK_MENU([self GOBJECT]))];
98 }
99
100 -(CGTKWidget*)getAttachWidget
101 {
102 return [[CGTKWidget alloc] initWithGObject:(GObject *)gtk_menu_get_attach_widget(GTK_MENU([self GOBJECT]))];
103 }
104
105 -(gint)getMonitor
106 {
107 return gtk_menu_get_monitor(GTK_MENU([self GOBJECT]));
108 }
109
110 -(BOOL)getReserveToggleSize
111 {
112 return (gtk_menu_get_reserve_toggle_size(GTK_MENU([self GOBJECT])) ? YES : NO);
113 }
114
115 -(BOOL)getTearoffState
116 {
117 return (gtk_menu_get_tearoff_state(GTK_MENU([self GOBJECT])) ? YES : NO);
118 }
119
120 -(NSString*)getTitle
121 {
122 return [NSString stringWithUTF8String:gtk_menu_get_title(GTK_MENU([self GOBJECT]))];
123 }
124
125 -(void)popdown
126 {
127 gtk_menu_popdown(GTK_MENU([self GOBJECT]));
128 }
129
130 -(void)popupWithParentMenuShell:(CGTKWidget*) parentMenuShell andParentMenuItem:(CGTKWidget*) parentMenuItem andFunc:(GtkMenuPositionFunc) func andData:(gpointer) data andButton:(guint) button andActivateTime:(guint32) activateTime
131 {
132 gtk_menu_popup(GTK_MENU([self GOBJECT]), [parentMenuShell WIDGET], [parentMenuItem WIDGET], func, data, button, activateTime);
133 }
134
135 -(void)popupForDeviceWithDevice:(GdkDevice*) device andParentMenuShell:(CGTKWidget*) parentMenuShell andParentMenuItem:(CGTKWidget*) parentMenuItem andFunc:(GtkMenuPositionFunc) func andData:(gpointer) data andDestroy:(GDestroyNotify) destroy andButton:(guint) button andActivateTime:(guint32) activateTime
136 {
137 gtk_menu_popup_for_device(GTK_MENU([self GOBJECT]), device, [parentMenuShell WIDGET], [parentMenuItem WIDGET], func, data, destroy, button, activateTime);
138 }
139
140 -(void)reorderChildWithChild:(CGTKWidget*) child andPosition:(gint) position
141 {
142 gtk_menu_reorder_child(GTK_MENU([self GOBJECT]), [child WIDGET], position);
143 }
144
145 -(void)reposition
146 {
147 gtk_menu_reposition(GTK_MENU([self GOBJECT]));
148 }
149
150 -(void)setAccelGroup:(GtkAccelGroup*) accelGroup
151 {
152 gtk_menu_set_accel_group(GTK_MENU([self GOBJECT]), accelGroup);
153 }
154
155 -(void)setAccelPath:(NSString*) accelPath
156 {
157 gtk_menu_set_accel_path(GTK_MENU([self GOBJECT]), [accelPath UTF8String]);
158 }
159
160 -(void)setActive:(guint) index
161 {
162 gtk_menu_set_active(GTK_MENU([self GOBJECT]), index);
163 }
164
165 -(void)setMonitor:(gint) monitorNum
166 {
167 gtk_menu_set_monitor(GTK_MENU([self GOBJECT]), monitorNum);
168 }
169
170 -(void)setReserveToggleSize:(BOOL) reserveToggleSize
171 {
172 gtk_menu_set_reserve_toggle_size(GTK_MENU([self GOBJECT]), (reserveToggleSize ? TRUE : FALSE));
173 }
174
175 -(void)setScreen:(GdkScreen*) screen
176 {
177 gtk_menu_set_screen(GTK_MENU([self GOBJECT]), screen);
178 }
179
180 -(void)setTearoffState:(BOOL) tornOff
181 {
182 gtk_menu_set_tearoff_state(GTK_MENU([self GOBJECT]), (tornOff ? TRUE : FALSE));
183 }
184
185 -(void)setTitle:(NSString*) title
186 {
187 gtk_menu_set_title(GTK_MENU([self GOBJECT]), [title UTF8String]);
188 }
189
190
191 @end
-[CGTKBase GOBJECT]
GObject * GOBJECT()
Definition: CGTKBase.m:82
-[CGTKBase initWithGObject:]
id initWithGObject:(GObject *obj)
Definition: CGTKBase.m:48
-[CGTKWidget destroy]
void destroy()
Definition: CGTKWidget.m:131
-[CGTKWidget WIDGET]
GtkWidget * WIDGET()
Definition: CGTKWidget.m:61
CGTKWidget
Definition: CGTKWidget.h:34