aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2005-02-27 06:01:48 +0800
committerChristian Persch <chpe@src.gnome.org>2005-02-27 06:01:48 +0800
commitfbf4b15ed54be3abfe2c3c937c50b9c623804cb5 (patch)
tree27639ff5895028fd04bcc8c4ce800354b040fa73 /src
parentcaba7f03132e463c48405eb602a8b77764c3ec75 (diff)
downloadgsoc2013-epiphany-fbf4b15ed54be3abfe2c3c937c50b9c623804cb5.tar
gsoc2013-epiphany-fbf4b15ed54be3abfe2c3c937c50b9c623804cb5.tar.gz
gsoc2013-epiphany-fbf4b15ed54be3abfe2c3c937c50b9c623804cb5.tar.bz2
gsoc2013-epiphany-fbf4b15ed54be3abfe2c3c937c50b9c623804cb5.tar.lz
gsoc2013-epiphany-fbf4b15ed54be3abfe2c3c937c50b9c623804cb5.tar.xz
gsoc2013-epiphany-fbf4b15ed54be3abfe2c3c937c50b9c623804cb5.tar.zst
gsoc2013-epiphany-fbf4b15ed54be3abfe2c3c937c50b9c623804cb5.zip
Depend on gnome-desktop for gnome-desktop-item, and up the gnome-vfs
2005-02-26 Christian Persch <chpe@cvs.gnome.org> * configure.ac: Depend on gnome-desktop for gnome-desktop-item, and up the gnome-vfs dependency version. * embed/ephy-embed-persist.c: (ephy_embed_persist_set_user_time), (ephy_embed_persist_get_user_time), (ephy_embed_persist_set_property), (ephy_embed_persist_get_property), (ephy_embed_persist_init), (ephy_embed_persist_class_init): * embed/ephy-embed-persist.h: Add user time property. * embed/mozilla/ContentHandler.cpp: * embed/mozilla/ContentHandler.h: Forward user time to MozDownload via a string. Not perfect, but better than nothing. * embed/mozilla/EphyHeaderSniffer.cpp: Set user time on filechooser. * embed/mozilla/MozDownload.cpp: Get user time from content handler, and use it when launching the external handler app. * lib/ephy-file-helpers.c: (ephy_file_check_mime), (launch_desktop_item), (ephy_file_launch_desktop_file), (ephy_file_launch_application), (ephy_file_launch_handler): * lib/ephy-file-helpers.h: Convenience functions to launch an app, or a desktop item, with user time. * lib/ephy-gui.c: (ephy_gui_confirm_overwrite_file), (ephy_gui_window_update_user_time), (ephy_gui_window_present): * lib/ephy-gui.h: Make our own gtk_window_present, to correctly update user time. Check if the path is writable in ephy_gui_confirm_overwrite_file(). * src/ephy-session.c: (ephy_session_autoresume): After showing the recovery dialogue, don't use the old user time to launch the windows; use the current event time instead. * src/popup-commands.c: (background_download_completed), (image_open_uri), (save_source_completed_cb), (popup_cmd_open_image): * src/window-commands.c: (window_cmd_file_save_as), (save_source_completed_cb), (save_temp_source), (window_cmd_view_page_source): Launch handlers with user time.
Diffstat (limited to 'src')
-rw-r--r--src/ephy-session.c4
-rw-r--r--src/popup-commands.c72
-rw-r--r--src/window-commands.c46
3 files changed, 36 insertions, 86 deletions
diff --git a/src/ephy-session.c b/src/ephy-session.c
index 4dbdb4f18..68e448504 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -444,7 +444,7 @@ ephy_session_autoresume (EphySession *session,
{
ephy_gui_window_update_user_time (session->priv->resume_dialog,
user_time);
- gtk_window_present (GTK_WINDOW (priv->resume_dialog));
+ ephy_gui_window_present (GTK_WINDOW (priv->resume_dialog), user_time);
return TRUE;
}
@@ -455,7 +455,7 @@ ephy_session_autoresume (EphySession *session,
{
session->priv->dont_save = TRUE;
retval = ephy_session_load (session, saved_session,
- user_time);
+ 0 /* since we've shown the dialogue */);
session->priv->dont_save = FALSE;
ephy_session_save (session, SESSION_CRASHED);
}
diff --git a/src/popup-commands.c b/src/popup-commands.c
index 4fa7457e0..16cdd8129 100644
--- a/src/popup-commands.c
+++ b/src/popup-commands.c
@@ -32,6 +32,7 @@
#include <string.h>
#include <glib/gi18n.h>
#include <gtk/gtkclipboard.h>
+#include <gtk/gtkmain.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include <libgnomevfs/gnome-vfs-file-info.h>
#include <libgnomevfs/gnome-vfs-ops.h>
@@ -266,11 +267,13 @@ popup_cmd_save_image_as (GtkAction *action,
#define GNOME_BACKGROUND_PREFERENCES "gnome-background-properties"
static void
-background_download_completed (EphyEmbedPersist *persist,
- gpointer data)
+background_download_completed (EphyEmbedPersist *persist)
{
const char *bg;
- char *type, *path;
+ char *type;
+ guint32 user_time;
+
+ user_time = ephy_embed_persist_get_user_time (persist);
bg = ephy_embed_persist_get_dest (persist);
eel_gconf_set_string (CONF_DESKTOP_BG_PICTURE, bg);
@@ -285,12 +288,7 @@ background_download_completed (EphyEmbedPersist *persist,
g_object_unref (persist);
/* open the "Background Properties" capplet */
- path = g_find_program_in_path (GNOME_BACKGROUND_PREFERENCES);
- if (path != NULL)
- {
- g_spawn_command_line_async (path, NULL);
- g_free (path);
- }
+ ephy_file_launch_desktop_file ("background.desktop", user_time);
}
void
@@ -375,63 +373,34 @@ popup_cmd_open_frame (GtkAction *action,
static void
image_open_uri (const char *address,
- gboolean delete)
+ gboolean delete,
+ guint32 user_time)
{
- GList *uris = NULL;
- char *canonical;
- GnomeVFSMimeApplication *app = NULL;
- GnomeVFSFileInfo *info;
-
- canonical = gnome_vfs_make_uri_canonical (address);
-
- info = gnome_vfs_file_info_new ();
- if (gnome_vfs_get_file_info (canonical, info,
- GNOME_VFS_FILE_INFO_GET_MIME_TYPE |
- GNOME_VFS_FILE_INFO_FORCE_SLOW_MIME_TYPE) == GNOME_VFS_OK &&
- (info->valid_fields & GNOME_VFS_FILE_INFO_FIELDS_MIME_TYPE) &&
- info->mime_type != NULL &&
- info->mime_type[0] != '\0' &&
- ephy_file_check_mime (info->mime_type) == EPHY_MIME_PERMISSION_SAFE)
- {
- app = gnome_vfs_mime_get_default_application (info->mime_type);
- }
+ gboolean success;
- if (app != NULL)
+ success = ephy_file_launch_handler (NULL, address, user_time);
+
+ if (delete && success)
{
- /* FIXME rename tmp file to right extension ? */
- uris = g_list_append (uris, canonical);
- gnome_vfs_mime_application_launch (app, uris);
- gnome_vfs_mime_application_free (app);
- g_list_free (uris);
- if (delete)
- {
- ephy_file_delete_on_exit (address);
- }
+ ephy_file_delete_on_exit (address);
}
- else
+ else if (delete)
{
- /* FIXME We should really warn the user here */
-
- g_warning ("Cannot find an application to open %s with.", address);
- if (delete)
- {
- gnome_vfs_unlink (address);
- }
+ gnome_vfs_unlink (address);
}
-
- g_free (canonical);
- gnome_vfs_file_info_unref (info);
}
static void
save_source_completed_cb (EphyEmbedPersist *persist)
{
const char *dest;
+ guint32 user_time;
+ user_time = ephy_embed_persist_get_user_time (persist);
dest = ephy_embed_persist_get_dest (persist);
g_return_if_fail (dest != NULL);
- image_open_uri (dest, TRUE);
+ image_open_uri (dest, TRUE, user_time);
}
static void
@@ -492,7 +461,8 @@ popup_cmd_open_image (GtkAction *action,
if (strcmp (scheme, "file") == 0)
{
- image_open_uri (address, FALSE);
+ image_open_uri (address, FALSE,
+ gtk_get_current_event_time ());
}
else
{
diff --git a/src/window-commands.c b/src/window-commands.c
index 48479061e..43dc10630 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -57,6 +57,8 @@
#include <gtk/gtkicontheme.h>
#include <gtk/gtktoggleaction.h>
#include <glib/gi18n.h>
+#include <libgnomeui/gnome-icon-theme.h>
+#include <libgnome/gnome-desktop-item.h>
void
window_cmd_edit_find (GtkAction *action,
@@ -394,6 +396,7 @@ window_cmd_file_save_as (GtkAction *action,
ephy_embed_persist_set_embed (persist, embed);
ephy_embed_persist_set_fc_title (persist, _("Save As"));
ephy_embed_persist_set_fc_parent (persist,GTK_WINDOW (window));
+
ephy_embed_persist_set_flags
(persist, EPHY_EMBED_PERSIST_MAINDOC | EPHY_EMBED_PERSIST_ASK_DESTINATION);
ephy_embed_persist_set_persist_key
@@ -404,7 +407,6 @@ window_cmd_file_save_as (GtkAction *action,
g_object_unref (G_OBJECT(persist));
}
-
void
window_cmd_file_work_offline (GtkAction *action,
EphyWindow *window)
@@ -619,48 +621,23 @@ window_cmd_view_zoom_normal (GtkAction *action,
}
static void
-editor_open_uri (const char *address)
-{
- GList *uris = NULL;
- char *canonical;
- GnomeVFSMimeApplication *app;
-
- canonical = gnome_vfs_make_uri_canonical (address);
-
- uris = g_list_append (uris, canonical);
-
- app = gnome_vfs_mime_get_default_application ("text/plain");
- if (app)
- {
- gnome_vfs_mime_application_launch (app, uris);
- gnome_vfs_mime_application_free (app);
- }
- else
- {
- /* FIXME We should really warn the user here */
-
- g_warning ("Cannot find a text editor.");
- }
-
- g_free (canonical);
- g_list_free (uris);
-}
-
-static void
save_source_completed_cb (EphyEmbedPersist *persist)
{
const char *dest;
+ guint32 user_time;
+ user_time = ephy_embed_persist_get_user_time (persist);
dest = ephy_embed_persist_get_dest (persist);
g_return_if_fail (dest != NULL);
ephy_file_delete_on_exit (dest);
- editor_open_uri (dest);
+ ephy_file_launch_handler ("text/plain", dest, user_time);
}
static void
-save_temp_source (EphyEmbed *embed)
+save_temp_source (EphyEmbed *embed,
+ guint32 user_time)
{
char *tmp, *base;
EphyEmbedPersist *persist;
@@ -687,6 +664,7 @@ save_temp_source (EphyEmbed *embed)
ephy_embed_persist_set_flags (persist, EPHY_EMBED_PERSIST_COPY_PAGE |
EPHY_EMBED_PERSIST_NO_VIEW);
ephy_embed_persist_set_dest (persist, tmp);
+ ephy_embed_persist_set_user_time (persist, user_time);
g_signal_connect (persist, "completed",
G_CALLBACK (save_source_completed_cb), NULL);
@@ -704,20 +682,22 @@ window_cmd_view_page_source (GtkAction *action,
EphyEmbed *embed;
char *address;
char *scheme;
+ guint32 user_time;
embed = ephy_window_get_active_embed (window);
g_return_if_fail (embed != NULL);
address = ephy_embed_get_location (embed, TRUE);
scheme = gnome_vfs_get_uri_scheme (address);
+ user_time = gtk_get_current_event_time ();
if (strcmp (scheme, "file") == 0)
{
- editor_open_uri (address);
+ ephy_file_launch_handler ("text/plain", address, user_time);
}
else
{
- save_temp_source (embed);
+ save_temp_source (embed, user_time);
}
g_free (scheme);