[gthumb: 44/57] [webalbums] renamed GthVar as GthAttribute



commit a5a7e448e318939c491fd9a4a2a225308af6739a
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Fri Jun 18 12:28:52 2010 +0200

    [webalbums] renamed GthVar as GthAttribute

 extensions/webalbums/albumtheme-private.c |   95 +++++++---------
 extensions/webalbums/albumtheme-private.h |   88 ++++++++--------
 extensions/webalbums/albumtheme.y         |   32 +++---
 extensions/webalbums/gth-web-exporter.c   |  168 +++++++++++++++++------------
 4 files changed, 202 insertions(+), 181 deletions(-)
---
diff --git a/extensions/webalbums/albumtheme-private.c b/extensions/webalbums/albumtheme-private.c
index 54d96f9..7e15058 100644
--- a/extensions/webalbums/albumtheme-private.c
+++ b/extensions/webalbums/albumtheme-private.c
@@ -533,68 +533,57 @@ gth_expr_eval (GthExpr *e)
 }
 
 
-/* GthVar */
+/* GthAttribute */
 
 
-GthVar *
-gth_var_new_integer (int value)
+GthAttribute *
+gth_attribute_new_expression (const char *name,
+			      GthExpr    *expr)
 {
-	GthVar *var;
-
-	var = g_new0 (GthVar, 1);
-	var->name = NULL;
-	var->type = GTH_VAR_EXPR;
-	var->value.expr = gth_expr_new ();
-	gth_expr_push_integer (var->value.expr, value);
-
-	return var;
-}
-
-
-GthVar *
-gth_var_new_expression (const char *name,
-			GthExpr    *e)
-{
-	GthVar *var;
+	GthAttribute *attribute;
 
 	g_return_val_if_fail (name != NULL, NULL);
 
-	var = g_new0 (GthVar, 1);
-	var->type = GTH_VAR_EXPR;
-	var->name = g_strdup (name);
-	var->value.expr = gth_expr_ref (e);
+	attribute = g_new0 (GthAttribute, 1);
+	attribute->type = GTH_ATTRIBUTE_EXPR;
+	attribute->name = g_strdup (name);
+	attribute->value.expr = gth_expr_ref (expr);
 
-	return var;
+	return attribute;
 }
 
 
-GthVar*
-gth_var_new_string (const char *name,
-                    const char *string)
+GthAttribute*
+gth_attribute_new_string (const char *name,
+			  const char *string)
 {
-	GthVar *var;
+	GthAttribute *attribute;
 
 	g_return_val_if_fail (name != NULL, NULL);
 
-	var = g_new0 (GthVar, 1);
-	var->type = GTH_VAR_STRING;
-	var->name = g_strdup (name);
+	attribute = g_new0 (GthAttribute, 1);
+	attribute->type = GTH_ATTRIBUTE_STRING;
+	attribute->name = g_strdup (name);
 	if (string != NULL)
-		var->value.string = g_strdup (string);
+		attribute->value.string = g_strdup (string);
 
-	return var;
+	return attribute;
 }
 
 
 void
-gth_var_free (GthVar *var)
-{
-	g_free (var->name);
-	if (var->type == GTH_VAR_EXPR)
-		gth_expr_unref (var->value.expr);
-	if (var->type == GTH_VAR_STRING)
-		g_free (var->value.string);
-	g_free (var);
+gth_attribute_free (GthAttribute *attribute)
+{
+	g_free (attribute->name);
+	switch (attribute->type) {
+	case GTH_ATTRIBUTE_EXPR:
+		gth_expr_unref (attribute->value.expr);
+		break;
+	case GTH_ATTRIBUTE_STRING:
+		g_free (attribute->value.string);
+		break;
+	}
+	g_free (attribute);
 }
 
 
@@ -681,13 +670,13 @@ gth_loop_add_document (GthLoop *loop,
 
 GthTag *
 gth_tag_new (GthTagType  type,
-	     GList      *arg_list)
+	     GList      *attributes)
 {
 	GthTag *tag;
 
 	tag = g_new0 (GthTag, 1);
 	tag->type = type;
-	tag->value.arg_list = arg_list;
+	tag->value.attributes = attributes;
 
 	return tag;
 }
@@ -760,10 +749,10 @@ gth_tag_free (GthTag *tag)
 		gth_loop_free (tag->value.loop);
 	}
 	else {
-		g_list_foreach (tag->value.arg_list,
-				(GFunc) gth_var_free,
+		g_list_foreach (tag->value.attributes,
+				(GFunc) gth_attribute_free,
 				NULL);
-		g_list_free (tag->value.arg_list);
+		g_list_free (tag->value.attributes);
 	}
 
 	if (tag->document != NULL)
@@ -891,14 +880,14 @@ gth_parsed_doc_print_tree (GList *document)
 		if ((tag->type != GTH_TAG_HTML) && (tag->type != GTH_TAG_IF)) {
 			GList *scan_arg;
 
-			for (scan_arg = tag->value.arg_list; scan_arg; scan_arg = scan_arg->next) {
-				GthVar *var = scan_arg->data;
+			for (scan_arg = tag->value.attributes; scan_arg; scan_arg = scan_arg->next) {
+				GthAttribute *attribute = scan_arg->data;
 
-				g_print ("  %s = ", var->name);
-				if (var->type == GTH_VAR_STRING)
-					g_print ("%s\n", var->value.string);
+				g_print ("  %s = ", attribute->name);
+				if (attribute->type == GTH_ATTRIBUTE_STRING)
+					g_print ("%s\n", attribute->value.string);
 				else
-					gth_expr_print (var->value.expr);
+					gth_expr_print (attribute->value.expr);
 			}
 		}
 	}
diff --git a/extensions/webalbums/albumtheme-private.h b/extensions/webalbums/albumtheme-private.h
index 8475630..55e0a91 100644
--- a/extensions/webalbums/albumtheme-private.h
+++ b/extensions/webalbums/albumtheme-private.h
@@ -25,9 +25,11 @@
 
 #include <glib.h>
 
+/* A list of GthTag elements that describes a parsed .gthtml file */
+
 extern GList *yy_parsed_doc;
 
-/* GthMem */
+/* GthMem: the memory stack used to evaluate an expression. */
 
 typedef struct {
 	int *data;
@@ -46,7 +48,8 @@ int       gth_mem_get_pos    (GthMem *mem,
 int       gth_mem_get        (GthMem *mem);
 int       gth_mem_get_top    (GthMem *mem);
 
-/* GthCell */
+/* GthCell: contains an element of the expression, therefore a GthExpr is a
+ * series of GthCells. */
 
 typedef enum {
 	GTH_OP_ADD,
@@ -104,54 +107,53 @@ struct _GthExpr {
 	gpointer             get_var_value_data;
 };
 
-GthExpr*  gth_expr_new                    (void);
-GthExpr*  gth_expr_ref                    (GthExpr            *e);
-void      gth_expr_unref                  (GthExpr            *e);
-void      gth_expr_set_empty              (GthExpr            *e);
-gboolean  gth_expr_is_empty               (GthExpr            *e);
-void      gth_expr_push_expr              (GthExpr            *e,
-					   GthExpr            *e2);
-void      gth_expr_push_op                (GthExpr            *e,
-					   GthOp               op);
-void      gth_expr_push_var               (GthExpr            *e,
-					   const char         *name);
-void      gth_expr_push_string            (GthExpr            *e,
-					   const char         *value);
-void      gth_expr_push_integer           (GthExpr            *e,
-					   int                 value);
-void      gth_expr_pop                    (GthExpr            *e);
-GthCell*  gth_expr_get_pos                (GthExpr            *e,
-					   int                 pos);
-GthCell*  gth_expr_get                    (GthExpr            *e);
-int       gth_expr_get_top                (GthExpr            *e);
-void      gth_expr_set_get_var_value_func (GthExpr            *e,
-					   GthGetVarValueFunc  f,
-					   gpointer            data);
-void      gth_expr_print                  (GthExpr            *e);
-int       gth_expr_eval                   (GthExpr            *e);
-
-/* GthVar */
+GthExpr *  gth_expr_new                    (void);
+GthExpr *  gth_expr_ref                    (GthExpr            *e);
+void       gth_expr_unref                  (GthExpr            *e);
+void       gth_expr_set_empty              (GthExpr            *e);
+gboolean   gth_expr_is_empty               (GthExpr            *e);
+void       gth_expr_push_expr              (GthExpr            *e,
+					    GthExpr            *e2);
+void       gth_expr_push_op                (GthExpr            *e,
+					    GthOp               op);
+void       gth_expr_push_var               (GthExpr            *e,
+					    const char         *name);
+void       gth_expr_push_string            (GthExpr            *e,
+					    const char         *value);
+void       gth_expr_push_integer           (GthExpr            *e,
+					    int                 value);
+void       gth_expr_pop                    (GthExpr            *e);
+GthCell *  gth_expr_get_pos                (GthExpr            *e,
+					    int                 pos);
+GthCell *  gth_expr_get                    (GthExpr            *e);
+int        gth_expr_get_top                (GthExpr            *e);
+void       gth_expr_set_get_var_value_func (GthExpr            *e,
+					    GthGetVarValueFunc  f,
+					    gpointer            data);
+void       gth_expr_print                  (GthExpr            *e);
+int        gth_expr_eval                   (GthExpr            *e);
+
+/* GthAttribute */
 
 typedef enum {
-	GTH_VAR_EXPR,
-	GTH_VAR_STRING
-} GthVarType;
+	GTH_ATTRIBUTE_EXPR,
+	GTH_ATTRIBUTE_STRING
+} GthAttributeType;
 
 typedef struct {
-	char       *name;
-	GthVarType  type;
+	char             *name;
+	GthAttributeType  type;
 	union {
 		GthExpr *expr;
 		char    *string;
 	} value;
-} GthVar;
+} GthAttribute;
 
-GthVar*  gth_var_new_integer    (int value);
-GthVar*  gth_var_new_expression (const char *name,
-				 GthExpr    *e);
-GthVar*  gth_var_new_string     (const char *name,
-				 const char *string);
-void     gth_var_free           (GthVar     *var);
+GthAttribute *  gth_attribute_new_expression  (const char   *name,
+					       GthExpr      *expr);
+GthAttribute *  gth_attribute_new_string      (const char   *name,
+					       const char   *string);
+void            gth_attribute_free            (GthAttribute *attribute);
 
 /* GthCondition */
 
@@ -215,7 +217,7 @@ void        gth_loop_add_document  (GthLoop    *loop,
 typedef struct {
 	GthTagType type;
 	union {
-		GList   *arg_list;    /* GthVar list */
+		GList   *attributes;  /* GthAttribute list */
 		char    *html;        /* html */
 		GList   *cond_list;   /* GthCondition list */
 		GthLoop *loop;        /* a loop tag */
@@ -224,7 +226,7 @@ typedef struct {
 } GthTag;
 
 GthTag *     gth_tag_new                 (GthTagType  type,
-				          GList      *arg_list);
+				          GList      *attributes);
 GthTag *     gth_tag_new_html            (const char *html);
 GthTag *     gth_tag_new_condition       (GList      *cond_list);
 GthTag *     gth_tag_new_loop            (GthLoop    *loop);
diff --git a/extensions/webalbums/albumtheme.y b/extensions/webalbums/albumtheme.y
index 795c6e3..f790bda 100644
--- a/extensions/webalbums/albumtheme.y
+++ b/extensions/webalbums/albumtheme.y
@@ -37,7 +37,7 @@ int   gth_albumtheme_yywrap  (void);
 %union {
 	char         *text;
 	int           ivalue;
-	GthVar       *var;
+	GthAttribute *attribute;
 	GthTag       *tag;
 	GthExpr      *expr;
 	GList        *list;
@@ -53,17 +53,17 @@ int   gth_albumtheme_yywrap  (void);
 %token <ivalue> SET_VAR
 %token <text>   HTML
 
-%type <list>   document
-%type <tag>    tag_command
-%type <tag>    tag_print
-%type <loop>   tag_loop
-%type <cond>   tag_if
-%type <cond>   tag_else_if
-%type <cond>   opt_tag_else
-%type <list>   opt_tag_else_if
-%type <list>   attribute_list
-%type <var>    attribute
-%type <expr>   expr
+%type <list>      document
+%type <tag>       tag_command
+%type <tag>       tag_print
+%type <loop>      tag_loop
+%type <cond>      tag_if
+%type <cond>      tag_else_if
+%type <cond>      opt_tag_else
+%type <list>      opt_tag_else_if
+%type <list>      attribute_list
+%type <attribute> attribute
+%type <expr>      expr
 
 %left  <ivalue> BOOL_OP
 %left  <ivalue> COMPARE
@@ -187,7 +187,7 @@ tag_print	: PRINT FUNCTION_NAME '\'' QUOTED_STRING '\'' END_TAG {
 			if (gth_tag_get_type_from_name ($2) == GTH_TAG_TRANSLATE) {
 				GList *arg_list;
 
-				arg_list = g_list_append (NULL, gth_var_new_string ("text", $4));
+				arg_list = g_list_append (NULL, gth_attribute_new_string ("text", $4));
 				$$ = gth_tag_new (GTH_TAG_TRANSLATE, arg_list);
 			}
 			else {
@@ -216,12 +216,12 @@ attribute_list	: attribute attribute_list {
 		;
 
 attribute	: ATTRIBUTE_NAME '=' '"' expr '"' {
-			$$ = gth_var_new_expression ($1, $4);
+			$$ = gth_attribute_new_expression ($1, $4);
 			g_free ($1);
 		}
 
 		| ATTRIBUTE_NAME '=' '\'' QUOTED_STRING '\'' {
-			$$ = gth_var_new_string ($1, $4);
+			$$ = gth_attribute_new_string ($1, $4);
 			g_free ($1);
 			g_free ($4);
 		}
@@ -229,7 +229,7 @@ attribute	: ATTRIBUTE_NAME '=' '"' expr '"' {
 		| ATTRIBUTE_NAME {
 			GthExpr *e = gth_expr_new ();
 			gth_expr_push_integer (e, 1);
-			$$ = gth_var_new_expression ($1, e);
+			$$ = gth_attribute_new_expression ($1, e);
 			g_free ($1);
 		}
 		;
diff --git a/extensions/webalbums/gth-web-exporter.c b/extensions/webalbums/gth-web-exporter.c
index 9ba18b4..b86e3ab 100644
--- a/extensions/webalbums/gth-web-exporter.c
+++ b/extensions/webalbums/gth-web-exporter.c
@@ -436,15 +436,15 @@ gth_tag_get_idx (GthTag         *tag,
 		return 0;
 	}
 
-	for (scan = tag->value.arg_list; scan; scan = scan->next) {
-		GthVar *var = scan->data;
+	for (scan = tag->value.attributes; scan; scan = scan->next) {
+		GthAttribute *attribute = scan->data;
 
-		if (strcmp (var->name, "idx_relative") == 0) {
-			retval = default_value + expression_value (self, var->value.expr);
+		if (strcmp (attribute->name, "idx_relative") == 0) {
+			retval = default_value + expression_value (self, attribute->value.expr);
 			break;
 
-		} else if (strcmp (var->name, "idx") == 0) {
-			retval = expression_value (self, var->value.expr) - 1;
+		} else if (strcmp (attribute->name, "idx") == 0) {
+			retval = expression_value (self, attribute->value.expr) - 1;
 			break;
 		}
 	}
@@ -473,16 +473,33 @@ get_page_idx (GthTag         *tag,
 
 
 static int
-gth_tag_get_var (GthWebExporter *self,
-		 GthTag         *tag,
-		 const char     *var_name)
+gth_tag_has_attribute (GthWebExporter *self,
+		       GthTag         *tag,
+		       const char     *attribute_name)
 {
 	GList *scan;
 
-	for (scan = tag->value.arg_list; scan; scan = scan->next) {
-		GthVar *var = scan->data;
-		if (strcmp (var->name, var_name) == 0)
-			return expression_value (self, var->value.expr);
+	for (scan = tag->value.attributes; scan; scan = scan->next) {
+		GthAttribute *attribute = scan->data;
+		if (strcmp (attribute->name, attribute_name) == 0)
+			return TRUE;
+	}
+
+	return FALSE;
+}
+
+
+static int
+gth_tag_get_attribute_int (GthWebExporter *self,
+			   GthTag         *tag,
+			   const char     *attribute_name)
+{
+	GList *scan;
+
+	for (scan = tag->value.attributes; scan; scan = scan->next) {
+		GthAttribute *attribute = scan->data;
+		if (strcmp (attribute->name, attribute_name) == 0)
+			return expression_value (self, attribute->value.expr);
 	}
 
 	return 0;
@@ -490,25 +507,25 @@ gth_tag_get_var (GthWebExporter *self,
 
 
 static const char *
-gth_tag_get_str (GthWebExporter *self,
-		 GthTag         *tag,
-		 const char     *var_name)
+gth_tag_get_attribute_string (GthWebExporter *self,
+			      GthTag         *tag,
+			      const char     *attribute_name)
 {
 	GList *scan;
 
-	for (scan = tag->value.arg_list; scan; scan = scan->next) {
-		GthVar *var = scan->data;
+	for (scan = tag->value.attributes; scan; scan = scan->next) {
+		GthAttribute *attribute = scan->data;
 
-		if (strcmp (var->name, var_name) == 0) {
-			if (var->type == GTH_VAR_EXPR) {
+		if (strcmp (attribute->name, attribute_name) == 0) {
+			if (attribute->type == GTH_ATTRIBUTE_EXPR) {
 				GthCell *cell;
 
-				cell = gth_expr_get (var->value.expr);
+				cell = gth_expr_get (attribute->value.expr);
 				if (cell->type == GTH_CELL_TYPE_VAR)
 					return cell->value.var;
 			}
-			else if (var->type == GTH_VAR_STRING)
-				return var->value.string;
+			else if (attribute->type == GTH_ATTRIBUTE_STRING)
+				return attribute->value.string;
 			else
 				return NULL;
 		}
@@ -635,7 +652,7 @@ get_image_attribute (GthWebExporter    *self,
 	if (value == NULL)
 		return NULL;
 
-	max_length = gth_tag_get_var (self, tag, "max_length");
+	max_length = gth_tag_get_attribute_int (self, tag, "max_length");
 	if (max_length > 0) {
 		char *truncated;
 
@@ -975,10 +992,10 @@ static GthAttrImageType
 get_attr_image_type_from_tag (GthWebExporter *self,
 			      GthTag         *tag)
 {
-	if (gth_tag_get_var (self, tag, "thumbnail") != 0)
+	if (gth_tag_get_attribute_int (self, tag, "thumbnail") != 0)
 		return GTH_IMAGE_TYPE_THUMBNAIL;
 
-	if (gth_tag_get_var (self, tag, "preview") != 0)
+	if (gth_tag_get_attribute_int (self, tag, "preview") != 0)
 		return GTH_IMAGE_TYPE_PREVIEW;
 
 	return GTH_IMAGE_TYPE_IMAGE;
@@ -1050,7 +1067,7 @@ gth_parsed_doc_print (GthWebExporter      *self,
 			break;
 
 		case GTH_TAG_THEME_LINK:
-			src = gth_tag_get_str (self, tag, "src");
+			src = gth_tag_get_attribute_string (self, tag, "src");
 			if (src == NULL)
 				break;
 			file = get_theme_file (self, self->priv->target_dir, src);
@@ -1087,13 +1104,13 @@ gth_parsed_doc_print (GthWebExporter      *self,
 			image_src = gfile_get_relative_uri (file, relative_to);
 			src_attr = _g_escape_for_html (image_src, -1);
 
-			class = gth_tag_get_str (self, tag, "class");
+			class = gth_tag_get_attribute_string (self, tag, "class");
 			if (class)
 				class_attr = g_strdup_printf (" class=\"%s\"", class);
 			else
 				class_attr = g_strdup ("");
 
-			max_length = gth_tag_get_var (self, tag, "max_length");
+			max_length = gth_tag_get_attribute_int (self, tag, "max_length");
 			if (max_length > 0)
 				scale_keeping_ratio (&image_width,
 						     &image_height,
@@ -1101,7 +1118,7 @@ gth_parsed_doc_print (GthWebExporter      *self,
 						     max_length,
 						     FALSE);
 
-			alt = gth_tag_get_str (self, tag, "alt");
+			alt = gth_tag_get_attribute_string (self, tag, "alt");
 			if (alt != NULL) {
 				alt_attr = g_strdup (alt);
 			}
@@ -1113,7 +1130,7 @@ gth_parsed_doc_print (GthWebExporter      *self,
 				g_free (unescaped_path);
 			}
 
-			id = gth_tag_get_str (self, tag, "id");
+			id = gth_tag_get_attribute_string (self, tag, "id");
 			if (id != NULL)
 				id_attr = g_strdup_printf (" id=\"%s\"", id);
 			else
@@ -1160,7 +1177,7 @@ gth_parsed_doc_print (GthWebExporter      *self,
 		case GTH_TAG_IMAGE_ATTRIBUTE:
 			idx = get_image_idx (tag, self);
 			idata = g_list_nth (self->priv->file_list, idx)->data;
-			id = gth_tag_get_str (self, tag, "id");
+			id = gth_tag_get_attribute_string (self, tag, "id");
 			if (id != NULL) {
 				line = get_image_attribute (self, tag, id, idata);
 				write_line (ostream, line, error);
@@ -1191,14 +1208,14 @@ gth_parsed_doc_print (GthWebExporter      *self,
 				break;
 			}
 
-			relative = (gth_tag_get_var (self, tag, "with_relative_path") != 0);
+			relative = (gth_tag_get_attribute_int (self, tag, "with_relative_path") != 0);
 
 			if (relative)
 				unescaped_path = gfile_get_relative_path (file, relative_to);
 			else
 				unescaped_path = g_file_get_path (file);
 
-			if (relative || (gth_tag_get_var (self, tag, "with_path") != 0)) {
+			if (relative || (gth_tag_get_attribute_int (self, tag, "with_path") != 0)) {
 				line = unescaped_path;
 			}
 			else {
@@ -1206,7 +1223,7 @@ gth_parsed_doc_print (GthWebExporter      *self,
 				g_free (unescaped_path);
 			}
 
-			if  (gth_tag_get_var (self, tag, "utf8") != 0)
+			if  (gth_tag_get_attribute_int (self, tag, "utf8") != 0)
 				write_markup_escape_locale_line (ostream, line, error);
 			else
 				write_markup_escape_line (ostream, line, error);
@@ -1241,14 +1258,14 @@ gth_parsed_doc_print (GthWebExporter      *self,
 
 			dir = g_file_get_parent (file);
 
-			relative = (gth_tag_get_var (self, tag, "relative_path") != 0);
+			relative = (gth_tag_get_attribute_int (self, tag, "relative_path") != 0);
 
 			if (relative)
 				line = gfile_get_relative_path (dir, relative_to);
 			else
 				line = g_file_get_path (dir);
 
-			if  (gth_tag_get_var (self, tag, "utf8") != 0)
+			if  (gth_tag_get_attribute_int (self, tag, "utf8") != 0)
 				write_markup_escape_locale_line (ostream, line, error);
 			else
 				write_markup_escape_line (ostream, line, error);
@@ -1265,7 +1282,7 @@ gth_parsed_doc_print (GthWebExporter      *self,
 			break;
 
 		case GTH_TAG_PAGE_LINK:
-			if (gth_tag_get_var (self, tag, "image_idx") != 0) {
+			if (gth_tag_get_attribute_int (self, tag, "image_idx") != 0) {
 				int image_idx;
 				image_idx = get_image_idx (tag, self);
 				idx = get_page_idx_from_image_idx (self, image_idx);
@@ -1354,7 +1371,7 @@ gth_parsed_doc_print (GthWebExporter      *self,
 			{
 				const char *format;
 
-				format = gth_tag_get_str (self, tag, "format");
+				format = gth_tag_get_attribute_string (self, tag, "format");
 				if (format == NULL)
 					format = DEFAULT_DATE_FORMAT;
 				line = get_current_date (format);
@@ -1371,7 +1388,7 @@ gth_parsed_doc_print (GthWebExporter      *self,
 			idata = g_list_nth (self->priv->file_list, idx)->data;
 			self->priv->eval_image = idata;
 
-			value = gth_tag_get_var (self, tag, "expr");
+			value = gth_tag_get_attribute_int (self, tag, "expr");
 			line = g_strdup_printf ("%d", value);
 			write_line (ostream, line, error);
 			break;
@@ -1489,16 +1506,16 @@ gth_parsed_doc_print (GthWebExporter      *self,
 
 				metadata_info = gth_main_get_metadata_info (loop_info->attribute);
 				if (metadata_info != NULL) {
-					if (gth_tag_get_var (self, tag, "id") != 0) {
+					if (gth_tag_get_attribute_int (self, tag, "id") != 0) {
 						line = g_strdup (metadata_info->id);
 					}
-					else if (gth_tag_get_var (self, tag, "display_name") != 0) {
+					else if (gth_tag_get_attribute_int (self, tag, "display_name") != 0) {
 						line = g_strdup (metadata_info->display_name);
 					}
-					else if (gth_tag_get_var (self, tag, "value") != 0) {
+					else if (gth_tag_get_attribute_int (self, tag, "value") != 0) {
 						line = gth_file_data_get_attribute_as_string (loop_info->item, loop_info->attribute);
 					}
-					else if (gth_tag_get_var (self, tag, "index") != 0) {
+					else if (gth_tag_get_attribute_int (self, tag, "index") != 0) {
 						line = g_strdup_printf ("%d", loop_info->item_index);
 					}
 				}
@@ -1518,7 +1535,7 @@ gth_parsed_doc_print (GthWebExporter      *self,
 			break;
 
 		case GTH_TAG_TRANSLATE:
-			line = g_strdup (_(gth_tag_get_str (self, tag, "text")));
+			line = g_strdup (_(gth_tag_get_attribute_string (self, tag, "text")));
 			write_markup_escape_line (ostream, line, error);
 			break;
 
@@ -2479,22 +2496,24 @@ parse_theme_files (GthWebExporter *self)
 	template = g_file_get_child (self->priv->style_dir, "thumbnail.gthtml");
 	self->priv->thumbnail_template = parse_template (template);
 	if (self->priv->thumbnail_template == NULL) {
-		GthExpr *expr;
-		GthVar  *var;
-		GList   *vars = NULL;
-		GthTag  *tag;
+		GList        *attributes = NULL;
+		GthExpr      *expr;
+		GthAttribute *attribute;
+		GthTag       *tag;
 
 		expr = gth_expr_new ();
 		gth_expr_push_integer (expr, 0);
-		var = gth_var_new_expression ("idx_relative", expr);
-		vars = g_list_prepend (vars, var);
+		attribute = gth_attribute_new_expression ("idx_relative", expr);
+		attributes = g_list_prepend (attributes, attribute);
+		gth_expr_unref (expr);
 
 		expr = gth_expr_new ();
 		gth_expr_push_integer (expr, 1);
-		var = gth_var_new_expression ("thumbnail", expr);
-		vars = g_list_prepend (vars, var);
+		attribute = gth_attribute_new_expression ("thumbnail", expr);
+		attributes = g_list_prepend (attributes, attribute);
+		gth_expr_unref (expr);
 
-		tag = gth_tag_new (GTH_TAG_IMAGE, vars);
+		tag = gth_tag_new (GTH_TAG_IMAGE, attributes);
 		self->priv->thumbnail_template = g_list_prepend (NULL, tag);
 	}
 	g_object_unref (template);
@@ -2504,22 +2523,24 @@ parse_theme_files (GthWebExporter *self)
 	template = g_file_get_child (self->priv->style_dir, "image.gthtml");
 	self->priv->image_template = parse_template (template);
 	if (self->priv->image_template == NULL) {
-		GthExpr *expr;
-		GthVar  *var;
-		GList   *vars = NULL;
-		GthTag  *tag;
+		GList        *attributes = NULL;
+		GthExpr      *expr;
+		GthAttribute *attribute;
+		GthTag       *tag;
 
 		expr = gth_expr_new ();
 		gth_expr_push_integer (expr, 0);
-		var = gth_var_new_expression ("idx_relative", expr);
-		vars = g_list_prepend (vars, var);
+		attribute = gth_attribute_new_expression ("idx_relative", expr);
+		attributes = g_list_prepend (attributes, attribute);
+		gth_expr_unref (expr);
 
 		expr = gth_expr_new ();
 		gth_expr_push_integer (expr, 0);
-		var = gth_var_new_expression ("thumbnail", expr);
-		vars = g_list_prepend (vars, var);
+		attribute = gth_attribute_new_expression ("thumbnail", expr);
+		attributes = g_list_prepend (attributes, attribute);
+		gth_expr_unref (expr);
 
-		tag = gth_tag_new (GTH_TAG_IMAGE, vars);
+		tag = gth_tag_new (GTH_TAG_IMAGE, attributes);
 		self->priv->image_template = g_list_prepend (NULL, tag);
 	}
 	g_object_unref (template);
@@ -2533,24 +2554,33 @@ parse_theme_files (GthWebExporter *self)
 			int width;
 			int height;
 
-			width = gth_tag_get_var (self, tag, "thumbnail_width");
-			height = gth_tag_get_var (self, tag, "thumbnail_height");
+			if (gth_tag_has_attribute (self, tag, "if")) {
+				if (! gth_tag_get_attribute_int (self, tag, "if"))
+					continue;
+			}
+			else if (gth_tag_has_attribute (self, tag, "unless")) {
+				if (gth_tag_get_attribute_int (self, tag, "unless"))
+					continue;
+			}
+
+			width = gth_tag_get_attribute_int (self, tag, "thumbnail_width");
+			height = gth_tag_get_attribute_int (self, tag, "thumbnail_height");
 			if ((width != 0) && (height != 0)) {
 				debug (DEBUG_INFO, "thumbnail --> %dx%d", width, height);
 				gth_web_exporter_set_thumb_size (self, width, height);
 				continue;
 			}
 
-			width = gth_tag_get_var (self, tag, "preview_width");
-			height = gth_tag_get_var (self, tag, "preview_height");
+			width = gth_tag_get_attribute_int (self, tag, "preview_width");
+			height = gth_tag_get_attribute_int (self, tag, "preview_height");
 			if ((width != 0) && (height != 0)) {
 				debug (DEBUG_INFO, "preview --> %dx%d", width, height);
 				gth_web_exporter_set_preview_size (self, width, height);
 				continue;
 			}
 
-			width = gth_tag_get_var (self, tag, "preview_min_width");
-			height = gth_tag_get_var (self, tag, "preview_min_height");
+			width = gth_tag_get_attribute_int (self, tag, "preview_min_width");
+			height = gth_tag_get_attribute_int (self, tag, "preview_min_height");
 			if ((width != 0) && (height != 0)) {
 				debug (DEBUG_INFO, "preview min --> %dx%d", width, height);
 				gth_web_exporter_set_preview_min_size (self, width, height);



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