| 579 } |
579 } |
| 580 if (filename) { |
580 if (filename) { |
| 581 img = gtk_image_new_from_file(filename); |
581 img = gtk_image_new_from_file(filename); |
| 582 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
582 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); |
| 583 } |
583 } |
| 584 d = gtk_dialog_new_with_buttons(NULL, NULL, GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT); |
584 d = gtk_dialog_new_with_buttons("", NULL, GTK_DIALOG_MODAL, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT); |
| 585 g_signal_connect(d, "response", G_CALLBACK(gtk_widget_destroy), NULL); |
585 g_signal_connect(d, "response", G_CALLBACK(gtk_widget_destroy), NULL); |
| 586 |
586 |
| 587 gtk_container_set_border_width (GTK_CONTAINER(d), 6); |
587 gtk_container_set_border_width (GTK_CONTAINER(d), 6); |
| 588 gtk_window_set_resizable(GTK_WINDOW(d), FALSE); |
588 gtk_window_set_resizable(GTK_WINDOW(d), FALSE); |
| 589 gtk_dialog_set_has_separator(GTK_DIALOG(d), FALSE); |
589 gtk_dialog_set_has_separator(GTK_DIALOG(d), FALSE); |
| 3204 |
3204 |
| 3205 void apply_font(GtkWidget *widget, GtkFontSelection *fontsel) |
3205 void apply_font(GtkWidget *widget, GtkFontSelection *fontsel) |
| 3206 { |
3206 { |
| 3207 /* this could be expanded to include font size, weight, etc. |
3207 /* this could be expanded to include font size, weight, etc. |
| 3208 but for now only works with font face */ |
3208 but for now only works with font face */ |
| 3209 int i, j = 0, k = 0; |
3209 int i = 0; |
| 3210 char *fontname; |
3210 char *fontname; |
| 3211 struct conversation *c = gtk_object_get_user_data(GTK_OBJECT(fontsel)); |
3211 struct conversation *c = gtk_object_get_user_data(GTK_OBJECT(fontsel)); |
| 3212 |
3212 |
| 3213 if (c) { |
3213 if (c) { |
| 3214 fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontsel)); |
3214 fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontsel)); |
| 3215 |
3215 while(fontname[i] && !isdigit(fontname[i])) { |
| |
3216 i++; |
| |
3217 } |
| |
3218 fontname[i] = 0; |
| 3216 set_font_face(fontname, c); |
3219 set_font_face(fontname, c); |
| 3217 } else { |
3220 } else { |
| 3218 fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontsel)); |
3221 fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontsel)); |
| 3219 |
3222 while(fontface[i] && !isdigit(fontname[i]) && i < sizeof(fontface)) { |
| 3220 for (i = 0; i < strlen(fontname); i++) { |
3223 fontface[i] = fontname[i]; |
| 3221 if (fontname[i] == '-') { |
3224 i++; |
| 3222 if (++j > 2) |
|
| 3223 break; |
|
| 3224 } else if (j == 2) |
|
| 3225 fontface[k++] = fontname[i]; |
|
| 3226 } |
3225 } |
| 3227 fontface[k] = '\0'; |
3226 fontface[i] = 0; |
| 3228 |
|
| 3229 g_snprintf(fontxfld, sizeof(fontxfld), "%s", fontname); |
|
| 3230 } |
3227 } |
| 3231 |
3228 |
| 3232 cancel_font(NULL, c); |
3229 cancel_font(NULL, c); |
| 3233 } |
3230 } |
| 3234 |
|
| 3235 static GtkWidget *fontseld; |
|
| 3236 |
3231 |
| 3237 void destroy_fontsel(GtkWidget *w, gpointer d) |
3232 void destroy_fontsel(GtkWidget *w, gpointer d) |
| 3238 { |
3233 { |
| 3239 gtk_widget_destroy(fontseld); |
3234 gtk_widget_destroy(fontseld); |
| 3240 fontseld = NULL; |
3235 fontseld = NULL; |
| 3241 } |
3236 } |
| 3242 |
3237 |
| 3243 void show_font_dialog(struct conversation *c, GtkWidget *font) |
3238 void show_font_dialog(struct conversation *c, GtkWidget *font) |
| 3244 { |
3239 { |
| 3245 |
3240 char fonttif[128]; |
| 3246 if (!font) { /* we came from the prefs dialog */ |
3241 if (!font) { /* we came from the prefs dialog */ |
| 3247 if (fontseld) |
3242 if (fontseld) |
| 3248 return; |
3243 return; |
| 3249 fontseld = gtk_font_selection_dialog_new(_("Select Font")); |
3244 fontseld = gtk_font_selection_dialog_new(_("Select Font")); |
| 3250 if (fontxfld[0]) { |
3245 if (fontface[0]) { |
| |
3246 g_snprintf(fonttif, sizeof(fonttif), "%s 12", fontface); |
| 3251 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld), |
3247 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld), |
| 3252 fontxfld); |
3248 fonttif); |
| 3253 } else { |
3249 } else { |
| 3254 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld), |
3250 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld), |
| 3255 DEFAULT_FONT_XFLD); |
3251 DEFAULT_FONT_FACE " 12"); |
| 3256 } |
3252 } |
| 3257 |
3253 |
| 3258 gtk_object_set_user_data(GTK_OBJECT(fontseld), NULL); |
3254 gtk_object_set_user_data(GTK_OBJECT(fontseld), NULL); |
| 3259 gtk_signal_connect(GTK_OBJECT(fontseld), "delete_event", |
3255 gtk_signal_connect(GTK_OBJECT(fontseld), "delete_event", |
| 3260 GTK_SIGNAL_FUNC(destroy_fontsel), NULL); |
3256 GTK_SIGNAL_FUNC(destroy_fontsel), NULL); |
| 3261 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(fontseld)->cancel_button), |
3257 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(fontseld)->cancel_button), |
| 3262 "clicked", GTK_SIGNAL_FUNC(destroy_fontsel), NULL); |
3258 "clicked", GTK_SIGNAL_FUNC(destroy_fontsel), NULL); |
| 3263 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(fontseld)->ok_button), "clicked", |
3259 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(fontseld)->ok_button), "clicked", |
| 3264 GTK_SIGNAL_FUNC(apply_font_dlg), NULL); |
3260 GTK_SIGNAL_FUNC(apply_font_dlg), fontseld); |
| 3265 gtk_widget_realize(fontseld); |
3261 gtk_widget_realize(fontseld); |
| 3266 aol_icon(fontseld->window); |
3262 aol_icon(fontseld->window); |
| 3267 gtk_widget_show(fontseld); |
3263 gtk_widget_show(fontseld); |
| 3268 gdk_window_raise(fontseld->window); |
3264 gdk_window_raise(fontseld->window); |
| 3269 return; |
3265 return; |
| 3275 if (font) |
3271 if (font) |
| 3276 gtk_object_set_user_data(GTK_OBJECT(c->font_dialog), c); |
3272 gtk_object_set_user_data(GTK_OBJECT(c->font_dialog), c); |
| 3277 else |
3273 else |
| 3278 gtk_object_set_user_data(GTK_OBJECT(c->font_dialog), NULL); |
3274 gtk_object_set_user_data(GTK_OBJECT(c->font_dialog), NULL); |
| 3279 |
3275 |
| 3280 if (c->fontxfld[0]) { |
3276 if (c->fontface[0]) { |
| |
3277 g_snprintf(fonttif, sizeof(fonttif), "%s 12", c->fontface); |
| 3281 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(c->font_dialog), |
3278 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(c->font_dialog), |
| 3282 c->fontxfld); |
3279 fonttif); |
| 3283 } else { |
3280 } else { |
| 3284 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(c->font_dialog), |
3281 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(c->font_dialog), |
| 3285 DEFAULT_FONT_XFLD); |
3282 DEFAULT_FONT_FACE); |
| 3286 } |
3283 } |
| 3287 |
3284 |
| 3288 gtk_signal_connect(GTK_OBJECT(c->font_dialog), "delete_event", |
3285 gtk_signal_connect(GTK_OBJECT(c->font_dialog), "delete_event", |
| 3289 GTK_SIGNAL_FUNC(delete_event_dialog), c); |
3286 GTK_SIGNAL_FUNC(delete_event_dialog), c); |
| 3290 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(c->font_dialog)->ok_button), |
3287 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(c->font_dialog)->ok_button), |