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>
37 * hildon_note_new_confirmation (window, "Confirmation message...");
39 * i = gtk_dialog_run (GTK_DIALOG (note));
40 * gtk_widget_destroy (GTK_WIDGET (note));
42 * if (i == GTK_RESPONSE_OK)
43 * gtk_infoprint (window, "User pressed 'OK' button'");
45 * gtk_infoprint (window, "User pressed 'Cancel' button" );
54 #include "hildon-note.h"
55 #include <gtk/gtklabel.h>
56 #include <gtk/gtkimage.h>
57 #include <gtk/gtkhbox.h>
58 #include <gtk/gtkalignment.h>
59 #include <gtk/gtkvbox.h>
60 #include <gtk/gtkbutton.h>
62 #include "hildon-defines.h"
63 #include "hildon-sound.h"
64 #include "hildon-banner.h"
65 #include "hildon-enum-types.h"
69 #include <X11/Xatom.h>
70 #include "hildon-note-private.h"
72 #define CONFIRMATION_SOUND_PATH \
73 "/usr/share/sounds/ui-confirmation_note.wav"
75 #define INFORMATION_SOUND_PATH \
76 "/usr/share/sounds/ui-information_note.wav"
78 #define HILDON_NOTE_CONFIRMATION_ICON \
81 #define HILDON_NOTE_INFORMATION_ICON \
84 #define _(String) dgettext("hildon-libs", String)
87 hildon_note_class_init (HildonNoteClass *class);
90 hildon_note_init (HildonNote *dialog);
93 hildon_note_rebuild (HildonNote *note);
96 hildon_note_finalize (GObject *obj_self);
99 hildon_note_button_release (GtkWidget *widget,
100 GdkEventButton *event);
103 hildon_note_map (GtkWidget *widget);
106 hildon_note_unmap (GtkWidget *widget);
109 hildon_note_realize (GtkWidget *widget);
112 hildon_note_set_property (GObject *object,
118 hildon_note_get_property (GObject *object,
124 sound_handling (GtkWidget *widget,
125 GdkEventExpose *event,
131 PROP_HILDON_NOTE_TYPE,
132 PROP_HILDON_NOTE_DESCRIPTION,
133 PROP_HILDON_NOTE_ICON,
134 PROP_HILDON_NOTE_PROGRESSBAR,
135 PROP_HILDON_NOTE_STOCK_ICON
138 static GtkDialogClass* parent_class;
141 grab_transfer_window_get (GtkWidget *widget)
144 GdkWindowAttr attributes;
145 gint attributes_mask;
149 attributes.width = 10;
150 attributes.height = 10;
151 attributes.window_type = GDK_WINDOW_TEMP;
152 attributes.wclass = GDK_INPUT_ONLY;
153 attributes.override_redirect = TRUE;
154 attributes.event_mask = 0;
156 attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_NOREDIR;
158 window = gdk_window_new (gtk_widget_get_root_window (widget),
159 &attributes, attributes_mask);
160 gdk_window_set_user_data (window, widget);
162 gdk_window_show (window);
168 hildon_note_set_property (GObject *object,
173 HildonNote *note = HILDON_NOTE (object);
174 HildonNotePrivate *priv;
177 priv = HILDON_NOTE_GET_PRIVATE (note);
182 case PROP_HILDON_NOTE_TYPE:
183 priv->note_n = g_value_get_enum (value);
184 hildon_note_rebuild (note);
187 case PROP_HILDON_NOTE_DESCRIPTION:
188 if (priv->original_description)
189 g_free (priv->original_description);
190 priv->original_description = g_value_dup_string (value);
192 gtk_label_set_text (GTK_LABEL (priv->label), priv->original_description);
193 /* FIXME Is the "original_description" used anywhere? */
197 case PROP_HILDON_NOTE_ICON:
198 gtk_image_set_from_icon_name (GTK_IMAGE (priv->icon),
199 g_value_get_string(value), HILDON_ICON_SIZE_BIG_NOTE);
202 case PROP_HILDON_NOTE_STOCK_ICON:
203 gtk_image_set_from_stock (GTK_IMAGE (priv->icon),
204 g_value_get_string (value), HILDON_ICON_SIZE_BIG_NOTE);
207 case PROP_HILDON_NOTE_PROGRESSBAR:
208 widget = g_value_get_object (value);
209 if (widget != priv->progressbar)
211 if (priv->progressbar)
212 g_object_unref (priv->progressbar);
214 priv->progressbar = widget;
218 g_object_ref (widget);
219 gtk_object_sink (GTK_OBJECT (widget));
222 hildon_note_rebuild (note);
227 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
233 hildon_note_get_property (GObject *object,
238 HildonNote *note = HILDON_NOTE (object);
239 HildonNotePrivate *priv;
241 priv = HILDON_NOTE_GET_PRIVATE (note);
245 case PROP_HILDON_NOTE_TYPE:
246 g_value_set_enum (value, priv->note_n);
249 case PROP_HILDON_NOTE_DESCRIPTION:
250 g_value_set_string (value, priv->original_description);
253 case PROP_HILDON_NOTE_ICON:
254 g_object_get_property (G_OBJECT (priv->icon), "icon-name", value);
257 case PROP_HILDON_NOTE_STOCK_ICON:
258 g_object_get_property (G_OBJECT (priv->icon), "stock", value);
261 case PROP_HILDON_NOTE_PROGRESSBAR:
262 g_value_set_object (value, priv->progressbar);
266 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
272 * hildon_note_get_type:
274 * Returns GType for HildonNote.
276 * Returns: HildonNote type
279 hildon_note_get_type (void)
281 static GType dialog_type = 0;
284 static const GTypeInfo dialog_info = {
285 sizeof(HildonNoteClass),
286 NULL, /* base_init */
287 NULL, /* base_finalize */
288 (GClassInitFunc) hildon_note_class_init,
289 NULL, /* class_finalize */
290 NULL, /* class_data */
293 (GInstanceInitFunc) hildon_note_init
295 dialog_type = g_type_register_static (GTK_TYPE_DIALOG,
303 hildon_note_class_init (HildonNoteClass *class)
305 GObjectClass *object_class = G_OBJECT_CLASS (class);
306 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
308 /* set the global parent_class */
309 parent_class = g_type_class_peek_parent (class);
311 g_type_class_add_private (class, sizeof (HildonNotePrivate));
313 object_class->finalize = hildon_note_finalize;
314 object_class->set_property = hildon_note_set_property;
315 object_class->get_property = hildon_note_get_property;
316 widget_class->button_release_event = hildon_note_button_release;
317 widget_class->map = hildon_note_map;
318 widget_class->unmap = hildon_note_unmap;
319 widget_class->realize = hildon_note_realize;
321 g_object_class_install_property (object_class,
322 PROP_HILDON_NOTE_TYPE,
323 g_param_spec_enum ("note-type",
325 "The type of the note dialog",
326 hildon_note_type_get_type (),
327 HILDON_NOTE_TYPE_CONFIRMATION,
328 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
331 * HildonNote:description:
333 * Description for the note.
335 g_object_class_install_property (object_class,
336 PROP_HILDON_NOTE_DESCRIPTION,
337 g_param_spec_string ("description",
339 "The text that appears in the note dialog",
348 g_object_class_install_property (object_class,
349 PROP_HILDON_NOTE_ICON,
350 g_param_spec_string ("icon",
352 "The name of the icon that appears in the note dialog",
357 * HildonNote:stock-icon:
359 * Stock icon name for the note.
361 g_object_class_install_property (object_class,
362 PROP_HILDON_NOTE_STOCK_ICON,
363 g_param_spec_string ("stock-icon",
365 "The stock name of the icon that appears in the note dialog",
370 * HildonNote:progressbar:
372 * Progressbar for the note (if any).
374 g_object_class_install_property (object_class,
375 PROP_HILDON_NOTE_PROGRESSBAR,
376 g_param_spec_object ("progressbar",
377 "Progressbar widget",
378 "The progressbar that appears in the note dialog",
379 GTK_TYPE_PROGRESS_BAR,
384 hildon_note_init (HildonNote *dialog)
386 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (dialog);
389 priv->label = gtk_label_new (NULL);
390 gtk_label_set_line_wrap (GTK_LABEL (priv->label), TRUE);
392 priv->icon = gtk_image_new ();
393 priv->close_if_pressed_outside = FALSE;
394 priv->transfer_window = NULL;
396 /* Acquire real references to our internal children, since
397 they are not nessecarily packed into container in each
399 g_object_ref_sink (priv->label);
400 g_object_ref_sink (priv->icon);
402 gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
403 gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
408 hildon_note_finalize (GObject *obj_self)
410 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (obj_self);
413 /* FIXME Some of this stuff should be moved to dispose */
415 /* Free internal data */
417 g_object_unref (priv->label);
420 g_object_unref (priv->icon);
422 if (priv->progressbar)
423 g_object_unref (priv->progressbar);
425 if (priv->original_description)
426 g_free (priv->original_description);
428 G_OBJECT_CLASS (parent_class)->finalize (obj_self);
433 hildon_note_button_release (GtkWidget *widget,
434 GdkEventButton *event)
437 gboolean released_outside;
438 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (widget);
440 gdk_window_get_position (widget->window, &x, &y);
442 /* Whether the button has been released outside the widget */
443 released_outside = (event->x_root < x || event->x_root > x + widget->allocation.width ||
444 event->y_root < y || event->y_root > y + widget->allocation.height);
446 if (released_outside && priv->close_if_pressed_outside) {
447 gtk_dialog_response (GTK_DIALOG (widget), GTK_RESPONSE_CANCEL);
450 if (GTK_WIDGET_CLASS (parent_class)->button_release_event) {
451 return GTK_WIDGET_CLASS (parent_class)->button_release_event (widget, event);
458 hildon_note_map (GtkWidget *widget)
460 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (widget);
464 GTK_WIDGET_CLASS (parent_class)->map (widget);
466 if (priv->transfer_window == NULL && priv->close_if_pressed_outside) {
467 gboolean has_grab = FALSE;
469 priv->transfer_window = grab_transfer_window_get (widget);
471 if (gdk_pointer_grab (priv->transfer_window, TRUE,
472 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
473 GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK |
474 GDK_POINTER_MOTION_MASK, NULL, NULL,
475 GDK_CURRENT_TIME) == GDK_GRAB_SUCCESS) {
476 if (gdk_keyboard_grab (priv->transfer_window, TRUE,
477 GDK_CURRENT_TIME) == GDK_GRAB_SUCCESS) {
480 gdk_display_pointer_ungrab (gtk_widget_get_display (widget),
486 gtk_grab_add (widget);
488 gdk_window_destroy (priv->transfer_window);
489 priv->transfer_window = NULL;
495 hildon_note_unmap (GtkWidget *widget)
497 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (widget);
500 if (priv->transfer_window != NULL) {
501 /* Remove the grab */
502 gdk_display_pointer_ungrab (gtk_widget_get_display (widget),
504 gtk_grab_remove (widget);
506 /* Destroy the transfer window */
507 gdk_window_destroy (priv->transfer_window);
508 priv->transfer_window = NULL;
513 hildon_note_realize (GtkWidget *widget)
517 const gchar *notification_type;
518 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (widget);
521 /* Make widget->window accessible */
522 GTK_WIDGET_CLASS (parent_class)->realize (widget);
524 /* Border only, no titlebar */
525 gdk_window_set_decorations (widget->window, GDK_DECOR_BORDER);
527 /* Because ESD is synchronous, we wish to play sound after the
528 note is already on screen to avoid blocking its appearance */
529 if (priv->sound_signal_handler == 0)
530 priv->sound_signal_handler = g_signal_connect_after(widget,
531 "expose-event", G_CALLBACK (sound_handling), NULL);
533 /* We use special hint to turn the note into information notification. */
534 gdk_window_set_type_hint (widget->window, GDK_WINDOW_TYPE_HINT_NOTIFICATION);
536 /* Set the _HILDON_NOTIFICATION_TYPE property so Matchbox places the window correctly */
537 display = gdk_drawable_get_display (widget->window);
538 atom = gdk_x11_get_xatom_by_name_for_display (display, "_HILDON_NOTIFICATION_TYPE");
540 if (priv->note_n == HILDON_NOTE_TYPE_INFORMATION ||
541 priv->note_n == HILDON_NOTE_TYPE_INFORMATION_THEME) {
542 notification_type = "_HILDON_NOTIFICATION_TYPE_INFO";
544 notification_type = "_HILDON_NOTIFICATION_TYPE_CONFIRMATION";
547 XChangeProperty (GDK_WINDOW_XDISPLAY (widget->window), GDK_WINDOW_XID (widget->window),
548 atom, XA_STRING, 8, PropModeReplace, (guchar *) notification_type,
549 strlen (notification_type));
552 /* Helper function for removing a widget from it's container.
553 we own a separate reference to each object we try to unpack,
554 so extra referencing is not needed. */
556 unpack_widget (GtkWidget *widget)
558 g_assert (widget == NULL || GTK_IS_WIDGET (widget));
560 if (widget && widget->parent)
561 gtk_container_remove (GTK_CONTAINER (widget->parent), widget);
565 hildon_note_rebuild (HildonNote *note)
568 HildonNotePrivate *priv;
569 gboolean IsHorizontal = TRUE;
571 g_assert (HILDON_IS_NOTE (note));
573 priv = HILDON_NOTE_GET_PRIVATE (note);
576 dialog = GTK_DIALOG (note);
578 /* Reuse exiting content widgets for new layout */
579 unpack_widget (priv->label);
580 unpack_widget (priv->icon);
581 unpack_widget (priv->progressbar);
583 /* Destroy old layout and buttons */
585 gtk_widget_destroy (priv->box);
588 if (priv->okButton) {
589 gtk_widget_destroy (priv->okButton);
590 priv->okButton = NULL;
592 if (priv->cancelButton) {
593 gtk_widget_destroy (priv->cancelButton);
594 priv->cancelButton = NULL;
597 /* By default the note won't be closed when pressing outside */
598 priv->close_if_pressed_outside = FALSE;
600 /* Add needed buttons and images for each note type */
601 switch (priv->note_n)
603 case HILDON_NOTE_TYPE_CONFIRMATION:
604 priv->okButton = gtk_dialog_add_button (dialog,
605 _("ecdg_bd_confirmation_note_ok"), GTK_RESPONSE_OK);
606 priv->cancelButton = gtk_dialog_add_button (dialog,
607 _("ecdg_bd_confirmation_note_cancel"), GTK_RESPONSE_CANCEL);
610 case HILDON_NOTE_TYPE_CONFIRMATION_BUTTON:
611 gtk_image_set_from_icon_name (GTK_IMAGE (priv->icon),
612 HILDON_NOTE_CONFIRMATION_ICON,
613 HILDON_ICON_SIZE_BIG_NOTE);
616 case HILDON_NOTE_TYPE_INFORMATION_THEME:
617 case HILDON_NOTE_TYPE_INFORMATION:
618 priv->close_if_pressed_outside = TRUE;
619 gtk_image_set_from_icon_name (GTK_IMAGE (priv->icon),
620 HILDON_NOTE_INFORMATION_ICON,
621 HILDON_ICON_SIZE_BIG_NOTE);
624 case HILDON_NOTE_TYPE_PROGRESSBAR:
625 priv->cancelButton = gtk_dialog_add_button (dialog,
626 _("ecdg_bd_cancel_note_cancel"), GTK_RESPONSE_CANCEL);
627 IsHorizontal = FALSE;
635 /* Pack item with label horizontally */
636 priv->box = gtk_hbox_new (FALSE, HILDON_MARGIN_DEFAULT);
637 gtk_container_add (GTK_CONTAINER (dialog->vbox), priv->box);
640 GtkWidget *alignment = gtk_alignment_new (0, 0, 0, 0);
642 gtk_box_pack_start (GTK_BOX (priv->box), alignment, FALSE, FALSE, 0);
643 gtk_container_add (GTK_CONTAINER (alignment), priv->icon);
645 gtk_box_pack_start (GTK_BOX (priv->box), priv->label, TRUE, TRUE, 0);
648 /* Pack item with label vertically */
649 priv->box = gtk_vbox_new (FALSE, HILDON_MARGIN_DOUBLE);
650 gtk_container_add (GTK_CONTAINER (dialog->vbox), priv->box);
651 gtk_box_pack_start (GTK_BOX (priv->box), priv->label, TRUE, TRUE, 0);
653 if (priv->progressbar)
654 gtk_box_pack_start (GTK_BOX (priv->box), priv->progressbar, FALSE, FALSE, 0);
657 gtk_widget_show_all (priv->box);
661 * hildon_note_new_confirmation_add_buttons:
662 * @parent: the parent window. The X window ID of the parent window
663 * has to be the same as the X window ID of the application. This is
664 * important so that the window manager could handle the windows
666 * In GTK the X window ID can be checked using
667 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
668 * @description: the message to confirm
669 * @Varargs: arguments pairs for new buttons(label and return value).
670 * Terminate the list with %NULL value.
672 * Create a new confirmation note with custom buttons. Confirmation
673 * note has a text and any number of buttons. It's important to note
674 * that even though the name of the function might suggest, the
675 * default ok/cancel buttons are not appended but you have to provide
676 * all of the buttons.
678 * FIXME: This doc seems to be wrong, the two buttons aren't added so
679 * it would only contain the "additional" buttons? However, changing
680 * this would break those applications that rely on current behaviour.
682 * Returns: A #GtkWidget pointer of the note
685 hildon_note_new_confirmation_add_buttons (GtkWindow *parent,
686 const gchar *description,
693 g_return_val_if_fail (description != NULL, NULL);
695 GtkWidget *conf_note =
696 g_object_new (HILDON_TYPE_NOTE,
697 "note-type", HILDON_NOTE_TYPE_CONFIRMATION_BUTTON,
698 "description", description,
699 "icon", HILDON_NOTE_CONFIRMATION_ICON,
703 gtk_window_set_transient_for (GTK_WINDOW (conf_note), parent);
705 /* Add the buttons from varargs */
706 va_start(args, description);
709 message = va_arg (args, char *);
714 value = va_arg (args, int);
716 gtk_dialog_add_button (GTK_DIALOG (conf_note), message, value);
726 * hildon_note_new_confirmation:
727 * @parent: the parent window. The X window ID of the parent window
728 * has to be the same as the X window ID of the application. This is
729 * important so that the window manager could handle the windows
730 * correctly. In GTK the X window ID can be checked using
731 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
732 * @description: the message to confirm
734 * Create a new confirmation note. Confirmation note has text (description)
735 * that you specify, two buttons and a default confirmation stock icon.
737 * Returns: a #GtkWidget pointer of the note
740 hildon_note_new_confirmation (GtkWindow *parent,
741 const gchar *description)
743 return hildon_note_new_confirmation_with_icon_name
744 (parent, description, HILDON_NOTE_CONFIRMATION_ICON);
748 * hildon_note_new_confirmation_with_icon_name:
749 * @parent: the parent window. The X window ID of the parent window
750 * has to be the same as the X window ID of the application. This is
751 * important so that the window manager could handle the windows
752 * correctly. In GTK the X window ID can be checked using
753 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
754 * @description: the message to confirm
755 * @icon_name: icon to be displayed. If NULL, default icon is used.
757 * Create a new confirmation note. Confirmation note has text(description)
758 * that you specify, two buttons and an icon.
760 * Returns: a #GtkWidget pointer of the note
763 hildon_note_new_confirmation_with_icon_name (GtkWindow *parent,
764 const gchar *description,
765 const gchar *icon_name)
767 GtkWidget *dialog = NULL;
769 g_return_val_if_fail (description != NULL, NULL);
771 dialog = g_object_new (HILDON_TYPE_NOTE,
773 HILDON_NOTE_TYPE_CONFIRMATION,
774 "description", description, "icon",
778 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
784 * hildon_note_new_information:
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
792 * Create a new information note. Information note has a text(description)
793 * that you specify, an OK button and an icon.
795 * Returns: a #GtkWidget pointer of the note
798 hildon_note_new_information (GtkWindow *parent,
799 const gchar *description)
801 return hildon_note_new_information_with_icon_name
802 (parent, description, HILDON_NOTE_INFORMATION_ICON);
806 * hildon_note_new_information_with_icon_name:
807 * @parent: the parent window. The X window ID of the parent window
808 * has to be the same as the X window ID of the application. This is
809 * important so that the window manager could handle the windows
810 * correctly. In GTK the X window ID can be checked using
811 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
812 * @description: the message to confirm
813 * @icon_name: icon to be displayed. If NULL, default icon is used.
815 * Create a new information note. Information note has text(description)
816 * that you specify, an OK button and an icon.
818 * Returns: a #GtkWidget pointer of the note
821 hildon_note_new_information_with_icon_name (GtkWindow * parent,
822 const gchar *description,
823 const gchar *icon_name)
825 GtkWidget *dialog = NULL;
827 g_return_val_if_fail (description != NULL, NULL);
828 g_return_val_if_fail (icon_name != NULL, NULL);
830 dialog = g_object_new (HILDON_TYPE_NOTE,
832 HILDON_NOTE_TYPE_INFORMATION_THEME,
833 "description", description,
834 "icon", icon_name, NULL);
837 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
842 /* FIXME This documentation string LIES! */
845 * hildon_note_new_cancel_with_progress_bar:
846 * @parent: the parent window. The X window ID of the parent window
847 * has to be the same as the X window ID of the application. This is
848 * important so that the window manager could handle the windows
849 * correctly. In GTK the X window ID can be checked using
850 * GDK_WINDOW_XID(GTK_WIDGET(parent)->window).
851 * @description: the action to cancel
852 * @progressbar: a pointer to #GtkProgressBar to be filled with the
853 * progressbar assigned to this note. Use this to set the fraction of
854 * progressbar done. This parameter can be %NULL as well, in which
855 * case plain text cancel note appears.
857 * Create a new cancel note with a progress bar. Cancel note has
858 * text(description) that you specify, a Cancel button and a progress bar.
860 * Returns: a #GtkDialog. Use this to get rid of this note when you
864 hildon_note_new_cancel_with_progress_bar (GtkWindow *parent,
865 const gchar *description,
866 GtkProgressBar *progressbar)
868 GtkWidget *dialog = NULL;
870 g_return_val_if_fail (description != NULL, NULL);
872 dialog = g_object_new (HILDON_TYPE_NOTE,
874 HILDON_NOTE_TYPE_PROGRESSBAR,
875 "description", description,
880 gtk_window_set_transient_for (GTK_WINDOW (dialog), parent);
887 * hildon_note_set_button_text:
888 * @note: a #HildonNote
889 * @text: sets the button text and if there is two buttons in dialog,
890 * the button texts will be <text>, "Cancel".
892 * Sets the button text to be used by the hildon_note widget.
895 hildon_note_set_button_text (HildonNote *note,
898 HildonNotePrivate *priv;
900 g_return_if_fail (HILDON_IS_NOTE (note));
902 priv = HILDON_NOTE_GET_PRIVATE (HILDON_NOTE (note));
905 if (priv->okButton) {
906 gtk_button_set_label (GTK_BUTTON (priv->okButton), text);
907 gtk_button_set_label (GTK_BUTTON (priv->cancelButton),
908 _("ecdg_bd_confirmation_note_cancel"));
910 gtk_button_set_label (GTK_BUTTON (priv->cancelButton), text);
915 * hildon_note_set_button_texts:
916 * @note: a #HildonNote
917 * @text_ok: the new text of the default OK button
918 * @text_cancel: the new text of the default cancel button
920 * Sets the button texts to be used by this hildon_note widget.
923 hildon_note_set_button_texts (HildonNote *note,
924 const gchar *text_ok,
925 const gchar *text_cancel)
927 HildonNotePrivate *priv;
929 g_return_if_fail (HILDON_IS_NOTE (note));
931 priv = HILDON_NOTE_GET_PRIVATE (HILDON_NOTE (note));
934 if (priv->okButton) {
935 gtk_button_set_label (GTK_BUTTON (priv->okButton), text_ok);
936 gtk_button_set_label (GTK_BUTTON (priv->cancelButton), text_cancel);
938 gtk_button_set_label (GTK_BUTTON (priv->cancelButton), text_cancel);
942 /* We play a system sound when the note comes visible */
944 sound_handling (GtkWidget *widget,
945 GdkEventExpose *event,
948 HildonNotePrivate *priv = HILDON_NOTE_GET_PRIVATE (widget);
951 g_signal_handler_disconnect (widget, priv->sound_signal_handler);
953 priv->sound_signal_handler = 0;
955 switch (priv->note_n)
957 case HILDON_NOTE_TYPE_INFORMATION:
958 case HILDON_NOTE_TYPE_INFORMATION_THEME:
959 hildon_play_system_sound (INFORMATION_SOUND_PATH);
962 case HILDON_NOTE_TYPE_CONFIRMATION:
963 case HILDON_NOTE_TYPE_CONFIRMATION_BUTTON:
964 hildon_play_system_sound (CONFIRMATION_SOUND_PATH);