Commit 11888a5b authored by Jim Krehl's avatar Jim Krehl

applied empty.ods patch

svn path=/trunk/; revision=246
parent 0200430e
......@@ -4,6 +4,12 @@
* libslab/app-shell.c:
Applied patch from Larry Ewing to fix some memory leaks, BNC #244456.
* main-menu/etc/empty.ods
* main-menu/etc/Makefile.am
* libslab/bookmark-agent.c:
Applied patch from Larry Ewing to create valid, empty .ods file, BNC
#249188.
2007-03-18 Jim Krehl <jimmyk@novell.com>
* main-menu/src/main-menu-ui.c
* libslab/libslab-utils.c
......
......@@ -56,6 +56,7 @@
#define USER_DOCS_STORE_FILE_NAME "documents.xbel"
#define USER_DIRS_STORE_FILE_NAME "places.xbel"
#define SYSTEM_STORE_FILE_NAME "system-items.xbel"
#define CALC_TEMPLATE_FILE_NAME "empty.ods"
#define GTK_BOOKMARKS_FILE ".gtk-bookmarks"
......@@ -137,6 +138,9 @@ static void weak_destroy_cb (gpointer, GObject *);
static gint recent_item_mru_comp_func (gconstpointer a, gconstpointer b);
#endif
static gchar *find_package_data_file (const gchar *filename);
GType
bookmark_agent_get_type ()
{
......@@ -890,6 +894,27 @@ load_recent_store (BookmarkAgent *this)
}
}
static gchar *
find_package_data_file (const gchar *filename)
{
const gchar * const *dirs = NULL;
gchar *path = NULL;
gint i;
dirs = g_get_system_data_dirs ();
for (i = 0; ! path && dirs && dirs [i]; ++i) {
path = g_build_filename (dirs [i], PACKAGE, filename, NULL);
if (! g_file_test (path, G_FILE_TEST_EXISTS)) {
g_free (path);
path = NULL;
}
}
return path;
}
static void
update_user_spec_path (BookmarkAgent *this)
{
......@@ -900,26 +925,13 @@ update_user_spec_path (BookmarkAgent *this)
BookmarkStoreStatus status;
const gchar * const *dirs = NULL;
gint i;
use_user_path = priv->user_modifiable &&
(priv->needs_sync || g_file_test (priv->user_store_path, G_FILE_TEST_EXISTS));
if (use_user_path)
path = g_strdup (priv->user_store_path);
else {
dirs = g_get_system_data_dirs ();
for (i = 0; ! path && dirs && dirs [i]; ++i) {
path = g_build_filename (dirs [i], PACKAGE, priv->store_filename, NULL);
if (! g_file_test (path, G_FILE_TEST_EXISTS)) {
g_free (path);
path = NULL;
}
}
path = find_package_data_file (priv->store_filename);
}
if (use_user_path)
......@@ -1027,13 +1039,18 @@ create_doc_item (BookmarkAgent *this, const gchar *uri)
gchar *path;
gchar *dir;
gchar *file;
gchar *template = NULL;
gsize length;
gchar *contents;
if (! (strcmp (uri, "BLANK_SPREADSHEET") && strcmp (uri, "BLANK_DOCUMENT"))) {
dir = g_build_filename (g_get_home_dir (), "Documents", NULL);
if (! strcmp (uri, "BLANK_SPREADSHEET"))
if (! strcmp (uri, "BLANK_SPREADSHEET")) {
file = g_strconcat (_("New Spreadsheet"), ".ods", NULL);
template = find_package_data_file (CALC_TEMPLATE_FILE_NAME);
}
else
file = g_strconcat (_("New Document"), ".odt", NULL);
......@@ -1041,7 +1058,16 @@ create_doc_item (BookmarkAgent *this, const gchar *uri)
if (! g_file_test (path, G_FILE_TEST_EXISTS)) {
g_mkdir_with_parents (dir, 0700);
fclose (g_fopen (path, "w"));
if (template != NULL) {
if (g_file_get_contents (template, & contents, & length, NULL))
g_file_set_contents (path, contents, length, NULL);
g_free (contents);
g_free (template);
}
else
fclose (g_fopen (path, "w"));
}
uri_new = g_filename_to_uri (path, NULL, NULL);
......
......@@ -14,7 +14,7 @@ desktop_DATA = gnome-screensaver-lock.desktop gnome-session-kill.desktop
@INTLTOOL_DESKTOP_RULE@
bookmarkdir = $(datadir)/gnome-main-menu
bookmark_DATA = applications.xbel documents.xbel system-items.xbel places.xbel
bookmark_DATA = applications.xbel documents.xbel system-items.xbel places.xbel empty.ods
$(server_DATA).in: $(server_DATA).in.in
sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" $< > $@
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment