2 * This file is a part of hildon
4 * Copyright (C) 2008 Nokia Corporation, all rights reserved.
6 * Contact: Rodrigo Novo <rodrigo.novo@nokia.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; version 2.1 of
11 * the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
26 * SECTION:hildon-dialog
27 * @short_description: Widget representing a popup window in the Hildon framework.
28 * @see_also: #HildonCodeDialog, #HildonColorChooserDialog, #HildonFontSelectionDialog, #HildonGetPasswordDialog, #HildonLoginDialog, #HildonSetPasswordDialog, #HildonSortDialog, #HildonWizardDialog
30 * #HildonDialog is a GTK widget which represent a popup window in the
31 * Hildon framework. It is derived from #GtkDialog and provides additional
32 * commodities specific to the Hildon framework.
34 * As of hildon 2.2, #HildonDialog has been deprecated in favor of #GtkDialog.
37 * <title>Simple <structname>HildonDialog</structname> usage</title>
39 * void quick_message (gchar *message)
42 * GtkWidget *dialog, *label;
44 * dialog = hildon_dialog_new ();
45 * label = gtk_label_new (message);
47 * g_signal_connect_swapped (dialog,
49 * G_CALLBACK (gtk_widget_destroy),
52 * gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox),
54 * gtk_widget_show_all (dialog);
61 #undef HILDON_DISABLE_DEPRECATED
63 #include "hildon-dialog.h"
64 #include "hildon-gtk.h"
66 G_DEFINE_TYPE (HildonDialog, hildon_dialog, GTK_TYPE_DIALOG);
69 hildon_dialog_class_init (HildonDialogClass *dialog_class)
74 hildon_dialog_init (HildonDialog *self)
81 * Creates a new #HildonDialog widget
83 * Returns: the newly created #HildonDialog
88 hildon_dialog_new (void)
90 GtkWidget *self = g_object_new (HILDON_TYPE_DIALOG, NULL);
96 * hildon_dialog_new_with_buttons:
97 * @title: Title of the dialog, or %NULL
98 * @parent: Transient parent of the dialog, or %NULL
99 * @flags: from #GtkDialogFlags
100 * @first_button_text: stock ID or text to go in first button, or %NULL
101 * @Varargs: response ID for first button, then additional buttons, ending with %NULL
103 * Creates a new #HildonDialog. See gtk_dialog_new_with_buttons() for
106 * Return value: a new #HildonDialog
111 hildon_dialog_new_with_buttons (const gchar *title,
113 GtkDialogFlags flags,
114 const gchar *first_button_text,
119 dialog = g_object_new (HILDON_TYPE_DIALOG, NULL);
121 /* This code is copied from gtk_dialog_new_empty(), as it's a
122 * private function that we cannot use here */
124 gtk_window_set_title (GTK_WINDOW (dialog), title);
127 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
129 if (flags & GTK_DIALOG_MODAL)
130 gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
132 if (flags & GTK_DIALOG_DESTROY_WITH_PARENT)
133 gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
135 if (flags & GTK_DIALOG_NO_SEPARATOR)
136 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
138 /* This is almost copied from gtk_dialog_add_buttons_valist() */
139 if (first_button_text != NULL) {
144 va_start (args, first_button_text);
145 text = first_button_text;
146 response_id = va_arg (args, gint);
148 while (text != NULL) {
149 hildon_dialog_add_button (HILDON_DIALOG (dialog), text, response_id);
151 text = va_arg (args, gchar*);
154 response_id = va_arg (args, int);
163 * hildon_dialog_add_button:
164 * @dialog: a #HildonDialog
165 * @button_text: text of the button, or stock ID
166 * @response_id: response ID for the button.
168 * Adds a button to the dialog. Works exactly like
169 * gtk_dialog_add_button(), the only difference being that the button
172 * Returns: the button widget that was added
177 hildon_dialog_add_button (HildonDialog *dialog,
178 const gchar *button_text,
182 button = gtk_dialog_add_button (GTK_DIALOG (dialog), button_text, response_id);
187 * hildon_dialog_add_buttons:
188 * @dialog: a #HildonDialog
189 * @first_button_text: text of the button, or stock ID
190 * @Varargs: response ID for first button, then more text-response_id pairs
192 * Adds several buttons to the dialog. Works exactly like
193 * gtk_dialog_add_buttons(), the only difference being that the
194 * buttons have finger size.
199 hildon_dialog_add_buttons (HildonDialog *dialog,
200 const gchar *first_button_text,
207 va_start (args, first_button_text);
208 text = first_button_text;
209 response_id = va_arg (args, gint);
211 while (text != NULL) {
212 hildon_dialog_add_button (HILDON_DIALOG (dialog), text, response_id);
214 text = va_arg (args, gchar*);
217 response_id = va_arg (args, int);