summaryrefslogtreecommitdiff
path: root/applets/notification_area/fixedtip.c
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2013-10-26 14:39:39 +0200
committerStefano Karapetsas <[email protected]>2013-10-26 14:39:39 +0200
commit5c99612305a3042d7096123619a83346492eadf3 (patch)
tree989b93367552259e0cce46c04b742b47266f31cd /applets/notification_area/fixedtip.c
parent57c9c407461f47ec09f0a2a631601450a0209af6 (diff)
downloadmate-panel-5c99612305a3042d7096123619a83346492eadf3.tar.bz2
mate-panel-5c99612305a3042d7096123619a83346492eadf3.tar.xz
notification_area: Add GTK3 support
Diffstat (limited to 'applets/notification_area/fixedtip.c')
-rw-r--r--applets/notification_area/fixedtip.c54
1 files changed, 47 insertions, 7 deletions
diff --git a/applets/notification_area/fixedtip.c b/applets/notification_area/fixedtip.c
index 220273b2..7bd61409 100644
--- a/applets/notification_area/fixedtip.c
+++ b/applets/notification_area/fixedtip.c
@@ -51,6 +51,35 @@ button_press_handler (GtkWidget *fixedtip,
return FALSE;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static gboolean
+na_fixed_tip_draw (GtkWidget *widget, cairo_t *cr)
+{
+ GtkStyleContext *context;
+ GtkStateFlags state;
+ int width, height;
+
+ width = gtk_widget_get_allocated_width (widget);
+ height = gtk_widget_get_allocated_height (widget);
+
+ state = gtk_widget_get_state_flags (widget);
+ context = gtk_widget_get_style_context (widget);
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_TOOLTIP);
+ gtk_style_context_set_state (context, state);
+
+ cairo_save (cr);
+ gtk_render_background (context, cr,
+ 0., 0.,
+ (gdouble)width,
+ (gdouble)height);
+ cairo_restore (cr);
+
+ gtk_style_context_restore (context);
+
+ return FALSE;
+}
+#else
static gboolean
expose_handler (GtkWidget *fixedtip)
{
@@ -66,10 +95,16 @@ expose_handler (GtkWidget *fixedtip)
return FALSE;
}
+#endif
static void
na_fixed_tip_class_init (NaFixedTipClass *class)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->draw = na_fixed_tip_draw;
+#endif
+
fixedtip_signals[CLICKED] =
g_signal_new ("clicked",
G_OBJECT_CLASS_TYPE (class),
@@ -106,8 +141,10 @@ na_fixed_tip_init (NaFixedTip *fixedtip)
gtk_container_add (GTK_CONTAINER (fixedtip), label);
fixedtip->priv->label = label;
+#if !GTK_CHECK_VERSION (3, 0, 0)
g_signal_connect (fixedtip, "expose_event",
G_CALLBACK (expose_handler), NULL);
+#endif
gtk_widget_add_events (GTK_WIDGET (fixedtip), GDK_BUTTON_PRESS_MASK);
@@ -135,16 +172,19 @@ na_fixed_tip_position (NaFixedTip *fixedtip)
gtk_window_set_screen (GTK_WINDOW (fixedtip), screen);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_get_preferred_size (GTK_WIDGET (fixedtip), &req, NULL);
+#else
gtk_widget_size_request (GTK_WIDGET (fixedtip), &req);
+#endif
gdk_window_get_origin (parent_window, &root_x, &root_y);
- #if GTK_CHECK_VERSION(3, 0, 0)
- parent_width = gdk_window_get_width(parent_window);
- parent_height = gdk_window_get_height(parent_window);
- #else
- gdk_drawable_get_size(GDK_DRAWABLE(parent_window), &parent_width, &parent_height);
- #endif
-
+#if GTK_CHECK_VERSION(3, 0, 0)
+ parent_width = gdk_window_get_width(parent_window);
+ parent_height = gdk_window_get_height(parent_window);
+#else
+ gdk_drawable_get_size(GDK_DRAWABLE(parent_window), &parent_width, &parent_height);
+#endif
screen_width = gdk_screen_get_width (screen);
screen_height = gdk_screen_get_height (screen);