Use gtk_get_default_language

2000-06-21  Havoc Pennington  <hp@redhat.com>

* gtk/gtkwidget.c (gtk_widget_create_pango_context): Use
gtk_get_default_language

* gtk/gtkmain.h, gtk/gtkmain.c (gtk_get_default_language):
new function to get the default language

* gtk/gtktexttagprivate.h, gtk/gtktexttag.c, gtktextview.c:
s/gtk_text_view_style_values/gtk_text_style_values/

* gtk/gtktexttag.c, gtk/gtktexttag.h, gtk/gtktexttagprivate.h:
Add a "language" field to tags.

(gtk_text_tag_set_arg): Fix bug in setting
"bg_full_height_set" tag.
This commit is contained in:
Havoc Pennington 2000-06-21 20:41:15 +00:00 committed by Havoc Pennington
parent f534125777
commit 443e8c395e
15 changed files with 240 additions and 71 deletions

View File

@ -1,3 +1,20 @@
2000-06-21 Havoc Pennington <hp@redhat.com>
* gtk/gtkwidget.c (gtk_widget_create_pango_context): Use
gtk_get_default_language
* gtk/gtkmain.h, gtk/gtkmain.c (gtk_get_default_language):
new function to get the default language
* gtk/gtktexttagprivate.h, gtk/gtktexttag.c, gtktextview.c:
s/gtk_text_view_style_values/gtk_text_style_values/
* gtk/gtktexttag.c, gtk/gtktexttag.h, gtk/gtktexttagprivate.h:
Add a "language" field to tags.
(gtk_text_tag_set_arg): Fix bug in setting
"bg_full_height_set" tag.
2000-06-21 Havoc Pennington <hp@redhat.com>
* gtk/gtktextiter.h: Use gunichar instead of gint when appropriate

View File

@ -1,3 +1,20 @@
2000-06-21 Havoc Pennington <hp@redhat.com>
* gtk/gtkwidget.c (gtk_widget_create_pango_context): Use
gtk_get_default_language
* gtk/gtkmain.h, gtk/gtkmain.c (gtk_get_default_language):
new function to get the default language
* gtk/gtktexttagprivate.h, gtk/gtktexttag.c, gtktextview.c:
s/gtk_text_view_style_values/gtk_text_style_values/
* gtk/gtktexttag.c, gtk/gtktexttag.h, gtk/gtktexttagprivate.h:
Add a "language" field to tags.
(gtk_text_tag_set_arg): Fix bug in setting
"bg_full_height_set" tag.
2000-06-21 Havoc Pennington <hp@redhat.com>
* gtk/gtktextiter.h: Use gunichar instead of gint when appropriate

View File

@ -1,3 +1,20 @@
2000-06-21 Havoc Pennington <hp@redhat.com>
* gtk/gtkwidget.c (gtk_widget_create_pango_context): Use
gtk_get_default_language
* gtk/gtkmain.h, gtk/gtkmain.c (gtk_get_default_language):
new function to get the default language
* gtk/gtktexttagprivate.h, gtk/gtktexttag.c, gtktextview.c:
s/gtk_text_view_style_values/gtk_text_style_values/
* gtk/gtktexttag.c, gtk/gtktexttag.h, gtk/gtktexttagprivate.h:
Add a "language" field to tags.
(gtk_text_tag_set_arg): Fix bug in setting
"bg_full_height_set" tag.
2000-06-21 Havoc Pennington <hp@redhat.com>
* gtk/gtktextiter.h: Use gunichar instead of gint when appropriate

View File

@ -1,3 +1,20 @@
2000-06-21 Havoc Pennington <hp@redhat.com>
* gtk/gtkwidget.c (gtk_widget_create_pango_context): Use
gtk_get_default_language
* gtk/gtkmain.h, gtk/gtkmain.c (gtk_get_default_language):
new function to get the default language
* gtk/gtktexttagprivate.h, gtk/gtktexttag.c, gtktextview.c:
s/gtk_text_view_style_values/gtk_text_style_values/
* gtk/gtktexttag.c, gtk/gtktexttag.h, gtk/gtktexttagprivate.h:
Add a "language" field to tags.
(gtk_text_tag_set_arg): Fix bug in setting
"bg_full_height_set" tag.
2000-06-21 Havoc Pennington <hp@redhat.com>
* gtk/gtktextiter.h: Use gunichar instead of gint when appropriate

View File

@ -1,3 +1,20 @@
2000-06-21 Havoc Pennington <hp@redhat.com>
* gtk/gtkwidget.c (gtk_widget_create_pango_context): Use
gtk_get_default_language
* gtk/gtkmain.h, gtk/gtkmain.c (gtk_get_default_language):
new function to get the default language
* gtk/gtktexttagprivate.h, gtk/gtktexttag.c, gtktextview.c:
s/gtk_text_view_style_values/gtk_text_style_values/
* gtk/gtktexttag.c, gtk/gtktexttag.h, gtk/gtktexttagprivate.h:
Add a "language" field to tags.
(gtk_text_tag_set_arg): Fix bug in setting
"bg_full_height_set" tag.
2000-06-21 Havoc Pennington <hp@redhat.com>
* gtk/gtktextiter.h: Use gunichar instead of gint when appropriate

View File

@ -1,3 +1,20 @@
2000-06-21 Havoc Pennington <hp@redhat.com>
* gtk/gtkwidget.c (gtk_widget_create_pango_context): Use
gtk_get_default_language
* gtk/gtkmain.h, gtk/gtkmain.c (gtk_get_default_language):
new function to get the default language
* gtk/gtktexttagprivate.h, gtk/gtktexttag.c, gtktextview.c:
s/gtk_text_view_style_values/gtk_text_style_values/
* gtk/gtktexttag.c, gtk/gtktexttag.h, gtk/gtktexttagprivate.h:
Add a "language" field to tags.
(gtk_text_tag_set_arg): Fix bug in setting
"bg_full_height_set" tag.
2000-06-21 Havoc Pennington <hp@redhat.com>
* gtk/gtktextiter.h: Use gunichar instead of gint when appropriate

View File

@ -1,3 +1,20 @@
2000-06-21 Havoc Pennington <hp@redhat.com>
* gtk/gtkwidget.c (gtk_widget_create_pango_context): Use
gtk_get_default_language
* gtk/gtkmain.h, gtk/gtkmain.c (gtk_get_default_language):
new function to get the default language
* gtk/gtktexttagprivate.h, gtk/gtktexttag.c, gtktextview.c:
s/gtk_text_view_style_values/gtk_text_style_values/
* gtk/gtktexttag.c, gtk/gtktexttag.h, gtk/gtktexttagprivate.h:
Add a "language" field to tags.
(gtk_text_tag_set_arg): Fix bug in setting
"bg_full_height_set" tag.
2000-06-21 Havoc Pennington <hp@redhat.com>
* gtk/gtktextiter.h: Use gunichar instead of gint when appropriate

View File

@ -487,6 +487,23 @@ gtk_set_locale (void)
return gdk_set_locale ();
}
gchar*
gtk_get_default_language (void)
{
gchar *lang;
gchar *p;
lang = g_strdup (setlocale (LC_CTYPE, NULL));
p = strchr (lang, '.');
if (p)
*p = '\0';
p = strchr (lang, '@');
if (p)
*p = '\0';
return lang;
}
void
gtk_main (void)
{

View File

@ -78,14 +78,18 @@ gchar* gtk_check_version (guint required_major,
/* Initialization, exit, mainloop and miscellaneous routines
*/
void gtk_init (int *argc,
char ***argv);
gboolean gtk_init_check (int *argc,
char ***argv);
void gtk_exit (gint error_code);
gchar* gtk_set_locale (void);
gchar* gtk_get_default_language (void);
gint gtk_events_pending (void);
/* The following is the event func GTK+ registers with GDK
* we expose it mainly to allow filtering of events between
* GDK and GTK+.

View File

@ -189,7 +189,7 @@ free_style_cache (GtkTextLayout *text_layout)
{
if (text_layout->one_style_cache)
{
gtk_text_view_style_values_unref (text_layout->one_style_cache);
gtk_text_style_values_unref (text_layout->one_style_cache);
text_layout->one_style_cache = NULL;
}
}
@ -204,7 +204,7 @@ gtk_text_layout_destroy (GtkObject *object)
gtk_text_layout_set_buffer (layout, NULL);
if (layout->default_style)
gtk_text_view_style_values_unref (layout->default_style);
gtk_text_style_values_unref (layout->default_style);
layout->default_style = NULL;
if (layout->ltr_context)
@ -280,10 +280,10 @@ gtk_text_layout_set_default_style (GtkTextLayout *layout,
if (values == layout->default_style)
return;
gtk_text_view_style_values_ref (values);
gtk_text_style_values_ref (values);
if (layout->default_style)
gtk_text_view_style_values_unref (layout->default_style);
gtk_text_style_values_unref (layout->default_style);
layout->default_style = values;
@ -784,7 +784,7 @@ get_style (GtkTextLayout *layout,
*/
if (layout->one_style_cache != NULL)
{
gtk_text_view_style_values_ref (layout->one_style_cache);
gtk_text_style_values_ref (layout->one_style_cache);
return layout->one_style_cache;
}
@ -798,8 +798,8 @@ get_style (GtkTextLayout *layout,
{
/* One ref for the return value, one ref for the
layout->one_style_cache reference */
gtk_text_view_style_values_ref (layout->default_style);
gtk_text_view_style_values_ref (layout->default_style);
gtk_text_style_values_ref (layout->default_style);
gtk_text_style_values_ref (layout->default_style);
layout->one_style_cache = layout->default_style;
if (tags)
@ -811,12 +811,12 @@ get_style (GtkTextLayout *layout,
/* Sort tags in ascending order of priority */
gtk_text_tag_array_sort (tags, tag_count);
style = gtk_text_view_style_values_new ();
style = gtk_text_style_values_new ();
gtk_text_view_style_values_copy (layout->default_style,
gtk_text_style_values_copy (layout->default_style,
style);
gtk_text_view_style_values_fill_from_tags (style,
gtk_text_style_values_fill_from_tags (style,
tags,
tag_count);
@ -826,7 +826,7 @@ get_style (GtkTextLayout *layout,
/* Leave this style as the last one seen */
g_assert (layout->one_style_cache == NULL);
gtk_text_view_style_values_ref (style); /* ref held by layout->one_style_cache */
gtk_text_style_values_ref (style); /* ref held by layout->one_style_cache */
layout->one_style_cache = style;
/* Returning yet another refcount */
@ -840,7 +840,7 @@ release_style (GtkTextLayout *layout,
g_return_if_fail (style != NULL);
g_return_if_fail (style->refcount > 0);
gtk_text_view_style_values_unref (style);
gtk_text_style_values_unref (style);
}
/*

View File

@ -87,6 +87,7 @@ enum {
ARG_UNDERLINE,
ARG_OFFSET,
ARG_BG_FULL_HEIGHT,
ARG_LANGUAGE,
/* Whether-a-style-arg-is-set args */
ARG_BACKGROUND_SET,
@ -109,6 +110,7 @@ enum {
ARG_UNDERLINE_SET,
ARG_OFFSET_SET,
ARG_BG_FULL_HEIGHT_SET,
ARG_LANGUAGE_SET,
LAST_ARG
};
@ -220,6 +222,8 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
GTK_ARG_READWRITE, ARG_OFFSET);
gtk_object_add_arg_type ("GtkTextTag::background_full_height", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_BG_FULL_HEIGHT);
gtk_object_add_arg_type ("GtkTextTag::language", GTK_TYPE_STRING,
GTK_ARG_READWRITE, ARG_LANGUAGE);
/* Style args are set or not */
gtk_object_add_arg_type ("GtkTextTag::background_set", GTK_TYPE_BOOL,
@ -270,6 +274,8 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
GTK_ARG_READWRITE, ARG_OFFSET_SET);
gtk_object_add_arg_type ("GtkTextTag::background_full_height_set", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_BG_FULL_HEIGHT_SET);
gtk_object_add_arg_type ("GtkTextTag::language_set", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_LANGUAGE_SET);
signals[EVENT] =
gtk_signal_new ("event",
@ -309,7 +315,7 @@ gtk_text_tag_new (const gchar *name)
tag->name = g_strdup(name);
tag->values = gtk_text_view_style_values_new();
tag->values = gtk_text_style_values_new();
return tag;
}
@ -328,7 +334,7 @@ gtk_text_tag_destroy (GtkObject *object)
g_assert(tkxt_tag->table == NULL);
gtk_text_view_style_values_unref(tkxt_tag->values);
gtk_text_style_values_unref(tkxt_tag->values);
tkxt_tag->values = NULL;
(* GTK_OBJECT_CLASS(parent_class)->destroy) (object);
@ -584,6 +590,10 @@ gtk_text_tag_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
tkxt_tag->values->bg_full_height = GTK_VALUE_BOOL(*arg);
break;
case ARG_LANGUAGE:
tkxt_tag->language_set = TRUE;
tkxt_tag->values->language = g_strdup (GTK_VALUE_STRING(*arg));
break;
/* Whether the value should be used... */
@ -668,8 +678,12 @@ gtk_text_tag_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
break;
case ARG_BG_FULL_HEIGHT_SET:
tkxt_tag->bg_full_height_set = TRUE;
tkxt_tag->values->bg_full_height = GTK_VALUE_BOOL(*arg);
tkxt_tag->bg_full_height_set = GTK_VALUE_BOOL(*arg);
break;
case ARG_LANGUAGE_SET:
tkxt_tag->language_set = GTK_VALUE_BOOL(*arg);
size_changed = TRUE;
break;
default:
@ -797,6 +811,10 @@ gtk_text_tag_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
GTK_VALUE_BOOL(*arg) = tag->values->bg_full_height;
break;
case ARG_LANGUAGE:
GTK_VALUE_STRING(*arg) = g_strdup (tag->values->language);
break;
case ARG_BACKGROUND_SET:
case ARG_BACKGROUND_GDK_SET:
GTK_VALUE_BOOL(*arg) = tag->bg_color_set;
@ -871,6 +889,10 @@ gtk_text_tag_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
GTK_VALUE_BOOL(*arg) = tag->bg_full_height_set;
break;
case ARG_LANGUAGE_SET:
GTK_VALUE_BOOL(*arg) = tag->language_set;
break;
case ARG_BACKGROUND:
case ARG_FOREGROUND:
default:
@ -1020,7 +1042,7 @@ gtk_text_tag_array_sort(GtkTextTag** tag_array_p,
*/
GtkTextStyleValues*
gtk_text_view_style_values_new(void)
gtk_text_style_values_new(void)
{
GtkTextStyleValues *values;
@ -1030,11 +1052,13 @@ gtk_text_view_style_values_new(void)
values->refcount = 1;
values->language = gtk_get_default_language ();
return values;
}
void
gtk_text_view_style_values_copy(GtkTextStyleValues *src,
gtk_text_style_values_copy(GtkTextStyleValues *src,
GtkTextStyleValues *dest)
{
guint orig_refcount;
@ -1072,13 +1096,14 @@ gtk_text_view_style_values_copy(GtkTextStyleValues *src,
*dest = *src;
dest->font_desc = pango_font_description_copy (src->font_desc);
dest->language = g_strdup (src->language);
dest->refcount = orig_refcount;
dest->realized = FALSE;
}
void
gtk_text_view_style_values_ref(GtkTextStyleValues *values)
gtk_text_style_values_ref(GtkTextStyleValues *values)
{
g_return_if_fail(values != NULL);
@ -1086,7 +1111,7 @@ gtk_text_view_style_values_ref(GtkTextStyleValues *values)
}
void
gtk_text_view_style_values_unref(GtkTextStyleValues *values)
gtk_text_style_values_unref(GtkTextStyleValues *values)
{
g_return_if_fail(values != NULL);
g_return_if_fail(values->refcount > 0);
@ -1109,12 +1134,15 @@ gtk_text_view_style_values_unref(GtkTextStyleValues *values)
if (values->tab_array)
gtk_text_view_tab_array_unref(values->tab_array);
if (values->language)
g_free (values->language);
g_free(values);
}
}
void
gtk_text_view_style_values_realize(GtkTextStyleValues *values,
gtk_text_style_values_realize(GtkTextStyleValues *values,
GdkColormap *cmap,
GdkVisual *visual)
{
@ -1135,7 +1163,7 @@ gtk_text_view_style_values_realize(GtkTextStyleValues *values,
}
void
gtk_text_view_style_values_unrealize(GtkTextStyleValues *values,
gtk_text_style_values_unrealize(GtkTextStyleValues *values,
GdkColormap *cmap,
GdkVisual *visual)
{
@ -1157,7 +1185,7 @@ gtk_text_view_style_values_unrealize(GtkTextStyleValues *values,
}
void
gtk_text_view_style_values_fill_from_tags(GtkTextStyleValues *dest,
gtk_text_style_values_fill_from_tags(GtkTextStyleValues *dest,
GtkTextTag** tags,
guint n_tags)
{
@ -1267,6 +1295,12 @@ gtk_text_view_style_values_fill_from_tags(GtkTextStyleValues *dest,
if (tag->bg_full_height_set)
dest->bg_full_height = vals->bg_full_height;
if (tag->language_set)
{
g_free (dest->language);
dest->language = g_strdup (vals->language);
}
++n;
}
}

View File

@ -79,10 +79,10 @@ struct _GtkTextTag {
guint bg_full_height_set : 1;
guint elide_set : 1;
guint editable_set : 1;
guint language_set : 1;
guint pad1 : 1;
guint pad2 : 1;
guint pad3 : 1;
guint pad4 : 1;
};
struct _GtkTextTagClass {

View File

@ -7,7 +7,7 @@
* the defaults with settings in the given tags, which should be sorted in
* ascending order of priority
*/
void gtk_text_view_style_values_fill_from_tags (GtkTextStyleValues *values,
void gtk_text_style_values_fill_from_tags (GtkTextStyleValues *values,
GtkTextTag **tags,
guint n_tags);
void gtk_text_tag_array_sort (GtkTextTag **tag_array_p,
@ -79,6 +79,8 @@ struct _GtkTextStyleValues
* GTK_WRAPMODE_NONE, GTK_WRAPMODE_WORD
*/
gchar *language;
/* hide the text */
guint elide : 1;
@ -98,19 +100,19 @@ struct _GtkTextStyleValues
guint pad4 : 1;
};
GtkTextStyleValues *gtk_text_view_style_values_new (void);
void gtk_text_view_style_values_copy (GtkTextStyleValues *src,
GtkTextStyleValues *gtk_text_style_values_new (void);
void gtk_text_style_values_copy (GtkTextStyleValues *src,
GtkTextStyleValues *dest);
void gtk_text_view_style_values_unref (GtkTextStyleValues *values);
void gtk_text_view_style_values_ref (GtkTextStyleValues *values);
void gtk_text_style_values_unref (GtkTextStyleValues *values);
void gtk_text_style_values_ref (GtkTextStyleValues *values);
/* ensure colors are allocated, etc. for drawing */
void gtk_text_view_style_values_realize (GtkTextStyleValues *values,
void gtk_text_style_values_realize (GtkTextStyleValues *values,
GdkColormap *cmap,
GdkVisual *visual);
/* free the stuff again */
void gtk_text_view_style_values_unrealize (GtkTextStyleValues *values,
void gtk_text_style_values_unrealize (GtkTextStyleValues *values,
GdkColormap *cmap,
GdkVisual *visual);

View File

@ -2406,7 +2406,7 @@ gtk_text_view_ensure_layout (GtkTextView *text_view)
g_object_unref (G_OBJECT (ltr_context));
g_object_unref (G_OBJECT (rtl_context));
style = gtk_text_view_style_values_new ();
style = gtk_text_style_values_new ();
gtk_widget_ensure_style (widget);
gtk_text_view_set_values_from_style (text_view, style, widget->style);
@ -2421,7 +2421,7 @@ gtk_text_view_ensure_layout (GtkTextView *text_view)
gtk_text_layout_set_default_style (text_view->layout, style);
gtk_text_view_style_values_unref (style);
gtk_text_style_values_unref (style);
}
}

View File

@ -3204,7 +3204,7 @@ PangoContext *
gtk_widget_create_pango_context (GtkWidget *widget)
{
PangoContext *context;
char *lang, *p;
char *lang;
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
@ -3216,14 +3216,7 @@ gtk_widget_create_pango_context (GtkWidget *widget)
PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL);
pango_context_set_font_description (context, widget->style->font_desc);
lang = g_strdup (setlocale (LC_CTYPE, NULL));
p = strchr (lang, '.');
if (p)
*p = '\0';
p = strchr (lang, '@');
if (p)
*p = '\0';
lang = gtk_get_default_language ();
pango_context_set_lang (context, lang);
g_free (lang);