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
28 * This file contains API for confirmation, information and cancel notes.
35 #include "hildon-note.h"
36 #include <gtk/gtklabel.h>
37 #include <gtk/gtkimage.h>
38 #include <gtk/gtkhbox.h>
39 #include <gtk/gtkalignment.h>
40 #include <gtk/gtkvbox.h>
41 #include <gtk/gtkbutton.h>
43 #include <hildon-widgets/hildon-defines.h>
44 #include <hildon-widgets/hildon-system-sound.h>
45 #include <hildon-widgets/hildon-banner.h>
50 /* FIXME: Can these be included from somewhere? */
51 #define CONFIRMATION_SOUND_PATH "/usr/share/sounds/ui-confirmation_note.wav"
52 #define INFORMATION_SOUND_PATH "/usr/share/sounds/ui-information_note.wav"
53 #define HILDON_NOTE_CONFIRMATION_ICON "qgn_note_confirm"
54 #define HILDON_NOTE_INFORMATION_ICON "qgn_note_info"
56 #define _(String) dgettext(PACKAGE, String)
58 static GtkDialogClass *parent_class;
60 #define HILDON_NOTE_GET_PRIVATE(obj)\
61 (G_TYPE_INSTANCE_GET_PRIVATE ((obj), \
62 HILDON_TYPE_NOTE, HildonNotePrivate));
64 typedef struct _HildonNotePrivate HildonNotePrivate;
66 static void hildon_note_class_init(HildonNoteClass * class);
67 static void hildon_note_init(HildonNote * dialog);
69 static void hildon_note_rebuild(HildonNote *note);
70 static void hildon_note_finalize(GObject * obj_self);
71 static void hildon_note_realize (GtkWidget *widget);
73 static void hildon_note_set_property(GObject * object,
77 static void hildon_note_get_property(GObject * object,
79 GValue * value, GParamSpec * pspec);
82 sound_handling(GtkWidget * widget, GdkEventExpose *event, gpointer data);
84 struct _HildonNotePrivate {
86 GtkWidget *cancelButton;
91 HildonNoteType note_n;
92 GtkWidget *progressbar;
93 gulong sound_signal_handler;
95 gchar *original_description;
100 PROP_HILDON_NOTE_TYPE,
101 PROP_HILDON_NOTE_DESCRIPTION,
102 PROP_HILDON_NOTE_ICON,
103 PROP_HILDON_NOTE_PROGRESSBAR
107 hildon_note_set_property(GObject * object,
109 const GValue * value, GParamSpec * pspec)
111 HildonNote *note = HILDON_NOTE(object);
112 HildonNotePrivate *priv;
115 priv = HILDON_NOTE_GET_PRIVATE(note);
118 case PROP_HILDON_NOTE_TYPE:
119 priv->note_n = g_value_get_enum(value);
120 hildon_note_rebuild(note);
122 case PROP_HILDON_NOTE_DESCRIPTION:
123 g_free(priv->original_description);
124 priv->original_description = g_value_dup_string(value);
126 _hildon_gtk_label_set_text_n_lines(GTK_LABEL(priv->label),
127 priv->original_description,
128 priv->note_n == HILDON_NOTE_PROGRESSBAR_TYPE ? 1 : 5);
131 case PROP_HILDON_NOTE_ICON:
132 gtk_image_set_from_icon_name(GTK_IMAGE(priv->icon),
133 g_value_get_string(value), HILDON_ICON_SIZE_BIG_NOTE);
135 case PROP_HILDON_NOTE_PROGRESSBAR:
136 widget = g_value_get_object(value);
137 if (widget != priv->progressbar)
139 if (priv->progressbar)
140 g_object_unref(priv->progressbar);
142 priv->progressbar = widget;
146 g_object_ref(widget);
147 gtk_object_sink(GTK_OBJECT(widget));
150 hildon_note_rebuild(note);
154 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
160 hildon_note_get_property(GObject * object,
161 guint prop_id, GValue * value, GParamSpec * pspec)
163 HildonNote *note = HILDON_NOTE(object);
164 HildonNotePrivate *priv;
166 priv = HILDON_NOTE_GET_PRIVATE(note);
169 case PROP_HILDON_NOTE_TYPE:
170 g_value_set_enum(value, priv->note_n);
172 case PROP_HILDON_NOTE_DESCRIPTION:
173 g_value_set_string(value, priv->original_description);
175 case PROP_HILDON_NOTE_ICON:
176 g_object_get_property(G_OBJECT(priv->icon), "icon-name", value);
178 case PROP_HILDON_NOTE_PROGRESSBAR:
179 g_value_set_object(value, priv->progressbar);
182 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
187 GType hildon_note_type_get_type (void)
189 static GType notetype = 0;
191 static const GEnumValue values[] = {
192 { HILDON_NOTE_CONFIRMATION_TYPE, "HILDON_NOTE_CONFIRMATION_TYPE", "confirmation" },
193 { HILDON_NOTE_CONFIRMATION_BUTTON_TYPE, "HILDON_NOTE_CONFIRMATION_BUTTON_TYPE", "confirmation-button" },
194 { HILDON_NOTE_INFORMATION_TYPE, "HILDON_NOTE_INFORMATION_TYPE", "note-information" },
195 { HILDON_NOTE_INFORMATION_THEME_TYPE, "HILDON_NOTE_INFORMATION_THEME_TYPE", "note-information-theme" },
196 { HILDON_NOTE_PROGRESSBAR_TYPE, "HILDON_NOTE_PROGRESSBAR_TYPE", "note-progressbar" },
199 notetype = g_enum_register_static ("HildonNoteType", values);
205 GType hildon_note_get_type()
207 static GType dialog_type = 0;
210 static const GTypeInfo dialog_info = {
211 sizeof(HildonNoteClass),
212 NULL, /* base_init */
213 NULL, /* base_finalize */
214 (GClassInitFunc) hildon_note_class_init,
215 NULL, /* class_finalize */
216 NULL, /* class_data */
219 (GInstanceInitFunc) hildon_note_init
221 dialog_type = g_type_register_static(GTK_TYPE_DIALOG,
228 static void hildon_note_class_init(HildonNoteClass * class)
230 GObjectClass *object_class = G_OBJECT_CLASS(class);
231 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(class);
233 /* set the global parent_class */
234 parent_class = g_type_class_peek_parent(class);
236 g_type_class_add_private(class, sizeof(HildonNotePrivate));
238 object_class->finalize = hildon_note_finalize;
239 object_class->set_property = hildon_note_set_property;
240 object_class->get_property = hildon_note_get_property;
241 widget_class->realize = hildon_note_realize;
243 g_object_class_install_property(object_class,
244 PROP_HILDON_NOTE_TYPE,
245 g_param_spec_enum("note_type",
247 "The type of the note dialog",
248 hildon_note_type_get_type(),
249 HILDON_NOTE_CONFIRMATION_TYPE,
250 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
253 * HildonNote:description:
255 * Description for note.
257 g_object_class_install_property(object_class,
258 PROP_HILDON_NOTE_DESCRIPTION,
259 g_param_spec_string("description",
261 "The text that appears in the note dialog",
270 g_object_class_install_property(object_class,
271 PROP_HILDON_NOTE_ICON,
272 g_param_spec_string("icon",
274 "The name of the icon that appears in the note dialog",
279 * HildonNote:progressbar:
281 * Progressbar for note.
283 g_object_class_install_property(object_class,
284 PROP_HILDON_NOTE_PROGRESSBAR,
285 g_param_spec_object("progressbar",
286 "Progressbar widget",
287 "The progressbar that appears in the note dialog",
288 GTK_TYPE_PROGRESS_BAR,
292 static void hildon_note_init(HildonNote * dialog)
294 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE(dialog);
296 priv->label = gtk_label_new(NULL);
297 priv->icon = gtk_image_new();
299 /* Acquire real references to our internal children, since
300 they are not nessecarily packed into container in each
302 g_object_ref(priv->label);
303 g_object_ref(priv->icon);
304 gtk_object_sink(GTK_OBJECT(priv->label));
305 gtk_object_sink(GTK_OBJECT(priv->icon));
307 gtk_dialog_set_has_separator(GTK_DIALOG(dialog), FALSE);
308 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
312 static void hildon_note_finalize(GObject * obj_self)
314 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE(obj_self);
316 /* Free internal data */
317 g_object_unref(priv->label);
318 g_object_unref(priv->icon);
319 if (priv->progressbar)
320 g_object_unref(priv->progressbar);
322 g_free(priv->original_description);
324 G_OBJECT_CLASS(parent_class)->finalize(obj_self);
328 hildon_note_realize (GtkWidget *widget)
330 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE(widget);
332 /* Make widget->window accessible */
333 GTK_WIDGET_CLASS (parent_class)->realize (widget);
335 /* Border only, no titlebar */
336 gdk_window_set_decorations (widget->window, GDK_DECOR_BORDER);
338 /* Because ESD is synchronous, we wish to play sound after the
339 note is already on screen to avoid blocking its appearance */
340 if (priv->sound_signal_handler == 0)
341 priv->sound_signal_handler = g_signal_connect_after(widget,
342 "expose-event", G_CALLBACK(sound_handling), NULL);
345 /* Helper function for removing a widget from it's container.
346 we own a separate reference to each object we try to unpack,
347 so extra referencing is not needed. */
348 static void unpack_widget(GtkWidget *widget)
350 g_assert(widget == NULL || GTK_IS_WIDGET(widget));
352 if (widget && widget->parent)
353 gtk_container_remove(GTK_CONTAINER(widget->parent), widget);
357 hildon_note_rebuild(HildonNote *note)
360 HildonNotePrivate *priv;
361 gboolean IsHorizontal = TRUE;
363 g_assert(HILDON_IS_NOTE(note));
365 priv = HILDON_NOTE_GET_PRIVATE (note);
366 dialog = GTK_DIALOG(note);
368 /* Reuse exiting content widgets for new layout */
369 unpack_widget(priv->label);
370 unpack_widget(priv->icon);
371 unpack_widget(priv->progressbar);
373 /* Destroy old layout and buttons */
375 gtk_widget_destroy(priv->box);
378 if (priv->okButton) {
379 gtk_widget_destroy(priv->okButton);
380 priv->okButton = NULL;
382 if (priv->cancelButton) {
383 gtk_widget_destroy(priv->cancelButton);
384 priv->cancelButton = NULL;
387 /* Add needed buttons and images for each note type */
388 switch (priv->note_n)
390 case HILDON_NOTE_CONFIRMATION_TYPE:
391 priv->okButton = gtk_dialog_add_button(dialog,
392 _("Ecdg_bd_confirmation_note_ok"), GTK_RESPONSE_OK);
393 priv->cancelButton = gtk_dialog_add_button(dialog,
394 _("Ecdg_bd_confirmation_note_cancel"), GTK_RESPONSE_CANCEL);
397 case HILDON_NOTE_CONFIRMATION_BUTTON_TYPE:
398 gtk_image_set_from_icon_name(GTK_IMAGE(priv->icon),
399 HILDON_NOTE_CONFIRMATION_ICON,
400 HILDON_ICON_SIZE_BIG_NOTE);
403 case HILDON_NOTE_INFORMATION_THEME_TYPE:
404 case HILDON_NOTE_INFORMATION_TYPE:
405 /* Add clickable OK button (cancel really,
406 but doesn't matter since this is info) */
407 priv->cancelButton = gtk_dialog_add_button(dialog,
408 _("Ecdg_bd_information_note_ok"), GTK_RESPONSE_CANCEL);
409 gtk_image_set_from_icon_name(GTK_IMAGE(priv->icon),
410 HILDON_NOTE_INFORMATION_ICON,
411 HILDON_ICON_SIZE_BIG_NOTE);
414 case HILDON_NOTE_PROGRESSBAR_TYPE:
415 priv->cancelButton = gtk_dialog_add_button(dialog,
416 _("Ecdg_bd_cancel_note_cancel"), GTK_RESPONSE_CANCEL);
417 IsHorizontal = FALSE;
425 /* Pack item with label horizontally */
426 priv->box = gtk_hbox_new(FALSE, HILDON_MARGIN_DEFAULT);
427 gtk_container_add(GTK_CONTAINER(dialog->vbox), priv->box);
430 GtkWidget *alignment = gtk_alignment_new(0, 0, 0, 0);
432 gtk_box_pack_start(GTK_BOX(priv->box), alignment, FALSE, FALSE, 0);
433 gtk_container_add(GTK_CONTAINER(alignment), priv->icon);
435 gtk_box_pack_start(GTK_BOX(priv->box), priv->label, TRUE, TRUE, 0);
438 /* Pack item with label vertically */
439 priv->box = gtk_vbox_new(FALSE, HILDON_MARGIN_DOUBLE);
440 gtk_container_add(GTK_CONTAINER(dialog->vbox), priv->box);
441 gtk_box_pack_start(GTK_BOX(priv->box), priv->label, TRUE, TRUE, 0);
443 if (priv->progressbar)
444 gtk_box_pack_start(GTK_BOX(priv->box), priv->progressbar, FALSE, FALSE, 0);
447 gtk_widget_show_all(priv->box);
451 * hildon_note_new_confirmation_add_buttons:
452 * @parent: The parent window. The X window ID of the parent window
453 * has to be the same as the X window ID of the application. This is
454 * important so that the window manager could handle the windows
456 * In GTK the X window ID can be checked with
457 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
458 * @description: The message to confirm.
459 * @Varargs: Arguments pairs for new buttons(label and return value).
460 * Terminate the list with %NULL value.
462 * Create a new confirmation note with custom buttons. Confirmation
463 * note has a text and any number of buttons. It's important to note
464 * that even though the name of the function might suggest, the
465 * default ok/cancel buttons are not appended but you have to provide
466 * all of the buttons.
468 * Return value: A #GtkWidget pointer of the note.
471 /* FIXME: This doc seems to be wrong, the two buttons aren't added so it
472 * would only contain the "additional" buttons? However, changing this would
473 break those applications that rely on current behaviour. */
474 GtkWidget *hildon_note_new_confirmation_add_buttons(GtkWindow * parent,
482 g_return_val_if_fail(parent == NULL || GTK_IS_WINDOW(parent), NULL);
484 GtkWidget *conf_note =
485 g_object_new(HILDON_TYPE_NOTE,
486 "note_type", HILDON_NOTE_CONFIRMATION_BUTTON_TYPE,
487 "description", description,
488 "icon", HILDON_NOTE_CONFIRMATION_ICON,
492 gtk_window_set_transient_for(GTK_WINDOW(conf_note), parent);
494 /* Add the buttons from varargs */
495 va_start(args, description);
498 message = va_arg(args, char *);
503 value = va_arg(args, int);
505 gtk_dialog_add_button(GTK_DIALOG(conf_note), message, value);
515 * hildon_note_new_confirmation:
516 * @parent: The parent window. The X window ID of the parent window
517 * has to be the same as the X window ID of the application. This is
518 * important so that the window manager could handle the windows
519 * correctly. In GTK the X window ID can be checked with
520 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
521 * @description: The message to confirm.
523 * Create a new confirmation note. Confirmation note has a text,
524 * two buttons and an default confirmation icon.
526 * Return value: A #GtkWidget pointer of the note.
528 GtkWidget *hildon_note_new_confirmation(GtkWindow * parent,
529 const gchar * description)
531 return hildon_note_new_confirmation_with_icon_name
532 (parent, description, HILDON_NOTE_CONFIRMATION_ICON);
537 * hildon_note_new_confirmation_with_icon_stock:
538 * @parent: The parent window. The X window ID of the parent window
539 * has to be the same as the X window ID of the application. This is
540 * important so that the window manager could handle the windows
541 * correctly. In GTK the X window ID can be checked with
542 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
543 * @description: The message to confirm.
544 * @stock_id: Icon to be displayed. If NULL, default icon is used.
546 * Create a new confirmation note. Confirmation note has a text,
547 * two buttons and an icon.
549 * Note! This function is deprecated and broken, and really should not
552 * Return value: A #GtkWidget pointer of the note.
554 GtkWidget *hildon_note_new_confirmation_with_icon_stock(GtkWindow * parent,
560 /* FIXME: This function is broken. We cannot detect if the "icon"
561 means icon name or stock-id, since the type is the same
562 as in the following function. Anyway, since we really
563 do not support stock icons properly, this is a minor issue. */
564 GtkWidget *dialog = g_object_new(HILDON_TYPE_NOTE,
566 HILDON_NOTE_CONFIRMATION_TYPE,
567 "description", description, "icon",
571 gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
577 * hildon_note_new_confirmation_with_icon_name:
578 * @parent: The parent window. The X window ID of the parent window
579 * has to be the same as the X window ID of the application. This is
580 * important so that the window manager could handle the windows
581 * correctly. In GTK the X window ID can be checked with
582 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
583 * @description: The message to confirm.
584 * @icon_name: Icon to be displayed. If NULL, default icon is used.
586 * Create a new confirmation note. Confirmation note has a text,
587 * two buttons and an icon.
589 * Return value: A #GtkWidget pointer of the note.
591 GtkWidget *hildon_note_new_confirmation_with_icon_name(GtkWindow * parent,
597 GtkWidget *dialog = NULL;
599 g_return_val_if_fail(parent == NULL || GTK_IS_WINDOW(parent), NULL);
601 dialog = g_object_new(HILDON_TYPE_NOTE,
603 HILDON_NOTE_CONFIRMATION_TYPE,
604 "description", description, "icon",
607 gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
613 * hildon_note_new_information:
614 * @parent: The parent window. The X window ID of the parent window
615 * has to be the same as the X window ID of the application. This is
616 * important so that the window manager could handle the windows
617 * correctly. In GTK the X window ID can be checked with
618 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
619 * @description: The message to confirm.
621 * Create a new information note. Information note has a text,
622 * 'OK' labeled button and an icon.
624 * Return value: A #GtkWidget pointer of the note.
626 GtkWidget *hildon_note_new_information(GtkWindow * parent,
627 const gchar * description)
629 return hildon_note_new_information_with_icon_name
630 (parent, description, HILDON_NOTE_INFORMATION_ICON);
634 * hildon_note_new_information_with_icon_stock:
635 * @parent: The parent window. The X window ID of the parent window
636 * has to be the same as the X window ID of the application. This is
637 * important so that the window manager could handle the windows
638 * correctly. In GTK the X window ID can be checked with
639 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
640 * @description: The message to confirm.
641 * @stock_id: Icon to be displayed. If NULL, default icon is used.
643 * Create a new information note. Information note has a text,
644 * 'OK' labeled button and an icon.
646 * Note! This function is broken and deprecated and should not be
647 * used by anybody. Since the platform doesn't use stock icons,
648 * use #hildon_note_new_information_with_icon_name instead.
650 * Return value: A #GtkWidget pointer of the note.
652 GtkWidget *hildon_note_new_information_with_icon_stock(GtkWindow * parent,
658 GtkWidget *dialog = NULL;
660 g_return_val_if_fail(parent == NULL || GTK_IS_WINDOW(parent), NULL);
662 dialog = g_object_new(HILDON_TYPE_NOTE,
664 HILDON_NOTE_INFORMATION_TYPE,
665 "description", description,
666 "icon", stock_id, NULL);
668 gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
674 * hildon_note_new_information_with_icon_name:
675 * @parent: The parent window. The X window ID of the parent window
676 * has to be the same as the X window ID of the application. This is
677 * important so that the window manager could handle the windows
678 * correctly. In GTK the X window ID can be checked with
679 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
680 * @description: The message to confirm.
681 * @icon_name: Icon to be displayed. If NULL, default icon is used.
683 * Create a new information note. Information note has a text,
684 * 'OK' labeled button and an icon.
686 * Return value: A #GtkWidget pointer of the note.
688 GtkWidget *hildon_note_new_information_with_icon_name(GtkWindow * parent,
694 GtkWidget *dialog = NULL;
696 g_return_val_if_fail(parent == NULL || GTK_IS_WINDOW(parent), NULL);
698 dialog = g_object_new(HILDON_TYPE_NOTE,
700 HILDON_NOTE_INFORMATION_THEME_TYPE,
701 "description", description,
702 "icon", icon_name, NULL);
704 gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
710 * hildon_note_new_information_with_icon_theme:
711 * @parent: The parent window.
712 * @description: The message to confirm.
713 * @icon: #GtkIconTheme icon to be displayed.
715 * This function is deprecated. Use
716 * #hildon_note_new_information_with_icon_name instead.
718 * Return value: A #GtkWidget pointer of the note.
720 GtkWidget *hildon_note_new_information_with_icon_theme(GtkWindow *parent,
721 const gchar *description,
724 return hildon_note_new_information_with_icon_name(parent, description, icon);
728 * hildon_note_new_cancel_with_progress_bar:
729 * @parent: The parent window. The X window ID of the parent window
730 * has to be the same as the X window ID of the application. This is
731 * important so that the window manager could handle the windows
732 * correctly. In GTK the X window ID can be checked with
733 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
734 * @description: The action to cancel.
735 * @progressbar: A pointer to #GtkProgressBar to be filled with the
736 * progressbar assigned to this note. Use this to set the fraction of
737 * progressbar done. This parameter can be %NULL as well, in which
738 * case plain text cancel note appears.
740 * Create a new cancel note with a progress bar. The note has a text,
741 * 'Cancel' labeled button and a progress bar.
743 * Return value: A #GtkDialog. Use this to get rid of this note when you
746 GtkWidget *hildon_note_new_cancel_with_progress_bar(GtkWindow * parent,
752 GtkWidget *dialog = NULL;
754 g_return_val_if_fail(parent == NULL || GTK_IS_WINDOW(parent), NULL);
756 dialog = g_object_new(HILDON_TYPE_NOTE,
758 HILDON_NOTE_PROGRESSBAR_TYPE,
759 "description", description,
763 gtk_window_set_transient_for(GTK_WINDOW(dialog), parent);
770 * hildon_note_set_button_text:
771 * @note: A #HildonNote
772 * @text: Sets the button text and if there is two buttons in dialog,
773 * the button texts will be <text>, "Cancel".
775 * Sets the button text to be used by this hildon_note widget.
777 void hildon_note_set_button_text(HildonNote * note, const gchar * text)
779 HildonNotePrivate *priv;
781 g_return_if_fail(HILDON_IS_NOTE(note));
783 priv = HILDON_NOTE_GET_PRIVATE(HILDON_NOTE(note));
784 if (priv->okButton) {
785 gtk_button_set_label(GTK_BUTTON(priv->okButton), text);
786 gtk_button_set_label(GTK_BUTTON(priv->cancelButton),
787 _("Ecdg_bd_confirmation_note_cancel"));
789 gtk_button_set_label(GTK_BUTTON(priv->cancelButton), text);
794 * hildon_note_set_button_texts:
795 * @note: A #HildonNote
796 * @textOk: the new text of the default OK button.
797 * @textCancel: the new text of the default cancel button.
799 * Sets the button texts to be used by this hildon_note widget.
801 void hildon_note_set_button_texts(HildonNote * note,
802 const gchar * textOk,
803 const gchar * textCancel)
805 HildonNotePrivate *priv;
807 g_return_if_fail(HILDON_IS_NOTE(note));
809 priv = HILDON_NOTE_GET_PRIVATE(HILDON_NOTE(note));
810 if (priv->okButton) {
811 gtk_button_set_label(GTK_BUTTON(priv->okButton), textOk);
812 gtk_button_set_label(GTK_BUTTON(priv->cancelButton),
815 gtk_button_set_label(GTK_BUTTON(priv->cancelButton), textCancel);
819 /* We play a system sound when the note comes visible */
821 sound_handling(GtkWidget * widget, GdkEventExpose *event, gpointer data)
823 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE(widget);
824 g_signal_handler_disconnect(widget, priv->sound_signal_handler);
825 priv->sound_signal_handler = 0;
827 switch (priv->note_n)
829 case HILDON_NOTE_INFORMATION_TYPE:
830 case HILDON_NOTE_INFORMATION_THEME_TYPE:
831 hildon_play_system_sound(INFORMATION_SOUND_PATH);
833 case HILDON_NOTE_CONFIRMATION_TYPE:
834 case HILDON_NOTE_CONFIRMATION_BUTTON_TYPE:
835 hildon_play_system_sound(CONFIRMATION_SOUND_PATH);