diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2010-07-25 11:34:46 +0200 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2010-07-25 19:35:31 +0200 |
commit | 6feed0a28d927a98aa5b09bc6622de1fc146387b (patch) | |
tree | a2f118a80e31fe030f42080bf63709773f5d1d31 | |
parent | 28fbb49494879666928a23aa37d36ca0e819d176 (diff) | |
download | nautilus-6feed0a28d927a98aa5b09bc6622de1fc146387b.tar.gz |
[eel] remove unused EelImageTable
-rw-r--r-- | eel/Makefile.am | 2 | ||||
-rw-r--r-- | eel/eel-image-table.c | 579 | ||||
-rw-r--r-- | eel/eel-image-table.h | 95 | ||||
-rw-r--r-- | eel/eel.h | 1 | ||||
-rw-r--r-- | test/Makefile.am | 2 | ||||
-rw-r--r-- | test/test-eel-image-table.c | 304 |
6 files changed, 0 insertions, 983 deletions
diff --git a/eel/Makefile.am b/eel/Makefile.am index 0b3f045b5..9f1a10572 100644 --- a/eel/Makefile.am +++ b/eel/Makefile.am @@ -46,7 +46,6 @@ libeel_2_la_SOURCES = \ eel-gtk-container.c \ eel-gtk-extensions.c \ eel-i18n.c \ - eel-image-table.c \ eel-labeled-image.c \ eel-lib-self-check-functions.c \ eel-pango-extensions.c \ @@ -81,7 +80,6 @@ eel_headers = \ eel-gtk-extensions.h \ eel-gtk-macros.h \ eel-i18n.h \ - eel-image-table.h \ eel-labeled-image.h \ eel-pango-extensions.h \ eel-self-checks.h \ diff --git a/eel/eel-image-table.c b/eel/eel-image-table.c deleted file mode 100644 index f6a3cb97f..000000000 --- a/eel/eel-image-table.c +++ /dev/null @@ -1,579 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* eel-image-table.c - An image table. - - Copyright (C) 2000 Eazel, Inc. - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Authors: Ramiro Estrugo <ramiro@eazel.com> -*/ - -#include <config.h> -#include "eel-image-table.h" - -#include "eel-art-extensions.h" -#include "eel-art-gtk-extensions.h" -#include "eel-debug-drawing.h" -#include "eel-gtk-extensions.h" -#include "eel-gtk-macros.h" -#include "eel-labeled-image.h" -#include "eel-marshal.h" -#include <gtk/gtk.h> - -/* Arguments */ -enum -{ - ARG_0, - ARG_CHILD_UNDER_POINTER -}; - -/* Detail member struct */ -struct EelImageTableDetails -{ - GtkWidget *child_under_pointer; - GtkWidget *child_being_pressed; - GdkGC *clear_gc; -}; - -/* Signals */ -typedef enum -{ - CHILD_ENTER, - CHILD_LEAVE, - CHILD_PRESSED, - CHILD_RELEASED, - CHILD_CLICKED, - LAST_SIGNAL -} ImageTableSignals; - -/* Signals */ -static guint image_table_signals[LAST_SIGNAL] = { 0 }; - -static void eel_image_table_class_init (EelImageTableClass *image_table_class); -static void eel_image_table_init (EelImageTable *image); - -/* GObjectClass methods */ -static void eel_image_table_finalize (GObject *object); - -/* GtkWidgetClass methods */ -static void eel_image_table_realize (GtkWidget *widget); -static void eel_image_table_unrealize (GtkWidget *widget); - -/* GtkContainerClass methods */ -static void eel_image_table_remove (GtkContainer *container, - GtkWidget *widget); -static GType eel_image_table_child_type (GtkContainer *container); - -/* Private EelImageTable methods */ -static void image_table_emit_signal (EelImageTable *image_table, - GtkWidget *child, - guint signal_index, - int x, - int y, - int button, - guint state, - GdkEvent *event); - -/* Ancestor callbacks */ -static int ancestor_enter_notify_event (GtkWidget *widget, - GdkEventCrossing *event, - gpointer event_data); -static int ancestor_leave_notify_event (GtkWidget *widget, - GdkEventCrossing *event, - gpointer event_data); -static int ancestor_motion_notify_event (GtkWidget *widget, - GdkEventMotion *event, - gpointer event_data); -static int ancestor_button_press_event (GtkWidget *widget, - GdkEventButton *event, - gpointer event_data); -static int ancestor_button_release_event (GtkWidget *widget, - GdkEventButton *event, - gpointer event_data); - -EEL_CLASS_BOILERPLATE (EelImageTable, eel_image_table, EEL_TYPE_WRAP_TABLE) - -static void -eel_image_table_class_init (EelImageTableClass *image_table_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (image_table_class); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (image_table_class); - GtkContainerClass *container_class = GTK_CONTAINER_CLASS (image_table_class); - - /* GObjectClass */ - object_class->finalize = eel_image_table_finalize; - - /* GtkWidgetClass */ - widget_class->realize = eel_image_table_realize; - widget_class->unrealize = eel_image_table_unrealize; - - /* GtkContainerClass */ - container_class->remove = eel_image_table_remove; - container_class->child_type = eel_image_table_child_type; - - /* Signals */ - image_table_signals[CHILD_ENTER] = g_signal_new ("child_enter", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EelImageTableClass, child_enter), - NULL, NULL, - eel_marshal_VOID__OBJECT_POINTER, - G_TYPE_NONE, - 2, - GTK_TYPE_WIDGET, - G_TYPE_POINTER); - image_table_signals[CHILD_LEAVE] = g_signal_new ("child_leave", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EelImageTableClass, child_leave), - NULL, NULL, - eel_marshal_VOID__OBJECT_POINTER, - G_TYPE_NONE, - 2, - GTK_TYPE_WIDGET, - G_TYPE_POINTER); - image_table_signals[CHILD_PRESSED] = g_signal_new ("child_pressed", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EelImageTableClass, child_pressed), - NULL, NULL, - eel_marshal_VOID__OBJECT_POINTER, - G_TYPE_NONE, - 2, - GTK_TYPE_WIDGET, - G_TYPE_POINTER); - image_table_signals[CHILD_RELEASED] = g_signal_new ("child_released", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EelImageTableClass, child_released), - NULL, NULL, - eel_marshal_VOID__OBJECT_POINTER, - G_TYPE_NONE, - 2, - GTK_TYPE_WIDGET, - G_TYPE_POINTER); - image_table_signals[CHILD_CLICKED] = g_signal_new ("child_clicked", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EelImageTableClass, child_clicked), - NULL, NULL, - eel_marshal_VOID__OBJECT_POINTER, - G_TYPE_NONE, - 2, - GTK_TYPE_WIDGET, - G_TYPE_POINTER); -} - -static void -eel_image_table_init (EelImageTable *image_table) -{ - gtk_widget_set_has_window (GTK_WIDGET (image_table), FALSE); - - image_table->details = g_new0 (EelImageTableDetails, 1); -} - -/* GObjectClass methods */ -static void -eel_image_table_finalize (GObject *object) -{ - EelImageTable *image_table; - - image_table = EEL_IMAGE_TABLE (object); - - g_free (image_table->details); - - EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object)); -} - -static void -eel_image_table_realize (GtkWidget *widget) -{ - GtkWidget *windowed_ancestor; - - g_assert (EEL_IS_IMAGE_TABLE (widget)); - - /* Chain realize */ - EEL_CALL_PARENT (GTK_WIDGET_CLASS, realize, (widget)); - - windowed_ancestor = eel_gtk_widget_find_windowed_ancestor (widget); - g_assert (GTK_IS_WIDGET (windowed_ancestor)); - - gtk_widget_add_events (windowed_ancestor, - GDK_BUTTON_PRESS_MASK - | GDK_BUTTON_RELEASE_MASK - | GDK_BUTTON_MOTION_MASK - | GDK_ENTER_NOTIFY_MASK - | GDK_LEAVE_NOTIFY_MASK - | GDK_POINTER_MOTION_MASK); - - eel_gtk_signal_connect_while_realized (GTK_OBJECT (windowed_ancestor), - "enter_notify_event", - G_CALLBACK (ancestor_enter_notify_event), - widget, - widget); - - eel_gtk_signal_connect_while_realized (GTK_OBJECT (windowed_ancestor), - "leave_notify_event", - G_CALLBACK (ancestor_leave_notify_event), - widget, - widget); - - eel_gtk_signal_connect_while_realized (GTK_OBJECT (windowed_ancestor), - "motion_notify_event", - G_CALLBACK (ancestor_motion_notify_event), - widget, - widget); - - eel_gtk_signal_connect_while_realized (GTK_OBJECT (windowed_ancestor), - "button_press_event", - G_CALLBACK (ancestor_button_press_event), - widget, - widget); - - eel_gtk_signal_connect_while_realized (GTK_OBJECT (windowed_ancestor), - "button_release_event", - G_CALLBACK (ancestor_button_release_event), - widget, - widget); -} - -static void -eel_image_table_unrealize (GtkWidget *widget) -{ - EelImageTable *image_table; - - g_assert (EEL_IS_IMAGE_TABLE (widget)); - - image_table = EEL_IMAGE_TABLE (widget); - - if (image_table->details->clear_gc != NULL) { - g_object_unref (image_table->details->clear_gc); - image_table->details->clear_gc = NULL; - } - - /* Chain unrealize */ - EEL_CALL_PARENT (GTK_WIDGET_CLASS, unrealize, (widget)); -} - -/* GtkContainerClass methods */ -static void -eel_image_table_remove (GtkContainer *container, - GtkWidget *child) -{ - EelImageTable *image_table; - - g_assert (EEL_IS_IMAGE_TABLE (container)); - g_assert (EEL_IS_LABELED_IMAGE (child)); - - image_table = EEL_IMAGE_TABLE (container); - - if (child == image_table->details->child_under_pointer) { - image_table->details->child_under_pointer = NULL; - } - - if (child == image_table->details->child_being_pressed) { - image_table->details->child_being_pressed = NULL; - } - - EEL_CALL_PARENT (GTK_CONTAINER_CLASS, remove, (container, child)); -} - -static GType -eel_image_table_child_type (GtkContainer *container) -{ - return EEL_TYPE_LABELED_IMAGE; -} - -/* Private EelImageTable methods */ - -static void -image_table_emit_signal (EelImageTable *image_table, - GtkWidget *child, - guint signal_index, - int x, - int y, - int button, - guint state, - GdkEvent *gdk_event) -{ - EelImageTableEvent event; - - g_assert (EEL_IS_IMAGE_TABLE (image_table)); - g_assert (GTK_IS_WIDGET (child)); - g_assert (signal_index < LAST_SIGNAL); - - event.x = x; - event.y = y; - event.button = button; - event.state = state; - event.event = gdk_event; - - g_signal_emit (image_table, - image_table_signals[signal_index], - 0, - child, - &event); -} - -static void -image_table_handle_motion (EelImageTable *image_table, - int x, - int y, - GdkEvent *event) -{ - GtkWidget *child; - GtkWidget *leave_emit_child = NULL; - GtkWidget *enter_emit_child = NULL; - - g_assert (EEL_IS_IMAGE_TABLE (image_table)); - - child = eel_wrap_table_find_child_at_event_point (EEL_WRAP_TABLE (image_table), x, y); - - if (child && !gtk_widget_get_sensitive (child)) { - return; - } - - if (child == image_table->details->child_under_pointer) { - return; - } - - if (child != NULL) { - if (image_table->details->child_under_pointer != NULL) { - leave_emit_child = image_table->details->child_under_pointer; - } - - image_table->details->child_under_pointer = child; - enter_emit_child = image_table->details->child_under_pointer; - } else { - if (image_table->details->child_under_pointer != NULL) { - leave_emit_child = image_table->details->child_under_pointer; - } - - image_table->details->child_under_pointer = NULL; - } - - if (leave_emit_child != NULL) { - image_table_emit_signal (image_table, - leave_emit_child, - CHILD_LEAVE, - x, - y, - 0, - 0, - (GdkEvent *)event); - } - - if (enter_emit_child != NULL) { - image_table_emit_signal (image_table, - enter_emit_child, - CHILD_ENTER, - x, - y, - 0, - 0, - (GdkEvent *)event); - } -} - -static int -ancestor_enter_notify_event (GtkWidget *widget, - GdkEventCrossing *event, - gpointer event_data) -{ - g_assert (GTK_IS_WIDGET (widget)); - g_assert (EEL_IS_IMAGE_TABLE (event_data)); - g_assert (event != NULL); - - image_table_handle_motion (EEL_IMAGE_TABLE (event_data), event->x, event->y, (GdkEvent *) event); - - return FALSE; -} - -static int -ancestor_leave_notify_event (GtkWidget *widget, - GdkEventCrossing *event, - gpointer event_data) -{ - EelIRect bounds; - int x = -1; - int y = -1; - - g_assert (GTK_IS_WIDGET (widget)); - g_assert (EEL_IS_IMAGE_TABLE (event_data)); - g_assert (event != NULL); - - bounds = eel_gtk_widget_get_bounds (GTK_WIDGET (event_data)); - - if (eel_irect_contains_point (bounds, event->x, event->y)) { - x = event->x; - y = event->y; - } - - image_table_handle_motion (EEL_IMAGE_TABLE (event_data), x, y, (GdkEvent *) event); - - return FALSE; -} - -static int -ancestor_motion_notify_event (GtkWidget *widget, - GdkEventMotion *event, - gpointer event_data) -{ - g_assert (GTK_IS_WIDGET (widget)); - g_assert (EEL_IS_IMAGE_TABLE (event_data)); - g_assert (event != NULL); - - image_table_handle_motion (EEL_IMAGE_TABLE (event_data), (int) event->x, (int) event->y, (GdkEvent *) event); - - return FALSE; -} - -static int -ancestor_button_press_event (GtkWidget *widget, - GdkEventButton *event, - gpointer event_data) -{ - EelImageTable *image_table; - GtkWidget *child; - - g_assert (GTK_IS_WIDGET (widget)); - g_assert (EEL_IS_IMAGE_TABLE (event_data)); - g_assert (event != NULL); - - image_table = EEL_IMAGE_TABLE (event_data); - - child = eel_wrap_table_find_child_at_event_point (EEL_WRAP_TABLE (image_table), event->x, event->y); - - if (child && !gtk_widget_get_sensitive (child)) { - return FALSE; - } - - if (child != NULL) { - if (child == image_table->details->child_under_pointer) { - image_table->details->child_being_pressed = child; - image_table_emit_signal (image_table, - child, - CHILD_PRESSED, - event->x, - event->y, - event->button, - event->state, - (GdkEvent *)event); - } - } - - return FALSE; -} - -static int -ancestor_button_release_event (GtkWidget *widget, - GdkEventButton *event, - gpointer event_data) -{ - EelImageTable *image_table; - GtkWidget *child; - GtkWidget *released_emit_child = NULL; - GtkWidget *clicked_emit_child = NULL; - - g_assert (GTK_IS_WIDGET (widget)); - g_assert (EEL_IS_IMAGE_TABLE (event_data)); - g_assert (event != NULL); - - image_table = EEL_IMAGE_TABLE (event_data); - - child = eel_wrap_table_find_child_at_event_point (EEL_WRAP_TABLE (image_table), event->x, event->y); - - if (child && !gtk_widget_get_sensitive (child)) { - return FALSE; - } - - if (image_table->details->child_being_pressed != NULL) { - released_emit_child = image_table->details->child_being_pressed; - } - - if (child != NULL) { - if (child == image_table->details->child_being_pressed) { - clicked_emit_child = child; - } - } - - image_table->details->child_being_pressed = NULL; - - if (released_emit_child != NULL) { - image_table_emit_signal (image_table, - released_emit_child, - CHILD_RELEASED, - event->x, - event->y, - event->button, - event->state, - (GdkEvent *)event); - } - - if (clicked_emit_child != NULL) { - - image_table_emit_signal (image_table, - clicked_emit_child, - CHILD_CLICKED, - event->x, - event->y, - event->button, - event->state, - (GdkEvent *)event); - } - - return FALSE; -} - -/** - * eel_image_table_new: - */ -GtkWidget* -eel_image_table_new (gboolean homogeneous) -{ - EelImageTable *image_table; - - image_table = EEL_IMAGE_TABLE (gtk_widget_new (eel_image_table_get_type (), NULL)); - - eel_wrap_table_set_homogeneous (EEL_WRAP_TABLE (image_table), homogeneous); - - return GTK_WIDGET (image_table); -} - -/** - * eel_image_table_add_empty_child: - * @image_table: A EelImageTable. - * - * Add a "empty" child to the table. Useful when you want to have - * empty space between 2 children. - * - * Returns: The empty child - A EelLabeledImage widget with no label - * or pixbuf. - */ -GtkWidget * -eel_image_table_add_empty_image (EelImageTable *image_table) -{ - GtkWidget *empty; - - g_return_val_if_fail (EEL_IS_IMAGE_TABLE (image_table), NULL); - - empty = eel_labeled_image_new (NULL, NULL); - gtk_container_add (GTK_CONTAINER (image_table), empty); - gtk_widget_set_sensitive (empty, FALSE); - - return empty; -} diff --git a/eel/eel-image-table.h b/eel/eel-image-table.h deleted file mode 100644 index d55f7b87b..000000000 --- a/eel/eel-image-table.h +++ /dev/null @@ -1,95 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* eel-image-table.h - An image table. - - Copyright (C) 2000 Eazel, Inc. - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Authors: Ramiro Estrugo <ramiro@eazel.com> -*/ - -#ifndef EEL_IMAGE_TABLE_H -#define EEL_IMAGE_TABLE_H - -#include <eel/eel-wrap-table.h> - -G_BEGIN_DECLS - -#define EEL_TYPE_IMAGE_TABLE eel_image_table_get_type() -#define EEL_IMAGE_TABLE(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEL_TYPE_IMAGE_TABLE, EelImageTable)) -#define EEL_IMAGE_TABLE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), EEL_TYPE_IMAGE_TABLE, EelImageTableClass)) -#define EEL_IS_IMAGE_TABLE(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EEL_TYPE_IMAGE_TABLE)) -#define EEL_IS_IMAGE_TABLE_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), EEL_TYPE_IMAGE_TABLE)) -#define EEL_IMAGE_TABLE_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), EEL_TYPE_IMAGE_TABLE, EelImageTableClass)) - -typedef struct EelImageTable EelImageTable; -typedef struct EelImageTableClass EelImageTableClass; -typedef struct EelImageTableDetails EelImageTableDetails; - -typedef struct -{ - int x; - int y; - int button; - guint state; - GdkEvent *event; -} EelImageTableEvent; - -struct EelImageTable -{ - /* Superclass */ - EelWrapTable wrap_table; - - /* Private things */ - EelImageTableDetails *details; -}; - -struct EelImageTableClass -{ - EelWrapTableClass parent_class; - - /* Signals */ - void (* child_enter) (EelImageTable *image_table, - GtkWidget *child, - const EelImageTableEvent *event); - void (* child_leave) (EelImageTable *image_table, - GtkWidget *child, - const EelImageTableEvent *event); - void (* child_pressed) (EelImageTable *image_table, - GtkWidget *child, - const EelImageTableEvent *event); - void (* child_released) (EelImageTable *image_table, - GtkWidget *child, - const EelImageTableEvent *event); - void (* child_clicked) (EelImageTable *image_table, - GtkWidget *child, - const EelImageTableEvent *event); -}; - -/* Public GtkImageTable methods */ -GType eel_image_table_get_type (void); -GtkWidget *eel_image_table_new (gboolean homogeneous); -GtkWidget *eel_image_table_add_empty_image (EelImageTable *image_table); - -G_END_DECLS - -#endif /* EEL_IMAGE_TABLE_H */ @@ -36,7 +36,6 @@ #include <eel/eel-gtk-container.h> #include <eel/eel-gtk-extensions.h> #include <eel/eel-gtk-macros.h> -#include <eel/eel-image-table.h> #include <eel/eel-labeled-image.h> #include <eel/eel-pango-extensions.h> #include <eel/eel-self-checks.h> diff --git a/test/Makefile.am b/test/Makefile.am index 1a846a502..89c1d9ab0 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -22,7 +22,6 @@ noinst_PROGRAMS =\ test-eel-background \ test-eel-editable-label \ test-eel-image-scrolled \ - test-eel-image-table \ test-eel-labeled-image \ test-eel-pixbuf-scale \ $(NULL) @@ -37,7 +36,6 @@ test_nautilus_directory_async_SOURCES = test-nautilus-directory-async.c test_eel_background_SOURCES = test-eel-background.c test_eel_image_scrolled_SOURCES = test-eel-image-scrolled.c test.c test.h -test_eel_image_table_SOURCES = test-eel-image-table.c test.c test_eel_labeled_image_SOURCES = test-eel-labeled-image.c test.c test.h test_eel_pixbuf_scale_SOURCES = test-eel-pixbuf-scale.c test.c test.h diff --git a/test/test-eel-image-table.c b/test/test-eel-image-table.c deleted file mode 100644 index 271642b88..000000000 --- a/test/test-eel-image-table.c +++ /dev/null @@ -1,304 +0,0 @@ -#include "test.h" - -#include <eel/eel-image-table.h> -#include <gtk/gtk.h> -#include <stdlib.h> - -static const char pixbuf_name[] = "/usr/share/pixmaps/gnome-about-logo.png"; - -#define BG_COLOR 0xFFFFFF -#define BG_COLOR_SPEC "white" - -static const char *names[] = -{ - "Tomaso Albinoni", - "Isaac Albéniz", - "Georges Bizet", - "Luigi Boccherini", - "Alexander Borodin", - "Johannes Brahms", - "Max Bruch", - "Anton Bruckner", - "Frédéric Chopin", - "Aaron Copland", - "John Corigliano", - "Claude Debussy", - "Léo Delibes", - "Antonín Dvorák", - "Edward Elgar", - "Manuel de Falla", - "George Gershwin", - "Alexander Glazunov", - "Mikhail Glinka", - "Enrique Granados", - "Edvard Grieg", - "Joseph Haydn", - "Scott Joplin", - "Franz Liszt", - "Gustav Mahler", - "Igor Markevitch", - "Felix Mendelssohn", - "Modest Mussorgsky", - "Sergei Prokofiev", - "Giacomo Puccini", - "Maurice Ravel", - "Ottorino Respighi", - "Joaquin Rodrigo", - "Gioachino Rossini", - "Domenico Scarlatti", - "Franz Schubert", - "Robert Schumann", - "Jean Sibelius", - "Bedrich Smetana", - "Johann Strauss", - "Igor Stravinsky", - "Giuseppe Verdi", - "Antonio Vivaldi", - "Richard Wagner", -}; - -static GtkWidget * -labeled_image_new (const char *text, - const char *icon_name) -{ - GtkWidget *image; - GdkPixbuf *pixbuf = NULL; - - if (icon_name) { - float sizes[] = { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, - 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0 }; - pixbuf = test_pixbuf_new_named (icon_name, sizes[random () % G_N_ELEMENTS (sizes)]); - } - - image = eel_labeled_image_new (text, pixbuf); - - eel_gdk_pixbuf_unref_if_not_null (pixbuf); - - return image; -} - - -static void -image_table_child_enter_callback (GtkWidget *image_table, - GtkWidget *item, - gpointer callback_data) -{ -#if 0 - char *text; - - g_return_if_fail (EEL_IS_IMAGE_TABLE (image_table)); - g_return_if_fail (EEL_IS_LABELED_IMAGE (item)); - - text = eel_labeled_image_get_text (EEL_LABELED_IMAGE (item)); - - g_print ("%s(%s)\n", G_STRFUNC, text); -#endif -} - -static void -image_table_child_leave_callback (GtkWidget *image_table, - GtkWidget *item, - gpointer callback_data) -{ -#if 0 - char *text; - - g_return_if_fail (EEL_IS_IMAGE_TABLE (image_table)); - g_return_if_fail (EEL_IS_LABELED_IMAGE (item)); - - text = eel_labeled_image_get_text (EEL_LABELED_IMAGE (item)); - - g_print ("%s(%s)\n", G_STRFUNC, text); -#endif -} - -static void -image_table_child_pressed_callback (GtkWidget *image_table, - GtkWidget *item, - gpointer callback_data) -{ - char *text; - - g_return_if_fail (EEL_IS_IMAGE_TABLE (image_table)); - g_return_if_fail (EEL_IS_LABELED_IMAGE (item)); - - text = eel_labeled_image_get_text (EEL_LABELED_IMAGE (item)); - - g_print ("%s(%s)\n", G_STRFUNC, text); -} - -static void -image_table_child_released_callback (GtkWidget *image_table, - GtkWidget *item, - gpointer callback_data) -{ - char *text; - - g_return_if_fail (EEL_IS_IMAGE_TABLE (image_table)); - g_return_if_fail (EEL_IS_LABELED_IMAGE (item)); - - text = eel_labeled_image_get_text (EEL_LABELED_IMAGE (item)); - - g_print ("%s(%s)\n", G_STRFUNC, text); -} - -static void -image_table_child_clicked_callback (GtkWidget *image_table, - GtkWidget *item, - gpointer callback_data) -{ - char *text; - - g_return_if_fail (EEL_IS_IMAGE_TABLE (image_table)); - g_return_if_fail (EEL_IS_LABELED_IMAGE (item)); - - text = eel_labeled_image_get_text (EEL_LABELED_IMAGE (item)); - - g_print ("%s(%s)\n", G_STRFUNC, text); -} - -static int -foo_timeout (gpointer callback_data) -{ - static int recursion_count = 0; - g_return_val_if_fail (GTK_IS_WINDOW (callback_data), FALSE); - - recursion_count++; - - g_print ("%s(%d)\n", G_STRFUNC, recursion_count); - gtk_widget_queue_resize (GTK_WIDGET (callback_data)); - - recursion_count--; - - return FALSE; -} - -static void -image_table_size_allocate (GtkWidget *image_table, - GtkAllocation *allocation, - gpointer callback_data) -{ - static int recursion_count = 0; - GtkAllocation w_allocation; - - g_return_if_fail (EEL_IS_IMAGE_TABLE (image_table)); - g_return_if_fail (allocation != NULL); - g_return_if_fail (GTK_IS_WINDOW (callback_data)); - - recursion_count++; - - if (0) g_timeout_add (0, foo_timeout, callback_data); - - /*gtk_widget_queue_resize (GTK_WIDGET (callback_data));*/ - - gtk_widget_get_allocation (GTK_WIDGET (image_table), &w_allocation); - if (0) gtk_widget_size_allocate (GTK_WIDGET (image_table), - &w_allocation); - - g_print ("%s(%d)\n", G_STRFUNC, recursion_count); - - recursion_count--; -} - -static GtkWidget * -image_table_new_scrolled (void) -{ - GtkWidget *scrolled; - GtkWidget *viewport; - GtkWidget *window; - GtkWidget *image_table; - int i; - - window = test_window_new ("Image Table Test", 10); - - gtk_window_set_default_size (GTK_WINDOW (window), 400, 300); - - /* Scrolled window */ - scrolled = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), - GTK_POLICY_NEVER, - GTK_POLICY_AUTOMATIC); - gtk_container_add (GTK_CONTAINER (window), scrolled); - - /* Viewport */ - viewport = gtk_viewport_new (NULL, NULL); - gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_OUT); - gtk_container_add (GTK_CONTAINER (scrolled), viewport); - - image_table = eel_image_table_new (FALSE); - - if (0) g_signal_connect (image_table, - "size_allocate", - G_CALLBACK (image_table_size_allocate), - window); - - eel_wrap_table_set_x_justification (EEL_WRAP_TABLE (image_table), - EEL_JUSTIFICATION_MIDDLE); - eel_wrap_table_set_y_justification (EEL_WRAP_TABLE (image_table), - EEL_JUSTIFICATION_END); - - gtk_container_add (GTK_CONTAINER (viewport), image_table); - - g_signal_connect (image_table, - "child_enter", - G_CALLBACK (image_table_child_enter_callback), - NULL); - - g_signal_connect (image_table, - "child_leave", - G_CALLBACK (image_table_child_leave_callback), - NULL); - - g_signal_connect (image_table, - "child_pressed", - G_CALLBACK (image_table_child_pressed_callback), - NULL); - - g_signal_connect (image_table, - "child_released", - G_CALLBACK (image_table_child_released_callback), - NULL); - - g_signal_connect (image_table, - "child_clicked", - G_CALLBACK (image_table_child_clicked_callback), - NULL); - - eel_gtk_widget_set_background_color (viewport, BG_COLOR_SPEC); - - for (i = 0; i < 100; i++) { - char *text; - GtkWidget *image; - - text = g_strdup_printf ("%s %d", - names[random () % G_N_ELEMENTS (names)], - i); - image = labeled_image_new (text, pixbuf_name); - g_free (text); - - gtk_container_add (GTK_CONTAINER (image_table), image); - gtk_widget_show (image); - } - - gtk_widget_show (viewport); - gtk_widget_show (scrolled); - gtk_widget_show (image_table); - - return window; -} - -int -main (int argc, char* argv[]) -{ - GtkWidget *window = NULL; - - test_init (&argc, &argv); - - window = image_table_new_scrolled (); - - gtk_widget_show (window); - - gtk_main (); - - return 0; -} |