2 * This file is a part of hildon
4 * Copyright (C) 2005, 2006 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
27 * @short_description: A widget to ask confirmation from the user.
29 * #HildonNote is a convenient way to prompt users for a small amount of
30 * input. A simple note contains an information text and, in case of
31 * confirmation notes, it shows buttons to confirm or cancel. It also can
32 * include a progress bar.
34 * This widget provides convenient functions to create either
35 * information notes, confirmation notes or cancel notes, which are
36 * useful to show the progress of a requested task allowing the user
39 * To create information notes you can use
40 * hildon_note_new_information(). hildon_note_new_confirmation()
41 * creates a note with a text and two buttons to confirm or
42 * cancel. Note that it is possible to create a confirmation note with
43 * customized buttons by using
44 * hildon_note_new_confirmation_add_buttons().
46 * To create a note with a text, a progress bar and cancel button,
47 * hildon_note_new_cancel_with_progress_bar() can be used.
50 * <title>HildonNote example</title>
54 * show_confirmation_note (GtkWindow *parent)
58 * note = hildon_note_new_confirmation (parent, "Confirmation message...");
60 * retcode = gtk_dialog_run (GTK_DIALOG (note));
61 * gtk_widget_destroy (note);
63 * if (retcode == GTK_RESPONSE_OK) {
64 * g_debug ("User pressed 'OK' button'");
67 * g_debug ("User pressed 'Cancel' button");
83 #include <X11/Xatom.h>
86 #undef HILDON_DISABLE_DEPRECATED
88 #include "hildon-note.h"
89 #include "hildon-defines.h"
90 #include "hildon-sound.h"
91 #include "hildon-banner.h"
92 #include "hildon-enum-types.h"
93 #include "hildon-note-private.h"
95 #define HILDON_INFORMATION_NOTE_MIN_HEIGHT 140
97 #define HILDON_INFORMATION_NOTE_MARGIN 100
99 #define CONFIRMATION_SOUND_PATH \
100 "/usr/share/sounds/ui-confirmation_note.wav"
102 #define INFORMATION_SOUND_PATH \
103 "/usr/share/sounds/ui-information_note.wav"
105 #define _(String) dgettext("hildon-libs", String)
108 hildon_note_class_init (HildonNoteClass *class);
111 hildon_note_init (HildonNote *dialog);
114 hildon_note_rebuild (HildonNote *note);
117 hildon_note_finalize (GObject *obj_self);
120 hildon_note_realize (GtkWidget *widget);
123 hildon_note_unrealize (GtkWidget *widget);
126 label_size_request (GtkWidget *label,
131 hildon_note_set_property (GObject *object,
137 hildon_note_get_property (GObject *object,
143 sound_handling (GtkWidget *widget,
144 GdkEventExpose *event,
150 PROP_HILDON_NOTE_TYPE,
151 PROP_HILDON_NOTE_DESCRIPTION,
152 PROP_HILDON_NOTE_ICON,
153 PROP_HILDON_NOTE_PROGRESSBAR,
154 PROP_HILDON_NOTE_STOCK_ICON
157 static GtkDialogClass* parent_class;
160 event_box_press_event (GtkEventBox *event_box,
161 GdkEventButton *event,
164 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (note);
166 if (priv->note_n == HILDON_NOTE_TYPE_INFORMATION ||
167 priv->note_n == HILDON_NOTE_TYPE_INFORMATION_THEME) {
168 gtk_dialog_response (note, GTK_RESPONSE_DELETE_EVENT);
176 hildon_note_set_property (GObject *object,
181 HildonNote *note = HILDON_NOTE (object);
182 HildonNotePrivate *priv;
185 priv = HILDON_NOTE_GET_PRIVATE (note);
190 case PROP_HILDON_NOTE_TYPE:
191 priv->note_n = g_value_get_enum (value);
192 hildon_note_rebuild (note);
195 case PROP_HILDON_NOTE_DESCRIPTION:
196 if (priv->original_description)
197 g_free (priv->original_description);
198 priv->original_description = g_value_dup_string (value);
200 gtk_label_set_text (GTK_LABEL (priv->label), priv->original_description);
201 /* FIXME Is the "original_description" used anywhere? */
205 case PROP_HILDON_NOTE_ICON:
209 priv->icon = g_value_dup_string (value);
212 case PROP_HILDON_NOTE_STOCK_ICON:
213 if (priv->stock_icon) {
214 g_free (priv->stock_icon);
216 priv->stock_icon = g_value_dup_string (value);
219 case PROP_HILDON_NOTE_PROGRESSBAR:
220 widget = g_value_get_object (value);
221 if (widget != priv->progressbar)
223 if (priv->progressbar)
224 g_object_unref (priv->progressbar);
226 priv->progressbar = widget;
230 g_object_ref (widget);
231 gtk_object_sink (GTK_OBJECT (widget));
234 hildon_note_rebuild (note);
239 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
245 hildon_note_get_property (GObject *object,
250 HildonNote *note = HILDON_NOTE (object);
251 HildonNotePrivate *priv;
253 priv = HILDON_NOTE_GET_PRIVATE (note);
257 case PROP_HILDON_NOTE_TYPE:
258 g_value_set_enum (value, priv->note_n);
261 case PROP_HILDON_NOTE_DESCRIPTION:
262 g_value_set_string (value, priv->original_description);
265 case PROP_HILDON_NOTE_ICON:
266 g_value_set_string (value, priv->icon);
269 case PROP_HILDON_NOTE_STOCK_ICON:
270 g_value_set_string (value, priv->stock_icon);
273 case PROP_HILDON_NOTE_PROGRESSBAR:
274 g_value_set_object (value, priv->progressbar);
278 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
284 * hildon_note_get_type:
286 * Returns GType for HildonNote.
288 * Returns: HildonNote type
291 hildon_note_get_type (void)
293 static GType dialog_type = 0;
296 static const GTypeInfo dialog_info = {
297 sizeof(HildonNoteClass),
298 NULL, /* base_init */
299 NULL, /* base_finalize */
300 (GClassInitFunc) hildon_note_class_init,
301 NULL, /* class_finalize */
302 NULL, /* class_data */
305 (GInstanceInitFunc) hildon_note_init
307 dialog_type = g_type_register_static (GTK_TYPE_DIALOG,
315 hildon_note_class_init (HildonNoteClass *class)
317 GObjectClass *object_class = G_OBJECT_CLASS (class);
318 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
320 /* set the global parent_class */
321 parent_class = g_type_class_peek_parent (class);
323 g_type_class_add_private (class, sizeof (HildonNotePrivate));
325 object_class->finalize = hildon_note_finalize;
326 object_class->set_property = hildon_note_set_property;
327 object_class->get_property = hildon_note_get_property;
328 widget_class->realize = hildon_note_realize;
329 widget_class->unrealize = hildon_note_unrealize;
331 g_object_class_install_property (object_class,
332 PROP_HILDON_NOTE_TYPE,
333 g_param_spec_enum ("note-type",
335 "The type of the note dialog",
336 hildon_note_type_get_type (),
337 HILDON_NOTE_TYPE_CONFIRMATION,
338 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
341 * HildonNote:description:
343 * Description for the note.
345 g_object_class_install_property (object_class,
346 PROP_HILDON_NOTE_DESCRIPTION,
347 g_param_spec_string ("description",
349 "The text that appears in the note dialog",
358 * Deprecated: Since 2.2
360 g_object_class_install_property (object_class,
361 PROP_HILDON_NOTE_ICON,
362 g_param_spec_string ("icon",
364 "The name of the icon that appears in the note dialog",
369 * HildonNote:stock-icon:
371 * Stock icon name for the note.
373 * Deprecated: Since 2.2
375 g_object_class_install_property (object_class,
376 PROP_HILDON_NOTE_STOCK_ICON,
377 g_param_spec_string ("stock-icon",
379 "The stock name of the icon that appears in the note dialog",
384 * HildonNote:progressbar:
386 * Progressbar for the note (if any).
388 g_object_class_install_property (object_class,
389 PROP_HILDON_NOTE_PROGRESSBAR,
390 g_param_spec_object ("progressbar",
391 "Progressbar widget",
392 "The progressbar that appears in the note dialog",
393 GTK_TYPE_PROGRESS_BAR,
398 hildon_note_init (HildonNote *dialog)
400 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (dialog);
403 priv->label = gtk_label_new (NULL);
404 gtk_label_set_line_wrap (GTK_LABEL (priv->label), TRUE);
406 priv->event_box = gtk_event_box_new ();
408 priv->stock_icon = NULL;
410 gtk_event_box_set_visible_window (GTK_EVENT_BOX (priv->event_box), FALSE);
411 gtk_event_box_set_above_child (GTK_EVENT_BOX (priv->event_box), TRUE);
412 g_signal_connect (priv->event_box, "button-press-event",
413 G_CALLBACK (event_box_press_event), dialog);
415 /* Acquire real references to our internal children, since
416 they are not nessecarily packed into container in each
418 g_object_ref_sink (priv->event_box);
419 g_object_ref_sink (priv->label);
421 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
422 gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
424 /* We use special hint to turn the note into information notification. */
425 gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_NOTIFICATION);
430 hildon_note_finalize (GObject *obj_self)
432 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (obj_self);
435 /* FIXME Some of this stuff should be moved to dispose */
437 /* Free internal data */
439 g_object_unref (priv->event_box);
442 g_object_unref (priv->label);
448 if (priv->stock_icon) {
449 g_free (priv->stock_icon);
450 priv->stock_icon = NULL;
453 if (priv->progressbar)
454 g_object_unref (priv->progressbar);
456 if (priv->original_description)
457 g_free (priv->original_description);
459 G_OBJECT_CLASS (parent_class)->finalize (obj_self);
463 label_size_request (GtkWidget *label,
467 gint note_height = MAX (HILDON_INFORMATION_NOTE_MIN_HEIGHT, req->height);
468 g_object_set (note, "height-request", note_height, NULL);
472 screen_size_changed (GdkScreen *screen,
475 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (note);
476 gint screen_width = gdk_screen_get_width (screen);
477 gint text_width = screen_width - HILDON_INFORMATION_NOTE_MARGIN * 2;
479 g_object_set (note, "width-request", screen_width, NULL);
480 g_object_set (priv->label, "width-request", text_width, NULL);
484 hildon_note_realize (GtkWidget *widget)
487 gboolean is_info_note = FALSE;
489 const gchar *notification_type;
490 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (widget);
493 /* Make widget->window accessible */
494 GTK_WIDGET_CLASS (parent_class)->realize (widget);
496 /* Border only, no titlebar */
497 gdk_window_set_decorations (widget->window, GDK_DECOR_BORDER);
499 /* Because ESD is synchronous, we wish to play sound after the
500 note is already on screen to avoid blocking its appearance */
501 if (priv->sound_signal_handler == 0)
502 priv->sound_signal_handler = g_signal_connect_after(widget,
503 "expose-event", G_CALLBACK (sound_handling), NULL);
505 /* Set the _HILDON_NOTIFICATION_TYPE property so Matchbox places the window correctly */
506 display = gdk_drawable_get_display (widget->window);
507 atom = gdk_x11_get_xatom_by_name_for_display (display, "_HILDON_NOTIFICATION_TYPE");
509 if (priv->note_n == HILDON_NOTE_TYPE_INFORMATION ||
510 priv->note_n == HILDON_NOTE_TYPE_INFORMATION_THEME) {
511 notification_type = "_HILDON_NOTIFICATION_TYPE_INFO";
514 notification_type = "_HILDON_NOTIFICATION_TYPE_CONFIRMATION";
517 XChangeProperty (GDK_WINDOW_XDISPLAY (widget->window), GDK_WINDOW_XID (widget->window),
518 atom, XA_STRING, 8, PropModeReplace, (guchar *) notification_type,
519 strlen (notification_type));
522 GdkScreen *screen = gtk_widget_get_screen (widget);
523 g_signal_connect (priv->label, "size-request", G_CALLBACK (label_size_request), widget);
524 g_signal_connect (screen, "size-changed", G_CALLBACK (screen_size_changed), widget);
525 screen_size_changed (screen, widget);
530 hildon_note_unrealize (GtkWidget *widget)
532 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (widget);
533 GdkScreen *screen = gtk_widget_get_screen (widget);
535 g_signal_handlers_disconnect_by_func (screen, G_CALLBACK (screen_size_changed), widget);
536 g_signal_handlers_disconnect_by_func (priv->label, G_CALLBACK (label_size_request), widget);
538 GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
542 /* Helper function for removing a widget from it's container.
543 we own a separate reference to each object we try to unpack,
544 so extra referencing is not needed. */
546 unpack_widget (GtkWidget *widget)
548 g_assert (widget == NULL || GTK_IS_WIDGET (widget));
550 if (widget && widget->parent)
551 gtk_container_remove (GTK_CONTAINER (widget->parent), widget);
555 hildon_note_rebuild (HildonNote *note)
558 HildonNotePrivate *priv;
559 gboolean IsHorizontal = TRUE;
561 g_assert (HILDON_IS_NOTE (note));
563 priv = HILDON_NOTE_GET_PRIVATE (note);
566 dialog = GTK_DIALOG (note);
568 /* Reuse exiting content widgets for new layout */
569 unpack_widget (priv->label);
570 unpack_widget (priv->progressbar);
571 unpack_widget (priv->event_box);
573 /* Destroy old layout and buttons */
575 gtk_widget_destroy (priv->box);
578 if (priv->okButton) {
579 gtk_widget_destroy (priv->okButton);
580 priv->okButton = NULL;
582 if (priv->cancelButton) {
583 gtk_widget_destroy (priv->cancelButton);
584 priv->cancelButton = NULL;
587 /* Add needed buttons and images for each note type */
588 switch (priv->note_n)
590 case HILDON_NOTE_TYPE_CONFIRMATION:
591 priv->okButton = gtk_dialog_add_button (dialog,
592 _("wdgt_bd_yes"), GTK_RESPONSE_OK);
593 priv->cancelButton = gtk_dialog_add_button (dialog,
594 _("wdgt_bd_no"), GTK_RESPONSE_CANCEL);
595 gtk_widget_show (priv->cancelButton);
596 gtk_widget_set_no_show_all (priv->cancelButton, FALSE);
599 case HILDON_NOTE_TYPE_PROGRESSBAR:
600 priv->cancelButton = gtk_dialog_add_button (dialog,
601 _("wdgt_bd_stop"), GTK_RESPONSE_CANCEL);
602 gtk_widget_show (priv->cancelButton);
603 gtk_widget_set_no_show_all (priv->cancelButton, FALSE);
604 IsHorizontal = FALSE;
607 case HILDON_NOTE_TYPE_CONFIRMATION_BUTTON:
608 case HILDON_NOTE_TYPE_INFORMATION_THEME:
609 case HILDON_NOTE_TYPE_INFORMATION:
615 /* Pack item with label horizontally */
616 priv->box = gtk_hbox_new (FALSE, HILDON_MARGIN_DEFAULT);
617 gtk_container_add (GTK_CONTAINER (priv->event_box), priv->box);
619 gtk_box_pack_start (GTK_BOX (priv->box), priv->label, TRUE, TRUE, 0);
622 /* Pack item with label vertically */
623 priv->box = gtk_vbox_new (FALSE, HILDON_MARGIN_DOUBLE);
624 gtk_container_add (GTK_CONTAINER (priv->event_box), priv->box);
625 gtk_box_pack_start (GTK_BOX (priv->box), priv->label, TRUE, TRUE, 0);
627 if (priv->progressbar)
628 gtk_box_pack_start (GTK_BOX (priv->box), priv->progressbar, FALSE, FALSE, 0);
631 gtk_container_add (GTK_CONTAINER (dialog->vbox), priv->event_box);
633 gtk_widget_show_all (priv->event_box);
637 * hildon_note_new_confirmation_add_buttons:
638 * @parent: the parent window. The X window ID of the parent window
639 * has to be the same as the X window ID of the application. This is
640 * important so that the window manager could handle the windows
642 * In GTK the X window ID can be checked using
643 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
644 * @description: the message to confirm
645 * @Varargs: arguments pairs for new buttons(label and return value).
646 * Terminate the list with %NULL value.
648 * Create a new confirmation note with custom buttons. Confirmation
649 * note has a text and any number of buttons. It's important to note
650 * that even though the name of the function might suggest, the
651 * default ok/cancel buttons are not appended but you have to provide
652 * all of the buttons.
654 * FIXME: This doc seems to be wrong, the two buttons aren't added so
655 * it would only contain the "additional" buttons? However, changing
656 * this would break those applications that rely on current behaviour.
658 * Returns: A #GtkWidget pointer of the note
661 hildon_note_new_confirmation_add_buttons (GtkWindow *parent,
662 const gchar *description,
670 g_return_val_if_fail (description != NULL, NULL);
672 GtkWidget *conf_note =
673 g_object_new (HILDON_TYPE_NOTE,
674 "note-type", HILDON_NOTE_TYPE_CONFIRMATION_BUTTON,
675 "description", description,
679 gtk_window_set_transient_for (GTK_WINDOW (conf_note), parent);
681 /* Add the buttons from varargs */
682 va_start(args, description);
685 message = va_arg (args, char *);
690 value = va_arg (args, int);
692 button = gtk_dialog_add_button (GTK_DIALOG (conf_note), message, value);
693 /* maemo-gtk is going to set the "no-show-all" property all
694 cancel/close-like buttons to TRUE, so that they are not shown. On
695 the other hand, this confirmation note with custom buttons should
696 not obey this rule, so we need to make sure they are shown. */
697 gtk_widget_show (button);
698 gtk_widget_set_no_show_all (button, FALSE);
708 * hildon_note_new_confirmation:
709 * @parent: the parent window. The X window ID of the parent window
710 * has to be the same as the X window ID of the application. This is
711 * important so that the window manager could handle the windows
712 * correctly. In GTK the X window ID can be checked using
713 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
714 * @description: the message to confirm
716 * Create a new confirmation note. Confirmation note has a text (description)
717 * that you specify and two buttons.
719 * Returns: a #GtkWidget pointer of the note
722 hildon_note_new_confirmation (GtkWindow *parent,
723 const gchar *description)
725 GtkWidget *dialog = NULL;
727 g_return_val_if_fail (description != NULL, NULL);
729 dialog = g_object_new (HILDON_TYPE_NOTE,
731 HILDON_NOTE_TYPE_CONFIRMATION,
732 "description", description, NULL);
735 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
741 * hildon_note_new_confirmation_with_icon_name:
742 * @parent: the parent window. The X window ID of the parent window
743 * has to be the same as the X window ID of the application. This is
744 * important so that the window manager could handle the windows
745 * correctly. In GTK the X window ID can be checked using
746 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
747 * @description: the message to confirm
748 * @icon_name: icon to be displayed. If NULL, default icon is used.
750 * Create a new confirmation note. Confirmation note has a text (description)
751 * that you specify and two buttons.
753 * Deprecated: Since 2.2, icons are not shown in confirmation notes. Icons set
754 * with this function will be ignored. Use hildon_note_new_confirmation() instead.
756 * Returns: a #GtkWidget pointer of the note
759 hildon_note_new_confirmation_with_icon_name (GtkWindow *parent,
760 const gchar *description,
761 const gchar *icon_name)
763 return hildon_note_new_confirmation (parent, description);
767 * hildon_note_new_information:
768 * @parent: the parent window. The X window ID of the parent window
769 * has to be the same as the X window ID of the application. This is
770 * important so that the window manager could handle the windows
771 * correctly. In GTK the X window ID can be checked using
772 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
773 * @description: the message to confirm
775 * Create a new information note. Information note has a text (description)
776 * that you specify and an OK button.
778 * Returns: a #GtkWidget pointer of the note
781 hildon_note_new_information (GtkWindow *parent,
782 const gchar *description)
784 GtkWidget *dialog = NULL;
786 g_return_val_if_fail (description != NULL, NULL);
788 dialog = g_object_new (HILDON_TYPE_NOTE,
790 HILDON_NOTE_TYPE_INFORMATION_THEME,
791 "description", description, NULL);
794 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
800 * hildon_note_new_information_with_icon_name:
801 * @parent: the parent window. The X window ID of the parent window
802 * has to be the same as the X window ID of the application. This is
803 * important so that the window manager could handle the windows
804 * correctly. In GTK the X window ID can be checked using
805 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
806 * @description: the message to confirm
807 * @icon_name: icon to be displayed. If NULL, default icon is used.
809 * Create a new information note. Information note has text(description)
810 * that you specify, an OK button and an icon.
812 * Deprecated: Since 2.2, icons are not shown in confirmation notes. Icons set
813 * with this function will be ignored. Use hildon_note_new_information() instead.
815 * Returns: a #GtkWidget pointer of the note
818 hildon_note_new_information_with_icon_name (GtkWindow * parent,
819 const gchar *description,
820 const gchar *icon_name)
822 return hildon_note_new_information (parent, description);
825 /* FIXME This documentation string LIES! */
828 * hildon_note_new_cancel_with_progress_bar:
829 * @parent: the parent window. The X window ID of the parent window
830 * has to be the same as the X window ID of the application. This is
831 * important so that the window manager could handle the windows
832 * correctly. In GTK the X window ID can be checked using
833 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
834 * @description: the action to cancel
835 * @progressbar: a pointer to #GtkProgressBar to be filled with the
836 * progressbar assigned to this note. Use this to set the fraction of
837 * progressbar done. This parameter can be %NULL as well, in which
838 * case plain text cancel note appears.
840 * Create a new cancel note with a progress bar. Cancel note has
841 * text(description) that you specify, a Cancel button and a progress bar.
843 * Returns: a #GtkDialog. Use this to get rid of this note when you
847 hildon_note_new_cancel_with_progress_bar (GtkWindow *parent,
848 const gchar *description,
849 GtkProgressBar *progressbar)
851 GtkWidget *dialog = NULL;
853 g_return_val_if_fail (description != NULL, NULL);
855 dialog = g_object_new (HILDON_TYPE_NOTE,
857 HILDON_NOTE_TYPE_PROGRESSBAR,
858 "description", description,
863 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
870 * hildon_note_set_button_text:
871 * @note: a #HildonNote
872 * @text: sets the button text and if there is two buttons in dialog,
873 * the button texts will be <text>, "Cancel".
875 * Sets the button text to be used by the hildon_note widget.
878 hildon_note_set_button_text (HildonNote *note,
881 HildonNotePrivate *priv;
883 g_return_if_fail (HILDON_IS_NOTE (note));
885 priv = HILDON_NOTE_GET_PRIVATE (HILDON_NOTE (note));
888 if (priv->okButton) {
889 gtk_button_set_label (GTK_BUTTON (priv->okButton), text);
890 gtk_button_set_label (GTK_BUTTON (priv->cancelButton),
893 gtk_button_set_label (GTK_BUTTON (priv->cancelButton), text);
898 * hildon_note_set_button_texts:
899 * @note: a #HildonNote
900 * @text_ok: the new text of the default OK button
901 * @text_cancel: the new text of the default cancel button
903 * Sets the button texts to be used by this hildon_note widget.
906 hildon_note_set_button_texts (HildonNote *note,
907 const gchar *text_ok,
908 const gchar *text_cancel)
910 HildonNotePrivate *priv;
912 g_return_if_fail (HILDON_IS_NOTE (note));
914 priv = HILDON_NOTE_GET_PRIVATE (HILDON_NOTE (note));
917 if (priv->okButton) {
918 gtk_button_set_label (GTK_BUTTON (priv->okButton), text_ok);
919 gtk_button_set_label (GTK_BUTTON (priv->cancelButton), text_cancel);
921 gtk_button_set_label (GTK_BUTTON (priv->cancelButton), text_cancel);
925 /* We play a system sound when the note comes visible */
927 sound_handling (GtkWidget *widget,
928 GdkEventExpose *event,
931 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (widget);
934 g_signal_handler_disconnect (widget, priv->sound_signal_handler);
936 priv->sound_signal_handler = 0;
938 switch (priv->note_n)
940 case HILDON_NOTE_TYPE_INFORMATION:
941 case HILDON_NOTE_TYPE_INFORMATION_THEME:
942 hildon_play_system_sound (INFORMATION_SOUND_PATH);
945 case HILDON_NOTE_TYPE_CONFIRMATION:
946 case HILDON_NOTE_TYPE_CONFIRMATION_BUTTON:
947 hildon_play_system_sound (CONFIRMATION_SOUND_PATH);