Fix compilation against latest GTK3 changes

With the newest changes to GTK3, some things were changed. This patch
now uses the features introduced in gtk3-compat.h in previous patches.

This patch also introduces a macro named USE_GTK3 that is used to
differentiate between GTK3 and GTK2. Its main use is differenting
between expose and draw handlers for GtkWidget subclasses.

The draw vs expose handlers question is usually handled by using ifdefs
at the beginning and end to set up/tear down a cairo_t and then use it.

However, when the function is too different and too many ifdefs would be
necessary, two versions of the function are written. This is currently
the case for:
- MetaAccelLabel
- MetaFrames

https://bugzilla.gnome.org/show_bug.cgi?id=630203
This commit is contained in:
Benjamin Otte
2010-09-24 13:30:40 +02:00
parent e75abacec6
commit 9f5d8d1a2a
12 changed files with 489 additions and 84 deletions

View File

@ -25,6 +25,8 @@
#include "fixedtip.h"
#include "ui.h"
#include "gdk2-drawing-utils.h"
/**
* The floating rectangle. This is a GtkWindow, and it contains
* the "label" widget, below.
@ -50,6 +52,22 @@ static int screen_right_edge = 0;
*/
static int screen_bottom_edge = 0;
#ifdef USE_GTK3
static gboolean
draw_handler (GtkWidget *tooltips,
cairo_t *cr)
{
gtk_paint_flat_box (gtk_widget_get_style (tip),
cr,
GTK_STATE_NORMAL, GTK_SHADOW_OUT,
tip, "tooltip",
0, 0,
gtk_widget_get_allocated_width (tooltips),
gtk_widget_get_allocated_height (tooltips));
return FALSE;
}
#else /* !USE_GTK3 */
static gint
expose_handler (GtkWidget *tooltips)
{
@ -61,6 +79,7 @@ expose_handler (GtkWidget *tooltips)
return FALSE;
}
#endif /* !USE_GTK3 */
void
meta_fixed_tip_show (Display *xdisplay, int screen_number,
@ -94,8 +113,13 @@ meta_fixed_tip_show (Display *xdisplay, int screen_number,
gtk_widget_set_name (tip, "gtk-tooltips");
gtk_container_set_border_width (GTK_CONTAINER (tip), 4);
#ifdef USE_GTK3
g_signal_connect_swapped (tip, "draw",
G_CALLBACK (draw_handler), NULL);
#else
g_signal_connect_swapped (tip, "expose_event",
G_CALLBACK (expose_handler), NULL);
#endif
label = gtk_label_new (NULL);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);