[Buoh-dev] CVS commit to /cvsroot/buoh/buoh/src by steve-0



CVS commit to /cvsroot/buoh/buoh/src by steve-0

Modified Files:
	buoh-comic-manager-date.c buoh-comic-manager-date.h buoh.c 
Log Message:
2005-12-16  Esteban Sanchez  <esteban steve-o org>
        * data/comics.xml: Added a couple of new comics.
        * src/buoh-comic-manager-date.[ch]: Added offset atribute.
        * src/buoh.c: Read and set the offset atribute of the comics.

===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh-comic-manager-date.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- /cvsroot/buoh/buoh/src/buoh-comic-manager-date.c	2005/11/21 20:59:45	1.10
+++ /cvsroot/buoh/buoh/src/buoh-comic-manager-date.c	2005/12/16 14:11:13	1.11
@@ -50,6 +50,7 @@
 	GDate     *date;
 	GDate     *first;
 	gboolean   publications[8]; /* Days of week */
+	guint      offset;
 };
 
 static const gchar *day_names[] = {
@@ -96,8 +97,9 @@
 	
 	comic_manager->priv = BUOH_COMIC_MANAGER_DATE_GET_PRIVATE (comic_manager);
 	
-	comic_manager->priv->date = NULL;
-	comic_manager->priv->first = NULL;
+	comic_manager->priv->date   = NULL;
+	comic_manager->priv->first  = NULL;
+	comic_manager->priv->offset = 0;
 
  	for (i = G_DATE_BAD_WEEKDAY; i <= G_DATE_SUNDAY; i++)
 		comic_manager->priv->publications[i] = TRUE;
@@ -168,6 +170,16 @@
 }
 
 void
+buoh_comic_manager_date_set_offset (BuohComicManagerDate *comic_manager,
+				    guint                 offset)
+{
+	g_return_if_fail (BUOH_IS_COMIC_MANAGER_DATE (comic_manager));
+	g_return_if_fail (offset > 0);
+
+	comic_manager->priv->offset = offset;
+}
+
+void
 buoh_comic_manager_date_set_restriction (BuohComicManagerDate *comic_manager,
 					 GDateWeekday          day)
 {
@@ -232,7 +244,7 @@
 		return NULL;
 	} else {
 		g_free (uri_aux);
-
+		
 		buoh_debug ("uri: %s", uri);
 		return g_strdup (uri);
 	}
@@ -364,10 +376,14 @@
 
 	now = time (NULL);
 	gmt = gmtime (&now);
-	
+
 	date = g_date_new ();
 	g_date_set_time (date, mktime (gmt));
 
+	if (priv->offset != 0) {
+		g_date_subtract_days (date, priv->offset);
+	}
+	
 	/* Check the restrictions */
 	weekday = g_date_get_weekday (date);
 	while (!priv->publications[weekday]) {
===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh-comic-manager-date.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- /cvsroot/buoh/buoh/src/buoh-comic-manager-date.h	2005/11/16 20:29:28	1.6
+++ /cvsroot/buoh/buoh/src/buoh-comic-manager-date.h	2005/12/16 14:11:13	1.7
@@ -55,6 +55,8 @@
 								const gchar          *language,
 								const gchar          *generic_uri);
 
+void		  buoh_comic_manager_date_set_offset 	       (BuohComicManagerDate *comic_manager,
+								guint                 offset);
 void              buoh_comic_manager_date_set_restriction      (BuohComicManagerDate *comic_manager,
 								GDateWeekday          day);
 void              buoh_comic_manager_date_set_first            (BuohComicManagerDate *comic_manager,
===================================================================
RCS file: /cvsroot/buoh/buoh/src/buoh.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- /cvsroot/buoh/buoh/src/buoh.c	2005/12/01 21:55:27	1.28
+++ /cvsroot/buoh/buoh/src/buoh.c	2005/12/16 14:11:13	1.29
@@ -165,6 +165,7 @@
 	xmlChar          *id, *class, *title, *author, *language, *uri, *first;
 	gboolean          visible;
 	xmlChar          *restriction;
+	xmlChar          *offset;
 	GDateWeekday      restriction_date;
 	gchar            *filename;
 	GList            *selected = NULL;
@@ -212,7 +213,7 @@
 								(gchar *)language,
 								(gchar *)uri);
 			
-			/* Comic simple */
+			/* Comic date */
 			if (BUOH_IS_COMIC_MANAGER_DATE (comic_manager)) {
 				
 				first = xmlGetProp (node, (xmlChar *) "first");
@@ -220,7 +221,14 @@
 				buoh_comic_manager_date_set_first (BUOH_COMIC_MANAGER_DATE (comic_manager),
 								   (gchar *) first);
 				g_free (first);
-
+				
+				offset = xmlGetProp (node, (xmlChar *) "offset");
+				if (offset != NULL) {
+					buoh_comic_manager_date_set_offset (BUOH_COMIC_MANAGER_DATE (comic_manager),
+									    atoi ((gchar *) offset));
+					g_free (offset);
+				}
+				
 				/* Read the restrictions */
 				child = node->children->next;
 				while (child) {



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