Use gtk_dialog_set_padding() to set HildonNote margins
[hildon] / hildon / hildon-note.c
index 5ab4248..14c77c1 100644 (file)
@@ -114,6 +114,9 @@ static void
 hildon_note_rebuild                             (HildonNote *note);
 
 static void
+hildon_note_set_padding                         (HildonNote *note);
+
+static void
 hildon_note_rename                              (HildonNote *note);
 
 static void
@@ -292,6 +295,21 @@ hildon_note_get_property                        (GObject *object,
     }
 }
 
+#ifdef MAEMO_GTK
+static GObject *
+hildon_note_constructor (GType type,
+                         guint n_construct_properties,
+                         GObjectConstructParam *construct_params)
+{
+    GObject *object;
+    object = (* G_OBJECT_CLASS (parent_class)->constructor)
+        (type, n_construct_properties, construct_params);
+    hildon_note_set_padding (HILDON_NOTE (object));
+
+    return object;
+}
+#endif /* MAEMO_GTK */
+
 /**
  * hildon_note_get_type:
  *
@@ -337,6 +355,9 @@ hildon_note_class_init                          (HildonNoteClass *class)
     object_class->finalize      = hildon_note_finalize;
     object_class->set_property  = hildon_note_set_property;
     object_class->get_property  = hildon_note_get_property;
+#ifdef MAEMO_GTK
+    object_class->constructor   = hildon_note_constructor;
+#endif /* MAEMO_GTK */
     widget_class->realize       = hildon_note_realize;
     widget_class->unrealize     = hildon_note_unrealize;
     widget_class->size_request  = hildon_note_size_request;
@@ -402,7 +423,7 @@ hildon_note_class_init                          (HildonNoteClass *class)
     /**
      * HildonNote:progressbar:
      *
-     * If set, a #GtkProgressBar visible in the note.
+     * If set, a #GtkProgressBar is displayed in the note.
      */
     g_object_class_install_property (object_class,
             PROP_HILDON_NOTE_PROGRESSBAR,
@@ -664,6 +685,39 @@ hildon_note_rename                              (HildonNote *note)
   g_type_class_unref (enum_class);
 }
 
+#ifdef MAEMO_GTK
+static void
+hildon_note_set_padding (HildonNote *note)
+{
+    HildonNotePrivate *priv;
+
+    priv = HILDON_NOTE_GET_PRIVATE (note);
+
+    switch (priv->note_n) {
+    case HILDON_NOTE_TYPE_INFORMATION:
+    case HILDON_NOTE_TYPE_INFORMATION_THEME:
+        gtk_dialog_set_padding (GTK_DIALOG (note),
+                                HILDON_MARGIN_DOUBLE,
+                                HILDON_MARGIN_DOUBLE,
+                                0,
+                                0);
+        break;
+
+    case HILDON_NOTE_TYPE_CONFIRMATION:
+    case HILDON_NOTE_TYPE_CONFIRMATION_BUTTON:
+        gtk_dialog_set_padding (GTK_DIALOG (note),
+                                HILDON_MARGIN_DOUBLE,
+                                HILDON_MARGIN_DEFAULT,
+                                HILDON_MARGIN_DOUBLE,
+                                HILDON_MARGIN_DOUBLE);
+        break;
+
+    default:
+        break;
+    }
+}
+#endif /* MAEMO_GTK */
+
 static void
 hildon_note_rebuild                             (HildonNote *note)
 {
@@ -709,6 +763,13 @@ hildon_note_rebuild                             (HildonNote *note)
             g_object_get (priv->okButton, "width-request",
                           &priv->button_width, NULL);
             gtk_widget_set_no_show_all (priv->cancelButton, FALSE);
+#ifdef MAEMO_GTK
+           gtk_dialog_set_padding (dialog,
+                                   HILDON_MARGIN_DOUBLE,
+                                   HILDON_MARGIN_DEFAULT,
+                                   HILDON_MARGIN_DOUBLE,
+                                   HILDON_MARGIN_DOUBLE);
+#endif /* MAEMO_GTK */
             break;
 
         case HILDON_NOTE_TYPE_PROGRESSBAR:
@@ -720,6 +781,13 @@ hildon_note_rebuild                             (HildonNote *note)
 
         case HILDON_NOTE_TYPE_INFORMATION_THEME:
         case HILDON_NOTE_TYPE_INFORMATION:
+#ifdef MAEMO_GTK
+           gtk_dialog_set_padding (dialog,
+                                   HILDON_MARGIN_DOUBLE,
+                                   HILDON_MARGIN_DOUBLE,
+                                   0,
+                                   0);
+#endif /* MAEMO_GTK */
             is_info_note = TRUE;
             break;
 
@@ -747,6 +815,10 @@ hildon_note_rebuild                             (HildonNote *note)
     if (priv->progressbar)
         gtk_box_pack_start (GTK_BOX (priv->box), priv->progressbar, FALSE, FALSE, 0);
 
+#ifdef MAEMO_GTK
+    hildon_note_set_padding (note);
+#endif /* MAEMO_GTK */
+
     gtk_container_add (GTK_CONTAINER (dialog->vbox), priv->event_box);
 
     gtk_widget_show_all (priv->event_box);
@@ -774,7 +846,7 @@ hildon_note_rebuild                             (HildonNote *note)
  * it would only contain the "additional" buttons? However, changing
  * this would break those applications that rely on current behaviour.
  *
- * Returns: A #GtkWidget pointer of the note
+ * Returns: A new #HildonNote.
  */
 GtkWidget*
 hildon_note_new_confirmation_add_buttons        (GtkWindow *parent,
@@ -830,12 +902,12 @@ hildon_note_new_confirmation_add_buttons        (GtkWindow *parent,
  *   important so that the window manager could handle the windows
  *   correctly. In GTK the X window ID can be checked using
  *   GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
- * @description: the message to confirm
+ * @description: the message to confirm.
  *
  * Create a new confirmation note. Confirmation note has a text (description)
  * that you specify and two buttons.
  *
- * Returns: a #GtkWidget pointer of the note
+ * Returns: a new #HildonNote.
  */
 GtkWidget*
 hildon_note_new_confirmation                    (GtkWindow *parent,
@@ -872,7 +944,7 @@ hildon_note_new_confirmation                    (GtkWindow *parent,
  * Deprecated: Since 2.2, icons are not shown in confirmation notes. Icons set
  * with this function will be ignored. Use hildon_note_new_confirmation() instead.
  *
- * Returns: a #GtkWidget pointer of the note
+ * Returns: a new #HildonNote.
  */
 GtkWidget*
 hildon_note_new_confirmation_with_icon_name     (GtkWindow *parent,
@@ -894,12 +966,12 @@ hildon_note_new_confirmation_with_icon_name     (GtkWindow *parent,
  *   important so that the window manager could handle the windows
  *   correctly. In GTK the X window ID can be checked using
  *   GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
- * @description: the message to confirm
+ * @description: the message to confirm.
  * 
- * Create a new information note. Information note has a text (description)
+ * Create a new information note. Information note has text (a description)
  * that you specify and an OK button.
  * 
- * Returns: a #GtkWidget pointer of the note
+ * Returns: a new #HildonNote.
  */
 GtkWidget*
 hildon_note_new_information                     (GtkWindow *parent,
@@ -927,16 +999,17 @@ hildon_note_new_information                     (GtkWindow *parent,
  *   important so that the window manager could handle the windows
  *   correctly. In GTK the X window ID can be checked using
  *   GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
- * @description: the message to confirm
- * @icon_name: icon to be displayed. If NULL, default icon is used.
+ * @description: the message to confirm.
+ * @icon_name: icon to be displayed. If %NULL, the default icon is used.
  * 
- * Create a new information note. Information note has text(description) 
+ * Create a new information note. An information note has text (a description)
  * that you specify, an OK button and an icon.
  * 
  * Deprecated: Since 2.2, icons are not shown in confirmation notes. Icons set
- * with this function will be ignored. Use hildon_note_new_information() instead.
+ * with this function will be ignored. Use hildon_note_new_information()
+ * instead.
  *
- * Returns: a #GtkWidget pointer of the note
+ * Returns: a new #HildonNote.
  */
 GtkWidget*
 hildon_note_new_information_with_icon_name      (GtkWindow * parent,
@@ -960,7 +1033,7 @@ hildon_note_new_information_with_icon_name      (GtkWindow * parent,
  *   important so that the window manager could handle the windows
  *   correctly. In GTK the X window ID can be checked using
  *   GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
- * @description: the action to cancel
+ * @description: the action to cancel.
  * @progressbar: a pointer to #GtkProgressBar to be filled with the
  *   progressbar assigned to this note. Use this to set the fraction of
  *   progressbar done. This parameter can be %NULL as well, in which
@@ -997,8 +1070,8 @@ hildon_note_new_cancel_with_progress_bar        (GtkWindow *parent,
 
 /**
  * hildon_note_set_button_text:
- * @note: a #HildonNote
- * @text: sets the button text and if there is two buttons in dialog, 
+ * @note: a #HildonNote.
+ * @text: sets the button text. If there are two buttons in dialog,
  *   the button texts will be <text>, "Cancel".  
  *
  * Sets the text of the button in @note.
@@ -1025,9 +1098,9 @@ hildon_note_set_button_text                     (HildonNote *note,
 
 /**
  * hildon_note_set_button_texts:
- * @note: a #HildonNote
- * @text_ok: the new text of the default OK button
- * @text_cancel: the new text of the default cancel button 
+ * @note: a #HildonNote.
+ * @text_ok: the new text of the default OK button.
+ * @text_cancel: the new text of the default cancel button.
  *
  * Sets the text for the buttons in @note.
  */