aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog64
-rw-r--r--calendar/gui/dialogs/alarm-page.c4
-rw-r--r--calendar/gui/dialogs/comp-editor.c15
-rw-r--r--calendar/gui/dialogs/delete-comp.c2
-rw-r--r--calendar/gui/dialogs/event-editor.c1
-rw-r--r--calendar/gui/dialogs/meeting-page.c7
-rw-r--r--calendar/gui/dialogs/recurrence-page.c4
-rw-r--r--calendar/gui/e-day-view-time-item.c71
-rw-r--r--calendar/gui/e-day-view-top-item.c18
-rw-r--r--calendar/gui/e-day-view.c31
-rw-r--r--calendar/gui/e-day-view.h2
-rw-r--r--calendar/gui/e-week-view-event-item.c74
-rw-r--r--calendar/gui/e-week-view-main-item.c25
-rw-r--r--calendar/gui/e-week-view-titles-item.c12
-rw-r--r--calendar/gui/e-week-view.c99
-rw-r--r--calendar/gui/e-week-view.h2
-rw-r--r--calendar/gui/itip-utils.c2
17 files changed, 308 insertions, 125 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 3667c6a1c5..ea31eb26c6 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,67 @@
+2003-01-25 Hans Petter Jansson <hpj@ximian.com>
+
+ Mainly making all views use PangoLayouts for text. When drawing a
+ PangoLayout, the draw offset is the top left corner of the layout,
+ not the text's baseline. Keep this in mind when viewing the
+ changes. I'll be brief about the exact changes, since they speak
+ better for themselves.
+
+ * gui/e-day-view-time-item.c (e_day_view_time_item_get_column_width):
+ Use Pango.
+ (e_day_view_time_item_draw): Use Pango.
+
+ * gui/e-day-view-top-item.c (e_day_view_top_item_draw): Use Pango.
+ (e_day_view_top_item_draw_long_event): Add some FIXME text so we can
+ see when this is being used. Is it in use at all?
+
+ * gui/e-day-view.c: No longer specify an explicit X font string for
+ the large font. Use the main font, and change the point size.
+ (e_day_view_init): Use Pango.
+ (e_day_view_style_set): Use Pango. Comment out the gdk_font setting
+ for the drag text items for now.
+
+ * gui/e-day-view.h: Use Pango.
+
+ * gui/e-week-view-event-item.c (e_week_view_draw_time): Use Pango.
+
+ * gui/e-week-view-main-item.c (e_week_view_main_item_draw_day):
+ Use Pango.
+
+ * gui/e-week-view-titles-item.c (e_week_view_titles_item_draw):
+ Use Pango.
+
+ * gui/e-week-view.c: No longer specify an explicit X font string for
+ the small font. Use the main font, and change the point size.
+ (e_week_view_init): Use Pango.
+ (e_week_view_destroy): Use Pango.
+ (get_string_width): Implemented for convenience.
+ (get_digit_width): Implemented for convenience.
+ (e_week_view_style_set): Use Pango.
+ (e_week_view_recalc_cell_sizes): Use Pango.
+ (e_week_view_get_time_string_width): Use Pango.
+
+ * gui/e-week-view.h: Use Pango.
+
+ Following are some random UTF-8 fixes and a crash fix.
+
+ * gui/itip-utils.c (comp_description): Use g_locale_to_utf8 ().
+
+ * gui/dialogs/comp-editor.c (make_title_from_comp): Return a
+ UTF-8 string.
+
+ * gui/dialogs/alarm-page.c (alarm_page_set_summary): Pass UTF-8
+ directly to GTK.
+
+ * gui/dialogs/delete-comp.c (delete_component_dialog): Ditto.
+
+ * gui/dialogs/meeting-page.c (meeting_page_fill_widgets): Ditto.
+ (meeting_page_construct): Ditto.
+
+ * gui/dialogs/recurrence-page.c (recurrence_page_set_summary): Ditto.
+
+ * gui/dialogs/event-editor.c (event_editor_finalize): Fix crash caused
+ by gtk_object_destroy()-ing a non-GtkObject.
+
2003-01-24 Hans Petter Jansson <hpj@ximian.com>
* gui/e-day-view.c (e_day_view_on_editing_stopped): Don't insist
diff --git a/calendar/gui/dialogs/alarm-page.c b/calendar/gui/dialogs/alarm-page.c
index 8f303fce6f..1447f8aca8 100644
--- a/calendar/gui/dialogs/alarm-page.c
+++ b/calendar/gui/dialogs/alarm-page.c
@@ -620,9 +620,7 @@ alarm_page_set_summary (CompEditorPage *page, const char *summary)
apage = ALARM_PAGE (page);
priv = apage->priv;
- s = e_utf8_to_gtk_string (priv->summary, summary);
- gtk_label_set_text (GTK_LABEL (priv->summary), s);
- g_free (s);
+ gtk_label_set_text (GTK_LABEL (priv->summary), summary);
}
/* set_dates handler for the alarm page */
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index 4b2e4fa882..61ce7e072e 100644
--- a/calendar/gui/dialogs/comp-editor.c
+++ b/calendar/gui/dialogs/comp-editor.c
@@ -768,7 +768,7 @@ comp_editor_get_cal_client (CompEditor *editor)
static char *
make_title_from_comp (CalComponent *comp)
{
- char *title;
+ char *title, *title_utf8;
const char *type_string;
CalComponentVType type;
CalComponentText text;
@@ -794,14 +794,15 @@ make_title_from_comp (CalComponent *comp)
cal_component_get_summary (comp, &text);
if (text.value) {
- char *summary;
- summary = e_utf8_to_locale_string (text.value);
- title = g_strdup_printf (type_string, summary);
- g_free (summary);
- } else
+ title = g_strdup_printf (type_string, text.value);
+ } else {
title = g_strdup_printf (type_string, _("No summary"));
+ }
+
+ title_utf8 = g_locale_to_utf8 (title, -1, NULL, NULL, NULL);
+ g_free (title);
- return title;
+ return title_utf8;
}
static const char *
diff --git a/calendar/gui/dialogs/delete-comp.c b/calendar/gui/dialogs/delete-comp.c
index 9b2621043a..995eed72d3 100644
--- a/calendar/gui/dialogs/delete-comp.c
+++ b/calendar/gui/dialogs/delete-comp.c
@@ -86,7 +86,7 @@ delete_component_dialog (CalComponent *comp,
if (!consider_as_untitled) {
cal_component_get_summary (comp, &summary);
- tmp = e_utf8_to_gtk_string (widget, summary.value);
+ tmp = g_strdup (summary.value);
} else
tmp = NULL;
diff --git a/calendar/gui/dialogs/event-editor.c b/calendar/gui/dialogs/event-editor.c
index 758d3c03b4..57c6eac920 100644
--- a/calendar/gui/dialogs/event-editor.c
+++ b/calendar/gui/dialogs/event-editor.c
@@ -375,7 +375,6 @@ event_editor_finalize (GObject *object)
g_object_unref((priv->meet_page));
g_object_unref((priv->sched_page));
- gtk_object_destroy (GTK_OBJECT (priv->model));
g_object_unref((priv->model));
if (G_OBJECT_CLASS (parent_class)->finalize)
diff --git a/calendar/gui/dialogs/meeting-page.c b/calendar/gui/dialogs/meeting-page.c
index 3917ef18bd..6089af5707 100644
--- a/calendar/gui/dialogs/meeting-page.c
+++ b/calendar/gui/dialogs/meeting-page.c
@@ -344,9 +344,7 @@ meeting_page_fill_widgets (CompEditorPage *page, CalComponent *comp)
string = g_strdup_printf ("%s <%s>", organizer.cn, strip);
else
string = g_strdup (strip);
- s = e_utf8_to_gtk_string (priv->existing_organizer, string);
- gtk_label_set_text (GTK_LABEL (priv->existing_organizer), s);
- g_free (s);
+ gtk_label_set_text (GTK_LABEL (priv->existing_organizer), string);
g_free (string);
priv->existing = TRUE;
@@ -744,8 +742,7 @@ meeting_page_construct (MeetingPage *mpage, EMeetingModel *emm,
ItipAddress *a = l->data;
char *s;
- s = e_utf8_to_gtk_string (GTK_COMBO (priv->organizer)->entry, a->full);
- priv->address_strings = g_list_append (priv->address_strings, s);
+ priv->address_strings = g_list_append (priv->address_strings, g_strdup (a->full));
/* Note that the address specified by the backend gets
* precedence over the default mail address.
diff --git a/calendar/gui/dialogs/recurrence-page.c b/calendar/gui/dialogs/recurrence-page.c
index f0defe7122..79c0224509 100644
--- a/calendar/gui/dialogs/recurrence-page.c
+++ b/calendar/gui/dialogs/recurrence-page.c
@@ -1930,9 +1930,7 @@ recurrence_page_set_summary (CompEditorPage *page, const char *summary)
rpage = RECURRENCE_PAGE (page);
priv = rpage->priv;
- s = e_utf8_to_gtk_string (priv->summary, summary);
- gtk_label_set_text (GTK_LABEL (priv->summary), s);
- g_free (s);
+ gtk_label_set_text (GTK_LABEL (priv->summary), summary);
}
/* set_dates handler for the recurrence page */
diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c
index 276c6062e4..b6e902e318 100644
--- a/calendar/gui/e-day-view-time-item.c
+++ b/calendar/gui/e-day-view-time-item.c
@@ -180,10 +180,12 @@ e_day_view_time_item_get_column_width (EDayViewTimeItem *dvtmitem)
{
EDayView *day_view;
GtkStyle *style;
- GdkFont *small_font, *large_font;
+ GdkFont *small_font;
+ PangoFontMetrics *large_font_metrics;
gint digit, large_digit_width, max_large_digit_width = 0;
gint max_suffix_width, max_minute_or_suffix_width;
gint column_width_default, column_width_60_min_rows;
+ PangoContext *context;
day_view = dvtmitem->day_view;
g_return_val_if_fail (day_view != NULL, 0);
@@ -192,11 +194,24 @@ e_day_view_time_item_get_column_width (EDayViewTimeItem *dvtmitem)
g_return_val_if_fail (style != NULL, 0);
small_font = gtk_style_get_font (style);
g_return_val_if_fail (small_font != NULL, 0);
- large_font = day_view->large_font;
- g_return_val_if_fail (large_font != NULL, 0);
+ context = gtk_widget_get_pango_context (GTK_WIDGET (day_view));
+
+ /* Find the maximum width a digit can have. FIXME: We could use pango's
+ * approximation function, but I worry it won't be precise enough. Also
+ * it needs a language tag that I don't know where to get. */
for (digit = '0'; digit <= '9'; digit++) {
- large_digit_width = gdk_char_width (large_font, digit);
+ PangoLayout *layout;
+ gchar digit_str [2];
+
+ digit_str [0] = digit;
+ digit_str [1] = '\0';
+
+ layout = gtk_widget_create_pango_layout (GTK_WIDGET (day_view), digit_str);
+ pango_layout_set_font_description (layout, day_view->large_font_desc);
+ pango_layout_get_pixel_size (layout, &large_digit_width, NULL);
+ g_object_unref (layout);
+
max_large_digit_width = MAX (max_large_digit_width,
large_digit_width);
}
@@ -245,7 +260,7 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item,
EDayView *day_view;
EDayViewTimeItem *dvtmitem;
GtkStyle *style;
- GdkFont *small_font, *large_font;
+ GdkFont *small_font;
GdkGC *fg_gc, *dark_gc;
gchar buffer[64], *suffix;
gint hour, display_hour, minute, row;
@@ -254,6 +269,10 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item,
gint large_hour_x2, minute_x2;
gint hour_width, minute_width, suffix_width;
gint max_suffix_width, max_minute_or_suffix_width;
+ PangoLayout *layout;
+ PangoContext *context;
+ PangoFontDescription *small_font_desc;
+ PangoFontMetrics *large_font_metrics;
dvtmitem = E_DAY_VIEW_TIME_ITEM (canvas_item);
day_view = dvtmitem->day_view;
@@ -261,7 +280,11 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item,
style = gtk_widget_get_style (GTK_WIDGET (day_view));
small_font = gtk_style_get_font (style);
- large_font = day_view->large_font;
+ small_font_desc = style->font_desc;
+
+ context = gtk_widget_get_pango_context (GTK_WIDGET (day_view));
+ large_font_metrics = pango_context_get_metrics (context, day_view->large_font_desc, NULL);
+
fg_gc = style->fg_gc[GTK_STATE_NORMAL];
dark_gc = style->dark_gc[GTK_STATE_NORMAL];
@@ -302,16 +325,18 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item,
minute = day_view->first_minute_shown;
/* The offset of the large hour string from the top of the row. */
- large_hour_y_offset = large_font->ascent + E_DVTMI_LARGE_HOUR_Y_PAD;
+ large_hour_y_offset = E_DVTMI_LARGE_HOUR_Y_PAD;
/* The offset of the small time/minute string from top of row. */
- small_font_y_offset = small_font->ascent + E_DVTMI_SMALL_FONT_Y_PAD;
+ 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. */
start_y = 0 - MAX (day_view->row_height,
- large_hour_y_offset + large_font->descent);
+ (pango_font_metrics_get_ascent (large_font_metrics) +
+ pango_font_metrics_get_descent (large_font_metrics)) / PANGO_SCALE +
+ E_DVTMI_LARGE_HOUR_Y_PAD);
/* Step through each row, drawing the times and the horizontal lines
between them. */
@@ -349,10 +374,13 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item,
display_hour, suffix);
}
minute_width = gdk_string_width (small_font, buffer);
- gdk_draw_string (drawable, small_font, fg_gc,
+
+ layout = gtk_widget_create_pango_layout (GTK_WIDGET (day_view), buffer);
+ gdk_draw_layout (drawable, fg_gc,
minute_x2 - minute_width,
row_y + small_font_y_offset,
- buffer);
+ layout);
+ g_object_unref (layout);
} else {
/* 5/10/15/30 minute intervals. */
@@ -366,12 +394,15 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item,
g_snprintf (buffer, sizeof (buffer), "%i",
display_hour);
- hour_width = gdk_string_width (large_font,
- buffer);
- gdk_draw_string (drawable, large_font, fg_gc,
+
+ layout = gtk_widget_create_pango_layout (GTK_WIDGET (day_view), buffer);
+ pango_layout_set_font_description (layout, day_view->large_font_desc);
+ pango_layout_get_pixel_size (layout, &hour_width, NULL);
+ gdk_draw_layout (drawable, fg_gc,
large_hour_x2 - hour_width,
row_y + large_hour_y_offset,
- buffer);
+ layout);
+ g_object_unref (layout);
} else {
/* Within the hour - draw a short line before
the time. */
@@ -393,12 +424,14 @@ e_day_view_time_item_draw (GnomeCanvasItem *canvas_item,
g_snprintf (buffer, sizeof (buffer),
"%02i", minute);
}
- minute_width = gdk_string_width (small_font,
- buffer);
- gdk_draw_string (drawable, small_font, fg_gc,
+
+ layout = gtk_widget_create_pango_layout (GTK_WIDGET (day_view), buffer);
+ pango_layout_get_pixel_size (layout, &minute_width, NULL);
+ gdk_draw_layout (drawable, fg_gc,
minute_x2 - minute_width,
row_y + small_font_y_offset,
- buffer);
+ layout);
+ g_object_unref (layout);
}
}
diff --git a/calendar/gui/e-day-view-top-item.c b/calendar/gui/e-day-view-top-item.c
index e35b08d830..0f7ce66124 100644
--- a/calendar/gui/e-day-view-top-item.c
+++ b/calendar/gui/e-day-view-top-item.c
@@ -171,6 +171,7 @@ e_day_view_top_item_draw (GnomeCanvasItem *canvas_item,
gint item_height, event_num;
struct tm day_start = { 0 };
struct icaltimetype day_start_tt;
+ PangoLayout *layout;
#if 0
g_print ("In e_day_view_top_item_draw %i,%i %ix%i\n",
@@ -280,8 +281,13 @@ e_day_view_top_item_draw (GnomeCanvasItem *canvas_item,
date_width = gdk_string_width (font, buffer);
date_x = day_view->day_offsets[day] + (day_view->day_widths[day] - date_width) / 2;
- gdk_draw_string (drawable, font, fg_gc,
- date_x - x, 3 + font->ascent - y, buffer);
+
+ layout = gtk_widget_create_pango_layout (GTK_WIDGET (day_view), buffer);
+ gdk_draw_layout (drawable, fg_gc,
+ date_x - x,
+ 3 - y,
+ layout);
+ g_object_unref (layout);
gdk_gc_set_clip_rectangle (fg_gc, NULL);
@@ -481,7 +487,11 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
item_y + E_DAY_VIEW_LONG_EVENT_BORDER_HEIGHT
+ E_DAY_VIEW_LONG_EVENT_Y_PAD
+ font->ascent - y,
+#if 0
buffer);
+#else
+ "FIXME text");
+#endif
gdk_gc_set_clip_rectangle (fg_gc, NULL);
@@ -522,7 +532,11 @@ e_day_view_top_item_draw_long_event (EDayViewTopItem *dvtitem,
time_x,
item_y + E_DAY_VIEW_LONG_EVENT_Y_PAD
+ font->ascent + 1 - y,
+#if 0
buffer);
+#else
+ "FIXME text");
+#endif
max_icon_x -= time_width + E_DAY_VIEW_LONG_EVENT_TIME_X_PAD;
}
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 82097fc87d..ea293d7e2c 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -77,10 +77,7 @@
/* The minimum amount of space wanted on each side of the date string. */
#define E_DAY_VIEW_DATE_X_PAD 4
-#define E_DAY_VIEW_LARGE_FONT \
- "-adobe-utopia-regular-r-normal-*-*-240-*-*-p-*-iso8859-*"
-#define E_DAY_VIEW_LARGE_FONT_FALLBACK \
- "-adobe-helvetica-bold-r-normal-*-*-240-*-*-p-*-iso8859-*"
+#define E_DAY_VIEW_LARGE_FONT_PTSIZE 24
/* The offset from the top/bottom of the canvas before auto-scrolling starts.*/
#define E_DAY_VIEW_AUTO_SCROLL_OFFSET 16
@@ -607,7 +604,7 @@ e_day_view_init (EDayView *day_view)
day_view->default_category = NULL;
- day_view->large_font = NULL;
+ day_view->large_font_desc = NULL;
/* String to use in 12-hour time format for times in the morning. */
day_view->am_string = _("am");
@@ -911,9 +908,9 @@ e_day_view_destroy (GtkObject *object)
day_view->query = NULL;
}
- if (day_view->large_font) {
- gdk_font_unref (day_view->large_font);
- day_view->large_font = NULL;
+ if (day_view->large_font_desc) {
+ g_object_unref (day_view->large_font_desc);
+ day_view->large_font_desc = NULL;
}
if (day_view->default_category) {
@@ -1106,6 +1103,7 @@ e_day_view_style_set (GtkWidget *widget,
{
EDayView *day_view;
GdkFont *font;
+ PangoContext *context;
gint top_rows, top_canvas_height;
gint hour, max_large_hour_width;
gint minute, max_minute_width, i;
@@ -1123,14 +1121,13 @@ e_day_view_style_set (GtkWidget *widget,
font = gtk_style_get_font (gtk_widget_get_style (widget));
/* Create the large font. */
- if (day_view->large_font != NULL)
- gdk_font_unref (day_view->large_font);
+ if (day_view->large_font_desc != NULL)
+ g_object_unref (day_view->large_font_desc);
- day_view->large_font = gdk_font_load (E_DAY_VIEW_LARGE_FONT);
- if (!day_view->large_font)
- day_view->large_font = gdk_font_load (E_DAY_VIEW_LARGE_FONT_FALLBACK);
- if (!day_view->large_font)
- day_view->large_font = font;
+ day_view->large_font_desc =
+ pango_font_description_copy (gtk_widget_get_style (widget)->font_desc);
+ pango_font_description_set_size (day_view->large_font_desc,
+ E_DAY_VIEW_LARGE_FONT_PTSIZE * PANGO_SCALE);
/* Recalculate the height of each row based on the font size. */
day_view->row_height = font->ascent + font->descent + E_DAY_VIEW_EVENT_BORDER_HEIGHT + E_DAY_VIEW_EVENT_Y_PAD * 2 + 2 /* FIXME */;
@@ -1234,12 +1231,16 @@ e_day_view_style_set (GtkWidget *widget,
e_day_view_foreach_event (day_view, e_day_view_set_event_font_cb,
font);
+#if 0
+ /* FIXME: Port. */
+
/* Set the fonts for the text items used when dragging. */
gnome_canvas_item_set (day_view->drag_long_event_item,
"font_gdk", font, NULL);
gnome_canvas_item_set (day_view->drag_item,
"font_gdk", font, NULL);
+#endif
}
diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h
index 0505e68d53..5419e336aa 100644
--- a/calendar/gui/e-day-view.h
+++ b/calendar/gui/e-day-view.h
@@ -361,7 +361,7 @@ struct _EDayView
/* The large font used to display the hours. I don't think we need a
fontset since we only display numbers. */
- GdkFont *large_font;
+ PangoFontDescription *large_font_desc;
/* The GC used for painting in different colors. */
GdkGC *main_gc;
diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c
index 1cc1cbe637..10932d76cc 100644
--- a/calendar/gui/e-week-view-event-item.c
+++ b/calendar/gui/e-week-view-event-item.c
@@ -462,65 +462,91 @@ e_week_view_draw_time (EWeekView *week_view,
{
GtkStyle *style;
GdkGC *gc;
- GdkFont *font, *small_font;
+ GdkFont *font;
gint hour_to_display, suffix_width;
gint time_y_normal_font, time_y_small_font;
gchar buffer[128], *suffix;
+ PangoLayout *layout;
+ PangoFontDescription *small_font_desc;
style = gtk_widget_get_style (GTK_WIDGET (week_view));
font = gtk_style_get_font (style);
- small_font = week_view->small_font;
+ small_font_desc = week_view->small_font_desc;
gc = week_view->main_gc;
gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_EVENT_TEXT]);
- time_y_normal_font = time_y_small_font = time_y + font->ascent;
- if (small_font)
- time_y_small_font = time_y + small_font->ascent;
+ layout = gtk_widget_create_pango_layout (GTK_WIDGET (week_view), NULL);
+
+ time_y_normal_font = time_y_small_font = time_y;
+ if (small_font_desc)
+ time_y_small_font = time_y;
e_week_view_convert_time_to_display (week_view, hour, &hour_to_display,
&suffix, &suffix_width);
- if (week_view->use_small_font && week_view->small_font) {
+ if (week_view->use_small_font && week_view->small_font_desc) {
g_snprintf (buffer, sizeof (buffer), "%2i:%02i",
hour_to_display, minute);
/* Draw the hour. */
- if (hour_to_display < 10)
- gdk_draw_text (drawable, font, gc,
- time_x + week_view->digit_width,
- time_y_normal_font, buffer + 1, 1);
- else
- gdk_draw_text (drawable, font, gc,
- time_x, time_y_normal_font, buffer, 2);
+ if (hour_to_display < 10) {
+ pango_layout_set_text (layout, buffer + 1, 1);
+ gdk_draw_layout (drawable, gc,
+ time_x + week_view->digit_width,
+ time_y_normal_font,
+ layout);
+ } else {
+ pango_layout_set_text (layout, buffer, 2);
+ gdk_draw_layout (drawable, gc,
+ time_x,
+ time_y_normal_font,
+ layout);
+ }
time_x += week_view->digit_width * 2;
/* Draw the start minute, in the small font. */
- gdk_draw_text (drawable, week_view->small_font, gc,
- time_x, time_y_small_font, buffer + 3, 2);
+ pango_layout_set_font_description (layout, week_view->small_font_desc);
+ pango_layout_set_text (layout, buffer + 3, 2);
+ gdk_draw_layout (drawable, gc,
+ time_x,
+ time_y_small_font,
+ layout);
+
+ pango_layout_set_font_description (layout, style->font_desc);
time_x += week_view->small_digit_width * 2;
/* Draw the 'am'/'pm' suffix, if 12-hour format. */
if (!week_view->use_24_hour_format) {
- gdk_draw_string (drawable, font, gc,
- time_x, time_y_normal_font, suffix);
+ pango_layout_set_text (layout, suffix, -1);
+ gdk_draw_layout (drawable, gc,
+ time_x,
+ time_y_normal_font,
+ layout);
}
} else {
/* Draw the start time in one go. */
g_snprintf (buffer, sizeof (buffer), "%2i:%02i%s",
hour_to_display, minute, suffix);
- if (hour_to_display < 10)
- gdk_draw_string (drawable, font, gc,
+ if (hour_to_display < 10) {
+ pango_layout_set_text (layout, buffer + 1, -1);
+ gdk_draw_layout (drawable, gc,
time_x + week_view->digit_width,
- time_y_normal_font, buffer + 1);
- else
- gdk_draw_string (drawable, font, gc,
- time_x, time_y_normal_font,
- buffer);
+ time_y_normal_font,
+ layout);
+ } else {
+ pango_layout_set_text (layout, buffer, -1);
+ gdk_draw_layout (drawable, gc,
+ time_x,
+ time_y_normal_font,
+ layout);
+ }
}
+
+ g_object_unref (layout);
}
diff --git a/calendar/gui/e-week-view-main-item.c b/calendar/gui/e-week-view-main-item.c
index d5d1e82d8b..e5fc58721d 100644
--- a/calendar/gui/e-week-view-main-item.c
+++ b/calendar/gui/e-week-view-main-item.c
@@ -211,6 +211,7 @@ e_week_view_main_item_draw_day (EWeekViewMainItem *wvmitem,
gchar buffer[128], *format_string;
gint month, day_of_month, max_width;
GdkColor *bg_color;
+ PangoLayout *layout;
#if 0
g_print ("Drawing Day:%i at %i,%i\n", day, x, y);
@@ -325,12 +326,6 @@ e_week_view_main_item_draw_day (EWeekViewMainItem *wvmitem,
format_string = _("%d %b");
}
- g_date_strftime (buffer, sizeof (buffer),
- format_string ? format_string : "%d", date);
- date_width = gdk_string_width (font, buffer);
- date_x = x + width - date_width - E_WEEK_VIEW_DATE_R_PAD;
- date_x = MAX (date_x, x + 1);
-
if (selected) {
gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_DATES_SELECTED]);
} else if (week_view->multi_week_view) {
@@ -347,10 +342,20 @@ e_week_view_main_item_draw_day (EWeekViewMainItem *wvmitem,
} else {
gdk_gc_set_foreground (gc, &week_view->colors[E_WEEK_VIEW_COLOR_DATES]);
}
-
- gdk_draw_string (drawable, font, gc,
- date_x, y + E_WEEK_VIEW_DATE_T_PAD + font->ascent,
- buffer);
+
+ g_date_strftime (buffer, sizeof (buffer),
+ format_string ? format_string : "%d", date);
+
+ layout = gtk_widget_create_pango_layout (GTK_WIDGET (week_view), buffer);
+ pango_layout_get_pixel_size (layout, &date_width, NULL);
+ date_x = x + width - date_width - E_WEEK_VIEW_DATE_R_PAD;
+ date_x = MAX (date_x, x + 1);
+
+ gdk_draw_layout (drawable, gc,
+ date_x,
+ y + E_WEEK_VIEW_DATE_T_PAD,
+ layout);
+ g_object_unref (layout);
/* Draw the line under the date. */
if (!week_view->multi_week_view) {
diff --git a/calendar/gui/e-week-view-titles-item.c b/calendar/gui/e-week-view-titles-item.c
index 2e2fe085ee..13faac1fce 100644
--- a/calendar/gui/e-week-view-titles-item.c
+++ b/calendar/gui/e-week-view-titles-item.c
@@ -153,6 +153,7 @@ e_week_view_titles_item_draw (GnomeCanvasItem *canvas_item,
GdkRectangle clip_rect;
gboolean long_format;
gint weekday;
+ PangoLayout *layout;
#if 0
g_print ("In e_week_view_titles_item_draw %i,%i %ix%i\n",
@@ -171,6 +172,7 @@ e_week_view_titles_item_draw (GnomeCanvasItem *canvas_item,
dark_gc = style->dark_gc[GTK_STATE_NORMAL];
canvas_width = GTK_WIDGET (canvas_item->canvas)->allocation.width;
canvas_height = GTK_WIDGET (canvas_item->canvas)->allocation.height;
+ layout = gtk_widget_create_pango_layout (GTK_WIDGET (week_view), NULL);
/* Draw the shadow around the dates. */
gdk_draw_line (drawable, light_gc,
@@ -233,8 +235,12 @@ e_week_view_titles_item_draw (GnomeCanvasItem *canvas_item,
date_x = week_view->col_offsets[col]
+ (week_view->col_widths[col] - date_width) / 2;
date_x = MAX (date_x, week_view->col_offsets[col]);
- gdk_draw_string (drawable, font, fg_gc,
- date_x - x, 3 + font->ascent - y, buffer);
+
+ pango_layout_set_text (layout, buffer, -1);
+ gdk_draw_layout (drawable, fg_gc,
+ date_x - x,
+ 3 - y,
+ layout);
gdk_gc_set_clip_rectangle (fg_gc, NULL);
@@ -271,6 +277,8 @@ e_week_view_titles_item_draw (GnomeCanvasItem *canvas_item,
g_date_add_days (&date, 1);
}
+
+ g_object_unref (layout);
}
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index aa8a2727d6..e92dbab6a7 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -72,10 +72,7 @@
#include "art/timezone-16.xpm"
#include "art/jump.xpm"
-#define E_WEEK_VIEW_SMALL_FONT \
- "-adobe-utopia-regular-r-normal-*-*-100-*-*-p-*-iso8859-*"
-#define E_WEEK_VIEW_SMALL_FONT_FALLBACK \
- "-adobe-helvetica-medium-r-normal-*-*-80-*-*-p-*-iso8859-*"
+#define E_WEEK_VIEW_SMALL_FONT_PTSIZE 7
#define E_WEEK_VIEW_JUMP_BUTTON_WIDTH 16
#define E_WEEK_VIEW_JUMP_BUTTON_HEIGHT 8
@@ -337,11 +334,11 @@ e_week_view_init (EWeekView *week_view)
/* Create the small font. */
week_view->use_small_font = TRUE;
- week_view->small_font = gdk_font_load (E_WEEK_VIEW_SMALL_FONT);
- if (!week_view->small_font)
- week_view->small_font = gdk_font_load (E_WEEK_VIEW_SMALL_FONT_FALLBACK);
- if (!week_view->small_font)
- week_view->use_small_font = FALSE;
+
+ week_view->small_font_desc =
+ pango_font_description_copy (gtk_widget_get_style (GTK_WIDGET (week_view))->font_desc);
+ pango_font_description_set_size (week_view->small_font_desc,
+ E_WEEK_VIEW_SMALL_FONT_PTSIZE * PANGO_SCALE);
/* String to use in 12-hour time format for times in the morning. */
week_view->am_string = _("am");
@@ -494,9 +491,9 @@ e_week_view_destroy (GtkObject *object)
week_view->query = NULL;
}
- if (week_view->small_font) {
- gdk_font_unref (week_view->small_font);
- week_view->small_font = NULL;
+ if (week_view->small_font_desc) {
+ g_object_unref (week_view->small_font_desc);
+ week_view->small_font_desc = NULL;
}
if (week_view->default_category) {
@@ -619,25 +616,62 @@ e_week_view_unrealize (GtkWidget *widget)
(*GTK_WIDGET_CLASS (parent_class)->unrealize)(widget);
}
+static gint
+get_string_width (PangoLayout *layout, const gchar *string)
+{
+ gint width;
+
+ pango_layout_set_text (layout, string, -1);
+ pango_layout_get_pixel_size (layout, &width, NULL);
+ return width;
+}
+
+/* FIXME: This is also needed in e-day-view-time-item.c. We should probably use
+ * pango's approximation function, but it needs a language tag. Find out how to
+ * get one of those properly. */
+static gint
+get_digit_width (PangoLayout *layout)
+{
+ gint digit;
+ gint max_digit_width = 1;
+
+ for (digit = '0'; digit <= '9'; digit++) {
+ gchar digit_char;
+ gint digit_width;
+
+ digit_char = digit;
+
+ pango_layout_set_text (layout, &digit_char, 1);
+ pango_layout_get_pixel_size (layout, &digit_width, NULL);
+
+ max_digit_width = MAX (max_digit_width, digit_width);
+ }
+
+ return max_digit_width;
+}
static void
e_week_view_style_set (GtkWidget *widget,
- GtkStyle *previous_style)
+ GtkStyle *previous_style)
{
EWeekView *week_view;
EWeekViewEventSpan *span;
GdkFont *font;
+ GtkStyle *style;
gint day, day_width, max_day_width, max_abbr_day_width;
gint month, month_width, max_month_width, max_abbr_month_width;
gint span_num;
GDate date;
gchar buffer[128];
+ PangoLayout *layout;
if (GTK_WIDGET_CLASS (parent_class)->style_set)
(*GTK_WIDGET_CLASS (parent_class)->style_set)(widget, previous_style);
week_view = E_WEEK_VIEW (widget);
- font = gtk_style_get_font (gtk_widget_get_style (widget));
+ style = gtk_widget_get_style (widget);
+ font = gtk_style_get_font (style);
+ layout = gtk_widget_create_pango_layout (widget, NULL);
/* Recalculate the height of each row based on the font size. */
week_view->row_height = font->ascent + font->descent + E_WEEK_VIEW_EVENT_BORDER_HEIGHT * 2 + E_WEEK_VIEW_EVENT_TEXT_Y_PAD * 2;
@@ -645,8 +679,8 @@ e_week_view_style_set (GtkWidget *widget,
/* Check that the small font is smaller than the default font.
If it isn't, we won't use it. */
- if (week_view->small_font) {
- if (font->ascent + font->descent <= week_view->small_font->ascent + week_view->small_font->descent)
+ if (week_view->small_font_desc) {
+ if (font->ascent + font->descent <= E_WEEK_VIEW_SMALL_FONT_PTSIZE)
week_view->use_small_font = FALSE;
}
@@ -663,12 +697,12 @@ e_week_view_style_set (GtkWidget *widget,
max_abbr_day_width = 0;
for (day = 0; day < 7; day++) {
g_date_strftime (buffer, 128, "%A", &date);
- day_width = gdk_string_width (font, buffer);
+ day_width = get_string_width (layout, buffer);
week_view->day_widths[day] = day_width;
max_day_width = MAX (max_day_width, day_width);
g_date_strftime (buffer, 128, "%a", &date);
- day_width = gdk_string_width (font, buffer);
+ day_width = get_string_width (layout, buffer);
week_view->abbr_day_widths[day] = day_width;
max_abbr_day_width = MAX (max_abbr_day_width, day_width);
@@ -681,30 +715,33 @@ e_week_view_style_set (GtkWidget *widget,
g_date_set_month (&date, month + 1);
g_date_strftime (buffer, 128, "%B", &date);
- month_width = gdk_string_width (font, buffer);
+ month_width = get_string_width (layout, buffer);
week_view->month_widths[month] = month_width;
max_month_width = MAX (max_month_width, month_width);
g_date_strftime (buffer, 128, "%b", &date);
- month_width = gdk_string_width (font, buffer);
+ month_width = get_string_width (layout, buffer);
week_view->abbr_month_widths[month] = month_width;
max_abbr_month_width = MAX (max_abbr_month_width, month_width);
}
- week_view->space_width = gdk_string_width (font, " ");
- week_view->colon_width = gdk_string_width (font, ":");
- week_view->slash_width = gdk_string_width (font, "/");
- week_view->digit_width = gdk_string_width (font, "5");
- if (week_view->small_font)
- week_view->small_digit_width = gdk_string_width (week_view->small_font, "5");
+ week_view->space_width = get_string_width (layout, " ");
+ week_view->colon_width = get_string_width (layout, ":");
+ week_view->slash_width = get_string_width (layout, "/");
+ week_view->digit_width = get_digit_width (layout);
+ if (week_view->small_font_desc) {
+ pango_layout_set_font_description (layout, week_view->small_font_desc);
+ week_view->small_digit_width = get_digit_width (layout);
+ pango_layout_set_font_description (layout, style->font_desc);
+ }
week_view->max_day_width = max_day_width;
week_view->max_abbr_day_width = max_abbr_day_width;
week_view->max_month_width = max_month_width;
week_view->max_abbr_month_width = max_abbr_month_width;
- week_view->am_string_width = gdk_string_width (font,
+ week_view->am_string_width = get_string_width (layout,
week_view->am_string);
- week_view->pm_string_width = gdk_string_width (font,
+ week_view->pm_string_width = get_string_width (layout,
week_view->pm_string);
/* Set the font of all the EText items. */
@@ -719,6 +756,8 @@ e_week_view_style_set (GtkWidget *widget,
NULL);
}
}
+
+ g_object_unref (layout);
}
@@ -857,7 +896,7 @@ e_week_view_recalc_cell_sizes (EWeekView *week_view)
time_width = e_week_view_get_time_string_width (week_view);
week_view->time_format = E_WEEK_VIEW_TIME_NONE;
- if (week_view->use_small_font && week_view->small_font) {
+ if (week_view->use_small_font && week_view->small_font_desc) {
if (week_view->show_event_end_times
&& width / 2 > time_width * 2 + E_WEEK_VIEW_EVENT_TIME_SPACING)
week_view->time_format = E_WEEK_VIEW_TIME_BOTH_SMALL_MIN;
@@ -4088,7 +4127,7 @@ e_week_view_get_time_string_width (EWeekView *week_view)
{
gint time_width;
- if (week_view->use_small_font && week_view->small_font)
+ if (week_view->use_small_font && week_view->small_font_desc)
time_width = week_view->digit_width * 2
+ week_view->small_digit_width * 2;
else
diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h
index abc0419815..f45ca7eb1d 100644
--- a/calendar/gui/e-week-view.h
+++ b/calendar/gui/e-week-view.h
@@ -270,7 +270,7 @@ struct _EWeekView
gboolean use_small_font;
/* Small font to display the minutes. */
- GdkFont *small_font;
+ PangoFontDescription *small_font_desc;
/* The widths of various pieces of text, used to determine which of
several date formats to display, set in e_week_view_style_set(). */
diff --git a/calendar/gui/itip-utils.c b/calendar/gui/itip-utils.c
index 6bf95c9732..92e35e6209 100644
--- a/calendar/gui/itip-utils.c
+++ b/calendar/gui/itip-utils.c
@@ -580,7 +580,7 @@ comp_description (CalComponent *comp)
if (start != NULL && end != NULL) {
char *tmp, *tmp_utf;
tmp = g_strdup_printf (_("Free/Busy information (%s to %s)"), start, end);
- tmp_utf = e_utf8_from_locale_string (tmp);
+ tmp_utf = g_locale_to_utf8 (tmp, -1, NULL, NULL, NULL);
description = CORBA_string_dup (tmp_utf);
g_free (tmp_utf);
g_free (tmp);