From d5537b72a7fa60fd169625f38ff88eb43b2e9fd5 Mon Sep 17 00:00:00 2001 From: Joanna Rutkowska Date: Thu, 31 Mar 2011 13:26:41 +0200 Subject: [PATCH] Use zenity instead of kdialog in appvm code --- appvm/dvm_file_editor.c | 6 ++++++ appvm/qvm-copy-to-vm2.gnome | 43 +++++++++++++++++++++++++++++++++++++ common/gui-fatal.c | 13 +++++++---- 3 files changed, 58 insertions(+), 4 deletions(-) create mode 100755 appvm/qvm-copy-to-vm2.gnome diff --git a/appvm/dvm_file_editor.c b/appvm/dvm_file_editor.c index 462d8535..283bb3e1 100644 --- a/appvm/dvm_file_editor.c +++ b/appvm/dvm_file_editor.c @@ -61,8 +61,14 @@ main() "HOME=/home/user DISPLAY=:0 /usr/bin/mimeopen -n -M '%s' > /tmp/kde-open.log 2>&1 /tmp/kdialog.log 2>&1 /tmp/kdialog.log 2>&1 +# +# 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 Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# + +VM=$(zenity --entry --title="File Copy" --text="Enter the destination domain name:") +if [ X$VM = X ] ; then exit 0 ; fi + +SIZE=$(du --apparent-size -c "$@" | tail -1 | cut -f 1) + +export PROGRESS_FILE=$(mktemp) +/usr/lib/qubes/qvm-trigger-copy-to-vm $VM "$@" +while ! [ -s $PROGRESS_FILE ] ; do + sleep 0.1 +done +(while true ; do + read agentpid sentsize agentstatus < $PROGRESS_FILE + if [ "x"$agentstatus = x ] ; then continue ; fi + if ! [ -e /proc/$agentpid ] ; then break ; fi + if [ "x"$agentstatus = xdone ] ; then break ; fi + CURRSIZE=$(($sentsize/1024)) + echo $((100*$CURRSIZE/$SIZE)) + sleep 0.1 +done) | | zenity --progress --text="Copying..." + +rm -f $PROGRESS_FILE diff --git a/common/gui-fatal.c b/common/gui-fatal.c index ed2b3d47..9ce4cf23 100644 --- a/common/gui-fatal.c +++ b/common/gui-fatal.c @@ -15,18 +15,23 @@ static void fix_display() static void produce_message(char * type, const char *fmt, va_list args) { - char *kdialog_msg; + char *dialog_msg; char buf[1024]; (void) vsnprintf(buf, sizeof(buf), fmt, args); - asprintf(&kdialog_msg, "%s: %s: %s (error type: %s)", + asprintf(&dialog_msg, "%s: %s: %s (error type: %s)", program_invocation_short_name, type, buf, strerror(errno)); - fprintf(stderr, "%s", kdialog_msg); + fprintf(stderr, "%s", dialog_msg); switch (fork()) { case -1: exit(1); //what else case 0: fix_display(); - execlp("kdialog", "kdialog", "--sorry", kdialog_msg, NULL); +#ifdef USE_KDIALOG + execlp("kdialog", "kdialog", "--sorry", dialog_msg, NULL); +#else + + execlp("zenity", "zenity", "--error --text", dialog_msg, NULL); +#endif exit(1); default:; }