aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2011-01-13 22:58:21 +0800
committerMatthew Barnes <mbarnes@redhat.com>2011-01-15 04:58:16 +0800
commita4d8c30310cfcd95a54153930336ff8196adde76 (patch)
treeedb331107ef6b418be65bf34be0bbf8f78387222 /widgets
parentd47adb5922a262effdd14c1c50bb0a3660088798 (diff)
downloadgsoc2013-evolution-a4d8c30310cfcd95a54153930336ff8196adde76.tar
gsoc2013-evolution-a4d8c30310cfcd95a54153930336ff8196adde76.tar.gz
gsoc2013-evolution-a4d8c30310cfcd95a54153930336ff8196adde76.tar.bz2
gsoc2013-evolution-a4d8c30310cfcd95a54153930336ff8196adde76.tar.lz
gsoc2013-evolution-a4d8c30310cfcd95a54153930336ff8196adde76.tar.xz
gsoc2013-evolution-a4d8c30310cfcd95a54153930336ff8196adde76.tar.zst
gsoc2013-evolution-a4d8c30310cfcd95a54153930336ff8196adde76.zip
Merge miscellaneous changes from gtk3 branch.
Mostly coding style and whitespace changes, to reduce diff noise.
Diffstat (limited to 'widgets')
-rw-r--r--widgets/misc/e-calendar-item.c6
-rw-r--r--widgets/misc/e-map.c972
-rw-r--r--widgets/table/e-cell-checkbox.c2
-rw-r--r--widgets/table/e-cell-hbox.c22
-rw-r--r--widgets/table/e-cell-text.c5
-rw-r--r--widgets/table/e-cell-tree.c97
-rw-r--r--widgets/table/e-cell-vbox.c33
-rw-r--r--widgets/table/e-table-header-utils.h6
8 files changed, 537 insertions, 606 deletions
diff --git a/widgets/misc/e-calendar-item.c b/widgets/misc/e-calendar-item.c
index 6afe62d381..e34e0d4428 100644
--- a/widgets/misc/e-calendar-item.c
+++ b/widgets/misc/e-calendar-item.c
@@ -1351,9 +1351,9 @@ e_calendar_item_draw_month (ECalendarItem *calitem,
cairo_restore (cr);
}
- e_calendar_item_draw_day_numbers (calitem, drawable, width, height,
- row, col, year, month, start_weekday,
- cells_x, cells_y);
+ e_calendar_item_draw_day_numbers (
+ calitem, drawable, width, height, row, col,
+ year, month, start_weekday, cells_x, cells_y);
g_object_unref (layout);
cairo_destroy (cr);
diff --git a/widgets/misc/e-map.c b/widgets/misc/e-map.c
index 4c292bfc4a..165a9c702f 100644
--- a/widgets/misc/e-map.c
+++ b/widgets/misc/e-map.c
@@ -64,11 +64,11 @@ EMapZoomState;
typedef struct _EMapTween EMapTween;
struct _EMapTween {
- guint start_time;
- guint end_time;
- double longitude_offset;
- double latitude_offset;
- double zoom_factor;
+ guint start_time;
+ guint end_time;
+ gdouble longitude_offset;
+ gdouble latitude_offset;
+ gdouble zoom_factor;
};
/* Private part of the EMap structure */
@@ -76,7 +76,7 @@ struct _EMapTween {
struct _EMapPrivate {
/* Pointer to map image */
GdkPixbuf *map_pixbuf;
- cairo_surface_t *map_render_surface;
+ cairo_surface_t *map_render_surface;
/* Settings */
gboolean frozen, smooth_zoom;
@@ -95,36 +95,24 @@ struct _EMapPrivate {
/* Dots */
GPtrArray *points;
- /* Tweens */
- GSList *tweens;
- GTimer *timer;
- guint timer_current_ms;
- guint tween_id;
+ /* Tweens */
+ GSList *tweens;
+ GTimer *timer;
+ guint timer_current_ms;
+ guint tween_id;
};
/* Internal prototypes */
-static void e_map_finalize (GObject *object);
-static void e_map_realize (GtkWidget *widget);
-static void e_map_unrealize (GtkWidget *widget);
-static void e_map_size_request (GtkWidget *widget, GtkRequisition *requisition);
-static void e_map_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
-static gint e_map_button_press (GtkWidget *widget, GdkEventButton *event);
-static gint e_map_button_release (GtkWidget *widget, GdkEventButton *event);
-static gint e_map_motion (GtkWidget *widget, GdkEventMotion *event);
-static gint e_map_expose (GtkWidget *widget, GdkEventExpose *event);
-static gint e_map_key_press (GtkWidget *widget, GdkEventKey *event);
-static void e_map_set_scroll_adjustments (GtkWidget *widget, GtkAdjustment *hadj, GtkAdjustment *vadj);
-
-static void e_map_get_current_location (EMap *map, double *longitude, double *latitude);
+static void e_map_get_current_location (EMap *map, gdouble *longitude, gdouble *latitude);
static void e_map_world_to_render_surface (EMap *map, gdouble world_longitude, gdouble world_latitude,
gdouble *win_x, gdouble *win_y);
static void update_render_surface (EMap *map, gboolean render_overlays);
-static void set_scroll_area (EMap *view, gint width, gint height);
-static void center_at (EMap *map, double longitude, double latitude);
-static void scroll_to (EMap *view, gint x, gint y);
-static gint load_map_background (EMap *view, gchar *name);
-static void adjustment_changed_cb (GtkAdjustment *adj, gpointer data);
+static void set_scroll_area (EMap *map, gint width, gint height);
+static void center_at (EMap *map, gdouble longitude, gdouble latitude);
+static void scroll_to (EMap *map, gint x, gint y);
+static gint load_map_background (EMap *map, gchar *name);
+static void adjustment_changed_cb (EMap *map);
static void update_and_paint (EMap *map);
static void update_render_point (EMap *map, EMapPoint *point);
static void repaint_point (EMap *map, EMapPoint *point);
@@ -134,104 +122,96 @@ static void repaint_point (EMap *map, EMapPoint *point);
* ------ */
static gboolean
-e_map_is_tweening (EMap *view)
+e_map_is_tweening (EMap *map)
{
- return view->priv->timer != NULL;
+ return map->priv->timer != NULL;
}
static void
-e_map_stop_tweening (EMap *view)
+e_map_stop_tweening (EMap *map)
{
- EMapPrivate *priv = view->priv;
+ g_assert (map->priv->tweens == NULL);
- g_assert (priv->tweens == NULL);
-
- if (!e_map_is_tweening (view))
- return;
+ if (!e_map_is_tweening (map))
+ return;
- g_timer_destroy (priv->timer);
- priv->timer = NULL;
- g_source_remove (priv->tween_id);
- priv->tween_id = 0;
+ g_timer_destroy (map->priv->timer);
+ map->priv->timer = NULL;
+ g_source_remove (map->priv->tween_id);
+ map->priv->tween_id = 0;
}
static void
-e_map_tween_destroy (EMap *view, EMapTween *tween)
+e_map_tween_destroy (EMap *map, EMapTween *tween)
{
- EMapPrivate *priv = view->priv;
+ map->priv->tweens = g_slist_remove (map->priv->tweens, tween);
+ g_slice_free (EMapTween, tween);
- priv->tweens = g_slist_remove (priv->tweens, tween);
- g_slice_free (EMapTween, tween);
-
- if (priv->tweens == NULL)
- e_map_stop_tweening (view);
+ if (map->priv->tweens == NULL)
+ e_map_stop_tweening (map);
}
static gboolean
e_map_do_tween_cb (gpointer data)
{
- EMap *view = data;
- EMapPrivate *priv = view->priv;
- GSList *walk;
+ EMap *map = data;
+ GSList *walk;
- priv->timer_current_ms = g_timer_elapsed (priv->timer, NULL) * 1000;
- gtk_widget_queue_draw (GTK_WIDGET (view));
+ map->priv->timer_current_ms =
+ g_timer_elapsed (map->priv->timer, NULL) * 1000;
+ gtk_widget_queue_draw (GTK_WIDGET (map));
- /* Can't use for loop here, because we need to advance
- * the list before deleting.
- */
- walk = priv->tweens;
- while (walk)
- {
- EMapTween *tween = walk->data;
+ /* Can't use for loop here, because we need to advance
+ * the list before deleting.
+ */
+ walk = map->priv->tweens;
+ while (walk)
+ {
+ EMapTween *tween = walk->data;
- walk = walk->next;
+ walk = walk->next;
- if (tween->end_time <= priv->timer_current_ms)
- e_map_tween_destroy (view, tween);
- }
+ if (tween->end_time <= map->priv->timer_current_ms)
+ e_map_tween_destroy (map, tween);
+ }
- return TRUE;
+ return TRUE;
}
static void
-e_map_start_tweening (EMap *view)
+e_map_start_tweening (EMap *map)
{
- EMapPrivate *priv = view->priv;
-
- if (e_map_is_tweening (view))
- return;
+ if (e_map_is_tweening (map))
+ return;
- priv->timer = g_timer_new ();
- priv->timer_current_ms = 0;
- priv->tween_id = gdk_threads_add_timeout (E_MAP_TWEEN_TIMEOUT_MSECS,
- e_map_do_tween_cb,
- view);
- g_timer_start (priv->timer);
+ map->priv->timer = g_timer_new ();
+ map->priv->timer_current_ms = 0;
+ map->priv->tween_id = gdk_threads_add_timeout (
+ E_MAP_TWEEN_TIMEOUT_MSECS, e_map_do_tween_cb, map);
+ g_timer_start (map->priv->timer);
}
static void
-e_map_tween_new (EMap *view, guint msecs, double longitude_offset, double latitude_offset, double zoom_factor)
+e_map_tween_new (EMap *map, guint msecs, gdouble longitude_offset, gdouble latitude_offset, gdouble zoom_factor)
{
- EMapPrivate *priv = view->priv;
- EMapTween *tween;
+ EMapTween *tween;
- if (!priv->smooth_zoom)
- return;
+ if (!map->priv->smooth_zoom)
+ return;
- e_map_start_tweening (view);
+ e_map_start_tweening (map);
- tween = g_slice_new (EMapTween);
+ tween = g_slice_new (EMapTween);
- tween->start_time = priv->timer_current_ms;
- tween->end_time = tween->start_time + msecs;
- tween->longitude_offset = longitude_offset;
- tween->latitude_offset = latitude_offset;
- tween->zoom_factor = zoom_factor;
+ tween->start_time = map->priv->timer_current_ms;
+ tween->end_time = tween->start_time + msecs;
+ tween->longitude_offset = longitude_offset;
+ tween->latitude_offset = latitude_offset;
+ tween->zoom_factor = zoom_factor;
- priv->tweens = g_slist_prepend (priv->tweens, tween);
+ map->priv->tweens = g_slist_prepend (map->priv->tweens, tween);
- gtk_widget_queue_draw (GTK_WIDGET (view));
+ gtk_widget_queue_draw (GTK_WIDGET (map));
}
G_DEFINE_TYPE (
@@ -240,127 +220,121 @@ G_DEFINE_TYPE (
GTK_TYPE_WIDGET)
static void
-e_map_tween_new_from (EMap *view, guint msecs, double longitude, double latitude, double zoom)
+e_map_tween_new_from (EMap *map,
+ guint msecs,
+ gdouble longitude,
+ gdouble latitude,
+ gdouble zoom)
{
- double current_longitude, current_latitude;
+ gdouble current_longitude, current_latitude;
- e_map_get_current_location (view, &current_longitude, &current_latitude);
+ e_map_get_current_location (
+ map, &current_longitude, &current_latitude);
- e_map_tween_new (view,
- msecs,
- longitude - current_longitude,
- latitude - current_latitude,
- zoom / e_map_get_magnification (view));
+ e_map_tween_new (
+ map, msecs,
+ longitude - current_longitude,
+ latitude - current_latitude,
+ zoom / e_map_get_magnification (map));
}
-/* ----------------- *
- * Widget management *
- * ----------------- */
-
-/* Class initialization function for the map view */
-
-static void
-e_map_class_init (EMapClass *class)
+static gdouble
+e_map_get_tween_effect (EMap *map,
+ EMapTween *tween)
{
- GObjectClass *gobject_class;
- GtkWidgetClass *widget_class;
-
- gobject_class = (GObjectClass *) class;
- widget_class = (GtkWidgetClass *) class;
+ gdouble elapsed;
- gobject_class->finalize = e_map_finalize;
-
- class->set_scroll_adjustments = e_map_set_scroll_adjustments;
- widget_class->set_scroll_adjustments_signal = g_signal_new ("set_scroll_adjustments",
- G_OBJECT_CLASS_TYPE (gobject_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (EMapClass, set_scroll_adjustments),
- NULL, NULL,
- e_marshal_NONE__OBJECT_OBJECT,
- G_TYPE_NONE, 2,
- GTK_TYPE_ADJUSTMENT,
- GTK_TYPE_ADJUSTMENT);
+ elapsed = (gdouble)
+ (map->priv->timer_current_ms - tween->start_time) /
+ tween->end_time;
- widget_class->realize = e_map_realize;
- widget_class->unrealize = e_map_unrealize;
- widget_class->size_request = e_map_size_request;
- widget_class->size_allocate = e_map_size_allocate;
- widget_class->button_press_event = e_map_button_press;
- widget_class->button_release_event = e_map_button_release;
- widget_class->motion_notify_event = e_map_motion;
- widget_class->expose_event = e_map_expose;
- widget_class->key_press_event = e_map_key_press;
+ return MAX (0.0, 1.0 - elapsed);
}
-/* Object initialization function for the map view */
+static void
+e_map_apply_tween (EMapTween *tween,
+ gdouble effect,
+ gdouble *longitude,
+ gdouble *latitude,
+ gdouble *zoom)
+{
+ *zoom *= pow (tween->zoom_factor, effect);
+ *longitude += tween->longitude_offset * effect;
+ *latitude += tween->latitude_offset * effect;
+}
static void
-e_map_init (EMap *view)
+e_map_tweens_compute_matrix (EMap *map, cairo_matrix_t *matrix)
{
- EMapPrivate *priv;
- GtkWidget *widget;
- gchar *map_file_name = g_build_filename (EVOLUTION_IMAGESDIR, "world_map-960.png", NULL);
+ GSList *walk;
+ gdouble zoom, x, y, latitude, longitude, effect;
+ GtkAllocation allocation;
+
+ if (!e_map_is_tweening (map)) {
+ cairo_matrix_init_translate (
+ matrix, -map->priv->xofs, -map->priv->yofs);
+ return;
+ }
- widget = GTK_WIDGET (view);
+ e_map_get_current_location (map, &longitude, &latitude);
+ zoom = 1.0;
- priv = g_new0 (EMapPrivate, 1);
- view->priv = priv;
+ for (walk = map->priv->tweens; walk; walk = walk->next) {
+ EMapTween *tween = walk->data;
- load_map_background (view, map_file_name);
- g_free (map_file_name);
- priv->frozen = FALSE;
- priv->smooth_zoom = TRUE;
- priv->zoom_state = E_MAP_ZOOMED_OUT;
- priv->points = g_ptr_array_new ();
+ effect = e_map_get_tween_effect (map, tween);
+ e_map_apply_tween (tween, effect, &longitude, &latitude, &zoom);
+ }
- gtk_widget_set_can_focus (widget, TRUE);
- gtk_widget_set_has_window (widget, TRUE);
+ gtk_widget_get_allocation (GTK_WIDGET (map), &allocation);
+ cairo_matrix_init_translate (matrix,
+ allocation.width / 2.0,
+ allocation.height / 2.0);
+
+ e_map_world_to_render_surface (map, longitude, latitude, &x, &y);
+ cairo_matrix_scale (matrix, zoom, zoom);
+ cairo_matrix_translate (matrix, -x, -y);
}
-/* Finalize handler for the map view */
+/* ----------------- *
+ * Widget management *
+ * ----------------- */
static void
e_map_finalize (GObject *object)
{
- EMap *view;
- EMapPrivate *priv;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (E_IS_MAP (object));
+ EMap *map;
- view = E_MAP (object);
- priv = view->priv;
+ map = E_MAP (object);
- while (priv->tweens)
- e_map_tween_destroy (view, priv->tweens->data);
- e_map_stop_tweening (view);
+ while (map->priv->tweens)
+ e_map_tween_destroy (map, map->priv->tweens->data);
+ e_map_stop_tweening (map);
- g_signal_handlers_disconnect_by_func (priv->hadj, adjustment_changed_cb, view);
- g_signal_handlers_disconnect_by_func (priv->vadj, adjustment_changed_cb, view);
+ g_signal_handlers_disconnect_by_func (map->priv->hadj, adjustment_changed_cb, map);
+ g_signal_handlers_disconnect_by_func (map->priv->vadj, adjustment_changed_cb, map);
- g_object_unref ((priv->hadj));
- priv->hadj = NULL;
+ g_object_unref ((map->priv->hadj));
+ map->priv->hadj = NULL;
- g_object_unref ((priv->vadj));
- priv->vadj = NULL;
+ g_object_unref ((map->priv->vadj));
+ map->priv->vadj = NULL;
- if (priv->map_pixbuf)
+ if (map->priv->map_pixbuf)
{
- g_object_unref (priv->map_pixbuf);
- priv->map_pixbuf = NULL;
+ g_object_unref (map->priv->map_pixbuf);
+ map->priv->map_pixbuf = NULL;
}
- /* gone in unrealize */
- g_assert (priv->map_render_surface == NULL);
+ /* gone in unrealize */
+ g_assert (map->priv->map_render_surface == NULL);
- g_free (priv);
- view->priv = NULL;
+ g_free (map->priv);
+ map->priv = NULL;
G_OBJECT_CLASS (e_map_parent_class)->finalize (object);
}
-/* Realize handler for the map view */
-
static void
e_map_realize (GtkWidget *widget)
{
@@ -407,49 +381,42 @@ e_map_realize (GtkWidget *widget)
static void
e_map_unrealize (GtkWidget *widget)
{
- EMap *view = E_MAP (widget);
- EMapPrivate *priv = view->priv;
+ EMap *map = E_MAP (widget);
- cairo_surface_destroy (priv->map_render_surface);
- priv->map_render_surface = NULL;
+ cairo_surface_destroy (map->priv->map_render_surface);
+ map->priv->map_render_surface = NULL;
- if (GTK_WIDGET_CLASS (e_map_parent_class)->unrealize)
- (*GTK_WIDGET_CLASS (e_map_parent_class)->unrealize) (widget);
+ if (GTK_WIDGET_CLASS (e_map_parent_class)->unrealize)
+ (*GTK_WIDGET_CLASS (e_map_parent_class)->unrealize) (widget);
}
-/* Size_request handler for the map view */
-
static void
e_map_size_request (GtkWidget *widget, GtkRequisition *requisition)
{
- EMap *view;
- EMapPrivate *priv;
+ EMap *map;
g_return_if_fail (widget != NULL);
g_return_if_fail (E_IS_MAP (widget));
g_return_if_fail (requisition != NULL);
- view = E_MAP (widget);
- priv = view->priv;
+ map = E_MAP (widget);
/* TODO: Put real sizes here. */
- requisition->width = gdk_pixbuf_get_width (priv->map_pixbuf);
- requisition->height = gdk_pixbuf_get_height (priv->map_pixbuf);
+ requisition->width = gdk_pixbuf_get_width (map->priv->map_pixbuf);
+ requisition->height = gdk_pixbuf_get_height (map->priv->map_pixbuf);
}
-/* Size_allocate handler for the map view */
-
static void
e_map_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
- EMap *view;
+ EMap *map;
g_return_if_fail (widget != NULL);
g_return_if_fail (E_IS_MAP (widget));
g_return_if_fail (allocation != NULL);
- view = E_MAP (widget);
+ map = E_MAP (widget);
/* Resize the window */
@@ -464,13 +431,38 @@ e_map_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
window, allocation->x, allocation->y,
allocation->width, allocation->height);
- gtk_widget_queue_draw (widget);
+ gtk_widget_queue_draw (widget);
}
- update_render_surface (view, TRUE);
+ update_render_surface (map, TRUE);
}
-/* Button press handler for the map view */
+static gboolean
+e_map_expose (GtkWidget *widget, GdkEventExpose *event)
+{
+ EMap *map;
+ cairo_t *cr;
+ cairo_matrix_t matrix;
+
+ if (!gtk_widget_is_drawable (widget))
+ return FALSE;
+
+ map = E_MAP (widget);
+
+ cr = gdk_cairo_create (event->window);
+ gdk_cairo_region (cr, event->region);
+ cairo_clip (cr);
+
+ e_map_tweens_compute_matrix (map, &matrix);
+ cairo_transform (cr, &matrix);
+
+ cairo_set_source_surface (cr, map->priv->map_render_surface, 0, 0);
+ cairo_paint (cr);
+
+ cairo_destroy (cr);
+
+ return FALSE;
+}
static gint
e_map_button_press (GtkWidget *widget, GdkEventButton *event)
@@ -479,8 +471,6 @@ e_map_button_press (GtkWidget *widget, GdkEventButton *event)
return TRUE;
}
-/* Button release handler for the map view */
-
static gint
e_map_button_release (GtkWidget *widget, GdkEventButton *event)
{
@@ -490,128 +480,86 @@ e_map_button_release (GtkWidget *widget, GdkEventButton *event)
return TRUE;
}
-/* Motion handler for the map view */
-
static gint
e_map_motion (GtkWidget *widget, GdkEventMotion *event)
{
return FALSE;
-
-/*
- * if (event->is_hint)
- * gdk_window_get_pointer(widget->window, &x, &y, &mods);
- * else
- * {
- * x = event->x;
- * y = event->y;
- * }
- *
- * return TRUE;
- */
}
-static double
-e_map_get_tween_effect (EMap *view, EMapTween *tween)
+static gint
+e_map_key_press (GtkWidget *widget,
+ GdkEventKey *event)
{
- double elapsed;
-
- elapsed = (double) (view->priv->timer_current_ms - tween->start_time) / tween->end_time;
+ EMap *map;
+ gboolean do_scroll;
+ gint xofs, yofs;
- return MAX (0.0, 1.0 - elapsed);
-}
+ map = E_MAP (widget);
-static void
-e_map_apply_tween (EMapTween *tween, double effect, double *longitude, double *latitude, double *zoom)
-{
- *zoom *= pow (tween->zoom_factor, effect);
- *longitude += tween->longitude_offset * effect;
- *latitude += tween->latitude_offset * effect;
-}
+ switch (event->keyval)
+ {
+ case GDK_KEY_Up:
+ do_scroll = TRUE;
+ xofs = 0;
+ yofs = -SCROLL_STEP_SIZE;
+ break;
-static void
-e_map_tweens_compute_matrix (EMap *view, cairo_matrix_t *matrix)
-{
- EMapPrivate *priv = view->priv;
- GSList *walk;
- double zoom, x, y, latitude, longitude, effect;
- GtkAllocation allocation;
-
- if (!e_map_is_tweening (view))
- {
- cairo_matrix_init_translate (matrix, -priv->xofs, -priv->yofs);
- return;
- }
-
- e_map_get_current_location (view, &longitude, &latitude);
- zoom = 1.0;
-
- for (walk = priv->tweens; walk; walk = walk->next)
- {
- EMapTween *tween = walk->data;
-
- effect = e_map_get_tween_effect (view, tween);
- e_map_apply_tween (tween, effect, &longitude, &latitude, &zoom);
- }
-
- gtk_widget_get_allocation (GTK_WIDGET (view), &allocation);
- cairo_matrix_init_translate (matrix,
- allocation.width / 2.0,
- allocation.height / 2.0);
-
- e_map_world_to_render_surface (view,
- longitude, latitude,
- &x, &y);
- cairo_matrix_scale (matrix, zoom, zoom);
- cairo_matrix_translate (matrix, -x, -y);
-}
+ case GDK_KEY_Down:
+ do_scroll = TRUE;
+ xofs = 0;
+ yofs = SCROLL_STEP_SIZE;
+ break;
-/* Expose handler for the map view */
+ case GDK_KEY_Left:
+ do_scroll = TRUE;
+ xofs = -SCROLL_STEP_SIZE;
+ yofs = 0;
+ break;
-static gboolean
-e_map_expose (GtkWidget *widget, GdkEventExpose *event)
-{
- EMap *view;
- EMapPrivate *priv;
- cairo_t *cr;
- cairo_matrix_t matrix;
+ case GDK_KEY_Right:
+ do_scroll = TRUE;
+ xofs = SCROLL_STEP_SIZE;
+ yofs = 0;
+ break;
- if (!gtk_widget_is_drawable (widget))
- return FALSE;
+ default:
+ return FALSE;
+ }
- view = E_MAP (widget);
- priv = view->priv;
+ if (do_scroll) {
+ gint page_size;
+ gint upper;
+ gint x, y;
- cr = gdk_cairo_create (event->window);
- gdk_cairo_region (cr, event->region);
- cairo_clip (cr);
+ page_size = gtk_adjustment_get_page_size (map->priv->hadj);
+ upper = gtk_adjustment_get_upper (map->priv->hadj);
+ x = CLAMP (map->priv->xofs + xofs, 0, upper - page_size);
- e_map_tweens_compute_matrix (view, &matrix);
- cairo_transform (cr, &matrix);
+ page_size = gtk_adjustment_get_page_size (map->priv->vadj);
+ upper = gtk_adjustment_get_upper (map->priv->vadj);
+ y = CLAMP (map->priv->yofs + yofs, 0, upper - page_size);
- cairo_set_source_surface (cr,
- priv->map_render_surface,
- 0, 0);
- cairo_paint (cr);
+ scroll_to (map, x, y);
- cairo_destroy (cr);
+ gtk_adjustment_set_value (map->priv->hadj, x);
+ gtk_adjustment_set_value (map->priv->vadj, y);
+ }
- return FALSE;
+ return TRUE;
}
-/* Set_scroll_adjustments handler for the map view */
-
static void
e_map_set_scroll_adjustments (GtkWidget *widget, GtkAdjustment *hadj, GtkAdjustment *vadj)
{
- EMap *view;
+ EMap *map;
EMapPrivate *priv;
gboolean need_adjust;
g_return_if_fail (widget != NULL);
g_return_if_fail (E_IS_MAP (widget));
- view = E_MAP (widget);
- priv = view->priv;
+ map = E_MAP (widget);
+ priv = map->priv;
if (hadj) g_return_if_fail (GTK_IS_ADJUSTMENT (hadj));
else hadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
@@ -619,113 +567,103 @@ e_map_set_scroll_adjustments (GtkWidget *widget, GtkAdjustment *hadj, GtkAdjustm
if (vadj) g_return_if_fail (GTK_IS_ADJUSTMENT (vadj));
else vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
- if (priv->hadj && priv->hadj != hadj)
+ if (map->priv->hadj && priv->hadj != hadj)
{
- g_signal_handlers_disconnect_by_func (priv->hadj,
+ g_signal_handlers_disconnect_by_func (map->priv->hadj,
adjustment_changed_cb,
- view);
- g_object_unref (priv->hadj);
+ map);
+ g_object_unref (map->priv->hadj);
}
- if (priv->vadj && priv->vadj != vadj)
+ if (map->priv->vadj && priv->vadj != vadj)
{
- g_signal_handlers_disconnect_by_func (priv->vadj,
+ g_signal_handlers_disconnect_by_func (map->priv->vadj,
adjustment_changed_cb,
- view);
- g_object_unref (priv->vadj);
+ map);
+ g_object_unref (map->priv->vadj);
}
need_adjust = FALSE;
- if (priv->hadj != hadj)
+ if (map->priv->hadj != hadj)
{
- priv->hadj = hadj;
- g_object_ref_sink (priv->hadj);
+ map->priv->hadj = hadj;
+ g_object_ref_sink (map->priv->hadj);
- g_signal_connect (priv->hadj, "value_changed",
- G_CALLBACK (adjustment_changed_cb), view);
+ g_signal_connect_swapped (
+ map->priv->hadj, "value_changed",
+ G_CALLBACK (adjustment_changed_cb), map);
need_adjust = TRUE;
}
- if (priv->vadj != vadj)
+ if (map->priv->vadj != vadj)
{
- priv->vadj = vadj;
- g_object_ref_sink (priv->vadj);
+ map->priv->vadj = vadj;
+ g_object_ref_sink (map->priv->vadj);
- g_signal_connect (priv->vadj, "value_changed",
- G_CALLBACK (adjustment_changed_cb), view);
+ g_signal_connect_swapped (
+ map->priv->vadj, "value_changed",
+ G_CALLBACK (adjustment_changed_cb), map);
need_adjust = TRUE;
}
- if (need_adjust) adjustment_changed_cb (NULL, view);
+ if (need_adjust) adjustment_changed_cb (map);
}
-/* Key press handler for the map view */
-
-static gint
-e_map_key_press (GtkWidget *widget, GdkEventKey *event)
+static void
+e_map_class_init (EMapClass *class)
{
- EMap *view;
- EMapPrivate *priv;
- gboolean do_scroll;
- gint xofs, yofs;
-
- view = E_MAP (widget);
- priv = view->priv;
-
- switch (event->keyval)
- {
- case GDK_KEY_Up:
- do_scroll = TRUE;
- xofs = 0;
- yofs = -SCROLL_STEP_SIZE;
- break;
+ GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
- case GDK_KEY_Down:
- do_scroll = TRUE;
- xofs = 0;
- yofs = SCROLL_STEP_SIZE;
- break;
+ object_class = G_OBJECT_CLASS (class);
+ object_class->finalize = e_map_finalize;
- case GDK_KEY_Left:
- do_scroll = TRUE;
- xofs = -SCROLL_STEP_SIZE;
- yofs = 0;
- break;
-
- case GDK_KEY_Right:
- do_scroll = TRUE;
- xofs = SCROLL_STEP_SIZE;
- yofs = 0;
- break;
+ widget_class = GTK_WIDGET_CLASS (class);
+ widget_class->realize = e_map_realize;
+ widget_class->unrealize = e_map_unrealize;
+ widget_class->size_request = e_map_size_request;
+ widget_class->size_allocate = e_map_size_allocate;
+ widget_class->button_press_event = e_map_button_press;
+ widget_class->button_release_event = e_map_button_release;
+ widget_class->motion_notify_event = e_map_motion;
+ widget_class->expose_event = e_map_expose;
+ widget_class->key_press_event = e_map_key_press;
- default:
- return FALSE;
- }
+ widget_class->set_scroll_adjustments_signal = g_signal_new ("set_scroll_adjustments",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (EMapClass, set_scroll_adjustments),
+ NULL, NULL,
+ e_marshal_NONE__OBJECT_OBJECT,
+ G_TYPE_NONE, 2,
+ GTK_TYPE_ADJUSTMENT,
+ GTK_TYPE_ADJUSTMENT);
- if (do_scroll)
- {
- gint page_size;
- gint upper;
- gint x, y;
+ class->set_scroll_adjustments = e_map_set_scroll_adjustments;
+}
- page_size = gtk_adjustment_get_page_size (priv->hadj);
- upper = gtk_adjustment_get_upper (priv->hadj);
- x = CLAMP (priv->xofs + xofs, 0, upper - page_size);
+static void
+e_map_init (EMap *map)
+{
+ GtkWidget *widget;
+ gchar *map_file_name = g_build_filename (EVOLUTION_IMAGESDIR, "world_map-960.png", NULL);
- page_size = gtk_adjustment_get_page_size (priv->vadj);
- upper = gtk_adjustment_get_upper (priv->vadj);
- y = CLAMP (priv->yofs + yofs, 0, upper - page_size);
+ widget = GTK_WIDGET (map);
- scroll_to (view, x, y);
+ map->priv = g_new0 (EMapPrivate, 1);
- gtk_adjustment_set_value (priv->hadj, x);
- gtk_adjustment_set_value (priv->vadj, y);
- }
+ load_map_background (map, map_file_name);
+ g_free (map_file_name);
+ map->priv->frozen = FALSE;
+ map->priv->smooth_zoom = TRUE;
+ map->priv->zoom_state = E_MAP_ZOOMED_OUT;
+ map->priv->points = g_ptr_array_new ();
- return TRUE;
+ gtk_widget_set_can_focus (widget, TRUE);
+ gtk_widget_set_has_window (widget, TRUE);
}
/* ---------------- *
@@ -766,20 +704,18 @@ e_map_new (void)
void
e_map_window_to_world (EMap *map, gdouble win_x, gdouble win_y, gdouble *world_longitude, gdouble *world_latitude)
{
- EMapPrivate *priv;
gint width, height;
g_return_if_fail (map);
- priv = map->priv;
g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (map)));
width = E_MAP_GET_WIDTH (map);
height = E_MAP_GET_HEIGHT (map);
- *world_longitude = (win_x + priv->xofs - (gdouble) width / 2.0) /
+ *world_longitude = (win_x + map->priv->xofs - (gdouble) width / 2.0) /
((gdouble) width / 2.0) * 180.0;
- *world_latitude = ((gdouble) height / 2.0 - win_y - priv->yofs) /
+ *world_latitude = ((gdouble) height / 2.0 - win_y - map->priv->yofs) /
((gdouble) height / 2.0) * 90.0;
}
@@ -798,18 +734,14 @@ e_map_world_to_render_surface (EMap *map, gdouble world_longitude, gdouble world
void
e_map_world_to_window (EMap *map, gdouble world_longitude, gdouble world_latitude, gdouble *win_x, gdouble *win_y)
{
- EMapPrivate *priv;
-
g_return_if_fail (E_IS_MAP (map));
g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (map)));
g_return_if_fail (world_longitude >= -180.0 && world_longitude <= 180.0);
g_return_if_fail (world_latitude >= -90.0 && world_latitude <= 90.0);
- priv = map->priv;
-
- e_map_world_to_render_surface (map, world_longitude, world_latitude, win_x, win_y);
- *win_x -= priv->xofs;
- *win_y -= priv->yofs;
+ e_map_world_to_render_surface (map, world_longitude, world_latitude, win_x, win_y);
+ *win_x -= map->priv->xofs;
+ *win_y -= map->priv->yofs;
#ifdef DEBUG
printf ("Map size: (%d, %d)\nCoords: (%.1f, %.1f) -> (%.1f, %.1f)\n---\n", width, height, world_longitude, world_latitude, *win_x, *win_y);
@@ -821,61 +753,54 @@ e_map_world_to_window (EMap *map, gdouble world_longitude, gdouble world_latitud
gdouble
e_map_get_magnification (EMap *map)
{
- EMapPrivate *priv;
-
- priv = map->priv;
- if (priv->zoom_state == E_MAP_ZOOMED_IN) return 2.0;
+ if (map->priv->zoom_state == E_MAP_ZOOMED_IN) return 2.0;
else return 1.0;
}
static void
-e_map_set_zoom (EMap *view, EMapZoomState zoom)
+e_map_set_zoom (EMap *map, EMapZoomState zoom)
{
- EMapPrivate *priv = view->priv;
-
- if (priv->zoom_state == zoom)
- return;
+ if (map->priv->zoom_state == zoom)
+ return;
- priv->zoom_state = zoom;
- update_render_surface (view, TRUE);
- gtk_widget_queue_draw (GTK_WIDGET (view));
+ map->priv->zoom_state = zoom;
+ update_render_surface (map, TRUE);
+ gtk_widget_queue_draw (GTK_WIDGET (map));
}
void
e_map_zoom_to_location (EMap *map, gdouble longitude, gdouble latitude)
{
- EMapPrivate *priv;
- double prevlong, prevlat;
- double prevzoom;
+ gdouble prevlong, prevlat;
+ gdouble prevzoom;
g_return_if_fail (map);
g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (map)));
- priv = map->priv;
- e_map_get_current_location (map, &prevlong, &prevlat);
- prevzoom = e_map_get_magnification (map);
+ e_map_get_current_location (map, &prevlong, &prevlat);
+ prevzoom = e_map_get_magnification (map);
- e_map_set_zoom (map, E_MAP_ZOOMED_IN);
- center_at (map, longitude, latitude);
+ e_map_set_zoom (map, E_MAP_ZOOMED_IN);
+ center_at (map, longitude, latitude);
- e_map_tween_new_from (map, E_MAP_TWEEN_DURATION_MSECS, prevlong, prevlat, prevzoom);
+ e_map_tween_new_from (map, E_MAP_TWEEN_DURATION_MSECS, prevlong, prevlat, prevzoom);
}
void
e_map_zoom_out (EMap *map)
{
- double longitude, latitude;
- double prevzoom;
+ gdouble longitude, latitude;
+ gdouble prevzoom;
g_return_if_fail (map);
g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (map)));
- e_map_get_current_location (map, &longitude, &latitude);
- prevzoom = e_map_get_magnification (map);
- e_map_set_zoom (map, E_MAP_ZOOMED_OUT);
- center_at (map, longitude, latitude);
+ e_map_get_current_location (map, &longitude, &latitude);
+ prevzoom = e_map_get_magnification (map);
+ e_map_set_zoom (map, E_MAP_ZOOMED_OUT);
+ center_at (map, longitude, latitude);
- e_map_tween_new_from (map, E_MAP_TWEEN_DURATION_MSECS, longitude, latitude, prevzoom);
+ e_map_tween_new_from (map, E_MAP_TWEEN_DURATION_MSECS, longitude, latitude, prevzoom);
}
void
@@ -908,10 +833,8 @@ e_map_thaw (EMap *map)
EMapPoint *
e_map_add_point (EMap *map, gchar *name, gdouble longitude, gdouble latitude, guint32 color_rgba)
{
- EMapPrivate *priv;
EMapPoint *point;
- priv = map->priv;
point = g_new0 (EMapPoint, 1);
point->name = name; /* Can be NULL */
@@ -919,10 +842,9 @@ e_map_add_point (EMap *map, gchar *name, gdouble longitude, gdouble latitude, gu
point->latitude = latitude;
point->rgba = color_rgba;
- g_ptr_array_add (priv->points, (gpointer) point);
+ g_ptr_array_add (map->priv->points, (gpointer) point);
- if (!priv->frozen)
- {
+ if (!map->priv->frozen) {
update_render_point (map, point);
repaint_point (map, point);
}
@@ -933,10 +855,7 @@ e_map_add_point (EMap *map, gchar *name, gdouble longitude, gdouble latitude, gu
void
e_map_remove_point (EMap *map, EMapPoint *point)
{
- EMapPrivate *priv;
-
- priv = map->priv;
- g_ptr_array_remove (priv->points, point);
+ g_ptr_array_remove (map->priv->points, point);
if (!((EMapPrivate *) map->priv)->frozen)
{
@@ -998,12 +917,10 @@ e_map_point_get_data (EMapPoint *point)
gboolean
e_map_point_is_in_view (EMap *map, EMapPoint *point)
{
- EMapPrivate *priv;
GtkAllocation allocation;
gdouble x, y;
- priv = map->priv;
- if (!priv->map_render_surface) return FALSE;
+ if (!map->priv->map_render_surface) return FALSE;
e_map_world_to_window (map, point->longitude, point->latitude, &x, &y);
gtk_widget_get_allocation (GTK_WIDGET (map), &allocation);
@@ -1018,17 +935,14 @@ e_map_point_is_in_view (EMap *map, EMapPoint *point)
EMapPoint *
e_map_get_closest_point (EMap *map, gdouble longitude, gdouble latitude, gboolean in_view)
{
- EMapPrivate *priv;
EMapPoint *point_chosen = NULL, *point;
gdouble min_dist = 0.0, dist;
gdouble dx, dy;
gint i;
- priv = map->priv;
-
- for (i = 0; i < priv->points->len; i++)
+ for (i = 0; i < map->priv->points->len; i++)
{
- point = g_ptr_array_index (priv->points, i);
+ point = g_ptr_array_index (map->priv->points, i);
if (in_view && !e_map_point_is_in_view (map, point)) continue;
dx = point->longitude - longitude;
@@ -1057,20 +971,17 @@ update_and_paint (EMap *map)
}
static gint
-load_map_background (EMap *view, gchar *name)
+load_map_background (EMap *map, gchar *name)
{
- EMapPrivate *priv;
GdkPixbuf *pb0;
- priv = view->priv;
-
pb0 = gdk_pixbuf_new_from_file (name, NULL);
if (!pb0)
return FALSE;
- if (priv->map_pixbuf) g_object_unref (priv->map_pixbuf);
- priv->map_pixbuf = pb0;
- update_render_surface (view, TRUE);
+ if (map->priv->map_pixbuf) g_object_unref (map->priv->map_pixbuf);
+ map->priv->map_pixbuf = pb0;
+ update_render_surface (map, TRUE);
return TRUE;
}
@@ -1079,7 +990,6 @@ static void
update_render_surface (EMap *map,
gboolean render_overlays)
{
- EMapPrivate *priv;
EMapPoint *point;
GtkAllocation allocation;
gint width, height, orig_width, orig_height;
@@ -1093,11 +1003,10 @@ update_render_surface (EMap *map,
/* Set up value shortcuts */
- priv = map->priv;
width = allocation.width;
height = allocation.height;
- orig_width = gdk_pixbuf_get_width (priv->map_pixbuf);
- orig_height = gdk_pixbuf_get_height (priv->map_pixbuf);
+ orig_width = gdk_pixbuf_get_width (map->priv->map_pixbuf);
+ orig_height = gdk_pixbuf_get_height (map->priv->map_pixbuf);
/* Compute scaled width and height based on the extreme dimension */
@@ -1106,40 +1015,40 @@ update_render_surface (EMap *map,
else
zoom = (gdouble) height / (gdouble) orig_height;
- if (priv->zoom_state == E_MAP_ZOOMED_IN)
+ if (map->priv->zoom_state == E_MAP_ZOOMED_IN)
zoom *= 2.0;
height = (orig_height * zoom) + 0.5;
width = (orig_width * zoom) + 0.5;
/* Reallocate the pixbuf */
- if (priv->map_render_surface) cairo_surface_destroy (priv->map_render_surface);
- priv->map_render_surface = gdk_window_create_similar_surface (gtk_widget_get_window (GTK_WIDGET (map)),
- CAIRO_CONTENT_COLOR,
- width, height);
+ if (map->priv->map_render_surface)
+ cairo_surface_destroy (map->priv->map_render_surface);
+ map->priv->map_render_surface = gdk_window_create_similar_surface (
+ gtk_widget_get_window (GTK_WIDGET (map)),
+ CAIRO_CONTENT_COLOR, width, height);
/* Scale the original map into the rendering pixbuf */
if (width > 1 && height > 1)
{
- cairo_t *cr = cairo_create (priv->map_render_surface);
- cairo_scale (cr, (double) width / orig_width, (double) height / orig_height);
- gdk_cairo_set_source_pixbuf (cr, priv->map_pixbuf, 0, 0);
- cairo_paint (cr);
- cairo_destroy (cr);
+ cairo_t *cr = cairo_create (map->priv->map_render_surface);
+ cairo_scale (cr, (gdouble) width / orig_width, (gdouble) height / orig_height);
+ gdk_cairo_set_source_pixbuf (cr, map->priv->map_pixbuf, 0, 0);
+ cairo_paint (cr);
+ cairo_destroy (cr);
}
- /* Compute image offsets with respect to window */
+ /* Compute image offsets with respect to window */
- set_scroll_area (map, width, height);
+ set_scroll_area (map, width, height);
- if (render_overlays)
- {
+ if (render_overlays) {
/* Add points */
- for (i = 0; i < priv->points->len; i++)
+ for (i = 0; i < map->priv->points->len; i++)
{
- point = g_ptr_array_index (priv->points, i);
+ point = g_ptr_array_index (map->priv->points, i);
update_render_point (map, point);
}
}
@@ -1150,46 +1059,43 @@ update_render_surface (EMap *map,
static void
update_render_point (EMap *map, EMapPoint *point)
{
- EMapPrivate *priv;
- cairo_t *cr;
+ cairo_t *cr;
gdouble px, py;
- static guchar mask1[] = { 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
- 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
- 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 };
- static guchar mask2[] = { 0x00, 0xff, 0x00, 0x00,
- 0xff, 0xff, 0xff, 0x00,
- 0x00, 0xff, 0x00, 0x00 };
- cairo_surface_t *mask;
-
- priv = map->priv;
-
- if (priv->map_render_surface == NULL)
- return;
+ static guchar mask1[] = { 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
+ 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00,
+ 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00 };
+ static guchar mask2[] = { 0x00, 0xff, 0x00, 0x00,
+ 0xff, 0xff, 0xff, 0x00,
+ 0x00, 0xff, 0x00, 0x00 };
+ cairo_surface_t *mask;
+
+ if (map->priv->map_render_surface == NULL)
+ return;
- cr = cairo_create (priv->map_render_surface);
- cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
+ cr = cairo_create (map->priv->map_render_surface);
+ cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
e_map_world_to_window (map, point->longitude, point->latitude, &px, &py);
- px = floor (px + priv->xofs);
- py = floor (py + priv->yofs);
-
- cairo_set_source_rgb (cr, 0, 0, 0);
- mask = cairo_image_surface_create_for_data (mask1, CAIRO_FORMAT_A8, 5, 5, 8);
- cairo_mask_surface (cr, mask, px - 2, py - 2);
- cairo_surface_destroy (mask);
-
- cairo_set_source_rgba (cr,
- ((point->rgba >> 24) & 0xff) / 255.0,
- ((point->rgba >> 16) & 0xff) / 255.0,
- ((point->rgba >> 8) & 0xff) / 255.0,
- ( point->rgba & 0xff) / 255.0);
- mask = cairo_image_surface_create_for_data (mask2, CAIRO_FORMAT_A8, 3, 3, 4);
- cairo_mask_surface (cr, mask, px - 1, py - 1);
- cairo_surface_destroy (mask);
-
- cairo_destroy (cr);
+ px = floor (px + map->priv->xofs);
+ py = floor (py + map->priv->yofs);
+
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ mask = cairo_image_surface_create_for_data (mask1, CAIRO_FORMAT_A8, 5, 5, 8);
+ cairo_mask_surface (cr, mask, px - 2, py - 2);
+ cairo_surface_destroy (mask);
+
+ cairo_set_source_rgba (cr,
+ ((point->rgba >> 24) & 0xff) / 255.0,
+ ((point->rgba >> 16) & 0xff) / 255.0,
+ ((point->rgba >> 8) & 0xff) / 255.0,
+ ( point->rgba & 0xff) / 255.0);
+ mask = cairo_image_surface_create_for_data (mask2, CAIRO_FORMAT_A8, 3, 3, 4);
+ cairo_mask_surface (cr, mask, px - 1, py - 1);
+ cairo_surface_destroy (mask);
+
+ cairo_destroy (cr);
}
/* Repaint point on X server */
@@ -1199,27 +1105,24 @@ repaint_point (EMap *map, EMapPoint *point)
{
gdouble px, py;
- if (!gtk_widget_is_drawable (GTK_WIDGET (map)))
- return;
+ if (!gtk_widget_is_drawable (GTK_WIDGET (map)))
+ return;
e_map_world_to_window (map, point->longitude, point->latitude, &px, &py);
gtk_widget_queue_draw_area (GTK_WIDGET (map),
- (gint) px - 2, (gint) py - 2,
- 5, 5);
+ (gint) px - 2, (gint) py - 2,
+ 5, 5);
}
static void
-center_at (EMap *map, double longitude, double latitude)
+center_at (EMap *map, gdouble longitude, gdouble latitude)
{
- EMapPrivate *priv;
GtkAllocation allocation;
gint pb_width, pb_height;
- double x, y;
-
- e_map_world_to_render_surface (map, longitude, latitude, &x, &y);
+ gdouble x, y;
- priv = map->priv;
+ e_map_world_to_render_surface (map, longitude, latitude, &x, &y);
pb_width = E_MAP_GET_WIDTH (map);
pb_height = E_MAP_GET_HEIGHT (map);
@@ -1229,97 +1132,88 @@ center_at (EMap *map, double longitude, double latitude)
x = CLAMP (x - (allocation.width / 2), 0, pb_width - allocation.width);
y = CLAMP (y - (allocation.height / 2), 0, pb_height - allocation.height);
- gtk_adjustment_set_value (priv->hadj, x);
- gtk_adjustment_set_value (priv->vadj, y);
+ gtk_adjustment_set_value (map->priv->hadj, x);
+ gtk_adjustment_set_value (map->priv->vadj, y);
- gtk_widget_queue_draw (GTK_WIDGET (map));
+ gtk_widget_queue_draw (GTK_WIDGET (map));
}
/* Scrolls the view to the specified offsets. Does not perform range checking! */
static void
-scroll_to (EMap *view, gint x, gint y)
+scroll_to (EMap *map, gint x, gint y)
{
- EMapPrivate *priv;
gint xofs, yofs;
- priv = view->priv;
-
/* Compute offsets and check bounds */
- xofs = x - priv->xofs;
- yofs = y - priv->yofs;
+ xofs = x - map->priv->xofs;
+ yofs = y - map->priv->yofs;
if (xofs == 0 && yofs == 0)
return;
- priv->xofs = x;
- priv->yofs = y;
+ map->priv->xofs = x;
+ map->priv->yofs = y;
- gtk_widget_queue_draw (GTK_WIDGET (view));
+ gtk_widget_queue_draw (GTK_WIDGET (map));
}
static void
-e_map_get_current_location (EMap *map, double *longitude, double *latitude)
+e_map_get_current_location (EMap *map, gdouble *longitude, gdouble *latitude)
{
GtkAllocation allocation;
gtk_widget_get_allocation (GTK_WIDGET (map), &allocation);
e_map_window_to_world (map,
- allocation.width / 2.0, allocation.height / 2.0,
+ allocation.width / 2.0, allocation.height / 2.0,
longitude, latitude);
}
/* Callback used when an adjustment is changed */
static void
-adjustment_changed_cb (GtkAdjustment *adj, gpointer data)
+adjustment_changed_cb (EMap *map)
{
- EMap *view;
gint hadj_value;
gint vadj_value;
- view = E_MAP (data);
-
- hadj_value = gtk_adjustment_get_value (view->priv->hadj);
- vadj_value = gtk_adjustment_get_value (view->priv->vadj);
+ hadj_value = gtk_adjustment_get_value (map->priv->hadj);
+ vadj_value = gtk_adjustment_get_value (map->priv->vadj);
- scroll_to (view, hadj_value, vadj_value);
+ scroll_to (map, hadj_value, vadj_value);
}
static void
-set_scroll_area (EMap *view, gint width, gint height)
+set_scroll_area (EMap *map, gint width, gint height)
{
- EMapPrivate *priv;
GtkAllocation allocation;
- priv = view->priv;
-
- if (!gtk_widget_get_realized (GTK_WIDGET (view))) return;
- if (!priv->hadj || !priv->vadj) return;
+ if (!gtk_widget_get_realized (GTK_WIDGET (map))) return;
+ if (!map->priv->hadj || !map->priv->vadj) return;
- g_object_freeze_notify (G_OBJECT (priv->hadj));
- g_object_freeze_notify (G_OBJECT (priv->vadj));
+ g_object_freeze_notify (G_OBJECT (map->priv->hadj));
+ g_object_freeze_notify (G_OBJECT (map->priv->vadj));
- gtk_widget_get_allocation (GTK_WIDGET (view), &allocation);
-
- priv->xofs = CLAMP (priv->xofs, 0, width - allocation.width);
- priv->yofs = CLAMP (priv->yofs, 0, height - allocation.height);
-
- gtk_adjustment_configure (priv->hadj,
- priv->xofs,
- 0, width,
- SCROLL_STEP_SIZE,
- allocation.width / 2,
- allocation.width);
- gtk_adjustment_configure (priv->vadj,
- priv->yofs,
- 0, height,
- SCROLL_STEP_SIZE,
- allocation.height / 2,
- allocation.height);
+ gtk_widget_get_allocation (GTK_WIDGET (map), &allocation);
- g_object_thaw_notify (G_OBJECT (priv->hadj));
- g_object_thaw_notify (G_OBJECT (priv->vadj));
+ map->priv->xofs = CLAMP (map->priv->xofs, 0, width - allocation.width);
+ map->priv->yofs = CLAMP (map->priv->yofs, 0, height - allocation.height);
+
+ gtk_adjustment_configure (map->priv->hadj,
+ map->priv->xofs,
+ 0, width,
+ SCROLL_STEP_SIZE,
+ allocation.width / 2,
+ allocation.width);
+ gtk_adjustment_configure (map->priv->vadj,
+ map->priv->yofs,
+ 0, height,
+ SCROLL_STEP_SIZE,
+ allocation.height / 2,
+ allocation.height);
+
+ g_object_thaw_notify (G_OBJECT (map->priv->hadj));
+ g_object_thaw_notify (G_OBJECT (map->priv->vadj));
}
diff --git a/widgets/table/e-cell-checkbox.c b/widgets/table/e-cell-checkbox.c
index 441f6723f3..20f56b443e 100644
--- a/widgets/table/e-cell-checkbox.c
+++ b/widgets/table/e-cell-checkbox.c
@@ -50,13 +50,13 @@ ecc_print (ECellView *ecell_view, GtkPrintContext *context,
cairo_save (cr);
if ( value == 1) {
-
cairo_set_line_width (cr, 2);
cairo_move_to (cr, 3, 11);
cairo_line_to (cr, 7, 14);
cairo_line_to (cr, 11, 5);
cairo_stroke (cr);
}
+
cairo_restore (cr);
}
diff --git a/widgets/table/e-cell-hbox.c b/widgets/table/e-cell-hbox.c
index 1e6c4a6efc..6f587db9d2 100644
--- a/widgets/table/e-cell-hbox.c
+++ b/widgets/table/e-cell-hbox.c
@@ -138,9 +138,16 @@ ecv_unrealize (ECellView *ecv)
* ECell::draw method
*/
static void
-ecv_draw (ECellView *ecell_view, GdkDrawable *drawable,
- gint model_col, gint view_col, gint row, ECellFlags flags,
- gint x1, gint y1, gint x2, gint y2)
+ecv_draw (ECellView *ecell_view,
+ GdkDrawable *drawable,
+ gint model_col,
+ gint view_col,
+ gint row,
+ ECellFlags flags,
+ gint x1,
+ gint y1,
+ gint x2,
+ gint y2)
{
ECellHboxView *hbox_view = (ECellHboxView *)ecell_view;
@@ -156,9 +163,12 @@ ecv_draw (ECellView *ecell_view, GdkDrawable *drawable,
if (width < hbox_view->def_size_cols[i])
width = hbox_view->def_size_cols[i];
printf("width of %d %d of %d\n", width,hbox_view->def_size_cols[i], allotted_width ); */
- e_cell_draw (hbox_view->subcell_views[i], drawable,
- hbox_view->model_cols[i], view_col, row, flags,
- x1 + subcell_offset , y1, x1 + subcell_offset + width, y2);
+
+ e_cell_draw (
+ hbox_view->subcell_views[i], drawable,
+ hbox_view->model_cols[i], view_col, row, flags,
+ x1 + subcell_offset , y1,
+ x1 + subcell_offset + width, y2);
subcell_offset += width; /* e_cell_max_width_by_row (hbox_view->subcell_views[i], hbox_view->model_cols[i], view_col, row); */
}
diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c
index 4d86378904..1b0545cc37 100644
--- a/widgets/table/e-cell-text.c
+++ b/widgets/table/e-cell-text.c
@@ -736,8 +736,9 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
gchar *color_spec;
GdkColor *cell_foreground;
- color_spec = e_table_model_value_at (ecell_view->e_table_model,
- ect->color_column, row);
+ color_spec = e_table_model_value_at (
+ ecell_view->e_table_model,
+ ect->color_column, row);
cell_foreground = e_cell_text_get_color (text_view,
color_spec);
if (cell_foreground)
diff --git a/widgets/table/e-cell-tree.c b/widgets/table/e-cell-tree.c
index 5771cbc053..9129fba446 100644
--- a/widgets/table/e-cell-tree.c
+++ b/widgets/table/e-cell-tree.c
@@ -126,8 +126,8 @@ ect_new_view (ECell *ecell, ETableModel *table_model, gpointer e_table_item_view
tree_view->cell_view.ecell = ecell;
tree_view->cell_view.e_table_model = table_model;
tree_view->cell_view.e_table_item_view = e_table_item_view;
- tree_view->cell_view.kill_view_cb = NULL;
- tree_view->cell_view.kill_view_cb_data = NULL;
+ tree_view->cell_view.kill_view_cb = NULL;
+ tree_view->cell_view.kill_view_cb_data = NULL;
/* create our subcell view */
tree_view->subcell_view = e_cell_new_view (ect->subcell, table_model, e_table_item_view /* XXX */);
@@ -145,11 +145,11 @@ ect_kill_view (ECellView *ecv)
{
ECellTreeView *tree_view = (ECellTreeView *) ecv;
- if (tree_view->cell_view.kill_view_cb)
- (tree_view->cell_view.kill_view_cb)(ecv, tree_view->cell_view.kill_view_cb_data);
+ if (tree_view->cell_view.kill_view_cb)
+ (tree_view->cell_view.kill_view_cb)(ecv, tree_view->cell_view.kill_view_cb_data);
- if (tree_view->cell_view.kill_view_cb_data)
- g_list_free (tree_view->cell_view.kill_view_cb_data);
+ if (tree_view->cell_view.kill_view_cb_data)
+ g_list_free (tree_view->cell_view.kill_view_cb_data);
/* kill our subcell view */
e_cell_kill_view (tree_view->subcell_view);
@@ -188,7 +188,11 @@ ect_unrealize (ECellView *ecv)
}
static void
-draw_expander (ECellTreeView *ectv, GdkDrawable *drawable, GtkExpanderStyle expander_style, GtkStateType state, GdkRectangle *rect)
+draw_expander (ECellTreeView *ectv,
+ GdkDrawable *drawable,
+ GtkExpanderStyle expander_style,
+ GtkStateType state,
+ GdkRectangle *rect)
{
GtkStyle *style;
GtkWidget *tree;
@@ -209,9 +213,16 @@ draw_expander (ECellTreeView *ectv, GdkDrawable *drawable, GtkExpanderStyle expa
* ECell::draw method
*/
static void
-ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
- gint model_col, gint view_col, gint row, ECellFlags flags,
- gint x1, gint y1, gint x2, gint y2)
+ect_draw (ECellView *ecell_view,
+ GdkDrawable *drawable,
+ gint model_col,
+ gint view_col,
+ gint row,
+ ECellFlags flags,
+ gint x1,
+ gint y1,
+ gint x2,
+ gint y2)
{
ECellTreeView *tree_view = (ECellTreeView *)ecell_view;
ETreeModel *tree_model = e_cell_tree_get_tree_model (ecell_view->e_table_model, row);
@@ -265,16 +276,16 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
gboolean expanded = e_tree_table_adapter_node_is_expanded (tree_table_adapter, node);
GdkRectangle r;
- r = rect;
- r.width -= node_image_width + 2;
- draw_expander (tree_view, drawable, expanded ? GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED, GTK_STATE_NORMAL, &r);
+ r = rect;
+ r.width -= node_image_width + 2;
+ draw_expander (tree_view, drawable, expanded ? GTK_EXPANDER_EXPANDED : GTK_EXPANDER_COLLAPSED, GTK_STATE_NORMAL, &r);
}
if (node_image) {
- gdk_cairo_set_source_pixbuf (cr, node_image,
- x1 + subcell_offset,
- y1 + (y2 - y1) / 2 - node_image_height / 2);
- cairo_paint (cr);
+ gdk_cairo_set_source_pixbuf (cr, node_image,
+ x1 + subcell_offset,
+ y1 + (y2 - y1) / 2 - node_image_height / 2);
+ cairo_paint (cr);
subcell_offset += node_image_width;
}
@@ -394,30 +405,30 @@ ect_event (ECellView *ecell_view, GdkEvent *event, gint model_col, gint view_col
if (event_in_expander (event, offset, 0)) {
if (e_tree_model_node_is_expandable (tree_model, node)) {
gboolean expanded = e_tree_table_adapter_node_is_expanded (etta, node);
- gint tmp_row = row;
- GdkRectangle area;
- animate_closure_t *closure = g_new0 (animate_closure_t, 1);
- gint hgt;
-
- e_table_item_get_cell_geometry (tree_view->cell_view.e_table_item_view,
- &tmp_row, &view_col, &area.x, &area.y, NULL, &area.height);
- area.width = offset - 2;
- hgt = e_cell_height (ecell_view, model_col, view_col, row);
-
- if (hgt != area.height) /* Composite cells */
- area.height += hgt;
-
- draw_expander (
- tree_view, window, expanded ?
- GTK_EXPANDER_SEMI_EXPANDED :
- GTK_EXPANDER_SEMI_COLLAPSED,
- GTK_STATE_NORMAL, &area);
- closure->ectv = tree_view;
- closure->etta = etta;
- closure->node = node;
- closure->expanded = expanded;
- closure->area = area;
- tree_view->animate_timeout = g_timeout_add (50, animate_expander, closure);
+ gint tmp_row = row;
+ GdkRectangle area;
+ animate_closure_t *closure = g_new0 (animate_closure_t, 1);
+ gint hgt;
+
+ e_table_item_get_cell_geometry (tree_view->cell_view.e_table_item_view,
+ &tmp_row, &view_col, &area.x, &area.y, NULL, &area.height);
+ area.width = offset - 2;
+ hgt = e_cell_height (ecell_view, model_col, view_col, row);
+
+ if (hgt != area.height) /* Composite cells */
+ area.height += hgt;
+
+ draw_expander (
+ tree_view, window, expanded ?
+ GTK_EXPANDER_SEMI_EXPANDED :
+ GTK_EXPANDER_SEMI_COLLAPSED,
+ GTK_STATE_NORMAL, &area);
+ closure->ectv = tree_view;
+ closure->etta = etta;
+ closure->node = node;
+ closure->expanded = expanded;
+ closure->area = area;
+ tree_view->animate_timeout = g_timeout_add (50, animate_expander, closure);
return TRUE;
}
}
@@ -531,8 +542,8 @@ ect_max_width (ECellView *ecell_view, gint model_col, gint view_col)
expanded = e_tree_table_adapter_node_is_expanded (tree_table_adapter, node);
/* This is unnecessary since this is already handled
- by the offset_of_node function. If that changes,
- this will have to change too. */
+ * by the offset_of_node function. If that changes,
+ * this will have to change too. */
if (expandable) {
GdkPixbuf *image;
diff --git a/widgets/table/e-cell-vbox.c b/widgets/table/e-cell-vbox.c
index f752e14834..b170604ade 100644
--- a/widgets/table/e-cell-vbox.c
+++ b/widgets/table/e-cell-vbox.c
@@ -131,9 +131,16 @@ ecv_unrealize (ECellView *ecv)
* ECell::draw method
*/
static void
-ecv_draw (ECellView *ecell_view, GdkDrawable *drawable,
- gint model_col, gint view_col, gint row, ECellFlags flags,
- gint x1, gint y1, gint x2, gint y2)
+ecv_draw (ECellView *ecell_view,
+ GdkDrawable *drawable,
+ gint model_col,
+ gint view_col,
+ gint row,
+ ECellFlags flags,
+ gint x1,
+ gint y1,
+ gint x2,
+ gint y2)
{
ECellVboxView *vbox_view = (ECellVboxView *)ecell_view;
@@ -143,12 +150,20 @@ ecv_draw (ECellView *ecell_view, GdkDrawable *drawable,
for (i = 0; i < vbox_view->subcell_view_count; i++) {
/* Now cause our subcells to draw their contents,
shifted by subcell_offset pixels */
- gint height = e_cell_height (vbox_view->subcell_views[i], vbox_view->model_cols[i], view_col, row);
- e_cell_draw (vbox_view->subcell_views[i], drawable,
- vbox_view->model_cols[i], view_col, row, flags,
- x1, y1 + subcell_offset, x2, y1 + subcell_offset + height);
-
- subcell_offset += e_cell_height (vbox_view->subcell_views[i], vbox_view->model_cols[i], view_col, row);
+ gint height;
+
+ height = e_cell_height (
+ vbox_view->subcell_views[i],
+ vbox_view->model_cols[i], view_col, row);
+ e_cell_draw (
+ vbox_view->subcell_views[i], drawable,
+ vbox_view->model_cols[i], view_col, row, flags,
+ x1, y1 + subcell_offset, x2,
+ y1 + subcell_offset + height);
+
+ subcell_offset += e_cell_height (
+ vbox_view->subcell_views[i],
+ vbox_view->model_cols[i], view_col, row);
}
}
diff --git a/widgets/table/e-table-header-utils.h b/widgets/table/e-table-header-utils.h
index 9117262d52..16cc867f8c 100644
--- a/widgets/table/e-table-header-utils.h
+++ b/widgets/table/e-table-header-utils.h
@@ -31,9 +31,9 @@
G_BEGIN_DECLS
gdouble e_table_header_compute_height (ETableCol *ecol,
- GtkWidget *widget);
-gdouble e_table_header_width_extras (GtkStyle *style);
-void e_table_header_draw_button (GdkDrawable *drawable,
+ GtkWidget *widget);
+gdouble e_table_header_width_extras (GtkStyle *style);
+void e_table_header_draw_button (GdkDrawable *drawable,
ETableCol *ecol,
GtkStyle *style,
GtkStateType state,