summaryrefslogtreecommitdiff
path: root/mate-window-picker-applet/task-title.c
diff options
context:
space:
mode:
Diffstat (limited to 'mate-window-picker-applet/task-title.c')
-rw-r--r--mate-window-picker-applet/task-title.c92
1 files changed, 82 insertions, 10 deletions
diff --git a/mate-window-picker-applet/task-title.c b/mate-window-picker-applet/task-title.c
index 5db675f..546e331 100644
--- a/mate-window-picker-applet/task-title.c
+++ b/mate-window-picker-applet/task-title.c
@@ -23,6 +23,12 @@
#include <libwnck/libwnck.h>
#include <mate-panel-applet.h>
+#if GTK_CHECK_VERSION (3, 0, 0)
+#include <math.h>
+#define MATE_DESKTOP_USE_UNSTABLE_API
+#include <libmate-desktop/mate-desktop-utils.h>
+#endif
+
#include "task-list.h"
G_DEFINE_TYPE (TaskTitle, task_title, GTK_TYPE_EVENT_BOX);
@@ -70,7 +76,11 @@ on_close_clicked (GtkButton *button,
if (!WNCK_IS_WINDOW (window)
|| wnck_window_get_window_type (window) == WNCK_WINDOW_DESKTOP)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ mate_gdk_spawn_command_line_on_screen (gdk_screen_get_default (),
+#else
gdk_spawn_command_line_on_screen (gdk_screen_get_default (),
+#endif
LOGOUT, NULL);
}
else
@@ -111,8 +121,13 @@ on_leave_notify (GtkWidget *widget,
}
static gboolean
+#if GTK_CHECK_VERSION (3, 0, 0)
+on_button_draw (GtkWidget *widget,
+ cairo_t *cr,
+#else
on_button_expose (GtkWidget *widget,
GdkEventExpose *event,
+#endif
TaskTitle *title)
{
g_return_val_if_fail (TASK_IS_TITLE (title), FALSE);
@@ -123,17 +138,39 @@ on_button_expose (GtkWidget *widget,
if (priv->mouse_in_close_button)
{
GtkStyle *style = gtk_widget_get_style (widget);
- gtk_paint_box (style,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRectangle area;
+ gdouble x1, y1, x2, y2;
+ cairo_clip_extents (cr, &x1, &y1, &x2, &y2);
+ area.x = floor (x1);
+ area.y = floor (y1);
+ area.width = ceil (x2) - area.x;
+ area.height = ceil (y2) - area.y;
+#endif
+ gtk_paint_box (style,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cr,
+#else
event->window,
+#endif
GTK_STATE_PRELIGHT,
GTK_SHADOW_NONE,
+#if !GTK_CHECK_VERSION (3, 0, 0)
NULL,
+#endif
NULL,
NULL,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ area.x,
+ area.y + 2,
+ area.width,
+ area.height - 4);
+#else
event->area.x,
event->area.y + 2,
event->area.width,
- event->area.height - 4);
+ event->area.height - 4);
+#endif
}
return FALSE;
}
@@ -356,20 +393,46 @@ on_button_release (GtkWidget *title, GdkEventButton *event)
static gboolean
+#if GTK_CHECK_VERSION (3, 0, 0)
+on_draw (GtkWidget *eb, cairo_t *cr)
+#else
on_expose (GtkWidget *eb, GdkEventExpose *event)
+#endif
{
-
- if (eb->state == GTK_STATE_ACTIVE)
- gtk_paint_box (eb->style, eb->window,
- eb->state, GTK_SHADOW_NONE,
- NULL, eb, "button",
- eb->allocation.x, eb->allocation.y,
- eb->allocation.width, eb->allocation.height);
+ GtkAllocation *allocation;
+ GtkStyle *style;
+ GtkStateType state;
+
+ gtk_widget_get_allocation (eb, allocation);
+ style = gtk_widget_get_style (eb);
+ state = gtk_widget_get_state (eb);
+
+ if (state == GTK_STATE_ACTIVE)
+ gtk_paint_box (style,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cr,
+#else
+ eb->window,
+#endif
+ state, GTK_SHADOW_NONE,
+#if !GTK_CHECK_VERSION (3, 0, 0)
+ NULL,
+#endif
+ eb, "button",
+ allocation->x, allocation->y,
+ allocation->width, allocation->height);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_container_propagate_draw (GTK_CONTAINER (eb),
+ gtk_bin_get_child (GTK_BIN (eb)),
+ cr);
+
+#else
gtk_container_propagate_expose (GTK_CONTAINER (eb),
gtk_bin_get_child (GTK_BIN (eb)),
event);
+#endif
return TRUE;
}
@@ -394,7 +457,11 @@ task_title_class_init (TaskTitleClass *klass)
GtkWidgetClass *wid_class = GTK_WIDGET_CLASS (klass);
obj_class->finalize = task_title_finalize;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ wid_class->draw = on_draw;
+#else
wid_class->expose_event = on_expose;
+#endif
g_type_class_add_private (obj_class, sizeof (TaskTitlePrivate));
}
@@ -461,11 +528,16 @@ task_title_init (TaskTitle *title)
G_CALLBACK (on_enter_notify), title);
g_signal_connect (priv->button, "leave-notify-event",
G_CALLBACK (on_leave_notify), title);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ g_signal_connect (priv->button, "draw",
+ G_CALLBACK (on_button_draw), title);
+#else
g_signal_connect (priv->button, "expose-event",
G_CALLBACK (on_button_expose), title);
+#endif
/* Load the quit icon. We have to do this in such a god-forsaken way
- because of http://bugzilla.mate.org/show_bug.cgi?id=581359 and the
+ because of http://bugzilla.gnome.org/show_bug.cgi?id=581359 and the
fact that we support as far back as GTK+ 2.12 (which never passes
FORCE_SIZE in GtkImage). The only way to guarantee icon size is to
load and scale it ourselves. We don't do this for all the other icons