comparison src/prefs.c @ 3472:d33ec392a5e1

[gaim-migrate @ 3523] Rob McQueen went and removed all the GTK version preprocessor statements. Thanks! committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Thu, 29 Aug 2002 21:40:08 +0000
parents 7a3f16a375a5
children 0073a014e55b
comparison
equal deleted inserted replaced
3471:7fb93ecd631c 3472:d33ec392a5e1
36 #include <gtk/gtk.h> 36 #include <gtk/gtk.h>
37 #include "gtkimhtml.h" 37 #include "gtkimhtml.h"
38 #include "gaim.h" 38 #include "gaim.h"
39 #include "prpl.h" 39 #include "prpl.h"
40 #include "proxy.h" 40 #include "proxy.h"
41
42 /* xpms for gtk1.2 */
43 #if !GTK_CHECK_VERSION (1,3,0)
44 #include "pixmaps/cancel.xpm"
45 #include "pixmaps/fontface2.xpm"
46 #include "pixmaps/gnome_add.xpm"
47 #include "pixmaps/gnome_remove.xpm"
48 #include "pixmaps/gnome_preferences.xpm"
49 #include "pixmaps/bgcolor.xpm"
50 #include "pixmaps/fgcolor.xpm"
51 #include "pixmaps/save.xpm"
52 #include "pixmaps/ok.xpm"
53 #include "pixmaps/join.xpm"
54 #endif
55
56 41
57 /* temporary preferences */ 42 /* temporary preferences */
58 static guint misc_options_new; 43 static guint misc_options_new;
59 static guint logging_options_new; 44 static guint logging_options_new;
60 static guint blist_options_new; 45 static guint blist_options_new;
75 static char web_command_new[2048]; 60 static char web_command_new[2048];
76 static int fontsize_new; 61 static int fontsize_new;
77 GdkColor fgcolor_new, bgcolor_new; 62 GdkColor fgcolor_new, bgcolor_new;
78 static struct window_size conv_size_new, buddy_chat_size_new; 63 static struct window_size conv_size_new, buddy_chat_size_new;
79 char fontface_new[128]; 64 char fontface_new[128];
80 #if !GTK_CHECK_VERSION(1,3,0)
81 char fontxfld_new[256];
82 char fontfacexfld[256];
83 #endif
84 char fontface[128]; 65 char fontface[128];
85 66
86 GtkWidget *prefs_away_list = NULL; 67 GtkWidget *prefs_away_list = NULL;
87 GtkWidget *prefs_away_menu = NULL; 68 GtkWidget *prefs_away_menu = NULL;
88 GtkWidget *preftree = NULL; 69 GtkWidget *preftree = NULL;
89 GtkWidget *fontseld = NULL; 70 GtkWidget *fontseld = NULL;
90 71
91 #if GTK_CHECK_VERSION(1,3,0)
92 GtkListStore *prefs_away_store = NULL; 72 GtkListStore *prefs_away_store = NULL;
93 #endif
94 73
95 static int sound_row_sel = 0; 74 static int sound_row_sel = 0;
96 static char *last_sound_dir = NULL; 75 static char *last_sound_dir = NULL;
97 76
98 static GtkWidget *sounddialog = NULL; 77 static GtkWidget *sounddialog = NULL;
125 sound_entry = NULL; 104 sound_entry = NULL;
126 browser_entry = NULL; 105 browser_entry = NULL;
127 debugbutton=NULL; 106 debugbutton=NULL;
128 if(sounddialog) 107 if(sounddialog)
129 gtk_widget_destroy(sounddialog); 108 gtk_widget_destroy(sounddialog);
130 #if GTK_CHECK_VERSION(1,3,0)
131 g_object_unref(G_OBJECT(prefs_away_store)); 109 g_object_unref(G_OBJECT(prefs_away_store));
132 #endif
133 } 110 }
134 111
135 GtkWidget *preflabel; 112 GtkWidget *preflabel;
136 GtkWidget *prefsnotebook; 113 GtkWidget *prefsnotebook;
137 #if GTK_CHECK_VERSION(1,3,0)
138 GtkTreeStore *prefstree; 114 GtkTreeStore *prefstree;
139 #else
140 GtkWidget *prefstree;
141 #endif
142 115
143 static void set_misc_options(); 116 static void set_misc_options();
144 static void set_logging_options(); 117 static void set_logging_options();
145 static void set_blist_options(); 118 static void set_blist_options();
146 static void set_convo_options(); 119 static void set_convo_options();
232 memcpy(&fgcolor, &fgcolor_new, sizeof(GdkColor)); 205 memcpy(&fgcolor, &fgcolor_new, sizeof(GdkColor));
233 memcpy(&bgcolor, &bgcolor_new, sizeof(GdkColor)); 206 memcpy(&bgcolor, &bgcolor_new, sizeof(GdkColor));
234 207
235 208
236 g_snprintf(fontface, sizeof(fontface), fontface_new); 209 g_snprintf(fontface, sizeof(fontface), fontface_new);
237 #if !GTK_CHECK_VERSION(1,3,0)
238 g_snprintf(fontxfld, sizeof(fontxfld), fontxfld_new);
239 #endif
240 update_convo_font(); 210 update_convo_font();
241 update_convo_color(); 211 update_convo_color();
242 save_prefs(); 212 save_prefs();
243 } 213 }
244 214
265 gtk_tree_model_get_value (model, &iter, 2, &val); 235 gtk_tree_model_get_value (model, &iter, 2, &val);
266 gtk_notebook_set_current_page (GTK_NOTEBOOK (prefsnotebook), g_value_get_int (&val)); 236 gtk_notebook_set_current_page (GTK_NOTEBOOK (prefsnotebook), g_value_get_int (&val));
267 237
268 } 238 }
269 239
270
271 /* These are the pages in the preferences notebook */ 240 /* These are the pages in the preferences notebook */
272 GtkWidget *interface_page() { 241 GtkWidget *interface_page() {
273 GtkWidget *ret; 242 GtkWidget *ret;
274 GtkWidget *vbox; 243 GtkWidget *vbox;
275 ret = gtk_vbox_new(FALSE, 18); 244 ret = gtk_vbox_new(FALSE, 18);
351 select = gtk_button_new_from_stock(GTK_STOCK_SELECT_COLOR); 320 select = gtk_button_new_from_stock(GTK_STOCK_SELECT_COLOR);
352 gtk_box_pack_start(GTK_BOX(hbox), select, FALSE, FALSE, 0); 321 gtk_box_pack_start(GTK_BOX(hbox), select, FALSE, FALSE, 0);
353 pref_bg_picture = show_color_pref(hbox, FALSE); 322 pref_bg_picture = show_color_pref(hbox, FALSE);
354 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(update_color), 323 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(update_color),
355 pref_bg_picture); 324 pref_bg_picture);
325
356 if (!(font_options_new & OPT_FONT_BGCOL)) 326 if (!(font_options_new & OPT_FONT_BGCOL))
357 gtk_widget_set_sensitive(GTK_WIDGET(select), FALSE); 327 gtk_widget_set_sensitive(GTK_WIDGET(select), FALSE);
358 gtk_signal_connect(GTK_OBJECT(select), "clicked", GTK_SIGNAL_FUNC(show_bgcolor_dialog), NULL); 328 gtk_signal_connect(GTK_OBJECT(select), "clicked", GTK_SIGNAL_FUNC(show_bgcolor_dialog), NULL);
359 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive), select); 329 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive), select);
360 330
410 GtkWidget *list_page() { 380 GtkWidget *list_page() {
411 GtkWidget *ret; 381 GtkWidget *ret;
412 GtkWidget *vbox; 382 GtkWidget *vbox;
413 ret = gtk_vbox_new(FALSE, 18); 383 ret = gtk_vbox_new(FALSE, 18);
414 gtk_container_set_border_width (GTK_CONTAINER (ret), 12); 384 gtk_container_set_border_width (GTK_CONTAINER (ret), 12);
385
386 /* fixme: docklet
387 gaim_button(_("Automatically show buddy list on sign on"), &blist_options_new,
388 OPT_BLIST_APP_BUDDY_SHOW, vbox);
389 gaim_button(_("Display Buddy List near applet"), &blist_options_new, OPT_BLIST_NEAR_APPLET, vbox); */
415 390
416 vbox = make_frame (ret, _("Buttons")); 391 vbox = make_frame (ret, _("Buttons"));
417 gaim_button(_("_Hide IM/Info/Chat buttons"), &blist_options_new, OPT_BLIST_NO_BUTTONS, vbox); 392 gaim_button(_("_Hide IM/Info/Chat buttons"), &blist_options_new, OPT_BLIST_NO_BUTTONS, vbox);
418 gaim_button(_("Show _pictures on buttons"), &blist_options_new, OPT_BLIST_SHOW_BUTTON_XPM, vbox); 393 gaim_button(_("Show _pictures on buttons"), &blist_options_new, OPT_BLIST_SHOW_BUTTON_XPM, vbox);
419 394
670 label = gaim_dropdown(vbox, "_Browser", &web_browser_new, -1, 645 label = gaim_dropdown(vbox, "_Browser", &web_browser_new, -1,
671 "Netscape", BROWSER_NETSCAPE, 646 "Netscape", BROWSER_NETSCAPE,
672 "Konqueror", BROWSER_KONQ, 647 "Konqueror", BROWSER_KONQ,
673 "Mozilla", BROWSER_MOZILLA, 648 "Mozilla", BROWSER_MOZILLA,
674 "Manual", BROWSER_MANUAL, 649 "Manual", BROWSER_MANUAL,
650 /* fixme: GNOME binary helper
651 "GNOME URL Handler", BROWSER_GNOME, */
675 "Galeon", BROWSER_GALEON, 652 "Galeon", BROWSER_GALEON,
676 "Opera", BROWSER_OPERA, NULL); 653 "Opera", BROWSER_OPERA, NULL);
677 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); 654 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
678 gtk_size_group_add_widget(sg, label); 655 gtk_size_group_add_widget(sg, label);
679 656
860 837
861 gtk_widget_show_all(ret); 838 gtk_widget_show_all(ret);
862 return ret; 839 return ret;
863 } 840 }
864 841
865 #if GTK_CHECK_VERSION (1,3,0)
866 static void event_toggled (GtkCellRendererToggle *cell, gchar *pth, gpointer data) 842 static void event_toggled (GtkCellRendererToggle *cell, gchar *pth, gpointer data)
867 { 843 {
868 GtkTreeModel *model = (GtkTreeModel *)data; 844 GtkTreeModel *model = (GtkTreeModel *)data;
869 GtkTreeIter iter; 845 GtkTreeIter iter;
870 GtkTreePath *path = gtk_tree_path_new_from_string(pth); 846 GtkTreePath *path = gtk_tree_path_new_from_string(pth);
874 gtk_tree_model_get (model, &iter, 2, &soundnum, -1); 850 gtk_tree_model_get (model, &iter, 2, &soundnum, -1);
875 851
876 sound_options_new ^= sounds[soundnum].opt; 852 sound_options_new ^= sounds[soundnum].opt;
877 gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, sound_options_new & sounds[soundnum].opt, -1); 853 gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, sound_options_new & sounds[soundnum].opt, -1);
878 } 854 }
879 #endif
880 855
881 static void test_sound(GtkWidget *button, gpointer i_am_NULL) 856 static void test_sound(GtkWidget *button, gpointer i_am_NULL)
882 { 857 {
883 guint32 tmp_sound = sound_options; 858 guint32 tmp_sound = sound_options;
884 char *save_me=NULL; 859 char *save_me=NULL;
973 gtk_widget_show(sounddialog); 948 gtk_widget_show(sounddialog);
974 gdk_window_raise(sounddialog->window); 949 gdk_window_raise(sounddialog->window);
975 } 950 }
976 951
977 952
978 #if GTK_CHECK_VERSION (1,3,0)
979 static void prefs_sound_sel (GtkTreeSelection *sel, GtkTreeModel *model) { 953 static void prefs_sound_sel (GtkTreeSelection *sel, GtkTreeModel *model) {
980 GtkTreeIter iter; 954 GtkTreeIter iter;
981 GValue val = { 0, }; 955 GValue val = { 0, };
982 956
983 if (! gtk_tree_selection_get_selected (sel, &model, &iter)) 957 if (! gtk_tree_selection_get_selected (sel, &model, &iter))
988 gtk_entry_set_text(GTK_ENTRY(sound_entry), sound_file_new[sound_row_sel] ? sound_file_new[sound_row_sel] : "(default)"); 962 gtk_entry_set_text(GTK_ENTRY(sound_entry), sound_file_new[sound_row_sel] ? sound_file_new[sound_row_sel] : "(default)");
989 g_value_unset (&val); 963 g_value_unset (&val);
990 if (sounddialog) 964 if (sounddialog)
991 gtk_widget_destroy(sounddialog); 965 gtk_widget_destroy(sounddialog);
992 } 966 }
993 #endif
994 967
995 GtkWidget *sound_events_page() { 968 GtkWidget *sound_events_page() {
996 969
997 GtkWidget *ret; 970 GtkWidget *ret;
998 GtkWidget *sw; 971 GtkWidget *sw;
1074 gtk_widget_show_all (ret); 1047 gtk_widget_show_all (ret);
1075 1048
1076 return ret; 1049 return ret;
1077 } 1050 }
1078 1051
1079 #if GTK_CHECK_VERSION (1,3,0)
1080 void away_message_sel(GtkTreeSelection *sel, GtkTreeModel *model) 1052 void away_message_sel(GtkTreeSelection *sel, GtkTreeModel *model)
1081 { 1053 {
1082 GtkTreeIter iter; 1054 GtkTreeIter iter;
1083 GValue val = { 0, }; 1055 GValue val = { 0, };
1084 gchar buffer[BUF_LONG]; 1056 gchar buffer[BUF_LONG];
1118 rem_away_mess(NULL, am); 1090 rem_away_mess(NULL, am);
1119 gtk_list_store_remove(GTK_LIST_STORE(ts), &iter); 1091 gtk_list_store_remove(GTK_LIST_STORE(ts), &iter);
1120 path = gtk_tree_path_new_first(); 1092 path = gtk_tree_path_new_first();
1121 gtk_tree_selection_select_path(sel, path); 1093 gtk_tree_selection_select_path(sel, path);
1122 } 1094 }
1123
1124 #else
1125 static struct away_message *cur_message;
1126 void away_message_sel(GtkWidget *w, struct away_message *a) {
1127 gchar buffer[BUF_LONG];
1128 char *tmp;
1129
1130 cur_message = a;
1131
1132 /* Clear the Box */
1133 gtk_imhtml_clear(GTK_IMHTML(away_text));
1134
1135 /* Fill the text box with new message */
1136 strncpy(buffer, a->message, BUF_LONG);
1137 tmp = stylize(buffer, BUF_LONG);
1138
1139 debug_printf("FSD: %s\n", tmp);
1140 gtk_imhtml_append_text(GTK_IMHTML(away_text), tmp, -1, GTK_IMHTML_NO_TITLE |
1141 GTK_IMHTML_NO_COMMENTS | GTK_IMHTML_NO_SCROLL);
1142 gtk_imhtml_append_text(GTK_IMHTML(away_text), "<BR>", -1, GTK_IMHTML_NO_TITLE |
1143 GTK_IMHTML_NO_COMMENTS | GTK_IMHTML_NO_SCROLL);
1144 g_free(tmp);
1145 }
1146 void remove_away_message(GtkWidget *widget, GtkWidget *list) {
1147 GList *i;
1148 struct away_message *a;
1149
1150 i = GTK_LIST(prefs_away_list)->selection;
1151
1152 if (!i)
1153 return;
1154 if (!i->next) {
1155 gtk_imhtml_clear(GTK_IMHTML(away_text));
1156 }
1157 a = gtk_object_get_user_data(GTK_OBJECT(i->data));
1158 rem_away_mess(NULL, a);
1159 }
1160 #endif
1161 1095
1162 GtkWidget *away_message_page() { 1096 GtkWidget *away_message_page() {
1163 GtkWidget *ret; 1097 GtkWidget *ret;
1164 GtkWidget *hbox; 1098 GtkWidget *hbox;
1165 GtkWidget *button; 1099 GtkWidget *button;
1228 gtk_box_pack_start(GTK_BOX(ret), hbox, FALSE, FALSE, 0); 1162 gtk_box_pack_start(GTK_BOX(ret), hbox, FALSE, FALSE, 0);
1229 button = gtk_button_new_from_stock (GTK_STOCK_ADD); 1163 button = gtk_button_new_from_stock (GTK_STOCK_ADD);
1230 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); 1164 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1231 gtk_size_group_add_widget(sg, button); 1165 gtk_size_group_add_widget(sg, button);
1232 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(create_away_mess), NULL); 1166 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(create_away_mess), NULL);
1233 1167
1234 button = gtk_button_new_from_stock (GTK_STOCK_REMOVE); 1168 button = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
1235 gtk_size_group_add_widget(sg, button); 1169 gtk_size_group_add_widget(sg, button);
1236 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(remove_away_message), event_view); 1170 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(remove_away_message), event_view);
1237 1171
1238 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); 1172 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1173
1239 button = pixbuf_button(_("_Edit"), "edit.png"); 1174 button = pixbuf_button(_("_Edit"), "edit.png");
1240 gtk_size_group_add_widget(sg, button); 1175 gtk_size_group_add_widget(sg, button);
1241 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(create_away_mess), event_view); 1176 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(create_away_mess), event_view);
1242 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); 1177 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1243 1178
1244 gtk_widget_show_all(ret); 1179 gtk_widget_show_all(ret);
1245 return ret; 1180 return ret;
1246 } 1181 }
1247 #if GTK_CHECK_VERSION (1,3,0) 1182
1248 GtkTreeIter *prefs_notebook_add_page(char *text, 1183 GtkTreeIter *prefs_notebook_add_page(char *text,
1249 GdkPixbuf *pixbuf, 1184 GdkPixbuf *pixbuf,
1250 GtkWidget *page, 1185 GtkWidget *page,
1251 GtkTreeIter *iter, 1186 GtkTreeIter *iter,
1252 GtkTreeIter *parent, 1187 GtkTreeIter *parent,
1264 if (icon) 1199 if (icon)
1265 g_object_unref(icon); 1200 g_object_unref(icon);
1266 gtk_notebook_append_page(GTK_NOTEBOOK(prefsnotebook), page, gtk_label_new(text)); 1201 gtk_notebook_append_page(GTK_NOTEBOOK(prefsnotebook), page, gtk_label_new(text));
1267 return iter; 1202 return iter;
1268 } 1203 }
1269 #else
1270 GtkCTreeNode *prefs_notebook_add_page(char *text,
1271 GdkPixmap *pixmap,
1272 GtkWidget *page,
1273 GtkCTreeNode **iter,
1274 GtkCTreeNode **parent,
1275 int ind) {
1276
1277 GtkCTreeNode *itern;
1278 char *texts[1];
1279
1280 texts[0] = text;
1281
1282 *iter = gtk_ctree_insert_node (GTK_CTREE(prefstree), parent ? *parent : NULL, NULL, &text,
1283 0, NULL, NULL, NULL, NULL, 0, 1);
1284 gtk_ctree_node_set_row_data(GTK_CTREE(prefstree), GTK_CTREE_NODE(*iter), (void *)ind);
1285 if (pixmap)
1286 gdk_pixmap_unref(pixmap);
1287
1288 debug_printf("%s\n", texts[0]);
1289
1290 gtk_notebook_append_page(GTK_NOTEBOOK(prefsnotebook), page, gtk_label_new(text));
1291 return iter;
1292 }
1293 #endif
1294 1204
1295 void prefs_notebook_init() { 1205 void prefs_notebook_init() {
1296 int a = 0; 1206 int a = 0;
1297 #if GTK_CHECK_VERSION(1,3,0)
1298 GtkTreeIter p, c; 1207 GtkTreeIter p, c;
1299 #else
1300 GtkCTreeNode *p = NULL;
1301 GtkCTreeNode *c = NULL;
1302 #endif
1303 prefs_notebook_add_page(_("Interface"), NULL, interface_page(), &p, NULL, a++); 1208 prefs_notebook_add_page(_("Interface"), NULL, interface_page(), &p, NULL, a++);
1304 prefs_notebook_add_page(_("Fonts"), NULL, font_page(), &c, &p, a++); 1209 prefs_notebook_add_page(_("Fonts"), NULL, font_page(), &c, &p, a++);
1305 prefs_notebook_add_page(_("Message Text"), NULL, messages_page(), &c, &p, a++); 1210 prefs_notebook_add_page(_("Message Text"), NULL, messages_page(), &c, &p, a++);
1306 prefs_notebook_add_page(_("Shortcuts"), NULL, hotkeys_page(), &c, &p, a++); 1211 prefs_notebook_add_page(_("Shortcuts"), NULL, hotkeys_page(), &c, &p, a++);
1307 prefs_notebook_add_page(_("Buddy List"), NULL, list_page(), &c, &p, a++); 1212 prefs_notebook_add_page(_("Buddy List"), NULL, list_page(), &c, &p, a++);
1321 void show_prefs() 1226 void show_prefs()
1322 { 1227 {
1323 GtkWidget *vbox, *vbox2; 1228 GtkWidget *vbox, *vbox2;
1324 GtkWidget *hbox; 1229 GtkWidget *hbox;
1325 GtkWidget *frame; 1230 GtkWidget *frame;
1326 #if GTK_CHECK_VERSION (1,3,0)
1327 GtkWidget *tree_v; 1231 GtkWidget *tree_v;
1328 GtkTreeViewColumn *column; 1232 GtkTreeViewColumn *column;
1329 GtkCellRenderer *cell; 1233 GtkCellRenderer *cell;
1330 GtkTreeSelection *sel; 1234 GtkTreeSelection *sel;
1331 #endif
1332 GtkWidget *notebook; 1235 GtkWidget *notebook;
1333 GtkWidget *sep; 1236 GtkWidget *sep;
1334 GtkWidget *button; 1237 GtkWidget *button;
1335 1238
1336 int r; 1239 int r;
1337 1240
1338 if (prefs) { 1241 if (prefs) {
1339 gtk_widget_show(prefs); 1242 gtk_window_present(GTK_WINDOW(prefs));
1340 return; 1243 return;
1341 } 1244 }
1342 1245
1343 /* copy the preferences to tmp values... 1246 /* copy the preferences to tmp values...
1344 * I liked "take affect immediately" Oh well :-( */ 1247 * I liked "take affect immediately" Oh well :-( */
1362 proxytype_new = proxytype; 1265 proxytype_new = proxytype;
1363 g_snprintf(sound_cmd_new, sizeof(sound_cmd_new), "%s", sound_cmd); 1266 g_snprintf(sound_cmd_new, sizeof(sound_cmd_new), "%s", sound_cmd);
1364 g_snprintf(web_command_new, sizeof(web_command_new), "%s", 1267 g_snprintf(web_command_new, sizeof(web_command_new), "%s",
1365 web_command ? web_command : "xterm -e lynx %%s"); 1268 web_command ? web_command : "xterm -e lynx %%s");
1366 g_snprintf(fontface_new, sizeof(fontface_new), fontface); 1269 g_snprintf(fontface_new, sizeof(fontface_new), fontface);
1367 #if !GTK_CHECK_VERSION(1,3,0)
1368 g_snprintf(fontxfld_new, sizeof(fontxfld_new), fontxfld);
1369 #endif
1370 memcpy(&conv_size_new, &conv_size, sizeof(struct window_size)); 1270 memcpy(&conv_size_new, &conv_size, sizeof(struct window_size));
1371 memcpy(&buddy_chat_size_new, &buddy_chat_size, sizeof(struct window_size)); 1271 memcpy(&buddy_chat_size_new, &buddy_chat_size, sizeof(struct window_size));
1372 memcpy(&fgcolor_new, &fgcolor, sizeof(GdkColor)); 1272 memcpy(&fgcolor_new, &fgcolor, sizeof(GdkColor));
1373 memcpy(&bgcolor_new, &bgcolor, sizeof(GdkColor)); 1273 memcpy(&bgcolor_new, &bgcolor, sizeof(GdkColor));
1374 1274
1395 gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); 1295 gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
1396 gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0); 1296 gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0);
1397 gtk_widget_show (frame); 1297 gtk_widget_show (frame);
1398 1298
1399 /* The tree -- much inspired by the Gimp */ 1299 /* The tree -- much inspired by the Gimp */
1400 #if GTK_CHECK_VERSION(1,3,0)
1401 prefstree = gtk_tree_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT); 1300 prefstree = gtk_tree_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT);
1402 tree_v = gtk_tree_view_new_with_model (GTK_TREE_MODEL (prefstree)); 1301 tree_v = gtk_tree_view_new_with_model (GTK_TREE_MODEL (prefstree));
1403 gtk_container_add (GTK_CONTAINER (frame), tree_v); 1302 gtk_container_add (GTK_CONTAINER (frame), tree_v);
1404 1303
1405 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_v), FALSE); 1304 gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_v), FALSE);
1412 cell = gtk_cell_renderer_text_new (); 1311 cell = gtk_cell_renderer_text_new ();
1413 column = gtk_tree_view_column_new_with_attributes ("text", cell, "text", 1, NULL); 1312 column = gtk_tree_view_column_new_with_attributes ("text", cell, "text", 1, NULL);
1414 1313
1415 gtk_tree_view_append_column (GTK_TREE_VIEW (tree_v), column); 1314 gtk_tree_view_append_column (GTK_TREE_VIEW (tree_v), column);
1416 1315
1417 #else 1316 /* The right side */
1418 prefstree = gtk_ctree_new(1,0); 1317 frame = gtk_frame_new (NULL);
1419 gtk_ctree_set_line_style(prefstree, GTK_CTREE_LINES_NONE); 1318 gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
1420 gtk_ctree_set_expander_style(GTK_CTREE(prefstree), GTK_CTREE_EXPANDER_TRIANGLE); 1319 gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
1421 gtk_container_add(GTK_CONTAINER (frame), prefstree); 1320 gtk_widget_show (frame);
1422 gtk_widget_set_usize(prefstree, 150, -1); 1321
1423 gtk_widget_show(prefstree); 1322 vbox2 = gtk_vbox_new (FALSE, 4);
1424 #endif /* GTK_CHECK_VERSION */ 1323 gtk_container_add (GTK_CONTAINER (frame), vbox2);
1425 1324 gtk_widget_show (vbox2);
1426 /* The right side */ 1325
1427 frame = gtk_frame_new (NULL); 1326 frame = gtk_frame_new (NULL);
1428 gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); 1327 gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
1429 gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0); 1328 gtk_box_pack_start (GTK_BOX (vbox2), frame, FALSE, TRUE, 0);
1430 gtk_widget_show (frame); 1329 gtk_widget_show (frame);
1330
1331 hbox = gtk_hbox_new (FALSE, 4);
1332 gtk_container_set_border_width (GTK_CONTAINER (hbox), 4);
1333 gtk_container_add (GTK_CONTAINER (frame), hbox);
1334 gtk_widget_show (hbox);
1335
1336 preflabel = gtk_label_new(NULL);
1337 gtk_box_pack_end (GTK_BOX (hbox), preflabel, FALSE, FALSE, 0);
1338 gtk_widget_show (preflabel);
1431 1339
1432 vbox2 = gtk_vbox_new (FALSE, 4); 1340 /* The notebook */
1433 gtk_container_add (GTK_CONTAINER (frame), vbox2); 1341 prefsnotebook = notebook = gtk_notebook_new ();
1434 gtk_widget_show (vbox2); 1342 gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
1435 1343 gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
1436 frame = gtk_frame_new (NULL); 1344 gtk_box_pack_start (GTK_BOX (vbox2), notebook, FALSE, FALSE, 0);
1437 gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT); 1345
1438 gtk_box_pack_start (GTK_BOX (vbox2), frame, FALSE, TRUE, 0); 1346 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_v));
1439 gtk_widget_show (frame); 1347 g_signal_connect (G_OBJECT (sel), "changed",
1440 1348 G_CALLBACK (pref_nb_select),
1441 hbox = gtk_hbox_new (FALSE, 4); 1349 notebook);
1442 gtk_container_set_border_width (GTK_CONTAINER (hbox), 4); 1350 gtk_widget_show(notebook);
1443 gtk_container_add (GTK_CONTAINER (frame), hbox); 1351 sep = gtk_hseparator_new();
1444 gtk_widget_show (hbox); 1352 gtk_widget_show(sep);
1445 1353 gtk_box_pack_start (GTK_BOX (vbox), sep, FALSE, FALSE, 0);
1446 preflabel = gtk_label_new(NULL); 1354
1447 gtk_box_pack_end (GTK_BOX (hbox), preflabel, FALSE, FALSE, 0); 1355 /* The buttons to press! */
1448 gtk_widget_show (preflabel); 1356 hbox = gtk_hbox_new (FALSE, 6);
1449 1357 gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
1450 1358 gtk_container_add (GTK_CONTAINER(vbox), hbox);
1451 /* The notebook */ 1359 gtk_widget_show (hbox);
1452 prefsnotebook = notebook = gtk_notebook_new (); 1360
1453 gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE); 1361 button = gtk_button_new_from_stock (GTK_STOCK_OK);
1454 gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE); 1362 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(ok_cb), prefs);
1455 gtk_box_pack_start (GTK_BOX (vbox2), notebook, FALSE, FALSE, 0); 1363 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1456 1364 gtk_widget_show(button);
1457 #if GTK_CHECK_VERSION(1,3,0) 1365
1458 sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_v)); 1366 button = gtk_button_new_from_stock (GTK_STOCK_APPLY);
1459 g_signal_connect (G_OBJECT (sel), "changed", 1367 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(apply_cb), prefs);
1460 G_CALLBACK (pref_nb_select), 1368 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1461 notebook); 1369 gtk_widget_show(button);
1462 #else 1370
1463 gtk_signal_connect(GTK_OBJECT(prefstree), "tree-select-row", GTK_SIGNAL_FUNC(pref_nb_select), notebook); 1371 button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
1464 #endif 1372 gtk_signal_connect_object(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), prefs);
1465 gtk_widget_show(notebook); 1373 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1466 sep = gtk_hseparator_new(); 1374 gtk_widget_show(button);
1467 gtk_widget_show(sep); 1375
1468 gtk_box_pack_start (GTK_BOX (vbox), sep, FALSE, FALSE, 0); 1376 prefs_notebook_init();
1469 1377
1470 /* The buttons to press! */ 1378 gtk_tree_view_expand_all (GTK_TREE_VIEW(tree_v));
1471 hbox = gtk_hbox_new (FALSE, 6); 1379 gtk_widget_show(prefs);
1472 gtk_container_set_border_width (GTK_CONTAINER (hbox), 6);
1473 gtk_container_add (GTK_CONTAINER(vbox), hbox);
1474 gtk_widget_show (hbox);
1475
1476 button = gtk_button_new_from_stock (GTK_STOCK_OK);
1477 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(ok_cb), prefs);
1478 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1479 gtk_widget_show(button);
1480
1481 button = gtk_button_new_from_stock (GTK_STOCK_APPLY);
1482 gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(apply_cb), prefs);
1483 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1484 gtk_widget_show(button);
1485
1486 button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
1487 gtk_signal_connect_object(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), prefs);
1488 gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0);
1489 gtk_widget_show(button);
1490
1491 prefs_notebook_init();
1492
1493 gtk_tree_view_expand_all (GTK_TREE_VIEW(tree_v));
1494 gtk_widget_show(prefs);
1495 } 1380 }
1496 1381
1497 static gint debug_delete(GtkWidget *w, GdkEvent *event, void *dummy) 1382 static gint debug_delete(GtkWidget *w, GdkEvent *event, void *dummy)
1498 { 1383 {
1499 if (debugbutton) 1384 if (debugbutton)
1801 } 1686 }
1802 } 1687 }
1803 1688
1804 void apply_color_dlg(GtkWidget *w, gpointer d) 1689 void apply_color_dlg(GtkWidget *w, gpointer d)
1805 { 1690 {
1806 #if GTK_CHECK_VERSION(1,3,0)
1807 if ((int)d == 1) { 1691 if ((int)d == 1) {
1808 gtk_color_selection_get_current_color(GTK_COLOR_SELECTION 1692 gtk_color_selection_get_current_color(GTK_COLOR_SELECTION
1809 (GTK_COLOR_SELECTION_DIALOG(fgcseld)->colorsel), 1693 (GTK_COLOR_SELECTION_DIALOG(fgcseld)->colorsel),
1810 &fgcolor_new); 1694 &fgcolor_new);
1811 #else
1812 gdouble color[3];
1813 if ((int)d == 1) {
1814 gtk_color_selection_get_color(GTK_COLOR_SELECTION
1815 (GTK_COLOR_SELECTION_DIALOG(fgcseld)->colorsel), color);
1816
1817 fgcolor_new.red = ((guint16)(color[0] * 65535)) >> 8;
1818 fgcolor_new.green = ((guint16)(color[1] * 65535)) >> 8;
1819 fgcolor_new.blue = ((guint16)(color[2] * 65535)) >> 8;
1820 #endif
1821 destroy_colorsel(NULL, (void *)1); 1695 destroy_colorsel(NULL, (void *)1);
1822 update_color(NULL, pref_fg_picture); 1696 update_color(NULL, pref_fg_picture);
1823 } else { 1697 } else {
1824 #if GTK_CHECK_VERSION(1,3,0)
1825 gtk_color_selection_get_current_color(GTK_COLOR_SELECTION 1698 gtk_color_selection_get_current_color(GTK_COLOR_SELECTION
1826 (GTK_COLOR_SELECTION_DIALOG(bgcseld)->colorsel), 1699 (GTK_COLOR_SELECTION_DIALOG(bgcseld)->colorsel),
1827 &bgcolor_new); 1700 &bgcolor_new);
1828 #else
1829 gtk_color_selection_get_color(GTK_COLOR_SELECTION
1830 (GTK_COLOR_SELECTION_DIALOG(bgcseld)->colorsel), color);
1831
1832 bgcolor_new.red = ((guint16)(color[0] * 65535)) >> 8;
1833 bgcolor_new.green = ((guint16)(color[1] * 65535)) >> 8;
1834 bgcolor_new.blue = ((guint16)(color[2] * 65535)) >> 8;
1835 #endif
1836 destroy_colorsel(NULL, (void *)0); 1701 destroy_colorsel(NULL, (void *)0);
1837 update_color(NULL, pref_bg_picture); 1702 update_color(NULL, pref_bg_picture);
1838 } 1703 }
1839 } 1704 }
1840 1705
2050 return swid; 1915 return swid;
2051 } 1916 }
2052 void apply_font_dlg(GtkWidget *w, GtkWidget *f) 1917 void apply_font_dlg(GtkWidget *w, GtkWidget *f)
2053 { 1918 {
2054 int i = 0; 1919 int i = 0;
2055 #if !GTK_CHECK_VERSION(1,3,0)
2056 int j = 0, k = 0;
2057 #endif
2058 char *fontname; 1920 char *fontname;
2059 1921
2060 fontname = g_strdup(gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontseld))); 1922 fontname = g_strdup(gtk_font_selection_dialog_get_font_name(GTK_FONT_SELECTION_DIALOG(fontseld)));
2061 destroy_fontsel(0, 0); 1923 destroy_fontsel(0, 0);
2062 1924
2063 #if !GTK_CHECK_VERSION(1,3,0)
2064 for (i = 0; i < strlen(fontname); i++) {
2065 if (fontname[i] == '-') {
2066 if (++j > 2)
2067 break;
2068 } else if (j == 2)
2069 fontface_new[k++] = fontname[i];
2070 }
2071 fontface_new[k] = '\0';
2072 g_snprintf(fontxfld_new, sizeof(fontxfld_new), "%s", fontname);
2073 #else
2074 while(fontname[i] && !isdigit(fontname[i]) && i < sizeof(fontface_new)) { 1925 while(fontname[i] && !isdigit(fontname[i]) && i < sizeof(fontface_new)) {
2075 fontface_new[i] = fontname[i]; 1926 fontface_new[i] = fontname[i];
2076 i++; 1927 i++;
2077 } 1928 }
2078 1929
2079 #endif
2080 g_free(fontname); 1930 g_free(fontname);
2081 } 1931 }