diff options
Diffstat (limited to 'applets/clock')
-rw-r--r-- | applets/clock/calendar-window.c | 25 | ||||
-rw-r--r-- | applets/clock/clock-face.c | 113 | ||||
-rw-r--r-- | applets/clock/clock-location-tile.c | 53 | ||||
-rw-r--r-- | applets/clock/clock-location-tile.h | 8 | ||||
-rw-r--r-- | applets/clock/clock-map.c | 80 | ||||
-rw-r--r-- | applets/clock/clock-utils.c | 167 | ||||
-rw-r--r-- | applets/clock/clock.c | 99 |
7 files changed, 0 insertions, 545 deletions
diff --git a/applets/clock/calendar-window.c b/applets/clock/calendar-window.c index 17333015..4f82f67a 100644 --- a/applets/clock/calendar-window.c +++ b/applets/clock/calendar-window.c @@ -123,9 +123,7 @@ calendar_window_create_calendar (CalendarWindow *calwin) struct tm tm1; calendar = gtk_calendar_new (); - #if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_set_size_request(GTK_WIDGET(calendar), 260, 100); - #endif options = gtk_calendar_get_display_options (GTK_CALENDAR (calendar)); if (calwin->priv->show_weeks) options |= GTK_CALENDAR_SHOW_WEEK_NUMBERS; @@ -185,9 +183,6 @@ create_hig_frame (CalendarWindow *calwin, GCallback callback) { GtkWidget *vbox; -#if !GTK_CHECK_VERSION (3, 0, 0) - GtkWidget *alignment; -#endif GtkWidget *label; GtkWidget *hbox; GtkWidget *button; @@ -195,22 +190,14 @@ create_hig_frame (CalendarWindow *calwin, char *text; GtkWidget *expander; -#if GTK_CHECK_VERSION (3, 0, 0) vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); -#else - vbox = gtk_vbox_new (FALSE, 6); -#endif bold_title = g_strdup_printf ("<b>%s</b>", title); expander = gtk_expander_new (bold_title); g_free (bold_title); gtk_expander_set_use_markup (GTK_EXPANDER (expander), TRUE); -#if GTK_CHECK_VERSION (3, 0, 0) hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); -#else - hbox = gtk_hbox_new (FALSE, 0); -#endif gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), expander, FALSE, FALSE, 0); @@ -235,17 +222,9 @@ create_hig_frame (CalendarWindow *calwin, gtk_label_set_use_markup (GTK_LABEL (label), TRUE); gtk_container_add (GTK_CONTAINER (button), label); -#if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_show_all (button); gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0); -#else - alignment = gtk_alignment_new (1, 0, 0, 0); - gtk_container_add (GTK_CONTAINER (alignment), button); - gtk_widget_show_all (alignment); - - gtk_container_add (GTK_CONTAINER (hbox), alignment); -#endif g_signal_connect_swapped (button, "clicked", callback, calwin); } @@ -290,11 +269,7 @@ calendar_window_fill (CalendarWindow *calwin) gtk_container_add (GTK_CONTAINER (calwin), frame); gtk_widget_show (frame); -#if GTK_CHECK_VERSION (3, 0, 0) vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); -#else - vbox = gtk_vbox_new (FALSE, 6); -#endif gtk_container_set_border_width (GTK_CONTAINER (vbox), 6); gtk_container_add (GTK_CONTAINER (frame), vbox); diff --git a/applets/clock/clock-face.c b/applets/clock/clock-face.c index 77c5de4b..dd63a2b6 100644 --- a/applets/clock/clock-face.c +++ b/applets/clock/clock-face.c @@ -26,7 +26,6 @@ static GHashTable *pixbuf_cache = NULL; G_DEFINE_TYPE (ClockFace, clock_face, GTK_TYPE_WIDGET) static void clock_face_finalize (GObject *); -#if GTK_CHECK_VERSION (3, 0, 0) static gboolean clock_face_draw (GtkWidget *clock, cairo_t *cr); static void clock_face_get_preferred_width (GtkWidget *this, @@ -35,11 +34,6 @@ static void clock_face_get_preferred_width (GtkWidget *this, static void clock_face_get_preferred_height (GtkWidget *this, gint *minimal_height, gint *natural_height); -#else -static gboolean clock_face_expose (GtkWidget *clock, GdkEventExpose *event); -static void clock_face_size_request (GtkWidget *clock, - GtkRequisition *requisition); -#endif static void clock_face_size_allocate (GtkWidget *clock, GtkAllocation *allocation); @@ -80,14 +74,9 @@ clock_face_class_init (ClockFaceClass *class) widget_class = GTK_WIDGET_CLASS (class); /* GtkWidget signals */ -#if GTK_CHECK_VERSION (3, 0, 0) widget_class->draw = clock_face_draw; widget_class->get_preferred_width = clock_face_get_preferred_width; widget_class->get_preferred_height = clock_face_get_preferred_height; -#else - widget_class->size_request = clock_face_size_request; - widget_class->expose_event = clock_face_expose; -#endif widget_class->size_allocate = clock_face_size_allocate; /* GObject signals */ @@ -109,20 +98,11 @@ clock_face_init (ClockFace *this) gtk_widget_set_has_window (GTK_WIDGET (this), FALSE); } -#if GTK_CHECK_VERSION (3, 0, 0) static gboolean clock_face_draw (GtkWidget *this, cairo_t *cr) -#else -static void -draw (GtkWidget *this, cairo_t *cr) -#endif { ClockFacePrivate *priv; -#if GTK_CHECK_VERSION (3, 0, 0) int width, height; -#else - GtkAllocation allocation; -#endif double x, y; double radius; int hours, minutes, seconds; @@ -132,10 +112,8 @@ draw (GtkWidget *this, cairo_t *cr) priv = CLOCK_FACE_GET_PRIVATE (this); -#if GTK_CHECK_VERSION (3, 0, 0) if (GTK_WIDGET_CLASS (clock_face_parent_class)->draw) GTK_WIDGET_CLASS (clock_face_parent_class)->draw (this, cr); -#endif if (priv->size == CLOCK_FACE_LARGE) { hour_length = 0.45; @@ -147,7 +125,6 @@ draw (GtkWidget *this, cairo_t *cr) sec_length = 0.8; /* not drawn currently */ } -#if GTK_CHECK_VERSION (3, 0, 0) width = gtk_widget_get_allocated_width (this); height = gtk_widget_get_allocated_width (this); x = width / 2; @@ -161,33 +138,6 @@ draw (GtkWidget *this, cairo_t *cr) cairo_paint (cr); cairo_restore (cr); } -#else - gtk_widget_get_allocation (this, &allocation); - - x = allocation.x + allocation.width / 2; - y = allocation.y + allocation.height / 2; - radius = MIN (allocation.width / 2, - allocation.height / 2) - 5; - - cairo_save (cr); - cairo_translate (cr, allocation.x, allocation.y); - - /* clock back */ - if (priv->face_pixbuf) { - GdkWindow *window = gtk_widget_get_window (this); - gdk_draw_pixbuf (GDK_DRAWABLE (window), - NULL, - priv->face_pixbuf, - 0, 0, - allocation.x, - allocation.y, - allocation.width, - allocation.height, - GDK_RGB_DITHER_NONE, 0, 0); - } - - cairo_restore (cr); -#endif /* clock hands */ hours = priv->time.tm_hour; @@ -228,32 +178,9 @@ draw (GtkWidget *this, cairo_t *cr) cairo_stroke (cr); cairo_restore (cr); } -#if GTK_CHECK_VERSION (3, 0, 0) - return FALSE; -#endif -} - -#if !GTK_CHECK_VERSION (3, 0, 0) -static gboolean -clock_face_expose (GtkWidget *this, GdkEventExpose *event) -{ - cairo_t *cr; - - /* get a cairo_t */ - cr = gdk_cairo_create (gtk_widget_get_window (this)); - - cairo_rectangle (cr, - event->area.x, event->area.y, - event->area.width, event->area.height); - cairo_clip (cr); - - draw (this, cr); - - cairo_destroy (cr); return FALSE; } -#endif static void clock_face_redraw_canvas (ClockFace *this) @@ -261,7 +188,6 @@ clock_face_redraw_canvas (ClockFace *this) gtk_widget_queue_draw (GTK_WIDGET (this)); } -#if GTK_CHECK_VERSION (3, 0, 0) static void clock_face_get_preferred_width (GtkWidget *this, gint *minimal_width, @@ -327,45 +253,6 @@ clock_face_get_preferred_height (GtkWidget *this, *minimal_height = *natural_height = 36; } } -#else -static void -clock_face_size_request (GtkWidget *this, - GtkRequisition *requisition) -{ - ClockFacePrivate *priv = CLOCK_FACE_GET_PRIVATE (this); - - if (priv->size_widget != NULL) { - GtkRequisition req; - - /* Tie our size to the height of the size_widget */ - gtk_widget_size_request (GTK_WIDGET (priv->size_widget), &req); - - /* Pad out our height by a little bit - this improves - the balance */ - requisition->width = req.height + req.height / 8; - requisition->height = req.height + req.height / 8; - } else if (priv->face_pixbuf != NULL) { - int w, h; - - /* Use the size of the current pixbuf */ - w = gdk_pixbuf_get_width (GDK_PIXBUF (priv->face_pixbuf)); - h = gdk_pixbuf_get_height (GDK_PIXBUF (priv->face_pixbuf)); - - requisition->width = w; - requisition->height = h; - } else { - /* we don't know anything, so use known dimensions for the svg - * files */ - if (priv->size == CLOCK_FACE_LARGE) { - requisition->width = 50; - requisition->height = 50; - } else { - requisition->width = 36; - requisition->height = 36; - } - } -} -#endif static void clock_face_size_allocate (GtkWidget *this, diff --git a/applets/clock/clock-location-tile.c b/applets/clock/clock-location-tile.c index ab860101..fd1ea82c 100644 --- a/applets/clock/clock-location-tile.c +++ b/applets/clock/clock-location-tile.c @@ -17,12 +17,7 @@ #include "clock-marshallers.h" #include "set-timezone.h" - -#if GTK_CHECK_VERSION (3, 0, 0) G_DEFINE_TYPE (ClockLocationTile, clock_location_tile, GTK_TYPE_BIN) -#else -G_DEFINE_TYPE (ClockLocationTile, clock_location_tile, GTK_TYPE_ALIGNMENT) -#endif enum { TILE_PRESSED, @@ -260,14 +255,8 @@ static void clock_location_tile_fill (ClockLocationTile *this) { ClockLocationTilePrivate *priv = PRIVATE (this); -#if !GTK_CHECK_VERSION (3, 0, 0) - GtkWidget *align; -#endif GtkWidget *strut; GtkWidget *box; -#if !GTK_CHECK_VERSION (3, 0, 0) - GtkWidget *alignment; -#endif GtkWidget *tile; GtkWidget *head_section; @@ -281,21 +270,13 @@ clock_location_tile_fill (ClockLocationTile *this) g_signal_connect (priv->box, "leave-notify-event", G_CALLBACK (enter_or_leave_tile), this); -#if GTK_CHECK_VERSION (3, 0, 0) tile = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); gtk_widget_set_margin_top (tile, 3); gtk_widget_set_margin_bottom (tile, 3); gtk_widget_set_margin_start (tile, 3); -#else - tile = gtk_hbox_new (FALSE, 6); - alignment = gtk_alignment_new (0, 0, 1, 0); - gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 3, 3, 3, 0); -#endif priv->city_label = gtk_label_new (NULL); -#if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_set_margin_end (priv->city_label, 3); -#endif #if GTK_CHECK_VERSION (3, 16, 0) gtk_label_set_xalign (GTK_LABEL (priv->city_label), 0.0); gtk_label_set_yalign (GTK_LABEL (priv->city_label), 0.0); @@ -303,21 +284,11 @@ clock_location_tile_fill (ClockLocationTile *this) gtk_misc_set_alignment (GTK_MISC (priv->city_label), 0, 0); #endif -#if GTK_CHECK_VERSION (3, 0, 0) head_section = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_box_pack_start (GTK_BOX (head_section), priv->city_label, FALSE, FALSE, 0); -#else - head_section = gtk_vbox_new (FALSE, 0); - align = gtk_alignment_new (0, 0, 0, 0); - gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 0, 0, 3); - gtk_container_add (GTK_CONTAINER (align), priv->city_label); - gtk_box_pack_start (GTK_BOX (head_section), align, FALSE, FALSE, 0); -#endif priv->time_label = gtk_label_new (NULL); -#if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_set_margin_end (priv->time_label, 3); -#endif #if GTK_CHECK_VERSION (3, 16, 0) gtk_label_set_xalign (GTK_LABEL (priv->time_label), 0.0); gtk_label_set_yalign (GTK_LABEL (priv->time_label), 0.0); @@ -326,22 +297,11 @@ clock_location_tile_fill (ClockLocationTile *this) #endif priv->weather_icon = gtk_image_new (); -#if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_set_valign (priv->weather_icon, GTK_ALIGN_START); -#else - align = gtk_alignment_new (0, 0, 0, 0); - gtk_container_add (GTK_CONTAINER (align), priv->weather_icon); -#endif -#if GTK_CHECK_VERSION (3, 0, 0) box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start (GTK_BOX (head_section), box, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (box), priv->weather_icon, FALSE, FALSE, 0); -#else - box = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (head_section), box, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (box), align, FALSE, FALSE, 0); -#endif gtk_box_pack_start (GTK_BOX (box), priv->time_label, FALSE, FALSE, 0); priv->current_button = gtk_button_new (); @@ -354,12 +314,8 @@ clock_location_tile_fill (ClockLocationTile *this) _("Set location as current location and use its timezone for this computer")); priv->current_marker = gtk_image_new_from_icon_name ("go-home", GTK_ICON_SIZE_BUTTON); -#if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_set_halign (priv->current_marker, GTK_ALIGN_END); gtk_widget_set_valign (priv->current_marker, GTK_ALIGN_CENTER); -#else - gtk_misc_set_alignment (GTK_MISC (priv->current_marker), 1.0, 0.5); -#endif gtk_widget_set_no_show_all (priv->current_marker, TRUE); priv->current_spacer = gtk_event_box_new (); @@ -403,12 +359,7 @@ clock_location_tile_fill (ClockLocationTile *this) gtk_box_pack_start (GTK_BOX (tile), priv->clock_face, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (tile), head_section, TRUE, TRUE, 0); -#if GTK_CHECK_VERSION (3, 0, 0) gtk_container_add (GTK_CONTAINER (priv->box), tile); -#else - gtk_container_add (GTK_CONTAINER (alignment), tile); - gtk_container_add (GTK_CONTAINER (priv->box), alignment); -#endif gtk_container_add (GTK_CONTAINER (this), priv->box); } @@ -753,11 +704,7 @@ update_weather_icon (ClockLocation *loc, WeatherInfo *info, gpointer data) if (pixbuf) { gtk_image_set_from_pixbuf (GTK_IMAGE (priv->weather_icon), pixbuf); -#if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_set_margin_end (priv->weather_icon, 6); -#else - gtk_alignment_set_padding (GTK_ALIGNMENT (gtk_widget_get_parent (priv->weather_icon)), 0, 0, 0, 6); -#endif } } diff --git a/applets/clock/clock-location-tile.h b/applets/clock/clock-location-tile.h index 0b1aa8e9..a4f75a15 100644 --- a/applets/clock/clock-location-tile.h +++ b/applets/clock/clock-location-tile.h @@ -21,20 +21,12 @@ extern "C" { typedef struct { -#if GTK_CHECK_VERSION (3, 0, 0) GtkBin parent; -#else - GtkAlignment parent; -#endif } ClockLocationTile; typedef struct { -#if GTK_CHECK_VERSION (3, 0, 0) GtkBinClass parent_class; -#else - GtkAlignmentClass parent_class; -#endif void (* tile_pressed) (ClockLocationTile *tile); int (* need_clock_format) (ClockLocationTile *tile); diff --git a/applets/clock/clock-map.c b/applets/clock/clock-map.c index 704835ea..a8e0c2b0 100644 --- a/applets/clock/clock-map.c +++ b/applets/clock/clock-map.c @@ -58,7 +58,6 @@ typedef struct { static void clock_map_finalize (GObject *); static void clock_map_size_allocate (GtkWidget *this, GtkAllocation *allocation); -#if GTK_CHECK_VERSION (3, 0, 0) static gboolean clock_map_draw (GtkWidget *this, cairo_t *cr); static void clock_map_get_preferred_width (GtkWidget *widget, @@ -67,12 +66,6 @@ static void clock_map_get_preferred_width (GtkWidget *widget, static void clock_map_get_preferred_height (GtkWidget *widget, gint *minimum_height, gint *natural_height); -#else -static gboolean clock_map_expose (GtkWidget *this, - GdkEventExpose *expose); -static void clock_map_size_request (GtkWidget *this, - GtkRequisition *requisition); -#endif static void clock_map_place_locations (ClockMap *this); static void clock_map_render_shadow (ClockMap *this); static void clock_map_display (ClockMap *this); @@ -100,14 +93,9 @@ clock_map_class_init (ClockMapClass *this_class) /* GtkWidget signals */ widget_class->size_allocate = clock_map_size_allocate; -#if GTK_CHECK_VERSION (3, 0, 0) widget_class->draw = clock_map_draw; widget_class->get_preferred_width = clock_map_get_preferred_width; widget_class->get_preferred_height = clock_map_get_preferred_height; -#else - widget_class->expose_event = clock_map_expose; - widget_class->size_request = clock_map_size_request; -#endif g_type_class_add_private (this_class, sizeof (ClockMapPrivate)); @@ -234,98 +222,38 @@ clock_map_refresh (ClockMap *this) } static gboolean -#if GTK_CHECK_VERSION (3, 0, 0) clock_map_draw (GtkWidget *this, cairo_t *cr) -#else -clock_map_expose (GtkWidget *this, GdkEventExpose *event) -#endif { ClockMapPrivate *priv = PRIVATE (this); -#if GTK_CHECK_VERSION (3, 0, 0) int width, height; GtkStyleContext *context; GdkRGBA color; context = gtk_widget_get_style_context (this); gtk_style_context_get_color (context, GTK_STATE_FLAG_ACTIVE, &color); -#else - GtkStyle *style; - GdkWindow *window; - GtkAllocation allocation; - GdkRectangle region; - cairo_t *cr; - - style = gtk_widget_get_style (this); -#endif - -#if !GTK_CHECK_VERSION (3, 0, 0) - window = gtk_widget_get_window (this); - gtk_widget_get_allocation (this, &allocation); -#endif if (!priv->shadow_map_pixbuf) { g_warning ("Needed to refresh the map in expose event."); clock_map_refresh (CLOCK_MAP (this)); } -#if GTK_CHECK_VERSION (3, 0, 0) width = gdk_pixbuf_get_width (priv->shadow_map_pixbuf); height = gdk_pixbuf_get_height (priv->shadow_map_pixbuf); gdk_cairo_set_source_pixbuf (cr, priv->shadow_map_pixbuf, 0, 0); cairo_rectangle (cr, 0, 0, width, height); cairo_paint (cr); -#else - cr = gdk_cairo_create (window); - - region.x = allocation.x; - region.y = allocation.y; - region.width = gdk_pixbuf_get_width (priv->shadow_map_pixbuf); - region.height = gdk_pixbuf_get_height (priv->shadow_map_pixbuf); - - gdk_rectangle_intersect (®ion, &(event->area), ®ion); - gdk_draw_pixbuf (window, - style->black_gc, - priv->shadow_map_pixbuf, - region.x - allocation.x, - region.y - allocation.y, - region.x, - region.y, - region.width, - region.height, - GDK_RGB_DITHER_NORMAL, - 0, 0); -#endif /* draw a simple outline */ -#if GTK_CHECK_VERSION (3, 0, 0) cairo_rectangle (cr, 0.5, 0.5, width - 1, height - 1); gdk_cairo_set_source_rgba (cr, &color); -#else - cairo_rectangle ( - cr, - allocation.x + 0.5, allocation.y + 0.5, - gdk_pixbuf_get_width (priv->shadow_map_pixbuf) - 1, - gdk_pixbuf_get_height (priv->shadow_map_pixbuf) - 1); - - cairo_set_source_rgb ( - cr, - style->mid [GTK_STATE_ACTIVE].red / 65535.0, - style->mid [GTK_STATE_ACTIVE].green / 65535.0, - style->mid [GTK_STATE_ACTIVE].blue / 65535.0); -#endif cairo_set_line_width (cr, 1.0); cairo_stroke (cr); -#if !GTK_CHECK_VERSION (3, 0, 0) - cairo_destroy (cr); -#endif - return FALSE; } -#if GTK_CHECK_VERSION (3, 0, 0) static void clock_map_get_preferred_width (GtkWidget *this, gint *minimum_width, @@ -341,14 +269,6 @@ clock_map_get_preferred_height (GtkWidget *this, { *minimum_height = *natural_height = 125; } -#else -static void -clock_map_size_request (GtkWidget *this, GtkRequisition *requisition) -{ - requisition->width = 250; - requisition->height = 125; -} -#endif static void clock_map_size_allocate (GtkWidget *this, GtkAllocation *allocation) diff --git a/applets/clock/clock-utils.c b/applets/clock/clock-utils.c index 088f5231..14cf06df 100644 --- a/applets/clock/clock-utils.c +++ b/applets/clock/clock-utils.c @@ -128,173 +128,6 @@ clock_utils_display_help (GtkWidget *widget, } } -#if !GTK_CHECK_VERSION (3, 0, 0) -/* code copied from GTK3 gdkpixbuf-drawable.c */ -static cairo_format_t -gdk_cairo_format_for_content (cairo_content_t content) -{ - switch (content) - { - case CAIRO_CONTENT_COLOR: - return CAIRO_FORMAT_RGB24; - case CAIRO_CONTENT_ALPHA: - return CAIRO_FORMAT_A8; - case CAIRO_CONTENT_COLOR_ALPHA: - default: - return CAIRO_FORMAT_ARGB32; - } -} - -static cairo_surface_t * -gdk_cairo_surface_coerce_to_image (cairo_surface_t *surface, - cairo_content_t content, - int src_x, - int src_y, - int width, - int height) -{ - cairo_surface_t *copy; - cairo_t *cr; - - copy = cairo_image_surface_create (gdk_cairo_format_for_content (content), - width, - height); - - cr = cairo_create (copy); - cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); - cairo_set_source_surface (cr, surface, -src_x, -src_y); - cairo_paint (cr); - cairo_destroy (cr); - - return copy; -} - -static void -convert_alpha (guchar *dest_data, - int dest_stride, - guchar *src_data, - int src_stride, - int src_x, - int src_y, - int width, - int height) -{ - int x, y; - - src_data += src_stride * src_y + src_x * 4; - - for (y = 0; y < height; y++) { - guint32 *src = (guint32 *) src_data; - - for (x = 0; x < width; x++) { - guint alpha = src[x] >> 24; - - if (alpha == 0) - { - dest_data[x * 4 + 0] = 0; - dest_data[x * 4 + 1] = 0; - dest_data[x * 4 + 2] = 0; - } - else - { - dest_data[x * 4 + 0] = (((src[x] & 0xff0000) >> 16) * 255 + alpha / 2) / alpha; - dest_data[x * 4 + 1] = (((src[x] & 0x00ff00) >> 8) * 255 + alpha / 2) / alpha; - dest_data[x * 4 + 2] = (((src[x] & 0x0000ff) >> 0) * 255 + alpha / 2) / alpha; - } - dest_data[x * 4 + 3] = alpha; - } - - src_data += src_stride; - dest_data += dest_stride; - } -} - -static void -convert_no_alpha (guchar *dest_data, - int dest_stride, - guchar *src_data, - int src_stride, - int src_x, - int src_y, - int width, - int height) -{ - int x, y; - - src_data += src_stride * src_y + src_x * 4; - - for (y = 0; y < height; y++) { - guint32 *src = (guint32 *) src_data; - - for (x = 0; x < width; x++) { - dest_data[x * 3 + 0] = src[x] >> 16; - dest_data[x * 3 + 1] = src[x] >> 8; - dest_data[x * 3 + 2] = src[x]; - } - - src_data += src_stride; - dest_data += dest_stride; - } -} - -static GdkPixbuf * -gdk_pixbuf_get_from_surface (cairo_surface_t *surface, - gint src_x, - gint src_y, - gint width, - gint height) -{ - cairo_content_t content; - GdkPixbuf *dest; - - /* General sanity checks */ - g_return_val_if_fail (surface != NULL, NULL); - g_return_val_if_fail (width > 0 && height > 0, NULL); - - content = cairo_surface_get_content (surface) | CAIRO_CONTENT_COLOR; - dest = gdk_pixbuf_new (GDK_COLORSPACE_RGB, - !!(content & CAIRO_CONTENT_ALPHA), - 8, - width, height); - - if (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_IMAGE && - cairo_image_surface_get_format (surface) == gdk_cairo_format_for_content (content)) - surface = cairo_surface_reference (surface); - else - { - surface = gdk_cairo_surface_coerce_to_image (surface, content, - src_x, src_y, - width, height); - src_x = 0; - src_y = 0; - } - cairo_surface_flush (surface); - if (cairo_surface_status (surface) || dest == NULL) - { - cairo_surface_destroy (surface); - return NULL; - } - - if (gdk_pixbuf_get_has_alpha (dest)) - convert_alpha (gdk_pixbuf_get_pixels (dest), - gdk_pixbuf_get_rowstride (dest), - cairo_image_surface_get_data (surface), - cairo_image_surface_get_stride (surface), - src_x, src_y, - width, height); - else - convert_no_alpha (gdk_pixbuf_get_pixels (dest), - gdk_pixbuf_get_rowstride (dest), - cairo_image_surface_get_data (surface), - cairo_image_surface_get_stride (surface), - src_x, src_y, - width, height); - - cairo_surface_destroy (surface); - return dest; -} -#endif - GdkPixbuf * clock_utils_pixbuf_from_svg_file_at_size (const char *name, int width, int height) { diff --git a/applets/clock/clock.c b/applets/clock/clock.c index 78c901b0..7685ff86 100644 --- a/applets/clock/clock.c +++ b/applets/clock/clock.c @@ -133,9 +133,6 @@ struct _ClockData { GtkListStore *cities_store; GtkWidget *cities_section; -#if !GTK_CHECK_VERSION (3, 0, 0) - GtkWidget *map_section; -#endif GtkWidget *map_widget; /* Window to set the time */ @@ -265,11 +262,9 @@ calculate_minimum_width (GtkWidget *widget, int focus_width = 0; int focus_pad = 0; #endif -#if GTK_CHECK_VERSION (3, 0, 0) GtkStyleContext *style_context; GtkStateFlags state; GtkBorder padding; -#endif pango_context = gtk_widget_get_pango_context (widget); @@ -280,12 +275,10 @@ calculate_minimum_width (GtkWidget *widget, g_object_unref (G_OBJECT (layout)); layout = NULL; -#if GTK_CHECK_VERSION (3, 0, 0) state = gtk_widget_get_state_flags (widget); style_context = gtk_widget_get_style_context (widget); gtk_style_context_get_padding (style_context, state, &padding); #if GTK_CHECK_VERSION (3, 20, 0) - width += padding.left + padding.right; #else gtk_style_context_get_style (style_context, @@ -295,15 +288,6 @@ calculate_minimum_width (GtkWidget *widget, width += 2 * (focus_width + focus_pad) + padding.left + padding.right; #endif -#else - gtk_widget_style_get (widget, - "focus-line-width", &focus_width, - "focus-padding", &focus_pad, - NULL); - - width += 2 * (focus_width + focus_pad + gtk_widget_get_style (widget)->xthickness); -#endif - return width; } @@ -394,14 +378,10 @@ static int calculate_minimum_height (GtkWidget *widget, MatePanelAppletOrient orientation) { -#if GTK_CHECK_VERSION (3, 0, 0) GtkStateFlags state; GtkStyleContext *style_context; const PangoFontDescription *font_desc; GtkBorder padding; -#else - GtkStyle *style; -#endif PangoContext *pango_context; PangoFontMetrics *metrics; int focus_width = 0; @@ -410,7 +390,6 @@ calculate_minimum_height (GtkWidget *widget, int descent; int thickness; -#if GTK_CHECK_VERSION (3, 0, 0) state = gtk_widget_get_state_flags (widget); style_context = gtk_widget_get_style_context (widget); @@ -419,45 +398,23 @@ calculate_minimum_height (GtkWidget *widget, metrics = pango_context_get_metrics (pango_context, font_desc, pango_context_get_language (pango_context)); -#else - style = gtk_widget_get_style (widget); - pango_context = gtk_widget_get_pango_context (widget); - metrics = pango_context_get_metrics (pango_context, - style->font_desc, - pango_context_get_language (pango_context)); -#endif ascent = pango_font_metrics_get_ascent (metrics); descent = pango_font_metrics_get_descent (metrics); pango_font_metrics_unref (metrics); -#if GTK_CHECK_VERSION (3, 0, 0) gtk_style_context_get_padding (style_context, state, &padding); gtk_style_context_get_style (style_context, "focus-line-width", &focus_width, "focus-padding", &focus_pad, NULL); -#else - gtk_widget_style_get (widget, - "focus-line-width", &focus_width, - "focus-padding", &focus_pad, - NULL); -#endif if (orientation == MATE_PANEL_APPLET_ORIENT_UP || orientation == MATE_PANEL_APPLET_ORIENT_DOWN) { -#if GTK_CHECK_VERSION (3, 0, 0) thickness = padding.top + padding.bottom; -#else - thickness = style->ythickness; -#endif } else { -#if GTK_CHECK_VERSION (3, 0, 0) thickness = padding.left + padding.right; -#else - thickness = style->xthickness; -#endif } return PANGO_PIXELS (ascent + descent) + 2 * (focus_width + focus_pad) + thickness; @@ -885,7 +842,6 @@ create_calendar (ClockData *cd) g_signal_connect (window, "key_press_event", G_CALLBACK (close_on_escape), cd->panel_button); -#if GTK_CHECK_VERSION (3, 0, 0) /*Name this window so the default theme can be overridden in panel theme, otherwise default GtkWindow bg will be pulled in and override transparency */ gtk_widget_set_name(window, "MatePanelPopupWindow"); @@ -894,7 +850,6 @@ create_calendar (ClockData *cd) GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(window)); GdkVisual *visual = gdk_screen_get_rgba_visual(screen); gtk_widget_set_visual(GTK_WIDGET(window), visual); -#endif return window; } @@ -918,11 +873,7 @@ position_calendar_popup (ClockData *cd) &x, &y); gtk_window_get_size (GTK_WINDOW (cd->calendar_popup), &w, &h); -#if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_get_preferred_size (cd->calendar_popup, &req, NULL); -#else - gtk_widget_size_request (cd->calendar_popup, &req); -#endif w = req.width; h = req.height; @@ -1017,11 +968,7 @@ create_clock_window (ClockData *cd) locations_box = calendar_window_get_locations_box (CALENDAR_WINDOW (cd->calendar_popup)); gtk_widget_show (locations_box); -#if GTK_CHECK_VERSION (3, 0, 0) cd->clock_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); -#else - cd->clock_vbox = gtk_vbox_new (FALSE, 6); -#endif gtk_container_add (GTK_CONTAINER (locations_box), cd->clock_vbox); cd->clock_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); @@ -1170,11 +1117,7 @@ create_cities_section (ClockData *cd) g_list_free (cd->location_tiles); cd->location_tiles = NULL; -#if GTK_CHECK_VERSION (3, 0, 0) cd->cities_section = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6); -#else - cd->cities_section = gtk_vbox_new (FALSE, 6); -#endif gtk_container_set_border_width (GTK_CONTAINER (cd->cities_section), 0); cities = cd->locations; @@ -1232,11 +1175,7 @@ create_map_section (ClockData *cd) ClockMap *map; if (cd->map_widget) { -#if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_destroy (cd->map_widget); -#else - gtk_widget_destroy (GTK_WIDGET (cd->map_section)); -#endif cd->map_widget = NULL; } @@ -1244,12 +1183,8 @@ create_map_section (ClockData *cd) g_signal_connect (map, "need-locations", G_CALLBACK (map_need_locations_cb), cd); -#if !GTK_CHECK_VERSION (3, 0, 0) - cd->map_section = gtk_alignment_new (0, 0, 1, 1); -#endif cd->map_widget = GTK_WIDGET (map); -#if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_set_margin_top (cd->map_widget, 1); gtk_widget_set_margin_bottom (cd->map_widget, 1); gtk_widget_set_margin_start (cd->map_widget, 1); @@ -1257,15 +1192,6 @@ create_map_section (ClockData *cd) gtk_box_pack_start (GTK_BOX (cd->clock_vbox), cd->map_widget, TRUE, TRUE, 0); gtk_widget_show (cd->map_widget); -#else - gtk_container_add (GTK_CONTAINER (cd->map_section), cd->map_widget); - - gtk_alignment_set_padding (GTK_ALIGNMENT (cd->map_section), 1, 1, 1, 1); - - gtk_box_pack_start (GTK_BOX (cd->clock_vbox), cd->map_section, FALSE, FALSE, 0); - gtk_widget_show (cd->map_widget); - gtk_widget_show (cd->map_section); -#endif } static void @@ -1276,9 +1202,6 @@ update_calendar_popup (ClockData *cd) gtk_widget_destroy (cd->calendar_popup); cd->calendar_popup = NULL; cd->cities_section = NULL; -#if !GTK_CHECK_VERSION (3, 0, 0) - cd->map_section = NULL; -#endif cd->map_widget = NULL; cd->clock_vbox = NULL; @@ -1357,7 +1280,6 @@ clock_update_text_gravity (GtkWidget *label) pango_context_set_base_gravity (context, PANGO_GRAVITY_AUTO); } -#if GTK_CHECK_VERSION (3, 0, 0) #if !GTK_CHECK_VERSION (3, 20, 0) static inline void force_no_focus_padding (GtkWidget *widget) @@ -1382,27 +1304,6 @@ force_no_focus_padding (GtkWidget *widget) gtk_widget_set_name (widget, "clock-applet-button"); } #endif -#else -static inline void -force_no_focus_padding (GtkWidget *widget) -{ - static gboolean first_time = TRUE; - if (first_time) { - gtk_rc_parse_string ("\n" - " style \"clock-applet-button-style\"\n" - " {\n" - " GtkWidget::focus-line-width=0\n" - " GtkWidget::focus-padding=0\n" - " }\n" - "\n" - " widget \"*.clock-applet-button\" style \"clock-applet-button-style\"\n" - "\n"); - first_time = FALSE; - } - - gtk_widget_set_name (widget, "clock-applet-button"); -} -#endif static GtkWidget * create_main_clock_button (void) |