2009-03-16 Claudio Saavedra <csaavedra@igalia.com>
[hildon] / src / hildon-dialog.c
index b7e7d14..4d0e68c 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 2008 Nokia Corporation, all rights reserved.
  *
- * Contact: Karl Lattimer <karl.lattimer@nokia.com>
+ * 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
  * @short_description: Widget representing a popup window in the Hildon framework.
  * @see_also: #HildonCodeDialog, #HildonColorChooserDialog, #HildonFontSelectionDialog, #HildonGetPasswordDialog, #HildonLoginDialog, #HildonSetPasswordDialog, #HildonSortDialog, #HildonWizardDialog
  *
- * The HildonDialog is a GTK widget which represent a popup window in the
- * Hildon framework. It is derived from the GtkDialog and provides additional
+ * #HildonDialog is a GTK widget which represent 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.
+ *
  * <example>
  * <title>Simple <structname>HildonDialog</structname> usage</title>
  * <programlisting>
  * </example>
  */
 
+#undef                                          HILDON_DISABLE_DEPRECATED
+
 #include                                        "hildon-dialog.h"
+#include                                        "hildon-gtk.h"
 
 G_DEFINE_TYPE (HildonDialog, hildon_dialog, GTK_TYPE_DIALOG);
 
@@ -76,6 +81,8 @@ hildon_dialog_init                              (HildonDialog *self)
  * Creates a new #HildonDialog widget
  *
  * Returns: the newly created #HildonDialog
+ *
+ * Since: 2.2
  */
 GtkWidget*
 hildon_dialog_new                               (void)
@@ -97,6 +104,8 @@ hildon_dialog_new                               (void)
  * more information.
  *
  * Return value: a new #HildonDialog
+ *
+ * Since: 2.2
  */
 GtkWidget*
 hildon_dialog_new_with_buttons                  (const gchar *title,
@@ -124,7 +133,7 @@ hildon_dialog_new_with_buttons                  (const gchar *title,
         gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
 
     if (flags & GTK_DIALOG_NO_SEPARATOR)
-        gtk_dialog_set_has_separator (dialog, FALSE);
+        gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
 
     /* This is almost copied from gtk_dialog_add_buttons_valist() */
     if (first_button_text != NULL) {
@@ -137,7 +146,7 @@ hildon_dialog_new_with_buttons                  (const gchar *title,
         response_id = va_arg (args, gint);
 
         while (text != NULL) {
-            gtk_dialog_add_button (GTK_DIALOG (dialog), text, response_id);
+            hildon_dialog_add_button (HILDON_DIALOG (dialog), text, response_id);
 
             text = va_arg (args, gchar*);
             if (text == NULL)
@@ -149,3 +158,65 @@ hildon_dialog_new_with_buttons                  (const gchar *title,
 
     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);
+}
+