summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog94
-rw-r--r--components/adapter/nautilus-adapter-control-embed-strategy.c9
-rw-r--r--components/adapter/nautilus-adapter-control-factory-embed-strategy.c12
-rw-r--r--components/adapter/nautilus-adapter-embed-strategy.c58
-rw-r--r--components/adapter/nautilus-adapter-embeddable-embed-strategy.c12
-rw-r--r--components/image-viewer/nautilus-image-view.c50
-rw-r--r--components/services/trilobite/utils/.cvsignore5
-rw-r--r--libnautilus-extensions/nautilus-file-operations-progress.c317
-rw-r--r--libnautilus-extensions/nautilus-file-operations-progress.h94
-rw-r--r--libnautilus-extensions/nautilus-file-operations.c91
-rw-r--r--libnautilus-extensions/nautilus-icon-container.c24
-rw-r--r--libnautilus-extensions/nautilus-stock-dialogs.c7
-rw-r--r--libnautilus-extensions/nautilus-volume-monitor.c7
-rw-r--r--libnautilus-private/nautilus-file-operations-progress.c317
-rw-r--r--libnautilus-private/nautilus-file-operations-progress.h94
-rw-r--r--libnautilus-private/nautilus-file-operations.c91
-rw-r--r--libnautilus-private/nautilus-icon-container.c24
-rw-r--r--libnautilus-private/nautilus-stock-dialogs.c7
-rw-r--r--libnautilus-private/nautilus-volume-monitor.c7
-rw-r--r--libnautilus/nautilus-view.c15
-rw-r--r--src/nautilus-information-panel.c13
-rw-r--r--src/nautilus-sidebar.c13
22 files changed, 747 insertions, 614 deletions
diff --git a/ChangeLog b/ChangeLog
index e7be7d15f..49e918c2d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,97 @@
+2001-04-02 Darin Adler <darin@eazel.com>
+
+ Make file operations progress dialog always stay up for at least 1
+ second total so it doesn't just appear and disappear.
+
+ Preparing for a fix to the nautilus-adapter process leaking when
+ Nautilus is terminated by Ctrl-C, I cleaned up some of the code
+ inside the adapter.
+
+ Improved the warning you get when neither /etc/mnttab nor
+ /proc/mounts can be opened.
+
+ Fix bug 6888 (when I view a large image, it appears first at 100%,
+ then zoomed to fit).
+
+ Re-added part of the code to make components go away when the main
+ program that is hosting them goes away. The X-window-based
+ solution is not working as well as I had hoped, so I'm re-adding
+ the 20-second-timeout-based solution.
+
+ * components/adapter/nautilus-adapter-embed-strategy.c:
+ (nautilus_adapter_embed_strategy_initialize_class),
+ (nautilus_adapter_embed_strategy_get),
+ (nautilus_adapter_embed_strategy_emit_open_location): Change the
+ strategy new functions to use more-normal reference rules. The
+ caller no longer expects them to "use up" a reference.
+
+ * components/adapter/nautilus-adapter-control-embed-strategy.c:
+ (nautilus_adapter_control_embed_strategy_destroy),
+ (nautilus_adapter_control_embed_strategy_new): Don't keep a
+ reference to the BonoboControl around after creating the frame.
+
+ * components/adapter/nautilus-adapter-embeddable-embed-strategy.c:
+ (nautilus_adapter_embeddable_embed_strategy_destroy),
+ (nautilus_adapter_embeddable_embed_strategy_new): Don't keep a
+ reference to the BonoboEmeddable around after creating the frame.
+
+ * components/image-viewer/nautilus-image-view.c: (redraw_control),
+ (scrolled_window_size_allocate_callback),
+ (control_factory_common), (init_bonobo_image_generic_factory):
+ Some name changes, and a fix so that we don't show the image first
+ at 100%, and then shrink to fit. The downside is that this might
+ be too hard-coded to the current behavior of Nautilus, but it's
+ better than flashing every time you open an image.
+
+ * components/services/trilobite/utils/.cvsignore: Ignore some
+ files in this new directory.
+
+ * libnautilus-extensions/nautilus-file-operations-progress.h:
+ * libnautilus-extensions/nautilus-file-operations-progress.c:
+ (nautilus_file_operations_progress_update), (close_callback),
+ (nautilus_file_operations_progress_destroy), (map_callback),
+ (delete_event_callback),
+ (nautilus_file_operations_progress_initialize),
+ (nautilus_file_operations_progress_initialize_class),
+ (nautilus_file_operations_progress_new),
+ (nautilus_file_operations_progress_set_total),
+ (nautilus_file_operations_progress_set_operation_string),
+ (nautilus_file_operations_progress_new_file),
+ (nautilus_file_operations_progress_clear),
+ (nautilus_file_operations_progress_update_sizes),
+ (delayed_close_callback), (nautilus_file_operations_progress_done):
+ Did a lot of code cleanups throughout the file, and added a new
+ call nautilus_file_operations_progress_done. Use this instead of
+ gtk_object_destroy so that the window can linger long enough for
+ the user to see it, if a copy was really fast.
+
+ * libnautilus-extensions/nautilus-file-operations.c:
+ (transfer_info_destroy), (parent_for_error_dialog),
+ (create_transfer_dialog), (handle_transfer_ok),
+ (handle_transfer_vfs_error): Change to use the new
+ nautilus_file_operations_progress_done call instead of
+ gtk_object_destroy when done with the progress dialog.
+
+ * libnautilus-extensions/nautilus-icon-container.c:
+ (nautilus_icon_container_update_scroll_region): Fix indentation.
+
+ * libnautilus-extensions/nautilus-volume-monitor.c:
+ (get_current_mount_list): Replace cryptic g_return_if_fail message
+ with better-worded g_warning.
+
+ * libnautilus/nautilus-view.c: (set_frame_callback),
+ (widget_destroyed_callback),
+ (nautilus_view_construct_from_bonobo_control): Re-added code to
+ monitor the lifetime of the frame and self-destruct when the frame
+ goes away. The X-window-based solution wasn't working 100%, and
+ this solution does.
+
+ * src/nautilus-sidebar.c: (toggle_sidebar_panel),
+ (sidebar_for_each_sidebar_panel): Change object data key to use a
+ prefix that includes the word "nautilus". Tweak code that builds
+ the menu so that it always includes any panel that's displayed,
+ even if the user level says it shouldn't be there.
+
2001-04-02 Michael Engber <engber@eazel.com>
reviewed by: John Harper <jsh@eazel.com>
diff --git a/components/adapter/nautilus-adapter-control-embed-strategy.c b/components/adapter/nautilus-adapter-control-embed-strategy.c
index a57218d2b..d7d4c8636 100644
--- a/components/adapter/nautilus-adapter-control-embed-strategy.c
+++ b/components/adapter/nautilus-adapter-control-embed-strategy.c
@@ -41,7 +41,6 @@
struct NautilusAdapterControlEmbedStrategyDetails {
- Bonobo_Control control;
BonoboControlFrame *control_frame;
BonoboObject *zoomable;
GtkWidget *widget;
@@ -90,16 +89,9 @@ static void
nautilus_adapter_control_embed_strategy_destroy (GtkObject *object)
{
NautilusAdapterControlEmbedStrategy *strategy;
- CORBA_Environment ev;
strategy = NAUTILUS_ADAPTER_CONTROL_EMBED_STRATEGY (object);
- if (strategy->details->control != CORBA_OBJECT_NIL) {
- CORBA_exception_init (&ev);
- bonobo_object_release_unref (strategy->details->control, &ev);
- CORBA_exception_free (&ev);
- }
-
if (strategy->details->control_frame != NULL) {
bonobo_object_unref (BONOBO_OBJECT (strategy->details->control_frame));
}
@@ -168,7 +160,6 @@ nautilus_adapter_control_embed_strategy_new (Bonobo_Control control,
gtk_object_ref (GTK_OBJECT (strategy));
gtk_object_sink (GTK_OBJECT (strategy));
- strategy->details->control = control;
strategy->details->control_frame = bonobo_control_frame_new (ui_container);
bonobo_control_frame_bind_to_control (strategy->details->control_frame, control);
diff --git a/components/adapter/nautilus-adapter-control-factory-embed-strategy.c b/components/adapter/nautilus-adapter-control-factory-embed-strategy.c
index 885c0a3c5..bc9d885db 100644
--- a/components/adapter/nautilus-adapter-control-factory-embed-strategy.c
+++ b/components/adapter/nautilus-adapter-control-factory-embed-strategy.c
@@ -41,7 +41,6 @@
#include <libnautilus/nautilus-view.h>
struct NautilusAdapterEmbeddableEmbedStrategyDetails {
- BonoboObjectClient *embeddable_wrapper;
BonoboItemContainer *container;
BonoboClientSite *client_site;
BonoboViewFrame *view_frame;
@@ -96,9 +95,6 @@ nautilus_adapter_embeddable_embed_strategy_destroy (GtkObject *object)
strategy = NAUTILUS_ADAPTER_EMBEDDABLE_EMBED_STRATEGY (object);
- if (strategy->details->embeddable_wrapper != NULL) {
- bonobo_object_unref (BONOBO_OBJECT (strategy->details->embeddable_wrapper));
- }
if (strategy->details->view_frame != NULL) {
bonobo_object_unref (BONOBO_OBJECT (strategy->details->view_frame));
}
@@ -167,6 +163,7 @@ nautilus_adapter_embeddable_embed_strategy_new (Bonobo_Embeddable embeddable,
Bonobo_UIContainer ui_container)
{
NautilusAdapterEmbeddableEmbedStrategy *strategy;
+ BonoboObjectClient *embeddable_wrapper;
Bonobo_Zoomable corba_zoomable;
Bonobo_View corba_view;
CORBA_Environment ev;
@@ -175,12 +172,15 @@ nautilus_adapter_embeddable_embed_strategy_new (Bonobo_Embeddable embeddable,
gtk_object_ref (GTK_OBJECT (strategy));
gtk_object_sink (GTK_OBJECT (strategy));
- strategy->details->embeddable_wrapper = bonobo_object_client_from_corba (embeddable);
+ embeddable_wrapper = bonobo_object_client_from_corba
+ (bonobo_object_dup_ref (embeddable, NULL));
strategy->details->container = bonobo_item_container_new ();
strategy->details->client_site = bonobo_client_site_new (strategy->details->container);
- bonobo_client_site_bind_embeddable (strategy->details->client_site, strategy->details->embeddable_wrapper);
+ bonobo_client_site_bind_embeddable (strategy->details->client_site, embeddable_wrapper);
+
+ bonobo_object_unref (BONOBO_OBJECT (embeddable_wrapper));
strategy->details->view_frame = bonobo_client_site_new_view (strategy->details->client_site, ui_container);
strategy->details->client_widget = bonobo_view_frame_get_wrapper (strategy->details->view_frame);
diff --git a/components/adapter/nautilus-adapter-embed-strategy.c b/components/adapter/nautilus-adapter-embed-strategy.c
index a3045c86f..f2739accc 100644
--- a/components/adapter/nautilus-adapter-embed-strategy.c
+++ b/components/adapter/nautilus-adapter-embed-strategy.c
@@ -3,7 +3,7 @@
/*
* Nautilus
*
- * Copyright (C) 2000 Eazel, Inc.
+ * Copyright (C) 2000, 2001 Eazel, Inc.
*
* Nautilus is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -29,12 +29,11 @@
#include <config.h>
-
#include "nautilus-adapter-embed-strategy.h"
-#include "nautilus-adapter-embed-strategy-private.h"
+
#include "nautilus-adapter-control-embed-strategy.h"
+#include "nautilus-adapter-embed-strategy-private.h"
#include "nautilus-adapter-embeddable-embed-strategy.h"
-
#include <gtk/gtkobject.h>
#include <gtk/gtksignal.h>
#include <libnautilus-extensions/nautilus-gtk-macros.h>
@@ -49,12 +48,12 @@ enum {
static guint signals[LAST_SIGNAL];
-
static void nautilus_adapter_embed_strategy_initialize_class (NautilusAdapterEmbedStrategyClass *klass);
static void nautilus_adapter_embed_strategy_initialize (NautilusAdapterEmbedStrategy *strategy);
-static void nautilus_adapter_embed_strategy_destroy (GtkObject *object);
-NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusAdapterEmbedStrategy, nautilus_adapter_embed_strategy, GTK_TYPE_OBJECT)
+NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusAdapterEmbedStrategy,
+ nautilus_adapter_embed_strategy,
+ GTK_TYPE_OBJECT)
NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (nautilus_adapter_embed_strategy, get_widget)
NAUTILUS_IMPLEMENT_MUST_OVERRIDE_SIGNAL (nautilus_adapter_embed_strategy, get_zoomable)
@@ -66,8 +65,6 @@ nautilus_adapter_embed_strategy_initialize_class (NautilusAdapterEmbedStrategyCl
object_class = (GtkObjectClass *) klass;
- object_class->destroy = nautilus_adapter_embed_strategy_destroy;
-
signals[ACTIVATE] =
gtk_signal_new ("activate",
GTK_RUN_LAST,
@@ -101,49 +98,39 @@ nautilus_adapter_embed_strategy_initialize (NautilusAdapterEmbedStrategy *strate
{
}
-static void
-nautilus_adapter_embed_strategy_destroy (GtkObject *object)
-{
- NautilusAdapterEmbedStrategy *strategy;
-
- strategy = NAUTILUS_ADAPTER_EMBED_STRATEGY (object);
-
- NAUTILUS_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
-}
-
-
-
NautilusAdapterEmbedStrategy *
nautilus_adapter_embed_strategy_get (Bonobo_Unknown component)
{
Bonobo_Control control;
Bonobo_Embeddable embeddable;
CORBA_Environment ev;
+ NautilusAdapterEmbedStrategy *strategy;
CORBA_exception_init (&ev);
- control = Bonobo_Unknown_queryInterface (component,
- "IDL:Bonobo/Control:1.0", &ev);
-
+ strategy = NULL;
+ control = Bonobo_Unknown_queryInterface
+ (component, "IDL:Bonobo/Control:1.0", &ev);
if (ev._major == CORBA_NO_EXCEPTION && !CORBA_Object_is_nil (control, &ev)) {
- CORBA_exception_free (&ev);
-
- return nautilus_adapter_control_embed_strategy_new (control, CORBA_OBJECT_NIL);
+ strategy = nautilus_adapter_control_embed_strategy_new
+ (control, CORBA_OBJECT_NIL);
+ bonobo_object_release_unref (control, NULL);
}
-
- embeddable = Bonobo_Unknown_queryInterface (component,
- "IDL:Bonobo/Embeddable:1.0", &ev);
- if (ev._major == CORBA_NO_EXCEPTION && !CORBA_Object_is_nil (embeddable, &ev)) {
- CORBA_exception_free (&ev);
-
- return nautilus_adapter_embeddable_embed_strategy_new (embeddable, CORBA_OBJECT_NIL);
+ if (strategy != NULL) {
+ embeddable = Bonobo_Unknown_queryInterface
+ (component, "IDL:Bonobo/Embeddable:1.0", &ev);
+ if (ev._major == CORBA_NO_EXCEPTION && !CORBA_Object_is_nil (embeddable, &ev)) {
+ strategy = nautilus_adapter_embeddable_embed_strategy_new
+ (embeddable, CORBA_OBJECT_NIL);
+ bonobo_object_release_unref (embeddable, NULL);
+ }
}
CORBA_exception_free (&ev);
- return NULL;
+ return strategy;
}
GtkWidget *
@@ -187,4 +174,3 @@ nautilus_adapter_embed_strategy_emit_open_location (NautilusAdapterEmbedStrategy
signals[OPEN_LOCATION],
uri);
}
-
diff --git a/components/adapter/nautilus-adapter-embeddable-embed-strategy.c b/components/adapter/nautilus-adapter-embeddable-embed-strategy.c
index 885c0a3c5..bc9d885db 100644
--- a/components/adapter/nautilus-adapter-embeddable-embed-strategy.c
+++ b/components/adapter/nautilus-adapter-embeddable-embed-strategy.c
@@ -41,7 +41,6 @@
#include <libnautilus/nautilus-view.h>
struct NautilusAdapterEmbeddableEmbedStrategyDetails {
- BonoboObjectClient *embeddable_wrapper;
BonoboItemContainer *container;
BonoboClientSite *client_site;
BonoboViewFrame *view_frame;
@@ -96,9 +95,6 @@ nautilus_adapter_embeddable_embed_strategy_destroy (GtkObject *object)
strategy = NAUTILUS_ADAPTER_EMBEDDABLE_EMBED_STRATEGY (object);
- if (strategy->details->embeddable_wrapper != NULL) {
- bonobo_object_unref (BONOBO_OBJECT (strategy->details->embeddable_wrapper));
- }
if (strategy->details->view_frame != NULL) {
bonobo_object_unref (BONOBO_OBJECT (strategy->details->view_frame));
}
@@ -167,6 +163,7 @@ nautilus_adapter_embeddable_embed_strategy_new (Bonobo_Embeddable embeddable,
Bonobo_UIContainer ui_container)
{
NautilusAdapterEmbeddableEmbedStrategy *strategy;
+ BonoboObjectClient *embeddable_wrapper;
Bonobo_Zoomable corba_zoomable;
Bonobo_View corba_view;
CORBA_Environment ev;
@@ -175,12 +172,15 @@ nautilus_adapter_embeddable_embed_strategy_new (Bonobo_Embeddable embeddable,
gtk_object_ref (GTK_OBJECT (strategy));
gtk_object_sink (GTK_OBJECT (strategy));
- strategy->details->embeddable_wrapper = bonobo_object_client_from_corba (embeddable);
+ embeddable_wrapper = bonobo_object_client_from_corba
+ (bonobo_object_dup_ref (embeddable, NULL));
strategy->details->container = bonobo_item_container_new ();
strategy->details->client_site = bonobo_client_site_new (strategy->details->container);
- bonobo_client_site_bind_embeddable (strategy->details->client_site, strategy->details->embeddable_wrapper);
+ bonobo_client_site_bind_embeddable (strategy->details->client_site, embeddable_wrapper);
+
+ bonobo_object_unref (BONOBO_OBJECT (embeddable_wrapper));
strategy->details->view_frame = bonobo_client_site_new_view (strategy->details->client_site, ui_container);
strategy->details->client_widget = bonobo_view_frame_get_wrapper (strategy->details->view_frame);
diff --git a/components/image-viewer/nautilus-image-view.c b/components/image-viewer/nautilus-image-view.c
index e102e73c4..d3352d603 100644
--- a/components/image-viewer/nautilus-image-view.c
+++ b/components/image-viewer/nautilus-image-view.c
@@ -1,3 +1,5 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
/*
* Generic image loading embeddable using gdk-pixbuf.
*
@@ -57,8 +59,8 @@ typedef struct {
GtkWidget *scrolled_window;
GdkPixbuf *scaled;
gboolean size_allocated;
- gboolean initial_flag;
- gboolean resize_flag;
+ gboolean got_initial_size;
+ gboolean got_penultimate_allocation;
GdkPixbuf *zoomed;
float zoom_level;
@@ -210,7 +212,7 @@ redraw_control (bonobo_object_data_t *bod, GdkRectangle *rect)
* so we don't screw up the size allocation process by drawing
* an unscaled image too early.
*/
- if (bod->size_allocated) {
+ if (bod->got_initial_size) {
render_pixbuf (buf, bod->drawing_area, rect);
}
}
@@ -580,7 +582,6 @@ control_size_allocate_callback (GtkWidget *drawing_area, GtkAllocation *allocati
control_update (bod);
}
-
/*
* This callback will be invoked when the container assigns us a size.
*/
@@ -615,23 +616,28 @@ image_fits_in_container (bonobo_object_data_t *bod)
*/
static void
scrolled_window_size_allocate_callback (GtkWidget *drawing_area,
- GtkAllocation *allocation,
- bonobo_object_data_t *bod)
+ GtkAllocation *allocation,
+ bonobo_object_data_t *bod)
{
- /* implement initial shrink-to-fit if necessary. It's hard to tell when resizing
- * is complete, inspiring this hackish solution determining when; it should
- * be replaced with a cleaner approach when the framework is improved.
+ /* Implement initial shrink-to-fit if necessary. It's hard to
+ * tell when resizing is complete, inspiring this hackish
+ * solution determining when; it should be replaced with a
+ * cleaner approach when the framework is improved.
*/
- if (bod->resize_flag && bod->initial_flag && allocation->width > 1 && allocation->height > 1)
- {
- bod->initial_flag = FALSE;
+ if (bod->got_penultimate_allocation
+ && !bod->got_initial_size
+ && allocation->width > 1
+ && allocation->height > 1) {
+ bod->got_initial_size = TRUE;
if (!image_fits_in_container (bod)) {
zoomable_zoom_to_fit_callback (bod->zoomable, bod);
}
- }
- else if (!bod->resize_flag && allocation->width == 1 && allocation->height == 1) {
- bod->resize_flag = TRUE;
+ gtk_widget_queue_draw (bod->drawing_area);
+ } else if (!bod->got_penultimate_allocation
+ && allocation->width == 1
+ && allocation->height == 1) {
+ bod->got_penultimate_allocation = TRUE;
}
}
@@ -652,17 +658,10 @@ control_factory_common (GtkWidget *scrolled_window)
bonobo_object_data_t *bod;
bod = g_new0 (bonobo_object_data_t, 1);
- bod->scaled = NULL;
- bod->zoomed = NULL;
bod->zoom_level = 1.0;
bod->drawing_area = gtk_drawing_area_new ();
- bod->size_allocated = FALSE;
bod->scrolled_window = scrolled_window;
- /* set flags that control initial shrink-to-fit */
- bod->initial_flag = TRUE;
- bod->resize_flag = FALSE;
-
gtk_signal_connect (GTK_OBJECT (bod->drawing_area),
"expose_event",
GTK_SIGNAL_FUNC (drawing_area_exposed), bod);
@@ -671,8 +670,10 @@ control_factory_common (GtkWidget *scrolled_window)
bod->root = scrolled_window;
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (bod->root),
bod->drawing_area);
- } else
+ } else {
bod->root = bod->drawing_area;
+ bod->got_initial_size = TRUE;
+ }
gtk_widget_show_all (bod->root);
bod->control = bonobo_control_new (bod->root);
@@ -802,7 +803,8 @@ init_bonobo_image_generic_factory (void)
{
char *registration_id;
- registration_id = oaf_make_registration_id ("OAFIID:nautilus_image_view_factory:61ea9ab1-e4b4-4da8-8f54-61cf6f33c4f6", g_getenv ("DISPLAY"));
+ registration_id = oaf_make_registration_id ("OAFIID:nautilus_image_view_factory:61ea9ab1-e4b4-4da8-8f54-61cf6f33c4f6",
+ g_getenv ("DISPLAY"));
image_factory = bonobo_generic_factory_new_multi
(registration_id,
diff --git a/components/services/trilobite/utils/.cvsignore b/components/services/trilobite/utils/.cvsignore
new file mode 100644
index 000000000..99e086a44
--- /dev/null
+++ b/components/services/trilobite/utils/.cvsignore
@@ -0,0 +1,5 @@
+.deps
+.libs
+Makefile
+Makefile.in
+eazel-helper-test
diff --git a/libnautilus-extensions/nautilus-file-operations-progress.c b/libnautilus-extensions/nautilus-file-operations-progress.c
index c3abd919a..339950baf 100644
--- a/libnautilus-extensions/nautilus-file-operations-progress.c
+++ b/libnautilus-extensions/nautilus-file-operations-progress.c
@@ -1,9 +1,10 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
/* dfos-xfer-progress-dialog.c - Progress dialog for transfer operations in the
GNOME Desktop File Operation Service.
Copyright (C) 1999, 2000 Free Software Foundation
- Copyright (C) 2000 Eazel Inc.
+ Copyright (C) 2000, 2001 Eazel Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -23,17 +24,23 @@
Authors:
Ettore Perazzoli <ettore@gnu.org>
Pavel Cisler <pavel@eazel.com>
- */
+*/
#include <config.h>
-#include <gnome.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include "nautilus-file-operations-progress.h"
-#include "libnautilus-extensions/nautilus-ellipsizing-label.h"
-#include "libnautilus-extensions/nautilus-gtk-extensions.h"
-#include "libnautilus-extensions/nautilus-gdk-font-extensions.h"
-#include "libnautilus-extensions/nautilus-gtk-macros.h"
+#include "nautilus-ellipsizing-label.h"
+#include "nautilus-gdk-font-extensions.h"
+#include "nautilus-glib-extensions.h"
+#include "nautilus-gtk-extensions.h"
+#include "nautilus-gtk-macros.h"
+#include <gtk/gtkhbox.h>
+#include <gtk/gtkmain.h>
+#include <gtk/gtkprogressbar.h>
+#include <gtk/gtktable.h>
+#include <libgnome/gnome-i18n.h>
+#include <libgnomeui/gnome-stock.h>
+#include <libgnomevfs/gnome-vfs-utils.h>
/* The width of the progress bar determines the minimum width of the
* window. It will be wider only if the font is really huge and the
@@ -41,13 +48,19 @@
*/
#define PROGRESS_BAR_WIDTH 350
-static void nautilus_file_operations_progress_initialize_class (NautilusFileOperationsProgressClass *klass);
-static void nautilus_file_operations_progress_initialize (NautilusFileOperationsProgress *dialog);
+#define OUTER_BORDER 5
+#define HORIZONTAL_SPACING 3
-NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusFileOperationsProgress, nautilus_file_operations_progress, GNOME_TYPE_DIALOG);
+#define MINIMUM_TIME_UP 1000
-struct NautilusFileOperationsProgressDetails {
+static void nautilus_file_operations_progress_initialize_class (NautilusFileOperationsProgressClass *klass);
+static void nautilus_file_operations_progress_initialize (NautilusFileOperationsProgress *dialog);
+
+NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusFileOperationsProgress,
+ nautilus_file_operations_progress,
+ GNOME_TYPE_DIALOG);
+struct NautilusFileOperationsProgressDetails {
GtkWidget *progress_title_label;
GtkWidget *progress_count_label;
GtkWidget *operation_name_label;
@@ -62,33 +75,31 @@ struct NautilusFileOperationsProgressDetails {
const char *from_prefix;
const char *to_prefix;
- guint freeze_count;
-
- gulong file_index;
- gulong file_size;
-
gulong bytes_copied;
- gulong total_bytes_copied;
-
gulong files_total;
gulong bytes_total;
+
+ /* system time (microseconds) when dialog was mapped */
+ gint64 start_time;
+
+ guint delayed_close_timeout_id;
};
-/* Private functions. */
+/* Private functions. */
static void
-nautilus_file_operations_progress_update (NautilusFileOperationsProgress *dialog)
+nautilus_file_operations_progress_update (NautilusFileOperationsProgress *progress)
{
- if (dialog->details->bytes_total == 0) {
- /* we haven't set up the file count yet, do not update the progress
- * bar until we do
+ if (progress->details->bytes_total == 0) {
+ /* We haven't set up the file count yet, do not update
+ * the progress bar until we do.
*/
return;
}
- gtk_progress_configure (GTK_PROGRESS (dialog->details->progress_bar),
- dialog->details->total_bytes_copied,
- 0.0, dialog->details->bytes_total);
+ gtk_progress_configure (GTK_PROGRESS (progress->details->progress_bar),
+ progress->details->bytes_copied,
+ 0.0, progress->details->bytes_total);
}
static void
@@ -106,16 +117,12 @@ set_text_unescaped_trimmed (NautilusEllipsizingLabel *label, const char *text)
g_free (unescaped_text);
}
-/* GnomeDialog default signal overrides. */
-
/* This is just to make sure the dialog is not closed without explicit
- intervention. */
+ * intervention.
+ */
static gboolean
-nautilus_file_operations_progress_close (GnomeDialog *dialog)
+close_callback (GnomeDialog *dialog)
{
- NautilusFileOperationsProgress *progress_dialog;
-
- progress_dialog = NAUTILUS_FILE_OPERATIONS_PROGRESS (dialog);
return FALSE;
}
@@ -124,11 +131,17 @@ nautilus_file_operations_progress_close (GnomeDialog *dialog)
static void
nautilus_file_operations_progress_destroy (GtkObject *object)
{
- NautilusFileOperationsProgress *dialog;
+ NautilusFileOperationsProgress *progress;
+
+ progress = NAUTILUS_FILE_OPERATIONS_PROGRESS (object);
- dialog = NAUTILUS_FILE_OPERATIONS_PROGRESS (object);
+ if (progress->details->delayed_close_timeout_id != 0) {
+ g_source_remove (progress->details->delayed_close_timeout_id);
+ }
- g_free (dialog->details);
+ g_free (progress->details);
+
+ NAUTILUS_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
}
/* Initialization. */
@@ -156,8 +169,21 @@ create_titled_label (GtkTable *table, int row, GtkWidget **title_widget, GtkWidg
gtk_misc_set_alignment (GTK_MISC (*label_text_widget), 0, 0);
}
+static void
+map_callback (GtkWidget *widget)
+{
+ NautilusFileOperationsProgress *progress;
+
+ progress = NAUTILUS_FILE_OPERATIONS_PROGRESS (widget);
+
+ NAUTILUS_CALL_PARENT (GTK_WIDGET_CLASS, map, (widget));
+
+ progress->details->start_time = nautilus_get_system_time ();
+}
+
static gboolean
-delete_event_callback (GtkWidget *widget, GdkEventAny *event)
+delete_event_callback (GtkWidget *widget,
+ GdkEventAny *event)
{
/* Do nothing -- we shouldn't be getting a close event because
* the dialog should not have a close box.
@@ -166,77 +192,66 @@ delete_event_callback (GtkWidget *widget, GdkEventAny *event)
}
static void
-nautilus_file_operations_progress_initialize (NautilusFileOperationsProgress *dialog)
+nautilus_file_operations_progress_initialize (NautilusFileOperationsProgress *progress)
{
- GnomeDialog *gnome_dialog;
GtkBox *vbox;
GtkWidget *hbox;
GtkTable *titled_label_table;
- dialog->details = g_new0 (NautilusFileOperationsProgressDetails, 1);
+ progress->details = g_new0 (NautilusFileOperationsProgressDetails, 1);
-
- gnome_dialog = GNOME_DIALOG (dialog);
- vbox = GTK_BOX (gnome_dialog->vbox);
+ vbox = GTK_BOX (GNOME_DIALOG (progress)->vbox);
/* This is evil but makes the dialog look less cramped. */
- gtk_container_border_width (GTK_CONTAINER (vbox), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), OUTER_BORDER);
hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (vbox, hbox, TRUE, TRUE, 3);
+ gtk_box_pack_start (vbox, hbox, TRUE, TRUE, HORIZONTAL_SPACING);
gtk_widget_show (hbox);
/* label- */
/* Files remaining to be copied: */
- dialog->details->progress_title_label = gtk_label_new ("");
- gtk_label_set_justify (GTK_LABEL (dialog->details->progress_title_label), GTK_JUSTIFY_LEFT);
- gtk_box_pack_start (GTK_BOX (hbox), dialog->details->progress_title_label, FALSE, FALSE, 0);
- gtk_widget_show (dialog->details->progress_title_label);
- nautilus_gtk_label_make_bold (GTK_LABEL (dialog->details->progress_title_label));
+ progress->details->progress_title_label = gtk_label_new ("");
+ gtk_label_set_justify (GTK_LABEL (progress->details->progress_title_label), GTK_JUSTIFY_LEFT);
+ gtk_box_pack_start (GTK_BOX (hbox), progress->details->progress_title_label, FALSE, FALSE, 0);
+ gtk_widget_show (progress->details->progress_title_label);
+ nautilus_gtk_label_make_bold (GTK_LABEL (progress->details->progress_title_label));
/* label -- */
/* 24 of 30 */
- dialog->details->progress_count_label = gtk_label_new ("");
- gtk_label_set_justify (GTK_LABEL (dialog->details->progress_count_label), GTK_JUSTIFY_RIGHT);
- gtk_box_pack_end (GTK_BOX (hbox), dialog->details->progress_count_label, FALSE, FALSE, 0);
- gtk_widget_show (dialog->details->progress_count_label);
- nautilus_gtk_label_make_bold (GTK_LABEL (dialog->details->progress_count_label));
+ progress->details->progress_count_label = gtk_label_new ("");
+ gtk_label_set_justify (GTK_LABEL (progress->details->progress_count_label), GTK_JUSTIFY_RIGHT);
+ gtk_box_pack_end (GTK_BOX (hbox), progress->details->progress_count_label, FALSE, FALSE, 0);
+ gtk_widget_show (progress->details->progress_count_label);
+ nautilus_gtk_label_make_bold (GTK_LABEL (progress->details->progress_count_label));
/* progress bar */
- dialog->details->progress_bar = gtk_progress_bar_new ();
- gtk_progress_bar_set_bar_style (GTK_PROGRESS_BAR (dialog->details->progress_bar),
+ progress->details->progress_bar = gtk_progress_bar_new ();
+ gtk_progress_bar_set_bar_style (GTK_PROGRESS_BAR (progress->details->progress_bar),
GTK_PROGRESS_CONTINUOUS);
- gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR (dialog->details->progress_bar),
+ gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR (progress->details->progress_bar),
GTK_PROGRESS_LEFT_TO_RIGHT);
- gtk_widget_set_usize (GTK_WIDGET (dialog->details->progress_bar), PROGRESS_BAR_WIDTH,
- -1);
- gtk_box_pack_start (vbox, dialog->details->progress_bar, FALSE, TRUE, 0);
- gtk_widget_show (dialog->details->progress_bar);
+ gtk_widget_set_usize (progress->details->progress_bar, PROGRESS_BAR_WIDTH, -1);
+ gtk_box_pack_start (vbox, progress->details->progress_bar, FALSE, TRUE, 0);
+ gtk_widget_show (progress->details->progress_bar);
titled_label_table = GTK_TABLE (gtk_table_new (3, 2, FALSE));
gtk_table_set_row_spacings (titled_label_table, 4);
gtk_table_set_col_spacings (titled_label_table, 4);
gtk_widget_show (GTK_WIDGET (titled_label_table));
- create_titled_label (titled_label_table, 0, &dialog->details->operation_name_label,
- &dialog->details->item_name);
- create_titled_label (titled_label_table, 1, &dialog->details->from_label,
- &dialog->details->from_path_label);
- create_titled_label (titled_label_table, 2, &dialog->details->to_label,
- &dialog->details->to_path_label);
+ create_titled_label (titled_label_table, 0,
+ &progress->details->operation_name_label,
+ &progress->details->item_name);
+ create_titled_label (titled_label_table, 1,
+ &progress->details->from_label,
+ &progress->details->from_path_label);
+ create_titled_label (titled_label_table, 2,
+ &progress->details->to_label,
+ &progress->details->to_path_label);
gtk_box_pack_start (vbox, GTK_WIDGET (titled_label_table), FALSE, FALSE, 0);
-
-
- dialog->details->file_index = 0;
- dialog->details->file_size = 0;
- dialog->details->files_total = 0;
- dialog->details->bytes_total = 0;
- dialog->details->bytes_copied = 0;
- dialog->details->total_bytes_copied = 0;
-
- dialog->details->freeze_count = 0;
}
static void
@@ -251,7 +266,6 @@ nautilus_file_operations_progress_initialize_class (NautilusFileOperationsProgre
dialog_class = GNOME_DIALOG_CLASS (klass);
object_class->destroy = nautilus_file_operations_progress_destroy;
- dialog_class->close = nautilus_file_operations_progress_close;
/* The progress dialog should not have a title and a close box.
* Some broken window manager themes still show the window title.
@@ -259,9 +273,12 @@ nautilus_file_operations_progress_initialize_class (NautilusFileOperationsProgre
* a crash.
*/
widget_class->delete_event = delete_event_callback;
+ widget_class->map = map_callback;
+
+ dialog_class->close = close_callback;
}
-GtkWidget *
+NautilusFileOperationsProgress *
nautilus_file_operations_progress_new (const char *title,
const char *operation_string,
const char *from_prefix,
@@ -270,50 +287,51 @@ nautilus_file_operations_progress_new (const char *title,
gulong total_bytes)
{
GtkWidget *widget;
- NautilusFileOperationsProgress *dialog;
+ NautilusFileOperationsProgress *progress;
widget = gtk_widget_new (nautilus_file_operations_progress_get_type (), NULL);
- dialog = NAUTILUS_FILE_OPERATIONS_PROGRESS (widget);
+ progress = NAUTILUS_FILE_OPERATIONS_PROGRESS (widget);
- nautilus_file_operations_progress_set_operation_string (dialog, operation_string);
- nautilus_file_operations_progress_set_total (dialog, total_files, total_bytes);
+ nautilus_file_operations_progress_set_operation_string (progress, operation_string);
+ nautilus_file_operations_progress_set_total (progress, total_files, total_bytes);
gtk_window_set_title (GTK_WINDOW (widget), title);
gtk_window_set_wmclass (GTK_WINDOW (widget), "file_progress", "Nautilus");
- gnome_dialog_append_button (GNOME_DIALOG (widget), GNOME_STOCK_BUTTON_CANCEL);
+ gnome_dialog_append_button (GNOME_DIALOG (widget),
+ GNOME_STOCK_BUTTON_CANCEL);
- dialog->details->from_prefix = from_prefix;
- dialog->details->to_prefix = to_prefix;
+ progress->details->from_prefix = from_prefix;
+ progress->details->to_prefix = to_prefix;
- return widget;
+ return progress;
}
void
-nautilus_file_operations_progress_set_total (NautilusFileOperationsProgress *dialog,
+nautilus_file_operations_progress_set_total (NautilusFileOperationsProgress *progress,
gulong files_total,
gulong bytes_total)
{
- g_return_if_fail (IS_NAUTILUS_FILE_OPERATIONS_PROGRESS (dialog));
+ g_return_if_fail (NAUTILUS_IS_FILE_OPERATIONS_PROGRESS (progress));
- dialog->details->files_total = files_total;
- dialog->details->bytes_total = bytes_total;
+ progress->details->files_total = files_total;
+ progress->details->bytes_total = bytes_total;
- nautilus_file_operations_progress_update (dialog);
+ nautilus_file_operations_progress_update (progress);
}
void
-nautilus_file_operations_progress_set_operation_string (NautilusFileOperationsProgress *dialog,
+nautilus_file_operations_progress_set_operation_string (NautilusFileOperationsProgress *progress,
const char *operation_string)
{
- g_return_if_fail (IS_NAUTILUS_FILE_OPERATIONS_PROGRESS (dialog));
+ g_return_if_fail (NAUTILUS_IS_FILE_OPERATIONS_PROGRESS (progress));
- gtk_label_set_text (GTK_LABEL (dialog->details->progress_title_label),
+ gtk_label_set_text (GTK_LABEL (progress->details->progress_title_label),
operation_string);
}
void
-nautilus_file_operations_progress_new_file (NautilusFileOperationsProgress *dialog,
+nautilus_file_operations_progress_new_file (NautilusFileOperationsProgress *progress,
const char *progress_verb,
const char *item_name,
const char *from_path,
@@ -325,81 +343,104 @@ nautilus_file_operations_progress_new_file (NautilusFileOperationsProgress *dial
{
char *progress_count;
- g_return_if_fail (IS_NAUTILUS_FILE_OPERATIONS_PROGRESS (dialog));
- g_return_if_fail (GTK_WIDGET_REALIZED (dialog));
-
- dialog->details->file_index = file_index;
- dialog->details->bytes_copied = 0;
- dialog->details->file_size = size;
+ g_return_if_fail (NAUTILUS_IS_FILE_OPERATIONS_PROGRESS (progress));
+ g_return_if_fail (GTK_WIDGET_REALIZED (progress));
- dialog->details->from_prefix = from_prefix;
- dialog->details->to_prefix = to_prefix;
+ progress->details->from_prefix = from_prefix;
+ progress->details->to_prefix = to_prefix;
- if (dialog->details->bytes_total > 0) {
+ if (progress->details->bytes_total > 0) {
/* we haven't set up the file count yet, do not update the progress
* count until we do
*/
- gtk_label_set_text (GTK_LABEL (dialog->details->operation_name_label), progress_verb);
+ gtk_label_set_text (GTK_LABEL (progress->details->operation_name_label),
+ progress_verb);
set_text_unescaped_trimmed
- (NAUTILUS_ELLIPSIZING_LABEL (dialog->details->item_name), item_name);
+ (NAUTILUS_ELLIPSIZING_LABEL (progress->details->item_name),
+ item_name);
- progress_count = g_strdup_printf (_("%ld of %ld"), dialog->details->file_index,
- dialog->details->files_total);
- gtk_label_set_text (GTK_LABEL (dialog->details->progress_count_label), progress_count);
+ progress_count = g_strdup_printf (_("%ld of %ld"), file_index + 1,
+ progress->details->files_total);
+ gtk_label_set_text (GTK_LABEL (progress->details->progress_count_label), progress_count);
g_free (progress_count);
- gtk_label_set_text (GTK_LABEL (dialog->details->from_label), from_prefix);
+ gtk_label_set_text (GTK_LABEL (progress->details->from_label), from_prefix);
set_text_unescaped_trimmed
- (NAUTILUS_ELLIPSIZING_LABEL (dialog->details->from_path_label), from_path);
+ (NAUTILUS_ELLIPSIZING_LABEL (progress->details->from_path_label), from_path);
- if (dialog->details->to_prefix != NULL && dialog->details->to_path_label != NULL) {
- gtk_label_set_text (GTK_LABEL (dialog->details->to_label), to_prefix);
+ if (progress->details->to_prefix != NULL && progress->details->to_path_label != NULL) {
+ gtk_label_set_text (GTK_LABEL (progress->details->to_label), to_prefix);
set_text_unescaped_trimmed
- (NAUTILUS_ELLIPSIZING_LABEL (dialog->details->to_path_label), to_path);
+ (NAUTILUS_ELLIPSIZING_LABEL (progress->details->to_path_label), to_path);
}
}
- nautilus_file_operations_progress_update (dialog);
+ nautilus_file_operations_progress_update (progress);
}
void
-nautilus_file_operations_progress_clear (NautilusFileOperationsProgress *dialog)
+nautilus_file_operations_progress_clear (NautilusFileOperationsProgress *progress)
{
- gtk_label_set_text (GTK_LABEL (dialog->details->from_label), "");
- gtk_label_set_text (GTK_LABEL (dialog->details->from_path_label), "");
- gtk_label_set_text (GTK_LABEL (dialog->details->to_label), "");
- gtk_label_set_text (GTK_LABEL (dialog->details->to_path_label), "");
+ gtk_label_set_text (GTK_LABEL (progress->details->from_label), "");
+ gtk_label_set_text (GTK_LABEL (progress->details->from_path_label), "");
+ gtk_label_set_text (GTK_LABEL (progress->details->to_label), "");
+ gtk_label_set_text (GTK_LABEL (progress->details->to_path_label), "");
- dialog->details->files_total = 0;
- dialog->details->bytes_total = 0;
+ progress->details->files_total = 0;
+ progress->details->bytes_total = 0;
- nautilus_file_operations_progress_update (dialog);
+ nautilus_file_operations_progress_update (progress);
}
void
-nautilus_file_operations_progress_update_sizes (NautilusFileOperationsProgress *dialog,
+nautilus_file_operations_progress_update_sizes (NautilusFileOperationsProgress *progress,
gulong bytes_done_in_file,
gulong bytes_done)
{
- g_return_if_fail (IS_NAUTILUS_FILE_OPERATIONS_PROGRESS (dialog));
+ g_return_if_fail (NAUTILUS_IS_FILE_OPERATIONS_PROGRESS (progress));
- dialog->details->bytes_copied = bytes_done_in_file;
- dialog->details->total_bytes_copied = bytes_done;
+ progress->details->bytes_copied = bytes_done;
- nautilus_file_operations_progress_update (dialog);
+ nautilus_file_operations_progress_update (progress);
}
-void
-nautilus_file_operations_progress_freeze (NautilusFileOperationsProgress *dialog)
+static gboolean
+delayed_close_callback (gpointer callback_data)
{
- dialog->details->freeze_count++;
+ NautilusFileOperationsProgress *progress;
+
+ progress = NAUTILUS_FILE_OPERATIONS_PROGRESS (callback_data);
+
+ progress->details->delayed_close_timeout_id = 0;
+ gtk_object_destroy (GTK_OBJECT (progress));
+ return FALSE;
}
void
-nautilus_file_operations_progress_thaw (NautilusFileOperationsProgress *dialog)
+nautilus_file_operations_progress_done (NautilusFileOperationsProgress *progress)
{
- if (dialog->details->freeze_count > 0) {
- dialog->details->freeze_count--;
+ guint time_up;
+
+ if (!GTK_WIDGET_MAPPED (progress)) {
+ gtk_object_destroy (GTK_OBJECT (progress));
+ return;
}
-}
+ g_assert (progress->details->start_time != 0);
+ /* compute time up in milliseconds */
+ time_up = (nautilus_get_system_time () - progress->details->start_time) / 1000;
+ if (time_up >= MINIMUM_TIME_UP) {
+ gtk_object_destroy (GTK_OBJECT (progress));
+ return;
+ }
+
+ /* Make dialog look "done". */
+ gnome_dialog_set_sensitive (GNOME_DIALOG (progress), 0, FALSE);
+ gtk_progress_configure (GTK_PROGRESS (progress->details->progress_bar),
+ 1.0, 0.0, 1.0);
+
+ progress->details->delayed_close_timeout_id = gtk_timeout_add
+ (MINIMUM_TIME_UP - time_up,
+ delayed_close_callback,
+ progress);
+}
diff --git a/libnautilus-extensions/nautilus-file-operations-progress.h b/libnautilus-extensions/nautilus-file-operations-progress.h
index 6055d2f91..3ec3445d4 100644
--- a/libnautilus-extensions/nautilus-file-operations-progress.h
+++ b/libnautilus-extensions/nautilus-file-operations-progress.h
@@ -1,9 +1,10 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
/* nautilus-file-operations-progress.h - Progress dialog for transfer
operations in the GNOME Desktop File Operation Service.
Copyright (C) 1999, 2000 Free Software Foundation
- Copyright (C) 2000 Eazel Inc.
+ Copyright (C) 2000, 2001 Eazel Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -25,73 +26,56 @@
Pavel Cisler <pavel@eazel.com>
*/
-#ifndef _NAUTILUS_FILE_OPERATIONS_PROGRESS_H
-#define _NAUTILUS_FILE_OPERATIONS_PROGRESS_H
+#ifndef NAUTILUS_FILE_OPERATIONS_PROGRESS_H
+#define NAUTILUS_FILE_OPERATIONS_PROGRESS_H
#include <libgnomeui/gnome-dialog.h>
typedef struct NautilusFileOperationsProgressDetails NautilusFileOperationsProgressDetails;
-typedef struct NautilusFileOperationsProgress NautilusFileOperationsProgress;
-struct NautilusFileOperationsProgress {
+typedef struct {
GnomeDialog dialog;
NautilusFileOperationsProgressDetails *details;
-};
+} NautilusFileOperationsProgress;
-typedef struct NautilusFileOperationsProgressClass NautilusFileOperationsProgressClass;
-struct NautilusFileOperationsProgressClass {
+typedef struct {
GnomeDialogClass parent_class;
-};
+} NautilusFileOperationsProgressClass;
#define NAUTILUS_FILE_OPERATIONS_PROGRESS(obj) \
GTK_CHECK_CAST (obj, nautilus_file_operations_progress_get_type (), NautilusFileOperationsProgress)
#define NAUTILUS_FILE_OPERATIONS_PROGRESS_CLASS(klass) \
GTK_CHECK_CLASS_CAST (klass, nautilus_file_operations_progress_get_type (), NautilusFileOperationsProgressClass)
-#define IS_NAUTILUS_FILE_OPERATIONS_PROGRESS(obj) \
+#define NAUTILUS_IS_FILE_OPERATIONS_PROGRESS(obj) \
GTK_CHECK_TYPE (obj, nautilus_file_operations_progress_get_type ())
-
-guint nautilus_file_operations_progress_get_type (void);
-
-GtkWidget *nautilus_file_operations_progress_new (const char *title,
- const char *operation_string,
- const char *from_prefix,
- const char *to_prefix,
- gulong files_total,
- gulong bytes_total);
-
-void nautilus_file_operations_progress_set_progress_title (NautilusFileOperationsProgress *dialog,
- const char *progress_title);
-
-void nautilus_file_operations_progress_set_total (NautilusFileOperationsProgress *dialog,
- gulong files_total,
- gulong bytes_total);
-
-void nautilus_file_operations_progress_set_operation_string (NautilusFileOperationsProgress *dialog,
- const char *operation_string);
-
-void nautilus_file_operations_progress_clear (NautilusFileOperationsProgress *dialog);
-
-void nautilus_file_operations_progress_new_file (NautilusFileOperationsProgress *dialog,
- const char *progress_verb,
- const char *item_name,
- const char *from_path,
- const char *to_path,
- const char *from_prefix,
- const char *to_prefix,
- gulong file_index,
- gulong size);
-
-void nautilus_file_operations_progress_update_sizes (NautilusFileOperationsProgress *dialog,
- gulong bytes_done_in_file,
- gulong bytes_done);
-
-void nautilus_file_operations_progress_freeze (NautilusFileOperationsProgress *dialog);
-
-void nautilus_file_operations_progress_thaw (NautilusFileOperationsProgress *dialog);
-
-
-#endif /* _NAUTILUS_FILE_OPERATIONS_PROGRESS_H */
-
-
-
+guint nautilus_file_operations_progress_get_type (void);
+NautilusFileOperationsProgress *nautilus_file_operations_progress_new (const char *title,
+ const char *operation_string,
+ const char *from_prefix,
+ const char *to_prefix,
+ gulong files_total,
+ gulong bytes_total);
+void nautilus_file_operations_progress_done (NautilusFileOperationsProgress *dialog);
+void nautilus_file_operations_progress_set_progress_title (NautilusFileOperationsProgress *dialog,
+ const char *progress_title);
+void nautilus_file_operations_progress_set_total (NautilusFileOperationsProgress *dialog,
+ gulong files_total,
+ gulong bytes_total);
+void nautilus_file_operations_progress_set_operation_string (NautilusFileOperationsProgress *dialog,
+ const char *operation_string);
+void nautilus_file_operations_progress_clear (NautilusFileOperationsProgress *dialog);
+void nautilus_file_operations_progress_new_file (NautilusFileOperationsProgress *dialog,
+ const char *progress_verb,
+ const char *item_name,
+ const char *from_path,
+ const char *to_path,
+ const char *from_prefix,
+ const char *to_prefix,
+ gulong file_index,
+ gulong size);
+void nautilus_file_operations_progress_update_sizes (NautilusFileOperationsProgress *dialog,
+ gulong bytes_done_in_file,
+ gulong bytes_done);
+
+#endif /* NAUTILUS_FILE_OPERATIONS_PROGRESS_H */
diff --git a/libnautilus-extensions/nautilus-file-operations.c b/libnautilus-extensions/nautilus-file-operations.c
index 3d8398e0b..adf50f7e8 100644
--- a/libnautilus-extensions/nautilus-file-operations.c
+++ b/libnautilus-extensions/nautilus-file-operations.c
@@ -60,7 +60,7 @@ typedef enum {
/* Copy engine callback state */
typedef struct {
GnomeVFSAsyncHandle *handle;
- GtkWidget *progress_dialog;
+ NautilusFileOperationsProgress *progress_dialog;
const char *operation_title; /* "Copying files" */
const char *action_label; /* "Files copied:" */
const char *progress_verb; /* "Copying" */
@@ -96,7 +96,7 @@ transfer_info_destroy (TransferInfo *transfer_info)
nautilus_nullify_cancel (&transfer_info->parent_view);
if (transfer_info->progress_dialog != NULL) {
- gtk_widget_destroy (transfer_info->progress_dialog);
+ nautilus_file_operations_progress_done (transfer_info->progress_dialog);
}
if (transfer_info->debuting_uris != NULL) {
@@ -273,7 +273,7 @@ static GtkWidget *
parent_for_error_dialog (TransferInfo *transfer_info)
{
if (transfer_info->progress_dialog != NULL) {
- return transfer_info->progress_dialog;
+ return GTK_WIDGET (transfer_info->progress_dialog);
}
return transfer_info->parent_view;
@@ -375,12 +375,12 @@ create_transfer_dialog (const GnomeVFSXferProgressInfo *progress_info,
gtk_signal_connect (GTK_OBJECT (transfer_info->progress_dialog), "close",
(GtkSignalFunc) handle_close_callback, transfer_info);
- gtk_widget_show (transfer_info->progress_dialog);
+ gtk_widget_show (GTK_WIDGET (transfer_info->progress_dialog));
/* Make the progress dialog show up over the window we are copying into */
if (transfer_info->parent_view != NULL) {
center_dialog_over_window (GTK_WINDOW (transfer_info->progress_dialog),
- GTK_WINDOW (gtk_widget_get_toplevel (transfer_info->parent_view)));
+ GTK_WINDOW (gtk_widget_get_toplevel (transfer_info->parent_view)));
}
}
@@ -455,7 +455,7 @@ progress_dialog_set_to_from_item_text (NautilusFileOperationsProgress *dialog,
static int
handle_transfer_ok (const GnomeVFSXferProgressInfo *progress_info,
- TransferInfo *transfer_info)
+ TransferInfo *transfer_info)
{
if (transfer_info->cancelled
&& progress_info->phase != GNOME_VFS_XFER_PHASE_COMPLETED) {
@@ -483,43 +483,40 @@ handle_transfer_ok (const GnomeVFSXferProgressInfo *progress_info,
case GNOME_VFS_XFER_PHASE_COLLECTING:
if (transfer_info->progress_dialog != NULL) {
nautilus_file_operations_progress_set_operation_string
- (NAUTILUS_FILE_OPERATIONS_PROGRESS
- (transfer_info->progress_dialog),
- transfer_info->preparation_name);
+ (transfer_info->progress_dialog,
+ transfer_info->preparation_name);
}
return 1;
case GNOME_VFS_XFER_PHASE_READYTOGO:
if (transfer_info->progress_dialog != NULL) {
- nautilus_file_operations_progress_set_operation_string (
- NAUTILUS_FILE_OPERATIONS_PROGRESS (transfer_info->progress_dialog),
- transfer_info->action_label);
+ nautilus_file_operations_progress_set_operation_string
+ (transfer_info->progress_dialog,
+ transfer_info->action_label);
nautilus_file_operations_progress_set_total
- (NAUTILUS_FILE_OPERATIONS_PROGRESS
- (transfer_info->progress_dialog),
- progress_info->files_total,
- progress_info->bytes_total);
+ (transfer_info->progress_dialog,
+ progress_info->files_total,
+ progress_info->bytes_total);
}
return 1;
case GNOME_VFS_XFER_PHASE_DELETESOURCE:
nautilus_file_changes_consume_changes (FALSE);
if (transfer_info->progress_dialog != NULL) {
- progress_dialog_set_to_from_item_text (
- NAUTILUS_FILE_OPERATIONS_PROGRESS (transfer_info->progress_dialog),
- transfer_info->progress_verb,
- progress_info->source_name,
- NULL,
- progress_info->file_index,
- progress_info->file_size);
+ progress_dialog_set_to_from_item_text
+ (transfer_info->progress_dialog,
+ transfer_info->progress_verb,
+ progress_info->source_name,
+ NULL,
+ progress_info->file_index,
+ progress_info->file_size);
nautilus_file_operations_progress_update_sizes
- (NAUTILUS_FILE_OPERATIONS_PROGRESS
- (transfer_info->progress_dialog),
+ (transfer_info->progress_dialog,
MIN (progress_info->bytes_copied,
- progress_info->bytes_total),
+ progress_info->bytes_total),
MIN (progress_info->total_bytes_copied,
- progress_info->bytes_total));
+ progress_info->bytes_total));
}
return 1;
@@ -532,34 +529,31 @@ handle_transfer_ok (const GnomeVFSXferProgressInfo *progress_info,
if (transfer_info->progress_dialog != NULL) {
if (progress_info->bytes_copied == 0) {
- progress_dialog_set_to_from_item_text (
- NAUTILUS_FILE_OPERATIONS_PROGRESS (transfer_info->progress_dialog),
- transfer_info->progress_verb,
- progress_info->source_name,
- progress_info->target_name,
- progress_info->file_index,
- progress_info->file_size);
+ progress_dialog_set_to_from_item_text
+ (transfer_info->progress_dialog,
+ transfer_info->progress_verb,
+ progress_info->source_name,
+ progress_info->target_name,
+ progress_info->file_index,
+ progress_info->file_size);
} else {
nautilus_file_operations_progress_update_sizes
- (NAUTILUS_FILE_OPERATIONS_PROGRESS
- (transfer_info->progress_dialog),
+ (transfer_info->progress_dialog,
MIN (progress_info->bytes_copied,
- progress_info->bytes_total),
+ progress_info->bytes_total),
MIN (progress_info->total_bytes_copied,
- progress_info->bytes_total));
+ progress_info->bytes_total));
}
}
return 1;
case GNOME_VFS_XFER_PHASE_CLEANUP:
if (transfer_info->progress_dialog != NULL) {
- nautilus_file_operations_progress_clear(
- NAUTILUS_FILE_OPERATIONS_PROGRESS
- (transfer_info->progress_dialog));
+ nautilus_file_operations_progress_clear
+ (transfer_info->progress_dialog);
nautilus_file_operations_progress_set_operation_string
- (NAUTILUS_FILE_OPERATIONS_PROGRESS
- (transfer_info->progress_dialog),
- transfer_info->cleanup_name);
+ (transfer_info->progress_dialog,
+ transfer_info->cleanup_name);
}
return 1;
@@ -861,7 +855,7 @@ build_error_string (const char *source_name, const char *target_name,
static int
handle_transfer_vfs_error (const GnomeVFSXferProgressInfo *progress_info,
- TransferInfo *transfer_info)
+ TransferInfo *transfer_info)
{
/* Notice that the error mode in `transfer_info' is the one we have been
* requested, but the transfer is always performed in mode
@@ -1042,11 +1036,8 @@ handle_transfer_vfs_error (const GnomeVFSXferProgressInfo *progress_info,
case GNOME_VFS_XFER_ERROR_MODE_ABORT:
default:
if (transfer_info->progress_dialog != NULL) {
- nautilus_file_operations_progress_freeze
- (NAUTILUS_FILE_OPERATIONS_PROGRESS (transfer_info->progress_dialog));
- nautilus_file_operations_progress_thaw
- (NAUTILUS_FILE_OPERATIONS_PROGRESS (transfer_info->progress_dialog));
- gtk_widget_destroy (transfer_info->progress_dialog);
+ nautilus_file_operations_progress_done
+ (transfer_info->progress_dialog);
}
return GNOME_VFS_XFER_ERROR_ACTION_ABORT;
}
diff --git a/libnautilus-extensions/nautilus-icon-container.c b/libnautilus-extensions/nautilus-icon-container.c
index 7746cb6eb..bb243de06 100644
--- a/libnautilus-extensions/nautilus-icon-container.c
+++ b/libnautilus-extensions/nautilus-icon-container.c
@@ -625,18 +625,18 @@ nautilus_icon_container_update_scroll_region (NautilusIconContainer *container)
gboolean reset_scroll_region;
if (nautilus_icon_container_get_is_fixed_size (container)) {
- /* Set the scroll region to the size of the container allocation */
- allocation = &GTK_WIDGET (container)->allocation;
- nautilus_gnome_canvas_set_scroll_region_left_justify
- (GNOME_CANVAS (container),
- (double) - container->details->left_margin,
- (double) - container->details->top_margin,
- (double) allocation->width - 1
- - container->details->left_margin
- - container->details->right_margin,
- (double) allocation->height - 1
- - container->details->top_margin
- - container->details->bottom_margin);
+ /* Set the scroll region to the size of the container allocation */
+ allocation = &GTK_WIDGET (container)->allocation;
+ nautilus_gnome_canvas_set_scroll_region_left_justify
+ (GNOME_CANVAS (container),
+ (double) - container->details->left_margin,
+ (double) - container->details->top_margin,
+ (double) allocation->width - 1
+ - container->details->left_margin
+ - container->details->right_margin,
+ (double) allocation->height - 1
+ - container->details->top_margin
+ - container->details->bottom_margin);
return;
}
diff --git a/libnautilus-extensions/nautilus-stock-dialogs.c b/libnautilus-extensions/nautilus-stock-dialogs.c
index 14262354e..d95f58706 100644
--- a/libnautilus-extensions/nautilus-stock-dialogs.c
+++ b/libnautilus-extensions/nautilus-stock-dialogs.c
@@ -122,12 +122,13 @@ timed_wait_delayed_close_timeout_callback (gpointer callback_data)
{
guint handler_id;
- handler_id = GPOINTER_TO_UINT (gtk_object_get_data (GTK_OBJECT (callback_data), "delayed_close_handler_timeout_id"));
+ handler_id = GPOINTER_TO_UINT (gtk_object_get_data (GTK_OBJECT (callback_data),
+ "nautilus-stock-dialogs/delayed_close_handler_timeout_id"));
gtk_signal_disconnect_by_func (GTK_OBJECT (callback_data),
timed_wait_delayed_close_destroy_dialog_callback,
GUINT_TO_POINTER (handler_id));
-
+
gtk_object_destroy (GTK_OBJECT (callback_data));
return FALSE;
@@ -167,7 +168,7 @@ timed_wait_free (TimedWait *wait)
timed_wait_delayed_close_timeout_callback,
wait->dialog);
gtk_object_set_data (GTK_OBJECT (wait->dialog),
- "delayed_close_handler_timeout_id",
+ "nautilus-stock-dialogs/delayed_close_handler_timeout_id",
GUINT_TO_POINTER (delayed_close_handler_id));
gtk_signal_connect (GTK_OBJECT (wait->dialog), "destroy",
timed_wait_delayed_close_destroy_dialog_callback,
diff --git a/libnautilus-extensions/nautilus-volume-monitor.c b/libnautilus-extensions/nautilus-volume-monitor.c
index 379ba433b..ae7d329c9 100644
--- a/libnautilus-extensions/nautilus-volume-monitor.c
+++ b/libnautilus-extensions/nautilus-volume-monitor.c
@@ -965,8 +965,11 @@ get_current_mount_list (void)
if (fh == NULL) {
fh = fopen ("/proc/mounts", "r");
separator = " ";
+ if (fh == NULL) {
+ g_warning ("can't open /etc/mnttab or /proc/mounts");
+ return NULL;
+ }
}
- g_return_val_if_fail (fh != NULL, NULL);
while (fgets (line, sizeof(line), fh)) {
if (sscanf (line, "%s", device_name) == 1) {
@@ -975,7 +978,7 @@ get_current_mount_list (void)
/* The string list needs to have at least 3 items per line.
* We need to find at least device path, mount path and file system type.
*/
- if (nautilus_string_list_get_length (list) >= 3) {
+ if (nautilus_string_list_get_length (list) >= 3) {
device_path = nautilus_string_list_nth (list, 0);
mount_path = nautilus_string_list_nth (list, 1);
filesystem = nautilus_string_list_nth (list, 2);
diff --git a/libnautilus-private/nautilus-file-operations-progress.c b/libnautilus-private/nautilus-file-operations-progress.c
index c3abd919a..339950baf 100644
--- a/libnautilus-private/nautilus-file-operations-progress.c
+++ b/libnautilus-private/nautilus-file-operations-progress.c
@@ -1,9 +1,10 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
/* dfos-xfer-progress-dialog.c - Progress dialog for transfer operations in the
GNOME Desktop File Operation Service.
Copyright (C) 1999, 2000 Free Software Foundation
- Copyright (C) 2000 Eazel Inc.
+ Copyright (C) 2000, 2001 Eazel Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -23,17 +24,23 @@
Authors:
Ettore Perazzoli <ettore@gnu.org>
Pavel Cisler <pavel@eazel.com>
- */
+*/
#include <config.h>
-#include <gnome.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
#include "nautilus-file-operations-progress.h"
-#include "libnautilus-extensions/nautilus-ellipsizing-label.h"
-#include "libnautilus-extensions/nautilus-gtk-extensions.h"
-#include "libnautilus-extensions/nautilus-gdk-font-extensions.h"
-#include "libnautilus-extensions/nautilus-gtk-macros.h"
+#include "nautilus-ellipsizing-label.h"
+#include "nautilus-gdk-font-extensions.h"
+#include "nautilus-glib-extensions.h"
+#include "nautilus-gtk-extensions.h"
+#include "nautilus-gtk-macros.h"
+#include <gtk/gtkhbox.h>
+#include <gtk/gtkmain.h>
+#include <gtk/gtkprogressbar.h>
+#include <gtk/gtktable.h>
+#include <libgnome/gnome-i18n.h>
+#include <libgnomeui/gnome-stock.h>
+#include <libgnomevfs/gnome-vfs-utils.h>
/* The width of the progress bar determines the minimum width of the
* window. It will be wider only if the font is really huge and the
@@ -41,13 +48,19 @@
*/
#define PROGRESS_BAR_WIDTH 350
-static void nautilus_file_operations_progress_initialize_class (NautilusFileOperationsProgressClass *klass);
-static void nautilus_file_operations_progress_initialize (NautilusFileOperationsProgress *dialog);
+#define OUTER_BORDER 5
+#define HORIZONTAL_SPACING 3
-NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusFileOperationsProgress, nautilus_file_operations_progress, GNOME_TYPE_DIALOG);
+#define MINIMUM_TIME_UP 1000
-struct NautilusFileOperationsProgressDetails {
+static void nautilus_file_operations_progress_initialize_class (NautilusFileOperationsProgressClass *klass);
+static void nautilus_file_operations_progress_initialize (NautilusFileOperationsProgress *dialog);
+
+NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusFileOperationsProgress,
+ nautilus_file_operations_progress,
+ GNOME_TYPE_DIALOG);
+struct NautilusFileOperationsProgressDetails {
GtkWidget *progress_title_label;
GtkWidget *progress_count_label;
GtkWidget *operation_name_label;
@@ -62,33 +75,31 @@ struct NautilusFileOperationsProgressDetails {
const char *from_prefix;
const char *to_prefix;
- guint freeze_count;
-
- gulong file_index;
- gulong file_size;
-
gulong bytes_copied;
- gulong total_bytes_copied;
-
gulong files_total;
gulong bytes_total;
+
+ /* system time (microseconds) when dialog was mapped */
+ gint64 start_time;
+
+ guint delayed_close_timeout_id;
};
-/* Private functions. */
+/* Private functions. */
static void
-nautilus_file_operations_progress_update (NautilusFileOperationsProgress *dialog)
+nautilus_file_operations_progress_update (NautilusFileOperationsProgress *progress)
{
- if (dialog->details->bytes_total == 0) {
- /* we haven't set up the file count yet, do not update the progress
- * bar until we do
+ if (progress->details->bytes_total == 0) {
+ /* We haven't set up the file count yet, do not update
+ * the progress bar until we do.
*/
return;
}
- gtk_progress_configure (GTK_PROGRESS (dialog->details->progress_bar),
- dialog->details->total_bytes_copied,
- 0.0, dialog->details->bytes_total);
+ gtk_progress_configure (GTK_PROGRESS (progress->details->progress_bar),
+ progress->details->bytes_copied,
+ 0.0, progress->details->bytes_total);
}
static void
@@ -106,16 +117,12 @@ set_text_unescaped_trimmed (NautilusEllipsizingLabel *label, const char *text)
g_free (unescaped_text);
}
-/* GnomeDialog default signal overrides. */
-
/* This is just to make sure the dialog is not closed without explicit
- intervention. */
+ * intervention.
+ */
static gboolean
-nautilus_file_operations_progress_close (GnomeDialog *dialog)
+close_callback (GnomeDialog *dialog)
{
- NautilusFileOperationsProgress *progress_dialog;
-
- progress_dialog = NAUTILUS_FILE_OPERATIONS_PROGRESS (dialog);
return FALSE;
}
@@ -124,11 +131,17 @@ nautilus_file_operations_progress_close (GnomeDialog *dialog)
static void
nautilus_file_operations_progress_destroy (GtkObject *object)
{
- NautilusFileOperationsProgress *dialog;
+ NautilusFileOperationsProgress *progress;
+
+ progress = NAUTILUS_FILE_OPERATIONS_PROGRESS (object);
- dialog = NAUTILUS_FILE_OPERATIONS_PROGRESS (object);
+ if (progress->details->delayed_close_timeout_id != 0) {
+ g_source_remove (progress->details->delayed_close_timeout_id);
+ }
- g_free (dialog->details);
+ g_free (progress->details);
+
+ NAUTILUS_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
}
/* Initialization. */
@@ -156,8 +169,21 @@ create_titled_label (GtkTable *table, int row, GtkWidget **title_widget, GtkWidg
gtk_misc_set_alignment (GTK_MISC (*label_text_widget), 0, 0);
}
+static void
+map_callback (GtkWidget *widget)
+{
+ NautilusFileOperationsProgress *progress;
+
+ progress = NAUTILUS_FILE_OPERATIONS_PROGRESS (widget);
+
+ NAUTILUS_CALL_PARENT (GTK_WIDGET_CLASS, map, (widget));
+
+ progress->details->start_time = nautilus_get_system_time ();
+}
+
static gboolean
-delete_event_callback (GtkWidget *widget, GdkEventAny *event)
+delete_event_callback (GtkWidget *widget,
+ GdkEventAny *event)
{
/* Do nothing -- we shouldn't be getting a close event because
* the dialog should not have a close box.
@@ -166,77 +192,66 @@ delete_event_callback (GtkWidget *widget, GdkEventAny *event)
}
static void
-nautilus_file_operations_progress_initialize (NautilusFileOperationsProgress *dialog)
+nautilus_file_operations_progress_initialize (NautilusFileOperationsProgress *progress)
{
- GnomeDialog *gnome_dialog;
GtkBox *vbox;
GtkWidget *hbox;
GtkTable *titled_label_table;
- dialog->details = g_new0 (NautilusFileOperationsProgressDetails, 1);
+ progress->details = g_new0 (NautilusFileOperationsProgressDetails, 1);
-
- gnome_dialog = GNOME_DIALOG (dialog);
- vbox = GTK_BOX (gnome_dialog->vbox);
+ vbox = GTK_BOX (GNOME_DIALOG (progress)->vbox);
/* This is evil but makes the dialog look less cramped. */
- gtk_container_border_width (GTK_CONTAINER (vbox), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), OUTER_BORDER);
hbox = gtk_hbox_new (FALSE, 0);
- gtk_box_pack_start (vbox, hbox, TRUE, TRUE, 3);
+ gtk_box_pack_start (vbox, hbox, TRUE, TRUE, HORIZONTAL_SPACING);
gtk_widget_show (hbox);
/* label- */
/* Files remaining to be copied: */
- dialog->details->progress_title_label = gtk_label_new ("");
- gtk_label_set_justify (GTK_LABEL (dialog->details->progress_title_label), GTK_JUSTIFY_LEFT);
- gtk_box_pack_start (GTK_BOX (hbox), dialog->details->progress_title_label, FALSE, FALSE, 0);
- gtk_widget_show (dialog->details->progress_title_label);
- nautilus_gtk_label_make_bold (GTK_LABEL (dialog->details->progress_title_label));
+ progress->details->progress_title_label = gtk_label_new ("");
+ gtk_label_set_justify (GTK_LABEL (progress->details->progress_title_label), GTK_JUSTIFY_LEFT);
+ gtk_box_pack_start (GTK_BOX (hbox), progress->details->progress_title_label, FALSE, FALSE, 0);
+ gtk_widget_show (progress->details->progress_title_label);
+ nautilus_gtk_label_make_bold (GTK_LABEL (progress->details->progress_title_label));
/* label -- */
/* 24 of 30 */
- dialog->details->progress_count_label = gtk_label_new ("");
- gtk_label_set_justify (GTK_LABEL (dialog->details->progress_count_label), GTK_JUSTIFY_RIGHT);
- gtk_box_pack_end (GTK_BOX (hbox), dialog->details->progress_count_label, FALSE, FALSE, 0);
- gtk_widget_show (dialog->details->progress_count_label);
- nautilus_gtk_label_make_bold (GTK_LABEL (dialog->details->progress_count_label));
+ progress->details->progress_count_label = gtk_label_new ("");
+ gtk_label_set_justify (GTK_LABEL (progress->details->progress_count_label), GTK_JUSTIFY_RIGHT);
+ gtk_box_pack_end (GTK_BOX (hbox), progress->details->progress_count_label, FALSE, FALSE, 0);
+ gtk_widget_show (progress->details->progress_count_label);
+ nautilus_gtk_label_make_bold (GTK_LABEL (progress->details->progress_count_label));
/* progress bar */
- dialog->details->progress_bar = gtk_progress_bar_new ();
- gtk_progress_bar_set_bar_style (GTK_PROGRESS_BAR (dialog->details->progress_bar),
+ progress->details->progress_bar = gtk_progress_bar_new ();
+ gtk_progress_bar_set_bar_style (GTK_PROGRESS_BAR (progress->details->progress_bar),
GTK_PROGRESS_CONTINUOUS);
- gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR (dialog->details->progress_bar),
+ gtk_progress_bar_set_orientation (GTK_PROGRESS_BAR (progress->details->progress_bar),
GTK_PROGRESS_LEFT_TO_RIGHT);
- gtk_widget_set_usize (GTK_WIDGET (dialog->details->progress_bar), PROGRESS_BAR_WIDTH,
- -1);
- gtk_box_pack_start (vbox, dialog->details->progress_bar, FALSE, TRUE, 0);
- gtk_widget_show (dialog->details->progress_bar);
+ gtk_widget_set_usize (progress->details->progress_bar, PROGRESS_BAR_WIDTH, -1);
+ gtk_box_pack_start (vbox, progress->details->progress_bar, FALSE, TRUE, 0);
+ gtk_widget_show (progress->details->progress_bar);
titled_label_table = GTK_TABLE (gtk_table_new (3, 2, FALSE));
gtk_table_set_row_spacings (titled_label_table, 4);
gtk_table_set_col_spacings (titled_label_table, 4);
gtk_widget_show (GTK_WIDGET (titled_label_table));
- create_titled_label (titled_label_table, 0, &dialog->details->operation_name_label,
- &dialog->details->item_name);
- create_titled_label (titled_label_table, 1, &dialog->details->from_label,
- &dialog->details->from_path_label);
- create_titled_label (titled_label_table, 2, &dialog->details->to_label,
- &dialog->details->to_path_label);
+ create_titled_label (titled_label_table, 0,
+ &progress->details->operation_name_label,
+ &progress->details->item_name);
+ create_titled_label (titled_label_table, 1,
+ &progress->details->from_label,
+ &progress->details->from_path_label);
+ create_titled_label (titled_label_table, 2,
+ &progress->details->to_label,
+ &progress->details->to_path_label);
gtk_box_pack_start (vbox, GTK_WIDGET (titled_label_table), FALSE, FALSE, 0);
-
-
- dialog->details->file_index = 0;
- dialog->details->file_size = 0;
- dialog->details->files_total = 0;
- dialog->details->bytes_total = 0;
- dialog->details->bytes_copied = 0;
- dialog->details->total_bytes_copied = 0;
-
- dialog->details->freeze_count = 0;
}
static void
@@ -251,7 +266,6 @@ nautilus_file_operations_progress_initialize_class (NautilusFileOperationsProgre
dialog_class = GNOME_DIALOG_CLASS (klass);
object_class->destroy = nautilus_file_operations_progress_destroy;
- dialog_class->close = nautilus_file_operations_progress_close;
/* The progress dialog should not have a title and a close box.
* Some broken window manager themes still show the window title.
@@ -259,9 +273,12 @@ nautilus_file_operations_progress_initialize_class (NautilusFileOperationsProgre
* a crash.
*/
widget_class->delete_event = delete_event_callback;
+ widget_class->map = map_callback;
+
+ dialog_class->close = close_callback;
}
-GtkWidget *
+NautilusFileOperationsProgress *
nautilus_file_operations_progress_new (const char *title,
const char *operation_string,
const char *from_prefix,
@@ -270,50 +287,51 @@ nautilus_file_operations_progress_new (const char *title,
gulong total_bytes)
{
GtkWidget *widget;
- NautilusFileOperationsProgress *dialog;
+ NautilusFileOperationsProgress *progress;
widget = gtk_widget_new (nautilus_file_operations_progress_get_type (), NULL);
- dialog = NAUTILUS_FILE_OPERATIONS_PROGRESS (widget);
+ progress = NAUTILUS_FILE_OPERATIONS_PROGRESS (widget);
- nautilus_file_operations_progress_set_operation_string (dialog, operation_string);
- nautilus_file_operations_progress_set_total (dialog, total_files, total_bytes);
+ nautilus_file_operations_progress_set_operation_string (progress, operation_string);
+ nautilus_file_operations_progress_set_total (progress, total_files, total_bytes);
gtk_window_set_title (GTK_WINDOW (widget), title);
gtk_window_set_wmclass (GTK_WINDOW (widget), "file_progress", "Nautilus");
- gnome_dialog_append_button (GNOME_DIALOG (widget), GNOME_STOCK_BUTTON_CANCEL);
+ gnome_dialog_append_button (GNOME_DIALOG (widget),
+ GNOME_STOCK_BUTTON_CANCEL);
- dialog->details->from_prefix = from_prefix;
- dialog->details->to_prefix = to_prefix;
+ progress->details->from_prefix = from_prefix;
+ progress->details->to_prefix = to_prefix;
- return widget;
+ return progress;
}
void
-nautilus_file_operations_progress_set_total (NautilusFileOperationsProgress *dialog,
+nautilus_file_operations_progress_set_total (NautilusFileOperationsProgress *progress,
gulong files_total,
gulong bytes_total)
{
- g_return_if_fail (IS_NAUTILUS_FILE_OPERATIONS_PROGRESS (dialog));
+ g_return_if_fail (NAUTILUS_IS_FILE_OPERATIONS_PROGRESS (progress));
- dialog->details->files_total = files_total;
- dialog->details->bytes_total = bytes_total;
+ progress->details->files_total = files_total;
+ progress->details->bytes_total = bytes_total;
- nautilus_file_operations_progress_update (dialog);
+ nautilus_file_operations_progress_update (progress);
}
void
-nautilus_file_operations_progress_set_operation_string (NautilusFileOperationsProgress *dialog,
+nautilus_file_operations_progress_set_operation_string (NautilusFileOperationsProgress *progress,
const char *operation_string)
{
- g_return_if_fail (IS_NAUTILUS_FILE_OPERATIONS_PROGRESS (dialog));
+ g_return_if_fail (NAUTILUS_IS_FILE_OPERATIONS_PROGRESS (progress));
- gtk_label_set_text (GTK_LABEL (dialog->details->progress_title_label),
+ gtk_label_set_text (GTK_LABEL (progress->details->progress_title_label),
operation_string);
}
void
-nautilus_file_operations_progress_new_file (NautilusFileOperationsProgress *dialog,
+nautilus_file_operations_progress_new_file (NautilusFileOperationsProgress *progress,
const char *progress_verb,
const char *item_name,
const char *from_path,
@@ -325,81 +343,104 @@ nautilus_file_operations_progress_new_file (NautilusFileOperationsProgress *dial
{
char *progress_count;
- g_return_if_fail (IS_NAUTILUS_FILE_OPERATIONS_PROGRESS (dialog));
- g_return_if_fail (GTK_WIDGET_REALIZED (dialog));
-
- dialog->details->file_index = file_index;
- dialog->details->bytes_copied = 0;
- dialog->details->file_size = size;
+ g_return_if_fail (NAUTILUS_IS_FILE_OPERATIONS_PROGRESS (progress));
+ g_return_if_fail (GTK_WIDGET_REALIZED (progress));
- dialog->details->from_prefix = from_prefix;
- dialog->details->to_prefix = to_prefix;
+ progress->details->from_prefix = from_prefix;
+ progress->details->to_prefix = to_prefix;
- if (dialog->details->bytes_total > 0) {
+ if (progress->details->bytes_total > 0) {
/* we haven't set up the file count yet, do not update the progress
* count until we do
*/
- gtk_label_set_text (GTK_LABEL (dialog->details->operation_name_label), progress_verb);
+ gtk_label_set_text (GTK_LABEL (progress->details->operation_name_label),
+ progress_verb);
set_text_unescaped_trimmed
- (NAUTILUS_ELLIPSIZING_LABEL (dialog->details->item_name), item_name);
+ (NAUTILUS_ELLIPSIZING_LABEL (progress->details->item_name),
+ item_name);
- progress_count = g_strdup_printf (_("%ld of %ld"), dialog->details->file_index,
- dialog->details->files_total);
- gtk_label_set_text (GTK_LABEL (dialog->details->progress_count_label), progress_count);
+ progress_count = g_strdup_printf (_("%ld of %ld"), file_index + 1,
+ progress->details->files_total);
+ gtk_label_set_text (GTK_LABEL (progress->details->progress_count_label), progress_count);
g_free (progress_count);
- gtk_label_set_text (GTK_LABEL (dialog->details->from_label), from_prefix);
+ gtk_label_set_text (GTK_LABEL (progress->details->from_label), from_prefix);
set_text_unescaped_trimmed
- (NAUTILUS_ELLIPSIZING_LABEL (dialog->details->from_path_label), from_path);
+ (NAUTILUS_ELLIPSIZING_LABEL (progress->details->from_path_label), from_path);
- if (dialog->details->to_prefix != NULL && dialog->details->to_path_label != NULL) {
- gtk_label_set_text (GTK_LABEL (dialog->details->to_label), to_prefix);
+ if (progress->details->to_prefix != NULL && progress->details->to_path_label != NULL) {
+ gtk_label_set_text (GTK_LABEL (progress->details->to_label), to_prefix);
set_text_unescaped_trimmed
- (NAUTILUS_ELLIPSIZING_LABEL (dialog->details->to_path_label), to_path);
+ (NAUTILUS_ELLIPSIZING_LABEL (progress->details->to_path_label), to_path);
}
}
- nautilus_file_operations_progress_update (dialog);
+ nautilus_file_operations_progress_update (progress);
}
void
-nautilus_file_operations_progress_clear (NautilusFileOperationsProgress *dialog)
+nautilus_file_operations_progress_clear (NautilusFileOperationsProgress *progress)
{
- gtk_label_set_text (GTK_LABEL (dialog->details->from_label), "");
- gtk_label_set_text (GTK_LABEL (dialog->details->from_path_label), "");
- gtk_label_set_text (GTK_LABEL (dialog->details->to_label), "");
- gtk_label_set_text (GTK_LABEL (dialog->details->to_path_label), "");
+ gtk_label_set_text (GTK_LABEL (progress->details->from_label), "");
+ gtk_label_set_text (GTK_LABEL (progress->details->from_path_label), "");
+ gtk_label_set_text (GTK_LABEL (progress->details->to_label), "");
+ gtk_label_set_text (GTK_LABEL (progress->details->to_path_label), "");
- dialog->details->files_total = 0;
- dialog->details->bytes_total = 0;
+ progress->details->files_total = 0;
+ progress->details->bytes_total = 0;
- nautilus_file_operations_progress_update (dialog);
+ nautilus_file_operations_progress_update (progress);
}
void
-nautilus_file_operations_progress_update_sizes (NautilusFileOperationsProgress *dialog,
+nautilus_file_operations_progress_update_sizes (NautilusFileOperationsProgress *progress,
gulong bytes_done_in_file,
gulong bytes_done)
{
- g_return_if_fail (IS_NAUTILUS_FILE_OPERATIONS_PROGRESS (dialog));
+ g_return_if_fail (NAUTILUS_IS_FILE_OPERATIONS_PROGRESS (progress));
- dialog->details->bytes_copied = bytes_done_in_file;
- dialog->details->total_bytes_copied = bytes_done;
+ progress->details->bytes_copied = bytes_done;
- nautilus_file_operations_progress_update (dialog);
+ nautilus_file_operations_progress_update (progress);
}
-void
-nautilus_file_operations_progress_freeze (NautilusFileOperationsProgress *dialog)
+static gboolean
+delayed_close_callback (gpointer callback_data)
{
- dialog->details->freeze_count++;
+ NautilusFileOperationsProgress *progress;
+
+ progress = NAUTILUS_FILE_OPERATIONS_PROGRESS (callback_data);
+
+ progress->details->delayed_close_timeout_id = 0;
+ gtk_object_destroy (GTK_OBJECT (progress));
+ return FALSE;
}
void
-nautilus_file_operations_progress_thaw (NautilusFileOperationsProgress *dialog)
+nautilus_file_operations_progress_done (NautilusFileOperationsProgress *progress)
{
- if (dialog->details->freeze_count > 0) {
- dialog->details->freeze_count--;
+ guint time_up;
+
+ if (!GTK_WIDGET_MAPPED (progress)) {
+ gtk_object_destroy (GTK_OBJECT (progress));
+ return;
}
-}
+ g_assert (progress->details->start_time != 0);
+ /* compute time up in milliseconds */
+ time_up = (nautilus_get_system_time () - progress->details->start_time) / 1000;
+ if (time_up >= MINIMUM_TIME_UP) {
+ gtk_object_destroy (GTK_OBJECT (progress));
+ return;
+ }
+
+ /* Make dialog look "done". */
+ gnome_dialog_set_sensitive (GNOME_DIALOG (progress), 0, FALSE);
+ gtk_progress_configure (GTK_PROGRESS (progress->details->progress_bar),
+ 1.0, 0.0, 1.0);
+
+ progress->details->delayed_close_timeout_id = gtk_timeout_add
+ (MINIMUM_TIME_UP - time_up,
+ delayed_close_callback,
+ progress);
+}
diff --git a/libnautilus-private/nautilus-file-operations-progress.h b/libnautilus-private/nautilus-file-operations-progress.h
index 6055d2f91..3ec3445d4 100644
--- a/libnautilus-private/nautilus-file-operations-progress.h
+++ b/libnautilus-private/nautilus-file-operations-progress.h
@@ -1,9 +1,10 @@
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
/* nautilus-file-operations-progress.h - Progress dialog for transfer
operations in the GNOME Desktop File Operation Service.
Copyright (C) 1999, 2000 Free Software Foundation
- Copyright (C) 2000 Eazel Inc.
+ Copyright (C) 2000, 2001 Eazel Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@ -25,73 +26,56 @@
Pavel Cisler <pavel@eazel.com>
*/
-#ifndef _NAUTILUS_FILE_OPERATIONS_PROGRESS_H
-#define _NAUTILUS_FILE_OPERATIONS_PROGRESS_H
+#ifndef NAUTILUS_FILE_OPERATIONS_PROGRESS_H
+#define NAUTILUS_FILE_OPERATIONS_PROGRESS_H
#include <libgnomeui/gnome-dialog.h>
typedef struct NautilusFileOperationsProgressDetails NautilusFileOperationsProgressDetails;
-typedef struct NautilusFileOperationsProgress NautilusFileOperationsProgress;
-struct NautilusFileOperationsProgress {
+typedef struct {
GnomeDialog dialog;
NautilusFileOperationsProgressDetails *details;
-};
+} NautilusFileOperationsProgress;
-typedef struct NautilusFileOperationsProgressClass NautilusFileOperationsProgressClass;
-struct NautilusFileOperationsProgressClass {
+typedef struct {
GnomeDialogClass parent_class;
-};
+} NautilusFileOperationsProgressClass;
#define NAUTILUS_FILE_OPERATIONS_PROGRESS(obj) \
GTK_CHECK_CAST (obj, nautilus_file_operations_progress_get_type (), NautilusFileOperationsProgress)
#define NAUTILUS_FILE_OPERATIONS_PROGRESS_CLASS(klass) \
GTK_CHECK_CLASS_CAST (klass, nautilus_file_operations_progress_get_type (), NautilusFileOperationsProgressClass)
-#define IS_NAUTILUS_FILE_OPERATIONS_PROGRESS(obj) \
+#define NAUTILUS_IS_FILE_OPERATIONS_PROGRESS(obj) \
GTK_CHECK_TYPE (obj, nautilus_file_operations_progress_get_type ())
-
-guint nautilus_file_operations_progress_get_type (void);
-
-GtkWidget *nautilus_file_operations_progress_new (const char *title,
- const char *operation_string,
- const char *from_prefix,
- const char *to_prefix,
- gulong files_total,
- gulong bytes_total);
-
-void nautilus_file_operations_progress_set_progress_title (NautilusFileOperationsProgress *dialog,
- const char *progress_title);
-
-void nautilus_file_operations_progress_set_total (NautilusFileOperationsProgress *dialog,
- gulong files_total,
- gulong bytes_total);
-
-void nautilus_file_operations_progress_set_operation_string (NautilusFileOperationsProgress *dialog,
- const char *operation_string);
-
-void nautilus_file_operations_progress_clear (NautilusFileOperationsProgress *dialog);
-
-void nautilus_file_operations_progress_new_file (NautilusFileOperationsProgress *dialog,
- const char *progress_verb,
- const char *item_name,
- const char *from_path,
- const char *to_path,
- const char *from_prefix,
- const char *to_prefix,
- gulong file_index,
- gulong size);
-
-void nautilus_file_operations_progress_update_sizes (NautilusFileOperationsProgress *dialog,
- gulong bytes_done_in_file,
- gulong bytes_done);
-
-void nautilus_file_operations_progress_freeze (NautilusFileOperationsProgress *dialog);
-
-void nautilus_file_operations_progress_thaw (NautilusFileOperationsProgress *dialog);
-
-
-#endif /* _NAUTILUS_FILE_OPERATIONS_PROGRESS_H */
-
-
-
+guint nautilus_file_operations_progress_get_type (void);
+NautilusFileOperationsProgress *nautilus_file_operations_progress_new (const char *title,
+ const char *operation_string,
+ const char *from_prefix,
+ const char *to_prefix,
+ gulong files_total,
+ gulong bytes_total);
+void nautilus_file_operations_progress_done (NautilusFileOperationsProgress *dialog);
+void nautilus_file_operations_progress_set_progress_title (NautilusFileOperationsProgress *dialog,
+ const char *progress_title);
+void nautilus_file_operations_progress_set_total (NautilusFileOperationsProgress *dialog,
+ gulong files_total,
+ gulong bytes_total);
+void nautilus_file_operations_progress_set_operation_string (NautilusFileOperationsProgress *dialog,
+ const char *operation_string);
+void nautilus_file_operations_progress_clear (NautilusFileOperationsProgress *dialog);
+void nautilus_file_operations_progress_new_file (NautilusFileOperationsProgress *dialog,
+ const char *progress_verb,
+ const char *item_name,
+ const char *from_path,
+ const char *to_path,
+ const char *from_prefix,
+ const char *to_prefix,
+ gulong file_index,
+ gulong size);
+void nautilus_file_operations_progress_update_sizes (NautilusFileOperationsProgress *dialog,
+ gulong bytes_done_in_file,
+ gulong bytes_done);
+
+#endif /* NAUTILUS_FILE_OPERATIONS_PROGRESS_H */
diff --git a/libnautilus-private/nautilus-file-operations.c b/libnautilus-private/nautilus-file-operations.c
index 3d8398e0b..adf50f7e8 100644
--- a/libnautilus-private/nautilus-file-operations.c
+++ b/libnautilus-private/nautilus-file-operations.c
@@ -60,7 +60,7 @@ typedef enum {
/* Copy engine callback state */
typedef struct {
GnomeVFSAsyncHandle *handle;
- GtkWidget *progress_dialog;
+ NautilusFileOperationsProgress *progress_dialog;
const char *operation_title; /* "Copying files" */
const char *action_label; /* "Files copied:" */
const char *progress_verb; /* "Copying" */
@@ -96,7 +96,7 @@ transfer_info_destroy (TransferInfo *transfer_info)
nautilus_nullify_cancel (&transfer_info->parent_view);
if (transfer_info->progress_dialog != NULL) {
- gtk_widget_destroy (transfer_info->progress_dialog);
+ nautilus_file_operations_progress_done (transfer_info->progress_dialog);
}
if (transfer_info->debuting_uris != NULL) {
@@ -273,7 +273,7 @@ static GtkWidget *
parent_for_error_dialog (TransferInfo *transfer_info)
{
if (transfer_info->progress_dialog != NULL) {
- return transfer_info->progress_dialog;
+ return GTK_WIDGET (transfer_info->progress_dialog);
}
return transfer_info->parent_view;
@@ -375,12 +375,12 @@ create_transfer_dialog (const GnomeVFSXferProgressInfo *progress_info,
gtk_signal_connect (GTK_OBJECT (transfer_info->progress_dialog), "close",
(GtkSignalFunc) handle_close_callback, transfer_info);
- gtk_widget_show (transfer_info->progress_dialog);
+ gtk_widget_show (GTK_WIDGET (transfer_info->progress_dialog));
/* Make the progress dialog show up over the window we are copying into */
if (transfer_info->parent_view != NULL) {
center_dialog_over_window (GTK_WINDOW (transfer_info->progress_dialog),
- GTK_WINDOW (gtk_widget_get_toplevel (transfer_info->parent_view)));
+ GTK_WINDOW (gtk_widget_get_toplevel (transfer_info->parent_view)));
}
}
@@ -455,7 +455,7 @@ progress_dialog_set_to_from_item_text (NautilusFileOperationsProgress *dialog,
static int
handle_transfer_ok (const GnomeVFSXferProgressInfo *progress_info,
- TransferInfo *transfer_info)
+ TransferInfo *transfer_info)
{
if (transfer_info->cancelled
&& progress_info->phase != GNOME_VFS_XFER_PHASE_COMPLETED) {
@@ -483,43 +483,40 @@ handle_transfer_ok (const GnomeVFSXferProgressInfo *progress_info,
case GNOME_VFS_XFER_PHASE_COLLECTING:
if (transfer_info->progress_dialog != NULL) {
nautilus_file_operations_progress_set_operation_string
- (NAUTILUS_FILE_OPERATIONS_PROGRESS
- (transfer_info->progress_dialog),
- transfer_info->preparation_name);
+ (transfer_info->progress_dialog,
+ transfer_info->preparation_name);
}
return 1;
case GNOME_VFS_XFER_PHASE_READYTOGO:
if (transfer_info->progress_dialog != NULL) {
- nautilus_file_operations_progress_set_operation_string (
- NAUTILUS_FILE_OPERATIONS_PROGRESS (transfer_info->progress_dialog),
- transfer_info->action_label);
+ nautilus_file_operations_progress_set_operation_string
+ (transfer_info->progress_dialog,
+ transfer_info->action_label);
nautilus_file_operations_progress_set_total
- (NAUTILUS_FILE_OPERATIONS_PROGRESS
- (transfer_info->progress_dialog),
- progress_info->files_total,
- progress_info->bytes_total);
+ (transfer_info->progress_dialog,
+ progress_info->files_total,
+ progress_info->bytes_total);
}
return 1;
case GNOME_VFS_XFER_PHASE_DELETESOURCE:
nautilus_file_changes_consume_changes (FALSE);
if (transfer_info->progress_dialog != NULL) {
- progress_dialog_set_to_from_item_text (
- NAUTILUS_FILE_OPERATIONS_PROGRESS (transfer_info->progress_dialog),
- transfer_info->progress_verb,
- progress_info->source_name,
- NULL,
- progress_info->file_index,
- progress_info->file_size);
+ progress_dialog_set_to_from_item_text
+ (transfer_info->progress_dialog,
+ transfer_info->progress_verb,
+ progress_info->source_name,
+ NULL,
+ progress_info->file_index,
+ progress_info->file_size);
nautilus_file_operations_progress_update_sizes
- (NAUTILUS_FILE_OPERATIONS_PROGRESS
- (transfer_info->progress_dialog),
+ (transfer_info->progress_dialog,
MIN (progress_info->bytes_copied,
- progress_info->bytes_total),
+ progress_info->bytes_total),
MIN (progress_info->total_bytes_copied,
- progress_info->bytes_total));
+ progress_info->bytes_total));
}
return 1;
@@ -532,34 +529,31 @@ handle_transfer_ok (const GnomeVFSXferProgressInfo *progress_info,
if (transfer_info->progress_dialog != NULL) {
if (progress_info->bytes_copied == 0) {
- progress_dialog_set_to_from_item_text (
- NAUTILUS_FILE_OPERATIONS_PROGRESS (transfer_info->progress_dialog),
- transfer_info->progress_verb,
- progress_info->source_name,
- progress_info->target_name,
- progress_info->file_index,
- progress_info->file_size);
+ progress_dialog_set_to_from_item_text
+ (transfer_info->progress_dialog,
+ transfer_info->progress_verb,
+ progress_info->source_name,
+ progress_info->target_name,
+ progress_info->file_index,
+ progress_info->file_size);
} else {
nautilus_file_operations_progress_update_sizes
- (NAUTILUS_FILE_OPERATIONS_PROGRESS
- (transfer_info->progress_dialog),
+ (transfer_info->progress_dialog,
MIN (progress_info->bytes_copied,
- progress_info->bytes_total),
+ progress_info->bytes_total),
MIN (progress_info->total_bytes_copied,
- progress_info->bytes_total));
+ progress_info->bytes_total));
}
}
return 1;
case GNOME_VFS_XFER_PHASE_CLEANUP:
if (transfer_info->progress_dialog != NULL) {
- nautilus_file_operations_progress_clear(
- NAUTILUS_FILE_OPERATIONS_PROGRESS
- (transfer_info->progress_dialog));
+ nautilus_file_operations_progress_clear
+ (transfer_info->progress_dialog);
nautilus_file_operations_progress_set_operation_string
- (NAUTILUS_FILE_OPERATIONS_PROGRESS
- (transfer_info->progress_dialog),
- transfer_info->cleanup_name);
+ (transfer_info->progress_dialog,
+ transfer_info->cleanup_name);
}
return 1;
@@ -861,7 +855,7 @@ build_error_string (const char *source_name, const char *target_name,
static int
handle_transfer_vfs_error (const GnomeVFSXferProgressInfo *progress_info,
- TransferInfo *transfer_info)
+ TransferInfo *transfer_info)
{
/* Notice that the error mode in `transfer_info' is the one we have been
* requested, but the transfer is always performed in mode
@@ -1042,11 +1036,8 @@ handle_transfer_vfs_error (const GnomeVFSXferProgressInfo *progress_info,
case GNOME_VFS_XFER_ERROR_MODE_ABORT:
default:
if (transfer_info->progress_dialog != NULL) {
- nautilus_file_operations_progress_freeze
- (NAUTILUS_FILE_OPERATIONS_PROGRESS (transfer_info->progress_dialog));
- nautilus_file_operations_progress_thaw
- (NAUTILUS_FILE_OPERATIONS_PROGRESS (transfer_info->progress_dialog));
- gtk_widget_destroy (transfer_info->progress_dialog);
+ nautilus_file_operations_progress_done
+ (transfer_info->progress_dialog);
}
return GNOME_VFS_XFER_ERROR_ACTION_ABORT;
}
diff --git a/libnautilus-private/nautilus-icon-container.c b/libnautilus-private/nautilus-icon-container.c
index 7746cb6eb..bb243de06 100644
--- a/libnautilus-private/nautilus-icon-container.c
+++ b/libnautilus-private/nautilus-icon-container.c
@@ -625,18 +625,18 @@ nautilus_icon_container_update_scroll_region (NautilusIconContainer *container)
gboolean reset_scroll_region;
if (nautilus_icon_container_get_is_fixed_size (container)) {
- /* Set the scroll region to the size of the container allocation */
- allocation = &GTK_WIDGET (container)->allocation;
- nautilus_gnome_canvas_set_scroll_region_left_justify
- (GNOME_CANVAS (container),
- (double) - container->details->left_margin,
- (double) - container->details->top_margin,
- (double) allocation->width - 1
- - container->details->left_margin
- - container->details->right_margin,
- (double) allocation->height - 1
- - container->details->top_margin
- - container->details->bottom_margin);
+ /* Set the scroll region to the size of the container allocation */
+ allocation = &GTK_WIDGET (container)->allocation;
+ nautilus_gnome_canvas_set_scroll_region_left_justify
+ (GNOME_CANVAS (container),
+ (double) - container->details->left_margin,
+ (double) - container->details->top_margin,
+ (double) allocation->width - 1
+ - container->details->left_margin
+ - container->details->right_margin,
+ (double) allocation->height - 1
+ - container->details->top_margin
+ - container->details->bottom_margin);
return;
}
diff --git a/libnautilus-private/nautilus-stock-dialogs.c b/libnautilus-private/nautilus-stock-dialogs.c
index 14262354e..d95f58706 100644
--- a/libnautilus-private/nautilus-stock-dialogs.c
+++ b/libnautilus-private/nautilus-stock-dialogs.c
@@ -122,12 +122,13 @@ timed_wait_delayed_close_timeout_callback (gpointer callback_data)
{
guint handler_id;
- handler_id = GPOINTER_TO_UINT (gtk_object_get_data (GTK_OBJECT (callback_data), "delayed_close_handler_timeout_id"));
+ handler_id = GPOINTER_TO_UINT (gtk_object_get_data (GTK_OBJECT (callback_data),
+ "nautilus-stock-dialogs/delayed_close_handler_timeout_id"));
gtk_signal_disconnect_by_func (GTK_OBJECT (callback_data),
timed_wait_delayed_close_destroy_dialog_callback,
GUINT_TO_POINTER (handler_id));
-
+
gtk_object_destroy (GTK_OBJECT (callback_data));
return FALSE;
@@ -167,7 +168,7 @@ timed_wait_free (TimedWait *wait)
timed_wait_delayed_close_timeout_callback,
wait->dialog);
gtk_object_set_data (GTK_OBJECT (wait->dialog),
- "delayed_close_handler_timeout_id",
+ "nautilus-stock-dialogs/delayed_close_handler_timeout_id",
GUINT_TO_POINTER (delayed_close_handler_id));
gtk_signal_connect (GTK_OBJECT (wait->dialog), "destroy",
timed_wait_delayed_close_destroy_dialog_callback,
diff --git a/libnautilus-private/nautilus-volume-monitor.c b/libnautilus-private/nautilus-volume-monitor.c
index 379ba433b..ae7d329c9 100644
--- a/libnautilus-private/nautilus-volume-monitor.c
+++ b/libnautilus-private/nautilus-volume-monitor.c
@@ -965,8 +965,11 @@ get_current_mount_list (void)
if (fh == NULL) {
fh = fopen ("/proc/mounts", "r");
separator = " ";
+ if (fh == NULL) {
+ g_warning ("can't open /etc/mnttab or /proc/mounts");
+ return NULL;
+ }
}
- g_return_val_if_fail (fh != NULL, NULL);
while (fgets (line, sizeof(line), fh)) {
if (sscanf (line, "%s", device_name) == 1) {
@@ -975,7 +978,7 @@ get_current_mount_list (void)
/* The string list needs to have at least 3 items per line.
* We need to find at least device path, mount path and file system type.
*/
- if (nautilus_string_list_get_length (list) >= 3) {
+ if (nautilus_string_list_get_length (list) >= 3) {
device_path = nautilus_string_list_nth (list, 0);
mount_path = nautilus_string_list_nth (list, 1);
filesystem = nautilus_string_list_nth (list, 2);
diff --git a/libnautilus/nautilus-view.c b/libnautilus/nautilus-view.c
index 8ab81c733..061130805 100644
--- a/libnautilus/nautilus-view.c
+++ b/libnautilus/nautilus-view.c
@@ -438,12 +438,22 @@ nautilus_view_construct (NautilusView *view,
}
static void
+set_frame_callback (BonoboControl *control,
+ gpointer callback_data)
+{
+ nautilus_bonobo_object_force_destroy_when_owner_disappears
+ (BONOBO_OBJECT (control),
+ bonobo_control_get_control_frame (control));
+}
+
+static void
widget_destroyed_callback (GtkWidget *widget,
gpointer callback_data)
{
g_assert (NAUTILUS_IS_VIEW (callback_data));
- nautilus_bonobo_object_force_destroy_at_idle (BONOBO_OBJECT (callback_data));
+ nautilus_bonobo_object_force_destroy_at_idle
+ (BONOBO_OBJECT (callback_data));
}
NautilusView *
@@ -459,6 +469,9 @@ nautilus_view_construct_from_bonobo_control (NautilusView *view,
bonobo_object_add_interface (BONOBO_OBJECT (view), BONOBO_OBJECT (control));
nautilus_undo_set_up_bonobo_control (control);
+ gtk_signal_connect (GTK_OBJECT (control), "set_frame",
+ set_frame_callback, NULL);
+
widget = bonobo_control_get_widget (control);
gtk_signal_connect_while_alive (GTK_OBJECT (widget), "destroy",
widget_destroyed_callback, view,
diff --git a/src/nautilus-information-panel.c b/src/nautilus-information-panel.c
index 3a302bedd..01250208b 100644
--- a/src/nautilus-information-panel.c
+++ b/src/nautilus-information-panel.c
@@ -396,9 +396,9 @@ toggle_sidebar_panel (GtkWidget *widget,
g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (widget));
g_return_if_fail (NAUTILUS_IS_SIDEBAR (gtk_object_get_user_data (GTK_OBJECT (widget))));
- g_return_if_fail (gtk_object_get_data (GTK_OBJECT (widget), "preference-key") != NULL);
+ g_return_if_fail (gtk_object_get_data (GTK_OBJECT (widget), "nautilus-sidebar/preference-key") != NULL);
- preference_key = gtk_object_get_data (GTK_OBJECT (widget), "preference-key");
+ preference_key = gtk_object_get_data (GTK_OBJECT (widget), "nautilus-sidebar/preference-key");
sidebar = NAUTILUS_SIDEBAR (gtk_object_get_user_data (GTK_OBJECT (widget)));
@@ -431,6 +431,7 @@ sidebar_for_each_sidebar_panel (const char *name,
{
ForEachPanelData *data;
GtkWidget *menu_item;
+ gboolean panel_visible;
g_return_if_fail (name != NULL);
g_return_if_fail (iid != NULL);
@@ -445,7 +446,8 @@ sidebar_for_each_sidebar_panel (const char *name,
/* If the panel is not visible in the current user level, then
* we dont need to create a menu item for it.
*/
- if (!nautilus_preferences_is_visible (preference_key)) {
+ panel_visible = any_panel_matches_iid (data->sidebar, iid);
+ if (!panel_visible && !nautilus_preferences_is_visible (preference_key)) {
return;
}
@@ -453,8 +455,7 @@ sidebar_for_each_sidebar_panel (const char *name,
menu_item = gtk_check_menu_item_new_with_label (name);
gtk_check_menu_item_set_show_toggle (GTK_CHECK_MENU_ITEM (menu_item), TRUE);
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
- any_panel_matches_iid (data->sidebar, iid));
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), panel_visible);
gtk_widget_show (menu_item);
gtk_object_set_user_data (GTK_OBJECT (menu_item), data->sidebar);
gtk_menu_append (data->menu, menu_item);
@@ -468,7 +469,7 @@ sidebar_for_each_sidebar_panel (const char *name,
FALSE);
gtk_object_set_data_full (GTK_OBJECT (menu_item),
- "preference-key",
+ "nautilus-sidebar/preference-key",
g_strdup (preference_key),
g_free);
}
diff --git a/src/nautilus-sidebar.c b/src/nautilus-sidebar.c
index 3a302bedd..01250208b 100644
--- a/src/nautilus-sidebar.c
+++ b/src/nautilus-sidebar.c
@@ -396,9 +396,9 @@ toggle_sidebar_panel (GtkWidget *widget,
g_return_if_fail (GTK_IS_CHECK_MENU_ITEM (widget));
g_return_if_fail (NAUTILUS_IS_SIDEBAR (gtk_object_get_user_data (GTK_OBJECT (widget))));
- g_return_if_fail (gtk_object_get_data (GTK_OBJECT (widget), "preference-key") != NULL);
+ g_return_if_fail (gtk_object_get_data (GTK_OBJECT (widget), "nautilus-sidebar/preference-key") != NULL);
- preference_key = gtk_object_get_data (GTK_OBJECT (widget), "preference-key");
+ preference_key = gtk_object_get_data (GTK_OBJECT (widget), "nautilus-sidebar/preference-key");
sidebar = NAUTILUS_SIDEBAR (gtk_object_get_user_data (GTK_OBJECT (widget)));
@@ -431,6 +431,7 @@ sidebar_for_each_sidebar_panel (const char *name,
{
ForEachPanelData *data;
GtkWidget *menu_item;
+ gboolean panel_visible;
g_return_if_fail (name != NULL);
g_return_if_fail (iid != NULL);
@@ -445,7 +446,8 @@ sidebar_for_each_sidebar_panel (const char *name,
/* If the panel is not visible in the current user level, then
* we dont need to create a menu item for it.
*/
- if (!nautilus_preferences_is_visible (preference_key)) {
+ panel_visible = any_panel_matches_iid (data->sidebar, iid);
+ if (!panel_visible && !nautilus_preferences_is_visible (preference_key)) {
return;
}
@@ -453,8 +455,7 @@ sidebar_for_each_sidebar_panel (const char *name,
menu_item = gtk_check_menu_item_new_with_label (name);
gtk_check_menu_item_set_show_toggle (GTK_CHECK_MENU_ITEM (menu_item), TRUE);
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
- any_panel_matches_iid (data->sidebar, iid));
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), panel_visible);
gtk_widget_show (menu_item);
gtk_object_set_user_data (GTK_OBJECT (menu_item), data->sidebar);
gtk_menu_append (data->menu, menu_item);
@@ -468,7 +469,7 @@ sidebar_for_each_sidebar_panel (const char *name,
FALSE);
gtk_object_set_data_full (GTK_OBJECT (menu_item),
- "preference-key",
+ "nautilus-sidebar/preference-key",
g_strdup (preference_key),
g_free);
}