-
Notifications
You must be signed in to change notification settings - Fork 0
/
dtlocate
87 lines (71 loc) · 2.59 KB
/
dtlocate
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/dt/bin/dtksh
dosearch()
{
# File or directory name to search
XtGetValues $TEXT0 value:z
CMD="locate"
# Ignore case button is on
if $(XmToggleButtonGetState $BUTTON0); then CMD=$CMD" -i"
fi
# Basename search button is on
if $(XmToggleButtonGetState $BUTTON1); then CMD=$CMD" -b"
fi
# Ignore accents button is on
if $(XmToggleButtonGetState $BUTTON2); then CMD=$CMD" -t"
fi
a=`$CMD $z`
if [[ $? -eq 0 ]]; then
# We test the return value of locate to be sure that at least 1 file was found.
j=0
for i in $a;do
j=$((j+1))
XmListAddItemUnselected $LIST1 $j $i;
done;
else
XmListAddItemUnselected $LIST1 1 "No File !";
fi
# XtUnmanageChild $LABEL0
# XtUnmanageChild $TEXT0
XtUnmanageChild $RW0
XtUnmanageChild $CHECK
XtManageChild $BUTTON3
XtManageChild $BUTTON4
XtManageChild $LIST1
}
newsearch()
{ XmListDeleteAllItems $LIST1
XtUnmanageChild $LIST1
XtUnmanageChild $BUTTON3
XtUnmanageChild $BUTTON4
# XtManageChild $LABEL0
# XtManageChild $TEXT0
XtManageChild $RW0
XtManageChild $CHECK
}
XtInitialize TOPLEVEL text TExt "$0" "$@"
XtCreateManagedWidget FORM form XmForm $TOPLEVEL \
marginHeight:5 \
marginWidth:5
XmCreateRowColumn RW0 $FORM rw0 numColumns:2 orientation:HORIZONTAL packing:PACK_COLUMN topAttachment:ATTACH_FORM leftAttachment:ATTACH_FORM
#XmCreateText TEXT0 $FORM text0
XmCreateLabel LABEL0 $RW0 label0 labelString:"File to search"
XmCreateTextField TEXT0 $RW0 text0 activateCallback:dosearch
XmCreateRowColumn CHECK $FORM check orientation:VERTICAL bottomAttachment:ATTACH_FORM leftAttachment:ATTACH_FORM numColumns:3
XmCreateToggleButton BUTTON0 $CHECK button0 labelString:"Ignore case"
XmCreateToggleButton BUTTON1 $CHECK button1 labelString:"Basename search"
XmCreateToggleButton BUTTON2 $CHECK button2 labelString:"Ignore accents"
XmCreateScrolledList LIST1 $FORM list1 selectionPolicy:SINGLE_SELECT visibleItemCount:10 scrollBarDisplayPolicy:STATIC
XmCreateScrollBar BAR1 $LIST1 bar1
XmCreatePushButton BUTTON3 $FORM button3 labelString:"New Search" activateCallback:newsearch bottomAttachment:ATTACH_FORM leftAttachment:ATTACH_FORM
XmCreatePushButton BUTTON4 $FORM button4 labelString:"Quit" activateCallback:"exit" bottomAttachment:ATTACH_FORM rightAttachment:ATTACH_FORM
XtManageChild $RW0
XtManageChild $LABEL0
XtManageChild $TEXT0
XtManageChild $CHECK
#XtManageChild $LIST1
XtManageChild $BUTTON0
XtManageChild $BUTTON1
XtManageChild $BUTTON2
#XtManageChild $LABEL1
XtRealizeWidget $TOPLEVEL
XtMainLoop