Yattm - unified GTK instant-messaging client | |
[Generated for version 0.2-17 - Mon Jan 6 19:01:23 GMT+1 2003] |
#include "intl.h"
#include <string.h>
#include "status.h"
#include "globals.h"
#include "util.h"
#include "dialog.h"
#include "add_contact_window.h"
#include "pixmaps/tb_preferences.xpm"
#include "pixmaps/cancel.xpm"
Include dependency graph for add_contact_window.c:
Go to the source code of this file.
Defines | |
#define | COMBO_TEXT(x) gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(x)->entry)) |
Functions | |
void | destroy (GtkWidget *widget, gpointer data) |
gint | strcasecmp_glist (gconstpointer a, gconstpointer b) |
GList * | get_groups () |
GList * | get_contacts (gchar *group) |
GList * | get_all_contacts () |
GList * | get_accounts (gchar *contact) |
GList * | get_eb_accounts (gchar *contact) |
GList * | get_all_accounts (int serviceid) |
void | dif_group (GtkEditable *editable, gpointer user_data) |
void | set_con (GtkEditable *editable, gpointer user_data) |
void | con_modified (GtkEditable *editable, gpointer user_data) |
void | add_button_callback (GtkButton *button, gpointer userdata) |
void | show_add_defined_contact_window (struct contact *cont, grouplist *grp) |
void | show_add_contact_window () |
void | show_add_contact_to_group_window (grouplist *g) |
void | show_add_group_window () |
void | show_add_account_to_contact_window (struct contact *cont) |
Variables | |
gint | window_open = 0 |
GtkWidget * | add_contact_window |
GtkWidget * | service_list |
GtkWidget * | account_name |
GtkWidget * | contact_name |
GtkWidget * | group_name |
int | flag |
int | contact_input_handler |
|
Definition at line 53 of file add_contact_window.c. Referenced by add_button_callback(), dif_group(), draw_edit_account_window(), group_changed(), ok_callback(), and show_add_defined_contact_window(). |
|
Definition at line 214 of file add_contact_window.c. References _, account_name, add_account(), add_contact_window, add_group(), add_new_contact(), COMBO_TEXT, contact_name, do_error_dialog(), find_contact_by_nick(), find_grouplist_by_name(), get_service_id(), group_name, contact::nick, account::service_id, service_list, update_contact_list(), and write_contact_list(). Referenced by show_add_defined_contact_window().
00215 { 00216 grouplist *gl; 00217 struct contact *con; 00218 gchar *service = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(service_list)->entry)); 00219 gchar *account = gtk_entry_get_text(GTK_ENTRY(account_name)); 00220 00221 gint service_id = get_service_id( service ); 00222 00223 eb_account *ea = eb_services[service_id].sc->new_account(account); 00224 ea->service_id = service_id; 00225 00226 if (eb_services[service_id].sc->check_login) { 00227 char *buf = NULL; 00228 char *err = eb_services[service_id].sc->check_login((char *)account, (char *)""); 00229 if (err != NULL) { 00230 buf = g_strdup_printf(_("The account is not syntaxically correct:\n%s"), err); 00231 g_free(err); 00232 do_error_dialog(buf, _("Error")); 00233 g_free(buf); 00234 return; 00235 } 00236 } 00237 gl = find_grouplist_by_name(COMBO_TEXT(group_name)); 00238 con = find_contact_by_nick(COMBO_TEXT(contact_name)); 00239 00240 if(!gl) { 00241 add_group(COMBO_TEXT(group_name)); 00242 gl = find_grouplist_by_name(COMBO_TEXT(group_name)); 00243 } 00244 00245 if(!con) { 00246 con = add_new_contact(COMBO_TEXT(group_name), COMBO_TEXT(contact_name), ea->service_id); 00247 } 00248 00249 add_account(con->nick, ea); 00250 update_contact_list (); 00251 write_contact_list(); 00252 gtk_widget_destroy(add_contact_window); 00253 } |
|
Definition at line 209 of file add_contact_window.c. References flag. Referenced by show_add_defined_contact_window().
00210 { 00211 flag = 1; 00212 } |
|
Definition at line 55 of file add_contact_window.c. References window_open. Referenced by show_add_defined_contact_window().
00056 { 00057 window_open = 0; 00058 } |
|
Definition at line 182 of file add_contact_window.c. References COMBO_TEXT, contact_input_handler, contact_name, get_contacts(), and group_name. Referenced by show_add_defined_contact_window().
00183 { 00184 GList * list = get_contacts(COMBO_TEXT(group_name)); 00185 gtk_signal_handler_block(GTK_OBJECT(GTK_COMBO(contact_name)->entry), 00186 contact_input_handler); 00187 gtk_combo_set_popdown_strings(GTK_COMBO(contact_name), list); 00188 g_list_free(list); 00189 gtk_signal_handler_unblock(GTK_OBJECT(GTK_COMBO(contact_name)->entry), 00190 contact_input_handler); 00191 } |
|
Definition at line 127 of file add_contact_window.c. References contact::accounts, and find_contact_by_nick().
00128 { 00129 GList *node = NULL, *newlist = NULL; 00130 struct contact * c; 00131 00132 c = find_contact_by_nick(contact); 00133 00134 if(c) 00135 node = c->accounts; 00136 00137 while(node) { 00138 newlist = g_list_append(newlist, ((eb_account *)node->data)->handle); 00139 node = node->next; 00140 } 00141 00142 return newlist; 00143 } |
|
Definition at line 163 of file add_contact_window.c. References get_all_contacts(), get_eb_accounts(), account::handle, and account::service_id.
00164 { 00165 GList *node = get_all_contacts(); 00166 GList *newlist = NULL; 00167 00168 while(node) { 00169 GList * g = get_eb_accounts(((struct contact*)node->data)->nick); 00170 while (g) { 00171 eb_account *ac = (eb_account *)g->data; 00172 if (ac->service_id == serviceid) 00173 newlist = g_list_append(newlist, ac->handle); 00174 g = g->next; 00175 } 00176 node = node->next; 00177 } 00178 00179 return newlist; 00180 } |
|
Definition at line 109 of file add_contact_window.c. References get_contacts(), and get_groups(). Referenced by get_all_accounts(), and show_add_defined_contact_window().
00110 { 00111 GList *node = get_groups(); 00112 GList *newlist = NULL; 00113 00114 while(node) { 00115 GList * g = get_contacts(node->data); 00116 newlist = g_list_concat(newlist, g); 00117 node = node->next; 00118 } 00119 00120 return newlist; 00121 } |
|
Definition at line 91 of file add_contact_window.c. References find_grouplist_by_name(), _grouplist::members, and strcasecmp_glist().
00092 { 00093 GList *node = NULL, *newlist = NULL; 00094 grouplist *g; 00095 00096 g = find_grouplist_by_name(group); 00097 00098 if(g) 00099 node = g->members; 00100 00101 while(node) { 00102 newlist = g_list_insert_sorted(newlist, ((struct contact *)node->data)->nick, strcasecmp_glist); 00103 node = node->next; 00104 } 00105 00106 return newlist; 00107 } |
|
Definition at line 145 of file add_contact_window.c. References contact::accounts, and find_contact_by_nick(). Referenced by get_all_accounts().
00146 { 00147 GList *node = NULL, *newlist = NULL; 00148 struct contact * c; 00149 00150 c = find_contact_by_nick(contact); 00151 00152 if(c) 00153 node = c->accounts; 00154 00155 while(node) { 00156 newlist = g_list_append(newlist, ((eb_account *)node->data)); 00157 node = node->next; 00158 } 00159 00160 return newlist; 00161 } |
|
Definition at line 71 of file add_contact_window.c. Referenced by draw_edit_account_window(), edit_contact_window_new(), get_all_contacts(), and show_add_defined_contact_window().
00072 { 00073 GList * node = NULL; 00074 GList * newlist = NULL; 00075 node = groups; 00076 00077 while(node) { 00078 newlist = g_list_append(newlist, ((grouplist *)node->data)->name); 00079 node = node->next; 00080 } 00081 00082 return newlist; 00083 } |
|
Definition at line 195 of file add_contact_window.c. References account_name, contact_input_handler, contact_name, and flag. Referenced by show_add_defined_contact_window().
00196 { 00197 if(flag == 0){ 00198 gtk_signal_handler_block(GTK_OBJECT(GTK_COMBO(contact_name)->entry), 00199 contact_input_handler); 00200 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(contact_name)->entry), 00201 gtk_entry_get_text(GTK_ENTRY(account_name))); 00202 gtk_signal_handler_unblock(GTK_OBJECT(GTK_COMBO(contact_name)->entry), 00203 contact_input_handler); 00204 } 00205 } |
|
Definition at line 500 of file add_contact_window.c. References show_add_defined_contact_window(). Referenced by add_account_to_contact_callback().
00501 { 00502 show_add_defined_contact_window(cont, NULL); 00503 } |
|
Definition at line 490 of file add_contact_window.c. References show_add_defined_contact_window(). Referenced by add_to_group_callback().
00491 { 00492 show_add_defined_contact_window(NULL, g); 00493 } |
|
Definition at line 485 of file add_contact_window.c. References show_add_defined_contact_window(). Referenced by add_callback().
00486 { 00487 show_add_defined_contact_window(NULL, NULL); 00488 } |
|
Definition at line 259 of file add_contact_window.c. References _, account_name, add_button_callback(), add_contact_window, COMBO_TEXT, con_modified(), contact_input_handler, contact_name, destroy(), dif_group(), eb_icon(), get_all_contacts(), get_groups(), get_service_list(), contact::group, group_name, _grouplist::name, contact::nick, service_list, set_con(), and window_open. Referenced by show_add_account_to_contact_window(), show_add_contact_to_group_window(), and show_add_contact_window().
00260 { 00261 /* 00262 * if the add contact window is already open, we don't want to 00263 * do anything 00264 */ 00265 00266 if(!window_open) { 00267 GtkWidget *hbox; 00268 GtkWidget *hbox2; 00269 GtkWidget *vbox; 00270 GtkWidget *label; 00271 GtkWidget *button; 00272 GtkWidget *iconwid; 00273 GtkWidget *table; 00274 GtkWidget *frame; 00275 GtkWidget *separator; 00276 GList *list; 00277 GdkPixmap *icon; 00278 GdkBitmap *mask; 00279 00280 add_contact_window = gtk_window_new(GTK_WINDOW_DIALOG); 00281 gtk_window_set_position(GTK_WINDOW(add_contact_window), GTK_WIN_POS_MOUSE); 00282 gtk_widget_realize(add_contact_window); 00283 gtk_container_set_border_width(GTK_CONTAINER(add_contact_window), 5); 00284 00285 table = gtk_table_new(2, 4, FALSE); 00286 gtk_table_set_row_spacings(GTK_TABLE(table), 5); 00287 gtk_table_set_row_spacings(GTK_TABLE(table), 5); 00288 gtk_container_set_border_width(GTK_CONTAINER(table), 5); 00289 vbox = gtk_vbox_new(FALSE, 5); 00290 hbox = gtk_hbox_new(FALSE, 0); 00291 00292 /*Section for adding account*/ 00293 00294 label = gtk_label_new(_("Account:")); 00295 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 5); 00296 gtk_widget_show(label); 00297 gtk_table_attach(GTK_TABLE(table), hbox, 0, 1, 0, 1, GTK_EXPAND, GTK_EXPAND, 0, 0); 00298 gtk_widget_show(hbox); 00299 00300 account_name = gtk_entry_new(); 00301 if (cont == NULL) 00302 gtk_signal_connect(GTK_OBJECT(GTK_ENTRY(account_name)), "changed", 00303 GTK_SIGNAL_FUNC(set_con), NULL); 00304 gtk_table_attach(GTK_TABLE(table), account_name, 1, 2, 0, 1, GTK_FILL, GTK_FILL, 0, 0); 00305 gtk_widget_show(account_name); 00306 00307 /*Section for declaring the protocol*/ 00308 00309 hbox = gtk_hbox_new(FALSE, 0); 00310 00311 label = gtk_label_new(_("Protocol:")); 00312 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 5); 00313 gtk_widget_show(label); 00314 gtk_table_attach(GTK_TABLE(table), hbox, 2, 3, 0, 1, GTK_EXPAND, GTK_EXPAND, 0, 0); 00315 gtk_widget_show(hbox); 00316 00317 /*List of Protocols*/ 00318 00319 service_list = gtk_combo_new(); 00320 list = get_service_list(); 00321 gtk_combo_set_popdown_strings(GTK_COMBO(service_list), list ); 00322 g_list_free(list); 00323 gtk_table_attach(GTK_TABLE(table), service_list, 3, 4, 0, 1, GTK_EXPAND, GTK_EXPAND, 0, 0); 00324 gtk_widget_show(service_list); 00325 00326 /*Section for Group declaration*/ 00327 00328 hbox = gtk_hbox_new(FALSE, 0); 00329 00330 label = gtk_label_new(_("Group:")); 00331 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 0); 00332 gtk_widget_show(label); 00333 gtk_table_attach(GTK_TABLE(table), hbox, 0, 1, 1, 2, GTK_EXPAND, GTK_EXPAND, 0, 0); 00334 gtk_widget_show(hbox); 00335 00336 /*List of available groups*/ 00337 00338 group_name = gtk_combo_new(); 00339 list = get_groups(); 00340 gtk_combo_set_popdown_strings(GTK_COMBO(group_name), list ); 00341 00342 if(strlen(COMBO_TEXT(group_name)) == 0) { 00343 if(cont != NULL) 00344 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(group_name)->entry), cont->group->name); 00345 else if (grp != NULL) 00346 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(group_name)->entry), grp->name); 00347 else 00348 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(group_name)->entry), _("Buddies")); 00349 } else if(cont != NULL) { 00350 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(group_name)->entry), cont->group->name); 00351 } else if (grp != NULL) { 00352 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(group_name)->entry), grp->name); 00353 } 00354 g_list_free(list); 00355 gtk_signal_connect(GTK_OBJECT(GTK_COMBO(group_name)->entry), "changed", 00356 GTK_SIGNAL_FUNC(dif_group), NULL); 00357 gtk_table_attach(GTK_TABLE(table), group_name, 1, 2, 1, 2, GTK_EXPAND, GTK_EXPAND, 0, 0); 00358 gtk_widget_show(group_name); 00359 00360 /*Section for Contact Name*/ 00361 00362 hbox = gtk_hbox_new(FALSE, 0); 00363 00364 label = gtk_label_new(_("Contact:")); 00365 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 5); 00366 gtk_widget_show(label); 00367 gtk_table_attach(GTK_TABLE(table), hbox, 2, 3, 1, 2, GTK_EXPAND, GTK_EXPAND, 0, 0); 00368 gtk_widget_show(hbox); 00369 00370 /*List of available contacts*/ 00371 00372 contact_name = gtk_combo_new(); 00373 list = get_all_contacts(); 00374 gtk_combo_set_popdown_strings(GTK_COMBO(contact_name), list ); 00375 if(cont != NULL) 00376 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(contact_name)->entry), cont->nick); 00377 else 00378 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(contact_name)->entry), ""); 00379 g_list_free(list); 00380 contact_input_handler = gtk_signal_connect(GTK_OBJECT(GTK_ENTRY(GTK_COMBO(contact_name)->entry)), "changed", 00381 GTK_SIGNAL_FUNC(con_modified), NULL); 00382 gtk_table_attach(GTK_TABLE(table), contact_name, 3, 4, 1, 2, GTK_EXPAND, GTK_EXPAND, 0, 0); 00383 gtk_widget_show(contact_name); 00384 00385 /*Lets create a frame to put all of this in*/ 00386 00387 frame = gtk_frame_new(NULL); 00388 gtk_frame_set_label(GTK_FRAME(frame), _("Add Contact")); 00389 00390 gtk_container_add(GTK_CONTAINER(frame), table); 00391 gtk_widget_show(table); 00392 00393 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); 00394 gtk_widget_show(frame); 00395 00396 /*Lets try adding a seperator*/ 00397 00398 separator = gtk_hseparator_new(); 00399 gtk_box_pack_start(GTK_BOX(vbox), separator, FALSE, FALSE, 5); 00400 gtk_widget_show(separator); 00401 00402 hbox = gtk_hbox_new(FALSE, 5); 00403 hbox2 = gtk_hbox_new(TRUE, 5); 00404 00405 /*Add Button*/ 00406 00407 gtk_widget_set_usize(hbox2, 200,25); 00408 00409 icon = gdk_pixmap_create_from_xpm_d(add_contact_window->window, &mask, NULL, tb_preferences_xpm); 00410 iconwid = gtk_pixmap_new(icon, mask); 00411 label = gtk_label_new(_("Add")); 00412 00413 gtk_box_pack_start(GTK_BOX(hbox), iconwid, FALSE, FALSE, 2); 00414 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2); 00415 00416 gtk_widget_show(iconwid); 00417 gtk_widget_show(label); 00418 00419 button = gtk_button_new(); 00420 00421 gtk_signal_connect(GTK_OBJECT(button), "clicked", 00422 GTK_SIGNAL_FUNC(add_button_callback), 00423 NULL); 00424 gtk_widget_show(hbox); 00425 00426 gtk_container_add(GTK_CONTAINER(button), hbox); 00427 00428 gtk_box_pack_start(GTK_BOX(hbox2), button, TRUE, TRUE, 0); 00429 gtk_widget_show(button); 00430 00431 /*Cancel Button*/ 00432 00433 hbox = gtk_hbox_new(FALSE, 5); 00434 icon = gdk_pixmap_create_from_xpm_d(add_contact_window->window, &mask, NULL, cancel_xpm); 00435 iconwid = gtk_pixmap_new(icon, mask); 00436 label = gtk_label_new(_("Cancel")); 00437 00438 gtk_box_pack_start(GTK_BOX(hbox), iconwid, FALSE, FALSE, 2); 00439 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2); 00440 00441 gtk_widget_show(iconwid); 00442 gtk_widget_show(label); 00443 00444 button = gtk_button_new(); 00445 00446 gtk_signal_connect_object(GTK_OBJECT(button), "clicked", 00447 GTK_SIGNAL_FUNC(gtk_widget_destroy), 00448 GTK_OBJECT(add_contact_window)); 00449 gtk_widget_show(hbox); 00450 00451 gtk_container_add(GTK_CONTAINER (button), hbox); 00452 00453 gtk_box_pack_start(GTK_BOX(hbox2), button, TRUE, TRUE, 0); 00454 gtk_widget_show(button); 00455 00456 /*Buttons End*/ 00457 00458 hbox = gtk_hbox_new(FALSE, 0); 00459 table = gtk_table_new(1, 1, FALSE); 00460 00461 gtk_box_pack_end(GTK_BOX(hbox),hbox2, FALSE, FALSE, 0); 00462 gtk_widget_show(hbox2); 00463 00464 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); 00465 gtk_widget_show(hbox); 00466 00467 gtk_table_attach(GTK_TABLE(table), vbox, 0, 1, 0, 1, GTK_EXPAND, GTK_EXPAND, 0, 0); 00468 gtk_widget_show(vbox); 00469 00470 gtk_container_add(GTK_CONTAINER(add_contact_window), table); 00471 gtk_widget_show(table); 00472 00473 gtk_window_set_title(GTK_WINDOW(add_contact_window), _("Yattm - Add Contact")); 00474 gtk_window_set_focus(GTK_WINDOW(add_contact_window), account_name); 00475 eb_icon(add_contact_window->window); 00476 gtk_widget_show(add_contact_window); 00477 00478 gtk_signal_connect(GTK_OBJECT(add_contact_window), "destroy", 00479 GTK_SIGNAL_FUNC(destroy), NULL); 00480 00481 window_open = 1; 00482 } 00483 } |
|
Definition at line 495 of file add_contact_window.c. References edit_group_window_new(). Referenced by add_group_callback().
00496 { 00497 edit_group_window_new(NULL); 00498 } |
|
Definition at line 60 of file add_contact_window.c. Referenced by get_contacts().
00061 { 00062 return strcasecmp((const char *)a, (const char *)b); 00063 } |
|
Definition at line 47 of file add_contact_window.c. Referenced by add_button_callback(), set_con(), and show_add_defined_contact_window(). |
|
Definition at line 45 of file add_contact_window.c. Referenced by add_button_callback(), and show_add_defined_contact_window(). |
|
Definition at line 51 of file add_contact_window.c. Referenced by dif_group(), set_con(), and show_add_defined_contact_window(). |
|
Definition at line 48 of file add_contact_window.c. Referenced by add_button_callback(), dif_group(), set_con(), and show_add_defined_contact_window(). |
|
Definition at line 50 of file add_contact_window.c. Referenced by con_modified(), and set_con(). |
|
Definition at line 49 of file add_contact_window.c. Referenced by add_button_callback(), dif_group(), and show_add_defined_contact_window(). |
|
Definition at line 46 of file add_contact_window.c. Referenced by add_button_callback(), and show_add_defined_contact_window(). |
|
Definition at line 44 of file add_contact_window.c. Referenced by destroy(), and show_add_defined_contact_window(). |