diff options
author | monsta <[email protected]> | 2016-11-20 22:24:08 +0300 |
---|---|---|
committer | monsta <[email protected]> | 2016-11-20 22:24:08 +0300 |
commit | de1227d4355f56017270f3a7541b8be21fd955af (patch) | |
tree | 37ad9b1c13c571ed51da2c5649e33cb9a2a9e7fe /plugins/common | |
parent | c0e9048f916f4141292ca3b107735496e698cac5 (diff) | |
download | mate-settings-daemon-de1227d4355f56017270f3a7541b8be21fd955af.tar.bz2 mate-settings-daemon-de1227d4355f56017270f3a7541b8be21fd955af.tar.xz |
move to GTK+3 (>= 3.14), drop GTK+2 code and --with-gtk build option
and require libmatekbd and libmate-desktop >= 1.17
Diffstat (limited to 'plugins/common')
-rw-r--r-- | plugins/common/eggaccelerators.h | 1 | ||||
-rw-r--r-- | plugins/common/msd-input-helper.c | 10 | ||||
-rw-r--r-- | plugins/common/msd-osd-window.c | 292 | ||||
-rw-r--r-- | plugins/common/msd-osd-window.h | 17 |
4 files changed, 4 insertions, 316 deletions
diff --git a/plugins/common/eggaccelerators.h b/plugins/common/eggaccelerators.h index 74a19e4..8584373 100644 --- a/plugins/common/eggaccelerators.h +++ b/plugins/common/eggaccelerators.h @@ -21,7 +21,6 @@ #ifndef __EGG_ACCELERATORS_H__ #define __EGG_ACCELERATORS_H__ -#include <gtk/gtk.h> #include <gdk/gdk.h> #ifdef __cplusplus diff --git a/plugins/common/msd-input-helper.c b/plugins/common/msd-input-helper.c index 35cc060..7101e43 100644 --- a/plugins/common/msd-input-helper.c +++ b/plugins/common/msd-input-helper.c @@ -22,7 +22,6 @@ #include <gdk/gdk.h> #include <gdk/gdkx.h> -#include <gtk/gtk.h> #include <sys/types.h> #include <X11/Xatom.h> @@ -66,19 +65,12 @@ device_is_touchpad (XDeviceInfo *deviceinfo) if ((XGetDeviceProperty (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device, prop, 0, 1, False, XA_INTEGER, &realtype, &realformat, &nitems, &bytes_after, &data) == Success) && (realtype != None)) { -#if GTK_CHECK_VERSION (3, 0, 0) gdk_error_trap_pop_ignored (); -#else - gdk_error_trap_pop (); -#endif XFree (data); return device; } -#if GTK_CHECK_VERSION (3, 0, 0) + gdk_error_trap_pop_ignored (); -#else - gdk_error_trap_pop (); -#endif XCloseDevice (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), device); return NULL; diff --git a/plugins/common/msd-osd-window.c b/plugins/common/msd-osd-window.c index 0ed2bf4..49b01cb 100644 --- a/plugins/common/msd-osd-window.c +++ b/plugins/common/msd-osd-window.c @@ -55,11 +55,7 @@ struct MsdOsdWindowPrivate }; enum { -#if GTK_CHECK_VERSION (3, 0, 0) DRAW_WHEN_COMPOSITED, -#else - EXPOSE_WHEN_COMPOSITED, -#endif LAST_SIGNAL }; @@ -143,137 +139,27 @@ add_hide_timeout (MsdOsdWindow *window) window); } -#if !GTK_CHECK_VERSION (3, 0, 0) -void -msd_osd_window_draw_rounded_rectangle (cairo_t* cr, - gdouble aspect, - gdouble x, - gdouble y, - gdouble corner_radius, - gdouble width, - gdouble height) -{ - gdouble radius = corner_radius / aspect; - - cairo_move_to (cr, x + radius, y); - - cairo_line_to (cr, - x + width - radius, - y); - cairo_arc (cr, - x + width - radius, - y + radius, - radius, - -90.0f * G_PI / 180.0f, - 0.0f * G_PI / 180.0f); - cairo_line_to (cr, - x + width, - y + height - radius); - cairo_arc (cr, - x + width - radius, - y + height - radius, - radius, - 0.0f * G_PI / 180.0f, - 90.0f * G_PI / 180.0f); - cairo_line_to (cr, - x + radius, - y + height); - cairo_arc (cr, - x + radius, - y + height - radius, - radius, - 90.0f * G_PI / 180.0f, - 180.0f * G_PI / 180.0f); - cairo_line_to (cr, - x, - y + radius); - cairo_arc (cr, - x + radius, - y + radius, - radius, - 180.0f * G_PI / 180.0f, - 270.0f * G_PI / 180.0f); - cairo_close_path (cr); -} - -void -msd_osd_window_color_reverse (const GdkColor *a, - GdkColor *b) -{ - gdouble red; - gdouble green; - gdouble blue; - gdouble h; - gdouble s; - gdouble v; - - red = (gdouble) a->red / 65535.0; - green = (gdouble) a->green / 65535.0; - blue = (gdouble) a->blue / 65535.0; - - gtk_rgb_to_hsv (red, green, blue, &h, &s, &v); - - v = 0.5 + (0.5 - v); - if (v > 1.0) - v = 1.0; - else if (v < 0.0) - v = 0.0; - - gtk_hsv_to_rgb (h, s, v, &red, &green, &blue); - - b->red = red * 65535.0; - b->green = green * 65535.0; - b->blue = blue * 65535.0; -} -#endif - -/* This is our expose/draw-event handler when the window is in a compositing manager. +/* This is our draw-event handler when the window is in a compositing manager. * We draw everything by hand, using Cairo, so that we can have a nice * transparent/rounded look. */ static void -#if GTK_CHECK_VERSION (3, 0, 0) draw_when_composited (GtkWidget *widget, cairo_t *orig_cr) -#else -expose_when_composited (GtkWidget *widget, GdkEventExpose *event) -#endif { MsdOsdWindow *window; -#if !GTK_CHECK_VERSION (3, 0, 0) - cairo_t *context; -#endif cairo_t *cr; cairo_surface_t *surface; int width; int height; -#if GTK_CHECK_VERSION (3, 0, 0) GtkStyleContext *context; -#else - GtkStyle *style; - GdkColor color; - double r, g, b; -#endif window = MSD_OSD_WINDOW (widget); -#if !GTK_CHECK_VERSION (3, 0, 0) - context = gdk_cairo_create (gtk_widget_get_window (widget)); -#endif - -#if GTK_CHECK_VERSION (3, 0, 0) context = gtk_widget_get_style_context (widget); cairo_set_operator (orig_cr, CAIRO_OPERATOR_SOURCE); -#else - style = gtk_widget_get_style (widget); - cairo_set_operator (context, CAIRO_OPERATOR_SOURCE); -#endif gtk_window_get_size (GTK_WINDOW (widget), &width, &height); -#if GTK_CHECK_VERSION (3, 0, 0) surface = cairo_surface_create_similar (cairo_get_target (orig_cr), -#else - surface = cairo_surface_create_similar (cairo_get_target (context), -#endif CAIRO_CONTENT_COLOR_ALPHA, width, height); @@ -286,75 +172,34 @@ expose_when_composited (GtkWidget *widget, GdkEventExpose *event) if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) { goto done; } -#if !GTK_CHECK_VERSION (3, 0, 0) - cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0); - cairo_set_operator (cr, CAIRO_OPERATOR_OVER); - cairo_paint (cr); -#endif -#if GTK_CHECK_VERSION (3, 0, 0) gtk_render_background (context, cr, 0, 0, width, height); gtk_render_frame (context, cr, 0, 0, width, height); -#else - /* draw a box */ - msd_osd_window_draw_rounded_rectangle (cr, 1.0, 0.5, 0.5, height / 10, width-1, height-1); - msd_osd_window_color_reverse (&style->bg[GTK_STATE_NORMAL], &color); - r = (float)color.red / 65535.0; - g = (float)color.green / 65535.0; - b = (float)color.blue / 65535.0; - cairo_set_source_rgba (cr, r, g, b, BG_ALPHA); - cairo_fill_preserve (cr); - - msd_osd_window_color_reverse (&style->text_aa[GTK_STATE_NORMAL], &color); - r = (float)color.red / 65535.0; - g = (float)color.green / 65535.0; - b = (float)color.blue / 65535.0; - cairo_set_source_rgba (cr, r, g, b, BG_ALPHA / 2); - cairo_set_line_width (cr, 1); - cairo_stroke (cr); -#endif -#if GTK_CHECK_VERSION (3, 0, 0) g_signal_emit (window, signals[DRAW_WHEN_COMPOSITED], 0, cr); -#else - g_signal_emit (window, signals[EXPOSE_WHEN_COMPOSITED], 0, cr); -#endif cairo_destroy (cr); /* Make sure we have a transparent background */ -#if GTK_CHECK_VERSION (3, 0, 0) cairo_rectangle (orig_cr, 0, 0, width, height); cairo_set_source_rgba (orig_cr, 0.0, 0.0, 0.0, 0.0); cairo_fill (orig_cr); cairo_set_source_surface (orig_cr, surface, 0, 0); cairo_paint_with_alpha (orig_cr, window->priv->fade_out_alpha); -#else - cairo_rectangle (context, 0, 0, width, height); - cairo_set_source_rgba (context, 0.0, 0.0, 0.0, 0.0); - cairo_fill (context); - - cairo_set_source_surface (context, surface, 0, 0); - cairo_paint_with_alpha (context, window->priv->fade_out_alpha); -#endif done: if (surface != NULL) { cairo_surface_destroy (surface); } -#if !GTK_CHECK_VERSION (3, 0, 0) - cairo_destroy (context); -#endif } -/* This is our expose/draw-event handler when the window is *not* in a compositing manager. +/* This is our draw-event handler when the window is *not* in a compositing manager. * We just draw a rectangular frame by hand. We do this with hardcoded drawing code, * instead of GtkFrame, to avoid changing the window's internal widget hierarchy: in * either case (composited or non-composited), callers can assume that this works * identically to a GtkWindow without any intermediate widgetry. */ -#if GTK_CHECK_VERSION (3, 0, 0) static void draw_when_not_composited (GtkWidget *widget, cairo_t *cr) { @@ -374,29 +219,7 @@ draw_when_not_composited (GtkWidget *widget, cairo_t *cr) width, height); } -#else -static void -expose_when_not_composited (GtkWidget *widget, GdkEventExpose *event) -{ - GtkAllocation allocation; - - gtk_widget_get_allocation (widget, &allocation); - - gtk_paint_shadow (gtk_widget_get_style (widget), - gtk_widget_get_window (widget), - gtk_widget_get_state (widget), - GTK_SHADOW_OUT, - &event->area, - widget, - NULL, /* NULL detail -> themes should use the MsdOsdWindow widget name, probably */ - 0, - 0, - allocation.width, - allocation.height); -} -#endif -#if GTK_CHECK_VERSION (3, 0, 0) static gboolean msd_osd_window_draw (GtkWidget *widget, cairo_t *cr) @@ -417,28 +240,6 @@ msd_osd_window_draw (GtkWidget *widget, return FALSE; } -#else -static gboolean -msd_osd_window_expose_event (GtkWidget *widget, - GdkEventExpose *event) -{ - MsdOsdWindow *window; - GtkWidget *child; - - window = MSD_OSD_WINDOW (widget); - - if (window->priv->is_composited) - expose_when_composited (widget, event); - else - expose_when_not_composited (widget, event); - - child = gtk_bin_get_child (GTK_BIN (window)); - if (child) - gtk_container_propagate_expose (GTK_CONTAINER (window), child, event); - - return FALSE; -} -#endif static void msd_osd_window_real_show (GtkWidget *widget) @@ -470,7 +271,6 @@ msd_osd_window_real_hide (GtkWidget *widget) static void msd_osd_window_real_realize (GtkWidget *widget) { -#if GTK_CHECK_VERSION (3, 0, 0) GdkScreen *screen; GdkVisual *visual; cairo_region_t *region; @@ -492,40 +292,8 @@ msd_osd_window_real_realize (GtkWidget *widget) region = cairo_region_create (); gtk_widget_input_shape_combine_region (widget, region); cairo_region_destroy (region); -#else - GdkColormap *colormap; - GtkAllocation allocation; - GdkBitmap *mask; - cairo_t *cr; - - colormap = gdk_screen_get_rgba_colormap (gtk_widget_get_screen (widget)); - - if (colormap != NULL) { - gtk_widget_set_colormap (widget, colormap); - } - - if (GTK_WIDGET_CLASS (msd_osd_window_parent_class)->realize) { - GTK_WIDGET_CLASS (msd_osd_window_parent_class)->realize (widget); - } - - gtk_widget_get_allocation (widget, &allocation); - mask = gdk_pixmap_new (gtk_widget_get_window (widget), - allocation.width, - allocation.height, - 1); - cr = gdk_cairo_create (mask); - - cairo_set_source_rgba (cr, 1., 1., 1., 0.); - cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); - cairo_paint (cr); - - /* make the whole window ignore events */ - gdk_window_input_shape_combine_mask (gtk_widget_get_window (widget), mask, 0, 0); - g_object_unref (mask); - cairo_destroy (cr); -#endif } -#if GTK_CHECK_VERSION (3, 0, 0) + static void msd_osd_window_style_updated (GtkWidget *widget) { @@ -543,25 +311,7 @@ msd_osd_window_style_updated (GtkWidget *widget) gtk_style_context_get_padding (context, GTK_STATE_FLAG_NORMAL, &padding); gtk_container_set_border_width (GTK_CONTAINER (widget), 12 + MAX (padding.left, padding.top)); } -#else -static void -msd_osd_window_style_set (GtkWidget *widget, - GtkStyle *previous_style) -{ - GtkStyle *style; - - GTK_WIDGET_CLASS (msd_osd_window_parent_class)->style_set (widget, previous_style); - /* We set our border width to 12 (per the MATE standard), plus the - * thickness of the frame that we draw in our expose/draw handler. This will - * make our child be 12 pixels away from the frame. - */ - - style = gtk_widget_get_style (widget); - gtk_container_set_border_width (GTK_CONTAINER (widget), 12 + MAX (style->xthickness, style->ythickness)); -} -#endif -#if GTK_CHECK_VERSION (3, 0, 0) static void msd_osd_window_get_preferred_width (GtkWidget *widget, gint *minimum, @@ -599,23 +349,6 @@ msd_osd_window_get_preferred_height (GtkWidget *widget, *minimum += padding.top; *natural += padding.top; } -#else -static void -msd_osd_window_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GtkStyle *style; - - GTK_WIDGET_CLASS (msd_osd_window_parent_class)->size_request (widget, requisition); - - /* See the comment in msd_osd_window_style_set() for why we add the thickness here */ - - style = gtk_widget_get_style (widget); - - requisition->width += style->xthickness; - requisition->height += style->ythickness; -} -#endif static GObject * msd_osd_window_constructor (GType type, @@ -634,11 +367,9 @@ msd_osd_window_constructor (GType type, "focus-on-map", FALSE, NULL); -#if GTK_CHECK_VERSION (3, 0, 0) GtkWidget *widget = GTK_WIDGET (object); GtkStyleContext *style_context = gtk_widget_get_style_context (widget); gtk_style_context_add_class (style_context, "osd"); -#endif return object; } @@ -654,29 +385,15 @@ msd_osd_window_class_init (MsdOsdWindowClass *klass) widget_class->show = msd_osd_window_real_show; widget_class->hide = msd_osd_window_real_hide; widget_class->realize = msd_osd_window_real_realize; -#if GTK_CHECK_VERSION (3, 0, 0) widget_class->style_updated = msd_osd_window_style_updated; widget_class->get_preferred_width = msd_osd_window_get_preferred_width; widget_class->get_preferred_height = msd_osd_window_get_preferred_height; widget_class->draw = msd_osd_window_draw; -#else - widget_class->style_set = msd_osd_window_style_set; - widget_class->size_request = msd_osd_window_size_request; - widget_class->expose_event = msd_osd_window_expose_event; -#endif -#if GTK_CHECK_VERSION (3, 0, 0) signals[DRAW_WHEN_COMPOSITED] = g_signal_new ("draw-when-composited", -#else - signals[EXPOSE_WHEN_COMPOSITED] = g_signal_new ("expose-when-composited", -#endif G_TYPE_FROM_CLASS (gobject_class), G_SIGNAL_RUN_FIRST, -#if GTK_CHECK_VERSION (3, 0, 0) G_STRUCT_OFFSET (MsdOsdWindowClass, draw_when_composited), -#else - G_STRUCT_OFFSET (MsdOsdWindowClass, expose_when_composited), -#endif NULL, NULL, g_cclosure_marshal_VOID__POINTER, G_TYPE_NONE, 1, @@ -685,7 +402,6 @@ msd_osd_window_class_init (MsdOsdWindowClass *klass) #if GTK_CHECK_VERSION (3, 20, 0) gtk_widget_class_set_css_name (widget_class, "MsdOsdWindow"); #endif - g_type_class_add_private (klass, sizeof (MsdOsdWindowPrivate)); } @@ -733,10 +449,8 @@ msd_osd_window_init (MsdOsdWindow *window) gtk_window_set_decorated (GTK_WINDOW (window), FALSE); gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE); -#if GTK_CHECK_VERSION (3, 0, 0) GtkStyleContext *style = gtk_widget_get_style_context (GTK_WIDGET (window)); gtk_style_context_add_class (style, "window-frame"); -#endif /* assume 130x130 on a 640x480 display and scale from there */ scalew = gdk_screen_get_width (screen) / 640.0; diff --git a/plugins/common/msd-osd-window.h b/plugins/common/msd-osd-window.h index 42229f4..ac3325a 100644 --- a/plugins/common/msd-osd-window.h +++ b/plugins/common/msd-osd-window.h @@ -70,11 +70,7 @@ struct MsdOsdWindow { struct MsdOsdWindowClass { GtkWindowClass parent_class; -#if GTK_CHECK_VERSION (3, 0, 0) void (* draw_when_composited) (MsdOsdWindow *window, cairo_t *cr); -#else - void (* expose_when_composited) (MsdOsdWindow *window, cairo_t *cr); -#endif }; GType msd_osd_window_get_type (void); @@ -84,19 +80,6 @@ gboolean msd_osd_window_is_composited (MsdOsdWindow *windo gboolean msd_osd_window_is_valid (MsdOsdWindow *window); void msd_osd_window_update_and_hide (MsdOsdWindow *window); -#if !GTK_CHECK_VERSION (3, 0, 0) -void msd_osd_window_draw_rounded_rectangle (cairo_t *cr, - gdouble aspect, - gdouble x, - gdouble y, - gdouble corner_radius, - gdouble width, - gdouble height); - -void msd_osd_window_color_reverse (const GdkColor *a, - GdkColor *b); -#endif - #ifdef __cplusplus } #endif |