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 * Notes are used to for confirmation (OK/Cancel/etc.) from the user.
30 * A simple note contains an information text. Additional features
31 * such as progress bars or animation can also be included.
34 * <title>HildonNote example</title>
38 * show_confirmation_note (GtkWindow *parent)
42 * note = hildon_note_new_confirmation (parent, "Confirmation message...");
44 * retcode = gtk_dialog_run (GTK_DIALOG (note));
45 * gtk_widget_destroy (note);
47 * if (retcode == GTK_RESPONSE_OK) {
48 * g_debug ("User pressed 'OK' button'");
51 * g_debug ("User pressed 'Cancel' button");
67 #include <X11/Xatom.h>
70 #undef HILDON_DISABLE_DEPRECATED
72 #include "hildon-note.h"
73 #include "hildon-defines.h"
74 #include "hildon-sound.h"
75 #include "hildon-banner.h"
76 #include "hildon-enum-types.h"
77 #include "hildon-note-private.h"
79 #define HILDON_INFORMATION_NOTE_MIN_HEIGHT 140
81 #define HILDON_INFORMATION_NOTE_MARGIN 100
83 #define CONFIRMATION_SOUND_PATH \
84 "/usr/share/sounds/ui-confirmation_note.wav"
86 #define INFORMATION_SOUND_PATH \
87 "/usr/share/sounds/ui-information_note.wav"
89 #define _(String) dgettext("hildon-libs", String)
92 hildon_note_class_init (HildonNoteClass *class);
95 hildon_note_init (HildonNote *dialog);
98 hildon_note_rebuild (HildonNote *note);
101 hildon_note_finalize (GObject *obj_self);
104 hildon_note_realize (GtkWidget *widget);
107 hildon_note_unrealize (GtkWidget *widget);
110 label_size_request (GtkWidget *label,
115 hildon_note_set_property (GObject *object,
121 hildon_note_get_property (GObject *object,
127 sound_handling (GtkWidget *widget,
128 GdkEventExpose *event,
134 PROP_HILDON_NOTE_TYPE,
135 PROP_HILDON_NOTE_DESCRIPTION,
136 PROP_HILDON_NOTE_ICON,
137 PROP_HILDON_NOTE_PROGRESSBAR,
138 PROP_HILDON_NOTE_STOCK_ICON
141 static GtkDialogClass* parent_class;
144 event_box_press_event (GtkEventBox *event_box,
145 GdkEventButton *event,
148 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (note);
150 if (priv->note_n == HILDON_NOTE_TYPE_INFORMATION ||
151 priv->note_n == HILDON_NOTE_TYPE_INFORMATION_THEME) {
152 gtk_dialog_response (note, GTK_RESPONSE_DELETE_EVENT);
160 hildon_note_set_property (GObject *object,
165 HildonNote *note = HILDON_NOTE (object);
166 HildonNotePrivate *priv;
169 priv = HILDON_NOTE_GET_PRIVATE (note);
174 case PROP_HILDON_NOTE_TYPE:
175 priv->note_n = g_value_get_enum (value);
176 hildon_note_rebuild (note);
179 case PROP_HILDON_NOTE_DESCRIPTION:
180 if (priv->original_description)
181 g_free (priv->original_description);
182 priv->original_description = g_value_dup_string (value);
184 gtk_label_set_text (GTK_LABEL (priv->label), priv->original_description);
185 /* FIXME Is the "original_description" used anywhere? */
189 case PROP_HILDON_NOTE_ICON:
193 priv->icon = g_value_dup_string (value);
196 case PROP_HILDON_NOTE_STOCK_ICON:
197 if (priv->stock_icon) {
198 g_free (priv->stock_icon);
200 priv->stock_icon = g_value_dup_string (value);
203 case PROP_HILDON_NOTE_PROGRESSBAR:
204 widget = g_value_get_object (value);
205 if (widget != priv->progressbar)
207 if (priv->progressbar)
208 g_object_unref (priv->progressbar);
210 priv->progressbar = widget;
214 g_object_ref (widget);
215 gtk_object_sink (GTK_OBJECT (widget));
218 hildon_note_rebuild (note);
223 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
229 hildon_note_get_property (GObject *object,
234 HildonNote *note = HILDON_NOTE (object);
235 HildonNotePrivate *priv;
237 priv = HILDON_NOTE_GET_PRIVATE (note);
241 case PROP_HILDON_NOTE_TYPE:
242 g_value_set_enum (value, priv->note_n);
245 case PROP_HILDON_NOTE_DESCRIPTION:
246 g_value_set_string (value, priv->original_description);
249 case PROP_HILDON_NOTE_ICON:
250 g_value_set_string (value, priv->icon);
253 case PROP_HILDON_NOTE_STOCK_ICON:
254 g_value_set_string (value, priv->stock_icon);
257 case PROP_HILDON_NOTE_PROGRESSBAR:
258 g_value_set_object (value, priv->progressbar);
262 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
268 * hildon_note_get_type:
270 * Returns GType for HildonNote.
272 * Returns: HildonNote type
275 hildon_note_get_type (void)
277 static GType dialog_type = 0;
280 static const GTypeInfo dialog_info = {
281 sizeof(HildonNoteClass),
282 NULL, /* base_init */
283 NULL, /* base_finalize */
284 (GClassInitFunc) hildon_note_class_init,
285 NULL, /* class_finalize */
286 NULL, /* class_data */
289 (GInstanceInitFunc) hildon_note_init
291 dialog_type = g_type_register_static (GTK_TYPE_DIALOG,
299 hildon_note_class_init (HildonNoteClass *class)
301 GObjectClass *object_class = G_OBJECT_CLASS (class);
302 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
304 /* set the global parent_class */
305 parent_class = g_type_class_peek_parent (class);
307 g_type_class_add_private (class, sizeof (HildonNotePrivate));
309 object_class->finalize = hildon_note_finalize;
310 object_class->set_property = hildon_note_set_property;
311 object_class->get_property = hildon_note_get_property;
312 widget_class->realize = hildon_note_realize;
313 widget_class->unrealize = hildon_note_unrealize;
315 g_object_class_install_property (object_class,
316 PROP_HILDON_NOTE_TYPE,
317 g_param_spec_enum ("note-type",
319 "The type of the note dialog",
320 hildon_note_type_get_type (),
321 HILDON_NOTE_TYPE_CONFIRMATION,
322 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
325 * HildonNote:description:
327 * Description for the note.
329 g_object_class_install_property (object_class,
330 PROP_HILDON_NOTE_DESCRIPTION,
331 g_param_spec_string ("description",
333 "The text that appears in the note dialog",
342 * Deprecated: Since 2.2
344 g_object_class_install_property (object_class,
345 PROP_HILDON_NOTE_ICON,
346 g_param_spec_string ("icon",
348 "The name of the icon that appears in the note dialog",
353 * HildonNote:stock-icon:
355 * Stock icon name for the note.
357 * Deprecated: Since 2.2
359 g_object_class_install_property (object_class,
360 PROP_HILDON_NOTE_STOCK_ICON,
361 g_param_spec_string ("stock-icon",
363 "The stock name of the icon that appears in the note dialog",
368 * HildonNote:progressbar:
370 * Progressbar for the note (if any).
372 g_object_class_install_property (object_class,
373 PROP_HILDON_NOTE_PROGRESSBAR,
374 g_param_spec_object ("progressbar",
375 "Progressbar widget",
376 "The progressbar that appears in the note dialog",
377 GTK_TYPE_PROGRESS_BAR,
382 hildon_note_init (HildonNote *dialog)
384 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (dialog);
387 priv->label = gtk_label_new (NULL);
388 gtk_label_set_line_wrap (GTK_LABEL (priv->label), TRUE);
390 priv->event_box = gtk_event_box_new ();
392 priv->stock_icon = NULL;
394 gtk_event_box_set_visible_window (GTK_EVENT_BOX (priv->event_box), FALSE);
395 gtk_event_box_set_above_child (GTK_EVENT_BOX (priv->event_box), TRUE);
396 g_signal_connect (priv->event_box, "button-press-event",
397 G_CALLBACK (event_box_press_event), dialog);
399 /* Acquire real references to our internal children, since
400 they are not nessecarily packed into container in each
402 g_object_ref_sink (priv->event_box);
403 g_object_ref_sink (priv->label);
405 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
406 gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
408 /* We use special hint to turn the note into information notification. */
409 gtk_window_set_type_hint (GTK_WINDOW (dialog), GDK_WINDOW_TYPE_HINT_NOTIFICATION);
414 hildon_note_finalize (GObject *obj_self)
416 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (obj_self);
419 /* FIXME Some of this stuff should be moved to dispose */
421 /* Free internal data */
423 g_object_unref (priv->event_box);
426 g_object_unref (priv->label);
432 if (priv->stock_icon) {
433 g_free (priv->stock_icon);
434 priv->stock_icon = NULL;
437 if (priv->progressbar)
438 g_object_unref (priv->progressbar);
440 if (priv->original_description)
441 g_free (priv->original_description);
443 G_OBJECT_CLASS (parent_class)->finalize (obj_self);
447 label_size_request (GtkWidget *label,
451 gint note_height = MAX (HILDON_INFORMATION_NOTE_MIN_HEIGHT, req->height);
452 g_object_set (note, "height-request", note_height, NULL);
456 screen_size_changed (GdkScreen *screen,
459 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (note);
460 gint screen_width = gdk_screen_get_width (screen);
461 gint text_width = screen_width - HILDON_INFORMATION_NOTE_MARGIN * 2;
463 g_object_set (note, "width-request", screen_width, NULL);
464 g_object_set (priv->label, "width-request", text_width, NULL);
468 hildon_note_realize (GtkWidget *widget)
471 gboolean is_info_note = FALSE;
473 const gchar *notification_type;
474 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (widget);
477 /* Make widget->window accessible */
478 GTK_WIDGET_CLASS (parent_class)->realize (widget);
480 /* Border only, no titlebar */
481 gdk_window_set_decorations (widget->window, GDK_DECOR_BORDER);
483 /* Because ESD is synchronous, we wish to play sound after the
484 note is already on screen to avoid blocking its appearance */
485 if (priv->sound_signal_handler == 0)
486 priv->sound_signal_handler = g_signal_connect_after(widget,
487 "expose-event", G_CALLBACK (sound_handling), NULL);
489 /* Set the _HILDON_NOTIFICATION_TYPE property so Matchbox places the window correctly */
490 display = gdk_drawable_get_display (widget->window);
491 atom = gdk_x11_get_xatom_by_name_for_display (display, "_HILDON_NOTIFICATION_TYPE");
493 if (priv->note_n == HILDON_NOTE_TYPE_INFORMATION ||
494 priv->note_n == HILDON_NOTE_TYPE_INFORMATION_THEME) {
495 notification_type = "_HILDON_NOTIFICATION_TYPE_INFO";
498 notification_type = "_HILDON_NOTIFICATION_TYPE_CONFIRMATION";
501 XChangeProperty (GDK_WINDOW_XDISPLAY (widget->window), GDK_WINDOW_XID (widget->window),
502 atom, XA_STRING, 8, PropModeReplace, (guchar *) notification_type,
503 strlen (notification_type));
506 GdkScreen *screen = gtk_widget_get_screen (widget);
507 g_signal_connect (priv->label, "size-request", G_CALLBACK (label_size_request), widget);
508 g_signal_connect (screen, "size-changed", G_CALLBACK (screen_size_changed), widget);
509 screen_size_changed (screen, widget);
514 hildon_note_unrealize (GtkWidget *widget)
516 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (widget);
517 GdkScreen *screen = gtk_widget_get_screen (widget);
519 g_signal_handlers_disconnect_by_func (screen, G_CALLBACK (screen_size_changed), widget);
520 g_signal_handlers_disconnect_by_func (priv->label, G_CALLBACK (label_size_request), widget);
522 GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
526 /* Helper function for removing a widget from it's container.
527 we own a separate reference to each object we try to unpack,
528 so extra referencing is not needed. */
530 unpack_widget (GtkWidget *widget)
532 g_assert (widget == NULL || GTK_IS_WIDGET (widget));
534 if (widget && widget->parent)
535 gtk_container_remove (GTK_CONTAINER (widget->parent), widget);
539 hildon_note_rebuild (HildonNote *note)
542 HildonNotePrivate *priv;
543 gboolean IsHorizontal = TRUE;
545 g_assert (HILDON_IS_NOTE (note));
547 priv = HILDON_NOTE_GET_PRIVATE (note);
550 dialog = GTK_DIALOG (note);
552 /* Reuse exiting content widgets for new layout */
553 unpack_widget (priv->label);
554 unpack_widget (priv->progressbar);
555 unpack_widget (priv->event_box);
557 /* Destroy old layout and buttons */
559 gtk_widget_destroy (priv->box);
562 if (priv->okButton) {
563 gtk_widget_destroy (priv->okButton);
564 priv->okButton = NULL;
566 if (priv->cancelButton) {
567 gtk_widget_destroy (priv->cancelButton);
568 priv->cancelButton = NULL;
571 /* Add needed buttons and images for each note type */
572 switch (priv->note_n)
574 case HILDON_NOTE_TYPE_CONFIRMATION:
575 priv->okButton = gtk_dialog_add_button (dialog,
576 _("wdgt_bd_yes"), GTK_RESPONSE_OK);
577 priv->cancelButton = gtk_dialog_add_button (dialog,
578 _("wdgt_bd_no"), GTK_RESPONSE_CANCEL);
579 gtk_widget_show (priv->cancelButton);
580 gtk_widget_set_no_show_all (priv->cancelButton, FALSE);
583 case HILDON_NOTE_TYPE_PROGRESSBAR:
584 priv->cancelButton = gtk_dialog_add_button (dialog,
585 _("wdgt_bd_stop"), GTK_RESPONSE_CANCEL);
586 gtk_widget_show (priv->cancelButton);
587 gtk_widget_set_no_show_all (priv->cancelButton, FALSE);
588 IsHorizontal = FALSE;
591 case HILDON_NOTE_TYPE_CONFIRMATION_BUTTON:
592 case HILDON_NOTE_TYPE_INFORMATION_THEME:
593 case HILDON_NOTE_TYPE_INFORMATION:
599 /* Pack item with label horizontally */
600 priv->box = gtk_hbox_new (FALSE, HILDON_MARGIN_DEFAULT);
601 gtk_container_add (GTK_CONTAINER (priv->event_box), priv->box);
603 gtk_box_pack_start (GTK_BOX (priv->box), priv->label, TRUE, TRUE, 0);
606 /* Pack item with label vertically */
607 priv->box = gtk_vbox_new (FALSE, HILDON_MARGIN_DOUBLE);
608 gtk_container_add (GTK_CONTAINER (priv->event_box), priv->box);
609 gtk_box_pack_start (GTK_BOX (priv->box), priv->label, TRUE, TRUE, 0);
611 if (priv->progressbar)
612 gtk_box_pack_start (GTK_BOX (priv->box), priv->progressbar, FALSE, FALSE, 0);
615 gtk_container_add (GTK_CONTAINER (dialog->vbox), priv->event_box);
617 gtk_widget_show_all (priv->event_box);
621 * hildon_note_new_confirmation_add_buttons:
622 * @parent: the parent window. The X window ID of the parent window
623 * has to be the same as the X window ID of the application. This is
624 * important so that the window manager could handle the windows
626 * In GTK the X window ID can be checked using
627 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
628 * @description: the message to confirm
629 * @Varargs: arguments pairs for new buttons(label and return value).
630 * Terminate the list with %NULL value.
632 * Create a new confirmation note with custom buttons. Confirmation
633 * note has a text and any number of buttons. It's important to note
634 * that even though the name of the function might suggest, the
635 * default ok/cancel buttons are not appended but you have to provide
636 * all of the buttons.
638 * FIXME: This doc seems to be wrong, the two buttons aren't added so
639 * it would only contain the "additional" buttons? However, changing
640 * this would break those applications that rely on current behaviour.
642 * Returns: A #GtkWidget pointer of the note
645 hildon_note_new_confirmation_add_buttons (GtkWindow *parent,
646 const gchar *description,
654 g_return_val_if_fail (description != NULL, NULL);
656 GtkWidget *conf_note =
657 g_object_new (HILDON_TYPE_NOTE,
658 "note-type", HILDON_NOTE_TYPE_CONFIRMATION_BUTTON,
659 "description", description,
663 gtk_window_set_transient_for (GTK_WINDOW (conf_note), parent);
665 /* Add the buttons from varargs */
666 va_start(args, description);
669 message = va_arg (args, char *);
674 value = va_arg (args, int);
676 button = gtk_dialog_add_button (GTK_DIALOG (conf_note), message, value);
677 /* maemo-gtk is going to set the "no-show-all" property all
678 cancel/close-like buttons to TRUE, so that they are not shown. On
679 the other hand, this confirmation note with custom buttons should
680 not obey this rule, so we need to make sure they are shown. */
681 gtk_widget_show (button);
682 gtk_widget_set_no_show_all (button, FALSE);
692 * hildon_note_new_confirmation:
693 * @parent: the parent window. The X window ID of the parent window
694 * has to be the same as the X window ID of the application. This is
695 * important so that the window manager could handle the windows
696 * correctly. In GTK the X window ID can be checked using
697 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
698 * @description: the message to confirm
700 * Create a new confirmation note. Confirmation note has a text (description)
701 * that you specify and two buttons.
703 * Returns: a #GtkWidget pointer of the note
706 hildon_note_new_confirmation (GtkWindow *parent,
707 const gchar *description)
709 GtkWidget *dialog = NULL;
711 g_return_val_if_fail (description != NULL, NULL);
713 dialog = g_object_new (HILDON_TYPE_NOTE,
715 HILDON_NOTE_TYPE_CONFIRMATION,
716 "description", description, NULL);
719 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
725 * hildon_note_new_confirmation_with_icon_name:
726 * @parent: the parent window. The X window ID of the parent window
727 * has to be the same as the X window ID of the application. This is
728 * important so that the window manager could handle the windows
729 * correctly. In GTK the X window ID can be checked using
730 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
731 * @description: the message to confirm
732 * @icon_name: icon to be displayed. If NULL, default icon is used.
734 * Create a new confirmation note. Confirmation note has a text (description)
735 * that you specify and two buttons.
737 * Deprecated: Since 2.2, icons are not shown in confirmation notes. Icons set
738 * with this function will be ignored. Use hildon_note_new_confirmation() instead.
740 * Returns: a #GtkWidget pointer of the note
743 hildon_note_new_confirmation_with_icon_name (GtkWindow *parent,
744 const gchar *description,
745 const gchar *icon_name)
747 return hildon_note_new_confirmation (parent, description);
751 * hildon_note_new_information:
752 * @parent: the parent window. The X window ID of the parent window
753 * has to be the same as the X window ID of the application. This is
754 * important so that the window manager could handle the windows
755 * correctly. In GTK the X window ID can be checked using
756 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
757 * @description: the message to confirm
759 * Create a new information note. Information note has a text (description)
760 * that you specify and an OK button.
762 * Returns: a #GtkWidget pointer of the note
765 hildon_note_new_information (GtkWindow *parent,
766 const gchar *description)
768 GtkWidget *dialog = NULL;
770 g_return_val_if_fail (description != NULL, NULL);
772 dialog = g_object_new (HILDON_TYPE_NOTE,
774 HILDON_NOTE_TYPE_INFORMATION_THEME,
775 "description", description, NULL);
778 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
784 * hildon_note_new_information_with_icon_name:
785 * @parent: the parent window. The X window ID of the parent window
786 * has to be the same as the X window ID of the application. This is
787 * important so that the window manager could handle the windows
788 * correctly. In GTK the X window ID can be checked using
789 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
790 * @description: the message to confirm
791 * @icon_name: icon to be displayed. If NULL, default icon is used.
793 * Create a new information note. Information note has text(description)
794 * that you specify, an OK button and an icon.
796 * Deprecated: Since 2.2, icons are not shown in confirmation notes. Icons set
797 * with this function will be ignored. Use hildon_note_new_information() instead.
799 * Returns: a #GtkWidget pointer of the note
802 hildon_note_new_information_with_icon_name (GtkWindow * parent,
803 const gchar *description,
804 const gchar *icon_name)
806 return hildon_note_new_information (parent, description);
809 /* FIXME This documentation string LIES! */
812 * hildon_note_new_cancel_with_progress_bar:
813 * @parent: the parent window. The X window ID of the parent window
814 * has to be the same as the X window ID of the application. This is
815 * important so that the window manager could handle the windows
816 * correctly. In GTK the X window ID can be checked using
817 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
818 * @description: the action to cancel
819 * @progressbar: a pointer to #GtkProgressBar to be filled with the
820 * progressbar assigned to this note. Use this to set the fraction of
821 * progressbar done. This parameter can be %NULL as well, in which
822 * case plain text cancel note appears.
824 * Create a new cancel note with a progress bar. Cancel note has
825 * text(description) that you specify, a Cancel button and a progress bar.
827 * Returns: a #GtkDialog. Use this to get rid of this note when you
831 hildon_note_new_cancel_with_progress_bar (GtkWindow *parent,
832 const gchar *description,
833 GtkProgressBar *progressbar)
835 GtkWidget *dialog = NULL;
837 g_return_val_if_fail (description != NULL, NULL);
839 dialog = g_object_new (HILDON_TYPE_NOTE,
841 HILDON_NOTE_TYPE_PROGRESSBAR,
842 "description", description,
847 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
854 * hildon_note_set_button_text:
855 * @note: a #HildonNote
856 * @text: sets the button text and if there is two buttons in dialog,
857 * the button texts will be <text>, "Cancel".
859 * Sets the button text to be used by the hildon_note widget.
862 hildon_note_set_button_text (HildonNote *note,
865 HildonNotePrivate *priv;
867 g_return_if_fail (HILDON_IS_NOTE (note));
869 priv = HILDON_NOTE_GET_PRIVATE (HILDON_NOTE (note));
872 if (priv->okButton) {
873 gtk_button_set_label (GTK_BUTTON (priv->okButton), text);
874 gtk_button_set_label (GTK_BUTTON (priv->cancelButton),
877 gtk_button_set_label (GTK_BUTTON (priv->cancelButton), text);
882 * hildon_note_set_button_texts:
883 * @note: a #HildonNote
884 * @text_ok: the new text of the default OK button
885 * @text_cancel: the new text of the default cancel button
887 * Sets the button texts to be used by this hildon_note widget.
890 hildon_note_set_button_texts (HildonNote *note,
891 const gchar *text_ok,
892 const gchar *text_cancel)
894 HildonNotePrivate *priv;
896 g_return_if_fail (HILDON_IS_NOTE (note));
898 priv = HILDON_NOTE_GET_PRIVATE (HILDON_NOTE (note));
901 if (priv->okButton) {
902 gtk_button_set_label (GTK_BUTTON (priv->okButton), text_ok);
903 gtk_button_set_label (GTK_BUTTON (priv->cancelButton), text_cancel);
905 gtk_button_set_label (GTK_BUTTON (priv->cancelButton), text_cancel);
909 /* We play a system sound when the note comes visible */
911 sound_handling (GtkWidget *widget,
912 GdkEventExpose *event,
915 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (widget);
918 g_signal_handler_disconnect (widget, priv->sound_signal_handler);
920 priv->sound_signal_handler = 0;
922 switch (priv->note_n)
924 case HILDON_NOTE_TYPE_INFORMATION:
925 case HILDON_NOTE_TYPE_INFORMATION_THEME:
926 hildon_play_system_sound (INFORMATION_SOUND_PATH);
929 case HILDON_NOTE_TYPE_CONFIRMATION:
930 case HILDON_NOTE_TYPE_CONFIRMATION_BUTTON:
931 hildon_play_system_sound (CONFIRMATION_SOUND_PATH);