Yattm - unified GTK instant-messaging client logo
   [Generated for version 0.2-17 - Mon Jan 6 19:01:23 GMT+1 2003]

Home - Main Page - Data Structures - File List - Data Fields - Globals

chat_room.c

Go to the documentation of this file.
00001 #ifdef HAVE_CONFIG_H
00002 #  include <config.h>
00003 #endif
00004 
00005 #include <string.h>
00006 #include "globals.h"
00007 #include "intl.h"
00008 #include "gtk_eb_html.h"
00009 #include "util.h"
00010 #include "sound.h"
00011 #include "dialog.h"
00012 #include "smileys.h"
00013 
00014 #include "pixmaps/tb_mail_send.xpm"
00015 #include "pixmaps/cancel.xpm"
00016 #include "pixmaps/ok.xpm"
00017 #include "pixmaps/tb_volume.xpm"
00018 
00019 GList * chat_rooms = NULL;
00020 
00021 static GList * get_contacts( eb_chat_room * room );
00022 static void send_message( GtkWidget * widget, gpointer data )
00023 {
00024     eb_chat_room * ecr = (eb_chat_room *)data;
00025 
00026     RUN_SERVICE(ecr->chat_room_account)->send_chat_room_message(ecr,
00027                         gtk_entry_get_text(GTK_ENTRY(ecr->entry)));
00028 
00029     if(ecr->sound_enabled && ecr->send_enabled)
00030         play_sound(SEND);
00031     gtk_entry_set_text(GTK_ENTRY(ecr->entry), "");
00032 }
00033 
00034 static void set_sound_on_toggle(GtkWidget * sound_button, gpointer userdata)
00035 {
00036   eb_chat_room * cr = (eb_chat_room *)userdata;
00037    
00038   /*Set the sound_enable variable depending on the toggle button*/
00039    
00040   if (GTK_TOGGLE_BUTTON (sound_button)->active)
00041     cr->sound_enabled = TRUE;
00042   else
00043     cr->sound_enabled = FALSE;
00044 }
00045 
00046 static GList * chat_service_list()
00047 {
00048     GList * list = NULL;
00049     int i;
00050     for(i = 0; i < NUM_SERVICES; i++ )
00051     {
00052         if(eb_services[i].group_chat)
00053         {
00054             list = g_list_append(list, eb_services[i].name);
00055         }
00056     }
00057     return list;
00058 }
00059 
00060 static void invite_callback( GtkWidget * widget, gpointer data )
00061 {
00062     eb_chat_room * ecr = data;
00063     RUN_SERVICE(ecr->chat_room_account)->send_invite(
00064                 ecr->chat_room_account, ecr,
00065                 gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(ecr->invite_buddy)->entry)),
00066                 gtk_entry_get_text(GTK_ENTRY(ecr->invite_message)));
00067 
00068     gtk_widget_destroy(ecr->invite_window);
00069 }
00070 
00071 static void destroy_invite( GtkWidget * widget, gpointer data )
00072 {
00073     eb_chat_room * ecr = data;
00074     ecr->invite_window_is_open = 0;
00075 }
00076 
00077 void do_invite_window(eb_chat_room * room )
00078 {
00079     GtkWidget * box;
00080     GtkWidget * box2;
00081     GtkWidget * label;
00082     GList * list;
00083     
00084     if( !room || room->invite_window_is_open )
00085     {
00086         return;
00087     }
00088 
00089     room->invite_window = gtk_window_new(GTK_WINDOW_DIALOG);
00090     gtk_window_set_position(GTK_WINDOW(room->invite_window), GTK_WIN_POS_MOUSE);
00091     box = gtk_vbox_new(FALSE, 3);
00092     box2 = gtk_hbox_new(FALSE, 3);
00093 
00094     label = gtk_label_new(_("Handle:"));
00095     gtk_container_add(GTK_CONTAINER(box2), label);
00096     gtk_widget_show(label);
00097 
00098     room->invite_buddy = gtk_combo_new();
00099     list = get_contacts(room);
00100     gtk_combo_set_popdown_strings(GTK_COMBO(room->invite_buddy), list);
00101     gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(room->invite_buddy)->entry), "");
00102     gtk_container_add(GTK_CONTAINER(box2), room->invite_buddy);
00103     gtk_widget_show(room->invite_buddy);
00104 
00105     gtk_container_add(GTK_CONTAINER(box), box2);
00106     gtk_widget_show(box2);
00107 
00108     box2 = gtk_hbox_new(FALSE,3);
00109     label = gtk_label_new(_("Message:"));
00110     gtk_container_add(GTK_CONTAINER(box2), label);
00111     gtk_widget_show(label);
00112 
00113     room->invite_message = gtk_entry_new();
00114     gtk_container_add(GTK_CONTAINER(box2), room->invite_message );
00115     gtk_widget_show(room->invite_message );
00116 
00117     gtk_container_add(GTK_CONTAINER(box), box2);
00118     gtk_widget_show(box2);
00119 
00120     label = gtk_button_new_with_label(_("Invite"));
00121     gtk_container_add(GTK_CONTAINER(box), label);
00122     gtk_widget_show(label);
00123 
00124 
00125     gtk_signal_connect(GTK_OBJECT(label), "clicked", invite_callback, room);
00126 
00127     gtk_container_add(GTK_CONTAINER(room->invite_window), box);
00128     gtk_widget_show(box);
00129 
00130     gtk_widget_show(room->invite_window);
00131     
00132     
00133     gtk_signal_connect( GTK_OBJECT(room->invite_window), "destroy",
00134                         GTK_SIGNAL_FUNC(destroy_invite), room);
00135 
00136 }
00137 
00138     
00139 
00140 static gboolean join_service_is_open = 0;
00141 
00142 static GtkWidget * chat_room_name;
00143 static GtkWidget * chat_room_type;
00144 static GtkWidget * join_chat_window;
00145 
00146 static void join_chat_callback(GtkWidget * widget, gpointer data )
00147 {
00148     int id = get_service_id(gtk_entry_get_text(
00149                 GTK_ENTRY(GTK_COMBO(chat_room_type)->entry)));
00150     
00151 
00152     eb_start_chat_room(id, gtk_entry_get_text(GTK_ENTRY(chat_room_name)));
00153     gtk_widget_destroy(join_chat_window);
00154 }
00155 
00156 static void join_chat_destroy(GtkWidget * widget, gpointer data )
00157 {
00158     join_service_is_open = 0;
00159 }
00160 
00161 /*
00162  *  Let's build ourselfs a nice little dialog window to
00163  *  ask us what chat window we want to join :)
00164  */
00165 
00166 void open_join_chat_window()
00167 {
00168     GtkWidget * label;
00169     GtkWidget * frame;
00170     GtkWidget * table;
00171     GtkWidget * vbox;
00172     GtkWidget * hbox;
00173     GtkWidget * hbox2;
00174     GtkWidget * button;
00175     GtkWidget * iconwid;
00176     GtkWidget * separator;
00177     GdkPixmap * icon;
00178     GdkBitmap * mask;
00179     GList * list;
00180 
00181     if(join_service_is_open)
00182     {
00183         return;
00184     }
00185     join_service_is_open = 1;
00186 
00187     join_chat_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
00188 
00189     gtk_widget_realize(join_chat_window);
00190 
00191     vbox = gtk_vbox_new(FALSE, 5);
00192 
00193     gtk_container_add(GTK_CONTAINER(join_chat_window), vbox);
00194 
00195     table = gtk_table_new(2, 2, FALSE);
00196 
00197     label = gtk_label_new(_("Chat Room Name:"));
00198     gtk_table_attach_defaults (GTK_TABLE(table), label, 0, 1, 0, 1);
00199     gtk_widget_show(label);
00200 
00201     chat_room_name = gtk_entry_new();
00202     gtk_table_attach_defaults (GTK_TABLE(table), chat_room_name, 1, 2, 0, 1);
00203     gtk_widget_show(chat_room_name);
00204 
00205     label = gtk_label_new(_("Service Type:"));
00206     gtk_table_attach_defaults (GTK_TABLE(table), label, 0, 1, 1, 2);
00207     gtk_widget_show(label);
00208 
00209     chat_room_type = gtk_combo_new();
00210     list = chat_service_list();
00211     gtk_combo_set_popdown_strings(GTK_COMBO(chat_room_type), list);
00212     g_list_free(list);
00213     gtk_table_attach_defaults (GTK_TABLE(table), chat_room_type, 1, 2, 1, 2);
00214     gtk_widget_show(chat_room_type);
00215 
00216     /* set up a frame (hopefully) */
00217 
00218     frame = gtk_frame_new(NULL);
00219     gtk_frame_set_label(GTK_FRAME(frame), _("Join a Chat Room"));
00220 
00221     gtk_container_add(GTK_CONTAINER(frame), table);
00222     gtk_widget_show(table);
00223 
00224     gtk_table_set_row_spacings (GTK_TABLE(table), 5);
00225     gtk_table_set_col_spacings (GTK_TABLE(table), 5);
00226     
00227     /* This is a test to see if I can make some padding action happen */
00228 
00229     gtk_container_set_border_width(GTK_CONTAINER(join_chat_window), 5);
00230     gtk_container_set_border_width(GTK_CONTAINER(table), 5);
00231     
00232     gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
00233     
00234     /* Window resize BAD, Same size GOOD */
00235 
00236     gtk_window_set_policy (GTK_WINDOW(join_chat_window), FALSE, FALSE, TRUE);
00237 
00238     /* Show the frame and window */
00239     
00240     gtk_widget_show(frame);
00241     
00242     /* add in that nice separator */
00243     
00244     separator = gtk_hseparator_new();
00245     gtk_box_pack_start(GTK_BOX(vbox), separator, FALSE, FALSE, 5);
00246     gtk_widget_show(separator);
00247     
00248     /* Add in the pretty buttons with pixmaps on them */
00249 
00250     hbox = gtk_hbox_new(FALSE, 5);
00251     hbox2 = gtk_hbox_new(TRUE, 5);
00252 
00253     gtk_widget_set_usize(hbox2, 200, 25);
00254     
00255     /* stuff for the join button */
00256     
00257     icon = gdk_pixmap_create_from_xpm_d(join_chat_window->window, &mask, NULL, ok_xpm);
00258     iconwid = gtk_pixmap_new(icon, mask);
00259     label = gtk_label_new(_("Join"));
00260                                 
00261     gtk_box_pack_start(GTK_BOX(hbox), iconwid, FALSE, FALSE, 2); 
00262     gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
00263     
00264     gtk_widget_show(iconwid);
00265     gtk_widget_show(label);
00266 
00267     button = gtk_button_new();
00268 
00269     gtk_signal_connect(GTK_OBJECT(button), "clicked",
00270                     GTK_SIGNAL_FUNC(join_chat_callback),
00271                     NULL);
00272     gtk_widget_show(hbox);
00273 
00274     gtk_container_add(GTK_CONTAINER(button), hbox);
00275     gtk_box_pack_start(GTK_BOX(hbox2), button, TRUE, TRUE, 0);
00276     gtk_widget_show(button);
00277     
00278     
00279     /* stuff for the cancel button */
00280 
00281     hbox = gtk_hbox_new(FALSE, 5);
00282     
00283     icon = gdk_pixmap_create_from_xpm_d(join_chat_window->window, &mask, NULL, cancel_xpm);
00284     iconwid = gtk_pixmap_new(icon, mask);
00285     label = gtk_label_new(_("Cancel"));
00286 
00287     gtk_box_pack_start(GTK_BOX(hbox), iconwid, FALSE, FALSE, 2); 
00288     gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
00289 
00290     gtk_widget_show(iconwid);
00291     gtk_widget_show(label);
00292 
00293     button = gtk_button_new();
00294 
00295     gtk_signal_connect_object(GTK_OBJECT(button), "clicked",
00296                         GTK_SIGNAL_FUNC(gtk_widget_destroy),
00297                         GTK_OBJECT(join_chat_window));
00298     gtk_widget_show(hbox);
00299 
00300     gtk_container_add(GTK_CONTAINER(button), hbox);
00301 
00302     gtk_box_pack_start(GTK_BOX(hbox2), button, TRUE, TRUE, 0);
00303     gtk_widget_show(button);
00304 
00305     /* now put the hbox with all the buttons into the vbox? */
00306 
00307     hbox = gtk_hbox_new(FALSE, 0);
00308     
00309     gtk_box_pack_end(GTK_BOX(hbox), hbox2, FALSE, FALSE, 0);
00310     gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
00311 
00312     gtk_widget_show(hbox);
00313     gtk_widget_show(hbox2);
00314     gtk_widget_show(vbox);
00315     
00316     /* show the window */
00317 
00318     gtk_widget_show(join_chat_window);
00319 
00320     gtk_signal_connect( GTK_OBJECT(join_chat_window), "destroy",
00321                 GTK_SIGNAL_FUNC(join_chat_destroy), NULL );
00322 }
00323     
00324 
00325 
00326 
00327 
00328 static void destroy(GtkWidget * widget, gpointer data)
00329 {
00330     eb_chat_room * ecr = data;
00331     RUN_SERVICE(ecr->chat_room_account)->leave_chat_room(ecr);
00332     chat_rooms = g_list_remove(chat_rooms, data);
00333     g_free(ecr);
00334 }
00335 
00336 static GList * find_chat_room_buddy( eb_chat_room * room, gchar * user )
00337 {
00338     GList * node;
00339     for( node = room->fellows; node; node = node->next)
00340     {
00341         eb_chat_room_buddy * ecrb = node->data;
00342         if( !strcmp(user, ecrb->handle) )
00343         {
00344             return node;
00345         }
00346     }
00347     return NULL;
00348 }
00349 
00350 static void eb_chat_room_refresh_list(eb_chat_room * room )
00351 {
00352     GList * node;
00353     gtk_clist_clear(GTK_CLIST(room->online));
00354 
00355     for( node = room->fellows; node; node = node->next )
00356     {
00357         eb_chat_room_buddy * ecrb = node->data;
00358         gchar * list[1] = {ecrb->alias};
00359         gtk_clist_append(GTK_CLIST(room->online), list);
00360     }
00361 }
00362 
00363 gboolean eb_chat_room_buddy_connected(eb_chat_room * room, gchar * user)
00364 {
00365     return find_chat_room_buddy(room, user) != NULL;
00366 }
00367 
00368 void eb_chat_room_buddy_arrive( eb_chat_room * room, gchar * alias, gchar * handle )
00369 {
00370     eb_chat_room_buddy * ecrb = g_new0(eb_chat_room_buddy, 1 );
00371 
00372         gchar buff[2048];
00373         g_snprintf(buff, 2048, _("<i>%s has joined the chat</i>"), handle);
00374         eb_chat_room_show_3rdperson(room, buff);
00375 
00376 
00377     strcpy( ecrb->alias, alias);
00378     strcpy( ecrb->handle, handle );
00379 
00380     room->fellows = g_list_append(room->fellows, ecrb);
00381 
00382     eb_chat_room_refresh_list(room);
00383 }
00384 
00385 void eb_chat_room_buddy_leave( eb_chat_room * room, gchar * handle )
00386 {
00387     GList * node = find_chat_room_buddy(room, handle);
00388 
00389         gchar buff[2048];
00390         g_snprintf(buff, 2048, _("<i>%s has left the chat</i>"), handle);
00391         eb_chat_room_show_3rdperson(room, buff);
00392 
00393     if(node)
00394     {
00395         eb_chat_room_buddy * ecrb = node->data;
00396         room->fellows = g_list_remove_link(room->fellows, node);
00397         g_free(ecrb);
00398     }
00399     eb_chat_room_refresh_list(room);
00400 }
00401 
00402 
00403 
00404 void eb_start_chat_room( gint service, gchar * name )
00405 {
00406     eb_local_account * ela =  find_suitable_local_account(NULL, service);
00407     eb_chat_room * ecb = NULL;
00408 
00409     /* if we don't have a working account just bail right now */
00410 
00411     if( !ela )
00412         return;
00413 
00414     ecb = RUN_SERVICE(ela)->make_chat_room(name, ela);
00415     ecb->service_id = service;
00416 
00417     if( ecb )
00418     {
00419         chat_rooms = g_list_append(chat_rooms, ecb);
00420     }
00421 }
00422 
00423 
00424 void eb_chat_room_show_3rdperson( eb_chat_room * chat_room, gchar * message)
00425 {
00426     gtk_eb_html_add(EXT_GTK_TEXT(chat_room->conversation), message,0,0,0 );
00427     gtk_eb_html_add(EXT_GTK_TEXT(chat_room->conversation), "\n",0,0,0 );
00428 }
00429 
00430 void eb_chat_room_show_message( eb_chat_room * chat_room,
00431                                 gchar * user, gchar * message )
00432 {
00433     gchar buff[2048];
00434     gchar *temp_message, *link_message;
00435     if(!strcmp(chat_room->chat_room_account->handle, user))
00436     {
00437         g_snprintf(buff, 2048, "<FONT COLOR=\"#0000FF\"><B>%s: </B></FONT>",
00438                    chat_room->chat_room_account->alias);
00439     }
00440     else
00441     {
00442 
00443         g_snprintf(buff, 2048, "<FONT COLOR=\"#FF0000\"><B>%s: </B></FONT>",
00444                    user);
00445     }
00446     temp_message = eb_smilify(g_strdup(message), RUN_SERVICE(chat_room->chat_room_account)->get_smileys());
00447     link_message = linkify(temp_message);
00448     
00449     gtk_eb_html_add(EXT_GTK_TEXT(chat_room->conversation), buff,0,0,0 );
00450     gtk_eb_html_add(EXT_GTK_TEXT(chat_room->conversation), link_message,do_ignore_back,do_ignore_fore,do_ignore_font );
00451     gtk_eb_html_add(EXT_GTK_TEXT(chat_room->conversation), "\n",0,0,0 );
00452     
00453     g_free(temp_message);
00454     
00455     if(chat_room->sound_enabled 
00456     && strcmp(chat_room->chat_room_account->handle, user))
00457     {   
00458         if (chat_room->first_message)
00459         {
00460             if (chat_room->first_enabled)
00461             {
00462                 play_sound(FIRSTMSG);
00463                 chat_room->first_message = FALSE;
00464             }
00465             else
00466             {
00467                 play_sound(RECEIVE);
00468                 chat_room->first_message = FALSE;
00469             }
00470         }
00471         else if (chat_room->receive_enabled)
00472             play_sound(RECEIVE);
00473     }
00474 
00475 }
00476 
00477 static void invite_button_callback( GtkWidget * widget, gpointer data )
00478 {
00479     do_invite_window(data);
00480 }
00481 
00482 static void destroy_chat_window(GtkWidget * widget, gpointer data)
00483 {
00484     eb_chat_room * ecr = data;
00485     gtk_widget_destroy(ecr->window);
00486 }
00487 
00488 void eb_join_chat_room( eb_chat_room * chat_room )
00489 {
00490     GtkWidget * vbox;
00491     GtkWidget * vbox2;
00492     GtkWidget * hbox;
00493     GtkWidget * hbox2;
00494     GtkWidget * label;
00495     GtkWidget * scrollwindow = gtk_scrolled_window_new(NULL, NULL);
00496     GtkWidget * toolbar;
00497     GdkPixmap * icon;
00498     GdkBitmap * mask;
00499     GtkWidget * iconwid;
00500     GtkWidget * send_button;
00501     GtkWidget * sound_button;
00502     GtkWidget * close_button;
00503     GtkWidget * separator;
00504     
00505     /*if we are already here, just leave*/
00506     if(chat_room->connected)
00507         return;
00508     
00509     /*otherwise we are going to make ourselves a gui right here*/
00510 
00511     vbox = gtk_vbox_new(FALSE, 1);
00512     hbox = gtk_hpaned_new();
00513 
00514     gtk_paned_set_gutter_size(GTK_PANED(hbox), 20);
00515     
00516     chat_room->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
00517     chat_room->online = gtk_clist_new(1);
00518     gtk_clist_set_column_title(GTK_CLIST(chat_room->online), 0, _("Online"));
00519     gtk_widget_set_usize(chat_room->online, 100, 20 );
00520     chat_room->conversation = ext_gtk_text_new(NULL, NULL);
00521     gtk_widget_set_usize(chat_room->conversation, 400, 200);
00522     gtk_eb_html_init(EXT_GTK_TEXT(chat_room->conversation));
00523     gtk_container_add(GTK_CONTAINER(scrollwindow), chat_room->conversation);
00524     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwindow), 
00525                                    GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
00526 
00527     /*make ourselves something to type into*/
00528     chat_room->entry = gtk_entry_new();
00529 
00530     gtk_signal_connect(GTK_OBJECT(chat_room->entry), "activate",
00531                         GTK_SIGNAL_FUNC(send_message), chat_room );
00532     
00533 
00534     /*
00535     gtk_box_pack_start(GTK_BOX(hbox), scrollwindow, TRUE, TRUE, 3);
00536     gtk_box_pack_start(GTK_BOX(hbox), chat_room->online, FALSE, FALSE, 3);
00537     */
00538     gtk_paned_add1(GTK_PANED(hbox), scrollwindow);
00539     gtk_widget_show(scrollwindow);
00540 
00541     vbox2 = gtk_vbox_new(FALSE, 5);
00542 
00543     scrollwindow = gtk_scrolled_window_new(NULL, NULL);
00544     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwindow), 
00545                                    GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
00546 
00547     gtk_container_add(GTK_CONTAINER(scrollwindow), chat_room->online );
00548     gtk_widget_show(chat_room->online);
00549     
00550 
00551     gtk_box_pack_start(GTK_BOX(vbox2), scrollwindow, TRUE, TRUE, 3 );
00552     gtk_widget_show(scrollwindow);
00553 
00554     label = gtk_button_new_with_label(_("Invite User"));
00555     gtk_signal_connect(GTK_OBJECT(label), "clicked", invite_button_callback, 
00556                         chat_room);
00557 
00558     gtk_box_pack_start(GTK_BOX(vbox2), label, FALSE, FALSE, 3);
00559     gtk_widget_show(label);
00560 
00561     gtk_paned_add2(GTK_PANED(hbox), vbox2);
00562     gtk_widget_show(vbox2);
00563 
00564 
00565     gtk_paned_add2(GTK_PANED(hbox), chat_room->online);
00566     gtk_widget_show(chat_room->conversation);
00567 
00568     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwindow),GTK_POLICY_NEVER, GTK_POLICY_ALWAYS);
00569     gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE,TRUE, 3);
00570     gtk_box_pack_start(GTK_BOX(vbox), chat_room->entry, FALSE, FALSE, 1);
00571     gtk_widget_show(hbox);
00572     gtk_widget_show(chat_room->entry);
00573 
00574     gtk_widget_realize(chat_room->window);
00575     gtk_window_set_title(GTK_WINDOW(chat_room->window), chat_room->room_name);
00576     eb_icon(chat_room->window->window);
00577     gtk_signal_connect(GTK_OBJECT(chat_room->window), "destroy",
00578                        GTK_SIGNAL_FUNC(destroy), chat_room );
00579 
00580     
00581     /* start a toolbar here */
00582     
00583     hbox2 = gtk_hbox_new(FALSE, 0);
00584     gtk_widget_set_usize(hbox2, 200, 25);
00585     
00586     toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS);
00587     gtk_toolbar_set_button_relief(GTK_TOOLBAR(toolbar), GTK_RELIEF_NONE);
00588     gtk_container_set_border_width(GTK_CONTAINER(toolbar), 0);
00589     gtk_toolbar_set_space_size(GTK_TOOLBAR(toolbar), 5);
00590     
00591     icon = gdk_pixmap_create_from_xpm_d(chat_room->window->window, &mask, NULL, tb_volume_xpm);
00592     iconwid = gtk_pixmap_new(icon, mask);
00593     gtk_widget_show(iconwid);
00594     
00595     sound_button = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
00596                         GTK_TOOLBAR_CHILD_TOGGLEBUTTON,
00597                         NULL,
00598                         _("Sound"),
00599                         _("Enable Sounds CTRL+S"),
00600                         _("Sound"),
00601                         iconwid,
00602                         GTK_SIGNAL_FUNC(set_sound_on_toggle),
00603                         chat_room);
00604   /*Toggle the sound button based on preferences*/
00605 
00606     if (do_play_send)
00607         chat_room->send_enabled=TRUE;
00608 
00609     if (do_play_receive)
00610         chat_room->receive_enabled = TRUE;
00611 
00612     if (do_play_first)
00613         chat_room->first_enabled = TRUE;
00614 
00615     if (do_play_send + do_play_receive + do_play_first > 0)
00616         gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(sound_button), TRUE);
00617     else
00618         gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(sound_button), FALSE);
00619 
00620     icon = gdk_pixmap_create_from_xpm_d(chat_room->window->window, &mask, NULL, tb_mail_send_xpm);
00621     iconwid = gtk_pixmap_new(icon, mask);
00622     gtk_widget_show(iconwid);
00623 
00624     gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
00625     separator = gtk_vseparator_new();
00626     gtk_widget_set_usize(GTK_WIDGET(separator), 0, 20);
00627     gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), separator, NULL, NULL);
00628     gtk_widget_show(separator);
00629     gtk_toolbar_append_space(GTK_TOOLBAR(toolbar));
00630 
00631 
00632     
00633     send_button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), 
00634                 "send",
00635                 _("Send Message"),
00636                 "send",
00637                 iconwid,
00638                 GTK_SIGNAL_FUNC(send_message),
00639                 chat_room);
00640     
00641     icon = gdk_pixmap_create_from_xpm_d(chat_room->window->window, &mask, NULL, cancel_xpm);
00642     iconwid = gtk_pixmap_new(icon, mask);
00643     gtk_widget_show(iconwid);
00644 
00645     close_button = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar),
00646                 "close",
00647                 _("Close"),
00648                 "close",
00649                 iconwid,
00650                 GTK_SIGNAL_FUNC(destroy_chat_window),
00651                 chat_room);
00652     
00653     gtk_box_pack_end(GTK_BOX(hbox2), toolbar, FALSE, FALSE, 0);
00654     gtk_widget_show(toolbar);
00655     
00656     gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, 5);
00657     gtk_widget_show(hbox2);
00658     
00659     gtk_container_add(GTK_CONTAINER(chat_room->window), vbox);
00660     gtk_widget_show(vbox);
00661 
00662     gtk_container_set_border_width(GTK_CONTAINER(chat_room->window), 5);
00663     
00664     gtk_widget_show(chat_room->window);
00665 
00666     /*then mark the fact that we have joined that room*/
00667     chat_room->connected = 1;
00668     
00669     /* actually call the callback :P .... */
00670     RUN_SERVICE(chat_room->chat_room_account)->join_chat_room(chat_room);
00671 
00672 }
00673 
00674 static GList * get_group_contacts(gchar *group, eb_chat_room * room)
00675 {
00676     GList *node = NULL, *newlist = NULL, *accounts = NULL;
00677     grouplist *g;
00678     
00679     g = find_grouplist_by_name(group);
00680 
00681     if(g)
00682         node = g->members;
00683     
00684     while(node)
00685     {
00686         struct contact * contact = (struct contact *)node->data;
00687         accounts = contact->accounts;
00688         while (accounts) {
00689             if( ((struct account *)accounts->data)->service_id == room->service_id
00690             &&  ((struct account *)accounts->data)->online) {
00691                 newlist = g_list_append(newlist, ((struct account *)accounts->data)->handle);   
00692             }
00693             accounts = accounts->next;
00694         }
00695         node = node->next;
00696     }
00697     
00698     return newlist;
00699 }
00700 
00701 static GList * get_contacts(eb_chat_room * room)
00702 {
00703     GList *node = groups;
00704     GList *newlist = NULL;
00705     while(node)
00706     {
00707         GList * g = get_group_contacts(node->data, room);
00708         newlist = g_list_concat(newlist, g);    
00709         node = node->next;
00710     }
00711     return newlist;
00712 }

Contact: Andy Maloney     [Documentation generated by doxygen]