- char buf [255];
- Arg av[10];
- int ac;
- char *label;
- XmString xm_label = 0;
- XmString new_xm_label;
-
- create_demo_dialog (parent);
- ac = 0;
- XtSetArg (av [ac], XmNlabelString, &xm_label); ac++;
- XtGetValues (label1, av, ac);
- XmStringGetLtoR (xm_label, XmSTRING_DEFAULT_CHARSET, &label);
- if (!strcmp (label, XtName (label1)))
- strcpy (buf, "ERROR: RESOURCES ARE NOT INSTALLED CORRECTLY");
- else
- sprintf (buf, label, screensaver_version);
- new_xm_label = XmStringCreate (buf, XmSTRING_DEFAULT_CHARSET);
- ac = 0;
- XtSetArg (av [ac], XmNlabelString, new_xm_label); ac++;
- XtSetValues (label1, av, ac);
- XmStringFree (new_xm_label);
- XtFree (label);
-
- XtAddCallback (demo_list, XmNbrowseSelectionCallback, select_cb,
- (XtPointer) hacks);
- XtAddCallback (demo_list, XmNdefaultActionCallback, select_cb,
- (XtPointer) hacks);
-
- XtAddCallback (text_line, XmNactivateCallback, text_cb, 0);
- XtAddCallback (next, XmNactivateCallback, next_cb, 0);
- XtAddCallback (prev, XmNactivateCallback, prev_cb, 0);
- XtAddCallback (done, XmNactivateCallback, done_cb, 0);
- XtAddCallback (restart, XmNactivateCallback, restart_cb, 0);
- XtAddCallback (edit, XmNactivateCallback, edit_cb, (XtPointer) parent);
-
- for (; *hacks; hacks++)
- {
- XmString xmstr = XmStringCreate (*hacks, XmSTRING_DEFAULT_CHARSET);
- XmListAddItem (demo_list, xmstr, 0);
- /* XmListSelectPos (widget, i, False); */
- XmStringFree (xmstr);
- }
-
-#if 0
- /* Dialogs that have scroll-lists don't obey maxWidth! Fuck!! Hack it. */
- ac = 0;
- XtSetArg (av [ac], XmNmaxWidth, &max_w); ac++;
- XtGetValues (demo_dialog, av, ac); /* great, this SEGVs */
-#endif
-
- pop_up_dialog_box (demo_dialog, demo_form, 0);
+ saver_preferences *p = pair->a;
+ /* saver_preferences *p2 = pair->b; */
+
+ Widget parent = toplevel_shell;
+ char **hacks = p->screenhacks;
+
+ create_demo_dialog (parent,
+ DefaultVisualOfScreen (XtScreen (parent)),
+ DefaultColormapOfScreen (XtScreen (parent)));
+ format_into_label (label1, short_version);
+
+ add_button_callback (next, next_cb, (XtPointer) p);
+ add_button_callback (prev, prev_cb, (XtPointer) p);
+ add_button_callback (done, quit_cb, (XtPointer) p);
+ if (restart)
+ add_button_callback(restart,restart_cb, (XtPointer) p);
+ add_button_callback (edit, preferences_cb, (XtPointer) pair);
+
+#ifdef HAVE_MOTIF
+ XtAddCallback (demo_list, XmNbrowseSelectionCallback,
+ select_cb, (XtPointer) p);
+ XtAddCallback (demo_list, XmNdefaultActionCallback,
+ select_cb, (XtPointer) p);
+ XtAddCallback (text_line, XmNactivateCallback, text_cb, (XtPointer) p);
+
+ if (hacks)
+ for (; *hacks; hacks++)
+ {
+ XmString xmstr = XmStringCreate (*hacks, XmSTRING_DEFAULT_CHARSET);
+ XmListAddItem (demo_list, xmstr, 0);
+ XmStringFree (xmstr);
+ }
+
+#else /* HAVE_ATHENA */
+
+ /* Hook up the text line. */
+
+ XtAppAddActions(XtWidgetToApplicationContext(text_line),
+ actions, XtNumber(actions));
+ XtOverrideTranslations(text_line, XtParseTranslationTable(translations));
+
+
+ /* Must realize the widget before populating the list, or the dialog
+ will be as wide as the longest string.
+ */
+ XtRealizeWidget (demo_dialog);
+
+ XtVaSetValues (demo_list,
+ XtNlist, hacks,
+ XtNnumberStrings, p->screenhacks_count,
+ 0);
+ XtAddCallback (demo_list, XtNcallback, select_cb, p);
+
+ /* Now that we've populated the list, make sure that the list is as
+ wide as the dialog itself.
+ */
+ {
+ Widget viewport = XtParent(demo_list);
+ Widget subform = XtParent(viewport);
+ Widget box = XtNameToWidget(demo_dialog, "*box");
+ Widget label1 = XtNameToWidget(demo_dialog, "*label1");
+ Widget label2 = XtNameToWidget(demo_dialog, "*label2");
+ Dimension x=0, y=0, w=0, h=0, bw=0, w2=0;
+ XtVaGetValues(subform,
+ XtNwidth, &w, XtNheight, &h, XtNborderWidth, &bw, 0);
+ XtVaGetValues(box, XtNwidth, &w2, 0);
+ if (w2 != w)
+ XtResizeWidget(subform, w2, h, bw);
+
+ /* Why isn't the viewport getting centered? */
+ XtVaGetValues(viewport,
+ XtNx, &x, XtNy, &y, XtNheight, &h, XtNborderWidth, &bw, 0);
+ XtConfigureWidget(viewport, x, y, w2-x-x, h, bw);
+
+ /* And the text line, too. */
+ XtVaGetValues(text_line,
+ XtNwidth, &w, XtNheight, &h, XtNborderWidth, &bw, 0);
+ XtVaGetValues(viewport, XtNwidth, &w2, 0);
+ if (w2 != w)
+ XtResizeWidget(text_line, w2, h, bw);
+
+ /* And the labels too. */
+ XtVaGetValues(label1,
+ XtNwidth, &w, XtNheight, &h, XtNborderWidth, &bw, 0);
+ if (w2 != w)
+ XtResizeWidget(label1, w2, h, bw);
+
+ XtVaGetValues(label2,
+ XtNwidth, &w, XtNheight, &h, XtNborderWidth, &bw, 0);
+ if (w2 != w)
+ XtResizeWidget(label2, w2, h, bw);
+
+ }
+
+#endif /* HAVE_ATHENA */
+
+ pop_up_dialog_box(demo_dialog, demo_form);
+
+#ifdef HAVE_ATHENA
+ /* For Athena, have to do this after the dialog is managed. */
+ ensure_selected_item_visible (demo_list);
+#endif /* HAVE_ATHENA */