Skip to content

Commit

Permalink
swap modes of openpanel
Browse files Browse the repository at this point in the history
This is a tiny revision of pure-data#592

closes pure-data#816
  • Loading branch information
porres committed Dec 10, 2019
1 parent 3c12b76 commit a0560bf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
30 changes: 15 additions & 15 deletions doc/5.reference/openpanel-help.pd
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,18 @@
#X obj 134 520 savepanel;
#X msg 128 170 symbol /tmp;
#X msg 140 199 symbol C:/;
#X obj 235 456 print;
#X obj 235 429 openpanel 1;
#X obj 357 456 print;
#X obj 357 429 openpanel 2;
#X msg 235 401 bang;
#X msg 357 401 bang;
#X text 233 380 directory;
#X text 356 380 multiple files;
#X obj 110 456 print;
#X msg 110 401 bang;
#X obj 110 429 openpanel 0;
#X obj 236 460 print;
#X obj 236 433 openpanel 1;
#X obj 378 460 print;
#X obj 378 433 openpanel 2;
#X msg 236 405 bang;
#X msg 378 405 bang;
#X obj 111 460 print;
#X msg 111 405 bang;
#X obj 111 433 openpanel 0;
#X obj 74 25 openpanel;
#X text 303 528 updated for Pd version 0.51.;
#X text 141 25 - query for files or directories;
#X text 146 25 - query for files or directories;
#X text 47 69 When openpanel gets a "bang" \, a file browser appears
on the screen. By default \, if you select a file \, its name appears
on the outlet.;
Expand All @@ -37,10 +35,12 @@ can make openpanel open the current directory for querying for files.
#X connect 1 0 0 0;
#X connect 2 0 4 0;
#X restore 273 250 pd current-directory;
#X text 88 378 file (default);
#X text 89 381 file (default);
#X text 223 173 Start in a specified directory given as a symbol,
f 31;
#X text 157 141 Starts in default directory;
#X text 232 381 multiple files;
#X text 368 381 directory;
#X connect 0 0 2 0;
#X connect 1 0 0 0;
#X connect 5 0 0 0;
Expand All @@ -49,5 +49,5 @@ f 31;
#X connect 10 0 9 0;
#X connect 11 0 8 0;
#X connect 12 0 10 0;
#X connect 16 0 17 0;
#X connect 17 0 15 0;
#X connect 14 0 15 0;
#X connect 15 0 13 0;
4 changes: 2 additions & 2 deletions src/x_gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ typedef struct _openpanel
{
t_object x_obj;
t_symbol *x_s;
int x_mode; /* 0: file, 1: folder, 2: multiple files */
int x_mode; /* 0: file, 1: multiple files, 2: folder */
} t_openpanel;

static void *openpanel_new(t_floatarg mode)
Expand Down Expand Up @@ -222,7 +222,7 @@ static void openpanel_bang(t_openpanel *x)

static void openpanel_callback(t_openpanel *x, t_symbol *s, int argc, t_atom *argv)
{
if (x->x_mode != 2) /* single file or folder */
if (x->x_mode != 1) /* single file or folder */
{
if (argc == 1 && argv->a_type == A_SYMBOL)
outlet_symbol(x->x_obj.ob_outlet, argv->a_w.w_symbol);
Expand Down
8 changes: 4 additions & 4 deletions tcl/wheredoesthisgo.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ proc pdtk_openpanel {target localdir {mode 0}} {
}
set localdir $::fileopendir
}
# 0: file, 1: directory, 2: multiple files
# 0: file, 1: multiple files, 2: directory
switch $mode {
0 { set result [tk_getOpenFile -initialdir $localdir] }
1 { set result [tk_chooseDirectory -initialdir $localdir] }
2 { set result [tk_getOpenFile -multiple 1 -initialdir $localdir] }
1 { set result [tk_getOpenFile -multiple 1 -initialdir $localdir] }
2 { set result [tk_chooseDirectory -initialdir $localdir] }
default { ::pdwindow::error "bad value for 'mode' argument" }
}
if {$result ne ""} {
if { $mode == 2 } {
if { $mode == 1 } {
# 'result' is a list
set ::fileopendir [file dirname [lindex $result 0]]
set args {}
Expand Down

0 comments on commit a0560bf

Please sign in to comment.