[Debianjr-commits] r16 - in /packages/trunk/xjig: debian/control debian/menu debian/rules xjig-menu xjig-menu.6

synrg at users.alioth.debian.org synrg at users.alioth.debian.org
Sat Apr 28 11:58:50 UTC 2007


Author: synrg
Date: Sat Apr 28 11:58:50 2007
New Revision: 16

URL: http://svn.debian.org/wsvn/debianjr/?sc=1&rev=16
Log:
Replace xjig-random menu launcher with xjig-menu

Added:
    packages/trunk/xjig/xjig-menu
    packages/trunk/xjig/xjig-menu.6
Modified:
    packages/trunk/xjig/debian/control
    packages/trunk/xjig/debian/menu
    packages/trunk/xjig/debian/rules

Modified: packages/trunk/xjig/debian/control
URL: http://svn.debian.org/wsvn/debianjr/packages/trunk/xjig/debian/control?rev=16&op=diff
==============================================================================
--- packages/trunk/xjig/debian/control (original)
+++ packages/trunk/xjig/debian/control Sat Apr 28 11:58:50 2007
@@ -8,7 +8,7 @@
 
 Package: xjig
 Architecture: any
-Depends: ${shlibs:Depends}
+Depends: ${shlibs:Depends}, zenity | kdebase-bin
 Description: An X11 jigsaw puzzle
  xjig is a puzzle that tries to replicate a jigsaw puzzle on the screen
  as closely as possible. Any GIF, JPEG or PPM image may be loaded and cut

Modified: packages/trunk/xjig/debian/menu
URL: http://svn.debian.org/wsvn/debianjr/packages/trunk/xjig/debian/menu?rev=16&op=diff
==============================================================================
--- packages/trunk/xjig/debian/menu (original)
+++ packages/trunk/xjig/debian/menu Sat Apr 28 11:58:50 2007
@@ -1,1 +1,1 @@
-?package(xjig):needs="x11" section="Games/Puzzles"  title="Xjig" command="/usr/games/xjig-random"
+?package(xjig):needs="x11" section="Games/Puzzles"  title="Xjig" command="/usr/games/xjig-menu"

Modified: packages/trunk/xjig/debian/rules
URL: http://svn.debian.org/wsvn/debianjr/packages/trunk/xjig/debian/rules?rev=16&op=diff
==============================================================================
--- packages/trunk/xjig/debian/rules (original)
+++ packages/trunk/xjig/debian/rules Sat Apr 28 11:58:50 2007
@@ -64,10 +64,11 @@
 	cp debian/copyright debian/tmp/usr/share/doc/xjig
 	cp xjig.6 debian/tmp/usr/share/man/man6
 	cp xjig-random.man debian/tmp/usr/share/man/man6/xjig-random.6
+	cp xjig-menu.6 debian/tmp/usr/share/man/man6/xjig-menu.6
 	gzip -9v debian/tmp/usr/share/man/man6/*
 	mkdir -p debian/tmp/usr/games
-	chmod a+rx xjig-random
-	cp xjig-random debian/tmp/usr/games
+	chmod a+rx xjig-random xjig-menu
+	cp xjig-random xjig-menu debian/tmp/usr/games
 	$(INSTALL) debian/tmp/usr/bin/xjig debian/tmp/usr/games/.
 	rm -rf debian/tmp/usr/bin
 	install -m 755 debian/prerm debian/postinst debian/postrm debian/tmp/DEBIAN

Added: packages/trunk/xjig/xjig-menu
URL: http://svn.debian.org/wsvn/debianjr/packages/trunk/xjig/xjig-menu?rev=16&op=file
==============================================================================
--- packages/trunk/xjig/xjig-menu (added)
+++ packages/trunk/xjig/xjig-menu Sat Apr 28 11:58:50 2007
@@ -1,0 +1,415 @@
+#!/bin/bash
+
+# xjig-menu(6) - front-end to launch xjig
+# Copyright (C) 2007 Ben Armstrong <synrg at sanctuary.nslug.ns.ca> 
+
+PROGRAM="`basename ${0}`"
+DESCRIPTION="front-end to launch xjig"
+VERSION="1.3"
+COPYRIGHT="${PROGRAM}, version ${VERSION}
+
+Copyright (C) 2007 Ben Armstrong <synrg at sanctuary.nslug.ns.ca>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+On Debian systems, the complete text of the GNU General Public License
+can be found in /usr/share/common-licenses/GPL file."
+
+USAGE="${PROGRAM} [COMMON-OPTIONS] [FILENAME]
+  ${PROGRAM} -m|--make [--desktop-directory DIR] [COMMON-OPTIONS] [FILENAME]"
+
+HELP="\
+COMMON-OPTIONS
+-p|--pieces XxY          number of pieces to make on the X and Y axes
+-s|--scale XxY           scaled image X and Y axis size (default: 640x480)
+-d|--directory DIR       directory to search for image files
+--dialog DIALOG          kind of dialog box to use
+--switches SWITCHES      switches to pass to xjig (default: -no_flip -side 2)
+
+MAKE-OPTIONS
+--make                   make a link to the specified puzzle in the desktop directory and exit
+--desktop-directory DIR  directory where desktop link will be made (default: \$HOME/Desktop)
+
+DIALOG                   auto, kdialog, zenity or none (default: auto)
+
+FILENAME                 gif, jpeg or ppm image, or any image type imagemagick can convert
+
+Examples:
+   To make a 5x4 (20 piece) puzzle from scene.jpg
+
+      $ $PROGRAM --pieces 5x4 scene.jpg
+
+   To make an 10x5 (50 piece) puzzle, selecting a file from
+   the ~/backgrounds directory 
+
+      $ $PROGRAM --directory ~/backgrounds --pieces 10x5
+
+   To make a desktop link for a puzzle
+
+      $ $PROGRAM --pieces 5x4 scene.jpg --make"
+
+Version ()
+{
+   echo "$COPYRIGHT"
+   exit 0
+}
+
+Do_Usage ()
+{
+   echo "${PROGRAM} - ${DESCRIPTION}"
+   echo
+   echo "Usage:"
+   echo
+
+   if [ -n "${USAGE}" ]
+   then
+      echo "  ${USAGE}"
+      echo
+   fi
+
+   echo "  ${PROGRAM} [-h|--help]"
+   echo "  ${PROGRAM} [-u|--usage]"
+   echo "  ${PROGRAM} [-v|--version]"
+   echo
+}
+
+Usage ()
+{
+   Do_Usage;
+   echo
+   echo "Try \"${PROGRAM} --help\" for more information."
+
+   exit 1
+}
+
+Help ()
+{
+   Do_Usage;
+
+   if [ -n "${HELP}" ]
+   then
+      echo "${HELP}"
+      echo
+   fi
+
+   exit 0
+}
+
+Defaults ()
+{
+   if [ -z "$pieces" ] ; then pieces="${XJIG_PIECES}"; fi
+   if [ -z "$directory" ] ; then directory="${XJIG_DIRECTORY}"; fi
+   if [ -z "$directory" ] ; then directory="${HOME}"; fi
+   if [ -z "$scale" ] ; then scale="${XJIG_SCALE}"; fi
+   # FIXME: default scale as 80% of display size (use xwininfo -root?)
+   if [ -z "$scale" ] ; then scale="640x480"; fi
+   if [ -z "$desktop_directory" ] ; then desktop_directory="${XJIG_DESKTOP_DIRECTORY}"; fi
+   if [ -z "$desktop_directory" ] ; then desktop_directory="${HOME}/Desktop"; fi
+   if [ -z "$switches" ] ; then switches="${XJIG_SWITCHES}"; fi
+   if [ -z "$switches" ] ; then switches="-no_flip -side 2"; fi
+   if [ -z "$dialog" ] ; then dialog="${XJIG_DIALOG}"; fi
+   if [ -z "$dialog" ] ; then dialog="auto"; fi
+}
+
+Cleanup ()
+{
+   rm -f "$tmperr" "$tmpout"
+}
+
+Zenity ()
+{
+   case ${1} in
+      error)
+         dialog_answer="$(zenity --error --text="${2}")"
+         ;;
+      text)
+         dialog_answer="$(zenity --entry --title="${2}" --text="${3}")"
+         ;;
+      file)
+         dialog_answer="$(cd "$directory" && zenity  --title="${2}" --file-selection)"
+         ;;
+   esac
+}
+
+Kdialog ()
+{
+   case ${1} in
+      error)
+         dialog_answer="$(kdialog --error "${2}")"
+         ;;
+      text)
+         dialog_answer="$(kdialog --title "${2}" --inputbox "${3}" "")"
+         ;;
+      file)
+         dialog_answer="$(kdialog --title "${2}" --getopenfilename "$directory")"
+         ;;
+   esac
+}
+
+Nodialog ()
+{
+   case ${1} in
+      error)
+         echo "${2}" >&2
+         ;;
+      text)
+         Error "${PROGRAM}: No value specified: ${2}"
+         ;;
+      file)
+         Error "${PROGRAM}: No value specified: ${2}"
+         ;;
+   esac
+}
+
+SetupDialog ()
+{
+   if [ "$dialog" = "kdialog" ] ; then 
+      if [ -x "/usr/bin/kcheckrunning" ] ; then
+         krunning="$(kcheckrunning 2>&1)"
+      else
+         krunning="$(dcopserver --serverid 2>&1)"
+      fi
+      if [ -z "$krunning" ] ; then
+         kdeinit --suicide &>/dev/null
+         export kde_initialized=1
+      fi
+   fi
+}
+
+Dialog ()
+{
+   case $dialog in
+      zenity)
+         Zenity "${1}" "${2}" "${3}"
+         ;;
+      kdialog)
+         Kdialog "${1}" "${2}" "${3}"
+         ;;
+      none)
+         Nodialog "${1}" "${2}" "${3}"
+         ;;
+   esac
+}
+
+Error ()
+{
+   if [ -n "${1}" ] ; then
+      Dialog error "${1}"
+   else
+      if [ -x /usr/bin/zenity ]; then
+         Dialog error "$(cat $tmperr)"
+      else
+         cat "$tmperr" >&2
+      fi
+      rm -f "$tmperr"
+   fi
+   Cleanup
+   exit 1
+}
+
+CheckError ()
+{
+   if [ ${1} -ne 0 ] ; then
+      Error "${2}"
+   else
+      rm -f "$tmperr"
+   fi
+}
+
+Arguments ()
+{
+   ARGUMENTS="`getopt --longoptions pieces:,directory:,scale:,dialog:,switches:,make,desktop_directory:,help,usage,version --name=${PROGRAM} --options p:d:s:mhuv --shell sh -- "${@}"`" 
+   if [ "${?}" != "0" ]
+   then
+      Error "${PROGRAM}: getopt error" >&2
+      exit 1
+   fi
+
+   eval set -- "${ARGUMENTS}"
+
+   while true
+   do
+      case "${1}" in
+         -p|--pieces)
+            pieces="${2}" ; shift 2
+            ;;
+
+         -d|--directory)
+            directory="${2}" ; shift 2
+            ;;
+
+         -s|--scale)
+            scale="${2}" ; shift 2
+            ;;
+
+         --dialog)
+            dialog="${2}" ; shift 2
+            ;;
+
+         --switches)
+            switches="${2}" ; shift 2
+            ;;
+
+         -m|--make)
+            make="enabled" ; shift
+            ;;
+
+         --desktop_directory)
+            desktop_directory="${2}" ; shift 2
+            ;;
+
+         -h|--help)
+            Help; shift
+            ;;
+
+         -u|--usage)
+            Usage; shift
+            ;;
+
+         -v|--version)
+            Version; shift
+            ;;
+
+         --)
+            shift
+            if [ -n "${1}" ] ; then
+               filename="${1}"
+               shift
+            fi
+            break
+            ;;
+
+         *)
+            echo "${PROGRAM}: Internal error 1" >2&
+            exit 1
+            ;;
+      esac
+   done
+}
+
+Validate ()
+{
+   case "$dialog" in
+      kdialog)
+         if [ ! -x /usr/bin/kdialog ]; then
+            dialog="none"
+            Error "${PROGRAM}: Missing /usr/bin/kdialog"
+         fi
+         ;;
+      zenity)
+         if [ ! -x /usr/bin/zenity ]; then
+            dialog="none"
+            Error "${PROGRAM}: Missing /usr/bin/zenity"
+         fi
+         ;;
+      auto)
+# FIXME: We currently prefer to use kdialog over zenity because it provides
+#        image previews.  But ideally the dialog chosen by 'auto' should
+#        match the user's session type (kdialog for KDE, zenity for
+#        GNOME & XFCE).  If zenity ever supports previews, do this kind
+#        of autodetection of the user's desktop.
+         if [ -x /usr/bin/kdialog ]; then
+            dialog="kdialog"
+         elif [ -x /usr/bin/zenity ]; then
+            dialog="zenity"
+         else
+            dialog="none"
+         fi
+         ;;
+      none)
+         ;;
+      *)
+         specified_dialog="$dialog"
+         dialog="none"
+         Error "${PROGRAM}: Invalid dialog: $specified_dialog"
+         ;;
+   esac
+   SetupDialog
+   if [ -z "$filename" ] ; then
+      Dialog file "Select a file to turn into a puzzle"
+      filename="$dialog_answer"
+   fi
+   if [ -z "$filename" ] || [ ! -f "$filename" ] ; then
+      Error "${PROGRAM}: File not found: $filename"
+   fi
+   if [ -z "$pieces" ] && [ -x /usr/bin/zenity ] ; then
+      Dialog text "Select number of pieces of puzzle" \
+         "Specify height and width in pieces as XxY, e.g. 5x4 for 20 pieces"
+      pieces="$dialog_answer"
+   fi
+   width="$(echo $pieces | cut -dx -f1)"
+   height="$(echo $pieces | cut -dx -f2)"
+   if [ $width -lt 1 ] || [ $height -lt 1 ] ; then
+      Error "${PROGRAM}: Invalid pieces: $pieces; specify XxY, where X and Y are positive integers"
+   fi
+   scale_width="$(echo $scale | cut -dx -f1)"
+   scale_height="$(echo $scale | cut -dx -f2)"
+   if [ $scale_width -lt 1 ] || [ $scale_height -lt 1 ] ; then
+      Error "${PROGRAM}: Invalid scale: $scale; specify XxY, where X and Y are positive integers"
+   fi
+}
+
+Convert ()
+{
+   tmpout=`tempfile --prefix=xjig --suffix=.jpg`
+   if [ -x /usr/bin/convert ] ; then
+      tmperr=`tempfile --prefix=xjigconv --suffix=.log`
+      # Notes: Aspect ratio is preserved by 'convert -resize'.  Without
+      # shrinking large images beforehand, xjig can run out of memory.
+      # See http://bugs.debian.org/225314
+      convert -resize $scale "${1}" "$tmpout" 2>"$tmperr"
+      CheckError ${?}
+      outfile="$tmpout"
+   else
+      outfile="${1}"
+   fi
+}
+
+Xjig ()
+{
+   tmperr=`tempfile --prefix=xjigxjig --suffix=.log`
+   xjig -w $width -h $height -file "${1}" $switches 2>"$tmperr"
+   err=$?
+   if [ $err -eq 1 ] ; then
+      grep -q 'X connection to .* broken (explicit kill or server shutdown).' $tmperr
+      err=$?
+   fi
+   CheckError $err
+}
+
+Main ()
+{
+   typeset -i width=0 height=0 scale_width=0 scale_height=0
+   typeset dialog_answer=""
+
+   export kde_initialized=0
+   trap "Cleanup" EXIT HUP INT QUIT BUS PIPE TERM
+
+   Defaults
+   Arguments "${@}"
+   Validate
+   if [ "$make" = "enabled" ] ; then
+      Error "${PROGRAM}: FIXME: make a desktop link in $desktop_directory"
+   else
+      Convert "$filename"
+      Xjig "$outfile"
+   fi
+   Cleanup
+}
+
+XJIGMENURC="$HOME/.xjigmenurc"
+if [ -f "$XJIGMENURC" ] ; then . $XJIGMENURC ; fi
+
+Main "${@}"

Added: packages/trunk/xjig/xjig-menu.6
URL: http://svn.debian.org/wsvn/debianjr/packages/trunk/xjig/xjig-menu.6?rev=16&op=file
==============================================================================
--- packages/trunk/xjig/xjig-menu.6 (added)
+++ packages/trunk/xjig/xjig-menu.6 Sat Apr 28 11:58:50 2007
@@ -1,0 +1,97 @@
+.TH XJIG-MENU "6" "April 2007" "xjig-menu, version 1.3" "Games"
+.SH NAME
+xjig-menu, \- manual page for xjig-menu, version 1.3
+.SH DESCRIPTION
+xjig\-menu \- front\-end to launch xjig
+.PP
+.SH USAGE
+.PP
+xjig\-menu [COMMON\-OPTIONS] [FILENAME]
+.PP
+xjig\-menu \fB\-m\fR|\-\-make [\-\-desktop\-directory DIR] [COMMON\-OPTIONS] [FILENAME]
+.PP
+xjig\-menu [\-h|\-\-help]
+.PP
+xjig\-menu [\-u|\-\-usage]
+.PP
+xjig\-menu [\-v|\-\-version]
+.SH COMMON\-OPTIONS
+.PP
+\fB\-p\fR|\-\-pieces XxY          number of pieces to make on the X and Y axes
+.PP
+\fB\-s\fR|\-\-scale XxY           scaled image X and Y axis size (default: 640x480)
+.PP
+\fB\-d\fR|\-\-directory DIR       directory to search for image files
+.PP
+\fB\-\-dialog DIALOG          kind of dialog box to use
+.PP
+\fB\-\-switches\fR SWITCHES      switches to pass to xjig (default: \fB\-no_flip\fR \fB\-side\fR 2)
+.SH MAKE\-OPTIONS
+.PP
+\fB\-\-make\fR                   make a link to the specified puzzle in the desktop directory and exit
+.PP
+\fB\-\-desktop\-directory\fR DIR  directory where desktop link will be made (default: $HOME/Desktop)
+.PP
+DIALOG                   auto, kdialog, zenity or none (default: auto)
+.PP
+FILENAME                 gif, jpeg or ppm image, or any image type imagemagick can convert
+.SH EXAMPLES
+.PP
+To make a 5x4 (20 piece) puzzle from scene.jpg
+.IP
+\f(CW$ xjig-menu --pieces 5x4 scene.jpg\fR
+.PP
+To make an 10x5 (50 piece) puzzle, selecting a file from
+the ~/backgrounds directory
+.IP
+\f(CW$ xjig-menu --directory ~/backgrounds --pieces 10x5\fR
+.PP
+To make a desktop link for a puzzle
+.IP
+\f(CW$ xjig-menu --pieces 5x4 scene.jpg --make\fR
+.SH FILES
+.PP
+\f(CW$HOME/xjigmenurc         set default values for the following switches
+.IP
+XJIG_PIECES            --pieces
+.IP
+XJIG_SCALE             --scale
+.IP
+XJIG_DIRECTORY         --directory
+.IP
+XJIG_DIALOG            --dialog
+.IP
+XJIG_SWITCHES          --switches
+.IP
+XJIG_DESKTOP_DIRECTORY --desktop-directory
+.PP
+For example:
+.PP
+XJIG_PIECES=8x5
+.PP
+XJIG_SCALE=1024x768
+.PP
+XJIG_DIRECTORY="\f(CW$HOME/.xjig"
+.PP
+XJIG_SWITCHES="-side 2 -no_flip -shapes"
+.PP
+XJIG_DIALOG=zenity
+.SH COPYRIGHT
+Copyright \(co 2007 Ben Armstrong <synrg at sanctuary.nslug.ns.ca>
+.PP
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+.PP
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+.PP
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110\-1301 USA
+.PP
+On Debian systems, the complete text of the GNU General Public License
+can be found in /usr/share/common\-licenses/GPL file.




More information about the Debianjr-commits mailing list