gboolean on_button_press (GtkWidget *widget, GdkEventButton *event) { HildonNote *note; if (hildon_helper_event_button_is_finger (event)) note = HILDON_NOTE (hildon_note_new_information (NULL, "You clicked with finger!")); else note = HILDON_NOTE (hildon_note_new_information (NULL, "You clicked with stylus!")); gtk_dialog_run (GTK_DIALOG (note)); gtk_object_destroy (GTK_OBJECT (note)); return TRUE; }
END_TEST /** * Purpose: Check that note dialog is properly created with description invalid values. * Cases considered: * - Create new information note with window set to NULL. * - Create new information note with description set to "NULL". * */ START_TEST (test_new_information_invalid) { const gchar * ret_description = NULL; GValue value= {0, }; GValue enum_value= {0, }; HildonNoteType note_type; HildonNote * invalid_note; g_value_init (&value, G_TYPE_STRING); g_value_init (&enum_value, G_TYPE_INT); /* Test 1: create new information note with window set to "NULL" */ invalid_note = HILDON_NOTE(hildon_note_new_information(NULL,"")); fail_if(!HILDON_IS_NOTE(invalid_note), "hildon-note: Creation failed with hildon_note_new_information"); g_object_get_property(G_OBJECT (invalid_note),"description",&value); ret_description = g_value_get_string (&value); fail_if( strcmp ("",ret_description) != 0, "hildon-note: Empty description was not set properly on creation. Returned description: %s", ret_description); g_object_get_property(G_OBJECT (invalid_note),"note_type",&enum_value); note_type = g_value_get_int(&enum_value); fail_if( note_type != HILDON_NOTE_TYPE_INFORMATION_THEME, "hildon-note: Type was not set property on creation (HILDON_NOTE_TYPE_INFORMATION_THEME)",note_type); gtk_widget_destroy (GTK_WIDGET (invalid_note)); invalid_note=NULL; /* Test 2: create new information note with description set to "NULL" */ invalid_note = HILDON_NOTE(hildon_note_new_information(n_window,NULL)); fail_if(HILDON_IS_NOTE(invalid_note), "hildon-note: Creation succeeded with hildon_note_new_information where msg == NULL"); g_value_unset(&value); g_value_unset(&enum_value); }
static gboolean on_information_clicked (GtkWidget *widget, gpointer data) { GtkWidget *window = data; gint i; HildonNote* note = HILDON_NOTE (hildon_note_new_information (NULL, "This is a really really really long text that should " "get wrapped but never truncated because truncating stuff " "automatically is really really bad! Blah blah blah!")); gtk_window_set_transient_for (GTK_WINDOW(note), GTK_WINDOW(window)); i = gtk_dialog_run (GTK_DIALOG (note)); if (i == GTK_RESPONSE_DELETE_EVENT) g_debug ("%s: GTK_RESPONSE_DELETE_EVENT", __FUNCTION__); gtk_object_destroy (GTK_OBJECT (note)); return TRUE; }
void ZLGtkDialogManager::informationBox(const std::string&, const std::string &message) const { GtkDialog *dialog = GTK_DIALOG(hildon_note_new_information(myWindow, message.c_str())); gtk_dialog_run(dialog); gtk_widget_destroy(GTK_WIDGET(dialog)); }
END_TEST /* ----- Test case for new_information -----*/ /** * Purpose: Check that note dialog is properly created with description regular values. * Cases considered: * - Create new information note with description set to TEST_STRING. * - Create new information note with description set to "". * */ START_TEST (test_new_information_regular) { const gchar * description = NULL; const gchar * ret_description = NULL; GValue value= {0, }; GValue enum_value= {0, }; HildonNoteType note_type; g_value_init (&value, G_TYPE_STRING); g_value_init (&enum_value, G_TYPE_INT); /* Test 1: create new information note with description set to "Standard question?" */ description = TEST_STRING; note = HILDON_NOTE(hildon_note_new_information(n_window,description)); fail_if(!HILDON_IS_NOTE(note), "hildon-note: Creation failed with hildon_note_new_information"); g_object_get_property(G_OBJECT (note),"description",&value); ret_description = g_value_get_string (&value); fail_if( strcmp (description,ret_description) != 0, "hildon-note: Description (%s) was not set properly on creation. Returned description: %s", description,ret_description); g_object_get_property(G_OBJECT (note),"note_type",&enum_value); note_type = g_value_get_int(&enum_value); fail_if( note_type != HILDON_NOTE_TYPE_INFORMATION_THEME, "hildon-note: Type was not set property on creation (HILDON_NOTE_TYPE_INFORMATION_THEME)",note_type); gtk_widget_destroy (GTK_WIDGET (note)); note=NULL; /* Test 2: create new information note with description set to "" */ description = ""; note = HILDON_NOTE(hildon_note_new_information(n_window,description)); fail_if(!HILDON_IS_NOTE(note), "hildon-note: Creation failed with hildon_note_new_information"); g_object_get_property(G_OBJECT (note),"description",&value); ret_description = g_value_get_string (&value); fail_if( strcmp (description,ret_description) != 0, "hildon-note: Description (%s) was not set properly on creation. Returned description: %s", description,ret_description); g_object_get_property(G_OBJECT (note),"note_type",&enum_value); note_type = g_value_get_int(&enum_value); fail_if( note_type != HILDON_NOTE_TYPE_INFORMATION_THEME, "hildon-note: Type was not set property on creation (HILDON_NOTE_TYPE_INFORMATION_THEME)",note_type); gtk_widget_destroy (GTK_WIDGET (note)); note=NULL; g_value_unset(&value); g_value_unset(&enum_value); }