Mercurial > pidgin
annotate src/aim.c @ 338:9d258a0aa560
[gaim-migrate @ 348]
Whoa, all kinds of things happened here. The applet looks better. The
preferences dialog changes based on your compile-time options (oscar,
gnome). Whispering works again. libfaim got updated; it can almost do
RVOUS stuff, and hopefully soon can make requests too. The applet doesn't
need to have its sounds go through GNOME, although it still can. There
is code to facilitate SOCKS5 support (all that needs to be done is to
actually write the code to communicate with the proxy server).
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Tue, 06 Jun 2000 09:55:30 +0000 |
| parents | a88b889b692b |
| children | f4fba304b236 |
| rev | line source |
|---|---|
| 1 | 1 /* |
| 2 * gaim | |
| 3 * | |
| 4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> | |
| 5 * | |
| 6 * This program is free software; you can redistribute it and/or modify | |
| 7 * it under the terms of the GNU General Public License as published by | |
| 8 * the Free Software Foundation; either version 2 of the License, or | |
| 9 * (at your option) any later version. | |
| 10 * | |
| 11 * This program is distributed in the hope that it will be useful, | |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 * GNU General Public License for more details. | |
| 15 * | |
| 16 * You should have received a copy of the GNU General Public License | |
| 17 * along with this program; if not, write to the Free Software | |
| 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 19 * | |
| 20 */ | |
| 21 | |
| 22 #ifdef USE_THEMES | |
| 23 #include <gnome.h> | |
| 24 #else | |
| 25 #ifdef USE_APPLET | |
| 26 #include "gnome_applet_mgr.h" | |
| 27 #include <gnome.h> | |
| 28 #endif /* USE_APPLET */ | |
| 29 #endif /* USE_THEMES */ | |
| 30 #include <gtk/gtk.h> | |
| 31 #include <gdk/gdkx.h> | |
|
216
f7e17fb767eb
[gaim-migrate @ 226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
32 #include <gdk/gdk.h> |
| 1 | 33 #include <unistd.h> |
| 34 #include <netinet/in.h> | |
| 35 #include <arpa/inet.h> | |
| 36 #include <sys/wait.h> | |
| 37 #include <stdio.h> | |
| 38 #include <string.h> | |
| 39 #include <stdarg.h> | |
| 40 #include <stdlib.h> | |
| 228 | 41 #include <ctype.h> |
| 1 | 42 #include "gaim.h" |
| 43 #ifndef USE_APPLET | |
| 44 #include "pixmaps/logo.xpm" | |
| 45 #endif /* USE_APPLET */ | |
| 46 | |
| 47 static GtkWidget *name; | |
| 48 static GtkWidget *pass; | |
| 49 static GtkWidget *signon; | |
| 50 static GtkWidget *cancel; | |
| 51 static GtkWidget *progress; | |
| 52 static GtkWidget *notice; | |
| 53 | |
| 54 GList *permit = NULL; | |
| 55 GList *deny = NULL; | |
| 56 GList *log_conversations = NULL; | |
| 57 GList *buddy_pounces = NULL; | |
| 58 GList *away_messages = NULL; | |
| 59 GList *groups = NULL; | |
| 60 GList *buddy_chats = NULL; | |
| 61 GList *conversations = NULL; | |
| 62 GList *chat_rooms = NULL; | |
| 63 | |
| 64 GtkWidget *mainwindow = NULL; | |
| 65 | |
| 66 char toc_addy[16]; | |
| 26 | 67 char *quad_addr = NULL; |
| 1 | 68 |
|
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
296
diff
changeset
|
69 gboolean running = FALSE; /* whether or not we're currently trying to sign on */ |
| 1 | 70 |
| 71 void cancel_logon(void) | |
| 72 { | |
| 73 #ifdef USE_APPLET | |
| 74 set_applet_draw_closed(); | |
| 75 AppletCancelLogon(); | |
| 76 gtk_widget_hide(mainwindow); | |
| 77 #else | |
| 78 exit(0); | |
| 79 #endif /* USE_APPLET */ | |
| 80 } | |
| 81 | |
| 82 void set_login_progress(int howfar, char *whattosay) | |
| 83 { | |
| 84 gtk_progress_bar_update(GTK_PROGRESS_BAR(progress), | |
| 85 ((float)howfar / (float)LOGIN_STEPS)); | |
| 86 gtk_statusbar_pop(GTK_STATUSBAR(notice), 1); | |
| 87 gtk_statusbar_push(GTK_STATUSBAR(notice), 1, whattosay); | |
| 88 | |
| 89 while (gtk_events_pending()) | |
| 90 gtk_main_iteration(); | |
| 91 | |
| 92 /* Why do I need these? */ | |
| 93 usleep(10); | |
| 94 while (gtk_events_pending()) | |
| 95 gtk_main_iteration(); | |
| 96 | |
| 97 } | |
| 98 | |
| 99 void hide_login_progress(char *why) | |
| 100 { | |
| 101 gtk_progress_bar_update(GTK_PROGRESS_BAR(progress), | |
| 102 0); | |
| 103 gtk_statusbar_pop(GTK_STATUSBAR(notice), 1); | |
| 104 gtk_statusbar_push(GTK_STATUSBAR(notice), 1, why); | |
| 105 | |
| 106 while (gtk_events_pending()) | |
| 107 gtk_main_iteration(); | |
| 108 | |
| 109 /* Why do I need these? */ | |
| 110 usleep(10); | |
| 111 while (gtk_events_pending()) | |
| 112 gtk_main_iteration(); | |
| 113 } | |
| 114 | |
|
109
45bcfa3b584c
[gaim-migrate @ 119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
115 static int snd_tmout; |
|
133
e277d5f0c1dd
[gaim-migrate @ 143]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
109
diff
changeset
|
116 int logins_not_muted = 1; |
|
109
45bcfa3b584c
[gaim-migrate @ 119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
117 static void sound_timeout() { |
|
133
e277d5f0c1dd
[gaim-migrate @ 143]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
109
diff
changeset
|
118 logins_not_muted = 1; |
|
109
45bcfa3b584c
[gaim-migrate @ 119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
119 gtk_timeout_remove(snd_tmout); |
|
45bcfa3b584c
[gaim-migrate @ 119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
120 } |
|
45bcfa3b584c
[gaim-migrate @ 119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
121 |
| 228 | 122 char g_screenname[ 64 ]; /* gotta be enough */ |
| 123 | |
| 1 | 124 void dologin(GtkWidget *widget, GtkWidget *w) |
| 125 { | |
| 126 char *username = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(name)->entry)); | |
| 127 char *password = gtk_entry_get_text(GTK_ENTRY(pass)); | |
| 228 | 128 int i; |
| 1 | 129 |
| 130 if (query_state() != STATE_OFFLINE) | |
| 131 return; | |
| 132 | |
| 133 if (!strlen(username)) { | |
| 134 hide_login_progress("Please enter your logon"); | |
| 135 return; | |
| 136 } | |
| 137 if (!strlen(password)) { | |
| 138 hide_login_progress("You must give your password"); | |
| 139 return; | |
| 140 } | |
| 141 | |
| 228 | 142 /* save screenname away for cache file use */ |
| 143 | |
| 144 strcpy( g_screenname, username ); | |
| 145 | |
| 146 /* fold cache screen name file to upper case to avoid problems | |
| 147 finding file later if user uses different case at login time */ | |
| 148 | |
| 149 for ( i = 0; i < strlen( g_screenname ); i++ ) | |
| 150 g_screenname[i] = toupper( g_screenname[i] ); | |
| 151 | |
| 1 | 152 #ifdef USE_APPLET |
| 153 set_applet_draw_closed(); | |
| 154 setUserState(signing_on); | |
| 155 #endif /* USE_APPLET */ | |
| 156 | |
| 84 | 157 if (running) return; |
| 158 running = TRUE; | |
| 1 | 159 |
| 84 | 160 if (serv_login(username, password) < 0) { |
| 161 running = FALSE; | |
| 1 | 162 return; |
| 84 | 163 } |
|
265
59f1748b09a6
[gaim-migrate @ 275]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
253
diff
changeset
|
164 #ifdef USE_OSCAR |
|
59f1748b09a6
[gaim-migrate @ 275]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
253
diff
changeset
|
165 } |
| 1 | 166 |
|
270
cfa39d39dec6
[gaim-migrate @ 280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
265
diff
changeset
|
167 void auth_failed() { |
|
cfa39d39dec6
[gaim-migrate @ 280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
265
diff
changeset
|
168 running = FALSE; |
|
cfa39d39dec6
[gaim-migrate @ 280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
265
diff
changeset
|
169 } |
|
cfa39d39dec6
[gaim-migrate @ 280]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
265
diff
changeset
|
170 |
|
265
59f1748b09a6
[gaim-migrate @ 275]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
253
diff
changeset
|
171 /* we need to do this for Oscar because serv_login only starts the login |
|
59f1748b09a6
[gaim-migrate @ 275]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
253
diff
changeset
|
172 * process, it doesn't end there. gaim_setup will be called later from |
|
59f1748b09a6
[gaim-migrate @ 275]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
253
diff
changeset
|
173 * oscar.c, after the buddy list is made and serv_finish_login is called */ |
|
59f1748b09a6
[gaim-migrate @ 275]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
253
diff
changeset
|
174 void gaim_setup() { |
|
59f1748b09a6
[gaim-migrate @ 275]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
253
diff
changeset
|
175 #endif /* USE_OSCAR */ |
|
109
45bcfa3b584c
[gaim-migrate @ 119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
176 if (sound_options & OPT_SOUND_LOGIN && |
|
45bcfa3b584c
[gaim-migrate @ 119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
177 sound_options & OPT_SOUND_SILENT_SIGNON) { |
|
133
e277d5f0c1dd
[gaim-migrate @ 143]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
109
diff
changeset
|
178 logins_not_muted = 0; |
|
109
45bcfa3b584c
[gaim-migrate @ 119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
179 snd_tmout = gtk_timeout_add(10000, (GtkFunction)sound_timeout, |
|
45bcfa3b584c
[gaim-migrate @ 119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
180 NULL); |
|
45bcfa3b584c
[gaim-migrate @ 119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
181 } |
|
45bcfa3b584c
[gaim-migrate @ 119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
182 |
| 84 | 183 #ifdef USE_APPLET |
| 184 applet_widget_unregister_callback(APPLET_WIDGET(applet),"signon"); | |
| 185 applet_widget_register_callback(APPLET_WIDGET(applet), | |
| 186 "signoff", | |
| 187 _("Signoff"), | |
| 188 signoff, | |
| 189 NULL); | |
|
265
59f1748b09a6
[gaim-migrate @ 275]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
253
diff
changeset
|
190 #endif /* USE_APPLET */ |
|
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
191 |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
192 #ifdef GAIM_PLUGINS |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
193 { |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
194 GList *c = callbacks; |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
195 struct gaim_callback *g; |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
196 void (*function)(void *); |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
197 while (c) { |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
198 g = (struct gaim_callback *)c->data; |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
199 if (g->event == event_signon && g->function != NULL) { |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
200 function = g->function; |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
201 (*function)(g->data); |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
202 } |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
203 c = c->next; |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
204 } |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
205 } |
|
265
59f1748b09a6
[gaim-migrate @ 275]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
253
diff
changeset
|
206 #endif /* GAIM_PLUGINS */ |
|
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
207 |
| 84 | 208 running = FALSE; |
| 209 return; | |
| 1 | 210 } |
| 211 | |
| 212 | |
| 213 | |
| 214 | |
| 215 void doenter(GtkWidget *widget, GtkWidget *w) | |
| 216 { | |
| 217 if (widget == name) { | |
| 218 gtk_entry_set_text(GTK_ENTRY(pass),""); | |
| 219 gtk_entry_select_region(GTK_ENTRY(GTK_COMBO(name)->entry), 0, 0); | |
|
158
e9414f13d8b7
[gaim-migrate @ 168]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
157
diff
changeset
|
220 gtk_widget_grab_focus(pass); |
| 1 | 221 } else if (widget == pass) { |
|
158
e9414f13d8b7
[gaim-migrate @ 168]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
157
diff
changeset
|
222 gtk_widget_grab_focus(signon); |
| 1 | 223 } |
| 224 | |
| 225 } | |
| 226 | |
| 227 | |
| 228 static void combo_changed(GtkWidget *w, GtkWidget *combo) | |
| 229 { | |
|
158
e9414f13d8b7
[gaim-migrate @ 168]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
157
diff
changeset
|
230 char *txt = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)); |
| 1 | 231 struct aim_user *u; |
| 232 | |
| 25 | 233 if (!(general_options & OPT_GEN_REMEMBER_PASS)) { |
| 1 | 234 return; |
| 25 | 235 } |
| 236 | |
| 1 | 237 u = find_user(txt); |
| 238 | |
| 239 if (u != NULL) { | |
| 240 gtk_entry_set_text(GTK_ENTRY(pass), u->password); | |
| 241 } else { | |
| 242 gtk_entry_set_text(GTK_ENTRY(pass), ""); | |
| 243 } | |
| 25 | 244 |
| 1 | 245 return; |
| 246 } | |
| 247 | |
| 248 static GList *combo_user_names() | |
| 249 { | |
| 250 GList *usr = aim_users; | |
| 251 GList *tmp = NULL; | |
| 252 struct aim_user *u; | |
| 253 | |
| 254 | |
| 255 if (!usr) | |
| 256 return g_list_append(NULL, "<unknown>"); | |
| 257 | |
| 258 while(usr) { | |
| 259 u = (struct aim_user *)usr->data; | |
| 260 tmp = g_list_append(tmp, g_strdup(u->username)); | |
| 261 usr = usr->next; | |
| 262 | |
| 263 } | |
| 264 | |
| 265 return tmp; | |
| 266 } | |
| 267 | |
| 268 | |
| 269 | |
| 270 void show_login() | |
| 271 { | |
| 272 GtkWidget *options; | |
|
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
273 #ifdef GAIM_PLUGINS |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
274 GtkWidget *plugs; |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
275 #endif |
| 1 | 276 GtkWidget *reg; |
| 277 GtkWidget *bbox; | |
|
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
278 GtkWidget *hbox; |
| 1 | 279 GtkWidget *sbox; |
| 280 GtkWidget *label; | |
| 281 GtkWidget *table; | |
| 282 GtkWidget *remember; | |
| 283 | |
| 284 #ifndef USE_APPLET | |
| 285 GtkWidget *pmw; | |
| 286 GdkPixmap *pm; | |
| 287 GtkStyle *style; | |
| 288 GdkBitmap *mask; | |
| 289 #endif /* USE_APPLET */ | |
| 290 | |
| 291 if (mainwindow) { | |
| 292 gtk_widget_show(mainwindow); | |
| 293 return; | |
| 294 } | |
| 295 | |
| 296 mainwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
| 297 signon = gtk_button_new_with_label("Signon"); | |
| 298 cancel = gtk_button_new_with_label("Cancel"); | |
| 299 reg = gtk_button_new_with_label("Register"); | |
| 300 options = gtk_button_new_with_label("Options"); | |
|
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
301 #ifdef GAIM_PLUGINS |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
302 plugs = gtk_button_new_with_label("Plugins"); |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
303 #endif |
| 1 | 304 table = gtk_table_new(8, 2, FALSE); |
| 305 name = gtk_combo_new(); | |
| 306 pass = gtk_entry_new(); | |
| 307 notice = gtk_statusbar_new(); | |
| 308 progress = gtk_progress_bar_new(); | |
| 309 | |
| 310 gtk_combo_set_popdown_strings(GTK_COMBO(name), combo_user_names()); | |
| 311 | |
| 312 /* Make the buttons do stuff */ | |
| 313 /* Clicking the button initiates a login */ | |
| 314 gtk_signal_connect(GTK_OBJECT(signon), "clicked", | |
| 315 GTK_SIGNAL_FUNC(dologin), mainwindow); | |
| 316 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
| 317 GTK_SIGNAL_FUNC(cancel_logon), mainwindow); | |
| 318 /* Allow user to change prefs before logging in */ | |
| 319 gtk_signal_connect(GTK_OBJECT(options), "clicked", | |
| 320 GTK_SIGNAL_FUNC(show_prefs), NULL); | |
|
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
321 #ifdef GAIM_PLUGINS |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
322 /* Allow user to control plugins before logging in */ |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
323 gtk_signal_connect(GTK_OBJECT(plugs), "clicked", |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
324 GTK_SIGNAL_FUNC(show_plugins), NULL); |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
325 #endif |
| 1 | 326 |
| 327 /* Register opens the right URL */ | |
| 328 gtk_signal_connect(GTK_OBJECT(reg), "clicked", | |
| 286 | 329 GTK_SIGNAL_FUNC(open_url), "http://aim.aol.com/aimnew/Aim/register.adp?promo=106723&pageset=Aim&client=no"); |
| 1 | 330 /* Enter in the username clears the password and sets |
| 331 the pointer in the password field */ | |
| 332 gtk_signal_connect(GTK_OBJECT(GTK_COMBO(name)->entry), "activate", | |
| 333 GTK_SIGNAL_FUNC(doenter), mainwindow); | |
| 334 | |
| 335 gtk_signal_connect(GTK_OBJECT(GTK_COMBO(name)->entry), "changed", | |
| 336 GTK_SIGNAL_FUNC(combo_changed), name); | |
| 337 | |
| 338 gtk_signal_connect(GTK_OBJECT(pass), "activate", | |
| 339 GTK_SIGNAL_FUNC(doenter), mainwindow); | |
| 340 gtk_signal_connect(GTK_OBJECT(mainwindow), "delete_event", | |
| 341 GTK_SIGNAL_FUNC(cancel_logon), mainwindow); | |
| 342 /* Homogenous spacing, 10 padding */ | |
| 343 bbox = gtk_hbox_new(TRUE, 10); | |
|
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
344 hbox = gtk_hbox_new(TRUE, 10); |
| 1 | 345 sbox = gtk_vbox_new(TRUE, 10); |
| 346 | |
| 347 gtk_box_pack_start(GTK_BOX(bbox), reg, TRUE, TRUE, 0); | |
| 348 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0); | |
| 349 gtk_box_pack_start(GTK_BOX(bbox), signon, TRUE, TRUE, 0); | |
|
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
350 |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
351 gtk_box_pack_start(GTK_BOX(hbox), options, TRUE, TRUE, 0); |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
352 #ifdef GAIM_PLUGINS |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
353 gtk_box_pack_start(GTK_BOX(hbox), plugs, TRUE, TRUE, 0); |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
354 #endif |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
355 |
| 1 | 356 gtk_box_pack_start(GTK_BOX(sbox), bbox, TRUE, TRUE, 0); |
|
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
357 gtk_box_pack_start(GTK_BOX(sbox), hbox, TRUE, TRUE, 0); |
| 1 | 358 |
| 359 /* Labels for selectors and text boxes */ | |
| 360 #if 0 | |
| 361 label = gtk_label_new("TOC: "); | |
| 362 gtk_table_attach(GTK_TABLE(table), label, 0,1,1,2,0,0, 5, 5); | |
| 363 gtk_widget_show(label); | |
| 364 #endif | |
| 365 label = gtk_label_new("Screen Name: "); | |
| 366 gtk_table_attach(GTK_TABLE(table), label, 0,1,2,3,0,0, 5, 5); | |
| 367 gtk_widget_show(label); | |
| 368 label = gtk_label_new("Password: "); | |
| 369 gtk_table_attach(GTK_TABLE(table), label, 0,1,3,4,0,0, 5, 5); | |
| 370 gtk_widget_show(label); | |
| 371 remember = gtk_check_button_new_with_label("Remember Password"); | |
| 372 gtk_table_attach(GTK_TABLE(table), remember, 0,2,4,5,0,0, 5, 5); | |
| 373 gtk_widget_show(remember); | |
| 374 | |
| 375 gtk_widget_show(options); | |
|
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
376 #ifdef GAIM_PLUGINS |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
377 gtk_widget_show(plugs); |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
378 #endif |
| 1 | 379 |
| 380 /* Adjust sizes of inputs */ | |
| 381 gtk_widget_set_usize(name,95,0); | |
| 382 gtk_widget_set_usize(pass,95,0); | |
| 383 | |
| 384 | |
| 385 /* Status and label */ | |
| 386 gtk_widget_show(notice); | |
| 387 | |
| 388 gtk_widget_set_usize(progress,150,0); | |
| 389 | |
| 390 gtk_widget_show(progress); | |
| 391 | |
| 392 gtk_table_attach(GTK_TABLE(table), progress, 0, 2, 6, 7, 0, 0, 5, 5); | |
| 393 gtk_widget_set_usize(GTK_STATUSBAR(notice)->label, 150, 0); | |
| 394 gtk_table_attach(GTK_TABLE(table), notice, 0, 2, 8, 9, 0, 0, 5, 5); | |
| 395 | |
| 396 /* Attach the buttons at the bottom */ | |
| 397 gtk_widget_show(signon); | |
| 398 gtk_widget_show(cancel); | |
| 399 gtk_widget_show(reg); | |
| 400 gtk_widget_show(bbox); | |
|
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
401 gtk_widget_show(hbox); |
| 1 | 402 gtk_widget_show(sbox); |
| 403 gtk_table_attach(GTK_TABLE(table), sbox, 0,2,7,8,0,0, 5, 5); | |
| 404 | |
| 405 /* Text fields */ | |
| 406 | |
| 407 gtk_table_attach(GTK_TABLE(table),name,1,2,2,3,0,0,5,5); | |
| 408 gtk_widget_show(name); | |
| 409 gtk_table_attach(GTK_TABLE(table),pass,1,2,3,4,0,0,5,5); | |
| 410 gtk_entry_set_visibility(GTK_ENTRY(pass), FALSE); | |
| 411 gtk_widget_show(pass); | |
| 412 | |
| 413 gtk_container_border_width(GTK_CONTAINER(sbox), 10); | |
| 414 | |
| 415 gtk_container_add(GTK_CONTAINER(mainwindow),table ); | |
| 416 | |
| 417 gtk_widget_show(table); | |
| 418 gtk_window_set_title(GTK_WINDOW(mainwindow),"Gaim - Login"); | |
| 419 | |
| 420 | |
| 421 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(remember), (general_options & OPT_GEN_REMEMBER_PASS)); | |
| 422 | |
| 423 if (current_user) { | |
|
138
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
133
diff
changeset
|
424 GList *all = aim_users; |
|
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
133
diff
changeset
|
425 GList *srch = g_list_find(all, (void *)current_user); |
| 85 | 426 int length = g_list_length(all) - g_list_length(srch); |
| 427 | |
| 428 gtk_combo_set_value_in_list(GTK_COMBO(name), length, 0); | |
|
158
e9414f13d8b7
[gaim-migrate @ 168]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
157
diff
changeset
|
429 if ((general_options & OPT_GEN_REMEMBER_PASS)) { |
|
e9414f13d8b7
[gaim-migrate @ 168]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
157
diff
changeset
|
430 combo_changed(NULL, name); |
|
157
aad89d9bce85
[gaim-migrate @ 167]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
155
diff
changeset
|
431 gtk_widget_grab_focus(signon); |
|
158
e9414f13d8b7
[gaim-migrate @ 168]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
157
diff
changeset
|
432 } else { |
|
157
aad89d9bce85
[gaim-migrate @ 167]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
155
diff
changeset
|
433 gtk_widget_grab_focus(pass); |
|
158
e9414f13d8b7
[gaim-migrate @ 168]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
157
diff
changeset
|
434 } |
|
e9414f13d8b7
[gaim-migrate @ 168]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
157
diff
changeset
|
435 } else { |
|
157
aad89d9bce85
[gaim-migrate @ 167]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
155
diff
changeset
|
436 gtk_widget_grab_focus(name); |
|
158
e9414f13d8b7
[gaim-migrate @ 168]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
157
diff
changeset
|
437 } |
| 1 | 438 |
| 439 | |
| 440 gtk_signal_connect(GTK_OBJECT(remember), "clicked", GTK_SIGNAL_FUNC(set_general_option), (int *)OPT_GEN_REMEMBER_PASS); | |
| 441 | |
| 442 | |
| 443 gtk_widget_realize(mainwindow); | |
| 444 | |
| 445 #ifndef USE_APPLET | |
| 446 /* Logo at the top */ | |
| 447 style = gtk_widget_get_style(mainwindow); | |
| 448 pm = gdk_pixmap_create_from_xpm_d(mainwindow->window, &mask, | |
| 449 &style->bg[GTK_STATE_NORMAL], (gchar **)aol_logo); | |
| 450 pmw = gtk_pixmap_new( pm, mask); | |
| 451 gtk_table_attach(GTK_TABLE(table), pmw, 0,2,0,1,0,0,5,5); | |
| 452 gtk_widget_show(pmw); | |
| 453 #endif /* USE_APPLET */ | |
| 454 | |
| 455 | |
| 456 aol_icon(mainwindow->window); | |
| 457 #ifndef _WIN32 | |
| 458 gdk_window_set_group(mainwindow->window, mainwindow->window); | |
| 459 #endif | |
| 460 | |
| 461 | |
| 462 gtk_widget_show(mainwindow); | |
| 463 | |
| 464 if((general_options & OPT_GEN_AUTO_LOGIN) && | |
| 465 (general_options & OPT_GEN_REMEMBER_PASS)) { | |
| 466 dologin(signon, NULL); | |
| 467 } | |
| 468 } | |
| 469 | |
|
200
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
184
diff
changeset
|
470 extern void show_debug(GtkObject *); |
| 180 | 471 |
| 1 | 472 int main(int argc, char *argv[]) |
| 473 { | |
| 474 #ifdef USE_APPLET | |
|
338
9d258a0aa560
[gaim-migrate @ 348]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
296
diff
changeset
|
475 init_applet_mgr(argc, argv); |
| 1 | 476 #elif defined USE_THEMES |
| 477 gnome_init("GAIM",NULL,argc,argv); | |
| 478 #else | |
| 479 gtk_init(&argc, &argv); | |
| 480 #endif /* USE_THEMES */ | |
| 481 | |
| 482 | |
| 483 set_defaults(); | |
| 484 load_prefs(); | |
| 180 | 485 |
|
176
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
158
diff
changeset
|
486 if (general_options & OPT_GEN_DEBUG) |
|
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
158
diff
changeset
|
487 show_debug(NULL); |
| 1 | 488 |
|
216
f7e17fb767eb
[gaim-migrate @ 226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
489 gdk_threads_enter(); |
|
f7e17fb767eb
[gaim-migrate @ 226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
490 |
| 1 | 491 #ifdef USE_APPLET |
| 492 applet_widget_register_callback(APPLET_WIDGET(applet), | |
| 493 "prefs", | |
| 494 _("Preferences"), | |
| 495 show_prefs, | |
| 496 NULL); | |
| 497 applet_widget_register_callback(APPLET_WIDGET(applet), | |
| 498 "signon", | |
| 499 _("Signon"), | |
| 500 applet_show_login, | |
| 501 NULL); | |
|
97
5b4b7aa8dd9a
[gaim-migrate @ 107]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
502 #ifdef GAIM_PLUGINS |
|
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
503 applet_widget_register_callback(APPLET_WIDGET(applet), |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
504 "plugins", |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
505 _("Plugins"), |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
506 GTK_SIGNAL_FUNC(show_plugins), |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
507 NULL); |
|
97
5b4b7aa8dd9a
[gaim-migrate @ 107]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
508 #endif /* GAIM_PLUGINS */ |
| 1 | 509 |
| 510 if((general_options & OPT_GEN_AUTO_LOGIN) && | |
| 511 (general_options & OPT_GEN_REMEMBER_PASS)) { | |
| 512 | |
| 513 applet_show_login(APPLET_WIDGET(applet), NULL); | |
| 514 } | |
| 82 | 515 |
| 516 update_pixmaps(); | |
| 1 | 517 |
| 518 applet_widget_gtk_main(); | |
| 519 #else | |
| 520 | |
| 521 | |
| 522 show_login(); | |
| 523 gtk_main(); | |
| 524 | |
| 525 #endif /* USE_APPLET */ | |
|
216
f7e17fb767eb
[gaim-migrate @ 226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
526 gdk_threads_leave(); |
| 1 | 527 |
| 528 return 0; | |
| 529 | |
| 530 } |
