2 * This file is part of hildon-libs
4 * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
6 * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@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 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
27 * @short_description: A widget to ask confirmation from the user
29 * Notes are used to for confirmation (OK/Cancel/etc.) from the user.
30 * A simple note contains an information text and an OK button to be
31 * pressed. Additional features such as progress bars or animation can
39 #include "hildon-note.h"
40 #include <gtk/gtklabel.h>
41 #include <gtk/gtkimage.h>
42 #include <gtk/gtkhbox.h>
43 #include <gtk/gtkalignment.h>
44 #include <gtk/gtkvbox.h>
45 #include <gtk/gtkbutton.h>
47 #include <hildon-widgets/hildon-defines.h>
48 #include <hildon-widgets/hildon-system-sound.h>
49 #include <hildon-widgets/hildon-banner.h> /* for _hildon_gtk_label_set_text_n_lines */
54 /* FIXME: Can these be included from somewhere? */
55 #define CONFIRMATION_SOUND_PATH "/usr/share/sounds/ui-confirmation_note.wav"
56 #define INFORMATION_SOUND_PATH "/usr/share/sounds/ui-information_note.wav"
57 #define HILDON_NOTE_CONFIRMATION_ICON "qgn_note_confirm"
58 #define HILDON_NOTE_INFORMATION_ICON "qgn_note_info"
60 #define _(String) dgettext(PACKAGE, String)
62 static GtkDialogClass *parent_class;
64 #define HILDON_NOTE_GET_PRIVATE(obj)\
65 (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
66 HILDON_TYPE_NOTE, HildonNotePrivate));
68 typedef struct _HildonNotePrivate HildonNotePrivate;
70 static void hildon_note_class_init(HildonNoteClass * class);
71 static void hildon_note_init(HildonNote * dialog);
73 static void hildon_note_rebuild(HildonNote *note);
74 static void hildon_note_finalize(GObject * obj_self);
75 static void hildon_note_realize (GtkWidget *widget);
77 static void hildon_note_set_property(GObject * object,
81 static void hildon_note_get_property(GObject * object,
83 GValue * value, GParamSpec * pspec);
86 sound_handling(GtkWidget * widget, GdkEventExpose *event, gpointer data);
88 struct _HildonNotePrivate {
90 GtkWidget *cancelButton;
95 HildonNoteType note_n;
96 GtkWidget *progressbar;
97 gulong sound_signal_handler;
99 gchar *original_description;
104 PROP_HILDON_NOTE_TYPE,
105 PROP_HILDON_NOTE_DESCRIPTION,
106 PROP_HILDON_NOTE_ICON,
107 PROP_HILDON_NOTE_PROGRESSBAR,
108 PROP_HILDON_NOTE_STOCK_ICON
112 hildon_note_set_property(GObject * object,
114 const GValue * value, GParamSpec * pspec)
116 HildonNote *note = HILDON_NOTE(object);
117 HildonNotePrivate *priv;
120 priv = HILDON_NOTE_GET_PRIVATE(note);
123 case PROP_HILDON_NOTE_TYPE:
124 priv->note_n = g_value_get_enum(value);
125 hildon_note_rebuild(note);
127 case PROP_HILDON_NOTE_DESCRIPTION:
128 g_free(priv->original_description);
129 priv->original_description = g_value_dup_string(value);
131 _hildon_gtk_label_set_text_n_lines(GTK_LABEL(priv->label),
132 priv->original_description,
133 priv->note_n == HILDON_NOTE_PROGRESSBAR_TYPE ? 1 : 5);
136 case PROP_HILDON_NOTE_ICON:
137 gtk_image_set_from_icon_name(GTK_IMAGE(priv->icon),
138 g_value_get_string(value), HILDON_ICON_SIZE_BIG_NOTE);
140 case PROP_HILDON_NOTE_STOCK_ICON:
141 gtk_image_set_from_stock(GTK_IMAGE(priv->icon),
142 g_value_get_string(value), HILDON_ICON_SIZE_BIG_NOTE);
144 case PROP_HILDON_NOTE_PROGRESSBAR:
145 widget = g_value_get_object(value);
146 if (widget != priv->progressbar)
148 if (priv->progressbar)
149 g_object_unref(priv->progressbar);
151 priv->progressbar = widget;
155 g_object_ref(widget);
156 gtk_object_sink(GTK_OBJECT(widget));
159 hildon_note_rebuild(note);
163 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
169 hildon_note_get_property(GObject * object,
170 guint prop_id, GValue * value, GParamSpec * pspec)
172 HildonNote *note = HILDON_NOTE(object);
173 HildonNotePrivate *priv;
175 priv = HILDON_NOTE_GET_PRIVATE(note);
178 case PROP_HILDON_NOTE_TYPE:
179 g_value_set_enum(value, priv->note_n);
181 case PROP_HILDON_NOTE_DESCRIPTION:
182 g_value_set_string(value, priv->original_description);
184 case PROP_HILDON_NOTE_ICON:
185 g_object_get_property(G_OBJECT(priv->icon), "icon-name", value);
187 case PROP_HILDON_NOTE_STOCK_ICON:
188 g_object_get_property(G_OBJECT(priv->icon), "stock", value);
190 case PROP_HILDON_NOTE_PROGRESSBAR:
191 g_value_set_object(value, priv->progressbar);
194 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
199 GType hildon_note_type_get_type (void)
201 static GType notetype = 0;
203 static const GEnumValue values[] = {
204 { HILDON_NOTE_CONFIRMATION_TYPE, "HILDON_NOTE_CONFIRMATION_TYPE", "confirmation" },
205 { HILDON_NOTE_CONFIRMATION_BUTTON_TYPE, "HILDON_NOTE_CONFIRMATION_BUTTON_TYPE", "confirmation-button" },
206 { HILDON_NOTE_INFORMATION_TYPE, "HILDON_NOTE_INFORMATION_TYPE", "note-information" },
207 { HILDON_NOTE_INFORMATION_THEME_TYPE, "HILDON_NOTE_INFORMATION_THEME_TYPE", "note-information-theme" },
208 { HILDON_NOTE_PROGRESSBAR_TYPE, "HILDON_NOTE_PROGRESSBAR_TYPE", "note-progressbar" },
211 notetype = g_enum_register_static ("HildonNoteType", values);
217 GType hildon_note_get_type()
219 static GType dialog_type = 0;
222 static const GTypeInfo dialog_info = {
223 sizeof(HildonNoteClass),
224 NULL, /* base_init */
225 NULL, /* base_finalize */
226 (GClassInitFunc) hildon_note_class_init,
227 NULL, /* class_finalize */
228 NULL, /* class_data */
231 (GInstanceInitFunc) hildon_note_init
233 dialog_type = g_type_register_static(GTK_TYPE_DIALOG,
240 static void hildon_note_class_init(HildonNoteClass * class)
242 GObjectClass *object_class = G_OBJECT_CLASS(class);
243 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(class);
245 /* set the global parent_class */
246 parent_class = g_type_class_peek_parent(class);
248 g_type_class_add_private(class, sizeof(HildonNotePrivate));
250 object_class->finalize = hildon_note_finalize;
251 object_class->set_property = hildon_note_set_property;
252 object_class->get_property = hildon_note_get_property;
253 widget_class->realize = hildon_note_realize;
255 g_object_class_install_property(object_class,
256 PROP_HILDON_NOTE_TYPE,
257 g_param_spec_enum("note_type",
259 "The type of the note dialog",
260 hildon_note_type_get_type(),
261 HILDON_NOTE_CONFIRMATION_TYPE,
262 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
265 * HildonNote:description:
267 * Description for note.
269 g_object_class_install_property(object_class,
270 PROP_HILDON_NOTE_DESCRIPTION,
271 g_param_spec_string("description",
273 "The text that appears in the note dialog",
282 g_object_class_install_property(object_class,
283 PROP_HILDON_NOTE_ICON,
284 g_param_spec_string("icon",
286 "The name of the icon that appears in the note dialog",
291 * HildonNote:stock-icon:
293 * Stock icon for note.
295 g_object_class_install_property(object_class,
296 PROP_HILDON_NOTE_STOCK_ICON,
297 g_param_spec_string("stock-icon",
299 "The stock name of the icon that appears in the note dialog",
304 * HildonNote:progressbar:
306 * Progressbar for note.
308 g_object_class_install_property(object_class,
309 PROP_HILDON_NOTE_PROGRESSBAR,
310 g_param_spec_object("progressbar",
311 "Progressbar widget",
312 "The progressbar that appears in the note dialog",
313 GTK_TYPE_PROGRESS_BAR,
317 static void hildon_note_init(HildonNote * dialog)
319 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE(dialog);
321 priv->label = gtk_label_new(NULL);
322 priv->icon = gtk_image_new();
324 /* Acquire real references to our internal children, since
325 they are not nessecarily packed into container in each
327 g_object_ref(priv->label);
328 g_object_ref(priv->icon);
329 gtk_object_sink(GTK_OBJECT(priv->label));
330 gtk_object_sink(GTK_OBJECT(priv->icon));
332 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
333 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
337 static void hildon_note_finalize(GObject * obj_self)
339 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE(obj_self);
341 /* Free internal data */
342 g_object_unref(priv->label);
343 g_object_unref(priv->icon);
344 if (priv->progressbar)
345 g_object_unref(priv->progressbar);
347 g_free(priv->original_description);
349 G_OBJECT_CLASS(parent_class)->finalize(obj_self);
353 hildon_note_realize (GtkWidget *widget)
355 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE(widget);
357 /* Make widget->window accessible */
358 GTK_WIDGET_CLASS (parent_class)->realize (widget);
360 /* Border only, no titlebar */
361 gdk_window_set_decorations (widget->window, GDK_DECOR_BORDER);
363 /* Because ESD is synchronous, we wish to play sound after the
364 note is already on screen to avoid blocking its appearance */
365 if (priv->sound_signal_handler == 0)
366 priv->sound_signal_handler = g_signal_connect_after(widget,
367 "expose-event", G_CALLBACK(sound_handling), NULL);
370 /* Helper function for removing a widget from it's container.
371 we own a separate reference to each object we try to unpack,
372 so extra referencing is not needed. */
373 static void unpack_widget(GtkWidget *widget)
375 g_assert(widget == NULL || GTK_IS_WIDGET(widget));
377 if (widget && widget->parent)
378 gtk_container_remove(GTK_CONTAINER(widget->parent), widget);
382 hildon_note_rebuild(HildonNote *note)
385 HildonNotePrivate *priv;
386 gboolean IsHorizontal = TRUE;
388 g_assert(HILDON_IS_NOTE(note));
390 priv = HILDON_NOTE_GET_PRIVATE (note);
391 dialog = GTK_DIALOG(note);
393 /* Reuse exiting content widgets for new layout */
394 unpack_widget(priv->label);
395 unpack_widget(priv->icon);
396 unpack_widget(priv->progressbar);
398 /* Destroy old layout and buttons */
400 gtk_widget_destroy(priv->box);
403 if (priv->okButton) {
404 gtk_widget_destroy(priv->okButton);
405 priv->okButton = NULL;
407 if (priv->cancelButton) {
408 gtk_widget_destroy(priv->cancelButton);
409 priv->cancelButton = NULL;
412 /* Add needed buttons and images for each note type */
413 switch (priv->note_n)
415 case HILDON_NOTE_CONFIRMATION_TYPE:
416 priv->okButton = gtk_dialog_add_button(dialog,
417 _("ecdg_bd_confirmation_note_ok"), GTK_RESPONSE_OK);
418 priv->cancelButton = gtk_dialog_add_button(dialog,
419 _("ecdg_bd_confirmation_note_cancel"), GTK_RESPONSE_CANCEL);
422 case HILDON_NOTE_CONFIRMATION_BUTTON_TYPE:
423 gtk_image_set_from_icon_name(GTK_IMAGE(priv->icon),
424 HILDON_NOTE_CONFIRMATION_ICON,
425 HILDON_ICON_SIZE_BIG_NOTE);
428 case HILDON_NOTE_INFORMATION_THEME_TYPE:
429 case HILDON_NOTE_INFORMATION_TYPE:
430 /* Add clickable OK button (cancel really,
431 but doesn't matter since this is info) */
432 priv->cancelButton = gtk_dialog_add_button(dialog,
433 _("ecdg_bd_information_note_ok"), GTK_RESPONSE_CANCEL);
434 gtk_image_set_from_icon_name(GTK_IMAGE(priv->icon),
435 HILDON_NOTE_INFORMATION_ICON,
436 HILDON_ICON_SIZE_BIG_NOTE);
439 case HILDON_NOTE_PROGRESSBAR_TYPE:
440 priv->cancelButton = gtk_dialog_add_button(dialog,
441 _("ecdg_bd_cancel_note_cancel"), GTK_RESPONSE_CANCEL);
442 IsHorizontal = FALSE;
450 /* Pack item with label horizontally */
451 priv->box = gtk_hbox_new(FALSE, HILDON_MARGIN_DEFAULT);
452 gtk_container_add(GTK_CONTAINER(dialog->vbox), priv->box);
455 GtkWidget *alignment = gtk_alignment_new(0, 0, 0, 0);
457 gtk_box_pack_start(GTK_BOX(priv->box), alignment, FALSE, FALSE, 0);
458 gtk_container_add(GTK_CONTAINER(alignment), priv->icon);
460 gtk_box_pack_start(GTK_BOX(priv->box), priv->label, TRUE, TRUE, 0);
463 /* Pack item with label vertically */
464 priv->box = gtk_vbox_new(FALSE, HILDON_MARGIN_DOUBLE);
465 gtk_container_add(GTK_CONTAINER(dialog->vbox), priv->box);
466 gtk_box_pack_start(GTK_BOX(priv->box), priv->label, TRUE, TRUE, 0);
468 if (priv->progressbar)
469 gtk_box_pack_start(GTK_BOX(priv->box), priv->progressbar, FALSE, FALSE, 0);
472 gtk_widget_show_all(priv->box);
476 * hildon_note_new_confirmation_add_buttons:
477 * @parent: the parent window. The X window ID of the parent window
478 * has to be the same as the X window ID of the application. This is
479 * important so that the window manager could handle the windows
481 * In GTK the X window ID can be checked using
482 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
483 * @description: the message to confirm
484 * @Varargs: arguments pairs for new buttons(label and return value).
485 * Terminate the list with %NULL value.
487 * Create a new confirmation note with custom buttons. Confirmation
488 * note has a text and any number of buttons. It's important to note
489 * that even though the name of the function might suggest, the
490 * default ok/cancel buttons are not appended but you have to provide
491 * all of the buttons.
493 * FIXME: This doc seems to be wrong, the two buttons aren't added so
494 * it would only contain the "additional" buttons? However, changing
495 * this would break those applications that rely on current behaviour.
497 * Returns: A #GtkWidget pointer of the note
499 GtkWidget *hildon_note_new_confirmation_add_buttons(GtkWindow *parent,
500 const gchar *description,
507 g_return_val_if_fail(parent == NULL || GTK_IS_WINDOW(parent), NULL);
509 GtkWidget *conf_note =
510 g_object_new(HILDON_TYPE_NOTE,
511 "note_type", HILDON_NOTE_CONFIRMATION_BUTTON_TYPE,
512 "description", description,
513 "icon", HILDON_NOTE_CONFIRMATION_ICON,
517 gtk_window_set_transient_for(GTK_WINDOW(conf_note), parent);
519 /* Add the buttons from varargs */
520 va_start(args, description);
523 message = va_arg(args, char *);
528 value = va_arg(args, int);
530 gtk_dialog_add_button(GTK_DIALOG(conf_note), message, value);
540 * hildon_note_new_confirmation:
541 * @parent: the parent window. The X window ID of the parent window
542 * has to be the same as the X window ID of the application. This is
543 * important so that the window manager could handle the windows
544 * correctly. In GTK the X window ID can be checked using
545 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
546 * @description: the message to confirm
548 * Create a new confirmation note. Confirmation note has text (description)
549 * that you specify, two buttons and a default confirmation stock icon.
551 * Returns: a #GtkWidget pointer of the note
553 GtkWidget *hildon_note_new_confirmation(GtkWindow * parent,
554 const gchar * description)
556 return hildon_note_new_confirmation_with_icon_name
557 (parent, description, HILDON_NOTE_CONFIRMATION_ICON);
562 * hildon_note_new_confirmation_with_icon_stock:
563 * @parent: the parent window. The X window ID of the parent window
564 * has to be the same as the X window ID of the application. This is
565 * important so that the window manager could handle the windows
566 * correctly. In GTK the X window ID can be checked using
567 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
568 * @description: the message to confirm
569 * @stock_id: icon to be displayed. If NULL, default icon is used.
571 * Create a new confirmation note. Confirmation note has text (description)
572 * that you specify, two buttons and an icon.
574 * Deprecated: this function is broken, and really should not be used by anyone!
576 * Returns: a #GtkWidget pointer of the note
578 GtkWidget *hildon_note_new_confirmation_with_icon_stock(GtkWindow * parent,
584 GtkWidget *dialog = g_object_new(HILDON_TYPE_NOTE,
586 HILDON_NOTE_CONFIRMATION_TYPE,
587 "description", description, "stock-icon",
591 gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
597 * hildon_note_new_confirmation_with_icon_name:
598 * @parent: the parent window. The X window ID of the parent window
599 * has to be the same as the X window ID of the application. This is
600 * important so that the window manager could handle the windows
601 * correctly. In GTK the X window ID can be checked using
602 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
603 * @description: the message to confirm
604 * @icon_name: icon to be displayed. If NULL, default icon is used.
606 * Create a new confirmation note. Confirmation note has text(description)
607 * that you specify, two buttons and an icon.
609 * Returns: a #GtkWidget pointer of the note
611 GtkWidget *hildon_note_new_confirmation_with_icon_name(GtkWindow * parent,
617 GtkWidget *dialog = NULL;
619 g_return_val_if_fail(parent == NULL || GTK_IS_WINDOW(parent), NULL);
621 dialog = g_object_new(HILDON_TYPE_NOTE,
623 HILDON_NOTE_CONFIRMATION_TYPE,
624 "description", description, "icon",
627 gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
633 * hildon_note_new_information:
634 * @parent: the parent window. The X window ID of the parent window
635 * has to be the same as the X window ID of the application. This is
636 * important so that the window manager could handle the windows
637 * correctly. In GTK the X window ID can be checked using
638 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
639 * @description: the message to confirm
641 * Create a new information note. Information note has a text(description)
642 * that you specify, an OK button and an icon.
644 * Returns: a #GtkWidget pointer of the note
646 GtkWidget *hildon_note_new_information(GtkWindow * parent,
647 const gchar * description)
649 return hildon_note_new_information_with_icon_name
650 (parent, description, HILDON_NOTE_INFORMATION_ICON);
654 * hildon_note_new_information_with_icon_stock:
655 * @parent: the parent window. The X window ID of the parent window
656 * has to be the same as the X window ID of the application. This is
657 * important so that the window manager could handle the windows
658 * correctly. In GTK the X window ID can be checked using
659 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
660 * @description: the message to confirm
661 * @stock_id: icon to be displayed. If NULL, default icon is used.
663 * Create a new information note. Information note has text(description)
664 * that you specify, an OK button and a default stock note icon.
666 * Note! This function is broken and deprecated and should not be
667 * used by anybody. Since the platform doesn't use stock icons,
668 * use #hildon_note_new_information_with_icon_name instead.
670 * Returns: a #GtkWidget pointer of the note
672 GtkWidget *hildon_note_new_information_with_icon_stock(GtkWindow * parent,
678 GtkWidget *dialog = NULL;
680 g_return_val_if_fail(parent == NULL || GTK_IS_WINDOW(parent), NULL);
682 dialog = g_object_new(HILDON_TYPE_NOTE,
684 HILDON_NOTE_INFORMATION_TYPE,
685 "description", description,
686 "icon", stock_id, NULL);
688 gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
694 * hildon_note_new_information_with_icon_name:
695 * @parent: the parent window. The X window ID of the parent window
696 * has to be the same as the X window ID of the application. This is
697 * important so that the window manager could handle the windows
698 * correctly. In GTK the X window ID can be checked using
699 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
700 * @description: the message to confirm
701 * @icon_name: icon to be displayed. If NULL, default icon is used.
703 * Create a new information note. Information note has text(description)
704 * that you specify, an OK button and an icon.
706 * Returns: a #GtkWidget pointer of the note
708 GtkWidget *hildon_note_new_information_with_icon_name(GtkWindow * parent,
714 GtkWidget *dialog = NULL;
716 g_return_val_if_fail(parent == NULL || GTK_IS_WINDOW(parent), NULL);
718 dialog = g_object_new(HILDON_TYPE_NOTE,
720 HILDON_NOTE_INFORMATION_THEME_TYPE,
721 "description", description,
722 "icon", icon_name, NULL);
724 gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
730 * hildon_note_new_information_with_icon_theme:
731 * @parent: the parent window. The X window ID of the parent window
732 * has to be the same as the X window ID of the application. This is
733 * important so that the window manager could handle the windows
734 * correctly. In GTK the X window ID can be checked using
735 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
736 * @description: the message to confirm
737 * @icon: #GtkIconTheme icon to be displayed
739 * This function is deprecated. Use
740 * #hildon_note_new_information_with_icon_name instead.
742 * Create a new information note. Information note has text(description)
743 * that you specify, an OK button and an icon.
745 * Returns: a #GtkWidget pointer of the note.
747 GtkWidget *hildon_note_new_information_with_icon_theme(GtkWindow *parent,
748 const gchar *description,
751 return hildon_note_new_information_with_icon_name(parent, description, icon);
755 * hildon_note_new_cancel_with_progress_bar:
756 * @parent: the parent window. The X window ID of the parent window
757 * has to be the same as the X window ID of the application. This is
758 * important so that the window manager could handle the windows
759 * correctly. In GTK the X window ID can be checked using
760 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
761 * @description: the action to cancel
762 * @progressbar: a pointer to #GtkProgressBar to be filled with the
763 * progressbar assigned to this note. Use this to set the fraction of
764 * progressbar done. This parameter can be %NULL as well, in which
765 * case plain text cancel note appears.
767 * Create a new cancel note with a progress bar. Cancel note has
768 * text(description) that you specify, a Cancel button and a progress bar.
770 * Returns: a #GtkDialog. Use this to get rid of this note when you
773 GtkWidget *hildon_note_new_cancel_with_progress_bar(GtkWindow * parent,
779 GtkWidget *dialog = NULL;
781 g_return_val_if_fail(parent == NULL || GTK_IS_WINDOW(parent), NULL);
783 dialog = g_object_new(HILDON_TYPE_NOTE,
785 HILDON_NOTE_PROGRESSBAR_TYPE,
786 "description", description,
790 gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
797 * hildon_note_set_button_text:
798 * @note: a #HildonNote
799 * @text: sets the button text and if there is two buttons in dialog,
800 * the button texts will be <text>, "Cancel".
802 * Sets the button text to be used by the hildon_note widget.
804 void hildon_note_set_button_text(HildonNote * note, const gchar * text)
806 HildonNotePrivate *priv;
808 g_return_if_fail(HILDON_IS_NOTE(note));
810 priv = HILDON_NOTE_GET_PRIVATE(HILDON_NOTE(note));
811 if (priv->okButton) {
812 gtk_button_set_label(GTK_BUTTON(priv->okButton), text);
813 gtk_button_set_label(GTK_BUTTON(priv->cancelButton),
814 _("ecdg_bd_confirmation_note_cancel"));
816 gtk_button_set_label(GTK_BUTTON(priv->cancelButton), text);
821 * hildon_note_set_button_texts:
822 * @note: a #HildonNote
823 * @textOk: the new text of the default OK button
824 * @textCancel: the new text of the default cancel button
826 * Sets the button texts to be used by this hildon_note widget.
828 void hildon_note_set_button_texts(HildonNote * note,
829 const gchar * textOk,
830 const gchar * textCancel)
832 HildonNotePrivate *priv;
834 g_return_if_fail(HILDON_IS_NOTE(note));
836 priv = HILDON_NOTE_GET_PRIVATE(HILDON_NOTE(note));
837 if (priv->okButton) {
838 gtk_button_set_label(GTK_BUTTON(priv->okButton), textOk);
839 gtk_button_set_label(GTK_BUTTON(priv->cancelButton),
842 gtk_button_set_label(GTK_BUTTON(priv->cancelButton), textCancel);
846 /* We play a system sound when the note comes visible */
848 sound_handling(GtkWidget * widget, GdkEventExpose *event, gpointer data)
850 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE(widget);
851 g_signal_handler_disconnect(widget, priv->sound_signal_handler);
852 priv->sound_signal_handler = 0;
854 switch (priv->note_n)
856 case HILDON_NOTE_INFORMATION_TYPE:
857 case HILDON_NOTE_INFORMATION_THEME_TYPE:
858 hildon_play_system_sound(INFORMATION_SOUND_PATH);
860 case HILDON_NOTE_CONFIRMATION_TYPE:
861 case HILDON_NOTE_CONFIRMATION_BUTTON_TYPE:
862 hildon_play_system_sound(CONFIRMATION_SOUND_PATH);