diff options
author | Christopher James Lahey <clahey@ximian.com> | 2004-01-23 03:23:06 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2004-01-23 03:23:06 +0800 |
commit | 8205e18cb651de99de58b7ea5779bc3fbaea69b5 (patch) | |
tree | 175904ff2446561fcbf509e06f977c1510802569 | |
parent | 416aef90dd0cc909929d6a7357107158cdf138f5 (diff) | |
download | gsoc2013-epiphany-8205e18cb651de99de58b7ea5779bc3fbaea69b5.tar gsoc2013-epiphany-8205e18cb651de99de58b7ea5779bc3fbaea69b5.tar.gz gsoc2013-epiphany-8205e18cb651de99de58b7ea5779bc3fbaea69b5.tar.bz2 gsoc2013-epiphany-8205e18cb651de99de58b7ea5779bc3fbaea69b5.tar.lz gsoc2013-epiphany-8205e18cb651de99de58b7ea5779bc3fbaea69b5.tar.xz gsoc2013-epiphany-8205e18cb651de99de58b7ea5779bc3fbaea69b5.tar.zst gsoc2013-epiphany-8205e18cb651de99de58b7ea5779bc3fbaea69b5.zip |
New function to get temp directory and moved ephy_shell_delete_on_exit to
2004-01-22 Christopher James Lahey <clahey@ximian.com>
* lib/ephy-file-helpers.c, lib/ephy-file-helpers.h
(ephy_file_tmp_directory, ephy_file_delete_on_exit): New function
to get temp directory and moved ephy_shell_delete_on_exit to here.
* lib/widgets/ephy-location-entry.c: Changed how this goes about
showing itself when hidden and activated.
* src/ephy-shell.c, src/ephy-shell.h (ephy_shell_delete_on_exit):
Moved to ephy_file_delete_on_exit.
* src/window-commands.c: Changed ephy_shell_delete_on_exit to
ephy_file_delete_on_exit. Used ephy_file_tmp_directory to save
source files for viewing in a directory that isn't world readable.
-rw-r--r-- | ChangeLog | 16 | ||||
-rw-r--r-- | lib/ephy-file-helpers.c | 50 | ||||
-rw-r--r-- | lib/ephy-file-helpers.h | 7 | ||||
-rw-r--r-- | lib/widgets/ephy-location-entry.c | 31 | ||||
-rw-r--r-- | src/ephy-shell.c | 20 | ||||
-rw-r--r-- | src/ephy-shell.h | 3 | ||||
-rw-r--r-- | src/window-commands.c | 15 |
7 files changed, 98 insertions, 44 deletions
@@ -1,3 +1,19 @@ +2004-01-22 Christopher James Lahey <clahey@ximian.com> + + * lib/ephy-file-helpers.c, lib/ephy-file-helpers.h + (ephy_file_tmp_directory, ephy_file_delete_on_exit): New function + to get temp directory and moved ephy_shell_delete_on_exit to here. + + * lib/widgets/ephy-location-entry.c: Changed how this goes about + showing itself when hidden and activated. + + * src/ephy-shell.c, src/ephy-shell.h (ephy_shell_delete_on_exit): + Moved to ephy_file_delete_on_exit. + + * src/window-commands.c: Changed ephy_shell_delete_on_exit to + ephy_file_delete_on_exit. Used ephy_file_tmp_directory to save + source files for viewing in a directory that isn't world readable. + 2004-01-22 Marco Pesenti Gritti <marco@gnome.org> * data/epiphany-lockdown.schemas.in: diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c index 1161f6ac7..db988a2e3 100644 --- a/lib/ephy-file-helpers.c +++ b/lib/ephy-file-helpers.c @@ -35,6 +35,29 @@ static GHashTable *files = NULL; static char *dot_dir = NULL; +static char *tmp_dir = NULL; +static GList *del_on_exit = NULL; + +char * +ephy_file_tmp_directory (void) +{ + if (tmp_dir == NULL) + { + char *partial_name; + char *full_name; + + partial_name = g_strconcat ("epiphany-", g_get_user_name (), "-XXXXXX", NULL); + full_name = g_build_filename (g_get_tmp_dir (), partial_name, NULL); + tmp_dir = mkdtemp (full_name); + g_free(partial_name); + if (tmp_dir == NULL) + { + g_free (full_name); + } + } + + return tmp_dir; +} char * ephy_file_tmp_filename (const char *base, @@ -128,12 +151,32 @@ ephy_file_helpers_init (void) (GDestroyNotify) g_free); } +static void +delete_files (GList *l) +{ + for (; l != NULL; l = l->next) + { + unlink (l->data); + } +} + void ephy_file_helpers_shutdown (void) { g_hash_table_destroy (files); + del_on_exit = g_list_reverse (del_on_exit); + delete_files (del_on_exit); + g_list_foreach (del_on_exit, (GFunc)g_free, NULL); + g_list_free (del_on_exit); + del_on_exit = NULL; + + rmdir (tmp_dir); + g_free (tmp_dir); + tmp_dir = NULL; + g_free (dot_dir); + dot_dir = NULL; } void @@ -237,3 +280,10 @@ failed: return retval; } + +void +ephy_file_delete_on_exit (const char *path) +{ + del_on_exit = g_list_prepend (del_on_exit, + g_strdup (path)); +} diff --git a/lib/ephy-file-helpers.h b/lib/ephy-file-helpers.h index 15fa16656..3366af330 100644 --- a/lib/ephy-file-helpers.h +++ b/lib/ephy-file-helpers.h @@ -34,18 +34,21 @@ void ephy_file_helpers_init (void); void ephy_file_helpers_shutdown (void); +char *ephy_file_tmp_directory (void); char *ephy_file_tmp_filename (const char *base, const char *extension); void ephy_ensure_dir_exists (const char *dir); GSList *ephy_file_find (const char *path, - const char *fname, - gint maxdepth); + const char *fname, + gint maxdepth); gboolean ephy_file_switch_temp_file (const char *filename, const char *filename_temp); +void ephy_file_delete_on_exit (const char *path); + G_END_DECLS #endif /* EPHY_FILE_HELPERS_H */ diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c index b991c6065..8d0a95bf1 100644 --- a/lib/widgets/ephy-location-entry.c +++ b/lib/widgets/ephy-location-entry.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * Copyright (C) 2002 Ricardo Fernández Pascual * Copyright (C) 2003 Marco Pesenti Gritti @@ -40,7 +41,7 @@ struct _EphyLocationEntryPrivate GtkWidget *entry; char *before_completion; gboolean user_changed; - gboolean activation_mode; + GtkWidget *shown_widget; guint text_col; guint action_col; @@ -153,15 +154,10 @@ ephy_location_entry_class_init (EphyLocationEntryClass *klass) static void ephy_location_entry_activation_finished (EphyLocationEntry *entry) { - if (entry->priv->activation_mode) + if (entry->priv->shown_widget) { - GtkWidget *toolbar; - - entry->priv->activation_mode = FALSE; - - toolbar = gtk_widget_get_ancestor (GTK_WIDGET (entry), - GTK_TYPE_TOOLBAR); - gtk_widget_hide (toolbar); + gtk_widget_hide (entry->priv->shown_widget); + entry->priv->shown_widget = NULL; } } @@ -309,7 +305,7 @@ ephy_location_entry_init (EphyLocationEntry *le) le->priv = p; p->user_changed = TRUE; - p->activation_mode = FALSE; + p->shown_widget = NULL; ephy_location_entry_construct_contents (le); @@ -407,15 +403,16 @@ ephy_location_entry_get_location (EphyLocationEntry *le) void ephy_location_entry_activate (EphyLocationEntry *le) { - GtkWidget *toplevel, *toolbar; - - toolbar = gtk_widget_get_ancestor (GTK_WIDGET (le), GTK_TYPE_TOOLBAR); + GtkWidget *toplevel, *widget; - if (!GTK_WIDGET_VISIBLE (toolbar)) + for (widget = GTK_WIDGET (le); widget != NULL; widget = widget->parent) { - le->priv->activation_mode = TRUE; - - gtk_widget_show (toolbar); + if (!GTK_WIDGET_VISIBLE (widget)) + { + le->priv->shown_widget = widget; + gtk_widget_show (le->priv->shown_widget); + break; + } } toplevel = gtk_widget_get_toplevel (le->priv->entry); diff --git a/src/ephy-shell.c b/src/ephy-shell.c index 47b51f7c8..8d65f60cb 100644 --- a/src/ephy-shell.c +++ b/src/ephy-shell.c @@ -432,15 +432,6 @@ ephy_shell_startup (EphyShell *shell, } static void -delete_files (GList *l) -{ - for (; l != NULL; l = l->next) - { - unlink (l->data); - } -} - -static void ephy_shell_finalize (GObject *object) { EphyShell *shell = EPHY_SHELL (object); @@ -456,10 +447,6 @@ ephy_shell_finalize (GObject *object) LOG ("Unref extension manager") g_object_unref (shell->priv->extensions_manager); - delete_files (shell->priv->del_on_exit); - g_list_foreach (shell->priv->del_on_exit, (GFunc)g_free, NULL); - g_list_free (shell->priv->del_on_exit); - LOG ("Unref toolbars model") if (shell->priv->toolbars_model) { @@ -836,10 +823,3 @@ ephy_shell_get_print_setup_dialog (EphyShell *shell) return shell->priv->print_setup_dialog; } - -void -ephy_shell_delete_on_exit (EphyShell *shell, const char *path) -{ - shell->priv->del_on_exit = g_list_append (shell->priv->del_on_exit, - g_strdup (path)); -} diff --git a/src/ephy-shell.h b/src/ephy-shell.h index a93d318c7..1c5e07a05 100644 --- a/src/ephy-shell.h +++ b/src/ephy-shell.h @@ -136,9 +136,6 @@ GObject *ephy_shell_get_prefs_dialog (EphyShell *shell); GObject *ephy_shell_get_print_setup_dialog (EphyShell *shell); -void ephy_shell_delete_on_exit (EphyShell *shell, - const char *path); - G_END_DECLS #endif diff --git a/src/window-commands.c b/src/window-commands.c index bb98bf12e..6c1191baf 100644 --- a/src/window-commands.c +++ b/src/window-commands.c @@ -689,7 +689,7 @@ save_source_completed_cb (EphyEmbedPersist *persist) dest = ephy_embed_persist_get_dest (persist); g_return_if_fail (dest != NULL); - ephy_shell_delete_on_exit (ephy_shell, dest); + ephy_file_delete_on_exit (dest); editor_open_uri (dest); } @@ -737,9 +737,20 @@ save_temp_source (EphyEmbed *embed) char *tmp, *base; EphyEmbedPersist *persist; - base = g_build_filename (g_get_tmp_dir (), "viewsourceXXXXXX", NULL); + char *static_temp_dir; + + static_temp_dir = ephy_file_tmp_directory (); + if (static_temp_dir == NULL) + { + return; + } + base = g_build_filename (static_temp_dir, "viewsourceXXXXXX", NULL); tmp = ephy_file_tmp_filename (base, "html"); g_free (base); + if (tmp == NULL) + { + return; + } persist = EPHY_EMBED_PERSIST (ephy_embed_factory_new_object ("EphyEmbedPersist")); |