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);
829 Widget *im_tog = NULL;
832 /* Clean first the existing list */
834 /* destroy toggle in radio box is any */
835 XtVaGetValues(i18n.inputMethodRC, XmNchildren, &im_tog,
836 XmNnumChildren, &n, NULL);
838 XtUnmanageChildren(im_tog, n);
839 for (i=0; i<n; i++) XtDestroyWidget(im_tog[i]);
843 /* Empty what we used to have here */
844 if (env->ims_sel->ims_list_size) {
845 XtFree((char *) env->ims_sel->ims_list);
846 env->ims_sel->ims_list = NULL;
847 env->ims_sel->ims_list_size = 0 ;
850 /* then update the env struct with new ims name and status */
851 ret = _DtI18nGetImList(env, hostname);
852 if (ret != NoError) {
853 _DtTurnOffHourGlass(i18n.inputMethodTB);
854 _DtI18nErrorDialog(ret);
859 /*+++++++++++++++++++++++++++++++++++++++*/
860 /* SystemDefaultCB */
861 /*+++++++++++++++++++++++++++++++++++++++*/
865 XtPointer client_data,
866 XtPointer call_data )
868 static XmStringTable preeditTable = NULL ;
874 /* Set the Server Host to local, that is use the NULL string */
875 XtVaSetValues(XtNameToWidget(i18n.serverHostCB,"Text"),
876 XmNvalue, "local", NULL);
878 UpdateImList(env, "local");
880 /* Set the Input Method Start Mode to Ask at login */
881 XmToggleButtonGadgetSetState(i18n.askAtLoginTG, True, True);
884 /* Set the preeditType list to the default in Motif */
885 preeditTable = (XmStringTable) XtMalloc(NUM_PREEDIT *
887 for ( i = 0; i < NUM_PREEDIT; i ++ )
888 preeditTable[i] = XmStringCreate(defaultPreedit[i],
892 SetPreeditType(env, preeditTable, NUM_PREEDIT);
894 /* Mark that the preeditType list has changed. */
895 i18n.preeditHasChanged = True;
901 /*+++++++++++++++++++++++++++++++++++++++*/
902 /* TextFocusCB - disable the default */
903 /* button in the dialog, so that return */
904 /* in the TextField doesn't activate it. */
905 /*+++++++++++++++++++++++++++++++++++++++*/
909 XtPointer client_data,
910 XtPointer call_data )
912 XtVaGetValues(style.i18nDialog, XmNdefaultButton, &i18n.defaultButton,
914 XtVaSetValues(style.i18nDialog, XmNdefaultButton, NULL, NULL);
920 /*+++++++++++++++++++++++++++++++++++++++*/
921 /* TextLosingFocusCB - enable the */
922 /* default button, so that return key in */
923 /* the dialog activate it. */
924 /*+++++++++++++++++++++++++++++++++++++++*/
928 XtPointer client_data,
929 XtPointer call_data )
931 XtVaSetValues(style.i18nDialog, XmNdefaultButton, i18n.defaultButton,
938 /*+++++++++++++++++++++++++++++++++++++++*/
940 /* callback for PushButtons in DialogBox */
941 /*+++++++++++++++++++++++++++++++++++++++*/
945 XtPointer client_data,
946 XtPointer call_data )
951 DtDialogBoxCallbackStruct *cb = (DtDialogBoxCallbackStruct *) call_data;
955 switch (cb->button_position)
959 ret = SaveSelectedValues(env);
969 /* reset the i18n values from last saved values */
970 ResetLastSavedValues(env);
972 if (i18n.preeditHasChanged) {
973 /* Reset the preeditType value from the saved one. */
974 SetPreeditType(env, i18n.preeditSavedVal, i18n.preeditSavedNum);
976 i18n.preeditHasChanged = False;
981 XtCallCallbacks(style.i18nDialog, XmNhelpCallback, (XtPointer)NULL);
994 char *preeditStr = NULL, *tmpStr;
995 int i, num_preedit = 0;
996 XmStringTable list_preedit;
997 static char preeditTypeRes[1024];
999 /* Get the values from the UI and update the FileSel structure */
1000 SetFileSelValues(env);
1002 /* Write these values in the IMS Selection File */
1003 ret = _DtI18nWriteImSelectionFile(env);
1005 /* Save the preeditType resource value if needed */
1006 if (i18n.preeditHasChanged) {
1008 if (style.xrdb.writeXrdbImmediate)
1009 InfoDialog(MSG_IMMEDIATE, style.shell, False);
1011 InfoDialog(MSG_LATER, style.shell, False);
1013 /* generate a string from the list to set the resource */
1014 XtVaGetValues(i18n.preeditTypeList,
1015 XmNitemCount, &num_preedit,
1016 XmNitems, &list_preedit, NULL);
1018 /* Save this value in case of a Cancel */
1019 if (i18n.preeditSavedVal) {
1020 FreeST(i18n.preeditSavedVal, i18n.preeditSavedNum);
1023 i18n.preeditSavedVal = CopyST(list_preedit, num_preedit);
1024 i18n.preeditSavedNum = num_preedit;
1026 for (i = 0; i < num_preedit; i++) {
1027 /* get the text of the XmString */
1028 tmpStr = XmStringUnparse(list_preedit[i], NULL, XmCHARSET_TEXT,
1029 XmCHARSET_TEXT, NULL, 0, XmOUTPUT_ALL);
1030 /* realloc mallocs the first time */
1031 preeditStr = XtRealloc(preeditStr,
1032 strlen(preeditStr) + strlen(tmpStr) + 2);
1034 /* insert the comma before the second, third. etc */
1036 strcat(preeditStr, ",");
1037 strcat(preeditStr, tmpStr);
1040 strcpy(preeditStr, tmpStr);
1045 /* if writeXrdbImmediate true write to Xrdb else send to
1048 sprintf(preeditTypeRes, "*preeditType: %s\n", preeditStr);
1052 if(style.xrdb.writeXrdbImmediate)
1053 _DtAddToResource(style.display, preeditTypeRes);
1055 SmNewPreeditSettings(preeditTypeRes);
1057 /* Reset the state of the list. */
1058 i18n.preeditHasChanged = False;
1074 /* The hostname value is stored in the ImsSel structure. */
1075 env->file_sel->hostname = XtNewString(env->ims_sel->host_name);
1077 /* Get the selected IM from the selected Toggle button */
1078 XtVaGetValues(i18n.inputMethodRC, XmNchildren, &im_tog,
1079 XmNnumChildren, &n, NULL);
1081 for (i=0; i<n; i++) {
1082 if (XmToggleButtonGadgetGetState(im_tog[i]) == TRUE) {
1083 XtVaGetValues(im_tog[i], XmNuserData,
1084 &(env->file_sel->im_name),
1091 env->file_sel->im_name = NULL;
1093 /* Get the start mode from the askAtLoginTG state */
1094 if (XmToggleButtonGadgetGetState(i18n.askAtLoginTG) == TRUE)
1095 env->file_sel->start_mode = 0;
1097 env->file_sel->start_mode = 1;
1101 ResetLastSavedValues(
1105 if (env->file_sel->start_mode == -1) return;
1107 /* Reset the TextField of the ComboBox to the last saved hostname. */
1108 XtVaSetValues(XtNameToWidget(i18n.serverHostCB,"Text"),
1109 XmNvalue, env->file_sel->hostname, NULL);
1111 UpdateImList(env, env->file_sel->hostname);
1113 /* Reset the saved start mode */
1118 /************************************************************************
1120 * restore any state information saved with savei18n.
1121 * This is called from restoreSession with the application
1122 * shell and the special xrm database retrieved for restore.
1123 ************************************************************************/
1129 XrmName xrm_name[5];
1130 XrmRepresentation rep_type;
1133 xrm_name [0] = XrmStringToQuark ("i18nDlg");
1134 xrm_name [2] = NULL;
1136 /* get x position */
1137 xrm_name [1] = XrmStringToQuark ("x");
1138 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
1139 XtSetArg (save.posArgs[save.poscnt], XmNx, atoi((char *)value.addr));
1141 save.restoreFlag = True;
1144 /* get y position */
1145 xrm_name [1] = XrmStringToQuark ("y");
1146 if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)){
1147 XtSetArg (save.posArgs[save.poscnt], XmNy, atoi((char *)value.addr)); save.poscnt++;
1150 xrm_name [1] = XrmStringToQuark ("ismapped");
1151 XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value);
1152 /* Are we supposed to be mapped? */
1153 if (strcmp(value.addr, "True") == 0)
1154 popup_i18nBB(shell);
1157 /************************************************************************
1160 * This routine will write out to the passed file descriptor any state
1161 * information this dialog needs. It is called from saveSessionCB with the
1162 * file already opened.
1163 * All information is saved in xrm format. There is no restriction
1164 * on what can be saved. It doesn't have to be defined or be part of any
1165 * widget or Xt definition. Just name and save it here and recover it in
1166 * restoreBackdrop. The suggested minimum is whether you are mapped, and your
1168 ************************************************************************/
1174 Dimension width, height;
1175 char *bufr = style.tmpBigStr; /* size=[1024], make bigger if needed */
1176 XmVendorShellExtObject vendorExt;
1177 XmWidgetExtData extData;
1179 if (style.i18nDialog != NULL)
1181 if (XtIsManaged(style.i18nDialog))
1182 sprintf(bufr, "*i18nDlg.ismapped: True\n");
1184 sprintf(bufr, "*i18nDlg.ismapped: False\n");
1186 /* Get and write out the geometry info for our Window */
1187 x = XtX(XtParent(style.i18nDialog));
1188 y = XtY(XtParent(style.i18nDialog));
1190 /* Modify x & y to take into account window mgr frames
1191 * This is pretty bogus, but I don't know a better way to do it.
1193 extData = _XmGetWidgetExtData(style.shell, XmSHELL_EXTENSION);
1194 vendorExt = (XmVendorShellExtObject)extData->widget;
1195 x -= vendorExt->vendor.xOffset;
1196 y -= vendorExt->vendor.yOffset;
1198 width = XtWidth(style.i18nDialog);
1199 height = XtHeight(style.i18nDialog);
1201 sprintf(bufr, "%s*i18nDlg.x: %d\n", bufr, x);
1202 sprintf(bufr, "%s*i18nDlg.y: %d\n", bufr, y);
1203 sprintf(bufr, "%s*i18nDlg.width: %d\n", bufr, width);
1204 sprintf(bufr, "%s*i18nDlg.height: %d\n", bufr, height);
1205 write (fd, bufr, strlen(bufr));
1210 /*+++++++++++++++++++++++++++++++++++++++*/
1211 /* cancelWarnCB - callback for the */
1212 /* cancel button of the warnDialog */
1213 /*+++++++++++++++++++++++++++++++++++++++*/
1218 XtPointer client_data,
1219 XtPointer call_data )
1227 /*+++++++++++++++++++++++++++++++++++++++*/
1228 /* okWarnCB - callback for the */
1229 /* OK button of the warnDialog */
1230 /*+++++++++++++++++++++++++++++++++++++++*/
1235 XtPointer client_data,
1236 XtPointer call_data )
1242 /*+++++++++++++++++++++++++++++++++++++++*/
1243 /* _DtI18nSetSensitiveImTB - set the */
1244 /* sensitivity of the TitleBox. This is */
1245 /* used when changing host, while getting*/
1247 /* Also recreate the toggle list. */
1248 /*+++++++++++++++++++++++++++++++++++++++*/
1251 _DtI18nSetSensitiveImTB(
1253 Boolean sensitivity )
1255 static Boolean first_time = True;
1257 XtSetSensitive(i18n.inputMethodRC, sensitivity);
1260 SetImsToggleList(env);
1261 /* Save the initial values in case of a Cancel */
1263 SetFileSelValues(env);
1281 err_str = GETMESSAGE(19, 30,
1282 "The environment variable HOME is not defined.");
1285 err_str = GETMESSAGE(19, 31,
1286 "The environment variable LANG is not defined.");
1288 case ErrNoCDELocale:
1289 err_str = GETMESSAGE(19, 32,
1290 "This locale is not supported by the desktop.");
1295 err_str = GETMESSAGE(19, 33,
1296 "Cannot create the user Input Method Selection file");
1300 case ErrNoSelectionFile:
1301 err_str = GETMESSAGE(19, 34,
1302 "Cannot find the user Input Method Selection file.");
1304 case ErrSaveSelection:
1305 err_str = GETMESSAGE(19, 35,
1306 "Cannot save the user Input Method Selection file.");
1310 case ErrUnknownHost:
1311 err_str = GETMESSAGE(19, 36, "Unknown host");
1313 case ErrNoDtimsstart:
1314 err_str = GETMESSAGE(19, 37,
1315 "dtimsstart was not found.\nPerhaps the desktop environment\nis not properly installed.");
1317 case ErrRemoteFailed:
1318 err_str = GETMESSAGE(19, 38, "Remote execution failed on\n the selected host.");
1322 err_str = GETMESSAGE(19, 39, "Cannot initialize remote execution");
1325 err_str = GETMESSAGE(19, 40, "Getting the Input Method on the \nselected host is taking too long");
1329 err_str = GETMESSAGE(19, 41, "Unknown error");
1333 ErrDialog(err_str, style.i18nDialog);
1336 /*+++++++++++++++++++++++++++++++++++++++*/
1337 /* ListItemSelectCB - callback for the */
1338 /* selection on an item in the preedit */
1340 /*+++++++++++++++++++++++++++++++++++++++*/
1345 XtPointer client_data,
1346 XtPointer call_data )
1348 XmListCallbackStruct *listCBS = (XmListCallbackStruct *) call_data;
1350 /* Set the sensitivity of the MoveUp and MoveDown buttons depending
1351 on the selected item position. MoveUp is insensitive is the first
1352 item in the list is selected; MoveDown is insensitive if the last
1353 item in the list is selected */
1355 if (listCBS->item_position == 1)
1356 XtSetSensitive(i18n.buttonMoveUp, False);
1358 XtSetSensitive(i18n.buttonMoveUp, True);
1360 if (listCBS->item_position == i18n.preeditTypeListLastPos)
1361 XtSetSensitive(i18n.buttonMoveDown, False);
1363 XtSetSensitive(i18n.buttonMoveDown, True);
1368 /*+++++++++++++++++++++++++++++++++++++++*/
1369 /* MoveUpCB - callback for the */
1371 /*+++++++++++++++++++++++++++++++++++++++*/
1376 XtPointer client_data,
1377 XtPointer call_data )
1382 if (XmListGetSelectedPos(i18n.preeditTypeList, &position_list,
1385 /* there should be only one selected per our selection
1386 policy set on the list, but consider the first selected one
1389 /* this should always be the case as the MoveUp button should be
1390 insensitive when the first item is selected, but check anyway */
1392 if (position_list[0] > 1) {
1393 XmStringTable list_items;
1395 int sel_pos = position_list[0];
1396 int sel_index = sel_pos - 1;
1398 XtVaGetValues(i18n.preeditTypeList, XmNitems, &list_items, NULL);
1400 /* makes an array of two XmStrings by reversing the selected
1401 one and the item preceeding it */
1402 items[0] = list_items[sel_index];
1403 items[1] = list_items[sel_index - 1];
1405 /* this call preserves selected state */
1406 XmListReplaceItemsPos(i18n.preeditTypeList,
1411 /* it's now 1, so set the MoveUp button insensitive */
1412 XtSetSensitive(i18n.buttonMoveUp, False);
1415 if (sel_pos == i18n.preeditTypeListLastPos) {
1416 /* it's not anymore the last one, so set the MoveDown
1418 XtSetSensitive(i18n.buttonMoveDown, True);
1421 /* preeditType has changed */
1422 i18n.preeditHasChanged = True;
1427 /*+++++++++++++++++++++++++++++++++++++++*/
1428 /* MoveDownCB - callback for the */
1429 /* MoveDown button */
1430 /*+++++++++++++++++++++++++++++++++++++++*/
1435 XtPointer client_data,
1436 XtPointer call_data )
1441 if (XmListGetSelectedPos(i18n.preeditTypeList, &position_list,
1444 /* there should be only one selected per our selection
1445 policy set on the list, but consider the first selected one
1448 /* this should always be the case as the Move Down button should be
1449 insensitive when the first item is selected, but check anyway */
1451 if (position_list[0] != i18n.preeditTypeListLastPos) {
1452 XmStringTable list_items;
1454 int sel_pos = position_list[0];
1455 int sel_index = sel_pos - 1;
1457 XtVaGetValues(i18n.preeditTypeList, XmNitems, &list_items, NULL);
1459 /* makes an array of two XmStrings by reversing the selected
1460 one and the item succeeding it */
1461 items[0] = list_items[sel_index + 1];
1462 items[1] = list_items[sel_index];
1464 /* this call preserves selected state */
1465 XmListReplaceItemsPos(i18n.preeditTypeList,
1469 if (sel_pos == (i18n.preeditTypeListLastPos - 1)) {
1470 /* it's now the last one, so set the MoveDown button
1472 XtSetSensitive(i18n.buttonMoveDown, False);
1476 /* it's not anymore the first one, so set the MoveUp
1478 XtSetSensitive(i18n.buttonMoveUp, True);
1481 /* preeditType has changed */
1482 i18n.preeditHasChanged = True;
1489 static XmStringTable
1490 CopyST (XmStringTable st, int nst)
1492 XmStringTable lst = (XmStringTable) XtMalloc(sizeof(XmString) * nst);
1495 for (i=0; i < nst ; i++) {
1496 lst[i] = XmStringCopy(st[i]);
1504 FreeST (XmStringTable st, int nst)
1508 for (i=0; i < nst ; i++) {
1509 XmStringFree(st[i]);