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 librararies 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 /*+++++++++++++++++++++++++++++++++++++++*/
49 #include <Xm/MwmUtil.h>
54 #include <Xm/LabelG.h>
55 #include <Xm/PushBG.h>
56 #include <Xm/RowColumn.h>
57 #include <Xm/ToggleBG.h>
58 #include <Xm/SeparatoG.h>
59 #include <Xm/VendorSEP.h>
60 #include <Xm/MessageB.h>
62 #include <Dt/DialogBox.h>
64 #include <Dt/TitleBox.h>
65 #include <Dt/UserMsg.h>
66 #include <Dt/Message.h>
67 #include <Dt/HourGlass.h>
72 #include "SaveRestore.h"
77 /*+++++++++++++++++++++++++++++++++++++++*/
78 /* include extern functions */
79 /*+++++++++++++++++++++++++++++++++++++++*/
83 /*+++++++++++++++++++++++++++++++++++++++*/
85 /*+++++++++++++++++++++++++++++++++++++++*/
87 #define MSG_IMMEDIATE ((char *)GETMESSAGE(19, 20, "The new XmNpreeditType value will take effect\nas applications are restarted."))
88 #define MSG_LATER ((char *)GETMESSAGE(19, 21, "Your selection will take effect\n at your next session."))
90 /*+++++++++++++++++++++++++++++++++++++++*/
91 /* Internal Functions */
92 /*+++++++++++++++++++++++++++++++++++++++*/
94 static int InitI18nValues(Widget shell);
95 static void SetImServerHosts(I18nEnv *env);
96 static void SetImsToggleList(I18nEnv *env);
97 static void SetImsMode(I18nEnv *env);
98 static void SetPreeditType(I18nEnv *env, XmStringTable preeditTable,
101 static Widget BuildI18nDlg(Widget shell);
102 static void FormLayoutCB(Widget w, XtPointer client_data, XtPointer call_data);
103 static void MapCB(Widget w, XtPointer client_data, XtPointer call_data);
104 static void SystemDefaultCB(Widget w, XtPointer client_data,
105 XtPointer call_data);
106 static void ServerHostCB(Widget w, XtPointer client_data, XtPointer call_data);
107 static void UpdateImList(I18nEnv *env, char *hostname);
108 static void TextFocusCB(Widget w, XtPointer client_data, XtPointer call_data);
109 static void TextLosingFocusCB(Widget w, XtPointer client_data,
110 XtPointer call_data);
111 static void ButtonCB(Widget w, XtPointer client_data, XtPointer call_data);
112 static int SaveSelectedValues(I18nEnv *env);
113 static void SetFileSelValues(I18nEnv *env);
114 static void ResetLastSavedValues(I18nEnv *env);
116 static void OkWarnCB(Widget w, XtPointer client_data, XtPointer call_data);
117 static void CancelWarnCB(Widget w, XtPointer client_data, XtPointer call_data);
119 static void ListItemSelectCB(Widget w, XtPointer client_data,
120 XtPointer call_data);
121 static void MoveUpCB(Widget w, XtPointer client_data, XtPointer call_data);
122 static void MoveDownCB(Widget w, XtPointer client_data, XtPointer call_data);
124 static XmStringTable CopyST (XmStringTable st, int nst);
125 static void FreeST (XmStringTable st, int nst);
127 /*+++++++++++++++++++++++++++++++++++++++*/
128 /* Internal Variables */
129 /*+++++++++++++++++++++++++++++++++++++++*/
133 Widget systemDefault;
134 Widget inputMethodTB;
135 Widget serverHostLabel;
137 Widget inputMethodLabel;
138 Widget inputMethodRC;
139 Widget imStartModeTB;
140 Widget imStartModeRC;
142 Widget resumeCurrentImTG;
143 Widget preeditTypeTB;
144 Widget preeditTypeList;
145 int preeditTypeListLastPos;
146 Boolean preeditHasChanged;
147 XmStringTable preeditSavedVal;
150 Widget buttonMoveDown;
152 Widget defaultButton;
157 static saveRestore save = {FALSE, 0, };
159 static char i18nRes[150]="";
161 static char *defaultPreedit[] =
167 #define NUM_PREEDIT 4
169 /*+++++++++++++++++++++++++++++++++++++++*/
171 /*+++++++++++++++++++++++++++++++++++++++*/
179 if (style.i18nDialog == NULL) {
180 _DtTurnOnHourGlass(shell);
182 ret = InitI18nValues(shell);
183 XtManageChild(style.i18nDialog);
185 _DtI18nErrorDialog(ret) ;
186 _DtTurnOffHourGlass(shell);
190 XtManageChild(style.i18nDialog);
191 raiseWindow(XtWindow(XtParent(style.i18nDialog)));
195 /*+++++++++++++++++++++++++++++++++++++++*/
197 /*+++++++++++++++++++++++++++++++++++++++*/
200 InitI18nValues(Widget shell)
205 XmString *str = style.xrdb.preeditType;
211 /* Get all the needed values from the environment. */
212 if ((ret = _DtI18nGetEnvValues(env)) == NoError) {
213 /* Update the display with the values */
214 SetImServerHosts(env);
218 /* Get the preeditType resource value */
219 while (str[num_preedit]) num_preedit++;
221 SetPreeditType(env, style.xrdb.preeditType, num_preedit);
223 i18n.preeditHasChanged = False;
225 /* Save the initial value in case of a reset. */
226 i18n.preeditSavedVal = style.xrdb.preeditType;
227 i18n.preeditSavedNum = num_preedit;
234 SetImServerHosts(I18nEnv *env)
236 Cardinal num_hosts = 0 ;
238 /* Set the TextField of the ComboBox with the value found in
239 the IMS selection file */
240 XtVaSetValues(XtNameToWidget(i18n.serverHostCB,"Text"),
241 XmNvalue, env->file_sel->hostname, NULL);
243 /* update ComboBox with list of server hostnames found in
244 "imServerHosts" resource */
246 if (style.xrdb.imServerHosts)
247 while (style.xrdb.imServerHosts[num_hosts]) num_hosts ++ ;
249 /* TBD: need to add file_sel->hostname if not null
250 or localhost, if not already present */
252 XtVaSetValues(i18n.serverHostCB,
253 XmNitemCount, num_hosts,
254 XmNitems, style.xrdb.imServerHosts, NULL);
258 SetImsToggleList(I18nEnv *env)
262 Widget *im_tog = NULL;
264 Boolean found = FALSE;
265 Cardinal default_index = 0;
267 /* create new toggles */
269 if (env->ims_sel->ims_list_size > 0)
270 im_tog = (Widget*)XtMalloc(sizeof(Widget)
271 * env->ims_sel->ims_list_size);
274 for (i=0; i< env->ims_sel->ims_list_size; i++) {
275 string = XmStringCreateLocalized(env->ims_sel->ims_list[i].im_label);
277 XtSetArg(args[n], XmNlabelString, string); n++;
278 XtSetArg(args[n], XmNsensitive,
279 !(env->ims_sel->ims_list[i].inactive)); n++;
280 XtSetArg(args[n], XmNuserData,
281 env->ims_sel->ims_list[i].im_name); n++;
283 /* Need to default to the file_sel->im_name, if in the list */
284 if (strcmp(env->file_sel->im_name,
285 env->ims_sel->ims_list[i].im_name) == 0) {
287 XtSetArg(args[n], XmNset, True); n++;
290 if (env->ims_sel->ims_list[i].im_default) {
294 im_tog[i] = XmCreateToggleButtonGadget(i18n.inputMethodRC,
296 XmStringFree(string);
299 if (env->ims_sel->ims_list_size > 0)
300 XtManageChildren(im_tog, env->ims_sel->ims_list_size);
302 /* If we provided toggle buttons, but the file_sel->im_name was not
303 found, default it to the default from the locale file. */
305 if (im_tog && !found) {
307 XtSetArg(args[n], XmNset, True); n++;
308 XtSetValues(im_tog[default_index], args, n);
312 XtFree((char *) im_tog);
314 _DtTurnOffHourGlass(i18n.inputMethodTB);
318 SetImsMode(I18nEnv *env)
321 /* only called once at startup, or when resetting the saved values */
322 if (env->file_sel->start_mode == 0)
323 XmToggleButtonGadgetSetState(i18n.askAtLoginTG, True, True);
325 XmToggleButtonGadgetSetState(i18n.resumeCurrentImTG, True, True);
331 XmStringTable preeditTable,
334 XmStringTable loc_preeditTable ;
336 loc_preeditTable = CopyST(preeditTable, preeditTableNum);
338 /* initialize List with preeditType values */
339 XtVaSetValues(i18n.preeditTypeList,
340 XmNvisibleItemCount, preeditTableNum,
341 XmNitemCount, preeditTableNum,
342 XmNitems, loc_preeditTable,
343 XmNselectedItemCount, 1,
344 XmNselectedItems, loc_preeditTable, NULL);
346 /* set the last item position - This is the number of items in the list. */
347 i18n.preeditTypeListLastPos = preeditTableNum;
349 /* If more than one item in the list, set the Button MoveDown sentivity to
351 if (preeditTableNum > 1)
352 XtVaSetValues(i18n.buttonMoveDown, XmNsensitive, True, NULL);
354 XtVaSetValues(i18n.buttonMoveUp, XmNsensitive, False, NULL);
358 /*+++++++++++++++++++++++++++++++++++++++*/
360 /*+++++++++++++++++++++++++++++++++++++++*/
367 XmString button_string[NUM_LABELS];
370 Widget inputMethodForm;
371 Widget imStartModeForm;
372 Widget preeditTypeForm;
374 Widget widgetList1[6];
376 /* get i18n resource values */
378 /* Set up DialogBoxDialog button labels */
379 button_string[0] = CMPSTR(_DtOkString);
380 button_string[1] = CMPSTR(_DtCancelString);
381 button_string[2] = CMPSTR(_DtHelpString);
383 /* Create toplevel DialogBox */
385 /* Initialize the i18n structure */
386 i18n.pictLabel = NULL;
387 i18n.systemDefault = NULL;
388 i18n.inputMethodTB = NULL;
389 i18n.serverHostLabel = NULL;
390 i18n.serverHostCB = NULL;
391 i18n.inputMethodLabel = NULL;
392 i18n.inputMethodRC = NULL;
393 i18n.imStartModeTB = NULL;
394 i18n.imStartModeRC = NULL;
395 i18n.askAtLoginTG = NULL;
396 i18n.resumeCurrentImTG = NULL;
397 i18n.preeditTypeTB = NULL;
398 i18n.preeditTypeList = NULL;
399 i18n.buttonMoveUp = NULL;
400 i18n.buttonMoveDown = NULL;
401 i18n.warnDialog = NULL;
404 * Note that save.poscnt has been initialized elsewhere.
405 * save.posArgs may contain information from restoreBeep().*/
407 XtSetArg(save.posArgs[save.poscnt], XmNbuttonCount, NUM_LABELS);
409 XtSetArg(save.posArgs[save.poscnt], XmNbuttonLabelStrings, button_string);
411 XtSetArg(save.posArgs[save.poscnt], XmNdefaultPosition, False);
414 __DtCreateDialogBoxDialog(shell, "i18nDialog", save.posArgs,
416 XtAddCallback(style.i18nDialog, XmNhelpCallback,
417 (XtCallbackProc)HelpRequestCB, (XtPointer)HELP_I18N_DIALOG);
419 XmStringFree(button_string[0]);
420 XmStringFree(button_string[1]);
421 XmStringFree(button_string[2]);
423 widgetList1[0] = _DtDialogBoxGetButton(style.i18nDialog,2);
425 XtSetArg(args[n], XmNautoUnmanage, False); n++;
426 XtSetArg(args[n], XmNcancelButton, widgetList1[0]); n++;
427 XtSetValues (style.i18nDialog, args, n);
430 XtSetArg(args[n], XmNtitle,
431 ((char *)GETMESSAGE(19, 1, "Style Manager - Internationalization")));
433 XtSetArg (args[n], XmNuseAsyncGeometry, True); n++;
434 XtSetArg(args[n], XmNmwmFunctions, DIALOG_MWM_FUNC); n++;
435 XtSetValues (XtParent(style.i18nDialog), args, n);
438 XtSetArg(args[n], XmNallowOverlap, False); n++;
439 XtSetArg(args[n], XmNchildType, XmWORK_AREA); n++;
440 form = XmCreateForm(style.i18nDialog, "i18nForm", args, n);
443 XtSetArg(args[n], XmNfillMode, XmFILL_SELF); n++;
444 XtSetArg(args[n], XmNbehavior, XmICON_LABEL); n++;
445 XtSetArg(args[n], XmNpixmapForeground, style.secBSCol); n++;
446 XtSetArg(args[n], XmNpixmapBackground, style.secTSCol); n++;
447 XtSetArg(args[n], XmNstring, NULL); n++;
448 XtSetArg(args[n], XmNshadowThickness, 0); n++;
449 XtSetArg(args[n], XmNimageName, I18N_ICON); n++;
450 XtSetArg(args[n], XmNtraversalOn, False); n++;
451 widgetList1[count++] = i18n.pictLabel =
452 _DtCreateIcon(form, "i18npictLabel", args, n);
455 XtSetArg(args[n], XmNmarginHeight, LB_MARGIN_HEIGHT); n++;
456 XtSetArg(args[n], XmNmarginWidth, LB_MARGIN_WIDTH); n++;
457 string = CMPSTR(((char *)GETMESSAGE(19, 2, "Default")));
458 XtSetArg(args[n], XmNlabelString, string); n++;
459 widgetList1[count++] = i18n.systemDefault =
460 XmCreatePushButtonGadget(form, "systemDefault", args, n);
461 XmStringFree(string);
464 string = CMPSTR((char *)GETMESSAGE(19, 3, "Input Method"));
465 XtSetArg(args[n], XmNtitleString, string); n++;
466 widgetList1[count++] = i18n.inputMethodTB =
467 _DtCreateTitleBox(form, "inputMethodTB", args, n);
468 XmStringFree(string);
471 XtSetArg(args[n], XmNallowOverlap, False); n++;
472 XtSetArg(args[n], XmNchildType, XmWORK_AREA); n++;
474 XmCreateForm(i18n.inputMethodTB, "inputMethodForm", args, n);
477 string = CMPSTR((char *)GETMESSAGE(19, 4, "Input Method Start Mode"));
478 XtSetArg(args[n], XmNtitleString, string); n++;
479 widgetList1[count++] = i18n.imStartModeTB =
480 _DtCreateTitleBox(form, "imStartModeTB", args, n);
481 XmStringFree(string);
484 XtSetArg(args[n], XmNallowOverlap, False); n++;
485 XtSetArg(args[n], XmNchildType, XmWORK_AREA); n++;
487 XmCreateForm(i18n.imStartModeTB, "imStartModeForm", args, n);
490 string = CMPSTR((char *)GETMESSAGE(19, 5, "Preedit Type"));
491 XtSetArg(args[n], XmNtitleString, string); n++;
492 widgetList1[count++] = i18n.preeditTypeTB =
493 _DtCreateTitleBox(form, "preeditTypeTB", args, n);
494 XmStringFree(string);
497 XtSetArg(args[n], XmNallowOverlap, False); n++;
498 XtSetArg(args[n], XmNchildType, XmWORK_AREA); n++;
500 XmCreateForm(i18n.preeditTypeTB, "preeditTypeForm", args, n);
502 /* Create widgets inside the inputMethodForm */
504 string = CMPSTR((char *)GETMESSAGE(19, 6, "Server Host :"));
505 XtSetArg(args[n], XmNlabelString, string); n++;
506 i18n.serverHostLabel =
507 XmCreateLabelGadget(inputMethodForm, "serverHostLabel", args, n);
510 XtSetArg(args[n], XmNcomboBoxType, XmDROP_DOWN_COMBO_BOX); n++;
512 (Widget) XmCreateComboBox(inputMethodForm, "serverHostCB", args, n);
514 XtAddCallback(XtNameToWidget(i18n.serverHostCB, "Text"),
515 XmNactivateCallback, ServerHostCB, NULL);
516 XtAddCallback(XtNameToWidget(i18n.serverHostCB, "Text"),
517 XmNfocusCallback, TextFocusCB, NULL);
518 XtAddCallback(XtNameToWidget(i18n.serverHostCB, "Text"),
519 XmNlosingFocusCallback, TextLosingFocusCB, NULL);
523 string = CMPSTR((char *)GETMESSAGE(19, 7, "Input Method"));
524 XtSetArg(args[n], XmNlabelString, string); n++;
525 i18n.inputMethodLabel =
526 XmCreateLabelGadget(inputMethodForm, "inputMethodLabel", args, n);
529 XtSetArg(args[n], XmNmarginWidth, LB_MARGIN_WIDTH); n++;
530 XtSetArg(args[n], XmNmarginHeight, LB_MARGIN_HEIGHT); n++;
532 XmCreateRadioBox(inputMethodForm, "inputMethodRC", args, n);
535 /* Create widgets inside the imStartModeForm */
537 XtSetArg(args[n], XmNmarginWidth, 0); n++;
538 XtSetArg(args[n], XmNmarginHeight, 0); n++;
540 XmCreateRadioBox(imStartModeForm, "imStartModeRC", args, n);
543 string = CMPSTR((char *)GETMESSAGE(19, 8, "Ask at login"));
544 XtSetArg(args[n], XmNlabelString, string); n++;
546 XmCreateToggleButtonGadget(i18n.imStartModeRC, "askAtLoginTG",
548 XmStringFree(string);
551 string = CMPSTR((char *)GETMESSAGE(19, 9, "Resume Current Input Method"));
552 XtSetArg(args[n], XmNlabelString, string); n++;
553 i18n.resumeCurrentImTG =
554 XmCreateToggleButtonGadget(i18n.imStartModeRC, "resumeCurrentImTG",
556 XmStringFree(string);
558 /* Create widgets inside the preeditTypeForm */
561 XtSetArg(args[n], XmNselectionPolicy, XmBROWSE_SELECT); n++;
562 i18n.preeditTypeList =
563 (Widget) XmCreateList(preeditTypeForm, "preeditTypeList", args, n);
566 string = CMPSTR((char *)GETMESSAGE(19, 10, "Move Up"));
567 XtSetArg(args[n], XmNlabelString, string); n++;
568 XtSetArg(args[n], XmNsensitive, False); n++;
570 XmCreatePushButtonGadget(preeditTypeForm, "buttonMoveUp", args, n);
571 XmStringFree(string);
574 string = CMPSTR((char *)GETMESSAGE(19, 11, "Move Down"));
575 XtSetArg(args[n], XmNlabelString, string); n++;
576 XtSetArg(args[n], XmNsensitive, False); n++;
577 i18n.buttonMoveDown =
578 XmCreatePushButtonGadget(preeditTypeForm, "buttonMoveDown", args, n);
579 XmStringFree(string);
581 XtAddCallback(style.i18nDialog, XmNmapCallback, FormLayoutCB, NULL);
582 XtAddCallback(style.i18nDialog, XmNmapCallback, MapCB, shell);
583 XtAddCallback(style.i18nDialog, XmNcallback, ButtonCB, NULL);
584 XtAddCallback(i18n.systemDefault, XmNactivateCallback,
585 SystemDefaultCB, NULL);
586 XtAddCallback(i18n.preeditTypeList, XmNbrowseSelectionCallback,
587 ListItemSelectCB, NULL);
588 XtAddCallback(i18n.buttonMoveUp, XmNactivateCallback,
590 XtAddCallback(i18n.buttonMoveDown, XmNactivateCallback,
594 XtManageChildren(widgetList1,count);
596 XtManageChild(inputMethodForm);
597 XtManageChild(imStartModeForm);
598 XtManageChild(preeditTypeForm);
600 XtManageChild(i18n.serverHostLabel);
601 XtManageChild(i18n.serverHostCB);
602 XtManageChild(i18n.inputMethodLabel);
603 XtManageChild(i18n.inputMethodRC);
605 XtManageChild(i18n.imStartModeRC);
606 XtManageChild(i18n.askAtLoginTG);
607 XtManageChild(i18n.resumeCurrentImTG);
609 XtManageChild(i18n.preeditTypeList);
610 XtManageChild(i18n.buttonMoveUp);
611 XtManageChild(i18n.buttonMoveDown);
613 return(style.i18nDialog);
617 /*+++++++++++++++++++++++++++++++++++++++*/
619 /*+++++++++++++++++++++++++++++++++++++++*/
623 XtPointer client_data,
624 XtPointer call_data )
631 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
632 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
633 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
634 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
635 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
636 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
637 XtSetValues (i18n.pictLabel, args, n);
641 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
642 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
643 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
644 XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++;
645 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
646 XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
647 XtSetValues (i18n.systemDefault, args, n);
649 /* Input Method TitleBox */
651 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
652 XtSetArg(args[n], XmNtopWidget, i18n.pictLabel); n++;
653 XtSetArg(args[n], XmNtopOffset, style.horizontalSpacing); n++;
654 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
655 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
656 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
657 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
658 XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
659 XtSetValues (i18n.inputMethodTB, args, n);
661 /* Input Method widgets */
664 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
665 XtSetArg(args[n], XmNtopOffset, 2*style.verticalSpacing); n++;
666 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
667 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
668 XtSetArg(args[n], XmNleftOffset, 0); n++;
669 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
670 XtSetValues (i18n.serverHostLabel, args, n);
673 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
674 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
675 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
676 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
677 XtSetArg(args[n], XmNleftWidget, i18n.serverHostLabel); n++;
678 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
679 XtSetValues (i18n.serverHostCB, args, n);
682 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
683 XtSetArg(args[n], XmNtopWidget, i18n.serverHostCB); n++;
684 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
685 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
686 XtSetArg(args[n], XmNleftOffset, 0); n++;
687 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
688 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
689 XtSetValues (i18n.inputMethodLabel, args, n);
692 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
693 XtSetArg(args[n], XmNtopWidget, i18n.inputMethodLabel); n++;
694 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
695 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
696 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
697 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
698 XtSetArg(args[n], XmNbottomOffset, style.verticalSpacing); n++;
699 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
700 XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
701 XtSetValues (i18n.inputMethodRC, args, n);
703 /* Input Method Start Mode TitleBox */
705 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
706 XtSetArg(args[n], XmNtopWidget, i18n.inputMethodTB); n++;
707 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
708 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
709 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
710 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
711 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
712 XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
713 XtSetValues (i18n.imStartModeTB, args, n);
715 /* IM Start Mode RC */
717 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
718 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
719 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
720 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
721 XtSetArg(args[n], XmNleftOffset, 0); n++;
722 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
723 XtSetArg(args[n], XmNrightOffset, 0); n++;
724 XtSetValues (i18n.imStartModeRC, args, n);
726 /* Preedit Type TitleBox */
728 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
729 XtSetArg(args[n], XmNtopWidget, i18n.imStartModeTB); n++;
730 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
731 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
732 XtSetArg(args[n], XmNbottomOffset, style.verticalSpacing); n++;
733 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
734 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
735 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
736 XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++;
737 XtSetValues (i18n.preeditTypeTB, args, n);
739 /* Preedit Type widgets */
741 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
742 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
743 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
744 XtSetArg(args[n], XmNbottomOffset, style.verticalSpacing); n++;
745 XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++;
746 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
747 XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++;
748 XtSetValues (i18n.preeditTypeList, args, n);
751 XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++;
752 XtSetArg(args[n], XmNtopOffset, 2*style.verticalSpacing); n++;
753 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
754 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
755 XtSetArg(args[n], XmNleftWidget, i18n.preeditTypeList); n++;
756 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
757 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
758 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
759 XtSetValues (i18n.buttonMoveUp, args, n);
762 XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
763 XtSetArg(args[n], XmNtopWidget, i18n.buttonMoveUp); n++;
764 XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++;
765 XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++;
766 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
767 XtSetArg(args[n], XmNleftWidget, i18n.preeditTypeList); n++;
768 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
769 XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++;
770 XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++;
771 XtSetValues (i18n.buttonMoveDown, args, n);
773 XtRemoveCallback(style.i18nDialog, XmNmapCallback, FormLayoutCB, NULL);
776 /*+++++++++++++++++++++++++++++++++++++++*/
778 /*+++++++++++++++++++++++++++++++++++++++*/
782 XtPointer client_data,
783 XtPointer call_data )
786 static int first_time = 1;
791 DtWsmRemoveWorkspaceFunctions(style.display, XtWindow(XtParent(w)));
793 if (!save.restoreFlag)
794 putDialog ((Widget)client_data, w);
796 XtRemoveCallback(style.i18nDialog, XmNmapCallback, MapCB, NULL);
800 /*+++++++++++++++++++++++++++++++++++++++*/
801 /* ServerHostCB - get the new hostname, */
802 /* query its list of im and update the */
804 /*+++++++++++++++++++++++++++++++++++++++*/
808 XtPointer client_data,
809 XtPointer call_data )
813 _DtTurnOnHourGlass(i18n.inputMethodTB);
814 /* Get the current hostname in the TextField of the ComboBox,
816 XtVaGetValues(XtNameToWidget(i18n.serverHostCB,"Text"),
817 XmNvalue, &hostname, NULL);
819 /* Update the display and query for new IM on this host. */
820 UpdateImList(&i18n_env, hostname);
830 Widget *im_tog = NULL;
833 /* Clean first the existing list */
835 /* destroy toggle in radio box is any */
836 XtVaGetValues(i18n.inputMethodRC, XmNchildren, &im_tog,
837 XmNnumChildren, &n, NULL);
839 XtUnmanageChildren(im_tog, n);
840 for (i=0; i<n; i++) XtDestroyWidget(im_tog[i]);
844 /* Empty what we used to have here */
845 if (env->ims_sel->ims_list_size) {
846 XtFree((char *) env->ims_sel->ims_list);
847 env->ims_sel->ims_list = NULL;
848 env->ims_sel->ims_list_size = 0 ;
851 /* then update the env struct with new ims name and status */
852 ret = _DtI18nGetImList(env, hostname);
853 if (ret != NoError) {
854 _DtTurnOffHourGlass(i18n.inputMethodTB);
855 _DtI18nErrorDialog(ret);
860 /*+++++++++++++++++++++++++++++++++++++++*/
861 /* SystemDefaultCB */
862 /*+++++++++++++++++++++++++++++++++++++++*/
866 XtPointer client_data,
867 XtPointer call_data )
869 static XmStringTable preeditTable = NULL ;
875 /* Set the Server Host to local, that is use the NULL string */
876 XtVaSetValues(XtNameToWidget(i18n.serverHostCB,"Text"),
877 XmNvalue, "local", NULL);
879 UpdateImList(env, "local");
881 /* Set the Input Method Start Mode to Ask at login */
882 XmToggleButtonGadgetSetState(i18n.askAtLoginTG, True, True);
885 /* Set the preeditType list to the default in Motif */
886 preeditTable = (XmStringTable) XtMalloc(NUM_PREEDIT *
888 for ( i = 0; i < NUM_PREEDIT; i ++ )
889 preeditTable[i] = XmStringCreate(defaultPreedit[i],
893 SetPreeditType(env, preeditTable, NUM_PREEDIT);
895 /* Mark that the preeditType list has changed. */
896 i18n.preeditHasChanged = True;
902 /*+++++++++++++++++++++++++++++++++++++++*/
903 /* TextFocusCB - disable the default */
904 /* button in the dialog, so that return */
905 /* in the TextField doesn't activate it. */
906 /*+++++++++++++++++++++++++++++++++++++++*/
910 XtPointer client_data,
911 XtPointer call_data )
913 XtVaGetValues(style.i18nDialog, XmNdefaultButton, &i18n.defaultButton,
915 XtVaSetValues(style.i18nDialog, XmNdefaultButton, NULL, NULL);
921 /*+++++++++++++++++++++++++++++++++++++++*/
922 /* TextLosingFocusCB - enable the */
923 /* default button, so that return key in */
924 /* the dialog activate it. */
925 /*+++++++++++++++++++++++++++++++++++++++*/
929 XtPointer client_data,
930 XtPointer call_data )
932 XtVaSetValues(style.i18nDialog, XmNdefaultButton, i18n.defaultButton,
939 /*+++++++++++++++++++++++++++++++++++++++*/
941 /* callback for PushButtons in DialogBox */
942 /*+++++++++++++++++++++++++++++++++++++++*/
946 XtPointer client_data,
947 XtPointer call_data )
952 DtDialogBoxCallbackStruct *cb = (DtDialogBoxCallbackStruct *) call_data;
956 switch (cb->button_position)
960 ret = SaveSelectedValues(env);
970 /* reset the i18n values from last saved values */
971 ResetLastSavedValues(env);
973 if (i18n.preeditHasChanged) {
974 /* Reset the preeditType value from the saved one. */
975 SetPreeditType(env, i18n.preeditSavedVal, i18n.preeditSavedNum);
977 i18n.preeditHasChanged = False;
982 XtCallCallbacks(style.i18nDialog, XmNhelpCallback, (XtPointer)NULL);
995 char *preeditStr = NULL, *tmpStr;
997 XtArgVal num_preedit = 0;
998 XmStringTable list_preedit;
999 static char preeditTypeRes[1024];
1001 /* Get the values from the UI and update the FileSel structure */
1002 SetFileSelValues(env);
1004 /* Write these values in the IMS Selection File */
1005 ret = _DtI18nWriteImSelectionFile(env);
1007 /* Save the preeditType resource value if needed */
1008 if (i18n.preeditHasChanged) {
1010 if (style.xrdb.writeXrdbImmediate)
1011 InfoDialog(MSG_IMMEDIATE, style.shell, False);
1013 InfoDialog(MSG_LATER, style.shell, False);
1015 /* generate a string from the list to set the resource */
1016 XtVaGetValues(i18n.preeditTypeList,
1017 XmNitemCount, &num_preedit,
1018 XmNitems, &list_preedit, NULL);
1020 /* Save this value in case of a Cancel */
1021 if (i18n.preeditSavedVal) {
1022 FreeST(i18n.preeditSavedVal, i18n.preeditSavedNum);
1025 i18n.preeditSavedVal = CopyST(list_preedit, num_preedit);
1026 i18n.preeditSavedNum = num_preedit;
1028 for (i = 0; i < num_preedit; i++) {
1029 /* get the text of the XmString */
1030 tmpStr = XmStringUnparse(list_preedit[i], NULL, XmCHARSET_TEXT,
1031 XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
1032 /* realloc mallocs the first time */
1033 preeditStr = XtRealloc(preeditStr,
1034 strlen(preeditStr) + strlen(tmpStr) + 2);
1036 /* insert the comma before the second, third. etc */
1038 strcat(preeditStr, ",");
1039 strcat(preeditStr, tmpStr);
1042 strcpy(preeditStr, tmpStr);
1047 /* if writeXrdbImmediate true write to Xrdb else send to
1050 sprintf(preeditTypeRes, "*preeditType: %s\n", preeditStr);
1054 if(style.xrdb.writeXrdbImmediate)
1055 _DtAddToResource(style.display, preeditTypeRes);
1057 SmNewPreeditSettings(preeditTypeRes);
1059 /* Reset the state of the list. */
1060 i18n.preeditHasChanged = False;
1077 /* The hostname value is stored in the ImsSel structure. */
1078 env->file_sel->hostname = XtNewString(env->ims_sel->host_name);
1080 /* Get the selected IM from the selected Toggle button */
1081 XtVaGetValues(i18n.inputMethodRC, XmNchildren, &im_tog,
1082 XmNnumChildren, &n, NULL);
1084 for (i=0; i<n; i++) {
1085 if (XmToggleButtonGadgetGetState(im_tog[i]) == TRUE) {
1086 XtVaGetValues(im_tog[i], XmNuserData,
1087 &(env->file_sel->im_name),
1094 env->file_sel->im_name = NULL;
1096 /* Get the start mode from the askAtLoginTG state */
1097 if (XmToggleButtonGadgetGetState(i18n.askAtLoginTG) == TRUE)
1098 env->file_sel->start_mode = 0;
1100 env->file_sel->start_mode = 1;
1104 ResetLastSavedValues(
1108 if (env->file_sel->start_mode == -1) return;
1110 /* Reset the TextField of the ComboBox to the last saved hostname. */
1111 XtVaSetValues(XtNameToWidget(i18n.serverHostCB,"Text"),
1112 XmNvalue, env->file_sel->hostname, NULL);
1114 UpdateImList(env, env->file_sel->hostname);
1116 /* Reset the saved start mode */
1121 /************************************************************************
1123 * restore any state information saved with savei18n.
1124 * This is called from restoreSession with the application
1125 * shell and the special xrm database retrieved for restore.
1126 ************************************************************************/
1132 XrmName xrm_name[5];
1133 XrmRepresentation rep_type;
1136 xrm_name [0] = XrmStringToQuark ("i18nDlg");
1139 /* get x position */
1140 xrm_name [1] = XrmStringToQuark ("x");
1141 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
1142 XtSetArg (save.posArgs[save.poscnt], XmNx, atoi((char *)value.addr));
1144 save.restoreFlag = True;
1147 /* get y position */
1148 xrm_name [1] = XrmStringToQuark ("y");
1149 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
1150 XtSetArg (save.posArgs[save.poscnt], XmNy, atoi((char *)value.addr)); save.poscnt++;
1153 xrm_name [1] = XrmStringToQuark ("ismapped");
1154 XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value);
1155 /* Are we supposed to be mapped? */
1156 if (strcmp(value.addr, "True") == 0)
1157 popup_i18nBB(shell);
1160 /************************************************************************
1163 * This routine will write out to the passed file descriptor any state
1164 * information this dialog needs. It is called from saveSessionCB with the
1165 * file already opened.
1166 * All information is saved in xrm format. There is no restriction
1167 * on what can be saved. It doesn't have to be defined or be part of any
1168 * widget or Xt definition. Just name and save it here and recover it in
1169 * restoreBackdrop. The suggested minimum is whether you are mapped, and your
1171 ************************************************************************/
1177 Dimension width, height;
1178 char *bufr = style.tmpBigStr; /* size=[1024], make bigger if needed */
1179 XmVendorShellExtObject vendorExt;
1180 XmWidgetExtData extData;
1182 if (style.i18nDialog != NULL)
1184 if (XtIsManaged(style.i18nDialog))
1185 sprintf(bufr, "*i18nDlg.ismapped: True\n");
1187 sprintf(bufr, "*i18nDlg.ismapped: False\n");
1189 /* Get and write out the geometry info for our Window */
1190 x = XtX(XtParent(style.i18nDialog));
1191 y = XtY(XtParent(style.i18nDialog));
1193 /* Modify x & y to take into account window mgr frames
1194 * This is pretty bogus, but I don't know a better way to do it.
1196 extData = _XmGetWidgetExtData(style.shell, XmSHELL_EXTENSION);
1197 vendorExt = (XmVendorShellExtObject)extData->widget;
1198 x -= vendorExt->vendor.xOffset;
1199 y -= vendorExt->vendor.yOffset;
1201 width = XtWidth(style.i18nDialog);
1202 height = XtHeight(style.i18nDialog);
1204 sprintf(bufr, "%s*i18nDlg.x: %d\n", bufr, x);
1205 sprintf(bufr, "%s*i18nDlg.y: %d\n", bufr, y);
1206 sprintf(bufr, "%s*i18nDlg.width: %d\n", bufr, width);
1207 sprintf(bufr, "%s*i18nDlg.height: %d\n", bufr, height);
1208 write (fd, bufr, strlen(bufr));
1213 /*+++++++++++++++++++++++++++++++++++++++*/
1214 /* cancelWarnCB - callback for the */
1215 /* cancel button of the warnDialog */
1216 /*+++++++++++++++++++++++++++++++++++++++*/
1221 XtPointer client_data,
1222 XtPointer call_data )
1230 /*+++++++++++++++++++++++++++++++++++++++*/
1231 /* okWarnCB - callback for the */
1232 /* OK button of the warnDialog */
1233 /*+++++++++++++++++++++++++++++++++++++++*/
1238 XtPointer client_data,
1239 XtPointer call_data )
1245 /*+++++++++++++++++++++++++++++++++++++++*/
1246 /* _DtI18nSetSensitiveImTB - set the */
1247 /* sensitivity of the TitleBox. This is */
1248 /* used when changing host, while getting*/
1250 /* Also recreate the toggle list. */
1251 /*+++++++++++++++++++++++++++++++++++++++*/
1254 _DtI18nSetSensitiveImTB(
1256 Boolean sensitivity )
1258 static Boolean first_time = True;
1260 XtSetSensitive(i18n.inputMethodRC, sensitivity);
1263 SetImsToggleList(env);
1264 /* Save the initial values in case of a Cancel */
1266 SetFileSelValues(env);
1284 err_str = GETMESSAGE(19, 30,
1285 "The environment variable HOME is not defined.");
1288 err_str = GETMESSAGE(19, 31,
1289 "The environment variable LANG is not defined.");
1291 case ErrNoCDELocale:
1292 err_str = GETMESSAGE(19, 32,
1293 "This locale is not supported by the desktop.");
1298 err_str = GETMESSAGE(19, 33,
1299 "Cannot create the user Input Method Selection file");
1303 case ErrNoSelectionFile:
1304 err_str = GETMESSAGE(19, 34,
1305 "Cannot find the user Input Method Selection file.");
1307 case ErrSaveSelection:
1308 err_str = GETMESSAGE(19, 35,
1309 "Cannot save the user Input Method Selection file.");
1313 case ErrUnknownHost:
1314 err_str = GETMESSAGE(19, 36, "Unknown host");
1316 case ErrNoDtimsstart:
1317 err_str = GETMESSAGE(19, 37,
1318 "dtimsstart was not found.\nPerhaps the desktop environment\nis not properly installed.");
1320 case ErrRemoteFailed:
1321 err_str = GETMESSAGE(19, 38, "Remote execution failed on\n the selected host.");
1325 err_str = GETMESSAGE(19, 39, "Cannot initialize remote execution");
1328 err_str = GETMESSAGE(19, 40, "Getting the Input Method on the \nselected host is taking too long");
1332 err_str = GETMESSAGE(19, 41, "Unknown error");
1336 ErrDialog(err_str, style.i18nDialog);
1339 /*+++++++++++++++++++++++++++++++++++++++*/
1340 /* ListItemSelectCB - callback for the */
1341 /* selection on an item in the preedit */
1343 /*+++++++++++++++++++++++++++++++++++++++*/
1348 XtPointer client_data,
1349 XtPointer call_data )
1351 XmListCallbackStruct *listCBS = (XmListCallbackStruct *) call_data;
1353 /* Set the sensitivity of the MoveUp and MoveDown buttons depending
1354 on the selected item position. MoveUp is insensitive is the first
1355 item in the list is selected; MoveDown is insensitive if the last
1356 item in the list is selected */
1358 if (listCBS->item_position == 1)
1359 XtSetSensitive(i18n.buttonMoveUp, False);
1361 XtSetSensitive(i18n.buttonMoveUp, True);
1363 if (listCBS->item_position == i18n.preeditTypeListLastPos)
1364 XtSetSensitive(i18n.buttonMoveDown, False);
1366 XtSetSensitive(i18n.buttonMoveDown, True);
1371 /*+++++++++++++++++++++++++++++++++++++++*/
1372 /* MoveUpCB - callback for the */
1374 /*+++++++++++++++++++++++++++++++++++++++*/
1379 XtPointer client_data,
1380 XtPointer call_data )
1385 if (XmListGetSelectedPos(i18n.preeditTypeList, &position_list,
1388 /* there should be only one selected per our selection
1389 policy set on the list, but consider the first selected one
1392 /* this should always be the case as the MoveUp button should be
1393 insensitive when the first item is selected, but check anyway */
1395 if (position_list[0] > 1) {
1396 XmStringTable list_items;
1398 int sel_pos = position_list[0];
1399 int sel_index = sel_pos - 1;
1401 XtVaGetValues(i18n.preeditTypeList, XmNitems, &list_items, NULL);
1403 /* makes an array of two XmStrings by reversing the selected
1404 one and the item preceeding it */
1405 items[0] = list_items[sel_index];
1406 items[1] = list_items[sel_index - 1];
1408 /* this call preserves selected state */
1409 XmListReplaceItemsPos(i18n.preeditTypeList,
1414 /* it's now 1, so set the MoveUp button insensitive */
1415 XtSetSensitive(i18n.buttonMoveUp, False);
1418 if (sel_pos == i18n.preeditTypeListLastPos) {
1419 /* it's not anymore the last one, so set the MoveDown
1421 XtSetSensitive(i18n.buttonMoveDown, True);
1424 /* preeditType has changed */
1425 i18n.preeditHasChanged = True;
1430 /*+++++++++++++++++++++++++++++++++++++++*/
1431 /* MoveDownCB - callback for the */
1432 /* MoveDown button */
1433 /*+++++++++++++++++++++++++++++++++++++++*/
1438 XtPointer client_data,
1439 XtPointer call_data )
1444 if (XmListGetSelectedPos(i18n.preeditTypeList, &position_list,
1447 /* there should be only one selected per our selection
1448 policy set on the list, but consider the first selected one
1451 /* this should always be the case as the Move Down button should be
1452 insensitive when the first item is selected, but check anyway */
1454 if (position_list[0] != i18n.preeditTypeListLastPos) {
1455 XmStringTable list_items;
1457 int sel_pos = position_list[0];
1458 int sel_index = sel_pos - 1;
1460 XtVaGetValues(i18n.preeditTypeList, XmNitems, &list_items, NULL);
1462 /* makes an array of two XmStrings by reversing the selected
1463 one and the item succeeding it */
1464 items[0] = list_items[sel_index + 1];
1465 items[1] = list_items[sel_index];
1467 /* this call preserves selected state */
1468 XmListReplaceItemsPos(i18n.preeditTypeList,
1472 if (sel_pos == (i18n.preeditTypeListLastPos - 1)) {
1473 /* it's now the last one, so set the MoveDown button
1475 XtSetSensitive(i18n.buttonMoveDown, False);
1479 /* it's not anymore the first one, so set the MoveUp
1481 XtSetSensitive(i18n.buttonMoveUp, True);
1484 /* preeditType has changed */
1485 i18n.preeditHasChanged = True;
1492 static XmStringTable
1493 CopyST (XmStringTable st, int nst)
1495 XmStringTable lst = (XmStringTable) XtMalloc(sizeof(XmString) * nst);
1498 for (i=0; i < nst ; i++) {
1499 lst[i] = XmStringCopy(st[i]);
1507 FreeST (XmStringTable st, int nst)
1511 for (i=0; i < nst ; i++) {
1512 XmStringFree(st[i]);