Request for freeze break (gnome-desktop)



Hi,

The attached patch removes a lot of code and changes some stuff
so gnome-about can now display the list of foundation members.

Seems to work quite well here. Note that the list of foundation members
is downloaded in autogen.sh, so each tarball will get an updated list of
members.

Vincent

-- 
Les gens heureux ne sont pas pressés.
diff --git a/ChangeLog b/ChangeLog
index be1429a..87ac19b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-09-11  Vincent Untz  <vuntz gnome org>
+
+	* autogen.sh: download foundation-members.list from api.gnome.org
+
+2007-09-11  Vincent Untz  <vuntz gnome org>
+
+	* configure.in: make gnome-about not depend on gnome-vfs
+
 2007-09-04  Vincent Untz  <vuntz gnome org>
 
 	* configure.in: post-release bump to 2.20.0
diff --git a/autogen.sh b/autogen.sh
index 8d932e6..4544163 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -20,4 +20,10 @@ which gnome-autogen.sh || {
     exit 1
 }
 
+if test "`which gnomevfs-copy`" = ""; then
+	touch gnome-about/foundation-members.list;
+else
+	gnomevfs-copy http://api.gnome.org/gnome-about/foundation-members gnome-about/foundation-members.list;
+fi
+
 REQUIRED_AUTOMAKE_VERSION=1.9 . gnome-autogen.sh
diff --git a/configure.in b/configure.in
index 6c34a36..c6ed4f6 100644
--- a/configure.in
+++ b/configure.in
@@ -107,7 +107,7 @@ dnl pkg-config dependency checks
 
 PKG_CHECK_MODULES(GNOME_DESKTOP, libxml-2.0 >= $LIBXML_REQUIRED gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED gtk+-2.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED gconf-2.0 >= $GCONF_REQUIRED gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED $STARTUP_NOTIFICATION_PACKAGE)
 
-PKG_CHECK_MODULES(GNOME_ABOUT, libxml-2.0 >= $LIBXML_REQUIRED gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED gtk+-2.0 >= $GTK_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED libgnomecanvas-2.0 >= $LIBGNOMECANVAS_REQUIRED gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED)
+PKG_CHECK_MODULES(GNOME_ABOUT, libxml-2.0 >= $LIBXML_REQUIRED gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED gtk+-2.0 >= $GTK_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED libgnomecanvas-2.0 >= $LIBGNOMECANVAS_REQUIRED)
 
 dnl gnome-doc-utils stuff
 
diff --git a/gnome-about/ChangeLog b/gnome-about/ChangeLog
index 5866850..1ff2303 100644
--- a/gnome-about/ChangeLog
+++ b/gnome-about/ChangeLog
@@ -1,3 +1,23 @@
+2007-09-11  Vincent Untz  <vuntz gnome org>
+
+	* Makefile.am: ship foundation-members.list
+
+2007-09-11  Vincent Untz  <vuntz gnome org>
+
+	Remove code to download the list of foundation members. This will be
+	in a file that is created during make dist.
+
+	* contributors.c: rename some variables.
+	(generate_randomness): update for new names
+	(contributors_get): ditto
+	(contributors_read): renamed from contributors_static_read(), make
+	more generic
+	(contributors_free): updated
+	(contributors_init): updated
+	(contributors_ensure_dir_exists): kill
+	(contributors_async_xfer_progress): kill
+	(contributors_online_read): kill
+
 ==================== 2.19.92 ====================
 
 ==================== 2.19.90 ====================
diff --git a/gnome-about/Makefile.am b/gnome-about/Makefile.am
index 27a7251..c57a4ba 100644
--- a/gnome-about/Makefile.am
+++ b/gnome-about/Makefile.am
@@ -23,7 +23,7 @@ desktop_in_files = gnome-about.desktop.in
 desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
 
 aboutdir = $(datadir)/gnome-about
-about_DATA = gnome-64.png contributors.list
+about_DATA = gnome-64.png contributors.list foundation-members.list
 
 EXTRA_DIST = $(about_DATA)
 
diff --git a/gnome-about/contributors.c b/gnome-about/contributors.c
index 21b5088..b8a9137 100644
--- a/gnome-about/contributors.c
+++ b/gnome-about/contributors.c
@@ -31,36 +31,26 @@
 
 #include <glib.h>
 #include <glib/gi18n.h>
-#include <glib/gstdio.h>
 
 #include <libgnome/gnome-program.h>
-#include <libgnome/gnome-util.h>
-
-#include <libgnomevfs/gnome-vfs-async-ops.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
 
 #include "contributors.h"
 
-static int    num_static_contributors;
-static int    num_online_contributors;
-static int    num_total_contributors;
+static int    num_old_contributors;
+static int    num_foundation_contributors;
+static int    num_total;
 static int   *contrib_order = NULL;
 
-#define CONTRIBUTORS_FILE "contributors.list"
-#define ONLINE_CONTRIBUTORS_URI "http://api.gnome.org/gnome-about/foundation-members";
-static char **static_contributors = NULL;
-static char **online_contributors = NULL;
+#define OLD_CONTRIBUTORS_FILE         "contributors.list"
+#define FOUNDATION_CONTRIBUTORS_FILE  "foundation-members.list"
+static char **old_contributors = NULL;
+static char **foundation_contributors = NULL;
 static char  *translated_contributors[] = {
 	N_("The Mysterious GEGL"),
 	N_("The Squeaky Rubber GNOME"),
 	N_("Wanda The GNOME Fish")
 };
 
-struct OnlineXfer {
-	GnomeVFSAsyncHandle *handle;
-	char *file;
-} online_xfer_data = { NULL, NULL } ;
-
 static void
 generate_randomness (void)
 {
@@ -74,14 +64,13 @@ generate_randomness (void)
 
 	generator = g_rand_new ();
 
-	contrib_order = g_malloc (num_total_contributors * sizeof (int));
+	contrib_order = g_malloc (num_total * sizeof (int));
 
-	for (i = 0; i < num_total_contributors; i++)
+	for (i = 0; i < num_total; i++)
 		contrib_order[i]=i;
 
-	for (i = 0; i < num_total_contributors; i++) {
-		random_number = g_rand_int_range (generator, i, 
-						  num_total_contributors);
+	for (i = 0; i < num_total; i++) {
+		random_number = g_rand_int_range (generator, i, num_total);
 		tmp = contrib_order[i];
 		contrib_order[i] = contrib_order[random_number];
 		contrib_order[random_number] = tmp;
@@ -97,20 +86,20 @@ contributors_get (int i)
 
 	g_assert (contrib_order != NULL);
 
-	real = i % (num_total_contributors);
+	real = i % (num_total);
 
 	if (contrib_order[real] < G_N_ELEMENTS (translated_contributors))
 		return _(translated_contributors[contrib_order[real]]);
 	else if (contrib_order[real] < G_N_ELEMENTS (translated_contributors)
-				       + num_static_contributors)
-		return static_contributors[contrib_order[real] -
-					   G_N_ELEMENTS (translated_contributors)];
+				       + num_old_contributors)
+		return old_contributors[contrib_order[real] -
+				        G_N_ELEMENTS (translated_contributors)];
 	else if (contrib_order[real] < G_N_ELEMENTS (translated_contributors)
-				       + num_static_contributors
-				       + num_online_contributors)
-		return online_contributors[contrib_order[real]
-					   - G_N_ELEMENTS (translated_contributors)
-					   - num_static_contributors];
+				       + num_old_contributors
+				       + num_foundation_contributors)
+		return foundation_contributors[contrib_order[real]
+					       - G_N_ELEMENTS (translated_contributors)
+					       - num_old_contributors];
 	else
 		g_assert_not_reached ();
 }
@@ -180,173 +169,21 @@ contributors_read_from_file (const char   *file,
 }
 
 static void
-contributors_static_read (void)
+contributors_read (const char  *filename,
+		   char       ***contributors,
+		   int          *contributors_nb)
 {
 	char *file;
 
 	file = gnome_program_locate_file (NULL,
 					  GNOME_FILE_DOMAIN_APP_DATADIR,
-					  CONTRIBUTORS_FILE,
+					  filename,
 					  TRUE, NULL);
 	if (!file)
 		return;
 
-	num_online_contributors = 0;
-	contributors_read_from_file (file,
-				     &static_contributors,
-				     &num_static_contributors);
-	num_total_contributors += num_static_contributors;
-
-	g_free (file);
-}
-
-static gboolean
-contributors_ensure_dir_exists (const char *dir)
-{
-	if (g_file_test (dir, G_FILE_TEST_IS_DIR))
-		return TRUE;
-
-	if (g_file_test (dir, G_FILE_TEST_EXISTS)) {
-		g_printerr ("%s is not a directory.", dir);
-		return FALSE;
-	}
-
-	if (g_mkdir_with_parents (dir, 0755) != 0) {
-		g_warning ("Failed to create directory %s.", dir);
-		return FALSE;
-	}
-
-	return TRUE;
-}
-
-static int
-contributors_async_xfer_progress (GnomeVFSAsyncHandle      *handle,
-				  GnomeVFSXferProgressInfo *progress_info,
-				  gpointer                  data)
-{
-	struct OnlineXfer *xfer_data = data;
-
-	switch (progress_info->status) {
-	case GNOME_VFS_XFER_PROGRESS_STATUS_OK:
-		if (progress_info->phase != GNOME_VFS_XFER_PHASE_COMPLETED)
-			return 1;
-		break;
-	case GNOME_VFS_XFER_PROGRESS_STATUS_VFSERROR:
-		return GNOME_VFS_XFER_ERROR_ACTION_ABORT;
-	case GNOME_VFS_XFER_PROGRESS_STATUS_OVERWRITE:
-		return GNOME_VFS_XFER_OVERWRITE_ACTION_REPLACE;
-	case GNOME_VFS_XFER_PROGRESS_STATUS_DUPLICATE:
-		return 0;
-	default:
-		g_warning ("Unknown GnomeVFSXferProgressStatus %d",
-			   progress_info->status);
-		return 0;
-	}
-
-	/* we're done with the xfer */
-
-	num_online_contributors = 0;
-	contributors_read_from_file (xfer_data->file,
-				     &online_contributors,
-				     &num_online_contributors);
-	num_total_contributors += num_online_contributors;
-
-	/* include the new contributors in the data we'll give */
-	generate_randomness ();
-
-	xfer_data->handle = NULL;
-	g_free (xfer_data->file);
-	xfer_data->file = NULL;
-
-	return 0;
-}
-
-static void
-contributors_online_read (void)
-{
-	char *dir;
-	char *file;
-	gboolean need_to_download;
-
-	//TODO: remove this when we get our api.gnome.org page
-	return;
-
-	dir = g_build_filename (gnome_user_dir_get (), "gnome-about", NULL);
-
-	if (!contributors_ensure_dir_exists (dir)) {
-		g_free (dir);
-		return;
-	}
-
-	file = g_build_filename (dir, CONTRIBUTORS_FILE, NULL);
-	g_free (dir);
-
-	need_to_download = TRUE;
-	if (g_file_test (file, G_FILE_TEST_EXISTS)) {
-		struct stat stat_data;
-
-		if (g_stat (file, &stat_data) == 0) {
-			GDate *validity_date;
-			GDate *modified;
-
-			validity_date = g_date_new ();
-			modified = g_date_new ();
-
-			g_date_set_time_t (validity_date, time (NULL));
-			g_date_subtract_days (validity_date, 14);
-			g_date_set_time_t (modified, stat_data.st_mtime);
-
-			if (g_date_compare (modified, validity_date) >= 0)
-				need_to_download = FALSE;
-
-			g_date_free (modified);
-			g_date_free (validity_date);
-		} else {
-			g_printerr ("Cannot stat %s: %s", file, strerror (errno));
-		}
-
-		if (need_to_download)
-			g_unlink (file);
-	}
-
-	if (need_to_download) {
-		char  *dest_file;
-		GList *src_list;
-		GList *dest_list;
-		GnomeVFSURI *src_uri;
-		GnomeVFSURI *dest_uri;
-
-		src_uri = gnome_vfs_uri_new (ONLINE_CONTRIBUTORS_URI);
-		src_list = g_list_append (NULL, src_uri);
-
-		dest_file = gnome_vfs_get_uri_from_local_path (file);
-		dest_uri = gnome_vfs_uri_new (dest_file);
-		dest_list = g_list_append (NULL, dest_uri);
-		g_free (dest_file);
-
-		online_xfer_data.file = g_strdup (file);
-
-		gnome_vfs_async_xfer (&online_xfer_data.handle,
-				      src_list, dest_list,
-				      GNOME_VFS_XFER_DEFAULT,
-				      GNOME_VFS_XFER_ERROR_MODE_ABORT,
-				      GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
-				      GNOME_VFS_PRIORITY_DEFAULT,
-				      contributors_async_xfer_progress,
-				      &online_xfer_data,
-				      NULL, NULL);
-
-		g_list_free (src_list);
-		g_list_free (dest_list);
-		gnome_vfs_uri_unref (src_uri);
-		gnome_vfs_uri_unref (dest_uri);
-	} else {
-		num_online_contributors = 0;
-		contributors_read_from_file (file,
-					     &online_contributors,
-					     &num_online_contributors);
-		num_total_contributors += num_online_contributors;
-	}
+	contributors_read_from_file (file, contributors, contributors_nb);
+	num_total += *contributors_nb;
 
 	g_free (file);
 }
@@ -358,32 +195,28 @@ contributors_free (void)
 		g_free (contrib_order);
 	contrib_order = NULL;
 
-	if (static_contributors)
-		g_strfreev (static_contributors);
-	static_contributors = NULL;
-
-	if (online_xfer_data.handle)
-		gnome_vfs_async_cancel (online_xfer_data.handle);
-	online_xfer_data.handle = NULL;
+	if (old_contributors)
+		g_strfreev (old_contributors);
+	old_contributors = NULL;
 
-	if (online_xfer_data.file)
-		g_free (online_xfer_data.file);
-	online_xfer_data.file = NULL;
-
-	if (online_contributors)
-		g_strfreev (online_contributors);
-	online_contributors = NULL;
+	if (foundation_contributors)
+		g_strfreev (foundation_contributors);
+	foundation_contributors = NULL;
 }
 
 void
 contributors_init (void)
 {
-	num_static_contributors = 0;
-	num_online_contributors = 0;
-	num_total_contributors = G_N_ELEMENTS (translated_contributors);
-
-	contributors_static_read ();
-	contributors_online_read ();
+	num_old_contributors = 0;
+	num_foundation_contributors = 0;
+	num_total = G_N_ELEMENTS (translated_contributors);
+
+	contributors_read (OLD_CONTRIBUTORS_FILE,
+			   &old_contributors,
+			   &num_old_contributors);
+	contributors_read (FOUNDATION_CONTRIBUTORS_FILE,
+			   &foundation_contributors,
+			   &num_foundation_contributors);
 
 	generate_randomness ();
 }


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