summaryrefslogtreecommitdiff
path: root/applets
diff options
context:
space:
mode:
Diffstat (limited to 'applets')
-rw-r--r--applets/clock/calendar-window.c18
-rw-r--r--applets/clock/clock-face.c68
-rw-r--r--applets/clock/clock-location-tile.c4
-rw-r--r--applets/clock/clock-map.c75
-rw-r--r--applets/clock/clock.c23
-rw-r--r--applets/fish/fish.c144
-rw-r--r--applets/notification_area/fixedtip.c54
-rw-r--r--applets/notification_area/main.c4
-rw-r--r--applets/notification_area/na-tray-child.c80
-rw-r--r--applets/notification_area/na-tray-child.h4
-rw-r--r--applets/notification_area/na-tray-manager.c60
-rw-r--r--applets/notification_area/na-tray-manager.h3
-rw-r--r--applets/notification_area/na-tray.c62
-rw-r--r--applets/notification_area/testtray.c6
-rw-r--r--applets/wncklet/showdesktop.c3
-rw-r--r--applets/wncklet/window-list.c47
-rw-r--r--applets/wncklet/window-menu.c36
-rw-r--r--applets/wncklet/wncklet.c4
-rw-r--r--applets/wncklet/wncklet.h2
-rw-r--r--applets/wncklet/workspace-switcher.c47
20 files changed, 677 insertions, 67 deletions
diff --git a/applets/clock/calendar-window.c b/applets/clock/calendar-window.c
index 665ea150..fe61ce58 100644
--- a/applets/clock/calendar-window.c
+++ b/applets/clock/calendar-window.c
@@ -33,7 +33,7 @@
#include <gio/gio.h>
#define MATE_DESKTOP_USE_UNSTABLE_API
-#include <libmate/mate-desktop-utils.h>
+#include <libmate-desktop/mate-desktop-utils.h>
#include "calendar-window.h"
@@ -359,7 +359,11 @@ calendar_window_set_property (GObject *object,
}
static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+calendar_window_dispose (GObject *object)
+#else
calendar_window_destroy (GtkObject *object)
+#endif
{
CalendarWindow *calwin;
@@ -369,20 +373,30 @@ calendar_window_destroy (GtkObject *object)
g_object_unref (calwin->priv->settings);
calwin->priv->settings = NULL;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ G_OBJECT_CLASS (calendar_window_parent_class)->dispose (object);
+#else
GTK_OBJECT_CLASS (calendar_window_parent_class)->destroy (object);
+#endif
}
static void
calendar_window_class_init (CalendarWindowClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+#if !GTK_CHECK_VERSION (3, 0, 0)
GtkObjectClass *gtkobject_class = GTK_OBJECT_CLASS (klass);
+#endif
gobject_class->constructor = calendar_window_constructor;
gobject_class->get_property = calendar_window_get_property;
- gobject_class->set_property = calendar_window_set_property;
+ gobject_class->set_property = calendar_window_set_property;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gobject_class->dispose = calendar_window_dispose;
+#else
gtkobject_class->destroy = calendar_window_destroy;
+#endif
g_type_class_add_private (klass, sizeof (CalendarWindowPrivate));
diff --git a/applets/clock/clock-face.c b/applets/clock/clock-face.c
index 143eef12..fe944a12 100644
--- a/applets/clock/clock-face.c
+++ b/applets/clock/clock-face.c
@@ -27,7 +27,13 @@ static GHashTable *pixbuf_cache = NULL;
G_DEFINE_TYPE (ClockFace, clock_face, GTK_TYPE_WIDGET)
static void clock_face_finalize (GObject *);
+#if GTK_CHECK_VERSION (3, 0, 0)
+static gboolean clock_face_draw (GtkWidget *clock, cairo_t *cr);
+static void clock_face_get_preferred_width (GtkWidget *widget, gint *minimum_width, gint *natural_width);
+static void clock_face_get_preferred_height (GtkWidget *widget, gint *minimum_height, gint *natural_height);
+#else
static gboolean clock_face_expose (GtkWidget *clock, GdkEventExpose *event);
+#endif
static void clock_face_size_request (GtkWidget *clock,
GtkRequisition *requisition);
static void clock_face_size_allocate (GtkWidget *clock,
@@ -70,8 +76,14 @@ clock_face_class_init (ClockFaceClass *class)
widget_class = GTK_WIDGET_CLASS (class);
/* GtkWidget signals */
- widget_class->expose_event = clock_face_expose;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ widget_class->draw = clock_face_draw;
+ widget_class->get_preferred_width = clock_face_get_preferred_width;
+ widget_class->get_preferred_height = clock_face_get_preferred_height;
+#else
widget_class->size_request = clock_face_size_request;
+ widget_class->expose_event = clock_face_expose;
+#endif
widget_class->size_allocate = clock_face_size_allocate;
/* GObject signals */
@@ -93,11 +105,20 @@ clock_face_init (ClockFace *this)
gtk_widget_set_has_window (GTK_WIDGET (this), FALSE);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static gboolean
+clock_face_draw (GtkWidget *this, cairo_t *cr)
+#else
static void
draw (GtkWidget *this, cairo_t *cr)
+#endif
{
ClockFacePrivate *priv;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ int width, height;
+#else
GtkAllocation allocation;
+#endif
double x, y;
double radius;
int hours, minutes, seconds;
@@ -107,6 +128,11 @@ draw (GtkWidget *this, cairo_t *cr)
priv = CLOCK_FACE_GET_PRIVATE (this);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ if (GTK_WIDGET_CLASS (clock_face_parent_class)->draw)
+ GTK_WIDGET_CLASS (clock_face_parent_class)->draw (this, cr);
+#endif
+
if (priv->size == CLOCK_FACE_LARGE) {
hour_length = 0.45;
min_length = 0.6;
@@ -117,6 +143,21 @@ draw (GtkWidget *this, cairo_t *cr)
sec_length = 0.8; /* not drawn currently */
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ width = gtk_widget_get_allocated_width (this);
+ height = gtk_widget_get_allocated_width (this);
+ x = width / 2;
+ y = height / 2;
+ radius = MIN (width / 2, height / 2) - 5;
+
+ /* clock back */
+ if (priv->face_pixbuf) {
+ cairo_save (cr);
+ gdk_cairo_set_source_pixbuf (cr, priv->face_pixbuf, 0, 0);
+ cairo_paint (cr);
+ cairo_restore (cr);
+ }
+#else
gtk_widget_get_allocation (this, &allocation);
x = allocation.x + allocation.width / 2;
@@ -142,6 +183,7 @@ draw (GtkWidget *this, cairo_t *cr)
}
cairo_restore (cr);
+#endif
/* clock hands */
hours = priv->time.tm_hour;
@@ -184,6 +226,7 @@ draw (GtkWidget *this, cairo_t *cr)
}
}
+#if !GTK_CHECK_VERSION (3, 0, 0)
static gboolean
clock_face_expose (GtkWidget *this, GdkEventExpose *event)
{
@@ -203,6 +246,7 @@ clock_face_expose (GtkWidget *this, GdkEventExpose *event)
return FALSE;
}
+#endif
static void
clock_face_redraw_canvas (ClockFace *this)
@@ -248,6 +292,28 @@ clock_face_size_request (GtkWidget *this,
}
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+clock_face_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width)
+{
+ GtkRequisition req;
+ clock_face_size_request (widget, &req);
+ *minimum_width = *natural_width = req.width;
+}
+
+static void
+clock_face_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height)
+{
+ GtkRequisition req;
+ clock_face_size_request (widget, &req);
+ *minimum_height = *natural_height = req.height;
+}
+#endif
+
static void
clock_face_size_allocate (GtkWidget *this,
GtkAllocation *allocation)
diff --git a/applets/clock/clock-location-tile.c b/applets/clock/clock-location-tile.c
index 33007b14..1ff428ab 100644
--- a/applets/clock/clock-location-tile.c
+++ b/applets/clock/clock-location-tile.c
@@ -204,7 +204,11 @@ make_current (GtkWidget *widget, ClockLocationTile *tile)
GdkWindow *window = gtk_widget_get_window (toplevel);
if (window)
+#if GTK_CHECK_VERSION (3, 0, 0)
+ xid = GDK_WINDOW_XID (window);
+#else
xid = GDK_WINDOW_XWINDOW (window);
+#endif
}
clock_location_make_current (priv->location,
diff --git a/applets/clock/clock-map.c b/applets/clock/clock-map.c
index 5a6e0379..5823f6ea 100644
--- a/applets/clock/clock-map.c
+++ b/applets/clock/clock-map.c
@@ -56,13 +56,23 @@ typedef struct {
} ClockMapPrivate;
static void clock_map_finalize (GObject *);
-static void clock_map_size_request (GtkWidget *this,
- GtkRequisition *requisition);
static void clock_map_size_allocate (GtkWidget *this,
GtkAllocation *allocation);
+#if GTK_CHECK_VERSION (3, 0, 0)
+static gboolean clock_map_draw (GtkWidget *this,
+ cairo_t *cr);
+static void clock_map_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width);
+static void clock_map_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height);
+#else
static gboolean clock_map_expose (GtkWidget *this,
GdkEventExpose *expose);
-
+static void clock_map_size_request (GtkWidget *this,
+ GtkRequisition *requisition);
+#endif
static void clock_map_place_locations (ClockMap *this);
static void clock_map_render_shadow (ClockMap *this);
static void clock_map_display (ClockMap *this);
@@ -88,9 +98,16 @@ clock_map_class_init (ClockMapClass *this_class)
g_obj_class->finalize = clock_map_finalize;
/* GtkWidget signals */
- widget_class->size_request = clock_map_size_request;
+
widget_class->size_allocate = clock_map_size_allocate;
- widget_class->expose_event = clock_map_expose;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ widget_class->draw = clock_map_draw;
+ widget_class->get_preferred_width = clock_map_get_preferred_width;
+ widget_class->get_preferred_height = clock_map_get_preferred_height;
+#else
+ widget_class->expose_event = clock_map_expose;
+ widget_class->size_request = clock_map_size_request;
+#endif
g_type_class_add_private (this_class, sizeof (ClockMapPrivate));
@@ -217,24 +234,42 @@ clock_map_refresh (ClockMap *this)
}
static gboolean
+#if GTK_CHECK_VERSION (3, 0, 0)
+clock_map_draw (GtkWidget *this, cairo_t *cr)
+#else
clock_map_expose (GtkWidget *this, GdkEventExpose *event)
+#endif
{
ClockMapPrivate *priv = PRIVATE (this);
- GdkWindow *window;
GtkStyle *style;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ int width, height;
+#else
+ GdkWindow *window;
GtkAllocation allocation;
GdkRectangle region;
cairo_t *cr;
+#endif
- window = gtk_widget_get_window (this);
style = gtk_widget_get_style (this);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ width = gdk_pixbuf_get_width (priv->shadow_map_pixbuf);
+ height = gdk_pixbuf_get_height (priv->shadow_map_pixbuf);
+#else
+ window = gtk_widget_get_window (this);
gtk_widget_get_allocation (this, &allocation);
+#endif
if (!priv->shadow_map_pixbuf) {
g_warning ("Needed to refresh the map in expose event.");
clock_map_refresh (CLOCK_MAP (this));
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_cairo_set_source_pixbuf (cr, priv->shadow_map_pixbuf, 0, 0);
+ cairo_rectangle (cr, 0, 0, width, height);
+ cairo_paint (cr);
+#else
cr = gdk_cairo_create (window);
region.x = allocation.x;
@@ -254,8 +289,13 @@ clock_map_expose (GtkWidget *this, GdkEventExpose *event)
region.height,
GDK_RGB_DITHER_NORMAL,
0, 0);
+#endif
/* draw a simple outline */
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_rectangle (cr, 0.5, 0.5, width - 1, height - 1);
+ gdk_cairo_set_source_color (cr, &style->mid [GTK_STATE_ACTIVE]);
+#else
cairo_rectangle (
cr,
allocation.x + 0.5, allocation.y + 0.5,
@@ -267,21 +307,42 @@ clock_map_expose (GtkWidget *this, GdkEventExpose *event)
style->mid [GTK_STATE_ACTIVE].red / 65535.0,
style->mid [GTK_STATE_ACTIVE].green / 65535.0,
style->mid [GTK_STATE_ACTIVE].blue / 65535.0);
+#endif
cairo_set_line_width (cr, 1.0);
cairo_stroke (cr);
+#if !GTK_CHECK_VERSION (3, 0, 0)
cairo_destroy (cr);
+#endif
return FALSE;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+clock_map_get_preferred_width (GtkWidget *widget,
+ gint *minimum_width,
+ gint *natural_width)
+{
+ *minimum_width = *natural_width = 250;
+}
+
+static void
+clock_map_get_preferred_height (GtkWidget *widget,
+ gint *minimum_height,
+ gint *natural_height)
+{
+ *minimum_height = *natural_height = 125;
+}
+#else
static void
clock_map_size_request (GtkWidget *this, GtkRequisition *requisition)
{
requisition->width = 250;
requisition->height = 125;
}
+#endif
static void
clock_map_size_allocate (GtkWidget *this, GtkAllocation *allocation)
diff --git a/applets/clock/clock.c b/applets/clock/clock.c
index bcbf847d..78b92c07 100644
--- a/applets/clock/clock.c
+++ b/applets/clock/clock.c
@@ -765,7 +765,7 @@ close_on_escape (GtkWidget *widget,
GdkEventKey *event,
GtkToggleButton *toggle_button)
{
- if (event->keyval == GDK_Escape) {
+ if (event->keyval == GDK_KEY_Escape) {
gtk_toggle_button_set_active (toggle_button, FALSE);
return TRUE;
}
@@ -2114,7 +2114,11 @@ location_start_element (GMarkupParseContext *context,
latitude, longitude, code, &prefs);
if (current && clock_location_is_current_timezone (loc))
+#if GTK_CHECK_VERSION (3, 0, 0)
+ clock_location_make_current (loc, GDK_WINDOW_XID (gtk_widget_get_window (cd->applet)),
+#else
clock_location_make_current (loc, GDK_WINDOW_XWINDOW (gtk_widget_get_window (cd->applet)),
+#endif
NULL, NULL, NULL);
data->cities = g_list_append (data->cities, loc);
@@ -2955,6 +2959,9 @@ fill_prefs_window (ClockData *cd)
GtkCellRenderer *renderer;
GtkTreeViewColumn *col;
GtkListStore *store;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GtkTreeIter iter;
+#endif
int i;
/* Set the 12 hour / 24 hour widget */
@@ -3017,9 +3024,15 @@ fill_prefs_window (ClockData *cd)
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (widget), renderer, "text", 0, NULL);
for (i = 0; temperatures[i] != -1; i++)
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_list_store_insert_with_values (store, &iter, -1,
+ 0, mateweather_prefs_get_temp_display_name (temperatures[i]),
+ -1);
+#else
gtk_combo_box_append_text (GTK_COMBO_BOX (widget),
mateweather_prefs_get_temp_display_name (temperatures[i]));
-
+#endif
+
if (cd->temperature_unit > 0)
gtk_combo_box_set_active (GTK_COMBO_BOX (widget),
cd->temperature_unit - 2);
@@ -3035,8 +3048,14 @@ fill_prefs_window (ClockData *cd)
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (widget), renderer, "text", 0, NULL);
for (i = 0; speeds[i] != -1; i++)
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_list_store_insert_with_values (store, &iter, -1,
+ 0, mateweather_prefs_get_speed_display_name (speeds[i]),
+ -1);
+#else
gtk_combo_box_append_text (GTK_COMBO_BOX (widget),
mateweather_prefs_get_speed_display_name (speeds[i]));
+#endif
if (cd->speed_unit > 0)
gtk_combo_box_set_active (GTK_COMBO_BOX (widget),
diff --git a/applets/fish/fish.c b/applets/fish/fish.c
index 01b9ed6c..ac3c196d 100644
--- a/applets/fish/fish.c
+++ b/applets/fish/fish.c
@@ -32,11 +32,15 @@
#include <time.h>
#include <cairo.h>
+#include <cairo-xlib.h>
#include <glib/gi18n.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
+#if GTK_CHECK_VERSION (3, 0, 0)
+#include <gdk/gdkkeysyms-compat.h>
+#endif
#include <gio/gio.h>
#include <mate-panel-applet.h>
@@ -79,7 +83,11 @@ typedef struct {
GtkWidget *drawing_area;
GtkRequisition requisition;
GdkRectangle prev_allocation;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_surface_t *surface;
+#else
GdkPixmap *pixmap;
+#endif
guint timeout;
int current_frame;
gboolean in_applet;
@@ -791,6 +799,17 @@ static gboolean fish_read_output(GIOChannel* source, GIOCondition condition, gpo
return (status != G_IO_STATUS_EOF);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+/*
+ * Set the DISPLAY variable, to be use by g_spawn_async.
+ */
+static void
+set_environment (gpointer display)
+{
+ g_setenv ("DISPLAY", display, TRUE);
+}
+#endif
+
static void display_fortune_dialog(FishApplet* fish)
{
GError *error = NULL;
@@ -799,6 +818,10 @@ static void display_fortune_dialog(FishApplet* fish)
const char *charset;
int argc;
char **argv;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkScreen *screen;
+ char *display;
+#endif
/* if there is still a pipe, close it */
if (fish->source_id)
@@ -826,8 +849,10 @@ static void display_fortune_dialog(FishApplet* fish)
gtk_window_set_icon_name (GTK_WINDOW (fish->fortune_dialog),
FISH_ICON);
+#if !GTK_CHECK_VERSION (3, 0, 0)
gtk_dialog_set_has_separator (
GTK_DIALOG (fish->fortune_dialog), FALSE);
+#endif
gtk_dialog_set_default_response (
GTK_DIALOG (fish->fortune_dialog), GTK_RESPONSE_CLOSE);
@@ -918,11 +943,28 @@ static void display_fortune_dialog(FishApplet* fish)
clear_fortune_text (fish);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ screen = gtk_widget_get_screen (GTK_WIDGET (fish));
+ display = gdk_screen_make_display_name (screen);
+ g_spawn_async_with_pipes (NULL, /* working directory */
+ argv,
+ NULL, /* envp */
+ G_SPAWN_SEARCH_PATH|G_SPAWN_STDERR_TO_DEV_NULL,
+ set_environment,
+ &display,
+ NULL, /* child pid */
+ NULL, /* stdin */
+ &output,
+ NULL, /* stderr */
+ &error);
+ g_free (display);
+#else
gdk_spawn_on_screen_with_pipes (gtk_widget_get_screen (GTK_WIDGET (fish)),
NULL, argv, NULL,
G_SPAWN_SEARCH_PATH|G_SPAWN_STDERR_TO_DEV_NULL,
NULL, NULL, NULL, NULL, &output, NULL,
&error);
+#endif
if (error) {
char *message;
@@ -1357,21 +1399,37 @@ static void update_pixmap(FishApplet* fish)
}
}
+ gtk_widget_set_size_request (fish->drawing_area,
+ fish->requisition.width,
+ fish->requisition.height);
+
g_assert (width != -1 && height != -1);
if (width == 0 || height == 0)
return;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ if (fish->surface)
+ cairo_surface_destroy (fish->surface);
+ fish->surface = gdk_window_create_similar_surface (gtk_widget_get_window (widget),
+ CAIRO_CONTENT_COLOR_ALPHA,
+ width, height);
+#else
if (fish->pixmap)
g_object_unref (fish->pixmap);
fish->pixmap = gdk_pixmap_new (gtk_widget_get_window (widget),
width, height, -1);
+#endif
gtk_widget_queue_resize (widget);
g_assert (pixbuf_width != -1 && pixbuf_height != -1);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cr = cairo_create (fish->surface);
+#else
cr = gdk_cairo_create (fish->pixmap);
+#endif
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_paint (cr);
@@ -1418,7 +1476,11 @@ static void update_pixmap(FishApplet* fish)
cairo_destroy (cr);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static gboolean fish_applet_draw(GtkWidget* widget, cairo_t *cr, FishApplet* fish)
+#else
static gboolean fish_applet_expose_event(GtkWidget* widget, GdkEventExpose* event, FishApplet* fish)
+#endif
{
GdkWindow *window;
GtkStyle *style;
@@ -1426,7 +1488,11 @@ static gboolean fish_applet_expose_event(GtkWidget* widget, GdkEventExpose* even
int width, height;
int src_x, src_y;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ g_return_val_if_fail (fish->surface != NULL, FALSE);
+#else
g_return_val_if_fail (fish->pixmap != NULL, FALSE);
+#endif
g_assert (fish->n_frames > 0);
@@ -1434,16 +1500,16 @@ static gboolean fish_applet_expose_event(GtkWidget* widget, GdkEventExpose* even
style = gtk_widget_get_style (widget);
state = gtk_widget_get_state (widget);
- #if GTK_CHECK_VERSION(3, 0, 0)
- width = gdk_window_get_width(fish->pixmap);
- height = gdk_window_get_height(fish->pixmap);
- #else
- gdk_drawable_get_size(fish->pixmap, &width, &height);
- #endif
-
-
+#if GTK_CHECK_VERSION(3, 0, 0)
+ width = cairo_xlib_surface_get_width (fish->surface);
+ height = cairo_xlib_surface_get_height (fish->surface);
+ src_x = 0;
+ src_y = 0;
+#else
+ gdk_drawable_get_size(fish->pixmap, &width, &height);
src_x = event->area.x;
src_y = event->area.y;
+#endif
if (fish->rotate) {
if (fish->orientation == MATE_PANEL_APPLET_ORIENT_RIGHT)
@@ -1455,20 +1521,29 @@ static gboolean fish_applet_expose_event(GtkWidget* widget, GdkEventExpose* even
} else
src_x += ((width * fish->current_frame) / fish->n_frames);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_save (cr);
+ cairo_set_source_surface (cr, fish->surface, -src_x, -src_y);
+ cairo_paint (cr);
+ cairo_restore (cr);
+#else
gdk_draw_drawable (window,
style->fg_gc [state],
fish->pixmap,
src_x, src_y,
event->area.x, event->area.y,
event->area.width, event->area.height);
+#endif
return FALSE;
}
+#if !GTK_CHECK_VERSION (3, 0, 0)
static void fish_applet_size_request(GtkWidget* widget, GtkRequisition* requisition, FishApplet* fish)
{
*requisition = fish->requisition;
}
+#endif
static void fish_applet_size_allocate(GtkWidget* widget, GtkAllocation* allocation, FishApplet* fish)
{
@@ -1485,15 +1560,25 @@ static void fish_applet_size_allocate(GtkWidget* widget, GtkAllocation* allocati
static void fish_applet_realize(GtkWidget* widget, FishApplet* fish)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ if (!fish->surface)
+#else
if (!fish->pixmap)
+#endif
update_pixmap (fish);
}
static void fish_applet_unrealize(GtkWidget* widget, FishApplet* fish)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ if (fish->surface)
+ cairo_surface_destroy (fish->surface);
+ fish->surface = NULL;
+#else
if (fish->pixmap)
g_object_unref (fish->pixmap);
fish->pixmap = NULL;
+#endif
}
static void fish_applet_change_orient(MatePanelApplet* applet, MatePanelAppletOrient orientation)
@@ -1505,7 +1590,11 @@ static void fish_applet_change_orient(MatePanelApplet* applet, MatePanelAppletOr
fish->orientation = orientation;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ if (fish->surface)
+#else
if (fish->pixmap)
+#endif
update_pixmap (fish);
}
@@ -1624,12 +1713,17 @@ static void setup_fish_widget(FishApplet* fish)
G_CALLBACK (fish_applet_realize), fish);
g_signal_connect (fish->drawing_area, "unrealize",
G_CALLBACK (fish_applet_unrealize), fish);
- g_signal_connect (fish->drawing_area, "size-request",
- G_CALLBACK (fish_applet_size_request), fish);
g_signal_connect (fish->drawing_area, "size-allocate",
G_CALLBACK (fish_applet_size_allocate), fish);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ g_signal_connect (fish->drawing_area, "draw",
+ G_CALLBACK (fish_applet_draw), fish);
+#else
g_signal_connect (fish->drawing_area, "expose-event",
G_CALLBACK (fish_applet_expose_event), fish);
+ g_signal_connect (fish->drawing_area, "size-request",
+ G_CALLBACK (fish_applet_size_request), fish);
+#endif
gtk_widget_add_events (widget, GDK_ENTER_NOTIFY_MASK |
GDK_LEAVE_NOTIFY_MASK |
@@ -1745,7 +1839,11 @@ static gboolean fishy_factory(MatePanelApplet* applet, const char* iid, gpointer
return retval;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void fish_applet_dispose (GObject *object)
+#else
static void fish_applet_destroy(GtkObject* object)
+#endif
{
FishApplet* fish = (FishApplet*) object;
@@ -1776,9 +1874,15 @@ static void fish_applet_destroy(GtkObject* object)
g_free (fish->command);
fish->command = NULL;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ if (fish->surface)
+ cairo_surface_destroy (fish->surface);
+ fish->surface = NULL;
+#else
if (fish->pixmap)
g_object_unref (fish->pixmap);
fish->pixmap = NULL;
+#endif
if (fish->pixbuf)
g_object_unref (fish->pixbuf);
@@ -1798,7 +1902,11 @@ static void fish_applet_destroy(GtkObject* object)
fish_close_channel (fish);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ G_OBJECT_CLASS (parent_class)->dispose (object);
+#else
GTK_OBJECT_CLASS (parent_class)->destroy (object);
+#endif
}
static void fish_applet_instance_init(FishApplet* fish, FishAppletClass* klass)
@@ -1814,7 +1922,11 @@ static void fish_applet_instance_init(FishApplet* fish, FishAppletClass* klass)
fish->frame = NULL;
fish->drawing_area = NULL;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ fish->surface = NULL;
+#else
fish->pixmap = NULL;
+#endif
fish->timeout = 0;
fish->current_frame = 0;
fish->in_applet = FALSE;
@@ -1857,14 +1969,22 @@ static void fish_applet_instance_init(FishApplet* fish, FishAppletClass* klass)
static void fish_applet_class_init(FishAppletClass* klass)
{
- MatePanelAppletClass* applet_class = (MatePanelAppletClass*) klass;
- GtkObjectClass* gtkobject_class = (GtkObjectClass*) klass;
+ MatePanelAppletClass* applet_class = (MatePanelAppletClass*) klass;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GObjectClass *gobject_class = (GObjectClass *) klass;
+#else
+ GtkObjectClass* gtkobject_class = (GtkObjectClass*) klass;
+#endif
parent_class = g_type_class_peek_parent(klass);
applet_class->change_orient = fish_applet_change_orient;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gobject_class->dispose = fish_applet_dispose;
+#else
gtkobject_class->destroy = fish_applet_destroy;
+#endif
init_fools_day();
}
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);
diff --git a/applets/notification_area/main.c b/applets/notification_area/main.c
index f752ca02..0b63bf65 100644
--- a/applets/notification_area/main.c
+++ b/applets/notification_area/main.c
@@ -141,7 +141,11 @@ static const GtkActionEntry menu_actions [] = {
G_CALLBACK (about_cb) }
};
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, cairo_pattern_t *pattern, AppletData* data)
+#else
static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, GdkPixmap* pixmap, AppletData* data)
+#endif
{
na_tray_force_redraw(data->tray);
}
diff --git a/applets/notification_area/na-tray-child.c b/applets/notification_area/na-tray-child.c
index 5160d699..93ac4bb8 100644
--- a/applets/notification_area/na-tray-child.c
+++ b/applets/notification_area/na-tray-child.c
@@ -54,21 +54,33 @@ na_tray_child_realize (GtkWidget *widget)
* extension. */
/* Set a transparent background */
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_pattern_t *transparent = cairo_pattern_create_rgba (0, 0, 0, 0);
+ gdk_window_set_background_pattern (window, transparent);
+#else
GdkColor transparent = { 0, 0, 0, 0 }; /* only pixel=0 matters */
gdk_window_set_background (window, &transparent);
+#endif
gdk_window_set_composited (window, TRUE);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_pattern_destroy (transparent);
+#endif
child->parent_relative_bg = FALSE;
- }
- #if GTK_CHECK_VERSION(3, 0, 0)
- else if (visual == gdk_window_get_visual(gdk_window_get_parent(window)))
- #else
- else if (visual == gdk_drawable_get_visual(GDK_DRAWABLE(gdk_window_get_parent(window))))
- #endif
- {
+ }
+#if GTK_CHECK_VERSION(3, 0, 0)
+ else if (visual == gdk_window_get_visual(gdk_window_get_parent(window)))
+#else
+ else if (visual == gdk_drawable_get_visual(GDK_DRAWABLE(gdk_window_get_parent(window))))
+#endif
+ {
/* Otherwise, if the visual matches the visual of the parent window, we
* can use a parent-relative background and fake transparency. */
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_window_set_background_pattern (window, NULL);
+#else
gdk_window_set_back_pixmap (window, NULL, TRUE);
+#endif
child->parent_relative_bg = TRUE;
}
@@ -180,8 +192,13 @@ na_tray_child_size_allocate (GtkWidget *widget,
* expose handler draws with real or fake transparency.
*/
static gboolean
+#if GTK_CHECK_VERSION (3, 0, 0)
+na_tray_child_draw (GtkWidget *widget,
+ cairo_t *cr)
+#else
na_tray_child_expose_event (GtkWidget *widget,
GdkEventExpose *event)
+#endif
{
NaTrayChild *child = NA_TRAY_CHILD (widget);
GdkWindow *window = gtk_widget_get_window (widget);
@@ -189,19 +206,50 @@ na_tray_child_expose_event (GtkWidget *widget,
if (na_tray_child_has_alpha (child))
{
/* Clear to transparent */
+#if !GTK_CHECK_VERSION (3, 0, 0)
cairo_t *cr = gdk_cairo_create (window);
+#endif
cairo_set_source_rgba (cr, 0, 0, 0, 0);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_paint (cr);
+#else
gdk_cairo_region (cr, event->region);
cairo_fill (cr);
cairo_destroy (cr);
+#endif
}
else if (child->parent_relative_bg)
{
/* Clear to parent-relative pixmap */
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkWindow *window;
+ cairo_surface_t *target;
+ GdkRectangle clip_rect;
+
+ window = gtk_widget_get_window (widget);
+ target = cairo_get_group_target (cr);
+
+ gdk_cairo_get_clip_rectangle (cr, &clip_rect);
+
+ /* Clear to parent-relative pixmap
+ * We need to use direct X access here because GDK doesn't know about
+ * the parent relative pixmap. */
+ cairo_surface_flush (target);
+
+ XClearArea (GDK_WINDOW_XDISPLAY (window),
+ GDK_WINDOW_XID (window),
+ clip_rect.x, clip_rect.y,
+ clip_rect.width, clip_rect.height,
+ False);
+ cairo_surface_mark_dirty_rectangle (target,
+ clip_rect.x, clip_rect.y,
+ clip_rect.width, clip_rect.height);
+#else
gdk_window_clear_area (window,
event->area.x, event->area.y,
event->area.width, event->area.height);
+#endif
}
return FALSE;
@@ -225,7 +273,11 @@ na_tray_child_class_init (NaTrayChildClass *klass)
widget_class->style_set = na_tray_child_style_set;
widget_class->realize = na_tray_child_realize;
widget_class->size_allocate = na_tray_child_size_allocate;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ widget_class->draw = na_tray_child_draw;
+#else
widget_class->expose_event = na_tray_child_expose_event;
+#endif
}
GtkWidget *
@@ -237,8 +289,10 @@ na_tray_child_new (GdkScreen *screen,
NaTrayChild *child;
GdkVisual *visual;
gboolean visual_has_alpha;
+#if !GTK_CHECK_VERSION (3, 0, 0)
GdkColormap *colormap;
gboolean new_colormap;
+#endif
int red_prec, green_prec, blue_prec, depth;
int result;
@@ -264,6 +318,7 @@ na_tray_child_new (GdkScreen *screen,
if (!visual) /* Icon window is on another screen? */
return NULL;
+#if !GTK_CHECK_VERSION (3, 0, 0)
new_colormap = FALSE;
if (visual == gdk_screen_get_rgb_visual (screen))
@@ -277,11 +332,16 @@ na_tray_child_new (GdkScreen *screen,
colormap = gdk_colormap_new (visual, FALSE);
new_colormap = TRUE;
}
+#endif
child = g_object_new (NA_TYPE_TRAY_CHILD, NULL);
child->icon_window = icon_window;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_set_visual (GTK_WIDGET (child), visual);
+#else
gtk_widget_set_colormap (GTK_WIDGET (child), colormap);
+#endif
/* We have alpha if the visual has something other than red, green,
* and blue */
@@ -296,8 +356,10 @@ na_tray_child_new (GdkScreen *screen,
child->composited = child->has_alpha;
+#if !GTK_CHECK_VERSION (3, 0, 0)
if (new_colormap)
g_object_unref (colormap);
+#endif
return GTK_WIDGET (child);
}
@@ -426,7 +488,11 @@ na_tray_child_force_redraw (NaTrayChild *child)
gtk_widget_get_allocation (widget, &allocation);
xev.xexpose.type = Expose;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ xev.xexpose.window = GDK_WINDOW_XID (plug_window);
+#else
xev.xexpose.window = GDK_WINDOW_XWINDOW (plug_window);
+#endif
xev.xexpose.x = 0;
xev.xexpose.y = 0;
xev.xexpose.width = allocation.width;
diff --git a/applets/notification_area/na-tray-child.h b/applets/notification_area/na-tray-child.h
index 8dd7202a..9427d74b 100644
--- a/applets/notification_area/na-tray-child.h
+++ b/applets/notification_area/na-tray-child.h
@@ -26,6 +26,10 @@
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
+#if GTK_CHECK_VERSION (3, 0, 0)
+#include <gtk/gtkx.h>
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/applets/notification_area/na-tray-manager.c b/applets/notification_area/na-tray-manager.c
index 9a397109..1a2acc7f 100644
--- a/applets/notification_area/na-tray-manager.c
+++ b/applets/notification_area/na-tray-manager.c
@@ -26,7 +26,12 @@
#include "na-tray-manager.h"
+#include <gtk/gtk.h>
+#if GTK_CHECK_VERSION (3, 0, 0)
+#define GDK_WINDOW_XWINDOW GDK_WINDOW_XID
+#else
#include <gdkconfig.h>
+#endif
#include <glib/gi18n.h>
#if defined (GDK_WINDOWING_X11)
#include <gdk/gdkx.h>
@@ -34,7 +39,6 @@
#elif defined (GDK_WINDOWING_WIN32)
#include <gdk/gdkwin32.h>
#endif
-#include <gtk/gtk.h>
#include "na-marshal.h"
@@ -316,18 +320,28 @@ pending_message_free (PendingMessage *message)
g_free (message);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void
+na_tray_manager_handle_message_data (NaTrayManager *manager,
+ XClientMessageEvent *xevent)
+#else
static GdkFilterReturn
na_tray_manager_handle_client_message_message_data (GdkXEvent *xev,
GdkEvent *event,
gpointer data)
+#endif
{
+#if !GTK_CHECK_VERSION (3, 0, 0)
XClientMessageEvent *xevent;
NaTrayManager *manager;
+#endif
GList *p;
int len;
+#if !GTK_CHECK_VERSION (3, 0, 0)
xevent = (XClientMessageEvent *) xev;
manager = data;
+#endif
/* Try to see if we can find the pending message in the list */
for (p = manager->messages; p; p = p->next)
@@ -363,7 +377,9 @@ na_tray_manager_handle_client_message_message_data (GdkXEvent *xev,
}
}
+#if !GTK_CHECK_VERSION (3, 0, 0)
return GDK_FILTER_REMOVE;
+#endif
}
static void
@@ -455,6 +471,7 @@ na_tray_manager_handle_cancel_message (NaTrayManager *manager,
}
}
+#if !GTK_CHECK_VERSION (3, 0, 0)
static GdkFilterReturn
na_tray_manager_handle_client_message_opcode (GdkXEvent *xev,
GdkEvent *event,
@@ -487,6 +504,7 @@ na_tray_manager_handle_client_message_opcode (GdkXEvent *xev,
return GDK_FILTER_CONTINUE;
}
+#endif
static GdkFilterReturn
na_tray_manager_window_filter (GdkXEvent *xev,
@@ -507,6 +525,31 @@ na_tray_manager_window_filter (GdkXEvent *xev,
(XClientMessageEvent *) xevent);
return GDK_FILTER_REMOVE;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ /* _NET_SYSTEM_TRAY_OPCODE: SYSTEM_TRAY_BEGIN_MESSAGE */
+ else if (xevent->xclient.message_type == manager->opcode_atom &&
+ xevent->xclient.data.l[1] == SYSTEM_TRAY_BEGIN_MESSAGE)
+ {
+ na_tray_manager_handle_begin_message (manager,
+ (XClientMessageEvent *) event);
+ return GDK_FILTER_REMOVE;
+ }
+ /* _NET_SYSTEM_TRAY_OPCODE: SYSTEM_TRAY_CANCEL_MESSAGE */
+ else if (xevent->xclient.message_type == manager->opcode_atom &&
+ xevent->xclient.data.l[1] == SYSTEM_TRAY_CANCEL_MESSAGE)
+ {
+ na_tray_manager_handle_cancel_message (manager,
+ (XClientMessageEvent *) event);
+ return GDK_FILTER_REMOVE;
+ }
+ /* _NET_SYSTEM_TRAY_MESSAGE_DATA */
+ else if (xevent->xclient.message_type == manager->message_data_atom)
+ {
+ na_tray_manager_handle_message_data (manager,
+ (XClientMessageEvent *) event);
+ return GDK_FILTER_REMOVE;
+ }
+#endif
}
else if (xevent->type == SelectionClear)
{
@@ -564,9 +607,12 @@ na_tray_manager_unmanage (NaTrayManager *manager)
TRUE);
}
+/* fixed in GTK3 */
+#if !GTK_CHECK_VERSION (3, 0, 0)
//FIXME: we should also use gdk_remove_client_message_filter when it's
//available
// See bug #351254
+#endif
gdk_window_remove_filter (window,
na_tray_manager_window_filter, manager);
@@ -647,10 +693,14 @@ na_tray_manager_set_visual_property (NaTrayManager *manager)
* be embedded. In almost all cases, this will be the same as the visual
* of the screen.
*/
+#if GTK_CHECK_VERSION (3, 0, 0)
+ xvisual = GDK_VISUAL_XVISUAL (gdk_screen_get_system_visual (manager->screen));
+#else
GdkColormap *colormap;
colormap = gdk_screen_get_default_colormap (manager->screen);
xvisual = GDK_VISUAL_XVISUAL (gdk_colormap_get_visual (colormap));
+#endif
}
data[0] = XVisualIDFromVisual (xvisual);
@@ -749,6 +799,12 @@ na_tray_manager_manage_screen_x11 (NaTrayManager *manager,
message_data_atom = gdk_atom_intern ("_NET_SYSTEM_TRAY_MESSAGE_DATA",
FALSE);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ manager->message_data_atom = gdk_x11_atom_to_xatom_for_display (display,
+ message_data_atom);
+#endif
+
+
/* Add a window filter */
#if 0
/* This is for when we lose the selection of _NET_SYSTEM_TRAY_Sx */
@@ -759,6 +815,7 @@ na_tray_manager_manage_screen_x11 (NaTrayManager *manager,
/* This is for SYSTEM_TRAY_REQUEST_DOCK and SelectionClear */
gdk_window_add_filter (window,
na_tray_manager_window_filter, manager);
+#if !GTK_CHECK_VERSION (3, 0, 0)
/* This is for SYSTEM_TRAY_BEGIN_MESSAGE and SYSTEM_TRAY_CANCEL_MESSAGE */
gdk_display_add_client_message_filter (display, opcode_atom,
na_tray_manager_handle_client_message_opcode,
@@ -767,6 +824,7 @@ na_tray_manager_manage_screen_x11 (NaTrayManager *manager,
gdk_display_add_client_message_filter (display, message_data_atom,
na_tray_manager_handle_client_message_message_data,
manager);
+#endif
return TRUE;
}
else
diff --git a/applets/notification_area/na-tray-manager.h b/applets/notification_area/na-tray-manager.h
index 19d03081..e98c4848 100644
--- a/applets/notification_area/na-tray-manager.h
+++ b/applets/notification_area/na-tray-manager.h
@@ -52,6 +52,9 @@ struct _NaTrayManager
#ifdef GDK_WINDOWING_X11
GdkAtom selection_atom;
Atom opcode_atom;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ Atom message_data_atom;
+#endif
#endif
GtkWidget *invisible;
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
diff --git a/applets/notification_area/testtray.c b/applets/notification_area/testtray.c
index f6a9111e..9feed828 100644
--- a/applets/notification_area/testtray.c
+++ b/applets/notification_area/testtray.c
@@ -162,9 +162,15 @@ create_tray_on_screen (GdkScreen *screen,
label = gtk_label_new_with_mnemonic ("_Orientation:");
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ combo = gtk_combo_box_text_new ();
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "Horizontal");
+ gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), "Vertical");
+#else
combo = gtk_combo_box_new_text ();
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "Horizontal");
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), "Vertical");
+#endif
g_signal_connect (combo, "changed",
G_CALLBACK (orientation_changed_cb), data);
gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
diff --git a/applets/wncklet/showdesktop.c b/applets/wncklet/showdesktop.c
index 3b961745..bdf4d568 100644
--- a/applets/wncklet/showdesktop.c
+++ b/applets/wncklet/showdesktop.c
@@ -30,7 +30,8 @@
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
-#include <libwnck/screen.h>
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
+#include <libwnck/libwnck.h>
#include "wncklet.h"
#include "showdesktop.h"
diff --git a/applets/wncklet/window-list.c b/applets/wncklet/window-list.c
index 60b0b177..e24d6eb6 100644
--- a/applets/wncklet/window-list.c
+++ b/applets/wncklet/window-list.c
@@ -19,9 +19,15 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
#include <libwnck/libwnck.h>
#include <gio/gio.h>
+#if GTK_CHECK_VERSION (3, 0, 0)
+#define MATE_DESKTOP_USE_UNSTABLE_API
+#include <libmate-desktop/mate-desktop-utils.h>
+#endif
+
#include "wncklet.h"
#include "window-list.h"
@@ -55,7 +61,7 @@ typedef struct {
GSettings* settings;
} TasklistData;
-static void callSystemMonitor(GtkAction* action, TasklistData* tasklist);
+static void call_system_monitor(GtkAction* action, TasklistData* tasklist);
static void display_properties_dialog(GtkAction* action, TasklistData* tasklist);
static void display_help_dialog(GtkAction* action, TasklistData* tasklist);
static void display_about_dialog(GtkAction* action, TasklistData* tasklist);
@@ -121,7 +127,11 @@ static void applet_change_orient(MatePanelApplet* applet, MatePanelAppletOrient
tasklist_update(tasklist);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, cairo_pattern_t* pattern, TasklistData* tasklist)
+#else
static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, GdkPixmap* pixmap, TasklistData* tasklist)
+#endif
{
switch (type)
{
@@ -157,7 +167,7 @@ static void destroy_tasklist(GtkWidget* widget, TasklistData* tasklist)
/* TODO: this is sad, should be used a function to retrieve applications from
* .desktop or some like that. */
-static const char* listOfSystemMonitors[] = {
+static const char* system_monitors[] = {
"mate-system-monitor",
"gnome-system-monitor",
};
@@ -169,7 +179,7 @@ static const GtkActionEntry tasklist_menu_actions[] = {
N_("_System Monitor"),
NULL,
NULL,
- G_CALLBACK(callSystemMonitor)
+ G_CALLBACK(call_system_monitor)
},
{
"TasklistPreferences",
@@ -415,7 +425,11 @@ gboolean window_list_applet_fill(MatePanelApplet* applet)
break;
}
+#if WNCK_CHECK_VERSION (2, 91, 6)
+ tasklist->tasklist = wnck_tasklist_new();
+#else
tasklist->tasklist = wnck_tasklist_new(NULL);
+#endif
#if WNCK_CHECK_VERSION (3, 4, 6)
wnck_tasklist_set_orientation (tasklist->tasklist, tasklist->orientation);
@@ -448,9 +462,9 @@ gboolean window_list_applet_fill(MatePanelApplet* applet)
char* programpath;
int i;
- for (i = 0; i < G_N_ELEMENTS(listOfSystemMonitors); i += 1)
+ for (i = 0; i < G_N_ELEMENTS(system_monitors); i += 1)
{
- programpath = g_find_program_in_path(listOfSystemMonitors[i]);
+ programpath = g_find_program_in_path(system_monitors[i]);
if (programpath != NULL)
{
@@ -488,26 +502,33 @@ gboolean window_list_applet_fill(MatePanelApplet* applet)
return TRUE;
}
-static void callSystemMonitor(GtkAction* action, TasklistData* tasklist)
+static void call_system_monitor(GtkAction* action, TasklistData* tasklist)
{
+#if !GTK_CHECK_VERSION (3, 0, 0)
char* argv[2] = {NULL, NULL};
+#endif
char* programpath;
int i;
- for (i = 0; i < G_N_ELEMENTS(listOfSystemMonitors); i += 1)
+ for (i = 0; i < G_N_ELEMENTS(system_monitors); i += 1)
{
- programpath = g_find_program_in_path(listOfSystemMonitors[i]);
-
+ programpath = g_find_program_in_path(system_monitors[i]);
+
if (programpath != NULL)
{
g_free(programpath);
-
- argv[0] = listOfSystemMonitors[i];
-
+
+#if GTK_CHECK_VERSION (3, 0, 0)
+ mate_gdk_spawn_command_line_on_screen(gtk_widget_get_screen(tasklist->applet),
+ system_monitors[i],
+ NULL);
+#else
+ argv[0] = system_monitors[i];
gdk_spawn_on_screen(gtk_widget_get_screen(tasklist->applet), NULL, argv, NULL,
G_SPAWN_SEARCH_PATH,
NULL, NULL, NULL, NULL);
-
+#endif
+
return;
}
}
diff --git a/applets/wncklet/window-menu.c b/applets/wncklet/window-menu.c
index b3133946..cef49657 100644
--- a/applets/wncklet/window-menu.c
+++ b/applets/wncklet/window-menu.c
@@ -34,8 +34,12 @@
#include <glib/gi18n.h>
#include <gdk/gdkkeysyms.h>
+#if GTK_CHECK_VERSION (3, 0, 0)
+#include <gdk/gdkkeysyms-compat.h>
+#endif
-#include <libwnck/selector.h>
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
+#include <libwnck/libwnck.h>
#include "wncklet.h"
#include "window-menu.h"
@@ -115,12 +119,34 @@ static void window_menu_destroy(GtkWidget* widget, WindowMenu* window_menu)
g_free(window_menu);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static gboolean window_menu_on_draw(GtkWidget* widget, cairo_t* cr, gpointer data)
+#else
static gboolean window_menu_on_expose(GtkWidget* widget, GdkEventExpose* event, gpointer data)
+#endif
{
WindowMenu* window_menu = data;
if (gtk_widget_has_focus(window_menu->applet))
- gtk_paint_focus(gtk_widget_get_style(widget), gtk_widget_get_window(widget), gtk_widget_get_state(widget), NULL, widget, "menu-applet", 0, 0, -1, -1);
+ gtk_paint_focus(gtk_widget_get_style(widget),
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cr,
+#else
+ gtk_widget_get_window(widget),
+#endif
+ gtk_widget_get_state(widget),
+#if !GTK_CHECK_VERSION (3, 0, 0)
+ NULL,
+#endif
+ widget,
+ "menu-applet",
+ 0, 0,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
+#else
+ -1, -1);
+#endif
return FALSE;
}
@@ -201,12 +227,14 @@ static gboolean window_menu_key_press_event(GtkWidget* widget, GdkEventKey* even
*/
menu_shell = GTK_MENU_SHELL(selector);
+#if !GTK_CHECK_VERSION (3, 0, 0)
if (!menu_shell->active)
{
gtk_grab_add(GTK_WIDGET(menu_shell));
menu_shell->have_grab = TRUE;
menu_shell->active = TRUE;
}
+#endif
gtk_menu_shell_select_first(menu_shell, FALSE);
return TRUE;
@@ -261,7 +289,11 @@ gboolean window_menu_applet_fill(MatePanelApplet* applet)
g_signal_connect_after(G_OBJECT(window_menu->applet), "focus-in-event", G_CALLBACK(gtk_widget_queue_draw), window_menu);
g_signal_connect_after(G_OBJECT(window_menu->applet), "focus-out-event", G_CALLBACK(gtk_widget_queue_draw), window_menu);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ g_signal_connect_after(G_OBJECT(window_menu->selector), "draw", G_CALLBACK(window_menu_on_draw), window_menu);
+#else
g_signal_connect_after(G_OBJECT(window_menu->selector), "expose-event", G_CALLBACK(window_menu_on_expose), window_menu);
+#endif
g_signal_connect(G_OBJECT(window_menu->selector), "button_press_event", G_CALLBACK(filter_button_press), window_menu);
diff --git a/applets/wncklet/wncklet.c b/applets/wncklet/wncklet.c
index e7c37bbc..d17c2ee0 100644
--- a/applets/wncklet/wncklet.c
+++ b/applets/wncklet/wncklet.c
@@ -30,8 +30,8 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-#include <libwnck/screen.h>
-#include <libwnck/util.h>
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
+#include <libwnck/libwnck.h>
#include "wncklet.h"
#include "window-menu.h"
diff --git a/applets/wncklet/wncklet.h b/applets/wncklet/wncklet.h
index 4a5ff11a..a2230536 100644
--- a/applets/wncklet/wncklet.h
+++ b/applets/wncklet/wncklet.h
@@ -24,7 +24,7 @@
#ifndef __WNCKLET_H__
#define __WNCKLET_H__
-#include <libwnck/screen.h>
+#include <libwnck/libwnck.h>
#include <glib.h>
#include <gtk/gtk.h>
diff --git a/applets/wncklet/workspace-switcher.c b/applets/wncklet/workspace-switcher.c
index ad747516..29a386e4 100644
--- a/applets/wncklet/workspace-switcher.c
+++ b/applets/wncklet/workspace-switcher.c
@@ -21,9 +21,12 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
+#define WNCK_I_KNOW_THIS_IS_UNSTABLE
#include <libwnck/libwnck.h>
#include <gio/gio.h>
+#include <libmate-desktop/mate-gsettings.h>
+
#include "workspace-switcher.h"
#include "wncklet.h"
@@ -192,7 +195,11 @@ static void applet_change_orient(MatePanelApplet* applet, MatePanelAppletOrient
gtk_label_set_text(GTK_LABEL(pager->label_row_col), pager->orientation == GTK_ORIENTATION_HORIZONTAL ? _("rows") : _("columns"));
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, cairo_pattern_t *pattern, PagerData* pager)
+#else
static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, GdkPixmap* pixmap, PagerData* pager)
+#endif
{
/* taken from the TrashApplet */
GtkRcStyle *rc_style;
@@ -204,6 +211,10 @@ static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBac
gtk_widget_modify_style (GTK_WIDGET (pager->pager), rc_style);
g_object_unref (rc_style);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ wnck_pager_set_shadow_type (WNCK_PAGER (pager->pager),
+ type == PANEL_NO_BACKGROUND ? GTK_SHADOW_NONE : GTK_SHADOW_IN);
+#else
switch (type)
{
case PANEL_COLOR_BACKGROUND:
@@ -223,6 +234,7 @@ static void applet_change_background(MatePanelApplet* applet, MatePanelAppletBac
default:
break;
}
+#endif
}
static gboolean applet_scroll(MatePanelApplet* applet, GdkEventScroll* event, PagerData* pager)
@@ -517,7 +529,11 @@ gboolean workspace_switcher_applet_fill(MatePanelApplet* applet)
break;
}
+#if WNCK_CHECK_VERSION (2, 91, 6)
+ pager->pager = wnck_pager_new();
+#else
pager->pager = wnck_pager_new(NULL);
+#endif
pager->screen = NULL;
pager->wm = PAGER_WM_UNKNOWN;
wnck_pager_set_shadow_type(WNCK_PAGER(pager->pager), GTK_SHADOW_IN);
@@ -669,10 +685,12 @@ static void workspace_destroyed(WnckScreen* screen, WnckWorkspace* space, PagerD
static void num_workspaces_value_changed(GtkSpinButton* button, PagerData* pager)
{
+#if !GTK_CHECK_VERSION (3, 0, 0)
/* Slow down a bit after the first change, since it's moving really to
* fast. See bug #336731 for background.
* FIXME: remove this if bug 410520 gets fixed. */
button->timer_step = 0.2;
+#endif
wnck_screen_change_workspace_count(pager->screen, gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(pager->num_workspaces_spin)));
}
@@ -747,6 +765,10 @@ static void close_dialog(GtkWidget* button, gpointer data)
{
PagerData* pager = data;
GtkTreeViewColumn* col;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GtkCellArea *area;
+ GtkCellEditable *edit_widget;
+#endif
/* This is a hack. The "editable" signal for GtkCellRenderer is emitted
only on button press or focus cycle. Hence when the user changes the
@@ -757,8 +779,15 @@ static void close_dialog(GtkWidget* button, gpointer data)
col = gtk_tree_view_get_column(GTK_TREE_VIEW(pager->workspaces_tree), 0);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (col));
+ edit_widget = gtk_cell_area_get_edit_widget (area);
+ if (edit_widget)
+ gtk_cell_editable_editing_done (edit_widget);
+#else
if (col->editable_widget != NULL && GTK_IS_CELL_EDITABLE(col->editable_widget))
gtk_cell_editable_editing_done(col->editable_widget);
+#endif
gtk_widget_destroy(pager->properties_dialog);
}
@@ -770,7 +799,7 @@ setup_sensitivity(PagerData* pager, GtkBuilder* builder, const char* wid1, const
{
GtkWidget* w;
- if (g_settings_is_writable(settings, key))
+ if ((settings != NULL) && g_settings_is_writable(settings, key))
{
return;
}
@@ -803,11 +832,13 @@ static void setup_dialog(GtkBuilder* builder, PagerData* pager)
GtkTreeViewColumn* column;
GtkCellRenderer* cell;
int nr_ws, i;
- GSettings *marco_general_settings;
- GSettings *marco_workspaces_settings;
+ GSettings *marco_general_settings = NULL;
+ GSettings *marco_workspaces_settings = NULL;
- marco_general_settings = g_settings_new (MARCO_GENERAL_SCHEMA);
- marco_workspaces_settings = g_settings_new (MARCO_WORSKACES_SCHEMA);
+ if (mate_gsettings_schema_exists(MARCO_GENERAL_SCHEMA))
+ marco_general_settings = g_settings_new (MARCO_GENERAL_SCHEMA);
+ if (mate_gsettings_schema_exists(MARCO_WORSKACES_SCHEMA))
+ marco_workspaces_settings = g_settings_new (MARCO_WORSKACES_SCHEMA);
pager->workspaces_frame = WID("workspaces_frame");
pager->workspace_names_label = WID("workspace_names_label");
@@ -833,8 +864,10 @@ static void setup_dialog(GtkBuilder* builder, PagerData* pager)
pager->workspaces_tree = WID("workspaces_tree_view");
setup_sensitivity(pager, builder, "workspaces_tree_view", NULL, NULL, marco_workspaces_settings, WORKSPACE_NAME /* key */);
- g_object_unref (marco_general_settings);
- g_object_unref (marco_workspaces_settings);
+ if (marco_general_settings != NULL)
+ g_object_unref (marco_general_settings);
+ if (marco_workspaces_settings != NULL)
+ g_object_unref (marco_workspaces_settings);
/* Wrap workspaces: */