diff options
39 files changed, 1708 insertions, 116 deletions
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, |