comparison src/dialogs.c @ 666:71ea550c22ac

[gaim-migrate @ 676] la la la. i also modified how fonts work a bit to make the convo window smaller and the code more understandable. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 11 Aug 2000 03:04:29 +0000
parents 4bbc103a3294
children b77c039c9d3d
comparison
equal deleted inserted replaced
665:0bbcdd94e5b0 666:71ea550c22ac
64 #include "pixmaps/wink.xpm" 64 #include "pixmaps/wink.xpm"
65 #include "pixmaps/yell.xpm" 65 #include "pixmaps/yell.xpm"
66 66
67 #define DEFAULT_FONT_NAME "-adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1" 67 #define DEFAULT_FONT_NAME "-adobe-helvetica-medium-r-normal--12-120-75-75-p-67-iso8859-1"
68 68
69 char *fontface;
70 char *fontname;
71 int smiley_array[FACE_TOTAL]; 69 int smiley_array[FACE_TOTAL];
72 70
73 static GtkWidget *imdialog = NULL; /*I only want ONE of these :) */ 71 static GtkWidget *imdialog = NULL; /*I only want ONE of these :) */
74 static GList *dialogwindows = NULL; 72 static GList *dialogwindows = NULL;
75 static GtkWidget *exportdialog, *importdialog; 73 static GtkWidget *exportdialog, *importdialog;
2359 } 2357 }
2360 2358
2361 static void apply_color_dlg(GtkWidget *w, gpointer d) 2359 static void apply_color_dlg(GtkWidget *w, gpointer d)
2362 { 2360 {
2363 gdouble color[3]; 2361 gdouble color[3];
2362 int red, green, blue;
2364 if ((int)d == 1) { 2363 if ((int)d == 1) {
2365 gtk_color_selection_get_color(GTK_COLOR_SELECTION(fgcseld), color); 2364 gtk_color_selection_get_color(GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(fgcseld)->colorsel), color);
2366 destroy_colorsel(NULL, (void *)1); 2365 destroy_colorsel(NULL, (void *)1);
2366
2367 red = ((guint16)(color[0]*65535))>>8;
2368 green = ((guint16)(color[1]*65535))>>8;
2369 blue = ((guint16)(color[2]*65535))>>8;
2370
2371 fgcolor = ((red & 0xff) << 16) | ((green & 0xff) < 8) | (blue & 0xff);
2367 } else { 2372 } else {
2368 gtk_color_selection_get_color(GTK_COLOR_SELECTION(bgcseld), color); 2373 gtk_color_selection_get_color(GTK_COLOR_SELECTION(bgcseld), color);
2369 destroy_colorsel(NULL, (void *)2); 2374 destroy_colorsel(NULL, (void *)2);
2370 } 2375
2371 /* FIXME ! here we need to set the preferences, etc */ 2376 red = ((guint16)(color[0]*65535))>>8;
2377 green = ((guint16)(color[1]*65535))>>8;
2378 blue = ((guint16)(color[2]*65535))>>8;
2379
2380 bgcolor = ((red & 0xff) << 16) | ((green & 0xff) < 8) | (blue & 0xff);
2381 }
2372 } 2382 }
2373 2383
2374 void show_color_dialog(struct conversation *c, GtkWidget *color) 2384 void show_color_dialog(struct conversation *c, GtkWidget *color)
2375 { 2385 {
2376 GtkWidget *colorsel; 2386 GtkWidget *colorsel;
2438 void apply_font(GtkWidget *widget, GtkFontSelection *fontsel) 2448 void apply_font(GtkWidget *widget, GtkFontSelection *fontsel)
2439 { 2449 {
2440 /* this could be expanded to include font size, weight, etc. 2450 /* this could be expanded to include font size, weight, etc.
2441 but for now only works with font face */ 2451 but for now only works with font face */
2442 int i, j = 0, k = 0; 2452 int i, j = 0, k = 0;
2443 struct conversation *c = gtk_object_get_user_data(GTK_OBJECT(fontsel)); 2453 char *fontname;
2454 char font[64];
2455 struct conversation *c = gtk_object_get_user_data(GTK_OBJECT(fontsel));
2444 2456
2445 if (c) 2457 if (c)
2446 { 2458 {
2447 char *tmp = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontsel)); 2459 fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontsel));
2448 strncpy(c->current_fontname, tmp, sizeof(c->current_fontname)); 2460
2449 2461 for (i = 0; i < strlen(fontname); i++)
2450 for (i = 0; i < strlen(c->current_fontname); i++)
2451 { 2462 {
2452 if (c->current_fontname[i] == '-') 2463 if (fontname[i] == '-')
2453 { 2464 {
2454 if (++j > 2) 2465 if (++j > 2)
2455 break; 2466 break;
2456 } 2467 }
2457 else if (j == 2) 2468 else if (j == 2)
2458 c->current_fontface[k++] = c->current_fontname[i]; 2469 font[k++] = fontname[i];
2459 } 2470 }
2460 c->current_fontface[k] = '\0'; 2471 font[k] = '\0';
2461 2472
2462 sprintf(debug_buff, "Setting font face %s\n", c->current_fontface); 2473 sprintf(debug_buff, "Setting font face %s\n", font);
2463 debug_print(debug_buff); 2474 debug_print(debug_buff);
2464 2475
2465 set_font_face(NULL, c); 2476 set_font_face(font, c);
2466 } 2477 }
2467 else 2478 else
2468 { 2479 {
2469 if (fontface)
2470 g_free(fontface);
2471
2472 fontface = g_malloc(64);
2473 fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontsel)); 2480 fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontsel));
2474 2481
2475 for (i = 0; i < strlen(fontname); i++) 2482 for (i = 0; i < strlen(fontname); i++)
2476 { 2483 {
2477 if (fontname[i] == '-') 2484 if (fontname[i] == '-')
2495 fontseld = NULL; 2502 fontseld = NULL;
2496 } 2503 }
2497 2504
2498 void apply_font_dlg(GtkWidget *w, GtkWidget *f) { 2505 void apply_font_dlg(GtkWidget *w, GtkWidget *f) {
2499 int i, j = 0, k = 0; 2506 int i, j = 0, k = 0;
2500 if (fontface) 2507 char *fontname;
2501 g_free(fontface); 2508
2502
2503 fontface = g_malloc(64);
2504 fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontseld)); 2509 fontname = gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontseld));
2505 destroy_fontsel(0, 0); 2510 destroy_fontsel(0, 0);
2506 for (i = 0; i < strlen(fontname); i++) { 2511 for (i = 0; i < strlen(fontname); i++) {
2507 if (fontname[i] == '-') { 2512 if (fontname[i] == '-') {
2508 if (++j > 2) break; 2513 if (++j > 2) break;
2516 { 2521 {
2517 2522
2518 if (!font) { /* we came from the prefs dialog */ 2523 if (!font) { /* we came from the prefs dialog */
2519 if (fontseld) return; 2524 if (fontseld) return;
2520 fontseld = gtk_font_selection_dialog_new(_("Select Font")); 2525 fontseld = gtk_font_selection_dialog_new(_("Select Font"));
2521 if (fontname) 2526 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld), DEFAULT_FONT_NAME);
2522 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld), fontname);
2523 else
2524 gtk_font_selection_dialog_set_font_name(GTK_FONT_SELECTION_DIALOG(fontseld), DEFAULT_FONT_NAME);
2525 2527
2526 gtk_object_set_user_data(GTK_OBJECT(fontseld), NULL); 2528 gtk_object_set_user_data(GTK_OBJECT(fontseld), NULL);
2527 gtk_signal_connect(GTK_OBJECT(fontseld), "delete_event", GTK_SIGNAL_FUNC(destroy_fontsel), NULL); 2529 gtk_signal_connect(GTK_OBJECT(fontseld), "delete_event", GTK_SIGNAL_FUNC(destroy_fontsel), NULL);
2528 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(fontseld)->cancel_button), "clicked", GTK_SIGNAL_FUNC(destroy_fontsel), NULL); 2530 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(fontseld)->cancel_button), "clicked", GTK_SIGNAL_FUNC(destroy_fontsel), NULL);
2529 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(fontseld)->ok_button), "clicked", GTK_SIGNAL_FUNC(apply_font_dlg), NULL); 2531 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(fontseld)->ok_button), "clicked", GTK_SIGNAL_FUNC(apply_font_dlg), NULL);
2547 2549
2548 gtk_signal_connect(GTK_OBJECT(c->font_dialog), "delete_event", GTK_SIGNAL_FUNC(delete_event_dialog), c); 2550 gtk_signal_connect(GTK_OBJECT(c->font_dialog), "delete_event", GTK_SIGNAL_FUNC(delete_event_dialog), c);
2549 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(c->font_dialog)->ok_button), "clicked", GTK_SIGNAL_FUNC(apply_font), c->font_dialog); 2551 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(c->font_dialog)->ok_button), "clicked", GTK_SIGNAL_FUNC(apply_font), c->font_dialog);
2550 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(c->font_dialog)->cancel_button), "clicked", GTK_SIGNAL_FUNC(cancel_font), c); 2552 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(c->font_dialog)->cancel_button), "clicked", GTK_SIGNAL_FUNC(cancel_font), c);
2551 2553
2552 if (fontname) 2554 gtk_font_selection_dialog_set_font_name((GtkFontSelectionDialog *)c->font_dialog, DEFAULT_FONT_NAME);
2553 gtk_font_selection_dialog_set_font_name((GtkFontSelectionDialog *)c->font_dialog, fontname);
2554 else
2555 gtk_font_selection_dialog_set_font_name((GtkFontSelectionDialog *)c->font_dialog, DEFAULT_FONT_NAME);
2556 2555
2557 gtk_widget_realize(c->font_dialog); 2556 gtk_widget_realize(c->font_dialog);
2558 2557
2559 aol_icon(c->font_dialog->window); 2558 aol_icon(c->font_dialog->window);
2560 } 2559 }
2970 case (FACE_SAD): smiley_text = g_strndup(":-(", strlen(":-(")); break; 2969 case (FACE_SAD): smiley_text = g_strndup(":-(", strlen(":-(")); break;
2971 case (FACE_SCREAM): smiley_text = g_strndup("=-O", strlen("=-O")); break; 2970 case (FACE_SCREAM): smiley_text = g_strndup("=-O", strlen("=-O")); break;
2972 case (FACE_SMILE): smiley_text = g_strndup(":-)", strlen(":-)")); break; 2971 case (FACE_SMILE): smiley_text = g_strndup(":-)", strlen(":-)")); break;
2973 case (FACE_SMILE8): smiley_text = g_strndup("8-)", strlen("8-)")); break; 2972 case (FACE_SMILE8): smiley_text = g_strndup("8-)", strlen("8-)")); break;
2974 case (FACE_THINK): smiley_text = g_strndup(":-/", strlen(":-/")); break; 2973 case (FACE_THINK): smiley_text = g_strndup(":-/", strlen(":-/")); break;
2975 case (FACE_TONGUE): smiley_text = g_strndup(":-p", strlen(":-p")); break; 2974 case (FACE_TONGUE): smiley_text = g_strndup(":-P", strlen(":-p")); break;
2976 case (FACE_WINK): smiley_text = g_strndup(";-)", strlen(";-)")); break; 2975 case (FACE_WINK): smiley_text = g_strndup(";-)", strlen(";-)")); break;
2977 case (FACE_YELL): smiley_text = g_strndup(">:o", strlen(">:o")); break; 2976 case (FACE_YELL): smiley_text = g_strndup(">:o", strlen(">:o")); break;
2978 default: smiley_text = g_strndup(":-)", strlen(":-)")); break; 2977 default: smiley_text = g_strndup(":-)", strlen(":-)")); break;
2979 } 2978 }
2980 2979