+ if (dp->flags & FLAG_UPDATING_LISTBOX)
+ return; /* not a user drag operation */
+
+ tree = g_object_get_data(G_OBJECT(treemodel), "user-data");
+ uc = dlg_find_bywidget(dp, GTK_WIDGET(tree));
+ if (uc) {
+ /*
+ * We should cause EVENT_VALCHANGE on the list box, now
+ * that its rows have been reordered. However, the GTK 2
+ * docs say that at the point this signal is received the
+ * new row might not have actually been filled in yet.
+ *
+ * (So what smegging use is it then, eh? Don't suppose it
+ * occurred to you at any point that letting the
+ * application know _after_ the reordering was compelete
+ * might be helpful to someone?)
+ *
+ * To get round this, I schedule an idle function, which I
+ * hope won't be called until the main event loop is
+ * re-entered after the drag-and-drop handler has finished
+ * furtling with the list store.
+ */
+ struct draglist_valchange_ctx *ctx =
+ snew(struct draglist_valchange_ctx);
+ ctx->uc = uc;
+ ctx->dp = dp;
+ g_idle_add(draglist_valchange, ctx);
+ }
+}
+
+#endif /* !GTK_CHECK_VERSION(2,0,0) */
+
+#if !GTK_CHECK_VERSION(2,4,0)
+
+static void menuitem_activate(GtkMenuItem *item, gpointer data)
+{
+ struct dlgparam *dp = (struct dlgparam *)data;
+ GtkWidget *menushell = GTK_WIDGET(item)->parent;
+ gpointer optmenu = gtk_object_get_data(GTK_OBJECT(menushell), "user-data");
+ struct uctrl *uc = dlg_find_bywidget(dp, GTK_WIDGET(optmenu));
+ uc->ctrl->generic.handler(uc->ctrl, dp, dp->data, EVENT_SELCHANGE);
+}
+
+#else
+
+static void droplist_selchange(GtkComboBox *combo, gpointer data)
+{
+ struct dlgparam *dp = (struct dlgparam *)data;
+ struct uctrl *uc = dlg_find_bywidget(dp, GTK_WIDGET(combo));
+ if (uc)
+ uc->ctrl->generic.handler(uc->ctrl, dp, dp->data, EVENT_SELCHANGE);
+}
+
+#endif /* !GTK_CHECK_VERSION(2,4,0) */
+
+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");
+ const char *name = gtk_file_selection_get_filename
+ (GTK_FILE_SELECTION(filesel));
+ gtk_entry_set_text(GTK_ENTRY(uc->entry), name);
+}
+
+static void fontsel_ok(GtkButton *button, gpointer data)
+{
+ /* struct dlgparam *dp = (struct dlgparam *)data; */
+
+#if !GTK_CHECK_VERSION(2,0,0)
+
+ gpointer fontsel = gtk_object_get_data(GTK_OBJECT(button), "user-data");
+ struct uctrl *uc = gtk_object_get_data(GTK_OBJECT(fontsel), "user-data");
+ const char *name = gtk_font_selection_dialog_get_font_name
+ (GTK_FONT_SELECTION_DIALOG(fontsel));
+ gtk_entry_set_text(GTK_ENTRY(uc->entry), name);
+
+#else
+
+ unifontsel *fontsel = (unifontsel *)gtk_object_get_data
+ (GTK_OBJECT(button), "user-data");
+ struct uctrl *uc = (struct uctrl *)fontsel->user_data;
+ char *name = unifontsel_get_name(fontsel);
+ assert(name); /* should always be ok after OK pressed */
+ gtk_entry_set_text(GTK_ENTRY(uc->entry), name);
+ sfree(name);
+
+#endif
+}
+
+static void coloursel_ok(GtkButton *button, gpointer data)
+{
+ struct dlgparam *dp = (struct dlgparam *)data;
+ gpointer coloursel = gtk_object_get_data(GTK_OBJECT(button), "user-data");
+ struct uctrl *uc = gtk_object_get_data(GTK_OBJECT(coloursel), "user-data");
+ gdouble cvals[4];
+ gtk_color_selection_get_color
+ (GTK_COLOR_SELECTION(GTK_COLOR_SELECTION_DIALOG(coloursel)->colorsel),
+ cvals);
+ dp->coloursel_result.r = (int) (255 * cvals[0]);
+ dp->coloursel_result.g = (int) (255 * cvals[1]);
+ dp->coloursel_result.b = (int) (255 * cvals[2]);
+ dp->coloursel_result.ok = TRUE;
+ uc->ctrl->generic.handler(uc->ctrl, dp, dp->data, EVENT_CALLBACK);
+}
+
+static void coloursel_cancel(GtkButton *button, gpointer data)
+{
+ struct dlgparam *dp = (struct dlgparam *)data;
+ gpointer coloursel = gtk_object_get_data(GTK_OBJECT(button), "user-data");
+ struct uctrl *uc = gtk_object_get_data(GTK_OBJECT(coloursel), "user-data");
+ dp->coloursel_result.ok = FALSE;
+ uc->ctrl->generic.handler(uc->ctrl, dp, dp->data, EVENT_CALLBACK);
+}
+
+static void filefont_clicked(GtkButton *button, gpointer data)
+{
+ struct dlgparam *dp = (struct dlgparam *)data;
+ struct uctrl *uc = dlg_find_bywidget(dp, GTK_WIDGET(button));
+
+ if (uc->ctrl->generic.type == CTRL_FILESELECT) {