Mercurial > pidgin
comparison src/dialogs.c @ 234:985635758c33
[gaim-migrate @ 244]
More patches from fflew. This adds a font selector to the conversation window,
among other things.
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Tue, 16 May 2000 20:48:47 +0000 |
| parents | 4a638177f917 |
| children | 62d470738cc7 |
comparison
equal
deleted
inserted
replaced
| 233:b8c5efaef154 | 234:985635758c33 |
|---|---|
| 282 if (dest == colordialog) | 282 if (dest == colordialog) |
| 283 colordialog = NULL; | 283 colordialog = NULL; |
| 284 | 284 |
| 285 if (dest == linkdialog) | 285 if (dest == linkdialog) |
| 286 linkdialog = NULL; | 286 linkdialog = NULL; |
| 287 | |
| 288 if (dest == fontdialog) | |
| 289 fontdialog = NULL; | |
| 287 | 290 |
| 288 dialogwindows = g_list_remove(dialogwindows, dest); | 291 dialogwindows = g_list_remove(dialogwindows, dest); |
| 289 gtk_widget_destroy(dest); | 292 gtk_widget_destroy(dest); |
| 290 | 293 |
| 291 } | 294 } |
| 332 if (logdialog) { | 335 if (logdialog) { |
| 333 destroy_dialog(NULL, logdialog); | 336 destroy_dialog(NULL, logdialog); |
| 334 logdialog = NULL; | 337 logdialog = NULL; |
| 335 } | 338 } |
| 336 | 339 |
| 340 if (fontdialog) { | |
| 341 destroy_dialog(NULL, fontdialog); | |
| 342 fontdialog = NULL; | |
| 343 } | |
| 337 } | 344 } |
| 338 | 345 |
| 339 static void do_warn(GtkWidget *widget, struct warning *w) | 346 static void do_warn(GtkWidget *widget, struct warning *w) |
| 340 { | 347 { |
| 341 serv_warn(w->who, (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w->anon))) ? | 348 serv_warn(w->who, (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w->anon))) ? |
| 1941 | 1948 |
| 1942 /*------------------------------------------------------------------------*/ | 1949 /*------------------------------------------------------------------------*/ |
| 1943 /* Font Selection Dialog */ | 1950 /* Font Selection Dialog */ |
| 1944 /*------------------------------------------------------------------------*/ | 1951 /*------------------------------------------------------------------------*/ |
| 1945 | 1952 |
| 1946 void cancel_font(GtkWidget *widget, GtkWidget *font) | 1953 void cancel_font(GtkWidget *widget, GtkWidget *window) |
| 1947 { | 1954 { |
| 1948 if (font) | |
| 1949 { | |
| 1950 set_state_lock(1); | |
| 1951 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(font), FALSE); | |
| 1952 set_state_lock(0); | |
| 1953 } | |
| 1954 | |
| 1955 destroy_dialog(NULL, fontdialog); | 1955 destroy_dialog(NULL, fontdialog); |
| 1956 } | 1956 } |
| 1957 | 1957 |
| 1958 void apply_font(GtkWidget *widget, GtkFontSelection *fontsel) | 1958 void apply_font(GtkWidget *widget, GtkFontSelection *fontsel) |
| 1959 { | 1959 { |
| 1960 /* this could be expanded to include font size, weight, etc. | 1960 /* this could be expanded to include font size, weight, etc. |
| 1961 but for now only works with font face */ | 1961 but for now only works with font face */ |
| 1962 int i, j = 0, k = 0; | 1962 int i, j = 0, k = 0; |
| 1963 | 1963 struct conversation *c = gtk_object_get_user_data(GTK_OBJECT(fontsel)); |
| 1964 fontface = g_malloc(64); | 1964 |
| 1965 fontname = gtk_font_selection_get_font_name(fontsel); | 1965 if (c) |
| 1966 | |
| 1967 for (i = 0; i < strlen(fontname); i++) | |
| 1968 { | 1966 { |
| 1969 if (fontname[i] == '-') | 1967 g_free(c->current_fontname); |
| 1968 g_free(c->current_fontface); | |
| 1969 c->current_fontface = g_malloc(64); | |
| 1970 c->current_fontname = gtk_font_selection_get_font_name(fontsel); | |
| 1971 | |
| 1972 for (i = 0; i < strlen(c->current_fontname); i++) | |
| 1970 { | 1973 { |
| 1971 if (++j > 2) | 1974 if (c->current_fontname[i] == '-') |
| 1972 break; | 1975 { |
| 1973 } | 1976 if (++j > 2) |
| 1974 else if (j == 2) | 1977 break; |
| 1975 fontface[k++] = fontname[i]; | 1978 } |
| 1976 } | 1979 else if (j == 2) |
| 1977 fontface[k] = '\0'; | 1980 c->current_fontface[k++] = c->current_fontname[i]; |
| 1978 | 1981 } |
| 1979 save_prefs(); | 1982 c->current_fontface[k] = '\0'; |
| 1980 | 1983 |
| 1981 cancel_font(widget, NULL); | 1984 set_font_face(NULL, c); |
| 1985 } | |
| 1986 else | |
| 1987 { | |
| 1988 if (fontface) | |
| 1989 g_free(fontface); | |
| 1990 | |
| 1991 fontface = g_malloc(64); | |
| 1992 fontname = gtk_font_selection_get_font_name(fontsel); | |
| 1993 | |
| 1994 for (i = 0; i < strlen(fontname); i++) | |
| 1995 { | |
| 1996 if (fontname[i] == '-') | |
| 1997 { | |
| 1998 if (++j > 2) | |
| 1999 break; | |
| 2000 } | |
| 2001 else if (j == 2) | |
| 2002 fontface[k++] = fontname[i]; | |
| 2003 } | |
| 2004 fontface[k] = '\0'; | |
| 2005 | |
| 2006 save_prefs(); | |
| 2007 } | |
| 2008 | |
| 2009 cancel_font(widget, NULL); | |
| 1982 } | 2010 } |
| 1983 | 2011 |
| 1984 void show_font_dialog(GtkWidget *widget, GtkWidget *font) | 2012 void show_font_dialog(GtkWidget *widget, GtkWidget *font) |
| 1985 { | 2013 { |
| 1986 GtkWidget *fontsel; | 2014 GtkWidget *fontsel; |
| 1987 | 2015 |
| 1988 fontdialog = gtk_font_selection_dialog_new("Select Font"); | 2016 fontdialog = gtk_font_selection_dialog_new("Select Font"); |
| 1989 fontsel = GTK_FONT_SELECTION_DIALOG(fontdialog)->fontsel; | 2017 fontsel = GTK_FONT_SELECTION_DIALOG(fontdialog)->fontsel; |
| 1990 | 2018 |
| 2019 if (font) | |
| 2020 gtk_object_set_user_data(GTK_OBJECT(fontsel), gtk_object_get_user_data(GTK_OBJECT(font))); | |
| 2021 else | |
| 2022 gtk_object_set_user_data(GTK_OBJECT(fontsel), NULL); | |
| 2023 | |
| 1991 gtk_font_selection_dialog_set_font_name((GtkFontSelectionDialog *)fontdialog, DEFAULT_FONT_NAME); | 2024 gtk_font_selection_dialog_set_font_name((GtkFontSelectionDialog *)fontdialog, DEFAULT_FONT_NAME); |
| 1992 gtk_window_set_modal(GTK_WINDOW(fontdialog), TRUE); | 2025 gtk_window_set_modal(GTK_WINDOW(fontdialog), TRUE); |
| 1993 gtk_signal_connect(GTK_OBJECT(fontdialog), "delete_event", GTK_SIGNAL_FUNC(cancel_font), font); | 2026 gtk_signal_connect(GTK_OBJECT(fontdialog), "delete_event", GTK_SIGNAL_FUNC(cancel_font), font); |
| 1994 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(fontdialog)->ok_button), "clicked", GTK_SIGNAL_FUNC(apply_font), fontsel); | 2027 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(fontdialog)->ok_button), "clicked", GTK_SIGNAL_FUNC(apply_font), fontsel); |
| 1995 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(fontdialog)->cancel_button), "clicked", GTK_SIGNAL_FUNC(cancel_font), font); | 2028 gtk_signal_connect(GTK_OBJECT(GTK_FONT_SELECTION_DIALOG(fontdialog)->cancel_button), "clicked", GTK_SIGNAL_FUNC(cancel_font), font); |
