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

edit_group_window.c

Go to the documentation of this file.
00001 /*
00002  * Yattm 
00003  *
00004  * Copyright (C) 1999, Torrey Searle <tsearle@uci.edu>
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 #ifdef HAVE_CONFIG_H
00023 #  include <config.h>
00024 #endif
00025 
00026 #include "intl.h"
00027 #include <string.h>
00028 
00029 #include "status.h"
00030 #include "dialog.h"
00031 #include "util.h"
00032 
00033 
00034 static gint window_open = 0;
00035 static GtkWidget * edit_group_window;
00036 static GtkWidget * group_name;
00037 static grouplist * current_group;
00038 
00039 static void destroy( GtkWidget *widget, gpointer data)
00040 {
00041     window_open = 0;
00042 }
00043 
00044 static void ok_callback( GtkWidget * widget, gpointer data)
00045 {
00046     if (group_name == NULL || gtk_entry_get_text(GTK_ENTRY(group_name)) == NULL
00047     ||  strlen(gtk_entry_get_text(GTK_ENTRY(group_name))) == 0)
00048         return;
00049     if (current_group) { /*edit*/
00050         strcpy(current_group->name, gtk_entry_get_text(GTK_ENTRY(group_name)));
00051 
00052         gtk_label_set_text(GTK_LABEL(current_group->label),
00053                    current_group->name);
00054     } else { /*add*/
00055         add_group(gtk_entry_get_text(GTK_ENTRY(group_name)));
00056     }
00057     update_contact_list ();
00058     write_contact_list();
00059     gtk_widget_destroy(edit_group_window);
00060 }
00061 
00062 static void cancel_callback( GtkWidget * widget, gpointer data)
00063 {
00064     gtk_widget_destroy(edit_group_window);
00065 }
00066 
00067 void edit_group_window_new( grouplist * g)
00068 {
00069     gchar buff[1024];
00070     gchar *name;
00071     if (g)
00072         name = g->name;
00073     else
00074         name = "";
00075     if ( !window_open )
00076     {
00077         GtkWidget * vbox = gtk_vbox_new( FALSE, 5 );
00078         GtkWidget * hbox = gtk_hbox_new( FALSE, 5 );
00079         GtkWidget * label;
00080 
00081         edit_group_window = gtk_window_new(GTK_WINDOW_DIALOG);
00082         gtk_window_set_position(GTK_WINDOW(edit_group_window), GTK_WIN_POS_MOUSE);
00083         gtk_widget_realize(edit_group_window);
00084 
00085         label = gtk_label_new(_("Group Name"));
00086         gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
00087         gtk_widget_show(label);
00088 
00089         group_name = gtk_entry_new();
00090         gtk_box_pack_start(GTK_BOX(hbox), group_name, TRUE, TRUE, 5);
00091         gtk_entry_set_text(GTK_ENTRY(group_name), name);
00092         gtk_widget_show(group_name);
00093 
00094         gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
00095         gtk_widget_show(hbox);
00096 
00097         hbox = gtk_hbox_new(TRUE, 5);
00098 
00099         label = gtk_button_new_with_label(_("OK"));
00100         gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 5);
00101         gtk_signal_connect(GTK_OBJECT(label), "clicked",
00102                 GTK_SIGNAL_FUNC(ok_callback), NULL);
00103         gtk_widget_show(label);
00104 
00105         label = gtk_button_new_with_label(_("Cancel"));
00106         gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 5);
00107         gtk_signal_connect(GTK_OBJECT(label), "clicked",
00108                 GTK_SIGNAL_FUNC(cancel_callback), NULL);
00109 
00110         gtk_widget_show(label);     
00111 
00112         gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
00113         gtk_widget_show(hbox);
00114 
00115         gtk_container_add(GTK_CONTAINER(edit_group_window), vbox);
00116         gtk_widget_show(vbox);
00117         
00118         gtk_signal_connect( GTK_OBJECT(edit_group_window), "destroy",
00119                 GTK_SIGNAL_FUNC(destroy), NULL);
00120         gtk_widget_show(edit_group_window);
00121     }
00122 
00123     gtk_entry_set_text(GTK_ENTRY(group_name), name);
00124     if (g)
00125         g_snprintf(buff, 1024, _("Edit Properties for %s"), name);
00126     else
00127         g_snprintf(buff, 1024, _("Add group"));
00128     gtk_window_set_title(GTK_WINDOW(edit_group_window), buff);
00129     eb_icon(edit_group_window->window);
00130     gtk_signal_connect(GTK_OBJECT(edit_group_window), "destroy",
00131                 GTK_SIGNAL_FUNC(destroy), NULL);
00132 
00133     current_group = g;
00134     window_open = 1;
00135 }
00136 

Contact: Andy Maloney     [Documentation generated by doxygen]