/* X-Chat * Copyright (C) 1998 Peter Zelezny. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #include #include #include #include #include #include #ifdef WIN32 #include #else #include #endif #include "fe-gtk.h" #include #include #include #include #include #include "../common/hexchat.h" #include "../common/cfgfiles.h" #include "../common/hexchatc.h" #include "../common/fe.h" #include "menu.h" #include "gtkutil.h" #include "maingui.h" #include "editlist.h" static GtkWidget *editlist_gui_entry_name; static GtkWidget *editlist_gui_entry_cmd; static GtkWidget *editlist_gui_window; static GtkWidget *editlist_gui_list; static GSList *editlist_list; static char *editlist_file; static char *editlist_help; static void editlist_gui_load (GtkWidget * listgad) { gchar *nnew[2]; GSList *list = editlist_list; struct popup *pop; while (list) { pop = (struct popup *) list->data; nnew[0] = pop->name; nnew[1] = pop->cmd; gtk_clist_append (GTK_CLIST (listgad), nnew); list = list->next; } } static void editlist_gui_row_unselected (GtkWidget * clist, gint row, gint column, GdkEventButton * even, gpointer none) { gtk_entry_set_text (GTK_ENTRY (editlist_gui_entry_name), ""); gtk_entry_set_text (GTK_ENTRY (editlist_gui_entry_cmd), ""); } static void editlist_gui_row_selected (GtkWidget * clist, gint row, gint column, GdkEventButton * even, gpointer none) { char *name, *cmd; row = gtkutil_clist_selection (editlist_gui_list); if (row != -1) { gtk_clist_get_text (GTK_CLIST (clist), row, 0, &name); gtk_clist_get_text (GTK_CLIST (clist), row, 1, &cmd); name = strdup (name); cmd = strdup (cmd); gtk_entry_set_text (GTK_ENTRY (editlist_gui_entry_name), name); gtk_entry_set_text (GTK_ENTRY (editlist_gui_entry_cmd), cmd); free (name); free (cmd); } else { editlist_gui_row_unselected (0, 0, 0, 0, 0); } } static void editlist_gui_handle_cmd (GtkWidget * igad) { int row; const char *reply; row = gtkutil_clist_selection (editlist_gui_list); if (row != -1) { reply = gtk_entry_get_text (GTK_ENTRY (igad)); gtk_clist_set_text (GTK_CLIST (editlist_gui_list), row, 1, reply); } } static void editlist_gui_handle_name (GtkWidget * igad) { int row; const char *ctcp; row = gtkutil_clist_selection (editlist_gui_list); if (row != -1) { ctcp = gtk_entry_get_text (GTK_ENTRY (igad)); gtk_clist_set_text (GTK_CLIST (editlist_gui_list), row, 0, ctcp); } } static void editlist_gui_addnew (GtkWidget * igad) { int i; gchar *nnew[2]; nnew[0] = _("*NEW*"); nnew[1] = _("EDIT ME"); i = gtk_clist_append (GTK_CLIST (editlist_gui_list), nnew); gtk_clist_select_row (GTK_CLIST (editlist_gui_list), i, 0); gtk_clist_moveto (GTK_CLIST (editlist_gui_list), i, 0, 0.5, 0); } static void editlist_gui_delete (GtkWidget * igad) { int row; row = gtkutil_clist_selection (editlist_gui_list); if (row != -1) { gtk_clist_unselect_all (GTK_CLIST (editlist_gui_list)); gtk_clist_remove (GTK_CLIST (editlist_gui_list), row); } } static void editlist_gui_save (GtkWidget * igad) { int fh, i = 0; char buf[512]; char *a, *b; fh = xchat_open_file (editlist_file, O_TRUNC | O_WRONLY | O_CREAT, 0600, XOF_DOMODE); if (fh != -1) { while (1) { if (!gtk_clist_get_text (GTK_CLIST (editlist_gui_list), i, 0, &a)) break; gtk_clist_get_text (GTK_CLIST (editlist_gui_list), i, 1, &b); snprintf (buf, sizeof (buf), "NAME %s\nCMD %s\n\n", a, b); write (fh, buf, strlen (buf)); i++; } close (fh); gtk_widget_destroy (editlist_gui_window); if (editlist_list == replace_list) { list_free (&replace_list); list_loadconf (editlist_file, &replace_list, 0); } else if (editlist_list == popup_list) { list_free (&popup_list); list_loadconf (editlist_file, &popup_list, 0); } else if (editlist_list == button_list) { GSList *list = sess_list; struct session *sess; list_free (&button_list); list_loadconf (editlist_file, &button_list, 0); while (list) { sess = (struct session *) list->data; fe_buttons_update (sess);
bin_PROGRAMS = xchat-text

EXTRA_DIST = README 

INCLUDES = $(COMMON_CFLAGS)

xchat_text_LDADD