Commit a674b545 authored by Jim Krehl's avatar Jim Krehl
Browse files

made default apps path independent.

changed default docs.
fixed nautilus-sendto bug

svn path=/branches/version-2/; revision=191
parent 52ba39ce
......@@ -24,9 +24,11 @@
#include <string.h>
#include <libgnomeui/gnome-icon-lookup.h>
#include <libgnomevfs/gnome-vfs.h>
#include <unistd.h>
#include "slab-gnome-util.h"
#include "gnome-utils.h"
#include "libslab-utils.h"
#define GCONF_SEND_TO_CMD_KEY "/desktop/gnome/applications/main-menu/file-area/file_send_to_cmd"
#define GCONF_ENABLE_DELETE_KEY_DIR "/apps/nautilus/preferences"
......@@ -52,9 +54,10 @@ static void send_to_trigger (Tile *, TileEvent *, TileAction *);
static void rename_entry_activate_cb (GtkEntry *, gpointer);
static gboolean rename_entry_key_release_cb (GtkWidget *, GdkEventKey *, gpointer);
static void gconf_enable_delete_cb (GConfClient *, guint, GConfEntry *, gpointer);
static void disown_spawned_child (gpointer);
typedef struct
{
gchar *basename;
......@@ -581,51 +584,68 @@ delete_trigger (Tile *tile, TileEvent *event, TileAction *action)
static void
send_to_trigger (Tile *tile, TileEvent *event, TileAction *action)
{
gchar *cmd;
gchar **argv;
gchar *cmd;
gint argc;
gchar **argv_parsed = NULL;
gchar **argv = NULL;
gchar *filename;
gchar *path;
gchar *dirname;
gchar *basename;
GError *error = NULL;
gchar *tmp;
gint i;
cmd = (gchar *) get_gconf_value (GCONF_SEND_TO_CMD_KEY);
argv = g_strsplit (cmd, " ", 0);
filename = g_filename_from_uri (TILE (tile)->uri, NULL, NULL);
dirname = g_path_get_dirname (filename);
basename = g_path_get_basename (filename);
if (! g_shell_parse_argv (cmd, & argc, & argv_parsed, NULL))
goto exit;
for (i = 0; argv[i]; ++i)
{
if (strstr (argv[i], "DIRNAME"))
{
tmp = string_replace_once (argv[i], "DIRNAME", dirname);
g_free (argv[i]);
argv[i] = tmp;
}
if (strstr (argv[i], "BASENAME"))
{
tmp = string_replace_once (argv[i], "BASENAME", basename);
g_free (argv[i]);
argv[i] = tmp;
}
}
argv = g_new0 (gchar *, argc + 1);
gdk_spawn_on_screen (gtk_widget_get_screen (GTK_WIDGET (tile)), NULL, argv, NULL,
G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &error);
path = g_filename_from_uri (tile->uri, NULL, NULL);
dirname = g_path_get_dirname (path);
basename = g_path_get_basename (path);
if (error)
handle_g_error (&error, "error in %s", G_STRFUNC);
for (i = 0; i < argc; ++i) {
if (strstr (argv_parsed [i], "DIRNAME"))
argv [i] = string_replace_once (argv_parsed [i], "DIRNAME", dirname);
else if (strstr (argv_parsed [i], "BASENAME"))
argv [i] = string_replace_once (argv_parsed [i], "BASENAME", basename);
else
argv [i] = g_strdup (argv_parsed [i]);
}
g_free (cmd);
g_free (filename);
argv [argc] = NULL;
g_free (path);
g_free (dirname);
g_free (basename);
g_spawn_async (
NULL, argv, NULL, G_SPAWN_SEARCH_PATH,
disown_spawned_child, NULL, NULL, & error);
if (error) {
cmd = g_strjoinv (" ", argv);
libslab_handle_g_error (
& error, "%s: can't execute search [%s]\n", G_STRFUNC, cmd);
g_free (cmd);
}
g_strfreev (argv);
exit:
g_free (cmd);
g_strfreev (argv_parsed);
}
static void
disown_spawned_child (gpointer user_data)
{
setsid ();
setpgrp ();
}
......@@ -839,6 +839,43 @@ libslab_desktop_item_is_a_terminal (const gchar *uri)
return is_terminal;
}
gchar *
libslab_string_replace_once (const gchar *string, const gchar *key, const gchar *value)
{
GString *str_built;
gint pivot;
pivot = strstr (string, key) - string;
str_built = g_string_new_len (string, pivot);
g_string_append (str_built, value);
g_string_append (str_built, & string [pivot + strlen (key)]);
return g_string_free (str_built, FALSE);
}
void
libslab_spawn_command (const gchar *cmd)
{
gchar **argv;
GError *error = NULL;
if (! cmd || strlen (cmd) < 1)
return;
argv = g_strsplit (cmd, " ", -1);
g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, & error);
if (error)
libslab_handle_g_error (& error, "%s: error spawning [%s]", G_STRFUNC, cmd);
g_strfreev (argv);
}
static gboolean
store_has_uri (const gchar *path, const gchar *uri)
{
......
......@@ -81,6 +81,8 @@ guint libslab_gconf_notify_add (const gchar *key, GConfClientNotifyF
void libslab_gconf_notify_remove (guint conn_id);
void libslab_handle_g_error (GError **error, const gchar *msg_format, ...);
gboolean libslab_desktop_item_is_a_terminal (const gchar *uri);
gchar *libslab_string_replace_once (const gchar *string, const gchar *key, const gchar *value);
void libslab_spawn_command (const gchar *cmd);
GList *libslab_get_system_item_uris (void);
GList *libslab_get_user_app_uris (void);
......
......@@ -379,7 +379,7 @@ string_replace_once (const gchar * str_template, const gchar * key, const gchar
}
void
spawn_process (const gchar * command)
spawn_process (const gchar *command)
{
gchar **argv;
GError *error = NULL;
......
......@@ -3,7 +3,7 @@
xmlns:bookmark="http://www.freedesktop.org/standards/desktop-bookmarks"
xmlns:mime="http://www.freedesktop.org/standards/shared-mime-info"
>
<bookmark href="file:///usr/share/applications/MozillaFirefox.desktop" added="2007-01-16T05:51:22Z" modified="2007-01-16T05:51:22Z" visited="2007-01-16T05:51:22Z">
<bookmark href="MozillaFirefox.desktop" added="2007-01-16T05:51:22Z" modified="2007-01-16T05:51:22Z" visited="2007-01-16T05:51:22Z">
<info>
<metadata owner="http://freedesktop.org">
<mime:mime-type type="application/x-desktop"/>
......@@ -13,7 +13,7 @@
</metadata>
</info>
</bookmark>
<bookmark href="file:///opt/gnome/share/applications/evolution.desktop" added="2007-01-16T05:51:22Z" modified="2007-01-16T05:51:22Z" visited="2007-01-16T05:51:22Z">
<bookmark href="evolution.desktop" added="2007-01-16T05:51:22Z" modified="2007-01-16T05:51:22Z" visited="2007-01-16T05:51:22Z">
<info>
<metadata owner="http://freedesktop.org">
<mime:mime-type type="application/x-desktop"/>
......@@ -23,7 +23,7 @@
</metadata>
</info>
</bookmark>
<bookmark href="file:///usr/share/applications/banshee.desktop" added="2007-01-16T05:51:22Z" modified="2007-01-16T05:51:22Z" visited="2007-01-16T05:51:22Z">
<bookmark href="banshee.desktop" added="2007-01-16T05:51:22Z" modified="2007-01-16T05:51:22Z" visited="2007-01-16T05:51:22Z">
<info>
<metadata owner="http://freedesktop.org">
<mime:mime-type type="application/x-desktop"/>
......@@ -33,7 +33,7 @@
</metadata>
</info>
</bookmark>
<bookmark href="file:///usr/share/applications/writer.desktop" added="2007-01-16T05:51:22Z" modified="2007-01-16T05:51:22Z" visited="2007-01-16T05:51:22Z">
<bookmark href="writer.desktop" added="2007-01-16T05:51:22Z" modified="2007-01-16T05:51:22Z" visited="2007-01-16T05:51:22Z">
<info>
<metadata owner="http://freedesktop.org">
<mime:mime-type type="application/x-desktop"/>
......@@ -43,7 +43,7 @@
</metadata>
</info>
</bookmark>
<bookmark href="file:///usr/share/applications/f-spot.desktop" added="2007-01-16T05:51:22Z" modified="2007-01-16T05:51:22Z" visited="2007-01-16T05:51:22Z">
<bookmark href="f-spot.desktop" added="2007-01-16T05:51:22Z" modified="2007-01-16T05:51:22Z" visited="2007-01-16T05:51:22Z">
<info>
<metadata owner="http://freedesktop.org">
<mime:mime-type type="application/x-desktop"/>
......@@ -53,7 +53,7 @@
</metadata>
</info>
</bookmark>
<bookmark href="file:///opt/gnome/share/applications/nautilus.desktop" added="2007-01-16T05:51:22Z" modified="2007-01-16T05:51:22Z" visited="2007-01-16T05:51:22Z">
<bookmark href="nautilus.desktop" added="2007-01-16T05:51:22Z" modified="2007-01-16T05:51:22Z" visited="2007-01-16T05:51:22Z">
<info>
<metadata owner="http://freedesktop.org">
<mime:mime-type type="application/x-desktop"/>
......
......@@ -3,12 +3,22 @@
xmlns:bookmark="http://www.freedesktop.org/standards/desktop-bookmarks"
xmlns:mime="http://www.freedesktop.org/standards/shared-mime-info"
>
<bookmark href="file:///usr/share/doc/packages/gnome-main-menu/README" added="2007-01-25T18:40:32Z" modified="2007-01-25T18:40:32Z" visited="2007-01-25T18:40:32Z">
<bookmark href="BLANK_SPREADSHEET" added="2007-01-25T18:40:32Z" modified="2007-01-25T18:40:32Z" visited="2007-01-25T18:40:32Z">
<info>
<metadata owner="http://freedesktop.org">
<mime:mime-type type="application/x-desktop"/>
<mime:mime-type type="application/vnd.oasis.opendocument.spreadsheet"/>
<bookmark:applications>
<bookmark:application name="gedit" exec="gedit file:///usr/share/doc/packages/gnome-main-menu/README" timestamp="1169750432" count="1"/>
<bookmark:application name="OpenOffice.org Calc" exec="oocalc %U" timestamp="1171584528" count="1"/>
</bookmark:applications>
</metadata>
</info>
</bookmark>
<bookmark href="BLANK_DOCUMENT" added="2007-01-25T18:40:32Z" modified="2007-01-25T18:40:32Z" visited="2007-01-25T18:40:32Z">
<info>
<metadata owner="http://freedesktop.org">
<mime:mime-type type="application/vnd.oasis.opendocument.text"/>
<bookmark:applications>
<bookmark:application name="OpenOffice.org Writer" exec="oowriter %U" timestamp="1171584528" count="1"/>
</bookmark:applications>
</metadata>
</info>
......
......@@ -429,44 +429,6 @@ exit:
g_free (bookmark_path);
}
void
migrate_user_docs_to_user_bookmark_file ()
{
gchar *bookmark_path;
gchar *bookmark_path_cp_dest;
gchar *contents;
GError *error = NULL;
if (! get_main_menu_user_data_file_path (& bookmark_path, DOCS_BOOKMARK_FILENAME, TRUE)) {
g_free (bookmark_path);
bookmark_path = libslab_get_user_docs_store_path (FALSE);
bookmark_path_cp_dest = libslab_get_user_docs_store_path (TRUE);
g_file_get_contents (bookmark_path, & contents, NULL, & error);
if (error)
libslab_handle_g_error (
& error, "%s: can't read user docs store path [%s]\n",
G_STRFUNC, bookmark_path);
else
g_file_set_contents (bookmark_path_cp_dest, contents, -1, & error);
if (error)
libslab_handle_g_error (
& error, "%s: can't save user docs store path [%s]\n",
G_STRFUNC, bookmark_path_cp_dest);
g_free (contents);
g_free (bookmark_path_cp_dest);
}
g_free (bookmark_path);
}
void
migrate_user_dirs_to_user_bookmark_file ()
{
......
......@@ -27,7 +27,6 @@ G_BEGIN_DECLS
void migrate_system_gconf_to_bookmark_file (void);
void migrate_user_apps_gconf_to_bookmark_file (void);
void migrate_user_docs_to_user_bookmark_file (void);
void migrate_user_dirs_to_user_bookmark_file (void);
void migrate_showable_file_types (void);
......
......@@ -49,15 +49,17 @@
#include "libslab-utils.h"
#include "double-click-detector.h"
#define CURRENT_PAGE_GCONF_KEY "/desktop/gnome/applications/main-menu/file-area/file_class"
#define URGENT_CLOSE_GCONF_KEY "/desktop/gnome/applications/main-menu/urgent_close"
#define MAX_TOTAL_ITEMS_GCONF_KEY "/desktop/gnome/applications/main-menu/file-area/max_total_items"
#define MIN_RECENT_ITEMS_GCONF_KEY "/desktop/gnome/applications/main-menu/file-area/min_recent_items"
#define APP_BROWSER_GCONF_KEY "/desktop/gnome/applications/main-menu/application_browser"
#define FILE_BROWSER_GCONF_KEY "/desktop/gnome/applications/main-menu/file_browser"
#define SEARCH_CMD_GCONF_KEY "/desktop/gnome/applications/main-menu/search_command"
#define LOCKDOWN_GCONF_DIR "/desktop/gnome/applications/main-menu/lock-down"
#define ROOT_GCONF_DIR "/desktop/gnome/applications/main-menu"
#define CURRENT_PAGE_GCONF_KEY ROOT_GCONF_DIR "/file-area/file_class"
#define URGENT_CLOSE_GCONF_KEY ROOT_GCONF_DIR "/urgent_close"
#define MAX_TOTAL_ITEMS_GCONF_KEY ROOT_GCONF_DIR "/file-area/max_total_items"
#define MIN_RECENT_ITEMS_GCONF_KEY ROOT_GCONF_DIR "/file-area/min_recent_items"
#define APP_BROWSER_GCONF_KEY ROOT_GCONF_DIR "/application_browser"
#define FILE_BROWSER_GCONF_KEY ROOT_GCONF_DIR "/file_browser"
#define SEARCH_CMD_GCONF_KEY ROOT_GCONF_DIR "/search_command"
#define FILE_MGR_OPEN_GCONF_KEY ROOT_GCONF_DIR "/file-area/file_mgr_open_cmd"
#define LOCKDOWN_GCONF_DIR ROOT_GCONF_DIR "/lock-down"
#define MORE_LINK_VIS_GCONF_KEY LOCKDOWN_GCONF_DIR "/application_browser_link_visible"
#define SEARCH_VIS_GCONF_KEY LOCKDOWN_GCONF_DIR "/search_area_visible"
#define STATUS_VIS_GCONF_KEY LOCKDOWN_GCONF_DIR "/status_area_visible"
......@@ -1770,6 +1772,11 @@ more_buttons_clicked_cb (GtkButton *button, gpointer user_data)
GnomeDesktopItem *ditem;
gchar *ditem_id;
gchar *cmd_template;
gchar *cmd;
gchar *dir;
gchar *uri;
detector = DOUBLE_CLICK_DETECTOR (
g_object_get_data (G_OBJECT (button), "double-click-detector"));
......@@ -1781,6 +1788,28 @@ more_buttons_clicked_cb (GtkButton *button, gpointer user_data)
if (! double_click_detector_is_double_click (detector, current_time_millis, TRUE)) {
if (GTK_WIDGET (button) == priv->more_buttons [APPS_PAGE])
ditem_id = libslab_get_gconf_value (APP_BROWSER_GCONF_KEY);
else if (GTK_WIDGET (button) == priv->more_buttons [DOCS_PAGE]) {
dir = g_build_filename (g_get_home_dir (), "Documents", NULL);
if (! g_file_test (dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))
dir = g_strdup (g_get_home_dir ());
uri = g_filename_to_uri (dir, NULL, NULL);
cmd_template = (gchar *) libslab_get_gconf_value (FILE_MGR_OPEN_GCONF_KEY);
cmd = libslab_string_replace_once (cmd_template, "FILE_URI", uri);
libslab_spawn_command (cmd);
g_free (cmd);
g_free (cmd_template);
g_free (uri);
g_free (dir);
ditem_id = NULL;
hide_slab_if_urgent_close (this);
}
else
ditem_id = libslab_get_gconf_value (FILE_BROWSER_GCONF_KEY);
......
......@@ -60,7 +60,6 @@ main_menu_applet_init (PanelApplet *applet, const gchar *iid, gpointer user_data
migrate_system_gconf_to_bookmark_file ();
migrate_user_apps_gconf_to_bookmark_file ();
migrate_user_docs_to_user_bookmark_file ();
migrate_user_dirs_to_user_bookmark_file ();
migrate_showable_file_types ();
......
......@@ -20,6 +20,9 @@
#include "user-docs-tile-table.h"
#include <glib/gi18n.h>
#include <glib/gstdio.h>
#include <string.h>
#include <libgnomevfs/gnome-vfs.h>
#include <libgnomevfs/gnome-vfs-mime-handlers.h>
......@@ -119,7 +122,7 @@ update_store (LibSlabBookmarkFile *bm_file_old, LibSlabBookmarkFile *bm_file_new
gnome_vfs_mime_application_free (default_app);
}
gnome_vfs_file_info_unref (info);
gnome_vfs_file_info_unref (info);
}
if (! (mime_type && apps && apps [0]))
......@@ -143,36 +146,66 @@ get_document_tile (LibSlabBookmarkFile *bm_file, const gchar *uri)
gchar *mime_type = NULL;
time_t modified = 0;
GnomeVFSFileInfo info;
gchar *dir;
gchar *file;
gchar *path;
gchar *uri_new;
GnomeVFSFileInfo *info;
GtkWidget *tile;
if (! strcmp (uri, "BLANK_SPREADSHEET") || ! strcmp (uri, "BLANK_DOCUMENT")) {
dir = g_build_filename (g_get_home_dir (), "Documents", NULL);
g_mkdir_with_parents (dir, 0700);
if (! strcmp (uri, "BLANK_SPREADSHEET"))
file = g_strconcat (_("New Spreadsheet"), ".ods", NULL);
else
file = g_strconcat (_("New Document"), ".odt", NULL);
path = g_build_filename (dir, file, NULL);
if (! g_file_test (path, G_FILE_TEST_EXISTS))
fclose (g_fopen (path, "w"));
uri_new = g_filename_to_uri (path, NULL, NULL);
g_free (dir);
g_free (file);
g_free (path);
}
else
uri_new = g_strdup (uri);
if (bm_file) {
mime_type = libslab_bookmark_file_get_mime_type (bm_file, uri, NULL);
modified = libslab_bookmark_file_get_modified (bm_file, uri, NULL);
mime_type = libslab_bookmark_file_get_mime_type (bm_file, uri_new, NULL);
modified = libslab_bookmark_file_get_modified (bm_file, uri_new, NULL);
}
if (! mime_type) {
info = gnome_vfs_file_info_new ();
gnome_vfs_get_file_info (
uri, & info,
uri_new, info,
GNOME_VFS_FILE_INFO_GET_MIME_TYPE | GNOME_VFS_FILE_INFO_FORCE_FAST_MIME_TYPE);
mime_type = g_strdup (info.mime_type);
modified = info.mtime;
mime_type = g_strdup (info->mime_type);
modified = info->mtime;
gnome_vfs_file_info_clear (& info);
gnome_vfs_file_info_clear (info);
}
if (! mime_type) {
g_warning ("Cannot make document tile [%s]\n", uri);
g_warning ("Cannot make document tile [%s]\n", uri_new);
tile = NULL;
}
else
tile = document_tile_new (uri, mime_type, modified);
tile = document_tile_new (uri_new, mime_type, modified);
g_free (mime_type);
g_free (uri_new);
return tile;
}
Supports Markdown
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