[gthumb/gthumb-2-12] webalbums: for generic ranges add the tag to the list, instead of the loop



commit bd7ce64a941e63faa339e810cc997903dcbef767
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Mon Mar 28 19:42:33 2011 +0200

    webalbums: for generic ranges add the tag to the list, instead of the loop

 extensions/webalbums/albumtheme-private.c |    9 +++++--
 extensions/webalbums/albumtheme-private.h |    9 ++++---
 extensions/webalbums/albumtheme.y         |   34 ++++++++++++++--------------
 extensions/webalbums/gth-web-exporter.c   |   14 ++++++------
 4 files changed, 35 insertions(+), 31 deletions(-)
---
diff --git a/extensions/webalbums/albumtheme-private.c b/extensions/webalbums/albumtheme-private.c
index 0a8cb9f..6e82c92 100644
--- a/extensions/webalbums/albumtheme-private.c
+++ b/extensions/webalbums/albumtheme-private.c
@@ -762,7 +762,10 @@ gth_tag_new_loop (GthLoop *loop)
 
 	tag = g_new0 (GthTag, 1);
 	tag->type = loop->type;
-	tag->value.loop = loop;
+	if (loop->type == GTH_TAG_FOR_EACH_IN_RANGE)
+		tag->value.range_loop = loop;
+	else
+		tag->value.loop = loop;
 
 	return tag;
 }
@@ -795,8 +798,8 @@ gth_tag_free (GthTag *tag)
 	{
 		gth_loop_free (tag->value.loop);
 	}
-	else if (tag->type == GTH_TAG_FOR_EACH_THUMBNAIL_CAPTION) {
-		gth_range_loop_free (GTH_RANGE_LOOP (tag->value.loop));
+	else if (tag->type == GTH_TAG_FOR_EACH_IN_RANGE) {
+		gth_range_loop_free (GTH_RANGE_LOOP (tag->value.range_loop));
 	}
 	else {
 		g_list_foreach (tag->value.attributes,
diff --git a/extensions/webalbums/albumtheme-private.h b/extensions/webalbums/albumtheme-private.h
index bb242f0..a3999ae 100644
--- a/extensions/webalbums/albumtheme-private.h
+++ b/extensions/webalbums/albumtheme-private.h
@@ -238,10 +238,11 @@ void       gth_range_loop_set_range (GthRangeLoop *loop,
 typedef struct {
 	GthTagType type;
 	union {
-		GList   *attributes;  /* GthAttribute list */
-		char    *html;        /* html */
-		GList   *cond_list;   /* GthCondition list */
-		GthLoop *loop;        /* a loop tag */
+		GList        *attributes;  /* GthAttribute list */
+		char         *html;        /* html */
+		GList        *cond_list;   /* GthCondition list */
+		GthLoop      *loop;        /* a loop tag */
+		GthRangeLoop *range_loop;
 	} value;
 	GList *document; /* GthTag list */
 } GthTag;
diff --git a/extensions/webalbums/albumtheme.y b/extensions/webalbums/albumtheme.y
index 069189b..b99ea6d 100644
--- a/extensions/webalbums/albumtheme.y
+++ b/extensions/webalbums/albumtheme.y
@@ -101,7 +101,7 @@ document	: HTML document {
 
 			gth_loop_add_document ($1, $2);
 			tag = gth_tag_new_loop ($1);
-			$$ = g_list_prepend ($4, $1);
+			$$ = g_list_prepend ($4, tag);
 		}
 
 		| tag_if document opt_tag_else_if opt_tag_else tag_end document {
@@ -138,23 +138,23 @@ tag_loop	: FOR_EACH VARIABLE END_TAG {
 			else {
 				yyerror ("Wrong iterator: '%s', expected 'thumbnail_caption' or 'image_caption'", $2);
 				YYERROR;
-			}			
+			}
 		}
 
 		| FOR_EACH VARIABLE IN expr RANGE expr END_TAG {
 			$$ = gth_range_loop_new ();
 			gth_range_loop_set_range (GTH_RANGE_LOOP ($$), $2, $4, $6);
-			
+
 			g_free ($2);
 			gth_expr_unref ($4);
 			gth_expr_unref ($6);
 		}
-		; 
+		;
 
 tag_if		: IF expr END_TAG {
 			$$ = gth_condition_new ($2);
 		}
-		
+
 		| IF '"' expr '"' END_TAG {
 			$$ = gth_condition_new ($3);
 		}
@@ -173,7 +173,7 @@ opt_tag_else_if	: tag_else_if document opt_tag_else_if {
 tag_else_if	: ELSE_IF expr END_TAG {
 			$$ = gth_condition_new ($2);
 		}
-		
+
 		| ELSE_IF '"' expr '"' END_TAG {
 			$$ = gth_condition_new ($3);
 		}
@@ -211,25 +211,25 @@ tag_print	: PRINT FUNCTION_NAME expr_list END_TAG {
 			if (gth_tag_get_type_from_name ($2) == GTH_TAG_EVAL) {
 				GthExpr *e;
 				GList   *arg_list;
-				
+
 				if ($3 == NULL) {
 					yyerror ("Missing argument for function 'eval', expected expression");
 					YYERROR;
 				}
-				
+
 				e = $3->data;
 				arg_list = g_list_append (NULL, gth_attribute_new_expression ("expr", e));
 				$$ = gth_tag_new (GTH_TAG_EVAL, arg_list);
-				
+
 				gth_expr_list_unref ($3);
 			}
 			else if (gth_tag_get_type_from_name ($2) == GTH_TAG_TRANSLATE) {
 				GList *arg_list = NULL;
 				GList *scan;
-				
+
 				for (scan = $3; scan; scan = scan->next) {
 					GthExpr *e = scan->data;
-					
+
 					if (scan == $3) {
 						GthCell *cell;
 
@@ -237,16 +237,16 @@ tag_print	: PRINT FUNCTION_NAME expr_list END_TAG {
 						if (cell->type != GTH_CELL_TYPE_STRING) {
 							yyerror ("Wrong argument type: %d, expected string", cell->type);
 							YYERROR;
-						}						
+						}
 						arg_list = g_list_append (arg_list, gth_attribute_new_string ("text", cell->value.string->str));
 
 						continue;
 					}
-									
+
 					arg_list = g_list_append (arg_list, gth_attribute_new_expression ("expr", e));
 				}
 				$$ = gth_tag_new (GTH_TAG_TRANSLATE, arg_list);
-				
+
 				gth_expr_list_unref ($3);
 			}
 			else {
@@ -407,12 +407,12 @@ expr		: '(' expr ')' {
 			gth_expr_push_var (e, $1);
 			if ($3 != NULL) {
 				GList *scan;
-				
+
 				for (scan = $3; scan; scan = scan->next) {
-					GthExpr *arg = scan->data;					
+					GthExpr *arg = scan->data;
 					gth_expr_push_expr (e, arg);
 					gth_expr_unref (arg);
-				}				
+				}
 				g_list_free ($3);
 			}
 			g_free ($1);
diff --git a/extensions/webalbums/gth-web-exporter.c b/extensions/webalbums/gth-web-exporter.c
index b61f915..18d1c20 100644
--- a/extensions/webalbums/gth-web-exporter.c
+++ b/extensions/webalbums/gth-web-exporter.c
@@ -1658,15 +1658,15 @@ gth_parsed_doc_print (GthWebExporter      *self,
 
 		case GTH_TAG_FOR_EACH_IN_RANGE:
 			{
-				LoopInfo  *inner_loop_info;
-				int        i;
-				int        first_value;
-				int        last_value;
+				LoopInfo *inner_loop_info;
+				int       i;
+				int       first_value;
+				int       last_value;
 
-				first_value = expression_value (self, GTH_RANGE_LOOP (tag)->first_value);
-				last_value = expression_value (self, GTH_RANGE_LOOP (tag)->last_value);
+				first_value = expression_value (self, tag->value.range_loop->first_value);
+				last_value = expression_value (self, tag->value.range_loop->last_value);
 				inner_loop_info = loop_info_new ();
-				inner_loop_info->iterator = g_strdup (GTH_RANGE_LOOP (tag)->iterator);
+				inner_loop_info->iterator = g_strdup (tag->value.range_loop->iterator);
 				for (i = first_value; i <= last_value; i++) {
 					inner_loop_info->first_item = (i == first_value);
 					inner_loop_info->last_item = (i == last_value);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]