#include "putty.h"
#include "terminal.h"
+#include "gtkfont.h"
#define CAT2(x,y) x ## y
#define CAT(x,y) CAT2(x,y)
#define ASSERT(x) enum {CAT(assertion_,__LINE__) = 1 / (x)}
+#if GTK_CHECK_VERSION(2,0,0)
+ASSERT(sizeof(long) <= sizeof(gsize));
+#define LONG_TO_GPOINTER(l) GSIZE_TO_POINTER(l)
+#define GPOINTER_TO_LONG(p) GPOINTER_TO_SIZE(p)
+#else /* Gtk 1.2 */
+ASSERT(sizeof(long) <= sizeof(gpointer));
+#define LONG_TO_GPOINTER(l) ((gpointer)(long)(l))
+#define GPOINTER_TO_LONG(p) ((long)(p))
+#endif
+
/* Colours come in two flavours: configurable, and xterm-extended. */
#define NCFGCOLOURS (lenof(((Config *)0)->colours))
#define NEXTCOLOURS 240 /* 216 colour-cube plus 24 shades of grey */
*restartitem;
GtkWidget *sessionsmenu;
GdkPixmap *pixmap;
- GdkFont *fonts[4]; /* normal, bold, wide, widebold */
- struct {
- int charset;
- int is_wide;
- } fontinfo[4];
+ unifont *fonts[4]; /* normal, bold, wide, widebold */
int xpos, ypos, gotpos, gravity;
GdkCursor *rawcursor, *textcursor, *blankcursor, *waitcursor, *currcursor;
GdkColor cols[NALLCOLOURS];
int mouseptr_visible;
int busy_status;
guint term_paste_idle_id;
+ guint term_exit_idle_id;
int alt_keycode;
int alt_digits;
char wintitle[sizeof(((Config *)0)->wintitle)];
{
FontSpec ret;
if (!strcmp(name, "Font"))
- strcpy(ret.name, "fixed");
+ strcpy(ret.name, "server:fixed");
else
*ret.name = '\0';
return ret;
char *platform_default_s(const char *name)
{
+ if (!strcmp(name, "SerialLine"))
+ return dupstr("/dev/ttyS0");
return NULL;
}
return def;
}
+/* Dummy routine, only required in plink. */
void ldisc_update(void *frontend, int echo, int edit)
{
- /*
- * This is a stub in pterm. If I ever produce a Unix
- * command-line ssh/telnet/rlogin client (i.e. a port of plink)
- * then it will require some termios manoeuvring analogous to
- * that in the Windows plink.c, but here it's meaningless.
- */
+}
+
+char *get_ttymode(void *frontend, const char *mode)
+{
+ struct gui_data *inst = (struct gui_data *)frontend;
+ return term_get_ttymode(inst->term, mode);
}
int from_backend(void *frontend, int is_stderr, const char *data, int len)
return term_data(inst->term, is_stderr, data, len);
}
+int from_backend_untrusted(void *frontend, const char *data, int len)
+{
+ struct gui_data *inst = (struct gui_data *)frontend;
+ return term_data_untrusted(inst->term, data, len);
+}
+
+int get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
+{
+ struct gui_data *inst = (struct gui_data *)p->frontend;
+ int ret;
+ ret = cmdline_get_passwd_input(p, in, inlen);
+ if (ret == -1)
+ ret = term_get_userpass_input(inst->term, p, in, inlen);
+ return ret;
+}
+
void logevent(void *frontend, const char *string)
{
struct gui_data *inst = (struct gui_data *)frontend;
*/
#if GTK_CHECK_VERSION(2,0,0)
struct gui_data *inst = (struct gui_data *)frontend;
- if (iconic)
+ if (zoomed)
gtk_window_maximize(GTK_WINDOW(inst->window));
else
gtk_window_unmaximize(GTK_WINDOW(inst->window));
gint key_event(GtkWidget *widget, GdkEventKey *event, gpointer data)
{
struct gui_data *inst = (struct gui_data *)data;
- char output[32];
+ char output[256];
wchar_t ucsoutput[2];
- int ucsval, start, end, special, use_ucsoutput;
+ int ucsval, start, end, special, output_charset, use_ucsoutput;
/* Remember the timestamp. */
inst->input_event_time = event->time;
/* By default, nothing is generated. */
end = start = 0;
special = use_ucsoutput = FALSE;
+ output_charset = CS_ISO8859_1;
/*
* If Alt is being released after typing an Alt+numberpad
#ifdef KEY_DEBUGGING
printf("Alt key up, keycode = %d\n", inst->alt_keycode);
#endif
+ /*
+ * FIXME: we might usefully try to do something clever here
+ * about interpreting the generated key code in a way that's
+ * appropriate to the line code page.
+ */
output[0] = inst->alt_keycode;
end = 1;
goto done;
/* ALT+things gives leading Escape. */
output[0] = '\033';
- strncpy(output+1, event->string, 31);
- if (!*event->string &&
+#if !GTK_CHECK_VERSION(2,0,0)
+ /*
+ * In vanilla X, and hence also GDK 1.2, the string received
+ * as part of a keyboard event is assumed to be in
+ * ISO-8859-1. (Seems woefully shortsighted in i18n terms,
+ * but it's true: see the man page for XLookupString(3) for
+ * confirmation.)
+ */
+ output_charset = CS_ISO8859_1;
+ strncpy(output+1, event->string, lenof(output)-1);
+#else
+ /*
+ * GDK 2.0 arranges to have done some translation for us: in
+ * GDK 2.0, event->string is encoded in the current locale.
+ *
+ * (However, it's also deprecated; we really ought to be
+ * using a GTKIMContext.)
+ *
+ * So we use the standard C library function mbstowcs() to
+ * convert from the current locale into Unicode; from there
+ * we can convert to whatever PuTTY is currently working in.
+ * (In fact I convert straight back to UTF-8 from
+ * wide-character Unicode, for the sake of simplicity: that
+ * way we can still use exactly the same code to manipulate
+ * the string, such as prefixing ESC.)
+ */
+ output_charset = CS_UTF8;
+ {
+ wchar_t widedata[32], *wp;
+ int wlen;
+ int ulen;
+
+ wlen = mb_to_wc(DEFAULT_CODEPAGE, 0,
+ event->string, strlen(event->string),
+ widedata, lenof(widedata)-1);
+
+ wp = widedata;
+ ulen = charset_from_unicode(&wp, &wlen, output+1, lenof(output)-2,
+ CS_UTF8, NULL, NULL, 0);
+ output[1+ulen] = '\0';
+ }
+#endif
+
+ if (!output[1] &&
(ucsval = keysym_to_unicode(event->keyval)) >= 0) {
ucsoutput[0] = '\033';
ucsoutput[1] = ucsval;
use_ucsoutput = TRUE;
end = 2;
} else {
- output[31] = '\0';
+ output[lenof(output)-1] = '\0';
end = strlen(output);
}
if (event->state & GDK_MOD1_MASK) {
start = 1;
/* Control-` is the same as Control-\ (unless gtk has a better idea) */
- if (!event->string[0] && event->keyval == '`' &&
+ if (!output[1] && event->keyval == '`' &&
(event->state & GDK_CONTROL_MASK)) {
output[1] = '\x1C';
use_ucsoutput = FALSE;
end = 2;
}
- /* Control-Break is the same as Control-C */
+ /* Control-Break sends a Break special to the backend */
if (event->keyval == GDK_Break &&
(event->state & GDK_CONTROL_MASK)) {
- output[1] = '\003';
- use_ucsoutput = FALSE;
- end = 2;
- special = TRUE;
+ if (inst->back)
+ inst->back->special(inst->backhandle, TS_BRK);
+ return TRUE;
}
/* We handle Return ourselves, because it needs to be flagged as
}
/* Control-2, Control-Space and Control-@ are NUL */
- if (!event->string[0] &&
+ if (!output[1] &&
(event->keyval == ' ' || event->keyval == '2' ||
event->keyval == '@') &&
(event->state & (GDK_SHIFT_MASK |
}
/* Control-Shift-Space is 160 (ISO8859 nonbreaking space) */
- if (!event->string[0] && event->keyval == ' ' &&
+ if (!output[1] && event->keyval == ' ' &&
(event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) ==
(GDK_SHIFT_MASK | GDK_CONTROL_MASK)) {
output[1] = '\240';
+ output_charset = CS_ISO8859_1;
use_ucsoutput = FALSE;
end = 2;
}
end = 1 + sprintf(output+1, "\033[Z");
use_ucsoutput = FALSE;
}
+ /* And normal Tab is Tab, if the keymap hasn't already told us.
+ * (Curiously, at least one version of the MacOS 10.5 X server
+ * doesn't translate Tab for us. */
+ if (event->keyval == GDK_Tab && end <= 1) {
+ output[1] = '\t';
+ end = 2;
+ }
/*
* NetHack keypad mode.
if (inst->cfg.nethack_keypad) {
char *keys = NULL;
switch (event->keyval) {
- case GDK_KP_1: case GDK_KP_End: keys = "bB"; break;
- case GDK_KP_2: case GDK_KP_Down: keys = "jJ"; break;
- case GDK_KP_3: case GDK_KP_Page_Down: keys = "nN"; break;
- case GDK_KP_4: case GDK_KP_Left: keys = "hH"; break;
- case GDK_KP_5: case GDK_KP_Begin: keys = ".."; break;
- case GDK_KP_6: case GDK_KP_Right: keys = "lL"; break;
- case GDK_KP_7: case GDK_KP_Home: keys = "yY"; break;
- case GDK_KP_8: case GDK_KP_Up: keys = "kK"; break;
- case GDK_KP_9: case GDK_KP_Page_Up: keys = "uU"; break;
+ case GDK_KP_1: case GDK_KP_End: keys = "bB\002"; break;
+ case GDK_KP_2: case GDK_KP_Down: keys = "jJ\012"; break;
+ case GDK_KP_3: case GDK_KP_Page_Down: keys = "nN\016"; break;
+ case GDK_KP_4: case GDK_KP_Left: keys = "hH\010"; break;
+ case GDK_KP_5: case GDK_KP_Begin: keys = "..."; break;
+ case GDK_KP_6: case GDK_KP_Right: keys = "lL\014"; break;
+ case GDK_KP_7: case GDK_KP_Home: keys = "yY\031"; break;
+ case GDK_KP_8: case GDK_KP_Up: keys = "kK\013"; break;
+ case GDK_KP_9: case GDK_KP_Page_Up: keys = "uU\025"; break;
}
if (keys) {
end = 2;
- if (event->state & GDK_SHIFT_MASK)
+ if (event->state & GDK_CONTROL_MASK)
+ output[1] = keys[2];
+ else if (event->state & GDK_SHIFT_MASK)
output[1] = keys[1];
else
output[1] = keys[0];
case GDK_Begin: case GDK_KP_Begin: xkey = 'G'; break;
}
if (xkey) {
- /*
- * The arrow keys normally do ESC [ A and so on. In
- * app cursor keys mode they do ESC O A instead.
- * Ctrl toggles the two modes.
- */
- if (inst->term->vt52_mode) {
- end = 1 + sprintf(output+1, "\033%c", xkey);
- } else if (!inst->term->app_cursor_keys ^
- !(event->state & GDK_CONTROL_MASK)) {
- end = 1 + sprintf(output+1, "\033O%c", xkey);
- } else {
- end = 1 + sprintf(output+1, "\033[%c", xkey);
- }
+ end = 1 + format_arrow_key(output+1, inst->term, xkey,
+ event->state & GDK_CONTROL_MASK);
use_ucsoutput = FALSE;
goto done;
}
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.
- */
if (inst->ldisc)
- lpage_send(inst->ldisc, CS_ISO8859_1, output+start,
+ lpage_send(inst->ldisc, output_charset, output+start,
end-start, 1);
} else {
/*
return TRUE;
}
-gint button_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
+gboolean button_internal(struct gui_data *inst, guint32 timestamp,
+ GdkEventType type, guint ebutton, guint state,
+ gdouble ex, gdouble ey)
{
- struct gui_data *inst = (struct gui_data *)data;
int shift, ctrl, alt, x, y, button, act;
/* Remember the timestamp. */
- inst->input_event_time = event->time;
+ inst->input_event_time = timestamp;
show_mouseptr(inst, 1);
- if (event->button == 4 && event->type == GDK_BUTTON_PRESS) {
+ if (ebutton == 4 && type == GDK_BUTTON_PRESS) {
term_scroll(inst->term, 0, -5);
return TRUE;
}
- if (event->button == 5 && event->type == GDK_BUTTON_PRESS) {
+ if (ebutton == 5 && type == GDK_BUTTON_PRESS) {
term_scroll(inst->term, 0, +5);
return TRUE;
}
- shift = event->state & GDK_SHIFT_MASK;
- ctrl = event->state & GDK_CONTROL_MASK;
- alt = event->state & GDK_MOD1_MASK;
+ shift = state & GDK_SHIFT_MASK;
+ ctrl = state & GDK_CONTROL_MASK;
+ alt = state & GDK_MOD1_MASK;
- if (event->button == 3 && ctrl) {
+ if (ebutton == 3 && ctrl) {
gtk_menu_popup(GTK_MENU(inst->menu), NULL, NULL, NULL, NULL,
- event->button, event->time);
+ ebutton, timestamp);
return TRUE;
}
- if (event->button == 1)
+ if (ebutton == 1)
button = MBT_LEFT;
- else if (event->button == 2)
+ else if (ebutton == 2)
button = MBT_MIDDLE;
- else if (event->button == 3)
+ else if (ebutton == 3)
button = MBT_RIGHT;
else
return FALSE; /* don't even know what button! */
- switch (event->type) {
+ switch (type) {
case GDK_BUTTON_PRESS: act = MA_CLICK; break;
case GDK_BUTTON_RELEASE: act = MA_RELEASE; break;
case GDK_2BUTTON_PRESS: act = MA_2CLK; break;
act != MA_CLICK && act != MA_RELEASE)
return TRUE; /* we ignore these in raw mouse mode */
- x = (event->x - inst->cfg.window_border) / inst->font_width;
- y = (event->y - inst->cfg.window_border) / inst->font_height;
+ x = (ex - inst->cfg.window_border) / inst->font_width;
+ y = (ey - inst->cfg.window_border) / inst->font_height;
term_mouse(inst->term, button, translate_button(button), act,
x, y, shift, ctrl, alt);
return TRUE;
}
+gboolean button_event(GtkWidget *widget, GdkEventButton *event, gpointer data)
+{
+ struct gui_data *inst = (struct gui_data *)data;
+ return button_internal(inst, event->time, event->type, event->button,
+ event->state, event->x, event->y);
+}
+
+#if GTK_CHECK_VERSION(2,0,0)
+/*
+ * In GTK 2, mouse wheel events have become a new type of event.
+ * This handler translates them back into button-4 and button-5
+ * presses so that I don't have to change my old code too much :-)
+ */
+gboolean scroll_event(GtkWidget *widget, GdkEventScroll *event, gpointer data)
+{
+ struct gui_data *inst = (struct gui_data *)data;
+ guint button;
+
+ if (event->direction == GDK_SCROLL_UP)
+ button = 4;
+ else if (event->direction == GDK_SCROLL_DOWN)
+ button = 5;
+ else
+ return FALSE;
+
+ return button_internal(inst, event->time, GDK_BUTTON_PRESS,
+ button, event->state, event->x, event->y);
+}
+#endif
+
gint motion_event(GtkWidget *widget, GdkEventMotion *event, gpointer data)
{
struct gui_data *inst = (struct gui_data *)data;
exit(0);
}
-void notify_remote_exit(void *frontend)
+static gint idle_exit_func(gpointer data)
{
- struct gui_data *inst = (struct gui_data *)frontend;
+ struct gui_data *inst = (struct gui_data *)data;
int exitcode;
if (!inst->exited &&
inst->back->free(inst->backhandle);
inst->backhandle = NULL;
inst->back = NULL;
+ term_provide_resize_fn(inst->term, NULL, NULL);
update_specials_menu(inst);
}
- gtk_widget_show(inst->restartitem);
+ gtk_widget_set_sensitive(inst->restartitem, TRUE);
}
+
+ gtk_idle_remove(inst->term_exit_idle_id);
+ return TRUE;
+}
+
+void notify_remote_exit(void *frontend)
+{
+ struct gui_data *inst = (struct gui_data *)frontend;
+
+ inst->term_exit_idle_id = gtk_idle_add(idle_exit_func, inst);
}
static gint timer_trigger(gpointer data)
{
- long now = GPOINTER_TO_INT(data);
+ long now = GPOINTER_TO_LONG(data);
long next;
long ticks;
if (run_timers(now, &next)) {
ticks = next - GETTICKCOUNT();
timer_id = gtk_timeout_add(ticks > 0 ? ticks : 1, timer_trigger,
- GINT_TO_POINTER(next));
+ LONG_TO_GPOINTER(next));
}
/*
ticks = 1; /* just in case */
timer_id = gtk_timeout_add(ticks, timer_trigger,
- GINT_TO_POINTER(next));
+ LONG_TO_GPOINTER(next));
}
void fd_input_func(gpointer data, gint sourcefd, GdkInputCondition condition)
*/
#if GTK_CHECK_VERSION(2,0,0)
gtk_widget_set_size_request(inst->area, area_x, area_y);
+ gtk_window_resize(GTK_WINDOW(inst->window),
+ area_x + offset_x, area_y + offset_y);
#else
gtk_widget_set_usize(inst->area, area_x, area_y);
gtk_drawing_area_size(GTK_DRAWING_AREA(inst->area), area_x, area_y);
-#endif
-
+ /*
+ * I can no longer remember what this call to
+ * gtk_container_dequeue_resize_handler is for. It was
+ * introduced in r3092 with no comment, and the commit log
+ * message was uninformative. I'm _guessing_ its purpose is to
+ * prevent gratuitous resize processing on the window given
+ * that we're about to resize it anyway, but I have no idea
+ * why that's so incredibly vital.
+ *
+ * I've tried removing the call, and nothing seems to go
+ * wrong. I've backtracked to r3092 and tried removing the
+ * call there, and still nothing goes wrong. So I'm going to
+ * adopt the working hypothesis that it's superfluous; I won't
+ * actually remove it from the GTK 1.2 code, but I won't
+ * attempt to replicate its functionality in the GTK 2 code
+ * above.
+ */
gtk_container_dequeue_resize_handler(GTK_CONTAINER(inst->window));
-
-#if GTK_CHECK_VERSION(2,0,0)
- gtk_window_resize(GTK_WINDOW(inst->window),
- area_x + offset_x, area_y + offset_y);
-#else
gdk_window_resize(inst->window->window,
area_x + offset_x, area_y + offset_y);
#endif
gdk_colormap_free_colors(inst->colmap, inst->cols + n, 1);
gdk_colormap_alloc_colors(inst->colmap, inst->cols + n, 1,
- FALSE, FALSE, success);
+ FALSE, TRUE, success);
if (!success[0])
g_error("%s: couldn't allocate colour %d (#%02x%02x%02x)\n", appname,
n, r, g, b);
if (n > NALLCOLOURS)
return;
real_palette_set(inst, n, r, g, b);
- if (n == 258)
+ if (n == 258) {
+ /* Default Background changed. Ensure space between text area and
+ * window border is redrawn */
set_window_background(inst);
+ draw_backing_rect(inst);
+ gtk_widget_queue_draw(inst->area);
+ }
}
void palette_reset(void *frontend)
for (i = 0; i < NEXTCOLOURS; i++) {
if (i < 216) {
int r = i / 36, g = (i / 6) % 6, b = i % 6;
- inst->cols[i+16].red = r * 0x3333;
- inst->cols[i+16].green = g * 0x3333;
- inst->cols[i+16].blue = b * 0x3333;
+ inst->cols[i+16].red = r ? r * 0x2828 + 0x3737 : 0;
+ inst->cols[i+16].green = g ? g * 0x2828 + 0x3737 : 0;
+ inst->cols[i+16].blue = b ? b * 0x2828 + 0x3737 : 0;
} else {
int shade = i - 216;
- shade = (shade + 1) * 0xFFFF / (NEXTCOLOURS - 216 + 1);
+ shade = shade * 0x0a0a + 0x0808;
inst->cols[i+16].red = inst->cols[i+16].green =
inst->cols[i+16].blue = shade;
}
}
gdk_colormap_alloc_colors(inst->colmap, inst->cols, NALLCOLOURS,
- FALSE, FALSE, success);
+ FALSE, TRUE, success);
for (i = 0; i < NALLCOLOURS; i++) {
if (!success[i])
g_error("%s: couldn't allocate colour %d (#%02x%02x%02x)\n",
inst->cfg.colours[i][1], inst->cfg.colours[i][2]);
}
+ /* Since Default Background may have changed, ensure that space
+ * between text area and window border is refreshed. */
set_window_background(inst);
+ if (inst->area && inst->area->window) {
+ draw_backing_rect(inst);
+ gtk_widget_queue_draw(inst->area);
+ }
}
/* Ensure that all the cut buffers exist - according to the ICCCM, we must
*/
void init_cutbuffers()
{
+ unsigned char empty[] = "";
XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
- XA_CUT_BUFFER0, XA_STRING, 8, PropModeAppend, "", 0);
+ XA_CUT_BUFFER0, XA_STRING, 8, PropModeAppend, empty, 0);
XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
- XA_CUT_BUFFER1, XA_STRING, 8, PropModeAppend, "", 0);
+ XA_CUT_BUFFER1, XA_STRING, 8, PropModeAppend, empty, 0);
XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
- XA_CUT_BUFFER2, XA_STRING, 8, PropModeAppend, "", 0);
+ XA_CUT_BUFFER2, XA_STRING, 8, PropModeAppend, empty, 0);
XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
- XA_CUT_BUFFER3, XA_STRING, 8, PropModeAppend, "", 0);
+ XA_CUT_BUFFER3, XA_STRING, 8, PropModeAppend, empty, 0);
XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
- XA_CUT_BUFFER4, XA_STRING, 8, PropModeAppend, "", 0);
+ XA_CUT_BUFFER4, XA_STRING, 8, PropModeAppend, empty, 0);
XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
- XA_CUT_BUFFER5, XA_STRING, 8, PropModeAppend, "", 0);
+ XA_CUT_BUFFER5, XA_STRING, 8, PropModeAppend, empty, 0);
XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
- XA_CUT_BUFFER6, XA_STRING, 8, PropModeAppend, "", 0);
+ XA_CUT_BUFFER6, XA_STRING, 8, PropModeAppend, empty, 0);
XChangeProperty(GDK_DISPLAY(), GDK_ROOT_WINDOW(),
- XA_CUT_BUFFER7, XA_STRING, 8, PropModeAppend, "", 0);
+ XA_CUT_BUFFER7, XA_STRING, 8, PropModeAppend, empty, 0);
}
/* Store the data in a cut-buffer. */
return ptr;
}
-void write_clip(void *frontend, wchar_t * data, int len, int must_deselect)
+void write_clip(void *frontend, wchar_t * data, int *attr, int len, int must_deselect)
{
struct gui_data *inst = (struct gui_data *)frontend;
if (inst->pasteout_data)
if (gtk_selection_owner_set(inst->area, GDK_SELECTION_PRIMARY,
inst->input_event_time)) {
+#if GTK_CHECK_VERSION(2,0,0)
+ gtk_selection_clear_targets(inst->area, GDK_SELECTION_PRIMARY);
+#endif
gtk_selection_add_target(inst->area, GDK_SELECTION_PRIMARY,
GDK_SELECTION_TYPE_STRING, 1);
if (inst->pasteout_data_ctext)
struct gui_data *inst = (struct gui_data *)data;
if (seldata->target == utf8_string_atom)
gtk_selection_data_set(seldata, seldata->target, 8,
- inst->pasteout_data_utf8,
+ (unsigned char *)inst->pasteout_data_utf8,
inst->pasteout_data_utf8_len);
else if (seldata->target == compound_text_atom)
gtk_selection_data_set(seldata, seldata->target, 8,
- inst->pasteout_data_ctext,
+ (unsigned char *)inst->pasteout_data_ctext,
inst->pasteout_data_ctext_len);
else
gtk_selection_data_set(seldata, seldata->target, 8,
- inst->pasteout_data, inst->pasteout_data_len);
+ (unsigned char *)inst->pasteout_data,
+ inst->pasteout_data_len);
}
gint selection_clear(GtkWidget *widget, GdkEventSelection *seldata,
* may want to perform additional actions on any kind of bell (for
* example, taskbar flashing in Windows).
*/
-void beep(void *frontend, int mode)
+void do_beep(void *frontend, int mode)
{
- if (mode != BELL_VISUAL)
+ if (mode == BELL_DEFAULT)
gdk_beep();
}
* Under X, any fixed-width font really _is_ fixed-width.
* Double-width characters will be dealt with using a separate
* font. For the moment we can simply return 1.
+ *
+ * FIXME: but is that also true of Pango?
*/
return 1;
}
struct gui_data *inst = dctx->inst;
GdkGC *gc = dctx->gc;
int ncombining, combining;
- int nfg, nbg, t, fontid, shadow, rlen, widefactor;
+ int nfg, nbg, t, fontid, shadow, rlen, widefactor, bold;
+ int monochrome = gtk_widget_get_visual(inst->area)->depth == 1;
if (attr & TATTR_COMBINING) {
ncombining = len;
} else
ncombining = 1;
- nfg = ((attr & ATTR_FGMASK) >> ATTR_FGSHIFT);
- nbg = ((attr & ATTR_BGMASK) >> ATTR_BGSHIFT);
- if (attr & ATTR_REVERSE) {
+ nfg = ((monochrome ? ATTR_DEFFG : (attr & ATTR_FGMASK)) >> ATTR_FGSHIFT);
+ nbg = ((monochrome ? ATTR_DEFBG : (attr & ATTR_BGMASK)) >> ATTR_BGSHIFT);
+ if (!!(attr & ATTR_REVERSE) ^ (monochrome && (attr & TATTR_ACTCURS))) {
t = nfg;
nfg = nbg;
nbg = t;
if (nbg < 16) nbg |= 8;
else if (nbg >= 256) nbg |= 1;
}
- if (attr & TATTR_ACTCURS) {
+ if ((attr & TATTR_ACTCURS) && !monochrome) {
nfg = 260;
nbg = 261;
}
}
if ((attr & ATTR_BOLD) && !inst->cfg.bold_colour) {
- if (inst->fonts[fontid | 1])
- fontid |= 1;
- else
- shadow = 1;
+ bold = 1;
+ fontid |= 1;
+ } else {
+ bold = 0;
+ }
+
+ if (!inst->fonts[fontid]) {
+ int i;
+ /*
+ * Fall back through font ids with subsets of this one's
+ * set bits, in order.
+ */
+ for (i = fontid; i-- > 0 ;) {
+ if (i & ~fontid)
+ continue; /* some other bit is set */
+ if (inst->fonts[i]) {
+ fontid = i;
+ break;
+ }
+ }
+ assert(inst->fonts[fontid]); /* we should at least have hit zero */
}
if ((lattr & LATTR_MODE) != LATTR_NORM) {
gdk_gc_set_foreground(gc, &inst->cols[nfg]);
{
- GdkWChar *gwcs;
gchar *gcs;
- wchar_t *wcs;
- int i;
- wcs = snewn(len*ncombining+1, wchar_t);
- for (i = 0; i < len*ncombining; i++) {
- wcs[i] = text[i];
- }
+ /*
+ * FIXME: this length is hardwired on the assumption that
+ * conversions from wide to multibyte characters will
+ * never generate more than 10 bytes for a single wide
+ * character.
+ */
+ gcs = snewn(len*10+1, gchar);
- if (inst->fonts[fontid] == NULL) {
- /*
- * The font for this contingency does not exist.
- * Typically this means we've been given ATTR_WIDE
- * character and have no wide font. So we display
- * nothing at all; such is life.
- */
- } else if (inst->fontinfo[fontid].is_wide) {
- /*
- * At least one version of gdk_draw_text_wc() has a
- * weird bug whereby it reads `len' elements of the
- * input string, but only draws `len/2'. Hence I'm
- * going to make its input array twice as long as it
- * theoretically needs to be, and pass in twice the
- * actual number of characters. If a fixed gdk actually
- * takes the doubled length seriously, then (a) the
- * array will stand scrutiny up to the full length, (b)
- * the spare elements of the array are full of zeroes
- * which will probably be an empty glyph in the font,
- * and (c) the clip rectangle should prevent it causing
- * trouble anyway.
- */
- gwcs = snewn(len*2+1, GdkWChar);
- memset(gwcs, 0, sizeof(GdkWChar) * (len*2+1));
- /*
- * FIXME: when we have a wide-char equivalent of
- * from_unicode, use it instead of this.
- */
- for (combining = 0; combining < ncombining; combining++) {
- for (i = 0; i <= len; i++)
- gwcs[i] = wcs[i + combining];
- gdk_draw_text_wc(inst->pixmap, inst->fonts[fontid], gc,
- x*inst->font_width+inst->cfg.window_border,
- y*inst->font_height+inst->cfg.window_border+inst->fonts[0]->ascent,
- gwcs, len*2);
- if (shadow)
- gdk_draw_text_wc(inst->pixmap, inst->fonts[fontid], gc,
- x*inst->font_width+inst->cfg.window_border+inst->cfg.shadowboldoffset,
- y*inst->font_height+inst->cfg.window_border+inst->fonts[0]->ascent,
- gwcs, len*2);
- }
- sfree(gwcs);
- } else {
- gcs = snewn(len+1, gchar);
- for (combining = 0; combining < ncombining; combining++) {
- wc_to_mb(inst->fontinfo[fontid].charset, 0,
- wcs + combining, len, gcs, len, ".", NULL, NULL);
- gdk_draw_text(inst->pixmap, inst->fonts[fontid], gc,
+ for (combining = 0; combining < ncombining; combining++) {
+ int mblen = wc_to_mb(inst->fonts[fontid]->real_charset, 0,
+ text + combining, len, gcs, len*10+1, ".",
+ NULL, NULL);
+ unifont_draw_text(inst->pixmap, gc, inst->fonts[fontid],
x*inst->font_width+inst->cfg.window_border,
y*inst->font_height+inst->cfg.window_border+inst->fonts[0]->ascent,
- gcs, len);
- if (shadow)
- gdk_draw_text(inst->pixmap, inst->fonts[fontid], gc,
- x*inst->font_width+inst->cfg.window_border+inst->cfg.shadowboldoffset,
- y*inst->font_height+inst->cfg.window_border+inst->fonts[0]->ascent,
- gcs, len);
- }
- sfree(gcs);
+ gcs, mblen, widefactor > 1, bold, inst->font_width);
}
- sfree(wcs);
+
+ sfree(gcs);
}
if (attr & ATTR_UNDER) {
return NULL;
}
- if (cursor_val >= 0 && !cursor_font)
+ if (cursor_val >= 0 && !cursor_font) {
cursor_font = gdk_font_load("cursor");
+ if (cursor_font)
+ gdk_font_ref(cursor_font);
+ }
/*
* Get the text extent of the cursor in question. We use the
}
}
-int do_cmdline(int argc, char **argv, int do_everything,
+int do_cmdline(int argc, char **argv, int do_everything, int *allow_launch,
struct gui_data *inst, Config *cfg)
{
int err = 0;
cfg->line_codepage[sizeof(cfg->line_codepage)-1] = '\0';
} else if (!strcmp(p, "-geometry")) {
- int flags, x, y, w, h;
+ int flags, x, y;
+ unsigned int w, h;
EXPECTS_ARG;
SECOND_PASS_ONLY;
flags = XParseGeometry(val, &x, &y, &w, &h);
if (flags & WidthValue)
- cfg->width = w;
+ cfg->width = (int)w;
if (flags & HeightValue)
- cfg->height = h;
+ cfg->height = (int)h;
if (flags & (XValue | YValue)) {
inst->xpos = x;
exit(1);
} else if(p[0] != '-' && (!do_everything ||
- process_nonoption_arg(p, cfg))) {
+ process_nonoption_arg(p, cfg,
+ allow_launch))) {
/* do nothing */
} else {
return err;
}
-/*
- * This function retrieves the character set encoding of a font. It
- * returns the character set without the X11 hack (in case the user
- * asks to use the font's own encoding).
- */
-static int set_font_info(struct gui_data *inst, int fontid)
-{
- GdkFont *font = inst->fonts[fontid];
- XFontStruct *xfs = GDK_FONT_XFONT(font);
- Display *disp = GDK_FONT_XDISPLAY(font);
- Atom charset_registry, charset_encoding;
- unsigned long registry_ret, encoding_ret;
- int retval = CS_NONE;
-
- charset_registry = XInternAtom(disp, "CHARSET_REGISTRY", False);
- charset_encoding = XInternAtom(disp, "CHARSET_ENCODING", False);
- inst->fontinfo[fontid].charset = CS_NONE;
- inst->fontinfo[fontid].is_wide = 0;
- if (XGetFontProperty(xfs, charset_registry, ®istry_ret) &&
- XGetFontProperty(xfs, charset_encoding, &encoding_ret)) {
- char *reg, *enc;
- reg = XGetAtomName(disp, (Atom)registry_ret);
- enc = XGetAtomName(disp, (Atom)encoding_ret);
- if (reg && enc) {
- char *encoding = dupcat(reg, "-", enc, NULL);
- retval = inst->fontinfo[fontid].charset =
- charset_from_xenc(encoding);
- /* FIXME: when libcharset supports wide encodings fix this. */
- if (!strcasecmp(encoding, "iso10646-1")) {
- inst->fontinfo[fontid].is_wide = 1;
- retval = CS_UTF8;
- }
-
- /*
- * Hack for X line-drawing characters: if the primary
- * font is encoded as ISO-8859-anything, and has valid
- * glyphs in the first 32 char positions, it is assumed
- * that those glyphs are the VT100 line-drawing
- * character set.
- *
- * Actually, we'll hack even harder by only checking
- * position 0x19 (vertical line, VT100 linedrawing
- * `x'). Then we can check it easily by seeing if the
- * ascent and descent differ.
- */
- if (inst->fontinfo[fontid].charset == CS_ISO8859_1) {
- int lb, rb, wid, asc, desc;
- gchar text[2];
-
- text[1] = '\0';
- text[0] = '\x12';
- gdk_string_extents(inst->fonts[fontid], text,
- &lb, &rb, &wid, &asc, &desc);
- if (asc != desc)
- inst->fontinfo[fontid].charset = CS_ISO8859_1_X11;
- }
-
- sfree(encoding);
- }
- }
-
- return retval;
-}
-
int uxsel_input_add(int fd, int rwx) {
int flags = 0;
if (rwx & 1) flags |= GDK_INPUT_READ;
if (rwx & 2) flags |= GDK_INPUT_WRITE;
if (rwx & 4) flags |= GDK_INPUT_EXCEPTION;
+ assert(flags);
return gdk_input_add(fd, flags, fd_input_func, NULL);
}
gdk_input_remove(id);
}
-char *guess_derived_font_name(GdkFont *font, int bold, int wide)
-{
- XFontStruct *xfs = GDK_FONT_XFONT(font);
- Display *disp = GDK_FONT_XDISPLAY(font);
- Atom fontprop = XInternAtom(disp, "FONT", False);
- unsigned long ret;
- if (XGetFontProperty(xfs, fontprop, &ret)) {
- char *name = XGetAtomName(disp, (Atom)ret);
- if (name && name[0] == '-') {
- char *strings[13];
- char *dupname, *extrafree = NULL, *ret;
- char *p, *q;
- int nstr;
-
- p = q = dupname = dupstr(name); /* skip initial minus */
- nstr = 0;
-
- while (*p && nstr < lenof(strings)) {
- if (*p == '-') {
- *p = '\0';
- strings[nstr++] = p+1;
- }
- p++;
- }
-
- if (nstr < lenof(strings))
- return NULL; /* XLFD was malformed */
-
- if (bold)
- strings[2] = "bold";
-
- if (wide) {
- /* 4 is `wideness', which obviously may have changed. */
- /* 5 is additional style, which may be e.g. `ja' or `ko'. */
- strings[4] = strings[5] = "*";
- strings[11] = extrafree = dupprintf("%d", 2*atoi(strings[11]));
- }
-
- ret = dupcat("-", strings[ 0], "-", strings[ 1], "-", strings[ 2],
- "-", strings[ 3], "-", strings[ 4], "-", strings[ 5],
- "-", strings[ 6], "-", strings[ 7], "-", strings[ 8],
- "-", strings[ 9], "-", strings[10], "-", strings[11],
- "-", strings[12], NULL);
- sfree(extrafree);
- sfree(dupname);
-
- return ret;
- }
- }
- return NULL;
-}
-
void setup_fonts_ucs(struct gui_data *inst)
{
- int font_charset;
- char *name;
- int guessed;
-
if (inst->fonts[0])
- gdk_font_unref(inst->fonts[0]);
+ unifont_destroy(inst->fonts[0]);
if (inst->fonts[1])
- gdk_font_unref(inst->fonts[1]);
+ unifont_destroy(inst->fonts[1]);
if (inst->fonts[2])
- gdk_font_unref(inst->fonts[2]);
+ unifont_destroy(inst->fonts[2]);
if (inst->fonts[3])
- gdk_font_unref(inst->fonts[3]);
+ unifont_destroy(inst->fonts[3]);
- inst->fonts[0] = gdk_font_load(inst->cfg.font.name);
+ inst->fonts[0] = unifont_create(inst->area, inst->cfg.font.name,
+ FALSE, FALSE,
+ inst->cfg.shadowboldoffset,
+ inst->cfg.shadowbold);
if (!inst->fonts[0]) {
fprintf(stderr, "%s: unable to load font \"%s\"\n", appname,
inst->cfg.font.name);
exit(1);
}
- font_charset = set_font_info(inst, 0);
- if (inst->cfg.shadowbold) {
+ if (inst->cfg.shadowbold || !inst->cfg.boldfont.name[0]) {
inst->fonts[1] = NULL;
} else {
- if (inst->cfg.boldfont.name[0]) {
- name = inst->cfg.boldfont.name;
- guessed = FALSE;
- } else {
- name = guess_derived_font_name(inst->fonts[0], TRUE, FALSE);
- guessed = TRUE;
- }
- inst->fonts[1] = name ? gdk_font_load(name) : NULL;
- if (inst->fonts[1]) {
- set_font_info(inst, 1);
- } else if (!guessed) {
+ inst->fonts[1] = unifont_create(inst->area, inst->cfg.boldfont.name,
+ FALSE, TRUE,
+ inst->cfg.shadowboldoffset,
+ inst->cfg.shadowbold);
+ if (!inst->fonts[1]) {
fprintf(stderr, "%s: unable to load bold font \"%s\"\n", appname,
inst->cfg.boldfont.name);
exit(1);
}
- if (guessed)
- sfree(name);
}
if (inst->cfg.widefont.name[0]) {
- name = inst->cfg.widefont.name;
- guessed = FALSE;
+ inst->fonts[2] = unifont_create(inst->area, inst->cfg.widefont.name,
+ TRUE, FALSE,
+ inst->cfg.shadowboldoffset,
+ inst->cfg.shadowbold);
+ if (!inst->fonts[2]) {
+ fprintf(stderr, "%s: unable to load wide font \"%s\"\n", appname,
+ inst->cfg.widefont.name);
+ exit(1);
+ }
} else {
- name = guess_derived_font_name(inst->fonts[0], FALSE, TRUE);
- guessed = TRUE;
- }
- inst->fonts[2] = name ? gdk_font_load(name) : NULL;
- if (inst->fonts[2]) {
- set_font_info(inst, 2);
- } else if (!guessed) {
- fprintf(stderr, "%s: unable to load wide font \"%s\"\n", appname,
- inst->cfg.widefont.name);
- exit(1);
+ inst->fonts[2] = NULL;
}
- if (guessed)
- sfree(name);
- if (inst->cfg.shadowbold) {
+ if (inst->cfg.shadowbold || !inst->cfg.wideboldfont.name[0]) {
inst->fonts[3] = NULL;
} else {
- if (inst->cfg.wideboldfont.name[0]) {
- name = inst->cfg.wideboldfont.name;
- guessed = FALSE;
- } else {
- /*
- * Here we have some choices. We can widen the bold font,
- * bolden the wide font, or widen and bolden the standard
- * font. Try them all, in that order!
- */
- if (inst->cfg.widefont.name[0])
- name = guess_derived_font_name(inst->fonts[2], TRUE, FALSE);
- else if (inst->cfg.boldfont.name[0])
- name = guess_derived_font_name(inst->fonts[1], FALSE, TRUE);
- else
- name = guess_derived_font_name(inst->fonts[0], TRUE, TRUE);
- guessed = TRUE;
- }
- inst->fonts[3] = name ? gdk_font_load(name) : NULL;
- if (inst->fonts[3]) {
- set_font_info(inst, 3);
- } else if (!guessed) {
- fprintf(stderr, "%s: unable to load wide/bold font \"%s\"\n", appname,
- inst->cfg.wideboldfont.name);
+ inst->fonts[3] = unifont_create(inst->area,
+ inst->cfg.wideboldfont.name, TRUE,
+ TRUE, inst->cfg.shadowboldoffset,
+ inst->cfg.shadowbold);
+ if (!inst->fonts[3]) {
+ fprintf(stderr, "%s: unable to load wide bold font \"%s\"\n", appname,
+ inst->cfg.boldfont.name);
exit(1);
}
- if (guessed)
- sfree(name);
}
- inst->font_width = gdk_char_width(inst->fonts[0], ' ');
- inst->font_height = inst->fonts[0]->ascent + inst->fonts[0]->descent;
+ inst->font_width = inst->fonts[0]->width;
+ inst->font_height = inst->fonts[0]->height;
inst->direct_to_font = init_ucs(&inst->ucsdata, inst->cfg.line_codepage,
- inst->cfg.utf8_override, font_charset,
+ inst->cfg.utf8_override,
+ inst->fonts[0]->public_charset,
inst->cfg.vtmode);
}
void reset_terminal_menuitem(GtkMenuItem *item, gpointer data)
{
struct gui_data *inst = (struct gui_data *)data;
- term_pwron(inst->term);
+ term_pwron(inst->term, TRUE);
if (inst->ldisc)
ldisc_send(inst->ldisc, NULL, 0, 0);
}
if (!inst->back) {
logevent(inst, "----- Session restarted -----");
+ term_pwron(inst->term, FALSE);
start_backend(inst);
inst->exited = FALSE;
}
(GtkCallback)gtk_widget_destroy, NULL);
get_sesslist(&sesslist, TRUE);
+ /* skip sesslist.sessions[0] == Default Settings */
for (i = 1; i < sesslist.nsessions; i++) {
GtkWidget *menuitem =
gtk_menu_item_new_with_label(sesslist.sessions[i]);
GTK_SIGNAL_FUNC(saved_session_freedata),
inst);
}
+ if (sesslist.nsessions <= 1) {
+ GtkWidget *menuitem =
+ gtk_menu_item_new_with_label("(No sessions)");
+ gtk_widget_set_sensitive(menuitem, FALSE);
+ gtk_container_add(GTK_CONTAINER(inst->sessionsmenu), menuitem);
+ gtk_widget_show(menuitem);
+ }
get_sesslist(&sesslist, FALSE); /* free up */
}
+void set_window_icon(GtkWidget *window, const char *const *const *icon,
+ int n_icon)
+{
+ GdkPixmap *iconpm;
+ GdkBitmap *iconmask;
+#if GTK_CHECK_VERSION(2,0,0)
+ GList *iconlist;
+ int n;
+#endif
+
+ if (!n_icon)
+ return;
+
+ gtk_widget_realize(window);
+ iconpm = gdk_pixmap_create_from_xpm_d(window->window, &iconmask,
+ NULL, (gchar **)icon[0]);
+ gdk_window_set_icon(window->window, NULL, iconpm, iconmask);
+
+#if GTK_CHECK_VERSION(2,0,0)
+ iconlist = NULL;
+ for (n = 0; n < n_icon; n++) {
+ iconlist =
+ g_list_append(iconlist,
+ gdk_pixbuf_new_from_xpm_data((const gchar **)
+ icon[n]));
+ }
+ gdk_window_set_icon_list(window->window, iconlist);
+#endif
+}
+
void update_specials_menu(void *frontend)
{
struct gui_data *inst = (struct gui_data *)frontend;
set_icon(inst, title);
sfree(title);
}
+ sfree(realhost);
+
inst->back->provide_logctx(inst->backhandle, inst->logctx);
term_provide_resize_fn(inst->term, inst->back->size, inst->backhandle);
ldisc_create(&inst->cfg, inst->term, inst->back, inst->backhandle,
inst);
- gtk_widget_hide(inst->restartitem);
+ gtk_widget_set_sensitive(inst->restartitem, FALSE);
}
int pt_main(int argc, char **argv)
/* 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))
+ /* By default, we bring up the config dialog, rather than launching
+ * a session. This gets set to TRUE if something happens to change
+ * that (e.g., a hostname is specified on the command-line). */
+ int allow_launch = FALSE;
+ if (do_cmdline(argc, argv, 0, &allow_launch, 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))
+ if (do_cmdline(argc, argv, 1, &allow_launch, inst, &inst->cfg))
exit(1); /* post-defaults, do everything */
cmdline_run_saved(&inst->cfg);
- if (!*inst->cfg.host && !cfgbox(&inst->cfg))
+ if (loaded_session)
+ allow_launch = TRUE;
+
+ if ((!allow_launch || !cfg_launchable(&inst->cfg)) &&
+ !cfgbox(&inst->cfg))
exit(0); /* config box hit Cancel */
}
if (!utf8_string_atom)
utf8_string_atom = gdk_atom_intern("UTF8_STRING", FALSE);
+ inst->area = gtk_drawing_area_new();
+
setup_fonts_ucs(inst);
init_cutbuffers();
inst->width = inst->cfg.width;
inst->height = inst->cfg.height;
- inst->area = gtk_drawing_area_new();
gtk_drawing_area_size(GTK_DRAWING_AREA(inst->area),
inst->font_width * inst->cfg.width + 2*inst->cfg.window_border,
inst->font_height * inst->cfg.height + 2*inst->cfg.window_border);
GTK_SIGNAL_FUNC(button_event), inst);
gtk_signal_connect(GTK_OBJECT(inst->area), "button_release_event",
GTK_SIGNAL_FUNC(button_event), inst);
+#if GTK_CHECK_VERSION(2,0,0)
+ gtk_signal_connect(GTK_OBJECT(inst->area), "scroll_event",
+ GTK_SIGNAL_FUNC(scroll_event), inst);
+#endif
gtk_signal_connect(GTK_OBJECT(inst->area), "motion_notify_event",
GTK_SIGNAL_FUNC(motion_event), inst);
gtk_signal_connect(GTK_OBJECT(inst->area), "selection_received",
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK | GDK_BUTTON_MOTION_MASK);
+ {
+ extern const char *const *const main_icon[];
+ extern const int n_main_icon;
+ set_window_icon(inst->window, main_icon, n_main_icon);
+ }
+
gtk_widget_show(inst->window);
set_window_background(inst);
GTK_SIGNAL_FUNC(func), inst); \
} while (0)
if (new_session)
- MKMENUITEM("New Session", new_session_menuitem);
+ MKMENUITEM("New Session...", new_session_menuitem);
MKMENUITEM("Restart Session", restart_session_menuitem);
inst->restartitem = menuitem;
- gtk_widget_hide(inst->restartitem);
+ gtk_widget_set_sensitive(inst->restartitem, FALSE);
MKMENUITEM("Duplicate Session", dup_session_menuitem);
if (saved_sessions) {
inst->sessionsmenu = gtk_menu_new();
inst->sessionsmenu);
}
MKMENUITEM(NULL, NULL);
- MKMENUITEM("Change Settings", change_settings_menuitem);
+ MKMENUITEM("Change Settings...", change_settings_menuitem);
MKMENUITEM(NULL, NULL);
if (use_event_log)
MKMENUITEM("Event Log", event_log_menuitem);