]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Merge out from trunk, to keep this branch viable. We are now up to
authorSimon Tatham <anakin@pobox.com>
Mon, 10 Mar 2008 18:48:36 +0000 (18:48 +0000)
committerSimon Tatham <anakin@pobox.com>
Mon, 10 Mar 2008 18:48:36 +0000 (18:48 +0000)
date as of r7913.

[originally from svn r7914]
[r7913 == d7eda6d99cb6b7c2e09489dcf13b23c4cfcc61a2]

13 files changed:
LICENCE
doc/licence.but
mac/mac_res.r
mac/macpgen.r
mkfiles.pl
unix/GTK2.TODO [new file with mode: 0644]
unix/gtkcols.c
unix/gtkdlg.c
unix/gtkwin.c
unix/uxsel.c
windows/pageant.rc
windows/puttygen.rc
windows/win_res.rc2

diff --git a/LICENCE b/LICENCE
index 6f8d4b2704e4baa28041e2089f26df06ab83851f..88eba7bb01e410cdebd72525b08ce493eaa47461 100644 (file)
--- a/LICENCE
+++ b/LICENCE
@@ -3,7 +3,7 @@ PuTTY is copyright 1997-2008 Simon Tatham.
 Portions copyright Robert de Bath, Joris van Rantwijk, Delian
 Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas Barry,
 Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa, Markus
-Kuhn, and CORE SDI S.A.
+Kuhn, Colin Watson, and CORE SDI S.A.
 
 Permission is hereby granted, free of charge, to any person
 obtaining a copy of this software and associated documentation files
index 6e97198d50a191c3c58f9ef88f342f6450399159..39023bf93a7a589cd34708ff76a52cb1d68373ca 100644 (file)
@@ -6,8 +6,8 @@ PuTTY is \i{copyright} 1997-2008 Simon Tatham.
 
 Portions copyright Robert de Bath, Joris van Rantwijk, Delian
 Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas Barry,
-Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa, Markus Kuhn,
-and CORE SDI S.A.
+Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa, Markus
+Kuhn, Colin Watson, and CORE SDI S.A.
 
 Permission is hereby granted, free of charge, to any person
 obtaining a copy of this software and associated documentation files
index d73621ec83d0e7fb661c13f4aed521bfc4633c43..1a8246fe2cfcba1a3c3babb1f626092414714355 100644 (file)
@@ -1247,7 +1247,7 @@ resource 'TEXT' (wLicence, "licence", purgeable) {
     "Portions copyright Robert de Bath, Joris van Rantwijk, Delian "
     "Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas Barry, "
     "Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa, Markus "
-    "Kuhn, and CORE SDI S.A.\n"
+    "Kuhn, Colin Watson, and CORE SDI S.A.\n"
     "\n"    
     "Permission is hereby granted, free of charge, to any person "
     "obtaining a copy of this software and associated documentation "
index 9919c62a44d8077648634639d089ca4a9faf1e9e..da0dd55f771b804e5a474d6cd9adb8acc8deb62e 100644 (file)
@@ -448,7 +448,7 @@ resource 'TEXT' (wLicence, "licence", purgeable) {
     "Portions copyright Robert de Bath, Joris van Rantwijk, Delian "
     "Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas Barry, "
     "Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa, Markus "
-    "Kuhn, and CORE SDI S.A.\n"
+    "Kuhn, Colin Watson, and CORE SDI S.A.\n"
     "\n"    
     "Permission is hereby granted, free of charge, to any person "
     "obtaining a copy of this software and associated documentation "
index d43551b3bf01734937956e7fc3d434ebc4962c39..f0a57570ce7482ae8d04159404a724fa57c07398 100755 (executable)
@@ -924,12 +924,18 @@ if (defined $makefiles{'gtk'}) {
     "# You can define this path to point at your tools if you need to\n".
     "# TOOLPATH = /opt/gcc/bin\n".
     "CC = \$(TOOLPATH)cc\n".
+    "# You can manually set this to `gtk-config' or `pkg-config gtk+-1.2'\n".
+    "# (depending on what works on your system) if you want to enforce\n".
+    "# building with GTK 1.2, or you can set it to `pkg-config gtk+-2.0'\n".
+    "# if you want to enforce 2.0. The default is to try 2.0 and fall back\n".
+    "# to 1.2 if it isn't found.\n".
+    "GTK_CONFIG = sh -c 'pkg-config gtk+-2.0 \$\$0 2>/dev/null || gtk-config \$\$0'\n".
     "\n".
     &splitline("CFLAGS = -O2 -Wall -Werror -g " .
               (join " ", map {"-I$dirpfx$_"} @srcdirs) .
-              " `gtk-config --cflags`").
+              " `\$(GTK_CONFIG) --cflags`").
                 " -D _FILE_OFFSET_BITS=64\n".
-    "XLDFLAGS = \$(LDFLAGS) `gtk-config --libs`\n".
+    "XLDFLAGS = \$(LDFLAGS) `\$(GTK_CONFIG) --libs`\n".
     "ULDFLAGS = \$(LDFLAGS)\n".
     "INSTALL=install\n",
     "INSTALL_PROGRAM=\$(INSTALL)\n",
diff --git a/unix/GTK2.TODO b/unix/GTK2.TODO
new file mode 100644 (file)
index 0000000..f3caf82
--- /dev/null
@@ -0,0 +1,50 @@
+TODO for PuTTY GTK2 port before merging back into main trunk code
+-----------------------------------------------------------------
+
+Things to do before deciding a merge is feasible:
+
+ - Font handling is the biggie. Current problems with it:
+    * The GTK2 font selection dialog only mentions client-side
+      fonts, but the actual text display code can't cope with them.
+       + Clearly one or the other needs to be fixed: the font
+        selection dialog certainly needs to agree with the fonts
+        actually available in the program.
+       + I want to keep being able to use my server-side fonts.
+       + People used to GTK2 applications will probably want to use
+        their client-side fonts.
+    * Also, the GTK2 font selection dialog doesn't allow filtering
+      to monospaced fonts only (and gnome-terminal, for example,
+      just has to cope if the user selects a proportional font).
+       + We can live with this problem if we really have to, but
+        it'd be nice not to have to.
+    * Colin's idea is that we should simply cook up a font selection
+      dialog entirely of our own, which handles both client- _and_
+      server-side fonts, and correspondingly soup up the text
+      display code to deal with whichever it's given (if necessary
+      by switching between two totally separate pieces of code).
+      This sounds like a sensible plan to me, or at least the most
+      sensible response to a generally insane situation.
+
+ - The call to _gtk_container_dequeue_resize_handler wants
+   revisiting, and preferably removing in favour of a cleaner way to
+   do the job.
+
+ - gtkcols.c is currently a minimal-work GTK2 port of my original
+   GTK1 implementation. Someone should go through it and compare it
+   to a real GTK2 container class, to make sure there aren't any
+   large chunks we should have reimplemented and haven't, or indeed
+   that we shouldn't have reimplemented and have.
+
+ - Uses of GtkList should be replaced with the non-deprecated
+   GtkTreeView.
+
+ - Investigate the shortcut mechanism in GTK2's GtkLabel, and see if
+   it's worth switching to it from the current ad-hockery.
+
+Things to do once GTK2 development is complete:
+
+ - Make sure we haven't broken GTK1.
+
+Things to do at point of actual merge:
+
+ - Mention Colin in the website's licence page.
index c0a0ed8df35351e5b33cd6aeda5749c19e7fcb00..e70400dea10838bc8ea4dac51d5bf573f1ea66fe 100644 (file)
@@ -3,18 +3,23 @@
  */
 
 #include "gtkcols.h"
+#include <gtk/gtk.h>
 
 static void columns_init(Columns *cols);
 static void columns_class_init(ColumnsClass *klass);
 static void columns_map(GtkWidget *widget);
 static void columns_unmap(GtkWidget *widget);
+#if !GTK_CHECK_VERSION(2,0,0)
 static void columns_draw(GtkWidget *widget, GdkRectangle *area);
 static gint columns_expose(GtkWidget *widget, GdkEventExpose *event);
+#endif
 static void columns_base_add(GtkContainer *container, GtkWidget *widget);
 static void columns_remove(GtkContainer *container, GtkWidget *widget);
 static void columns_forall(GtkContainer *container, gboolean include_internals,
                            GtkCallback callback, gpointer callback_data);
+#if !GTK_CHECK_VERSION(2,0,0)
 static gint columns_focus(GtkContainer *container, GtkDirectionType dir);
+#endif
 static GtkType columns_child_type(GtkContainer *container);
 static void columns_size_request(GtkWidget *widget, GtkRequisition *req);
 static void columns_size_allocate(GtkWidget *widget, GtkAllocation *alloc);
@@ -43,8 +48,10 @@ GtkType columns_get_type(void)
     return columns_type;
 }
 
+#if !GTK_CHECK_VERSION(2,0,0)
 static gint (*columns_inherited_focus)(GtkContainer *container,
                                       GtkDirectionType direction);
+#endif
 
 static void columns_class_init(ColumnsClass *klass)
 {
@@ -65,8 +72,10 @@ static void columns_class_init(ColumnsClass *klass)
 
     widget_class->map = columns_map;
     widget_class->unmap = columns_unmap;
+#if !GTK_CHECK_VERSION(2,0,0)
     widget_class->draw = columns_draw;
     widget_class->expose_event = columns_expose;
+#endif
     widget_class->size_request = columns_size_request;
     widget_class->size_allocate = columns_size_allocate;
 
@@ -74,10 +83,12 @@ static void columns_class_init(ColumnsClass *klass)
     container_class->remove = columns_remove;
     container_class->forall = columns_forall;
     container_class->child_type = columns_child_type;
+#if !GTK_CHECK_VERSION(2,0,0)
     /* Save the previous value of this method. */
     if (!columns_inherited_focus)
        columns_inherited_focus = container_class->focus;
     container_class->focus = columns_focus;
+#endif
 }
 
 static void columns_init(Columns *cols)
@@ -135,6 +146,7 @@ static void columns_unmap(GtkWidget *widget)
             gtk_widget_unmap(child->widget);
     }
 }
+#if !GTK_CHECK_VERSION(2,0,0)
 static void columns_draw(GtkWidget *widget, GdkRectangle *area)
 {
     Columns *cols;
@@ -186,6 +198,7 @@ static gint columns_expose(GtkWidget *widget, GdkEventExpose *event)
     }
     return FALSE;
 }
+#endif
 
 static void columns_base_add(GtkContainer *container, GtkWidget *widget)
 {
@@ -241,6 +254,9 @@ static void columns_remove(GtkContainer *container, GtkWidget *widget)
 
         cols->taborder = g_list_remove_link(cols->taborder, children);
         g_list_free(children);
+#if GTK_CHECK_VERSION(2,0,0)
+       gtk_container_set_focus_chain(container, cols->taborder);
+#endif
         break;
     }
 }
@@ -332,6 +348,10 @@ void columns_add(Columns *cols, GtkWidget *child,
 
     gtk_widget_set_parent(child, GTK_WIDGET(cols));
 
+#if GTK_CHECK_VERSION(2,0,0)
+    gtk_container_set_focus_chain(GTK_CONTAINER(cols), cols->taborder);
+#endif
+
     if (GTK_WIDGET_REALIZED(cols))
         gtk_widget_realize(child);
 
@@ -382,10 +402,14 @@ void columns_taborder_last(Columns *cols, GtkWidget *widget)
         cols->taborder = g_list_remove_link(cols->taborder, children);
         g_list_free(children);
        cols->taborder = g_list_append(cols->taborder, widget);
+#if GTK_CHECK_VERSION(2,0,0)
+       gtk_container_set_focus_chain(GTK_CONTAINER(cols), cols->taborder);
+#endif
         break;
     }
 }
 
+#if !GTK_CHECK_VERSION(2,0,0)
 /*
  * Override GtkContainer's focus movement so the user can
  * explicitly specify the tab order.
@@ -449,6 +473,7 @@ static gint columns_focus(GtkContainer *container, GtkDirectionType dir)
     } else
        return columns_inherited_focus(container, dir);
 }
+#endif
 
 /*
  * Now here comes the interesting bit. The actual layout part is
index bdfe3e55ecc320f3fbea6fe45378e1d3ff7c5ae2..ee520a374990ca729de2766103aaebd218bb6c3a 100644 (file)
@@ -2,15 +2,6 @@
  * gtkdlg.c - GTK implementation of the PuTTY configuration box.
  */
 
-/*
- * TODO when porting to GTK 2.0:
- * 
- *  - GtkTree is apparently deprecated and we should switch to
- *    GtkTreeView instead.
- *  - GtkLabel has a built-in mnemonic scheme, so we should at
- *    least consider switching to that from the current adhockery.
- */
-
 #include <assert.h>
 #include <stdarg.h>
 #include <ctype.h>
@@ -56,6 +47,7 @@ struct uctrl {
     GtkWidget *text;         /* for text */
     GtkWidget *label;         /* for dlg_label_change */
     GtkAdjustment *adj;       /* for the scrollbar in a list box */
+    guint entrysig;
     guint textsig;
     int nclicks;
 };
@@ -68,9 +60,12 @@ struct dlgparam {
      * due to automatic processing and should not flag a user event. */
     int flags;
     struct Shortcuts *shortcuts;
-    GtkWidget *window, *cancelbutton, *currtreeitem, **treeitems;
+    GtkWidget *window, *cancelbutton;
     union control *currfocus, *lastfocus;
+#if !GTK_CHECK_VERSION(2,0,0)
+    GtkWidget *currtreeitem, **treeitems;
     int ntreeitems;
+#endif
     int retval;
 };
 #define FLAG_UPDATING_COMBO_LIST 1
@@ -84,6 +79,14 @@ enum {                                      /* values for Shortcut.action */
     SHORTCUT_UCTRL_DOWN,              /* uctrl is a draglist, move Down */
 };
 
+#if GTK_CHECK_VERSION(2,0,0)
+enum {
+    TREESTORE_PATH,
+    TREESTORE_PARAMS,
+    TREESTORE_NUM
+};
+#endif
+
 /*
  * Forward references.
  */
@@ -92,14 +95,14 @@ static gboolean widget_focus(GtkWidget *widget, GdkEventFocus *event,
 static void shortcut_add(struct Shortcuts *scs, GtkWidget *labelw,
                         int chr, int action, void *ptr);
 static void shortcut_highlight(GtkWidget *label, int chr);
-static int listitem_single_key(GtkWidget *item, GdkEventKey *event,
-                               gpointer data);
-static int listitem_multi_key(GtkWidget *item, GdkEventKey *event,
-                                 gpointer data);
-static int listitem_button_press(GtkWidget *item, GdkEventButton *event,
-                                gpointer data);
-static int listitem_button_release(GtkWidget *item, GdkEventButton *event,
-                                  gpointer data);
+static gboolean listitem_single_key(GtkWidget *item, GdkEventKey *event,
+                                   gpointer data);
+static gboolean listitem_multi_key(GtkWidget *item, GdkEventKey *event,
+                                  gpointer data);
+static gboolean listitem_button_press(GtkWidget *item, GdkEventButton *event,
+                                     gpointer data);
+static gboolean listitem_button_release(GtkWidget *item, GdkEventButton *event,
+                                       gpointer data);
 static void menuitem_activate(GtkMenuItem *item, gpointer data);
 static void coloursel_ok(GtkButton *button, gpointer data);
 static void coloursel_cancel(GtkButton *button, gpointer data);
@@ -154,8 +157,11 @@ static void dlg_init(struct dlgparam *dp)
     dp->byctrl = newtree234(uctrl_cmp_byctrl);
     dp->bywidget = newtree234(uctrl_cmp_bywidget);
     dp->coloursel_result.ok = FALSE;
+    dp->window = dp->cancelbutton = NULL;
+#if !GTK_CHECK_VERSION(2,0,0)
     dp->treeitems = NULL;
-    dp->window = dp->cancelbutton = dp->currtreeitem = NULL;
+    dp->currtreeitem = NULL;
+#endif
     dp->flags = 0;
     dp->currfocus = NULL;
 }
@@ -175,7 +181,9 @@ static void dlg_cleanup(struct dlgparam *dp)
     }
     freetree234(dp->bywidget);
     dp->bywidget = NULL;
+#if !GTK_CHECK_VERSION(2,0,0)
     sfree(dp->treeitems);
+#endif
 }
 
 static void dlg_add_uctrl(struct dlgparam *dp, struct uctrl *uc)
@@ -287,7 +295,27 @@ void dlg_editbox_set(union control *ctrl, void *dlg, char const *text)
     struct uctrl *uc = dlg_find_byctrl(dp, ctrl);
     assert(uc->ctrl->generic.type == CTRL_EDITBOX);
     assert(uc->entry != NULL);
+    /*
+     * GTK 2 implements gtk_entry_set_text by means of two separate
+     * operations: first delete the previous text leaving the empty
+     * string, then insert the new text. This causes two calls to
+     * the "changed" signal.
+     * 
+     * The first call to "changed", if allowed to proceed normally,
+     * will cause an EVENT_VALCHANGE event on the edit box, causing
+     * a call to dlg_editbox_get() which will read the empty string
+     * out of the GtkEntry - and promptly write it straight into
+     * the Config structure, which is precisely where our `text'
+     * pointer is probably pointing, so the second editing
+     * operation will insert that instead of the string we
+     * originally asked for.
+     * 
+     * Hence, we must block our "changed" signal handler for the
+     * duration of this call to gtk_entry_set_text.
+     */
+    g_signal_handler_block(uc->entry, uc->entrysig);
     gtk_entry_set_text(GTK_ENTRY(uc->entry), text);
+    g_signal_handler_unblock(uc->entry, uc->entrysig);
 }
 
 void dlg_editbox_get(union control *ctrl, void *dlg, char *buffer, int length)
@@ -740,7 +768,11 @@ void dlg_set_focus(union control *ctrl, void *dlg)
             gtk_widget_grab_focus(uc->optmenu);
         } else {
             assert(uc->list != NULL);
+#if GTK_CHECK_VERSION(2,0,0)
+           gtk_widget_grab_focus(uc->list);
+#else
             gtk_container_focus(GTK_CONTAINER(uc->list), GTK_DIR_TAB_FORWARD);
+#endif
         }
         break;
     }
@@ -868,7 +900,11 @@ void dlg_coloursel_start(union control *ctrl, void *dlg, int r, int g, int b)
     dp->coloursel_result.ok = FALSE;
 
     gtk_window_set_modal(GTK_WINDOW(coloursel), TRUE);
+#if GTK_CHECK_VERSION(2,0,0)
+    gtk_color_selection_set_has_opacity_control(GTK_COLOR_SELECTION(ccs->colorsel), FALSE);
+#else
     gtk_color_selection_set_opacity(GTK_COLOR_SELECTION(ccs->colorsel), FALSE);
+#endif
     cvals[0] = r / 255.0;
     cvals[1] = g / 255.0;
     cvals[2] = b / 255.0;
@@ -944,7 +980,8 @@ static void button_toggled(GtkToggleButton *tb, gpointer data)
     uc->ctrl->generic.handler(uc->ctrl, dp, dp->data, EVENT_VALCHANGE);
 }
 
-static int editbox_key(GtkWidget *widget, GdkEventKey *event, gpointer data)
+static gboolean editbox_key(GtkWidget *widget, GdkEventKey *event,
+                           gpointer data)
 {
     /*
      * GtkEntry has a nasty habit of eating the Return key, which
@@ -956,7 +993,7 @@ static int editbox_key(GtkWidget *widget, GdkEventKey *event, gpointer data)
      * in the dialog just like it will everywhere else.
      */
     if (event->keyval == GDK_Return && widget->parent != NULL) {
-       gint return_val;
+       gboolean return_val;
        gtk_signal_emit_stop_by_name(GTK_OBJECT(widget), "key_press_event");
        gtk_signal_emit_by_name(GTK_OBJECT(widget->parent), "key_press_event",
                                event, &return_val);
@@ -974,16 +1011,17 @@ static void editbox_changed(GtkEditable *ed, gpointer data)
     }
 }
 
-static void editbox_lostfocus(GtkWidget *ed, GdkEventFocus *event,
-                             gpointer data)
+static gboolean editbox_lostfocus(GtkWidget *ed, GdkEventFocus *event,
+                                 gpointer data)
 {
     struct dlgparam *dp = (struct dlgparam *)data;
     struct uctrl *uc = dlg_find_bywidget(dp, GTK_WIDGET(ed));
     uc->ctrl->generic.handler(uc->ctrl, dp, dp->data, EVENT_REFRESH);
+    return FALSE;
 }
 
-static int listitem_key(GtkWidget *item, GdkEventKey *event, gpointer data,
-                        int multiple)
+static gboolean listitem_key(GtkWidget *item, GdkEventKey *event,
+                            gpointer data, int multiple)
 {
     GtkAdjustment *adj = GTK_ADJUSTMENT(data);
 
@@ -1076,20 +1114,20 @@ static int listitem_key(GtkWidget *item, GdkEventKey *event, gpointer data,
     return FALSE;
 }
 
-static int listitem_single_key(GtkWidget *item, GdkEventKey *event,
-                               gpointer data)
+static gboolean listitem_single_key(GtkWidget *item, GdkEventKey *event,
+                                   gpointer data)
 {
     return listitem_key(item, event, data, FALSE);
 }
 
-static int listitem_multi_key(GtkWidget *item, GdkEventKey *event,
-                                 gpointer data)
+static gboolean listitem_multi_key(GtkWidget *item, GdkEventKey *event,
+                                  gpointer data)
 {
     return listitem_key(item, event, data, TRUE);
 }
 
-static int listitem_button_press(GtkWidget *item, GdkEventButton *event,
-                                gpointer data)
+static gboolean listitem_button_press(GtkWidget *item, GdkEventButton *event,
+                                     gpointer data)
 {
     struct dlgparam *dp = (struct dlgparam *)data;
     struct uctrl *uc = dlg_find_bywidget(dp, GTK_WIDGET(item));
@@ -1102,8 +1140,8 @@ static int listitem_button_press(GtkWidget *item, GdkEventButton *event,
     return FALSE;
 }
 
-static int listitem_button_release(GtkWidget *item, GdkEventButton *event,
-                                   gpointer data)
+static gboolean listitem_button_release(GtkWidget *item, GdkEventButton *event,
+                                       gpointer data)
 {
     struct dlgparam *dp = (struct dlgparam *)data;
     struct uctrl *uc = dlg_find_bywidget(dp, GTK_WIDGET(item));
@@ -1175,7 +1213,8 @@ static void filesel_ok(GtkButton *button, gpointer data)
     /* struct dlgparam *dp = (struct dlgparam *)data; */
     gpointer filesel = gtk_object_get_data(GTK_OBJECT(button), "user-data");
     struct uctrl *uc = gtk_object_get_data(GTK_OBJECT(filesel), "user-data");
-    char *name = gtk_file_selection_get_filename(GTK_FILE_SELECTION(filesel));
+    const char *name = gtk_file_selection_get_filename
+       (GTK_FILE_SELECTION(filesel));
     gtk_entry_set_text(GTK_ENTRY(uc->entry), name);
 }
 
@@ -1184,7 +1223,7 @@ static void fontsel_ok(GtkButton *button, gpointer data)
     /* struct dlgparam *dp = (struct dlgparam *)data; */
     gpointer fontsel = gtk_object_get_data(GTK_OBJECT(button), "user-data");
     struct uctrl *uc = gtk_object_get_data(GTK_OBJECT(fontsel), "user-data");
-    char *name = gtk_font_selection_dialog_get_font_name
+    const char *name = gtk_font_selection_dialog_get_font_name
        (GTK_FONT_SELECTION_DIALOG(fontsel));
     gtk_entry_set_text(GTK_ENTRY(uc->entry), name);
 }
@@ -1240,15 +1279,20 @@ static void filefont_clicked(GtkButton *button, gpointer data)
     }
 
     if (uc->ctrl->generic.type == CTRL_FONTSELECT) {
+#if !GTK_CHECK_VERSION(2,0,0)
        gchar *spacings[] = { "c", "m", NULL };
-        gchar *fontname = gtk_entry_get_text(GTK_ENTRY(uc->entry));
+#endif
+        const gchar *fontname = gtk_entry_get_text(GTK_ENTRY(uc->entry));
+       /* TODO: In GTK 2, this only seems to offer client-side fonts. */
        GtkWidget *fontsel =
            gtk_font_selection_dialog_new("Select a font");
        gtk_window_set_modal(GTK_WINDOW(fontsel), TRUE);
+#if !GTK_CHECK_VERSION(2,0,0)
        gtk_font_selection_dialog_set_filter
            (GTK_FONT_SELECTION_DIALOG(fontsel),
             GTK_FONT_FILTER_BASE, GTK_FONT_ALL,
             NULL, NULL, NULL, NULL, spacings, NULL);
+#endif
        if (!gtk_font_selection_dialog_set_font_name
            (GTK_FONT_SELECTION_DIALOG(fontsel), fontname)) {
             /*
@@ -1263,6 +1307,7 @@ static void filefont_clicked(GtkButton *button, gpointer data)
                 Display *disp = GDK_FONT_XDISPLAY(font);
                 Atom fontprop = XInternAtom(disp, "FONT", False);
                 unsigned long ret;
+               gdk_font_ref(font);
                 if (XGetFontProperty(xfs, fontprop, &ret)) {
                     char *name = XGetAtomName(disp, (Atom)ret);
                     if (name)
@@ -1488,8 +1533,9 @@ GtkWidget *layout_ctrls(struct dlgparam *dp, struct Shortcuts *scs,
                        gtk_entry_set_visibility(GTK_ENTRY(w), FALSE);
                    uc->entry = w;
                }
-               gtk_signal_connect(GTK_OBJECT(uc->entry), "changed",
-                                  GTK_SIGNAL_FUNC(editbox_changed), dp);
+               uc->entrysig =
+                   gtk_signal_connect(GTK_OBJECT(uc->entry), "changed",
+                                      GTK_SIGNAL_FUNC(editbox_changed), dp);
                gtk_signal_connect(GTK_OBJECT(uc->entry), "key_press_event",
                                   GTK_SIGNAL_FUNC(editbox_key), dp);
                gtk_signal_connect(GTK_OBJECT(uc->entry), "focus_in_event",
@@ -1580,8 +1626,9 @@ GtkWidget *layout_ctrls(struct dlgparam *dp, struct Shortcuts *scs,
 
                gtk_signal_connect(GTK_OBJECT(uc->entry), "key_press_event",
                                   GTK_SIGNAL_FUNC(editbox_key), dp);
-               gtk_signal_connect(GTK_OBJECT(uc->entry), "changed",
-                                  GTK_SIGNAL_FUNC(editbox_changed), dp);
+               uc->entrysig =
+                   gtk_signal_connect(GTK_OBJECT(uc->entry), "changed",
+                                      GTK_SIGNAL_FUNC(editbox_changed), dp);
                 gtk_signal_connect(GTK_OBJECT(uc->entry), "focus_in_event",
                                    GTK_SIGNAL_FUNC(widget_focus), dp);
                 gtk_signal_connect(GTK_OBJECT(uc->button), "focus_in_event",
@@ -1639,7 +1686,12 @@ GtkWidget *layout_ctrls(struct dlgparam *dp, struct Shortcuts *scs,
                  * upgrades, I'd be grateful.
                  */
                {
-                   int edge = GTK_WIDGET(uc->list)->style->klass->ythickness;
+                   int edge;
+#if GTK_CHECK_VERSION(2,0,0)
+                   edge = GTK_WIDGET(uc->list)->style->ythickness;
+#else
+                   edge = GTK_WIDGET(uc->list)->style->klass->ythickness;
+#endif
                     gtk_widget_set_usize(w, 10,
                                          2*edge + (ctrl->listbox.height *
                                                   listitemheight));
@@ -1760,10 +1812,37 @@ GtkWidget *layout_ctrls(struct dlgparam *dp, struct Shortcuts *scs,
 struct selparam {
     struct dlgparam *dp;
     GtkNotebook *panels;
-    GtkWidget *panel, *treeitem;
+    GtkWidget *panel;
+#if !GTK_CHECK_VERSION(2,0,0)
+    GtkWidget *treeitem;
+#endif
     struct Shortcuts shortcuts;
 };
 
+#if GTK_CHECK_VERSION(2,0,0)
+static void treeselection_changed(GtkTreeSelection *treeselection,
+                                 gpointer data)
+{
+    struct selparam *sps = (struct selparam *)data, *sp;
+    GtkTreeModel *treemodel;
+    GtkTreeIter treeiter;
+    gint spindex;
+    gint page_num;
+
+    if (!gtk_tree_selection_get_selected(treeselection, &treemodel, &treeiter))
+       return;
+
+    gtk_tree_model_get(treemodel, &treeiter, TREESTORE_PARAMS, &spindex, -1);
+    sp = &sps[spindex];
+
+    page_num = gtk_notebook_page_num(sp->panels, sp->panel);
+    gtk_notebook_set_page(sp->panels, page_num);
+
+    dlg_refresh(NULL, sp->dp);
+
+    sp->dp->shortcuts = &sp->shortcuts;
+}
+#else
 static void treeitem_sel(GtkItem *item, gpointer data)
 {
     struct selparam *sp = (struct selparam *)data;
@@ -1777,12 +1856,14 @@ static void treeitem_sel(GtkItem *item, gpointer data)
     sp->dp->shortcuts = &sp->shortcuts;
     sp->dp->currtreeitem = sp->treeitem;
 }
+#endif
 
 static void window_destroy(GtkWidget *widget, gpointer data)
 {
     gtk_main_quit();
 }
 
+#if !GTK_CHECK_VERSION(2,0,0)
 static int tree_grab_focus(struct dlgparam *dp)
 {
     int i, f;
@@ -1818,6 +1899,7 @@ gint tree_focus(GtkContainer *container, GtkDirectionType direction,
      */
     return tree_grab_focus(dp);
 }
+#endif
 
 int win_key_press(GtkWidget *widget, GdkEventKey *event, gpointer data)
 {
@@ -1836,7 +1918,11 @@ int win_key_press(GtkWidget *widget, GdkEventKey *event, gpointer data)
 
        switch (sc->action) {
          case SHORTCUT_TREE:
+#if GTK_CHECK_VERSION(2,0,0)
+           gtk_widget_grab_focus(sc->widget);
+#else
            tree_grab_focus(dp);
+#endif
            break;
          case SHORTCUT_FOCUS:
            gtk_widget_grab_focus(sc->widget);
@@ -1912,8 +1998,12 @@ int win_key_press(GtkWidget *widget, GdkEventKey *event, gpointer data)
                } else {
                     assert(sc->uc->list != NULL);
 
+#if GTK_CHECK_VERSION(2,0,0)
+                   gtk_widget_grab_focus(sc->uc->list);
+#else
                     gtk_container_focus(GTK_CONTAINER(sc->uc->list),
                                         GTK_DIR_TAB_FORWARD);
+#endif
                }
                break;
            }
@@ -1924,6 +2014,7 @@ int win_key_press(GtkWidget *widget, GdkEventKey *event, gpointer data)
     return FALSE;
 }
 
+#if !GTK_CHECK_VERSION(2,0,0)
 int tree_key_press(GtkWidget *widget, GdkEventKey *event, gpointer data)
 {
     struct dlgparam *dp = (struct dlgparam *)data;
@@ -1992,6 +2083,7 @@ int tree_key_press(GtkWidget *widget, GdkEventKey *event, gpointer data)
 
     return FALSE;
 }
+#endif
 
 static void shortcut_highlight(GtkWidget *labelw, int chr)
 {
@@ -2043,10 +2135,76 @@ int get_listitemheight(void)
     GtkWidget *listitem = gtk_list_item_new_with_label("foo");
     GtkRequisition req;
     gtk_widget_size_request(listitem, &req);
-    gtk_widget_unref(listitem);
+    gtk_object_sink(GTK_OBJECT(listitem));
     return req.height;
 }
 
+void set_dialog_action_area(GtkDialog *dlg, GtkWidget *w)
+{
+#if !GTK_CHECK_VERSION(2,0,0)
+
+    /*
+     * In GTK 1, laying out the buttons at the bottom of the
+     * configuration box is nice and easy, because a GtkDialog's
+     * action_area is a GtkHBox which stretches to cover the full
+     * width of the dialog. So we just put our Columns widget
+     * straight into that hbox, and it ends up just where we want
+     * it.
+     */
+    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->action_area),
+                      w, TRUE, TRUE, 0);
+
+#else
+    /*
+     * In GTK 2, the action area is now a GtkHButtonBox and its
+     * layout behaviour seems to be different: it doesn't stretch
+     * to cover the full width of the window, but instead finds its
+     * own preferred width and right-aligns that within the window.
+     * This isn't what we want, because we have both left-aligned
+     * and right-aligned buttons coming out of the above call to
+     * layout_ctrls(), and right-aligning the whole thing will
+     * result in the former being centred and looking weird.
+     *
+     * So instead we abandon the dialog's action area completely:
+     * we gtk_widget_hide() it in the below code, and we also call
+     * gtk_dialog_set_has_separator() to remove the separator above
+     * it. We then insert our own action area into the end of the
+     * dialog's main vbox, and add our own separator above that.
+     *
+     * (Ideally, if we were a native GTK app, we would use the
+     * GtkHButtonBox's _own_ innate ability to support one set of
+     * buttons being right-aligned and one left-aligned. But to do
+     * that here, we would have to either (a) pick apart our cross-
+     * platform layout structures and treat them specially for this
+     * particular set of controls, which would be painful, or else
+     * (b) develop a special and simpler cross-platform
+     * representation for these particular controls, and introduce
+     * special-case code into all the _other_ platforms to handle
+     * it. Neither appeals. Therefore, I regretfully discard the
+     * GTKHButtonBox and go it alone.)
+     */
+
+    GtkWidget *align;
+    align = gtk_alignment_new(0, 0, 1, 1);
+    gtk_container_add(GTK_CONTAINER(align), w);
+    /*
+     * The purpose of this GtkAlignment is to provide padding
+     * around the buttons. The padding we use is twice the padding
+     * used in our GtkColumns, because we nest two GtkColumns most
+     * of the time (one separating the tree view from the main
+     * controls, and another for the main controls themselves).
+     */
+    gtk_alignment_set_padding(GTK_ALIGNMENT(align), 8, 8, 8, 8);
+    gtk_widget_show(align);
+    gtk_box_pack_end(GTK_BOX(dlg->vbox), align, FALSE, TRUE, 0);
+    w = gtk_hseparator_new();
+    gtk_box_pack_end(GTK_BOX(dlg->vbox), w, FALSE, TRUE, 0);
+    gtk_widget_show(w);
+    gtk_widget_hide(dlg->action_area);
+    gtk_dialog_set_has_separator(dlg, FALSE);
+#endif
+}
+
 int do_config_box(const char *title, Config *cfg, int midsession,
                  int protcfginfo)
 {
@@ -2055,8 +2213,16 @@ int do_config_box(const char *title, Config *cfg, int midsession,
     int index, level, listitemheight;
     struct controlbox *ctrlbox;
     char *path;
+#if GTK_CHECK_VERSION(2,0,0)
+    GtkTreeStore *treestore;
+    GtkCellRenderer *treerenderer;
+    GtkTreeViewColumn *treecolumn;
+    GtkTreeSelection *treeselection;
+    GtkTreeIter treeiterlevels[8];
+#else
     GtkTreeItem *treeitemlevels[8];
     GtkTree *treelevels[8];
+#endif
     struct dlgparam dp;
     struct Shortcuts scs;
 
@@ -2094,14 +2260,28 @@ int do_config_box(const char *title, Config *cfg, int midsession,
     columns_force_left_align(COLUMNS(cols), label);
     gtk_widget_show(label);
     treescroll = gtk_scrolled_window_new(NULL, NULL);
+#if GTK_CHECK_VERSION(2,0,0)
+    treestore = gtk_tree_store_new
+       (TREESTORE_NUM, G_TYPE_STRING, G_TYPE_INT);
+    tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(treestore));
+    gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(tree), FALSE);
+    treerenderer = gtk_cell_renderer_text_new();
+    treecolumn = gtk_tree_view_column_new_with_attributes
+       ("Label", treerenderer, "text", 0, NULL);
+    gtk_tree_view_append_column(GTK_TREE_VIEW(tree), treecolumn);
+    treeselection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
+    gtk_tree_selection_set_mode(treeselection, GTK_SELECTION_BROWSE);
+    gtk_container_add(GTK_CONTAINER(treescroll), tree);
+#else
     tree = gtk_tree_new();
-    gtk_signal_connect(GTK_OBJECT(tree), "focus_in_event",
-                       GTK_SIGNAL_FUNC(widget_focus), &dp);
-    shortcut_add(&scs, label, 'g', SHORTCUT_TREE, tree);
     gtk_tree_set_view_mode(GTK_TREE(tree), GTK_TREE_VIEW_ITEM);
     gtk_tree_set_selection_mode(GTK_TREE(tree), GTK_SELECTION_BROWSE);
     gtk_signal_connect(GTK_OBJECT(tree), "focus",
                       GTK_SIGNAL_FUNC(tree_focus), &dp);
+#endif
+    gtk_signal_connect(GTK_OBJECT(tree), "focus_in_event",
+                       GTK_SIGNAL_FUNC(widget_focus), &dp);
+    shortcut_add(&scs, label, 'g', SHORTCUT_TREE, tree);
     gtk_widget_show(treescroll);
     gtk_box_pack_start(GTK_BOX(vbox), treescroll, TRUE, TRUE, 0);
     panels = gtk_notebook_new();
@@ -2119,13 +2299,17 @@ int do_config_box(const char *title, Config *cfg, int midsession,
 
        if (!*s->pathname) {
            w = layout_ctrls(&dp, &scs, s, listitemheight, GTK_WINDOW(window));
-           gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->action_area),
-                              w, TRUE, TRUE, 0);
+
+           set_dialog_action_area(GTK_DIALOG(window), w);
        } else {
            int j = path ? ctrl_path_compare(s->pathname, path) : 0;
            if (j != INT_MAX) {        /* add to treeview, start new panel */
                char *c;
+#if GTK_CHECK_VERSION(2,0,0)
+               GtkTreeIter treeiter;
+#else
                GtkWidget *treeitem;
+#endif
                int first;
 
                /*
@@ -2146,8 +2330,63 @@ int do_config_box(const char *title, Config *cfg, int midsession,
                else
                    c++;
 
-               treeitem = gtk_tree_item_new_with_label(c);
+               path = s->pathname;
+
+               first = (panelvbox == NULL);
+
+               panelvbox = gtk_vbox_new(FALSE, 4);
+               gtk_widget_show(panelvbox);
+               gtk_notebook_append_page(GTK_NOTEBOOK(panels), panelvbox,
+                                        NULL);
+               if (first) {
+                   gint page_num;
+
+                   page_num = gtk_notebook_page_num(GTK_NOTEBOOK(panels),
+                                                    panelvbox);
+                   gtk_notebook_set_page(GTK_NOTEBOOK(panels), page_num);
+               }
+
+               if (nselparams >= selparamsize) {
+                   selparamsize += 16;
+                   selparams = sresize(selparams, selparamsize,
+                                       struct selparam);
+               }
+               selparams[nselparams].dp = &dp;
+               selparams[nselparams].panels = GTK_NOTEBOOK(panels);
+               selparams[nselparams].panel = panelvbox;
+               selparams[nselparams].shortcuts = scs;   /* structure copy */
+
                assert(j-1 < level);
+
+#if GTK_CHECK_VERSION(2,0,0)
+               if (j > 0)
+                   /* treeiterlevels[j-1] will always be valid because we
+                    * don't allow implicit path components; see above.
+                    */
+                   gtk_tree_store_append(treestore, &treeiter,
+                                         &treeiterlevels[j-1]);
+               else
+                   gtk_tree_store_append(treestore, &treeiter, NULL);
+               gtk_tree_store_set(treestore, &treeiter,
+                                  TREESTORE_PATH, c,
+                                  TREESTORE_PARAMS, nselparams,
+                                  -1);
+               treeiterlevels[j] = treeiter;
+
+               if (j > 0) {
+                   GtkTreePath *path;
+
+                   path = gtk_tree_model_get_path(GTK_TREE_MODEL(treestore),
+                                                  &treeiterlevels[j-1]);
+                   if (j < 2)
+                       gtk_tree_view_expand_row(GTK_TREE_VIEW(tree), path,
+                                                FALSE);
+                   else
+                       gtk_tree_view_collapse_row(GTK_TREE_VIEW(tree), path);
+                   gtk_tree_path_free(path);
+               }
+#else
+               treeitem = gtk_tree_item_new_with_label(c);
                if (j > 0) {
                    if (!treelevels[j-1]) {
                        treelevels[j-1] = GTK_TREE(gtk_tree_new());
@@ -2165,7 +2404,6 @@ int do_config_box(const char *title, Config *cfg, int midsession,
                }
                treeitemlevels[j] = GTK_TREE_ITEM(treeitem);
                treelevels[j] = NULL;
-               level = j+1;
 
                 gtk_signal_connect(GTK_OBJECT(treeitem), "key_press_event",
                                    GTK_SIGNAL_FUNC(tree_key_press), &dp);
@@ -2174,35 +2412,13 @@ int do_config_box(const char *title, Config *cfg, int midsession,
 
                gtk_widget_show(treeitem);
 
-               path = s->pathname;
-
-               first = (panelvbox == NULL);
-
-               panelvbox = gtk_vbox_new(FALSE, 4);
-               gtk_widget_show(panelvbox);
-               gtk_notebook_append_page(GTK_NOTEBOOK(panels), panelvbox,
-                                        NULL);
-               if (first) {
-                   gint page_num;
-
-                   page_num = gtk_notebook_page_num(GTK_NOTEBOOK(panels),
-                                                    panelvbox);
-                   gtk_notebook_set_page(GTK_NOTEBOOK(panels), page_num);
+               if (first)
                    gtk_tree_select_child(GTK_TREE(tree), treeitem);
-               }
-
-               if (nselparams >= selparamsize) {
-                   selparamsize += 16;
-                   selparams = sresize(selparams, selparamsize,
-                                       struct selparam);
-               }
-               selparams[nselparams].dp = &dp;
-               selparams[nselparams].panels = GTK_NOTEBOOK(panels);
-               selparams[nselparams].panel = panelvbox;
-               selparams[nselparams].shortcuts = scs;   /* structure copy */
                selparams[nselparams].treeitem = treeitem;
-               nselparams++;
+#endif
 
+               level = j+1;
+               nselparams++;
            }
 
            w = layout_ctrls(&dp,
@@ -2213,6 +2429,10 @@ int do_config_box(const char *title, Config *cfg, int midsession,
        }
     }
 
+#if GTK_CHECK_VERSION(2,0,0)
+    g_signal_connect(G_OBJECT(treeselection), "changed",
+                    G_CALLBACK(treeselection_changed), selparams);
+#else
     dp.ntreeitems = nselparams;
     dp.treeitems = snewn(dp.ntreeitems, GtkWidget *);
 
@@ -2222,12 +2442,15 @@ int do_config_box(const char *title, Config *cfg, int midsession,
                           &selparams[index]);
         dp.treeitems[index] = selparams[index].treeitem;
     }
+#endif
 
     dp.data = cfg;
     dlg_refresh(NULL, &dp);
 
     dp.shortcuts = &selparams[0].shortcuts;
+#if !GTK_CHECK_VERSION(2,0,0)
     dp.currtreeitem = dp.treeitems[0];
+#endif
     dp.lastfocus = NULL;
     dp.retval = 0;
     dp.window = window;
@@ -2242,8 +2465,10 @@ int do_config_box(const char *title, Config *cfg, int midsession,
        set_window_icon(window, cfg_icon, n_cfg_icon);
     }
 
+#if !GTK_CHECK_VERSION(2,0,0)
     gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(treescroll),
                                          tree);
+#endif
     gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(treescroll),
                                   GTK_POLICY_NEVER,
                                   GTK_POLICY_AUTOMATIC);
@@ -2355,8 +2580,7 @@ int messagebox(GtkWidget *parentwin, char *title, char *msg, int minwid, ...)
     window = gtk_dialog_new();
     gtk_window_set_title(GTK_WINDOW(window), title);
     w0 = layout_ctrls(&dp, &scs, s0, 0, GTK_WINDOW(window));
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->action_area),
-                      w0, TRUE, TRUE, 0);
+    set_dialog_action_area(GTK_DIALOG(window), w0);
     gtk_widget_show(w0);
     w1 = layout_ctrls(&dp, &scs, s1, 0, GTK_WINDOW(window));
     gtk_container_set_border_width(GTK_CONTAINER(w1), 10);
@@ -2397,7 +2621,7 @@ static int string_width(char *text)
     GtkWidget *label = gtk_label_new(text);
     GtkRequisition req;
     gtk_widget_size_request(label, &req);
-    gtk_widget_unref(label);
+    gtk_object_sink(GTK_OBJECT(label));
     return req.width;
 }
 
@@ -2549,7 +2773,7 @@ static void licence_clicked(GtkButton *button, gpointer data)
        "Portions copyright Robert de Bath, Joris van Rantwijk, Delian "
        "Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas "
        "Barry, Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa, "
-       "Markus Kuhn, and CORE SDI S.A.\n\n"
+       "Markus Kuhn, Colin Watson, and CORE SDI S.A.\n\n"
 
        "Permission is hereby granted, free of charge, to any person "
        "obtaining a copy of this software and associated documentation "
@@ -2801,8 +3025,7 @@ void showeventlog(void *estuff, void *parentwin)
     sfree(title);
     w0 = layout_ctrls(&es->dp, &es->scs, s0,
                      listitemheight, GTK_WINDOW(window));
-    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->action_area),
-                      w0, TRUE, TRUE, 0);
+    set_dialog_action_area(GTK_DIALOG(window), w0);
     gtk_widget_show(w0);
     w1 = layout_ctrls(&es->dp, &es->scs, s1,
                      listitemheight, GTK_WINDOW(window));
index d31037b6cd37264b56a10aa7c041f1761e241c9a..e6ff13c352c0d9066c0a9c32cfc96d438e26ea4a 100644 (file)
@@ -327,7 +327,7 @@ void set_zoomed(void *frontend, int zoomed)
      */
 #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));
@@ -1353,17 +1353,13 @@ void request_resize(void *frontend, int w, int h)
      */
 #if GTK_CHECK_VERSION(2,0,0)
     gtk_widget_set_size_request(inst->area, area_x, area_y);
+    _gtk_container_dequeue_resize_handler(GTK_CONTAINER(inst->window));
+    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
-
     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
@@ -2292,8 +2288,11 @@ GdkCursor *make_mouse_ptr(struct gui_data *inst, int cursor_val)
        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
@@ -2703,6 +2702,7 @@ int uxsel_input_add(int fd, int rwx) {
     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);
 }
 
@@ -2783,6 +2783,7 @@ void setup_fonts_ucs(struct gui_data *inst)
                inst->cfg.font.name);
        exit(1);
     }
+    gdk_font_ref(inst->fonts[0]);
     font_charset = set_font_info(inst, 0);
 
     if (inst->cfg.shadowbold) {
@@ -2797,6 +2798,7 @@ void setup_fonts_ucs(struct gui_data *inst)
        }
        inst->fonts[1] = name ? gdk_font_load(name) : NULL;
        if (inst->fonts[1]) {
+           gdk_font_ref(inst->fonts[1]);
            set_font_info(inst, 1);
        } else if (!guessed) {
            fprintf(stderr, "%s: unable to load bold font \"%s\"\n", appname,
@@ -2816,6 +2818,7 @@ void setup_fonts_ucs(struct gui_data *inst)
     }
     inst->fonts[2] = name ? gdk_font_load(name) : NULL;
     if (inst->fonts[2]) {
+       gdk_font_ref(inst->fonts[2]);
        set_font_info(inst, 2);
     } else if (!guessed) {
        fprintf(stderr, "%s: unable to load wide font \"%s\"\n", appname,
@@ -2847,6 +2850,7 @@ void setup_fonts_ucs(struct gui_data *inst)
        }
        inst->fonts[3] = name ? gdk_font_load(name) : NULL;
        if (inst->fonts[3]) {
+           gdk_font_ref(inst->fonts[3]);
            set_font_info(inst, 3);
        } else if (!guessed) {
            fprintf(stderr, "%s: unable to load wide/bold font \"%s\"\n", appname,
@@ -2858,6 +2862,17 @@ void setup_fonts_ucs(struct gui_data *inst)
     }
 
     inst->font_width = gdk_char_width(inst->fonts[0], ' ');
+    if (!inst->font_width) {
+       /* Maybe this is a 16-bit font? If so, GDK 2 actually expects a
+        * pointer to an XChar2b. This is pretty revolting. Can Pango do
+        * this more neatly even for server-side fonts?
+        */
+       XChar2b space;
+       space.byte1 = 0;
+       space.byte2 = ' ';
+       inst->font_width = gdk_text_width(inst->fonts[0],
+                                         (const gchar *)&space, 2);
+    }
     inst->font_height = inst->fonts[0]->ascent + inst->fonts[0]->descent;
 
     inst->direct_to_font = init_ucs(&inst->ucsdata, inst->cfg.line_codepage,
index 0383faa69d02624c9d459afb046f7d0177705687..e2979c9a01e6aed34f27c5f2bf440bb5dd083717 100644 (file)
@@ -62,22 +62,18 @@ void uxsel_init(void)
 
 void uxsel_set(int fd, int rwx, uxsel_callback_fn callback)
 {
-    struct fd *newfd = snew(struct fd);
-    struct fd *oldfd;
+    struct fd *newfd;
 
-    newfd->fd = fd;
-    newfd->rwx = rwx;
-    newfd->callback = callback;
+    uxsel_del(fd);
 
-    oldfd = find234(fds, newfd, NULL);
-    if (oldfd) {
-       uxsel_input_remove(oldfd->id);
-       del234(fds, oldfd);
-       sfree(oldfd);
+    if (rwx) {
+       newfd = snew(struct fd);
+       newfd->fd = fd;
+       newfd->rwx = rwx;
+       newfd->callback = callback;
+       newfd->id = uxsel_input_add(fd, rwx);
+       add234(fds, newfd);
     }
-
-    add234(fds, newfd);
-    newfd->id = uxsel_input_add(fd, rwx);
 }
 
 void uxsel_del(int fd)
index 8445258711ef72646d55dd5d98bd2b428c9e6fa7..f70b1bfc17d98de5339c8b4b87bda32e4dd2d1ef 100644 (file)
@@ -62,7 +62,7 @@ BEGIN
     LTEXT "Portions copyright Robert de Bath, Joris van Rantwijk, Delian", 1001, 10, 26, 206, 8
     LTEXT "Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas", 1002, 10, 34, 206, 8
     LTEXT "Barry, Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa,", 1003, 10, 42, 206, 8
-    LTEXT "Markus Kuhn, and CORE SDI S.A.", 1004, 10, 50, 206, 8
+    LTEXT "Markus Kuhn, Colin Watson, and CORE SDI S.A.", 1004, 10, 50, 206, 8
 
     LTEXT "Permission is hereby granted, free of charge, to any person", 1005, 10, 66, 206, 8
     LTEXT "obtaining a copy of this software and associated documentation", 1006, 10, 74, 206, 8
index d353d244bfdd647f930477d2ce9265d8b7da2c18..1dc7a37f30f32f5375efa59fef9592c52e158cc2 100644 (file)
@@ -55,7 +55,7 @@ BEGIN
     LTEXT "Portions copyright Robert de Bath, Joris van Rantwijk, Delian", 1001, 10, 26, 206, 8
     LTEXT "Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas", 1002, 10, 34, 206, 8
     LTEXT "Barry, Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa,", 1003, 10, 42, 206, 8
-    LTEXT "Markus Kuhn, and CORE SDI S.A.", 1004, 10, 50, 206, 8
+    LTEXT "Markus Kuhn, Colin Watson, and CORE SDI S.A.", 1004, 10, 50, 206, 8
 
     LTEXT "Permission is hereby granted, free of charge, to any person", 1005, 10, 66, 206, 8
     LTEXT "obtaining a copy of this software and associated documentation", 1006, 10, 74, 206, 8
index 04660c30ed0b270ce61c5492a87f8a9b9c734413..03695dbda4750a5b28f5f864342fef2ed51d6f30 100644 (file)
@@ -63,7 +63,7 @@ BEGIN
     LTEXT "Portions copyright Robert de Bath, Joris van Rantwijk, Delian", 1001, 10, 26, 206, 8
     LTEXT "Delchev, Andreas Schultz, Jeroen Massar, Wez Furlong, Nicolas", 1002, 10, 34, 206, 8
     LTEXT "Barry, Justin Bradford, Ben Harris, Malcolm Smith, Ahmad Khalifa,", 1003, 10, 42, 206, 8
-    LTEXT "Markus Kuhn, and CORE SDI S.A.", 1004, 10, 50, 206, 8
+    LTEXT "Markus Kuhn, Colin Watson, and CORE SDI S.A.", 1004, 10, 50, 206, 8
 
     LTEXT "Permission is hereby granted, free of charge, to any person", 1005, 10, 66, 206, 8
     LTEXT "obtaining a copy of this software and associated documentation", 1006, 10, 74, 206, 8