00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
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 #include "add_contact_window.h"
00033
00034 #include "pixmaps/tb_edit.xpm"
00035 #include "pixmaps/cancel.xpm"
00036
00037
00038 static gint window_open = 0;
00039 static struct contact * my_contact;
00040 static GtkWidget * edit_contact_window;
00041 static GtkWidget * nick;
00042 static GtkWidget * service_list;
00043 static GtkWidget * group_list;
00044
00045 static void destroy( GtkWidget *widget, gpointer data )
00046 {
00047 window_open = 0;
00048 }
00049
00050 static void ok_callback( GtkWidget * widget, gpointer data )
00051 {
00052 gint service_id = get_service_id(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(service_list)->entry)));
00053
00054 rename_nick_log(my_contact->nick, gtk_entry_get_text(GTK_ENTRY(nick)));
00055 strncpy(my_contact->nick, gtk_entry_get_text(GTK_ENTRY(nick)), 254);
00056 my_contact->nick[254] = '\0';
00057 my_contact->default_chatb = service_id;
00058 my_contact->default_filetransb = service_id;
00059
00060 if (my_contact->label)
00061 gtk_label_set_text(GTK_LABEL(my_contact->label), my_contact->nick);
00062 move_contact(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(group_list)->entry)),
00063 my_contact);
00064 update_contact_list ();
00065 write_contact_list();
00066 gtk_widget_destroy(edit_contact_window);
00067 }
00068
00069 void edit_contact_window_new( struct contact * c )
00070 {
00071 gchar buff[1024];
00072 if( !window_open )
00073 {
00074 GtkWidget * vbox = gtk_vbox_new( FALSE, 5 );
00075 GtkWidget * hbox = gtk_hbox_new( FALSE, 0 );
00076 GtkWidget * hbox2;
00077 GtkWidget * button;
00078 GtkWidget * label;
00079 GtkWidget * iconwid;
00080 GtkWidget * frame;
00081 GtkWidget * table;
00082 GtkWidget * separator;
00083 GdkPixmap *icon;
00084 GdkBitmap *mask;
00085 GList * list;
00086 edit_contact_window = gtk_window_new(GTK_WINDOW_DIALOG);
00087 gtk_widget_realize(edit_contact_window);
00088 gtk_container_set_border_width(GTK_CONTAINER(edit_contact_window), 5);
00089
00090 table = gtk_table_new(2, 4, FALSE);
00091 gtk_table_set_row_spacings(GTK_TABLE(table), 5);
00092 gtk_table_set_row_spacings(GTK_TABLE(table), 5);
00093 gtk_container_set_border_width(GTK_CONTAINER(table), 5);
00094
00095 label = gtk_label_new(_("Contact Name:"));
00096 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 5);
00097 gtk_widget_show(label);
00098 gtk_table_attach(GTK_TABLE(table), hbox, 0, 1, 0, 1, GTK_EXPAND,
00099 GTK_EXPAND, 0, 0);
00100 gtk_widget_show(hbox);
00101
00102 nick = gtk_entry_new();
00103 gtk_table_attach(GTK_TABLE(table), nick, 1, 2, 0, 1,
00104 GTK_FILL, GTK_FILL, 0, 0);
00105
00106 gtk_entry_set_text(GTK_ENTRY(nick), c->nick );
00107 gtk_widget_show(nick);
00108
00109 hbox = gtk_hbox_new(FALSE, 0);
00110 label = gtk_label_new(_("Default Protocol:"));
00111 gtk_box_pack_end(GTK_BOX(hbox),label, FALSE, FALSE, 5);
00112 gtk_widget_show(label);
00113 gtk_table_attach(GTK_TABLE(table), hbox, 2, 3, 0, 1, GTK_EXPAND, GTK_EXPAND,
00114 0, 0);
00115 gtk_widget_show(hbox);
00116
00117
00118 service_list = gtk_combo_new();
00119 list = get_service_list();
00120 gtk_combo_set_popdown_strings(GTK_COMBO(service_list), list );
00121 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(service_list)->entry),
00122 eb_services[c->default_chatb].name);
00123 g_list_free(list);
00124 gtk_table_attach(GTK_TABLE(table), service_list, 3, 4, 0, 1,
00125 GTK_EXPAND, GTK_EXPAND, 0, 0);
00126 gtk_widget_show(service_list);
00127
00128 hbox = gtk_hbox_new( FALSE, 0 );
00129
00130 label = gtk_label_new(_("Group Name:"));
00131 gtk_box_pack_end(GTK_BOX(hbox),label, FALSE, FALSE, 5);
00132 gtk_widget_show(label);
00133
00134 gtk_table_attach(GTK_TABLE(table), hbox, 0, 1, 1, 2,
00135 GTK_EXPAND, GTK_EXPAND, 0, 0);
00136 gtk_widget_show(hbox);
00137
00138 group_list = gtk_combo_new();
00139 list = get_groups();
00140 gtk_combo_set_popdown_strings(GTK_COMBO(group_list), list );
00141 g_list_free(list);
00142 gtk_table_attach(GTK_TABLE(table), group_list, 1, 2, 1, 2,
00143 GTK_EXPAND, GTK_EXPAND, 0, 0);
00144
00145 gtk_widget_show(group_list);
00146 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(group_list)->entry),
00147 c->group->name);
00148
00149 frame = gtk_frame_new(NULL);
00150
00151 g_snprintf(buff,1024,_("Edit Properties for %s"), c->nick);
00152 gtk_frame_set_label(GTK_FRAME(frame), buff);
00153
00154 gtk_container_add(GTK_CONTAINER(frame), table);
00155 gtk_widget_show(table);
00156
00157 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
00158 gtk_widget_show(frame);
00159
00160 separator = gtk_hseparator_new();
00161 gtk_box_pack_start(GTK_BOX(vbox), separator, FALSE, FALSE, 5);
00162 gtk_widget_show(separator);
00163
00164 hbox = gtk_hbox_new(FALSE, 5);
00165 hbox2 = gtk_hbox_new(TRUE, 5);
00166 gtk_widget_set_usize(hbox2, 200,25 );
00167
00168
00169
00170 icon = gdk_pixmap_create_from_xpm_d( edit_contact_window->window, &mask, NULL, tb_edit_xpm);
00171 iconwid = gtk_pixmap_new( icon, mask );
00172 label = gtk_label_new(_("Apply"));
00173
00174 gtk_box_pack_start(GTK_BOX(hbox), iconwid, FALSE, FALSE, 2);
00175 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
00176
00177 gtk_widget_show(iconwid);
00178 gtk_widget_show(label);
00179
00180 button = gtk_button_new();
00181
00182 gtk_signal_connect(GTK_OBJECT(button), "clicked",
00183 GTK_SIGNAL_FUNC(ok_callback), NULL );
00184
00185 gtk_container_add (GTK_CONTAINER (button), hbox);
00186 gtk_widget_show(hbox);
00187
00188 gtk_box_pack_start(GTK_BOX(hbox2), button, TRUE, TRUE, 0);
00189 gtk_widget_show(button);
00190
00191
00192
00193 hbox = gtk_hbox_new(FALSE, 5);
00194 icon = gdk_pixmap_create_from_xpm_d( edit_contact_window->window, &mask, NULL, cancel_xpm);
00195 iconwid = gtk_pixmap_new( icon, mask );
00196 label = gtk_label_new(_("Cancel"));
00197
00198 gtk_box_pack_start(GTK_BOX(hbox), iconwid, FALSE, FALSE, 2);
00199 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 2);
00200
00201 gtk_widget_show(iconwid);
00202 gtk_widget_show(label);
00203
00204 button = gtk_button_new();
00205
00206 gtk_signal_connect_object(GTK_OBJECT(button), "clicked",
00207 GTK_SIGNAL_FUNC(gtk_widget_destroy),
00208 GTK_OBJECT(edit_contact_window));
00209 gtk_container_add (GTK_CONTAINER (button), hbox);
00210 gtk_widget_show(hbox);
00211
00212 gtk_box_pack_start(GTK_BOX(hbox2), button, TRUE, TRUE, 0);
00213 gtk_widget_show(button);
00214
00215
00216
00217 hbox = gtk_hbox_new(FALSE, 5);
00218
00219 gtk_box_pack_end(GTK_BOX(hbox), hbox2, FALSE, FALSE, 0 );
00220 gtk_widget_show(hbox2);
00221
00222 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
00223 gtk_widget_show(hbox);
00224
00225 table = gtk_table_new(1, 1, FALSE);
00226 gtk_table_attach(GTK_TABLE(table), vbox, 0, 1, 0, 1,
00227 GTK_EXPAND, GTK_EXPAND, 0, 0);
00228 gtk_widget_show(vbox);
00229
00230 gtk_container_add(GTK_CONTAINER(edit_contact_window), table);
00231 gtk_widget_show(table);
00232
00233 gtk_signal_connect( GTK_OBJECT(edit_contact_window), "destroy",
00234 GTK_SIGNAL_FUNC(destroy), NULL );
00235 gtk_widget_show(edit_contact_window);
00236 }
00237
00238
00239
00240 g_snprintf(buff,1024,_("Edit Properties for %s"), c->nick);
00241 gtk_window_set_title(GTK_WINDOW(edit_contact_window), buff );
00242 eb_icon(edit_contact_window->window);
00243 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(service_list)->entry),
00244 eb_services[c->default_chatb].name );
00245
00246 gtk_signal_connect( GTK_OBJECT(edit_contact_window), "destroy",
00247 GTK_SIGNAL_FUNC(destroy), NULL );
00248 my_contact = c;
00249 window_open = 1;
00250 }
00251