/* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #include #include #include #include #include #include #include #include "fe-gtk.h" #include "../common/hexchat.h" #include "../common/hexchatc.h" #include "../common/cfgfiles.h" #include "../common/outbound.h" #include "../common/fe.h" #include "../common/text.h" #include "gtkutil.h" #include "xtext.h" #include "maingui.h" #include "palette.h" #include "textgui.h" extern struct text_event te[]; extern char *pntevts_text[]; extern char *pntevts[]; static GtkWidget *pevent_dialog = NULL, *pevent_dialog_twid, *pevent_dialog_list, *pevent_dialog_hlist; enum { EVENT_COLUMN, TEXT_COLUMN, ROW_COLUMN, N_COLUMNS }; /* this is only used in xtext.c for indented timestamping */ int xtext_get_stamp_str (time_t tim, char **ret) { return get_stamp_str (prefs.hex_stamp_text_format, tim, ret); } static void PrintTextLine (xtext_buffer *xtbuf, unsigned char *text, int len, int indent, time_t timet) { unsigned char *tab, *new_text; int leftlen; if (len == 0) len = 1; if (!indent) { if (prefs.hex_stamp_text) { int stamp_size; char *stamp; if (timet == 0) timet = time (0); stamp_size = get_stamp_str (prefs.hex_stamp_text_format, timet, &stamp); new_text = malloc (len + stamp_size + 1); memcpy (new_text, stamp, stamp_size); g_free (stamp); memcpy (new_text + stamp_size, text, len); gtk_xtext_append (xtbuf, new_text, len + stamp_size); free (new_text); } else gtk_xtext_append (xtbuf, text, len); return; } tab = strchr (text, '\t'); if (tab && tab < (text + len)) { leftlen = tab - text; gtk_xtext_append_indent (xtbuf, text, leftlen, tab + 1, len - (leftlen + 1), timet); } else gtk_xtext_append_indent (xtbuf, 0, 0, text, len, timet); } void PrintTextRaw (void *xtbuf, unsigned char *text, int indent, time_t stamp) { char *last_text = text; int len = 0; int beep_done = FALSE; /* split the text into separate lines */ while (1) { switch (*text) { case 0: PrintTextLine (xtbuf, last_text, len, indent, stamp); return; case '\n': PrintTextLine (xtbuf, last_text, len, indent, stamp); text++; if (*text == 0) return; last_text = text; len = 0; break; case ATTR_BEEP: *text = ' '; if (!beep_done) /* beeps may be slow, so only do 1 per line */ { beep_done = TRUE; if (!prefs.hex_input_filter_beep) gdk_beep (); } default: text++; len++; } } } static void pevent_dialog_close (GtkWidget *wid, gpointer arg) { pevent_dialog = NULL; pevent_save (NULL); } static void pevent_edited (GtkCellRendererText *render, gchar *pathstr, gchar *new_text, gpointer data) { GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (pevent_dialog_list)); GtkTreePath *path; GtkTreeIter iter; GtkXText *xtext = GTK_XTEXT (pevent_dialog_twid); int len, m; const char *text; char *out; int sig; if (!gtkutil_treeview_get_selected (GTK_TREE_VIEW (pevent_dialog_list), &iter, ROW_COLUMN, &sig, -1)) return; text = new_text; len = strlen (new_text); if (pevt_build_string (text, &out, &m) != 0) { fe_message (_("There was an error parsing the string"), FE_MSG_ERROR); return; } if (m > (te[sig].num_args & 0x7f)) { free (out); out = malloc (4096); snprintf (out, 4096, _("This signal is only passed %d args, $%d is invalid"), te[sig].num_args & 0x7f, m); fe_message (out, FE_MSG_WARN); free (out); return; } path = gtk_tree_path_new_from_string (pathstr); gtk_tree_model_get_iter (model, &iter, path); gtk_list_store_set (GTK_LIST_STORE (model), &iter, TEXT_COLUMN, new_text, -1); gtk_tree_path_free (path); if (pntevts_text[sig]) free (pntevts_text[sig]); if (pntevts[sig]) free (pntevts[sig]); pntevts_text[sig] = malloc (len + 1); memcpy (pntevts_text[sig], text, len + 1); pntevts[sig] = out; out = malloc (len + 2); memcpy (out, text, len + 1); out[len] = '\n'; out[len + 1] = 0; check_special_chars (out, TRUE); PrintTextRaw (xtext->buffer, out, 0, 0); free (out); /* Scroll to bottom */ gtk_adjustment_set_value (xtext->adj, gtk_adjustment_get_upper (xtext->adj)); /* save this when we exit */ prefs.save_pevents = 1; } static void pevent_dialog_hfill (GtkWidget *list, int e) { int i = 0; char *text; GtkTreeIter iter; GtkListStore *store; store = GTK_LIST_STORE (gtk_tre
/* X-Tray
 * Copyright (C) 2005 Michael Hotaling <Mike.Hotaling@SinisterDevelopments.com>
 *
 * X-Tray 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.
 * 
 * X-Tray 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 X-Tray; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef _H_CALLBACKS_H
#define _H_CALLBACKS_H

int					event_cb		(char *word[], void *userdata);
int