Mercurial > pidgin
annotate src/aim.c @ 216:f7e17fb767eb
[gaim-migrate @ 226]
Gtk-safe thread-safe code, here we come! Yah!
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Thu, 04 May 2000 09:32:51 +0000 |
| parents | bc117fbcf527 |
| children | f3b61c04f44e |
| 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> | |
| 41 #include "gaim.h" | |
| 42 #ifndef USE_APPLET | |
| 43 #include "pixmaps/logo.xpm" | |
| 44 #endif /* USE_APPLET */ | |
| 45 | |
| 46 static GtkWidget *name; | |
| 47 static GtkWidget *pass; | |
| 48 static GtkWidget *signon; | |
| 49 static GtkWidget *cancel; | |
| 50 static GtkWidget *progress; | |
| 51 static GtkWidget *notice; | |
| 52 | |
| 53 GList *permit = NULL; | |
| 54 GList *deny = NULL; | |
| 55 GList *log_conversations = NULL; | |
| 56 GList *buddy_pounces = NULL; | |
| 57 GList *away_messages = NULL; | |
| 58 GList *groups = NULL; | |
| 59 GList *buddy_chats = NULL; | |
| 60 GList *conversations = NULL; | |
| 61 GList *chat_rooms = NULL; | |
| 62 | |
| 63 GtkWidget *mainwindow = NULL; | |
| 64 | |
| 65 char toc_addy[16]; | |
| 26 | 66 char *quad_addr = NULL; |
| 1 | 67 |
| 68 | |
| 69 void cancel_logon(void) | |
| 70 { | |
| 71 #ifdef USE_APPLET | |
| 72 set_applet_draw_closed(); | |
| 73 AppletCancelLogon(); | |
| 74 gtk_widget_hide(mainwindow); | |
| 75 #else | |
| 76 exit(0); | |
| 77 #endif /* USE_APPLET */ | |
| 78 } | |
| 79 | |
| 80 void set_login_progress(int howfar, char *whattosay) | |
| 81 { | |
| 82 gtk_progress_bar_update(GTK_PROGRESS_BAR(progress), | |
| 83 ((float)howfar / (float)LOGIN_STEPS)); | |
| 84 gtk_statusbar_pop(GTK_STATUSBAR(notice), 1); | |
| 85 gtk_statusbar_push(GTK_STATUSBAR(notice), 1, whattosay); | |
| 86 | |
| 87 while (gtk_events_pending()) | |
| 88 gtk_main_iteration(); | |
| 89 | |
| 90 /* Why do I need these? */ | |
| 91 usleep(10); | |
| 92 while (gtk_events_pending()) | |
| 93 gtk_main_iteration(); | |
| 94 | |
| 95 } | |
| 96 | |
| 97 void hide_login_progress(char *why) | |
| 98 { | |
| 99 gtk_progress_bar_update(GTK_PROGRESS_BAR(progress), | |
| 100 0); | |
| 101 gtk_statusbar_pop(GTK_STATUSBAR(notice), 1); | |
| 102 gtk_statusbar_push(GTK_STATUSBAR(notice), 1, why); | |
| 103 | |
| 104 while (gtk_events_pending()) | |
| 105 gtk_main_iteration(); | |
| 106 | |
| 107 /* Why do I need these? */ | |
| 108 usleep(10); | |
| 109 while (gtk_events_pending()) | |
| 110 gtk_main_iteration(); | |
| 111 } | |
| 112 | |
|
109
45bcfa3b584c
[gaim-migrate @ 119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
113 static int snd_tmout; |
|
133
e277d5f0c1dd
[gaim-migrate @ 143]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
109
diff
changeset
|
114 int logins_not_muted = 1; |
|
109
45bcfa3b584c
[gaim-migrate @ 119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
115 static void sound_timeout() { |
|
133
e277d5f0c1dd
[gaim-migrate @ 143]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
109
diff
changeset
|
116 logins_not_muted = 1; |
|
109
45bcfa3b584c
[gaim-migrate @ 119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
117 gtk_timeout_remove(snd_tmout); |
|
45bcfa3b584c
[gaim-migrate @ 119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
118 } |
|
45bcfa3b584c
[gaim-migrate @ 119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
119 |
| 1 | 120 void dologin(GtkWidget *widget, GtkWidget *w) |
| 121 { | |
| 84 | 122 static gboolean running = FALSE; |
| 1 | 123 char *username = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(name)->entry)); |
| 124 char *password = gtk_entry_get_text(GTK_ENTRY(pass)); | |
| 125 | |
| 126 if (query_state() != STATE_OFFLINE) | |
| 127 return; | |
| 128 | |
| 129 if (!strlen(username)) { | |
| 130 hide_login_progress("Please enter your logon"); | |
| 131 return; | |
| 132 } | |
| 133 if (!strlen(password)) { | |
| 134 hide_login_progress("You must give your password"); | |
| 135 return; | |
| 136 } | |
| 137 | |
| 138 #ifdef USE_APPLET | |
| 139 set_applet_draw_closed(); | |
| 140 setUserState(signing_on); | |
| 141 #endif /* USE_APPLET */ | |
| 142 | |
| 84 | 143 if (running) return; |
| 144 running = TRUE; | |
| 1 | 145 |
| 84 | 146 if (serv_login(username, password) < 0) { |
| 147 running = FALSE; | |
| 1 | 148 return; |
| 84 | 149 } |
| 1 | 150 |
|
109
45bcfa3b584c
[gaim-migrate @ 119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
151 if (sound_options & OPT_SOUND_LOGIN && |
|
45bcfa3b584c
[gaim-migrate @ 119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
152 sound_options & OPT_SOUND_SILENT_SIGNON) { |
|
133
e277d5f0c1dd
[gaim-migrate @ 143]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
109
diff
changeset
|
153 logins_not_muted = 0; |
|
109
45bcfa3b584c
[gaim-migrate @ 119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
154 snd_tmout = gtk_timeout_add(10000, (GtkFunction)sound_timeout, |
|
45bcfa3b584c
[gaim-migrate @ 119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
155 NULL); |
|
45bcfa3b584c
[gaim-migrate @ 119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
156 } |
|
45bcfa3b584c
[gaim-migrate @ 119]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
107
diff
changeset
|
157 |
| 84 | 158 #ifdef USE_APPLET |
| 159 applet_widget_unregister_callback(APPLET_WIDGET(applet),"signon"); | |
| 160 applet_widget_register_callback(APPLET_WIDGET(applet), | |
| 161 "buddy", | |
| 162 _("Buddy List"), | |
|
107
55faf2e3a134
[gaim-migrate @ 117]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
97
diff
changeset
|
163 (AppletCallbackFunc)createOnlinePopup, |
| 84 | 164 NULL); |
| 165 applet_widget_register_callback(APPLET_WIDGET(applet), | |
| 166 "signoff", | |
| 167 _("Signoff"), | |
| 168 signoff, | |
| 169 NULL); | |
| 170 #endif | |
|
94
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
171 |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
172 #ifdef GAIM_PLUGINS |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
173 { |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
174 GList *c = callbacks; |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
175 struct gaim_callback *g; |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
176 void (*function)(void *); |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
177 while (c) { |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
178 g = (struct gaim_callback *)c->data; |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
179 if (g->event == event_signon && g->function != NULL) { |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
180 function = g->function; |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
181 (*function)(g->data); |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
182 } |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
183 c = c->next; |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
184 } |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
185 } |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
186 #endif |
|
9f6ce50ffb78
[gaim-migrate @ 104]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
85
diff
changeset
|
187 |
| 84 | 188 running = FALSE; |
| 189 return; | |
| 1 | 190 } |
| 191 | |
| 192 | |
| 193 | |
| 194 | |
| 195 void doenter(GtkWidget *widget, GtkWidget *w) | |
| 196 { | |
| 197 if (widget == name) { | |
| 198 gtk_entry_set_text(GTK_ENTRY(pass),""); | |
| 199 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
|
200 gtk_widget_grab_focus(pass); |
| 1 | 201 } else if (widget == pass) { |
|
158
e9414f13d8b7
[gaim-migrate @ 168]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
157
diff
changeset
|
202 gtk_widget_grab_focus(signon); |
| 1 | 203 } |
| 204 | |
| 205 } | |
| 206 | |
| 207 | |
| 208 static void combo_changed(GtkWidget *w, GtkWidget *combo) | |
| 209 { | |
|
158
e9414f13d8b7
[gaim-migrate @ 168]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
157
diff
changeset
|
210 char *txt = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry)); |
| 1 | 211 struct aim_user *u; |
| 212 | |
| 25 | 213 if (!(general_options & OPT_GEN_REMEMBER_PASS)) { |
| 1 | 214 return; |
| 25 | 215 } |
| 216 | |
| 1 | 217 u = find_user(txt); |
| 218 | |
| 219 if (u != NULL) { | |
| 220 gtk_entry_set_text(GTK_ENTRY(pass), u->password); | |
| 221 } else { | |
| 222 gtk_entry_set_text(GTK_ENTRY(pass), ""); | |
| 223 } | |
| 25 | 224 |
| 1 | 225 return; |
| 226 } | |
| 227 | |
| 228 static GList *combo_user_names() | |
| 229 { | |
| 230 GList *usr = aim_users; | |
| 231 GList *tmp = NULL; | |
| 232 struct aim_user *u; | |
| 233 | |
| 234 | |
| 235 if (!usr) | |
| 236 return g_list_append(NULL, "<unknown>"); | |
| 237 | |
| 238 while(usr) { | |
| 239 u = (struct aim_user *)usr->data; | |
| 240 tmp = g_list_append(tmp, g_strdup(u->username)); | |
| 241 usr = usr->next; | |
| 242 | |
| 243 } | |
| 244 | |
| 245 return tmp; | |
| 246 } | |
| 247 | |
| 248 | |
| 249 | |
| 250 void show_login() | |
| 251 { | |
| 252 GtkWidget *options; | |
|
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
253 #ifdef GAIM_PLUGINS |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
254 GtkWidget *plugs; |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
255 #endif |
| 1 | 256 GtkWidget *reg; |
| 257 GtkWidget *bbox; | |
|
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
258 GtkWidget *hbox; |
| 1 | 259 GtkWidget *sbox; |
| 260 GtkWidget *label; | |
| 261 GtkWidget *table; | |
| 262 GtkWidget *remember; | |
| 263 | |
| 264 #ifndef USE_APPLET | |
| 265 GtkWidget *pmw; | |
| 266 GdkPixmap *pm; | |
| 267 GtkStyle *style; | |
| 268 GdkBitmap *mask; | |
| 269 #endif /* USE_APPLET */ | |
| 270 | |
| 271 if (mainwindow) { | |
| 272 gtk_widget_show(mainwindow); | |
| 273 return; | |
| 274 } | |
| 275 | |
| 276 mainwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
| 277 signon = gtk_button_new_with_label("Signon"); | |
| 278 cancel = gtk_button_new_with_label("Cancel"); | |
| 279 reg = gtk_button_new_with_label("Register"); | |
| 280 options = gtk_button_new_with_label("Options"); | |
|
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
281 #ifdef GAIM_PLUGINS |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
282 plugs = gtk_button_new_with_label("Plugins"); |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
283 #endif |
| 1 | 284 table = gtk_table_new(8, 2, FALSE); |
| 285 name = gtk_combo_new(); | |
| 286 pass = gtk_entry_new(); | |
| 287 notice = gtk_statusbar_new(); | |
| 288 progress = gtk_progress_bar_new(); | |
| 289 | |
| 290 gtk_combo_set_popdown_strings(GTK_COMBO(name), combo_user_names()); | |
| 291 | |
| 292 /* Make the buttons do stuff */ | |
| 293 /* Clicking the button initiates a login */ | |
| 294 gtk_signal_connect(GTK_OBJECT(signon), "clicked", | |
| 295 GTK_SIGNAL_FUNC(dologin), mainwindow); | |
| 296 gtk_signal_connect(GTK_OBJECT(cancel), "clicked", | |
| 297 GTK_SIGNAL_FUNC(cancel_logon), mainwindow); | |
| 298 /* Allow user to change prefs before logging in */ | |
| 299 gtk_signal_connect(GTK_OBJECT(options), "clicked", | |
| 300 GTK_SIGNAL_FUNC(show_prefs), NULL); | |
|
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 /* Allow user to control plugins before logging in */ |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
303 gtk_signal_connect(GTK_OBJECT(plugs), "clicked", |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
304 GTK_SIGNAL_FUNC(show_plugins), NULL); |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
305 #endif |
| 1 | 306 |
| 307 /* Register opens the right URL */ | |
| 308 gtk_signal_connect(GTK_OBJECT(reg), "clicked", | |
| 309 GTK_SIGNAL_FUNC(open_url), "http://www.aol.com/aim"); | |
| 310 /* Enter in the username clears the password and sets | |
| 311 the pointer in the password field */ | |
| 312 gtk_signal_connect(GTK_OBJECT(GTK_COMBO(name)->entry), "activate", | |
| 313 GTK_SIGNAL_FUNC(doenter), mainwindow); | |
| 314 | |
| 315 gtk_signal_connect(GTK_OBJECT(GTK_COMBO(name)->entry), "changed", | |
| 316 GTK_SIGNAL_FUNC(combo_changed), name); | |
| 317 | |
| 318 gtk_signal_connect(GTK_OBJECT(pass), "activate", | |
| 319 GTK_SIGNAL_FUNC(doenter), mainwindow); | |
| 320 gtk_signal_connect(GTK_OBJECT(mainwindow), "delete_event", | |
| 321 GTK_SIGNAL_FUNC(cancel_logon), mainwindow); | |
| 322 /* Homogenous spacing, 10 padding */ | |
| 323 bbox = gtk_hbox_new(TRUE, 10); | |
|
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
324 hbox = gtk_hbox_new(TRUE, 10); |
| 1 | 325 sbox = gtk_vbox_new(TRUE, 10); |
| 326 | |
| 327 gtk_box_pack_start(GTK_BOX(bbox), reg, TRUE, TRUE, 0); | |
| 328 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0); | |
| 329 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
|
330 |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
331 gtk_box_pack_start(GTK_BOX(hbox), options, TRUE, TRUE, 0); |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
332 #ifdef GAIM_PLUGINS |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
333 gtk_box_pack_start(GTK_BOX(hbox), plugs, TRUE, TRUE, 0); |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
334 #endif |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
335 |
| 1 | 336 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
|
337 gtk_box_pack_start(GTK_BOX(sbox), hbox, TRUE, TRUE, 0); |
| 1 | 338 |
| 339 /* Labels for selectors and text boxes */ | |
| 340 #if 0 | |
| 341 label = gtk_label_new("TOC: "); | |
| 342 gtk_table_attach(GTK_TABLE(table), label, 0,1,1,2,0,0, 5, 5); | |
| 343 gtk_widget_show(label); | |
| 344 #endif | |
| 345 label = gtk_label_new("Screen Name: "); | |
| 346 gtk_table_attach(GTK_TABLE(table), label, 0,1,2,3,0,0, 5, 5); | |
| 347 gtk_widget_show(label); | |
| 348 label = gtk_label_new("Password: "); | |
| 349 gtk_table_attach(GTK_TABLE(table), label, 0,1,3,4,0,0, 5, 5); | |
| 350 gtk_widget_show(label); | |
| 351 remember = gtk_check_button_new_with_label("Remember Password"); | |
| 352 gtk_table_attach(GTK_TABLE(table), remember, 0,2,4,5,0,0, 5, 5); | |
| 353 gtk_widget_show(remember); | |
| 354 | |
| 355 gtk_widget_show(options); | |
|
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
356 #ifdef GAIM_PLUGINS |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
357 gtk_widget_show(plugs); |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
358 #endif |
| 1 | 359 |
| 360 /* Adjust sizes of inputs */ | |
| 361 gtk_widget_set_usize(name,95,0); | |
| 362 gtk_widget_set_usize(pass,95,0); | |
| 363 | |
| 364 | |
| 365 /* Status and label */ | |
| 366 gtk_widget_show(notice); | |
| 367 | |
| 368 gtk_widget_set_usize(progress,150,0); | |
| 369 | |
| 370 gtk_widget_show(progress); | |
| 371 | |
| 372 gtk_table_attach(GTK_TABLE(table), progress, 0, 2, 6, 7, 0, 0, 5, 5); | |
| 373 gtk_widget_set_usize(GTK_STATUSBAR(notice)->label, 150, 0); | |
| 374 gtk_table_attach(GTK_TABLE(table), notice, 0, 2, 8, 9, 0, 0, 5, 5); | |
| 375 | |
| 376 /* Attach the buttons at the bottom */ | |
| 377 gtk_widget_show(signon); | |
| 378 gtk_widget_show(cancel); | |
| 379 gtk_widget_show(reg); | |
| 380 gtk_widget_show(bbox); | |
|
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
381 gtk_widget_show(hbox); |
| 1 | 382 gtk_widget_show(sbox); |
| 383 gtk_table_attach(GTK_TABLE(table), sbox, 0,2,7,8,0,0, 5, 5); | |
| 384 | |
| 385 /* Text fields */ | |
| 386 | |
| 387 gtk_table_attach(GTK_TABLE(table),name,1,2,2,3,0,0,5,5); | |
| 388 gtk_widget_show(name); | |
| 389 gtk_table_attach(GTK_TABLE(table),pass,1,2,3,4,0,0,5,5); | |
| 390 gtk_entry_set_visibility(GTK_ENTRY(pass), FALSE); | |
| 391 gtk_widget_show(pass); | |
| 392 | |
| 393 gtk_container_border_width(GTK_CONTAINER(sbox), 10); | |
| 394 | |
| 395 gtk_container_add(GTK_CONTAINER(mainwindow),table ); | |
| 396 | |
| 397 gtk_widget_show(table); | |
| 398 gtk_window_set_title(GTK_WINDOW(mainwindow),"Gaim - Login"); | |
| 399 | |
| 400 | |
| 401 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(remember), (general_options & OPT_GEN_REMEMBER_PASS)); | |
| 402 | |
| 403 if (current_user) { | |
|
138
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
133
diff
changeset
|
404 GList *all = aim_users; |
|
e8ea1e2fdf0c
[gaim-migrate @ 148]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
133
diff
changeset
|
405 GList *srch = g_list_find(all, (void *)current_user); |
| 85 | 406 int length = g_list_length(all) - g_list_length(srch); |
| 407 | |
| 408 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
|
409 if ((general_options & OPT_GEN_REMEMBER_PASS)) { |
|
e9414f13d8b7
[gaim-migrate @ 168]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
157
diff
changeset
|
410 combo_changed(NULL, name); |
|
157
aad89d9bce85
[gaim-migrate @ 167]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
155
diff
changeset
|
411 gtk_widget_grab_focus(signon); |
|
158
e9414f13d8b7
[gaim-migrate @ 168]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
157
diff
changeset
|
412 } else { |
|
157
aad89d9bce85
[gaim-migrate @ 167]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
155
diff
changeset
|
413 gtk_widget_grab_focus(pass); |
|
158
e9414f13d8b7
[gaim-migrate @ 168]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
157
diff
changeset
|
414 } |
|
e9414f13d8b7
[gaim-migrate @ 168]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
157
diff
changeset
|
415 } else { |
|
157
aad89d9bce85
[gaim-migrate @ 167]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
155
diff
changeset
|
416 gtk_widget_grab_focus(name); |
|
158
e9414f13d8b7
[gaim-migrate @ 168]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
157
diff
changeset
|
417 } |
| 1 | 418 |
| 419 | |
| 420 gtk_signal_connect(GTK_OBJECT(remember), "clicked", GTK_SIGNAL_FUNC(set_general_option), (int *)OPT_GEN_REMEMBER_PASS); | |
| 421 | |
| 422 | |
| 423 gtk_widget_realize(mainwindow); | |
| 424 | |
| 425 #ifndef USE_APPLET | |
| 426 /* Logo at the top */ | |
| 427 style = gtk_widget_get_style(mainwindow); | |
| 428 pm = gdk_pixmap_create_from_xpm_d(mainwindow->window, &mask, | |
| 429 &style->bg[GTK_STATE_NORMAL], (gchar **)aol_logo); | |
| 430 pmw = gtk_pixmap_new( pm, mask); | |
| 431 gtk_table_attach(GTK_TABLE(table), pmw, 0,2,0,1,0,0,5,5); | |
| 432 gtk_widget_show(pmw); | |
| 433 #endif /* USE_APPLET */ | |
| 434 | |
| 435 | |
| 436 aol_icon(mainwindow->window); | |
| 437 #ifndef _WIN32 | |
| 438 gdk_window_set_group(mainwindow->window, mainwindow->window); | |
| 439 #endif | |
| 440 | |
| 441 | |
| 442 gtk_widget_show(mainwindow); | |
| 443 | |
| 444 if((general_options & OPT_GEN_AUTO_LOGIN) && | |
| 445 (general_options & OPT_GEN_REMEMBER_PASS)) { | |
| 446 dologin(signon, NULL); | |
| 447 } | |
| 448 } | |
| 449 | |
|
200
bc117fbcf527
[gaim-migrate @ 210]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
184
diff
changeset
|
450 extern void show_debug(GtkObject *); |
| 180 | 451 |
| 1 | 452 int main(int argc, char *argv[]) |
| 453 { | |
| 454 #ifdef USE_APPLET | |
| 455 InitAppletMgr( argc, argv ); | |
| 456 #elif defined USE_THEMES | |
| 457 gnome_init("GAIM",NULL,argc,argv); | |
| 458 #else | |
| 459 gtk_init(&argc, &argv); | |
| 460 #endif /* USE_THEMES */ | |
| 461 | |
| 462 | |
| 463 set_defaults(); | |
| 464 load_prefs(); | |
| 180 | 465 |
| 466 if (general_options & OPT_GEN_CHECK_VERSIONS) | |
| 467 { | |
| 184 | 468 /* FIXME: |
| 469 Thread this code later | |
| 180 | 470 check_gaim_versions(); |
| 184 | 471 */ |
| 180 | 472 } |
| 473 | |
|
176
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
158
diff
changeset
|
474 if (general_options & OPT_GEN_DEBUG) |
|
c99d0b82c8a8
[gaim-migrate @ 186]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
158
diff
changeset
|
475 show_debug(NULL); |
| 1 | 476 |
|
216
f7e17fb767eb
[gaim-migrate @ 226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
477 gdk_threads_enter(); |
|
f7e17fb767eb
[gaim-migrate @ 226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
478 |
| 1 | 479 #ifdef USE_APPLET |
| 480 applet_widget_register_callback(APPLET_WIDGET(applet), | |
| 481 "prefs", | |
| 482 _("Preferences"), | |
| 483 show_prefs, | |
| 484 NULL); | |
| 485 applet_widget_register_callback(APPLET_WIDGET(applet), | |
| 486 "signon", | |
| 487 _("Signon"), | |
| 488 applet_show_login, | |
| 489 NULL); | |
|
97
5b4b7aa8dd9a
[gaim-migrate @ 107]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
490 #ifdef GAIM_PLUGINS |
|
96
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
491 applet_widget_register_callback(APPLET_WIDGET(applet), |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
492 "plugins", |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
493 _("Plugins"), |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
494 GTK_SIGNAL_FUNC(show_plugins), |
|
247f540ea6e1
[gaim-migrate @ 106]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
94
diff
changeset
|
495 NULL); |
|
97
5b4b7aa8dd9a
[gaim-migrate @ 107]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
96
diff
changeset
|
496 #endif /* GAIM_PLUGINS */ |
| 1 | 497 |
| 498 if((general_options & OPT_GEN_AUTO_LOGIN) && | |
| 499 (general_options & OPT_GEN_REMEMBER_PASS)) { | |
| 500 | |
| 501 applet_show_login(APPLET_WIDGET(applet), NULL); | |
| 502 } | |
| 82 | 503 |
| 504 update_pixmaps(); | |
| 1 | 505 |
| 506 applet_widget_gtk_main(); | |
| 507 #else | |
| 508 | |
| 509 | |
| 510 show_login(); | |
| 511 gtk_main(); | |
| 512 | |
| 513 #endif /* USE_APPLET */ | |
|
216
f7e17fb767eb
[gaim-migrate @ 226]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
200
diff
changeset
|
514 gdk_threads_leave(); |
| 1 | 515 |
| 516 return 0; | |
| 517 | |
| 518 } |
