GdkAtom compound_text_atom, utf8_string_atom;
+extern char **pty_argv; /* declared in pty.c */
+extern int use_pty_argv;
+
struct gui_data {
GtkWidget *window, *area, *sbar;
GtkBox *hbox;
GtkAdjustment *sbar_adjust;
GtkWidget *menu, *specialsmenu, *specialsitem1, *specialsitem2;
+ GtkWidget *sessionsmenu;
GdkPixmap *pixmap;
GdkFont *fonts[4]; /* normal, bold, wide, widebold */
struct {
struct unicode_data ucsdata;
Config cfg;
void *eventlogstuff;
+ char *progname, **gtkargvstart;
+ int ngtkargs;
};
struct draw_ctx {
{
if (!strcmp(name, "CloseOnExit"))
return 2; /* maps to FORCE_ON after painful rearrangement :-( */
+ if (!strcmp(name, "WinNameAlways"))
+ return 0; /* X natively supports icon titles, so use 'em by default */
return def;
}
*/
}
-int askappend(void *frontend, Filename filename)
-{
- /*
- * Logging in an xterm-alike is liable to be something you only
- * do at serious diagnostic need. Hence, I'm going to take the
- * easy option for now and assume we always want to overwrite
- * log files. I can always make it properly configurable later.
- */
- return 2;
-}
-
int from_backend(void *frontend, int is_stderr, const char *data, int len)
{
struct gui_data *inst = (struct gui_data *)frontend;
return term_data(inst->term, is_stderr, data, len);
}
-void logevent(void *frontend, char *string)
+void logevent(void *frontend, const char *string)
{
struct gui_data *inst = (struct gui_data *)frontend;
gint delete_window(GtkWidget *widget, GdkEvent *event, gpointer data)
{
struct gui_data *inst = (struct gui_data *)data;
- if (inst->cfg.warn_on_close) {
+ if (!inst->exited && inst->cfg.warn_on_close) {
if (!reallyclose(inst))
return TRUE;
}
{
struct gui_data *inst = (struct gui_data *)data;
int w, h, need_size = 0;
+ GdkGC *gc;
+ /*
+ * See if the terminal size has changed, in which case we must
+ * let the terminal know.
+ */
w = (event->width - 2*inst->cfg.window_border) / inst->font_width;
h = (event->height - 2*inst->cfg.window_border) / inst->font_height;
-
if (w != inst->width || h != inst->height) {
- if (inst->pixmap) {
- gdk_pixmap_unref(inst->pixmap);
- inst->pixmap = NULL;
- }
inst->cfg.width = inst->width = w;
inst->cfg.height = inst->height = h;
need_size = 1;
}
- if (!inst->pixmap) {
- GdkGC *gc;
-
- inst->pixmap = gdk_pixmap_new(widget->window,
- (inst->cfg.width * inst->font_width +
- 2*inst->cfg.window_border),
- (inst->cfg.height * inst->font_height +
- 2*inst->cfg.window_border), -1);
-
- gc = gdk_gc_new(inst->area->window);
- gdk_gc_set_foreground(gc, &inst->cols[18]); /* default background */
- gdk_draw_rectangle(inst->pixmap, gc, 1, 0, 0,
- inst->cfg.width * inst->font_width + 2*inst->cfg.window_border,
- inst->cfg.height * inst->font_height + 2*inst->cfg.window_border);
- gdk_gc_unref(gc);
+
+ if (inst->pixmap) {
+ gdk_pixmap_unref(inst->pixmap);
+ inst->pixmap = NULL;
}
- if (need_size) {
+ inst->pixmap = gdk_pixmap_new(widget->window,
+ (inst->cfg.width * inst->font_width +
+ 2*inst->cfg.window_border),
+ (inst->cfg.height * inst->font_height +
+ 2*inst->cfg.window_border), -1);
+
+ gc = gdk_gc_new(inst->area->window);
+ gdk_gc_set_foreground(gc, &inst->cols[18]); /* default background */
+ gdk_draw_rectangle(inst->pixmap, gc, 1, 0, 0,
+ inst->cfg.width * inst->font_width + 2*inst->cfg.window_border,
+ inst->cfg.height * inst->font_height + 2*inst->cfg.window_border);
+ gdk_gc_unref(gc);
+
+ if (need_size && inst->term) {
term_size(inst->term, h, w, inst->cfg.savelines);
}
+ if (inst->term)
+ term_invalidate(inst->term);
+
return TRUE;
}
{
struct gui_data *inst = (struct gui_data *)data;
char output[32];
- int start, end;
+ wchar_t ucsoutput[2];
+ int ucsval, start, end, special, use_ucsoutput;
/* By default, nothing is generated. */
end = start = 0;
+ special = use_ucsoutput = FALSE;
/*
* If Alt is being released after typing an Alt+numberpad
return TRUE;
}
+ special = FALSE;
+ use_ucsoutput = FALSE;
+
/* ALT+things gives leading Escape. */
output[0] = '\033';
strncpy(output+1, event->string, 31);
- output[31] = '\0';
- end = strlen(output);
+ if (!*event->string &&
+ (ucsval = keysym_to_unicode(event->keyval)) >= 0) {
+ ucsoutput[0] = '\033';
+ ucsoutput[1] = ucsval;
+ use_ucsoutput = TRUE;
+ end = 2;
+ } else {
+ output[31] = '\0';
+ end = strlen(output);
+ }
if (event->state & GDK_MOD1_MASK) {
start = 0;
if (end == 1) end = 0;
if (!event->string[0] && event->keyval == '`' &&
(event->state & GDK_CONTROL_MASK)) {
output[1] = '\x1C';
+ use_ucsoutput = FALSE;
end = 2;
}
if (event->keyval == GDK_Break &&
(event->state & GDK_CONTROL_MASK)) {
output[1] = '\003';
+ use_ucsoutput = FALSE;
end = 2;
+ special = TRUE;
+ }
+
+ /* We handle Return ourselves, because it needs to be flagged as
+ * special to ldisc. */
+ if (event->keyval == GDK_Return) {
+ output[1] = '\015';
+ use_ucsoutput = FALSE;
+ end = 2;
+ special = TRUE;
}
/* Control-2, Control-Space and Control-@ are NUL */
(event->state & (GDK_SHIFT_MASK |
GDK_CONTROL_MASK)) == GDK_CONTROL_MASK) {
output[1] = '\0';
+ use_ucsoutput = FALSE;
end = 2;
}
(event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) ==
(GDK_SHIFT_MASK | GDK_CONTROL_MASK)) {
output[1] = '\240';
+ use_ucsoutput = FALSE;
end = 2;
}
if (event->keyval == GDK_BackSpace &&
!(event->state & GDK_SHIFT_MASK)) {
output[1] = inst->cfg.bksp_is_delete ? '\x7F' : '\x08';
+ use_ucsoutput = FALSE;
end = 2;
+ special = TRUE;
}
/* For Shift Backspace, do opposite of what is configured. */
if (event->keyval == GDK_BackSpace &&
(event->state & GDK_SHIFT_MASK)) {
output[1] = inst->cfg.bksp_is_delete ? '\x08' : '\x7F';
+ use_ucsoutput = FALSE;
end = 2;
+ special = TRUE;
}
/* Shift-Tab is ESC [ Z */
if (event->keyval == GDK_ISO_Left_Tab ||
(event->keyval == GDK_Tab && (event->state & GDK_SHIFT_MASK))) {
end = 1 + sprintf(output+1, "\033[Z");
+ use_ucsoutput = FALSE;
}
/*
output[1] = keys[1];
else
output[1] = keys[0];
+ use_ucsoutput = FALSE;
goto done;
}
}
end = 1 + sprintf(output+1, "\033?%c", xkey);
} else
end = 1 + sprintf(output+1, "\033O%c", xkey);
+ use_ucsoutput = FALSE;
goto done;
}
}
if (inst->term->vt52_mode && code > 0 && code <= 6) {
end = 1 + sprintf(output+1, "\x1B%c", " HLMEIG"[code]);
+ use_ucsoutput = FALSE;
goto done;
}
if (event->state & GDK_SHIFT_MASK) index += 12;
if (event->state & GDK_CONTROL_MASK) index += 24;
end = 1 + sprintf(output+1, "\x1B[%c", codes[index]);
+ use_ucsoutput = FALSE;
goto done;
}
if (inst->cfg.funky_type == 5 && /* SCO small keypad */
} else {
end = 1 + sprintf(output+1, "\x1B[%c", codes[code-1]);
}
+ use_ucsoutput = FALSE;
goto done;
}
if ((inst->term->vt52_mode || inst->cfg.funky_type == 4) &&
else
end = 1 + sprintf(output+1,
"\x1BO%c", code + 'P' - 11 - offt);
+ use_ucsoutput = FALSE;
goto done;
}
if (inst->cfg.funky_type == 1 && code >= 11 && code <= 15) {
end = 1 + sprintf(output+1, "\x1B[[%c", code + 'A' - 11);
+ use_ucsoutput = FALSE;
goto done;
}
if (inst->cfg.funky_type == 2 && code >= 11 && code <= 14) {
end = 1 + sprintf(output+1, "\x1B%c", code + 'P' - 11);
else
end = 1 + sprintf(output+1, "\x1BO%c", code + 'P' - 11);
+ use_ucsoutput = FALSE;
goto done;
}
if (inst->cfg.rxvt_homeend && (code == 1 || code == 4)) {
end = 1 + sprintf(output+1, code == 1 ? "\x1B[H" : "\x1BOw");
+ use_ucsoutput = FALSE;
goto done;
}
if (code) {
end = 1 + sprintf(output+1, "\x1B[%d~", code);
+ use_ucsoutput = FALSE;
goto done;
}
}
} else {
end = 1 + sprintf(output+1, "\033[%c", xkey);
}
+ use_ucsoutput = FALSE;
goto done;
}
}
printf("\n");
#endif
- if (!inst->direct_to_font) {
+ if (special) {
/*
- * The stuff we've just generated is assumed to be
- * ISO-8859-1! This sounds insane, but `man
- * XLookupString' agrees: strings of this type returned
- * from the X server are hardcoded to 8859-1. Strictly
- * speaking we should be doing this using some sort of
- * GtkIMContext, which (if we're lucky) would give us
- * our data directly in Unicode; but that's not
- * supported in GTK 1.2 as far as I can tell, and it's
- * poorly documented even in 2.0, so it'll have to
- * wait.
+ * For special control characters, the character set
+ * should never matter.
*/
- lpage_send(inst->ldisc, CS_ISO8859_1, output+start, end-start, 1);
+ output[end] = '\0'; /* NUL-terminate */
+ ldisc_send(inst->ldisc, output+start, -2, 1);
+ } else if (!inst->direct_to_font) {
+ if (!use_ucsoutput) {
+ /*
+ * The stuff we've just generated is assumed to be
+ * ISO-8859-1! This sounds insane, but `man
+ * XLookupString' agrees: strings of this type
+ * returned from the X server are hardcoded to
+ * 8859-1. Strictly speaking we should be doing
+ * this using some sort of GtkIMContext, which (if
+ * we're lucky) would give us our data directly in
+ * Unicode; but that's not supported in GTK 1.2 as
+ * far as I can tell, and it's poorly documented
+ * even in 2.0, so it'll have to wait.
+ */
+ lpage_send(inst->ldisc, CS_ISO8859_1, output+start,
+ end-start, 1);
+ } else {
+ /*
+ * We generated our own Unicode key data from the
+ * keysym, so use that instead.
+ */
+ luni_send(inst->ldisc, ucsoutput+start, end-start, 1);
+ }
} else {
/*
* In direct-to-font mode, we just send the string
}
}
+static void set_window_titles(struct gui_data *inst)
+{
+ /*
+ * We must always call set_icon_name after calling set_title,
+ * since set_title will write both names. Irritating, but such
+ * is life.
+ */
+ gtk_window_set_title(GTK_WINDOW(inst->window), inst->wintitle);
+ if (!inst->cfg.win_name_always)
+ gdk_window_set_icon_name(inst->window->window, inst->icontitle);
+}
+
void set_title(void *frontend, char *title)
{
struct gui_data *inst = (struct gui_data *)frontend;
strncpy(inst->wintitle, title, lenof(inst->wintitle));
inst->wintitle[lenof(inst->wintitle)-1] = '\0';
- gtk_window_set_title(GTK_WINDOW(inst->window), inst->wintitle);
+ set_window_titles(inst);
}
void set_icon(void *frontend, char *title)
struct gui_data *inst = (struct gui_data *)frontend;
strncpy(inst->icontitle, title, lenof(inst->icontitle));
inst->icontitle[lenof(inst->icontitle)-1] = '\0';
- gdk_window_set_icon_name(inst->window->window, inst->icontitle);
+ set_window_titles(inst);
}
void set_sbar(void *frontend, int total, int start, int page)
struct gui_data *inst, Config *cfg)
{
int err = 0;
- extern char **pty_argv; /* declared in pty.c */
- extern int use_pty_argv;
+ char *val;
/*
* Macros to make argument handling easier. Note that because
}
#define SECOND_PASS_ONLY { if (!do_everything) continue; }
- char *val;
while (--argc > 0) {
char *p = *++argv;
int ret;
+ /*
+ * Shameless cheating. Debian requires all X terminal
+ * emulators to support `-T title'; but
+ * cmdline_process_param will eat -T (it means no-pty) and
+ * complain that pterm doesn't support it. So, in pterm
+ * only, we convert -T into -title.
+ */
+ if ((cmdline_tooltype & TOOLTYPE_NONNETWORK) &&
+ !strcmp(p, "-T"))
+ p = "-title";
+
ret = cmdline_process_param(p, (argc > 1 ? argv[1] : NULL),
do_everything ? 1 : -1, cfg);
inst->font_height = inst->fonts[0]->ascent + inst->fonts[0]->descent;
inst->direct_to_font = init_ucs(&inst->ucsdata,
- inst->cfg.line_codepage, font_charset);
+ inst->cfg.line_codepage, font_charset,
+ inst->cfg.vtmode);
}
void set_geom_hints(struct gui_data *inst)
*/
if (strcmp(oldcfg.wintitle, cfg2.wintitle))
set_title(inst, cfg2.wintitle);
+ set_window_titles(inst);
/*
* Redo the whole tangled fonts and Unicode mess if
strcmp(oldcfg.boldfont.name, cfg2.boldfont.name) ||
strcmp(oldcfg.widefont.name, cfg2.widefont.name) ||
strcmp(oldcfg.wideboldfont.name, cfg2.wideboldfont.name) ||
- strcmp(oldcfg.line_codepage, cfg2.line_codepage)) {
+ strcmp(oldcfg.line_codepage, cfg2.line_codepage) ||
+ oldcfg.vtmode != cfg2.vtmode) {
setup_fonts_ucs(inst);
need_size = 1;
} else
oldcfg.window_border != cfg2.window_border || need_size) {
set_geom_hints(inst);
request_resize(inst, cfg2.width, cfg2.height);
- }
+ } else {
+ /*
+ * The above will have caused a call to term_size() for
+ * us if it happened. If the user has fiddled with only
+ * the scrollback size, the above will not have
+ * happened and we will need an explicit term_size()
+ * here.
+ */
+ if (oldcfg.savelines != cfg2.savelines)
+ term_size(inst->term, inst->term->rows, inst->term->cols,
+ cfg2.savelines);
+ }
term_invalidate(inst->term);
}
sfree(title);
}
+void fork_and_exec_self(struct gui_data *inst, int fd_to_close, ...)
+{
+ /*
+ * Re-execing ourself is not an exact science under Unix. I do
+ * the best I can by using /proc/self/exe if available and by
+ * assuming argv[0] can be found on $PATH if not.
+ *
+ * Note that we also have to reconstruct the elements of the
+ * original argv which gtk swallowed, since the user wants the
+ * new session to appear on the same X display as the old one.
+ */
+ char **args;
+ va_list ap;
+ int i, n;
+ int pid;
+
+ /*
+ * Collect the arguments with which to re-exec ourself.
+ */
+ va_start(ap, fd_to_close);
+ n = 2; /* progname and terminating NULL */
+ n += inst->ngtkargs;
+ while (va_arg(ap, char *) != NULL)
+ n++;
+ va_end(ap);
+
+ args = snewn(n, char *);
+ args[0] = inst->progname;
+ args[n-1] = NULL;
+ for (i = 0; i < inst->ngtkargs; i++)
+ args[i+1] = inst->gtkargvstart[i];
+
+ i++;
+ va_start(ap, fd_to_close);
+ while ((args[i++] = va_arg(ap, char *)) != NULL);
+ va_end(ap);
+
+ assert(i == n);
+
+ /*
+ * Do the double fork.
+ */
+ pid = fork();
+ if (pid < 0) {
+ perror("fork");
+ return;
+ }
+
+ if (pid == 0) {
+ int pid2 = fork();
+ if (pid2 < 0) {
+ perror("fork");
+ _exit(1);
+ } else if (pid2 > 0) {
+ /*
+ * First child has successfully forked second child. My
+ * Work Here Is Done. Note the use of _exit rather than
+ * exit: the latter appears to cause destroy messages
+ * to be sent to the X server. I suspect gtk uses
+ * atexit.
+ */
+ _exit(0);
+ }
+
+ /*
+ * If we reach here, we are the second child, so we now
+ * actually perform the exec.
+ */
+ if (fd_to_close >= 0)
+ close(fd_to_close);
+
+ execv("/proc/self/exe", args);
+ execvp(inst->progname, args);
+ perror("exec");
+ _exit(127);
+
+ } else {
+ int status;
+ waitpid(pid, &status, 0);
+ }
+
+}
+
+void dup_session_menuitem(GtkMenuItem *item, gpointer gdata)
+{
+ struct gui_data *inst = (struct gui_data *)gdata;
+ /*
+ * For this feature we must marshal cfg and (possibly) pty_argv
+ * into a byte stream, create a pipe, and send this byte stream
+ * to the child through the pipe.
+ */
+ int i, ret, size;
+ char *data;
+ char option[80];
+ int pipefd[2];
+
+ if (pipe(pipefd) < 0) {
+ perror("pipe");
+ return;
+ }
+
+ size = sizeof(inst->cfg);
+ if (use_pty_argv && pty_argv) {
+ for (i = 0; pty_argv[i]; i++)
+ size += strlen(pty_argv[i]) + 1;
+ }
+
+ data = snewn(size, char);
+ memcpy(data, &inst->cfg, sizeof(inst->cfg));
+ if (use_pty_argv && pty_argv) {
+ int p = sizeof(inst->cfg);
+ for (i = 0; pty_argv[i]; i++) {
+ strcpy(data + p, pty_argv[i]);
+ p += strlen(pty_argv[i]) + 1;
+ }
+ assert(p == size);
+ }
+
+ sprintf(option, "---[%d,%d]", pipefd[0], size);
+ fcntl(pipefd[0], F_SETFD, 0);
+ fork_and_exec_self(inst, pipefd[1], option, NULL);
+ close(pipefd[0]);
+
+ i = ret = 0;
+ while (i < size && (ret = write(pipefd[1], data + i, size - i)) > 0)
+ i += ret;
+ if (ret < 0)
+ perror("write to pipe");
+ close(pipefd[1]);
+ sfree(data);
+}
+
+int read_dupsession_data(struct gui_data *inst, Config *cfg, char *arg)
+{
+ int fd, i, ret, size;
+ char *data;
+
+ if (sscanf(arg, "---[%d,%d]", &fd, &size) != 2) {
+ fprintf(stderr, "%s: malformed magic argument `%s'\n", appname, arg);
+ exit(1);
+ }
+
+ data = snewn(size, char);
+ i = ret = 0;
+ while (i < size && (ret = read(fd, data + i, size - i)) > 0)
+ i += ret;
+ if (ret < 0) {
+ perror("read from pipe");
+ exit(1);
+ } else if (i < size) {
+ fprintf(stderr, "%s: unexpected EOF in Duplicate Session data\n",
+ appname);
+ exit(1);
+ }
+
+ memcpy(cfg, data, sizeof(Config));
+ if (use_pty_argv && size > sizeof(Config)) {
+ int n = 0;
+ i = sizeof(Config);
+ while (i < size) {
+ while (i < size && data[i]) i++;
+ if (i >= size) {
+ fprintf(stderr, "%s: malformed Duplicate Session data\n",
+ appname);
+ exit(1);
+ }
+ i++;
+ n++;
+ }
+ pty_argv = snewn(n+1, char *);
+ pty_argv[n] = NULL;
+ n = 0;
+ i = sizeof(Config);
+ while (i < size) {
+ char *p = data + i;
+ while (i < size && data[i]) i++;
+ assert(i < size);
+ i++;
+ pty_argv[n++] = dupstr(p);
+ }
+ }
+
+ return 0;
+}
+
+void new_session_menuitem(GtkMenuItem *item, gpointer data)
+{
+ struct gui_data *inst = (struct gui_data *)data;
+
+ fork_and_exec_self(inst, -1, NULL);
+}
+
+void saved_session_menuitem(GtkMenuItem *item, gpointer data)
+{
+ struct gui_data *inst = (struct gui_data *)data;
+ char *str = (char *)gtk_object_get_data(GTK_OBJECT(item), "user-data");
+
+ fork_and_exec_self(inst, -1, "-load", str, NULL);
+}
+
+void saved_session_freedata(GtkMenuItem *item, gpointer data)
+{
+ char *str = (char *)gtk_object_get_data(GTK_OBJECT(item), "user-data");
+
+ sfree(str);
+}
+
void update_specials_menu(void *frontend)
{
struct gui_data *inst = (struct gui_data *)frontend;
extern int cfgbox(Config *cfg);
struct gui_data *inst;
- /* defer any child exit handling until we're ready to deal with
- * it */
- block_signal(SIGCHLD, 1);
-
- gtk_init(&argc, &argv);
-
/*
* Create an instance structure and initialise to zeroes
*/
memset(inst, 0, sizeof(*inst));
inst->alt_keycode = -1; /* this one needs _not_ to be zero */
- if (do_cmdline(argc, argv, 0, inst, &inst->cfg))
- exit(1); /* pre-defaults pass to get -class */
- do_defaults(NULL, &inst->cfg);
- if (do_cmdline(argc, argv, 1, inst, &inst->cfg))
- exit(1); /* post-defaults, do everything */
+ /* defer any child exit handling until we're ready to deal with
+ * it */
+ block_signal(SIGCHLD, 1);
+
+ inst->progname = argv[0];
+ /*
+ * Copy the original argv before letting gtk_init fiddle with
+ * it. It will be required later.
+ */
+ {
+ int i, oldargc;
+ inst->gtkargvstart = snewn(argc-1, char *);
+ for (i = 1; i < argc; i++)
+ inst->gtkargvstart[i-1] = dupstr(argv[i]);
+ oldargc = argc;
+ gtk_init(&argc, &argv);
+ inst->ngtkargs = oldargc - argc;
+ }
+
+ if (argc > 1 && !strncmp(argv[1], "---", 3)) {
+ read_dupsession_data(inst, &inst->cfg, argv[1]);
+ /* Splatter this argument so it doesn't clutter a ps listing */
+ memset(argv[1], 0, strlen(argv[1]));
+ } else {
+ if (do_cmdline(argc, argv, 0, inst, &inst->cfg))
+ exit(1); /* pre-defaults pass to get -class */
+ do_defaults(NULL, &inst->cfg);
+ if (do_cmdline(argc, argv, 1, inst, &inst->cfg))
+ exit(1); /* post-defaults, do everything */
- cmdline_run_saved(&inst->cfg);
+ cmdline_run_saved(&inst->cfg);
- if (!*inst->cfg.host && !cfgbox(&inst->cfg))
- exit(0); /* config box hit Cancel */
+ if (!*inst->cfg.host && !cfgbox(&inst->cfg))
+ exit(0); /* config box hit Cancel */
+ }
if (!compound_text_atom)
compound_text_atom = gdk_atom_intern("COMPOUND_TEXT", FALSE);
{
GtkWidget *menuitem;
char *s;
- extern const int use_event_log;
+ extern const int use_event_log, new_session, saved_sessions;
inst->menu = gtk_menu_new();
gtk_signal_connect(GTK_OBJECT(menuitem), "activate", \
GTK_SIGNAL_FUNC(func), inst); \
} while (0)
+ if (new_session)
+ MKMENUITEM("New Session", new_session_menuitem);
+ MKMENUITEM("Duplicate Session", dup_session_menuitem);
+ if (saved_sessions) {
+ struct sesslist sesslist;
+ int i;
+
+ inst->sessionsmenu = gtk_menu_new();
+
+ get_sesslist(&sesslist, TRUE);
+ for (i = 1; i < sesslist.nsessions; i++) {
+ menuitem = gtk_menu_item_new_with_label(sesslist.sessions[i]);
+ gtk_container_add(GTK_CONTAINER(inst->sessionsmenu), menuitem);
+ gtk_widget_show(menuitem);
+ gtk_object_set_data(GTK_OBJECT(menuitem), "user-data",
+ dupstr(sesslist.sessions[i]));
+ gtk_signal_connect(GTK_OBJECT(menuitem), "activate",
+ GTK_SIGNAL_FUNC(saved_session_menuitem),
+ inst);
+ gtk_signal_connect(GTK_OBJECT(menuitem), "destroy",
+ GTK_SIGNAL_FUNC(saved_session_freedata),
+ inst);
+ }
+ get_sesslist(&sesslist, FALSE);
+
+ MKMENUITEM("Saved Sessions", NULL);
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem),
+ inst->sessionsmenu);
+ }
+ MKMENUITEM(NULL, NULL);
MKMENUITEM("Change Settings", change_settings_menuitem);
MKMENUITEM(NULL, NULL);
if (use_event_log)
inst->back = select_backend(&inst->cfg);
{
- char *realhost, *error;
+ char *realhost;
+ const char *error;
error = inst->back->init((void *)inst, &inst->backhandle,
&inst->cfg, inst->cfg.host, inst->cfg.port,
return 0;
}
- if (inst->cfg.wintitle[0])
+ if (inst->cfg.wintitle[0]) {
set_title(inst, inst->cfg.wintitle);
- else {
+ set_icon(inst, inst->cfg.wintitle);
+ } else {
char *title = make_default_wintitle(realhost);
set_title(inst, title);
+ set_icon(inst, title);
sfree(title);
}
}
* called */
block_signal(SIGCHLD, 0);
+ /*
+ * Block SIGPIPE: if we attempt Duplicate Session or similar
+ * and it falls over in some way, we certainly don't want
+ * SIGPIPE terminating the main pterm/PuTTY. Note that we do
+ * this _after_ (at least pterm) forks off its child process,
+ * since the child wants SIGPIPE handled in the usual way.
+ */
+ block_signal(SIGPIPE, 1);
+
inst->exited = FALSE;
gtk_main();