END_TEST

/**
 * Purpose: Check that note dialog is properly created with description invalid values.
 * Cases considered:
 *    - Create new confirmation note with window set to NULL.
 *    - Create new confirmation note with description set to "NULL".
 *
 */
START_TEST (test_new_confirmation_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 confirmation note with window set to "NULL" */
    invalid_note = HILDON_NOTE(hildon_note_new_confirmation(NULL,""));
    fail_if(!HILDON_IS_NOTE(invalid_note),
            "hildon-note: Creation failed with hildon_note_new_confirmation");

    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_CONFIRMATION,
             "hildon-note: Type was not set property on creation (HILDON_NOTE_TYPE_CONFIRMATION)",note_type);

    gtk_widget_destroy (GTK_WIDGET (invalid_note));
    invalid_note=NULL;

    /* Test 2: create new confirmation note with description set to "NULL" */
    invalid_note = HILDON_NOTE(hildon_note_new_confirmation(n_window,NULL));
    fail_if(HILDON_IS_NOTE(invalid_note),
            "hildon-note: Creation succeeded with hildon_note_new_confirmation with NULL description");

    g_value_unset(&value);
    g_value_unset(&enum_value);
}
static gboolean
on_confirmation_clicked                         (GtkWidget *widget, gpointer data)
{
    gint i;
    GtkWidget *window = data;
    HildonNote* note = HILDON_NOTE (hildon_note_new_confirmation (NULL, 
            "Do you want to confirm?!"));

    gtk_window_set_transient_for (GTK_WINDOW(note), GTK_WINDOW(window));
    i = gtk_dialog_run (GTK_DIALOG (note));
    gtk_object_destroy (GTK_OBJECT (note));
    
    if (i == GTK_RESPONSE_OK)
        g_debug ("Button 'OK' pressed");
    else if (i == GTK_RESPONSE_DELETE_EVENT)
        g_debug ("%s: GTK_RESPONSE_DELETE_EVENT", __FUNCTION__);
    else
        g_debug ("Button 'Cancel' pressed");

    return TRUE;
}
Exemplo n.º 3
0
/**
 * main callback for control panel plugins
 */
osso_return_t execute(osso_context_t *osso, gpointer data,
					  gboolean user_activated)
{
	gint response;

	create_list_dialog (data);

	if (!user_activated)
	{
		/* load state */
	}

	do
	{
		gchar *selected;
		response = gtk_dialog_run (GTK_DIALOG (ListDialog.dialog));
		switch (response)
		{
			case RESPONSE_NEW:
			{
				edit_connection (data, NULL);
				break;
			}
			case RESPONSE_EDIT:
			{
				StrongswanConnection *conn;
				selected = get_selected ();
				conn = strongswan_connections_get_connection (ListDialog.conns,
															  selected);
				if (conn)
				{
					edit_connection (data, conn);
				}
				else
				{
					hildon_banner_show_information (NULL, NULL,
												"Select a connection first");
				}
				g_free (selected);
				break;
			}
			case RESPONSE_DELETE:
			{
				GtkWidget *confirm;
				gint retval;
				gchar *msg;
				selected = get_selected ();
				if (!selected)
				{
					hildon_banner_show_information (NULL, NULL,
												"Select a connection first");
					break;
				}
				msg = g_strdup_printf ("Delete connection?\n%s", selected);
				confirm = hildon_note_new_confirmation (data, msg);
				retval = gtk_dialog_run (GTK_DIALOG (confirm));
				if (retval == GTK_RESPONSE_OK)
				{
					strongswan_connections_remove_connection (ListDialog.conns,
															  selected);
				}
				gtk_widget_destroy (confirm);
				g_free (msg);
				g_free (selected);
				break;
			}
			default:
				break;
		}
	}
	while (response > 0);

	gtk_widget_destroy (ListDialog.dialog);
	g_object_unref (ListDialog.conns);
	return OSSO_OK;
}