diff options
author | Ramiro Estrugo <ramiro@src.gnome.org> | 2000-07-10 13:14:58 +0000 |
---|---|---|
committer | Ramiro Estrugo <ramiro@src.gnome.org> | 2000-07-10 13:14:58 +0000 |
commit | 747245d712e4f56c9c2dc6ffd30b9fa14e262b91 (patch) | |
tree | f466cf541fff224ead4f25d776ff45748f1ff323 /test | |
parent | 33d57594f3a725f95ce98c0a8aa04c1eb3f3d17a (diff) | |
download | nautilus-747245d712e4f56c9c2dc6ffd30b9fa14e262b91.tar.gz |
Add arlo's services title icons.
* components/services/startup/nautilus-view/icons/Makefile.am,
eazel-services-logo.png,
eazel-services-logo-tile.png:
Add arlo's services title icons.
* libnautilus-extensions/Makefile.am:
* libnautilus-extensions/nautilus-graphic.c:
(nautilus_graphic_initialize_class), (nautilus_graphic_initialize),
(nautilus_graphic_destroy), (nautilus_graphic_set_arg),
(nautilus_graphic_get_arg), (nautilus_graphic_realize),
(nautilus_graphic_unrealize), (nautilus_graphic_draw),
(nautilus_graphic_size_allocate), (nautilus_graphic_size_request),
(nautilus_graphic_map), (nautilus_graphic_unmap),
(nautilus_graphic_expose), (ensure_buffer_size),
(create_child_window), (nautilus_gdk_create_copy_area_gc),
(nautilus_gdk_pixbuf_render_to_drawable),
(nautilus_gdk_pixbuf_render_to_pixbuf),
(nautilus_gdk_pixbuf_render_to_pixbuf_alpha),
(gdk_string_dimensions), (nautilus_gdk_pixbuf_set_to_color),
(nautilus_gdk_pixbuf_tile), (nautilus_gdk_pixbuf_tile_alpha),
(nautilus_graphic_new), (nautilus_graphic_set_background_pixbuf),
(nautilus_graphic_get_background_pixbuf),
(nautilus_graphic_set_background_type),
(nautilus_graphic_get_background_type),
(nautilus_graphic_set_background_color),
(nautilus_graphic_get_background_color),
(nautilus_graphic_set_placement_type),
(nautilus_graphic_get_placement_type),
(nautilus_graphic_set_pixbuf), (nautilus_graphic_get_pixbuf),
(nautilus_graphic_set_overall_alpha),
(nautilus_graphic_set_label_text),
(nautilus_graphic_get_label_text),
(nautilus_graphic_set_label_font),
(nautilus_graphic_get_label_font):
* libnautilus-extensions/nautilus-graphic.h:
Add NautilusGraphic widget to build.
* test/.cvsignore:
* test/Makefile.am:
* test/test-nautilus-graphic.c: (create_background),
(create_pixbuf), (create_graphic), (alpha_scale_value_changed),
(red_color_value_changed), (green_color_value_changed),
(blue_color_value_changed), (toggle_background_type_callback),
(create_color_scale), (main):
Add test for NautilusGraphic widget.
Diffstat (limited to 'test')
-rw-r--r-- | test/.cvsignore | 2 | ||||
-rw-r--r-- | test/Makefile.am | 3 | ||||
-rw-r--r-- | test/test-nautilus-graphic.c | 350 |
3 files changed, 355 insertions, 0 deletions
diff --git a/test/.cvsignore b/test/.cvsignore index a0463bfae..f662c0ba1 100644 --- a/test/.cvsignore +++ b/test/.cvsignore @@ -8,3 +8,5 @@ test-nautilus-mime-actions test-nautilus-mime-actions-set test-nautilus-widgets test-nautilus-preferences +test-nautilus-graphic + diff --git a/test/Makefile.am b/test/Makefile.am index 8b5730ef8..8ea6825a3 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -35,6 +35,7 @@ noinst_PROGRAMS =\ test-nautilus-mime-actions-set \ test-nautilus-widgets \ test-nautilus-preferences \ + test-nautilus-graphic \ $(NULL) test_nautilus_mime_actions_SOURCES = test-nautilus-mime-actions.c @@ -45,6 +46,8 @@ test_nautilus_widgets_SOURCES = test-nautilus-widgets.c test_nautilus_preferences_SOURCES = test-nautilus-preferences.c +test_nautilus_graphic_SOURCES = test-nautilus-graphic.c + #libleakcheck_la_SOURCES = \ # nautilus-leak-checker.c \ # nautilus-leak-checker.h \ diff --git a/test/test-nautilus-graphic.c b/test/test-nautilus-graphic.c new file mode 100644 index 000000000..87ec38fe3 --- /dev/null +++ b/test/test-nautilus-graphic.c @@ -0,0 +1,350 @@ + +#include <config.h> + +#include <gtk/gtk.h> +#include <libnautilus-extensions/nautilus-graphic.h> +#include <libnautilus-extensions/nautilus-icon-factory.h> +#include <libnautilus-extensions/nautilus-file-utilities.h> + +static GdkPixbuf* +create_background (void) +{ + GdkPixbuf *background; + + background = gdk_pixbuf_new_from_file ("/gnome/share/nautilus/backgrounds/pale_coins.png"); + + g_assert (background != NULL); + + return background; +} + +static GdkPixbuf* +create_pixbuf (const char *name) +{ + char *icon_path; + GdkPixbuf *pixbuf = NULL; + + g_assert (name != NULL); + + icon_path = nautilus_pixmap_file (name); + g_assert (icon_path != NULL); + + pixbuf = gdk_pixbuf_new_from_file (icon_path); + + g_assert (pixbuf != NULL); + + g_free (icon_path); + + return pixbuf; +} + +static GtkWidget* +create_graphic (const char *name, GdkPixbuf *background) +{ + GtkWidget *graphic; + GdkPixbuf *pixbuf; + + g_assert (background != NULL); + + graphic = nautilus_graphic_new (); + g_assert (graphic != NULL); + + nautilus_graphic_set_background_type (NAUTILUS_GRAPHIC (graphic), NAUTILUS_GRAPHIC_BACKGROUND_PIXBUF); + nautilus_graphic_set_background_pixbuf (NAUTILUS_GRAPHIC (graphic), background); + + if (name != NULL) + { + pixbuf = create_pixbuf (name); + g_assert (pixbuf != NULL); + + nautilus_graphic_set_pixbuf (NAUTILUS_GRAPHIC (graphic), pixbuf); + + gdk_pixbuf_unref (pixbuf); + } + + return graphic; +} + +static void +alpha_scale_value_changed (GtkAdjustment *adjustment, gpointer client_data) +{ + GList *graphic_list; + + g_return_if_fail (adjustment != NULL); + g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment)); + g_return_if_fail (client_data != NULL); + + graphic_list = (GList *) client_data; + + while (graphic_list) + { + g_assert (graphic_list->data != NULL); + g_assert (NAUTILUS_IS_GRAPHIC (graphic_list->data)); + + nautilus_graphic_set_overall_alpha (NAUTILUS_GRAPHIC (graphic_list->data), (guchar) adjustment->value); + + graphic_list = graphic_list->next; + } +} + +static void +red_color_value_changed (GtkAdjustment *adjustment, gpointer client_data) +{ + GList *graphic_list; + + g_return_if_fail (adjustment != NULL); + g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment)); + g_return_if_fail (client_data != NULL); + + graphic_list = (GList *) client_data; + + while (graphic_list) + { + NautilusGraphic *graphic; + guint32 color; + + g_assert (graphic_list->data != NULL); + g_assert (NAUTILUS_IS_GRAPHIC (graphic_list->data)); + + graphic = NAUTILUS_GRAPHIC (graphic_list->data); + + color = nautilus_graphic_get_background_color (graphic); + + color = NAUTILUS_RGBA_COLOR_PACK ((guchar) adjustment->value, + NAUTILUS_RGBA_COLOR_GET_G (color), + NAUTILUS_RGBA_COLOR_GET_B (color), + NAUTILUS_RGBA_COLOR_GET_A (color)); + + nautilus_graphic_set_background_color (graphic, color); + + graphic_list = graphic_list->next; + } +} + +static void +green_color_value_changed (GtkAdjustment *adjustment, gpointer client_data) +{ + GList *graphic_list; + + g_return_if_fail (adjustment != NULL); + g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment)); + g_return_if_fail (client_data != NULL); + + graphic_list = (GList *) client_data; + + while (graphic_list) + { + NautilusGraphic *graphic; + guint32 color; + + g_assert (graphic_list->data != NULL); + g_assert (NAUTILUS_IS_GRAPHIC (graphic_list->data)); + + graphic = NAUTILUS_GRAPHIC (graphic_list->data); + + color = nautilus_graphic_get_background_color (graphic); + + color = NAUTILUS_RGBA_COLOR_PACK (NAUTILUS_RGBA_COLOR_GET_R (color), + (guchar) adjustment->value, + NAUTILUS_RGBA_COLOR_GET_B (color), + NAUTILUS_RGBA_COLOR_GET_A (color)); + + nautilus_graphic_set_background_color (graphic, color); + + graphic_list = graphic_list->next; + } +} + +static void +blue_color_value_changed (GtkAdjustment *adjustment, gpointer client_data) +{ + GList *graphic_list; + + g_return_if_fail (adjustment != NULL); + g_return_if_fail (GTK_IS_ADJUSTMENT (adjustment)); + g_return_if_fail (client_data != NULL); + + graphic_list = (GList *) client_data; + + while (graphic_list) + { + NautilusGraphic *graphic; + guint32 color; + + g_assert (graphic_list->data != NULL); + g_assert (NAUTILUS_IS_GRAPHIC (graphic_list->data)); + + graphic = NAUTILUS_GRAPHIC (graphic_list->data); + + color = nautilus_graphic_get_background_color (graphic); + + color = NAUTILUS_RGBA_COLOR_PACK (NAUTILUS_RGBA_COLOR_GET_R (color), + NAUTILUS_RGBA_COLOR_GET_G (color), + (guchar) adjustment->value, + NAUTILUS_RGBA_COLOR_GET_A (color)); + + nautilus_graphic_set_background_color (graphic, color); + + graphic_list = graphic_list->next; + } +} + +static void +toggle_background_type_callback (GtkWidget *widget, gpointer client_data) +{ + NautilusGraphic *graphic; + + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_BUTTON (widget)); + g_return_if_fail (client_data != NULL); + g_return_if_fail (NAUTILUS_IS_GRAPHIC (client_data)); + + graphic = NAUTILUS_GRAPHIC (client_data); + + if (nautilus_graphic_get_background_type (graphic) == NAUTILUS_GRAPHIC_BACKGROUND_PIXBUF) + { + nautilus_graphic_set_background_type (graphic, NAUTILUS_GRAPHIC_BACKGROUND_SOLID); + } + else + { + nautilus_graphic_set_background_type (graphic, NAUTILUS_GRAPHIC_BACKGROUND_PIXBUF); + } +} + +static GtkWidget* +create_color_scale (guint num_colors, GtkSignalFunc callback, gpointer callback_data) +{ + GtkAdjustment *adjustment; + GtkWidget *scale; + + g_assert (num_colors > 0); + g_assert (callback > 0); + + adjustment = (GtkAdjustment *) gtk_adjustment_new (num_colors, + 0, + num_colors, + 1, + num_colors / 10, + 0); + + scale = gtk_hscale_new (adjustment); + + gtk_signal_connect (GTK_OBJECT (adjustment), "value_changed", callback, callback_data); + + return scale; +} + +int +main (int argc, char* argv[]) +{ + GtkWidget *window; + GtkWidget *main_box; + GtkWidget *graphic_box; + GtkWidget *tool_box; + GtkWidget *toggle_background_type; + + GtkWidget *alpha_scale; + + GtkWidget *red_scale; + GtkWidget *green_scale; + GtkWidget *blue_scale; + + GdkPixbuf *background; + + GtkWidget *graphic1; + GtkWidget *graphic2; + GtkWidget *graphic3; + + GtkWidget *background_graphic; + + GList *graphic_list = NULL; + + const char *file_name1 = "eazel-services-logo.png"; + const char *file_name2 = "eazel-services-logo-tile.png"; + const char *file_name3 = "eazel-services-logo-tile.png"; + + gtk_init (&argc, &argv); + gdk_rgb_init (); + + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_window_set_title (GTK_WINDOW (window), "Graphic Test"); + gtk_container_set_border_width (GTK_CONTAINER (window), 10); + + main_box = gtk_vbox_new (FALSE, 0); + gtk_container_add (GTK_CONTAINER (window), main_box); + + background = create_background (); + + graphic1 = create_graphic (file_name1, background); + graphic2 = create_graphic (file_name2, background); + graphic3 = create_graphic (file_name3, background); + background_graphic = create_graphic (NULL, background); + + graphic_list = g_list_append (graphic_list, graphic1); + graphic_list = g_list_append (graphic_list, graphic2); + graphic_list = g_list_append (graphic_list, graphic3); + graphic_list = g_list_append (graphic_list, background_graphic); + + nautilus_graphic_set_placement_type (NAUTILUS_GRAPHIC (graphic2), NAUTILUS_GRAPHIC_PLACEMENT_TILE); + nautilus_graphic_set_placement_type (NAUTILUS_GRAPHIC (graphic3), NAUTILUS_GRAPHIC_PLACEMENT_TILE); + + { + GdkFont *font; + + font = gdk_font_load ("-adobe-helvetica-medium-r-normal--20-140-*"); + + nautilus_graphic_set_label_text (NAUTILUS_GRAPHIC (graphic3), "Welcome Back, Arlo!"); + nautilus_graphic_set_label_font (NAUTILUS_GRAPHIC (graphic3), font); + + gdk_font_unref (font); + } + + graphic_box = gtk_hbox_new (FALSE, 0); + tool_box = gtk_hbox_new (FALSE, 0); + + gtk_box_pack_start (GTK_BOX (main_box), graphic_box, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (main_box), background_graphic, TRUE, TRUE, 0); + gtk_box_pack_end (GTK_BOX (main_box), tool_box, FALSE, FALSE, 10); + + gtk_box_pack_start (GTK_BOX (graphic_box), graphic1, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (graphic_box), graphic2, TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (graphic_box), graphic3, FALSE, FALSE, 0); + + alpha_scale = create_color_scale (255, alpha_scale_value_changed, graphic_list); + + toggle_background_type = gtk_button_new_with_label ("Toggle Background Type"); + red_scale = create_color_scale (255, red_color_value_changed, graphic_list); + green_scale = create_color_scale (255, green_color_value_changed, graphic_list); + blue_scale = create_color_scale (255, blue_color_value_changed, graphic_list); + + gtk_box_pack_start (GTK_BOX (tool_box), alpha_scale, FALSE, FALSE, 5); + gtk_box_pack_start (GTK_BOX (tool_box), toggle_background_type, FALSE, FALSE, 5); + gtk_box_pack_start (GTK_BOX (tool_box), red_scale, FALSE, FALSE, 5); + gtk_box_pack_start (GTK_BOX (tool_box), green_scale, FALSE, FALSE, 5); + gtk_box_pack_start (GTK_BOX (tool_box), blue_scale, FALSE, FALSE, 5); + + gtk_signal_connect (GTK_OBJECT (toggle_background_type), + "clicked", + GTK_SIGNAL_FUNC (toggle_background_type_callback), + (gpointer) graphic1); + + gtk_signal_connect (GTK_OBJECT (toggle_background_type), + "clicked", + GTK_SIGNAL_FUNC (toggle_background_type_callback), + (gpointer) graphic2); + gtk_signal_connect (GTK_OBJECT (toggle_background_type), + "clicked", + GTK_SIGNAL_FUNC (toggle_background_type_callback), + (gpointer) graphic3); + + gtk_signal_connect (GTK_OBJECT (toggle_background_type), + "clicked", + GTK_SIGNAL_FUNC (toggle_background_type_callback), + (gpointer) background_graphic); + + gtk_widget_show_all (window); + + gtk_main (); + + return 0; +} |