From d8d6d65386b7392aba4a67132e531f85cb9df269 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 19 May 2003 18:46:03 +0000 Subject: Compatibility wrapper script from Mike Newman . 2003-05-19 Glynn Foster * src/Makefile.am, src/gdialog: Compatibility wrapper script from Mike Newman . Disabled for the present until I have a chance to review the code. --- src/gdialog | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 src/gdialog (limited to 'src/gdialog') diff --git a/src/gdialog b/src/gdialog new file mode 100644 index 00000000..2eb5b0fa --- /dev/null +++ b/src/gdialog @@ -0,0 +1,156 @@ +#!/usr/bin/perl + +# gdialog -> zenity conversion wrapper +# +# by Mike Newman +# +# This is all, of course, horrible - but it should translate +# most commond gdialog types to zenity equivalents. It will drop +# the pointless and unused (even by gdialog!) size arguments +# but hopefully will pass all the others. +# +# For testing purposes, I've used a couple of the nautilus scripts +# available at http://g-scripts.sourceforge.net - what is sometimes +# unclear is what is a gdialog/zenity translation problem, and what is +# a problem with the script + +my $command = "zenity "; # the command line we build up to execute +my $element = ""; # current bit of command line +my $argn = 0; # counter for walking args +my $args = $#ARGV + 1; # total number of command line arguments + +# this just loads the current arg into $element + +sub get_arg () { + $element = $ARGV[$argn]; +} + +# walk the command line + +ARG: while ($argn < $args) { + + get_arg; + + if ($element eq "--title") { + + # --title argument is almost analogous in gdialog and + # zenity - so pass it almost entirely as is + + $argn++; + get_arg; + $command .= "--title=\"$element\" "; + $argn++; + + # keep processing args + + next ARG; + } + + if ($element eq "--msgbox" || $element eq "--infobox") { + + # This bit is common to almost all of the dialogs + # the arg following the dialog type in gdialog is usually + # equivalent to zenity's --text arg. + + $argn++; + get_arg; + $command .= "--info --text=\"$element\" "; + + # this also happens a lot - gdialog accepted size args + # for dialog compatability - which it pretty much ignored + # and we will do the same + + $argn+=2; + last ARG; + } + + if ($element eq "--yesno") { + + # this will silently ignore the gdialog option to set + # the default button in question dialogs - which is + # highly hig-norant anyway! + + $argn++; + get_arg; + $command .= "--question --text=\"$element\" "; + last ARG; + } + + if ($element eq "--inputbox") { + $argn++; + get_arg; + $command .= "--entry --text=\"$element\" "; + + # ignore size elements and maybe there is some + # default text to initialize the entry with? + + $argn+=3; + get_arg; + $command .= "--entry-text=\"$element\" "; + last ARG; + } + + if ($element eq "--textbox") { + $argn++; + get_arg; + $command .= "--text-info "; + + # the arg immediately following the dialog type in + # gdialog is the filename, so pass this to zenity + + $argn++; + get_arg; + $command .= "--filename=\"$element\" "; + last ARG; + } + + if ($element eq "--checklist" || $element eq "--radiolist") { + $list=$element; + $argn++; + get_arg; + + # Conveniently, zenity and gdialog use the same names + # for list types, so pass this to zenity intact along with + # an untitled column for the check or radio buttons + + $command .= "--list $list --column='' --column $element "; + + # Skip to the first 'name' arg of the list content + + $argn += 6; + + # Loop over the remainder of the commandline + # discarding the 'status' and 'tag' args of each item + # and using the 'name' for display in our second column + + while ($argn < $args) { + get_arg; + $command .= "$element "; + $argn += 3; + } + last ARG; + } + + if ($element eq "--gauge") { + $argn++; + get_arg; + $command .= "--progress --text=\"$element\" "; + + # discard the size args as usually, and see if + # a percentage value was supplied to initialize the + # dialog + + $argn += 3; + get_arg; + if ($element) { + $command .= "--percentage=$element "; + } + last ARG; + } + + $argn++; +} + +# execute the constructed zenity command line + +system($command); -- cgit From 0664c941978b167c44441758de7ee383fca6251b Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Tue, 20 May 2003 23:48:12 +0000 Subject: Update to gdialog wrapper script --- src/gdialog | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) (limited to 'src/gdialog') diff --git a/src/gdialog b/src/gdialog index 2eb5b0fa..14e7bed2 100644 --- a/src/gdialog +++ b/src/gdialog @@ -112,25 +112,59 @@ ARG: while ($argn < $args) { # Conveniently, zenity and gdialog use the same names # for list types, so pass this to zenity intact along with # an untitled column for the check or radio buttons + # and the 'text' arg as a second column header $command .= "--list $list --column='' --column $element "; - # Skip to the first 'name' arg of the list content + # Skip to the first 'item' arg of the list content + # bypassing height, width and list-height + # from here args run [tag] [item] [status] ... - $argn += 6; + $argn += 5; # Loop over the remainder of the commandline # discarding the 'status' and 'tag' args of each item - # and using the 'name' for display in our second column + # and using the 'item' for display in our second column + # also pass a NULL argument since zenity can't set the status + # of a row like gdialog can while ($argn < $args) { get_arg; - $command .= "$element "; + $command .= "NULL $element "; $argn += 3; } last ARG; } + if ($element eq "--menu") { + $list=$element; + $argn++; + get_arg; + + # a gdialog --menu is just a one column zenity --list + # Use the 'text' arg as a second column header + # FIXME: or should it be the dialog text? + + $command .= "--list --column $element "; + + # Skip to the first 'item' arg of the list content + # bypassing height, width and list-height + # from here args run [tag] [item] ... + + $argn += 5; + + # Loop over the remainder of the commandline + # discarding the 'tag' args of each item + # and using the 'item' for display in our second column + + while ($argn < $args) { + get_arg; + $command .= "$element "; + $argn += 2; + } + last ARG; + } + if ($element eq "--gauge") { $argn++; get_arg; -- cgit From c4bdad5128b2bbf1cb93e36697027aa15e348742 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Fri, 23 May 2003 16:18:26 +0000 Subject: More work on wrapper - fix --textbox to actually load the file --- src/gdialog | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/gdialog') diff --git a/src/gdialog b/src/gdialog index 14e7bed2..63e0e1d4 100644 --- a/src/gdialog +++ b/src/gdialog @@ -91,8 +91,6 @@ ARG: while ($argn < $args) { } if ($element eq "--textbox") { - $argn++; - get_arg; $command .= "--text-info "; # the arg immediately following the dialog type in -- cgit From 1930a4a763d2136ea41fbdb6daa4249853b950d2 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Fri, 23 May 2003 16:57:16 +0000 Subject: Hmm, forgot some other bits - support --separate-output, ensure list rows are returned. --- src/gdialog | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'src/gdialog') diff --git a/src/gdialog b/src/gdialog index 63e0e1d4..649d3f3c 100644 --- a/src/gdialog +++ b/src/gdialog @@ -18,6 +18,7 @@ my $command = "zenity "; # the command line we build up to execute my $element = ""; # current bit of command line my $argn = 0; # counter for walking args my $args = $#ARGV + 1; # total number of command line arguments +my $separator = 0; # set if --separate-output is in use # this just loads the current arg into $element @@ -31,6 +32,10 @@ ARG: while ($argn < $args) { get_arg; + + # Section 1 : Args which gdialog expects BEFORE box options + # --clear, --backtitle have no obvious effect - ignored + if ($element eq "--title") { # --title argument is almost analogous in gdialog and @@ -39,12 +44,23 @@ ARG: while ($argn < $args) { $argn++; get_arg; $command .= "--title=\"$element\" "; - $argn++; # keep processing args - + $argn++; + next ARG; + } + + if ($element eq "--separate-output") { + + # set the flag to pring list output line by line + $separator = 1; + + # keep processing args + $argn++; next ARG; } + + # Section 2 : Box Options and subsequent args if ($element eq "--msgbox" || $element eq "--infobox") { @@ -113,7 +129,12 @@ ARG: while ($argn < $args) { # and the 'text' arg as a second column header $command .= "--list $list --column='' --column $element "; - + + # should output be line by line? + if ($separator) { + $command .= " --separator='\n' "; + } + # Skip to the first 'item' arg of the list content # bypassing height, width and list-height # from here args run [tag] [item] [status] ... @@ -184,5 +205,5 @@ ARG: while ($argn < $args) { } # execute the constructed zenity command line - +$command .= " 2>&1"; system($command); -- cgit From 25d20adbd11319e7224ada5970c1a1b1ba6557df Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Sat, 24 May 2003 09:15:50 +0000 Subject: Fix typo in gdialog wrapper. Sensitize OK button in progress when 100% reached. --- src/gdialog | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/gdialog') diff --git a/src/gdialog b/src/gdialog index 649d3f3c..20322c77 100644 --- a/src/gdialog +++ b/src/gdialog @@ -33,8 +33,8 @@ ARG: while ($argn < $args) { get_arg; - # Section 1 : Args which gdialog expects BEFORE box options - # --clear, --backtitle have no obvious effect - ignored +# Section 1 : Args which gdialog expects BEFORE box options +# --clear, --backtitle have no obvious effect - ignored if ($element eq "--title") { @@ -60,7 +60,7 @@ ARG: while ($argn < $args) { next ARG; } - # Section 2 : Box Options and subsequent args +# Section 2 : Box Options and subsequent args if ($element eq "--msgbox" || $element eq "--infobox") { @@ -144,8 +144,8 @@ ARG: while ($argn < $args) { # Loop over the remainder of the commandline # discarding the 'status' and 'tag' args of each item # and using the 'item' for display in our second column - # also pass a NULL argument since zenity can't set the status - # of a row like gdialog can + # also pass a fake NULL argument since zenity can't set + # the status of a row like gdialog can while ($argn < $args) { get_arg; @@ -162,7 +162,7 @@ ARG: while ($argn < $args) { # a gdialog --menu is just a one column zenity --list # Use the 'text' arg as a second column header - # FIXME: or should it be the dialog text? + # FIXME: or should it be the dialog text, or both? $command .= "--list --column $element "; -- cgit From a7673b42d20f5cbacd61b4dd85408e54aafd135d Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Tue, 27 May 2003 17:56:51 +0000 Subject: Fix an indentation weirdness in calendar.c Take notice of width and height in gdialog wrapper for textbox, because the original gdialog also did. --- src/gdialog | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/gdialog') diff --git a/src/gdialog b/src/gdialog index 20322c77..02ac6a91 100644 --- a/src/gdialog +++ b/src/gdialog @@ -28,6 +28,8 @@ sub get_arg () { # walk the command line +print $args; + ARG: while ($argn < $args) { get_arg; @@ -115,6 +117,18 @@ ARG: while ($argn < $args) { $argn++; get_arg; $command .= "--filename=\"$element\" "; + + # width and height matter for this one, so get them + # and apply the same multipliers as used in gdialog + + $argn++; + get_arg; + $element = $element * 8; + $command .= "--width=\"$element\" "; + $argn++; + get_arg; + $element = $element * 7; + $command .= "--height=\"$element\" "; last ARG; } -- cgit From 15c5b0f48ee2114b5a9f4ad25da258fc34065320 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Tue, 27 May 2003 18:00:56 +0000 Subject: Oops - committed with debugging instrumentation which would confuse scripts! --- src/gdialog | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/gdialog') diff --git a/src/gdialog b/src/gdialog index 02ac6a91..488ee5a0 100644 --- a/src/gdialog +++ b/src/gdialog @@ -5,14 +5,14 @@ # by Mike Newman # # This is all, of course, horrible - but it should translate -# most commond gdialog types to zenity equivalents. It will drop +# most commond gdialog types to zenity equivalents. It will mostly drop # the pointless and unused (even by gdialog!) size arguments -# but hopefully will pass all the others. +# but hopefully will translate all the others. # # For testing purposes, I've used a couple of the nautilus scripts # available at http://g-scripts.sourceforge.net - what is sometimes # unclear is what is a gdialog/zenity translation problem, and what is -# a problem with the script +# a problem with the original script my $command = "zenity "; # the command line we build up to execute my $element = ""; # current bit of command line @@ -28,8 +28,6 @@ sub get_arg () { # walk the command line -print $args; - ARG: while ($argn < $args) { get_arg; -- cgit From 34f3758977b56e72dc07b509d1ed4e215794eee9 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Tue, 27 May 2003 18:05:18 +0000 Subject: Not my day. Fix order of height and width args of textbox in gdialog wrapper. --- src/gdialog | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/gdialog') diff --git a/src/gdialog b/src/gdialog index 488ee5a0..092ab13b 100644 --- a/src/gdialog +++ b/src/gdialog @@ -119,14 +119,14 @@ ARG: while ($argn < $args) { # width and height matter for this one, so get them # and apply the same multipliers as used in gdialog - $argn++; - get_arg; - $element = $element * 8; - $command .= "--width=\"$element\" "; $argn++; get_arg; $element = $element * 7; $command .= "--height=\"$element\" "; + $argn++; + get_arg; + $element = $element * 8; + $command .= "--width=\"$element\" "; last ARG; } -- cgit From beaff4a661f5d1329e1afd4b5e3f980ee703035a Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Tue, 27 May 2003 22:00:43 +0000 Subject: Enable the gdialog wrapper script. --- src/gdialog | 221 ------------------------------------------------------------ 1 file changed, 221 deletions(-) delete mode 100644 src/gdialog (limited to 'src/gdialog') diff --git a/src/gdialog b/src/gdialog deleted file mode 100644 index 092ab13b..00000000 --- a/src/gdialog +++ /dev/null @@ -1,221 +0,0 @@ -#!/usr/bin/perl - -# gdialog -> zenity conversion wrapper -# -# by Mike Newman -# -# This is all, of course, horrible - but it should translate -# most commond gdialog types to zenity equivalents. It will mostly drop -# the pointless and unused (even by gdialog!) size arguments -# but hopefully will translate all the others. -# -# For testing purposes, I've used a couple of the nautilus scripts -# available at http://g-scripts.sourceforge.net - what is sometimes -# unclear is what is a gdialog/zenity translation problem, and what is -# a problem with the original script - -my $command = "zenity "; # the command line we build up to execute -my $element = ""; # current bit of command line -my $argn = 0; # counter for walking args -my $args = $#ARGV + 1; # total number of command line arguments -my $separator = 0; # set if --separate-output is in use - -# this just loads the current arg into $element - -sub get_arg () { - $element = $ARGV[$argn]; -} - -# walk the command line - -ARG: while ($argn < $args) { - - get_arg; - - -# Section 1 : Args which gdialog expects BEFORE box options -# --clear, --backtitle have no obvious effect - ignored - - if ($element eq "--title") { - - # --title argument is almost analogous in gdialog and - # zenity - so pass it almost entirely as is - - $argn++; - get_arg; - $command .= "--title=\"$element\" "; - - # keep processing args - $argn++; - next ARG; - } - - if ($element eq "--separate-output") { - - # set the flag to pring list output line by line - $separator = 1; - - # keep processing args - $argn++; - next ARG; - } - -# Section 2 : Box Options and subsequent args - - if ($element eq "--msgbox" || $element eq "--infobox") { - - # This bit is common to almost all of the dialogs - # the arg following the dialog type in gdialog is usually - # equivalent to zenity's --text arg. - - $argn++; - get_arg; - $command .= "--info --text=\"$element\" "; - - # this also happens a lot - gdialog accepted size args - # for dialog compatability - which it pretty much ignored - # and we will do the same - - $argn+=2; - last ARG; - } - - if ($element eq "--yesno") { - - # this will silently ignore the gdialog option to set - # the default button in question dialogs - which is - # highly hig-norant anyway! - - $argn++; - get_arg; - $command .= "--question --text=\"$element\" "; - last ARG; - } - - if ($element eq "--inputbox") { - $argn++; - get_arg; - $command .= "--entry --text=\"$element\" "; - - # ignore size elements and maybe there is some - # default text to initialize the entry with? - - $argn+=3; - get_arg; - $command .= "--entry-text=\"$element\" "; - last ARG; - } - - if ($element eq "--textbox") { - $command .= "--text-info "; - - # the arg immediately following the dialog type in - # gdialog is the filename, so pass this to zenity - - $argn++; - get_arg; - $command .= "--filename=\"$element\" "; - - # width and height matter for this one, so get them - # and apply the same multipliers as used in gdialog - - $argn++; - get_arg; - $element = $element * 7; - $command .= "--height=\"$element\" "; - $argn++; - get_arg; - $element = $element * 8; - $command .= "--width=\"$element\" "; - last ARG; - } - - if ($element eq "--checklist" || $element eq "--radiolist") { - $list=$element; - $argn++; - get_arg; - - # Conveniently, zenity and gdialog use the same names - # for list types, so pass this to zenity intact along with - # an untitled column for the check or radio buttons - # and the 'text' arg as a second column header - - $command .= "--list $list --column='' --column $element "; - - # should output be line by line? - if ($separator) { - $command .= " --separator='\n' "; - } - - # Skip to the first 'item' arg of the list content - # bypassing height, width and list-height - # from here args run [tag] [item] [status] ... - - $argn += 5; - - # Loop over the remainder of the commandline - # discarding the 'status' and 'tag' args of each item - # and using the 'item' for display in our second column - # also pass a fake NULL argument since zenity can't set - # the status of a row like gdialog can - - while ($argn < $args) { - get_arg; - $command .= "NULL $element "; - $argn += 3; - } - last ARG; - } - - if ($element eq "--menu") { - $list=$element; - $argn++; - get_arg; - - # a gdialog --menu is just a one column zenity --list - # Use the 'text' arg as a second column header - # FIXME: or should it be the dialog text, or both? - - $command .= "--list --column $element "; - - # Skip to the first 'item' arg of the list content - # bypassing height, width and list-height - # from here args run [tag] [item] ... - - $argn += 5; - - # Loop over the remainder of the commandline - # discarding the 'tag' args of each item - # and using the 'item' for display in our second column - - while ($argn < $args) { - get_arg; - $command .= "$element "; - $argn += 2; - } - last ARG; - } - - if ($element eq "--gauge") { - $argn++; - get_arg; - $command .= "--progress --text=\"$element\" "; - - # discard the size args as usually, and see if - # a percentage value was supplied to initialize the - # dialog - - $argn += 3; - get_arg; - if ($element) { - $command .= "--percentage=$element "; - } - last ARG; - } - - $argn++; -} - -# execute the constructed zenity command line -$command .= " 2>&1"; -system($command); -- cgit