summaryrefslogtreecommitdiff
path: root/eel
diff options
context:
space:
mode:
Diffstat (limited to 'eel')
-rw-r--r--eel/eel-image-table.c215
-rw-r--r--eel/eel-wrap-table.c175
2 files changed, 175 insertions, 215 deletions
diff --git a/eel/eel-image-table.c b/eel/eel-image-table.c
index 84dff9aa..205fc70a 100644
--- a/eel/eel-image-table.c
+++ b/eel/eel-image-table.c
@@ -29,7 +29,6 @@
#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>
@@ -62,33 +61,13 @@ typedef enum
/* 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);
-
-/* 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 methods */
GtkWidget * find_windowed_ancestor (GtkWidget *widget);
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void signal_connect_while_realized (GtkWidget *object,
+#else
static void signal_connect_while_realized (GtkObject *object,
+#endif
const char *name,
GCallback callback,
gpointer callback_data,
@@ -110,84 +89,16 @@ 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;
-
- /* 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);
-}
+G_DEFINE_TYPE (EelImageTable, eel_image_table, EEL_TYPE_WRAP_TABLE)
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);
+ image_table->details = G_TYPE_INSTANCE_GET_PRIVATE (image_table,
+ EEL_TYPE_IMAGE_TABLE,
+ EelImageTableDetails);
}
/* GObjectClass methods */
@@ -198,9 +109,7 @@ eel_image_table_finalize (GObject *object)
image_table = EEL_IMAGE_TABLE (object);
- g_free (image_table->details);
-
- EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
+ G_OBJECT_CLASS (eel_image_table_parent_class)->finalize (object);
}
static void
@@ -211,7 +120,7 @@ eel_image_table_realize (GtkWidget *widget)
g_assert (EEL_IS_IMAGE_TABLE (widget));
/* Chain realize */
- EEL_CALL_PARENT (GTK_WIDGET_CLASS, realize, (widget));
+ GTK_WIDGET_CLASS (eel_image_table_parent_class)->realize (widget);
windowed_ancestor = find_windowed_ancestor (widget);
g_assert (GTK_IS_WIDGET (windowed_ancestor));
@@ -224,31 +133,35 @@ eel_image_table_realize (GtkWidget *widget)
| GDK_LEAVE_NOTIFY_MASK
| GDK_POINTER_MOTION_MASK);
- signal_connect_while_realized (GTK_OBJECT (windowed_ancestor),
+#if !GTK_CHECK_VERSION (3, 0, 0)
+#define windowed_ancestor GTK_OBJECT(windowed_ancestor)
+#endif
+
+ signal_connect_while_realized (windowed_ancestor,
"enter_notify_event",
G_CALLBACK (ancestor_enter_notify_event),
widget,
widget);
- signal_connect_while_realized (GTK_OBJECT (windowed_ancestor),
+ signal_connect_while_realized (windowed_ancestor,
"leave_notify_event",
G_CALLBACK (ancestor_leave_notify_event),
widget,
widget);
- signal_connect_while_realized (GTK_OBJECT (windowed_ancestor),
+ signal_connect_while_realized (windowed_ancestor,
"motion_notify_event",
G_CALLBACK (ancestor_motion_notify_event),
widget,
widget);
- signal_connect_while_realized (GTK_OBJECT (windowed_ancestor),
+ signal_connect_while_realized (windowed_ancestor,
"button_press_event",
G_CALLBACK (ancestor_button_press_event),
widget,
widget);
- signal_connect_while_realized (GTK_OBJECT (windowed_ancestor),
+ signal_connect_while_realized (windowed_ancestor,
"button_release_event",
G_CALLBACK (ancestor_button_release_event),
widget,
@@ -277,7 +190,7 @@ eel_image_table_remove (GtkContainer *container,
image_table->details->child_being_pressed = NULL;
}
- EEL_CALL_PARENT (GTK_CONTAINER_CLASS, remove, (container, child));
+ GTK_CONTAINER_CLASS (eel_image_table_parent_class)->remove (container, child);
}
static GType
@@ -318,6 +231,78 @@ image_table_emit_signal (EelImageTable *image_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;
+
+ /* 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);
+
+ g_type_class_add_private (image_table_class, sizeof (EelImageTableDetails));
+}
+
+static void
image_table_handle_motion (EelImageTable *image_table,
int x,
int y,
@@ -401,7 +386,7 @@ find_windowed_ancestor (GtkWidget *widget)
typedef struct
{
- GtkObject *object;
+ GObject *object;
guint object_destroy_handler;
GtkWidget *realized_widget;
@@ -412,12 +397,12 @@ typedef struct
} RealizeDisconnectInfo;
static void
-while_realized_disconnecter (GtkObject *object,
+while_realized_disconnecter (GObject *object,
RealizeDisconnectInfo *info)
{
- g_assert (GTK_IS_OBJECT (object));
+ g_assert (G_IS_OBJECT (object));
g_assert (info != NULL);
- g_assert (GTK_IS_OBJECT (info->object));
+ g_assert (G_IS_OBJECT (info->object));
g_assert (info->object_destroy_handler != 0);
g_assert (info->object_destroy_handler != 0);
g_assert (info->realized_widget_destroy_handler != 0);
@@ -447,7 +432,11 @@ while_realized_disconnecter (GtkObject *object,
* or &widget are destroyed.
**/
static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+signal_connect_while_realized (GtkWidget *object,
+#else
signal_connect_while_realized (GtkObject *object,
+#endif
const char *name,
GCallback callback,
gpointer callback_data,
@@ -455,7 +444,11 @@ signal_connect_while_realized (GtkObject *object,
{
RealizeDisconnectInfo *info;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ g_return_if_fail (GTK_IS_WIDGET (object));
+#else
g_return_if_fail (GTK_IS_OBJECT (object));
+#endif
g_return_if_fail (name != NULL);
g_return_if_fail (name[0] != '\0');
g_return_if_fail (callback != NULL);
diff --git a/eel/eel-wrap-table.c b/eel/eel-wrap-table.c
index 794e1c72..42253acd 100644
--- a/eel/eel-wrap-table.c
+++ b/eel/eel-wrap-table.c
@@ -28,7 +28,6 @@
#include "eel-art-extensions.h"
#include "eel-art-gtk-extensions.h"
#include "eel-gtk-extensions.h"
-#include "eel-gtk-macros.h"
#include <gtk/gtk.h>
/* Arguments */
@@ -56,41 +55,6 @@ struct EelWrapTableDetails
guint cols;
};
-static void eel_wrap_table_class_init (EelWrapTableClass *wrap_table_class);
-static void eel_wrap_table_init (EelWrapTable *wrap);
-/* GObjectClass methods */
-static void eel_wrap_table_finalize (GObject *object);
-static void eel_wrap_table_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
-static void eel_wrap_table_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
-/* GtkWidgetClass methods */
-static void eel_wrap_table_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static int eel_wrap_table_expose_event (GtkWidget *widget,
- GdkEventExpose *event);
-static void eel_wrap_table_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static void eel_wrap_table_map (GtkWidget *widget);
-static void eel_wrap_table_unmap (GtkWidget *widget);
-static void eel_wrap_table_realize (GtkWidget *widget);
-
-/* GtkContainerClass methods */
-static void eel_wrap_table_add (GtkContainer *container,
- GtkWidget *widget);
-static void eel_wrap_table_remove (GtkContainer *container,
- GtkWidget *widget);
-static void eel_wrap_table_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-static GType eel_wrap_table_child_type (GtkContainer *container);
-
-
/* Private EelWrapTable methods */
static EelDimensions wrap_table_irect_max_dimensions (const EelDimensions *one,
const EelDimensions *two);
@@ -105,77 +69,16 @@ static gboolean wrap_table_child_focus_in (GtkWidget *w
static void wrap_table_layout (EelWrapTable *wrap_table);
-EEL_CLASS_BOILERPLATE (EelWrapTable, eel_wrap_table, GTK_TYPE_CONTAINER)
-
-/* Class init methods */
-static void
-eel_wrap_table_class_init (EelWrapTableClass *wrap_table_class)
-{
- GObjectClass *gobject_class = G_OBJECT_CLASS (wrap_table_class);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (wrap_table_class);
- GtkContainerClass *container_class = GTK_CONTAINER_CLASS (wrap_table_class);
-
- /* GObjectClass */
- gobject_class->finalize = eel_wrap_table_finalize;
- gobject_class->set_property = eel_wrap_table_set_property;
- gobject_class->get_property = eel_wrap_table_get_property;
-
- /* GtkWidgetClass */
- widget_class->size_request = eel_wrap_table_size_request;
- widget_class->size_allocate = eel_wrap_table_size_allocate;
- widget_class->expose_event = eel_wrap_table_expose_event;
- widget_class->map = eel_wrap_table_map;
- widget_class->unmap = eel_wrap_table_unmap;
- widget_class->realize = eel_wrap_table_realize;
-
- /* GtkContainerClass */
- container_class->add = eel_wrap_table_add;
- container_class->remove = eel_wrap_table_remove;
- container_class->forall = eel_wrap_table_forall;
- container_class->child_type = eel_wrap_table_child_type;
-
- /* Arguments */
- g_object_class_install_property
- (gobject_class,
- PROP_X_SPACING,
- g_param_spec_uint ("x_spacing", NULL, NULL,
- 0, G_MAXINT, 0, G_PARAM_READWRITE));
-
- g_object_class_install_property
- (gobject_class,
- PROP_Y_SPACING,
- g_param_spec_uint ("y_spacing", NULL, NULL,
- 0, G_MAXINT, 0, G_PARAM_READWRITE));
-
- g_object_class_install_property
- (gobject_class,
- PROP_X_JUSTIFICATION,
- g_param_spec_enum ("x_justification", NULL, NULL,
- GTK_TYPE_JUSTIFICATION,
- GTK_JUSTIFY_LEFT,
- G_PARAM_READWRITE));
-
- g_object_class_install_property
- (gobject_class,
- PROP_Y_JUSTIFICATION,
- g_param_spec_enum ("y_justification", NULL, NULL,
- GTK_TYPE_JUSTIFICATION,
- GTK_JUSTIFY_LEFT,
- G_PARAM_READWRITE));
-
- g_object_class_install_property
- (gobject_class,
- PROP_HOMOGENEOUS,
- g_param_spec_boolean ("homogenous", NULL, NULL,
- FALSE, G_PARAM_READWRITE));
-}
+G_DEFINE_TYPE (EelWrapTable, eel_wrap_table, GTK_TYPE_CONTAINER)
static void
eel_wrap_table_init (EelWrapTable *wrap_table)
{
gtk_widget_set_has_window (GTK_WIDGET (wrap_table), FALSE);
- wrap_table->details = g_new0 (EelWrapTableDetails, 1);
+ wrap_table->details = G_TYPE_INSTANCE_GET_PRIVATE (wrap_table,
+ EEL_TYPE_WRAP_TABLE,
+ EelWrapTableDetails);
wrap_table->details->x_justification = EEL_JUSTIFICATION_BEGINNING;
wrap_table->details->y_justification = EEL_JUSTIFICATION_END;
wrap_table->details->cols = 1;
@@ -189,9 +92,8 @@ eel_wrap_table_finalize (GObject *object)
wrap_table = EEL_WRAP_TABLE (object);
g_list_free (wrap_table->details->children);
- g_free (wrap_table->details);
- EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object));
+ G_OBJECT_CLASS (eel_wrap_table_parent_class)->finalize (object);
}
/* GObjectClass methods */
@@ -389,7 +291,7 @@ eel_wrap_table_realize (GtkWidget *widget)
{
g_assert (EEL_IS_WRAP_TABLE (widget));
- GTK_WIDGET_CLASS (parent_class)->realize (widget);
+ GTK_WIDGET_CLASS (eel_wrap_table_parent_class)->realize (widget);
gtk_widget_queue_resize (widget);
}
@@ -495,6 +397,71 @@ eel_wrap_table_child_type (GtkContainer *container)
return GTK_TYPE_WIDGET;
}
+/* Class init methods */
+static void
+eel_wrap_table_class_init (EelWrapTableClass *wrap_table_class)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (wrap_table_class);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (wrap_table_class);
+ GtkContainerClass *container_class = GTK_CONTAINER_CLASS (wrap_table_class);
+
+ /* GObjectClass */
+ gobject_class->finalize = eel_wrap_table_finalize;
+ gobject_class->set_property = eel_wrap_table_set_property;
+ gobject_class->get_property = eel_wrap_table_get_property;
+
+ /* GtkWidgetClass */
+ widget_class->size_request = eel_wrap_table_size_request;
+ widget_class->size_allocate = eel_wrap_table_size_allocate;
+ widget_class->expose_event = eel_wrap_table_expose_event;
+ widget_class->map = eel_wrap_table_map;
+ widget_class->unmap = eel_wrap_table_unmap;
+ widget_class->realize = eel_wrap_table_realize;
+
+ /* GtkContainerClass */
+ container_class->add = eel_wrap_table_add;
+ container_class->remove = eel_wrap_table_remove;
+ container_class->forall = eel_wrap_table_forall;
+ container_class->child_type = eel_wrap_table_child_type;
+
+ /* Arguments */
+ g_object_class_install_property
+ (gobject_class,
+ PROP_X_SPACING,
+ g_param_spec_uint ("x_spacing", NULL, NULL,
+ 0, G_MAXINT, 0, G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (gobject_class,
+ PROP_Y_SPACING,
+ g_param_spec_uint ("y_spacing", NULL, NULL,
+ 0, G_MAXINT, 0, G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (gobject_class,
+ PROP_X_JUSTIFICATION,
+ g_param_spec_enum ("x_justification", NULL, NULL,
+ GTK_TYPE_JUSTIFICATION,
+ GTK_JUSTIFY_LEFT,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (gobject_class,
+ PROP_Y_JUSTIFICATION,
+ g_param_spec_enum ("y_justification", NULL, NULL,
+ GTK_TYPE_JUSTIFICATION,
+ GTK_JUSTIFY_LEFT,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property
+ (gobject_class,
+ PROP_HOMOGENEOUS,
+ g_param_spec_boolean ("homogenous", NULL, NULL,
+ FALSE, G_PARAM_READWRITE));
+
+ g_type_class_add_private (wrap_table_class, sizeof (EelWrapTableDetails));
+}
+
/* Private EelWrapTable methods */
static int
wrap_table_get_num_fitting (int available,