2 * This file is part of hildon-libs
4 * Copyright (C) 2005 Nokia Corporation.
6 * Contact: Luc Pionchon <luc.pionchon@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; either 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 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>
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
111 hildon_note_set_property(GObject * object,
113 const GValue * value, GParamSpec * pspec)
115 HildonNote *note = HILDON_NOTE(object);
116 HildonNotePrivate *priv;
119 priv = HILDON_NOTE_GET_PRIVATE(note);
122 case PROP_HILDON_NOTE_TYPE:
123 priv->note_n = g_value_get_enum(value);
124 hildon_note_rebuild(note);
126 case PROP_HILDON_NOTE_DESCRIPTION:
127 g_free(priv->original_description);
128 priv->original_description = g_value_dup_string(value);
130 _hildon_gtk_label_set_text_n_lines(GTK_LABEL(priv->label),
131 priv->original_description,
132 priv->note_n == HILDON_NOTE_PROGRESSBAR_TYPE ? 1 : 5);
135 case PROP_HILDON_NOTE_ICON:
136 gtk_image_set_from_icon_name(GTK_IMAGE(priv->icon),
137 g_value_get_string(value), HILDON_ICON_SIZE_BIG_NOTE);
139 case PROP_HILDON_NOTE_PROGRESSBAR:
140 widget = g_value_get_object(value);
141 if (widget != priv->progressbar)
143 if (priv->progressbar)
144 g_object_unref(priv->progressbar);
146 priv->progressbar = widget;
150 g_object_ref(widget);
151 gtk_object_sink(GTK_OBJECT(widget));
154 hildon_note_rebuild(note);
158 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
164 hildon_note_get_property(GObject * object,
165 guint prop_id, GValue * value, GParamSpec * pspec)
167 HildonNote *note = HILDON_NOTE(object);
168 HildonNotePrivate *priv;
170 priv = HILDON_NOTE_GET_PRIVATE(note);
173 case PROP_HILDON_NOTE_TYPE:
174 g_value_set_enum(value, priv->note_n);
176 case PROP_HILDON_NOTE_DESCRIPTION:
177 g_value_set_string(value, priv->original_description);
179 case PROP_HILDON_NOTE_ICON:
180 g_object_get_property(G_OBJECT(priv->icon), "icon-name", value);
182 case PROP_HILDON_NOTE_PROGRESSBAR:
183 g_value_set_object(value, priv->progressbar);
186 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
191 GType hildon_note_type_get_type (void)
193 static GType notetype = 0;
195 static const GEnumValue values[] = {
196 { HILDON_NOTE_CONFIRMATION_TYPE, "HILDON_NOTE_CONFIRMATION_TYPE", "confirmation" },
197 { HILDON_NOTE_CONFIRMATION_BUTTON_TYPE, "HILDON_NOTE_CONFIRMATION_BUTTON_TYPE", "confirmation-button" },
198 { HILDON_NOTE_INFORMATION_TYPE, "HILDON_NOTE_INFORMATION_TYPE", "note-information" },
199 { HILDON_NOTE_INFORMATION_THEME_TYPE, "HILDON_NOTE_INFORMATION_THEME_TYPE", "note-information-theme" },
200 { HILDON_NOTE_PROGRESSBAR_TYPE, "HILDON_NOTE_PROGRESSBAR_TYPE", "note-progressbar" },
203 notetype = g_enum_register_static ("HildonNoteType", values);
209 GType hildon_note_get_type()
211 static GType dialog_type = 0;
214 static const GTypeInfo dialog_info = {
215 sizeof(HildonNoteClass),
216 NULL, /* base_init */
217 NULL, /* base_finalize */
218 (GClassInitFunc) hildon_note_class_init,
219 NULL, /* class_finalize */
220 NULL, /* class_data */
223 (GInstanceInitFunc) hildon_note_init
225 dialog_type = g_type_register_static(GTK_TYPE_DIALOG,
232 static void hildon_note_class_init(HildonNoteClass * class)
234 GObjectClass *object_class = G_OBJECT_CLASS(class);
235 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(class);
237 /* set the global parent_class */
238 parent_class = g_type_class_peek_parent(class);
240 g_type_class_add_private(class, sizeof(HildonNotePrivate));
242 object_class->finalize = hildon_note_finalize;
243 object_class->set_property = hildon_note_set_property;
244 object_class->get_property = hildon_note_get_property;
245 widget_class->realize = hildon_note_realize;
247 g_object_class_install_property(object_class,
248 PROP_HILDON_NOTE_TYPE,
249 g_param_spec_enum("note_type",
251 "The type of the note dialog",
252 hildon_note_type_get_type(),
253 HILDON_NOTE_CONFIRMATION_TYPE,
254 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
257 * HildonNote:description:
259 * Description for note.
261 g_object_class_install_property(object_class,
262 PROP_HILDON_NOTE_DESCRIPTION,
263 g_param_spec_string("description",
265 "The text that appears in the note dialog",
274 g_object_class_install_property(object_class,
275 PROP_HILDON_NOTE_ICON,
276 g_param_spec_string("icon",
278 "The name of the icon that appears in the note dialog",
283 * HildonNote:progressbar:
285 * Progressbar for note.
287 g_object_class_install_property(object_class,
288 PROP_HILDON_NOTE_PROGRESSBAR,
289 g_param_spec_object("progressbar",
290 "Progressbar widget",
291 "The progressbar that appears in the note dialog",
292 GTK_TYPE_PROGRESS_BAR,
296 static void hildon_note_init(HildonNote * dialog)
298 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE(dialog);
300 priv->label = gtk_label_new(NULL);
301 priv->icon = gtk_image_new();
303 /* Acquire real references to our internal children, since
304 they are not nessecarily packed into container in each
306 g_object_ref(priv->label);
307 g_object_ref(priv->icon);
308 gtk_object_sink(GTK_OBJECT(priv->label));
309 gtk_object_sink(GTK_OBJECT(priv->icon));
311 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
312 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
316 static void hildon_note_finalize(GObject * obj_self)
318 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE(obj_self);
320 /* Free internal data */
321 g_object_unref(priv->label);
322 g_object_unref(priv->icon);
323 if (priv->progressbar)
324 g_object_unref(priv->progressbar);
326 g_free(priv->original_description);
328 G_OBJECT_CLASS(parent_class)->finalize(obj_self);
332 hildon_note_realize (GtkWidget *widget)
334 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE(widget);
336 /* Make widget->window accessible */
337 GTK_WIDGET_CLASS (parent_class)->realize (widget);
339 /* Border only, no titlebar */
340 gdk_window_set_decorations (widget->window, GDK_DECOR_BORDER);
342 /* Because ESD is synchronous, we wish to play sound after the
343 note is already on screen to avoid blocking its appearance */
344 if (priv->sound_signal_handler == 0)
345 priv->sound_signal_handler = g_signal_connect_after(widget,
346 "expose-event", G_CALLBACK(sound_handling), NULL);
349 /* Helper function for removing a widget from it's container.
350 we own a separate reference to each object we try to unpack,
351 so extra referencing is not needed. */
352 static void unpack_widget(GtkWidget *widget)
354 g_assert(widget == NULL || GTK_IS_WIDGET(widget));
356 if (widget && widget->parent)
357 gtk_container_remove(GTK_CONTAINER(widget->parent), widget);
361 hildon_note_rebuild(HildonNote *note)
364 HildonNotePrivate *priv;
365 gboolean IsHorizontal = TRUE;
367 g_assert(HILDON_IS_NOTE(note));
369 priv = HILDON_NOTE_GET_PRIVATE (note);
370 dialog = GTK_DIALOG(note);
372 /* Reuse exiting content widgets for new layout */
373 unpack_widget(priv->label);
374 unpack_widget(priv->icon);
375 unpack_widget(priv->progressbar);
377 /* Destroy old layout and buttons */
379 gtk_widget_destroy(priv->box);
382 if (priv->okButton) {
383 gtk_widget_destroy(priv->okButton);
384 priv->okButton = NULL;
386 if (priv->cancelButton) {
387 gtk_widget_destroy(priv->cancelButton);
388 priv->cancelButton = NULL;
391 /* Add needed buttons and images for each note type */
392 switch (priv->note_n)
394 case HILDON_NOTE_CONFIRMATION_TYPE:
395 priv->okButton = gtk_dialog_add_button(dialog,
396 _("ecdg_bd_confirmation_note_ok"), GTK_RESPONSE_OK);
397 priv->cancelButton = gtk_dialog_add_button(dialog,
398 _("ecdg_bd_confirmation_note_cancel"), GTK_RESPONSE_CANCEL);
401 case HILDON_NOTE_CONFIRMATION_BUTTON_TYPE:
402 gtk_image_set_from_icon_name(GTK_IMAGE(priv->icon),
403 HILDON_NOTE_CONFIRMATION_ICON,
404 HILDON_ICON_SIZE_BIG_NOTE);
407 case HILDON_NOTE_INFORMATION_THEME_TYPE:
408 case HILDON_NOTE_INFORMATION_TYPE:
409 /* Add clickable OK button (cancel really,
410 but doesn't matter since this is info) */
411 priv->cancelButton = gtk_dialog_add_button(dialog,
412 _("ecdg_bd_information_note_ok"), GTK_RESPONSE_CANCEL);
413 gtk_image_set_from_icon_name(GTK_IMAGE(priv->icon),
414 HILDON_NOTE_INFORMATION_ICON,
415 HILDON_ICON_SIZE_BIG_NOTE);
418 case HILDON_NOTE_PROGRESSBAR_TYPE:
419 priv->cancelButton = gtk_dialog_add_button(dialog,
420 _("ecdg_bd_cancel_note_cancel"), GTK_RESPONSE_CANCEL);
421 IsHorizontal = FALSE;
429 /* Pack item with label horizontally */
430 priv->box = gtk_hbox_new(FALSE, HILDON_MARGIN_DEFAULT);
431 gtk_container_add(GTK_CONTAINER(dialog->vbox), priv->box);
434 GtkWidget *alignment = gtk_alignment_new(0, 0, 0, 0);
436 gtk_box_pack_start(GTK_BOX(priv->box), alignment, FALSE, FALSE, 0);
437 gtk_container_add(GTK_CONTAINER(alignment), priv->icon);
439 gtk_box_pack_start(GTK_BOX(priv->box), priv->label, TRUE, TRUE, 0);
442 /* Pack item with label vertically */
443 priv->box = gtk_vbox_new(FALSE, HILDON_MARGIN_DOUBLE);
444 gtk_container_add(GTK_CONTAINER(dialog->vbox), priv->box);
445 gtk_box_pack_start(GTK_BOX(priv->box), priv->label, TRUE, TRUE, 0);
447 if (priv->progressbar)
448 gtk_box_pack_start(GTK_BOX(priv->box), priv->progressbar, FALSE, FALSE, 0);
451 gtk_widget_show_all(priv->box);
455 * hildon_note_new_confirmation_add_buttons:
456 * @parent: the parent window. The X window ID of the parent window
457 * has to be the same as the X window ID of the application. This is
458 * important so that the window manager could handle the windows
460 * In GTK the X window ID can be checked using
461 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
462 * @description: the message to confirm
463 * @Varargs: arguments pairs for new buttons(label and return value).
464 * Terminate the list with %NULL value.
466 * Create a new confirmation note with custom buttons. Confirmation
467 * note has a text and any number of buttons. It's important to note
468 * that even though the name of the function might suggest, the
469 * default ok/cancel buttons are not appended but you have to provide
470 * all of the buttons.
472 * FIXME: This doc seems to be wrong, the two buttons aren't added so
473 * it would only contain the "additional" buttons? However, changing
474 * this would break those applications that rely on current behaviour.
476 * Returns: A #GtkWidget pointer of the note
478 GtkWidget *hildon_note_new_confirmation_add_buttons(GtkWindow *parent,
479 const gchar *description,
486 g_return_val_if_fail(parent == NULL || GTK_IS_WINDOW(parent), NULL);
488 GtkWidget *conf_note =
489 g_object_new(HILDON_TYPE_NOTE,
490 "note_type", HILDON_NOTE_CONFIRMATION_BUTTON_TYPE,
491 "description", description,
492 "icon", HILDON_NOTE_CONFIRMATION_ICON,
496 gtk_window_set_transient_for(GTK_WINDOW(conf_note), parent);
498 /* Add the buttons from varargs */
499 va_start(args, description);
502 message = va_arg(args, char *);
507 value = va_arg(args, int);
509 gtk_dialog_add_button(GTK_DIALOG(conf_note), message, value);
519 * hildon_note_new_confirmation:
520 * @parent: the parent window. The X window ID of the parent window
521 * has to be the same as the X window ID of the application. This is
522 * important so that the window manager could handle the windows
523 * correctly. In GTK the X window ID can be checked using
524 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
525 * @description: the message to confirm
527 * Create a new confirmation note. Confirmation note has text (description)
528 * that you specify, two buttons and a default confirmation stock icon.
530 * Returns: a #GtkWidget pointer of the note
532 GtkWidget *hildon_note_new_confirmation(GtkWindow * parent,
533 const gchar * description)
535 return hildon_note_new_confirmation_with_icon_name
536 (parent, description, HILDON_NOTE_CONFIRMATION_ICON);
541 * hildon_note_new_confirmation_with_icon_stock:
542 * @parent: the parent window. The X window ID of the parent window
543 * has to be the same as the X window ID of the application. This is
544 * important so that the window manager could handle the windows
545 * correctly. In GTK the X window ID can be checked using
546 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
547 * @description: the message to confirm
548 * @stock_id: icon to be displayed. If NULL, default icon is used.
550 * Create a new confirmation note. Confirmation note has text (description)
551 * that you specify, two buttons and an icon.
553 * Note! This function is deprecated and broken, and really should not
556 * Returns: a #GtkWidget pointer of the note
558 GtkWidget *hildon_note_new_confirmation_with_icon_stock(GtkWindow * parent,
564 /* FIXME: This function is broken. We cannot detect if the "icon"
565 means icon name or stock-id, since the type is the same
566 as in the following function. Anyway, since we really
567 do not support stock icons properly, this is a minor issue. */
568 GtkWidget *dialog = g_object_new(HILDON_TYPE_NOTE,
570 HILDON_NOTE_CONFIRMATION_TYPE,
571 "description", description, "icon",
575 gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
581 * hildon_note_new_confirmation_with_icon_name:
582 * @parent: the parent window. The X window ID of the parent window
583 * has to be the same as the X window ID of the application. This is
584 * important so that the window manager could handle the windows
585 * correctly. In GTK the X window ID can be checked using
586 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
587 * @description: the message to confirm
588 * @icon_name: icon to be displayed. If NULL, default icon is used.
590 * Create a new confirmation note. Confirmation note has text(description)
591 * that you specify, two buttons and an icon.
593 * Returns: a #GtkWidget pointer of the note
595 GtkWidget *hildon_note_new_confirmation_with_icon_name(GtkWindow * parent,
601 GtkWidget *dialog = NULL;
603 g_return_val_if_fail(parent == NULL || GTK_IS_WINDOW(parent), NULL);
605 dialog = g_object_new(HILDON_TYPE_NOTE,
607 HILDON_NOTE_CONFIRMATION_TYPE,
608 "description", description, "icon",
611 gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
617 * hildon_note_new_information:
618 * @parent: the parent window. The X window ID of the parent window
619 * has to be the same as the X window ID of the application. This is
620 * important so that the window manager could handle the windows
621 * correctly. In GTK the X window ID can be checked using
622 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
623 * @description: the message to confirm
625 * Create a new information note. Information note has a text(description)
626 * that you specify, an OK button and an icon.
628 * Returns: a #GtkWidget pointer of the note
630 GtkWidget *hildon_note_new_information(GtkWindow * parent,
631 const gchar * description)
633 return hildon_note_new_information_with_icon_name
634 (parent, description, HILDON_NOTE_INFORMATION_ICON);
638 * hildon_note_new_information_with_icon_stock:
639 * @parent: the parent window. The X window ID of the parent window
640 * has to be the same as the X window ID of the application. This is
641 * important so that the window manager could handle the windows
642 * correctly. 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 * @stock_id: icon to be displayed. If NULL, default icon is used.
647 * Create a new information note. Information note has text(description)
648 * that you specify, an OK button and a default stock note icon.
650 * Note! This function is broken and deprecated and should not be
651 * used by anybody. Since the platform doesn't use stock icons,
652 * use #hildon_note_new_information_with_icon_name instead.
654 * Returns: a #GtkWidget pointer of the note
656 GtkWidget *hildon_note_new_information_with_icon_stock(GtkWindow * parent,
662 GtkWidget *dialog = NULL;
664 g_return_val_if_fail(parent == NULL || GTK_IS_WINDOW(parent), NULL);
666 dialog = g_object_new(HILDON_TYPE_NOTE,
668 HILDON_NOTE_INFORMATION_TYPE,
669 "description", description,
670 "icon", stock_id, NULL);
672 gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
678 * hildon_note_new_information_with_icon_name:
679 * @parent: the parent window. The X window ID of the parent window
680 * has to be the same as the X window ID of the application. This is
681 * important so that the window manager could handle the windows
682 * correctly. In GTK the X window ID can be checked using
683 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
684 * @description: the message to confirm
685 * @icon_name: icon to be displayed. If NULL, default icon is used.
687 * Create a new information note. Information note has text(description)
688 * that you specify, an OK button and an icon.
690 * Returns: a #GtkWidget pointer of the note
692 GtkWidget *hildon_note_new_information_with_icon_name(GtkWindow * parent,
698 GtkWidget *dialog = NULL;
700 g_return_val_if_fail(parent == NULL || GTK_IS_WINDOW(parent), NULL);
702 dialog = g_object_new(HILDON_TYPE_NOTE,
704 HILDON_NOTE_INFORMATION_THEME_TYPE,
705 "description", description,
706 "icon", icon_name, NULL);
708 gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
714 * hildon_note_new_information_with_icon_theme:
715 * @parent: the parent window. The X window ID of the parent window
716 * has to be the same as the X window ID of the application. This is
717 * important so that the window manager could handle the windows
718 * correctly. In GTK the X window ID can be checked using
719 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
720 * @description: the message to confirm
721 * @icon: #GtkIconTheme icon to be displayed
723 * This function is deprecated. Use
724 * #hildon_note_new_information_with_icon_name instead.
726 * Create a new information note. Information note has text(description)
727 * that you specify, an OK button and an icon.
729 * Returns: a #GtkWidget pointer of the note.
731 GtkWidget *hildon_note_new_information_with_icon_theme(GtkWindow *parent,
732 const gchar *description,
735 return hildon_note_new_information_with_icon_name(parent, description, icon);
739 * hildon_note_new_cancel_with_progress_bar:
740 * @parent: the parent window. The X window ID of the parent window
741 * has to be the same as the X window ID of the application. This is
742 * important so that the window manager could handle the windows
743 * correctly. In GTK the X window ID can be checked using
744 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
745 * @description: the action to cancel
746 * @progressbar: a pointer to #GtkProgressBar to be filled with the
747 * progressbar assigned to this note. Use this to set the fraction of
748 * progressbar done. This parameter can be %NULL as well, in which
749 * case plain text cancel note appears.
751 * Create a new cancel note with a progress bar. Cancel note has
752 * text(description) that you specify, a Cancel button and a progress bar.
754 * Returns: a #GtkDialog. Use this to get rid of this note when you
757 GtkWidget *hildon_note_new_cancel_with_progress_bar(GtkWindow * parent,
763 GtkWidget *dialog = NULL;
765 g_return_val_if_fail(parent == NULL || GTK_IS_WINDOW(parent), NULL);
767 dialog = g_object_new(HILDON_TYPE_NOTE,
769 HILDON_NOTE_PROGRESSBAR_TYPE,
770 "description", description,
774 gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
781 * hildon_note_set_button_text:
782 * @note: a #HildonNote
783 * @text: sets the button text and if there is two buttons in dialog,
784 * the button texts will be <text>, "Cancel".
786 * Sets the button text to be used by the hildon_note widget.
788 void hildon_note_set_button_text(HildonNote * note, const gchar * text)
790 HildonNotePrivate *priv;
792 g_return_if_fail(HILDON_IS_NOTE(note));
794 priv = HILDON_NOTE_GET_PRIVATE(HILDON_NOTE(note));
795 if (priv->okButton) {
796 gtk_button_set_label(GTK_BUTTON(priv->okButton), text);
797 gtk_button_set_label(GTK_BUTTON(priv->cancelButton),
798 _("ecdg_bd_confirmation_note_cancel"));
800 gtk_button_set_label(GTK_BUTTON(priv->cancelButton), text);
805 * hildon_note_set_button_texts:
806 * @note: a #HildonNote
807 * @textOk: the new text of the default OK button
808 * @textCancel: the new text of the default cancel button
810 * Sets the button texts to be used by this hildon_note widget.
812 void hildon_note_set_button_texts(HildonNote * note,
813 const gchar * textOk,
814 const gchar * textCancel)
816 HildonNotePrivate *priv;
818 g_return_if_fail(HILDON_IS_NOTE(note));
820 priv = HILDON_NOTE_GET_PRIVATE(HILDON_NOTE(note));
821 if (priv->okButton) {
822 gtk_button_set_label(GTK_BUTTON(priv->okButton), textOk);
823 gtk_button_set_label(GTK_BUTTON(priv->cancelButton),
826 gtk_button_set_label(GTK_BUTTON(priv->cancelButton), textCancel);
830 /* We play a system sound when the note comes visible */
832 sound_handling(GtkWidget * widget, GdkEventExpose *event, gpointer data)
834 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE(widget);
835 g_signal_handler_disconnect(widget, priv->sound_signal_handler);
836 priv->sound_signal_handler = 0;
838 switch (priv->note_n)
840 case HILDON_NOTE_INFORMATION_TYPE:
841 case HILDON_NOTE_INFORMATION_THEME_TYPE:
842 hildon_play_system_sound(INFORMATION_SOUND_PATH);
844 case HILDON_NOTE_CONFIRMATION_TYPE:
845 case HILDON_NOTE_CONFIRMATION_BUTTON_TYPE:
846 hildon_play_system_sound(CONFIRMATION_SOUND_PATH);