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

- Main Page
- Classes
- Files

- File List

CGTKDialog.m
1 /*
2 * CGTKDialog.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/CGTKDialog.h"
33
34 @implementation CGTKDialog
35
36 -(void)addButtons:(NSDictionary *)buttonTextDict
37 {
38 CGTKTypeWrapper *wrapper;
39 for(NSString *text in buttonTextDict)
40 {
41 wrapper = [buttonTextDict objectForKey:text];
42
43 [self addButtonWithButtonText:text andResponseId:wrapper.gintValue];
44 }
45 }
46
47 -(id)initWithTitle:(NSString *)title andParent:(CGTKWindow *)parent andFlags:(GtkDialogFlags)flags andButtonTextResponseDictionary:(NSDictionary *)buttonTextDict
48 {
49 self = [super initWithGObject:(GObject *)gtk_dialog_new_with_buttons([title UTF8String], [parent WINDOW], flags, NULL, NULL)];
50
51 if(self)
52 {
53 CGTKTypeWrapper *wrapper;
54 for(NSString *text in buttonTextDict)
55 {
56 wrapper = [buttonTextDict objectForKey:text];
57
58 [self addButtonWithButtonText:text andResponseId:wrapper.gintValue];
59 }
60 }
61
62 return self;
63 }
64
65 -(id)init
66 {
67 self = [super initWithGObject:(GObject *)gtk_dialog_new()];
68
69 if(self)
70 {
71 //Do nothing
72 }
73
74 return self;
75 }
76
77 -(GtkDialog*)DIALOG
78 {
79 return GTK_DIALOG([self GOBJECT]);
80 }
81
82 -(void)addActionWidgetWithChild:(CGTKWidget*) child andResponseId:(gint) responseId
83 {
84 gtk_dialog_add_action_widget(GTK_DIALOG([self GOBJECT]), [child WIDGET], responseId);
85 }
86
87 -(CGTKWidget*)addButtonWithButtonText:(NSString*) buttonText andResponseId:(gint) responseId
88 {
89 return [[CGTKWidget alloc] initWithGObject:(GObject *)gtk_dialog_add_button(GTK_DIALOG([self GOBJECT]), [buttonText UTF8String], responseId)];
90 }
91
92 -(CGTKWidget*)getActionArea
93 {
94 return [[CGTKWidget alloc] initWithGObject:(GObject *)gtk_dialog_get_action_area(GTK_DIALOG([self GOBJECT]))];
95 }
96
97 -(CGTKWidget*)getContentArea
98 {
99 return [[CGTKWidget alloc] initWithGObject:(GObject *)gtk_dialog_get_content_area(GTK_DIALOG([self GOBJECT]))];
100 }
101
102 -(CGTKWidget*)getHeaderBar
103 {
104 return [[CGTKWidget alloc] initWithGObject:(GObject *)gtk_dialog_get_header_bar(GTK_DIALOG([self GOBJECT]))];
105 }
106
107 -(gint)getResponseForWidget:(CGTKWidget*) widget
108 {
109 return gtk_dialog_get_response_for_widget(GTK_DIALOG([self GOBJECT]), [widget WIDGET]);
110 }
111
112 -(CGTKWidget*)getWidgetForResponse:(gint) responseId
113 {
114 return [[CGTKWidget alloc] initWithGObject:(GObject *)gtk_dialog_get_widget_for_response(GTK_DIALOG([self GOBJECT]), responseId)];
115 }
116
117 -(void)response:(gint) responseId
118 {
119 gtk_dialog_response(GTK_DIALOG([self GOBJECT]), responseId);
120 }
121
122 -(gint)run
123 {
124 return gtk_dialog_run(GTK_DIALOG([self GOBJECT]));
125 }
126
127 -(void)setAlternativeButtonOrderFromArrayWithNparams:(gint) nparams andNewOrder:(gint*) newOrder
128 {
129 gtk_dialog_set_alternative_button_order_from_array(GTK_DIALOG([self GOBJECT]), nparams, newOrder);
130 }
131
132 -(void)setDefaultResponse:(gint) responseId
133 {
134 gtk_dialog_set_default_response(GTK_DIALOG([self GOBJECT]), responseId);
135 }
136
137 -(void)setResponseSensitiveWithResponseId:(gint) responseId andSetting:(BOOL) setting
138 {
139 gtk_dialog_set_response_sensitive(GTK_DIALOG([self GOBJECT]), responseId, (setting ? TRUE : FALSE));
140 }
141
142
143 @end
-[CGTKBase GOBJECT]
GObject * GOBJECT()
Definition: CGTKBase.m:82
CGTKTypeWrapper
Definition: CGTKTypeWrapper.h:38
-[CGTKBase initWithGObject:]
id initWithGObject:(GObject *obj)
Definition: CGTKBase.m:48
CGTKWindow
Definition: CGTKWindow.h:34
-[CGTKWindow WINDOW]
GtkWindow * WINDOW()
Definition: CGTKWindow.m:93
-[CGTKWidget WIDGET]
GtkWidget * WIDGET()
Definition: CGTKWidget.m:61
-[CGTKDialog getActionArea]
CGTKWidget * getActionArea()
Definition: CGTKDialog.m:92
-[CGTKDialog run]
gint run()
Definition: CGTKDialog.m:122
-[CGTKDialog init]
id init()
Definition: CGTKDialog.m:65
-[CGTKDialog getHeaderBar]
CGTKWidget * getHeaderBar()
Definition: CGTKDialog.m:102
CGTKDialog
Definition: CGTKDialog.h:34
CGTKWidget
Definition: CGTKWidget.h:34
-[CGTKDialog getContentArea]
CGTKWidget * getContentArea()
Definition: CGTKDialog.m:97
-[CGTKDialog DIALOG]
GtkDialog * DIALOG()
Definition: CGTKDialog.m:77