summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej Stachowiak <mstachow@src.gnome.org>2001-01-27 01:28:59 +0000
committerMaciej Stachowiak <mstachow@src.gnome.org>2001-01-27 01:28:59 +0000
commit841af08641cf0d4dcec4cb26691fd7d1eaabbfdd (patch)
tree5c4587306791b281cf9a76219cf594e7eb627ec0
parent3968d02a5e5eedc65abd27a76cfca055daf0794a (diff)
downloadnautilus-841af08641cf0d4dcec4cb26691fd7d1eaabbfdd.tar.gz
Hold a ref on the widget to avoid it being finalized before we can destroy
* src/nautilus-window-manage-views.c (disconnect_and_destroy_sidebar_panel): Hold a ref on the widget to avoid it being finalized before we can destroy it.
-rw-r--r--ChangeLog17
-rw-r--r--components/services/nautilus-dependent-shared/shared-service-widgets.c212
-rw-r--r--components/services/summary/eazel-summary-shared.h1
-rw-r--r--components/services/summary/lib/eazel-summary-shared.h1
-rw-r--r--components/tree/libmain.c5
-rw-r--r--components/tree/nautilus-tree-view-dnd.c4
-rw-r--r--libnautilus-extensions/nautilus-file-operations.c34
-rw-r--r--libnautilus-extensions/nautilus-file-operations.h5
-rw-r--r--libnautilus-private/nautilus-file-operations.c34
-rw-r--r--libnautilus-private/nautilus-file-operations.h5
-rw-r--r--src/nautilus-window-manage-views.c2
11 files changed, 297 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index 64c84d16c..34b76cdd5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2001-01-26 Maciej Stachowiak <mjs@eazel.com>
+
+ * src/nautilus-window-manage-views.c
+ (disconnect_and_destroy_sidebar_panel): Hold a ref on the widget
+ to avoid it being finalized before we can destroy it.
+
2001-01-26 Andy Hertzfeld <andy@eazel.com>
* libnautilus-extensions/nautilus-icon-dnd.c:
@@ -4035,11 +4041,12 @@ Wed Jan 24 21:21:52 2001 George Lebl <jirka@5z.com>
2001-01-12 Andy Hertzfeld <andy@eazel.com>
- fixed bug 5198, removing an active sidebar panel messes up the
- remaining ones . I had already fixed this but missed the case
- when multiple windows were open. Fixed by adding a sidebar call to
- close the active panel if it matches a passed-in id, and used that in
- nautilus window to close the panel if necessary before destroying it.
+ fixed bug 5198, removing an active sidebar panel messes up the
+ remaining ones. I had already fixed this but missed the case when
+ multiple windows were open. Fixed by adding a sidebar call to
+ close the active panel if it matches a passed-in id, and used that
+ in nautilus window to close the panel if necessary before
+ destroying it.
* src/nautilus-sidebar.c:
(nautilus_sidebar_hide_active_panel_if_matches),
diff --git a/components/services/nautilus-dependent-shared/shared-service-widgets.c b/components/services/nautilus-dependent-shared/shared-service-widgets.c
new file mode 100644
index 000000000..c88adcbd9
--- /dev/null
+++ b/components/services/nautilus-dependent-shared/shared-service-widgets.c
@@ -0,0 +1,212 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
+/*
+ * Copyright (C) 2000 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
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Authors: Ramiro Estrugo <ramiro@eazel.com>
+ * J Shane Culpepper <pepper@eazel.com>
+ *
+ */
+
+#include <config.h>
+
+#include "shared-service-widgets.h"
+
+#include <libnautilus-extensions/nautilus-background.h>
+#include <libnautilus-extensions/nautilus-gdk-pixbuf-extensions.h>
+#include <libnautilus-extensions/nautilus-gtk-extensions.h>
+#include <libnautilus-extensions/nautilus-gtk-macros.h>
+#include <libnautilus-extensions/nautilus-glib-extensions.h>
+#include <libnautilus-extensions/nautilus-global-preferences.h>
+#include <libnautilus-extensions/nautilus-file-utilities.h>
+#include <libnautilus-extensions/nautilus-string.h>
+#include <libnautilus-extensions/nautilus-font-factory.h>
+#include <libnautilus-extensions/nautilus-gdk-extensions.h>
+#include <libnautilus-extensions/nautilus-theme.h>
+
+#include <stdio.h>
+
+/* private shared helper routine to create an image widget from a pixbuf */
+static GtkWidget*
+create_image_widget_from_pixbuf (GdkPixbuf *icon_pixbuf,
+ const char *tile_icon_name)
+{
+ GtkWidget *image_widget;
+
+ g_return_val_if_fail (icon_pixbuf || tile_icon_name, NULL);
+
+ image_widget = nautilus_image_new ();
+
+ if (icon_pixbuf != NULL) {
+ nautilus_image_set_pixbuf (NAUTILUS_IMAGE (image_widget), icon_pixbuf);
+ }
+
+ if (tile_icon_name != NULL) {
+ char *tile_icon_path;
+
+ tile_icon_path = nautilus_pixmap_file (tile_icon_name);
+
+ if (tile_icon_path != NULL) {
+ GdkPixbuf *tile_icon_pixbuf;
+ tile_icon_pixbuf = gdk_pixbuf_new_from_file (tile_icon_path);
+ g_free (tile_icon_path);
+
+ if (tile_icon_pixbuf != NULL) {
+ nautilus_buffered_widget_set_tile_pixbuf (NAUTILUS_BUFFERED_WIDGET (image_widget), tile_icon_pixbuf);
+ gdk_pixbuf_unref (tile_icon_pixbuf);
+ }
+ else {
+ g_warning ("Could not find the requested tile_icon: %s", tile_icon_path);
+ }
+ }
+ }
+
+ return image_widget;
+}
+
+/* create and return an image widget using a themed nautilus icon name and a tiled background */
+GtkWidget*
+create_image_widget (const char *icon_name, const char *tile_icon_name)
+{
+ GtkWidget *image_widget;
+ GdkPixbuf *pixbuf;
+
+ g_return_val_if_fail (icon_name || tile_icon_name, NULL);
+
+ pixbuf = NULL;
+ if (icon_name != NULL) {
+ char *icon_path;
+
+ icon_path = nautilus_theme_get_image_path (icon_name);
+ if (icon_path != NULL) {
+ pixbuf = gdk_pixbuf_new_from_file (icon_path);
+ g_free (icon_path);
+
+ if (pixbuf == NULL) {
+ g_warning ("Could not find the requested icon: %s", icon_path);
+ }
+ }
+ }
+
+ /* create the image widget then release the pixbuf*/
+ image_widget = create_image_widget_from_pixbuf (pixbuf, tile_icon_name);
+ if (pixbuf != NULL) {
+ gdk_pixbuf_unref (pixbuf);
+ }
+ return image_widget;
+}
+
+/* create and return an image widget from a uri and a tiled background.
+ It also pins the image to the specified dimensions */
+
+/* FIXME bugzilla.eazel.com 5138
+ * this calls gnome-vfs synchronously for an HTTP uri and thus can block
+ * the UI indefinitely
+ */
+GtkWidget*
+create_image_widget_from_uri (const char *uri, const char *tile_icon_name,
+ int max_width, int max_height)
+{
+ GtkWidget *image_widget;
+ GdkPixbuf *pixbuf, *scaled_pixbuf;
+
+ g_return_val_if_fail (uri || tile_icon_name, NULL);
+
+ /* as an optimization, it can be a local file. If it doesn't start with http://,
+ just pass it on to create_image_widget */
+ if (!nautilus_istr_has_prefix (uri, "http://")) {
+ return create_image_widget (uri, tile_icon_name);
+ }
+
+ /* load the image - synchronously, at least at first */
+ pixbuf = nautilus_gdk_pixbuf_load (uri);
+
+ /* pin the image to the specified dimensions if necessary */
+ if (pixbuf && max_width > 0 && max_height > 0) {
+ scaled_pixbuf = nautilus_gdk_pixbuf_scale_down_to_fit (pixbuf, max_width, max_height);
+ gdk_pixbuf_unref (pixbuf);
+ pixbuf = scaled_pixbuf;
+ }
+
+ /* create the image widget then release the pixbuf*/
+ image_widget = create_image_widget_from_pixbuf (pixbuf, tile_icon_name);
+ if (pixbuf != NULL) {
+ gdk_pixbuf_unref (pixbuf);
+ }
+
+ return image_widget;
+}
+
+/* create a label widget with anti-aliased text and a tiled image background */
+GtkWidget*
+create_label_widget (const char *text,
+ guint font_size,
+ const char *tile_icon_name,
+ guint xpad,
+ guint ypad,
+ gint horizontal_offset,
+ gint vertical_offset)
+{
+ GtkWidget *label;
+
+ g_return_val_if_fail (text != NULL, NULL);
+ g_return_val_if_fail (font_size > 0, NULL);
+
+ label = nautilus_label_new (text);
+
+ nautilus_label_set_font_from_components (NAUTILUS_LABEL (label), "helvetica", "bold", NULL, NULL);
+ nautilus_label_set_font_size (NAUTILUS_LABEL (label), font_size);
+ nautilus_label_set_text_color (NAUTILUS_LABEL (label), NAUTILUS_RGB_COLOR_WHITE);
+
+ if (tile_icon_name != NULL) {
+ char *tile_icon_path;
+
+ tile_icon_path = nautilus_pixmap_file (tile_icon_name);
+
+ if (tile_icon_path != NULL) {
+ GdkPixbuf *tile_icon_pixbuf;
+ tile_icon_pixbuf = gdk_pixbuf_new_from_file (tile_icon_path);
+ g_free (tile_icon_path);
+
+ if (tile_icon_pixbuf != NULL) {
+ nautilus_buffered_widget_set_tile_pixbuf (NAUTILUS_BUFFERED_WIDGET (label), tile_icon_pixbuf);
+ gdk_pixbuf_unref (tile_icon_pixbuf);
+ }
+ else {
+ g_warning ("Could not find the requested tile_icon: %s", tile_icon_path);
+ }
+ }
+ }
+
+ gtk_misc_set_padding (GTK_MISC (label), xpad, ypad);
+
+ nautilus_buffered_widget_set_vertical_offset (NAUTILUS_BUFFERED_WIDGET (label), vertical_offset);
+ nautilus_buffered_widget_set_horizontal_offset (NAUTILUS_BUFFERED_WIDGET (label), horizontal_offset);
+
+ return label;
+}
+
+/* utility routine to show an error message */
+void
+show_feedback (GtkWidget *widget,
+ char *error_message)
+{
+ nautilus_label_set_text (NAUTILUS_LABEL (widget), error_message);
+ gtk_widget_show (widget);
+}
+
diff --git a/components/services/summary/eazel-summary-shared.h b/components/services/summary/eazel-summary-shared.h
index 44acfebe3..8b70a1ad3 100644
--- a/components/services/summary/eazel-summary-shared.h
+++ b/components/services/summary/eazel-summary-shared.h
@@ -68,4 +68,3 @@ struct _SummaryData {
SummaryData * parse_summary_xml_file (const char *url);
#endif /* EAZEL_SUMMARY_SHARED_H */
-
diff --git a/components/services/summary/lib/eazel-summary-shared.h b/components/services/summary/lib/eazel-summary-shared.h
index 44acfebe3..8b70a1ad3 100644
--- a/components/services/summary/lib/eazel-summary-shared.h
+++ b/components/services/summary/lib/eazel-summary-shared.h
@@ -68,4 +68,3 @@ struct _SummaryData {
SummaryData * parse_summary_xml_file (const char *url);
#endif /* EAZEL_SUMMARY_SHARED_H */
-
diff --git a/components/tree/libmain.c b/components/tree/libmain.c
index 2a38ed02e..11395f9c8 100644
--- a/components/tree/libmain.c
+++ b/components/tree/libmain.c
@@ -40,9 +40,8 @@ static void
tree_shlib_object_destroyed (GtkObject *object)
{
/* FIXME bugzilla.eazel.com 2736: oaf_plugin_unuse can't possibly work! this sucks */
-#if 0
+
oaf_plugin_unuse (gtk_object_get_user_data (object));
-#endif
}
@@ -66,7 +65,7 @@ tree_shlib_make_object (PortableServer_POA poa,
gtk_signal_connect (GTK_OBJECT (nautilus_view), "destroy", tree_shlib_object_destroyed, NULL);
- gtk_object_set_user_data (GTK_OBJECT (view), impl_ptr);
+ gtk_object_set_user_data (GTK_OBJECT (nautilus_view), impl_ptr);
oaf_plugin_use (poa, impl_ptr);
diff --git a/components/tree/nautilus-tree-view-dnd.c b/components/tree/nautilus-tree-view-dnd.c
index 5e5854ed2..8c773127b 100644
--- a/components/tree/nautilus-tree-view-dnd.c
+++ b/components/tree/nautilus-tree-view-dnd.c
@@ -417,8 +417,6 @@ nautilus_tree_view_drag_drop (GtkWidget *widget,
GPOINTER_TO_INT (context->targets->data),
time);
-
-
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget),
"drag_drop");
return TRUE;
@@ -1290,7 +1288,7 @@ nautilus_tree_view_receive_dropped_icons (NautilusTreeView *view,
}
#endif
nautilus_tree_view_move_copy_files (tree_view, drag_info->selection_list,
- context, drop_target_uri);
+ context, drop_target_uri);
/* collapse all expanded directories during drag except the one we
droped into */
dropped_node = nautilus_tree_view_tree_node_at (tree_view, x, y);
diff --git a/libnautilus-extensions/nautilus-file-operations.c b/libnautilus-extensions/nautilus-file-operations.c
index 6936a8f40..9403809ae 100644
--- a/libnautilus-extensions/nautilus-file-operations.c
+++ b/libnautilus-extensions/nautilus-file-operations.c
@@ -1644,7 +1644,7 @@ void
nautilus_file_operations_copy_move (const GList *item_uris,
GArray *relative_item_points,
const char *target_dir,
- int copy_action,
+ GdkDragAction copy_action,
GtkWidget *parent_view,
void (*done_callback) (GHashTable *debuting_uris, gpointer data),
gpointer done_callback_data)
@@ -1844,10 +1844,16 @@ nautilus_file_operations_copy_move (const GList *item_uris,
/* Distinguish Trash file on desktop from other trash folders for
* message purposes.
*/
+ /* FIXME: is_special_link finds more than just trash links,
+ * so these messages are wrong.
+ */
is_desktop_trash_link = vfs_uri_is_special_link (uri);
+
nautilus_simple_dialog
(parent_view,
FALSE,
+
+
((move_options & GNOME_VFS_XFER_REMOVESOURCE) != 0)
? (is_desktop_trash_link
? _("The Trash must remain on the desktop.")
@@ -1866,8 +1872,7 @@ nautilus_file_operations_copy_move (const GList *item_uris,
/* Don't allow recursive move/copy into itself.
* (We would get a file system error if we proceeded but it is nicer to
- * detect and report it at this level)
- */
+ * detect and report it at this level) */
if ((move_options & GNOME_VFS_XFER_LINK_ITEMS) == 0
&& (gnome_vfs_uri_equal (uri, target_dir_uri)
|| gnome_vfs_uri_is_parent (uri, target_dir_uri, TRUE))) {
@@ -1877,7 +1882,28 @@ nautilus_file_operations_copy_move (const GList *item_uris,
((move_options & GNOME_VFS_XFER_REMOVESOURCE) != 0)
? _("You cannot move a folder into itself.")
: _("You cannot copy a folder into itself."),
- _("Can't Move Into Self"),
+ ((move_options & GNOME_VFS_XFER_REMOVESOURCE) != 0)
+ ? _("Can't Move Into Self")
+ : _("Can't Copy Into Self"),
+ GNOME_STOCK_BUTTON_OK, NULL, NULL);
+
+ result = GNOME_VFS_ERROR_NOT_PERMITTED;
+ break;
+ }
+ if (gnome_vfs_uri_is_parent (target_dir_uri, uri, FALSE)) {
+ nautilus_simple_dialog
+ (parent_view,
+ FALSE,
+ ((move_options & GNOME_VFS_XFER_LINK_ITEMS) != 0)
+ ? _("You cannot link a file to itself.")
+ : ((move_options & GNOME_VFS_XFER_REMOVESOURCE) != 0)
+ ? _("You cannot move a file onto itself.")
+ : _("You cannot copy a file over itself."),
+ ((move_options & GNOME_VFS_XFER_LINK_ITEMS) != 0)
+ ? _("Can't Link To Self")
+ : ((move_options & GNOME_VFS_XFER_REMOVESOURCE) != 0)
+ ? _("Can't Move Onto Self")
+ : _("Can't Copy Over Self"),
GNOME_STOCK_BUTTON_OK, NULL, NULL);
result = GNOME_VFS_ERROR_NOT_PERMITTED;
diff --git a/libnautilus-extensions/nautilus-file-operations.h b/libnautilus-extensions/nautilus-file-operations.h
index b053d5980..931c44e2d 100644
--- a/libnautilus-extensions/nautilus-file-operations.h
+++ b/libnautilus-extensions/nautilus-file-operations.h
@@ -26,16 +26,19 @@
#define NAUTILUS_FILE_OPERATIONS_H
#include <gtk/gtkwidget.h>
+#include <libgnomevfs/gnome-vfs-types.h>
typedef void (* NautilusCopyCallback) (GHashTable *debuting_uris,
gpointer callback_data);
typedef void (* NautilusNewFolderCallback) (const char *new_folder_uri,
gpointer callback_data);
+/* FIXME: int copy_action should be an enum */
+
void nautilus_file_operations_copy_move (const GList *item_uris,
GArray *target_item_points,
const char *target_dir_uri,
- int copy_action,
+ GdkDragAction copy_action,
GtkWidget *parent_view,
NautilusCopyCallback done_callback,
gpointer done_callback_data);
diff --git a/libnautilus-private/nautilus-file-operations.c b/libnautilus-private/nautilus-file-operations.c
index 6936a8f40..9403809ae 100644
--- a/libnautilus-private/nautilus-file-operations.c
+++ b/libnautilus-private/nautilus-file-operations.c
@@ -1644,7 +1644,7 @@ void
nautilus_file_operations_copy_move (const GList *item_uris,
GArray *relative_item_points,
const char *target_dir,
- int copy_action,
+ GdkDragAction copy_action,
GtkWidget *parent_view,
void (*done_callback) (GHashTable *debuting_uris, gpointer data),
gpointer done_callback_data)
@@ -1844,10 +1844,16 @@ nautilus_file_operations_copy_move (const GList *item_uris,
/* Distinguish Trash file on desktop from other trash folders for
* message purposes.
*/
+ /* FIXME: is_special_link finds more than just trash links,
+ * so these messages are wrong.
+ */
is_desktop_trash_link = vfs_uri_is_special_link (uri);
+
nautilus_simple_dialog
(parent_view,
FALSE,
+
+
((move_options & GNOME_VFS_XFER_REMOVESOURCE) != 0)
? (is_desktop_trash_link
? _("The Trash must remain on the desktop.")
@@ -1866,8 +1872,7 @@ nautilus_file_operations_copy_move (const GList *item_uris,
/* Don't allow recursive move/copy into itself.
* (We would get a file system error if we proceeded but it is nicer to
- * detect and report it at this level)
- */
+ * detect and report it at this level) */
if ((move_options & GNOME_VFS_XFER_LINK_ITEMS) == 0
&& (gnome_vfs_uri_equal (uri, target_dir_uri)
|| gnome_vfs_uri_is_parent (uri, target_dir_uri, TRUE))) {
@@ -1877,7 +1882,28 @@ nautilus_file_operations_copy_move (const GList *item_uris,
((move_options & GNOME_VFS_XFER_REMOVESOURCE) != 0)
? _("You cannot move a folder into itself.")
: _("You cannot copy a folder into itself."),
- _("Can't Move Into Self"),
+ ((move_options & GNOME_VFS_XFER_REMOVESOURCE) != 0)
+ ? _("Can't Move Into Self")
+ : _("Can't Copy Into Self"),
+ GNOME_STOCK_BUTTON_OK, NULL, NULL);
+
+ result = GNOME_VFS_ERROR_NOT_PERMITTED;
+ break;
+ }
+ if (gnome_vfs_uri_is_parent (target_dir_uri, uri, FALSE)) {
+ nautilus_simple_dialog
+ (parent_view,
+ FALSE,
+ ((move_options & GNOME_VFS_XFER_LINK_ITEMS) != 0)
+ ? _("You cannot link a file to itself.")
+ : ((move_options & GNOME_VFS_XFER_REMOVESOURCE) != 0)
+ ? _("You cannot move a file onto itself.")
+ : _("You cannot copy a file over itself."),
+ ((move_options & GNOME_VFS_XFER_LINK_ITEMS) != 0)
+ ? _("Can't Link To Self")
+ : ((move_options & GNOME_VFS_XFER_REMOVESOURCE) != 0)
+ ? _("Can't Move Onto Self")
+ : _("Can't Copy Over Self"),
GNOME_STOCK_BUTTON_OK, NULL, NULL);
result = GNOME_VFS_ERROR_NOT_PERMITTED;
diff --git a/libnautilus-private/nautilus-file-operations.h b/libnautilus-private/nautilus-file-operations.h
index b053d5980..931c44e2d 100644
--- a/libnautilus-private/nautilus-file-operations.h
+++ b/libnautilus-private/nautilus-file-operations.h
@@ -26,16 +26,19 @@
#define NAUTILUS_FILE_OPERATIONS_H
#include <gtk/gtkwidget.h>
+#include <libgnomevfs/gnome-vfs-types.h>
typedef void (* NautilusCopyCallback) (GHashTable *debuting_uris,
gpointer callback_data);
typedef void (* NautilusNewFolderCallback) (const char *new_folder_uri,
gpointer callback_data);
+/* FIXME: int copy_action should be an enum */
+
void nautilus_file_operations_copy_move (const GList *item_uris,
GArray *target_item_points,
const char *target_dir_uri,
- int copy_action,
+ GdkDragAction copy_action,
GtkWidget *parent_view,
NautilusCopyCallback done_callback,
gpointer done_callback_data);
diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c
index 9e367c155..03e59240a 100644
--- a/src/nautilus-window-manage-views.c
+++ b/src/nautilus-window-manage-views.c
@@ -887,9 +887,11 @@ report_sidebar_panel_failure_to_user (NautilusWindow *window, NautilusViewFrame
static void
disconnect_and_destroy_sidebar_panel (NautilusWindow *window, NautilusViewFrame *view)
{
+ gtk_widget_ref (GTK_WIDGET (view));
disconnect_view (window, view);
nautilus_window_remove_sidebar_panel (window, view);
gtk_widget_destroy (GTK_WIDGET (view));
+ gtk_widget_unref (GTK_WIDGET (view));
}
static void