[maemo-commits] [maemo-commits] r8492 - in projects/haf/trunk/hildon-theme-tools: . src

From: www-data at stage.maemo.org www-data at stage.maemo.org
Date: Thu Nov 30 12:09:05 EET 2006
Author: mdk
Date: 2006-11-30 12:09:03 +0200 (Thu, 30 Nov 2006)
New Revision: 8492

Added:
   projects/haf/trunk/hildon-theme-tools/src/hildon-theme-subst
Modified:
   projects/haf/trunk/hildon-theme-tools/ChangeLog
   projects/haf/trunk/hildon-theme-tools/src/Makefile.am
   projects/haf/trunk/hildon-theme-tools/src/colourizer.c
   projects/haf/trunk/hildon-theme-tools/src/hildon-theme-rc-parser
   projects/haf/trunk/hildon-theme-tools/src/outliner.c
   projects/haf/trunk/hildon-theme-tools/src/regenerator.c
   projects/haf/trunk/hildon-theme-tools/src/slicer.c
Log:
Adding the subst tool. Fixing the error reporting in other tools.


Modified: projects/haf/trunk/hildon-theme-tools/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-theme-tools/ChangeLog	2006-11-30 09:23:12 UTC (rev 8491)
+++ projects/haf/trunk/hildon-theme-tools/ChangeLog	2006-11-30 10:09:03 UTC (rev 8492)
@@ -1,3 +1,14 @@
+2006-11-30  Michael Dominic K.  <mdk at mdk.am> 
+
+	* src/Makefile.am:
+	* src/colourizer.c:
+	* src/hildon-theme-rc-parser:
+	* src/hildon-theme-subst:
+	* src/outliner.c:
+	* src/regenerator.c:
+	* src/slicer.c: Adding the subst tool. Fixing the error reporting in
+	other tools.
+
 2006-11-29  Michael Dominic Kostrzewa  <michael.kostrzewa at nokia.com> 
 
 	* src/slicer.c:

Modified: projects/haf/trunk/hildon-theme-tools/src/Makefile.am
===================================================================
--- projects/haf/trunk/hildon-theme-tools/src/Makefile.am	2006-11-30 09:23:12 UTC (rev 8491)
+++ projects/haf/trunk/hildon-theme-tools/src/Makefile.am	2006-11-30 10:09:03 UTC (rev 8492)
@@ -1,7 +1,8 @@
 bin_PROGRAMS 				= hildon-theme-slicer 		\
 					  hildon-theme-colourizer 	\
 					  hildon-theme-regenerator 	\
-					  hildon-theme-outliner
+					  hildon-theme-outliner		\
+					  hildon-theme-subst
 
 dist_bin_SCRIPTS			= hildon-theme-rc-parser
 

Modified: projects/haf/trunk/hildon-theme-tools/src/colourizer.c
===================================================================
--- projects/haf/trunk/hildon-theme-tools/src/colourizer.c	2006-11-30 09:23:12 UTC (rev 8491)
+++ projects/haf/trunk/hildon-theme-tools/src/colourizer.c	2006-11-30 10:09:03 UTC (rev 8492)
@@ -95,7 +95,7 @@
         if (argc != 3) {
                 show_banner ();
                 show_usage ();
-                goto Error;
+                g_error ("Not enough arguments given!");
         }
 
         /* Get file vals */
@@ -103,8 +103,9 @@
         image_file = argv [2];
 
         if (template_file == NULL || image_file == NULL) {
+                show_banner ();
                 show_usage ();
-                g_error ("Not enough arguments given!");
+                g_error ("Bad arguments given!");
         }
 
         /* Check the template file... */

Modified: projects/haf/trunk/hildon-theme-tools/src/hildon-theme-rc-parser
===================================================================
--- projects/haf/trunk/hildon-theme-tools/src/hildon-theme-rc-parser	2006-11-30 09:23:12 UTC (rev 8491)
+++ projects/haf/trunk/hildon-theme-tools/src/hildon-theme-rc-parser	2006-11-30 10:09:03 UTC (rev 8492)
@@ -61,13 +61,11 @@
         return 1;
 }
 
-# Show our nice welcome info
-show_banner;
-
 # Check if we have enough arguments
 if ($#ARGV + 1 < 2) {
+        show_banner;
         show_usage ();
-        print STDERR "ERROR: Not enough arguments specified.";
+        print STDERR "ERROR: Not enough arguments specified.\n";
         exit 128;
 }
 
@@ -77,7 +75,6 @@
         exit 128;
 }
 
-
 # Recursively process the rc file
 if (not process_gtkrc ($ARGV[0])) {
         exit 128;

Added: projects/haf/trunk/hildon-theme-tools/src/hildon-theme-subst
===================================================================
--- projects/haf/trunk/hildon-theme-tools/src/hildon-theme-subst	2006-11-30 09:23:12 UTC (rev 8491)
+++ projects/haf/trunk/hildon-theme-tools/src/hildon-theme-subst	2006-11-30 10:09:03 UTC (rev 8492)
@@ -0,0 +1,100 @@
+#! /usr/bin/perl
+
+# GPL license, Copyright (c) 2006 by Nokia Corporation                       
+#                                                                            
+# Authors:                                                                   
+#      Michael Dominic K. <michael.kostrzewa at nokia.com>
+#                                                                            
+# 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, version 2.                                                                   
+#                                                                            
+# 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., 59 
+# Temple Place - Suite 330, Boston, MA 02111-1307, USA.                      
+
+use File::Basename;
+
+sub show_banner 
+{
+        print "Substitution tool by Michael Dominic K.\n";
+        print "Copyright 2006 by Nokia Corporation.\n\n";
+}
+
+sub show_usage 
+{
+        my $program_name = basename($0);
+        print "Usage: $program_name <layout> <template> <input file> <output file>\n\n";
+        print "This tool will process the supplied input file and substitute\n";
+        print "the color values with real colors fetched from the layout.\n\n";
+}
+
+sub do_substitutions
+{
+        my $line = $_[0];
+        foreach $pat (keys(%substitutions))
+        {
+                $subst = $substitutions{$pat};
+                $line =~ s/$pat/$subst/g;
+        }
+        return $line;
+}
+
+sub process_file
+{
+        my $file_name = "$_[0]";
+        my $file;
+
+        if (not open ($file, "< $file_name")) {
+                print STDERR "ERROR: Failed to open \"$file_name\" rc file.\n";
+                return 0;
+        }
+    
+        while (<$file>)
+        {
+                print TARGET do_substitutions ($_);
+        }
+
+        close ($file);
+        return 1;
+}
+
+# Check if we have enough arguments
+if ($#ARGV + 1 < 4) {
+        show_banner;
+        show_usage ();
+        print STDERR "ERROR: Not enough arguments specified.\n";
+        exit 128;
+}
+
+%substitutions = 
+    ( qw{@ThemeName@} => "ThemeName" );
+
+# Get the colors
+print "Fetching colors...\n";
+$eval_value =`hildon-theme-colourizer $ARGV[0] $ARGV[1]`;
+if ($? != 0) {
+        print STDERR "ERROR: Could not fetch colors\n";
+        exit 128;
+}
+
+eval $eval_value;
+
+# Open the output file
+if (not open (TARGET, "> $ARGV[3]")) {
+        print STDERR "ERROR: Could not open the output file \"$ARGV[3]\"\n";
+        exit 128;
+}
+
+# Process the file
+print "Processing $ARGV[2]...\n";
+if (not process_file ($ARGV[2])) {
+        exit 128;
+} else {
+        exit 0;
+}


Property changes on: projects/haf/trunk/hildon-theme-tools/src/hildon-theme-subst
___________________________________________________________________
Name: svn:executable
   + *

Modified: projects/haf/trunk/hildon-theme-tools/src/outliner.c
===================================================================
--- projects/haf/trunk/hildon-theme-tools/src/outliner.c	2006-11-30 09:23:12 UTC (rev 8491)
+++ projects/haf/trunk/hildon-theme-tools/src/outliner.c	2006-11-30 10:09:03 UTC (rev 8492)
@@ -103,12 +103,11 @@
 
 	g_type_init ();
 
-        show_banner ();
-
         /* Check the args... */
         if (argc < 3) {
+                show_banner ();
                 show_usage ();
-                goto Error;
+                g_error ("Not enough arguments given!");
         }
 
         /* Get file vals */
@@ -116,8 +115,9 @@
         output_image_file = argv [2];
 
         if (template_file == NULL || output_image_file == NULL) {
+                show_banner ();
                 show_usage ();
-                g_error ("Not enough arguments given!");
+                g_error ("Bad arguments given!");
         }
 
         /* Check the template file... */

Modified: projects/haf/trunk/hildon-theme-tools/src/regenerator.c
===================================================================
--- projects/haf/trunk/hildon-theme-tools/src/regenerator.c	2006-11-30 09:23:12 UTC (rev 8491)
+++ projects/haf/trunk/hildon-theme-tools/src/regenerator.c	2006-11-30 10:09:03 UTC (rev 8492)
@@ -105,13 +105,12 @@
         GdkPixbuf *output_image = NULL;
 
 	g_type_init ();
-
-        show_banner ();
-
+        
         /* Check the args... */
         if (argc < 3) {
+                show_banner ();
                 show_usage ();
-                goto Error;
+                g_error ("Not enough arguments given!");
         }
 
         /* Get file vals */
@@ -119,8 +118,9 @@
         output_image_file = argv [2];
 
         if (template_file == NULL || output_image_file == NULL) {
+                show_banner ();
                 show_usage ();
-                g_error ("Not enough arguments given!");
+                g_error ("Bad arguments given!");
         }
 
         /* Check the template file... */

Modified: projects/haf/trunk/hildon-theme-tools/src/slicer.c
===================================================================
--- projects/haf/trunk/hildon-theme-tools/src/slicer.c	2006-11-30 09:23:12 UTC (rev 8491)
+++ projects/haf/trunk/hildon-theme-tools/src/slicer.c	2006-11-30 10:09:03 UTC (rev 8492)
@@ -185,12 +185,11 @@
 
 	g_type_init ();
 
-        show_banner ();
-
         /* Check the args... */
         if (argc < 3) {
+                show_banner ();
                 show_usage ();
-                goto Error;
+                g_error ("Not enough arguments given!");
         }
 
         /* Get file vals */
@@ -198,8 +197,9 @@
         image_file = argv [2];
 
         if (template_file == NULL || image_file == NULL) {
+                show_banner ();
                 show_usage ();
-                g_error ("Not enough arguments given!");
+                g_error ("Bad arguments given!");
         }
 
         /* Check the template file... */


More information about the maemo-commits mailing list