diff options
63 files changed, 2716 insertions, 198 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: */ diff --git a/configure.ac b/configure.ac index a4a2d9f3..22738b1e 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([mate-panel], [1.6.1], [https://github.com/mate-desktop/mate-panel/issues], +AC_INIT([mate-panel], [1.7.0], [https://github.com/mate-desktop/mate-panel/issues], [mate-panel], [http://www.mate-desktop.org]) AC_CONFIG_HEADERS(config.h) AM_INIT_AUTOMAKE([1.9 no-dist-gzip dist-xz tar-ustar -Wno-portability]) @@ -92,8 +92,8 @@ case "$with_gtk" in LIBCANBERRA_API_VERSION=3 LIBWNCK_API_VERSION=3.0 LIBWNCK_REQUIRED=3.0.0 - WEATHER_LIB=gweather-3.0 - WEATHER_REQUIRED=3.8.0 + WEATHER_LIB=mateweather + WEATHER_REQUIRED=1.7.0 ;; esac @@ -128,7 +128,7 @@ PKG_CHECK_MODULES(NOTIFICATION_AREA, gtk+-$GTK_API_VERSION >= $GTK_REQUIRED) AC_SUBST(NOTIFICATION_AREA_CFLAGS) AC_SUBST(NOTIFICATION_AREA_LIBS) -PKG_CHECK_MODULES(WNCKLET, gtk+-$GTK_API_VERSION >= $GTK_REQUIRED libwnck-$LIBWNCK_API_VERSION >= $LIBWNCK_REQUIRED) +PKG_CHECK_MODULES(WNCKLET, gtk+-$GTK_API_VERSION >= $GTK_REQUIRED libwnck-$LIBWNCK_API_VERSION >= $LIBWNCK_REQUIRED mate-desktop-2.0 >= $LIBMATE_DESKTOP_REQUIRED) AC_SUBST(WNCKLET_CFLAGS) AC_SUBST(WNCKLET_LIBS) diff --git a/libmate-panel-applet/mate-panel-applet.c b/libmate-panel-applet/mate-panel-applet.c index 9435709b..33ec6f15 100644 --- a/libmate-panel-applet/mate-panel-applet.c +++ b/libmate-panel-applet/mate-panel-applet.c @@ -33,10 +33,15 @@ #include <glib/gi18n-lib.h> #include <cairo.h> +#include <cairo-xlib.h> #include <gdk/gdk.h> #include <gdk/gdkx.h> #include <gdk/gdkkeysyms.h> #include <gtk/gtk.h> +#if GTK_CHECK_VERSION (3, 0, 0) +#include <gtk/gtkx.h> +#include <gdk/gdkkeysyms-compat.h> +#endif #include <X11/Xatom.h> #include "mate-panel-applet.h" @@ -557,7 +562,11 @@ mate_panel_applet_request_focus (MatePanelApplet *applet, display = gdk_screen_get_display (screen); xdisplay = GDK_DISPLAY_XDISPLAY (display); +#if GTK_CHECK_VERSION (3, 0, 0) + xroot = GDK_WINDOW_XID (root); +#else xroot = GDK_WINDOW_XWINDOW (root); +#endif mate_panel_applet_init_atoms (xdisplay); @@ -804,7 +813,11 @@ mate_panel_applet_position_menu (GtkMenu *menu, screen = gtk_window_get_screen (GTK_WINDOW (applet->priv->plug)); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_widget_get_preferred_size (GTK_WIDGET (menu), &requisition, NULL); +#else gtk_widget_size_request (GTK_WIDGET (menu), &requisition); +#endif gdk_window_get_origin (gtk_widget_get_window (widget), &menu_x, &menu_y); gtk_widget_get_pointer (widget, &pointer_x, &pointer_y); @@ -916,9 +929,15 @@ mate_panel_applet_button_event (GtkWidget *widget, } xevent.xbutton.display = GDK_WINDOW_XDISPLAY (window); +#if GTK_CHECK_VERSION (3, 0, 0) + xevent.xbutton.window = GDK_WINDOW_XID (socket_window); + xevent.xbutton.root = GDK_WINDOW_XID (gdk_screen_get_root_window + (gdk_window_get_screen (window))); +#else xevent.xbutton.window = GDK_WINDOW_XWINDOW (socket_window); xevent.xbutton.root = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (gdk_drawable_get_screen (window))); +#endif /* * FIXME: the following might cause * big problems for non-GTK apps @@ -934,7 +953,11 @@ mate_panel_applet_button_event (GtkWidget *widget, gdk_error_trap_push (); XSendEvent (GDK_WINDOW_XDISPLAY (window), +#if GTK_CHECK_VERSION (3, 0, 0) + GDK_WINDOW_XID (socket_window), +#else GDK_WINDOW_XWINDOW (socket_window), +#endif False, NoEventMask, &xevent); gdk_flush (); @@ -982,13 +1005,76 @@ mate_panel_applet_popup_menu (GtkWidget *widget) return TRUE; } +#if GTK_CHECK_VERSION (3, 0, 0) +static void +mate_panel_applet_get_preferred_width (GtkWidget *widget, + int *minimum_width, + int *natural_width) +{ + int focus_width = 0; + + GTK_WIDGET_CLASS (mate_panel_applet_parent_class)->get_preferred_width (widget, + minimum_width, + natural_width); + if (!mate_panel_applet_can_focus (widget)) + return; + + /* We are deliberately ignoring focus-padding here to + * save valuable panel real estate. + */ + gtk_widget_style_get (widget, + "focus-line-width", &focus_width, + NULL); + + *minimum_width += 2 * focus_width; + *natural_width += 2 * focus_width; +} + +static void +mate_panel_applet_get_preferred_height (GtkWidget *widget, + int *minimum_height, + int *natural_height) +{ + int focus_width = 0; + + GTK_WIDGET_CLASS (mate_panel_applet_parent_class)->get_preferred_height (widget, + minimum_height, + natural_height); + if (!mate_panel_applet_can_focus (widget)) + return; + + /* We are deliberately ignoring focus-padding here to + * save valuable panel real estate. + */ + gtk_widget_style_get (widget, + "focus-line-width", &focus_width, + NULL); + + *minimum_height += 2 * focus_width; + *natural_height += 2 * focus_width; +} + +static GtkSizeRequestMode +mate_panel_applet_get_request_mode (GtkWidget *widget) +{ + MatePanelApplet *applet = MATE_PANEL_APPLET (widget); + MatePanelAppletOrient orientation; + + orientation = mate_panel_applet_get_orient (applet); + if (orientation == MATE_PANEL_APPLET_ORIENT_UP || + orientation == MATE_PANEL_APPLET_ORIENT_DOWN) + return GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH; + + return GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT; +} +#else static void mate_panel_applet_size_request (GtkWidget *widget, GtkRequisition *requisition) { int focus_width = 0; GTK_WIDGET_CLASS (mate_panel_applet_parent_class)->size_request (widget, - requisition); + requisition); if (!mate_panel_applet_can_focus (widget)) return; @@ -1004,6 +1090,7 @@ mate_panel_applet_size_request (GtkWidget *widget, GtkRequisition *requisition) requisition->width += 2 * focus_width; requisition->height += 2 * focus_width; } +#endif static void mate_panel_applet_size_allocate (GtkWidget *widget, @@ -1064,22 +1151,39 @@ mate_panel_applet_size_allocate (GtkWidget *widget, } } +#if GTK_CHECK_VERSION (3, 0, 0) +static gboolean mate_panel_applet_draw(GtkWidget* widget, cairo_t* cr) +#else static gboolean mate_panel_applet_expose(GtkWidget* widget, GdkEventExpose* event) +#endif { +#if !GTK_CHECK_VERSION (3, 0, 0) GtkAllocation allocation; +#endif int border_width; int focus_width = 0; int x, y, width, height; g_return_val_if_fail (PANEL_IS_APPLET (widget), FALSE); +#if !GTK_CHECK_VERSION (3, 0, 0) g_return_val_if_fail (event != NULL, FALSE); +#endif +#if GTK_CHECK_VERSION (3, 0, 0) + GTK_WIDGET_CLASS (mate_panel_applet_parent_class)->draw(widget, cr); +#else GTK_WIDGET_CLASS (mate_panel_applet_parent_class)->expose_event(widget, event); +#endif if (!gtk_widget_has_focus (widget)) return FALSE; +#if GTK_CHECK_VERSION (3, 0, 0) + width = gtk_widget_get_allocated_width (widget); + height = gtk_widget_get_allocated_height (widget); +#else gtk_widget_get_allocation(widget, &allocation); +#endif /* * We are deliberately ignoring focus-padding here to @@ -1091,16 +1195,31 @@ static gboolean mate_panel_applet_expose(GtkWidget* widget, GdkEventExpose* even border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); +#if GTK_CHECK_VERSION (3, 0, 0) + x = 0; + y = 0; + + width -= 2 * border_width; + height -= 2 * border_width; +#else x = allocation.x; y = allocation.y; width = allocation.width - 2 * border_width; height = allocation.height - 2 * border_width; +#endif 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), - &event->area, widget, "mate_panel_applet", +#if !GTK_CHECK_VERSION (3, 0, 0) + &event->area, +#endif + widget, "mate_panel_applet", x, y, width, height); return FALSE; @@ -1174,7 +1293,11 @@ mate_panel_applet_parse_color (const gchar *color_str, static gboolean mate_panel_applet_parse_pixmap_str (const char *str, +#if GTK_CHECK_VERSION (3, 0, 0) + Window *xid, +#else GdkNativeWindow *xid, +#endif int *x, int *y) { @@ -1216,16 +1339,49 @@ mate_panel_applet_parse_pixmap_str (const char *str, return FALSE; } +#if GTK_CHECK_VERSION (3, 0, 0) +static cairo_surface_t * +mate_panel_applet_create_foreign_surface_for_display (GdkDisplay *display, + GdkVisual *visual, + Window xid) +{ + Window window; + gint x, y; + guint width, height, border, depth; + + if (!XGetGeometry (GDK_DISPLAY_XDISPLAY (display), xid, &window, + &x, &y, &width, &height, &border, &depth)) + return NULL; + + return cairo_xlib_surface_create (GDK_DISPLAY_XDISPLAY (display), + xid, gdk_x11_visual_get_xvisual (visual), + width, height); +} + +static cairo_pattern_t * +mate_panel_applet_get_pattern_from_pixmap (MatePanelApplet *applet, +#else static GdkPixmap * mate_panel_applet_get_pixmap (MatePanelApplet *applet, +#endif +#if GTK_CHECK_VERSION (3, 0, 0) + Window xid, +#else GdkNativeWindow xid, +#endif int x, int y) { +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_surface_t *background; + cairo_surface_t *surface; + cairo_matrix_t matrix; +#else gboolean display_grabbed; GdkPixmap *pixmap; GdkDisplay *display; GdkPixmap *retval; +#endif GdkWindow *window; int width; int height; @@ -1237,11 +1393,28 @@ mate_panel_applet_get_pixmap (MatePanelApplet *applet, if (!gtk_widget_get_realized (GTK_WIDGET (applet))) return NULL; +#if !GTK_CHECK_VERSION (3, 0, 0) display = gdk_display_get_default (); display_grabbed = FALSE; +#endif window = gtk_widget_get_window (GTK_WIDGET (applet)); +#if GTK_CHECK_VERSION (3, 0, 0) + gdk_error_trap_push (); + background = mate_panel_applet_create_foreign_surface_for_display (gdk_window_get_display (window), + gdk_window_get_visual (window), + xid); + gdk_error_trap_pop_ignored (); + + /* background can be NULL if the user changes the background very fast. + * We'll get the next update, so it's not a big deal. */ + if (!background || cairo_surface_status (background) != CAIRO_STATUS_SUCCESS) { + if (background) + cairo_surface_destroy (background); + return NULL; + } +#else pixmap = gdk_pixmap_lookup_for_display (display, xid); if (pixmap) g_object_ref (pixmap); @@ -1258,20 +1431,49 @@ mate_panel_applet_get_pixmap (MatePanelApplet *applet, gdk_x11_display_ungrab (display); return NULL; } +#endif - #if GTK_CHECK_VERSION(3, 0, 0) - width = gdk_window_get_width(window); - height = gdk_window_get_height(window); - #else - gdk_drawable_get_size(GDK_DRAWABLE(window), &width, &height); - #endif +#if GTK_CHECK_VERSION(3, 0, 0) + width = gdk_window_get_width(window); + height = gdk_window_get_height(window); +#else + gdk_drawable_get_size(GDK_DRAWABLE(window), &width, &height); +#endif +#if GTK_CHECK_VERSION (3, 0, 0) + gdk_error_trap_push (); + cr = cairo_create (surface); + cairo_set_source_surface (cr, background, -x, -y); + cairo_rectangle (cr, 0, 0, width, height); + cairo_fill (cr); + gdk_error_trap_pop_ignored (); +#else retval = gdk_pixmap_new (window, width, height, -1); +#endif +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_surface_destroy (background); + pattern = NULL; +#else /* the pixmap has no colormap, and we need one */ gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), gdk_drawable_get_colormap (window)); +#endif + +#if GTK_CHECK_VERSION (3, 0, 0) + if (cairo_status (cr) == CAIRO_STATUS_SUCCESS) { + pattern = cairo_pattern_create_for_surface (surface); + cairo_matrix_init_translate (&matrix, 0, 0); + cairo_matrix_scale (&matrix, width, height); + cairo_pattern_set_matrix (pattern, &matrix); + cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD); + } + cairo_destroy (cr); + cairo_surface_destroy (surface); + + return pattern; +#else cr = gdk_cairo_create (GDK_DRAWABLE (retval)); gdk_cairo_set_source_pixmap (cr, pixmap, -x, -y); pattern = cairo_get_source (cr); @@ -1288,12 +1490,17 @@ mate_panel_applet_get_pixmap (MatePanelApplet *applet, gdk_x11_display_ungrab (display); return retval; +#endif } static MatePanelAppletBackgroundType mate_panel_applet_handle_background_string (MatePanelApplet *applet, GdkColor *color, +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_pattern_t **pattern) +#else GdkPixmap **pixmap) +#endif { MatePanelAppletBackgroundType retval; char **elements; @@ -1321,10 +1528,18 @@ mate_panel_applet_handle_background_string (MatePanelApplet *applet, retval = PANEL_COLOR_BACKGROUND; } else if (elements [0] && !strcmp (elements [0], "pixmap")) { +#if GTK_CHECK_VERSION (3, 0, 0) + Window pixmap_id; +#else GdkNativeWindow pixmap_id; +#endif int x, y; +#if GTK_CHECK_VERSION (3, 0, 0) + g_return_val_if_fail (pattern != NULL, PANEL_NO_BACKGROUND); +#else g_return_val_if_fail (pixmap != NULL, PANEL_NO_BACKGROUND); +#endif if (!mate_panel_applet_parse_pixmap_str (elements [1], &pixmap_id, &x, &y)) { g_warning ("Incomplete '%s' background type received: %s", @@ -1334,12 +1549,21 @@ mate_panel_applet_handle_background_string (MatePanelApplet *applet, return PANEL_NO_BACKGROUND; } +#if GTK_CHECK_VERSION (3, 0, 0) + *pattern = mate_panel_applet_get_pattern_from_pixmap (applet, pixmap_id, x, y); + if (!*pattern) { + g_warning ("Failed to get pattern %s", elements [1]); + g_strfreev (elements); + return PANEL_NO_BACKGROUND; + } +#else *pixmap = mate_panel_applet_get_pixmap (applet, pixmap_id, x, y); if (!*pixmap) { g_warning ("Failed to get pixmap %s", elements [1]); g_strfreev (elements); return PANEL_NO_BACKGROUND; } +#endif retval = PANEL_PIXMAP_BACKGROUND; } else @@ -1353,17 +1577,30 @@ mate_panel_applet_handle_background_string (MatePanelApplet *applet, MatePanelAppletBackgroundType mate_panel_applet_get_background (MatePanelApplet *applet, GdkColor *color, +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_pattern_t **pattern) +#else GdkPixmap **pixmap) +#endif { g_return_val_if_fail (PANEL_IS_APPLET (applet), PANEL_NO_BACKGROUND); /* initial sanity */ +#if GTK_CHECK_VERSION (3, 0, 0) + if (pattern != NULL) + *pattern = NULL; +#else if (pixmap != NULL) *pixmap = NULL; +#endif if (color != NULL) memset (color, 0, sizeof (GdkColor)); +#if GTK_CHECK_VERSION (3, 0, 0) + return mate_panel_applet_handle_background_string (applet, color, pattern); +#else return mate_panel_applet_handle_background_string (applet, color, pixmap); +#endif } static void @@ -1388,7 +1625,11 @@ static void mate_panel_applet_update_background_for_widget (GtkWidget *widget, MatePanelAppletBackgroundType type, GdkColor *color, +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_pattern_t *pattern) +#else GdkPixmap *pixmap) +#endif { GtkRcStyle *rc_style; GtkStyle *style; @@ -1407,9 +1648,15 @@ mate_panel_applet_update_background_for_widget (GtkWidget *widge break; case PANEL_PIXMAP_BACKGROUND: style = gtk_style_copy (gtk_widget_get_style (widget)); +#if GTK_CHECK_VERSION (3, 0, 0) + if (style->background[GTK_STATE_NORMAL]) + cairo_pattern_destroy (style->background[GTK_STATE_NORMAL]); + style->background[GTK_STATE_NORMAL] = cairo_pattern_reference (pattern); +#else if (style->bg_pixmap[GTK_STATE_NORMAL]) g_object_unref (style->bg_pixmap[GTK_STATE_NORMAL]); style->bg_pixmap[GTK_STATE_NORMAL] = g_object_ref (pixmap); +#endif gtk_widget_set_style (widget, style); g_object_unref (style); break; @@ -1424,6 +1671,15 @@ mate_panel_applet_handle_background (MatePanelApplet *applet) { MatePanelAppletBackgroundType type; GdkColor color; +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_pattern_t *pattern; + + type = mate_panel_applet_get_background (applet, &color, &pattern); + + if (applet->priv->background_widget) + mate_panel_applet_update_background_for_widget (applet->priv->background_widget, + type, &color, pattern); +#else GdkPixmap *pixmap; type = mate_panel_applet_get_background (applet, &color, &pixmap); @@ -1431,6 +1687,7 @@ mate_panel_applet_handle_background (MatePanelApplet *applet) if (applet->priv->background_widget) mate_panel_applet_update_background_for_widget (applet->priv->background_widget, type, &color, pixmap); +#endif switch (type) { case PANEL_NO_BACKGROUND: @@ -1446,9 +1703,17 @@ mate_panel_applet_handle_background (MatePanelApplet *applet) case PANEL_PIXMAP_BACKGROUND: g_signal_emit (G_OBJECT (applet), mate_panel_applet_signals [CHANGE_BACKGROUND], +#if GTK_CHECK_VERSION (3, 0, 0) + 0, PANEL_PIXMAP_BACKGROUND, NULL, pattern); +#else 0, PANEL_PIXMAP_BACKGROUND, NULL, pixmap); +#endif +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_pattern_destroy (pattern); +#else g_object_unref (pixmap); +#endif break; default: g_assert_not_reached (); @@ -1707,7 +1972,9 @@ static void mate_panel_applet_class_init (MatePanelAppletClass *klass) { GObjectClass *gobject_class = (GObjectClass *) klass; +#if !GTK_CHECK_VERSION (3, 0, 0) GtkObjectClass *object_class = (GtkObjectClass *) klass; +#endif GtkWidgetClass *widget_class = (GtkWidgetClass *) klass; GtkBindingSet *binding_set; @@ -1718,9 +1985,16 @@ mate_panel_applet_class_init (MatePanelAppletClass *klass) widget_class->button_press_event = mate_panel_applet_button_press; widget_class->button_release_event = mate_panel_applet_button_release; +#if GTK_CHECK_VERSION (3, 0, 0) + widget_class->get_request_mode = mate_panel_applet_get_request_mode; + widget_class->get_preferred_width = mate_panel_applet_get_preferred_width; + widget_class->get_preferred_height = mate_panel_applet_get_preferred_height; + widget_class->draw = mate_panel_applet_draw; +#else widget_class->size_request = mate_panel_applet_size_request; - widget_class->size_allocate = mate_panel_applet_size_allocate; widget_class->expose_event = mate_panel_applet_expose; +#endif + widget_class->size_allocate = mate_panel_applet_size_allocate; widget_class->focus = mate_panel_applet_focus; widget_class->realize = mate_panel_applet_realize; widget_class->popup_menu = mate_panel_applet_popup_menu; @@ -1845,7 +2119,11 @@ mate_panel_applet_class_init (MatePanelAppletClass *klass) 3, PANEL_TYPE_MATE_PANEL_APPLET_BACKGROUND_TYPE, GDK_TYPE_COLOR, +#if GTK_CHECK_VERSION (3, 0, 0) + CAIRO_GOBJECT_TYPE_PATTERN); +#else GDK_TYPE_PIXMAP); +#endif mate_panel_applet_signals [MOVE_FOCUS_OUT_OF_APPLET] = g_signal_new ("move_focus_out_of_applet", @@ -1859,7 +2137,11 @@ mate_panel_applet_class_init (MatePanelAppletClass *klass) 1, GTK_TYPE_DIRECTION_TYPE); +#if GTK_CHECK_VERSION (3, 0, 0) + binding_set = gtk_binding_set_by_class (gobject_class); +#else binding_set = gtk_binding_set_by_class (object_class); +#endif add_tab_bindings (binding_set, 0, GTK_DIR_TAB_FORWARD); add_tab_bindings (binding_set, GDK_SHIFT_MASK, GTK_DIR_TAB_BACKWARD); add_tab_bindings (binding_set, GDK_CONTROL_MASK, GTK_DIR_TAB_FORWARD); @@ -2142,13 +2424,21 @@ mate_panel_applet_set_background_widget (MatePanelApplet *applet, if (widget) { MatePanelAppletBackgroundType type; GdkColor color; +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_pattern_t *pattern; + type = mate_panel_applet_get_background (applet, &color, &pattern); + mate_panel_applet_update_background_for_widget (widget, type, + &color, pattern); + if (type == PANEL_PIXMAP_BACKGROUND) + cairo_pattern_destroy (pattern); +#else GdkPixmap *pixmap; - type = mate_panel_applet_get_background (applet, &color, &pixmap); mate_panel_applet_update_background_for_widget (widget, type, &color, pixmap); if (type == PANEL_PIXMAP_BACKGROUND) g_object_unref (pixmap); +#endif } } diff --git a/libmate-panel-applet/mate-panel-applet.h b/libmate-panel-applet/mate-panel-applet.h index dadc92bc..ed089c22 100644 --- a/libmate-panel-applet/mate-panel-applet.h +++ b/libmate-panel-applet/mate-panel-applet.h @@ -27,6 +27,8 @@ #include <glib.h> #include <gtk/gtk.h> +#include <cairo.h> +#include <cairo-gobject.h> #ifdef __cplusplus extern "C" { @@ -78,7 +80,11 @@ struct _MatePanelAppletClass { void (*change_size) (MatePanelApplet* applet, guint size); +#if GTK_CHECK_VERSION (3, 0, 0) + void (*change_background) (MatePanelApplet *applet, cairo_pattern_t *pattern); +#else void (*change_background) (MatePanelApplet* applet, MatePanelAppletBackgroundType type, GdkColor* color, GdkPixmap* pixmap); +#endif void (*move_focus_out_of_applet) (MatePanelApplet* frame, GtkDirectionType direction); }; @@ -88,8 +94,11 @@ GtkWidget* mate_panel_applet_new(void); MatePanelAppletOrient mate_panel_applet_get_orient(MatePanelApplet* applet); guint mate_panel_applet_get_size(MatePanelApplet* applet); +#if GTK_CHECK_VERSION (3, 0, 0) +MatePanelAppletBackgroundType mate_panel_applet_get_background (MatePanelApplet *applet, /* return values */ GdkColor* color, cairo_pattern_t** pattern); +#else MatePanelAppletBackgroundType mate_panel_applet_get_background(MatePanelApplet* applet, /* return values */ GdkColor* color, GdkPixmap** pixmap); - +#endif void mate_panel_applet_set_background_widget(MatePanelApplet* applet, GtkWidget* widget); gchar* mate_panel_applet_get_preferences_path(MatePanelApplet* applet); diff --git a/libmate-panel-applet/test-dbus-applet.c b/libmate-panel-applet/test-dbus-applet.c index abcae5c0..f2033057 100644 --- a/libmate-panel-applet/test-dbus-applet.c +++ b/libmate-panel-applet/test-dbus-applet.c @@ -113,7 +113,11 @@ static void test_applet_handle_background_change (TestApplet *applet, MatePanelAppletBackgroundType type, GdkColor *color, +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_pattern_t *pattern, +#else GdkPixmap *pixmap, +#endif gpointer dummy) { GdkWindow *window = gtk_widget_get_window (applet->label); @@ -121,16 +125,29 @@ test_applet_handle_background_change (TestApplet *applet, switch (type) { case PANEL_NO_BACKGROUND: g_message ("Setting background to default"); +#if GTK_CHECK_VERSION (3, 0, 0) + gdk_window_set_background_pattern (window, NULL); +#else gdk_window_set_back_pixmap (window, NULL, FALSE); +#endif break; case PANEL_COLOR_BACKGROUND: g_message ("Setting background to #%2x%2x%2x", color->red, color->green, color->blue); +#if GTK_CHECK_VERSION (3, 0, 0) + gdk_window_set_background_pattern (window, NULL); +#else gdk_window_set_back_pixmap (window, NULL, FALSE); +#endif break; case PANEL_PIXMAP_BACKGROUND: +#if GTK_CHECK_VERSION (3, 0, 0) + g_message ("Setting background to '%p'", pattern); + gdk_window_set_background_pattern (window, pattern); +#else g_message ("Setting background to '%p'", pixmap); gdk_window_set_back_pixmap (window, pixmap, FALSE); +#endif break; default: g_assert_not_reached (); diff --git a/mate-panel/button-widget.c b/mate-panel/button-widget.c index 7748a821..2d3c29b3 100644 --- a/mate-panel/button-widget.c +++ b/mate-panel/button-widget.c @@ -115,6 +115,7 @@ make_hc_pixbuf (GdkPixbuf *pb) static void button_widget_realize(GtkWidget *widget) { +#if !GTK_CHECK_VERSION (3, 0, 0) GtkAllocation allocation; GdkWindowAttr attributes; gint attributes_mask; @@ -153,12 +154,23 @@ button_widget_realize(GtkWidget *widget) gdk_window_set_user_data (button->event_window, widget); widget->style = gtk_style_attach (widget->style, gtk_widget_get_window (widget)); +#else + gtk_widget_add_events (widget, GDK_POINTER_MOTION_MASK | + GDK_POINTER_MOTION_HINT_MASK | + GDK_KEY_PRESS_MASK); + + GTK_WIDGET_CLASS (button_widget_parent_class)->realize (widget); +#endif BUTTON_WIDGET (widget)->priv->icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget)); g_signal_connect_object (BUTTON_WIDGET (widget)->priv->icon_theme, "changed", G_CALLBACK (button_widget_icon_theme_changed), +#if GTK_CHECK_VERSION (3, 0, 0) + widget, +#else button, +#endif G_CONNECT_SWAPPED); button_widget_reload_pixbuf (BUTTON_WIDGET (widget)); @@ -167,6 +179,11 @@ button_widget_realize(GtkWidget *widget) static void button_widget_unrealize (GtkWidget *widget) { +#if GTK_CHECK_VERSION (3, 0, 0) + g_signal_handlers_disconnect_by_func (BUTTON_WIDGET (widget)->priv->icon_theme, + G_CALLBACK (button_widget_icon_theme_changed), + widget); +#else GtkButton *button; g_return_if_fail (widget != NULL); @@ -179,6 +196,7 @@ button_widget_unrealize (GtkWidget *widget) gdk_window_destroy (button->event_window); button->event_window = NULL; } +#endif GTK_WIDGET_CLASS (button_widget_parent_class)->unrealize (widget); } @@ -367,13 +385,24 @@ calc_arrow (PanelOrientation orientation, } static gboolean +#if GTK_CHECK_VERSION (3, 0, 0) +button_widget_draw (GtkWidget *widget, + cairo_t *cr) +#else button_widget_expose (GtkWidget *widget, GdkEventExpose *event) +#endif { ButtonWidget *button_widget; GtkButton *button; GdkWindow *window; +#if GTK_CHECK_VERSION (3, 0, 0) + GtkStateFlags state_flags; + int width; + int height; +#else GtkAllocation allocation; +#endif GdkRectangle area, image_bound; GtkStyle *style; int off; @@ -381,10 +410,12 @@ button_widget_expose (GtkWidget *widget, GdkPixbuf *pb = NULL; g_return_val_if_fail (BUTTON_IS_WIDGET (widget), FALSE); +#if !GTK_CHECK_VERSION (3, 0, 0) g_return_val_if_fail (event != NULL, FALSE); if (!gtk_widget_get_visible (widget) || !gtk_widget_get_mapped (widget)) return FALSE; +#endif button_widget = BUTTON_WIDGET (widget); @@ -393,12 +424,23 @@ button_widget_expose (GtkWidget *widget, button = GTK_BUTTON (widget); window = gtk_widget_get_window (widget); +#if GTK_CHECK_VERSION (3, 0, 0) + state_flags = gtk_widget_get_state_flags (widget); + width = gtk_widget_get_allocated_width (widget); + height = gtk_widget_get_allocated_height (widget); +#else gtk_widget_get_allocation (widget, &allocation); +#endif /* offset for pressed buttons */ off = (button_widget->priv->activatable && - button->in_button && button->button_down) ? +#if GTK_CHECK_VERSION (3, 0, 0) + (state_flags & GTK_STATE_FLAG_PRELIGHT) && (state_flags & GTK_STATE_FLAG_ACTIVE)) ? + BUTTON_WIDGET_DISPLACEMENT * height / 48.0 : 0; +#else + button->in_button && button->button_down) ? BUTTON_WIDGET_DISPLACEMENT * allocation.height / 48.0 : 0; +#endif if (!button_widget->priv->activatable) { pb = gdk_pixbuf_copy (button_widget->priv->pixbuf); @@ -407,7 +449,11 @@ button_widget_expose (GtkWidget *widget, 0.8, TRUE); } else if (panel_global_config_get_highlight_when_over () && +#if GTK_CHECK_VERSION (3, 0, 0) + (state_flags & GTK_STATE_FLAG_PRELIGHT || gtk_widget_has_focus (widget))) +#else (button->in_button || gtk_widget_has_focus (widget))) +#endif pb = g_object_ref (button_widget->priv->pixbuf_hc); else pb = g_object_ref (button_widget->priv->pixbuf); @@ -416,6 +462,10 @@ button_widget_expose (GtkWidget *widget, w = gdk_pixbuf_get_width (pb); h = gdk_pixbuf_get_height (pb); +#if GTK_CHECK_VERSION (3, 0, 0) + x = off + (width - w)/2; + y = off + (height - h)/2; +#else x = allocation.x + off + (allocation.width - w)/2; y = allocation.y + off + (allocation.height - h)/2; @@ -425,7 +475,14 @@ button_widget_expose (GtkWidget *widget, image_bound.height = h; area = event->area; - +#endif + +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_save (cr); + gdk_cairo_set_source_pixbuf (cr, pb, x, y); + cairo_paint (cr); + cairo_restore (cr); +#else if (gdk_rectangle_intersect (&area, &allocation, &area) && gdk_rectangle_intersect (&image_bound, &area, &image_bound)) gdk_draw_pixbuf (window, NULL, pb, @@ -434,6 +491,7 @@ button_widget_expose (GtkWidget *widget, image_bound.width, image_bound.height, GDK_RGB_DITHER_NORMAL, 0, 0); +#endif g_object_unref (pb); @@ -441,56 +499,97 @@ button_widget_expose (GtkWidget *widget, if (button_widget->priv->arrow) { GtkArrowType arrow_type; - int x, y, width, height; - - x = y = width = height = -1; arrow_type = calc_arrow (button_widget->priv->orientation, +#if GTK_CHECK_VERSION (3, 0, 0) + width, + height, + &x, + &y, + &w, + &h); +#else allocation.width, allocation.height, &x, &y, &width, &height); +#endif gtk_paint_arrow (style, +#if GTK_CHECK_VERSION (3, 0, 0) + cr, +#else window, +#endif GTK_STATE_NORMAL, GTK_SHADOW_NONE, +#if !GTK_CHECK_VERSION (3, 0, 0) NULL, +#endif widget, "panel-button", arrow_type, TRUE, +#if GTK_CHECK_VERSION (3, 0, 0) + x, y, w, h); +#else allocation.x + x, allocation.y + y, width, height); +#endif } if (button_widget->priv->dnd_highlight) { +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_save (cr); + cairo_set_line_width (cr, 1); + gdk_cairo_set_source_color (cr, &style->black); + cairo_rectangle (cr, 0.5, 0.5, width - 1, height - 1); + cairo_stroke (cr); + cairo_restore (cr); +#else gdk_draw_rectangle(window, style->black_gc, FALSE, allocation.x, allocation.y, allocation.width - 1, allocation.height - 1); +#endif } if (gtk_widget_has_focus (widget)) { gint focus_width, focus_pad; - gint x, y, width, height; gtk_widget_style_get (widget, "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL); +#if GTK_CHECK_VERSION (3, 0, 0) + x = focus_pad; + y = focus_pad; + w= width - 2 * focus_pad; + h= height - 2 * focus_pad; +#else x = allocation.x + focus_pad; y = allocation.y + focus_pad; width = allocation.width - 2 * focus_pad; height = allocation.height - 2 * focus_pad; - gtk_paint_focus (style, window, +#endif + gtk_paint_focus (style, +#if GTK_CHECK_VERSION (3, 0, 0) + cr, +#else + window, +#endif GTK_STATE_NORMAL, +#if GTK_CHECK_VERSION (3, 0, 0) + widget, "button", + x, y, w, h); +#else &event->area, widget, "button", x, y, width, height); +#endif } return FALSE; @@ -508,6 +607,28 @@ button_widget_size_request (GtkWidget *widget, } } +#if GTK_CHECK_VERSION (3, 0, 0) +static void +button_widget_get_preferred_width (GtkWidget *widget, + gint *minimum_width, + gint *natural_width) +{ + GtkRequisition req; + button_widget_size_request (widget, &req); + *minimum_width = *natural_width = req.width; +} + +static void +button_widget_get_preferred_height (GtkWidget *widget, + gint *minimum_height, + gint *natural_height) +{ + GtkRequisition req; + button_widget_size_request (widget, &req); + *minimum_height = *natural_height = req.height; +} +#endif + static void button_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation) @@ -516,6 +637,10 @@ button_widget_size_allocate (GtkWidget *widget, GtkButton *button = GTK_BUTTON (widget); int size; +#if GTK_CHECK_VERSION (3, 0, 0) + GTK_WIDGET_CLASS (button_widget_parent_class)->size_allocate (widget, allocation); +#endif + if (button_widget->priv->orientation & PANEL_HORIZONTAL_MASK) size = allocation->height; else @@ -538,6 +663,7 @@ button_widget_size_allocate (GtkWidget *widget, button_widget_reload_pixbuf (button_widget); } +#if !GTK_CHECK_VERSION (3, 0, 0) gtk_widget_set_allocation (widget, allocation); if (gtk_widget_get_realized (widget)) { @@ -547,6 +673,7 @@ button_widget_size_allocate (GtkWidget *widget, allocation->width, allocation->height); } +#endif } static void @@ -583,9 +710,19 @@ button_widget_enter_notify (GtkWidget *widget, GdkEventCrossing *event) g_return_val_if_fail (BUTTON_IS_WIDGET (widget), FALSE); +#if GTK_CHECK_VERSION (3, 0, 0) + GtkStateFlags state_flags; + in_button = state_flags & GTK_STATE_FLAG_PRELIGHT; +#else in_button = GTK_BUTTON (widget)->in_button; +#endif GTK_WIDGET_CLASS (button_widget_parent_class)->enter_notify_event (widget, event); +#if GTK_CHECK_VERSION (3, 0, 0) + state_flags = gtk_widget_get_state_flags (widget); + if (in_button != (state_flags & GTK_STATE_FLAG_PRELIGHT) && +#else if (in_button != GTK_BUTTON (widget)->in_button && +#endif panel_global_config_get_highlight_when_over ()) gtk_widget_queue_draw (widget); @@ -599,9 +736,19 @@ button_widget_leave_notify (GtkWidget *widget, GdkEventCrossing *event) g_return_val_if_fail (BUTTON_IS_WIDGET (widget), FALSE); +#if GTK_CHECK_VERSION (3, 0, 0) + GtkStateFlags state_flags; + in_button = state_flags & GTK_STATE_FLAG_PRELIGHT; +#else in_button = GTK_BUTTON (widget)->in_button; +#endif GTK_WIDGET_CLASS (button_widget_parent_class)->leave_notify_event (widget, event); +#if GTK_CHECK_VERSION (3, 0, 0) + state_flags = gtk_widget_get_state_flags (widget); + if (in_button != (state_flags & GTK_STATE_FLAG_PRELIGHT) && +#else if (in_button != GTK_BUTTON (widget)->in_button && +#endif panel_global_config_get_highlight_when_over ()) gtk_widget_queue_draw (widget); @@ -645,11 +792,20 @@ button_widget_class_init (ButtonWidgetClass *klass) widget_class->realize = button_widget_realize; widget_class->unrealize = button_widget_unrealize; widget_class->size_allocate = button_widget_size_allocate; +#if GTK_CHECK_VERSION (3, 0, 0) + widget_class->get_preferred_width = button_widget_get_preferred_width; + widget_class->get_preferred_height = button_widget_get_preferred_height; +#else widget_class->size_request = button_widget_size_request; +#endif widget_class->button_press_event = button_widget_button_press; widget_class->enter_notify_event = button_widget_enter_notify; widget_class->leave_notify_event = button_widget_leave_notify; +#if GTK_CHECK_VERSION (3, 0, 0) + widget_class->draw = button_widget_draw; +#else widget_class->expose_event = button_widget_expose; +#endif button_class->activate = button_widget_activate; diff --git a/mate-panel/drawer.c b/mate-panel/drawer.c index 727924b2..6961343f 100644 --- a/mate-panel/drawer.c +++ b/mate-panel/drawer.c @@ -16,7 +16,11 @@ #include <string.h> #include <glib/gi18n.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 "drawer.h" diff --git a/mate-panel/libegg/eggsmclient-xsmp.c b/mate-panel/libegg/eggsmclient-xsmp.c index 75fced19..b5f90cee 100644 --- a/mate-panel/libegg/eggsmclient-xsmp.c +++ b/mate-panel/libegg/eggsmclient-xsmp.c @@ -35,7 +35,11 @@ #include <unistd.h> #include <X11/SM/SMlib.h> +#include <gtk/gtk.h> #include <gdk/gdk.h> +#if GTK_CHECK_VERSION (3, 0, 0) +#include <gdk/gdkx.h> +#endif #define EGG_TYPE_SM_CLIENT_XSMP (egg_sm_client_xsmp_get_type ()) #define EGG_SM_CLIENT_XSMP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_SM_CLIENT_XSMP, EggSMClientXSMP)) @@ -367,7 +371,11 @@ sm_client_xsmp_startup (EggSMClient *client, free (ret_client_id); gdk_threads_enter (); +#if GTK_CHECK_VERSION (3, 0, 0) + gdk_x11_set_sm_client_id (xsmp->client_id); +#else gdk_set_sm_client_id (xsmp->client_id); +#endif gdk_threads_leave (); g_debug ("Got client ID \"%s\"", xsmp->client_id); diff --git a/mate-panel/libmate-panel-applet-private/mate-panel-applet-container.c b/mate-panel/libmate-panel-applet-private/mate-panel-applet-container.c index 9eb7d897..e99c8cf8 100644 --- a/mate-panel/libmate-panel-applet-private/mate-panel-applet-container.c +++ b/mate-panel/libmate-panel-applet-private/mate-panel-applet-container.c @@ -21,6 +21,7 @@ */ #include <string.h> +#include <gtk/gtkx.h> #include "mate-panel-applet-container.h" #include "panel-marshal.h" diff --git a/mate-panel/libpanel-util/panel-icon-chooser.c b/mate-panel/libpanel-util/panel-icon-chooser.c index 7cd56fb4..a24d425e 100644 --- a/mate-panel/libpanel-util/panel-icon-chooser.c +++ b/mate-panel/libpanel-util/panel-icon-chooser.c @@ -141,7 +141,11 @@ panel_icon_chooser_set_property (GObject *object, } static void +#if GTK_CHECK_VERSION (3, 0, 0) +panel_icon_chooser_dispose (GObject *object) +#else panel_icon_chooser_destroy (GtkObject *object) +#endif { PanelIconChooser *chooser; @@ -166,14 +170,20 @@ panel_icon_chooser_destroy (GtkObject *object) g_free (chooser->priv->icon_theme_dir); chooser->priv->icon_theme_dir = NULL; +#if GTK_CHECK_VERSION (3, 0, 0) + G_OBJECT_CLASS (panel_icon_chooser_parent_class)->dispose (object); +#else GTK_OBJECT_CLASS (panel_icon_chooser_parent_class)->destroy (object); +#endif } static void panel_icon_chooser_class_init (PanelIconChooserClass *class) { GObjectClass *gobject_class = G_OBJECT_CLASS (class); +#if !GTK_CHECK_VERSION (3, 0, 0) GtkObjectClass *gtkobject_class = GTK_OBJECT_CLASS (class); +#endif GtkWidgetClass *gtkwidget_class = GTK_WIDGET_CLASS (class); GtkButtonClass *gtkbutton_class = GTK_BUTTON_CLASS (class); @@ -181,7 +191,11 @@ panel_icon_chooser_class_init (PanelIconChooserClass *class) gobject_class->get_property = panel_icon_chooser_get_property; gobject_class->set_property = panel_icon_chooser_set_property; +#if GTK_CHECK_VERSION (3, 0, 0) + gobject_class->dispose = panel_icon_chooser_dispose; +#else gtkobject_class->destroy = panel_icon_chooser_destroy; +#endif gtkwidget_class->style_set = _panel_icon_chooser_style_set; gtkwidget_class->screen_changed = _panel_icon_chooser_screen_changed; @@ -422,7 +436,11 @@ _panel_icon_chooser_clicked (GtkButton *button) if (info) { path = g_strdup (gtk_icon_info_get_filename (info)); +#if GTK_CHECK_VERSION (3, 8, 0) + g_object_unref (info); +#else gtk_icon_info_free (info); +#endif } } diff --git a/mate-panel/libpanel-util/panel-launch.c b/mate-panel/libpanel-util/panel-launch.c index c332d09a..28824269 100644 --- a/mate-panel/libpanel-util/panel-launch.c +++ b/mate-panel/libpanel-util/panel-launch.c @@ -221,6 +221,15 @@ panel_launch_desktop_file (const char *desktop_file, return retval; } +/* + * Set the DISPLAY variable, to be use by g_spawn_async. + */ +static void +set_environment (gpointer display) +{ + g_setenv ("DISPLAY", display, TRUE); +} + gboolean panel_launch_desktop_file_with_fallback (const char *desktop_file, const char *fallback_exec, @@ -231,6 +240,9 @@ panel_launch_desktop_file_with_fallback (const char *desktop_file, GError *local_error; gboolean retval; GPid pid; +#if GTK_CHECK_VERSION (3, 0, 0) + char *display; +#endif g_return_val_if_fail (desktop_file != NULL, FALSE); g_return_val_if_fail (fallback_exec != NULL, FALSE); @@ -247,9 +259,22 @@ panel_launch_desktop_file_with_fallback (const char *desktop_file, local_error = NULL; } +#if GTK_CHECK_VERSION (3, 0, 0) + display = gdk_screen_make_display_name (screen); + retval = g_spawn_async (NULL, /* working directory */ + argv, + NULL, /* envp */ + G_SPAWN_SEARCH_PATH, + set_environment, + &display, + NULL, + &local_error); + g_free (display); +#else retval = gdk_spawn_on_screen (screen, NULL, argv, NULL, G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &pid, &local_error); +#endif if (local_error == NULL && retval == TRUE) { g_child_watch_add (pid, dummy_child_watch, NULL); diff --git a/mate-panel/mate-panel-applet-frame.c b/mate-panel/mate-panel-applet-frame.c index 0a9990ab..bdabbc93 100644 --- a/mate-panel/mate-panel-applet-frame.c +++ b/mate-panel/mate-panel-applet-frame.c @@ -90,6 +90,64 @@ struct _MatePanelAppletFramePrivate { guint has_handle : 1; }; +#if GTK_CHECK_VERSION (3, 0, 0) +static gboolean +mate_panel_applet_frame_draw (GtkWidget *widget, + cairo_t *cr) +{ + MatePanelAppletFrame *frame = MATE_PANEL_APPLET_FRAME (widget); + GtkStyleContext *context; + GtkStateFlags state; + cairo_pattern_t *bg_pattern; + PanelBackground *background; + + if (GTK_WIDGET_CLASS (mate_panel_applet_frame_parent_class)->draw) + GTK_WIDGET_CLASS (mate_panel_applet_frame_parent_class)->draw (widget, cr); + + if (!frame->priv->has_handle) + return FALSE; + + context = gtk_widget_get_style_context (widget); + state = gtk_widget_get_state_flags (widget); + gtk_style_context_save (context); + gtk_style_context_set_state (context, state); + + cairo_save (cr); + + /* Set the pattern transform so as to correctly render a patterned + * background with the handle */ + gtk_style_context_get (context, state, + "background-image", &bg_pattern, + NULL); + background = &frame->priv->panel->background; + + if (bg_pattern && (background->type == PANEL_BACK_IMAGE || + (background->type == PANEL_BACK_COLOR && background->has_alpha))) { + cairo_matrix_t ptm; + + cairo_matrix_init_translate (&ptm, + frame->priv->handle_rect.x, + frame->priv->handle_rect.y); + cairo_matrix_scale (&ptm, + frame->priv->handle_rect.width, + frame->priv->handle_rect.height); + cairo_pattern_set_matrix (bg_pattern, &ptm); + cairo_pattern_destroy (bg_pattern); + } + + gtk_render_handle (context, cr, + frame->priv->handle_rect.x, + frame->priv->handle_rect.y, + frame->priv->handle_rect.width, + frame->priv->handle_rect.height); + + cairo_restore (cr); + + gtk_style_context_restore (context); + + return FALSE; +} +#else static void mate_panel_applet_frame_paint (GtkWidget *widget, GdkRectangle *area) @@ -142,6 +200,7 @@ static gboolean mate_panel_applet_frame_expose(GtkWidget* widget, GdkEventExpose return FALSE; } +#endif static void mate_panel_applet_frame_update_background_size (MatePanelAppletFrame *frame, @@ -165,6 +224,85 @@ mate_panel_applet_frame_update_background_size (MatePanelAppletFrame *frame, mate_panel_applet_frame_change_background (frame, background->type); } +#if GTK_CHECK_VERSION (3, 0, 0) +static void +mate_panel_applet_frame_get_preferred_width(GtkWidget *widget, gint *minimal_width, gint *natural_width) +{ + MatePanelAppletFrame *frame; + GtkBin *bin; + GtkWidget *child; + guint border_width; + + frame = MATE_PANEL_APPLET_FRAME (widget); + bin = GTK_BIN (widget); + + if (!frame->priv->has_handle) { + GTK_WIDGET_CLASS (mate_panel_applet_frame_parent_class)->get_preferred_width (widget, minimal_width, natural_width); + return; + } + + child = gtk_bin_get_child (bin); + if (child && gtk_widget_get_visible (child)) + gtk_widget_get_preferred_width (child, minimal_width, natural_width); + + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); + *minimal_width += border_width; + *natural_width += border_width; + + switch (frame->priv->orientation) { + case PANEL_ORIENTATION_TOP: + case PANEL_ORIENTATION_BOTTOM: + *minimal_width += HANDLE_SIZE; + *natural_width += HANDLE_SIZE; + break; + case PANEL_ORIENTATION_LEFT: + case PANEL_ORIENTATION_RIGHT: + break; + default: + g_assert_not_reached (); + break; + } +} + +static void +mate_panel_applet_frame_get_preferred_height(GtkWidget *widget, gint *minimal_height, gint *natural_height) +{ + MatePanelAppletFrame *frame; + GtkBin *bin; + GtkWidget *child; + guint border_width; + + frame = MATE_PANEL_APPLET_FRAME (widget); + bin = GTK_BIN (widget); + + if (!frame->priv->has_handle) { + GTK_WIDGET_CLASS (mate_panel_applet_frame_parent_class)->get_preferred_height (widget, minimal_height, natural_height); + return; + } + + child = gtk_bin_get_child (bin); + if (child && gtk_widget_get_visible (child)) + gtk_widget_get_preferred_height (child, minimal_height, natural_height); + + border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); + *minimal_height += border_width; + *natural_height += border_width; + + switch (frame->priv->orientation) { + case PANEL_ORIENTATION_LEFT: + case PANEL_ORIENTATION_RIGHT: + *minimal_height += HANDLE_SIZE; + *natural_height += HANDLE_SIZE; + break; + case PANEL_ORIENTATION_TOP: + case PANEL_ORIENTATION_BOTTOM: + break; + default: + g_assert_not_reached (); + break; + } +} +#else static void mate_panel_applet_frame_size_request (GtkWidget *widget, GtkRequisition *requisition) @@ -209,6 +347,7 @@ mate_panel_applet_frame_size_request (GtkWidget *widget, break; } } +#endif static void mate_panel_applet_frame_size_allocate (GtkWidget *widget, @@ -401,8 +540,14 @@ mate_panel_applet_frame_class_init (MatePanelAppletFrameClass *klass) gobject_class->finalize = mate_panel_applet_frame_finalize; +#if GTK_CHECK_VERSION (3, 0, 0) + widget_class->draw = mate_panel_applet_frame_draw; + widget_class->get_preferred_width = mate_panel_applet_frame_get_preferred_width; + widget_class->get_preferred_height = mate_panel_applet_frame_get_preferred_height; +#else widget_class->expose_event = mate_panel_applet_frame_expose; widget_class->size_request = mate_panel_applet_frame_size_request; +#endif widget_class->size_allocate = mate_panel_applet_frame_size_allocate; widget_class->button_press_event = mate_panel_applet_frame_button_changed; widget_class->button_release_event = mate_panel_applet_frame_button_changed; diff --git a/mate-panel/menu.c b/mate-panel/menu.c index 3e099cd2..55ec955c 100644 --- a/mate-panel/menu.c +++ b/mate-panel/menu.c @@ -28,7 +28,12 @@ #include <glib/gi18n.h> #include <gio/gio.h> +#include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> +#if GTK_CHECK_VERSION (3, 0, 0) +#include <gdk/gdkkeysyms-compat.h> +#endif + #include <libpanel-util/panel-keyfile.h> #include <libpanel-util/panel-xdg.h> @@ -837,10 +842,16 @@ restore_grabs(GtkWidget *w, gpointer data) if (viewable) xgrab_shell = parent; +#if GTK_CHECK_VERSION (3, 0, 0) + parent = gtk_menu_shell_get_parent_shell (GTK_MENU_SHELL (parent)); +#else parent = GTK_MENU_SHELL (parent)->parent_menu_shell; +#endif } /*only grab if this HAD a grab before*/ + /* FIXME fix for GTK3 */ +#if !GTK_CHECK_VERSION (3, 0, 0) if (xgrab_shell && (GTK_MENU_SHELL (xgrab_shell)->have_xgrab)) { GdkWindow *window = gtk_widget_get_window (xgrab_shell); @@ -859,6 +870,7 @@ restore_grabs(GtkWidget *w, gpointer data) gdk_pointer_ungrab (GDK_CURRENT_TIME); } } +#endif gtk_grab_add (GTK_WIDGET (menu)); } @@ -1052,7 +1064,11 @@ drag_end_menu_cb (GtkWidget *widget, GdkDragContext *context) if (viewable) xgrab_shell = parent; +#if GTK_CHECK_VERSION (3, 0, 0) + parent = gtk_menu_shell_get_parent_shell (GTK_MENU_SHELL (parent)); +#else parent = GTK_MENU_SHELL (parent)->parent_menu_shell; +#endif } if (xgrab_shell && !gtk_menu_get_tearoff_state (GTK_MENU(xgrab_shell))) @@ -1068,7 +1084,12 @@ drag_end_menu_cb (GtkWidget *widget, GdkDragContext *context) { if (gdk_keyboard_grab (window, TRUE, GDK_CURRENT_TIME) == 0) - GTK_MENU_SHELL (xgrab_shell)->have_xgrab = TRUE; + { +/* FIXME fix for GTK3 */ +#if !GTK_CHECK_VERSION (3, 0, 0) + GTK_MENU_SHELL (xgrab_shell)->have_xgrab = TRUE; +#endif + } else { gdk_pointer_ungrab (GDK_CURRENT_TIME); @@ -1103,11 +1124,18 @@ drag_data_get_menu_cb (GtkWidget *widget, } static void +#if GTK_CHECK_VERSION (3, 0, 0) +image_menuitem_set_size_request (GtkWidget *menuitem, + GtkIconSize icon_size) +#else image_menuitem_size_request (GtkWidget *menuitem, GtkRequisition *requisition, gpointer data) +#endif { +#if !GTK_CHECK_VERSION (3, 0, 0) GtkIconSize icon_size = (GtkIconSize) GPOINTER_TO_INT (data); +#endif int icon_height; int req_height; @@ -1123,7 +1151,12 @@ image_menuitem_size_request (GtkWidget *menuitem, req_height = icon_height; req_height += (gtk_container_get_border_width (GTK_CONTAINER (menuitem)) + (gtk_widget_get_style (menuitem))->ythickness) * 2; + +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_widget_set_size_request (menuitem, -1, req_height); +#else requisition->height = MAX (requisition->height, req_height); +#endif } static char * @@ -1196,9 +1229,13 @@ setup_menuitem (GtkWidget *menuitem, gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image); } else if (icon_size != GTK_ICON_SIZE_INVALID) +#if GTK_CHECK_VERSION (3, 0, 0) + image_menuitem_set_size_request (menuitem, icon_size); +#else g_signal_connect (menuitem, "size_request", G_CALLBACK (image_menuitem_size_request), GINT_TO_POINTER (icon_size)); +#endif gtk_widget_show (menuitem); } @@ -1591,8 +1628,16 @@ handle_matemenu_tree_changed (MateMenuTree *tree, { guint idle_id; +#if GTK_CHECK_VERSION (3, 0, 0) + GList *list, *l; + list = gtk_container_get_children (GTK_CONTAINER (menu)); + for (l = list; l; l = l->next) + gtk_widget_destroy (l->data); + g_list_free (list); +#else while (GTK_MENU_SHELL (menu)->children) gtk_widget_destroy (GTK_MENU_SHELL (menu)->children->data); +#endif g_object_set_data_full (G_OBJECT (menu), "panel-menu-tree-directory", @@ -1899,20 +1944,31 @@ panel_menu_key_press_handler (GtkWidget *widget, GdkEventKey *event) { gboolean retval = FALSE; +#if GTK_CHECK_VERSION (3, 0, 0) + GtkWidget *active_menu_item = NULL; +#endif if ((event->keyval == GDK_Menu) || (event->keyval == GDK_F10 && (event->state & gtk_accelerator_get_default_mod_mask ()) == GDK_SHIFT_MASK)) { GtkMenuShell *menu_shell = GTK_MENU_SHELL (widget); +#if GTK_CHECK_VERSION (3, 0, 0) + active_menu_item = gtk_menu_shell_get_selected_item (menu_shell); + if (active_menu_item && gtk_menu_item_get_submenu (GTK_MENU_ITEM (active_menu_item)) == NULL) { +#else if (menu_shell->active_menu_item && GTK_MENU_ITEM (menu_shell->active_menu_item)->submenu == NULL) { +#endif GdkEventButton bevent; bevent.button = 3; bevent.time = GDK_CURRENT_TIME; - retval = show_item_menu (menu_shell->active_menu_item, - &bevent); +#if GTK_CHECK_VERSION (3, 0, 0) + retval = show_item_menu (active_menu_item, &bevent); +#else + retval = show_item_menu (menu_shell->active_menu_item, &bevent); +#endif } } diff --git a/mate-panel/nothing.cP b/mate-panel/nothing.cP index 4ce1f246..cfb935c5 100644 --- a/mate-panel/nothing.cP +++ b/mate-panel/nothing.cP @@ -4,7 +4,11 @@ #include <X11/Xlib.h> #include <cairo.h> +#include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> +#if GTK_CHECK_VERSION (3, 0, 0) +#include <gdk/gdkkeysyms-compat.h> +#endif #include <canberra-gtk.h> #ifdef CA_CHECK_VERSION @@ -16,6 +20,7 @@ #include "panel-util.h" #include "nothing.h" +#if !GTK_CHECK_VERSION (3, 0, 0) static void pixbuf_reverse (GdkPixbuf *gp) { @@ -1566,3 +1571,4 @@ panel_dialog_window_event (GtkWidget *window, return FALSE; } +#endif
\ No newline at end of file diff --git a/mate-panel/nothing.h b/mate-panel/nothing.h index 1dc7f02f..2c8d8f79 100644 --- a/mate-panel/nothing.h +++ b/mate-panel/nothing.h @@ -7,6 +7,7 @@ extern "C" { #endif +#if !GTK_CHECK_VERSION (3, 0, 0) void start_screen_check (void); void start_geginv (void); gboolean panel_dialog_window_event (GtkWidget *window, @@ -14,6 +15,7 @@ gboolean panel_dialog_window_event (GtkWidget *window, int config_event (GtkWidget *widget, GdkEvent *event, GtkNotebook *nbook); +#endif #ifdef __cplusplus } diff --git a/mate-panel/panel-action-button.c b/mate-panel/panel-action-button.c index 6fc891e9..214fdf2a 100644 --- a/mate-panel/panel-action-button.c +++ b/mate-panel/panel-action-button.c @@ -33,6 +33,11 @@ #include <glib/gi18n.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 <libpanel-util/panel-error.h> #include <libpanel-util/panel-launch.h> #include <libpanel-util/panel-session-manager.h> @@ -290,7 +295,11 @@ panel_action_connect_server (GtkWidget *widget) screen = gtk_widget_get_screen (GTK_WIDGET (widget)); error = NULL; +#if GTK_CHECK_VERSION (3, 0, 0) + mate_gdk_spawn_command_line_on_screen (screen, "caja-connect-server", +#else gdk_spawn_command_line_on_screen (screen, "caja-connect-server", +#endif &error); if (error) { diff --git a/mate-panel/panel-action-protocol.c b/mate-panel/panel-action-protocol.c index 10040478..6669f248 100644 --- a/mate-panel/panel-action-protocol.c +++ b/mate-panel/panel-action-protocol.c @@ -98,6 +98,9 @@ panel_action_protocol_filter (GdkXEvent *gdk_xevent, { GdkWindow *window; GdkScreen *screen; +#if GTK_CHECK_VERSION (3, 0, 0) + GdkDisplay *display; +#endif XEvent *xevent = (XEvent *) gdk_xevent; if (xevent->type != ClientMessage) @@ -106,11 +109,21 @@ panel_action_protocol_filter (GdkXEvent *gdk_xevent, if (xevent->xclient.message_type != atom_mate_panel_action) return GDK_FILTER_CONTINUE; +#if GTK_CHECK_VERSION (3, 0, 0) + screen = gdk_event_get_screen (event); + display = gdk_screen_get_display (screen); + window = gdk_x11_window_lookup_for_display (display, xevent->xclient.window); +#else + screen = gdk_drawable_get_screen (window); window = gdk_window_lookup (xevent->xclient.window); +#endif if (!window) return GDK_FILTER_CONTINUE; - screen = gdk_drawable_get_screen (window); +#if GTK_CHECK_VERSION (3, 0, 0) + if (window != gdk_screen_get_root_window (screen)) + return GDK_FILTER_CONTINUE; +#endif if (xevent->xclient.data.l [0] == atom_mate_panel_action_main_menu) panel_action_protocol_main_menu (screen, xevent->xclient.data.l [1]); @@ -128,12 +141,16 @@ void panel_action_protocol_init (void) { GdkDisplay *display; +#if !GTK_CHECK_VERSION (3, 0, 0) GdkAtom gdk_atom_mate_panel_action; +#endif display = gdk_display_get_default (); +#if !GTK_CHECK_VERSION (3, 0, 0) gdk_atom_mate_panel_action = gdk_atom_intern_static_string ("_MATE_PANEL_ACTION"); +#endif atom_mate_panel_action = XInternAtom (GDK_DISPLAY_XDISPLAY (display), @@ -152,7 +169,12 @@ panel_action_protocol_init (void) "_MATE_PANEL_ACTION_KILL_DIALOG", FALSE); +#if GTK_CHECK_VERSION (3, 0, 0) + /* We'll filter event sent on non-root windows later */ + gdk_window_add_filter (NULL, panel_action_protocol_filter, NULL); +#else gdk_display_add_client_message_filter ( display, gdk_atom_mate_panel_action, panel_action_protocol_filter, NULL); +#endif } diff --git a/mate-panel/panel-addto.c b/mate-panel/panel-addto.c index 77528feb..77e915e0 100644 --- a/mate-panel/panel-addto.c +++ b/mate-panel/panel-addto.c @@ -1258,8 +1258,10 @@ panel_addto_dialog_new (PanelWidget *panel_widget) GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); gtk_widget_set_sensitive (GTK_WIDGET (dialog->add_button), FALSE); +#if !GTK_CHECK_VERSION (3, 0, 0) gtk_dialog_set_has_separator (GTK_DIALOG (dialog->addto_dialog), FALSE); +#endif gtk_dialog_set_default_response (GTK_DIALOG (dialog->addto_dialog), PANEL_ADDTO_RESPONSE_ADD); diff --git a/mate-panel/panel-background-monitor.c b/mate-panel/panel-background-monitor.c index 9a67c2b1..a7e67e05 100644 --- a/mate-panel/panel-background-monitor.c +++ b/mate-panel/panel-background-monitor.c @@ -28,9 +28,13 @@ #include <glib-object.h> #include <gdk/gdk.h> #include <gdk/gdkx.h> +#include <cairo-xlib.h> #include <X11/Xlib.h> #include <X11/Xatom.h> +#define MATE_DESKTOP_USE_UNSTABLE_API +#include <libmate-desktop/mate-bg.h> + #include "panel-background-monitor.h" #include "panel-util.h" @@ -61,7 +65,11 @@ struct _PanelBackgroundMonitor { Atom xatom; GdkAtom gdkatom; +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_surface_t *surface; +#else GdkPixmap *gdkpixmap; +#endif GdkPixbuf *gdkpixbuf; int width; @@ -88,9 +96,15 @@ panel_background_monitor_finalize (GObject *object) g_signal_handlers_disconnect_by_func (monitor->screen, panel_background_monitor_changed, monitor); +#if GTK_CHECK_VERSION (3, 0, 0) + if (monitor->surface) + cairo_surface_destroy (monitor->surface); + monitor->surface= NULL; +#else if (monitor->gdkpixmap) g_object_unref (monitor->gdkpixmap); monitor->gdkpixmap = NULL; +#endif if (monitor->gdkpixbuf) g_object_unref (monitor->gdkpixbuf); @@ -127,7 +141,11 @@ panel_background_monitor_init (PanelBackgroundMonitor *monitor) monitor->gdkatom = gdk_atom_intern_static_string ("_XROOTPMAP_ID"); monitor->xatom = gdk_x11_atom_to_xatom (monitor->gdkatom); +#if GTK_CHECK_VERSION (3, 0, 0) + monitor->surface = NULL; +#else monitor->gdkpixmap = NULL; +#endif monitor->gdkpixbuf = NULL; monitor->display_grabbed = FALSE; @@ -148,7 +166,11 @@ panel_background_monitor_connect_to_screen (PanelBackgroundMonitor *monitor, G_CALLBACK (panel_background_monitor_changed), monitor); monitor->gdkwindow = gdk_screen_get_root_window (screen); +#if GTK_CHECK_VERSION (3, 0, 0) + monitor->xwindow = gdk_x11_window_get_xid (monitor->gdkwindow); +#else monitor->xwindow = gdk_x11_drawable_get_xid (monitor->gdkwindow); +#endif gdk_window_add_filter ( monitor->gdkwindow, panel_background_monitor_xevent_filter, monitor); @@ -202,9 +224,15 @@ panel_background_monitor_get_for_screen (GdkScreen *screen) static void panel_background_monitor_changed (PanelBackgroundMonitor *monitor) { +#if GTK_CHECK_VERSION (3, 0, 0) + if (monitor->surface) + cairo_surface_destroy (monitor->surface); + monitor->surface = NULL; +#else if (monitor->gdkpixmap) g_object_unref (monitor->gdkpixmap); monitor->gdkpixmap = NULL; +#endif if (monitor->gdkpixbuf) g_object_unref (monitor->gdkpixbuf); @@ -234,6 +262,7 @@ panel_background_monitor_xevent_filter (GdkXEvent *xevent, return GDK_FILTER_CONTINUE; } +#if !GTK_CHECK_VERSION (3, 0, 0) static void panel_background_monitor_setup_pixmap (PanelBackgroundMonitor *monitor) { @@ -264,6 +293,7 @@ panel_background_monitor_setup_pixmap (PanelBackgroundMonitor *monitor) g_free (prop_data); } +#endif static GdkPixbuf * panel_background_monitor_tile_background (PanelBackgroundMonitor *monitor, @@ -333,7 +363,9 @@ panel_background_monitor_tile_background (PanelBackgroundMonitor *monitor, static void panel_background_monitor_setup_pixbuf (PanelBackgroundMonitor *monitor) { +#if !GTK_CHECK_VERSION (3, 0, 0) GdkColormap *colormap = NULL; +#endif GdkDisplay *display; int rwidth, rheight; int pwidth, pheight; @@ -343,35 +375,58 @@ panel_background_monitor_setup_pixbuf (PanelBackgroundMonitor *monitor) gdk_x11_display_grab (display); monitor->display_grabbed = TRUE; +#if GTK_CHECK_VERSION (3, 0, 0) + if (!monitor->surface) + monitor->surface = mate_bg_get_surface_from_root (monitor->screen); +#else if (!monitor->gdkpixmap) panel_background_monitor_setup_pixmap (monitor); +#endif - if (!monitor->gdkpixmap) { +#if GTK_CHECK_VERSION (3, 0, 0) + if (!monitor->surface) +#else + if (!monitor->gdkpixmap) +#endif + { + g_warning ("couldn't get background pixmap\n"); gdk_x11_display_ungrab (display); monitor->display_grabbed = FALSE; return; } - #if GTK_CHECK_VERSION(3, 0, 0) - pwidth = gdk_window_get_width(monitor->gdkpixmap); - pheight = gdk_window_get_height(monitor->gdkpixmap); - #else - gdk_drawable_get_size(GDK_DRAWABLE(monitor->gdkpixmap), &pwidth, &pheight); - #endif +#if GTK_CHECK_VERSION (3, 0, 0) + pwidth = cairo_xlib_surface_get_width (monitor->surface); + pheight = cairo_xlib_surface_get_height (monitor->surface); +#else + gdk_drawable_get_size(GDK_DRAWABLE(monitor->gdkpixmap), &pwidth, &pheight); +#endif gdk_window_get_geometry (monitor->gdkwindow, +#if GTK_CHECK_VERSION (3, 0, 0) + NULL, NULL, &rwidth, &rheight); +#else NULL, NULL, &rwidth, &rheight, NULL); +#endif monitor->width = MIN (pwidth, rwidth); monitor->height = MIN (pheight, rheight); +#if !GTK_CHECK_VERSION (3, 0, 0) colormap = gdk_drawable_get_colormap (monitor->gdkwindow); +#endif g_assert (monitor->gdkpixbuf == NULL); +#if GTK_CHECK_VERSION (3, 0, 0) + monitor->gdkpixbuf = gdk_pixbuf_get_from_surface (monitor->surface, + 0, 0, + monitor->width, monitor->height); +#else monitor->gdkpixbuf = gdk_pixbuf_get_from_drawable ( NULL, monitor->gdkpixmap, colormap, 0, 0, 0, 0, monitor->width, monitor->height); +#endif gdk_x11_display_ungrab (display); monitor->display_grabbed = FALSE; diff --git a/mate-panel/panel-background.c b/mate-panel/panel-background.c index 196a6a6b..eb2308e5 100644 --- a/mate-panel/panel-background.c +++ b/mate-panel/panel-background.c @@ -48,6 +48,10 @@ free_prepared_resources (PanelBackground *background) case PANEL_BACK_NONE: break; case PANEL_BACK_COLOR: +#if GTK_CHECK_VERSION (3, 0, 0) + if (!background->has_alpha) + background->color.red = background->color.green = background->color.blue = 0.; +#else if (background->has_alpha) { if (background->pixmap) g_object_unref (background->pixmap); @@ -59,11 +63,14 @@ free_prepared_resources (PanelBackground *background) &background->color.gdk, 1); background->color.gdk.pixel = 0; } +#endif break; case PANEL_BACK_IMAGE: +#if !GTK_CHECK_VERSION (3, 0, 0) if (background->pixmap) g_object_unref (background->pixmap); background->pixmap = NULL; +#endif break; default: g_assert_not_reached (); @@ -74,6 +81,11 @@ free_prepared_resources (PanelBackground *background) static void set_pixbuf_background (PanelBackground *background) { +#if GTK_CHECK_VERSION (3, 0, 0) + g_assert (background->composited_pattern != NULL); + + gdk_window_set_background_pattern (background->window, background->composited_pattern); +#else g_assert (background->composited_image != NULL); gdk_pixbuf_render_pixmap_and_mask_for_colormap ( @@ -83,6 +95,7 @@ set_pixbuf_background (PanelBackground *background) gdk_window_set_back_pixmap ( background->window, background->pixmap, FALSE); +#endif } static gboolean @@ -91,7 +104,11 @@ panel_background_prepare (PanelBackground *background) PanelBackgroundType effective_type; GtkWidget *widget = NULL; +#if GTK_CHECK_VERSION (3, 0, 0) + if (!background->transformed) +#else if (!background->colormap || !background->transformed) +#endif return FALSE; free_prepared_resources (background); @@ -100,6 +117,24 @@ panel_background_prepare (PanelBackground *background) switch (effective_type) { case PANEL_BACK_NONE: +#if GTK_CHECK_VERSION (3, 0, 0) + if (background->default_pattern) { + /* the theme background-image pattern must be scaled by + * the width & height of the panel so that when the + * backing region is cleared + * (gdk_window_clear_backing_region), the correctly + * scaled pattern is used */ + cairo_matrix_t m; + + cairo_matrix_init_translate (&m, 0, 0); + cairo_matrix_scale (&m, + 1.0 / background->region.width, + 1.0 / background->region.height); + cairo_pattern_set_matrix (background->default_pattern, &m); + + gdk_window_set_background_pattern (background->window, + background->default_pattern); +#else if (background->default_pixmap) { if (background->default_pixmap != (GdkPixmap*) GDK_PARENT_RELATIVE) gdk_window_set_back_pixmap (background->window, @@ -109,21 +144,31 @@ panel_background_prepare (PanelBackground *background) gdk_window_set_back_pixmap (background->window, NULL, TRUE); +#endif } else gdk_window_set_background ( background->window, &background->default_color); break; case PANEL_BACK_COLOR: if (background->has_alpha && +#if GTK_CHECK_VERSION (3, 0, 0) + background->composited_pattern) +#else background->composited_image) +#endif set_pixbuf_background (background); else { +#if GTK_CHECK_VERSION (3, 0, 0) + gdk_window_set_background_rgba (background->window, + &background->color); +#else gdk_colormap_alloc_color ( background->colormap, &background->color.gdk, FALSE, TRUE); gdk_window_set_background ( background->window, &background->color.gdk); +#endif } break; case PANEL_BACK_IMAGE: @@ -138,7 +183,11 @@ panel_background_prepare (PanelBackground *background) * decide how to draw themselves. Therefore, we need to * make sure that all drawing has been completed before * the applet looks at the pixmap. */ +#if GTK_CHECK_VERSION (3, 0, 0) + gdk_display_sync (gdk_window_get_display (background->window)); +#else gdk_display_sync (gdk_drawable_get_display (background->window)); +#endif gdk_window_get_user_data (GDK_WINDOW (background->window), (gpointer) &widget); @@ -160,9 +209,15 @@ free_composited_resources (PanelBackground *background) background->composited = FALSE; +#if GTK_CHECK_VERSION (3, 0, 0) + if (background->composited_pattern) + cairo_pattern_destroy (background->composited_pattern); + background->composited_pattern = NULL; +#else if (background->composited_image) g_object_unref (background->composited_image); background->composited_image = NULL; +#endif } static void @@ -194,7 +249,11 @@ get_desktop_pixbuf (PanelBackground *background) if (!background->monitor) { background->monitor = panel_background_monitor_get_for_screen ( +#if GTK_CHECK_VERSION (3, 0, 0) + gdk_window_get_screen (background->window)); +#else gdk_drawable_get_screen (background->window)); +#endif background->monitor_signal = g_signal_connect ( @@ -212,12 +271,20 @@ get_desktop_pixbuf (PanelBackground *background) return desktop; } +#if GTK_CHECK_VERSION (3, 0, 0) +static cairo_pattern_t * +#else static GdkPixbuf * +#endif composite_image_onto_desktop (PanelBackground *background) { +#if GTK_CHECK_VERSION (3, 0, 0) + static const cairo_user_data_key_t key; +#else GdkPixbuf *retval; - int width, height; unsigned char *data; +#endif + int width, height; cairo_t *cr; cairo_surface_t *surface; cairo_pattern_t *pattern; @@ -231,6 +298,15 @@ composite_image_onto_desktop (PanelBackground *background) width = gdk_pixbuf_get_width (background->desktop); height = gdk_pixbuf_get_height (background->desktop); +#if GTK_CHECK_VERSION (3, 0, 0) + surface = gdk_window_create_similar_surface (background->window, + CAIRO_CONTENT_COLOR_ALPHA, + width, height); + if (cairo_surface_status (surface)) { + cairo_surface_destroy (surface); + return NULL; + } +#else data = g_malloc (width * height * 4); if (!data) return NULL; @@ -239,6 +315,8 @@ composite_image_onto_desktop (PanelBackground *background) CAIRO_FORMAT_RGB24, width, height, width * 4); +#endif + cr = cairo_create (surface); cairo_set_source_rgb (cr, 1, 1, 1); cairo_paint (cr); @@ -247,26 +325,44 @@ composite_image_onto_desktop (PanelBackground *background) cairo_rectangle (cr, 0, 0, width, height); cairo_fill (cr); +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_set_source (cr, background->transformed_pattern); +#else gdk_cairo_set_source_pixbuf (cr, background->transformed_image, 0, 0); pattern = cairo_get_source (cr); cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); +#endif cairo_rectangle (cr, 0, 0, width, height); cairo_fill (cr); cairo_destroy (cr); - cairo_surface_destroy (surface); +#if GTK_CHECK_VERSION (3, 0, 0) + pattern = cairo_pattern_create_for_surface (surface); + cairo_surface_destroy (surface); + return pattern; +#else + cairo_surface_destroy (surface); retval = panel_util_cairo_rgbdata_to_pixbuf (data, width, height); - g_free (data); - return retval; +#endif } +#if GTK_CHECK_VERSION (3, 0, 0) +static cairo_pattern_t * +#else static GdkPixbuf * +#endif composite_color_onto_desktop (PanelBackground *background) { +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_surface_t *surface; + cairo_pattern_t *pattern; + cairo_t *cr; +#else guint32 color; +#endif if (!background->desktop) background->desktop = get_desktop_pixbuf (background); @@ -274,6 +370,30 @@ composite_color_onto_desktop (PanelBackground *background) if (!background->desktop) return NULL; +#if GTK_CHECK_VERSION (3, 0, 0) + surface = gdk_window_create_similar_surface (background->window, + CAIRO_CONTENT_COLOR_ALPHA, + background->region.width, + background->region.height); + if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS) { + cairo_surface_destroy (surface); + return NULL; + } + + cr = cairo_create (surface); + gdk_cairo_set_source_pixbuf (cr, background->desktop, 0, 0); + cairo_paint (cr); + + gdk_cairo_set_source_rgba (cr, &background->color); + cairo_paint (cr); + + cairo_destroy (cr); + + pattern = cairo_pattern_create_for_surface (surface); + cairo_surface_destroy (surface); + + return pattern; +#else color = ((background->color.gdk.red & 0xff00) << 8) + (background->color.gdk.green & 0xff00) + (background->color.gdk.blue >> 8); @@ -285,12 +405,22 @@ composite_color_onto_desktop (PanelBackground *background) GDK_INTERP_NEAREST, (255 - (background->color.alpha >> 8)), 255, color, color); +#endif } +#if GTK_CHECK_VERSION (3, 0, 0) +static cairo_pattern_t * +get_composited_pattern (PanelBackground *background) +#else static GdkPixbuf * get_composited_pixbuf (PanelBackground *background) +#endif { +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_pattern_t *retval = NULL; +#else GdkPixbuf *retval = NULL; +#endif switch (background->type) { case PANEL_BACK_NONE: @@ -300,8 +430,13 @@ get_composited_pixbuf (PanelBackground *background) break; case PANEL_BACK_IMAGE: retval = composite_image_onto_desktop (background); +#if GTK_CHECK_VERSION (3, 0, 0) + if (!retval && background->transformed_pattern); + retval = cairo_pattern_reference (background->transformed_pattern); +#else if (!retval) retval = g_object_ref (background->transformed_image); +#endif break; default: g_assert_not_reached (); @@ -324,10 +459,25 @@ panel_background_composite (PanelBackground *background) break; case PANEL_BACK_COLOR: if (background->has_alpha) +#if GTK_CHECK_VERSION (3, 0, 0) + background->composited_pattern = + get_composited_pattern (background); +#else background->composited_image = get_composited_pixbuf (background); +#endif break; case PANEL_BACK_IMAGE: +#if GTK_CHECK_VERSION (3, 0, 0) + if (background->transformed_pattern) { + if (background->has_alpha) + background->composited_pattern = + get_composited_pattern (background); + else + background->composited_pattern = + cairo_pattern_reference (background->transformed_pattern); + } +#else if (background->transformed_image) { if (background->has_alpha) background->composited_image = @@ -336,6 +486,7 @@ panel_background_composite (PanelBackground *background) background->composited_image = g_object_ref (background->transformed_image); } +#endif break; default: g_assert_not_reached (); @@ -359,14 +510,28 @@ free_transformed_resources (PanelBackground *background) if (background->type != PANEL_BACK_IMAGE) return; +#if GTK_CHECK_VERSION (3, 0, 0) + if (background->transformed_pattern) + cairo_pattern_destroy (background->transformed_pattern); + background->transformed_pattern = NULL; +#else if (background->transformed_image) g_object_unref (background->transformed_image); background->transformed_image = NULL; +#endif } +#if GTK_CHECK_VERSION (3, 0, 0) +static cairo_pattern_t * +get_scaled_and_rotated_pattern (PanelBackground *background) +#else static GdkPixbuf * get_scaled_and_rotated_pixbuf (PanelBackground *background) +#endif { +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_pattern_t *pattern; +#endif GdkPixbuf *scaled; GdkPixbuf *retval; int orig_width, orig_height; @@ -484,7 +649,17 @@ get_scaled_and_rotated_pixbuf (PanelBackground *background) } else retval = scaled; +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_t *cr = gdk_cairo_create (background->window ? background->window : gdk_get_default_root_window()); + gdk_cairo_set_source_pixbuf (cr, retval, 0, 0); + g_object_unref (retval); + pattern = cairo_pattern_reference (cairo_get_source (cr)); + cairo_destroy (cr); + cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); + return pattern; +#else return retval; +#endif } static gboolean @@ -496,8 +671,13 @@ panel_background_transform (PanelBackground *background) free_transformed_resources (background); if (background->type == PANEL_BACK_IMAGE) +#if GTK_CHECK_VERSION (3, 0, 0) + background->transformed_pattern = + get_scaled_and_rotated_pattern (background); +#else background->transformed_image = get_scaled_and_rotated_pixbuf (background); +#endif background->transformed = TRUE; @@ -578,6 +758,7 @@ panel_background_set_type (PanelBackground *background, panel_background_transform (background); } +#if !GTK_CHECK_VERSION (3, 0, 0) static void panel_background_set_gdk_color_no_update (PanelBackground *background, GdkColor *gdk_color) @@ -625,29 +806,50 @@ panel_background_set_opacity (PanelBackground *background, panel_background_set_opacity_no_update (background, opacity); panel_background_transform (background); } +#endif static void panel_background_set_color_no_update (PanelBackground *background, +#if GTK_CHECK_VERSION (3, 0, 0) + const GdkRGBA *color) +#else PanelColor *color) +#endif { g_return_if_fail (color != NULL); +#if GTK_CHECK_VERSION (3, 0, 0) + if (gdk_rgba_equal (color, &background->color)) + return; + background->color = *color; + panel_background_update_has_alpha (background); +#else panel_background_set_gdk_color_no_update (background, &(color->gdk)); panel_background_set_opacity_no_update (background, color->alpha); +#endif } void panel_background_set_color (PanelBackground *background, +#if GTK_CHECK_VERSION (3, 0, 0) + const GdkRGBA *color) +#else PanelColor *color) +#endif { g_return_if_fail (color != NULL); +#if GTK_CHECK_VERSION (3, 0, 0) + if (gdk_rgba_equal (color, &background->color)) +#else if (background->color.gdk.red == color->gdk.red && background->color.gdk.green == color->gdk.green && background->color.gdk.blue == color->gdk.blue && background->color.alpha == color->alpha) +#endif return; + free_transformed_resources (background); panel_background_set_color_no_update (background, color); panel_background_transform (background); @@ -752,7 +954,11 @@ panel_background_set_rotate (PanelBackground *background, void panel_background_set (PanelBackground *background, PanelBackgroundType type, +#if GTK_CHECK_VERSION (3, 0, 0) + const GdkRGBA *color, +#else PanelColor *color, +#endif const char *image, gboolean fit_image, gboolean stretch_image, @@ -769,12 +975,25 @@ panel_background_set (PanelBackground *background, void panel_background_set_default_style (PanelBackground *background, GdkColor *color, +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_pattern_t *pattern) +#else GdkPixmap *pixmap) +#endif { g_return_if_fail (color != NULL); background->default_color = *color; +#if GTK_CHECK_VERSION (3, 0, 0) + if (pattern) + cairo_pattern_reference (pattern); + + if (background->default_pattern) + cairo_pattern_destroy (background->default_pattern); + + background->default_pattern = pattern; +#else if (pixmap && pixmap != (GdkPixmap*) GDK_PARENT_RELATIVE) g_object_ref (pixmap); @@ -783,6 +1002,7 @@ panel_background_set_default_style (PanelBackground *background, g_object_unref (background->default_pixmap); background->default_pixmap = pixmap; +#endif if (background->type == PANEL_BACK_NONE) panel_background_prepare (background); @@ -794,9 +1014,16 @@ panel_background_realized (PanelBackground *background, { g_return_if_fail (window != NULL); +#if GTK_CHECK_VERSION (3, 0, 0) + if (background->window) +#else if (background->window && background->colormap && background->gc) +#endif return; +#if GTK_CHECK_VERSION (3, 0, 0) + background->window = g_object_ref (window); +#else if (!background->window) background->window = g_object_ref (window); @@ -806,6 +1033,7 @@ panel_background_realized (PanelBackground *background, if (!background->gc) background->gc = gdk_gc_new (window); +#endif panel_background_prepare (background); } @@ -819,6 +1047,7 @@ panel_background_unrealized (PanelBackground *background) g_object_unref (background->window); background->window = NULL; +#if !GTK_CHECK_VERSION (3, 0, 0) if (background->colormap) g_object_unref (background->colormap); background->colormap = NULL; @@ -826,6 +1055,7 @@ panel_background_unrealized (PanelBackground *background) if (background->gc) g_object_unref (background->gc); background->gc = NULL; +#endif } void @@ -905,11 +1135,18 @@ panel_background_init (PanelBackground *background, background->notify_changed = notify_changed; background->user_data = user_data; +#if GTK_CHECK_VERSION (3, 0, 0) + background->color.red = 0.; + background->color.blue = 0.; + background->color.green = 0.; + background->color.alpha = 1.; +#else background->color.gdk.red = 0; background->color.gdk.blue = 0; background->color.gdk.green = 0; background->color.gdk.pixel = 0; background->color.alpha = 0xffff; +#endif background->image = NULL; background->loaded_image = NULL; @@ -919,19 +1156,30 @@ panel_background_init (PanelBackground *background, background->region.y = -1; background->region.width = -1; background->region.height = -1; +#if GTK_CHECK_VERSION (3, 0, 0) + background->transformed_pattern = NULL; + background->composited_pattern = NULL; +#else background->transformed_image = NULL; background->composited_image = NULL; +#endif background->monitor = NULL; background->desktop = NULL; background->monitor_signal = -1; - background->pixmap = NULL; background->window = NULL; +#if !GTK_CHECK_VERSION (3, 0, 0) + background->pixmap = NULL; background->colormap = NULL; background->gc = NULL; +#endif +#if GTK_CHECK_VERSION (3, 0, 0) + background->default_pattern = NULL; +#else background->default_pixmap = NULL; +#endif background->default_color.red = 0; background->default_color.green = 0; background->default_color.blue = 0; @@ -971,6 +1219,11 @@ panel_background_free (PanelBackground *background) g_object_unref (background->window); background->window = NULL; +#if GTK_CHECK_VERSION (3, 0, 0) + if (background->default_pattern) + cairo_pattern_destroy (background->default_pattern); + background->default_pattern = NULL; +#else if (background->colormap) g_object_unref (background->colormap); background->colormap = NULL; @@ -983,6 +1236,7 @@ panel_background_free (PanelBackground *background) && background->default_pixmap != (GdkPixmap*) GDK_PARENT_RELATIVE) g_object_unref (background->default_pixmap); background->default_pixmap = NULL; +#endif } char * @@ -999,22 +1253,36 @@ panel_background_make_string (PanelBackground *background, if (effective_type == PANEL_BACK_IMAGE || (effective_type == PANEL_BACK_COLOR && background->has_alpha)) { +#if GTK_CHECK_VERSION (3, 0, 0) + Window pixmap_xid; +#else GdkNativeWindow pixmap_xid; if (!background->pixmap) return NULL; +#endif +#if GTK_CHECK_VERSION (3, 0, 0) + pixmap_xid = gdk_x11_window_get_xid (background->window); +#else pixmap_xid = gdk_x11_drawable_get_xid ( GDK_DRAWABLE (background->pixmap)); +#endif retval = g_strdup_printf ("pixmap:%d,%d,%d", pixmap_xid, x, y); } else if (effective_type == PANEL_BACK_COLOR) retval = g_strdup_printf ( "color:%.4x%.4x%.4x", +#if GTK_CHECK_VERSION (3, 0, 0) + background->color.red, + background->color.green, + background->color.blue); +#else background->color.gdk.red, background->color.gdk.green, background->color.gdk.blue); +#endif else retval = g_strdup ("none:"); @@ -1028,17 +1296,23 @@ panel_background_get_type (PanelBackground *background) return background->type; } +#if GTK_CHECK_VERSION (3, 0, 0) +const GdkRGBA * +#else const PanelColor * +#endif panel_background_get_color (PanelBackground *background) { return &(background->color); } +#if !GTK_CHECK_VERSION (3, 0, 0) const GdkPixmap * panel_background_get_pixmap (PanelBackground *background) { return background->pixmap; } +#endif /* What are we actually rendering - e.g. if we're supposed to @@ -1051,7 +1325,11 @@ panel_background_effective_type (PanelBackground *background) PanelBackgroundType retval; retval = background->type; +#if GTK_CHECK_VERSION (3, 0, 0) + if (background->type == PANEL_BACK_IMAGE && !background->composited_pattern) +#else if (background->type == PANEL_BACK_IMAGE && !background->composited_image) +#endif retval = PANEL_BACK_NONE; return retval; @@ -1069,17 +1347,57 @@ panel_background_set_no_background_on_widget (PanelBackground *background, g_object_unref (rc_style); } +#if GTK_CHECK_VERSION (3, 0, 0) +static cairo_pattern_t * +panel_background_get_pattern_for_widget (PanelBackground *background, + GtkWidget *widget) +#else static void panel_background_set_image_background_on_widget (PanelBackground *background, + GtkWidget *widget) +#endif { - const GdkPixmap *bg_pixmap; GtkAllocation allocation; - GdkPixmap *pixmap; cairo_t *cr; cairo_pattern_t *pattern; +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_surface_t *surface; + cairo_surface_t *bg_surface; + cairo_matrix_t matrix; +#else + const GdkPixmap *bg_pixmap; + GdkPixmap *pixmap; GtkStyle *style; +#endif + +#if GTK_CHECK_VERSION (3, 0, 0) + if (!background->composited_pattern) + return NULL; + + if (cairo_pattern_get_surface (background->composited_pattern, &bg_surface) != CAIRO_STATUS_SUCCESS) + return NULL; + + gtk_widget_get_allocation (widget, &allocation); + surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, + allocation.width, allocation.height); + + cr = cairo_create (surface); + cairo_set_source_surface (cr, bg_surface, -allocation.x, -allocation.y); + cairo_rectangle (cr, 0, 0, allocation.width, allocation.height); + cairo_fill (cr); + cairo_destroy (cr); + pattern = cairo_pattern_create_for_surface (surface); + cairo_matrix_init_translate (&matrix, 0, 0); + cairo_matrix_scale (&matrix, allocation.width, allocation.height); + cairo_pattern_set_matrix (pattern, &matrix); + cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD); + + cairo_surface_destroy (surface); + + return pattern; +#else bg_pixmap = panel_background_get_pixmap (background); if (!bg_pixmap) return; @@ -1111,28 +1429,119 @@ panel_background_set_image_background_on_widget (PanelBackground *background, g_object_unref (style); g_object_unref (pixmap); +#endif } static void panel_background_set_color_background_on_widget (PanelBackground *background, GtkWidget *widget) { +#if GTK_CHECK_VERSION (3, 0, 0) + const GdkRGBA *color; + GdkColor gdkcolor; +#else const PanelColor *color; +#endif color = panel_background_get_color (background); +#if GTK_CHECK_VERSION (3, 0, 0) + if (color->alpha < 1.) { +#else if (color->alpha != 0xffff) { +#endif panel_background_set_image_background_on_widget (background, widget); return; } +#if GTK_CHECK_VERSION (3, 0, 0) + gdkcolor.red = color->red * 65535.; + gdkcolor.green = color->green * 65535.; + gdkcolor.blue = color->blue * 65535.; + gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, &gdkcolor); +#else gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, &color->gdk); +#endif } +#if GTK_CHECK_VERSION (3, 0, 0) +static GtkStyleProperties * +_panel_background_get_widget_style_properties (GtkWidget *widget, gboolean create_if_needed) +{ + GtkStyleProperties *properties; + + properties = g_object_get_data (G_OBJECT (widget), "panel-object-style-props"); + if (!properties && create_if_needed) { + properties = gtk_style_properties_new (); + g_object_set_data_full (G_OBJECT (widget), "panel-object-style-props", + properties, (GDestroyNotify) g_object_unref); + } + return properties; +} + +static void +_panel_background_reset_widget_style_properties (GtkWidget *widget) +{ + GtkStyleProperties *properties; + + properties = _panel_background_get_widget_style_properties (widget, FALSE); + + if (properties) + gtk_style_context_remove_provider (gtk_widget_get_style_context (widget), + GTK_STYLE_PROVIDER (properties)); + + g_object_set_data (G_OBJECT (widget), "panel-object-style-props", NULL); +} +#endif + void panel_background_change_background_on_widget (PanelBackground *background, GtkWidget *widget) { +#if GTK_CHECK_VERSION (3, 0, 0) + GtkStyleProperties *properties; + + gtk_widget_reset_style (widget); + + switch (panel_background_get_type (background)) { + case PANEL_BACK_NONE: + _panel_background_reset_widget_style_properties (widget); + return; + case PANEL_BACK_COLOR: + if (!background->has_alpha) { + properties = _panel_background_get_widget_style_properties (widget, TRUE); + gtk_style_properties_set (properties, GTK_STATE_FLAG_NORMAL, + "background-color", &background->color, + "background-image", NULL, + NULL); + break; + } + // Color with alpha, fallback to image + case PANEL_BACK_IMAGE: { + cairo_pattern_t *pattern; + + properties = _panel_background_get_widget_style_properties (widget, TRUE); + pattern = panel_background_get_pattern_for_widget (background, widget); + if (pattern) { + gtk_style_properties_set (properties, GTK_STATE_FLAG_NORMAL, + "background-image", pattern, + NULL); + cairo_pattern_destroy (pattern); + } else { + _panel_background_reset_widget_style_properties (widget); + return; + } + } + break; + default: + g_assert_not_reached (); + break; + } + + gtk_style_context_add_provider (gtk_widget_get_style_context (widget), + GTK_STYLE_PROVIDER (properties), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); +#else PanelBackgroundType type; panel_background_set_no_background_on_widget (background, widget); @@ -1154,4 +1563,6 @@ panel_background_change_background_on_widget (PanelBackground *background, g_assert_not_reached (); break; } +#endif } + diff --git a/mate-panel/panel-background.h b/mate-panel/panel-background.h index 59f6cfcd..e8491dda 100644 --- a/mate-panel/panel-background.h +++ b/mate-panel/panel-background.h @@ -44,30 +44,42 @@ struct _PanelBackground { PanelBackgroundChangedNotify notify_changed; gpointer user_data; +#if GTK_CHECK_VERSION (3, 0, 0) + GdkRGBA color; +#else PanelColor color; +#endif char *image; GdkPixbuf *loaded_image; GtkOrientation orientation; GdkRectangle region; +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_pattern_t *transformed_pattern; + cairo_pattern_t *composited_pattern; +#else GdkPixbuf *transformed_image; GdkPixbuf *composited_image; +#endif PanelBackgroundMonitor *monitor; GdkPixbuf *desktop; gulong monitor_signal; - GdkPixmap *pixmap; +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_pattern_t *default_pattern; GdkWindow *window; +#else + GdkPixmap *pixmap; GdkColormap *colormap; GdkGC *gc; - GdkPixmap *default_pixmap; +#endif GdkColor default_color; - guint fit_image : 1; - guint stretch_image : 1; - guint rotate_image : 1; + guint fit_image : 1; + guint stretch_image : 1; + guint rotate_image : 1; guint has_alpha : 1; @@ -83,19 +95,29 @@ void panel_background_init (PanelBackground *background, void panel_background_free (PanelBackground *background); void panel_background_set (PanelBackground *background, PanelBackgroundType type, +#if GTK_CHECK_VERSION (3, 0, 0) + const GdkRGBA *color, +#else PanelColor *color, +#endif const char *image, gboolean fit_image, gboolean stretch_image, gboolean rotate_image); void panel_background_set_type (PanelBackground *background, PanelBackgroundType type); +#if !GTK_CHECK_VERSION (3, 0, 0) void panel_background_set_gdk_color (PanelBackground *background, GdkColor *gdk_color); void panel_background_set_opacity (PanelBackground *background, guint16 opacity); +#endif void panel_background_set_color (PanelBackground *background, +#if GTK_CHECK_VERSION (3, 0, 0) + const GdkRGBA *color); +#else PanelColor *color); +#endif void panel_background_set_image (PanelBackground *background, const char *image); void panel_background_set_fit (PanelBackground *background, @@ -106,7 +128,11 @@ void panel_background_set_rotate (PanelBackground *background, gboolean rotate_image); void panel_background_set_default_style (PanelBackground *background, GdkColor *color, +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_pattern_t *pattern); +#else GdkPixmap *pixmap); +#endif void panel_background_realized (PanelBackground *background, GdkWindow *window); void panel_background_unrealized (PanelBackground *background); @@ -121,8 +147,12 @@ char *panel_background_make_string (PanelBackground *background, int y); PanelBackgroundType panel_background_get_type (PanelBackground *background); +#if GTK_CHECK_VERSION (3, 0, 0) +const GdkRGBA *panel_background_get_color (PanelBackground *background); +#else const PanelColor *panel_background_get_color (PanelBackground *background); const GdkPixmap *panel_background_get_pixmap (PanelBackground *background); +#endif PanelBackgroundType panel_background_effective_type (PanelBackground *background); diff --git a/mate-panel/panel-bindings.c b/mate-panel/panel-bindings.c index 8a737769..a5c2530b 100644 --- a/mate-panel/panel-bindings.c +++ b/mate-panel/panel-bindings.c @@ -30,6 +30,8 @@ #include <glib/gi18n.h> #include <gio/gio.h> +#include <libmate-desktop/mate-gsettings.h> + #include "panel-schemas.h" #include "panel-profile.h" #include "panel-xutils.h" @@ -187,6 +189,11 @@ panel_bindings_initialise (void) if (initialised) return; + if (!mate_gsettings_schema_exists (MARCO_SCHEMA)) { + initialised = TRUE; + return; + } + marco_settings = g_settings_new (MARCO_SCHEMA); marco_keybindings_settings = g_settings_new (MARCO_KEYBINDINGS_SCHEMA); diff --git a/mate-panel/panel-context-menu.c b/mate-panel/panel-context-menu.c index a7c01774..41c61b93 100644 --- a/mate-panel/panel-context-menu.c +++ b/mate-panel/panel-context-menu.c @@ -65,12 +65,15 @@ panel_context_menu_check_for_screen (GtkWidget *w, static int times = 0; if (ev->type != GDK_KEY_PRESS) return FALSE; - if (ev->key.keyval == GDK_f || - ev->key.keyval == GDK_F) { + if (ev->key.keyval == GDK_KEY_f || + ev->key.keyval == GDK_KEY_F) { times++; if (times == 3) { times = 0; +#if !GTK_CHECK_VERSION (3, 0, 0) + /* FIXME re-add once GTK3 support is fixed */ start_screen_check (); +#endif } } return FALSE; diff --git a/mate-panel/panel-ditem-editor.c b/mate-panel/panel-ditem-editor.c index 9f7b4760..a7106b27 100644 --- a/mate-panel/panel-ditem-editor.c +++ b/mate-panel/panel-ditem-editor.c @@ -338,7 +338,11 @@ panel_ditem_editor_set_property (GObject *object, } static void +#if GTK_CHECK_VERSION (3, 0, 0) +panel_ditem_editor_dispose (GObject *object) +#else panel_ditem_editor_destroy (GtkObject *object) +#endif { PanelDItemEditor *dialog; @@ -366,20 +370,30 @@ panel_ditem_editor_destroy (GtkObject *object) g_free (dialog->priv->uri); dialog->priv->uri = NULL; +#if GTK_CHECK_VERSION (3, 0, 0) + G_OBJECT_CLASS (panel_ditem_editor_parent_class)->dispose (object); +#else GTK_OBJECT_CLASS (panel_ditem_editor_parent_class)->destroy (object); +#endif } static void panel_ditem_editor_class_init (PanelDItemEditorClass *class) { GObjectClass *gobject_class = G_OBJECT_CLASS (class); +#if !GTK_CHECK_VERSION (3, 0, 0) GtkObjectClass *gtkobject_class = GTK_OBJECT_CLASS (class); +#endif gobject_class->constructor = panel_ditem_editor_constructor; gobject_class->get_property = panel_ditem_editor_get_property; gobject_class->set_property = panel_ditem_editor_set_property; +#if GTK_CHECK_VERSION (3, 0, 0) + gobject_class->dispose = panel_ditem_editor_dispose; +#else gtkobject_class->destroy = panel_ditem_editor_destroy; +#endif g_type_class_add_private (class, sizeof (PanelDItemEditorPrivate)); @@ -608,7 +622,9 @@ panel_ditem_editor_make_ui (PanelDItemEditor *dialog) dialog_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); gtk_box_set_spacing (GTK_BOX (dialog_vbox), 2); +#if !GTK_CHECK_VERSION (3, 0, 0) gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); +#endif priv->table = gtk_table_new (4, 3, FALSE); gtk_container_set_border_width (GTK_CONTAINER (priv->table), 5); diff --git a/mate-panel/panel-force-quit.c b/mate-panel/panel-force-quit.c index 4b627e1f..b86517e4 100644 --- a/mate-panel/panel-force-quit.c +++ b/mate-panel/panel-force-quit.c @@ -251,7 +251,11 @@ handle_button_press_event (GtkWidget *popup, window = find_managed_window (event->display, event->subwindow); if (window != None) { +#if GTK_CHECK_VERSION (3, 0, 0) + if (!gdk_x11_window_lookup_for_display (gdk_x11_lookup_xdisplay (event->display), window)) +#else if (!gdk_xid_table_lookup_for_display (gdk_x11_lookup_xdisplay (event->display), window)) +#endif kill_window_question ((gpointer) window); } } diff --git a/mate-panel/panel-frame.c b/mate-panel/panel-frame.c index ab0cbc6a..7311e945 100644 --- a/mate-panel/panel-frame.c +++ b/mate-panel/panel-frame.c @@ -68,6 +68,28 @@ panel_frame_size_request (GtkWidget *widget, requisition->width += style->ythickness; } +#if GTK_CHECK_VERSION (3, 0, 0) +static void +panel_frame_get_preferred_width (GtkWidget *widget, + gint *minimum_width, + gint *natural_width) +{ + GtkRequisition req; + panel_frame_size_request (widget, &req); + *minimum_width = *natural_width = req.width; +} + +static void +panel_frame_get_preferred_height (GtkWidget *widget, + gint *minimum_height, + gint *natural_height) +{ + GtkRequisition req; + panel_frame_size_request (widget, &req); + *minimum_height = *natural_height = req.height; +} +#endif + static void panel_frame_size_allocate (GtkWidget *widget, GtkAllocation *allocation) @@ -122,13 +144,20 @@ panel_frame_size_allocate (GtkWidget *widget, void panel_frame_draw (GtkWidget *widget, +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_t *cr, +#endif PanelFrameEdge edges) { GdkWindow *window; GtkStyle *style; GtkStateType state; +#if GTK_CHECK_VERSION (3, 0, 0) + GdkColor *dark, *light, *black; +#else GtkAllocation allocation; GdkGC *dark, *light, *black; +#endif int x, y, width, height; int xthickness, ythickness; @@ -138,22 +167,103 @@ panel_frame_draw (GtkWidget *widget, window = gtk_widget_get_window (widget); style = gtk_widget_get_style (widget); state = gtk_widget_get_state (widget); +#if GTK_CHECK_VERSION (3, 0, 0) + x = 0; + y = 0; + width = gtk_widget_get_allocated_width (widget); + height = gtk_widget_get_allocated_height (widget); +#else gtk_widget_get_allocation (widget, &allocation); + x = allocation.x; + y = allocation.y; + width = allocation.width; + height = allocation.height; +#endif +#if GTK_CHECK_VERSION (3, 0, 0) + dark = &style->dark [state]; + light = &style->light [state]; + black = &style->black; +#else dark = style->dark_gc [state]; light = style->light_gc [state]; black = style->black_gc; +#endif xthickness = style->xthickness; ythickness = style->ythickness; - x = allocation.x; - y = allocation.y; - width = allocation.width; - height = allocation.height; - /* Copied from gtk_default_draw_shadow() */ +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_set_line_width (cr, 1); + + if (edges & PANEL_EDGE_BOTTOM && ythickness > 0) { + if (ythickness > 1) { + gdk_cairo_set_source_color (cr, dark); + cairo_move_to (cr, x + .5, y + height - 2 + .5); + cairo_line_to (cr, x + width - 1 - .5, y + height - 2 + .5); + cairo_stroke (cr); + + gdk_cairo_set_source_color (cr, black); + cairo_move_to (cr, x + .5, y + height - 1 - .5); + cairo_line_to (cr, x + width - 1 - .5, y + height - 1 - .5); + cairo_stroke (cr); + } else { + gdk_cairo_set_source_color (cr, dark); + cairo_move_to (cr, x + .5, y + height - 1 - .5); + cairo_line_to (cr, x + width - 1 - .5, y + height - 1 - .5); + cairo_stroke (cr); + } + } + + if (edges & PANEL_EDGE_RIGHT && xthickness > 0) { + if (xthickness > 1) { + gdk_cairo_set_source_color (cr, dark); + cairo_move_to (cr, x + width - 2 - .5, y + .5); + cairo_line_to (cr, x + width - 2 - .5, y + height - 1 - .5); + cairo_stroke (cr); + + gdk_cairo_set_source_color (cr, black); + cairo_move_to (cr, x + width - 1 - .5, y + .5); + cairo_line_to (cr, x + width - 1 - .5, y + height - 1 - .5); + cairo_stroke (cr); + } else { + gdk_cairo_set_source_color (cr, dark); + cairo_move_to (cr, x + width - 1 - .5, y + .5); + cairo_line_to (cr, x + width - 1 - .5, y + height - 1 - .5); + cairo_stroke (cr); + } + } + + if (edges & PANEL_EDGE_TOP && ythickness > 0) { + gdk_cairo_set_source_color (cr, light); + cairo_move_to (cr, x + .5, y + .5); + cairo_line_to (cr, x + width - 1 - .5, y + .5); + cairo_stroke (cr); + + if (ythickness > 1) { + gdk_cairo_set_source_color (cr, &style->bg [state]); + cairo_move_to (cr, x + .5, y + 1 + .5); + cairo_line_to (cr, x + width - 1 - .5, y + 1 + .5); + cairo_stroke (cr); + } + } + + if (edges & PANEL_EDGE_LEFT && xthickness > 0) { + gdk_cairo_set_source_color (cr, light); + cairo_move_to (cr, x + .5, y + .5); + cairo_line_to (cr, x + .5, y + height - 1 - .5); + cairo_stroke (cr); + + if (xthickness > 1) { + gdk_cairo_set_source_color (cr, &style->bg [state]); + cairo_move_to (cr, x + 1 + .5, y + .5); + cairo_line_to (cr, x + 1 + .5, y + height - 1 - .5); + cairo_stroke (cr); + } + } +#else if (edges & PANEL_EDGE_BOTTOM && ythickness > 0) { if (ythickness > 1) { gdk_draw_line (window, dark, @@ -202,9 +312,14 @@ panel_frame_draw (GtkWidget *widget, style->bg_gc [state], x + 1, y, x + 1, y + height - 1); } +#endif } +#if GTK_CHECK_VERSION (3, 0, 0) +static gboolean panel_frame_expose(GtkWidget* widget, cairo_t* cr) +#else static gboolean panel_frame_expose(GtkWidget* widget, GdkEventExpose* event) +#endif { PanelFrame *frame = (PanelFrame *) widget; gboolean retval = FALSE; @@ -212,12 +327,19 @@ static gboolean panel_frame_expose(GtkWidget* widget, GdkEventExpose* event) if (!gtk_widget_is_drawable (widget)) return retval; +#if GTK_CHECK_VERSION (3, 0, 0) + if (GTK_WIDGET_CLASS (panel_frame_parent_class)->draw) + retval = GTK_WIDGET_CLASS (panel_frame_parent_class)->draw (widget, cr); +#else if (GTK_WIDGET_CLASS (panel_frame_parent_class)->expose_event) - { retval = GTK_WIDGET_CLASS (panel_frame_parent_class)->expose_event (widget, event); - } +#endif +#if GTK_CHECK_VERSION (3, 0, 0) + panel_frame_draw (widget, cr, frame->edges); +#else panel_frame_draw (widget, frame->edges); +#endif return retval; } @@ -275,9 +397,15 @@ panel_frame_class_init (PanelFrameClass *klass) gobject_class->set_property = panel_frame_set_property; gobject_class->get_property = panel_frame_get_property; - widget_class->size_request = panel_frame_size_request; widget_class->size_allocate = panel_frame_size_allocate; +#if GTK_CHECK_VERSION (3, 0, 0) + widget_class->get_preferred_width = panel_frame_get_preferred_width; + widget_class->get_preferred_height = panel_frame_get_preferred_height; + widget_class->draw = panel_frame_expose; +#else + widget_class->size_request = panel_frame_size_request; widget_class->expose_event = panel_frame_expose; +#endif g_object_class_install_property ( gobject_class, diff --git a/mate-panel/panel-frame.h b/mate-panel/panel-frame.h index b1286f2f..e5988ddb 100644 --- a/mate-panel/panel-frame.h +++ b/mate-panel/panel-frame.h @@ -60,6 +60,9 @@ void panel_frame_set_edges (PanelFrame *toplevel, PanelFrameEdge panel_frame_get_edges (PanelFrame *toplevel); void panel_frame_draw (GtkWidget *widget, +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_t *cr, +#endif PanelFrameEdge edges); #ifdef __cplusplus diff --git a/mate-panel/panel-menu-bar.c b/mate-panel/panel-menu-bar.c index c7995c3d..ab40b3b7 100644 --- a/mate-panel/panel-menu-bar.c +++ b/mate-panel/panel-menu-bar.c @@ -257,13 +257,37 @@ static void panel_menu_bar_class_init(PanelMenuBarClass* klass) "class \"PanelMenuBar\" style \"panel-menubar-style\""); } +#if GTK_CHECK_VERSION (3, 0, 0) +static gboolean panel_menu_bar_on_draw(GtkWidget* widget, cairo_t* cr, gpointer data) +#else static gboolean panel_menu_bar_on_expose(GtkWidget* widget, GdkEventExpose* event, gpointer data) +#endif { PanelMenuBar* menubar = data; if (gtk_widget_has_focus(GTK_WIDGET(menubar))) { - gtk_paint_focus(gtk_widget_get_style(widget), gtk_widget_get_window(widget), gtk_widget_get_state(GTK_WIDGET(menubar)), NULL, widget, "menubar-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(GTK_WIDGET(menubar)), +#if !GTK_CHECK_VERSION (3, 0, 0) + NULL, +#endif + widget, + "menubar-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; @@ -295,7 +319,11 @@ static void panel_menu_bar_load(PanelWidget* panel, gboolean locked, int positio g_signal_connect_after(menubar, "focus-in-event", G_CALLBACK(gtk_widget_queue_draw), menubar); g_signal_connect_after(menubar, "focus-out-event", G_CALLBACK(gtk_widget_queue_draw), menubar); +#if GTK_CHECK_VERSION (3, 0, 0) + g_signal_connect_after(menubar, "draw", G_CALLBACK(panel_menu_bar_on_draw), menubar); +#else g_signal_connect_after(menubar, "expose-event", G_CALLBACK(panel_menu_bar_on_expose), menubar); +#endif gtk_widget_set_can_focus(GTK_WIDGET(menubar), TRUE); @@ -362,6 +390,7 @@ void panel_menu_bar_popup_menu(PanelMenuBar* menubar, guint32 activate_time) */ menu_shell = GTK_MENU_SHELL(menubar); +#if !GTK_CHECK_VERSION (3, 0, 0) if (!menu_shell->active) { gtk_grab_add(GTK_WIDGET(menu_shell)); @@ -369,6 +398,7 @@ void panel_menu_bar_popup_menu(PanelMenuBar* menubar, guint32 activate_time) menu_shell->have_grab = TRUE; menu_shell->active = TRUE; } +#endif gtk_menu_shell_select_item(menu_shell, gtk_menu_get_attach_widget(menu)); } diff --git a/mate-panel/panel-menu-button.c b/mate-panel/panel-menu-button.c index a4ce15ad..019173d4 100644 --- a/mate-panel/panel-menu-button.c +++ b/mate-panel/panel-menu-button.c @@ -359,7 +359,12 @@ panel_menu_button_menu_deactivated (PanelMenuButton *button) { panel_toplevel_pop_autohide_disabler (button->priv->toplevel); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_widget_unset_state_flags (GTK_WIDGET (button), + GTK_STATE_FLAG_PRELIGHT); +#else GTK_BUTTON (button)->in_button = FALSE; +#endif button_widget_set_ignore_leave (BUTTON_WIDGET (button), FALSE); } diff --git a/mate-panel/panel-menu-items.c b/mate-panel/panel-menu-items.c index 85ee31ce..88a11eb4 100644 --- a/mate-panel/panel-menu-items.c +++ b/mate-panel/panel-menu-items.c @@ -39,6 +39,7 @@ #include <string.h> #include <glib/gi18n.h> #include <gio/gio.h> +#include <libmate-desktop/mate-gsettings.h> #include <libpanel-util/panel-error.h> #include <libpanel-util/panel-glib.h> @@ -1047,7 +1048,8 @@ panel_place_menu_item_create_menu (PanelPlaceMenuItem *place_item) g_free (name); g_free (uri); - if (!g_settings_get_boolean (place_item->priv->caja_prefs_settings, + if (!place_item->priv->caja_prefs_settings || + !g_settings_get_boolean (place_item->priv->caja_prefs_settings, CAJA_PREFS_DESKTOP_IS_HOME_DIR_KEY)) { file = g_file_new_for_path (g_get_user_special_dir (G_USER_DIRECTORY_DESKTOP)); uri = g_file_get_uri (file); @@ -1070,14 +1072,16 @@ panel_place_menu_item_create_menu (PanelPlaceMenuItem *place_item) panel_place_menu_item_append_gtk_bookmarks (places_menu); add_menu_separator (places_menu); - gsettings_name = g_settings_get_string (place_item->priv->caja_desktop_settings, - CAJA_DESKTOP_COMPUTER_ICON_NAME_KEY); - panel_menu_items_append_from_desktop (places_menu, - "caja-computer.desktop", - gsettings_name, - TRUE); - if (gsettings_name) + if (place_item->priv->caja_desktop_settings != NULL) { + gsettings_name = g_settings_get_string (place_item->priv->caja_desktop_settings, + CAJA_DESKTOP_COMPUTER_ICON_NAME_KEY); + panel_menu_items_append_from_desktop (places_menu, + "caja-computer.desktop", + gsettings_name, + TRUE); + if (gsettings_name) g_free (gsettings_name); + } panel_place_menu_item_append_local_gio (place_item, places_menu); add_menu_separator (places_menu); @@ -1326,21 +1330,29 @@ panel_place_menu_item_init (PanelPlaceMenuItem *menuitem) menuitem->priv = PANEL_PLACE_MENU_ITEM_GET_PRIVATE (menuitem); - menuitem->priv->caja_desktop_settings = g_settings_new (CAJA_DESKTOP_SCHEMA); - menuitem->priv->caja_prefs_settings = g_settings_new (CAJA_PREFS_SCHEMA); - - g_signal_connect (menuitem->priv->caja_desktop_settings, - "changed::" CAJA_DESKTOP_HOME_ICON_NAME_KEY, - G_CALLBACK (panel_place_menu_item_key_changed), - G_OBJECT (menuitem)); - g_signal_connect (menuitem->priv->caja_desktop_settings, - "changed::" CAJA_DESKTOP_COMPUTER_ICON_NAME_KEY, - G_CALLBACK (panel_place_menu_item_key_changed), - G_OBJECT (menuitem)); - g_signal_connect (menuitem->priv->caja_prefs_settings, - "changed::" CAJA_PREFS_DESKTOP_IS_HOME_DIR_KEY, - G_CALLBACK (panel_place_menu_item_key_changed), - G_OBJECT (menuitem)); + if (mate_gsettings_schema_exists (CAJA_DESKTOP_SCHEMA)) { + menuitem->priv->caja_desktop_settings = g_settings_new (CAJA_DESKTOP_SCHEMA); + g_signal_connect (menuitem->priv->caja_desktop_settings, + "changed::" CAJA_DESKTOP_HOME_ICON_NAME_KEY, + G_CALLBACK (panel_place_menu_item_key_changed), + G_OBJECT (menuitem)); + g_signal_connect (menuitem->priv->caja_desktop_settings, + "changed::" CAJA_DESKTOP_COMPUTER_ICON_NAME_KEY, + G_CALLBACK (panel_place_menu_item_key_changed), + G_OBJECT (menuitem)); + } + else + menuitem->priv->caja_desktop_settings = NULL; + + if (mate_gsettings_schema_exists (CAJA_PREFS_SCHEMA)) { + menuitem->priv->caja_prefs_settings = g_settings_new (CAJA_PREFS_SCHEMA); + g_signal_connect (menuitem->priv->caja_prefs_settings, + "changed::" CAJA_PREFS_DESKTOP_IS_HOME_DIR_KEY, + G_CALLBACK (panel_place_menu_item_key_changed), + G_OBJECT (menuitem)); + } + else + menuitem->priv->caja_prefs_settings = NULL; menuitem->priv->recent_manager = gtk_recent_manager_get_default (); diff --git a/mate-panel/panel-multiscreen.c b/mate-panel/panel-multiscreen.c index 838ca526..27c29135 100644 --- a/mate-panel/panel-multiscreen.c +++ b/mate-panel/panel-multiscreen.c @@ -133,7 +133,11 @@ panel_multiscreen_get_randr_monitors_for_screen (GdkScreen *screen, */ xdisplay = GDK_SCREEN_XDISPLAY (screen); +#if GTK_CHECK_VERSION (3, 0, 0) + xroot = GDK_WINDOW_XID (gdk_screen_get_root_window (screen)); +#else xroot = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (screen)); +#endif #if (RANDR_MAJOR > 1 || (RANDR_MAJOR == 1 && RANDR_MINOR >= 3)) if (have_randr_1_3) { diff --git a/mate-panel/panel-profile.c b/mate-panel/panel-profile.c index 57e11d00..2c5b328c 100644 --- a/mate-panel/panel-profile.c +++ b/mate-panel/panel-profile.c @@ -495,15 +495,27 @@ panel_profile_is_writable_attached_tooltip (PanelToplevel *toplevel) static void get_background_color (PanelToplevel *toplevel, - PanelColor *color) +#if GTK_CHECK_VERSION (3, 0, 0) + GdkRGBA *color) +#else + PanelColor *color) +#endif { char *color_str; color_str = g_settings_get_string (toplevel->background_settings, "color"); +#if GTK_CHECK_VERSION (3, 0, 0) + if (!color_str || !gdk_rgba_parse (color, color_str)) { + color->red = 0; + color->green = 0; + color->blue = 0; + } +#else if (!color_str || !gdk_color_parse (color_str, &(color->gdk))) { color->gdk.red = 0; color->gdk.green = 0; color->gdk.blue = 0; } +#endif g_free (color_str); color->alpha = g_settings_get_int (toplevel->background_settings, "opacity"); @@ -529,7 +541,11 @@ panel_profile_load_background (PanelToplevel *toplevel) PanelWidget *panel_widget; PanelBackground *background; PanelBackgroundType background_type; +#if GTK_CHECK_VERSION (3, 0, 0) + GdkRGBA color; +#else PanelColor color; +#endif char *image; gboolean fit; gboolean stretch; @@ -823,14 +839,26 @@ panel_profile_background_change_notify (GSettings *settings, panel_background_set_type (background, background_type); panel_toplevel_update_edges (toplevel); } else if (!strcmp (key, "color")) { +#if GTK_CHECK_VERSION (3, 0, 0) + GdkRGBA color; + gchar *str; + str = g_settings_get_string (settings, key); + if (gdk_rgba_parse (&color, str)) + panel_background_set_color (background, &color); + g_free (str); +#else GdkColor gdk_color; - const char *str; + gchar *str; str = g_settings_get_string (settings, key); if (gdk_color_parse (str, &gdk_color)) panel_background_set_gdk_color (background, &gdk_color); + g_free (str); +#endif } else if (!strcmp (key, "opacity")) { +#if !GTK_CHECK_VERSION (3, 0, 0) panel_background_set_opacity (background, g_settings_get_int (settings, key)); +#endif } else if (!strcmp (key, "image")) { panel_background_set_image (background, g_settings_get_string (settings, key)); diff --git a/mate-panel/panel-properties-dialog.c b/mate-panel/panel-properties-dialog.c index 596ab062..5818522f 100644 --- a/mate-panel/panel-properties-dialog.c +++ b/mate-panel/panel-properties-dialog.c @@ -922,9 +922,12 @@ panel_properties_dialog_new (PanelToplevel *toplevel, panel_widget_register_open_dialog (panel_toplevel_get_panel_widget (dialog->toplevel), dialog->properties_dialog); +#if !GTK_CHECK_VERSION (3, 0, 0) + /* FIXME re-add once GTK3 support is fixed */ g_signal_connect (dialog->properties_dialog, "event", G_CALLBACK (config_event), PANEL_GTK_BUILDER_GET (gui, "notebook")); +#endif gtk_widget_show (dialog->properties_dialog); diff --git a/mate-panel/panel-run-dialog.c b/mate-panel/panel-run-dialog.c index 339240d2..0299374f 100644 --- a/mate-panel/panel-run-dialog.c +++ b/mate-panel/panel-run-dialog.c @@ -43,7 +43,7 @@ #include <matemenu-tree.h> #define MATE_DESKTOP_USE_UNSTABLE_API -#include <libmate/mate-desktop-utils.h> +#include <libmate-desktop/mate-desktop-utils.h> #include <libpanel-util/panel-error.h> #include <libpanel-util/panel-glib.h> @@ -147,7 +147,7 @@ _panel_run_get_recent_programs_list (PanelRunDialog *dialog) static void _panel_run_save_recent_programs_list (PanelRunDialog *dialog, - GtkComboBoxEntry *entry, + GtkComboBox *entry, char *lastcommand) { GtkTreeModel *model; @@ -360,6 +360,17 @@ dummy_child_watch (GPid pid, */ } +#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 gboolean panel_run_dialog_launch_command (PanelRunDialog *dialog, const char *command, @@ -371,6 +382,9 @@ panel_run_dialog_launch_command (PanelRunDialog *dialog, char **argv; int argc; GPid pid; +#if GTK_CHECK_VERSION (3, 0, 0) + char *display; +#endif if (!command_is_executable (locale_command, &argc, &argv)) return FALSE; @@ -380,6 +394,20 @@ panel_run_dialog_launch_command (PanelRunDialog *dialog, if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->terminal_checkbox))) mate_desktop_prepend_terminal_to_vector (&argc, &argv); +#if GTK_CHECK_VERSION (3, 0, 0) + display = gdk_screen_make_display_name (screen); + + result = g_spawn_async (NULL, /* working directory */ + argv, + NULL, /* envp */ + G_SPAWN_SEARCH_PATH, + set_environment, + &display, + NULL, + &error); + + g_free (display); +#else result = gdk_spawn_on_screen (screen, NULL, /* working directory */ argv, @@ -389,6 +417,7 @@ panel_run_dialog_launch_command (PanelRunDialog *dialog, NULL, /* user data */ &pid, /* child pid */ &error); +#endif if (!result) { char *primary; @@ -419,7 +448,7 @@ panel_run_dialog_execute (PanelRunDialog *dialog) char *disk; char *scheme; - command = gtk_combo_box_get_active_text (GTK_COMBO_BOX (dialog->combobox)); + command = g_strdup (gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (dialog->combobox))))); command = g_strchug (command); if (!command || !command [0]) { @@ -428,6 +457,8 @@ panel_run_dialog_execute (PanelRunDialog *dialog) } /* evil eggies, do not translate! */ +#if !GTK_CHECK_VERSION (3, 0, 0) + /* FIXME re-add once GTK3 support is fixed */ if (!strcmp (command, "free the fish")) { start_screen_check (); @@ -441,6 +472,7 @@ panel_run_dialog_execute (PanelRunDialog *dialog) gtk_widget_destroy (dialog->run_dialog); return; } +#endif error = NULL; disk = g_locale_from_utf8 (command, -1, NULL, NULL, &error); @@ -486,7 +518,7 @@ panel_run_dialog_execute (PanelRunDialog *dialog) if (result) { /* only save working commands in history */ _panel_run_save_recent_programs_list - (dialog, GTK_COMBO_BOX_ENTRY (dialog->combobox), command); + (dialog, GTK_COMBO_BOX (dialog->combobox), command); /* only close the dialog if we successfully showed or launched * something */ @@ -545,7 +577,7 @@ static void panel_run_dialog_append_file_utf8 (PanelRunDialog *dialog, const char *file) { - char *text; + const char *text; char *quoted, *temp; GtkWidget *entry; @@ -555,7 +587,7 @@ panel_run_dialog_append_file_utf8 (PanelRunDialog *dialog, quoted = quote_string (file); entry = gtk_bin_get_child (GTK_BIN (dialog->combobox)); - text = gtk_combo_box_get_active_text (GTK_COMBO_BOX (dialog->combobox)); + text = gtk_entry_get_text (GTK_ENTRY (entry)); if (text && text [0]) { temp = g_strconcat (text, " ", quoted, NULL); gtk_entry_set_text (GTK_ENTRY (entry), temp); @@ -563,7 +595,6 @@ panel_run_dialog_append_file_utf8 (PanelRunDialog *dialog, } else gtk_entry_set_text (GTK_ENTRY (entry), quoted); - g_free (text); g_free (quoted); } @@ -671,7 +702,7 @@ panel_run_dialog_find_command_idle (PanelRunDialog *dialog) return FALSE; } - text = gtk_combo_box_get_active_text (GTK_COMBO_BOX (dialog->combobox)); + text = g_strdup (gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (dialog->combobox))))); found_icon = NULL; found_name = NULL; fuzzy = FALSE; @@ -1506,7 +1537,7 @@ entry_event (GtkEditable *entry, return FALSE; /* tab completion */ - if (event->keyval == GDK_Tab) { + if (event->keyval == GDK_KEY_Tab) { gtk_editable_get_selection_bounds (entry, &pos, &tmp); if (dialog->completion_started && @@ -1602,7 +1633,7 @@ combobox_changed (GtkComboBox *combobox, char *start; char *msg; - text = gtk_combo_box_get_active_text (combobox); + text = g_strdup (gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (combobox))))); start = text; while (*start != '\0' && g_ascii_isspace (*start)) @@ -1746,8 +1777,8 @@ panel_run_dialog_setup_entry (PanelRunDialog *dialog, gtk_combo_box_set_model (GTK_COMBO_BOX (dialog->combobox), _panel_run_get_recent_programs_list (dialog)); - gtk_combo_box_entry_set_text_column - (GTK_COMBO_BOX_ENTRY (dialog->combobox), 0); + gtk_combo_box_set_entry_text_column + (GTK_COMBO_BOX (dialog->combobox), 0); screen = gtk_window_get_screen (GTK_WINDOW (dialog->run_dialog)); @@ -1787,7 +1818,7 @@ panel_run_dialog_create_desktop_file (PanelRunDialog *dialog) char *scheme; char *save_uri; - text = gtk_combo_box_get_active_text (GTK_COMBO_BOX (dialog->combobox)); + text = g_strdup (gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (dialog->combobox))))); if (!text || !text [0]) { g_free (text); diff --git a/mate-panel/panel-run-dialog.ui b/mate-panel/panel-run-dialog.ui index d2bb2a86..04fa84f7 100644 --- a/mate-panel/panel-run-dialog.ui +++ b/mate-panel/panel-run-dialog.ui @@ -58,8 +58,9 @@ <property name="orientation">vertical</property> <property name="spacing">6</property> <child> - <object class="GtkComboBoxEntry" id="comboboxentry"> + <object class="GtkComboBoxText" id="comboboxentry"> <property name="visible">True</property> + <property name="has-entry">True</property> </object> <packing> <property name="position">0</property> diff --git a/mate-panel/panel-separator.c b/mate-panel/panel-separator.c index 0f286e5d..7cb378fd 100644 --- a/mate-panel/panel-separator.c +++ b/mate-panel/panel-separator.c @@ -43,43 +43,91 @@ G_DEFINE_TYPE (PanelSeparator, panel_separator, GTK_TYPE_EVENT_BOX) static void panel_separator_paint (GtkWidget *widget, +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_t *cr) +#else GdkRectangle *area) +#endif { PanelSeparator *separator; GdkWindow *window; GtkStyle *style; +#if GTK_CHECK_VERSION (3, 0, 0) + int width; + int height; +#else GtkAllocation allocation; +#endif separator = PANEL_SEPARATOR (widget); window = gtk_widget_get_window (widget); style = gtk_widget_get_style (widget); +#if GTK_CHECK_VERSION (3, 0, 0) + width = gtk_widget_get_allocated_width (widget); + height = gtk_widget_get_allocated_height (widget); +#else gtk_widget_get_allocation (widget, &allocation); +#endif if (separator->priv->orientation == GTK_ORIENTATION_HORIZONTAL) { - gtk_paint_vline (style, window, + gtk_paint_vline (style, +#if GTK_CHECK_VERSION (3, 0, 0) + cr, +#else + window, +#endif gtk_widget_get_state (widget), - area, widget, "separator", +#if !GTK_CHECK_VERSION (3, 0, 0) + area, +#endif + widget, "separator", style->xthickness, +#if GTK_CHECK_VERSION (3, 0, 0) + height - style->xthickness, + (width - style->xthickness) / 2); +#else allocation.height - style->xthickness, (allocation.width - style->xthickness) / 2); +#endif } else { - gtk_paint_hline (style, window, + gtk_paint_hline (style, +#if GTK_CHECK_VERSION (3, 0, 0) + cr, +#else + window, +#endif gtk_widget_get_state (widget), - area, widget, "separator", +#if !GTK_CHECK_VERSION (3, 0, 0) + area, +#endif + widget, "separator", style->ythickness, +#if GTK_CHECK_VERSION (3, 0, 0) + width - style->ythickness, + (height - style->ythickness) / 2); +#else allocation.width - style->ythickness, (allocation.height - style->ythickness) / 2); +#endif } } +#if GTK_CHECK_VERSION (3, 0, 0) +static gboolean panel_separator_draw(GtkWidget* widget, cairo_t* cr) +#else static gboolean panel_separator_expose_event(GtkWidget* widget, GdkEventExpose* event) +#endif { if (gtk_widget_is_drawable(widget)) { +#if GTK_CHECK_VERSION (3, 0, 0) + GTK_WIDGET_CLASS(panel_separator_parent_class)->draw(widget, cr); + panel_separator_paint(widget, cr); +#else GTK_WIDGET_CLASS(panel_separator_parent_class)->expose_event(widget, event); - panel_separator_paint(widget, &event->area); +#endif } return FALSE; @@ -105,6 +153,28 @@ panel_separator_size_request (GtkWidget *widget, } } +#if GTK_CHECK_VERSION (3, 0, 0) +static void +panel_separator_get_preferred_width (GtkWidget *widget, + gint *minimum_width, + gint *natural_width) +{ + GtkRequisition req; + panel_separator_size_request (widget, &req); + *minimum_width = *natural_width = req.width; +} + +static void +panel_separator_get_preferred_height (GtkWidget *widget, + gint *minimum_height, + gint *natural_height) +{ + GtkRequisition req; + panel_separator_size_request (widget, &req); + *minimum_height = *natural_height = req.height; +} +#endif + static void panel_separator_size_allocate (GtkWidget *widget, GtkAllocation *allocation) @@ -157,8 +227,14 @@ panel_separator_class_init (PanelSeparatorClass *klass) { GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); +#if GTK_CHECK_VERSION (3, 0, 0) + widget_class->draw = panel_separator_draw; + widget_class->get_preferred_width = panel_separator_get_preferred_width; + widget_class->get_preferred_height = panel_separator_get_preferred_height; +#else widget_class->expose_event = panel_separator_expose_event; widget_class->size_request = panel_separator_size_request; +#endif widget_class->size_allocate = panel_separator_size_allocate; widget_class->parent_set = panel_separator_parent_set; diff --git a/mate-panel/panel-session.c b/mate-panel/panel-session.c index dbfcebb5..5f43f3f4 100644 --- a/mate-panel/panel-session.c +++ b/mate-panel/panel-session.c @@ -26,7 +26,11 @@ #include <stdlib.h> +#include <gtk/gtk.h> #include <gdk/gdk.h> +#if GTK_CHECK_VERSION (3, 0, 0) +#include <gdk/gdkx.h> +#endif #include <libegg/eggsmclient.h> @@ -76,5 +80,9 @@ panel_session_init (void) /* We don't want the WM to try and save/restore our * window position */ +#if GTK_CHECK_VERSION (3, 0, 0) + gdk_x11_set_sm_client_id (NULL); +#else gdk_set_sm_client_id (NULL); +#endif } diff --git a/mate-panel/panel-toplevel.c b/mate-panel/panel-toplevel.c index 692ca441..0ea04bfd 100644 --- a/mate-panel/panel-toplevel.c +++ b/mate-panel/panel-toplevel.c @@ -33,6 +33,9 @@ #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> +#if GTK_CHECK_VERSION (3, 0, 0) +#include <gdk/gdkkeysyms-compat.h> +#endif #include <glib/gi18n.h> #include "panel-profile.h" @@ -2940,7 +2943,11 @@ panel_toplevel_unrealize (GtkWidget *widget) } static void +#if GTK_CHECK_VERSION (3, 0, 0) +panel_toplevel_dispose (GObject *widget) +#else panel_toplevel_destroy (GtkObject *widget) +#endif { PanelToplevel *toplevel = (PanelToplevel *) widget; @@ -2954,8 +2961,12 @@ panel_toplevel_destroy (GtkObject *widget) panel_toplevel_disconnect_timeouts (toplevel); +#if GTK_CHECK_VERSION (3, 0, 0) + G_OBJECT_CLASS (panel_toplevel_parent_class)->dispose (widget); +#else if (GTK_OBJECT_CLASS (panel_toplevel_parent_class)->destroy) GTK_OBJECT_CLASS (panel_toplevel_parent_class)->destroy (widget); +#endif } static void @@ -3028,6 +3039,28 @@ panel_toplevel_size_request (GtkWidget *widget, panel_toplevel_move_resize_window (toplevel, position_changed, size_changed); } +#if GTK_CHECK_VERSION (3, 0, 0) +static void +panel_toplevel_get_preferred_width (GtkWidget *widget, + gint *minimum_width, + gint *natural_width) +{ + GtkRequisition req; + panel_toplevel_size_request (widget, &req); + *minimum_width = *natural_width = req.width; +} + +static void +panel_toplevel_get_preferred_height (GtkWidget *widget, + gint *minimum_height, + gint *natural_height) +{ + GtkRequisition req; + panel_toplevel_size_request (widget, &req); + *minimum_height = *natural_height = req.height; +} +#endif + static void panel_toplevel_size_allocate (GtkWidget *widget, GtkAllocation *allocation) @@ -3098,7 +3131,11 @@ panel_toplevel_size_allocate (GtkWidget *widget, gtk_widget_size_allocate (child, &challoc); } +#if GTK_CHECK_VERSION (3, 0, 0) +static gboolean panel_toplevel_draw(GtkWidget* widget, cairo_t* cr) +#else static gboolean panel_toplevel_expose(GtkWidget* widget, GdkEventExpose* event) +#endif { PanelToplevel* toplevel = (PanelToplevel*) widget; PanelFrameEdge edges; @@ -3106,16 +3143,30 @@ static gboolean panel_toplevel_expose(GtkWidget* widget, GdkEventExpose* event) GdkWindow *window; GtkStyle *style; GtkStateType state; +#if GTK_CHECK_VERSION (3, 0, 0) + int awidth; + int aheight; +#else GtkAllocation allocation; +#endif if (!gtk_widget_is_drawable (widget)) return retval; +#if GTK_CHECK_VERSION (3, 0, 0) + if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)->draw) + retval = GTK_WIDGET_CLASS (panel_toplevel_parent_class)->draw (widget, cr); +#else if (GTK_WIDGET_CLASS (panel_toplevel_parent_class)->expose_event) retval = GTK_WIDGET_CLASS (panel_toplevel_parent_class)->expose_event (widget, event); +#endif edges = toplevel->priv->edges; +#if GTK_CHECK_VERSION (3, 0, 0) + panel_frame_draw (widget, cr, edges); +#else panel_frame_draw (widget, edges); +#endif if (toplevel->priv->expand || toplevel->priv->buttons_enabled || @@ -3125,16 +3176,27 @@ static gboolean panel_toplevel_expose(GtkWidget* widget, GdkEventExpose* event) window = gtk_widget_get_window (widget); style = gtk_widget_get_style (widget); state = gtk_widget_get_state (widget); +#if GTK_CHECK_VERSION (3, 0, 0) + awidth = gtk_widget_get_allocated_width (widget); + aheight = gtk_widget_get_allocated_height (widget); +#else gtk_widget_get_allocation (widget, &allocation); +#endif if (toplevel->priv->orientation & PANEL_HORIZONTAL_MASK) { int x, y, width, height; int xthickness, ythickness; +#if GTK_CHECK_VERSION (3, 0, 0) + x = 0; + y = 0; + height = height; +#else x = allocation.x; y = allocation.y; - width = HANDLE_SIZE; height = allocation.height; +#endif + width = HANDLE_SIZE; xthickness = style->xthickness; ythickness = style->ythickness; @@ -3148,28 +3210,56 @@ static gboolean panel_toplevel_expose(GtkWidget* widget, GdkEventExpose* event) if (edges & PANEL_EDGE_LEFT) x += xthickness; - gtk_paint_handle (style, window, state, + gtk_paint_handle (style, +#if GTK_CHECK_VERSION (3, 0, 0) + cr, +#else + window, +#endif + state, GTK_SHADOW_OUT, - &event->area, widget, "handlebox", +#if !GTK_CHECK_VERSION (3, 0, 0) + &event->area, +#endif + widget, "handlebox", x, y, width, height, GTK_ORIENTATION_VERTICAL); +#if GTK_CHECK_VERSION (3, 0, 0) + x = awidth - HANDLE_SIZE; +#else x = allocation.width - HANDLE_SIZE; +#endif if (edges & PANEL_EDGE_RIGHT) x -= xthickness; - gtk_paint_handle (style, window, state, + gtk_paint_handle (style, +#if GTK_CHECK_VERSION (3, 0, 0) + cr, +#else + window, +#endif + state, GTK_SHADOW_OUT, - &event->area, widget, "handlebox", +#if !GTK_CHECK_VERSION (3, 0, 0) + &event->area, +#endif + widget, "handlebox", x, y, width, height, GTK_ORIENTATION_VERTICAL); } else { int x, y, width, height; int xthickness, ythickness; +#if GTK_CHECK_VERSION (3, 0, 0) + x = 0; + y = 0; + width = awidth; +#else x = allocation.x; y = allocation.y; width = allocation.width; +#endif height = HANDLE_SIZE; xthickness = style->xthickness; @@ -3184,19 +3274,41 @@ static gboolean panel_toplevel_expose(GtkWidget* widget, GdkEventExpose* event) if (edges & PANEL_EDGE_TOP) y += ythickness; - gtk_paint_handle (style, window, state, + gtk_paint_handle (style, +#if GTK_CHECK_VERSION (3, 0, 0) + cr, +#else + window, +#endif + state, GTK_SHADOW_OUT, - &event->area, widget, "handlebox", +#if !GTK_CHECK_VERSION (3, 0, 0) + &event->area, +#endif + widget, "handlebox", x, y, width, height, GTK_ORIENTATION_HORIZONTAL); +#if GTK_CHECK_VERSION (3, 0, 0) + y = aheight - HANDLE_SIZE; +#else y = allocation.height - HANDLE_SIZE; +#endif if (edges & PANEL_EDGE_BOTTOM) y -= ythickness; - gtk_paint_handle (style, window, state, + gtk_paint_handle (style, +#if GTK_CHECK_VERSION (3, 0, 0) + cr, +#else + window, +#endif + state, GTK_SHADOW_OUT, - &event->area, widget, "handlebox", +#if !GTK_CHECK_VERSION (3, 0, 0) + &event->area, +#endif + widget, "handlebox", x, y, width, height, GTK_ORIENTATION_HORIZONTAL); } @@ -4040,7 +4152,9 @@ static void panel_toplevel_class_init (PanelToplevelClass *klass) { GObjectClass *gobject_class = (GObjectClass *) klass; +#if !GTK_CHECK_VERSION (3, 0, 0) GtkObjectClass *gtkobject_class = (GtkObjectClass *) klass; +#endif GtkWidgetClass *widget_class = (GtkWidgetClass *) klass; GtkContainerClass *container_class = (GtkContainerClass *) klass; GtkBindingSet *binding_set; @@ -4051,13 +4165,23 @@ panel_toplevel_class_init (PanelToplevelClass *klass) gobject_class->get_property = panel_toplevel_get_property; gobject_class->finalize = panel_toplevel_finalize; +#if GTK_CHECK_VERSION (3, 0, 0) + gobject_class->dispose = panel_toplevel_dispose; +#else gtkobject_class->destroy = panel_toplevel_destroy; +#endif widget_class->realize = panel_toplevel_realize; widget_class->unrealize = panel_toplevel_unrealize; +#if GTK_CHECK_VERSION (3, 0, 0) + widget_class->draw = panel_toplevel_draw; + widget_class->get_preferred_width = panel_toplevel_get_preferred_width; + widget_class->get_preferred_height = panel_toplevel_get_preferred_height; +#else + widget_class->expose_event = panel_toplevel_expose; widget_class->size_request = panel_toplevel_size_request; +#endif widget_class->size_allocate = panel_toplevel_size_allocate; - widget_class->expose_event = panel_toplevel_expose; widget_class->button_press_event = panel_toplevel_button_press_event; widget_class->button_release_event = panel_toplevel_button_release_event; widget_class->key_press_event = panel_toplevel_key_press_event; diff --git a/mate-panel/panel-util.c b/mate-panel/panel-util.c index 2259aff3..dd6ad79b 100644 --- a/mate-panel/panel-util.c +++ b/mate-panel/panel-util.c @@ -29,6 +29,12 @@ #include <gio/gio.h> #include <gdk-pixbuf/gdk-pixbuf.h> +#if GTK_CHECK_VERSION (3, 0, 0) +#define MATE_DESKTOP_USE_UNSTABLE_API +#include <libmate-desktop/mate-desktop-utils.h> +#endif +#include <libmate-desktop/mate-gsettings.h> + #include <libpanel-util/panel-error.h> #include <libpanel-util/panel-glib.h> #include <libpanel-util/panel-keyfile.h> @@ -428,7 +434,11 @@ void panel_lock_screen_action(GdkScreen* screen, const char* action) return; } +#if GTK_CHECK_VERSION (3, 0, 0) + if (!mate_gdk_spawn_command_line_on_screen(screen, command, &error)) +#else if (!gdk_spawn_command_line_on_screen(screen, command, &error)) +#endif { char* primary = g_strdup_printf(_("Could not execute '%s'"), command); panel_error_dialog (NULL, screen, "cannot_exec_screensaver", TRUE, primary, error->message); @@ -830,14 +840,16 @@ panel_util_get_file_display_for_common_files (GFile *file) compare = g_file_new_for_path (g_get_home_dir ()); if (g_file_equal (file, compare)) { GSettings *caja_desktop_settings; - char *caja_home_icon_name; + char *caja_home_icon_name = NULL; g_object_unref (compare); - caja_desktop_settings = g_settings_new (CAJA_DESKTOP_SCHEMA); - caja_home_icon_name = g_settings_get_string (caja_desktop_settings, - CAJA_DESKTOP_HOME_ICON_NAME_KEY); - g_object_unref (caja_desktop_settings); + if (mate_gsettings_schema_exists (CAJA_DESKTOP_SCHEMA)) { + caja_desktop_settings = g_settings_new (CAJA_DESKTOP_SCHEMA); + caja_home_icon_name = g_settings_get_string (caja_desktop_settings, + CAJA_DESKTOP_HOME_ICON_NAME_KEY); + g_object_unref (caja_desktop_settings); + } if (PANEL_GLIB_STR_EMPTY (caja_home_icon_name)) { g_free (caja_home_icon_name); return g_strdup (_("Home Folder")); diff --git a/mate-panel/panel-widget.c b/mate-panel/panel-widget.c index 1800a7b5..969096b2 100644 --- a/mate-panel/panel-widget.c +++ b/mate-panel/panel-widget.c @@ -9,8 +9,12 @@ #include <string.h> #include <stdlib.h> -#include <gdk/gdkkeysyms.h> #include <gtk/gtk.h> +#include <gdk/gdkkeysyms.h> +#if GTK_CHECK_VERSION (3, 0, 0) +#include <gtk/gtkx.h> /* for GTK_IS_SOCKET */ +#include <gdk/gdkkeysyms-compat.h> +#endif #include <libpanel-util/panel-list.h> @@ -59,6 +63,14 @@ static guint panel_widget_signals [LAST_SIGNAL] = {0}; static gboolean mate_panel_applet_in_drag = FALSE; static GtkWidget *saved_focus_widget = NULL; +#if GTK_CHECK_VERSION (3, 0, 0) +static void panel_widget_get_preferred_width (GtkWidget *widget, + gint *minimum_width, + gint *natural_width); +static void panel_widget_get_preferred_height (GtkWidget *widget, + gint *minimum_height, + gint *natural_height); +#endif static void panel_widget_size_request (GtkWidget *widget, GtkRequisition *requisition); static void panel_widget_size_allocate (GtkWidget *widget, @@ -67,7 +79,11 @@ static void panel_widget_cadd (GtkContainer *container, GtkWidget *widget); static void panel_widget_cremove (GtkContainer *container, GtkWidget *widget); +#if GTK_CHECK_VERSION (3, 0, 0) +static void panel_widget_dispose (GObject *obj); +#else static void panel_widget_destroy (GtkObject *obj); +#endif static void panel_widget_finalize (GObject *obj); static void panel_widget_realize (GtkWidget *widget); static void panel_widget_unrealize (GtkWidget *panel); @@ -274,8 +290,12 @@ remove_all_move_bindings (PanelWidget *panel) static void panel_widget_class_init (PanelWidgetClass *class) { +#if GTK_CHECK_VERSION (3, 0, 0) + GObjectClass *object_class = (GObjectClass*) class; +#else GtkObjectClass *object_class = (GtkObjectClass*) class; GObjectClass *gobject_class = (GObjectClass*) class; +#endif GtkWidgetClass *widget_class = (GtkWidgetClass*) class; GtkContainerClass *container_class = (GtkContainerClass*) class; @@ -407,10 +427,20 @@ panel_widget_class_init (PanelWidgetClass *class) class->tab_move = panel_widget_tab_move; class->end_move = panel_widget_end_move; +#if GTK_CHECK_VERSION (3, 0, 0) + object_class->dispose = panel_widget_dispose; + object_class->finalize = panel_widget_finalize; +#else object_class->destroy = panel_widget_destroy; gobject_class->finalize = panel_widget_finalize; - +#endif + +#if GTK_CHECK_VERSION (3, 0, 0) + widget_class->get_preferred_width = panel_widget_get_preferred_width; + widget_class->get_preferred_height = panel_widget_get_preferred_height; +#else widget_class->size_request = panel_widget_size_request; +#endif widget_class->size_allocate = panel_widget_size_allocate; widget_class->realize = panel_widget_realize; widget_class->unrealize = panel_widget_unrealize; @@ -1294,6 +1324,28 @@ panel_widget_size_request(GtkWidget *widget, GtkRequisition *requisition) } } +#if GTK_CHECK_VERSION (3, 0, 0) +static void +panel_widget_get_preferred_width (GtkWidget *widget, + gint *minimum_width, + gint *natural_width) +{ + GtkRequisition req; + panel_widget_size_request (widget, &req); + *minimum_width = *natural_width = req.width; +} + +static void +panel_widget_get_preferred_height (GtkWidget *widget, + gint *minimum_height, + gint *natural_height) +{ + GtkRequisition req; + panel_widget_size_request (widget, &req); + *minimum_height = *natural_height = req.height; +} +#endif + static void queue_resize_on_all_applets(PanelWidget *panel) { @@ -1568,7 +1620,11 @@ panel_widget_style_set (GtkWidget *widget, panel_background_set_default_style ( &PANEL_WIDGET (widget)->background, &style->bg [state], +#if GTK_CHECK_VERSION (3, 0, 0) + style->background [state]); +#else style->bg_pixmap [state]); +#endif } } @@ -1586,7 +1642,11 @@ panel_widget_state_changed (GtkWidget *widget, panel_background_set_default_style ( &PANEL_WIDGET (widget)->background, &style->bg [state], +#if GTK_CHECK_VERSION (3, 0, 0) + style->background [state]); +#else style->bg_pixmap [state]); +#endif } } @@ -1624,7 +1684,11 @@ panel_widget_realize (GtkWidget *widget) panel_background_set_default_style ( &panel->background, &style->bg [state], +#if GTK_CHECK_VERSION (3, 0, 0) + style->background [state]); +#else style->bg_pixmap [state]); +#endif panel_background_realized (&panel->background, window); } @@ -1694,7 +1758,11 @@ panel_widget_destroy_open_dialogs (PanelWidget *panel_widget) } static void +#if GTK_CHECK_VERSION (3, 0, 0) +panel_widget_dispose (GObject *obj) +#else panel_widget_destroy (GtkObject *obj) +#endif { PanelWidget *panel; @@ -1715,8 +1783,12 @@ panel_widget_destroy (GtkObject *obj) panel->master_widget = NULL; } +#if GTK_CHECK_VERSION (3, 0, 0) + G_OBJECT_CLASS (panel_widget_parent_class)->dispose (obj); +#else if (GTK_OBJECT_CLASS (panel_widget_parent_class)->destroy) GTK_OBJECT_CLASS (panel_widget_parent_class)->destroy (obj); +#endif } static void @@ -2328,8 +2400,12 @@ panel_widget_applet_key_press_event (GtkWidget *widget, if (!mate_panel_applet_in_drag) return FALSE; - + +#if GTK_CHECK_VERSION (3, 0, 0) + return gtk_bindings_activate (G_OBJECT (panel), +#else return gtk_bindings_activate (GTK_OBJECT (panel), +#endif ((GdkEventKey *)event)->keyval, ((GdkEventKey *)event)->state); } diff --git a/mate-panel/panel-xutils.c b/mate-panel/panel-xutils.c index 14b57632..e970fb37 100644 --- a/mate-panel/panel-xutils.c +++ b/mate-panel/panel-xutils.c @@ -27,6 +27,7 @@ #include "panel-xutils.h" #include <glib.h> +#include <gtk/gtk.h> #include <gdk/gdk.h> #include <gdk/gdkx.h> #include <X11/Xlib.h> @@ -50,7 +51,11 @@ panel_xutils_set_window_type (GdkWindow *gdk_window, g_return_if_fail (GDK_IS_WINDOW (gdk_window)); display = GDK_WINDOW_XDISPLAY (gdk_window); +#if GTK_CHECK_VERSION (3, 0, 0) + window = GDK_WINDOW_XID (gdk_window); +#else window = GDK_WINDOW_XWINDOW (gdk_window); +#endif if (net_wm_window_type == None) net_wm_window_type = XInternAtom (display, @@ -113,7 +118,11 @@ panel_xutils_set_strut (GdkWindow *gdk_window, g_return_if_fail (GDK_IS_WINDOW (gdk_window)); display = GDK_WINDOW_XDISPLAY (gdk_window); +#if GTK_CHECK_VERSION (3, 0, 0) + window = GDK_WINDOW_XID (gdk_window); +#else window = GDK_WINDOW_XWINDOW (gdk_window); +#endif if (net_wm_strut == None) net_wm_strut = XInternAtom (display, "_NET_WM_STRUT", False); @@ -164,7 +173,11 @@ panel_warp_pointer (GdkWindow *gdk_window, g_return_if_fail (GDK_IS_WINDOW (gdk_window)); display = GDK_WINDOW_XDISPLAY (gdk_window); +#if GTK_CHECK_VERSION (3, 0, 0) + window = GDK_WINDOW_XID (gdk_window); +#else window = GDK_WINDOW_XWINDOW (gdk_window); +#endif gdk_error_trap_push (); XWarpPointer (display, None, window, 0, 0, 0, 0, x, y); diff --git a/mate-panel/panel.c b/mate-panel/panel.c index 15719418..8ac44a88 100644 --- a/mate-panel/panel.c +++ b/mate-panel/panel.c @@ -20,6 +20,7 @@ #include <gtk/gtk.h> #include <gdk/gdkkeysyms.h> #if GTK_CHECK_VERSION (3, 0, 0) +#include <gtk/gtkx.h> /* for GTK_IS_SOCKET */ #include <gdk/gdkkeysyms-compat.h> #endif diff --git a/mate-panel/xstuff.c b/mate-panel/xstuff.c index 6bcc3396..2b54e293 100644 --- a/mate-panel/xstuff.c +++ b/mate-panel/xstuff.c @@ -163,8 +163,11 @@ xstuff_is_compliant_wm (void) int size; xdisplay = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); - root_window = GDK_WINDOW_XWINDOW ( - gdk_get_default_root_window ()); +#if GTK_CHECK_VERSION (3, 0, 0) + root_window = GDK_WINDOW_XID (gdk_get_default_root_window ()); +#else + root_window = GDK_WINDOW_XWINDOW (gdk_get_default_root_window ()); +#endif /* FIXME this is totally broken; should be using * gdk_net_wm_supports() on particular hints when we rely @@ -183,12 +186,6 @@ xstuff_is_compliant_wm (void) return TRUE; } -gboolean -xstuff_net_wm_supports (const char *hint) -{ - return gdk_net_wm_supports (gdk_atom_intern (hint, FALSE)); -} - /* This is such a broken stupid function. */ void xstuff_set_pos_size (GdkWindow *window, int x, int y, int w, int h) @@ -218,7 +215,11 @@ xstuff_set_pos_size (GdkWindow *window, int x, int y, int w, int h) gdk_error_trap_push (); XSetWMNormalHints (GDK_WINDOW_XDISPLAY (window), +#if GTK_CHECK_VERSION (3, 0, 0) + GDK_WINDOW_XID (window), +#else GDK_WINDOW_XWINDOW (window), +#endif &size_hints); gdk_window_move_resize (window, x, y, w, h); @@ -246,7 +247,11 @@ xstuff_set_wmspec_dock_hints (GdkWindow *window, } XChangeProperty (GDK_WINDOW_XDISPLAY (window), +#if GTK_CHECK_VERSION (3, 0, 0) + GDK_WINDOW_XID (window), +#else GDK_WINDOW_XWINDOW (window), +#endif panel_atom_get ("_NET_WM_WINDOW_TYPE"), XA_ATOM, 32, PropModeReplace, (unsigned char *) atoms, @@ -268,7 +273,11 @@ xstuff_set_wmspec_strut (GdkWindow *window, vals [3] = bottom; XChangeProperty (GDK_WINDOW_XDISPLAY (window), +#if GTK_CHECK_VERSION (3, 0, 0) + GDK_WINDOW_XID (window), +#else GDK_WINDOW_XWINDOW (window), +#endif panel_atom_get ("_NET_WM_STRUT"), XA_CARDINAL, 32, PropModeReplace, (unsigned char *) vals, 4); @@ -278,7 +287,11 @@ void xstuff_delete_property (GdkWindow *window, const char *name) { Display *xdisplay = GDK_WINDOW_XDISPLAY (window); +#if GTK_CHECK_VERSION (3, 0, 0) + Window xwindow = GDK_WINDOW_XID (window); +#else Window xwindow = GDK_WINDOW_XWINDOW (window); +#endif XDeleteProperty (xdisplay, xwindow, panel_atom_get (name)); @@ -313,8 +326,13 @@ zoom_timeout (GtkWidget *window) } static gboolean +#if GTK_CHECK_VERSION (3, 0, 0) +zoom_draw (GtkWidget *widget, + cairo_t *cr, +#else zoom_expose (GtkWidget *widget, GdkEventExpose *event, +#endif gpointer user_data) { CompositedZoomData *zoom; @@ -336,7 +354,9 @@ zoom_expose (GtkWidget *widget, GdkPixbuf *scaled; int width, height; int x = 0, y = 0; +#if !GTK_CHECK_VERSION (3, 0, 0) cairo_t *cr; +#endif gtk_window_get_size (GTK_WINDOW (widget), &width, &height); @@ -369,8 +389,9 @@ zoom_expose (GtkWidget *widget, break; } - +#if !GTK_CHECK_VERSION (3, 0, 0) cr = gdk_cairo_create (gtk_widget_get_window (widget)); +#endif cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); cairo_set_source_rgba (cr, 0, 0, 0, 0.0); cairo_rectangle (cr, 0, 0, width, height); @@ -380,7 +401,9 @@ zoom_expose (GtkWidget *widget, cairo_set_operator (cr, CAIRO_OPERATOR_OVER); cairo_paint_with_alpha (cr, MAX (zoom->opacity, 0)); +#if !GTK_CHECK_VERSION (3, 0, 0) cairo_destroy (cr); +#endif g_object_unref (scaled); } @@ -415,7 +438,11 @@ draw_zoom_animation_composited (GdkScreen *gscreen, gtk_window_set_keep_above (GTK_WINDOW (win), TRUE); gtk_window_set_decorated (GTK_WINDOW (win), FALSE); gtk_widget_set_app_paintable(win, TRUE); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_widget_set_visual (win, gdk_screen_get_rgba_visual (gscreen)); +#else gtk_widget_set_colormap (win, gdk_screen_get_rgba_colormap (gscreen)); +#endif gtk_window_set_gravity (GTK_WINDOW (win), GDK_GRAVITY_STATIC); gtk_window_set_default_size (GTK_WINDOW (win), @@ -445,12 +472,21 @@ draw_zoom_animation_composited (GdkScreen *gscreen, gtk_window_move (GTK_WINDOW (win), wx, wy); +#if GTK_CHECK_VERSION (3, 0, 0) + g_signal_connect (G_OBJECT (win), "draw", + G_CALLBACK (zoom_draw), zoom); +#else g_signal_connect (G_OBJECT (win), "expose-event", G_CALLBACK (zoom_expose), zoom); +#endif /* see doc for gtk_widget_set_app_paintable() */ gtk_widget_realize (win); +#if GTK_CHECK_VERSION (3, 0, 0) + gdk_window_set_background_pattern (gtk_widget_get_window (win), NULL); +#else gdk_window_set_back_pixmap (gtk_widget_get_window (win), NULL, FALSE); +#endif gtk_widget_show (win); zoom->timeout_id = g_timeout_add (ZOOM_DELAY, @@ -478,13 +514,23 @@ draw_zoom_animation (GdkScreen *gscreen, int depth; dpy = gdk_x11_display_get_xdisplay (gdk_screen_get_display (gscreen)); +#if GTK_CHECK_VERSION (3, 0, 0) + root_win = GDK_WINDOW_XID (gdk_screen_get_root_window (gscreen)); +#else root_win = gdk_x11_drawable_get_xid (gdk_screen_get_root_window (gscreen)); +#endif screen = gdk_screen_get_number (gscreen); +#if GTK_CHECK_VERSION (3, 0, 0) + depth = DefaultDepth(dpy,screen); +#else depth = gdk_drawable_get_depth (gdk_screen_get_root_window (gscreen)); +#endif /* frame GC */ +#if !GTK_CHECK_VERSION (3, 0, 0) gdk_colormap_alloc_color ( gdk_screen_get_system_colormap (gscreen), &color, FALSE, TRUE); +#endif gcv.function = GXxor; /* this will raise the probability of the XORed color being different * of the original color in PseudoColor when not all color cells are @@ -575,9 +621,10 @@ draw_zoom_animation (GdkScreen *gscreen, XUngrabServer(dpy); XFreeGC (dpy, frame_gc); +#if !GTK_CHECK_VERSION (3, 0, 0) gdk_colormap_free_colors (gdk_screen_get_system_colormap (gscreen), &color, 1); - +#endif } #undef FRAMES @@ -639,8 +686,11 @@ xstuff_get_current_workspace (GdkScreen *screen) int result; int retval; - root_window = gdk_x11_drawable_get_xid ( - gdk_screen_get_root_window (screen)); +#if GTK_CHECK_VERSION (3, 0, 0) + root_window = GDK_WINDOW_XID (gdk_screen_get_root_window (screen)); +#else + root_window = gdk_x11_drawable_get_xid (gdk_screen_get_root_window (screen)); +#endif gdk_error_trap_push (); result = XGetWindowProperty (GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen)), @@ -685,12 +735,20 @@ xstuff_grab_key_on_all_screens (int keycode, if (grab) XGrabKey (gdk_x11_display_get_xdisplay (display), keycode, modifiers, +#if GTK_CHECK_VERSION (3, 0, 0) + GDK_WINDOW_XID (root), +#else gdk_x11_drawable_get_xid (root), +#endif True, GrabModeAsync, GrabModeAsync); else XUngrabKey (gdk_x11_display_get_xdisplay (display), keycode, modifiers, +#if GTK_CHECK_VERSION (3, 0, 0) + GDK_WINDOW_XID (root)); +#else gdk_x11_drawable_get_xid (root)); +#endif } } diff --git a/mate-panel/xstuff.h b/mate-panel/xstuff.h index 0bd5f92b..e441f182 100644 --- a/mate-panel/xstuff.h +++ b/mate-panel/xstuff.h @@ -7,7 +7,6 @@ void xstuff_delete_property (GdkWindow *window, const char *name); gboolean xstuff_is_compliant_wm (void); -gboolean xstuff_net_wm_supports (const char *hint); void xstuff_unsetup_desktop_area (void); void xstuff_set_pos_size (GdkWindow *window, |