Default button in Xdialog

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
big_bass
Posts: 1740
Joined: Mon 13 Aug 2007, 12:21

#21 Post by big_bass »

Hey Gilbert

I made edits to a slackbuild to auto patch and make the binary in gtk2
using the patches you supplied

*someone may want a build script to simplify things a bit

there was one small thing the man patch asks which patch you want
type in doc/Xdialog.man

all the other patches are automatically applied no questions asked

working fine and tested with the no default example now 8)

@Dougal thanks for your work on Xdialog

@amigo thanks for all your work with Xdialog

EDIT in the credits if you are going to have a typo dont do it with someones name its fixed now in the slackbuild
I included sources and patches
*this isnt a package its the build folder with everything to build the package running
the slack.build against whatever gtk2 you are using

Joe
Last edited by big_bass on Thu 03 Mar 2011, 15:59, edited 4 times in total.

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#22 Post by amigo »

@dougal I didn't mean to sound disparaging. I'm glad you took time to even try and fix something, and even more so since you seem to have succeeded.

Here's a src2pkg script for building Xdialog with GTK2. It, of course, includes the PATCHLIST which goes with the xdialog-patches tarball. Just place the Xdialog-2.3.1 sources tarball, the xdialog-patches.tar.bz2 archive and the following script (named xdialog.src2pkg) together in one place, then cd in there and run 'src2pkg -X -E' to get a nice package *fast*.

Code: Select all

#!/bin/bash
## src2pkg script for: 	xdialog
## Auto-generated by src2pkg-2.4
## src2pkg - Copyright 2005-2011 Gilbert Ashley <amigo@ibilio.org>

SOURCE_NAME='Xdialog-2.3.1.tar.bz2'
ALT_NAME='xdialog'
VERSION='2.3.1'   # Use ALT_VERSION to override guessed value
# ARCH=''
# BUILD='1'
# PRE_FIX='usr'
# Any extra options go here:
EXTRA_CONFIGS="--with-gtk2"
INSTALL_LINE='make -i install'

PATCHLIST='xdialog-patches/00-Xdialog-extra-button.diff
xdialog-patches/01-Xdialog-gtk2-fixes-dougal.diff
xdialog-patches/02-Xdialog-combobox-default-item.diff
xdialog-patches/03-Xdialog-fix-yesno-button-default.diff
xdialog-patches/04-Xdialog-2.3.1-nostrip.patch
xdialog-patches/05-Xdialog_2.3.1-2.diff
xdialog-patches/06-Xdialog.man.diff'

AUTORECONF=YES

# Optional function replaces configure_source, compile_source, fake_install
# To use, uncomment and write/paste CODE between the {} brackets.
# build() { CODE }

# Get the functions and configs
. /usr/libexec/src2pkg/FUNCTIONS ;

# Execute the named packaging steps:
pre_process
find_source
make_dirs
unpack_source
fix_source_perms

( cd $PATCHES_DIR/xdialog-patches/xpm
	for XPM in *.xpm ; do
		cat $XPM > $SRC_DIR/src/$XPM
	done
)

# get rid of useless link
rm -f $SRC_DIR/NEWS

configure_source #
compile_source   # If used, the 'build' function replaces these 3
fake_install     #
fix_pkg_perms
strip_bins
create_docs
compress_man_pages
make_description
make_doinst
make_package
post_process

Note that it includes code to replace some of the existing icons with ones which I find nicer. if you don't like the new icons, you can comment out those lines in the script.

User avatar
Dougal
Posts: 2502
Joined: Wed 19 Oct 2005, 13:06
Location: Hell more grotesque than any medieval woodcut

#23 Post by Dougal »

I tried looking for the Knoppix Xdialog and bumped into this... it's a statically linked binary, but I can't download it to see if it's gtk1 or gtk2.
What's the ugliest part of your body?
Some say your nose
Some say your toes
But I think it's your mind

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#24 Post by 8-bit »

What am I missing here?
In Puppy Lucid 520, this works when adding a button to trapster's script.
If you remove the test for existence of $answer, hitting return will exit and not display the second xmessage.

Code: Select all

#!/bin/sh
#use xmessage to ask first.

answer=$(xmessage -c  "Would you like start a terminal? " -buttons yes,no,maybe -default no -print)
if [ ! $answer ]
then
answer="no"
fi
if [ $answer = "yes" ]
then
xterm
fi
if [ $answer = "maybe" ]
then
urxvt
fi
if [ $answer = "no" ]
then
answer=$(xmessage -c  "Are you sure you want to exit? " -buttons yes,no -default yes -print)
fi
if [ $answer = "no" ]
then
xterm
fi




Last edited by 8-bit on Tue 20 Sep 2011, 15:28, edited 1 time in total.

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#25 Post by BarryK »

Note, the source that I used for the Xdialog in the 'common' repo, the PET that is used by most Puppy builds, is xdialog-2.3.1-patched20090721.tar.gz here:

http://bkhome.org/sources/alphabetical/x/
Us#er#na#me: pu#pp#y Pa#ss#wo#rd: li#nu#x

I don't remember much about it, but it does have Dougal's patches.
[url]https://bkhome.org/news/[/url]

PANZERKOPF
Posts: 282
Joined: Wed 16 Dec 2009, 21:38
Location: Earth

#26 Post by PANZERKOPF »

8-bit wrote:What am I missing here?
Maybe following modifications will help you?

Code: Select all

#!/bin/sh

 #use xmessage to ask first. 
 xmessage -c  "Would you like start a terminal? " -buttons yes,no,maybe -default no
 ANSWER=$?
 
 case ${ANSWER} in
  101)
   # yes
   xterm
  ;;
  103)
   # maybe
   urxvt
  ;;
  102|1)
   # no
   xmessage -c  "Are you sure you want to exit? " -buttons yes,no -default yes
   [ $? -ne 101 ] && exec $0
  ;; 
  *)
   exit
  ;; 
 esac

SUUM CUIQUE.

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#27 Post by 8-bit »

One thing no one allowed for with a default button is a check for an empty variable if Enter/Return is pressed.
Even the simplified example of my first script by PANZERKOPF does not check for an empty variable.
So back to old and ugly for an example of what I am talking about.
If you remove the lines that check the variable for content, the script will exit without running the second xmessage.

Code: Select all

#!/bin/sh
#use xmessage to ask first.
# Call this script yes-no.sh and make it executable
# As you can see, I am not enough of a programmer to get away from a bunch of if tests.
# The lines with if [! $answer ] check for an empty variable and assign the default button to it.
answer=$(xmessage -c  "Would you like start a terminal? " -buttons yes,no,maybe -default no -print)
if [ ! $answer ]
then
answer="no"
fi
if [ $answer = "yes" ]
then
xterm
fi
if [ $answer = "maybe" ]
then
urxvt
fi
if [ $answer = "no" ]
then
answer=$(xmessage -c  "Are you sure you want to exit? " -buttons yes,no -default yes -print)
fi
if [ ! $answer ]
then
answer="yes"
fi
if [ $answer = "no" ]
then
./yes-no.sh
fi

PANZERKOPF
Posts: 282
Joined: Wed 16 Dec 2009, 21:38
Location: Earth

#28 Post by PANZERKOPF »

8-bit wrote:One thing no one allowed for with a default button is a check for an empty variable if Enter/Return is pressed.
Even the simplified example of my first script by PANZERKOPF does not check for an empty variable.
Sorry, maybe I didn't understand your problem completely.
This program (my edition) have following algorithm:
1) "yes" - run xterm
2) "maybe" - run urxvt
3) "no" - call soubrutine "are you sure?"
4) "Return" - call soubrutine "are you sure?"
5) Closing window - call "are you sure?"
Subroutine ("are you sure"):
1) "yes" - terminate.
2) "no" - recall main script.
That is what you want?
P.S.
Note check your app-default file of xmessage. This string should be present
in this file (for correct working):

Code: Select all

*baseTranslations: #override :<Key>Return: default-exit()
SUUM CUIQUE.

User avatar
8-bit
Posts: 3406
Joined: Wed 04 Apr 2007, 03:37
Location: Oregon

#29 Post by 8-bit »

What I was getting at is if one does not click on any buttons and just presses the Return/Enter key, the default key action should take place.
But if the check for the existence of the variable is not chacked and acted upon, the Return/Enter key will just exit the program without preforming the requested action of the default button.
If you add an action for the default key in your script and just press Return, does it execute the action for that default button?
Ok, I was wrong as to your script.
It works correctly! :oops:
Mine, without the test did not.
My script would exit instead of executing the next xmessage when I would press the Enter key.

Your script works correctly!

User avatar
Karl Godt
Posts: 4199
Joined: Sun 20 Jun 2010, 13:52
Location: Kiel,Germany

#30 Post by Karl Godt »

First I want to thank everybody here for the work on Xdialog .

Second : The original Xdialog-orig.tar compiles nice , but

Xdialog --buildlist TEXT 0 0 10 1 item_1 on 2 item_2 off

puts everything into the "off" (left pane) .


BK source compiles with the same warnings :
interface.c:913: warning: pointer targets in passing argument 2 of 'strcatsafe' differ in signedness
callbacks.c:1208: warning: pointer targets in passing argument 2 of 'gtk_calendar_get_date' differ in signedness
callbacks.c:1208: warning: pointer targets in passing argument 3 of 'gtk_calendar_get_date' differ in signedness
callbacks.c:1208: warning: pointer targets in passing argument 4 of 'gtk_calendar_get_date' differ in signedness

but works ok with the --buildlist parameter .


The slack-build of big_bass does not work for me that simple :
1 . 04-Xdialog-2.3.1-nostrip.patch
config.status: creating po/Makefile
cd . && aclocal-1.9 -I m4
/usr/share/aclocal/audiofile.m4:12: warning: underquoted definition of AM_PATH_AUDIOFILE
configure.in:43: error: possibly undefined macro: AM_PATH_GTK
make: *** [configure] Error 1

2 . 06-Xdialog.man.diff
the partch command does not asks me where to apply to :
--- xdialog-2.3.1/doc/Xdialog.man.old Sun Dec 2 09:51:47 2001
+++ xdialog-2.3.1/doc/Xdialog.man Wed Mar 27 08:40:39 2002
fixes this .

I tested on three puppies (431 , (2x 5xx)) and everywhere the same errs . the aclocal&&automake also wants version-1.9 , so needed to symlink later versions 1.9->1.11 for example .

Post Reply