Mercurial > pidgin.yaz
comparison src/gtkimhtml.c @ 10525:ddea15f4cbc2
[gaim-migrate @ 11842]
Kevin and Tim both pointed out that I'd missed some of the zoom stuff, so this should be the rest of it.
committer: Tailor Script <tailor@pidgin.im>
author | Etan Reisner <pidgin@unreliablesource.net> |
---|---|
date | Tue, 18 Jan 2005 15:36:39 +0000 |
parents | 98daaf2f3209 |
children | 55e7d72fc09a |
comparison
equal
deleted
inserted
replaced
10524:98daaf2f3209 | 10525:ddea15f4cbc2 |
---|---|
1063 imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2); | 1063 imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2); |
1064 imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); | 1064 imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); |
1065 imhtml->text_cursor = gdk_cursor_new (GDK_XTERM); | 1065 imhtml->text_cursor = gdk_cursor_new (GDK_XTERM); |
1066 | 1066 |
1067 imhtml->show_comments = TRUE; | 1067 imhtml->show_comments = TRUE; |
1068 | |
1069 imhtml->zoom = 1.0; | |
1070 imhtml->original_fsize = 0; | |
1071 | 1068 |
1072 imhtml->smiley_data = g_hash_table_new_full(g_str_hash, g_str_equal, | 1069 imhtml->smiley_data = g_hash_table_new_full(g_str_hash, g_str_equal, |
1073 g_free, (GDestroyNotify)gtk_smiley_tree_destroy); | 1070 g_free, (GDestroyNotify)gtk_smiley_tree_destroy); |
1074 imhtml->default_smilies = gtk_smiley_tree_new(); | 1071 imhtml->default_smilies = gtk_smiley_tree_new(); |
1075 | 1072 |
3146 tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "family", face, NULL); | 3143 tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "family", face, NULL); |
3147 | 3144 |
3148 return tag; | 3145 return tag; |
3149 } | 3146 } |
3150 | 3147 |
3151 static void _init_original_fsize(GtkIMHtml *imhtml) | |
3152 { | |
3153 GtkTextAttributes *attr; | |
3154 attr = gtk_text_view_get_default_attributes(GTK_TEXT_VIEW(imhtml)); | |
3155 imhtml->original_fsize = pango_font_description_get_size(attr->font); | |
3156 gtk_text_attributes_unref(attr); | |
3157 } | |
3158 | |
3159 static void _recalculate_font_sizes(GtkTextTag *tag, gpointer imhtml) | |
3160 { | |
3161 if (strncmp(tag->name, "FONT SIZE ", 10) == 0) { | |
3162 int size; | |
3163 | |
3164 size = strtol(tag->name + 10, NULL, 10); | |
3165 g_object_set(G_OBJECT(tag), "size", | |
3166 (gint) (GTK_IMHTML(imhtml)->original_fsize * | |
3167 ((double) _point_sizes[size-1] * GTK_IMHTML(imhtml)->zoom)), NULL); | |
3168 } | |
3169 | |
3170 | |
3171 } | |
3172 | |
3173 static GtkTextTag *find_font_size_tag(GtkIMHtml *imhtml, int size) | 3148 static GtkTextTag *find_font_size_tag(GtkIMHtml *imhtml, int size) |
3174 { | 3149 { |
3175 gchar str[24]; | 3150 gchar str[24]; |
3176 GtkTextTag *tag; | 3151 GtkTextTag *tag; |
3177 | 3152 |
3178 if (!imhtml->original_fsize) | |
3179 _init_original_fsize(imhtml); | |
3180 | |
3181 g_snprintf(str, sizeof(str), "FONT SIZE %d", size); | 3153 g_snprintf(str, sizeof(str), "FONT SIZE %d", size); |
3182 str[23] = '\0'; | 3154 str[23] = '\0'; |
3183 | 3155 |
3184 tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | 3156 tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); |
3185 if (!tag) { | 3157 if (!tag) { |
3186 /* For reasons I don't understand, setting "scale" here scaled based on some default | 3158 /* For reasons I don't understand, setting "scale" here scaled |
3187 * size other than my theme's default size. Our size 4 was actually smaller than | 3159 * based on some default size other than my theme's default |
3188 * our size 3 for me. So this works around that oddity. | 3160 * size. Our size 4 was actually smaller than our size 3 for |
3161 * me. So this works around that oddity. | |
3189 */ | 3162 */ |
3163 GtkTextAttributes *attr = gtk_text_view_get_default_attributes(GTK_TEXT_VIEW(imhtml)); | |
3190 tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "size", | 3164 tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "size", |
3191 (gint) (imhtml->original_fsize * | 3165 (gint) (pango_font_description_get_size(attr->font) * |
3192 ((double) _point_sizes[size-1] * imhtml->zoom)), NULL); | 3166 (double) _point_sizes[size-1]), NULL); |
3167 gtk_text_attributes_unref(attr); | |
3193 } | 3168 } |
3194 | 3169 |
3195 return tag; | 3170 return tag; |
3196 } | 3171 } |
3197 | 3172 |