summaryrefslogtreecommitdiff
path: root/libslab/tile.c
diff options
context:
space:
mode:
Diffstat (limited to 'libslab/tile.c')
-rw-r--r--libslab/tile.c44
1 files changed, 37 insertions, 7 deletions
diff --git a/libslab/tile.c b/libslab/tile.c
index 870944d9..aaa4203e 100644
--- a/libslab/tile.c
+++ b/libslab/tile.c
@@ -47,7 +47,11 @@ static void tile_clicked (GtkButton *widget);
static gboolean tile_focus_in (GtkWidget *, GdkEventFocus *);
static gboolean tile_focus_out (GtkWidget *, GdkEventFocus *);
+#if GTK_CHECK_VERSION (3, 0, 0)
+static gboolean tile_draw (GtkWidget *, cairo_t *);
+#else
static gboolean tile_expose (GtkWidget *, GdkEventExpose *);
+#endif
static gboolean tile_button_release (GtkWidget *, GdkEventButton *);
static gboolean tile_key_release (GtkWidget *, GdkEventKey *);
static gboolean tile_popup_menu (GtkWidget *);
@@ -101,7 +105,11 @@ tile_class_init (TileClass * this_class)
widget_class->focus_in_event = tile_focus_in;
widget_class->focus_out_event = tile_focus_out;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ widget_class->draw = tile_draw;
+#else
widget_class->expose_event = tile_expose;
+#endif
widget_class->button_release_event = tile_button_release;
widget_class->key_release_event = tile_key_release;
widget_class->drag_begin = tile_drag_begin;
@@ -300,7 +308,7 @@ tile_enter (GtkButton * widget)
static void
tile_leave (GtkButton * widget)
{
- if (GTK_WIDGET_HAS_FOCUS (widget))
+ if (gtk_widget_has_focus (widget))
gtk_widget_set_state (GTK_WIDGET (widget), TILE_STATE_FOCUSED);
else
gtk_widget_set_state (GTK_WIDGET (widget), GTK_STATE_NORMAL);
@@ -343,20 +351,36 @@ tile_focus_out (GtkWidget * widget, GdkEventFocus * event)
}
static gboolean
+#if GTK_CHECK_VERSION (3, 0, 0)
+tile_draw (GtkWidget * widget, cairo_t * cr)
+#else
tile_expose (GtkWidget * widget, GdkEventExpose * event)
+#endif
{
/* FIXME: there ought to be a better way to prevent the focus from being rendered. */
gboolean has_focus;
gboolean retval;
- if ((has_focus = GTK_WIDGET_HAS_FOCUS (widget)))
+ if ((has_focus = gtk_widget_has_focus (widget)))
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_FOCUSED);
+#else
GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
+#endif
+#if GTK_CHECK_VERSION (3, 0, 0)
+ retval = (*GTK_WIDGET_CLASS (tile_parent_class)->draw) (widget, cr);
+#else
retval = (*GTK_WIDGET_CLASS (tile_parent_class)->expose_event) (widget, event);
+#endif
if (has_focus)
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_FOCUSED, TRUE);
+#else
GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
+#endif
return retval;
}
@@ -414,7 +438,7 @@ tile_key_release (GtkWidget * widget, GdkEventKey * event)
{
TileEvent *tile_event;
- if (event->keyval == GDK_Return)
+ if (event->keyval == GDK_KEY_Return)
{
tile_event = g_new0 (TileEvent, 1);
tile_event->type = TILE_EVENT_ACTIVATED_KEYBOARD;
@@ -433,20 +457,26 @@ tile_popup_menu_position (GtkMenu * menu, gint * x, gint * y, gboolean * push_in
{
Tile *tile = TILE (data);
+ GtkAllocation all;
GtkRequisition req;
GtkWidget *top;
- if (!GTK_WIDGET_REALIZED (tile))
+ if (!gtk_widget_get_realized (GTK_WIDGET (tile)))
return;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
+#else
gtk_widget_size_request (GTK_WIDGET (menu), &req);
+#endif
+ gtk_widget_get_allocation (GTK_WIDGET (menu), &all);
top = gtk_widget_get_toplevel (GTK_WIDGET (tile));
- gdk_window_get_origin (top->window, x, y);
+ gdk_window_get_origin (gtk_widget_get_window (top), x, y);
- *x += (top->allocation.width / 2) - (req.width / 2);
- *y += (top->allocation.height / 2) - (req.height / 2);
+ *x += (all.width / 2) - (req.width / 2);
+ *y += (all.height / 2) - (req.height / 2);
*push_in = FALSE;
}