rpms/planner/devel planner-gnome596171-recentlyused.patch, NONE, 1.1 planner-gnome596173-xdg.patch, NONE, 1.1 planner.spec, 1.64, 1.65

Caolan McNamara caolanm at fedoraproject.org
Thu Sep 24 11:01:37 UTC 2009


Author: caolanm

Update of /cvs/pkgs/rpms/planner/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv29622

Modified Files:
	planner.spec 
Added Files:
	planner-gnome596171-recentlyused.patch 
	planner-gnome596173-xdg.patch 
Log Message:
Resolves: rhbz#524662 Gnome XDG Config Folders for planner

planner-gnome596171-recentlyused.patch:
 Makefile.am               |    1 
 Makefile.in               |    3 
 src/Makefile.am           |    1 
 src/Makefile.in           |    2 
 src/planner-application.c |   23 --
 src/planner-application.h |    2 
 src/planner-window.c      |  379 +++++++++++++++++++++++++++++++++++++++-------
 7 files changed, 326 insertions(+), 85 deletions(-)

--- NEW FILE planner-gnome596171-recentlyused.patch ---
diff -ru planner-0.14.4.orig/Makefile.am planner-0.14.4/Makefile.am
--- planner-0.14.4.orig/Makefile.am	2009-09-23 10:07:20.000000000 +0100
+++ planner-0.14.4/Makefile.am	2009-09-23 13:14:28.000000000 +0100
@@ -14,7 +14,6 @@
 SUBDIRS = \
 	po 				\
 	libplanner			\
-	libegg				\
 	src				\
 	data				\
 	docs				\
diff -ru planner-0.14.4.orig/Makefile.in planner-0.14.4/Makefile.in
--- planner-0.14.4.orig/Makefile.in	2009-09-23 10:07:21.000000000 +0100
+++ planner-0.14.4/Makefile.in	2009-09-23 13:14:55.000000000 +0100
@@ -71,7 +71,7 @@
 DATA = $(pkgconfig_DATA)
 ETAGS = etags
 CTAGS = ctags
-DIST_SUBDIRS = po libplanner libegg src data docs examples tests \
+DIST_SUBDIRS = po libplanner src data docs examples tests \
 	python eds-backend
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
@@ -307,7 +307,6 @@
 SUBDIRS = \
 	po 				\
 	libplanner			\
-	libegg				\
 	src				\
 	data				\
 	docs				\
diff -ru planner-0.14.4.orig/src/Makefile.am planner-0.14.4/src/Makefile.am
--- planner-0.14.4.orig/src/Makefile.am	2009-09-23 10:07:20.000000000 +0100
+++ planner-0.14.4/src/Makefile.am	2009-09-24 10:30:03.000000000 +0100
@@ -21,7 +21,6 @@
 planner_LDADD = \
 	libplannerapp.la \
 	$(top_builddir)/libplanner/libplanner-1.la \
-	$(top_builddir)/libegg/recent-files/libeggrecent.la \
 	$(PLANNER_LIBS)
 
 
diff -ru planner-0.14.4.orig/src/Makefile.in planner-0.14.4/src/Makefile.in
--- planner-0.14.4.orig/src/Makefile.in	2009-09-23 10:07:20.000000000 +0100
+++ planner-0.14.4/src/Makefile.in	2009-09-24 10:29:58.000000000 +0100
@@ -131,7 +131,6 @@
 planner_OBJECTS = $(am_planner_OBJECTS)
 planner_DEPENDENCIES = libplannerapp.la \
 	$(top_builddir)/libplanner/libplanner-1.la \
-	$(top_builddir)/libegg/recent-files/libeggrecent.la \
 	$(am__DEPENDENCIES_1)
 DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
@@ -387,7 +386,6 @@
 planner_LDADD = \
 	libplannerapp.la \
 	$(top_builddir)/libplanner/libplanner-1.la \
-	$(top_builddir)/libegg/recent-files/libeggrecent.la \
 	$(PLANNER_LIBS)
 
 
diff -ru planner-0.14.4.orig/src/planner-application.c planner-0.14.4/src/planner-application.c
--- planner-0.14.4.orig/src/planner-application.c	2009-09-23 10:07:20.000000000 +0100
+++ planner-0.14.4/src/planner-application.c	2009-09-23 13:20:54.000000000 +0100
@@ -34,9 +34,6 @@
 
 struct _PlannerApplicationPriv {
 	GList *windows;
-
-	/* recent file stuff */
-	EggRecentModel *recent_model;
 };
 
 
@@ -181,15 +178,6 @@
 
 	priv->windows = NULL;
 	
-	priv->recent_model = egg_recent_model_new (EGG_RECENT_MODEL_SORT_MRU);
-	egg_recent_model_set_filter_mime_types (priv->recent_model,
-						"application/x-planner",
-						"application/x-mrproject",
-						NULL);
-	egg_recent_model_set_filter_uri_schemes (priv->recent_model, "file", NULL);
-
-	g_object_set (priv->recent_model, "limit", 5, NULL);
-
 	app->priv = priv;
 }
 
@@ -198,8 +186,6 @@
 {
 	PlannerApplication *app = PLANNER_APPLICATION (object);
 
-	g_object_unref (app->priv->recent_model);
-	
 	g_free (app->priv);
 
 	if (G_OBJECT_CLASS (parent_class)->finalize) {
@@ -281,12 +267,3 @@
 	
 	g_list_free (list_cpy);
 }
-
-EggRecentModel *
-planner_application_get_recent_model (PlannerApplication *app)
-{
-	g_return_val_if_fail (PLANNER_IS_APPLICATION (app), NULL);
-
-	return app->priv->recent_model;
-}
-
diff -ru planner-0.14.4.orig/src/planner-application.h planner-0.14.4/src/planner-application.h
--- planner-0.14.4.orig/src/planner-application.h	2009-09-23 10:07:20.000000000 +0100
+++ planner-0.14.4/src/planner-application.h	2009-09-23 13:16:52.000000000 +0100
@@ -26,7 +26,6 @@
 
 #include <libplanner/mrp-application.h>
 #include <libplanner/mrp-project.h>
-#include <libegg/recent-files/egg-recent-model.h>
 
 #define PLANNER_TYPE_APPLICATION                (planner_application_get_type ())
 #define PLANNER_APPLICATION(obj)                (G_TYPE_CHECK_INSTANCE_CAST ((obj), PLANNER_TYPE_APPLICATION, PlannerApplication))
@@ -54,6 +53,5 @@
 PlannerApplication   *planner_application_new              (void);
 GtkWidget       *     planner_application_new_window       (PlannerApplication *app);
 void                  planner_application_exit             (PlannerApplication *app);
-EggRecentModel  *     planner_application_get_recent_model (PlannerApplication *app);
 
 #endif /* __PLANNER_APPLICATION_H__ */
diff -ru planner-0.14.4.orig/src/planner-window.c planner-0.14.4/src/planner-window.c
--- planner-0.14.4.orig/src/planner-window.c	2009-09-23 10:07:20.000000000 +0100
+++ planner-0.14.4/src/planner-window.c	2009-09-24 10:28:38.000000000 +0100
@@ -32,9 +32,6 @@
 #include <libplanner/mrp-error.h>
 #include <libplanner/mrp-project.h>
 #include <libplanner/mrp-paths.h>
-#include <libegg/recent-files/egg-recent-view.h>
-#include <libegg/recent-files/egg-recent-view-uimanager.h>
-#include <libegg/recent-files/egg-recent-util.h>
 #include "planner-marshal.h"
 #include "planner-conf.h"
 #include "planner-sidebar.h"
@@ -80,7 +77,9 @@
 	GList               *plugins;
 	GTimer              *last_saved;
 
-	EggRecentViewUIManager *recent_view;
+	GtkActionGroup      *recents_action_group;
+	guint               recents_menu_ui_id;
+	gulong              recents_handler_id;
 };
 
 /* Drop targets. */
@@ -183,8 +182,6 @@
 static void       window_update_title                    (PlannerWindow                *window);
 static GtkWidget *window_create_dialog_button            (const gchar                  *icon_name,
 							  const gchar                  *text);
-static gchar *    window_recent_tooltip_func             (EggRecentItem                *item,
-							  gpointer                      user_data);
 static void       window_save_state                      (PlannerWindow *window);
 static void       window_restore_state                   (PlannerWindow *window);
 
@@ -410,10 +407,6 @@
 		g_object_unref (priv->cmd_manager);
 	}
 
-	if (priv->recent_view) {
-		g_object_unref (priv->recent_view);
-	}
-
 	if (priv->ui_manager) {
 		g_object_unref (priv->ui_manager);
 	}
@@ -429,11 +422,13 @@
 planner_window_open_recent_cb (GtkAction     *action,
 			       PlannerWindow *window)
 {
-	const EggRecentItem *item;
-	const gchar         *uri;
+	GtkRecentInfo *info;
+	const gchar   *uri;
+
+	info = g_object_get_data (G_OBJECT (action), "gtk-recent-info");
+	g_return_if_fail (info != NULL);
 
-	item = egg_recent_view_uimanager_get_item (window->priv->recent_view, action);
-	uri = egg_recent_item_peek_uri (item);
+	uri = gtk_recent_info_get_uri (info);
 
 	planner_window_open_in_existing_or_new (window, uri, FALSE);
 }
@@ -530,6 +525,264 @@
 			       "24_groups.png");
 }
 
+/*recent files stuff lifted from gedit*/
+static void     update_recent_files_menu (PlannerWindow *window);
+
+static void
+recent_manager_changed (GtkRecentManager *manager,
+                        PlannerWindow *window)
+{
+	/* regenerate the menu when the model changes */
+	update_recent_files_menu (window);
+}
+
+static gint
+sort_recents_mru (GtkRecentInfo *a, GtkRecentInfo *b)
+{
+        return (gtk_recent_info_get_modified (b) - gtk_recent_info_get_modified (a));
+}
+
+
+/*
+ * Doubles underscore to avoid spurious menu accels.
+ */
+static gchar * 
+escape_underscores (const gchar* text,
+                    gssize       length)
+{
+	GString *str;
+	const gchar *p;
+	const gchar *end;
+
+	g_return_val_if_fail (text != NULL, NULL);
+
+	if (length < 0)
+		length = strlen (text);
+
+	str = g_string_sized_new (length);
+
+	p = text;
+	end = text + length;
+
+	while (p != end)
+	{
+		const gchar *next;
+		next = g_utf8_next_char (p);
+
+		switch (*p)
+		{
+			case '_':
+				g_string_append (str, "__");
+				break;
+			default:
+				g_string_append_len (str, p, next - p);
+				break;
+		}
+
+		p = next;
+	}
+
+	return g_string_free (str, FALSE);
+}
+
+
+/**
+ * uri_for_display:
+ * @uri: uri to be displayed.
+ *
+ * Filter, modify, unescape and change @uri to make it appropriate
+ * for display to users.
+ * 
+ * This function is a convenient wrapper for g_file_get_parse_name
+ *
+ * Return value: a string which represents @uri and can be displayed.
+ */
+static gchar *
+uri_for_display (const gchar *uri)
+{
+	GFile *gfile;
+	gchar *parse_name;
+
+	gfile = g_file_new_for_uri (uri);
+	parse_name = g_file_get_parse_name (gfile);
+	g_object_unref (gfile);
+
+	return parse_name;
+}
+
+static gchar *
+replace_home_dir_with_tilde (const gchar *uri)
+{
+	gchar *tmp;
+	gchar *home;
+
+	g_return_val_if_fail (uri != NULL, NULL);
+
+	/* Note that g_get_home_dir returns a const string */
+	tmp = (gchar *)g_get_home_dir ();
+
+	if (tmp == NULL)
+		return g_strdup (uri);
+
+	home = g_filename_to_utf8 (tmp, -1, NULL, NULL, NULL);
+	if (home == NULL)
+		return g_strdup (uri);
+
+	if (strcmp (uri, home) == 0)
+	{
+		g_free (home);
+		
+		return g_strdup ("~");
+	}
+
+	tmp = home;
+	home = g_strdup_printf ("%s/", tmp);
+	g_free (tmp);
+
+	if (g_str_has_prefix (uri, home))
+	{
+		gchar *res;
+
+		res = g_strdup_printf ("~/%s", uri + strlen (home));
+
+		g_free (home);
+		
+		return res;		
+	}
+
+	g_free (home);
+
+	return g_strdup (uri);
+}
+
+static void
+update_recent_files_menu (PlannerWindow *window)
+{
+        PlannerWindowPriv *p = window->priv;
+	GtkRecentManager *recent_manager;
+        gint max_recents = 5;
+	GList *actions, *l, *items;
+	GList *filtered_items = NULL;
+	gint i;
+
+	g_return_if_fail (p->recents_action_group != NULL);
+
+	if (p->recents_menu_ui_id != 0)
+		gtk_ui_manager_remove_ui (p->ui_manager,
+		                          p->recents_menu_ui_id);
+
+	actions = gtk_action_group_list_actions (p->recents_action_group);
+	for (l = actions; l != NULL; l = l->next)
+	{
+		g_signal_handlers_disconnect_by_func (GTK_ACTION (l->data),
+		                                      G_CALLBACK (planner_window_open_recent_cb),
+		                                      window);
+		gtk_action_group_remove_action (p->recents_action_group,
+		                                GTK_ACTION (l->data));
+	}
+	g_list_free (actions);
+
+	p->recents_menu_ui_id = gtk_ui_manager_new_merge_id (p->ui_manager);
+
+	recent_manager =  gtk_recent_manager_get_default ();
+	items = gtk_recent_manager_get_items (recent_manager);
+
+	/* filter */
+	for (l = items; l != NULL; l = l->next)
+	{
+		GtkRecentInfo *info = l->data;
+
+		if (!gtk_recent_info_has_group (info, "planner"))
+			continue;
+
+		filtered_items = g_list_prepend (filtered_items, info);
+	}
+
+	/* sort */
+	filtered_items = g_list_sort (filtered_items,
+				      (GCompareFunc) sort_recents_mru);
+
+	i = 0;
+	for (l = filtered_items; l != NULL; l = l->next)
+	{
+		gchar *action_name;
+		const gchar *display_name;
+		gchar *escaped;
+		gchar *label;
+		gchar *uri;
+		gchar *ruri;
+		gchar *tip;
+		GtkAction *action;
+		GtkRecentInfo *info = l->data;
+
+		/* clamp */
+		if (i >= max_recents)
+			break;
+
+		i++;
+
+		action_name = g_strdup_printf ("recent-info-%d", i);
+
+		display_name = gtk_recent_info_get_display_name (info);
+		escaped = escape_underscores (display_name, -1);
+		if (i >= 10)
+			label = g_strdup_printf ("%d.  %s",
+						 i, 
+						 escaped);
+		else
+			label = g_strdup_printf ("_%d.  %s",
+						 i, 
+						 escaped);
+		g_free (escaped);
+
+		/* gtk_recent_info_get_uri_display (info) is buggy and
+		 * works only for local files */
+		uri = uri_for_display (gtk_recent_info_get_uri (info));
+		ruri = replace_home_dir_with_tilde (uri);
+		g_free (uri);
+
+		/* Translators: %s is a URI */
+		tip = g_strdup_printf (_("Open '%s'"), ruri);
+		g_free (ruri);
+
+		action = gtk_action_new (action_name,
+					 label,
+					 tip,
+					 NULL);
+
+		g_object_set_data_full (G_OBJECT (action),
+					"gtk-recent-info",
+					gtk_recent_info_ref (info),
+					(GDestroyNotify) gtk_recent_info_unref);
+
+		g_signal_connect (action,
+				  "activate",
+				  G_CALLBACK (planner_window_open_recent_cb),
+				  window);
+
+		gtk_action_group_add_action (p->recents_action_group,
+					     action);
+		g_object_unref (action);
+
+		gtk_ui_manager_add_ui (p->ui_manager,
+				       p->recents_menu_ui_id,
+				       "/MenuBar/File/OpenRecent",
+				       action_name,
+				       action_name,
+				       GTK_UI_MANAGER_MENUITEM,
+				       FALSE);
+
+		g_free (action_name);
+		g_free (label);
+		g_free (tip);
+	}
+
+	g_list_free (filtered_items);
+
+	g_list_foreach (items, (GFunc) gtk_recent_info_unref, NULL);
+	g_list_free (items);
+}
+
 static void
 window_populate (PlannerWindow *window)
 {
@@ -606,17 +859,17 @@
 		      NULL);
 
 	/* Handle recent file stuff. */
-	priv->recent_view = egg_recent_view_uimanager_new (priv->ui_manager,
-							   "/MenuBar/File/OpenRecent",
-							   G_CALLBACK (planner_window_open_recent_cb),
-							   window);
-
-	egg_recent_view_set_model (EGG_RECENT_VIEW (priv->recent_view),
-				   planner_application_get_recent_model (priv->application));
-	egg_recent_view_uimanager_set_tooltip_func (priv->recent_view,
-						    window_recent_tooltip_func,
-						    NULL);
+        window->priv->recents_action_group = gtk_action_group_new ("RecentFilesActions");
+        gtk_action_group_set_translation_domain (window->priv->recents_action_group, NULL);
+        gtk_ui_manager_insert_action_group (priv->ui_manager, window->priv->recents_action_group, 0);
+        g_object_unref (window->priv->recents_action_group);
+
+        window->priv->recents_handler_id = g_signal_connect (gtk_recent_manager_get_default (),
+                                                             "changed",
+                                                             G_CALLBACK (recent_manager_changed),
+                                                             window);
 
+	update_recent_files_menu (window);
 	hbox = gtk_hbox_new (FALSE, 0);
 
 	priv->sidebar = planner_sidebar_new ();
@@ -1507,6 +1760,52 @@
 	return TRUE;
 }
 
+static void
+_planner_recent_add (const gchar *uri, const gchar *mime)
+{
+        GtkRecentManager *recent_manager;
+        GtkRecentData *recent_data;
+        gchar *fixeduri = NULL;
+        gchar *scratch;
+
+        static gchar *groups[2] = {
+                "planner",
+                NULL
+        };
+
+        recent_manager =  gtk_recent_manager_get_default ();
+
+        recent_data = g_slice_new (GtkRecentData);
+
+        recent_data->display_name = NULL;
+        recent_data->description = NULL;
+        recent_data->mime_type = (gchar *) mime;
+        recent_data->app_name = (gchar *) g_get_application_name ();
+        recent_data->app_exec = g_strjoin (" ", g_get_prgname (), "%u", NULL);
+        recent_data->groups = groups;
+        recent_data->is_private = FALSE;
+
+	/*
+	 * planner has stripped the file: from local uris so
+	 * if there's not scheme turn it back to a proper uri
+	 */
+	scratch = g_uri_parse_scheme (uri);
+	if (!scratch)
+        	uri = fixeduri = g_filename_to_uri (uri, NULL, NULL);
+	g_free (scratch);
+
+        gtk_recent_manager_add_full (recent_manager,
+                                     uri,
+                                     recent_data);
+
+	if (fixeduri)
+		g_free (fixeduri);
+
+        g_free (recent_data->app_exec);
+
+        g_slice_free (GtkRecentData, recent_data);
+}
+
 static gboolean
 window_do_save_as (PlannerWindow *window)
 {
@@ -1515,7 +1814,6 @@
 	gint              response;
 	gchar            *filename = NULL;
 	gchar            *last_dir;
-	EggRecentItem    *item;
 
 	priv = window->priv;
 
@@ -1583,10 +1881,7 @@
 
 		if (success) {
 			/* Add the file to the recent list */
-			item = egg_recent_item_new_from_uri (mrp_project_get_uri (priv->project));
-			egg_recent_item_set_mime_type (item, "application/x-planner");
-			egg_recent_model_add_full (planner_application_get_recent_model (priv->application), item);
-			egg_recent_item_unref (item);
+			_planner_recent_add(mrp_project_get_uri (priv->project), "application/x-planner");
 		} else {
 			GtkWidget *dialog;
 			
@@ -1686,7 +1981,6 @@
 	PlannerWindowPriv *priv;
 	GError           *error = NULL;
 	GtkWidget        *dialog;
-	EggRecentItem    *item;
 	
 	g_return_val_if_fail (PLANNER_IS_WINDOW (window), FALSE);
 	g_return_val_if_fail (uri != NULL, FALSE);
@@ -1710,11 +2004,7 @@
 
 	if (!internal) {
 		/* Add the file to the recent list */
-		item = egg_recent_item_new_from_uri (uri);
-		egg_recent_item_set_mime_type (item, "application/x-planner");
-		egg_recent_model_add_full (planner_application_get_recent_model (priv->application), item);
-		egg_recent_item_unref (item);
-		
+		_planner_recent_add(uri, "application/x-planner");
 		window_update_title (window);
 	}
 	
@@ -1943,25 +2233,6 @@
 	}
 }
 
-static gchar *
-window_recent_tooltip_func (EggRecentItem *item,
-			    gpointer user_data)
-{
-	gchar *uri;
-	gchar *escaped;
-	gchar *tooltip;
-
-	uri = egg_recent_item_get_uri_for_display (item);
-
-	escaped = egg_recent_util_escape_underlines (uri);
-	tooltip = g_strdup_printf (_("Open '%s'"), escaped);
-
-	g_free (uri);
-	g_free (escaped);
-
-	return tooltip;
-}
-
 PlannerCmdManager *
 planner_window_get_cmd_manager (PlannerWindow *window)
 {

planner-gnome596173-xdg.patch:
 planner-msp-plugin.c         |    2 -
 planner-print-dialog.c       |   30 ++++++++++++++++++++++++++--
 planner-python-plugin.c      |   45 ++++++++++++++++++++++++++-----------------
 planner-window.c             |    2 -
 planner-xml-planner-plugin.c |    2 -
 5 files changed, 59 insertions(+), 22 deletions(-)

--- NEW FILE planner-gnome596173-xdg.patch ---
diff -ru planner-0.14.4.orig/src/planner-msp-plugin.c planner-0.14.4/src/planner-msp-plugin.c
--- planner-0.14.4.orig/src/planner-msp-plugin.c	2009-09-24 11:12:52.000000000 +0100
+++ planner-0.14.4/src/planner-msp-plugin.c	2009-09-24 11:19:20.000000000 +0100
@@ -178,7 +178,7 @@
 	
 	dir = planner_conf_get_string (CONF_MSP_PLUGIN_LAST_DIR, NULL);
 	if (dir == NULL) {
-		dir = g_strdup (g_get_home_dir ());
+		dir = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS));
 	}
 	
 	return dir;
diff -ru planner-0.14.4.orig/src/planner-print-dialog.c planner-0.14.4/src/planner-print-dialog.c
--- planner-0.14.4.orig/src/planner-print-dialog.c	2009-09-24 11:12:52.000000000 +0100
+++ planner-0.14.4/src/planner-print-dialog.c	2009-09-24 11:13:10.000000000 +0100
@@ -43,7 +43,7 @@
 {
 	char *dir;
 	
-	dir = g_build_filename (g_get_home_dir (), ".gnome2", NULL);
+	dir = g_build_filename (g_get_user_config_dir (), NULL);
 	
 	if (!g_file_test (dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
 		if (g_mkdir (dir, 0755) != 0) {
@@ -54,7 +54,7 @@
 	
 	g_free (dir);
 	
-	dir = g_build_filename (g_get_home_dir (), ".gnome2", "planner", NULL);
+	dir = g_build_filename (g_get_user_config_dir (), "planner", NULL);
 	
 	if (!g_file_test (dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
 		if (g_mkdir (dir, 0755) != 0) {
@@ -75,6 +75,19 @@
 		return NULL;
 	}
 	
+	return g_build_filename (g_get_user_config_dir (),
+				 "planner",
+				 PLANNER_PRINT_CONFIG_FILE,
+				 NULL);
+}
+
+static gchar *
+get_old_config_filename (void)
+{
+	if (!ensure_dir ()) {
+		return NULL;
+	}
+	
 	return g_build_filename (g_get_home_dir (),
 				 ".gnome2", "planner",
 				 PLANNER_PRINT_CONFIG_FILE,
@@ -171,8 +184,21 @@
 						     filename,
 						     G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS,
 						     NULL);
+
 		g_free (filename);
 
+		/*try the older config dir if the new one didn't exist*/
+		if (!success) {
+			filename = get_old_config_filename ();
+			if(filename) {
+				success = g_key_file_load_from_file (key_file,
+						     filename,
+						     G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS,
+						     NULL);
+				g_free (filename);
+			}
+		}
+
 		if (success) {
 			settings = gtk_print_settings_new_from_key_file (key_file, NULL, NULL);
 		}
diff -ru planner-0.14.4.orig/src/planner-python-plugin.c planner-0.14.4/src/planner-python-plugin.c
--- planner-0.14.4.orig/src/planner-python-plugin.c	2009-09-24 11:12:52.000000000 +0100
+++ planner-0.14.4/src/planner-python-plugin.c	2009-09-24 11:31:06.000000000 +0100
@@ -127,27 +127,14 @@
 	}
 }
 
-G_MODULE_EXPORT void 
-plugin_init (PlannerPlugin *plugin, PlannerWindow *main_window)
+static void
+plugin_execute_scripts(const gchar *dirname)
 {
-	PlannerPluginPriv *priv;
 	GDir              *dir;
-	gchar             *dirname, *full_filename;
+	gchar             *full_filename;
 	const gchar       *filename;
-	
-	priv = g_new0 (PlannerPluginPriv, 1);
-	plugin->priv = priv;
-
-	priv->main_window = main_window;
-	priv->scripts = g_hash_table_new (g_str_hash, g_str_equal);
-	
-	Py_Initialize ();
-	
-	/* Look in ~/.gnome2/planner/python/  and run the scripts that we find */
-	dirname = g_build_filename (g_get_home_dir(), ".gnome2", "planner", "python", NULL);
 	dir = g_dir_open (dirname, 0, NULL);
 	if (dir == NULL) {
-		g_free (dirname);
 		return;
 	}
 
@@ -162,11 +149,35 @@
 		filename = g_dir_read_name (dir);
 	}
 	
-	g_free (dirname);
 	g_dir_close (dir);
 }
 
 G_MODULE_EXPORT void 
+plugin_init (PlannerPlugin *plugin, PlannerWindow *main_window)
+{
+	PlannerPluginPriv *priv;
+	gchar             *dirname;
+	
+	priv = g_new0 (PlannerPluginPriv, 1);
+	plugin->priv = priv;
+
+	priv->main_window = main_window;
+	priv->scripts = g_hash_table_new (g_str_hash, g_str_equal);
+	
+	Py_Initialize ();
+
+	/* Look in $XDG_DATA_HOME/planner/python/  and run the scripts that we find */
+	dirname = g_build_filename (g_get_user_data_dir(), "planner", "python", NULL);
+	plugin_execute_scripts(dirname);
+	g_free (dirname);
+
+	/* Look in legacy ~/.gnome2/planner/python/  and run the scripts that we find */
+	dirname = g_build_filename (g_get_home_dir(), ".gnome2", "planner", "python", NULL);
+	plugin_execute_scripts(dirname);
+	g_free (dirname);
+}
+
+G_MODULE_EXPORT void 
 plugin_exit (PlannerPlugin *plugin) 
 {
 	Py_Finalize ();
diff -ru planner-0.14.4.orig/src/planner-window.c planner-0.14.4/src/planner-window.c
--- planner-0.14.4.orig/src/planner-window.c	2009-09-24 11:12:52.000000000 +0100
+++ planner-0.14.4/src/planner-window.c	2009-09-24 11:18:11.000000000 +0100
@@ -1066,7 +1066,7 @@
 	last_dir = planner_conf_get_string (CONF_LAST_DIR, NULL);
 	
 	if (last_dir == NULL) {
-		last_dir = g_strdup (g_get_home_dir ());
+		last_dir = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS));
 	}
 	
 	return last_dir;
diff -ru planner-0.14.4.orig/src/planner-xml-planner-plugin.c planner-0.14.4/src/planner-xml-planner-plugin.c
--- planner-0.14.4.orig/src/planner-xml-planner-plugin.c	2009-09-24 11:12:52.000000000 +0100
+++ planner-0.14.4/src/planner-xml-planner-plugin.c	2009-09-24 11:19:05.000000000 +0100
@@ -63,7 +63,7 @@
 	
 	last_dir = planner_conf_get_string (CONF_MAIN_LAST_XML_EXPORT_DIR, NULL);
 	if (last_dir == NULL) {
-		last_dir = g_strdup (g_get_home_dir ());
+		last_dir = g_strdup (g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS));
 	}
 	
 	return last_dir;


Index: planner.spec
===================================================================
RCS file: /cvs/pkgs/rpms/planner/devel/planner.spec,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -p -r1.64 -r1.65
--- planner.spec	26 Jul 2009 18:52:50 -0000	1.64
+++ planner.spec	24 Sep 2009 11:01:37 -0000	1.65
@@ -1,7 +1,7 @@
 Summary:   A graphical project management tool
 Name:      planner
 Version:   0.14.4
-Release:   2%{?dist}
+Release:   3%{?dist}
 License:   GPLv2+
 Group:     Applications/Productivity
 URL:       http://live.gnome.org/Planner
@@ -18,6 +18,9 @@ Requires:  shared-mime-info
 Requires(post): %{_bindir}/scrollkeeper-update
 Requires(postun): %{_bindir}/scrollkeeper-update
 
+Patch0: planner-gnome596171-recentlyused.patch
+Patch1: planner-gnome596173-xdg.patch
+
 %description
 Planner is a visual project management application which allows users to
 manage several aspects of a project, including schedule tracking using
@@ -46,6 +49,8 @@ This package provides a plugin to integr
 
 %prep
 %setup -q
+%patch0 -p1 -b .recentlyused
+%patch1 -p1 -b .xdg
 
 %build
 %configure --enable-python --disable-gtk-doc --disable-dotnet --disable-update-mimedb --enable-eds --enable-eds-backend --disable-static
@@ -142,6 +147,11 @@ rm -rf $RPM_BUILD_ROOT
 %{_libdir}/pkgconfig/*
 
 %changelog
+* Thu Sep 24 2009 Caolán McNamara <caolanm at redhat.com> - 0.14.4-3
+- Resolves: rhbz#524662 Implement new Gnome XDG Config Folders for planner
+    + gnome#596171 change recently used to use new recently used backend
+    + gnome#XXXXXX split config/data setting into xdg dirs
+
 * Sun Jul 26 2009 Fedora Release Engineering <rel-eng at lists.fedoraproject.org> - 0.14.4-2
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild
 




More information about the scm-commits mailing list