summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/.cvsignore3
-rw-r--r--test/Makefile.am6
-rw-r--r--test/test-nautilus-preferences-change.c230
-rw-r--r--test/test-nautilus-preferences-display.c265
-rw-r--r--test/test-nautilus-preferences.c123
-rw-r--r--test/test-nautilus-smooth-graphics.c6
-rw-r--r--test/test.c100
-rw-r--r--test/test.h92
8 files changed, 658 insertions, 167 deletions
diff --git a/test/.cvsignore b/test/.cvsignore
index 1c3ea334a..08ec2e66f 100644
--- a/test/.cvsignore
+++ b/test/.cvsignore
@@ -28,4 +28,5 @@ test-nautilus-pixbuf-tile
test-nautilus-preferences
test-nautilus-smooth-graphics
test-nautilus-widgets
-test-nautilus-wrapped-label
+test-nautilus-preferences-display
+test-nautilus-preferences-change
diff --git a/test/Makefile.am b/test/Makefile.am
index 4f4de40f0..782e1acfd 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -49,9 +49,10 @@ noinst_PROGRAMS =\
test-nautilus-mime-actions-set \
test-nautilus-password-dialog \
test-nautilus-pixbuf-tile \
- test-nautilus-preferences \
test-nautilus-smooth-graphics \
test-nautilus-widgets \
+ test-nautilus-preferences-display \
+ test-nautilus-preferences-change \
$(NULL)
test_nautilus_async_activation_SOURCES = test-nautilus-async-activation.c
@@ -75,7 +76,8 @@ test_nautilus_mime_actions_SOURCES = test-nautilus-mime-actions.c
test_nautilus_mime_actions_set_SOURCES = test-nautilus-mime-actions-set.c
test_nautilus_password_dialog_SOURCES = test-nautilus-password-dialog.c
test_nautilus_pixbuf_tile_SOURCES = test-nautilus-pixbuf-tile.c test.c
-test_nautilus_preferences_SOURCES = test-nautilus-preferences.c
+test_nautilus_preferences_change_SOURCES = test-nautilus-preferences-change.c test.c
+test_nautilus_preferences_display_SOURCES = test-nautilus-preferences-display.c test.c
test_nautilus_smooth_graphics_SOURCES = test-nautilus-smooth-graphics.c
test_nautilus_widgets_SOURCES = test-nautilus-widgets.c
diff --git a/test/test-nautilus-preferences-change.c b/test/test-nautilus-preferences-change.c
new file mode 100644
index 000000000..9b269acdd
--- /dev/null
+++ b/test/test-nautilus-preferences-change.c
@@ -0,0 +1,230 @@
+#include "test.h"
+
+#include <libnautilus-extensions/nautilus-image.h>
+#include <libnautilus-extensions/nautilus-image-with-background.h>
+#include <libnautilus-extensions/nautilus-string-picker.h>
+#include <libnautilus-extensions/nautilus-preferences.h>
+
+#include <unistd.h>
+
+static void
+user_level_changed_callback (gpointer callback_data)
+{
+ char *name;
+ int user_level;
+ int visible_user_level;
+
+ g_return_if_fail (NAUTILUS_IS_STRING_PICKER (callback_data));
+
+
+ name = nautilus_caption_get_title_label (NAUTILUS_CAPTION (callback_data));
+
+ user_level = nautilus_preferences_get_user_level ();
+ visible_user_level = nautilus_preferences_get_visible_user_level (name);
+
+ if (visible_user_level <= user_level) {
+ gtk_widget_show (GTK_WIDGET (callback_data));
+ } else {
+ gtk_widget_hide (GTK_WIDGET (callback_data));
+ }
+
+#if 0
+ g_print ("%s(data=%s) user_level = %d, visible_user_level = %d, action = %s\n",
+ __FUNCTION__,
+ name,
+ user_level,
+ visible_user_level,
+ (visible_user_level <= user_level) ? "show" : "hide");
+#endif
+
+ g_free (name);
+}
+
+static void
+fruits_changed_callback (gpointer callback_data)
+{
+ g_print ("Something underneath 'fruits' changed, dunno what\n");
+}
+
+static void
+int_picker_changed_callback (NautilusStringPicker *string_picker,
+ gpointer callback_data)
+{
+ char *selected_string;
+ int new_value;
+
+ g_return_if_fail (NAUTILUS_IS_STRING_PICKER (string_picker));
+ g_return_if_fail (callback_data != NULL);
+
+ selected_string = nautilus_string_picker_get_selected_string (string_picker);
+
+ new_value = nautilus_string_picker_get_index_for_string (string_picker, selected_string);
+
+ nautilus_preferences_set_integer ((const char *) callback_data, new_value);
+
+ g_free (selected_string);
+}
+
+static void
+user_level_picker_changed_callback (NautilusStringPicker *string_picker,
+ gpointer callback_data)
+{
+ char *selected_string;
+ int new_user_level;
+
+ g_return_if_fail (NAUTILUS_IS_STRING_PICKER (string_picker));
+ g_return_if_fail (callback_data != NULL);
+
+ selected_string = nautilus_string_picker_get_selected_string (string_picker);
+
+ new_user_level = nautilus_string_picker_get_index_for_string (string_picker, selected_string);
+
+ nautilus_preferences_set_user_level (new_user_level);
+
+ g_free (selected_string);
+}
+
+static GtkWidget *
+picker_new (const char *name,
+ const NautilusStringList *entries)
+{
+ GtkWidget *string_picker;
+
+ g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (entries != NULL, NULL);
+
+ string_picker = nautilus_string_picker_new ();
+ nautilus_caption_set_title_label (NAUTILUS_CAPTION (string_picker), name);
+ gtk_signal_connect (GTK_OBJECT (string_picker), "changed", GTK_SIGNAL_FUNC (int_picker_changed_callback),
+ (gpointer) name);
+
+ nautilus_string_picker_set_string_list (NAUTILUS_STRING_PICKER (string_picker), entries);
+ nautilus_string_picker_set_selected_string_index (NAUTILUS_STRING_PICKER (string_picker),
+ nautilus_preferences_get_integer (name));
+
+ nautilus_preferences_add_callback ("user_level", user_level_changed_callback, string_picker);
+ user_level_changed_callback (string_picker);
+
+ return string_picker;
+}
+
+static GtkWidget *
+user_level_picker_new (const char *name,
+ const NautilusStringList *entries)
+{
+ GtkWidget *string_picker;
+
+ g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (entries != NULL, NULL);
+
+ string_picker = nautilus_string_picker_new ();
+ nautilus_caption_set_title_label (NAUTILUS_CAPTION (string_picker), name);
+ gtk_signal_connect (GTK_OBJECT (string_picker), "changed", GTK_SIGNAL_FUNC (user_level_picker_changed_callback),
+ (gpointer) name);
+
+ nautilus_string_picker_set_string_list (NAUTILUS_STRING_PICKER (string_picker), entries);
+ nautilus_string_picker_set_selected_string_index (NAUTILUS_STRING_PICKER (string_picker),
+ nautilus_preferences_get_user_level ());
+
+ nautilus_preferences_add_callback ("user_level", user_level_changed_callback, string_picker);
+ user_level_changed_callback (string_picker);
+
+ return string_picker;
+}
+
+int
+main (int argc, char *argv[])
+{
+ GtkWidget *window;
+
+ GtkWidget *user_level_picker;
+ GtkWidget *green_picker;
+ GtkWidget *yellow_picker;
+ GtkWidget *red_picker;
+ GtkWidget *fruits_apple_picker;
+ GtkWidget *fruits_orange_picker;
+ GtkWidget *fruits_pear_picker;
+
+ GtkWidget *vbox;
+
+ NautilusStringList *user_level_entries;
+ NautilusStringList *color_entries;
+ NautilusStringList *fruits_entries;
+
+ test_init (&argc, &argv);
+
+ user_level_entries = nautilus_string_list_new_from_tokens ("Beginner,Intermediate,Hacker", ",", TRUE);
+ color_entries = nautilus_string_list_new_from_tokens ("0,1,2,3,4,5,6,7,8,9,10", ",", TRUE);
+ fruits_entries = nautilus_string_list_new_from_tokens ("0,1,2,3", ",", TRUE);
+
+ nautilus_preferences_default_set_string ("user_level",
+ NAUTILUS_USER_LEVEL_NOVICE,
+ "hacker");
+
+ nautilus_preferences_default_set_integer ("green",
+ NAUTILUS_USER_LEVEL_NOVICE,
+ 3);
+
+ nautilus_preferences_default_set_integer ("yellow",
+ NAUTILUS_USER_LEVEL_NOVICE,
+ 9);
+
+ nautilus_preferences_default_set_integer ("red",
+ NAUTILUS_USER_LEVEL_NOVICE,
+ 7);
+
+ nautilus_preferences_default_set_integer ("fruits/apple",
+ NAUTILUS_USER_LEVEL_NOVICE,
+ 1);
+ nautilus_preferences_default_set_integer ("fruits/orange",
+ NAUTILUS_USER_LEVEL_NOVICE,
+ 2);
+ nautilus_preferences_default_set_integer ("fruits/pear",
+ NAUTILUS_USER_LEVEL_NOVICE,
+ 3);
+
+ nautilus_preferences_set_visible_user_level ("yellow", 1);
+ nautilus_preferences_set_visible_user_level ("green", 0);
+ nautilus_preferences_set_visible_user_level ("red", 2);
+
+ //sleep (10);
+
+ window = test_window_new (NULL, 4);
+ test_window_set_title_with_pid (GTK_WINDOW (window), "Preferences Change");
+
+ vbox = gtk_vbox_new (FALSE, 2);
+ gtk_container_add (GTK_CONTAINER (window), vbox);
+
+ user_level_picker = user_level_picker_new ("user_level", user_level_entries);
+ green_picker = picker_new ("green", color_entries);
+ yellow_picker = picker_new ("yellow", color_entries);
+ red_picker = picker_new ("red", color_entries);
+ fruits_apple_picker = picker_new ("fruits/apple", fruits_entries);
+ fruits_orange_picker = picker_new ("fruits/orange", fruits_entries);
+ fruits_pear_picker = picker_new ("fruits/pear", fruits_entries);
+
+ gtk_box_pack_start (GTK_BOX (vbox), user_level_picker, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), green_picker, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), yellow_picker, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), red_picker, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), fruits_apple_picker, FALSE, FALSE, 20);
+ gtk_box_pack_start (GTK_BOX (vbox), fruits_orange_picker, FALSE, FALSE, 20);
+ gtk_box_pack_start (GTK_BOX (vbox), fruits_pear_picker, FALSE, FALSE, 20);
+
+ nautilus_string_list_free (user_level_entries);
+ nautilus_string_list_free (color_entries);
+ nautilus_string_list_free (fruits_entries);
+
+ nautilus_preferences_add_callback ("fruits", fruits_changed_callback, NULL);
+
+ gtk_widget_show (vbox);
+ gtk_widget_show (window);
+
+// user_level_changed_callback (green_picker);
+// user_level_changed_callback (yellow_picker);
+// user_level_changed_callback (red_picker);
+
+ gtk_main ();
+
+ return 0;
+}
diff --git a/test/test-nautilus-preferences-display.c b/test/test-nautilus-preferences-display.c
new file mode 100644
index 000000000..bf27cf9e4
--- /dev/null
+++ b/test/test-nautilus-preferences-display.c
@@ -0,0 +1,265 @@
+#include "test.h"
+
+#include <libnautilus-extensions/nautilus-image.h>
+#include <libnautilus-extensions/nautilus-image-with-background.h>
+#include <libnautilus-extensions/nautilus-text-caption.h>
+#include <libnautilus-extensions/nautilus-preferences.h>
+
+static void
+text_caption_update (NautilusTextCaption *text_caption,
+ const char *name)
+{
+ g_return_if_fail (NAUTILUS_IS_TEXT_CAPTION (text_caption));
+ g_return_if_fail (name != NULL);
+
+ g_print ("'%s' changed from '%d' to '%d'\n",
+ name,
+ test_text_caption_get_text_as_int (text_caption),
+ nautilus_preferences_get_integer (name));
+
+ test_text_caption_set_text_for_int_preferences (text_caption, name);
+}
+
+static void
+user_level_caption_update (NautilusTextCaption *text_caption)
+{
+ char *old_text;
+ char *new_text;
+
+ g_return_if_fail (NAUTILUS_IS_TEXT_CAPTION (text_caption));
+
+ old_text = nautilus_text_caption_get_text (text_caption);
+ new_text = nautilus_preferences_get ("user_level");
+
+ g_print ("'%s' changed from '%s' to '%s'\n",
+ "user_level",
+ old_text, new_text);
+
+ g_free (old_text);
+ g_free (new_text);
+
+ test_text_caption_set_text_for_string_preferences (text_caption, "user_level");
+}
+
+static void
+user_level_changed_callback (gpointer callback_data)
+{
+ user_level_caption_update (NAUTILUS_TEXT_CAPTION (callback_data));
+}
+
+static void
+green_changed_callback (gpointer callback_data)
+{
+ text_caption_update (NAUTILUS_TEXT_CAPTION (callback_data), "green");
+}
+
+static void
+yellow_changed_callback (gpointer callback_data)
+{
+ text_caption_update (NAUTILUS_TEXT_CAPTION (callback_data), "yellow");
+}
+
+static void
+red_changed_callback (gpointer callback_data)
+{
+ text_caption_update (NAUTILUS_TEXT_CAPTION (callback_data), "red");
+}
+
+static void
+apple_changed_callback (gpointer callback_data)
+{
+ text_caption_update (NAUTILUS_TEXT_CAPTION (callback_data), "fruits/apple");
+}
+
+static void
+orange_changed_callback (gpointer callback_data)
+{
+ text_caption_update (NAUTILUS_TEXT_CAPTION (callback_data), "fruits/orange");
+}
+
+static void
+pear_changed_callback (gpointer callback_data)
+{
+ text_caption_update (NAUTILUS_TEXT_CAPTION (callback_data), "fruits/pear");
+}
+
+static GtkWidget *
+entry_new (const char *name,
+ GtkWidget **caption_out,
+ GtkWidget **default_caption_out)
+{
+ GtkWidget *hbox;
+
+ g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (caption_out != NULL, NULL);
+ g_return_val_if_fail (default_caption_out != NULL, NULL);
+
+ hbox = gtk_hbox_new (TRUE, 2);
+
+ *caption_out = nautilus_text_caption_new ();
+ nautilus_text_caption_set_editable (NAUTILUS_TEXT_CAPTION (*caption_out), FALSE);
+ nautilus_caption_set_title_label (NAUTILUS_CAPTION (*caption_out), name);
+
+ *default_caption_out = nautilus_text_caption_new ();
+ nautilus_text_caption_set_editable (NAUTILUS_TEXT_CAPTION (*default_caption_out), FALSE);
+ nautilus_caption_set_title_label (NAUTILUS_CAPTION (*default_caption_out), "default:");
+
+ gtk_box_pack_start (GTK_BOX (hbox), *caption_out, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), *default_caption_out, FALSE, FALSE, 0);
+
+ gtk_widget_show (*caption_out);
+ gtk_widget_show (*default_caption_out);
+
+ return hbox;
+}
+
+static GtkWidget *
+user_level_frame_new (void)
+{
+ GtkWidget *user_level_caption;
+ GtkWidget *user_level_default_caption;
+ GtkWidget *user_level_hbox;
+ GtkWidget *frame;
+
+ frame = gtk_frame_new ("user_level");
+
+ user_level_hbox = entry_new ("user_level", &user_level_caption, &user_level_default_caption);
+ test_text_caption_set_text_for_string_preferences (NAUTILUS_TEXT_CAPTION (user_level_caption), "user_level");
+ test_text_caption_set_text_for_default_string_preferences (NAUTILUS_TEXT_CAPTION (user_level_default_caption), "user_level");
+ nautilus_preferences_add_callback ("user_level", user_level_changed_callback, user_level_caption);
+
+ gtk_container_add (GTK_CONTAINER (frame), user_level_hbox);
+
+ gtk_widget_show_all (frame);
+
+ return frame;
+}
+
+static GtkWidget *
+colors_frame_new (void)
+{
+ GtkWidget *green_caption;
+ GtkWidget *green_default_caption;
+ GtkWidget *green_hbox;
+
+ GtkWidget *yellow_caption;
+ GtkWidget *yellow_default_caption;
+ GtkWidget *yellow_hbox;
+
+ GtkWidget *red_caption;
+ GtkWidget *red_default_caption;
+ GtkWidget *red_hbox;
+
+ GtkWidget *frame;
+ GtkWidget *vbox;
+
+ vbox = gtk_vbox_new (FALSE, 2);
+
+ frame = gtk_frame_new ("colors");
+ gtk_container_add (GTK_CONTAINER (frame), vbox);
+
+ green_hbox = entry_new ("green", &green_caption, &green_default_caption);
+ yellow_hbox = entry_new ("yellow", &yellow_caption, &yellow_default_caption);
+ red_hbox = entry_new ("red", &red_caption, &red_default_caption);
+
+ test_text_caption_set_text_for_int_preferences (NAUTILUS_TEXT_CAPTION (green_caption), "green");
+ test_text_caption_set_text_for_int_preferences (NAUTILUS_TEXT_CAPTION (yellow_caption), "yellow");
+ test_text_caption_set_text_for_int_preferences (NAUTILUS_TEXT_CAPTION (red_caption), "red");
+
+ test_text_caption_set_text_for_default_int_preferences (NAUTILUS_TEXT_CAPTION (green_default_caption), "green");
+ test_text_caption_set_text_for_default_int_preferences (NAUTILUS_TEXT_CAPTION (yellow_default_caption), "yellow");
+ test_text_caption_set_text_for_default_int_preferences (NAUTILUS_TEXT_CAPTION (red_default_caption), "red");
+
+ nautilus_preferences_add_callback ("green", green_changed_callback, green_caption);
+ nautilus_preferences_add_callback ("yellow", yellow_changed_callback, yellow_caption);
+ nautilus_preferences_add_callback ("red", red_changed_callback, red_caption);
+
+ gtk_box_pack_start (GTK_BOX (vbox), green_hbox, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), yellow_hbox, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), red_hbox, TRUE, TRUE, 0);
+
+ gtk_widget_show_all (frame);
+
+ return frame;
+}
+
+static GtkWidget *
+fruits_frame_new (void)
+{
+ GtkWidget *apple_caption;
+ GtkWidget *apple_default_caption;
+ GtkWidget *apple_hbox;
+
+ GtkWidget *orange_caption;
+ GtkWidget *orange_default_caption;
+ GtkWidget *orange_hbox;
+
+ GtkWidget *pear_caption;
+ GtkWidget *pear_default_caption;
+ GtkWidget *pear_hbox;
+
+ GtkWidget *frame;
+ GtkWidget *vbox;
+
+ vbox = gtk_vbox_new (FALSE, 2);
+
+ frame = gtk_frame_new ("fruits");
+ gtk_container_add (GTK_CONTAINER (frame), vbox);
+
+ apple_hbox = entry_new ("fruits/apple", &apple_caption, &apple_default_caption);
+ orange_hbox = entry_new ("fruits/orange", &orange_caption, &orange_default_caption);
+ pear_hbox = entry_new ("fruits/pear", &pear_caption, &pear_default_caption);
+
+ test_text_caption_set_text_for_int_preferences (NAUTILUS_TEXT_CAPTION (apple_caption), "fruits/apple");
+ test_text_caption_set_text_for_int_preferences (NAUTILUS_TEXT_CAPTION (orange_caption), "fruits/orange");
+ test_text_caption_set_text_for_int_preferences (NAUTILUS_TEXT_CAPTION (pear_caption), "fruits/pear");
+
+ test_text_caption_set_text_for_default_int_preferences (NAUTILUS_TEXT_CAPTION (apple_default_caption), "fruits/apple");
+ test_text_caption_set_text_for_default_int_preferences (NAUTILUS_TEXT_CAPTION (orange_default_caption), "fruits/orange");
+ test_text_caption_set_text_for_default_int_preferences (NAUTILUS_TEXT_CAPTION (pear_default_caption), "fruits/pear");
+
+ nautilus_preferences_add_callback ("fruits/apple", apple_changed_callback, apple_caption);
+ nautilus_preferences_add_callback ("fruits/orange", orange_changed_callback, orange_caption);
+ nautilus_preferences_add_callback ("fruits/pear", pear_changed_callback, pear_caption);
+
+ gtk_box_pack_start (GTK_BOX (vbox), apple_hbox, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), orange_hbox, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), pear_hbox, TRUE, TRUE, 0);
+
+ gtk_widget_show_all (frame);
+
+ return frame;
+}
+
+int
+main (int argc, char *argv[])
+{
+ GtkWidget *window;
+ GtkWidget *vbox;
+
+ GtkWidget *user_level_frame;
+ GtkWidget *colors_frame;
+ GtkWidget *fruits_frame;
+
+ test_init (&argc, &argv);
+
+ window = test_window_new (NULL, 4);
+ test_window_set_title_with_pid (GTK_WINDOW (window), "Preferences Display");
+
+ vbox = gtk_vbox_new (FALSE, 2);
+ gtk_container_add (GTK_CONTAINER (window), vbox);
+
+ user_level_frame = user_level_frame_new ();
+ colors_frame = colors_frame_new ();
+ fruits_frame = fruits_frame_new ();
+
+ gtk_box_pack_start (GTK_BOX (vbox), user_level_frame, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), colors_frame, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), fruits_frame, TRUE, TRUE, 0);
+
+ gtk_widget_show_all (window);
+
+ gtk_main ();
+
+ return 0;
+}
diff --git a/test/test-nautilus-preferences.c b/test/test-nautilus-preferences.c
deleted file mode 100644
index ebafcb6d5..000000000
--- a/test/test-nautilus-preferences.c
+++ /dev/null
@@ -1,123 +0,0 @@
-#include <config.h>
-
-#include <gtk/gtk.h>
-#include <libgnome/gnome-defs.h>
-#include <libgnomeui/gnome-init.h>
-#include <libnautilus-extensions/nautilus-caption-table.h>
-#include <libnautilus-extensions/nautilus-password-dialog.h>
-#include <libnautilus-extensions/nautilus-preferences-group.h>
-#include <libnautilus-extensions/nautilus-preferences-item.h>
-#include <libnautilus-extensions/nautilus-preferences.h>
-#include <libnautilus-extensions/nautilus-radio-button-group.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);
-
- gtk_widget_show (window);
-}
-
-GtkWidget *
-create_enum_item (const char *preference_name)
-{
- return nautilus_preferences_item_new (preference_name, NAUTILUS_PREFERENCE_ITEM_ENUM);
-}
-
-// GtkWidget *
-// create_bool_item (const char *preference_name)
-// {
-// return nautilus_preferences_item_new (global_preferences,
-// preference_name,
-// NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
-// }
-
-static void
-register_global_preferences (void)
-{
- gconstpointer default_values[3] = { (gconstpointer)FRUIT_ORANGE, (gconstpointer)FRUIT_ORANGE, (gconstpointer)FRUIT_ORANGE };
-
- nautilus_preference_set_info_by_name (FRUIT_PREFERENCE,
- "Fruits",
- NAUTILUS_PREFERENCE_ENUM,
- default_values,
- 3);
-
- nautilus_preference_enum_add_entry_by_name (FRUIT_PREFERENCE,
- "apple",
- "Apple",
- FRUIT_APPLE);
-
- nautilus_preference_enum_add_entry_by_name (FRUIT_PREFERENCE,
- "orange",
- "Orange",
- FRUIT_ORANGE);
-
- nautilus_preference_enum_add_entry_by_name (FRUIT_PREFERENCE,
- "bannana",
- "Bannana",
- FRUIT_BANNANA);
-
- nautilus_preferences_set_enum (FRUIT_PREFERENCE,
- FRUIT_BANNANA);
-}
diff --git a/test/test-nautilus-smooth-graphics.c b/test/test-nautilus-smooth-graphics.c
index 30dd6c573..275b18fda 100644
--- a/test/test-nautilus-smooth-graphics.c
+++ b/test/test-nautilus-smooth-graphics.c
@@ -18,10 +18,10 @@ smooth_graphics_mode_changed_callback (gpointer callback_data)
{
gboolean is_smooth;
- is_smooth = nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, TRUE);
+ is_smooth = nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (callback_data),
- nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, TRUE));
+ nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE));
}
static void
@@ -46,7 +46,7 @@ main (int argc, char * argv[])
button = gtk_toggle_button_new_with_label ("Smooth Graphics");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
- nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE, TRUE));
+ nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_SMOOTH_GRAPHICS_MODE));
gtk_container_add (GTK_CONTAINER (window), button);
diff --git a/test/test.c b/test/test.c
index 3348695fe..8ded85ad5 100644
--- a/test/test.c
+++ b/test/test.c
@@ -1,6 +1,7 @@
#include "test.h"
#include <libart_lgpl/art_rgb.h>
+#include <libnautilus-extensions/nautilus-preferences.h>
void
test_init (int *argc,
@@ -406,3 +407,102 @@ test_pixbuf_draw_rectangle_tiled (GdkPixbuf *pixbuf,
gdk_pixbuf_unref (tile_pixbuf);
}
+
+/* Preferences hacks */
+void
+test_text_caption_set_text_for_int_preferences (NautilusTextCaption *text_caption,
+ const char *name)
+{
+ int int_value;
+ char *text;
+
+ g_return_if_fail (NAUTILUS_IS_TEXT_CAPTION (text_caption));
+ g_return_if_fail (name != NULL);
+
+ int_value = nautilus_preferences_get_integer (name);
+
+ text = g_strdup_printf ("%d", int_value);
+
+ nautilus_text_caption_set_text (NAUTILUS_TEXT_CAPTION (text_caption), text);
+
+ g_free (text);
+}
+
+void
+test_text_caption_set_text_for_string_preferences (NautilusTextCaption *text_caption,
+ const char *name)
+{
+ char *text;
+
+ g_return_if_fail (NAUTILUS_IS_TEXT_CAPTION (text_caption));
+ g_return_if_fail (name != NULL);
+
+ text = nautilus_preferences_get (name);
+
+ nautilus_text_caption_set_text (NAUTILUS_TEXT_CAPTION (text_caption), text);
+
+ g_free (text);
+}
+
+void
+test_text_caption_set_text_for_default_int_preferences (NautilusTextCaption *text_caption,
+ const char *name)
+{
+ int int_value;
+ char *text;
+
+ g_return_if_fail (NAUTILUS_IS_TEXT_CAPTION (text_caption));
+ g_return_if_fail (name != NULL);
+
+ int_value = nautilus_preferences_default_get_integer (name, nautilus_preferences_get_user_level ());
+
+ text = g_strdup_printf ("%d", int_value);
+
+ nautilus_text_caption_set_text (NAUTILUS_TEXT_CAPTION (text_caption), text);
+
+ g_free (text);
+}
+
+void
+test_text_caption_set_text_for_default_string_preferences (NautilusTextCaption *text_caption,
+ const char *name)
+{
+ char *text;
+
+ g_return_if_fail (NAUTILUS_IS_TEXT_CAPTION (text_caption));
+ g_return_if_fail (name != NULL);
+
+ text = nautilus_preferences_default_get_string (name, nautilus_preferences_get_user_level ());
+
+ nautilus_text_caption_set_text (NAUTILUS_TEXT_CAPTION (text_caption), text);
+
+ g_free (text);
+}
+
+int
+test_text_caption_get_text_as_int (const NautilusTextCaption *text_caption)
+{
+ int result = 0;
+ char *text;
+
+ g_return_val_if_fail (NAUTILUS_IS_TEXT_CAPTION (text_caption), 0);
+
+ text = nautilus_text_caption_get_text (text_caption);
+
+ nautilus_eat_str_to_int (text, &result);
+
+ return result;
+}
+
+void
+test_window_set_title_with_pid (GtkWindow *window,
+ const char *title)
+{
+ char *tmp;
+
+ g_return_if_fail (GTK_IS_WINDOW (window));
+
+ tmp = g_strdup_printf ("%d: %s", getpid (), title);
+ gtk_window_set_title (GTK_WINDOW (window), tmp);
+ g_free (tmp);
+}
diff --git a/test/test.h b/test/test.h
index 4517cbb9e..f2f123203 100644
--- a/test/test.h
+++ b/test/test.h
@@ -25,43 +25,59 @@
#include <libnautilus-extensions/nautilus-string.h>
#include <libnautilus-extensions/nautilus-file-utilities.h>
-void test_init (int *argc,
- char ***argv);
-void test_quit (int exit_code);
-void test_delete_event (GtkWidget *widget,
- GdkEvent *event,
- gpointer callback_data);
-GtkWidget *test_window_new (const char *title,
- guint border_width);
-void test_gtk_widget_set_background_image (GtkWidget *widget,
- const char *image_name);
-void test_gtk_widget_set_background_color (GtkWidget *widget,
- const char *color_spec);
-GdkPixbuf *test_pixbuf_new_named (const char *name,
- float scale);
-GtkWidget *test_image_new (const char *pixbuf_name,
- const char *tile_name,
- float scale,
- gboolean with_background);
-GtkWidget *test_label_new (const char *text,
- const char *tile_name,
- gboolean with_background,
- int num_sizes_larger);
-void test_pixbuf_draw_rectangle (GdkPixbuf *pixbuf,
- int x0,
- int y0,
- int x1,
- int y1,
- int inset,
- gboolean filled,
- guint32 color,
- int opacity);
-void test_pixbuf_draw_rectangle_tiled (GdkPixbuf *pixbuf,
- const char *tile_name,
- int x0,
- int y0,
- int x1,
- int y1,
- int opacity);
+#include <libnautilus-extensions/nautilus-text-caption.h>
+#include <libnautilus-extensions/nautilus-string-picker.h>
+
+void test_init (int *argc,
+ char ***argv);
+void test_quit (int exit_code);
+void test_delete_event (GtkWidget *widget,
+ GdkEvent *event,
+ gpointer callback_data);
+GtkWidget *test_window_new (const char *title,
+ guint border_width);
+void test_gtk_widget_set_background_image (GtkWidget *widget,
+ const char *image_name);
+void test_gtk_widget_set_background_color (GtkWidget *widget,
+ const char *color_spec);
+GdkPixbuf *test_pixbuf_new_named (const char *name,
+ float scale);
+GtkWidget *test_image_new (const char *pixbuf_name,
+ const char *tile_name,
+ float scale,
+ gboolean with_background);
+GtkWidget *test_label_new (const char *text,
+ const char *tile_name,
+ gboolean with_background,
+ int num_sizes_larger);
+void test_pixbuf_draw_rectangle (GdkPixbuf *pixbuf,
+ int x0,
+ int y0,
+ int x1,
+ int y1,
+ int inset,
+ gboolean filled,
+ guint32 color,
+ int opacity);
+void test_pixbuf_draw_rectangle_tiled (GdkPixbuf *pixbuf,
+ const char *tile_name,
+ int x0,
+ int y0,
+ int x1,
+ int y1,
+ int opacity);
+void test_window_set_title_with_pid (GtkWindow *window,
+ const char *title);
+int test_text_caption_get_text_as_int (const NautilusTextCaption *text_caption);
+
+/* Preferences hacks */
+void test_text_caption_set_text_for_int_preferences (NautilusTextCaption *text_caption,
+ const char *name);
+void test_text_caption_set_text_for_string_preferences (NautilusTextCaption *text_caption,
+ const char *name);
+void test_text_caption_set_text_for_default_int_preferences (NautilusTextCaption *text_caption,
+ const char *name);
+void test_text_caption_set_text_for_default_string_preferences (NautilusTextCaption *text_caption,
+ const char *name);
#endif /* TEST_H */