Mercurial > pidgin.yaz
comparison src/aim.c @ 1250:b5783215b245
[gaim-migrate @ 1260]
decklin's clean up of the account editor, much needed.
indent -kr -i8 -l105 -ncs -cp7 -npcs -T GtkWidget -T gpointer -T AppletCallbackFunc -T GtkFunction -T gaim_plugin_remove -T name -T FILE -T gchar -T user_opts -T GdkEvent -T GtkObject ...
did about.c, aim.c, away.c, browser.c, buddy_chat.c, gaimrc.c, html.c, idle.c, multi.c. Need to do buddy.c, conversation.c, dialogs.c, oscar.c, perl.c, plugins.c, prefs.c, proxy.c, prpl.c, rvous.c, server.c, sound.c, toc.c, util.c. not doing gtkhtml.c because it's a piece of crap anyway, or *ticker.c because they're syd's.
got rid of debug_buff, just debug_printf now.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 13 Dec 2000 20:18:35 +0000 |
parents | 4593153a956c |
children | 9da444224f0e |
comparison
equal
deleted
inserted
replaced
1249:3e44de27622d | 1250:b5783215b245 |
---|---|
69 GList *conversations = NULL; | 69 GList *conversations = NULL; |
70 GList *chat_rooms = NULL; | 70 GList *chat_rooms = NULL; |
71 | 71 |
72 GtkWidget *mainwindow = NULL; | 72 GtkWidget *mainwindow = NULL; |
73 | 73 |
74 void BuddyTickerCreateWindow( void ); | 74 void BuddyTickerCreateWindow(void); |
75 | 75 |
76 void cancel_logon(void) | 76 void cancel_logon(void) |
77 { | 77 { |
78 #ifdef USE_APPLET | 78 #ifdef USE_APPLET |
79 applet_buddy_show = FALSE; | 79 applet_buddy_show = FALSE; |
91 /* then we remove everyone in a mass suicide */ | 91 /* then we remove everyone in a mass suicide */ |
92 c = plugins; | 92 c = plugins; |
93 while (c) { | 93 while (c) { |
94 p = (struct gaim_plugin *)c->data; | 94 p = (struct gaim_plugin *)c->data; |
95 if (g_module_symbol(p->handle, "gaim_plugin_remove", (gpointer *)&gaim_plugin_remove)) | 95 if (g_module_symbol(p->handle, "gaim_plugin_remove", (gpointer *)&gaim_plugin_remove)) |
96 (*gaim_plugin_remove)(); | 96 (*gaim_plugin_remove)(); |
97 /* we don't need to worry about removing callbacks since | 97 /* we don't need to worry about removing callbacks since |
98 * there won't be any more chance to call them back :) */ | 98 * there won't be any more chance to call them back :) */ |
99 g_free(p); | 99 g_free(p); |
100 c = c->next; | 100 c = c->next; |
101 } | 101 } |
108 #endif /* USE_APPLET */ | 108 #endif /* USE_APPLET */ |
109 } | 109 } |
110 | 110 |
111 static int snd_tmout; | 111 static int snd_tmout; |
112 int logins_not_muted = 1; | 112 int logins_not_muted = 1; |
113 static void sound_timeout() { | 113 static void sound_timeout() |
114 { | |
114 logins_not_muted = 1; | 115 logins_not_muted = 1; |
115 gtk_timeout_remove(snd_tmout); | 116 gtk_timeout_remove(snd_tmout); |
116 } | 117 } |
117 | 118 |
118 /* we need to do this for Oscar because serv_login only starts the login | 119 /* we need to do this for Oscar because serv_login only starts the login |
119 * process, it doesn't end there. gaim_setup will be called later from | 120 * process, it doesn't end there. gaim_setup will be called later from |
120 * oscar.c, after the buddy list is made and serv_finish_login is called */ | 121 * oscar.c, after the buddy list is made and serv_finish_login is called */ |
121 void gaim_setup(struct gaim_connection *gc) { | 122 void gaim_setup(struct gaim_connection *gc) |
122 if (sound_options & OPT_SOUND_LOGIN && | 123 { |
123 sound_options & OPT_SOUND_SILENT_SIGNON) { | 124 if ((sound_options & OPT_SOUND_LOGIN) && (sound_options & OPT_SOUND_SILENT_SIGNON)) { |
124 logins_not_muted = 0; | 125 logins_not_muted = 0; |
125 snd_tmout = gtk_timeout_add(10000, (GtkFunction)sound_timeout, | 126 snd_tmout = gtk_timeout_add(10000, (GtkFunction)sound_timeout, NULL); |
126 NULL); | 127 } |
127 } | |
128 | |
129 #ifdef USE_APPLET | 128 #ifdef USE_APPLET |
130 set_user_state(online); | 129 set_user_state(online); |
131 applet_widget_register_callback(APPLET_WIDGET(applet), | 130 applet_widget_register_callback(APPLET_WIDGET(applet), |
132 "signoff", | 131 "signoff", _("Signoff"), (AppletCallbackFunc)signoff_all, NULL); |
133 _("Signoff"), | |
134 (AppletCallbackFunc)signoff_all, | |
135 NULL); | |
136 #endif /* USE_APPLET */ | 132 #endif /* USE_APPLET */ |
137 } | 133 } |
138 | 134 |
139 | 135 |
140 static void dologin(GtkWidget *widget, GtkWidget *w) | 136 static void dologin(GtkWidget *widget, GtkWidget *w) |
236 GtkWidget *pmw; | 232 GtkWidget *pmw; |
237 GdkPixmap *pm; | 233 GdkPixmap *pm; |
238 GtkStyle *style; | 234 GtkStyle *style; |
239 GdkBitmap *mask; | 235 GdkBitmap *mask; |
240 | 236 |
241 if (mainwindow) { | 237 if (mainwindow) { |
242 gtk_widget_show(mainwindow); | 238 gtk_widget_show(mainwindow); |
243 return; | 239 return; |
244 } | 240 } |
245 | 241 |
246 mainwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); | 242 mainwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
247 /* Set the WM name and class */ | 243 /* Set the WM name and class */ |
248 gtk_window_set_wmclass(GTK_WINDOW(mainwindow), "login", | 244 gtk_window_set_wmclass(GTK_WINDOW(mainwindow), "login", "Gaim"); |
249 "Gaim"); | 245 /* Disallow resizing */ |
250 /* Disallow resizing */ | 246 gtk_window_set_policy(GTK_WINDOW(mainwindow), FALSE, FALSE, TRUE); |
251 gtk_window_set_policy(GTK_WINDOW(mainwindow), FALSE, FALSE, TRUE); | |
252 gtk_widget_realize(mainwindow); | 247 gtk_widget_realize(mainwindow); |
253 | 248 |
254 signon = gtk_button_new_with_label(_("Signon")); | 249 signon = gtk_button_new_with_label(_("Signon")); |
255 #ifndef NO_MULTI | 250 #ifndef NO_MULTI |
256 accts = gtk_button_new_with_label(_("Accounts")); | 251 accts = gtk_button_new_with_label(_("Accounts")); |
257 #endif | 252 #endif |
258 cancel = gtk_button_new_with_label(_("Cancel")); | 253 cancel = gtk_button_new_with_label(_("Cancel")); |
259 reg = gtk_button_new_with_label(_("Register")); | 254 reg = gtk_button_new_with_label(_("Register")); |
260 options = gtk_button_new_with_label(_("Options")); | 255 options = gtk_button_new_with_label(_("Options")); |
261 #ifdef GAIM_PLUGINS | 256 #ifdef GAIM_PLUGINS |
262 plugs = gtk_button_new_with_label(_("Plugins")); | 257 plugs = gtk_button_new_with_label(_("Plugins")); |
263 #endif | 258 #endif |
264 table = gtk_table_new(8, 2, FALSE); | 259 table = gtk_table_new(8, 2, FALSE); |
265 name = gtk_combo_new(); | 260 name = gtk_combo_new(); |
266 pass = gtk_entry_new(); | 261 pass = gtk_entry_new(); |
267 | 262 |
268 gtk_combo_set_popdown_strings(GTK_COMBO(name), combo_user_names()); | 263 gtk_combo_set_popdown_strings(GTK_COMBO(name), combo_user_names()); |
269 | 264 |
270 if (display_options & OPT_DISP_COOL_LOOK) | 265 if (display_options & OPT_DISP_COOL_LOOK) { |
271 { | |
272 gtk_button_set_relief(GTK_BUTTON(signon), GTK_RELIEF_NONE); | 266 gtk_button_set_relief(GTK_BUTTON(signon), GTK_RELIEF_NONE); |
273 #ifndef NO_MULTI | 267 #ifndef NO_MULTI |
274 gtk_button_set_relief(GTK_BUTTON(accts), GTK_RELIEF_NONE); | 268 gtk_button_set_relief(GTK_BUTTON(accts), GTK_RELIEF_NONE); |
275 #endif | 269 #endif |
276 gtk_button_set_relief(GTK_BUTTON(cancel), GTK_RELIEF_NONE); | 270 gtk_button_set_relief(GTK_BUTTON(cancel), GTK_RELIEF_NONE); |
281 #endif | 275 #endif |
282 } | 276 } |
283 | 277 |
284 /* Make the buttons do stuff */ | 278 /* Make the buttons do stuff */ |
285 /* Clicking the button initiates a login */ | 279 /* Clicking the button initiates a login */ |
286 gtk_signal_connect(GTK_OBJECT(signon), "clicked", | 280 gtk_signal_connect(GTK_OBJECT(signon), "clicked", GTK_SIGNAL_FUNC(dologin), mainwindow); |
287 GTK_SIGNAL_FUNC(dologin), mainwindow); | |
288 #ifndef NO_MULTI | 281 #ifndef NO_MULTI |
289 gtk_signal_connect(GTK_OBJECT(accts), "clicked", | 282 gtk_signal_connect(GTK_OBJECT(accts), "clicked", GTK_SIGNAL_FUNC(account_editor), mainwindow); |
290 GTK_SIGNAL_FUNC(account_editor), mainwindow); | 283 #endif |
291 #endif | 284 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(cancel_logon), mainwindow); |
292 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
293 GTK_SIGNAL_FUNC(cancel_logon), mainwindow); | |
294 /* Allow user to change prefs before logging in */ | 285 /* Allow user to change prefs before logging in */ |
295 gtk_signal_connect(GTK_OBJECT(options), "clicked", | 286 gtk_signal_connect(GTK_OBJECT(options), "clicked", GTK_SIGNAL_FUNC(show_prefs), NULL); |
296 GTK_SIGNAL_FUNC(show_prefs), NULL); | |
297 #ifdef GAIM_PLUGINS | 287 #ifdef GAIM_PLUGINS |
298 /* Allow user to control plugins before logging in */ | 288 /* Allow user to control plugins before logging in */ |
299 gtk_signal_connect(GTK_OBJECT(plugs), "clicked", | 289 gtk_signal_connect(GTK_OBJECT(plugs), "clicked", GTK_SIGNAL_FUNC(show_plugins), NULL); |
300 GTK_SIGNAL_FUNC(show_plugins), NULL); | |
301 #endif | 290 #endif |
302 | 291 |
303 /* Register opens the right URL */ | 292 /* Register opens the right URL */ |
304 gtk_signal_connect(GTK_OBJECT(reg), "clicked", | 293 gtk_signal_connect(GTK_OBJECT(reg), "clicked", |
305 GTK_SIGNAL_FUNC(open_url), "http://aim.aol.com/aimnew/Aim/register.adp?promo=106723&pageset=Aim&client=no"); | 294 GTK_SIGNAL_FUNC(open_url), |
295 "http://aim.aol.com/aimnew/Aim/register.adp?promo=106723&pageset=Aim&client=no"); | |
306 /* Enter in the username clears the password and sets | 296 /* Enter in the username clears the password and sets |
307 the pointer in the password field */ | 297 the pointer in the password field */ |
308 gtk_signal_connect(GTK_OBJECT(GTK_COMBO(name)->entry), "activate", | 298 gtk_signal_connect(GTK_OBJECT(GTK_COMBO(name)->entry), "activate", |
309 GTK_SIGNAL_FUNC(doenter), mainwindow); | 299 GTK_SIGNAL_FUNC(doenter), mainwindow); |
310 gtk_signal_connect(GTK_OBJECT(GTK_COMBO(name)->entry), "changed", | 300 gtk_signal_connect(GTK_OBJECT(GTK_COMBO(name)->entry), "changed", |
311 GTK_SIGNAL_FUNC(combo_changed), name); | 301 GTK_SIGNAL_FUNC(combo_changed), name); |
312 | 302 |
313 gtk_signal_connect(GTK_OBJECT(pass), "activate", | 303 gtk_signal_connect(GTK_OBJECT(pass), "activate", GTK_SIGNAL_FUNC(doenter), mainwindow); |
314 GTK_SIGNAL_FUNC(doenter), mainwindow); | |
315 gtk_signal_connect(GTK_OBJECT(mainwindow), "delete_event", | 304 gtk_signal_connect(GTK_OBJECT(mainwindow), "delete_event", |
316 GTK_SIGNAL_FUNC(cancel_logon), mainwindow); | 305 GTK_SIGNAL_FUNC(cancel_logon), mainwindow); |
317 /* Homogenous spacing, 10 padding */ | 306 /* Homogenous spacing, 10 padding */ |
318 bbox = gtk_hbox_new(TRUE, 10); | 307 bbox = gtk_hbox_new(TRUE, 10); |
319 hbox = gtk_hbox_new(TRUE, 10); | 308 hbox = gtk_hbox_new(TRUE, 10); |
320 sbox = gtk_vbox_new(TRUE, 5); | 309 sbox = gtk_vbox_new(TRUE, 5); |
321 | 310 |
322 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0); | 311 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0); |
323 #ifndef NO_MULTI | 312 #ifndef NO_MULTI |
324 gtk_box_pack_start(GTK_BOX(bbox), accts, TRUE, TRUE, 0); | 313 gtk_box_pack_start(GTK_BOX(bbox), accts, TRUE, TRUE, 0); |
325 #endif | 314 #endif |
326 gtk_box_pack_start(GTK_BOX(bbox), signon, TRUE, TRUE, 0); | 315 gtk_box_pack_start(GTK_BOX(bbox), signon, TRUE, TRUE, 0); |
334 gtk_box_pack_start(GTK_BOX(sbox), bbox, TRUE, TRUE, 0); | 323 gtk_box_pack_start(GTK_BOX(sbox), bbox, TRUE, TRUE, 0); |
335 gtk_box_pack_start(GTK_BOX(sbox), hbox, TRUE, TRUE, 0); | 324 gtk_box_pack_start(GTK_BOX(sbox), hbox, TRUE, TRUE, 0); |
336 | 325 |
337 /* Labels for selectors and text boxes */ | 326 /* Labels for selectors and text boxes */ |
338 label = gtk_label_new(_("Screen Name: ")); | 327 label = gtk_label_new(_("Screen Name: ")); |
339 gtk_table_attach(GTK_TABLE(table), label, 0,1,2,3,0,0, 5, 5); | 328 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, 0, 0, 5, 5); |
340 gtk_widget_show(label); | 329 gtk_widget_show(label); |
341 label = gtk_label_new(_("Password: ")); | 330 label = gtk_label_new(_("Password: ")); |
342 gtk_table_attach(GTK_TABLE(table), label, 0,1,3,4,0,0, 5, 5); | 331 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, 0, 0, 5, 5); |
343 gtk_widget_show(label); | 332 gtk_widget_show(label); |
344 | 333 |
345 gtk_widget_show(options); | 334 gtk_widget_show(options); |
346 #ifdef GAIM_PLUGINS | 335 #ifdef GAIM_PLUGINS |
347 gtk_widget_show(plugs); | 336 gtk_widget_show(plugs); |
348 #endif | 337 #endif |
349 | 338 |
350 /* Adjust sizes of inputs */ | 339 /* Adjust sizes of inputs */ |
351 gtk_widget_set_usize(name,100,0); | 340 gtk_widget_set_usize(name, 100, 0); |
352 gtk_widget_set_usize(pass,100,0); | 341 gtk_widget_set_usize(pass, 100, 0); |
353 | 342 |
354 | 343 |
355 /* Attach the buttons at the bottom */ | 344 /* Attach the buttons at the bottom */ |
356 gtk_widget_show(signon); | 345 gtk_widget_show(signon); |
357 gtk_widget_show(cancel); | 346 gtk_widget_show(cancel); |
358 gtk_widget_show(reg); | 347 gtk_widget_show(reg); |
359 #ifndef NO_MULTI | 348 #ifndef NO_MULTI |
360 gtk_widget_show(accts); | 349 gtk_widget_show(accts); |
361 #endif | 350 #endif |
362 gtk_widget_show(bbox); | 351 gtk_widget_show(bbox); |
363 gtk_widget_show(hbox); | 352 gtk_widget_show(hbox); |
364 gtk_widget_show(sbox); | 353 gtk_widget_show(sbox); |
365 gtk_table_attach(GTK_TABLE(table), sbox, 0,2,7,8,0,0, 5, 5); | 354 gtk_table_attach(GTK_TABLE(table), sbox, 0, 2, 7, 8, 0, 0, 5, 5); |
366 | 355 |
367 /* Text fields */ | 356 /* Text fields */ |
368 | 357 |
369 gtk_table_attach(GTK_TABLE(table),name,1,2,2,3,0,0,5,5); | 358 gtk_table_attach(GTK_TABLE(table), name, 1, 2, 2, 3, 0, 0, 5, 5); |
370 gtk_widget_show(name); | 359 gtk_widget_show(name); |
371 gtk_table_attach(GTK_TABLE(table),pass,1,2,3,4,0,0,5,5); | 360 gtk_table_attach(GTK_TABLE(table), pass, 1, 2, 3, 4, 0, 0, 5, 5); |
372 gtk_entry_set_visibility(GTK_ENTRY(pass), FALSE); | 361 gtk_entry_set_visibility(GTK_ENTRY(pass), FALSE); |
373 gtk_widget_show(pass); | 362 gtk_widget_show(pass); |
374 | 363 |
375 gtk_container_border_width(GTK_CONTAINER(sbox), 10); | 364 gtk_container_border_width(GTK_CONTAINER(sbox), 10); |
376 | 365 |
377 gtk_container_add(GTK_CONTAINER(mainwindow),table ); | 366 gtk_container_add(GTK_CONTAINER(mainwindow), table); |
378 | 367 |
379 gtk_widget_show(table); | 368 gtk_widget_show(table); |
380 gtk_window_set_title(GTK_WINDOW(mainwindow),_("Gaim - Login")); | 369 gtk_window_set_title(GTK_WINDOW(mainwindow), _("Gaim - Login")); |
381 | 370 |
382 | 371 |
383 if (aim_users) { | 372 if (aim_users) { |
384 struct aim_user *c = (struct aim_user *)aim_users->data; | 373 struct aim_user *c = (struct aim_user *)aim_users->data; |
385 sprintf(debug_buff, "First user is %s\n", c->username); | |
386 if (c->options & OPT_USR_REM_PASS) { | 374 if (c->options & OPT_USR_REM_PASS) { |
387 combo_changed(NULL, name); | 375 combo_changed(NULL, name); |
388 gtk_widget_grab_focus(signon); | 376 gtk_widget_grab_focus(signon); |
389 } else { | 377 } else { |
390 gtk_widget_grab_focus(pass); | 378 gtk_widget_grab_focus(pass); |
391 } | 379 } |
392 } else { | 380 } else { |
393 gtk_widget_grab_focus(name); | 381 gtk_widget_grab_focus(name); |
394 } | 382 } |
395 | 383 |
396 gtk_widget_realize(mainwindow); | 384 gtk_widget_realize(mainwindow); |
397 | 385 |
398 /* Logo at the top */ | 386 /* Logo at the top */ |
399 style = gtk_widget_get_style(mainwindow); | 387 style = gtk_widget_get_style(mainwindow); |
400 pm = gdk_pixmap_create_from_xpm_d(mainwindow->window, &mask, | 388 pm = gdk_pixmap_create_from_xpm_d(mainwindow->window, &mask, |
401 &style->bg[GTK_STATE_NORMAL], (gchar **)aol_logo); | 389 &style->bg[GTK_STATE_NORMAL], (gchar **) aol_logo); |
402 pmw = gtk_pixmap_new( pm, mask); | 390 pmw = gtk_pixmap_new(pm, mask); |
403 gtk_table_attach(GTK_TABLE(table), pmw, 0,2,0,1,0,0,5,5); | 391 gtk_table_attach(GTK_TABLE(table), pmw, 0, 2, 0, 1, 0, 0, 5, 5); |
404 gtk_widget_show(pmw); | 392 gtk_widget_show(pmw); |
405 gdk_pixmap_unref(pm); | 393 gdk_pixmap_unref(pm); |
406 gdk_bitmap_unref(mask); | 394 gdk_bitmap_unref(mask); |
407 | 395 |
408 | 396 |
409 aol_icon(mainwindow->window); | 397 aol_icon(mainwindow->window); |
410 #ifndef _WIN32 | 398 #ifndef _WIN32 |
411 gdk_window_set_group(mainwindow->window, mainwindow->window); | 399 gdk_window_set_group(mainwindow->window, mainwindow->window); |
412 #endif | 400 #endif |
413 | 401 |
414 | 402 |
415 gtk_widget_show(mainwindow); | 403 gtk_widget_show(mainwindow); |
416 | 404 |
417 SetTickerPrefs(); | 405 SetTickerPrefs(); |
418 | 406 |
419 } | 407 } |
420 | 408 |
421 extern void show_debug(GtkObject *); | 409 extern void show_debug(GtkObject *); |
422 | 410 |
423 #if HAVE_SIGNAL_H | 411 #if HAVE_SIGNAL_H |
424 void sighandler(int sig) | 412 void sighandler(int sig) |
425 { | 413 { |
426 fprintf(stderr, "God damn, I tripped.\n"); | 414 fprintf(stderr, "God damn, I tripped.\n"); |
427 exit(11); /* signal 11 */ | 415 exit(11); /* signal 11 */ |
428 } | 416 } |
429 #endif | 417 #endif |
430 | 418 |
431 | 419 |
432 int main(int argc, char *argv[]) | 420 int main(int argc, char *argv[]) |
433 { | 421 { |
434 char opt; | 422 char opt; |
435 int opt_acct = 0, opt_help = 0, opt_version = 0, | 423 int opt_acct = 0, opt_help = 0, opt_version = 0, opt_user = 0, opt_login = 0, do_login_ret = -1; |
436 opt_user = 0, opt_login = 0, do_login_ret = -1; | |
437 char *opt_user_arg = NULL, *opt_login_arg = NULL; | 424 char *opt_user_arg = NULL, *opt_login_arg = NULL; |
438 | 425 |
439 #ifdef USE_GNOME | 426 #ifdef USE_GNOME |
440 int i; | 427 int i; |
441 poptContext popt_context; | 428 poptContext popt_context; |
442 struct poptOption popt_options[] = | 429 struct poptOption popt_options[] = { |
443 { | 430 {"acct", 'a', POPT_ARG_NONE, &opt_acct, 'a', |
444 {"acct", 'a', POPT_ARG_NONE, &opt_acct, 'a', | |
445 "Display account editor window", NULL}, | 431 "Display account editor window", NULL}, |
446 {"login", 'l', POPT_ARG_STRING, NULL, 'l', | 432 {"login", 'l', POPT_ARG_STRING, NULL, 'l', |
447 "Automatically login (optional argument NAME specifies account(s) to use)", "[NAME]"}, | 433 "Automatically login (optional argument NAME specifies account(s) to use)", "[NAME]"}, |
448 {"user", 'u', POPT_ARG_STRING, &opt_user_arg, 'u', | 434 {"user", 'u', POPT_ARG_STRING, &opt_user_arg, 'u', |
449 "Use account NAME", "NAME"}, | 435 "Use account NAME", "NAME"}, |
450 {0, 0, 0, 0, 0, 0, 0} | 436 {0, 0, 0, 0, 0, 0, 0} |
451 }; | 437 }; |
452 #else | 438 #else |
453 struct option long_options[] = | 439 struct option long_options[] = { |
454 { | 440 {"acct", no_argument, NULL, 'a'}, |
455 {"acct", no_argument, NULL, 'a'}, | 441 {"help", no_argument, NULL, 'h'}, |
456 {"help", no_argument, NULL, 'h'}, | 442 {"login", optional_argument, NULL, 'l'}, |
457 {"login", optional_argument, NULL, 'l'}, | 443 {"user", required_argument, NULL, 'u'}, |
458 {"user", required_argument, NULL, 'u'}, | 444 {"version", no_argument, NULL, 'v'}, |
459 {"version", no_argument, NULL, 'v'}, | |
460 {0, 0, 0, 0} | 445 {0, 0, 0, 0} |
461 }; | 446 }; |
462 #endif /* USE_GNOME */ | 447 #endif /* USE_GNOME */ |
463 | 448 |
464 | 449 |
472 /* signal(SIGSEGV, sighandler); */ | 457 /* signal(SIGSEGV, sighandler); */ |
473 #endif | 458 #endif |
474 | 459 |
475 | 460 |
476 #ifdef USE_APPLET | 461 #ifdef USE_APPLET |
477 init_applet_mgr(argc, argv); | 462 init_applet_mgr(argc, argv); |
478 #elif defined USE_GNOME | 463 #elif defined USE_GNOME |
479 for (i = 0; i < argc; i++) { | 464 for (i = 0; i < argc; i++) { |
480 /* --login option */ | 465 /* --login option */ |
481 if (strstr (argv[i], "--l") == argv[i]) { | 466 if (strstr(argv[i], "--l") == argv[i]) { |
482 char *equals; | 467 char *equals; |
483 opt_login = 1; | 468 opt_login = 1; |
484 if ((equals = strchr(argv[i], '=')) != NULL) { | 469 if ((equals = strchr(argv[i], '=')) != NULL) { |
485 /* --login=NAME */ | 470 /* --login=NAME */ |
486 opt_login_arg = g_strdup (equals+1); | 471 opt_login_arg = g_strdup(equals + 1); |
487 } else if (i+1 < argc && argv[i+1][0] != '-') { | 472 } else if (i + 1 < argc && argv[i + 1][0] != '-') { |
488 /* --login NAME */ | 473 /* --login NAME */ |
489 opt_login_arg = g_strdup (argv[i+1]); | 474 opt_login_arg = g_strdup(argv[i + 1]); |
490 strcpy (argv[i+1], " "); | 475 strcpy(argv[i + 1], " "); |
491 } | 476 } |
492 strcpy (argv[i], " "); | 477 strcpy(argv[i], " "); |
493 } | 478 } |
494 /* -l option */ | 479 /* -l option */ |
495 else if (strstr (argv[i], "-l") == argv[i]) { | 480 else if (strstr(argv[i], "-l") == argv[i]) { |
496 opt_login = 1; | 481 opt_login = 1; |
497 if (strlen (argv[i]) > 2) { | 482 if (strlen(argv[i]) > 2) { |
498 /* -lNAME */ | 483 /* -lNAME */ |
499 opt_login_arg = g_strdup (argv[i]+2); | 484 opt_login_arg = g_strdup(argv[i] + 2); |
500 } else if (i+1 < argc && argv[i+1][0] != '-') { | 485 } else if (i + 1 < argc && argv[i + 1][0] != '-') { |
501 /* -l NAME */ | 486 /* -l NAME */ |
502 opt_login_arg = g_strdup (argv[i+1]); | 487 opt_login_arg = g_strdup(argv[i + 1]); |
503 strcpy (argv[i+1], " "); | 488 strcpy(argv[i + 1], " "); |
504 } | 489 } |
505 strcpy (argv[i], " "); | 490 strcpy(argv[i], " "); |
506 } | 491 } |
507 } | 492 } |
508 | 493 |
509 gnome_init_with_popt_table(PACKAGE,VERSION,argc,argv, | 494 gnome_init_with_popt_table(PACKAGE, VERSION, argc, argv, popt_options, 0, NULL); |
510 popt_options,0,NULL); | |
511 #else | 495 #else |
512 gtk_init(&argc, &argv); | 496 gtk_init(&argc, &argv); |
513 | 497 |
514 /* scan command-line options */ | 498 /* scan command-line options */ |
515 opterr = 1; | 499 opterr = 1; |
516 while ((opt = getopt_long (argc, argv, /*"ahl::u:v"*/"ahl::u:v", | 500 while ((opt = getopt_long(argc, argv, /*"ahl::u:v" */ "ahl::u:v", |
517 long_options, NULL)) != -1) { | 501 long_options, NULL)) != -1) { |
518 switch (opt) { | 502 switch (opt) { |
519 case 'u': /* set user */ | 503 case 'u': /* set user */ |
520 opt_user = 1; | 504 opt_user = 1; |
521 opt_user_arg = g_strdup (optarg); | 505 opt_user_arg = g_strdup(optarg); |
522 break; | 506 break; |
523 case 'l': | 507 case 'l': |
524 opt_login = 1; | 508 opt_login = 1; |
525 opt_login_arg = g_strdup (optarg); | 509 opt_login_arg = g_strdup(optarg); |
526 break; | 510 break; |
527 case 'a': /* account editor */ | 511 case 'a': /* account editor */ |
528 opt_acct = 1; | 512 opt_acct = 1; |
529 break; | 513 break; |
530 case 'v': /* version */ | 514 case 'v': /* version */ |
531 opt_version = 1; | 515 opt_version = 1; |
532 break; | 516 break; |
533 case 'h': /* help */ | 517 case 'h': /* help */ |
534 opt_help = 1; | 518 opt_help = 1; |
535 break; | 519 break; |
536 case '?': | 520 case '?': |
537 default: | 521 default: |
538 show_usage(1, argv[0]); | 522 show_usage(1, argv[0]); |
549 return 0; | 533 return 0; |
550 } | 534 } |
551 /* show version window */ | 535 /* show version window */ |
552 if (opt_version) { | 536 if (opt_version) { |
553 gtk_init(&argc, &argv); | 537 gtk_init(&argc, &argv); |
554 set_defaults(FALSE); /* needed for open_url_nw */ | 538 set_defaults(FALSE); /* needed for open_url_nw */ |
555 load_prefs(); | 539 load_prefs(); |
556 show_about(0, (void *)2); | 540 show_about(0, (void *)2); |
557 gtk_main(); | 541 gtk_main(); |
558 return 0; | 542 return 0; |
559 } | 543 } |
560 | 544 |
561 | 545 |
562 set_defaults(FALSE); | 546 set_defaults(FALSE); |
563 load_prefs(); | 547 load_prefs(); |
564 | 548 |
565 /* set the default username */ | 549 /* set the default username */ |
566 if (opt_user_arg != NULL) { | 550 if (opt_user_arg != NULL) { |
567 set_first_user (opt_user_arg); | 551 set_first_user(opt_user_arg); |
568 #ifndef USE_GNOME | 552 #ifndef USE_GNOME |
569 g_free (opt_user_arg); | 553 g_free(opt_user_arg); |
570 opt_user_arg = NULL; | 554 opt_user_arg = NULL; |
571 #endif /* USE_GNOME */ | 555 #endif /* USE_GNOME */ |
572 } | 556 } |
573 | 557 |
574 if (general_options & OPT_GEN_DEBUG) | 558 if (general_options & OPT_GEN_DEBUG) |
581 #endif | 565 #endif |
582 static_proto_init(); | 566 static_proto_init(); |
583 | 567 |
584 /* deal with --login */ | 568 /* deal with --login */ |
585 if (opt_login) { | 569 if (opt_login) { |
586 do_login_ret = do_auto_login (opt_login_arg); | 570 do_login_ret = do_auto_login(opt_login_arg); |
587 if (opt_login_arg != NULL) { | 571 if (opt_login_arg != NULL) { |
588 g_free (opt_login_arg); | 572 g_free(opt_login_arg); |
589 opt_login_arg = NULL; | 573 opt_login_arg = NULL; |
590 } | 574 } |
591 } | 575 } |
592 | 576 |
593 if (!opt_acct) | 577 if (!opt_acct) |
594 auto_login(); | 578 auto_login(); |
595 | 579 |
596 #ifdef USE_APPLET | 580 #ifdef USE_APPLET |
597 applet_widget_register_callback(APPLET_WIDGET(applet), | 581 applet_widget_register_callback(APPLET_WIDGET(applet), |
598 "prefs", | 582 "prefs", _("Preferences"), show_prefs, NULL); |
599 _("Preferences"), | 583 applet_widget_register_callback(APPLET_WIDGET(applet), |
600 show_prefs, | |
601 NULL); | |
602 applet_widget_register_callback(APPLET_WIDGET(applet), | |
603 "accounts", | 584 "accounts", |
604 _("Accounts"), | 585 _("Accounts"), (AppletCallbackFunc)account_editor, (void *)1); |
605 (AppletCallbackFunc)account_editor, | 586 #ifdef GAIM_PLUGINS |
606 (void *)1); | 587 applet_widget_register_callback(APPLET_WIDGET(applet), |
607 #ifdef GAIM_PLUGINS | 588 "plugins", _("Plugins"), GTK_SIGNAL_FUNC(show_plugins), NULL); |
608 applet_widget_register_callback(APPLET_WIDGET(applet), | |
609 "plugins", | |
610 _("Plugins"), | |
611 GTK_SIGNAL_FUNC(show_plugins), | |
612 NULL); | |
613 #endif /* GAIM_PLUGINS */ | 589 #endif /* GAIM_PLUGINS */ |
614 | 590 |
615 update_pixmaps(); | 591 update_pixmaps(); |
616 | 592 |
617 applet_widget_gtk_main(); | 593 applet_widget_gtk_main(); |
618 #else | 594 #else |
619 | 595 |
620 if (opt_acct) { | 596 if (opt_acct) { |
621 account_editor (NULL, NULL); | 597 account_editor(NULL, NULL); |
622 } else if (do_login_ret == -1) | 598 } else if (do_login_ret == -1) |
623 show_login(); | 599 show_login(); |
624 | 600 |
625 gtk_main(); | 601 gtk_main(); |
626 | 602 |
627 #endif /* USE_APPLET */ | 603 #endif /* USE_APPLET */ |
628 | 604 |
629 gtkspell_stop(); | 605 gtkspell_stop(); |
630 | 606 |
631 return 0; | 607 return 0; |
632 | 608 |
633 } | 609 } |