diff options
author | Owen Taylor <otaylor@redhat.com> | 2000-05-30 19:21:05 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2000-05-30 19:21:05 +0000 |
commit | 524ddc35c95ef8b3aa46d1ff62f1c0fa5ed1db91 (patch) | |
tree | c8d8f3828fdea284f1cb93b2242333eeb05eade4 | |
parent | 08fa3f2f26f0f5e10c0b5f85ba3561b25aa6fa82 (diff) | |
download | gtk+-524ddc35c95ef8b3aa46d1ff62f1c0fa5ed1db91.tar.gz |
Use font descriptions.
Tue May 30 15:03:19 2000 Owen Taylor <otaylor@redhat.com>
* gtk/testcalendar.c (calendar_font_selection_ok): Use font
descriptions.
* gtk/gtkentry.c (gtk_entry_draw_text): Center text within
the entry.
* gtk/gtkfontsel.c (gtk_font_selection_dialog_init): Start of
redoing (vastly simplifying) for Pango. Still needs quite
a bit of work. (Size selection is currently poor. List of
predefined sizes is not a good idea, since all of these
sizes won't necessarily be distinct.)
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | ChangeLog.pre-2-0 | 8 | ||||
-rw-r--r-- | ChangeLog.pre-2-10 | 8 | ||||
-rw-r--r-- | ChangeLog.pre-2-2 | 8 | ||||
-rw-r--r-- | ChangeLog.pre-2-4 | 8 | ||||
-rw-r--r-- | ChangeLog.pre-2-6 | 8 | ||||
-rw-r--r-- | ChangeLog.pre-2-8 | 8 | ||||
-rw-r--r-- | gdk/x11/gdkfont-x11.c | 6 | ||||
-rw-r--r-- | gtk/gtkentry.c | 10 | ||||
-rw-r--r-- | gtk/gtkfontsel.c | 6 | ||||
-rw-r--r-- | gtk/testcalendar.c | 28 | ||||
-rw-r--r-- | tests/testcalendar.c | 28 |
12 files changed, 92 insertions, 42 deletions
@@ -1,4 +1,10 @@ -Tue May 30 14:01:10 2000 Owen Taylor <otaylor@redhat.com> +Tue May 30 15:03:19 2000 Owen Taylor <otaylor@redhat.com> + + * gtk/testcalendar.c (calendar_font_selection_ok): Use font + descriptions. + + * gtk/gtkentry.c (gtk_entry_draw_text): Center text within + the entry. * gtk/gtkfontsel.c (gtk_font_selection_dialog_init): Start of redoing (vastly simplifying) for Pango. Still needs quite diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 467432863a..a72a222803 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,4 +1,10 @@ -Tue May 30 14:01:10 2000 Owen Taylor <otaylor@redhat.com> +Tue May 30 15:03:19 2000 Owen Taylor <otaylor@redhat.com> + + * gtk/testcalendar.c (calendar_font_selection_ok): Use font + descriptions. + + * gtk/gtkentry.c (gtk_entry_draw_text): Center text within + the entry. * gtk/gtkfontsel.c (gtk_font_selection_dialog_init): Start of redoing (vastly simplifying) for Pango. Still needs quite diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 467432863a..a72a222803 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,4 +1,10 @@ -Tue May 30 14:01:10 2000 Owen Taylor <otaylor@redhat.com> +Tue May 30 15:03:19 2000 Owen Taylor <otaylor@redhat.com> + + * gtk/testcalendar.c (calendar_font_selection_ok): Use font + descriptions. + + * gtk/gtkentry.c (gtk_entry_draw_text): Center text within + the entry. * gtk/gtkfontsel.c (gtk_font_selection_dialog_init): Start of redoing (vastly simplifying) for Pango. Still needs quite diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 467432863a..a72a222803 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,4 +1,10 @@ -Tue May 30 14:01:10 2000 Owen Taylor <otaylor@redhat.com> +Tue May 30 15:03:19 2000 Owen Taylor <otaylor@redhat.com> + + * gtk/testcalendar.c (calendar_font_selection_ok): Use font + descriptions. + + * gtk/gtkentry.c (gtk_entry_draw_text): Center text within + the entry. * gtk/gtkfontsel.c (gtk_font_selection_dialog_init): Start of redoing (vastly simplifying) for Pango. Still needs quite diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 467432863a..a72a222803 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,4 +1,10 @@ -Tue May 30 14:01:10 2000 Owen Taylor <otaylor@redhat.com> +Tue May 30 15:03:19 2000 Owen Taylor <otaylor@redhat.com> + + * gtk/testcalendar.c (calendar_font_selection_ok): Use font + descriptions. + + * gtk/gtkentry.c (gtk_entry_draw_text): Center text within + the entry. * gtk/gtkfontsel.c (gtk_font_selection_dialog_init): Start of redoing (vastly simplifying) for Pango. Still needs quite diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 467432863a..a72a222803 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,4 +1,10 @@ -Tue May 30 14:01:10 2000 Owen Taylor <otaylor@redhat.com> +Tue May 30 15:03:19 2000 Owen Taylor <otaylor@redhat.com> + + * gtk/testcalendar.c (calendar_font_selection_ok): Use font + descriptions. + + * gtk/gtkentry.c (gtk_entry_draw_text): Center text within + the entry. * gtk/gtkfontsel.c (gtk_font_selection_dialog_init): Start of redoing (vastly simplifying) for Pango. Still needs quite diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 467432863a..a72a222803 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,4 +1,10 @@ -Tue May 30 14:01:10 2000 Owen Taylor <otaylor@redhat.com> +Tue May 30 15:03:19 2000 Owen Taylor <otaylor@redhat.com> + + * gtk/testcalendar.c (calendar_font_selection_ok): Use font + descriptions. + + * gtk/gtkentry.c (gtk_entry_draw_text): Center text within + the entry. * gtk/gtkfontsel.c (gtk_font_selection_dialog_init): Start of redoing (vastly simplifying) for Pango. Still needs quite diff --git a/gdk/x11/gdkfont-x11.c b/gdk/x11/gdkfont-x11.c index 88f5915193..3ee07358d2 100644 --- a/gdk/x11/gdkfont-x11.c +++ b/gdk/x11/gdkfont-x11.c @@ -140,6 +140,7 @@ static char * gdk_font_charset_for_locale () { static char *charset_map[][2] = { + { "ANSI_X3.4-1968", "iso8859-1" }, { "ISO-8859-1", "iso8859-1" }, { "ISO-8859-2", "iso8859-2" }, { "ISO-8859-3", "iso8859-3" }, @@ -164,7 +165,10 @@ gdk_font_charset_for_locale () g_free (codeset); - return g_strdup (result); + if (result) + return g_strdup (result); + else + return g_strdup ("iso-8859-1"); }; /** diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 4885ab7c91..8935973b73 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -1222,6 +1222,10 @@ gtk_entry_draw_text (GtkEntry *entry) if (GTK_WIDGET_DRAWABLE (entry)) { PangoRectangle logical_rect; + int area_height; + + gdk_window_get_size (entry->text_area, NULL, &area_height); + area_height = PANGO_SCALE * (area_height - 2 * INNER_BORDER); widget = GTK_WIDGET (entry); @@ -1232,7 +1236,8 @@ gtk_entry_draw_text (GtkEntry *entry) gdk_draw_layout (entry->text_area, widget->style->text_gc [widget->state], INNER_BORDER - entry->scroll_offset, - INNER_BORDER + (entry->ascent + logical_rect.y) / PANGO_SCALE, + INNER_BORDER + ((area_height - logical_rect.height) / 2 + + entry->ascent + logical_rect.y) / PANGO_SCALE, entry->layout); if (editable->selection_start_pos != editable->selection_end_pos) @@ -1266,7 +1271,8 @@ gtk_entry_draw_text (GtkEntry *entry) gdk_gc_set_clip_region (widget->style->fg_gc [selected_state], clip_region); gdk_draw_layout (entry->text_area, widget->style->fg_gc [selected_state], INNER_BORDER - entry->scroll_offset, - INNER_BORDER + (entry->ascent + logical_rect.y) / PANGO_SCALE, + INNER_BORDER + ((area_height - logical_rect.height) / 2 + + entry->ascent + logical_rect.y) / PANGO_SCALE, entry->layout); gdk_gc_set_clip_region (widget->style->fg_gc [selected_state], NULL); diff --git a/gtk/gtkfontsel.c b/gtk/gtkfontsel.c index 2992ac87d2..a4260a2535 100644 --- a/gtk/gtkfontsel.c +++ b/gtk/gtkfontsel.c @@ -326,6 +326,8 @@ gtk_font_selection_init(GtkFontSelection *fontsel) gtk_widget_set_usize (fontsel->preview_entry, -1, INITIAL_PREVIEW_HEIGHT); gtk_box_pack_start (GTK_BOX (text_box), fontsel->preview_entry, TRUE, TRUE, 0); + + gtk_font_selection_update_preview (fontsel); } GtkWidget * @@ -354,8 +356,8 @@ gtk_font_selection_finalize (GtkObject *object) if (fontsel->font) gdk_font_unref (fontsel->font); - if (GTK_OBJECT_CLASS (font_selection_parent_class)->destroy) - (* GTK_OBJECT_CLASS (font_selection_parent_class)->destroy) (object); + if (GTK_OBJECT_CLASS (font_selection_parent_class)->finalize) + (* GTK_OBJECT_CLASS (font_selection_parent_class)->finalize) (object); } diff --git a/gtk/testcalendar.c b/gtk/testcalendar.c index 3ecded2ad0..0eaa0c9602 100644 --- a/gtk/testcalendar.c +++ b/gtk/testcalendar.c @@ -31,7 +31,6 @@ typedef struct _CalendarData { GtkWidget *flag_checkboxes[5]; gboolean settings[5]; - gchar *font; GtkWidget *font_dialog; GtkWidget *window; GtkWidget *prev2_sig; @@ -184,26 +183,26 @@ void calendar_toggle_flag( GtkWidget *toggle, } -void calendar_font_selection_ok( GtkWidget *button, - CalendarData *calendar ) +void calendar_font_selection_ok (GtkWidget *button, + CalendarData *calendar) { - GtkStyle *style; - GdkFont *font; + GtkRcStyle *style; + char *font_name; - calendar->font = gtk_font_selection_dialog_get_font_name( - GTK_FONT_SELECTION_DIALOG (calendar->font_dialog)); if (calendar->window) { - font = gtk_font_selection_dialog_get_font(GTK_FONT_SELECTION_DIALOG(calendar->font_dialog)); - if (font) + font_name = gtk_font_selection_dialog_get_font_name (GTK_FONT_SELECTION_DIALOG(calendar->font_dialog)); + if (font_name) { - style = gtk_style_copy (gtk_widget_get_style (calendar->window)); - gdk_font_unref (style->font); - style->font = font; - gdk_font_ref (style->font); - gtk_widget_set_style (calendar->window, style); + style = gtk_rc_style_new (); + pango_font_description_free (style->font_desc); + style->font_desc = pango_font_description_from_string (font_name); + gtk_widget_modify_style (calendar->window, style); + g_free (font_name); } } + + gtk_widget_destroy (calendar->font_dialog); } void calendar_select_font( GtkWidget *button, @@ -267,7 +266,6 @@ void create_calendar() calendar_data.window = NULL; - calendar_data.font = NULL; calendar_data.font_dialog = NULL; for (i=0; i<5; i++) { diff --git a/tests/testcalendar.c b/tests/testcalendar.c index 3ecded2ad0..0eaa0c9602 100644 --- a/tests/testcalendar.c +++ b/tests/testcalendar.c @@ -31,7 +31,6 @@ typedef struct _CalendarData { GtkWidget *flag_checkboxes[5]; gboolean settings[5]; - gchar *font; GtkWidget *font_dialog; GtkWidget *window; GtkWidget *prev2_sig; @@ -184,26 +183,26 @@ void calendar_toggle_flag( GtkWidget *toggle, } -void calendar_font_selection_ok( GtkWidget *button, - CalendarData *calendar ) +void calendar_font_selection_ok (GtkWidget *button, + CalendarData *calendar) { - GtkStyle *style; - GdkFont *font; + GtkRcStyle *style; + char *font_name; - calendar->font = gtk_font_selection_dialog_get_font_name( - GTK_FONT_SELECTION_DIALOG (calendar->font_dialog)); if (calendar->window) { - font = gtk_font_selection_dialog_get_font(GTK_FONT_SELECTION_DIALOG(calendar->font_dialog)); - if (font) + font_name = gtk_font_selection_dialog_get_font_name (GTK_FONT_SELECTION_DIALOG(calendar->font_dialog)); + if (font_name) { - style = gtk_style_copy (gtk_widget_get_style (calendar->window)); - gdk_font_unref (style->font); - style->font = font; - gdk_font_ref (style->font); - gtk_widget_set_style (calendar->window, style); + style = gtk_rc_style_new (); + pango_font_description_free (style->font_desc); + style->font_desc = pango_font_description_from_string (font_name); + gtk_widget_modify_style (calendar->window, style); + g_free (font_name); } } + + gtk_widget_destroy (calendar->font_dialog); } void calendar_select_font( GtkWidget *button, @@ -267,7 +266,6 @@ void create_calendar() calendar_data.window = NULL; - calendar_data.font = NULL; calendar_data.font_dialog = NULL; for (i=0; i<5; i++) { |