From dce5bdc3699faf592453492fe201606ed47e06b9 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 2 Nov 2010 11:49:38 -0400 Subject: Move calendar preferences to the calendar module. Continue replacing the use of calendar-config functions with GObject property bindings to EShellSettings properties. --- calendar/gui/e-day-view-time-item.c | 38 ++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'calendar/gui/e-day-view-time-item.c') diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c index e163e278ac..35a8e3ebda 100644 --- a/calendar/gui/e-day-view-time-item.c +++ b/calendar/gui/e-day-view-time-item.c @@ -87,7 +87,7 @@ static gint e_day_view_time_item_event (GnomeCanvasItem *item, GdkEvent *event); static void e_day_view_time_item_increment_time (gint *hour, gint *minute, - gint mins_per_row); + gint time_divisions); static void e_day_view_time_item_show_popup_menu (EDayViewTimeItem *time_item, GdkEvent *event); static void e_day_view_time_item_on_set_divisions (GtkWidget *item, @@ -285,10 +285,12 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, { EDayView *day_view; EDayViewTimeItem *time_item; + ECalendarView *cal_view; ECalModel *model; GtkStyle *style; const gchar *suffix; gchar buffer[64], *midnight_day = NULL, *midnight_month = NULL; + gint time_divisions; gint hour, display_hour, minute, row; gint row_y, start_y, large_hour_y_offset, small_font_y_offset; gint long_line_x1, long_line_x2, short_line_x1; @@ -309,7 +311,9 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, day_view = e_day_view_time_item_get_day_view (time_item); g_return_if_fail (day_view != NULL); - model = e_calendar_view_get_model (E_CALENDAR_VIEW (day_view)); + cal_view = E_CALENDAR_VIEW (day_view); + model = e_calendar_view_get_model (cal_view); + time_divisions = e_calendar_view_get_time_divisions (cal_view); style = gtk_widget_get_style (GTK_WIDGET (day_view)); small_font_desc = style->font_desc; @@ -327,7 +331,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, long_line_x1 = (use_zone ? 0 : E_DVTMI_TIME_GRID_X_PAD) - x + x_offset; long_line_x2 = time_item->priv->column_width - E_DVTMI_TIME_GRID_X_PAD - x - (use_zone ? E_DVTMI_TIME_GRID_X_PAD : 0) + x_offset; - if (day_view->mins_per_row == 60) { + if (time_divisions == 60) { /* The right edge of the complete time string in 60-min divisions, e.g. "14:00" or "2 pm". */ minute_x2 = long_line_x2 - E_DVTMI_60_MIN_X_PAD; @@ -437,7 +441,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, mb_color = day_view->colors[E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE]; time_now = icaltime_current_time_with_zone (e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); - marcus_bains_y = (time_now.hour * 60 + time_now.minute) * day_view->row_height / day_view->mins_per_row - y; + marcus_bains_y = (time_now.hour * 60 + time_now.minute) * day_view->row_height / time_divisions - y; cairo_set_line_width (cr, 1.5); cairo_move_to (cr, long_line_x1 - (use_zone ? E_DVTMI_TIME_GRID_X_PAD : 0), marcus_bains_y); cairo_line_to (cr, long_line_x2, marcus_bains_y); @@ -461,13 +465,13 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, for (row = 0, row_y = 0 - y; row < day_view->rows && row_y < height; row++, row_y += day_view->row_height) { - gboolean show_midnight_date = use_zone && hour == 0 && (minute == 0 || day_view->mins_per_row == 60) && midnight_day && midnight_month; + gboolean show_midnight_date = use_zone && hour == 0 && (minute == 0 || time_divisions == 60) && midnight_day && midnight_month; /* If the row is above the first row we want to draw just increment the time and skip to the next row. */ if (row_y < start_y) { e_day_view_time_item_increment_time (&hour, &minute, - day_view->mins_per_row); + time_divisions); continue; } @@ -477,7 +481,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, &display_hour, &suffix, &suffix_width); - if (day_view->mins_per_row == 60) { + if (time_divisions == 60) { /* 60 minute intervals - draw a long horizontal line between hours and display as one long string, e.g. "14:00" or "2 pm". */ @@ -568,7 +572,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, /* Normally we display the minute in each interval, but when using 30-minute intervals we don't display the '30'. */ - if (day_view->mins_per_row != 30 || minute != 30) { + if (time_divisions != 30 || minute != 30) { /* In 12-hour format we display 'am' or 'pm' instead of '00'. */ if (show_midnight_date) @@ -600,7 +604,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, } e_day_view_time_item_increment_time (&hour, &minute, - day_view->mins_per_row); + time_divisions); } pango_font_metrics_unref (large_font_metrics); @@ -631,14 +635,14 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item, } /* Increment the time by the 5/10/15/30/60 minute interval. - Note that mins_per_row is never > 60, so we never have to + Note that time_divisions is never > 60, so we never have to worry about adding more than 60 minutes. */ static void e_day_view_time_item_increment_time (gint *hour, gint *minute, - gint mins_per_row) + gint time_divisions) { - *minute += mins_per_row; + *minute += time_divisions; if (*minute >= 60) { *minute -= 60; /* Currently we never wrap around to the next day, but @@ -728,6 +732,7 @@ e_day_view_time_item_show_popup_menu (EDayViewTimeItem *time_item, { static gint divisions[] = { 60, 30, 15, 10, 5 }; EDayView *day_view; + ECalendarView *cal_view; GtkWidget *menu, *item, *submenu; gchar buffer[256]; GSList *group = NULL, *recent_zones, *s; @@ -737,7 +742,8 @@ e_day_view_time_item_show_popup_menu (EDayViewTimeItem *time_item, day_view = e_day_view_time_item_get_day_view (time_item); g_return_if_fail (day_view != NULL); - current_divisions = e_day_view_get_mins_per_row (day_view); + cal_view = E_CALENDAR_VIEW (day_view); + current_divisions = e_calendar_view_get_time_divisions (cal_view); menu = gtk_menu_new (); @@ -832,6 +838,7 @@ e_day_view_time_item_on_set_divisions (GtkWidget *item, EDayViewTimeItem *time_item) { EDayView *day_view; + ECalendarView *cal_view; gint divisions; day_view = e_day_view_time_item_get_day_view (time_item); @@ -841,8 +848,9 @@ e_day_view_time_item_on_set_divisions (GtkWidget *item, return; divisions = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "divisions")); - e_day_view_set_mins_per_row (day_view, divisions); - calendar_config_set_time_divisions (divisions); + + cal_view = E_CALENDAR_VIEW (day_view); + e_calendar_view_set_time_divisions (cal_view, divisions); } static void -- cgit v1.2.3 From d0f088d329977e9a5f8aa4d4cf1122596eb8704f Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 15 Jan 2011 10:21:08 -0500 Subject: Adapt EDayView + widgets to latest gtk+-3.0 API. --- calendar/gui/e-day-view-time-item.c | 27 +++++++-------------------- 1 file changed, 7 insertions(+), 20 deletions(-) (limited to 'calendar/gui/e-day-view-time-item.c') diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c index 35a8e3ebda..2340f25220 100644 --- a/calendar/gui/e-day-view-time-item.c +++ b/calendar/gui/e-day-view-time-item.c @@ -77,7 +77,7 @@ static void e_day_view_time_item_update (GnomeCanvasItem *item, const cairo_matrix_t *i2c, gint flags); static void e_day_view_time_item_draw (GnomeCanvasItem *item, - GdkDrawable *drawable, + cairo_t *cr, gint x, gint y, gint width, gint height); static GnomeCanvasItem *e_day_view_time_item_point (GnomeCanvasItem *item, @@ -275,7 +275,7 @@ e_day_view_time_item_update (GnomeCanvasItem *item, */ static void edvti_draw_zone (GnomeCanvasItem *canvas_item, - GdkDrawable *drawable, + cairo_t *cr, gint x, gint y, gint width, @@ -301,12 +301,9 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, PangoContext *context; PangoFontDescription *small_font_desc; PangoFontMetrics *large_font_metrics, *small_font_metrics; - cairo_t *cr; GdkColor fg, dark; GdkColor mb_color; - cr = gdk_cairo_create (drawable); - time_item = E_DAY_VIEW_TIME_ITEM (canvas_item); day_view = e_day_view_time_item_get_day_view (time_item); g_return_if_fail (day_view != NULL); @@ -431,12 +428,8 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, gdk_cairo_set_source_color (cr, &day_view->colors[E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE]); if (day_view->marcus_bains_time_bar_color && gdk_color_parse (day_view->marcus_bains_time_bar_color, &mb_color)) { - GdkColormap *colormap; - colormap = gtk_widget_get_colormap (GTK_WIDGET (day_view)); - if (gdk_colormap_alloc_color (colormap, &mb_color, TRUE, TRUE)) { - gdk_cairo_set_source_color (cr, &mb_color); - } + gdk_cairo_set_source_color (cr, &mb_color); } else mb_color = day_view->colors[E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE]; @@ -451,12 +444,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, mb_color = day_view->colors[E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE]; if (day_view->marcus_bains_time_bar_color && gdk_color_parse (day_view->marcus_bains_time_bar_color, &mb_color)) { - GdkColormap *colormap; - - colormap = gtk_widget_get_colormap (GTK_WIDGET (day_view)); - if (gdk_colormap_alloc_color (colormap, &mb_color, TRUE, TRUE)) { - gdk_cairo_set_source_color (cr, &mb_color); - } + gdk_cairo_set_source_color (cr, &mb_color); } } @@ -609,7 +597,6 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, pango_font_metrics_unref (large_font_metrics); pango_font_metrics_unref (small_font_metrics); - cairo_destroy (cr); g_free (midnight_day); g_free (midnight_month); @@ -617,7 +604,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, static void e_day_view_time_item_draw (GnomeCanvasItem *canvas_item, - GdkDrawable *drawable, + cairo_t *cr, gint x, gint y, gint width, @@ -628,10 +615,10 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item, time_item = E_DAY_VIEW_TIME_ITEM (canvas_item); g_return_if_fail (time_item != NULL); - edvti_draw_zone (canvas_item, drawable, x, y, width, height, 0, NULL); + edvti_draw_zone (canvas_item, cr, x, y, width, height, 0, NULL); if (time_item->priv->second_zone) - edvti_draw_zone (canvas_item, drawable, x, y, width, height, time_item->priv->column_width, time_item->priv->second_zone); + edvti_draw_zone (canvas_item, cr, x, y, width, height, time_item->priv->column_width, time_item->priv->second_zone); } /* Increment the time by the 5/10/15/30/60 minute interval. -- cgit v1.2.3 From 6af0c53b697c6981c1470c177b2c37e081635258 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 29 Jan 2011 10:50:53 -0500 Subject: Coding style and whitespace cleanup. --- calendar/gui/e-day-view-time-item.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'calendar/gui/e-day-view-time-item.c') diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c index 2340f25220..cfe808f806 100644 --- a/calendar/gui/e-day-view-time-item.c +++ b/calendar/gui/e-day-view-time-item.c @@ -274,14 +274,14 @@ e_day_view_time_item_update (GnomeCanvasItem *item, * DRAWING ROUTINES - functions to paint the canvas item. */ static void -edvti_draw_zone (GnomeCanvasItem *canvas_item, - cairo_t *cr, - gint x, - gint y, - gint width, - gint height, - gint x_offset, - icaltimezone *use_zone) +edvti_draw_zone (GnomeCanvasItem *canvas_item, + cairo_t *cr, + gint x, + gint y, + gint width, + gint height, + gint x_offset, + icaltimezone *use_zone) { EDayView *day_view; EDayViewTimeItem *time_item; @@ -604,11 +604,11 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, static void e_day_view_time_item_draw (GnomeCanvasItem *canvas_item, - cairo_t *cr, - gint x, - gint y, - gint width, - gint height) + cairo_t *cr, + gint x, + gint y, + gint width, + gint height) { EDayViewTimeItem *time_item; -- cgit v1.2.3 From c003c99a75587ba39a45d164272760c33f9666b5 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 25 Feb 2011 16:20:41 +0100 Subject: Bug #614480 - Avoid using G_TYPE_INSTANCE_GET_PRIVATE repeatedly --- calendar/gui/e-day-view-time-item.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'calendar/gui/e-day-view-time-item.c') diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c index cfe808f806..6cf379f6a9 100644 --- a/calendar/gui/e-day-view-time-item.c +++ b/calendar/gui/e-day-view-time-item.c @@ -54,10 +54,6 @@ #define E_DVTMI_LARGE_HOUR_Y_PAD 1 #define E_DVTMI_SMALL_FONT_Y_PAD 1 -#define E_DAY_VIEW_TIME_ITEM_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), E_TYPE_DAY_VIEW_TIME_ITEM, EDayViewTimeItemPrivate)) - struct _EDayViewTimeItemPrivate { /* The parent EDayView widget. */ EDayView *day_view; @@ -149,7 +145,7 @@ day_view_time_item_dispose (GObject *object) { EDayViewTimeItemPrivate *priv; - priv = E_DAY_VIEW_TIME_ITEM_GET_PRIVATE (object); + priv = E_DAY_VIEW_TIME_ITEM (object)->priv; if (priv->day_view != NULL) { g_object_unref (priv->day_view); @@ -212,7 +208,7 @@ day_view_time_item_init (EDayViewTimeItem *time_item) { gchar *last; - time_item->priv = E_DAY_VIEW_TIME_ITEM_GET_PRIVATE (time_item); + time_item->priv = G_TYPE_INSTANCE_GET_PRIVATE (time_item, E_TYPE_DAY_VIEW_TIME_ITEM, EDayViewTimeItemPrivate); time_item->priv->dragging_selection = FALSE; time_item->priv->second_zone = NULL; -- cgit v1.2.3 From 7aacf983b32ecac26bc9707697da622b3ef164a3 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 5 Mar 2011 12:33:49 -0500 Subject: Coding style and whitespace cleanup. --- calendar/gui/e-day-view-time-item.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'calendar/gui/e-day-view-time-item.c') diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c index 6cf379f6a9..30efc13e74 100644 --- a/calendar/gui/e-day-view-time-item.c +++ b/calendar/gui/e-day-view-time-item.c @@ -208,7 +208,8 @@ day_view_time_item_init (EDayViewTimeItem *time_item) { gchar *last; - time_item->priv = G_TYPE_INSTANCE_GET_PRIVATE (time_item, E_TYPE_DAY_VIEW_TIME_ITEM, EDayViewTimeItemPrivate); + time_item->priv = G_TYPE_INSTANCE_GET_PRIVATE ( + time_item, E_TYPE_DAY_VIEW_TIME_ITEM, EDayViewTimeItemPrivate); time_item->priv->dragging_selection = FALSE; time_item->priv->second_zone = NULL; -- cgit v1.2.3 From 5146ff4c535f443fe25290eb96631e91ad44c8ef Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 21 May 2011 10:02:58 -0400 Subject: Coding style and whitespace cleanup. --- calendar/gui/e-day-view-time-item.c | 172 ++++++++++++++++++++++++------------ 1 file changed, 116 insertions(+), 56 deletions(-) (limited to 'calendar/gui/e-day-view-time-item.c') diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c index 30efc13e74..7d87f6a02d 100644 --- a/calendar/gui/e-day-view-time-item.c +++ b/calendar/gui/e-day-view-time-item.c @@ -69,35 +69,50 @@ struct _EDayViewTimeItemPrivate { icaltimezone *second_zone; }; -static void e_day_view_time_item_update (GnomeCanvasItem *item, - const cairo_matrix_t *i2c, - gint flags); -static void e_day_view_time_item_draw (GnomeCanvasItem *item, - cairo_t *cr, - gint x, gint y, - gint width, gint height); -static GnomeCanvasItem *e_day_view_time_item_point (GnomeCanvasItem *item, - double x, double y, - gint cx, gint cy); -static gint e_day_view_time_item_event (GnomeCanvasItem *item, - GdkEvent *event); -static void e_day_view_time_item_increment_time (gint *hour, - gint *minute, - gint time_divisions); -static void e_day_view_time_item_show_popup_menu (EDayViewTimeItem *time_item, - GdkEvent *event); -static void e_day_view_time_item_on_set_divisions (GtkWidget *item, - EDayViewTimeItem *time_item); -static void e_day_view_time_item_on_button_press (EDayViewTimeItem *time_item, - GdkEvent *event); -static void e_day_view_time_item_on_button_release (EDayViewTimeItem *time_item, - GdkEvent *event); -static void e_day_view_time_item_on_motion_notify (EDayViewTimeItem *time_item, - GdkEvent *event); -static gint e_day_view_time_item_convert_position_to_row (EDayViewTimeItem *time_item, - gint y); - -static void edvti_second_zone_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data); +static void e_day_view_time_item_update (GnomeCanvasItem *item, + const cairo_matrix_t *i2c, + gint flags); +static void e_day_view_time_item_draw (GnomeCanvasItem *item, + cairo_t *cr, + gint x, + gint y, + gint width, + gint height); +static GnomeCanvasItem * + e_day_view_time_item_point (GnomeCanvasItem *item, + gdouble x, + gdouble y, + gint cx, + gint cy); +static gint e_day_view_time_item_event (GnomeCanvasItem *item, + GdkEvent *event); +static void e_day_view_time_item_increment_time + (gint *hour, + gint *minute, + gint time_divisions); +static void e_day_view_time_item_show_popup_menu + (EDayViewTimeItem *time_item, + GdkEvent *event); +static void e_day_view_time_item_on_set_divisions + (GtkWidget *item, + EDayViewTimeItem *time_item); +static void e_day_view_time_item_on_button_press + (EDayViewTimeItem *time_item, + GdkEvent *event); +static void e_day_view_time_item_on_button_release + (EDayViewTimeItem *time_item, + GdkEvent *event); +static void e_day_view_time_item_on_motion_notify + (EDayViewTimeItem *time_item, + GdkEvent *event); +static gint e_day_view_time_item_convert_position_to_row + (EDayViewTimeItem *time_item, + gint y); + +static void edvti_second_zone_changed_cb (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + gpointer user_data); enum { PROP_0, @@ -218,11 +233,14 @@ day_view_time_item_init (EDayViewTimeItem *time_item) if (last) { if (*last) - time_item->priv->second_zone = icaltimezone_get_builtin_timezone (last); + time_item->priv->second_zone = + icaltimezone_get_builtin_timezone (last); g_free (last); } - time_item->priv->second_zone_changed_id = calendar_config_add_notification_day_second_zone (edvti_second_zone_changed_cb, time_item); + time_item->priv->second_zone_changed_id = + calendar_config_add_notification_day_second_zone ( + edvti_second_zone_changed_cb, time_item); } GType @@ -323,7 +341,10 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, /* The start and end of the long horizontal line between hours. */ long_line_x1 = (use_zone ? 0 : E_DVTMI_TIME_GRID_X_PAD) - x + x_offset; - long_line_x2 = time_item->priv->column_width - E_DVTMI_TIME_GRID_X_PAD - x - (use_zone ? E_DVTMI_TIME_GRID_X_PAD : 0) + x_offset; + long_line_x2 = + time_item->priv->column_width - + E_DVTMI_TIME_GRID_X_PAD - x - + (use_zone ? E_DVTMI_TIME_GRID_X_PAD : 0) + x_offset; if (time_divisions == 60) { /* The right edge of the complete time string in 60-min @@ -358,13 +379,17 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, minute = day_view->first_minute_shown; if (use_zone) { - /* shift time with a difference between local time and the other timezone */ - icaltimezone *cal_zone = e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view)); + /* shift time with a difference between + * local time and the other timezone */ + icaltimezone *cal_zone; struct icaltimetype tt; gint diff; struct tm mn; - tt = icaltime_from_timet_with_zone (day_view->day_starts[0], 0, cal_zone); + cal_zone = e_calendar_view_get_timezone ( + E_CALENDAR_VIEW (day_view)); + tt = icaltime_from_timet_with_zone ( + day_view->day_starts[0], 0, cal_zone); /* diff is number of minutes */ diff = (icaltimezone_get_utc_offset (use_zone, &tt, NULL) - @@ -422,25 +447,38 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, gint marcus_bains_y; cairo_save (cr); - gdk_cairo_set_source_color (cr, &day_view->colors[E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE]); - - if (day_view->marcus_bains_time_bar_color && gdk_color_parse (day_view->marcus_bains_time_bar_color, &mb_color)) { + gdk_cairo_set_source_color ( + cr, &day_view->colors[E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE]); + if (day_view->marcus_bains_time_bar_color && + gdk_color_parse ( + day_view->marcus_bains_time_bar_color, + &mb_color)) { gdk_cairo_set_source_color (cr, &mb_color); } else mb_color = day_view->colors[E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE]; - time_now = icaltime_current_time_with_zone (e_calendar_view_get_timezone (E_CALENDAR_VIEW (day_view))); - marcus_bains_y = (time_now.hour * 60 + time_now.minute) * day_view->row_height / time_divisions - y; + time_now = icaltime_current_time_with_zone ( + e_calendar_view_get_timezone ( + E_CALENDAR_VIEW (day_view))); + marcus_bains_y = + (time_now.hour * 60 + time_now.minute) * + day_view->row_height / time_divisions - y; cairo_set_line_width (cr, 1.5); - cairo_move_to (cr, long_line_x1 - (use_zone ? E_DVTMI_TIME_GRID_X_PAD : 0), marcus_bains_y); + cairo_move_to ( + cr, long_line_x1 - + (use_zone ? E_DVTMI_TIME_GRID_X_PAD : 0), + marcus_bains_y); cairo_line_to (cr, long_line_x2, marcus_bains_y); cairo_stroke (cr); cairo_restore (cr); } else { mb_color = day_view->colors[E_DAY_VIEW_COLOR_MARCUS_BAINS_LINE]; - if (day_view->marcus_bains_time_bar_color && gdk_color_parse (day_view->marcus_bains_time_bar_color, &mb_color)) { + if (day_view->marcus_bains_time_bar_color && + gdk_color_parse ( + day_view->marcus_bains_time_bar_color, + &mb_color)) { gdk_cairo_set_source_color (cr, &mb_color); } } @@ -450,13 +488,18 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, for (row = 0, row_y = 0 - y; row < day_view->rows && row_y < height; row++, row_y += day_view->row_height) { - gboolean show_midnight_date = use_zone && hour == 0 && (minute == 0 || time_divisions == 60) && midnight_day && midnight_month; + gboolean show_midnight_date; + + show_midnight_date = + use_zone && hour == 0 && + (minute == 0 || time_divisions == 60) && + midnight_day && midnight_month; /* If the row is above the first row we want to draw just increment the time and skip to the next row. */ if (row_y < start_y) { - e_day_view_time_item_increment_time (&hour, &minute, - time_divisions); + e_day_view_time_item_increment_time ( + &hour, &minute, time_divisions); continue; } @@ -536,7 +579,9 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, pango_layout_set_text (layout, buffer, -1); pango_layout_set_font_description (layout, day_view->large_font_desc); pango_layout_get_pixel_size (layout, &hour_width, NULL); - cairo_translate (cr, large_hour_x2 - hour_width, row_y + large_hour_y_offset); + cairo_translate ( + cr, large_hour_x2 - hour_width, + row_y + large_hour_y_offset); pango_cairo_update_layout (cr, layout); pango_cairo_show_layout (cr, layout); cairo_restore (cr); @@ -579,7 +624,9 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, pango_layout_set_text (layout, buffer, -1); pango_layout_set_font_description (layout, day_view->small_font_desc); pango_layout_get_pixel_size (layout, &minute_width, NULL); - cairo_translate (cr, minute_x2 - minute_width, row_y + small_font_y_offset); + cairo_translate ( + cr, minute_x2 - minute_width, + row_y + small_font_y_offset); pango_cairo_update_layout (cr, layout); pango_cairo_show_layout (cr, layout); cairo_restore (cr); @@ -615,7 +662,10 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item, edvti_draw_zone (canvas_item, cr, x, y, width, height, 0, NULL); if (time_item->priv->second_zone) - edvti_draw_zone (canvas_item, cr, x, y, width, height, time_item->priv->column_width, time_item->priv->second_zone); + edvti_draw_zone ( + canvas_item, cr, x, y, width, height, + time_item->priv->column_width, + time_item->priv->second_zone); } /* Increment the time by the 5/10/15/30/60 minute interval. @@ -677,7 +727,10 @@ e_day_view_time_item_event (GnomeCanvasItem *item, } static void -edvti_second_zone_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *entry, gpointer user_data) +edvti_second_zone_changed_cb (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + gpointer user_data) { EDayViewTimeItem *time_item = user_data; EDayView *day_view; @@ -687,32 +740,38 @@ edvti_second_zone_changed_cb (GConfClient *client, guint cnxn_id, GConfEntry *en g_return_if_fail (E_IS_DAY_VIEW_TIME_ITEM (time_item)); location = calendar_config_get_day_second_zone (); - time_item->priv->second_zone = location ? icaltimezone_get_builtin_timezone (location) : NULL; + time_item->priv->second_zone = + location ? icaltimezone_get_builtin_timezone (location) : NULL; g_free (location); day_view = e_day_view_time_item_get_day_view (time_item); - gtk_widget_set_size_request (day_view->time_canvas, e_day_view_time_item_get_column_width (time_item), -1); + gtk_widget_set_size_request ( + day_view->time_canvas, + e_day_view_time_item_get_column_width (time_item), -1); gtk_widget_queue_draw (day_view->time_canvas); } static void -edvti_on_select_zone (GtkWidget *item, EDayViewTimeItem *time_item) +edvti_on_select_zone (GtkWidget *item, + EDayViewTimeItem *time_item) { calendar_config_select_day_second_zone (); } static void -edvti_on_set_zone (GtkWidget *item, EDayViewTimeItem *time_item) +edvti_on_set_zone (GtkWidget *item, + EDayViewTimeItem *time_item) { if (!gtk_check_menu_item_get_active (GTK_CHECK_MENU_ITEM (item))) return; - calendar_config_set_day_second_zone (g_object_get_data (G_OBJECT (item), "timezone")); + calendar_config_set_day_second_zone ( + g_object_get_data (G_OBJECT (item), "timezone")); } static void e_day_view_time_item_show_popup_menu (EDayViewTimeItem *time_item, - GdkEvent *event) + GdkEvent *event) { static gint divisions[] = { 60, 30, 15, 10, 5 }; EDayView *day_view; @@ -793,7 +852,8 @@ e_day_view_time_item_show_popup_menu (EDayViewTimeItem *time_item, if (!zone) continue; - item = gtk_radio_menu_item_new_with_label (group, icaltimezone_get_display_name (zone)); + item = gtk_radio_menu_item_new_with_label ( + group, icaltimezone_get_display_name (zone)); group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (item)); /* both comes from builtin, thus no problem to compare pointers */ if (zone == time_item->priv->second_zone) -- cgit v1.2.3 From e7954c3f251aabbf95d099159709c8c66dfedc44 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 4 Jun 2011 15:53:10 -0500 Subject: Coding style and whitespace cleanups. --- calendar/gui/e-day-view-time-item.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'calendar/gui/e-day-view-time-item.c') diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c index 7d87f6a02d..e65dc4d617 100644 --- a/calendar/gui/e-day-view-time-item.c +++ b/calendar/gui/e-day-view-time-item.c @@ -542,7 +542,9 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, layout = pango_cairo_create_layout (cr); pango_layout_set_text (layout, buffer, -1); pango_layout_get_pixel_size (layout, &minute_width, NULL); - cairo_translate (cr, minute_x2 - minute_width, row_y + small_font_y_offset); + cairo_translate ( + cr, minute_x2 - minute_width, + row_y + small_font_y_offset); pango_cairo_update_layout (cr, layout); pango_cairo_show_layout (cr, layout); cairo_restore (cr); @@ -859,8 +861,12 @@ e_day_view_time_item_show_popup_menu (EDayViewTimeItem *time_item, if (zone == time_item->priv->second_zone) gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); gtk_menu_shell_append (GTK_MENU_SHELL (submenu), item); - g_object_set_data_full (G_OBJECT (item), "timezone", g_strdup (s->data), g_free); - g_signal_connect (item, "toggled", G_CALLBACK (edvti_on_set_zone), time_item); + g_object_set_data_full ( + G_OBJECT (item), "timezone", + g_strdup (s->data), g_free); + g_signal_connect ( + item, "toggled", + G_CALLBACK (edvti_on_set_zone), time_item); } calendar_config_free_day_second_zones (recent_zones); -- cgit v1.2.3 From 777c1cbd40eb63365f2c28e38f6a93beb2d1c9d1 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 16 Aug 2011 11:25:56 -0400 Subject: Coding style and whitespace cleanup. --- calendar/gui/e-day-view-time-item.c | 97 +++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 47 deletions(-) (limited to 'calendar/gui/e-day-view-time-item.c') diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c index e65dc4d617..928a91bbfb 100644 --- a/calendar/gui/e-day-view-time-item.c +++ b/calendar/gui/e-day-view-time-item.c @@ -35,17 +35,17 @@ #include /* The spacing between items in the time column. GRID_X_PAD is the space down - either side of the column, i.e. outside the main horizontal grid lines. - HOUR_L_PAD & HOUR_R_PAD are the spaces on the left & right side of the - big hour number (this is inside the horizontal grid lines). - MIN_X_PAD is the spacing either side of the minute number. The smaller - horizontal grid lines match with this. - 60_MIN_X_PAD is the space either side of the HH:MM display used when - we are displaying 60 mins per row (inside the main grid lines). - LARGE_HOUR_Y_PAD is the offset of the large hour string from the top of the - row. - SMALL_FONT_Y_PAD is the offset of the small time/minute string from the top - of the row. */ + * either side of the column, i.e. outside the main horizontal grid lines. + * HOUR_L_PAD & HOUR_R_PAD are the spaces on the left & right side of the + * big hour number (this is inside the horizontal grid lines). + * MIN_X_PAD is the spacing either side of the minute number. The smaller + * horizontal grid lines match with this. + * 60_MIN_X_PAD is the space either side of the HH:MM display used when + * we are displaying 60 mins per row (inside the main grid lines). + * LARGE_HOUR_Y_PAD is the offset of the large hour string from the top of the + * row. + * SMALL_FONT_Y_PAD is the offset of the small time/minute string from the top + * of the row. */ #define E_DVTMI_TIME_GRID_X_PAD 4 #define E_DVTMI_HOUR_L_PAD 4 #define E_DVTMI_HOUR_R_PAD 2 @@ -272,8 +272,8 @@ e_day_view_time_item_get_type (void) static void e_day_view_time_item_update (GnomeCanvasItem *item, - const cairo_matrix_t *i2c, - gint flags) + const cairo_matrix_t *i2c, + gint flags) { if (GNOME_CANVAS_ITEM_CLASS (parent_class)->update) (* GNOME_CANVAS_ITEM_CLASS (parent_class)->update) (item, i2c, flags); @@ -348,11 +348,11 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, if (time_divisions == 60) { /* The right edge of the complete time string in 60-min - divisions, e.g. "14:00" or "2 pm". */ + * divisions, e.g. "14:00" or "2 pm". */ minute_x2 = long_line_x2 - E_DVTMI_60_MIN_X_PAD; /* These aren't used for 60-minute divisions, but we initialize - them to keep gcc happy. */ + * them to keep gcc happy. */ short_line_x1 = 0; large_hour_x2 = 0; } else { @@ -363,7 +363,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, day_view->max_minute_width); /* The start of the short horizontal line between the periods - within each hour. */ + * within each hour. */ short_line_x1 = long_line_x2 - E_DVTMI_MIN_X_PAD * 2 - max_minute_or_suffix_width; @@ -434,8 +434,8 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, small_font_y_offset = E_DVTMI_SMALL_FONT_Y_PAD; /* Calculate the minimum y position of the first row we need to draw. - This is normally one row height above the 0 position, but if we - are using the large font we may have to go back a bit further. */ + * This is normally one row height above the 0 position, but if we + * are using the large font we may have to go back a bit further. */ start_y = 0 - MAX (day_view->row_height, (pango_font_metrics_get_ascent (large_font_metrics) + pango_font_metrics_get_descent (large_font_metrics)) / PANGO_SCALE + @@ -484,7 +484,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, } /* Step through each row, drawing the times and the horizontal lines - between them. */ + * between them. */ for (row = 0, row_y = 0 - y; row < day_view->rows && row_y < height; row++, row_y += day_view->row_height) { @@ -496,7 +496,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, midnight_day && midnight_month; /* If the row is above the first row we want to draw just - increment the time and skip to the next row. */ + * increment the time and skip to the next row. */ if (row_y < start_y) { e_day_view_time_item_increment_time ( &hour, &minute, time_divisions); @@ -504,15 +504,15 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, } /* Calculate the actual hour number to display. For 12-hour - format we convert 0-23 to 12-11am/12-11pm. */ + * format we convert 0-23 to 12-11am / 12 - 11pm. */ e_day_view_convert_time_to_display (day_view, hour, &display_hour, &suffix, &suffix_width); if (time_divisions == 60) { /* 60 minute intervals - draw a long horizontal line - between hours and display as one long string, - e.g. "14:00" or "2 pm". */ + * between hours and display as one long string, + * e.g. "14:00" or "2 pm". */ cairo_save (cr); gdk_cairo_set_source_color (cr, &dark); cairo_save (cr); @@ -555,8 +555,8 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, if (minute == 0) { /* On the hour - draw a long horizontal line - before the hour and display the hour in the - large font. */ + * before the hour and display the hour in the + * large font. */ cairo_save (cr); gdk_cairo_set_source_color (cr, &dark); @@ -591,7 +591,7 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, g_object_unref (layout); } else { /* Within the hour - draw a short line before - the time. */ + * the time. */ cairo_save (cr); gdk_cairo_set_source_color (cr, &dark); cairo_set_line_width (cr, 0.7); @@ -602,11 +602,11 @@ edvti_draw_zone (GnomeCanvasItem *canvas_item, } /* Normally we display the minute in each - interval, but when using 30-minute intervals - we don't display the '30'. */ + * interval, but when using 30-minute intervals + * we don't display the '30'. */ if (time_divisions != 30 || minute != 30) { /* In 12-hour format we display 'am' or 'pm' - instead of '00'. */ + * instead of '00'. */ if (show_midnight_date) strcpy (buffer, midnight_month); else if (minute == 0 @@ -671,32 +671,35 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item, } /* Increment the time by the 5/10/15/30/60 minute interval. - Note that time_divisions is never > 60, so we never have to - worry about adding more than 60 minutes. */ + * Note that time_divisions is never > 60, so we never have to + * worry about adding more than 60 minutes. */ static void -e_day_view_time_item_increment_time (gint *hour, - gint *minute, - gint time_divisions) +e_day_view_time_item_increment_time (gint *hour, + gint *minute, + gint time_divisions) { *minute += time_divisions; if (*minute >= 60) { *minute -= 60; /* Currently we never wrap around to the next day, but - we may do if we display extra timezones. */ + * we may do if we display extra timezones. */ *hour = (*hour + 1) % 24; } } static GnomeCanvasItem * -e_day_view_time_item_point (GnomeCanvasItem *item, double x, double y, - gint cx, gint cy) +e_day_view_time_item_point (GnomeCanvasItem *item, + gdouble x, + gdouble y, + gint cx, + gint cy) { return item; } static gint e_day_view_time_item_event (GnomeCanvasItem *item, - GdkEvent *event) + GdkEvent *event) { EDayViewTimeItem *time_item; @@ -885,7 +888,7 @@ e_day_view_time_item_show_popup_menu (EDayViewTimeItem *time_item, static void e_day_view_time_item_on_set_divisions (GtkWidget *item, - EDayViewTimeItem *time_item) + EDayViewTimeItem *time_item) { EDayView *day_view; ECalendarView *cal_view; @@ -905,7 +908,7 @@ e_day_view_time_item_on_set_divisions (GtkWidget *item, static void e_day_view_time_item_on_button_press (EDayViewTimeItem *time_item, - GdkEvent *event) + GdkEvent *event) { GdkWindow *window; EDayView *day_view; @@ -939,7 +942,7 @@ e_day_view_time_item_on_button_press (EDayViewTimeItem *time_item, static void e_day_view_time_item_on_button_release (EDayViewTimeItem *time_item, - GdkEvent *event) + GdkEvent *event) { EDayView *day_view; @@ -957,7 +960,7 @@ e_day_view_time_item_on_button_release (EDayViewTimeItem *time_item, static void e_day_view_time_item_on_motion_notify (EDayViewTimeItem *time_item, - GdkEvent *event) + GdkEvent *event) { EDayView *day_view; GnomeCanvas *canvas; @@ -986,7 +989,7 @@ e_day_view_time_item_on_motion_notify (EDayViewTimeItem *time_item, /* Returns the row corresponding to the y position, or -1. */ static gint e_day_view_time_item_convert_position_to_row (EDayViewTimeItem *time_item, - gint y) + gint y) { EDayView *day_view; gint row; @@ -1028,8 +1031,8 @@ e_day_view_time_item_set_day_view (EDayViewTimeItem *time_item, } /* Returns the minimum width needed for the column, by adding up all the - maximum widths of the strings. The string widths are all calculated in - the style_set handlers of EDayView and EDayViewTimeCanvas. */ + * maximum widths of the strings. The string widths are all calculated in + * the style_set handlers of EDayView and EDayViewTimeCanvas. */ gint e_day_view_time_item_get_column_width (EDayViewTimeItem *time_item) { @@ -1066,8 +1069,8 @@ e_day_view_time_item_get_column_width (EDayViewTimeItem *time_item) } /* Calculate the width of each time column, using the maximum of the - default format with large hour numbers, and the 60-min divisions - format which uses small text. */ + * default format with large hour numbers, and the 60-min divisions + * format which uses small text. */ max_suffix_width = MAX (day_view->am_string_width, day_view->pm_string_width); -- cgit v1.2.3 From 90ffcfd8ce2aeb5159d5c6f8a44601b89ea0ba05 Mon Sep 17 00:00:00 2001 From: Rodrigo Moya Date: Mon, 10 Oct 2011 17:40:06 +0200 Subject: Last bits of calendar-config migrated to GSettings --- calendar/gui/e-day-view-time-item.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'calendar/gui/e-day-view-time-item.c') diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c index 928a91bbfb..c901b82013 100644 --- a/calendar/gui/e-day-view-time-item.c +++ b/calendar/gui/e-day-view-time-item.c @@ -65,7 +65,6 @@ struct _EDayViewTimeItemPrivate { gboolean dragging_selection; /* The second timezone if shown, or else NULL. */ - guint second_zone_changed_id; icaltimezone *second_zone; }; @@ -109,9 +108,8 @@ static gint e_day_view_time_item_convert_position_to_row (EDayViewTimeItem *time_item, gint y); -static void edvti_second_zone_changed_cb (GConfClient *client, - guint cnxn_id, - GConfEntry *entry, +static void edvti_second_zone_changed_cb (GSettings *settings, + const gchar *key, gpointer user_data); enum { @@ -178,9 +176,7 @@ day_view_time_item_finalize (GObject *object) time_item = E_DAY_VIEW_TIME_ITEM (object); - if (time_item->priv->second_zone_changed_id) - calendar_config_remove_notification (time_item->priv->second_zone_changed_id); - time_item->priv->second_zone_changed_id = 0; + calendar_config_remove_notification ((CalendarConfigChangedFunc) edvti_second_zone_changed_cb, time_item); /* Chain up to parent's dispose() method. */ G_OBJECT_CLASS (parent_class)->finalize (object); @@ -238,9 +234,9 @@ day_view_time_item_init (EDayViewTimeItem *time_item) g_free (last); } - time_item->priv->second_zone_changed_id = - calendar_config_add_notification_day_second_zone ( - edvti_second_zone_changed_cb, time_item); + calendar_config_add_notification_day_second_zone ( + (CalendarConfigChangedFunc) edvti_second_zone_changed_cb, + time_item); } GType @@ -732,9 +728,8 @@ e_day_view_time_item_event (GnomeCanvasItem *item, } static void -edvti_second_zone_changed_cb (GConfClient *client, - guint cnxn_id, - GConfEntry *entry, +edvti_second_zone_changed_cb (GSettings *settings, + const gchar *key, gpointer user_data) { EDayViewTimeItem *time_item = user_data; -- cgit v1.2.3 From e64d6fe05c30c2cc1d7625a202afba3ba2da07cd Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 22 Nov 2011 18:22:14 -0500 Subject: Miscellaneous cleanups. --- calendar/gui/e-day-view-time-item.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'calendar/gui/e-day-view-time-item.c') diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c index c901b82013..9b61f11649 100644 --- a/calendar/gui/e-day-view-time-item.c +++ b/calendar/gui/e-day-view-time-item.c @@ -729,7 +729,7 @@ e_day_view_time_item_event (GnomeCanvasItem *item, static void edvti_second_zone_changed_cb (GSettings *settings, - const gchar *key, + const gchar *key, gpointer user_data) { EDayViewTimeItem *time_item = user_data; -- cgit v1.2.3