2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $TOG: I18nMain.c /main/4 1997/08/11 12:31:36 samborn $ */
25 * (c) Copyright 1996 Digital Equipment Corporation.
26 * (c) Copyright 1996 Hewlett-Packard Company.
27 * (c) Copyright 1996 International Business Machines Corp.
28 * (c) Copyright 1996 Sun Microsystems, Inc.
29 * (c) Copyright 1996 Novell, Inc.
30 * (c) Copyright 1996 FUJITSU LIMITED.
31 * (c) Copyright 1996 Hitachi.
33 /************************************<+>*************************************
34 ****************************************************************************
38 ** Description: Controls the Dtstyle I18N customization dialog
41 ****************************************************************************
42 ************************************<+>*************************************/
44 /*+++++++++++++++++++++++++++++++++++++++*/
46 /*+++++++++++++++++++++++++++++++++++++++*/
50 #include <Xm/MwmUtil.h>
55 #include <Xm/LabelG.h>
56 #include <Xm/PushBG.h>
57 #include <Xm/RowColumn.h>
58 #include <Xm/ToggleBG.h>
59 #include <Xm/SeparatoG.h>
60 #include <Xm/VendorSEP.h>
61 #include <Xm/MessageB.h>
63 #include <Dt/DialogBox.h>
65 #include <Dt/TitleBox.h>
66 #include <Dt/UserMsg.h>
67 #include <Dt/Message.h>
68 #include <Dt/HourGlass.h>
73 #include "SaveRestore.h"
78 /*+++++++++++++++++++++++++++++++++++++++*/
79 /* include extern functions */
80 /*+++++++++++++++++++++++++++++++++++++++*/
84 /*+++++++++++++++++++++++++++++++++++++++*/
86 /*+++++++++++++++++++++++++++++++++++++++*/
88 #define MSG_IMMEDIATE ((char *)GETMESSAGE(19, 20, "The new XmNpreeditType value will take effect\nas applications are restarted."))
89 #define MSG_LATER ((char *)GETMESSAGE(19, 21, "Your selection will take effect\n at your next session."))
91 /*+++++++++++++++++++++++++++++++++++++++*/
92 /* Internal Functions */
93 /*+++++++++++++++++++++++++++++++++++++++*/
95 static int InitI18nValues(Widget shell);
96 static void SetImServerHosts(I18nEnv *env);
97 static void SetImsToggleList(I18nEnv *env);
98 static void SetImsMode(I18nEnv *env);
99 static void SetPreeditType(I18nEnv *env, XmStringTable preeditTable,
100 int preeditTableNum);
102 static Widget BuildI18nDlg(Widget shell);
103 static void FormLayoutCB(Widget w, XtPointer client_data, XtPointer call_data);
104 static void MapCB(Widget w, XtPointer client_data, XtPointer call_data);
105 static void SystemDefaultCB(Widget w, XtPointer client_data,
106 XtPointer call_data);
107 static void ServerHostCB(Widget w, XtPointer client_data, XtPointer call_data);
108 static void UpdateImList(I18nEnv *env, char *hostname);
109 static void TextFocusCB(Widget w, XtPointer client_data, XtPointer call_data);
110 static void TextLosingFocusCB(Widget w, XtPointer client_data,
111 XtPointer call_data);
112 static void ButtonCB(Widget w, XtPointer client_data, XtPointer call_data);
113 static int SaveSelectedValues(I18nEnv *env);
114 static void SetFileSelValues(I18nEnv *env);
115 static void ResetLastSavedValues(I18nEnv *env);
117 static void OkWarnCB(Widget w, XtPointer client_data, XtPointer call_data);
118 static void CancelWarnCB(Widget w, XtPointer client_data, XtPointer call_data);
120 static void ListItemSelectCB(Widget w, XtPointer client_data,
121 XtPointer call_data);
122 static void MoveUpCB(Widget w, XtPointer client_data, XtPointer call_data);
123 static void MoveDownCB(Widget w, XtPointer client_data, XtPointer call_data);
125 static XmStringTable CopyST (XmStringTable st, int nst);
126 static void FreeST (XmStringTable st, int nst);
128 /*+++++++++++++++++++++++++++++++++++++++*/
129 /* Internal Variables */
130 /*+++++++++++++++++++++++++++++++++++++++*/
134 Widget systemDefault;
135 Widget inputMethodTB;
136 Widget serverHostLabel;
138 Widget inputMethodLabel;
139 Widget inputMethodRC;
140 Widget imStartModeTB;
141 Widget imStartModeRC;
143 Widget resumeCurrentImTG;
144 Widget preeditTypeTB;
145 Widget preeditTypeList;
146 int preeditTypeListLastPos;
147 Boolean preeditHasChanged;
148 XmStringTable preeditSavedVal;
151 Widget buttonMoveDown;
153 Widget defaultButton;
158 static saveRestore save = {FALSE, 0, };
160 static char i18nRes[150]="";
162 static char *defaultPreedit[] =
168 #define NUM_PREEDIT 4
170 /*+++++++++++++++++++++++++++++++++++++++*/
172 /*+++++++++++++++++++++++++++++++++++++++*/
180 if (style.i18nDialog == NULL) {
181 _DtTurnOnHourGlass(shell);
183 ret = InitI18nValues(shell);
184 XtManageChild(style.i18nDialog);
186 _DtI18nErrorDialog(ret) ;
187 _DtTurnOffHourGlass(shell);
191 XtManageChild(style.i18nDialog);
192 raiseWindow(XtWindow(XtParent(style.i18nDialog)));
196 /*+++++++++++++++++++++++++++++++++++++++*/
198 /*+++++++++++++++++++++++++++++++++++++++*/
201 InitI18nValues(Widget shell)
206 XmString *str = style.xrdb.preeditType;
212 /* Get all the needed values from the environment. */
213 if ((ret = _DtI18nGetEnvValues(env)) == NoError) {
214 /* Update the display with the values */
215 SetImServerHosts(env);
219 /* Get the preeditType resource value */
220 while (str[num_preedit]) num_preedit++;
222 SetPreeditType(env, style.xrdb.preeditType, num_preedit);
224 i18n.preeditHasChanged = False;
226 /* Save the initial value in case of a reset. */
227 i18n.preeditSavedVal = style.xrdb.preeditType;
228 i18n.preeditSavedNum = num_preedit;
235 SetImServerHosts(I18nEnv *env)
237 Cardinal num_hosts = 0 ;
239 /* Set the TextField of the ComboBox with the value found in
240 the IMS selection file */
241 XtVaSetValues(XtNameToWidget(i18n.serverHostCB,"Text"),
242 XmNvalue, env->file_sel->hostname, NULL);
244 /* update ComboBox with list of server hostnames found in
245 "imServerHosts" resource */
247 if (style.xrdb.imServerHosts)
248 while (style.xrdb.imServerHosts[num_hosts]) num_hosts ++ ;
250 /* TBD: need to add file_sel->hostname if not null
251 or localhost, if not already present */
253 XtVaSetValues(i18n.serverHostCB,
254 XmNitemCount, num_hosts,
255 XmNitems, style.xrdb.imServerHosts, NULL);
259 SetImsToggleList(I18nEnv *env)
263 Widget *im_tog = NULL;
265 Boolean found = FALSE;
266 Cardinal default_index = 0;
268 /* create new toggles */
270 if (env->ims_sel->ims_list_size > 0)
271 im_tog = (Widget*)XtMalloc(sizeof(Widget)
272 * env->ims_sel->ims_list_size);
275 for (i=0; i< env->ims_sel->ims_list_size; i++) {
276 string = XmStringCreateLocalized(env->ims_sel->ims_list[i].im_label);
278 XtSetArg(args[n], XmNlabelString, string); n++;
279 XtSetArg(args[n], XmNsensitive,
280 !(env->ims_sel->ims_list[i].inactive)); n++;
281 XtSetArg(args[n], XmNuserData,
282 env->ims_sel->ims_list[i].im_name); n++;
284 /* Need to default to the file_sel->im_name, if in the list */
285 if (strcmp(env->file_sel->im_name,
286 env->ims_sel->ims_list[i].im_name) == 0) {
288 XtSetArg(args[n], XmNset, True); n++;
291 if (env->ims_sel->ims_list[i].im_default) {
295 im_tog[i] = XmCreateToggleButtonGadget(i18n.inputMethodRC,
297 XmStringFree(string);
300 if (env->ims_sel->ims_list_size > 0)
301 XtManageChildren(im_tog, env->ims_sel->ims_list_size);
303 /* If we provided toggle buttons, but the file_sel->im_name was not
304 found, default it to the default from the locale file. */
306 if (im_tog && !found) {
308 XtSetArg(args[n], XmNset, True); n++;
309 XtSetValues(im_tog[default_index], args, n);
313 XtFree((char *) im_tog);
315 _DtTurnOffHourGlass(i18n.inputMethodTB);
319 SetImsMode(I18nEnv *env)
322 /* only called once at startup, or when resetting the saved values */
323 if (env->file_sel->start_mode == 0)
324 XmToggleButtonGadgetSetState(i18n.askAtLoginTG, True, True);
326 XmToggleButtonGadgetSetState(i18n.resumeCurrentImTG, True, True);
332 XmStringTable preeditTable,
335 XmStringTable loc_preeditTable ;
337 loc_preeditTable = CopyST(preeditTable, preeditTableNum);
339 /* initialize List with preeditType values */
340 XtVaSetValues(i18n.preeditTypeList,
341 XmNvisibleItemCount, preeditTableNum,
342 XmNitemCount, preeditTableNum,
343 XmNitems, loc_preeditTable,
344 XmNselectedItemCount, 1,
345 XmNselectedItems, loc_preeditTable, NULL);
347 /* set the last item position - This is the number of items in the list. */
348 i18n.preeditTypeListLastPos = preeditTableNum;
350 /* If more than one item in the list, set the Button MoveDown sentivity to
352 if (preeditTableNum > 1)
353 XtVaSetValues(i18n.buttonMoveDown, XmNsensitive, True, NULL);
355 XtVaSetValues(i18n.buttonMoveUp, XmNsensitive, False, NULL);
359 /*+++++++++++++++++++++++++++++++++++++++*/
361 /*+++++++++++++++++++++++++++++++++++++++*/
368 XmString button_string[NUM_LABELS];
371 Widget inputMethodForm;
372 Widget imStartModeForm;
373 Widget preeditTypeForm;
375 Widget widgetList1[6];
377 /* get i18n resource values */
379 /* Set up DialogBoxDialog button labels */
380 button_string[0] = CMPSTR((String) _DtOkString);
381 button_string[1] = CMPSTR((String) _DtCancelString);
382 button_string[2] = CMPSTR((String) _DtHelpString);
384 /* Create toplevel DialogBox */
386 /* Initialize the i18n structure */
387 i18n.pictLabel = NULL;
388 i18n.systemDefault = NULL;
389 i18n.inputMethodTB = NULL;
390 i18n.serverHostLabel = NULL;
391 i18n.serverHostCB = NULL;
392 i18n.inputMethodLabel = NULL;
393 i18n.inputMethodRC = NULL;
394 i18n.imStartModeTB = NULL;
395 i18n.imStartModeRC = NULL;
396 i18n.askAtLoginTG = NULL;
397 i18n.resumeCurrentImTG = NULL;
398 i18n.preeditTypeTB = NULL;
399 i18n.preeditTypeList = NULL;
400 i18n.buttonMoveUp = NULL;
401 i18n.buttonMoveDown = NULL;
402 i18n.warnDialog = NULL;
405 * Note that save.poscnt has been initialized elsewhere.
406 * save.posArgs may contain information from restoreBeep().*/
408 XtSetArg(save.posArgs[save.poscnt], XmNbuttonCount, NUM_LABELS);
410 XtSetArg(save.posArgs[save.poscnt], XmNbuttonLabelStrings, button_string);
412 XtSetArg(save.posArgs[save.poscnt], XmNdefaultPosition, False);
415 __DtCreateDialogBoxDialog(shell, "i18nDialog", save.posArgs,
417 XtAddCallback(style.i18nDialog, XmNhelpCallback,
418 (XtCallbackProc)HelpRequestCB, (XtPointer)HELP_I18N_DIALOG);
420 XmStringFree(button_string[0]);
421 XmStringFree(button_string[1]);
422 XmStringFree(button_string[2]);
424 widgetList1[0] = _DtDialogBoxGetButton(style.i18nDialog,2);
426 XtSetArg(args[n], XmNautoUnmanage, False); n++;
427 XtSetArg(args[n], XmNcancelButton, widgetList1[0]); n++;
428 XtSetValues (style.i18nDialog, args, n);
431 XtSetArg(args[n], XmNtitle,
432 ((char *)GETMESSAGE(19, 1, "Style Manager - Internationalization")));
434 XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
435 XtSetArg(args[n], XmNmwmFunctions, DIALOG_MWM_FUNC); n++;
436 XtSetValues (XtParent(style.i18nDialog), args, n);
439 XtSetArg(args[n], XmNallowOverlap, False); n++;
440 XtSetArg(args[n], XmNchildType, XmWORK_AREA); n++;
441 form = XmCreateForm(style.i18nDialog, "i18nForm", args, n);
444 XtSetArg(args[n], XmNfillMode, XmFILL_SELF); n++;
445 XtSetArg(args[n], XmNbehavior, XmICON_LABEL); n++;
446 XtSetArg(args[n], XmNpixmapForeground, style.secBSCol); n++;
447 XtSetArg(args[n], XmNpixmapBackground, style.secTSCol); n++;
448 XtSetArg(args[n], XmNstring, NULL); n++;
449 XtSetArg(args[n], XmNshadowThickness, 0); n++;
450 XtSetArg(args[n], XmNimageName, I18N_ICON); n++;
451 XtSetArg(args[n], XmNtraversalOn, False); n++;
452 widgetList1[count++] = i18n.pictLabel =
453 _DtCreateIcon(form, "i18npictLabel", args, n);
456 XtSetArg(args[n], XmNmarginHeight, LB_MARGIN_HEIGHT); n++;
457 XtSetArg(args[n], XmNmarginWidth, LB_MARGIN_WIDTH); n++;
458 string = CMPSTR(((char *)GETMESSAGE(19, 2, "Default")));
459 XtSetArg(args[n], XmNlabelString, string); n++;
460 widgetList1[count++] = i18n.systemDefault =
461 XmCreatePushButtonGadget(form, "systemDefault", args, n);
462 XmStringFree(string);
465 string = CMPSTR((char *)GETMESSAGE(19, 3, "Input Method"));
466 XtSetArg(args[n], XmNtitleString, string); n++;
467 widgetList1[count++] = i18n.inputMethodTB =
468 _DtCreateTitleBox(form, "inputMethodTB", args, n);
469 XmStringFree(string);
472 XtSetArg(args[n], XmNallowOverlap, False); n++;
473 XtSetArg(args[n], XmNchildType, XmWORK_AREA); n++;
475 XmCreateForm(i18n.inputMethodTB, "inputMethodForm", args, n);
478 string = CMPSTR((char *)GETMESSAGE(19, 4, "Input Method Start Mode"));
479 XtSetArg(args[n], XmNtitleString, string); n++;
480 widgetList1[count++] = i18n.imStartModeTB =
481 _DtCreateTitleBox(form, "imStartModeTB", args, n);
482 XmStringFree(string);
485 XtSetArg(args[n], XmNallowOverlap, False); n++;
486 XtSetArg(args[n], XmNchildType, XmWORK_AREA); n++;
488 XmCreateForm(i18n.imStartModeTB, "imStartModeForm", args, n);
491 string = CMPSTR((char *)GETMESSAGE(19, 5, "Preedit Type"));
492 XtSetArg(args[n], XmNtitleString, string); n++;
493 widgetList1[count++] = i18n.preeditTypeTB =
494 _DtCreateTitleBox(form, "preeditTypeTB", args, n);
495 XmStringFree(string);
498 XtSetArg(args[n], XmNallowOverlap, False); n++;
499 XtSetArg(args[n], XmNchildType, XmWORK_AREA); n++;
501 XmCreateForm(i18n.preeditTypeTB, "preeditTypeForm", args, n);
503 /* Create widgets inside the inputMethodForm */
505 string = CMPSTR((char *)GETMESSAGE(19, 6, "Server Host :"));
506 XtSetArg(args[n], XmNlabelString, string); n++;
507 i18n.serverHostLabel =
508 XmCreateLabelGadget(inputMethodForm, "serverHostLabel", args, n);
511 XtSetArg(args[n], XmNcomboBoxType, XmDROP_DOWN_COMBO_BOX); n++;
513 (Widget) (intptr_t) XmCreateComboBox(inputMethodForm, "serverHostCB", args, n);
515 XtAddCallback(XtNameToWidget(i18n.serverHostCB, "Text"),
516 XmNactivateCallback, ServerHostCB, NULL);
517 XtAddCallback(XtNameToWidget(i18n.serverHostCB, "Text"),
518 XmNfocusCallback, TextFocusCB, NULL);
519 XtAddCallback(XtNameToWidget(i18n.serverHostCB, "Text"),
520 XmNlosingFocusCallback, TextLosingFocusCB, NULL);
524 string = CMPSTR((char *)GETMESSAGE(19, 7, "Input Method"));
525 XtSetArg(args[n], XmNlabelString, string); n++;
526 i18n.inputMethodLabel =
527 XmCreateLabelGadget(inputMethodForm, "inputMethodLabel", args, n);
530 XtSetArg(args[n], XmNmarginWidth, LB_MARGIN_WIDTH); n++;
531 XtSetArg(args[n], XmNmarginHeight, LB_MARGIN_HEIGHT); n++;
533 XmCreateRadioBox(inputMethodForm, "inputMethodRC", args, n);
536 /* Create widgets inside the imStartModeForm */
538 XtSetArg(args[n], XmNmarginWidth, 0); n++;
539 XtSetArg(args[n], XmNmarginHeight, 0); n++;
541 XmCreateRadioBox(imStartModeForm, "imStartModeRC", args, n);
544 string = CMPSTR((char *)GETMESSAGE(19, 8, "Ask at login"));
545 XtSetArg(args[n], XmNlabelString, string); n++;
547 XmCreateToggleButtonGadget(i18n.imStartModeRC, "askAtLoginTG",
549 XmStringFree(string);
552 string = CMPSTR((char *)GETMESSAGE(19, 9, "Resume Current Input Method"));
553 XtSetArg(args[n], XmNlabelString, string); n++;
554 i18n.resumeCurrentImTG =
555 XmCreateToggleButtonGadget(i18n.imStartModeRC, "resumeCurrentImTG",
557 XmStringFree(string);
559 /* Create widgets inside the preeditTypeForm */
562 XtSetArg(args[n], XmNselectionPolicy, XmBROWSE_SELECT); n++;
563 i18n.preeditTypeList =
564 (Widget) (intptr_t) XmCreateList(preeditTypeForm, "preeditTypeList", args, n);
567 string = CMPSTR((char *)GETMESSAGE(19, 10, "Move Up"));
568 XtSetArg(args[n], XmNlabelString, string); n++;
569 XtSetArg(args[n], XmNsensitive, False); n++;
571 XmCreatePushButtonGadget(preeditTypeForm, "buttonMoveUp", args, n);
572 XmStringFree(string);
575 string = CMPSTR((char *)GETMESSAGE(19, 11, "Move Down"));
576 XtSetArg(args[n], XmNlabelString, string); n++;
577 XtSetArg(args[n], XmNsensitive, False); n++;
578 i18n.buttonMoveDown =
579 XmCreatePushButtonGadget(preeditTypeForm, "buttonMoveDown", args, n);
580 XmStringFree(string);
582 XtAddCallback(style.i18nDialog, XmNmapCallback, FormLayoutCB, NULL);
583 XtAddCallback(style.i18nDialog, XmNmapCallback, MapCB, shell);
584 XtAddCallback(style.i18nDialog, XmNcallback, ButtonCB, NULL);
585 XtAddCallback(i18n.systemDefault, XmNactivateCallback,
586 SystemDefaultCB, NULL);
587 XtAddCallback(i18n.preeditTypeList, XmNbrowseSelectionCallback,
588 ListItemSelectCB, NULL);
589 XtAddCallback(i18n.buttonMoveUp, XmNactivateCallback,
591 XtAddCallback(i18n.buttonMoveDown, XmNactivateCallback,
595 XtManageChildren(widgetList1,count);
597 XtManageChild(inputMethodForm);
598 XtManageChild(imStartModeForm);
599 XtManageChild(preeditTypeForm);
601 XtManageChild(i18n.serverHostLabel);
602 XtManageChild(i18n.serverHostCB);
603 XtManageChild(i18n.inputMethodLabel);
604 XtManageChild(i18n.inputMethodRC);
606 XtManageChild(i18n.imStartModeRC);
607 XtManageChild(i18n.askAtLoginTG);
608 XtManageChild(i18n.resumeCurrentImTG);
610 XtManageChild(i18n.preeditTypeList);
611 XtManageChild(i18n.buttonMoveUp);
612 XtManageChild(i18n.buttonMoveDown);
614 return(style.i18nDialog);
618 /*+++++++++++++++++++++++++++++++++++++++*/
620 /*+++++++++++++++++++++++++++++++++++++++*/
624 XtPointer client_data,
625 XtPointer call_data )
632 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
633 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
634 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
635 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
636 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
637 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
638 XtSetValues (i18n.pictLabel, args, n);
642 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
643 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
644 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
645 XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
646 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
647 XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
648 XtSetValues (i18n.systemDefault, args, n);
650 /* Input Method TitleBox */
652 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
653 XtSetArg(args[n], XmNtopWidget, i18n.pictLabel); n++;
654 XtSetArg(args[n], XmNtopOffset, style.horizontalSpacing); n++;
655 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
656 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
657 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
658 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
659 XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
660 XtSetValues (i18n.inputMethodTB, args, n);
662 /* Input Method widgets */
665 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
666 XtSetArg(args[n], XmNtopOffset, 2*style.verticalSpacing); n++;
667 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
668 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
669 XtSetArg(args[n], XmNleftOffset, 0); n++;
670 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
671 XtSetValues (i18n.serverHostLabel, args, n);
674 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
675 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
676 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
677 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
678 XtSetArg(args[n], XmNleftWidget, i18n.serverHostLabel); n++;
679 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
680 XtSetValues (i18n.serverHostCB, args, n);
683 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
684 XtSetArg(args[n], XmNtopWidget, i18n.serverHostCB); n++;
685 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
686 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
687 XtSetArg(args[n], XmNleftOffset, 0); n++;
688 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
689 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
690 XtSetValues (i18n.inputMethodLabel, args, n);
693 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
694 XtSetArg(args[n], XmNtopWidget, i18n.inputMethodLabel); n++;
695 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
696 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
697 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
698 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
699 XtSetArg(args[n], XmNbottomOffset, style.verticalSpacing); n++;
700 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
701 XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
702 XtSetValues (i18n.inputMethodRC, args, n);
704 /* Input Method Start Mode TitleBox */
706 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
707 XtSetArg(args[n], XmNtopWidget, i18n.inputMethodTB); n++;
708 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
709 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
710 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
711 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
712 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
713 XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
714 XtSetValues (i18n.imStartModeTB, args, n);
716 /* IM Start Mode RC */
718 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
719 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
720 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
721 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
722 XtSetArg(args[n], XmNleftOffset, 0); n++;
723 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
724 XtSetArg(args[n], XmNrightOffset, 0); n++;
725 XtSetValues (i18n.imStartModeRC, args, n);
727 /* Preedit Type TitleBox */
729 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
730 XtSetArg(args[n], XmNtopWidget, i18n.imStartModeTB); n++;
731 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
732 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
733 XtSetArg(args[n], XmNbottomOffset, style.verticalSpacing); n++;
734 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
735 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
736 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
737 XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
738 XtSetValues (i18n.preeditTypeTB, args, n);
740 /* Preedit Type widgets */
742 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
743 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
744 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
745 XtSetArg(args[n], XmNbottomOffset, style.verticalSpacing); n++;
746 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
747 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
748 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
749 XtSetValues (i18n.preeditTypeList, args, n);
752 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
753 XtSetArg(args[n], XmNtopOffset, 2*style.verticalSpacing); n++;
754 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
755 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
756 XtSetArg(args[n], XmNleftWidget, i18n.preeditTypeList); n++;
757 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
758 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
759 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
760 XtSetValues (i18n.buttonMoveUp, args, n);
763 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
764 XtSetArg(args[n], XmNtopWidget, i18n.buttonMoveUp); n++;
765 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
766 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
767 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
768 XtSetArg(args[n], XmNleftWidget, i18n.preeditTypeList); n++;
769 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
770 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
771 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
772 XtSetValues (i18n.buttonMoveDown, args, n);
774 XtRemoveCallback(style.i18nDialog, XmNmapCallback, FormLayoutCB, NULL);
777 /*+++++++++++++++++++++++++++++++++++++++*/
779 /*+++++++++++++++++++++++++++++++++++++++*/
783 XtPointer client_data,
784 XtPointer call_data )
787 static int first_time = 1;
792 DtWsmRemoveWorkspaceFunctions(style.display, XtWindow(XtParent(w)));
794 if (!save.restoreFlag)
795 putDialog ((Widget)client_data, w);
797 XtRemoveCallback(style.i18nDialog, XmNmapCallback, MapCB, NULL);
801 /*+++++++++++++++++++++++++++++++++++++++*/
802 /* ServerHostCB - get the new hostname, */
803 /* query its list of im and update the */
805 /*+++++++++++++++++++++++++++++++++++++++*/
809 XtPointer client_data,
810 XtPointer call_data )
814 _DtTurnOnHourGlass(i18n.inputMethodTB);
815 /* Get the current hostname in the TextField of the ComboBox,
817 XtVaGetValues(XtNameToWidget(i18n.serverHostCB,"Text"),
818 XmNvalue, &hostname, NULL);
820 /* Update the display and query for new IM on this host. */
821 UpdateImList(&i18n_env, hostname);
831 Widget *im_tog = NULL;
834 /* Clean first the existing list */
836 /* destroy toggle in radio box is any */
837 XtVaGetValues(i18n.inputMethodRC, XmNchildren, &im_tog,
838 XmNnumChildren, &n, NULL);
840 XtUnmanageChildren(im_tog, n);
841 for (i=0; i<n; i++) XtDestroyWidget(im_tog[i]);
845 /* Empty what we used to have here */
846 if (env->ims_sel->ims_list_size) {
847 XtFree((char *) env->ims_sel->ims_list);
848 env->ims_sel->ims_list = NULL;
849 env->ims_sel->ims_list_size = 0 ;
852 /* then update the env struct with new ims name and status */
853 ret = _DtI18nGetImList(env, hostname);
854 if (ret != NoError) {
855 _DtTurnOffHourGlass(i18n.inputMethodTB);
856 _DtI18nErrorDialog(ret);
861 /*+++++++++++++++++++++++++++++++++++++++*/
862 /* SystemDefaultCB */
863 /*+++++++++++++++++++++++++++++++++++++++*/
867 XtPointer client_data,
868 XtPointer call_data )
870 static XmStringTable preeditTable = NULL ;
876 /* Set the Server Host to local, that is use the NULL string */
877 XtVaSetValues(XtNameToWidget(i18n.serverHostCB,"Text"),
878 XmNvalue, "local", NULL);
880 UpdateImList(env, "local");
882 /* Set the Input Method Start Mode to Ask at login */
883 XmToggleButtonGadgetSetState(i18n.askAtLoginTG, True, True);
886 /* Set the preeditType list to the default in Motif */
887 preeditTable = (XmStringTable) XtMalloc(NUM_PREEDIT *
889 for ( i = 0; i < NUM_PREEDIT; i ++ )
890 preeditTable[i] = XmStringCreate(defaultPreedit[i],
894 SetPreeditType(env, preeditTable, NUM_PREEDIT);
896 /* Mark that the preeditType list has changed. */
897 i18n.preeditHasChanged = True;
903 /*+++++++++++++++++++++++++++++++++++++++*/
904 /* TextFocusCB - disable the default */
905 /* button in the dialog, so that return */
906 /* in the TextField doesn't activate it. */
907 /*+++++++++++++++++++++++++++++++++++++++*/
911 XtPointer client_data,
912 XtPointer call_data )
914 XtVaGetValues(style.i18nDialog, XmNdefaultButton, &i18n.defaultButton,
916 XtVaSetValues(style.i18nDialog, XmNdefaultButton, NULL, NULL);
922 /*+++++++++++++++++++++++++++++++++++++++*/
923 /* TextLosingFocusCB - enable the */
924 /* default button, so that return key in */
925 /* the dialog activate it. */
926 /*+++++++++++++++++++++++++++++++++++++++*/
930 XtPointer client_data,
931 XtPointer call_data )
933 XtVaSetValues(style.i18nDialog, XmNdefaultButton, i18n.defaultButton,
940 /*+++++++++++++++++++++++++++++++++++++++*/
942 /* callback for PushButtons in DialogBox */
943 /*+++++++++++++++++++++++++++++++++++++++*/
947 XtPointer client_data,
948 XtPointer call_data )
953 DtDialogBoxCallbackStruct *cb = (DtDialogBoxCallbackStruct *) call_data;
957 switch (cb->button_position)
961 ret = SaveSelectedValues(env);
971 /* reset the i18n values from last saved values */
972 ResetLastSavedValues(env);
974 if (i18n.preeditHasChanged) {
975 /* Reset the preeditType value from the saved one. */
976 SetPreeditType(env, i18n.preeditSavedVal, i18n.preeditSavedNum);
978 i18n.preeditHasChanged = False;
983 XtCallCallbacks(style.i18nDialog, XmNhelpCallback, (XtPointer)NULL);
996 char *preeditStr = NULL, *tmpStr;
998 XtArgVal num_preedit = 0;
999 XmStringTable list_preedit;
1000 static char preeditTypeRes[1024];
1002 /* Get the values from the UI and update the FileSel structure */
1003 SetFileSelValues(env);
1005 /* Write these values in the IMS Selection File */
1006 ret = _DtI18nWriteImSelectionFile(env);
1008 /* Save the preeditType resource value if needed */
1009 if (i18n.preeditHasChanged) {
1011 if (style.xrdb.writeXrdbImmediate)
1012 InfoDialog(MSG_IMMEDIATE, style.shell, False);
1014 InfoDialog(MSG_LATER, style.shell, False);
1016 /* generate a string from the list to set the resource */
1017 XtVaGetValues(i18n.preeditTypeList,
1018 XmNitemCount, &num_preedit,
1019 XmNitems, &list_preedit, NULL);
1021 /* Save this value in case of a Cancel */
1022 if (i18n.preeditSavedVal) {
1023 FreeST(i18n.preeditSavedVal, i18n.preeditSavedNum);
1026 i18n.preeditSavedVal = CopyST(list_preedit, num_preedit);
1027 i18n.preeditSavedNum = num_preedit;
1029 for (i = 0; i < num_preedit; i++) {
1030 /* get the text of the XmString */
1031 tmpStr = XmStringUnparse(list_preedit[i], NULL, XmCHARSET_TEXT,
1032 XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
1033 /* realloc mallocs the first time */
1034 preeditStr = XtRealloc(preeditStr,
1035 strlen(preeditStr) + strlen(tmpStr) + 2);
1037 /* insert the comma before the second, third. etc */
1039 strcat(preeditStr, ",");
1040 strcat(preeditStr, tmpStr);
1043 strcpy(preeditStr, tmpStr);
1048 /* if writeXrdbImmediate true write to Xrdb else send to
1051 sprintf(preeditTypeRes, "*preeditType: %s\n", preeditStr);
1055 if(style.xrdb.writeXrdbImmediate)
1056 _DtAddToResource(style.display, preeditTypeRes);
1058 SmNewPreeditSettings(preeditTypeRes);
1060 /* Reset the state of the list. */
1061 i18n.preeditHasChanged = False;
1078 /* The hostname value is stored in the ImsSel structure. */
1079 env->file_sel->hostname = XtNewString(env->ims_sel->host_name);
1081 /* Get the selected IM from the selected Toggle button */
1082 XtVaGetValues(i18n.inputMethodRC, XmNchildren, &im_tog,
1083 XmNnumChildren, &n, NULL);
1085 for (i=0; i<n; i++) {
1086 if (XmToggleButtonGadgetGetState(im_tog[i]) == TRUE) {
1087 XtVaGetValues(im_tog[i], XmNuserData,
1088 &(env->file_sel->im_name),
1095 env->file_sel->im_name = NULL;
1097 /* Get the start mode from the askAtLoginTG state */
1098 if (XmToggleButtonGadgetGetState(i18n.askAtLoginTG) == TRUE)
1099 env->file_sel->start_mode = 0;
1101 env->file_sel->start_mode = 1;
1105 ResetLastSavedValues(
1109 if (env->file_sel->start_mode == -1) return;
1111 /* Reset the TextField of the ComboBox to the last saved hostname. */
1112 XtVaSetValues(XtNameToWidget(i18n.serverHostCB,"Text"),
1113 XmNvalue, env->file_sel->hostname, NULL);
1115 UpdateImList(env, env->file_sel->hostname);
1117 /* Reset the saved start mode */
1122 /************************************************************************
1124 * restore any state information saved with savei18n.
1125 * This is called from restoreSession with the application
1126 * shell and the special xrm database retrieved for restore.
1127 ************************************************************************/
1133 XrmName xrm_name[5];
1134 XrmRepresentation rep_type;
1137 xrm_name [0] = XrmStringToQuark ("i18nDlg");
1140 /* get x position */
1141 xrm_name [1] = XrmStringToQuark ("x");
1142 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
1143 XtSetArg (save.posArgs[save.poscnt], XmNx, atoi((char *)value.addr));
1145 save.restoreFlag = True;
1148 /* get y position */
1149 xrm_name [1] = XrmStringToQuark ("y");
1150 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
1151 XtSetArg (save.posArgs[save.poscnt], XmNy, atoi((char *)value.addr)); save.poscnt++;
1154 xrm_name [1] = XrmStringToQuark ("ismapped");
1155 XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value);
1156 /* Are we supposed to be mapped? */
1157 if (strcmp(value.addr, "True") == 0)
1158 popup_i18nBB(shell);
1161 /************************************************************************
1164 * This routine will write out to the passed file descriptor any state
1165 * information this dialog needs. It is called from saveSessionCB with the
1166 * file already opened.
1167 * All information is saved in xrm format. There is no restriction
1168 * on what can be saved. It doesn't have to be defined or be part of any
1169 * widget or Xt definition. Just name and save it here and recover it in
1170 * restoreBackdrop. The suggested minimum is whether you are mapped, and your
1172 ************************************************************************/
1178 Dimension width, height;
1179 char *bufr = style.tmpBigStr; /* size=[1024], make bigger if needed */
1180 XmVendorShellExtObject vendorExt;
1181 XmWidgetExtData extData;
1183 if (style.i18nDialog != NULL)
1185 if (XtIsManaged(style.i18nDialog))
1186 sprintf(bufr, "*i18nDlg.ismapped: True\n");
1188 sprintf(bufr, "*i18nDlg.ismapped: False\n");
1190 /* Get and write out the geometry info for our Window */
1191 x = XtX(XtParent(style.i18nDialog));
1192 y = XtY(XtParent(style.i18nDialog));
1194 /* Modify x & y to take into account window mgr frames
1195 * This is pretty bogus, but I don't know a better way to do it.
1197 extData = _XmGetWidgetExtData(style.shell, XmSHELL_EXTENSION);
1198 vendorExt = (XmVendorShellExtObject)extData->widget;
1199 x -= vendorExt->vendor.xOffset;
1200 y -= vendorExt->vendor.yOffset;
1202 width = XtWidth(style.i18nDialog);
1203 height = XtHeight(style.i18nDialog);
1205 sprintf(bufr, "%s*i18nDlg.x: %d\n", bufr, x);
1206 sprintf(bufr, "%s*i18nDlg.y: %d\n", bufr, y);
1207 sprintf(bufr, "%s*i18nDlg.width: %d\n", bufr, width);
1208 sprintf(bufr, "%s*i18nDlg.height: %d\n", bufr, height);
1209 if(-1 == write (fd, bufr, strlen(bufr))) {
1210 perror(strerror(errno));
1216 /*+++++++++++++++++++++++++++++++++++++++*/
1217 /* cancelWarnCB - callback for the */
1218 /* cancel button of the warnDialog */
1219 /*+++++++++++++++++++++++++++++++++++++++*/
1224 XtPointer client_data,
1225 XtPointer call_data )
1233 /*+++++++++++++++++++++++++++++++++++++++*/
1234 /* okWarnCB - callback for the */
1235 /* OK button of the warnDialog */
1236 /*+++++++++++++++++++++++++++++++++++++++*/
1241 XtPointer client_data,
1242 XtPointer call_data )
1248 /*+++++++++++++++++++++++++++++++++++++++*/
1249 /* _DtI18nSetSensitiveImTB - set the */
1250 /* sensitivity of the TitleBox. This is */
1251 /* used when changing host, while getting*/
1253 /* Also recreate the toggle list. */
1254 /*+++++++++++++++++++++++++++++++++++++++*/
1257 _DtI18nSetSensitiveImTB(
1259 Boolean sensitivity )
1261 static Boolean first_time = True;
1263 XtSetSensitive(i18n.inputMethodRC, sensitivity);
1266 SetImsToggleList(env);
1267 /* Save the initial values in case of a Cancel */
1269 SetFileSelValues(env);
1287 err_str = GETMESSAGE(19, 30,
1288 "The environment variable HOME is not defined.");
1291 err_str = GETMESSAGE(19, 31,
1292 "The environment variable LANG is not defined.");
1294 case ErrNoCDELocale:
1295 err_str = GETMESSAGE(19, 32,
1296 "This locale is not supported by the desktop.");
1301 err_str = GETMESSAGE(19, 33,
1302 "Cannot create the user Input Method Selection file");
1306 case ErrNoSelectionFile:
1307 err_str = GETMESSAGE(19, 34,
1308 "Cannot find the user Input Method Selection file.");
1310 case ErrSaveSelection:
1311 err_str = GETMESSAGE(19, 35,
1312 "Cannot save the user Input Method Selection file.");
1316 case ErrUnknownHost:
1317 err_str = GETMESSAGE(19, 36, "Unknown host");
1319 case ErrNoDtimsstart:
1320 err_str = GETMESSAGE(19, 37,
1321 "dtimsstart was not found.\nPerhaps the desktop environment\nis not properly installed.");
1323 case ErrRemoteFailed:
1324 err_str = GETMESSAGE(19, 38, "Remote execution failed on\n the selected host.");
1328 err_str = GETMESSAGE(19, 39, "Cannot initialize remote execution");
1331 err_str = GETMESSAGE(19, 40, "Getting the Input Method on the \nselected host is taking too long");
1335 err_str = GETMESSAGE(19, 41, "Unknown error");
1339 ErrDialog(err_str, style.i18nDialog);
1342 /*+++++++++++++++++++++++++++++++++++++++*/
1343 /* ListItemSelectCB - callback for the */
1344 /* selection on an item in the preedit */
1346 /*+++++++++++++++++++++++++++++++++++++++*/
1351 XtPointer client_data,
1352 XtPointer call_data )
1354 XmListCallbackStruct *listCBS = (XmListCallbackStruct *) call_data;
1356 /* Set the sensitivity of the MoveUp and MoveDown buttons depending
1357 on the selected item position. MoveUp is insensitive is the first
1358 item in the list is selected; MoveDown is insensitive if the last
1359 item in the list is selected */
1361 if (listCBS->item_position == 1)
1362 XtSetSensitive(i18n.buttonMoveUp, False);
1364 XtSetSensitive(i18n.buttonMoveUp, True);
1366 if (listCBS->item_position == i18n.preeditTypeListLastPos)
1367 XtSetSensitive(i18n.buttonMoveDown, False);
1369 XtSetSensitive(i18n.buttonMoveDown, True);
1374 /*+++++++++++++++++++++++++++++++++++++++*/
1375 /* MoveUpCB - callback for the */
1377 /*+++++++++++++++++++++++++++++++++++++++*/
1382 XtPointer client_data,
1383 XtPointer call_data )
1388 if (XmListGetSelectedPos(i18n.preeditTypeList, &position_list,
1391 /* there should be only one selected per our selection
1392 policy set on the list, but consider the first selected one
1395 /* this should always be the case as the MoveUp button should be
1396 insensitive when the first item is selected, but check anyway */
1398 if (position_list[0] > 1) {
1399 XmStringTable list_items;
1401 int sel_pos = position_list[0];
1402 int sel_index = sel_pos - 1;
1404 XtVaGetValues(i18n.preeditTypeList, XmNitems, &list_items, NULL);
1406 /* makes an array of two XmStrings by reversing the selected
1407 one and the item preceding it */
1408 items[0] = list_items[sel_index];
1409 items[1] = list_items[sel_index - 1];
1411 /* this call preserves selected state */
1412 XmListReplaceItemsPos(i18n.preeditTypeList,
1417 /* it's now 1, so set the MoveUp button insensitive */
1418 XtSetSensitive(i18n.buttonMoveUp, False);
1421 if (sel_pos == i18n.preeditTypeListLastPos) {
1422 /* it's not anymore the last one, so set the MoveDown
1424 XtSetSensitive(i18n.buttonMoveDown, True);
1427 /* preeditType has changed */
1428 i18n.preeditHasChanged = True;
1433 /*+++++++++++++++++++++++++++++++++++++++*/
1434 /* MoveDownCB - callback for the */
1435 /* MoveDown button */
1436 /*+++++++++++++++++++++++++++++++++++++++*/
1441 XtPointer client_data,
1442 XtPointer call_data )
1447 if (XmListGetSelectedPos(i18n.preeditTypeList, &position_list,
1450 /* there should be only one selected per our selection
1451 policy set on the list, but consider the first selected one
1454 /* this should always be the case as the Move Down button should be
1455 insensitive when the first item is selected, but check anyway */
1457 if (position_list[0] != i18n.preeditTypeListLastPos) {
1458 XmStringTable list_items;
1460 int sel_pos = position_list[0];
1461 int sel_index = sel_pos - 1;
1463 XtVaGetValues(i18n.preeditTypeList, XmNitems, &list_items, NULL);
1465 /* makes an array of two XmStrings by reversing the selected
1466 one and the item succeeding it */
1467 items[0] = list_items[sel_index + 1];
1468 items[1] = list_items[sel_index];
1470 /* this call preserves selected state */
1471 XmListReplaceItemsPos(i18n.preeditTypeList,
1475 if (sel_pos == (i18n.preeditTypeListLastPos - 1)) {
1476 /* it's now the last one, so set the MoveDown button
1478 XtSetSensitive(i18n.buttonMoveDown, False);
1482 /* it's not anymore the first one, so set the MoveUp
1484 XtSetSensitive(i18n.buttonMoveUp, True);
1487 /* preeditType has changed */
1488 i18n.preeditHasChanged = True;
1495 static XmStringTable
1496 CopyST (XmStringTable st, int nst)
1498 XmStringTable lst = (XmStringTable) XtMalloc(sizeof(XmString) * nst);
1501 for (i=0; i < nst ; i++) {
1502 lst[i] = XmStringCopy(st[i]);
1510 FreeST (XmStringTable st, int nst)
1514 for (i=0; i < nst ; i++) {
1515 XmStringFree(st[i]);