Hullo List,

This patch adds a "clock" style progress, so one doesn't have to mouse over the Zenity icon to see where it currently stands.

Very simple, very rudimentary, but already summat useful for me. Hope others find it so as well.

Kevin
>From adb5e92ef23923089b0fed77261403fe001b59a4 Mon Sep 17 00:00:00 2001
From: Kevin Hunter <hunt...@earlham.edu>
Date: Mon, 19 Sep 2011 14:28:43 -0400
Subject: [PATCH] Update Zenity with progress icon notification

Add a "clock" style progress meter for the build via dynamically
generated svg images.  The colors are rather arbitrarily chosen, but
with a very minor attempt to be readable by color-blind folks.  A second
round cut of this patch might make the fill and stroke colors
configurable.
---
 solenv/bin/build.pl |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/solenv/bin/build.pl b/solenv/bin/build.pl
index 865e4d1..93a6952 100755
--- a/solenv/bin/build.pl
+++ b/solenv/bin/build.pl
@@ -1910,10 +1910,67 @@ sub print_announce {
     $announce_string .= $echo . "=============\n";
     print $announce_string;
 
+    my $percent_progress = $modules_started / $total_modules;
     zenity_tooltip("$text");
+    my $zenity_icon = create_progress_svg($percent_progress);
+    zenity_icon( $zenity_icon ) if ( $zenity_icon );
+
     $module_announced{$prj}++;
 };
 
+sub create_progress_svg {
+    # The colors are rather arbitrarily chosen, but with a very minor attempt
+    #   to be readable by color-blind folks.  A second round cut might make
+    #   the fill and stroke colors configurable.
+
+    # This function currently leaves a stray svg file in the tmp directory.
+    #  This shouldn't be too much of a problem, but if the next person in line
+    #  wants to remove this, go ahead.
+
+    if (! zenity_enabled()) {
+        return undef;
+    }
+
+    my $pi = 3.1415923;
+    my $percentage = shift;
+    my $path = $percentage > .5 ? '1,1' : '0,1';
+
+    # Creating a "clock" progress meter that starts from the 12 position; the
+    #  cursor starts in the center (M50,50), then goes immediately vertical
+    #  (v-50).  Associating sin with x, because it's the /difference/ of where
+    #  the cursor needs to move.  Other relevent documentation may be found at
+    #
+    #  http://www.w3.org/TR/SVG11/paths.html#PathElement and
+    #  http://www.w3.org/TR/SVG11/images/paths/arcs02.svg
+
+    my $x = 50 * sin( $percentage * 2 * $pi );
+    my $y = 50 - 50 * cos( $percentage * 2 * $pi );
+
+    my $progress_file = "$tmp_dir/lo_build_progress.svg";
+    open( PROGRESS, '>', $progress_file ) or return undef;
+    print PROGRESS <<EOF;
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+	xmlns:dc="http://purl.org/dc/elements/1.1/";
+	xmlns:cc="http://creativecommons.org/ns#";
+	xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+	xmlns:svg="http://www.w3.org/2000/svg";
+	xmlns="http://www.w3.org/2000/svg";
+	version="1.1"
+	viewBox="0 0 100 100">
+	<path
+		d="M50,50 v-50 a50,50 0 $path $x,$y z"
+		fill="#aaa"
+		stroke="#00f"
+		stroke-width="1" />
+</svg>
+EOF
+
+    close( PROGRESS );
+
+    return $progress_file;
+}
+
 sub zenity_enabled {
     return 0 if ($ENV{ENABLE_ZENITY} ne "TRUE");
     return 0 if (!defined $ENV{DISPLAY});
-- 
1.7.1

_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to