CoreGTK  3.22.0
CoreGTK is an Objective-C language binding for the GTK+ widget toolkit
CGTKMenu.m
1 /*
2  * CGTKMenu.m
3  * This file is part of CoreGTK
4  *
5  * Copyright (C) 2017 - 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, 2017. 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 
96 {
97  return [[CGTKWidget alloc] initWithGObject:(GObject *)gtk_menu_get_active(GTK_MENU([self GOBJECT]))];
98 }
99 
101 {
102  return [[CGTKWidget alloc] initWithGObject:(GObject *)gtk_menu_get_attach_widget(GTK_MENU([self GOBJECT]))];
103 }
104 
106 {
107  return gtk_menu_get_monitor(GTK_MENU([self GOBJECT]));
108 }
109 
111 {
112  return (gtk_menu_get_reserve_toggle_size(GTK_MENU([self GOBJECT])) ? YES : NO);
113 }
114 
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)placeOnMonitor:(GdkMonitor*) monitor
126 {
127  gtk_menu_place_on_monitor(GTK_MENU([self GOBJECT]), monitor);
128 }
129 
130 -(void)popdown
131 {
132  gtk_menu_popdown(GTK_MENU([self GOBJECT]));
133 }
134 
135 -(void)popupWithParentMenuShell:(CGTKWidget*) parentMenuShell andParentMenuItem:(CGTKWidget*) parentMenuItem andFunc:(GtkMenuPositionFunc) func andData:(gpointer) data andButton:(guint) button andActivateTime:(guint32) activateTime
136 {
137  gtk_menu_popup(GTK_MENU([self GOBJECT]), [parentMenuShell WIDGET], [parentMenuItem WIDGET], func, data, button, activateTime);
138 }
139 
140 -(void)popupAtPointer:(const GdkEvent*) triggerEvent
141 {
142  gtk_menu_popup_at_pointer(GTK_MENU([self GOBJECT]), triggerEvent);
143 }
144 
145 -(void)popupAtRectWithRectWindow:(GdkWindow*) rectWindow andRect:(const GdkRectangle*) rect andRectAnchor:(GdkGravity) rectAnchor andMenuAnchor:(GdkGravity) menuAnchor andTriggerEvent:(const GdkEvent*) triggerEvent
146 {
147  gtk_menu_popup_at_rect(GTK_MENU([self GOBJECT]), rectWindow, rect, rectAnchor, menuAnchor, triggerEvent);
148 }
149 
150 -(void)popupAtWidgetWithWidget:(CGTKWidget*) widget andWidgetAnchor:(GdkGravity) widgetAnchor andMenuAnchor:(GdkGravity) menuAnchor andTriggerEvent:(const GdkEvent*) triggerEvent
151 {
152  gtk_menu_popup_at_widget(GTK_MENU([self GOBJECT]), [widget WIDGET], widgetAnchor, menuAnchor, triggerEvent);
153 }
154 
155 -(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
156 {
157  gtk_menu_popup_for_device(GTK_MENU([self GOBJECT]), device, [parentMenuShell WIDGET], [parentMenuItem WIDGET], func, data, destroy, button, activateTime);
158 }
159 
160 -(void)reorderChildWithChild:(CGTKWidget*) child andPosition:(gint) position
161 {
162  gtk_menu_reorder_child(GTK_MENU([self GOBJECT]), [child WIDGET], position);
163 }
164 
166 {
167  gtk_menu_reposition(GTK_MENU([self GOBJECT]));
168 }
169 
170 -(void)setAccelGroup:(GtkAccelGroup*) accelGroup
171 {
172  gtk_menu_set_accel_group(GTK_MENU([self GOBJECT]), accelGroup);
173 }
174 
175 -(void)setAccelPath:(NSString*) accelPath
176 {
177  gtk_menu_set_accel_path(GTK_MENU([self GOBJECT]), [accelPath UTF8String]);
178 }
179 
180 -(void)setActive:(guint) index
181 {
182  gtk_menu_set_active(GTK_MENU([self GOBJECT]), index);
183 }
184 
185 -(void)setMonitor:(gint) monitorNum
186 {
187  gtk_menu_set_monitor(GTK_MENU([self GOBJECT]), monitorNum);
188 }
189 
190 -(void)setReserveToggleSize:(BOOL) reserveToggleSize
191 {
192  gtk_menu_set_reserve_toggle_size(GTK_MENU([self GOBJECT]), (reserveToggleSize ? TRUE : FALSE));
193 }
194 
195 -(void)setScreen:(GdkScreen*) screen
196 {
197  gtk_menu_set_screen(GTK_MENU([self GOBJECT]), screen);
198 }
199 
200 -(void)setTearoffState:(BOOL) tornOff
201 {
202  gtk_menu_set_tearoff_state(GTK_MENU([self GOBJECT]), (tornOff ? TRUE : FALSE));
203 }
204 
205 -(void)setTitle:(NSString*) title
206 {
207  gtk_menu_set_title(GTK_MENU([self GOBJECT]), [title UTF8String]);
208 }
209 
210 
211 @end
BOOL getReserveToggleSize()
Definition: CGTKMenu.m:110
id init()
Definition: CGTKMenu.m:41
GObject * GOBJECT()
Definition: CGTKBase.m:82
GtkAccelGroup * getAccelGroup()
Definition: CGTKMenu.m:85
void detach()
Definition: CGTKMenu.m:80
GtkMenu * MENU()
Definition: CGTKMenu.m:65
id initWithGObject:(GObject *obj)
Definition: CGTKBase.m:48
BOOL getTearoffState()
Definition: CGTKMenu.m:115
NSString * getTitle()
Definition: CGTKMenu.m:120
NSString * getAccelPath()
Definition: CGTKMenu.m:90
void reposition()
Definition: CGTKMenu.m:165
void destroy()
Definition: CGTKWidget.m:131
GtkWidget * WIDGET()
Definition: CGTKWidget.m:61
void popdown()
Definition: CGTKMenu.m:130
CGTKWidget * getActive()
Definition: CGTKMenu.m:95
CGTKWidget * getAttachWidget()
Definition: CGTKMenu.m:100
gint getMonitor()
Definition: CGTKMenu.m:105