"Fossies" - the Fresh Open Source Software Archive 
Member "namefix.pl/libs/gui/dir_hlist.pm" (30 Jan 2010, 5859 Bytes) of package /linux/privat/old/namefix.pl_4.0.2.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "dir_hlist.pm" see the
Fossies "Dox" file reference documentation.
1 use strict;
2 use warnings;
3
4 #--------------------------------------------------------------------------------------------------------------
5 # clear list
6 #--------------------------------------------------------------------------------------------------------------
7
8 sub hlist_clear
9 {
10 $main::hl_counter = 0;
11 $main::hlist2->delete("all");
12
13 return 1;
14 }
15
16 #--------------------------------------------------------------------------------------------------------------
17 # hlist right click menu
18 #--------------------------------------------------------------------------------------------------------------
19
20 sub show_rc_menu
21 {
22 &plog(3, "sub show_rc_menu ");
23 my ($x, $y) = $main::mw->pointerxy;
24
25 my $s = $main::hlist2->nearest($y - $main::hlist2->rooty);
26 $main::hlist2->selectionClear();
27 $main::hlist2->selectionSet($s);
28 $main::hlist_selection = $s;
29 $main::rc_menu->post($x,$y);
30 }
31
32 sub hide_rc_menu
33 {
34 &plog(3, "sub hide_rc_menu ");
35 my ($l,$m)=@_;
36 $m->unpost();
37 }
38
39 #--------------------------------------------------------------------------------------------------------------
40 # draw list
41 #--------------------------------------------------------------------------------------------------------------
42
43 sub hlist_cd
44 {
45 my $file = shift;
46 my $wd = shift;
47 my $old = $main::dir;
48 my $path = $wd . "/" . "$file";
49
50 &plog(3, "sub hlist_cd: \"$file\"");
51 &plog(4, "sub hlist_cd: \$path = \"$path\"");
52
53 if(-d $path)
54 {
55 $main::dir = $path;
56 if(chdir $main::dir)
57 {
58 $main::dir = cwd();
59 &ls_dir;
60 return;
61 }
62 &plog(4, "sub hlist_cd: couldnt chdir to $main::dir");
63 &plog(4, "sub hlist_cd: setting \$main::dir to old value \"$old\"");
64 $main::dir = $old;
65 }
66 &plog(4, "sub hlist_cd: \$path not a valid directory ignoring");
67 # not a valid path, ignore
68 return;
69 }
70
71 #--------------------------------------------------------------------------------------------------------------
72 # hlist_update
73 #--------------------------------------------------------------------------------------------------------------
74 # called from various subs that need updates, update is delayed n times for speedups.
75
76 sub fn_update_delay
77 {
78 $main::update_delay--;
79 if($main::update_delay == 0 || $main::LISTING == 0)
80 {
81 $main::mw->update();
82 $main::update_delay = $main::delay;
83 }
84 }
85
86 #--------------------------------------------------------------------------------------------------------------
87 # draw list
88 #--------------------------------------------------------------------------------------------------------------
89
90 sub draw_list
91 {
92 &plog(3, "sub draw_list ");
93 my $columns = 4;
94 if($main::id3_mode == 1)
95 {
96 $columns = 18;
97 }
98
99 if($main::hlist2)
100 {
101 $main::hlist2->destroy;
102 }
103
104 our $hlist2 = $main::frm_right2 -> Scrolled
105 (
106 "HList",
107 -scrollbars=>"osoe",
108 -header => 1,
109 -columns=>$columns,
110 -selectbackground => 'Cyan',
111 -browsecmd => sub
112 {
113 # when user clicks on an entry update global variables
114 $main::hlist_selection = shift;
115 ($main::hlist_file, $main::hlist_cwd) = $main::hlist2->info("data", $main::hlist_selection);
116 },
117 -command=> sub
118 {
119 # user has double clicked
120 &hlist_cd($main::hlist_file, $main::hlist_cwd);
121 }
122
123 )
124 ->pack
125 (
126 -side=>'bottom',
127 -expand=>1,
128 -fill=>'both'
129 );
130 $main::hlist2->header('create', 0, -text =>' '); # these 2 columns are the same
131 $main::hlist2->header('create', 1, -text =>'Filename'); # for norm & id3 mode
132
133 if($main::id3_mode == 1)
134 {
135 $main::hlist2->header('create', 2, -text => 'Artist');
136 $main::hlist2->header('create', 3, -text => 'Track');
137 $main::hlist2->header('create', 4, -text => 'Title');
138 $main::hlist2->header('create', 5, -text => 'Album');
139 $main::hlist2->header('create', 6, -text => 'Genre');
140 $main::hlist2->header('create', 7, -text => 'Year');
141 $main::hlist2->header('create', 8, -text => 'Comment');
142
143 $main::hlist2->header('create', 9, -text => '#');
144 $main::hlist2->header('create', 10, -text => 'New Filename');
145 $main::hlist2->header('create', 11, -text => 'New Artist');
146 $main::hlist2->header('create', 12, -text => 'New Track');
147 $main::hlist2->header('create', 13, -text => 'New Title');
148 $main::hlist2->header('create', 14, -text => 'New Album');
149 $main::hlist2->header('create', 15, -text => 'New Genre');
150 $main::hlist2->header('create', 16, -text => 'New Year');
151 $main::hlist2->header('create', 17, -text => 'New Comment');
152 }
153 else
154 {
155 $main::hlist2->header('create', 2, -text => '#');
156 $main::hlist2->header('create', 3, -text => 'New Filename');
157 }
158
159 our $rc_menu = $main::hlist2->Menu(-tearoff=>0);
160 $rc_menu -> command
161 (
162 -label=>"Properties",
163 -underline=> 1,
164 -command=> sub
165 {
166 print "Stub Properties $main::hlist_file, $main::hlist_cwd \n";
167
168 # update file current selected file
169 ($main::hlist_file, $main::hlist_cwd) = $main::hlist2->info("data", $main::hlist_selection);
170 my $ff = $main::hlist_cwd . "/" . $main::hlist_file;
171
172 show_file_prop($ff);
173 }
174 );
175 $rc_menu -> command
176 (
177 -label=>"Manual Rename",
178 -underline=> 1,
179 -command=> sub
180 {
181 &manual_edit($main::hlist_file, $main::hlist_cwd);
182 }
183 );
184 $rc_menu -> command
185 (
186 -label=>"Delete",
187 -underline=> 1,
188 -command=> sub
189 {
190 # update file current selected file
191 ($main::hlist_file, $main::hlist_cwd) = $main::hlist2->info("data", $main::hlist_selection);
192 my $ff = $main::hlist_cwd . "/" . $main::hlist_file;
193 show_del_dialog($ff);
194 }
195 );
196
197
198 $main::hlist2->bind('<Any-ButtonPress-3>', \&show_rc_menu);
199 $main::hlist2->bind('<Any-ButtonPress-1>',[\&hide_rc_menu, $rc_menu]);
200 $main::hlist2->bind('<Any-ButtonPress-2>',[\&hide_rc_menu, $rc_menu]);
201
202 &ls_dir;
203 }
204
205
206
207
208
209
210
211
212
213
214 1;