diff options
-rw-r--r-- | applets/clock/calendar-window.c | 18 | ||||
-rw-r--r-- | applets/clock/clock-face.c | 68 | ||||
-rw-r--r-- | applets/clock/clock-location-tile.c | 4 | ||||
-rw-r--r-- | applets/clock/clock-map.c | 75 | ||||
-rw-r--r-- | applets/clock/clock.c | 23 |
5 files changed, 176 insertions, 12 deletions
diff --git a/applets/clock/calendar-window.c b/applets/clock/calendar-window.c index 665ea150..fe61ce58 100644 --- a/applets/clock/calendar-window.c +++ b/applets/clock/calendar-window.c @@ -33,7 +33,7 @@ #include <gio/gio.h> #define MATE_DESKTOP_USE_UNSTABLE_API -#include <libmate/mate-desktop-utils.h> +#include <libmate-desktop/mate-desktop-utils.h> #include "calendar-window.h" @@ -359,7 +359,11 @@ calendar_window_set_property (GObject *object, } static void +#if GTK_CHECK_VERSION (3, 0, 0) +calendar_window_dispose (GObject *object) +#else calendar_window_destroy (GtkObject *object) +#endif { CalendarWindow *calwin; @@ -369,20 +373,30 @@ calendar_window_destroy (GtkObject *object) g_object_unref (calwin->priv->settings); calwin->priv->settings = NULL; +#if GTK_CHECK_VERSION (3, 0, 0) + G_OBJECT_CLASS (calendar_window_parent_class)->dispose (object); +#else GTK_OBJECT_CLASS (calendar_window_parent_class)->destroy (object); +#endif } static void calendar_window_class_init (CalendarWindowClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); +#if !GTK_CHECK_VERSION (3, 0, 0) GtkObjectClass *gtkobject_class = GTK_OBJECT_CLASS (klass); +#endif gobject_class->constructor = calendar_window_constructor; gobject_class->get_property = calendar_window_get_property; - gobject_class->set_property = calendar_window_set_property; + gobject_class->set_property = calendar_window_set_property; +#if GTK_CHECK_VERSION (3, 0, 0) + gobject_class->dispose = calendar_window_dispose; +#else gtkobject_class->destroy = calendar_window_destroy; +#endif g_type_class_add_private (klass, sizeof (CalendarWindowPrivate)); diff --git a/applets/clock/clock-face.c b/applets/clock/clock-face.c index 143eef12..fe944a12 100644 --- a/applets/clock/clock-face.c +++ b/applets/clock/clock-face.c @@ -27,7 +27,13 @@ static GHashTable *pixbuf_cache = NULL; G_DEFINE_TYPE (ClockFace, clock_face, GTK_TYPE_WIDGET) static void clock_face_finalize (GObject *); +#if GTK_CHECK_VERSION (3, 0, 0) +static gboolean clock_face_draw (GtkWidget *clock, cairo_t *cr); +static void clock_face_get_preferred_width (GtkWidget *widget, gint *minimum_width, gint *natural_width); +static void clock_face_get_preferred_height (GtkWidget *widget, gint *minimum_height, gint *natural_height); +#else static gboolean clock_face_expose (GtkWidget *clock, GdkEventExpose *event); +#endif static void clock_face_size_request (GtkWidget *clock, GtkRequisition *requisition); static void clock_face_size_allocate (GtkWidget *clock, @@ -70,8 +76,14 @@ clock_face_class_init (ClockFaceClass *class) widget_class = GTK_WIDGET_CLASS (class); /* GtkWidget signals */ - widget_class->expose_event = clock_face_expose; +#if GTK_CHECK_VERSION (3, 0, 0) + widget_class->draw = clock_face_draw; + widget_class->get_preferred_width = clock_face_get_preferred_width; + widget_class->get_preferred_height = clock_face_get_preferred_height; +#else widget_class->size_request = clock_face_size_request; + widget_class->expose_event = clock_face_expose; +#endif widget_class->size_allocate = clock_face_size_allocate; /* GObject signals */ @@ -93,11 +105,20 @@ clock_face_init (ClockFace *this) gtk_widget_set_has_window (GTK_WIDGET (this), FALSE); } +#if GTK_CHECK_VERSION (3, 0, 0) +static gboolean +clock_face_draw (GtkWidget *this, cairo_t *cr) +#else static void draw (GtkWidget *this, cairo_t *cr) +#endif { ClockFacePrivate *priv; +#if GTK_CHECK_VERSION (3, 0, 0) + int width, height; +#else GtkAllocation allocation; +#endif double x, y; double radius; int hours, minutes, seconds; @@ -107,6 +128,11 @@ draw (GtkWidget *this, cairo_t *cr) priv = CLOCK_FACE_GET_PRIVATE (this); +#if GTK_CHECK_VERSION (3, 0, 0) + if (GTK_WIDGET_CLASS (clock_face_parent_class)->draw) + GTK_WIDGET_CLASS (clock_face_parent_class)->draw (this, cr); +#endif + if (priv->size == CLOCK_FACE_LARGE) { hour_length = 0.45; min_length = 0.6; @@ -117,6 +143,21 @@ draw (GtkWidget *this, cairo_t *cr) sec_length = 0.8; /* not drawn currently */ } +#if GTK_CHECK_VERSION (3, 0, 0) + width = gtk_widget_get_allocated_width (this); + height = gtk_widget_get_allocated_width (this); + x = width / 2; + y = height / 2; + radius = MIN (width / 2, height / 2) - 5; + + /* clock back */ + if (priv->face_pixbuf) { + cairo_save (cr); + gdk_cairo_set_source_pixbuf (cr, priv->face_pixbuf, 0, 0); + cairo_paint (cr); + cairo_restore (cr); + } +#else gtk_widget_get_allocation (this, &allocation); x = allocation.x + allocation.width / 2; @@ -142,6 +183,7 @@ draw (GtkWidget *this, cairo_t *cr) } cairo_restore (cr); +#endif /* clock hands */ hours = priv->time.tm_hour; @@ -184,6 +226,7 @@ draw (GtkWidget *this, cairo_t *cr) } } +#if !GTK_CHECK_VERSION (3, 0, 0) static gboolean clock_face_expose (GtkWidget *this, GdkEventExpose *event) { @@ -203,6 +246,7 @@ clock_face_expose (GtkWidget *this, GdkEventExpose *event) return FALSE; } +#endif static void clock_face_redraw_canvas (ClockFace *this) @@ -248,6 +292,28 @@ clock_face_size_request (GtkWidget *this, } } +#if GTK_CHECK_VERSION (3, 0, 0) +static void +clock_face_get_preferred_width (GtkWidget *widget, + gint *minimum_width, + gint *natural_width) +{ + GtkRequisition req; + clock_face_size_request (widget, &req); + *minimum_width = *natural_width = req.width; +} + +static void +clock_face_get_preferred_height (GtkWidget *widget, + gint *minimum_height, + gint *natural_height) +{ + GtkRequisition req; + clock_face_size_request (widget, &req); + *minimum_height = *natural_height = req.height; +} +#endif + static void clock_face_size_allocate (GtkWidget *this, GtkAllocation *allocation) diff --git a/applets/clock/clock-location-tile.c b/applets/clock/clock-location-tile.c index 33007b14..1ff428ab 100644 --- a/applets/clock/clock-location-tile.c +++ b/applets/clock/clock-location-tile.c @@ -204,7 +204,11 @@ make_current (GtkWidget *widget, ClockLocationTile *tile) GdkWindow *window = gtk_widget_get_window (toplevel); if (window) +#if GTK_CHECK_VERSION (3, 0, 0) + xid = GDK_WINDOW_XID (window); +#else xid = GDK_WINDOW_XWINDOW (window); +#endif } clock_location_make_current (priv->location, diff --git a/applets/clock/clock-map.c b/applets/clock/clock-map.c index 5a6e0379..5823f6ea 100644 --- a/applets/clock/clock-map.c +++ b/applets/clock/clock-map.c @@ -56,13 +56,23 @@ typedef struct { } ClockMapPrivate; static void clock_map_finalize (GObject *); -static void clock_map_size_request (GtkWidget *this, - GtkRequisition *requisition); static void clock_map_size_allocate (GtkWidget *this, GtkAllocation *allocation); +#if GTK_CHECK_VERSION (3, 0, 0) +static gboolean clock_map_draw (GtkWidget *this, + cairo_t *cr); +static void clock_map_get_preferred_width (GtkWidget *widget, + gint *minimum_width, + gint *natural_width); +static void clock_map_get_preferred_height (GtkWidget *widget, + gint *minimum_height, + gint *natural_height); +#else static gboolean clock_map_expose (GtkWidget *this, GdkEventExpose *expose); - +static void clock_map_size_request (GtkWidget *this, + GtkRequisition *requisition); +#endif static void clock_map_place_locations (ClockMap *this); static void clock_map_render_shadow (ClockMap *this); static void clock_map_display (ClockMap *this); @@ -88,9 +98,16 @@ clock_map_class_init (ClockMapClass *this_class) g_obj_class->finalize = clock_map_finalize; /* GtkWidget signals */ - widget_class->size_request = clock_map_size_request; + widget_class->size_allocate = clock_map_size_allocate; - widget_class->expose_event = clock_map_expose; +#if GTK_CHECK_VERSION (3, 0, 0) + widget_class->draw = clock_map_draw; + widget_class->get_preferred_width = clock_map_get_preferred_width; + widget_class->get_preferred_height = clock_map_get_preferred_height; +#else + widget_class->expose_event = clock_map_expose; + widget_class->size_request = clock_map_size_request; +#endif g_type_class_add_private (this_class, sizeof (ClockMapPrivate)); @@ -217,24 +234,42 @@ clock_map_refresh (ClockMap *this) } static gboolean +#if GTK_CHECK_VERSION (3, 0, 0) +clock_map_draw (GtkWidget *this, cairo_t *cr) +#else clock_map_expose (GtkWidget *this, GdkEventExpose *event) +#endif { ClockMapPrivate *priv = PRIVATE (this); - GdkWindow *window; GtkStyle *style; +#if GTK_CHECK_VERSION (3, 0, 0) + int width, height; +#else + GdkWindow *window; GtkAllocation allocation; GdkRectangle region; cairo_t *cr; +#endif - window = gtk_widget_get_window (this); style = gtk_widget_get_style (this); +#if GTK_CHECK_VERSION (3, 0, 0) + width = gdk_pixbuf_get_width (priv->shadow_map_pixbuf); + height = gdk_pixbuf_get_height (priv->shadow_map_pixbuf); +#else + window = gtk_widget_get_window (this); gtk_widget_get_allocation (this, &allocation); +#endif if (!priv->shadow_map_pixbuf) { g_warning ("Needed to refresh the map in expose event."); clock_map_refresh (CLOCK_MAP (this)); } +#if GTK_CHECK_VERSION (3, 0, 0) + gdk_cairo_set_source_pixbuf (cr, priv->shadow_map_pixbuf, 0, 0); + cairo_rectangle (cr, 0, 0, width, height); + cairo_paint (cr); +#else cr = gdk_cairo_create (window); region.x = allocation.x; @@ -254,8 +289,13 @@ clock_map_expose (GtkWidget *this, GdkEventExpose *event) region.height, GDK_RGB_DITHER_NORMAL, 0, 0); +#endif /* draw a simple outline */ +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_rectangle (cr, 0.5, 0.5, width - 1, height - 1); + gdk_cairo_set_source_color (cr, &style->mid [GTK_STATE_ACTIVE]); +#else cairo_rectangle ( cr, allocation.x + 0.5, allocation.y + 0.5, @@ -267,21 +307,42 @@ clock_map_expose (GtkWidget *this, GdkEventExpose *event) style->mid [GTK_STATE_ACTIVE].red / 65535.0, style->mid [GTK_STATE_ACTIVE].green / 65535.0, style->mid [GTK_STATE_ACTIVE].blue / 65535.0); +#endif cairo_set_line_width (cr, 1.0); cairo_stroke (cr); +#if !GTK_CHECK_VERSION (3, 0, 0) cairo_destroy (cr); +#endif return FALSE; } +#if GTK_CHECK_VERSION (3, 0, 0) +static void +clock_map_get_preferred_width (GtkWidget *widget, + gint *minimum_width, + gint *natural_width) +{ + *minimum_width = *natural_width = 250; +} + +static void +clock_map_get_preferred_height (GtkWidget *widget, + gint *minimum_height, + gint *natural_height) +{ + *minimum_height = *natural_height = 125; +} +#else static void clock_map_size_request (GtkWidget *this, GtkRequisition *requisition) { requisition->width = 250; requisition->height = 125; } +#endif static void clock_map_size_allocate (GtkWidget *this, GtkAllocation *allocation) diff --git a/applets/clock/clock.c b/applets/clock/clock.c index bcbf847d..78b92c07 100644 --- a/applets/clock/clock.c +++ b/applets/clock/clock.c @@ -765,7 +765,7 @@ close_on_escape (GtkWidget *widget, GdkEventKey *event, GtkToggleButton *toggle_button) { - if (event->keyval == GDK_Escape) { + if (event->keyval == GDK_KEY_Escape) { gtk_toggle_button_set_active (toggle_button, FALSE); return TRUE; } @@ -2114,7 +2114,11 @@ location_start_element (GMarkupParseContext *context, latitude, longitude, code, &prefs); if (current && clock_location_is_current_timezone (loc)) +#if GTK_CHECK_VERSION (3, 0, 0) + clock_location_make_current (loc, GDK_WINDOW_XID (gtk_widget_get_window (cd->applet)), +#else clock_location_make_current (loc, GDK_WINDOW_XWINDOW (gtk_widget_get_window (cd->applet)), +#endif NULL, NULL, NULL); data->cities = g_list_append (data->cities, loc); @@ -2955,6 +2959,9 @@ fill_prefs_window (ClockData *cd) GtkCellRenderer *renderer; GtkTreeViewColumn *col; GtkListStore *store; +#if GTK_CHECK_VERSION (3, 0, 0) + GtkTreeIter iter; +#endif int i; /* Set the 12 hour / 24 hour widget */ @@ -3017,9 +3024,15 @@ fill_prefs_window (ClockData *cd) gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (widget), renderer, "text", 0, NULL); for (i = 0; temperatures[i] != -1; i++) +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_list_store_insert_with_values (store, &iter, -1, + 0, mateweather_prefs_get_temp_display_name (temperatures[i]), + -1); +#else gtk_combo_box_append_text (GTK_COMBO_BOX (widget), mateweather_prefs_get_temp_display_name (temperatures[i])); - +#endif + if (cd->temperature_unit > 0) gtk_combo_box_set_active (GTK_COMBO_BOX (widget), cd->temperature_unit - 2); @@ -3035,8 +3048,14 @@ fill_prefs_window (ClockData *cd) gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (widget), renderer, "text", 0, NULL); for (i = 0; speeds[i] != -1; i++) +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_list_store_insert_with_values (store, &iter, -1, + 0, mateweather_prefs_get_speed_display_name (speeds[i]), + -1); +#else gtk_combo_box_append_text (GTK_COMBO_BOX (widget), mateweather_prefs_get_speed_display_name (speeds[i])); +#endif if (cd->speed_unit > 0) gtk_combo_box_set_active (GTK_COMBO_BOX (widget), |