/[antiright]/antiright/src/arshell/dialog.c
ViewVC logotype

Diff of /antiright/src/arshell/dialog.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10 by jefbed, Sat Jul 23 17:10:09 2005 UTC revision 1.11 by jefbed, Sun Jul 31 16:19:50 2005 UTC
# Line 27  Line 27 
27  #endif /* XmVERSION > 1 & XmREVISION > 1  */  #endif /* XmVERSION > 1 & XmREVISION > 1  */
28    
29  void  void
30  arshell_dialog_cb(Widget widget, XtPointer client_data, XtPointer call_data)  arshell_dialog_cb (Widget widget, XtPointer client_data, XtPointer call_data)
31  {  {
32    widget=NULL;    widget = NULL;
33    client_data=NULL;    client_data = NULL;
34    call_data=NULL;    call_data = NULL;
35    exit(0);    exit (0);
36  }  }
37    
38  #if XmVERSION > 1 & XmREVISION > 1  #if XmVERSION > 1 & XmREVISION > 1
39  void  void
40  arshell_font_select_cb(ARCBARG)  arshell_font_select_cb (ARCBARG)
41  {  {
42    Widget font_selector=(Widget)client_data;    Widget font_selector = (Widget) client_data;
43    char* font;    char *font;
44    widget=NULL;    widget = NULL;
45    call_data=NULL;    call_data = NULL;
46    ARCLARG;    ARCLARG;
47    antiright_set(XmNcurrentFont, (XtArgVal)&font);    antiright_set (XmNcurrentFont, (XtArgVal) & font);
48    antiright_get_values(font_selector);    antiright_get_values (font_selector);
49    ARCLARG;    ARCLARG;
50    printf(font);    printf (font);
51    exit(0);    exit (0);
52  }  }
53  #endif /* XmVERSION > 1 & XmREVISION > 1  */  #endif /* XmVERSION > 1 & XmREVISION > 1  */
54  /*#define DEBUG_OLD_MOTIF  /*#define DEBUG_OLD_MOTIF
# Line 64  arshell_font_select_cb(ARCBARG) Line 65  arshell_font_select_cb(ARCBARG)
65  #endif /* HAVE_XLT  */  #endif /* HAVE_XLT  */
66  #endif /* DEBUG_NO_XLT  */  #endif /* DEBUG_NO_XLT  */
67    
68  #if XmVERSION < 2 | XmREVISION < 2  #if XmVERSION < 2 | XmREVISION < 2
69  #ifdef HAVE_XLT  #ifdef HAVE_XLT
70  void  void
71  arshell_font_chooser_ok_cb(ARCBARG)  arshell_font_chooser_ok_cb (ARCBARG)
72  {  {
73    char *font;    char *font;
74    antiright_set(XmNfontName, (XtArgVal)&font);    antiright_set (XmNfontName, (XtArgVal) & font);
75    antiright_get_values(widget);    antiright_get_values (widget);
76    printf(font);    printf (font);
77    exit(0);    exit (0);
78  }  }
79    
80  void  void
81  arshell_font_chooser_cancel_cb(ARCBARG)  arshell_font_chooser_cancel_cb (ARCBARG)
82  {  {
83    exit(0);    exit (0);
84  }  }
85  #endif /* HAVE_XLT  */  #endif /* HAVE_XLT  */
86  #endif /* XmVERSION < 1 & XmREVISION < 1 & HAVE_XLT  */  #endif /* XmVERSION < 1 & XmREVISION < 1 & HAVE_XLT  */
87  void  void
88  arshell_font_dialog()  arshell_font_dialog ()
89  {  {
90  #if XmVERSION > 1 & XmREVISION > 1  #if XmVERSION > 1 & XmREVISION > 1
91    Widget form;    Widget form;
92    Widget font_selector;    Widget font_selector;
93    ARCLARG;    ARCLARG;
94    form=antiright_form(arshell.gui.widgets.mainwindow);    form = antiright_form (arshell.gui.widgets.mainwindow);
95    arshell.gui.widgets.work=form;    arshell.gui.widgets.work = form;
96    antiright_set_title("Font Selector");    antiright_set_title ("Font Selector");
97    ARCLARG;    ARCLARG;
98    antiright_form_positions(0, 90, 0, 100);    antiright_form_positions (0, 90, 0, 100);
99    font_selector=XmCreateFontSelector(form, "font_selector", ARARGS);    font_selector = XmCreateFontSelector (form, "font_selector", ARARGS);
100    XtManageChild(font_selector);    XtManageChild (font_selector);
101    ARCLARG;    ARCLARG;
102    antiright_set(XmNwidth, 500);    antiright_set (XmNwidth, 500);
103    antiright_set(XmNheight, 256);    antiright_set (XmNheight, 256);
104    antiright_set_values(antiright.parent_widget);    antiright_set_values (antiright.parent_widget);
105    ARCLARG;    ARCLARG;
106    XtUnmanageChild(arshell.gui.widgets.row);    XtUnmanageChild (arshell.gui.widgets.row);
107    ARCLARG;    ARCLARG;
108    antiright_form_positions(90, 100, 0, 100);    antiright_form_positions (90, 100, 0, 100);
109    antiright_button(form, "Select", arshell_font_select_cb, font_selector);    antiright_button (form, "Select", arshell_font_select_cb, font_selector);
110    ARCLARG;    ARCLARG;
111  #else  #else
112  #if HAVE_XLT  #if HAVE_XLT
113    Widget font_selector;    Widget font_selector;
114    antiright_set_title("Font Selector");    antiright_set_title ("Font Selector");
115    ARCLARG;    ARCLARG;
116    font_selector=XltCreateFontChooser(arshell.gui.widgets.mainwindow,    font_selector = XltCreateFontChooser (arshell.gui.widgets.mainwindow,
117                                       "font_selector", ARARGS);                                          "font_selector", ARARGS);
118    XtManageChild(font_selector);    XtManageChild (font_selector);
119    XtAddCallback(font_selector, XmNokCallback,    XtAddCallback (font_selector, XmNokCallback,
120                  arshell_font_chooser_ok_cb, NULL);                   arshell_font_chooser_ok_cb, NULL);
121    XtAddCallback(font_selector, XmNcancelCallback,    XtAddCallback (font_selector, XmNcancelCallback,
122                  arshell_font_chooser_cancel_cb, NULL);                   arshell_font_chooser_cancel_cb, NULL);
123    XtAddCallback(font_selector, XmNhelpCallback,    XtAddCallback (font_selector, XmNhelpCallback,
124                  antiright_help_cb, "Use_this_dialog_to_select_a_font.");                   antiright_help_cb, "Use_this_dialog_to_select_a_font.");
125  #else  #else
126    system("arshell -ADp 'Enter a font name:' &");    system ("arshell -ADp 'Enter a font name:' &");
127    exit(0);    exit (0);
128  #endif /* HAVE_XLT  */  #endif /* HAVE_XLT  */
129  #endif /* XmVERSION > 1 & XmREVISION > 1  */  #endif /* XmVERSION > 1 & XmREVISION > 1  */
130    
131  }  }
132    
133  void  void
134  arshell_setup_message_dialog_callbacks(Widget dialog)  arshell_setup_message_dialog_callbacks (Widget dialog)
135  {  {
136    XtAddCallback(dialog, XmNokCallback, arshell_dialog_cb, NULL);    XtAddCallback (dialog, XmNokCallback, arshell_dialog_cb, NULL);
137    XtAddCallback(dialog, XmNhelpCallback, antiright_help_cb,    XtAddCallback (dialog, XmNhelpCallback, antiright_help_cb,
138                  "This_dialog_displays_application_messages.");                   "This_dialog_displays_application_messages.");
139  }  }
140    
141  void  void
142  arshell_message_dialog(int *counter_int, char **argv)  arshell_message_dialog (int *counter_int, char **argv)
143  {  {
144    Widget dialog;    Widget dialog;
145    Widget child;    Widget child;
146    XmString motif_string;    XmString motif_string;
147    (*counter_int)++;    (*counter_int)++;
148    ARCLARG;    ARCLARG;
149    motif_string=XmStringCreateLocalized(argv[(*counter_int)]);    motif_string = XmStringCreateLocalized (argv[(*counter_int)]);
150    antiright_set(XmNmessageString, (XtArgVal)motif_string);    antiright_set (XmNmessageString, (XtArgVal) motif_string);
151    dialog=XmCreateMessageBox(arshell.gui.widgets.row, "dialog",    dialog = XmCreateMessageBox (arshell.gui.widgets.row, "dialog",
152                              antiright.arguments, antiright.arguments_int);                                 antiright.arguments, antiright.arguments_int);
153    child=XmSelectionBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON);    child = XmSelectionBoxGetChild (dialog, XmDIALOG_CANCEL_BUTTON);
154    XtUnmanageChild(child);    XtUnmanageChild (child);
155    arshell_setup_message_dialog_callbacks(dialog);    arshell_setup_message_dialog_callbacks (dialog);
156    XtManageChild(dialog);    XtManageChild (dialog);
157    ARCLARG;    ARCLARG;
158    XmStringFree(motif_string);    XmStringFree (motif_string);
159  }  }
160    
161  void  void
162  arshell_prompt_cb(Widget widget, XtPointer client_data, XtPointer call_data)  arshell_prompt_cb (Widget widget, XtPointer client_data, XtPointer call_data)
163  {  {
164    XmSelectionBoxCallbackStruct *call_pointer=call_data;    XmSelectionBoxCallbackStruct *call_pointer = call_data;
165    char *value;    char *value;
166    client_data=NULL;    client_data = NULL;
167    widget=NULL;    widget = NULL;
168    value=antiright_c_string(call_pointer->value);    value = antiright_c_string (call_pointer->value);
169    puts(value);    puts (value);
170    XtFree(value);    XtFree (value);
171    exit(0);    exit (0);
172  }  }
173    
174  void  void
175  arshell_setup_prompt_dialog_callbacks(Widget dialog)  arshell_setup_prompt_dialog_callbacks (Widget dialog)
176  {  {
177    XtAddCallback(dialog, XmNokCallback, arshell_prompt_cb, NULL);    XtAddCallback (dialog, XmNokCallback, arshell_prompt_cb, NULL);
178    XtAddCallback(dialog, XmNcancelCallback, arshell_dialog_cb, NULL);    XtAddCallback (dialog, XmNcancelCallback, arshell_dialog_cb, NULL);
179    XtAddCallback(dialog, XmNhelpCallback, antiright_help_cb,    XtAddCallback (dialog, XmNhelpCallback, antiright_help_cb,
180                  "This_is_an_application_request_for_user_input.");                   "This_is_an_application_request_for_user_input.");
181  }  }
182    
183  void  void
184  arshell_prompt_remove_buttons(Widget dialog)  arshell_prompt_remove_buttons (Widget dialog)
185  {  {
186    Widget child;    Widget child;
187    
188    child=XmSelectionBoxGetChild(dialog, XmDIALOG_LIST);    child = XmSelectionBoxGetChild (dialog, XmDIALOG_LIST);
189    XtUnmanageChild(child);    XtUnmanageChild (child);
190    child=XmSelectionBoxGetChild(dialog, XmDIALOG_LIST_LABEL);    child = XmSelectionBoxGetChild (dialog, XmDIALOG_LIST_LABEL);
191    XtUnmanageChild(child);    XtUnmanageChild (child);
192  }  }
193    
194  void  void
195  arshell_prompt_dialog(int *counter_int, char **argv)  arshell_prompt_dialog (int *counter_int, char **argv)
196  {  {
197    Widget dialog;    Widget dialog;
198    XmString motif_string;    XmString motif_string;
199    (*counter_int)++;    (*counter_int)++;
200    ARCLARG;    ARCLARG;
201    motif_string=XmStringCreateLocalized(argv[(*counter_int)]);    motif_string = XmStringCreateLocalized (argv[(*counter_int)]);
202    antiright_set(XmNselectionLabelString, (XtArgVal)motif_string);    antiright_set (XmNselectionLabelString, (XtArgVal) motif_string);
203    dialog=XmCreateSelectionBox(arshell.gui.widgets.row, "dialog",    dialog = XmCreateSelectionBox (arshell.gui.widgets.row, "dialog",
204                                antiright.arguments, antiright.arguments_int);                                   antiright.arguments,
205    arshell_prompt_remove_buttons(dialog);                                   antiright.arguments_int);
206    arshell_setup_prompt_dialog_callbacks(dialog);    arshell_prompt_remove_buttons (dialog);
207    XtManageChild(dialog);    arshell_setup_prompt_dialog_callbacks (dialog);
208      XtManageChild (dialog);
209    ARCLARG;    ARCLARG;
210    XmStringFree(motif_string);    XmStringFree (motif_string);
211  }  }
212    
213  void  void
214  arshell_file_select_cb(Widget widget,  arshell_file_select_cb (Widget widget,
215                         XtPointer client_data, XtPointer call_data)                          XtPointer client_data, XtPointer call_data)
216  {  {
217    XmFileSelectionBoxCallbackStruct *call_pointer=call_data;    XmFileSelectionBoxCallbackStruct *call_pointer = call_data;
218    char *value=antiright_c_string(call_pointer->value);    char *value = antiright_c_string (call_pointer->value);
219    puts(value);    puts (value);
220    XtFree(value);    XtFree (value);
221    widget=NULL;    widget = NULL;
222    client_data=NULL;    client_data = NULL;
223    exit(0);    exit (0);
224  }  }
225    
226  void  void
227  arshell_setup_file_selection_dialog_callbacks(Widget dialog)  arshell_setup_file_selection_dialog_callbacks (Widget dialog)
228  {  {
229    XtAddCallback(dialog, XmNokCallback, arshell_file_select_cb, NULL);    XtAddCallback (dialog, XmNokCallback, arshell_file_select_cb, NULL);
230    XtAddCallback(dialog, XmNcancelCallback, arshell_dialog_cb, NULL);    XtAddCallback (dialog, XmNcancelCallback, arshell_dialog_cb, NULL);
231    XtAddCallback(dialog, XmNhelpCallback, antiright_help_cb,    XtAddCallback (dialog, XmNhelpCallback, antiright_help_cb,
232                  "Use_this_dialog_to_select_a_file.");                   "Use_this_dialog_to_select_a_file.");
233  }  }
234    
235  void  void
236  arshell_file_select_dialog()  arshell_file_select_dialog ()
237  {  {
238    Widget dialog;    Widget dialog;
239    ARCLARG;    ARCLARG;
240    dialog=XmCreateFileSelectionBox(arshell.gui.widgets.row, "dialog",    dialog = XmCreateFileSelectionBox (arshell.gui.widgets.row, "dialog",
241                                    antiright.arguments, antiright.arguments_int);                                       antiright.arguments,
242    arshell_setup_file_selection_dialog_callbacks(dialog);                                       antiright.arguments_int);
243    XtManageChild(dialog);    arshell_setup_file_selection_dialog_callbacks (dialog);
244      XtManageChild (dialog);
245    ARCLARG;    ARCLARG;
246  }  }
247    
248  void  void
249  arshell_handle_dialog_arguments(int *counter_int, char **argv)  arshell_handle_dialog_arguments (int *counter_int, char **argv)
250  {  {
251    /* The following add dialogs to the main row as opposed to creating    /* The following add dialogs to the main row as opposed to creating
252       a new shell.  */       a new shell.  */
253    switch(argv[(*counter_int)][3])    switch (argv[(*counter_int)][3])
254      {      {
255      case 'F':      case 'F':
256        arshell_font_dialog();        arshell_font_dialog ();
257        break;        break;
258      case 'f': /* Create a file selection dialog.  */      case 'f':                   /* Create a file selection dialog.  */
259        arshell_file_select_dialog();        arshell_file_select_dialog ();
260        break;        break;
261      case 'm':      case 'm':
262        arshell_message_dialog(counter_int, argv);        arshell_message_dialog (counter_int, argv);
263        break;        break;
264      case 'p': /* Create a prompt dialog.  */      case 'p':                   /* Create a prompt dialog.  */
265        arshell_prompt_dialog(counter_int, argv);        arshell_prompt_dialog (counter_int, argv);
266        break;        break;
267      }      }
268  }  }

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26