comparison src/dialogs.c @ 2986:1c6a3516e1ff

[gaim-migrate @ 2999] Funky :) Editable buddy pouncen committer: Tailor Script <tailor@pidgin.im>
author Rob Flynn <gaim@robflynn.com>
date Sat, 23 Feb 2002 23:41:50 +0000
parents 626729653436
children 7239a392486c
comparison
equal deleted inserted replaced
2985:32c78c57b351 2986:1c6a3516e1ff
152 GtkWidget *menu; 152 GtkWidget *menu;
153 GtkWidget *sound; 153 GtkWidget *sound;
154 GtkWidget *soundentry; 154 GtkWidget *soundentry;
155 155
156 struct aim_user *user; 156 struct aim_user *user;
157 struct buddy_pounce *buddy_pounce;
157 }; 158 };
158 159
159 struct findbyemail { 160 struct findbyemail {
160 GtkWidget *window; 161 GtkWidget *window;
161 GtkWidget *emailentry; 162 GtkWidget *emailentry;
1075 /*------------------------------------------------------------------------*/ 1076 /*------------------------------------------------------------------------*/
1076 1077
1077 1078
1078 void do_new_bp(GtkWidget *w, struct addbp *b) 1079 void do_new_bp(GtkWidget *w, struct addbp *b)
1079 { 1080 {
1080 struct buddy_pounce *bp = g_new0(struct buddy_pounce, 1); 1081 struct buddy_pounce *bp;
1081 1082
1082 if (strlen(gtk_entry_get_text(GTK_ENTRY(b->nameentry))) == 0) { 1083 if (strlen(gtk_entry_get_text(GTK_ENTRY(b->nameentry))) == 0) {
1083 do_error_dialog(_("Please enter a buddy to pounce."), _("Buddy Pounce Error")); 1084 do_error_dialog(_("Please enter a buddy to pounce."), _("Buddy Pounce Error"));
1084 g_free(bp);
1085 return; 1085 return;
1086 } 1086 }
1087 1087
1088 if(!b->buddy_pounce)
1089 bp = g_new0(struct buddy_pounce, 1);
1090 else
1091 bp = b->buddy_pounce;
1092
1093
1088 g_snprintf(bp->name, 80, "%s", gtk_entry_get_text(GTK_ENTRY(b->nameentry))); 1094 g_snprintf(bp->name, 80, "%s", gtk_entry_get_text(GTK_ENTRY(b->nameentry)));
1089 g_snprintf(bp->message, 2048, "%s", gtk_entry_get_text(GTK_ENTRY(b->messentry))); 1095 g_snprintf(bp->message, 2048, "%s", gtk_entry_get_text(GTK_ENTRY(b->messentry)));
1090 g_snprintf(bp->command, 2048, "%s", gtk_entry_get_text(GTK_ENTRY(b->commentry))); 1096 g_snprintf(bp->command, 2048, "%s", gtk_entry_get_text(GTK_ENTRY(b->commentry)));
1091 g_snprintf(bp->sound, 2048, "%s", gtk_entry_get_text(GTK_ENTRY(b->soundentry))); 1097 g_snprintf(bp->sound, 2048, "%s", gtk_entry_get_text(GTK_ENTRY(b->soundentry)));
1092 g_snprintf(bp->pouncer, 80, "%s", b->user->username); 1098 g_snprintf(bp->pouncer, 80, "%s", b->user->username);
1120 bp->options |= OPT_POUNCE_UNIDLE; 1126 bp->options |= OPT_POUNCE_UNIDLE;
1121 1127
1122 if (GTK_TOGGLE_BUTTON(b->save)->active) 1128 if (GTK_TOGGLE_BUTTON(b->save)->active)
1123 bp->options |= OPT_POUNCE_SAVE; 1129 bp->options |= OPT_POUNCE_SAVE;
1124 1130
1125 buddy_pounces = g_list_append(buddy_pounces, bp); 1131 if(!b->buddy_pounce)
1132 buddy_pounces = g_list_append(buddy_pounces, bp);
1126 1133
1127 do_bp_menu(); 1134 do_bp_menu();
1128 1135
1129 destroy_dialog(NULL, b->window); 1136 destroy_dialog(NULL, b->window);
1130 1137
1177 1184
1178 return optmenu; 1185 return optmenu;
1179 } 1186 }
1180 1187
1181 1188
1182 void show_new_bp(char *name, struct gaim_connection *gc, int idle, int away) 1189 void show_new_bp(char *name, struct gaim_connection *gc, int idle, int away, struct buddy_pounce *edit_bp)
1183 { 1190 {
1184 GtkWidget *label; 1191 GtkWidget *label;
1185 GtkWidget *bbox; 1192 GtkWidget *bbox;
1186 GtkWidget *vbox; 1193 GtkWidget *vbox;
1187 GtkWidget *button; 1194 GtkWidget *button;
1188 GtkWidget *frame; 1195 GtkWidget *frame;
1189 GtkWidget *table; 1196 GtkWidget *table;
1190 GtkWidget *optmenu; 1197 GtkWidget *optmenu;
1191 1198
1192 struct addbp *b = g_new0(struct addbp, 1); 1199 struct addbp *b = g_new0(struct addbp, 1);
1193 b->user = gc ? gc->user : aim_users->data; 1200
1201 if(edit_bp) {
1202 b->buddy_pounce = edit_bp;
1203 b->user = find_user(edit_bp->pouncer, edit_bp->protocol);
1204 } else {
1205 b->user = gc ? gc->user : aim_users->data;
1206 b->buddy_pounce = NULL;
1207 }
1194 1208
1195 GAIM_DIALOG(b->window); 1209 GAIM_DIALOG(b->window);
1196 dialogwindows = g_list_prepend(dialogwindows, b->window); 1210 dialogwindows = g_list_prepend(dialogwindows, b->window);
1197 gtk_window_set_policy(GTK_WINDOW(b->window), FALSE, TRUE, TRUE); 1211 gtk_window_set_policy(GTK_WINDOW(b->window), FALSE, TRUE, TRUE);
1198 gtk_window_set_wmclass(GTK_WINDOW(b->window), "new_bp", "Gaim"); 1212 gtk_window_set_wmclass(GTK_WINDOW(b->window), "new_bp", "Gaim");
1234 1248
1235 b->nameentry = gtk_entry_new(); 1249 b->nameentry = gtk_entry_new();
1236 gtk_table_attach(GTK_TABLE(table), b->nameentry, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 0); 1250 gtk_table_attach(GTK_TABLE(table), b->nameentry, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
1237 if (name !=NULL) 1251 if (name !=NULL)
1238 gtk_entry_set_text(GTK_ENTRY(b->nameentry), name); 1252 gtk_entry_set_text(GTK_ENTRY(b->nameentry), name);
1253 else if(edit_bp)
1254 gtk_entry_set_text(GTK_ENTRY(b->nameentry), edit_bp->name);
1239 gtk_window_set_focus(GTK_WINDOW(b->window), b->nameentry); 1255 gtk_window_set_focus(GTK_WINDOW(b->window), b->nameentry);
1240 gtk_widget_show(b->nameentry); 1256 gtk_widget_show(b->nameentry);
1241 /* </pounce type="who"> */ 1257 /* </pounce type="who"> */
1242 1258
1243 1259
1251 gtk_container_set_border_width(GTK_CONTAINER(table), 5); 1267 gtk_container_set_border_width(GTK_CONTAINER(table), 5);
1252 gtk_table_set_col_spacings(GTK_TABLE(table), 5); 1268 gtk_table_set_col_spacings(GTK_TABLE(table), 5);
1253 gtk_widget_show(table); 1269 gtk_widget_show(table);
1254 1270
1255 b->p_signon = gtk_check_button_new_with_label(_("Pounce on sign on")); 1271 b->p_signon = gtk_check_button_new_with_label(_("Pounce on sign on"));
1256 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_signon), TRUE); 1272 if(edit_bp)
1273 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_signon),
1274 (edit_bp->options & OPT_POUNCE_SIGNON) ? TRUE : FALSE);
1275 else
1276 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_signon), TRUE);
1257 gtk_table_attach(GTK_TABLE(table), b->p_signon, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); 1277 gtk_table_attach(GTK_TABLE(table), b->p_signon, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
1258 gtk_widget_show(b->p_signon); 1278 gtk_widget_show(b->p_signon);
1259 1279
1260 b->p_unaway = gtk_check_button_new_with_label(_("Pounce on return from away")); 1280 b->p_unaway = gtk_check_button_new_with_label(_("Pounce on return from away"));
1261 if (away) 1281 if (away)
1262 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_unaway), TRUE); 1282 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_unaway), TRUE);
1283 else if(edit_bp)
1284 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_unaway),
1285 (edit_bp->options & OPT_POUNCE_UNAWAY) ? TRUE : FALSE);
1263 gtk_table_attach(GTK_TABLE(table), b->p_unaway, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0); 1286 gtk_table_attach(GTK_TABLE(table), b->p_unaway, 1, 2, 0, 1, GTK_FILL | GTK_EXPAND, 0, 0, 0);
1264 gtk_widget_show(b->p_unaway); 1287 gtk_widget_show(b->p_unaway);
1265 1288
1266 b->p_unidle = gtk_check_button_new_with_label(_("Pounce on return from idle")); 1289 b->p_unidle = gtk_check_button_new_with_label(_("Pounce on return from idle"));
1267 if (idle) 1290 if (idle)
1268 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_unidle), TRUE); 1291 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_unidle), TRUE);
1292 else if(edit_bp)
1293 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->p_unidle),
1294 (edit_bp->options & OPT_POUNCE_UNIDLE) ? TRUE : FALSE);
1269 gtk_table_attach(GTK_TABLE(table), b->p_unidle, 0, 1, 1, 2, GTK_FILL, 0, 0, 0); 1295 gtk_table_attach(GTK_TABLE(table), b->p_unidle, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
1270 gtk_widget_show(b->p_unidle); 1296 gtk_widget_show(b->p_unidle);
1271 1297
1272 label = gtk_label_new(NULL); 1298 label = gtk_label_new(NULL);
1273 gtk_table_attach(GTK_TABLE(table), label, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 0); 1299 gtk_table_attach(GTK_TABLE(table), label, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
1285 gtk_table_set_col_spacings(GTK_TABLE(table), 5); 1311 gtk_table_set_col_spacings(GTK_TABLE(table), 5);
1286 gtk_table_set_row_spacings(GTK_TABLE(table), 5); 1312 gtk_table_set_row_spacings(GTK_TABLE(table), 5);
1287 gtk_widget_show(table); 1313 gtk_widget_show(table);
1288 1314
1289 b->openwindow = gtk_check_button_new_with_label(_("Open IM Window")); 1315 b->openwindow = gtk_check_button_new_with_label(_("Open IM Window"));
1290 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->openwindow), FALSE); 1316 if(edit_bp)
1317 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->openwindow),
1318 (edit_bp->options & OPT_POUNCE_POPUP) ? TRUE : FALSE);
1319 else
1320 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->openwindow), FALSE);
1291 gtk_table_attach(GTK_TABLE(table), b->openwindow, 0, 1, 0, 1, GTK_FILL, 0, 0, 0); 1321 gtk_table_attach(GTK_TABLE(table), b->openwindow, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
1292 gtk_widget_show(b->openwindow); 1322 gtk_widget_show(b->openwindow);
1293 1323
1294 b->popupnotify = gtk_check_button_new_with_label(_("Popup Notification")); 1324 b->popupnotify = gtk_check_button_new_with_label(_("Popup Notification"));
1295 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->popupnotify), FALSE); 1325 if(edit_bp)
1326 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->popupnotify),
1327 (edit_bp->options & OPT_POUNCE_NOTIFY) ? TRUE : FALSE);
1328 else
1329 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->popupnotify), FALSE);
1296 gtk_table_attach(GTK_TABLE(table), b->popupnotify, 1, 2, 0, 1, GTK_FILL, 0, 0, 0); 1330 gtk_table_attach(GTK_TABLE(table), b->popupnotify, 1, 2, 0, 1, GTK_FILL, 0, 0, 0);
1297 gtk_widget_show(b->popupnotify); 1331 gtk_widget_show(b->popupnotify);
1298 1332
1299 b->sendim = gtk_check_button_new_with_label(_("Send Message")); 1333 b->sendim = gtk_check_button_new_with_label(_("Send Message"));
1300 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->sendim), TRUE); 1334 if(edit_bp)
1335 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->sendim),
1336 (edit_bp->options & OPT_POUNCE_SEND_IM) ? TRUE : FALSE);
1337 else
1338 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->sendim), TRUE);
1301 gtk_table_attach(GTK_TABLE(table), b->sendim, 0, 1, 1, 2, GTK_FILL, 0, 0, 0); 1339 gtk_table_attach(GTK_TABLE(table), b->sendim, 0, 1, 1, 2, GTK_FILL, 0, 0, 0);
1302 gtk_widget_show(b->sendim); 1340 gtk_widget_show(b->sendim);
1303 1341
1304 b->messentry = gtk_entry_new(); 1342 b->messentry = gtk_entry_new();
1305 gtk_table_attach(GTK_TABLE(table), b->messentry, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 0); 1343 gtk_table_attach(GTK_TABLE(table), b->messentry, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, 0, 0, 0);
1306 gtk_signal_connect(GTK_OBJECT(b->messentry), "activate", GTK_SIGNAL_FUNC(do_new_bp), b); 1344 gtk_signal_connect(GTK_OBJECT(b->messentry), "activate", GTK_SIGNAL_FUNC(do_new_bp), b);
1345 if(edit_bp) {
1346 gtk_widget_set_sensitive(GTK_WIDGET(b->messentry),
1347 (edit_bp->options & OPT_POUNCE_SEND_IM) ? TRUE : FALSE);
1348 gtk_entry_set_text(GTK_ENTRY(b->messentry), edit_bp->message);
1349 }
1307 gtk_widget_show(b->messentry); 1350 gtk_widget_show(b->messentry);
1308 1351
1309 gtk_signal_connect(GTK_OBJECT(b->sendim), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive), 1352 gtk_signal_connect(GTK_OBJECT(b->sendim), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive), b->messentry);
1310 b->messentry);
1311 1353
1312 b->command = gtk_check_button_new_with_label(_("Execute command on pounce")); 1354 b->command = gtk_check_button_new_with_label(_("Execute command on pounce"));
1313 gtk_table_attach(GTK_TABLE(table), b->command, 0, 1, 2, 3, GTK_FILL, 0, 0, 0); 1355 gtk_table_attach(GTK_TABLE(table), b->command, 0, 1, 2, 3, GTK_FILL, 0, 0, 0);
1356 if(edit_bp)
1357 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->command),
1358 (edit_bp->options & OPT_POUNCE_COMMAND) ? TRUE : FALSE);
1359 else
1360 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->command), FALSE);
1314 gtk_widget_show(b->command); 1361 gtk_widget_show(b->command);
1315 1362
1316 b->commentry = gtk_entry_new(); 1363 b->commentry = gtk_entry_new();
1317 gtk_table_attach(GTK_TABLE(table), b->commentry, 1, 2, 2, 3, GTK_FILL | GTK_EXPAND, 0, 0, 0); 1364 gtk_table_attach(GTK_TABLE(table), b->commentry, 1, 2, 2, 3, GTK_FILL | GTK_EXPAND, 0, 0, 0);
1318 gtk_signal_connect(GTK_OBJECT(b->commentry), "activate", GTK_SIGNAL_FUNC(do_new_bp), b); 1365 gtk_signal_connect(GTK_OBJECT(b->commentry), "activate", GTK_SIGNAL_FUNC(do_new_bp), b);
1366 if(edit_bp) {
1367 gtk_widget_set_sensitive(GTK_WIDGET(b->commentry),
1368 (edit_bp->options & OPT_POUNCE_COMMAND) ? TRUE : FALSE);
1369 gtk_entry_set_text(GTK_ENTRY(b->commentry), edit_bp->command);
1370 }
1371 else
1372 gtk_widget_set_sensitive(GTK_WIDGET(b->commentry), FALSE);
1319 gtk_widget_show(b->commentry); 1373 gtk_widget_show(b->commentry);
1320 1374 gtk_signal_connect(GTK_OBJECT(b->command), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive), b->commentry);
1321 gtk_widget_set_sensitive(b->commentry, FALSE); 1375
1322 gtk_signal_connect(GTK_OBJECT(b->command), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive),
1323 b->commentry);
1324
1325 b->sound = gtk_check_button_new_with_label(_("Play sound on pounce")); 1376 b->sound = gtk_check_button_new_with_label(_("Play sound on pounce"));
1326 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->sound), FALSE); 1377 if(edit_bp)
1378 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->sound),
1379 (edit_bp->options & OPT_POUNCE_SOUND) ? TRUE : FALSE);
1380 else
1381 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->sound), FALSE);
1327 gtk_table_attach(GTK_TABLE(table), b->sound, 0, 1, 3, 4, GTK_FILL, 0, 0, 0); 1382 gtk_table_attach(GTK_TABLE(table), b->sound, 0, 1, 3, 4, GTK_FILL, 0, 0, 0);
1328 gtk_widget_show(b->sound); 1383 gtk_widget_show(b->sound);
1329 1384
1330 b->soundentry = gtk_entry_new(); 1385 b->soundentry = gtk_entry_new();
1331 gtk_table_attach(GTK_TABLE(table), b->soundentry, 1, 2, 3, 4, GTK_FILL | GTK_EXPAND, 0, 0, 0); 1386 gtk_table_attach(GTK_TABLE(table), b->soundentry, 1, 2, 3, 4, GTK_FILL | GTK_EXPAND, 0, 0, 0);
1332 gtk_signal_connect(GTK_OBJECT(b->soundentry), "activate", GTK_SIGNAL_FUNC(do_new_bp), b); 1387 gtk_signal_connect(GTK_OBJECT(b->soundentry), "activate", GTK_SIGNAL_FUNC(do_new_bp), b);
1388 if(edit_bp) {
1389 gtk_widget_set_sensitive(GTK_WIDGET(b->soundentry),
1390 (edit_bp->options & OPT_POUNCE_SOUND) ? TRUE : FALSE);
1391 gtk_entry_set_text(GTK_ENTRY(b->soundentry), edit_bp->sound);
1392 } else
1393 gtk_widget_set_sensitive(GTK_WIDGET(b->soundentry), FALSE);
1333 gtk_widget_show(b->soundentry); 1394 gtk_widget_show(b->soundentry);
1334 1395 gtk_signal_connect(GTK_OBJECT(b->sound), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive), b->soundentry);
1335 gtk_widget_set_sensitive(b->soundentry, FALSE);
1336 gtk_signal_connect(GTK_OBJECT(b->sound), "clicked", GTK_SIGNAL_FUNC(toggle_sensitive),
1337 b->soundentry);
1338 /* </pounce type="action"> */ 1396 /* </pounce type="action"> */
1339 1397
1340 b->save = gtk_check_button_new_with_label(_("Save this pounce after activation")); 1398 b->save = gtk_check_button_new_with_label(_("Save this pounce after activation"));
1341 gtk_container_set_border_width(GTK_CONTAINER(b->save), 7); 1399 gtk_container_set_border_width(GTK_CONTAINER(b->save), 7);
1342 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->save), FALSE); 1400 if(edit_bp)
1401 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->save),
1402 (edit_bp->options & OPT_POUNCE_SAVE) ? TRUE : FALSE);
1403 else
1404 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(b->save), FALSE);
1343 gtk_box_pack_start(GTK_BOX(vbox), b->save, FALSE, FALSE, 0); 1405 gtk_box_pack_start(GTK_BOX(vbox), b->save, FALSE, FALSE, 0);
1344 gtk_widget_show(b->save); 1406 gtk_widget_show(b->save);
1345 1407
1346 bbox = gtk_hbox_new(FALSE, 5); 1408 bbox = gtk_hbox_new(FALSE, 5);
1347 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); 1409 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);