diff options
Diffstat (limited to 'applets/notification_area/na-tray.c')
-rw-r--r-- | applets/notification_area/na-tray.c | 62 |
1 files changed, 60 insertions, 2 deletions
diff --git a/applets/notification_area/na-tray.c b/applets/notification_area/na-tray.c index 61f9b568..e6359581 100644 --- a/applets/notification_area/na-tray.c +++ b/applets/notification_area/na-tray.c @@ -527,7 +527,11 @@ update_size_and_orientation (NaTray *tray) * gdk_window_set_composited(). We need to paint these children ourselves. */ static void +#if GTK_CHECK_VERSION (3, 0, 0) +na_tray_draw_icon (GtkWidget *widget, +#else na_tray_expose_icon (GtkWidget *widget, +#endif gpointer data) { cairo_t *cr = data; @@ -538,18 +542,39 @@ na_tray_expose_icon (GtkWidget *widget, gtk_widget_get_allocation (widget, &allocation); +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_save (cr); + gdk_cairo_set_source_window (cr, + gtk_widget_get_window (widget), + allocation.x, + allocation.y); + cairo_rectangle (cr, allocation.x, allocation.y, allocation.width, allocation.height); + cairo_clip (cr); +#else gdk_cairo_set_source_pixmap (cr, gtk_widget_get_window (widget), allocation.x, allocation.y); +#endif cairo_paint (cr); +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_restore (cr); +#endif } } static void +#if GTK_CHECK_VERSION (3, 0, 0) +na_tray_draw_box (GtkWidget *box, + cairo_t *cr) +#else na_tray_expose_box (GtkWidget *box, - GdkEventExpose *event) + GdkEventExpose *event) +#endif { +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_container_foreach (GTK_CONTAINER (box), na_tray_draw_icon, cr); +#else cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (box)); gdk_cairo_region (cr, event->region); @@ -558,6 +583,7 @@ na_tray_expose_box (GtkWidget *box, gtk_container_foreach (GTK_CONTAINER (box), na_tray_expose_icon, cr); cairo_destroy (cr); +#endif } static void @@ -575,8 +601,13 @@ na_tray_init (NaTray *tray) gtk_widget_show (priv->frame); priv->box = g_object_new (na_box_get_type (), NULL); +#if GTK_CHECK_VERSION (3, 0, 0) + g_signal_connect (priv->box, "draw", + G_CALLBACK (na_tray_draw_box), NULL); +#else g_signal_connect (priv->box, "expose-event", - G_CALLBACK (na_tray_expose_box), tray); + G_CALLBACK (na_tray_expose_box), tray); +#endif gtk_box_set_spacing (GTK_BOX (priv->box), ICON_SPACING); gtk_container_add (GTK_CONTAINER (priv->frame), priv->box); gtk_widget_show (priv->box); @@ -729,12 +760,34 @@ na_tray_set_property (GObject *object, } } +#if GTK_CHECK_VERSION (3, 0, 0) +static void +na_tray_get_preferred_width (GtkWidget *widget, + gint *minimal_width, + gint *natural_width) +{ + gtk_widget_get_preferred_width (gtk_bin_get_child (GTK_BIN (widget)), + minimal_width, + natural_width); +} + +static void +na_tray_get_preferred_height (GtkWidget *widget, + gint *minimal_height, + gint *natural_height) +{ + gtk_widget_get_preferred_height (gtk_bin_get_child (GTK_BIN (widget)), + minimal_height, + natural_height); +} +#else static void na_tray_size_request (GtkWidget *widget, GtkRequisition *requisition) { gtk_widget_size_request (gtk_bin_get_child (GTK_BIN (widget)), requisition); } +#endif static void na_tray_size_allocate (GtkWidget *widget, @@ -753,7 +806,12 @@ na_tray_class_init (NaTrayClass *klass) gobject_class->set_property = na_tray_set_property; gobject_class->dispose = na_tray_dispose; +#if GTK_CHECK_VERSION (3, 0, 0) + widget_class->get_preferred_width = na_tray_get_preferred_width; + widget_class->get_preferred_height = na_tray_get_preferred_height; +#else widget_class->size_request = na_tray_size_request; +#endif widget_class->size_allocate = na_tray_size_allocate; g_object_class_install_property |