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

away_window.h File Reference

#include <gtk/gtk.h>

Include dependency graph for away_window.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Data Structures

struct  _away

Typedefs

typedef _away away

Functions

void show_away (GtkWidget *w, gchar *a_message)
void show_away2 (GtkWidget *w, void *null)
void load_away_messages ()
void build_away_menu ()
void write_away_messages ()

Variables

GtkWidget * away_message


Typedef Documentation

typedef struct _away away
 


Function Documentation

void build_away_menu  
 

Definition at line 126 of file away_window.c.

References _, away_messages, _away::message, show_away(), show_away2(), and _away::title.

Referenced by eb_status_window(), and ok_callback().

00127 {
00128     GList * l;
00129     GtkWidget * label;
00130     GList * away_list = away_messages;
00131     away * my_away = NULL;
00132 
00133     l = gtk_container_children(GTK_CONTAINER(away_menu));
00134     
00135     while (l) {
00136         gtk_widget_destroy(GTK_WIDGET(l->data));
00137         l = l->next;
00138     }
00139 
00140     label = gtk_tearoff_menu_item_new();
00141     gtk_menu_append(GTK_MENU(away_menu), label);
00142     gtk_widget_show(label);
00143 
00144     label = gtk_menu_item_new_with_label(_("New Away Message"));
00145     gtk_menu_append(GTK_MENU(away_menu), label);
00146     gtk_signal_connect(GTK_OBJECT(label), "activate",
00147                 show_away2, NULL );
00148     gtk_widget_show(label);
00149 
00150     if (away_list) {
00151         label = gtk_menu_item_new();
00152                 gtk_menu_append(GTK_MENU(away_menu), label );
00153                 gtk_widget_show(label);
00154     }
00155         
00156     while (away_list) {
00157         my_away = (away *)away_list->data;
00158         
00159         label = gtk_menu_item_new_with_label(my_away->title);
00160         gtk_menu_append(GTK_MENU(away_menu), label);
00161         gtk_signal_connect(GTK_OBJECT(label), "activate",
00162                 show_away, my_away->message->str);
00163             
00164         gtk_widget_show(label);
00165 
00166         away_list = away_list->next;
00167     }
00168     gtk_widget_show(away_menu);
00169 }

void load_away_messages  
 

Definition at line 82 of file away_window.c.

References away_messages, _away::message, MIN, and _away::title.

Referenced by eb_status_window().

00083 {
00084     FILE * fp;
00085     char buff[2048];
00086     away * my_away = NULL;
00087     gboolean reading_title=FALSE;
00088     gboolean reading_message=FALSE;
00089 
00090     g_snprintf (buff, 1024, "%saway_messages", config_dir);
00091 
00092     if(!(fp = fopen(buff, "r")))
00093         return;
00094 
00095     away_messages = NULL;
00096 
00097     while ( fgets(buff, sizeof(buff), fp))
00098     {
00099         g_strchomp(buff);
00100         if (!g_strncasecmp(buff, "<AWAY_MESSAGE>", strlen("<AWAY_MESSAGE>"))) {
00101             my_away = g_new0(away, 1);
00102         } else if (!g_strncasecmp( buff, "</AWAY_MESSAGE>", strlen("</AWAY_MESSAGE>"))) {
00103             away_messages = g_list_append(away_messages, my_away);
00104         } else if (!g_strncasecmp(buff, "<TITLE>", strlen("<TITLE>"))) {
00105             reading_title=TRUE;
00106         } else if (!g_strncasecmp(buff, "</TITLE>", strlen("</TITLE>"))) {
00107             reading_title=FALSE;
00108         } else if (!g_strncasecmp(buff, "<MESSAGE>", strlen("<MESSAGE>"))) {
00109             reading_message=TRUE;
00110             my_away->message = g_string_new(NULL);
00111         } else if (!g_strncasecmp(buff, "</MESSAGE>", strlen("</MESSAGE>")))  {
00112             reading_message=FALSE;
00113         } else if(reading_title) {
00114             strncpy(my_away->title, buff, MIN(strlen(buff), sizeof(my_away->title)));
00115         } else if(reading_message) {
00116             if(my_away->message && my_away->message->len)
00117                 g_string_append_c(my_away->message, '\n');
00118             g_string_append(my_away->message, buff);
00119         }
00120     }
00121 
00122     fclose(fp);
00123 }

void show_away GtkWidget *    w,
gchar *    a_message
 

Definition at line 385 of file away_window.c.

References _, away_message, awaybox, local_account::connected, destroy_away(), eb_icon(), imback(), is_away, and local_account::service_id.

Referenced by build_away_menu(), and ok_callback().

00386 {
00387     GList * list;
00388     eb_local_account * ela = NULL;
00389 
00390     if (!is_away) {
00391         GtkWidget *label;
00392         GtkWidget *vbox;
00393 
00394         awaybox = gtk_window_new(GTK_WINDOW_TOPLEVEL);
00395         gtk_widget_realize(awaybox);
00396 
00397         vbox = gtk_vbox_new(FALSE, 0);
00398 
00399         label = gtk_label_new(_("You are currently away, click \"I'm back\" to return"));
00400 
00401         gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 5);
00402         gtk_widget_show(label);
00403 
00404         label = gtk_label_new(_("This is the away message that will \nbe sent to people messaging you.\nYou may edit this message if you wish."));
00405 
00406         gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 5);
00407         gtk_widget_show(label);
00408 
00409 
00410         away_message = gtk_entry_new();
00411         gtk_entry_set_text(GTK_ENTRY(away_message), (strlen(a_message)>0 ? a_message : _("User is currently away")) );
00412         gtk_box_pack_start(GTK_BOX(vbox), away_message, TRUE, TRUE, 5);
00413         gtk_widget_show(away_message);
00414 
00415         label = gtk_button_new_with_label(_("I'm Back"));
00416         gtk_signal_connect_object(GTK_OBJECT(label), "clicked",
00417                   GTK_SIGNAL_FUNC(imback), GTK_OBJECT(awaybox));
00418 
00419         gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, FALSE, 0);
00420         GTK_WIDGET_SET_FLAGS(label, GTK_CAN_DEFAULT);
00421         gtk_widget_grab_default(label);
00422         gtk_widget_show(label);
00423 
00424     
00425         gtk_signal_connect_object(GTK_OBJECT(awaybox), "destroy",
00426                   GTK_SIGNAL_FUNC(destroy_away), GTK_OBJECT(awaybox));
00427 
00428         gtk_container_add(GTK_CONTAINER(awaybox), vbox);
00429         gtk_widget_show(vbox);
00430     }
00431 
00432     gtk_window_set_title(GTK_WINDOW(awaybox), _("Away"));
00433     eb_icon(awaybox->window);
00434     gtk_container_border_width(GTK_CONTAINER(awaybox), 2);
00435     gtk_widget_show(awaybox);
00436     is_away = 1;
00437     
00438     for (list = accounts; list; list = g_list_next(list)) {
00439             ela = list->data;
00440         /* Only change state for those accounts which are connected */
00441         if(ela->connected)
00442             eb_services[ela->service_id].sc->set_away(ela, a_message);
00443     }
00444 }

void show_away2 GtkWidget *    w,
void *    null
 

Definition at line 242 of file away_window.c.

References _, away_message, away_open, away_window, cancel_callback(), destroy(), eb_icon(), ok_callback(), save_later, and title.

Referenced by build_away_menu().

00243 {
00244     if ( !away_open ) {
00245         GtkWidget * vbox;
00246         GtkWidget * hbox;
00247         GtkWidget * hbox2;
00248         GtkWidget * label;
00249         GtkWidget * frame;
00250         GtkWidget * table;
00251         GtkWidget * separator;
00252         GtkWidget * button;
00253         GtkWidget * iconwid;
00254         GdkPixmap * icon;
00255         GdkBitmap * mask;
00256 
00257         away_window = gtk_window_new(GTK_WINDOW_DIALOG);
00258         gtk_window_set_position(GTK_WINDOW(away_window), GTK_WIN_POS_MOUSE);
00259         gtk_widget_realize(away_window);
00260 
00261         vbox = gtk_vbox_new(FALSE, 5);
00262     
00263         /* make the window not resizable */
00264 
00265         table = gtk_table_new(2, 3, FALSE);
00266 
00267         label = gtk_label_new(_("Title:"));
00268         gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
00269         gtk_widget_show(label);
00270 
00271         title = gtk_entry_new();
00272         gtk_table_attach_defaults(GTK_TABLE(table), title, 1, 2, 0, 1);
00273         gtk_widget_show(title);
00274         
00275         label = gtk_label_new(_("Away Message:"));
00276         gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2);
00277         gtk_widget_show(label);
00278 
00279         away_message = gtk_entry_new();
00280         gtk_table_attach_defaults(GTK_TABLE(table), away_message, 1, 2, 1, 2);
00281         gtk_widget_show(away_message);
00282 
00283         save_later = gtk_check_button_new_with_label(_("Save for later use"));
00284         gtk_table_attach_defaults(GTK_TABLE(table), save_later, 1, 2, 2, 3);
00285         gtk_widget_show(save_later);
00286 
00287         frame = gtk_frame_new(_("New Away Message"));
00288         gtk_container_add(GTK_CONTAINER(frame), table);
00289         gtk_widget_show(table);
00290 
00291         gtk_table_set_row_spacings (GTK_TABLE(table), 5);
00292         gtk_table_set_col_spacings (GTK_TABLE(table), 5);
00293 
00294         gtk_container_set_border_width(GTK_CONTAINER(away_window), 5);
00295         gtk_container_set_border_width(GTK_CONTAINER(table), 5);
00296 
00297         gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
00298         gtk_widget_show(frame);
00299 
00300         /* seperator goes here */
00301     
00302         separator = gtk_hseparator_new();
00303         gtk_box_pack_start(GTK_BOX(vbox), separator, FALSE, FALSE, 5);
00304         gtk_widget_show(separator);
00305 
00306         /* 'Set away' and 'Cancel' buttons go here */
00307 
00308         hbox = gtk_hbox_new(FALSE, 5);
00309         hbox2 = gtk_hbox_new(TRUE, 5);
00310 
00311         gtk_widget_set_usize(hbox2, 200, 25);
00312 
00313         /* put in the pixmap and label for the 'Set away' button */
00314 
00315         icon = gdk_pixmap_create_from_xpm_d(away_window->window, &mask, NULL, ok_xpm);
00316         iconwid = gtk_pixmap_new(icon, mask);
00317         label = gtk_label_new(_("Set Away"));
00318 
00319         gtk_box_pack_start(GTK_BOX(hbox), iconwid, FALSE, FALSE, 2);
00320         gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
00321 
00322         gtk_widget_show(iconwid);
00323         gtk_widget_show(label);
00324 
00325         button = gtk_button_new();
00326 
00327         gtk_signal_connect(GTK_OBJECT(button), "clicked",
00328                 GTK_SIGNAL_FUNC(ok_callback), NULL);
00329 
00330         gtk_widget_show(hbox);
00331 
00332         gtk_container_add(GTK_CONTAINER(button), hbox);
00333         gtk_box_pack_start(GTK_BOX(hbox2), button, TRUE, TRUE, 0);
00334         gtk_widget_show(button);
00335 
00336         /* now start on the cancel button */
00337 
00338         hbox = gtk_hbox_new(FALSE, 5);
00339 
00340         icon = gdk_pixmap_create_from_xpm_d(away_window->window, &mask, NULL, cancel_xpm);
00341         iconwid = gtk_pixmap_new(icon, mask);
00342         label = gtk_label_new(_("Cancel"));
00343 
00344         gtk_box_pack_start(GTK_BOX(hbox), iconwid, FALSE, FALSE, 2);
00345         gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
00346 
00347         gtk_widget_show(iconwid);
00348         gtk_widget_show(label);
00349 
00350         button = gtk_button_new();
00351 
00352         gtk_signal_connect(GTK_OBJECT(button), "clicked",
00353                 GTK_SIGNAL_FUNC(cancel_callback), NULL);
00354 
00355         gtk_widget_show(hbox);
00356 
00357         gtk_container_add(GTK_CONTAINER(button), hbox);
00358 
00359         gtk_box_pack_start(GTK_BOX(hbox2), button, TRUE, TRUE, 0);
00360         gtk_widget_show(button);
00361 
00362         hbox = gtk_hbox_new(FALSE, 0);
00363         
00364         gtk_box_pack_end(GTK_BOX(hbox), hbox2, FALSE, FALSE, 0);
00365         gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
00366 
00367         gtk_widget_show(hbox);
00368         gtk_widget_show(hbox2);
00369         gtk_widget_show(vbox);
00370         
00371         gtk_container_add(GTK_CONTAINER(away_window), vbox);
00372         
00373         gtk_window_set_policy(GTK_WINDOW(away_window), FALSE, FALSE, TRUE);     
00374         
00375         gtk_widget_show(away_window);
00376     }
00377 
00378     gtk_window_set_title(GTK_WINDOW(away_window), _("New Away Message"));
00379     eb_icon(away_window->window);
00380     gtk_signal_connect(GTK_OBJECT(away_window), "destroy",
00381             GTK_SIGNAL_FUNC(destroy), NULL);
00382     away_open = 1; 
00383 }

void write_away_messages  
 

Definition at line 171 of file away_window.c.

References away_messages, _away::message, and _away::title.

Referenced by ok_callback().

00172 {
00173     GList * away_list = away_messages;
00174     FILE *fp;
00175     char buff2[2048];
00176     away * my_away;
00177 
00178     g_snprintf(buff2, 1024, "%saway_messages",config_dir);
00179 
00180     if(!(fp = fdopen(creat(buff2,0700),"w")))
00181         return;
00182 
00183     while (away_list) {
00184         my_away = (away *)away_list->data;
00185 
00186         fprintf(fp,"<AWAY_MESSAGE>\n");
00187         fprintf(fp,"<TITLE>\n");
00188         strncpy(buff2, my_away->title, strlen(my_away->title) + 1);
00189         g_strchomp(buff2);
00190         fprintf(fp,"%s\n",buff2);
00191         fprintf(fp,"</TITLE>\n");
00192         fprintf(fp,"<MESSAGE>\n");
00193         strncpy(buff2, my_away->message->str, strlen(my_away->message->str) + 1);
00194         g_strchomp(buff2);
00195         fprintf(fp,"%s\n",buff2);
00196         fprintf(fp,"</MESSAGE>\n");
00197         fprintf(fp,"</AWAY_MESSAGE>\n");
00198 
00199         away_list = away_list->next;
00200     }   
00201     fclose(fp);
00202 }


Variable Documentation

GtkWidget* away_message
 

Definition at line 32 of file away_window.h.

Referenced by ok_callback(), show_away(), and show_away2().


Contact: Andy Maloney     [Documentation generated by doxygen]