1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
|
/*
* This file is a part of hildon
*
* Copyright (C) 2008 Nokia Corporation, all rights reserved.
*
* Contact: Rodrigo Novo <rodrigo.novo@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
/**
* SECTION:hildon-dialog
* @short_description: A popup window in the Hildon framework.
* @see_also: #HildonCodeDialog, #HildonColorChooserDialog, #HildonFontSelectionDialog, #HildonGetPasswordDialog, #HildonLoginDialog, #HildonSetPasswordDialog, #HildonSortDialog, #HildonWizardDialog
*
* #HildonDialog is a popup window in the
* Hildon framework. It is derived from #GtkDialog and provides additional
* commodities specific to the Hildon framework.
*
* As of hildon 2.2, #HildonDialog has been deprecated in favor of #GtkDialog.
*
* <note>
* <para>
* #HildonDialog has been deprecated since Hildon 2.2 and should not
* be used in newly written code. See
* <link linkend="hildon-migrating-hildon-dialogs">Migrating Hildon Dialogs</link>
* section to know how to migrate this deprecated widget.
* </para>
* </note>
*
* <example>
* <title>Simple <structname>HildonDialog</structname> usage</title>
* <programlisting>
* void quick_message (gchar *message)
* {
* <!-- -->
* GtkWidget *dialog, *label;
* <!-- -->
* dialog = hildon_dialog_new ();
* label = gtk_label_new (message);
* <!-- -->
* g_signal_connect_swapped (dialog,
* "response",
* G_CALLBACK (gtk_widget_destroy),
* dialog);
* <!-- -->
* gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox),
* label);
* gtk_widget_show_all (dialog);
* <!-- -->
* }
* </programlisting>
* </example>
*/
#undef HILDON_DISABLE_DEPRECATED
#include "hildon-dialog.h"
#include "hildon-gtk.h"
G_DEFINE_TYPE (HildonDialog, hildon_dialog, GTK_TYPE_DIALOG);
static void
hildon_dialog_class_init (HildonDialogClass *dialog_class)
{
}
static void
hildon_dialog_init (HildonDialog *self)
{
}
/**
* hildon_dialog_new:
*
* Creates a new #HildonDialog widget
*
* Returns: the newly created #HildonDialog
*
* Since: 2.2
*/
GtkWidget*
hildon_dialog_new (void)
{
GtkWidget *self = g_object_new (HILDON_TYPE_DIALOG, NULL);
return self;
}
/**
* hildon_dialog_new_with_buttons:
* @title: Title of the dialog, or %NULL
* @parent: Transient parent of the dialog, or %NULL
* @flags: from #GtkDialogFlags
* @first_button_text: stock ID or text to go in first button, or %NULL
* @Varargs: response ID for first button, then additional buttons, ending with %NULL
*
* Creates a new #HildonDialog. See gtk_dialog_new_with_buttons() for
* more information.
*
* Return value: a new #HildonDialog
*
* Since: 2.2
*/
GtkWidget*
hildon_dialog_new_with_buttons (const gchar *title,
GtkWindow *parent,
GtkDialogFlags flags,
const gchar *first_button_text,
...)
{
GtkWidget *dialog;
dialog = g_object_new (HILDON_TYPE_DIALOG, NULL);
/* This code is copied from gtk_dialog_new_empty(), as it's a
* private function that we cannot use here */
if (title)
gtk_window_set_title (GTK_WINDOW (dialog), title);
if (parent)
gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
if (flags & GTK_DIALOG_MODAL)
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
if (flags & GTK_DIALOG_DESTROY_WITH_PARENT)
gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
if (flags & GTK_DIALOG_NO_SEPARATOR)
gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
/* This is almost copied from gtk_dialog_add_buttons_valist() */
if (first_button_text != NULL) {
va_list args;
const gchar *text;
gint response_id;
va_start (args, first_button_text);
text = first_button_text;
response_id = va_arg (args, gint);
while (text != NULL) {
hildon_dialog_add_button (HILDON_DIALOG (dialog), text, response_id);
text = va_arg (args, gchar*);
if (text == NULL)
break;
response_id = va_arg (args, int);
}
va_end (args);
}
return dialog;
}
/**
* hildon_dialog_add_button:
* @dialog: a #HildonDialog
* @button_text: text of the button, or stock ID
* @response_id: response ID for the button.
*
* Adds a button to the dialog. Works exactly like
* gtk_dialog_add_button(), the only difference being that the button
* has finger size.
*
* Returns: the button widget that was added
*
* Since: 2.2
*/
GtkWidget *
hildon_dialog_add_button (HildonDialog *dialog,
const gchar *button_text,
gint response_id)
{
GtkWidget *button;
button = gtk_dialog_add_button (GTK_DIALOG (dialog), button_text, response_id);
return button;
}
/**
* hildon_dialog_add_buttons:
* @dialog: a #HildonDialog
* @first_button_text: text of the button, or stock ID
* @Varargs: response ID for first button, then more text-response_id pairs
*
* Adds several buttons to the dialog. Works exactly like
* gtk_dialog_add_buttons(), the only difference being that the
* buttons have finger size.
*
* Since: 2.2
*/
void
hildon_dialog_add_buttons (HildonDialog *dialog,
const gchar *first_button_text,
...)
{
va_list args;
const gchar *text;
gint response_id;
va_start (args, first_button_text);
text = first_button_text;
response_id = va_arg (args, gint);
while (text != NULL) {
hildon_dialog_add_button (HILDON_DIALOG (dialog), text, response_id);
text = va_arg (args, gchar*);
if (text == NULL)
break;
response_id = va_arg (args, int);
}
va_end (args);
}
|