Commit a356df0d authored by Ramiro Estrugo's avatar Ramiro Estrugo
Browse files

Moved widgets and preferences test to nautilus/test.

* libnautilus-extensions/test-nautilus-preferences.c:
* libnautilus-extensions/test-nautilus-widgets.c:
* libnautilus-extensions/test-preferences.c:
Moved widgets and preferences test to nautilus/test.

* test/.cvsignore:
* test/Makefile.am:
* test/test-nautilus-preferences.c: (main),
(test_preferences_item), (test_preferences_group),
(create_enum_item), (register_global_preferences):
* test/test-nautilus-widgets.c: (main), (test_radio_group),
(test_caption_table), (test_string_picker), (test_text_caption),
(test_authenticate_boink_callback),
(string_picker_changed_callback), (text_caption_changed_callback),
(test_password_dialog), (test_radio_changed_callback),
(test_caption_table_activate_callback):
Ressurect my widgets/preferences test over here.  They got whacked
in the nautilus-widgets -> libnautilus-extensions renamings.
parent 5ed6ea8a
2000-07-05 Ramiro Estrugo <ramiro@eazel.com>
* libnautilus-extensions/test-nautilus-preferences.c:
* libnautilus-extensions/test-nautilus-widgets.c:
* libnautilus-extensions/test-preferences.c:
Moved widgets and preferences test to nautilus/test.
* test/.cvsignore:
* test/Makefile.am:
* test/test-nautilus-preferences.c: (main),
(test_preferences_item), (test_preferences_group),
(create_enum_item), (register_global_preferences):
* test/test-nautilus-widgets.c: (main), (test_radio_group),
(test_caption_table), (test_string_picker), (test_text_caption),
(test_authenticate_boink_callback),
(string_picker_changed_callback), (text_caption_changed_callback),
(test_password_dialog), (test_radio_changed_callback),
(test_caption_table_activate_callback):
Ressurect my widgets/preferences test over here. They got whacked
in the nautilus-widgets -> libnautilus-extensions renamings.
2000-07-05 Ramiro Estrugo <ramiro@eazel.com>
* libnautilus-extensions/nautilus-directory.c:
......
#include <config.h>
#include "nautilus-caption-table.h"
#include "nautilus-password-dialog.h"
#include "nautilus-radio-button-group.h"
#include "nautilus-string-picker.h"
#include "nautilus-text-caption.h"
#include <gtk/gtk.h>
static void test_radio_group (void);
static void test_caption_table (void);
static void test_password_dialog (void);
static void test_string_picker (void);
static void test_text_caption (void);
/* Callbacks */
static void test_radio_changed_callback (GtkWidget *button_group,
gpointer user_data);
static void test_authenticate_boink_callback (GtkWidget *button,
gpointer user_data);
static void string_picker_changed_callback (GtkWidget *string_picker,
gpointer user_data);
static void text_caption_changed_callback (GtkWidget *text_caption,
gpointer user_data);
static void test_caption_table_activate_callback (GtkWidget *button_group,
gint active_index,
gpointer user_data);
int
main (int argc, char * argv[])
{
gnome_init ("foo", "bar", argc, argv);
test_radio_group ();
test_caption_table ();
test_password_dialog ();
test_string_picker ();
test_text_caption ();
gtk_main ();
return 0;
}
static void
test_radio_group (void)
{
GtkWidget * window;
GtkWidget * buttons;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
buttons = nautilus_radio_button_group_new ();
nautilus_radio_button_group_insert (NAUTILUS_RADIO_BUTTON_GROUP (buttons), "Apples");
nautilus_radio_button_group_insert (NAUTILUS_RADIO_BUTTON_GROUP (buttons), "Oranges");
nautilus_radio_button_group_insert (NAUTILUS_RADIO_BUTTON_GROUP (buttons), "Strawberries");
gtk_signal_connect (GTK_OBJECT (buttons),
"changed",
GTK_SIGNAL_FUNC (test_radio_changed_callback),
(gpointer) NULL);
gtk_container_add (GTK_CONTAINER (window), buttons);
gtk_widget_show (buttons);
gtk_widget_show (window);
}
static void
test_caption_table (void)
{
GtkWidget * window;
GtkWidget * table;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
table = nautilus_caption_table_new (4);
nautilus_caption_table_set_row_info (NAUTILUS_CAPTION_TABLE (table),
0,
"Something",
"Text",
TRUE,
FALSE);
nautilus_caption_table_set_row_info (NAUTILUS_CAPTION_TABLE (table),
1,
"ReadOnly",
"Cant Change Me",
TRUE,
TRUE);
nautilus_caption_table_set_row_info (NAUTILUS_CAPTION_TABLE (table),
2,
"Password",
"sekret",
FALSE,
FALSE);
nautilus_caption_table_set_row_info (NAUTILUS_CAPTION_TABLE (table),
3,
"This is a very long label",
"Text",
TRUE,
FALSE);
gtk_signal_connect (GTK_OBJECT (table),
"activate",
GTK_SIGNAL_FUNC (test_caption_table_activate_callback),
(gpointer) NULL);
gtk_container_add (GTK_CONTAINER (window), table);
gtk_widget_show (table);
gtk_widget_show (window);
}
static void
test_string_picker (void)
{
GtkWidget *window;
GtkWidget *picker;
NautilusStringList *font_list;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
picker = nautilus_string_picker_new ();
nautilus_caption_set_title_label (NAUTILUS_CAPTION (picker), "Icon Font Family:");
font_list = nautilus_string_list_new ();
nautilus_string_list_insert (font_list, "Helvetica");
nautilus_string_list_insert (font_list, "Times");
nautilus_string_list_insert (font_list, "Courier");
nautilus_string_list_insert (font_list, "Lucida");
nautilus_string_list_insert (font_list, "Fixed");
nautilus_string_picker_set_string_list (NAUTILUS_STRING_PICKER (picker), font_list);
nautilus_string_list_free (font_list);
gtk_container_add (GTK_CONTAINER (window), picker);
gtk_signal_connect (GTK_OBJECT (picker),
"changed",
GTK_SIGNAL_FUNC (string_picker_changed_callback),
(gpointer) NULL);
gtk_widget_show_all (window);
}
static void
test_text_caption (void)
{
GtkWidget *window;
GtkWidget *picker;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
picker = nautilus_text_caption_new ();
nautilus_caption_set_title_label (NAUTILUS_CAPTION (picker), "Home Page:");
nautilus_text_caption_set_text (NAUTILUS_TEXT_CAPTION (picker), "file:///tmp");
gtk_container_add (GTK_CONTAINER (window), picker);
gtk_signal_connect (GTK_OBJECT (picker),
"changed",
GTK_SIGNAL_FUNC (text_caption_changed_callback),
(gpointer) NULL);
gtk_widget_show_all (window);
}
static void
test_authenticate_boink_callback (GtkWidget *button, gpointer user_data)
{
GtkWidget *dialog;
gboolean rv;
char *username;
char *password;
dialog = nautilus_password_dialog_new ("Authenticate Me",
"foouser",
"sekret",
FALSE);
rv = nautilus_password_dialog_run_and_block (NAUTILUS_PASSWORD_DIALOG (dialog));
username = nautilus_password_dialog_get_username (NAUTILUS_PASSWORD_DIALOG (dialog));
password = nautilus_password_dialog_get_password (NAUTILUS_PASSWORD_DIALOG (dialog));
g_assert (username != NULL);
g_assert (password != NULL);
g_print ("test_authenticate_boink_callback (rv=%d , username='%s' , password='%s')\n",
rv,
username,
password);
g_free (username);
g_free (password);
}
static void
string_picker_changed_callback (GtkWidget *string_picker, gpointer user_data)
{
char *text;
g_assert (string_picker != NULL);
g_assert (NAUTILUS_IS_STRING_PICKER (string_picker));
text = nautilus_string_picker_get_text (NAUTILUS_STRING_PICKER (string_picker));
g_print ("string_picker_changed_callback(%s)\n", text);
g_free (text);
}
static void
text_caption_changed_callback (GtkWidget *text_caption, gpointer user_data)
{
char *text;
g_assert (text_caption != NULL);
g_assert (NAUTILUS_IS_TEXT_CAPTION (text_caption));
text = nautilus_text_caption_get_text (NAUTILUS_TEXT_CAPTION (text_caption));
g_print ("text_caption_changed_callback(%s)\n", text);
g_free (text);
}
static void
test_password_dialog (void)
{
GtkWidget * window;
GtkWidget * button;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
button = gtk_button_new_with_label ("Boink me to authenticate");
gtk_signal_connect (GTK_OBJECT (button),
"clicked",
GTK_SIGNAL_FUNC (test_authenticate_boink_callback),
(gpointer) NULL);
gtk_container_add (GTK_CONTAINER (window), button);
gtk_widget_show (button);
gtk_widget_show (window);
}
static void
test_radio_changed_callback (GtkWidget *buttons, gpointer user_data)
{
gint i;
i = nautilus_radio_button_group_get_active_index (NAUTILUS_RADIO_BUTTON_GROUP (buttons));
g_print ("test_radio_changed_callback (%d)\n", i);
}
static void
test_caption_table_activate_callback (GtkWidget *button_group,
gint active_index,
gpointer user_data)
{
g_print ("test_caption_table_activate_callback (active_index=%d)\n", active_index);
}
#include <config.h>
#include "nautilus-radio-button-group.h"
#include "nautilus-preferences-group.h"
#include "nautilus-preferences-item.h"
#include "nautilus-preferences.h"
#include <gtk/gtk.h>
#include <stdio.h>
static void test_radio_group (void);
static void test_preferences_group (void);
static void test_preferences_item (void);
static void test_radio_changed_signal (GtkWidget *button_group, gpointer user_data);
static GtkObject *
create_dummy_prefs (void);
GtkWidget *
create_enum_item (void);
GtkWidget *
create_bool_item (void);
static GtkObject * dummy_prefs = NULL;
int
main (int argc, char * argv[])
{
gtk_init (&argc, &argv);
dummy_prefs = create_dummy_prefs ();
test_preferences_group ();
test_preferences_item ();
gtk_main ();
return 0;
}
static void
test_radio_group (void)
{
GtkWidget * window;
GtkWidget * buttons;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
buttons = nautilus_radio_button_group_new ();
nautilus_radio_button_group_insert (NAUTILUS_RADIO_BUTTON_GROUP (buttons), "Apples");
nautilus_radio_button_group_insert (NAUTILUS_RADIO_BUTTON_GROUP (buttons), "Oranges");
nautilus_radio_button_group_insert (NAUTILUS_RADIO_BUTTON_GROUP (buttons), "Strawberries");
gtk_signal_connect (GTK_OBJECT (buttons),
"changed",
GTK_SIGNAL_FUNC (test_radio_changed_signal),
(gpointer) NULL);
gtk_container_add (GTK_CONTAINER (window), buttons);
gtk_widget_show (buttons);
gtk_widget_show (window);
}
static void
test_preferences_item (void)
{
GtkWidget * window;
GtkWidget * item;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
item = create_enum_item ();
gtk_container_add (GTK_CONTAINER (window), item);
gtk_widget_show (item);
gtk_widget_show (window);
}
static void
test_preferences_group (void)
{
GtkWidget * window;
GtkWidget * group;
GtkWidget * item;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
group = nautilus_preferences_group_new ("A group");
item = create_enum_item ();
nautilus_preferences_group_add (NAUTILUS_PREFERENCES_GROUP (group),
item);
gtk_widget_show (item);
gtk_container_add (GTK_CONTAINER (window), group);
gtk_widget_show (group);
gtk_widget_show (window);
}
static void
test_radio_changed_signal (GtkWidget *buttons, gpointer user_data)
{
gint i;
i = nautilus_radio_button_group_get_active_index (NAUTILUS_RADIO_BUTTON_GROUP (buttons));
printf ("test_radio_changed_signal (%d)\n", i);
}
GtkWidget *
create_enum_item (void)
{
GtkWidget * item;
item = nautilus_preferences_item_new (dummy_prefs,
"user_level",
NAUTILUS_PREFERENCES_ITEM_ENUM);
return item;
}
GtkWidget *
create_bool_item (void)
{
GtkWidget * item;
item = nautilus_preferences_item_new (dummy_prefs,
"foo",
NAUTILUS_PREFERENCES_ITEM_BOOL);
return item;
}
static const gchar * prefs_global_user_level_names[] =
{
"novice",
"intermediate",
"hacker",
"ettore"
};
static const gchar * prefs_global_user_level_descriptions[] =
{
"Novice",
"Intermediate",
"Hacker",
"Ettore"
};
static const gint prefs_global_user_level_values[] =
{
0,
1,
2,
3
};
static NautilusPrefEnumData prefs_global_user_level_data =
{
prefs_global_user_level_names,
prefs_global_user_level_descriptions,
prefs_global_user_level_values,
4
};
static NautilusPrefInfo prefs_global_static_pref_info[] =
{
{
"user_level",
"User Level",
GTK_TYPE_ENUM,
FALSE,
&prefs_global_user_level_data
},
{
"foo",
"Create new window for each new page",
GTK_TYPE_BOOL,
FALSE,
NULL
},
{
"bar",
"Do not open more than one window with the same page",
GTK_TYPE_BOOL,
FALSE,
NULL
},
};
static GtkObject *
create_dummy_prefs (void)
{
GtkObject * dummy_prefs;
guint i;
dummy_prefs = nautilus_preferences_new ("dummy");
/* Register the static prefs */
for (i = 0; i < 3; i++)
{
nautilus_preferences_register_from_info (NAUTILUS_PREFS (dummy_prefs),
&prefs_global_static_pref_info[i]);
}
nautilus_preferences_set_enum (NAUTILUS_PREFS (dummy_prefs),
"user_level",
2);
return dummy_prefs;
}
#include <config.h>
#include "nautilus-radio-button-group.h"
#include "nautilus-caption-table.h"
#include "nautilus-password-dialog.h"
#include "nautilus-preferences-group.h"
#include "nautilus-preferences-item.h"
#include "nautilus-preferences.h"
#include <gtk/gtk.h>
static void test_preferences_group (void);
static void test_preferences_item (void);
static void register_global_preferences (void);
GtkWidget * create_enum_item (const char *preference_name);
GtkWidget * create_bool_item (const char *preference_name);
enum
{
FRUIT_APPLE,
FRUIT_ORANGE,
FRUIT_BANNANA
};
static const char FRUIT_PREFERENCE[] = "/a/very/fruity/path";
int
main (int argc, char * argv[])
{
gnome_init ("foo", "bar", argc, argv);
register_global_preferences ();
test_preferences_group ();
test_preferences_item ();
gtk_main ();
return 0;
}
static void
test_preferences_item (void)
{
GtkWidget * window;
GtkWidget * item;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
item = create_enum_item (FRUIT_PREFERENCE);
gtk_container_add (GTK_CONTAINER (window), item);
gtk_widget_show (item);
gtk_widget_show (window);
}
static void
test_preferences_group (void)
{
GtkWidget * window;
GtkWidget * group;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
group = nautilus_preferences_group_new ("A group");
nautilus_preferences_group_add_item (NAUTILUS_PREFERENCES_GROUP (group),
FRUIT_PREFERENCE,
NAUTILUS_PREFERENCE_ITEM_ENUM);
gtk_container_add (GTK_CONTAINER (window), group);
gtk_widget_show (group);