2008-05-05 Paolo Borelli <pborelli@katamail.com>
[nautilus.git] / test / test-nautilus-wrap-table.c
blob258bde9a994567d4939b36158e38e808aea7e506
1 #include "test.h"
3 #include <eel/eel-wrap-table.h>
4 #include <eel/eel-labeled-image.h>
5 #include <libnautilus-private/nautilus-customization-data.h>
6 #include <libnautilus-private/nautilus-icon-info.h>
8 int
9 main (int argc, char* argv[])
11 NautilusCustomizationData *customization_data;
12 GtkWidget *window;
13 GtkWidget *emblems_table, *button, *scroller;
14 char *emblem_name, *dot_pos;
15 GdkPixbuf *pixbuf;
16 char *label;
18 test_init (&argc, &argv);
20 window = test_window_new ("Wrap Table Test", 10);
22 gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
24 /* The emblems wrapped table */
25 emblems_table = eel_wrap_table_new (TRUE);
27 gtk_widget_show (emblems_table);
28 gtk_container_set_border_width (GTK_CONTAINER (emblems_table), GNOME_PAD);
30 scroller = gtk_scrolled_window_new (NULL, NULL);
31 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroller),
32 GTK_POLICY_NEVER,
33 GTK_POLICY_AUTOMATIC);
35 /* Viewport */
36 gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroller),
37 emblems_table);
39 gtk_container_add (GTK_CONTAINER (window), scroller);
41 gtk_widget_show (scroller);
43 #if 0
44 /* Get rid of default lowered shadow appearance.
45 * This must be done after the widget is realized, due to
46 * an apparent bug in gtk_viewport_set_shadow_type.
48 g_signal_connect (GTK_BIN (scroller->child),
49 "realize",
50 remove_default_viewport_shadow,
51 NULL);
52 #endif
55 /* Use nautilus_customization to make the emblem widgets */
56 customization_data = nautilus_customization_data_new ("emblems", TRUE,
57 NAUTILUS_ICON_SIZE_SMALL,
58 NAUTILUS_ICON_SIZE_SMALL);
60 while (nautilus_customization_data_get_next_element_for_display (customization_data,
61 &emblem_name,
62 &pixbuf,
63 &label) == GNOME_VFS_OK) {
65 /* strip the suffix, if any */
66 dot_pos = strrchr(emblem_name, '.');
67 if (dot_pos) {
68 *dot_pos = '\0';
71 if (strcmp (emblem_name, "erase") == 0) {
72 g_object_unref (pixbuf);
73 g_free (label);
74 g_free (emblem_name);
75 continue;
78 button = eel_labeled_image_check_button_new (label, pixbuf);
79 g_free (label);
80 g_object_unref (pixbuf);
82 /* Attach parameters and signal handler. */
83 g_object_set_data_full (G_OBJECT (button),
84 "nautilus_property_name",
85 emblem_name,
86 (GDestroyNotify) g_free);
88 gtk_container_add (GTK_CONTAINER (emblems_table), button);
91 gtk_widget_show_all (emblems_table);
93 gtk_widget_show (window);
95 gtk_main ();
97 return 0;