2 * This file is a part of hildon
4 * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
6 * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; version 2.1 of
11 * the License, or (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 #include "hildon-note.h"
71 #include "hildon-defines.h"
72 #include "hildon-sound.h"
73 #include "hildon-banner.h"
74 #include "hildon-enum-types.h"
75 #include "hildon-note-private.h"
78 #define CONFIRMATION_SOUND_PATH \
79 "/usr/share/sounds/ui-confirmation_note.wav"
81 #define INFORMATION_SOUND_PATH \
82 "/usr/share/sounds/ui-information_note.wav"
84 #define HILDON_NOTE_CONFIRMATION_ICON \
87 #define HILDON_NOTE_INFORMATION_ICON \
90 #define _(String) dgettext("hildon-libs", String)
93 hildon_note_class_init (HildonNoteClass *class);
96 hildon_note_init (HildonNote *dialog);
99 hildon_note_rebuild (HildonNote *note);
102 hildon_note_finalize (GObject *obj_self);
105 hildon_note_button_release (GtkWidget *widget,
106 GdkEventButton *event);
109 hildon_note_map (GtkWidget *widget);
112 hildon_note_unmap (GtkWidget *widget);
115 hildon_note_realize (GtkWidget *widget);
118 hildon_note_set_property (GObject *object,
124 hildon_note_get_property (GObject *object,
130 sound_handling (GtkWidget *widget,
131 GdkEventExpose *event,
137 PROP_HILDON_NOTE_TYPE,
138 PROP_HILDON_NOTE_DESCRIPTION,
139 PROP_HILDON_NOTE_ICON,
140 PROP_HILDON_NOTE_PROGRESSBAR,
141 PROP_HILDON_NOTE_STOCK_ICON
144 static GtkDialogClass* parent_class;
147 grab_transfer_window_get (GtkWidget *widget)
150 GdkWindowAttr attributes;
151 gint attributes_mask;
155 attributes.width = 10;
156 attributes.height = 10;
157 attributes.window_type = GDK_WINDOW_TEMP;
158 attributes.wclass = GDK_INPUT_ONLY;
159 attributes.override_redirect = TRUE;
160 attributes.event_mask = 0;
162 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR;
164 window = gdk_window_new (gtk_widget_get_root_window (widget),
165 &attributes, attributes_mask);
166 gdk_window_set_user_data (window, widget);
168 gdk_window_show (window);
174 hildon_note_set_property (GObject *object,
179 HildonNote *note = HILDON_NOTE (object);
180 HildonNotePrivate *priv;
183 priv = HILDON_NOTE_GET_PRIVATE (note);
188 case PROP_HILDON_NOTE_TYPE:
189 priv->note_n = g_value_get_enum (value);
190 hildon_note_rebuild (note);
193 case PROP_HILDON_NOTE_DESCRIPTION:
194 if (priv->original_description)
195 g_free (priv->original_description);
196 priv->original_description = g_value_dup_string (value);
198 gtk_label_set_text (GTK_LABEL (priv->label), priv->original_description);
199 /* FIXME Is the "original_description" used anywhere? */
203 case PROP_HILDON_NOTE_ICON:
204 gtk_image_set_from_icon_name (GTK_IMAGE (priv->icon),
205 g_value_get_string(value), HILDON_ICON_SIZE_BIG_NOTE);
208 case PROP_HILDON_NOTE_STOCK_ICON:
209 gtk_image_set_from_stock (GTK_IMAGE (priv->icon),
210 g_value_get_string (value), HILDON_ICON_SIZE_BIG_NOTE);
213 case PROP_HILDON_NOTE_PROGRESSBAR:
214 widget = g_value_get_object (value);
215 if (widget != priv->progressbar)
217 if (priv->progressbar)
218 g_object_unref (priv->progressbar);
220 priv->progressbar = widget;
224 g_object_ref (widget);
225 gtk_object_sink (GTK_OBJECT (widget));
228 hildon_note_rebuild (note);
233 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
239 hildon_note_get_property (GObject *object,
244 HildonNote *note = HILDON_NOTE (object);
245 HildonNotePrivate *priv;
247 priv = HILDON_NOTE_GET_PRIVATE (note);
251 case PROP_HILDON_NOTE_TYPE:
252 g_value_set_enum (value, priv->note_n);
255 case PROP_HILDON_NOTE_DESCRIPTION:
256 g_value_set_string (value, priv->original_description);
259 case PROP_HILDON_NOTE_ICON:
260 g_object_get_property (G_OBJECT (priv->icon), "icon-name", value);
263 case PROP_HILDON_NOTE_STOCK_ICON:
264 g_object_get_property (G_OBJECT (priv->icon), "stock", value);
267 case PROP_HILDON_NOTE_PROGRESSBAR:
268 g_value_set_object (value, priv->progressbar);
272 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
278 * hildon_note_get_type:
280 * Returns GType for HildonNote.
282 * Returns: HildonNote type
285 hildon_note_get_type (void)
287 static GType dialog_type = 0;
290 static const GTypeInfo dialog_info = {
291 sizeof(HildonNoteClass),
292 NULL, /* base_init */
293 NULL, /* base_finalize */
294 (GClassInitFunc) hildon_note_class_init,
295 NULL, /* class_finalize */
296 NULL, /* class_data */
299 (GInstanceInitFunc) hildon_note_init
301 dialog_type = g_type_register_static (GTK_TYPE_DIALOG,
309 hildon_note_class_init (HildonNoteClass *class)
311 GObjectClass *object_class = G_OBJECT_CLASS (class);
312 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
314 /* set the global parent_class */
315 parent_class = g_type_class_peek_parent (class);
317 g_type_class_add_private (class, sizeof (HildonNotePrivate));
319 object_class->finalize = hildon_note_finalize;
320 object_class->set_property = hildon_note_set_property;
321 object_class->get_property = hildon_note_get_property;
322 widget_class->button_release_event = hildon_note_button_release;
323 widget_class->map = hildon_note_map;
324 widget_class->unmap = hildon_note_unmap;
325 widget_class->realize = hildon_note_realize;
327 g_object_class_install_property (object_class,
328 PROP_HILDON_NOTE_TYPE,
329 g_param_spec_enum ("note-type",
331 "The type of the note dialog",
332 hildon_note_type_get_type (),
333 HILDON_NOTE_TYPE_CONFIRMATION,
334 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
337 * HildonNote:description:
339 * Description for the note.
341 g_object_class_install_property (object_class,
342 PROP_HILDON_NOTE_DESCRIPTION,
343 g_param_spec_string ("description",
345 "The text that appears in the note dialog",
354 g_object_class_install_property (object_class,
355 PROP_HILDON_NOTE_ICON,
356 g_param_spec_string ("icon",
358 "The name of the icon that appears in the note dialog",
363 * HildonNote:stock-icon:
365 * Stock icon name for the note.
367 g_object_class_install_property (object_class,
368 PROP_HILDON_NOTE_STOCK_ICON,
369 g_param_spec_string ("stock-icon",
371 "The stock name of the icon that appears in the note dialog",
376 * HildonNote:progressbar:
378 * Progressbar for the note (if any).
380 g_object_class_install_property (object_class,
381 PROP_HILDON_NOTE_PROGRESSBAR,
382 g_param_spec_object ("progressbar",
383 "Progressbar widget",
384 "The progressbar that appears in the note dialog",
385 GTK_TYPE_PROGRESS_BAR,
390 hildon_note_init (HildonNote *dialog)
392 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (dialog);
395 priv->label = gtk_label_new (NULL);
396 gtk_label_set_line_wrap (GTK_LABEL (priv->label), TRUE);
398 priv->icon = gtk_image_new ();
399 priv->close_if_pressed_outside = FALSE;
400 priv->transfer_window = NULL;
402 /* Acquire real references to our internal children, since
403 they are not nessecarily packed into container in each
405 g_object_ref_sink (priv->label);
406 g_object_ref_sink (priv->icon);
408 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
409 gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
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->label);
426 g_object_unref (priv->icon);
428 if (priv->progressbar)
429 g_object_unref (priv->progressbar);
431 if (priv->original_description)
432 g_free (priv->original_description);
434 G_OBJECT_CLASS (parent_class)->finalize (obj_self);
439 hildon_note_button_release (GtkWidget *widget,
440 GdkEventButton *event)
443 gboolean info_note, released_outside;
444 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (widget);
446 gdk_window_get_position (widget->window, &x, &y);
448 /* Whether the button has been released outside the widget */
449 released_outside = (event->x_root < x || event->x_root > x + widget->allocation.width ||
450 event->y_root < y || event->y_root > y + widget->allocation.height);
452 /* Information notes are also closed by tapping on them */
453 info_note = (priv->note_n == HILDON_NOTE_TYPE_INFORMATION ||
454 priv->note_n == HILDON_NOTE_TYPE_INFORMATION_THEME);
456 if (info_note || (released_outside && priv->close_if_pressed_outside)) {
457 gtk_dialog_response (GTK_DIALOG (widget), GTK_RESPONSE_CANCEL);
460 if (GTK_WIDGET_CLASS (parent_class)->button_release_event) {
461 return GTK_WIDGET_CLASS (parent_class)->button_release_event (widget, event);
468 hildon_note_map (GtkWidget *widget)
470 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (widget);
474 GTK_WIDGET_CLASS (parent_class)->map (widget);
476 if (priv->transfer_window == NULL && priv->close_if_pressed_outside) {
477 gboolean has_grab = FALSE;
479 priv->transfer_window = grab_transfer_window_get (widget);
481 if (gdk_pointer_grab (priv->transfer_window, TRUE,
482 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
483 GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
484 GDK_POINTER_MOTION_MASK, NULL, NULL,
485 GDK_CURRENT_TIME) == GDK_GRAB_SUCCESS) {
486 if (gdk_keyboard_grab (priv->transfer_window, TRUE,
487 GDK_CURRENT_TIME) == GDK_GRAB_SUCCESS) {
490 gdk_display_pointer_ungrab (gtk_widget_get_display (widget),
496 gtk_grab_add (widget);
498 gdk_window_destroy (priv->transfer_window);
499 priv->transfer_window = NULL;
505 hildon_note_unmap (GtkWidget *widget)
507 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (widget);
510 if (priv->transfer_window != NULL) {
511 /* Remove the grab */
512 gdk_display_pointer_ungrab (gtk_widget_get_display (widget),
514 gtk_grab_remove (widget);
516 /* Destroy the transfer window */
517 gdk_window_destroy (priv->transfer_window);
518 priv->transfer_window = NULL;
523 hildon_note_realize (GtkWidget *widget)
527 const gchar *notification_type;
528 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (widget);
531 /* Make widget->window accessible */
532 GTK_WIDGET_CLASS (parent_class)->realize (widget);
534 /* Border only, no titlebar */
535 gdk_window_set_decorations (widget->window, GDK_DECOR_BORDER);
537 /* Because ESD is synchronous, we wish to play sound after the
538 note is already on screen to avoid blocking its appearance */
539 if (priv->sound_signal_handler == 0)
540 priv->sound_signal_handler = g_signal_connect_after(widget,
541 "expose-event", G_CALLBACK (sound_handling), NULL);
543 /* We use special hint to turn the note into information notification. */
544 gdk_window_set_type_hint (widget->window, GDK_WINDOW_TYPE_HINT_NOTIFICATION);
546 /* Set the _HILDON_NOTIFICATION_TYPE property so Matchbox places the window correctly */
547 display = gdk_drawable_get_display (widget->window);
548 atom = gdk_x11_get_xatom_by_name_for_display (display, "_HILDON_NOTIFICATION_TYPE");
550 if (priv->note_n == HILDON_NOTE_TYPE_INFORMATION ||
551 priv->note_n == HILDON_NOTE_TYPE_INFORMATION_THEME) {
552 notification_type = "_HILDON_NOTIFICATION_TYPE_INFO";
554 notification_type = "_HILDON_NOTIFICATION_TYPE_CONFIRMATION";
557 XChangeProperty (GDK_WINDOW_XDISPLAY (widget->window), GDK_WINDOW_XID (widget->window),
558 atom, XA_STRING, 8, PropModeReplace, (guchar *) notification_type,
559 strlen (notification_type));
562 /* Helper function for removing a widget from it's container.
563 we own a separate reference to each object we try to unpack,
564 so extra referencing is not needed. */
566 unpack_widget (GtkWidget *widget)
568 g_assert (widget == NULL || GTK_IS_WIDGET (widget));
570 if (widget && widget->parent)
571 gtk_container_remove (GTK_CONTAINER (widget->parent), widget);
575 hildon_note_rebuild (HildonNote *note)
578 HildonNotePrivate *priv;
579 gboolean IsHorizontal = TRUE;
581 g_assert (HILDON_IS_NOTE (note));
583 priv = HILDON_NOTE_GET_PRIVATE (note);
586 dialog = GTK_DIALOG (note);
588 /* Reuse exiting content widgets for new layout */
589 unpack_widget (priv->label);
590 unpack_widget (priv->icon);
591 unpack_widget (priv->progressbar);
593 /* Destroy old layout and buttons */
595 gtk_widget_destroy (priv->box);
598 if (priv->okButton) {
599 gtk_widget_destroy (priv->okButton);
600 priv->okButton = NULL;
602 if (priv->cancelButton) {
603 gtk_widget_destroy (priv->cancelButton);
604 priv->cancelButton = NULL;
607 /* By default the note won't be closed when pressing outside */
608 priv->close_if_pressed_outside = FALSE;
610 /* Add needed buttons and images for each note type */
611 switch (priv->note_n)
613 case HILDON_NOTE_TYPE_CONFIRMATION:
614 priv->okButton = gtk_dialog_add_button (dialog,
615 _("ecdg_bd_confirmation_note_ok"), GTK_RESPONSE_OK);
616 priv->cancelButton = gtk_dialog_add_button (dialog,
617 _("ecdg_bd_confirmation_note_cancel"), GTK_RESPONSE_CANCEL);
620 case HILDON_NOTE_TYPE_CONFIRMATION_BUTTON:
621 gtk_image_set_from_icon_name (GTK_IMAGE (priv->icon),
622 HILDON_NOTE_CONFIRMATION_ICON,
623 HILDON_ICON_SIZE_BIG_NOTE);
626 case HILDON_NOTE_TYPE_INFORMATION_THEME:
627 case HILDON_NOTE_TYPE_INFORMATION:
628 priv->close_if_pressed_outside = TRUE;
629 gtk_image_set_from_icon_name (GTK_IMAGE (priv->icon),
630 HILDON_NOTE_INFORMATION_ICON,
631 HILDON_ICON_SIZE_BIG_NOTE);
634 case HILDON_NOTE_TYPE_PROGRESSBAR:
635 priv->cancelButton = gtk_dialog_add_button (dialog,
636 _("ecdg_bd_cancel_note_cancel"), GTK_RESPONSE_CANCEL);
637 IsHorizontal = FALSE;
645 /* Pack item with label horizontally */
646 priv->box = gtk_hbox_new (FALSE, HILDON_MARGIN_DEFAULT);
647 gtk_container_add (GTK_CONTAINER (dialog->vbox), priv->box);
650 GtkWidget *alignment = gtk_alignment_new (0, 0, 0, 0);
652 gtk_box_pack_start (GTK_BOX (priv->box), alignment, FALSE, FALSE, 0);
653 gtk_container_add (GTK_CONTAINER (alignment), priv->icon);
655 gtk_box_pack_start (GTK_BOX (priv->box), priv->label, TRUE, TRUE, 0);
658 /* Pack item with label vertically */
659 priv->box = gtk_vbox_new (FALSE, HILDON_MARGIN_DOUBLE);
660 gtk_container_add (GTK_CONTAINER (dialog->vbox), priv->box);
661 gtk_box_pack_start (GTK_BOX (priv->box), priv->label, TRUE, TRUE, 0);
663 if (priv->progressbar)
664 gtk_box_pack_start (GTK_BOX (priv->box), priv->progressbar, FALSE, FALSE, 0);
667 gtk_widget_show_all (priv->box);
671 * hildon_note_new_confirmation_add_buttons:
672 * @parent: the parent window. The X window ID of the parent window
673 * has to be the same as the X window ID of the application. This is
674 * important so that the window manager could handle the windows
676 * In GTK the X window ID can be checked using
677 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
678 * @description: the message to confirm
679 * @Varargs: arguments pairs for new buttons(label and return value).
680 * Terminate the list with %NULL value.
682 * Create a new confirmation note with custom buttons. Confirmation
683 * note has a text and any number of buttons. It's important to note
684 * that even though the name of the function might suggest, the
685 * default ok/cancel buttons are not appended but you have to provide
686 * all of the buttons.
688 * FIXME: This doc seems to be wrong, the two buttons aren't added so
689 * it would only contain the "additional" buttons? However, changing
690 * this would break those applications that rely on current behaviour.
692 * Returns: A #GtkWidget pointer of the note
695 hildon_note_new_confirmation_add_buttons (GtkWindow *parent,
696 const gchar *description,
703 g_return_val_if_fail (description != NULL, NULL);
705 GtkWidget *conf_note =
706 g_object_new (HILDON_TYPE_NOTE,
707 "note-type", HILDON_NOTE_TYPE_CONFIRMATION_BUTTON,
708 "description", description,
709 "icon", HILDON_NOTE_CONFIRMATION_ICON,
713 gtk_window_set_transient_for (GTK_WINDOW (conf_note), parent);
715 /* Add the buttons from varargs */
716 va_start(args, description);
719 message = va_arg (args, char *);
724 value = va_arg (args, int);
726 gtk_dialog_add_button (GTK_DIALOG (conf_note), message, value);
736 * hildon_note_new_confirmation:
737 * @parent: the parent window. The X window ID of the parent window
738 * has to be the same as the X window ID of the application. This is
739 * important so that the window manager could handle the windows
740 * correctly. In GTK the X window ID can be checked using
741 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
742 * @description: the message to confirm
744 * Create a new confirmation note. Confirmation note has text (description)
745 * that you specify, two buttons and a default confirmation stock icon.
747 * Returns: a #GtkWidget pointer of the note
750 hildon_note_new_confirmation (GtkWindow *parent,
751 const gchar *description)
753 return hildon_note_new_confirmation_with_icon_name
754 (parent, description, HILDON_NOTE_CONFIRMATION_ICON);
758 * hildon_note_new_confirmation_with_icon_name:
759 * @parent: the parent window. The X window ID of the parent window
760 * has to be the same as the X window ID of the application. This is
761 * important so that the window manager could handle the windows
762 * correctly. In GTK the X window ID can be checked using
763 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
764 * @description: the message to confirm
765 * @icon_name: icon to be displayed. If NULL, default icon is used.
767 * Create a new confirmation note. Confirmation note has text(description)
768 * that you specify, two buttons and an icon.
770 * Returns: a #GtkWidget pointer of the note
773 hildon_note_new_confirmation_with_icon_name (GtkWindow *parent,
774 const gchar *description,
775 const gchar *icon_name)
777 GtkWidget *dialog = NULL;
779 g_return_val_if_fail (description != NULL, NULL);
781 dialog = g_object_new (HILDON_TYPE_NOTE,
783 HILDON_NOTE_TYPE_CONFIRMATION,
784 "description", description, "icon",
788 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
794 * hildon_note_new_information:
795 * @parent: the parent window. The X window ID of the parent window
796 * has to be the same as the X window ID of the application. This is
797 * important so that the window manager could handle the windows
798 * correctly. In GTK the X window ID can be checked using
799 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
800 * @description: the message to confirm
802 * Create a new information note. Information note has a text(description)
803 * that you specify, an OK button and an icon.
805 * Returns: a #GtkWidget pointer of the note
808 hildon_note_new_information (GtkWindow *parent,
809 const gchar *description)
811 return hildon_note_new_information_with_icon_name
812 (parent, description, HILDON_NOTE_INFORMATION_ICON);
816 * hildon_note_new_information_with_icon_name:
817 * @parent: the parent window. The X window ID of the parent window
818 * has to be the same as the X window ID of the application. This is
819 * important so that the window manager could handle the windows
820 * correctly. In GTK the X window ID can be checked using
821 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
822 * @description: the message to confirm
823 * @icon_name: icon to be displayed. If NULL, default icon is used.
825 * Create a new information note. Information note has text(description)
826 * that you specify, an OK button and an icon.
828 * Returns: a #GtkWidget pointer of the note
831 hildon_note_new_information_with_icon_name (GtkWindow * parent,
832 const gchar *description,
833 const gchar *icon_name)
835 GtkWidget *dialog = NULL;
837 g_return_val_if_fail (description != NULL, NULL);
838 g_return_val_if_fail (icon_name != NULL, NULL);
840 dialog = g_object_new (HILDON_TYPE_NOTE,
842 HILDON_NOTE_TYPE_INFORMATION_THEME,
843 "description", description,
844 "icon", icon_name, NULL);
847 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
852 /* FIXME This documentation string LIES! */
855 * hildon_note_new_cancel_with_progress_bar:
856 * @parent: the parent window. The X window ID of the parent window
857 * has to be the same as the X window ID of the application. This is
858 * important so that the window manager could handle the windows
859 * correctly. In GTK the X window ID can be checked using
860 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
861 * @description: the action to cancel
862 * @progressbar: a pointer to #GtkProgressBar to be filled with the
863 * progressbar assigned to this note. Use this to set the fraction of
864 * progressbar done. This parameter can be %NULL as well, in which
865 * case plain text cancel note appears.
867 * Create a new cancel note with a progress bar. Cancel note has
868 * text(description) that you specify, a Cancel button and a progress bar.
870 * Returns: a #GtkDialog. Use this to get rid of this note when you
874 hildon_note_new_cancel_with_progress_bar (GtkWindow *parent,
875 const gchar *description,
876 GtkProgressBar *progressbar)
878 GtkWidget *dialog = NULL;
880 g_return_val_if_fail (description != NULL, NULL);
882 dialog = g_object_new (HILDON_TYPE_NOTE,
884 HILDON_NOTE_TYPE_PROGRESSBAR,
885 "description", description,
890 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
897 * hildon_note_set_button_text:
898 * @note: a #HildonNote
899 * @text: sets the button text and if there is two buttons in dialog,
900 * the button texts will be <text>, "Cancel".
902 * Sets the button text to be used by the hildon_note widget.
905 hildon_note_set_button_text (HildonNote *note,
908 HildonNotePrivate *priv;
910 g_return_if_fail (HILDON_IS_NOTE (note));
912 priv = HILDON_NOTE_GET_PRIVATE (HILDON_NOTE (note));
915 if (priv->okButton) {
916 gtk_button_set_label (GTK_BUTTON (priv->okButton), text);
917 gtk_button_set_label (GTK_BUTTON (priv->cancelButton),
918 _("ecdg_bd_confirmation_note_cancel"));
920 gtk_button_set_label (GTK_BUTTON (priv->cancelButton), text);
925 * hildon_note_set_button_texts:
926 * @note: a #HildonNote
927 * @text_ok: the new text of the default OK button
928 * @text_cancel: the new text of the default cancel button
930 * Sets the button texts to be used by this hildon_note widget.
933 hildon_note_set_button_texts (HildonNote *note,
934 const gchar *text_ok,
935 const gchar *text_cancel)
937 HildonNotePrivate *priv;
939 g_return_if_fail (HILDON_IS_NOTE (note));
941 priv = HILDON_NOTE_GET_PRIVATE (HILDON_NOTE (note));
944 if (priv->okButton) {
945 gtk_button_set_label (GTK_BUTTON (priv->okButton), text_ok);
946 gtk_button_set_label (GTK_BUTTON (priv->cancelButton), text_cancel);
948 gtk_button_set_label (GTK_BUTTON (priv->cancelButton), text_cancel);
952 /* We play a system sound when the note comes visible */
954 sound_handling (GtkWidget *widget,
955 GdkEventExpose *event,
958 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (widget);
961 g_signal_handler_disconnect (widget, priv->sound_signal_handler);
963 priv->sound_signal_handler = 0;
965 switch (priv->note_n)
967 case HILDON_NOTE_TYPE_INFORMATION:
968 case HILDON_NOTE_TYPE_INFORMATION_THEME:
969 hildon_play_system_sound (INFORMATION_SOUND_PATH);
972 case HILDON_NOTE_TYPE_CONFIRMATION:
973 case HILDON_NOTE_TYPE_CONFIRMATION_BUTTON:
974 hildon_play_system_sound (CONFIRMATION_SOUND_PATH);