From: Hugo Villeneuve Date: Sun, 21 Dec 2014 19:29:52 +0000 (-0500) Subject: Add allocation width/height macro for Gtk+-3 support X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=14b04451bfd27147f068285e44f4946e8d5733c1;p=dockapps%2Fhvclock.git Add allocation width/height macro for Gtk+-3 support Directly accessing allocation structure is no more allowed in Gtk+-3. --- diff --git a/src/clock.c b/src/clock.c index cdce025..5615d56 100644 --- a/src/clock.c +++ b/src/clock.c @@ -82,11 +82,15 @@ /* Starting mode is clock mode */ static int hvclock_mode = CLOCK_MODE; +/* In preparation for Gtk+-3 support. */ +#define gtk_widget_get_allocated_width(_widget_) _widget_->allocation.width +#define gtk_widget_get_allocated_height(_widget_) _widget_->allocation.height + static double get_clock_face_radius(GtkWidget *clock) { /* Compute clock face radius */ - return (MIN(clock->allocation.width, clock->allocation.height) / 2) - 3; + return (MIN(gtk_widget_get_allocated_width(clock), gtk_widget_get_allocated_height(clock)) / 2) - 3; } static struct tm * @@ -109,8 +113,8 @@ draw_clock_background(GtkWidget *clock, cairo_t *cr) double radius, radius_numbers, radius_dots; int digit; - center_x = clock->allocation.width / 2; - center_y = clock->allocation.height / 2; + center_x = gtk_widget_get_allocated_width(clock) / 2; + center_y = gtk_widget_get_allocated_height(clock) / 2; radius = get_clock_face_radius(clock); @@ -221,8 +225,8 @@ draw_clock_hand_common(GtkWidget *clock, cairo_t *cr, double angle, radius = get_clock_face_radius(clock); - center_x = clock->allocation.width / 2; - center_y = clock->allocation.height / 2; + center_x = gtk_widget_get_allocated_width(clock) / 2; + center_y = gtk_widget_get_allocated_height(clock) / 2; sin_x = sin(angle); cos_y = cos(angle); @@ -254,8 +258,8 @@ draw_clock_hands(GtkWidget *clock, cairo_t *cr) ts = clock_get_time(); - center_x = clock->allocation.width / 2; - center_y = clock->allocation.height / 2; + center_x = gtk_widget_get_allocated_width(clock) / 2; + center_y = gtk_widget_get_allocated_height(clock) / 2; radius = get_clock_face_radius(clock); @@ -325,8 +329,8 @@ calendar_display_test(GtkWidget *clock, struct tm *ts, cairo_t *cr, char str[32]; diameter = 2 * get_clock_face_radius(clock); - center_x = (clock->allocation.width / 2) - 2; - start_y = (clock->allocation.height / 2) - (diameter / 2); + center_x = (gtk_widget_get_allocated_width(clock) / 2) - 2; + start_y = (gtk_widget_get_allocated_height(clock) / 2) - (diameter / 2); cairo_set_font_size(cr, diameter * font_ratio);