0 Replies - 1049 Views - Last Post: 02 December 2009 - 07:48 AM

#1 nathanpc  Icon User is offline

  • SCIENCE!
  • member icon

Reputation: 113
  • View blog
  • Posts: 1,171
  • Joined: 31-July 09

GTKDialog In Bash

Posted 02 December 2009 - 07:48 AM

Description: You're going to need the Gtkdialog program, that you can get on ftp://linux.pte.hu/p...ialog/Designing GUI applications with Bash
#! /bin/bash
##! /usr/bin/gtkdialog -e

function mk_yesno(){
#USAGE: mk_yesno $"Question text?" "yes-button-icon" "no-button-icon"
	export MAIN_DIALOG='
	<window title=" - Update-Notifier - " resizable="false" icon-name="computer">
	<vbox>
	<text use-markup="true" width-chars="40">
		<label>"'`echo $1`'"</label>
	</text>
	<hbox>
		<button>
			<label>"'`gettext " No "`'"</label>
			<input file icon="'`echo $3`'"></input>
			<action type="exit">no button clicked</action>
		</button>
		<button>
			<label>"'`gettext " Yes "`'"</label>
			<input file icon="'`echo $2`'"></input>
			<action type="exit">yes button clicked</action>
		</button>
	</hbox>
	</vbox>
	</window>
	'
}


function parse_dialog_stdout() {
	I=$IFS; IFS=""
	for STATEMENT in  $(gtkdialog --center --program=MAIN_DIALOG); do
		eval $STATEMENT
	done
	IFS=$I
}


mk_yesno $"Would you like to talk about linux?" "irc_section" "gtk-quit"
parse_dialog_stdout

if [ "$EXIT" ]; then  echo -e "nnExit action: $EXITn"; fi


mk_yesno $"Would you like update-notifier to give pop-up status notifications?" "help-faq" "stop"
parse_dialog_stdout

if [ "$EXIT" ]; then  echo -e "nnExit action: $EXITn"; fi

sleep 1
exit


Is This A Good Question/Topic? 0
  • +

Page 1 of 1