diff options
author | Alexander Larsson <alexl@redhat.com> | 2004-11-04 22:45:47 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2004-11-04 22:45:47 +0000 |
commit | 0dd0f822bfd6ac97ce0b2a05712a6d7f964c192e (patch) | |
tree | 149207f111d37fbed294b691d60d9638835859ea | |
parent | 29f971f470d06c70d8fda6009a7a16b6abe784a4 (diff) | |
download | nautilus-0dd0f822bfd6ac97ce0b2a05712a6d7f964c192e.tar.gz |
Don't build libnautilus subdir
2004-11-04 Alexander Larsson <alexl@redhat.com>
* Makefile.am:
Don't build libnautilus subdir
* libnautilus-private/Makefile.am:
Don't link to libnautilus
Add new files (some from libnautilus)
Remove not used files
* libnautilus-private/apps_nautilus_preferences.schemas.in:
Remove hide_built_in_bookmarks
* libnautilus-private/nautilus-bonobo-ui.h:
* libnautilus-private/nautilus-clipboard-ui.xml:
* libnautilus-private/nautilus-clipboard.[ch]:
* libnautilus-private/nautilus-idle-queue.[ch]:
Move here from libnautilus
* libnautilus-private/nautilus-desktop-link.c:
* libnautilus-private/nautilus-global-preferences.[ch]:
Remove WEB_NAVIGATION_ENABLED ifdef and HOME_URI/BUILT_IN_BOOKMARKS
prefs
* libnautilus-private/nautilus-directory-private.h:
* libnautilus-private/nautilus-metafile-server.idl:
* libnautilus-private/nautilus-program-choosing.h:
Remove not needed header inclusions
* libnautilus-private/nautilus-sidebar-factory.[ch]:
NautilusSidebar registration and creation
* libnautilus-private/nautilus-sidebar.[ch]:
New NautilusSidebar interface
* libnautilus-private/nautilus-sidebar-functions.[ch]:
* libnautilus-private/nautilus-undo-context.[ch]:
* libnautilus-private/nautilus-view-identifier.[ch]:
* libnautilus-private/nautilus-view-query.[ch]:
Remove not needed files
* libnautilus-private/nautilus-undo-manager.[ch]:
* libnautilus-private/nautilus-undo-private.h:
* libnautilus-private/nautilus-undo-transaction.[ch]:
* libnautilus-private/nautilus-undo.[ch]:
Convert from bonobo. Some moved from libnautilus.
* libnautilus-private/nautilus-view-factory.[ch]:
NautilusView registration and creation
* libnautilus-private/nautilus-view.[ch]:
New NautilusView interface
* libnautilus-private/nautilus-window-info.[ch]:
New NautilusWindowInfo interface
* src/Makefile.am:
Don't link to libnautilus
Remove not used files
* src/nautilus-applicable-views.[ch]:
* src/nautilus-component-adapter-factory.[ch]:
* src/nautilus-view-frame-corba.[ch]:
* src/nautilus-view-frame-private.h:
* src/nautilus-view-frame.[ch]:
Removed. Not needed anymore.
* src/nautilus-bookmarks-window.c:
* src/nautilus-complex-search-bar.c:
* src/nautilus-information-panel.[ch]:
* src/nautilus-location-bar.c:
* src/nautilus-location-dialog.c:
* src/nautilus-location-entry.c:
* src/nautilus-shell-interface.idl:
* src/nautilus-side-pane.h:
* src/nautilus-sidebar-title.c:
* src/nautilus-simple-search-bar.c:
Minor changes to build.
* src/nautilus-shell.c:
Remove WEB_NAVIGATION_ENABLED
* src/nautilus-application.c:
* src/nautilus-desktop-window.c:
* src/nautilus-navigation-window-menus.c:
* src/nautilus-navigation-window.[ch]:
* src/nautilus-spatial-window.c:
* src/nautilus-window-manage-views.[ch]:
* src/nautilus-window-menus.c:
* src/nautilus-window-private.h:
* src/nautilus-window.[ch]:
Initial conversion to new NautilusView interface.
* src/file-manager/Makefile.am:
* src/file-manager/fm-bonobo-provider.[ch]:
Removed. Not needed anymore.
Temporary commented out fm-tree-view.[ch]
* src/file-manager/fm-desktop-icon-view.c:
* src/file-manager/fm-desktop-icon-view.h:
* src/file-manager/fm-directory-view.c:
* src/file-manager/fm-directory-view.h:
* src/file-manager/fm-icon-view.c:
* src/file-manager/fm-icon-view.h:
* src/file-manager/fm-list-view.c:
* src/file-manager/fm-list-view.h:
* src/file-manager/fm-properties-window.c:
* src/file-manager/fm-tree-view.h:
Initial conversion to new NautilusView interface.
88 files changed, 5168 insertions, 7865 deletions
@@ -1,3 +1,113 @@ +2004-11-04 Alexander Larsson <alexl@redhat.com> + + * Makefile.am: + Don't build libnautilus subdir + + * libnautilus-private/Makefile.am: + Don't link to libnautilus + Add new files (some from libnautilus) + Remove not used files + + * libnautilus-private/apps_nautilus_preferences.schemas.in: + Remove hide_built_in_bookmarks + + * libnautilus-private/nautilus-bonobo-ui.h: + * libnautilus-private/nautilus-clipboard-ui.xml: + * libnautilus-private/nautilus-clipboard.[ch]: + * libnautilus-private/nautilus-idle-queue.[ch]: + Move here from libnautilus + + * libnautilus-private/nautilus-desktop-link.c: + * libnautilus-private/nautilus-global-preferences.[ch]: + Remove WEB_NAVIGATION_ENABLED ifdef and HOME_URI/BUILT_IN_BOOKMARKS + prefs + + * libnautilus-private/nautilus-directory-private.h: + * libnautilus-private/nautilus-metafile-server.idl: + * libnautilus-private/nautilus-program-choosing.h: + Remove not needed header inclusions + + * libnautilus-private/nautilus-sidebar-factory.[ch]: + NautilusSidebar registration and creation + + * libnautilus-private/nautilus-sidebar.[ch]: + New NautilusSidebar interface + + * libnautilus-private/nautilus-sidebar-functions.[ch]: + * libnautilus-private/nautilus-undo-context.[ch]: + * libnautilus-private/nautilus-view-identifier.[ch]: + * libnautilus-private/nautilus-view-query.[ch]: + Remove not needed files + + * libnautilus-private/nautilus-undo-manager.[ch]: + * libnautilus-private/nautilus-undo-private.h: + * libnautilus-private/nautilus-undo-transaction.[ch]: + * libnautilus-private/nautilus-undo.[ch]: + Convert from bonobo. Some moved from libnautilus. + + * libnautilus-private/nautilus-view-factory.[ch]: + NautilusView registration and creation + + * libnautilus-private/nautilus-view.[ch]: + New NautilusView interface + + * libnautilus-private/nautilus-window-info.[ch]: + New NautilusWindowInfo interface + + * src/Makefile.am: + Don't link to libnautilus + Remove not used files + + * src/nautilus-applicable-views.[ch]: + * src/nautilus-component-adapter-factory.[ch]: + * src/nautilus-view-frame-corba.[ch]: + * src/nautilus-view-frame-private.h: + * src/nautilus-view-frame.[ch]: + Removed. Not needed anymore. + + * src/nautilus-bookmarks-window.c: + * src/nautilus-complex-search-bar.c: + * src/nautilus-information-panel.[ch]: + * src/nautilus-location-bar.c: + * src/nautilus-location-dialog.c: + * src/nautilus-location-entry.c: + * src/nautilus-shell-interface.idl: + * src/nautilus-side-pane.h: + * src/nautilus-sidebar-title.c: + * src/nautilus-simple-search-bar.c: + Minor changes to build. + + * src/nautilus-shell.c: + Remove WEB_NAVIGATION_ENABLED + + * src/nautilus-application.c: + * src/nautilus-desktop-window.c: + * src/nautilus-navigation-window-menus.c: + * src/nautilus-navigation-window.[ch]: + * src/nautilus-spatial-window.c: + * src/nautilus-window-manage-views.[ch]: + * src/nautilus-window-menus.c: + * src/nautilus-window-private.h: + * src/nautilus-window.[ch]: + Initial conversion to new NautilusView interface. + + * src/file-manager/Makefile.am: + * src/file-manager/fm-bonobo-provider.[ch]: + Removed. Not needed anymore. + Temporary commented out fm-tree-view.[ch] + + * src/file-manager/fm-desktop-icon-view.c: + * src/file-manager/fm-desktop-icon-view.h: + * src/file-manager/fm-directory-view.c: + * src/file-manager/fm-directory-view.h: + * src/file-manager/fm-icon-view.c: + * src/file-manager/fm-icon-view.h: + * src/file-manager/fm-list-view.c: + * src/file-manager/fm-list-view.h: + * src/file-manager/fm-properties-window.c: + * src/file-manager/fm-tree-view.h: + Initial conversion to new NautilusView interface. + 2004-10-29 Alexander Larsson <alexl@redhat.com> * configure.in: diff --git a/Makefile.am b/Makefile.am index 3ad326b2c..6b5145845 100644 --- a/Makefile.am +++ b/Makefile.am @@ -15,11 +15,10 @@ DESKTOP_SETTINGS_FILES= \ nautilus-file-management-properties.desktop SUBDIRS = \ - libnautilus \ libnautilus-extension \ cut-n-paste-code \ libbackground \ - libnautilus-private \ + libnautilus-private \ libnautilus-adapter \ src \ test \ diff --git a/components/services/nautilus-dependent-shared/shared-service-widgets.c b/components/services/nautilus-dependent-shared/shared-service-widgets.c deleted file mode 100644 index c88adcbd9..000000000 --- a/components/services/nautilus-dependent-shared/shared-service-widgets.c +++ /dev/null @@ -1,212 +0,0 @@ -/* -*- 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/libnautilus-private/Makefile.am b/libnautilus-private/Makefile.am index 52062cfc9..337b62017 100644 --- a/libnautilus-private/Makefile.am +++ b/libnautilus-private/Makefile.am @@ -3,7 +3,6 @@ include $(top_srcdir)/Makefile.shared lib_LTLIBRARIES=libnautilus-private.la libnautilus_private_la_LIBADD = \ - ../libnautilus/libnautilus.la \ ../libnautilus-extension/libnautilus-extension.la INCLUDES = \ @@ -43,6 +42,10 @@ marshal_sources = \ nautilus-marshal-guts.c \ $(NULL) +uidir = $(datadir)/gnome-2.0/ui +ui_DATA = \ + nautilus-clipboard-ui.xml \ + $(NULL) libnautilus_private_la_SOURCES = \ $(nautilus_metafile_server_idl_sources) \ @@ -50,6 +53,7 @@ libnautilus_private_la_SOURCES = \ nautilus-audio-player.h \ nautilus-bonobo-extensions.c \ nautilus-bonobo-extensions.h \ + nautilus-bonobo-ui.h \ nautilus-bookmark.c \ nautilus-bookmark.h \ nautilus-cell-renderer-pixbuf-emblem.c \ @@ -57,6 +61,8 @@ libnautilus_private_la_SOURCES = \ nautilus-cdrom-extensions.h \ nautilus-clipboard-monitor.c \ nautilus-clipboard-monitor.h \ + nautilus-clipboard.c \ + nautilus-clipboard.h \ nautilus-column-chooser.c \ nautilus-column-chooser.h \ nautilus-column-utilities.c \ @@ -125,6 +131,8 @@ libnautilus_private_la_SOURCES = \ nautilus-icon-factory.c \ nautilus-icon-factory.h \ nautilus-icon-private.h \ + nautilus-idle-queue.c \ + nautilus-idle-queue.h \ nautilus-iso9660.h \ nautilus-keep-last-vertical-box.c \ nautilus-keep-last-vertical-box.h \ @@ -159,8 +167,10 @@ libnautilus_private_la_SOURCES = \ nautilus-recent.c \ nautilus-search-uri.c \ nautilus-search-uri.h \ - nautilus-sidebar-functions.c \ - nautilus-sidebar-functions.h \ + nautilus-sidebar-factory.c \ + nautilus-sidebar-factory.h \ + nautilus-sidebar.c \ + nautilus-sidebar.h \ nautilus-sound.c \ nautilus-sound.h \ nautilus-theme.c \ @@ -175,20 +185,25 @@ libnautilus_private_la_SOURCES = \ nautilus-trash-monitor.h \ nautilus-tree-view-drag-dest.c \ nautilus-tree-view-drag-dest.h \ - nautilus-undo-context.c \ - nautilus-undo-context.h \ nautilus-undo-manager.c \ nautilus-undo-manager.h \ + nautilus-undo-private.h \ nautilus-undo-signal-handlers.c \ nautilus-undo-signal-handlers.h \ + nautilus-undo-transaction.c \ + nautilus-undo-transaction.h \ + nautilus-undo.c \ + nautilus-undo.h \ nautilus-vfs-directory.c \ nautilus-vfs-directory.h \ nautilus-vfs-file.c \ nautilus-vfs-file.h \ - nautilus-view-identifier.c \ - nautilus-view-identifier.h \ - nautilus-view-query.c \ - nautilus-view-query.h \ + nautilus-view-factory.c \ + nautilus-view-factory.h \ + nautilus-view.c \ + nautilus-view.h \ + nautilus-window-info.c \ + nautilus-window-info.h \ $(NULL) $(lib_LTLIBRARIES): $(dependency_static_libs) @@ -226,6 +241,7 @@ EXTRA_DIST = \ nautilus-metafile-server.idl \ nautilus-marshal.list \ $(schema_in_files) \ + $(ui_DATA) \ $(NULL) CLEANFILES = \ diff --git a/libnautilus-private/apps_nautilus_preferences.schemas.in b/libnautilus-private/apps_nautilus_preferences.schemas.in index 753ea66ce..d52031681 100644 --- a/libnautilus-private/apps_nautilus_preferences.schemas.in +++ b/libnautilus-private/apps_nautilus_preferences.schemas.in @@ -644,21 +644,6 @@ </schema> <schema> - <key>/schemas/apps/nautilus/preferences/hide_built_in_bookmarks</key> - <applyto>/apps/nautilus/preferences/hide_built_in_bookmarks</applyto> - <owner>nautilus</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Hide default bookmarks in the bookmark menu</short> - <long> - If set to true, then Nautilus will just show the user's - bookmarks in the bookmark menu. - </long> - </locale> - </schema> - - <schema> <key>/schemas/apps/nautilus/preferences/sidebar_width</key> <applyto>/apps/nautilus/preferences/sidbar_width</applyto> <owner>nautilus</owner> diff --git a/libnautilus-private/nautilus-bonobo-ui.h b/libnautilus-private/nautilus-bonobo-ui.h new file mode 100644 index 000000000..41fa3747d --- /dev/null +++ b/libnautilus-private/nautilus-bonobo-ui.h @@ -0,0 +1,130 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */ + +/* + * libnautilus: A library for nautilus view implementations. + * + * Copyright (C) 2000 Eazel, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Author: Maciej Stachowiak <mjs@eazel.com> + * + */ + +/* nautilus-bonobo-ui.h: bonobo UI paths usable by Nautilus components + * for merging menus and toolbars. + */ + +#ifndef NAUTILUS_BONOBO_UI_H +#define NAUTILUS_BONOBO_UI_H + +/** + * Components can use these menu paths with BonoboUIContainer calls to + * place entire new menus. + */ + +#define NAUTILUS_MENU_PATH_FILE_MENU "/menu/File" +#define NAUTILUS_MENU_PATH_EDIT_MENU "/menu/Edit" +#define NAUTILUS_MENU_PATH_VIEW_MENU "/menu/View" +#define NAUTILUS_MENU_PATH_GO_MENU "/menu/Go" +#define NAUTILUS_MENU_PATH_BOOKMARKS_MENU "/menu/Bookmarks" +#define NAUTILUS_MENU_PATH_PROFILER "/menu/Profiler" +#define NAUTILUS_MENU_PATH_HELP_MENU "/menu/Help" + +/** + * Components can use these menu item paths with BonoboUIContainer calls to + * merge over certain existing items. Only items that we expect to be + * merged over are listed here, to avoid making public details that might + * change later. + */ + +#define NAUTILUS_MENU_PATH_CUT_ITEM "/menu/Edit/Cut" +#define NAUTILUS_MENU_PATH_COPY_ITEM "/menu/Edit/Copy" +#define NAUTILUS_MENU_PATH_PASTE_ITEM "/menu/Edit/Paste" +#define NAUTILUS_MENU_PATH_CLEAR_ITEM "/menu/Edit/Clear" +#define NAUTILUS_MENU_PATH_SELECT_ALL_ITEM "/menu/Edit/Select All" + +#define NAUTILUS_COMMAND_CUT "/commands/Cut" +#define NAUTILUS_COMMAND_COPY "/commands/Copy" +#define NAUTILUS_COMMAND_PASTE "/commands/Paste" +#define NAUTILUS_COMMAND_CLEAR "/commands/Clear" +#define NAUTILUS_COMMAND_SELECT_ALL "/commands/Select All" + +/** + * Components can use these placeholder paths with BonoboUIContainer calls to + * insert new items in well-defined positions. + */ + +/* Use the "new items" placeholder to insert menu items like "New xxx" */ +#define NAUTILUS_MENU_PATH_NEW_ITEMS_PLACEHOLDER "/menu/File/New Items Placeholder" + +/** + * Use the "open" placeholder to insert menu items dealing with opening the + * selected item, like "Open", "Open in New Window", etc. + */ +#define NAUTILUS_MENU_PATH_OPEN_PLACEHOLDER "/menu/File/Open Placeholder" + +/** + * Use the "file items" placeholder to insert other File menu items dealing with + * individual files, such as "Show Properties" and "Rename" + */ +#define NAUTILUS_MENU_PATH_FILE_ITEMS_PLACEHOLDER "/menu/File/File Items Placeholder" + +/** + * Use the "global file items" placeholder to insert other File menu items + * dealing with nautilus as a whole, such as "Empty Trash". + */ +#define NAUTILUS_MENU_PATH_GLOBAL_FILE_ITEMS_PLACEHOLDER "/menu/File/Global File Items Placeholder" + +/** + * Use the "global edit items" placeholder to insert other Edit menu items + * dealing with nautilus as a whole, such as "Icon Captions...". + */ +#define NAUTILUS_MENU_PATH_GLOBAL_EDIT_ITEMS_PLACEHOLDER "/menu/Edit/Global Edit Items Placeholder" + +/** + * Use the "edit items" placeholder to insert other Edit menu items dealing with + * individual files, such as "Remove Custom Image" + */ +#define NAUTILUS_MENU_PATH_EDIT_ITEMS_PLACEHOLDER "/menu/Edit/Edit Items Placeholder" + +/** + * Use the "show/hide" placeholder to insert other View menu items that + * control the visibility of some piece of the UI, such as "Show/Hide Status Bar". + */ +#define NAUTILUS_MENU_PATH_SHOW_HIDE_PLACEHOLDER "/menu/View/Show Hide Placeholder" + +/** + * Use the "view items" placeholder to insert other View menu items that + * are specific to a component, such as the Icon View's layout options. + */ +#define NAUTILUS_MENU_PATH_VIEW_ITEMS_PLACEHOLDER "/menu/View/View Items Placeholder" + +/* Use the "extra help items" placeholder to add help-related items */ +#define NAUTILUS_MENU_PATH_EXTRA_HELP_ITEMS_PLACEHOLDER "/menu/Help/Extra Help Items" + +/* This holds the zooming-related items in the context menu */ +#define NAUTILUS_POPUP_PATH_ZOOM_ITEMS_PLACEHOLDER "/popups/background/Zoom Items" + +/* Components can use these paths with BonoboUIHandler calls to + * locate toolbars and toolbar items for the purpose of merging. + * Note: Not all Nautilus toolbars or toolbar items are necessarily published + * here; these are the ones whose existence components can count on. + */ + +/* Main toolbar */ +#define NAUTILUS_TOOLBAR_PATH_MAIN_TOOLBAR "/Main" + +#endif /* NAUTILUS_BONOBO_UI_H */ diff --git a/libnautilus-private/nautilus-clipboard-ui.xml b/libnautilus-private/nautilus-clipboard-ui.xml new file mode 100644 index 000000000..a6f4ebfed --- /dev/null +++ b/libnautilus-private/nautilus-clipboard-ui.xml @@ -0,0 +1,49 @@ +<Root> + +<commands> + <cmd name="Cut" + _label="Cut Text" + accel="*Control*x" + _tip="Cut the selected text to the clipboard"/> + <cmd name="Copy" + _label="_Copy Text" + accel="*Control*c" + _tip="Copy the selected text to the clipboard"/> + <cmd name="Paste" + _label="_Paste Text" + _tip="Paste the text stored on the clipboard" + accel="*Control*v"/> + <cmd name="Clear" + _tip="Remove the selected text without putting it on the clipboard" + _label="C_lear Text"/> + <cmd name="Select All" + _label="Select _All" + _tip="Select all the text in a text field" + accel="*Control*a"/> +</commands> + +<menu> + <submenu name="Edit"> + <menuitem name="Cut" + _label="Cut _Text" + pixtype="stock" pixname="gtk-cut" + verb="Cut"/> + <menuitem name="Copy" + _label="_Copy Text" + pixtype="stock" pixname="gtk-copy" + verb="Copy"/> + <menuitem name="Paste" + _label="_Paste Text" + pixtype="stock" pixname="gtk-paste" + verb="Paste"/> + <menuitem name="Clear" + _label="C_lear Text" + pixtype="stock" pixname="gtk-clear" + verb="Clear"/> + <menuitem name="Select All" + _label="Select _All" + verb="Select All"/> + </submenu> +</menu> + +</Root> diff --git a/libnautilus-private/nautilus-clipboard.c b/libnautilus-private/nautilus-clipboard.c new file mode 100644 index 000000000..9e595e103 --- /dev/null +++ b/libnautilus-private/nautilus-clipboard.c @@ -0,0 +1,512 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* nautilus-clipboard.c + * + * Nautilus Clipboard support. For now, routines to support component cut + * and paste. + * + * Copyright (C) 1999, 2000 Free Software Foundaton + * 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 Library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library 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: Rebecca Schulman <rebecka@eazel.com>, + * Darin Adler <darin@bentspoon.com> + */ + +#include <config.h> +#include "nautilus-clipboard.h" + +#include "nautilus-bonobo-ui.h" +#include <bonobo/bonobo-ui-util.h> +#include <gtk/gtkinvisible.h> +#include <gtk/gtkmain.h> +#include <gtk/gtksignal.h> +#include <gtk/gtktext.h> +#include <string.h> + +typedef void (* EditableFunction) (GtkEditable *editable); + +static void disconnect_set_up_in_control_handlers (GtkObject *object, + gpointer callback_data); +static void selection_changed_callback (GtkWidget *widget, + gpointer callback_data); + +static void +cut_callback (BonoboUIComponent *ui, + gpointer callback_data, + const char *command_name) +{ + g_assert (BONOBO_IS_UI_COMPONENT (ui)); + g_assert (strcmp (command_name, "Cut") == 0); + + gtk_editable_cut_clipboard (GTK_EDITABLE (callback_data)); +} + +static void +copy_callback (BonoboUIComponent *ui, + gpointer callback_data, + const char *command_name) +{ + g_assert (BONOBO_IS_UI_COMPONENT (ui)); + g_assert (strcmp (command_name, "Copy") == 0); + + gtk_editable_copy_clipboard (GTK_EDITABLE (callback_data)); +} + +static void +paste_callback (BonoboUIComponent *ui, + gpointer callback_data, + const char *command_name) +{ + g_assert (BONOBO_IS_UI_COMPONENT (ui)); + g_assert (strcmp (command_name, "Paste") == 0); + + gtk_editable_paste_clipboard (GTK_EDITABLE (callback_data)); +} + +static void +clear_callback (BonoboUIComponent *ui, + gpointer callback_data, + const char *command_name) +{ + g_assert (BONOBO_IS_UI_COMPONENT (ui)); + g_assert (strcmp (command_name, "Clear") == 0); + + gtk_editable_delete_selection (GTK_EDITABLE (callback_data)); +} + +static void +select_all (GtkEditable *editable) +{ + gtk_editable_set_position (editable, -1); + gtk_editable_select_region (editable, 0, -1); +} + +static void +idle_source_destroy_callback (gpointer data, + GObject *where_the_object_was) +{ + g_source_destroy (data); +} + +static gboolean +select_all_idle_callback (gpointer callback_data) +{ + GtkEditable *editable; + GSource *source; + + editable = GTK_EDITABLE (callback_data); + + source = g_object_get_data (G_OBJECT (editable), + "clipboard-select-all-source"); + + g_object_weak_unref (G_OBJECT (editable), + idle_source_destroy_callback, + source); + + g_object_set_data (G_OBJECT (editable), + "clipboard-select-all-source", + NULL); + + select_all (editable); + + return FALSE; +} + +static void +select_all_callback (BonoboUIComponent *ui, + gpointer callback_data, + const char *command_name) +{ + GSource *source; + GtkEditable *editable; + + g_assert (BONOBO_IS_UI_COMPONENT (ui)); + g_assert (strcmp (command_name, "Select All") == 0); + + editable = GTK_EDITABLE (callback_data); + + if (g_object_get_data (G_OBJECT (editable), + "clipboard-select-all-source")) { + return; + } + + source = g_idle_source_new (); + g_source_set_callback (source, select_all_idle_callback, editable, NULL); + g_object_weak_ref (G_OBJECT (editable), + idle_source_destroy_callback, + source); + g_source_attach (source, NULL); + g_source_unref (source); + + g_object_set_data (G_OBJECT (editable), + "clipboard-select-all-source", + source); +} + +static void +set_menu_item_sensitive (BonoboUIComponent *component, + const char *path, + gboolean sensitive) +{ + bonobo_ui_component_set_prop (component, path, + "sensitive", sensitive ? "1" : "0", NULL); + +} + +#if 0 +static void +set_paste_sensitive_if_clipboard_contains_data (BonoboUIComponent *component) +{ + gboolean clipboard_contains_data; + + /* FIXME: This check is wrong, because gdk_selection_owner_get + * will only return non-null if the clipboard owner is in + * process, which may not be the case, and we may still be + * able to paste data. + */ + /* FIXME: PRIMARY is wrong here. We are interested in + * CLIPBOARD, not PRIMARY. + */ + /* FIXME: This doesn't tell us what kind of data is on the + * clipboard, and we only want to be sensitive if it's text. + */ + clipboard_contains_data = + (gdk_selection_owner_get (GDK_SELECTION_PRIMARY) != NULL); + + set_menu_item_sensitive (component, + NAUTILUS_COMMAND_PASTE, + clipboard_contains_data); +} +#endif + +static void +set_clipboard_menu_items_sensitive (BonoboUIComponent *component) +{ + set_menu_item_sensitive (component, + NAUTILUS_COMMAND_CUT, + TRUE); + set_menu_item_sensitive (component, + NAUTILUS_COMMAND_COPY, + TRUE); + set_menu_item_sensitive (component, + NAUTILUS_COMMAND_CLEAR, + TRUE); +} + +static void +set_clipboard_menu_items_insensitive (BonoboUIComponent *component) +{ + set_menu_item_sensitive (component, + NAUTILUS_COMMAND_CUT, + FALSE); + set_menu_item_sensitive (component, + NAUTILUS_COMMAND_COPY, + FALSE); + set_menu_item_sensitive (component, + NAUTILUS_COMMAND_CLEAR, + FALSE); +} + +typedef struct { + BonoboUIComponent *component; + Bonobo_UIContainer container; + gboolean editable_shares_selection_changes; +} TargetCallbackData; + +static gboolean +clipboard_items_are_merged_in (GtkWidget *widget) +{ + return GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), + "Nautilus:clipboard_menu_items_merged")); +} + +static void +set_clipboard_items_are_merged_in (GObject *widget_as_object, + gboolean merged_in) +{ + g_object_set_data (widget_as_object, + "Nautilus:clipboard_menu_items_merged", + GINT_TO_POINTER (merged_in)); +} + +static void +merge_in_clipboard_menu_items (GObject *widget_as_object, + TargetCallbackData *target_data) +{ + BonoboUIComponent *ui; + Bonobo_UIContainer container; + gboolean add_selection_callback; + + g_assert (target_data != NULL); + ui = target_data->component; + container = target_data->container; + add_selection_callback = target_data->editable_shares_selection_changes; + + if (ui == NULL || container == CORBA_OBJECT_NIL) { + return; + } + + bonobo_ui_component_set_container (ui, container, NULL); + bonobo_ui_component_freeze (ui, NULL); + bonobo_ui_util_set_ui (ui, + DATADIR, + "nautilus-clipboard-ui.xml", + "nautilus", NULL); + + if (add_selection_callback) { + g_signal_connect_after (widget_as_object, "selection_changed", + G_CALLBACK (selection_changed_callback), target_data); + selection_changed_callback (GTK_WIDGET (widget_as_object), + target_data); + + } else { + /* If we don't use sensitivity, everything should be on */ + set_clipboard_menu_items_sensitive (ui); + } + set_clipboard_items_are_merged_in (widget_as_object, TRUE); + bonobo_ui_component_thaw (ui, NULL); +} + +static void +merge_out_clipboard_menu_items (GObject *widget_as_object, + TargetCallbackData *target_data) + +{ + BonoboUIComponent *ui; + gboolean selection_callback_was_added; + + g_assert (target_data != NULL); + ui = BONOBO_UI_COMPONENT (target_data->component); + selection_callback_was_added = target_data->editable_shares_selection_changes; + + if (ui == NULL) { + return; + } + + bonobo_ui_component_unset_container (ui, NULL); + + if (selection_callback_was_added) { + g_signal_handlers_disconnect_matched (widget_as_object, + G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, + 0, 0, NULL, + G_CALLBACK (selection_changed_callback), + target_data); + } + set_clipboard_items_are_merged_in (widget_as_object, FALSE); +} + +static gboolean +focus_changed_callback (GtkWidget *widget, + GdkEventAny *event, + gpointer callback_data) +{ + /* Connect the component to the container if the widget has focus. */ + if (GTK_WIDGET_HAS_FOCUS (widget)) { + if (!clipboard_items_are_merged_in (widget)) { + merge_in_clipboard_menu_items (G_OBJECT (widget), callback_data); + } + } else { + if (clipboard_items_are_merged_in (widget)) { + merge_out_clipboard_menu_items (G_OBJECT (widget), callback_data); + } + } + + return FALSE; +} + +static void +selection_changed_callback (GtkWidget *widget, + gpointer callback_data) +{ + TargetCallbackData *target_data; + BonoboUIComponent *component; + GtkEditable *editable; + int start, end; + + target_data = (TargetCallbackData *) callback_data; + g_assert (target_data != NULL); + + component = target_data->component; + editable = GTK_EDITABLE (widget); + + if (gtk_editable_get_selection_bounds (editable, &start, &end) && start != end) { + set_clipboard_menu_items_sensitive (component); + } else { + set_clipboard_menu_items_insensitive (component); + } +} + +static void +target_destroy_callback (GtkObject *object, + gpointer callback_data) +{ + TargetCallbackData *target_data; + + g_assert (callback_data != NULL); + target_data = callback_data; + + if (target_data->component != NULL) { + bonobo_ui_component_unset_container (target_data->component, NULL); + bonobo_object_unref (target_data->component); + target_data->component = NULL; + } + bonobo_object_release_unref (target_data->container, NULL); + target_data->container = CORBA_OBJECT_NIL; +} + +static TargetCallbackData * +initialize_clipboard_component_with_callback_data (GtkEditable *target, + Bonobo_UIContainer ui_container, + gboolean shares_selection_changes) +{ + BonoboUIVerb verbs [] = { + BONOBO_UI_VERB ("Cut", cut_callback), + BONOBO_UI_VERB ("Copy", copy_callback), + BONOBO_UI_VERB ("Paste", paste_callback), + BONOBO_UI_VERB ("Clear", clear_callback), + BONOBO_UI_VERB ("Select All", select_all_callback), + BONOBO_UI_VERB_END + }; + BonoboUIComponent *ui; + TargetCallbackData *target_data; + + /* Create the UI component and set up the verbs. */ + ui = bonobo_ui_component_new_default (); + bonobo_ui_component_add_verb_list_with_data (ui, verbs, target); + + /* Do the actual connection of the UI to the container at + * focus time, and disconnect at both focus and destroy + * time. + */ + target_data = g_new (TargetCallbackData, 1); + target_data->component = ui; + target_data->container = bonobo_object_dup_ref (ui_container, NULL); + target_data->editable_shares_selection_changes = shares_selection_changes; + + return target_data; +} + +void +nautilus_clipboard_set_up_editable (GtkEditable *target, + Bonobo_UIContainer ui_container, + gboolean shares_selection_changes) +{ + TargetCallbackData *target_data; + + g_return_if_fail (GTK_IS_EDITABLE (target)); + g_return_if_fail (ui_container != CORBA_OBJECT_NIL); + + target_data = initialize_clipboard_component_with_callback_data + (target, + ui_container, + shares_selection_changes); + + g_signal_connect (target, "focus_in_event", + G_CALLBACK (focus_changed_callback), target_data); + g_signal_connect (target, "focus_out_event", + G_CALLBACK (focus_changed_callback), target_data); + g_signal_connect (target, "destroy", + G_CALLBACK (target_destroy_callback), target_data); + + g_object_weak_ref (G_OBJECT (target), (GWeakNotify) g_free, target_data); + + /* Call the focus changed callback once to merge if the window is + * already in focus. + */ + focus_changed_callback (GTK_WIDGET (target), NULL, target_data); +} + +static gboolean +widget_was_set_up_with_selection_sensitivity (GtkWidget *widget) +{ + return GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), + "Nautilus:shares_selection_changes")); +} + +static gboolean +first_focus_callback (GtkWidget *widget, + GdkEventAny *event, + gpointer callback_data) +{ + /* Don't set up the clipboard again on future focus_in's. This + * is one-time work. + */ + disconnect_set_up_in_control_handlers (GTK_OBJECT (widget), callback_data); + + /* Do the rest of the setup. */ + nautilus_clipboard_set_up_editable + (GTK_EDITABLE (widget), + bonobo_control_get_remote_ui_container (BONOBO_CONTROL (callback_data), NULL), + widget_was_set_up_with_selection_sensitivity (widget)); + + return FALSE; +} + +static void +control_destroyed_callback (GtkObject *object, + gpointer callback_data) +{ + disconnect_set_up_in_control_handlers (object, callback_data); +} + +void +nautilus_clipboard_set_up_editable_in_control (GtkEditable *target, + BonoboControl *control, + gboolean shares_selection_changes) +{ + g_return_if_fail (GTK_IS_EDITABLE (target)); + g_return_if_fail (BONOBO_IS_CONTROL (control)); + + if (GTK_WIDGET_HAS_FOCUS (target)) { + nautilus_clipboard_set_up_editable + (target, + bonobo_control_get_remote_ui_container (control, NULL), + shares_selection_changes); + return; + } + + /* Use lazy initialization, so that we wait until after + * embedding. At that point, the UI container will be set up, + * but it's not necessarily set up now. + */ + /* We'd like to use gtk_signal_connect_while_alive, but it's + * not compatible with gtk_signal_disconnect calls. + */ + g_object_set_data (G_OBJECT (target), "Nautilus:shares_selection_changes", + GINT_TO_POINTER (shares_selection_changes)); + g_signal_connect (target, "focus_in_event", + G_CALLBACK (first_focus_callback), control); + g_signal_connect (target, "destroy", + G_CALLBACK (control_destroyed_callback), control); +} + +static void +disconnect_set_up_in_control_handlers (GtkObject *object, + gpointer callback_data) +{ + g_signal_handlers_disconnect_matched (object, + G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, + 0, 0, NULL, + G_CALLBACK (first_focus_callback), + callback_data); + g_signal_handlers_disconnect_matched (object, + G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, + 0, 0, NULL, + G_CALLBACK (control_destroyed_callback), + callback_data); +} diff --git a/libnautilus-private/nautilus-clipboard.h b/libnautilus-private/nautilus-clipboard.h new file mode 100644 index 000000000..20b15511d --- /dev/null +++ b/libnautilus-private/nautilus-clipboard.h @@ -0,0 +1,54 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* fm-directory-view.h + * + * Copyright (C) 1999, 2000 Free Software Foundaton + * Copyright (C) 2000 Eazel, Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library 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. + * + * Author: Rebecca Schulman <rebecka@eazel.com> + */ + +#ifndef NAUTILUS_CLIPBOARD_H +#define NAUTILUS_CLIPBOARD_H + +#include <gtk/gtkeditable.h> +#include <bonobo/bonobo-control.h> + +/* This makes this editable put clipboard commands into the passed UI + * container when the editable is in focus. Callers in Nautilus + * normally get the UI container from + * nautilus_window_get_bonobo_ui_container. */ +/* The shares selection changes argument should be set to true if the + * editable is a widget that uses the signal "selection_changed" to + * tell others about text selection changes. The NautilusEntry widget + * is currently the only widget in nautilus that shares selection + * changes. */ +void nautilus_clipboard_set_up_editable (GtkEditable *target, + Bonobo_UIContainer container, + gboolean shares_selection_changes); + +/* Components should use this convenient cover instead of the call + * above. This cover waits until the UI container shows up, so it can be + * called even before the control has a UI container. Set the + */ +/* Set the shares_selection changes as for the nautilus_clipboard_set_up_editable */ +void nautilus_clipboard_set_up_editable_in_control (GtkEditable *target, + BonoboControl *control, + gboolean shares_selection_changes); + +#endif /* NAUTILUS_CLIPBOARD_H */ diff --git a/libnautilus-private/nautilus-desktop-link.c b/libnautilus-private/nautilus-desktop-link.c index 5d3ae3440..2d88a5f2b 100644 --- a/libnautilus-private/nautilus-desktop-link.c +++ b/libnautilus-private/nautilus-desktop-link.c @@ -63,7 +63,6 @@ static void trash_state_changed_callback (NautilusTrashMonitor *trash_monito gboolean state, gpointer callback_data); static void nautilus_desktop_link_changed (NautilusDesktopLink *link); -static void home_uri_changed (gpointer callback_data); EEL_CLASS_BOILERPLATE (NautilusDesktopLink, nautilus_desktop_link, @@ -133,16 +132,9 @@ nautilus_desktop_link_new (NautilusDesktopLinkType type) link->details->display_name = eel_preferences_get (NAUTILUS_PREFERENCES_DESKTOP_HOME_NAME); -#ifdef WEB_NAVIGATION_ENABLED - link->details->activation_uri = eel_preferences_get (NAUTILUS_PREFERENCES_HOME_URI); -#else link->details->activation_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ()); -#endif link->details->icon = g_strdup ("gnome-fs-home"); - eel_preferences_add_callback (NAUTILUS_PREFERENCES_HOME_URI, - home_uri_changed, - link); eel_preferences_add_callback (NAUTILUS_PREFERENCES_DESKTOP_HOME_NAME, home_name_changed, link); @@ -301,24 +293,6 @@ trash_state_changed_callback (NautilusTrashMonitor *trash_monitor, nautilus_desktop_link_changed (link); } -static void -home_uri_changed (gpointer callback_data) -{ - NautilusDesktopLink *link; - - link = NAUTILUS_DESKTOP_LINK (callback_data); - - g_free (link->details->activation_uri); -#ifdef WEB_NAVIGATION_ENABLED - link->details->activation_uri = eel_preferences_get (NAUTILUS_PREFERENCES_HOME_URI); -#else - link->details->activation_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ()); -#endif - - nautilus_desktop_link_changed (link); -} - - gboolean nautilus_desktop_link_can_rename (NautilusDesktopLink *link) { @@ -383,9 +357,6 @@ desktop_link_finalize (GObject *object) } if (link->details->type == NAUTILUS_DESKTOP_LINK_HOME) { - eel_preferences_remove_callback (NAUTILUS_PREFERENCES_HOME_URI, - home_uri_changed, - link); eel_preferences_remove_callback (NAUTILUS_PREFERENCES_DESKTOP_HOME_NAME, home_name_changed, link); diff --git a/libnautilus-private/nautilus-directory-private.h b/libnautilus-private/nautilus-directory-private.h index d60554ea1..c00986bb5 100644 --- a/libnautilus-private/nautilus-directory-private.h +++ b/libnautilus-private/nautilus-directory-private.h @@ -32,7 +32,7 @@ #include <libnautilus-private/nautilus-file.h> #include <libnautilus-private/nautilus-metafile-server.h> #include <libnautilus-private/nautilus-monitor.h> -#include <libnautilus/nautilus-idle-queue.h> +#include <libnautilus-private/nautilus-idle-queue.h> #include <libnautilus-extension/nautilus-info-provider.h> #include <libxml/tree.h> diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c index 5a12b561e..0492dce8e 100644 --- a/libnautilus-private/nautilus-global-preferences.c +++ b/libnautilus-private/nautilus-global-preferences.c @@ -52,7 +52,6 @@ static const char *EXTRA_MONITOR_PATHS[] = { "/system/gnome_vfs", static void global_preferences_install_defaults (void); static void global_preferences_register_enumerations (void); static gpointer default_font_callback (void); -static gpointer default_home_location_callback (void); static void import_old_preferences_if_needed (void); static gpointer default_home_link_name (void); static gpointer default_computer_link_name (void); @@ -382,10 +381,6 @@ static const PreferenceDefault preference_defaults[] = { NULL, NULL, NULL }, - { NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS, - PREFERENCE_BOOLEAN, - GINT_TO_POINTER (FALSE) - }, /* FIXME bugzilla.gnome.org 41245: Saved in pixels instead of in %? */ { NAUTILUS_PREFERENCES_SIDEBAR_WIDTH, PREFERENCE_INTEGER, @@ -427,11 +422,6 @@ static const PreferenceDefault preference_defaults[] = { NULL, NULL, "default_folder_viewer" }, - /* Home URI */ - { NAUTILUS_PREFERENCES_HOME_URI, - PREFERENCE_STRING, - NULL, default_home_location_callback, g_free - }, { NAUTILUS_PREFERENCES_DESKTOP_FONT, PREFERENCE_STRING, NULL, default_font_callback, g_free @@ -666,12 +656,6 @@ default_font_callback (void) return g_strdup ("sans 12"); } -static gpointer -default_home_location_callback (void) -{ - return gnome_vfs_get_uri_from_local_path (g_get_home_dir ()); -} - /* * Public functions */ diff --git a/libnautilus-private/nautilus-global-preferences.h b/libnautilus-private/nautilus-global-preferences.h index 5e8d628b0..3596681bc 100644 --- a/libnautilus-private/nautilus-global-preferences.h +++ b/libnautilus-private/nautilus-global-preferences.h @@ -71,10 +71,6 @@ typedef enum /* Sidebar panels */ #define NAUTILUS_PREFERENCES_TREE_SHOW_ONLY_DIRECTORIES "sidebar_panels/tree/show_only_directories" -/* Navigation */ -#define NAUTILUS_PREFERENCES_HOME_URI "preferences/home_uri" -#define NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS "preferences/hide_built_in_bookmarks" - /* Single/Double click preference */ #define NAUTILUS_PREFERENCES_CLICK_POLICY "preferences/click_policy" diff --git a/libnautilus-private/nautilus-idle-queue.c b/libnautilus-private/nautilus-idle-queue.c new file mode 100644 index 000000000..431b8d39a --- /dev/null +++ b/libnautilus-private/nautilus-idle-queue.c @@ -0,0 +1,144 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */ + +/* + * libnautilus: A library for nautilus view implementations. + * + * Copyright (C) 2001 Eazel, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Author: Darin Adler <darin@bentspoon.com> + * + */ + +#include <config.h> +#include "nautilus-idle-queue.h" + +#include <gtk/gtkmain.h> + +struct NautilusIdleQueue { + GList *functions; + guint idle_id; + gboolean in_idle; + gboolean destroy; +}; + +typedef struct { + GFunc callback; + gpointer data; + gpointer callback_data; + GFreeFunc free_callback_data; +} QueuedFunction; + +static gboolean +execute_queued_functions (gpointer callback_data) +{ + NautilusIdleQueue *queue; + GList *functions, *node; + QueuedFunction *function; + + queue = callback_data; + + /* We could receive more incoming functions while dispatching + * these, so keep going until the queue is empty. + */ + queue->in_idle = TRUE; + while (queue->functions != NULL) { + functions = g_list_reverse (queue->functions); + queue->functions = NULL; + + for (node = functions; node != NULL; node = node->next) { + function = node->data; + + if (!queue->destroy) { + (* function->callback) (function->data, function->callback_data); + } + if (function->free_callback_data != NULL) { + (* function->free_callback_data) (function->callback_data); + } + + g_free (function); + } + + g_list_free (functions); + } + queue->in_idle = FALSE; + + queue->idle_id = 0; + + if (queue->destroy) { + nautilus_idle_queue_destroy (queue); + } + + return FALSE; +} + +NautilusIdleQueue * +nautilus_idle_queue_new (void) +{ + return g_new0 (NautilusIdleQueue, 1); +} + +void +nautilus_idle_queue_add (NautilusIdleQueue *queue, + GFunc callback, + gpointer data, + gpointer callback_data, + GFreeFunc free_callback_data) +{ + QueuedFunction *function; + + function = g_new (QueuedFunction, 1); + function->callback = callback; + function->data = data; + function->callback_data = callback_data; + function->free_callback_data = free_callback_data; + + queue->functions = g_list_prepend (queue->functions, function); + + if (queue->idle_id == 0) { + queue->idle_id = g_idle_add (execute_queued_functions, queue); + } +} + +void +nautilus_idle_queue_destroy (NautilusIdleQueue *queue) +{ + GList *node; + QueuedFunction *function; + + if (queue->in_idle) { + queue->destroy = TRUE; + return; + } + + for (node = queue->functions; node != NULL; node = node->next) { + function = node->data; + + if (function->free_callback_data != NULL) { + (* function->free_callback_data) (function->callback_data); + } + + g_free (function); + } + + g_list_free (queue->functions); + + if (queue->idle_id != 0) { + g_source_remove (queue->idle_id); + } + + g_free (queue); +} diff --git a/libnautilus-private/nautilus-idle-queue.h b/libnautilus-private/nautilus-idle-queue.h new file mode 100644 index 000000000..3446973d3 --- /dev/null +++ b/libnautilus-private/nautilus-idle-queue.h @@ -0,0 +1,45 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */ + +/* + * libnautilus: A library for nautilus view implementations. + * + * Copyright (C) 2001 Eazel, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Author: Darin Adler <darin@bentspoon.com> + * + */ + +#ifndef NAUTILUS_IDLE_QUEUE_H +#define NAUTILUS_IDLE_QUEUE_H + +#include <glib/gtypes.h> + +G_BEGIN_DECLS + +typedef struct NautilusIdleQueue NautilusIdleQueue; + +NautilusIdleQueue *nautilus_idle_queue_new (void); +void nautilus_idle_queue_add (NautilusIdleQueue *queue, + GFunc callback, + gpointer data, + gpointer callback_data, + GFreeFunc free_callback_data); +void nautilus_idle_queue_destroy (NautilusIdleQueue *queue); + +G_END_DECLS + +#endif /* NAUTILUS_IDLE_QUEUE_H */ diff --git a/libnautilus-private/nautilus-metafile-server.idl b/libnautilus-private/nautilus-metafile-server.idl index afa1a6617..0410225e0 100644 --- a/libnautilus-private/nautilus-metafile-server.idl +++ b/libnautilus-private/nautilus-metafile-server.idl @@ -24,10 +24,10 @@ #define NAUTILUS_METAFILE_SERVER_IDL_INCLUDED #include <Bonobo.idl> -#include <libnautilus/nautilus-view-component.idl> module Nautilus { + typedef string URI; typedef sequence<string> FileNameList; /* NautilusFiles creates (and registers) MetafileMonitors in order diff --git a/libnautilus-private/nautilus-program-choosing.h b/libnautilus-private/nautilus-program-choosing.h index 5c3c0a1e1..48d5c3249 100644 --- a/libnautilus-private/nautilus-program-choosing.h +++ b/libnautilus-private/nautilus-program-choosing.h @@ -29,15 +29,12 @@ #include <gtk/gtkwindow.h> #include <libgnomevfs/gnome-vfs-mime-handlers.h> #include <libnautilus-private/nautilus-file.h> -#include <libnautilus-private/nautilus-view-identifier.h> #define NAUTILUS_COMMAND_SPECIFIER "command:" #define NAUTILUS_DESKTOP_COMMAND_SPECIFIER "desktop-file:" typedef void (*NautilusApplicationChoiceCallback) (GnomeVFSMimeApplication *application, gpointer callback_data); -typedef void (*NautilusComponentChoiceCallback) (NautilusViewIdentifier *identifier, - gpointer callback_data); void nautilus_launch_application (GnomeVFSMimeApplication *application, NautilusFile *file, diff --git a/libnautilus-private/nautilus-sidebar-factory.c b/libnautilus-private/nautilus-sidebar-factory.c new file mode 100644 index 000000000..535a867cf --- /dev/null +++ b/libnautilus-private/nautilus-sidebar-factory.c @@ -0,0 +1,91 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- + + nautilus-sidebar-factory.c: register and create NautilusSidebars + + Copyright (C) 2004 Red Hat 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. + + Author: Alexander Larsson <alexl@redhat.com> +*/ + +#include <string.h> +#include "nautilus-sidebar-factory.h" + +static GList *registered_sidebars; + +void +nautilus_sidebar_factory_register (NautilusSidebarInfo *sidebar_info) +{ + g_return_if_fail (sidebar_info != NULL); + g_return_if_fail (sidebar_info->id != NULL); + g_return_if_fail (nautilus_sidebar_factory_lookup (sidebar_info->id) == NULL); + + registered_sidebars = g_list_append (registered_sidebars, sidebar_info); + +} + +const NautilusSidebarInfo * +nautilus_sidebar_factory_lookup (char *id) +{ + GList *l; + NautilusSidebarInfo *sidebar_info; + + g_return_val_if_fail (id != NULL, NULL); + + for (l = registered_sidebars; l != NULL; l = l->next) { + sidebar_info = l->data; + + if (strcmp (sidebar_info->id, id) == 0) { + return sidebar_info; + } + } + return NULL; + +} + +NautilusSidebar * +nautilus_sidebar_factory_create (char *id, + NautilusWindowInfo *window) +{ + const NautilusSidebarInfo *sidebar_info; + + sidebar_info = nautilus_sidebar_factory_lookup (id); + if (sidebar_info == NULL) { + return NULL; + } + + return sidebar_info->create (window); +} + +GList * +nautilus_sidebar_factory_enumerate_sidebars (void) +{ + GList *l, *res; + const NautilusSidebarInfo *sidebar_info; + + res = NULL; + + for (l = registered_sidebars; l != NULL; l = l->next) { + sidebar_info = l->data; + + res = g_list_prepend (res, g_strdup (sidebar_info->id)); + } + + return g_list_reverse (res); +} + + diff --git a/libnautilus-private/nautilus-sidebar-factory.h b/libnautilus-private/nautilus-sidebar-factory.h new file mode 100644 index 000000000..22917820e --- /dev/null +++ b/libnautilus-private/nautilus-sidebar-factory.h @@ -0,0 +1,49 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- + + nautilus-sidebar-factory.h: register and create NautilusSidebars + + Copyright (C) 2004 Red Hat 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. + + Author: Alexander Larsson <alexl@redhat.com> +*/ + +#ifndef NAUTILUS_SIDEBAR_FACTORY_H +#define NAUTILUS_SIDEBAR_FACTORY_H + +#include <libnautilus-private/nautilus-sidebar.h> +#include <libnautilus-private/nautilus-window-info.h> + +G_BEGIN_DECLS + +typedef struct _NautilusSidebarInfo NautilusSidebarInfo; + +struct _NautilusSidebarInfo { + char *id; + NautilusSidebar * (*create) (NautilusWindowInfo *window); +}; + + +void nautilus_sidebar_factory_register (NautilusSidebarInfo *sidebar_info); +const NautilusSidebarInfo *nautilus_sidebar_factory_lookup (char *id); +NautilusSidebar * nautilus_sidebar_factory_create (char *id, + NautilusWindowInfo *window); +GList * nautilus_sidebar_factory_enumerate_sidebars (void); + +G_END_DECLS + +#endif /* NAUTILUS_SIDEBAR_FACTORY_H */ diff --git a/libnautilus-private/nautilus-sidebar-functions.c b/libnautilus-private/nautilus-sidebar-functions.c deleted file mode 100644 index 4f71c3c3e..000000000 --- a/libnautilus-private/nautilus-sidebar-functions.c +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* nautilus-sidebar-functions.c - Sidebar functions used throughout Nautilus. - - Copyright (C) 2001 Eazel, Inc. - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. 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> -*/ - -#include <config.h> -#include "nautilus-sidebar-functions.h" - -#include "nautilus-view-identifier.h" -#include <eel/eel-glib-extensions.h> -#include <eel/eel-string.h> - -static int -compare_view_identifiers (gconstpointer a, gconstpointer b) -{ - NautilusViewIdentifier *idenfifier_a; - NautilusViewIdentifier *idenfifier_b; - - g_assert (a != NULL); - g_assert (b != NULL); - - idenfifier_a = (NautilusViewIdentifier*) a; - idenfifier_b = (NautilusViewIdentifier*) b; - - return eel_strcmp (idenfifier_a->name, idenfifier_b->name); -} - -/* Make a query to find out what sidebar panels are available. */ -static GList * -sidebar_get_sidebar_panel_view_identifiers (void) -{ - CORBA_Environment ev; - const char *query; - Bonobo_ServerInfoList *bonobo_activation_result; - guint i; - NautilusViewIdentifier *id; - GList *view_identifiers; - - CORBA_exception_init (&ev); - - /* get all the sidebars, and ignore the "loser" ones */ - query = "nautilus:sidebar_panel_name.defined() AND repo_ids.has ('IDL:Bonobo/Control:1.0') AND (NOT test_only == true)"; - - bonobo_activation_result = bonobo_activation_query (query, NULL, &ev); - - view_identifiers = NULL; - - if (ev._major == CORBA_NO_EXCEPTION && bonobo_activation_result != NULL) { - for (i = 0; i < bonobo_activation_result->_length; i++) { - id = nautilus_view_identifier_new_from_sidebar_panel - (&bonobo_activation_result->_buffer[i]); - view_identifiers = g_list_prepend (view_identifiers, id); - } - view_identifiers = g_list_reverse (view_identifiers); - } - - if (bonobo_activation_result != NULL) { - CORBA_free (bonobo_activation_result); - } - - CORBA_exception_free (&ev); - - view_identifiers = g_list_sort (view_identifiers, compare_view_identifiers); - - return view_identifiers; -} - -GList * -nautilus_sidebar_get_all_sidebar_panel_view_identifiers (void) -{ - return sidebar_get_sidebar_panel_view_identifiers (); -} diff --git a/libnautilus-private/nautilus-sidebar-functions.h b/libnautilus-private/nautilus-sidebar-functions.h deleted file mode 100644 index 03d007d77..000000000 --- a/libnautilus-private/nautilus-sidebar-functions.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* nautilus-sidebar-functions.h - Sidebar functions used throughout Nautilus. - - Copyright (C) 2001 Eazel, Inc. - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. 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> -*/ - -#ifndef NAUTILUS_SIDEBAR_FUNCTIONS_H -#define NAUTILUS_SIDEBAR_FUNCTIONS_H - -#include <glib/glist.h> - -GList *nautilus_sidebar_get_all_sidebar_panel_view_identifiers (void); - -#endif /* NAUTILUS_SIDEBAR_FUNCTIONS_H */ - diff --git a/libnautilus-private/nautilus-sidebar.c b/libnautilus-private/nautilus-sidebar.c new file mode 100644 index 000000000..2f39db63e --- /dev/null +++ b/libnautilus-private/nautilus-sidebar.c @@ -0,0 +1,116 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- + + nautilus-sidebar.c: Interface for nautilus sidebar plugins + + Copyright (C) 2004 Red Hat 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. + + Author: Alexander Larsson <alexl@redhat.com> +*/ + +#include <config.h> +#include "nautilus-sidebar.h" + +enum { + TAB_ICON_CHANGED, + ZOOM_PARAMETERS_CHANGED, + ZOOM_LEVEL_CHANGED, + LAST_SIGNAL +}; + +static guint nautilus_sidebar_signals[LAST_SIGNAL] = { 0 }; + +static void +nautilus_sidebar_base_init (gpointer g_class) +{ + static gboolean initialized = FALSE; + + if (! initialized) { + nautilus_sidebar_signals[TAB_ICON_CHANGED] = + g_signal_new ("tab_icon_changed", + NAUTILUS_TYPE_SIDEBAR, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (NautilusSidebarIface, tab_icon_changed), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + initialized = TRUE; + } +} + +GType +nautilus_sidebar_get_type (void) +{ + static GType type = 0; + + if (!type) { + static const GTypeInfo info = { + sizeof (NautilusSidebarIface), + nautilus_sidebar_base_init, + NULL, + NULL, + NULL, + NULL, + 0, + 0, + NULL + }; + + type = g_type_register_static (G_TYPE_INTERFACE, + "NautilusSidebar", + &info, 0); + g_type_interface_add_prerequisite (type, GTK_TYPE_WIDGET); + } + + return type; +} + + +const char * +nautilus_sidebar_get_sidebar_id (NautilusSidebar *sidebar) +{ + g_return_val_if_fail (NAUTILUS_IS_SIDEBAR (sidebar), NULL); + + return (* NAUTILUS_SIDEBAR_GET_IFACE (sidebar)->get_sidebar_id) (sidebar); +} + +char * +nautilus_sidebar_get_tab_label (NautilusSidebar *sidebar) +{ + g_return_val_if_fail (NAUTILUS_IS_SIDEBAR (sidebar), NULL); + + return (* NAUTILUS_SIDEBAR_GET_IFACE (sidebar)->get_tab_label) (sidebar); +} + +GdkPixbuf * +nautilus_sidebar_get_tab_icon (NautilusSidebar *sidebar) +{ + g_return_val_if_fail (NAUTILUS_IS_SIDEBAR (sidebar), NULL); + + return (* NAUTILUS_SIDEBAR_GET_IFACE (sidebar)->get_tab_icon) (sidebar); +} + +void +nautilus_sidebar_is_visible_changed (NautilusSidebar *sidebar, + gboolean is_visible) +{ + g_return_if_fail (NAUTILUS_IS_SIDEBAR (sidebar)); + + (* NAUTILUS_SIDEBAR_GET_IFACE (sidebar)->is_visible_changed) (sidebar, + is_visible); +} diff --git a/libnautilus-private/nautilus-sidebar.h b/libnautilus-private/nautilus-sidebar.h new file mode 100644 index 000000000..4bdade1f1 --- /dev/null +++ b/libnautilus-private/nautilus-sidebar.h @@ -0,0 +1,78 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- + + nautilus-sidebar.h: Interface for nautilus sidebar plugins + + Copyright (C) 2004 Red Hat 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. + + Author: Alexander Larsson <alexl@redhat.com> +*/ + +#ifndef NAUTILUS_SIDEBAR_H +#define NAUTILUS_SIDEBAR_H + +#include <glib-object.h> +#include <gtk/gtkwidget.h> + +G_BEGIN_DECLS + +#define NAUTILUS_TYPE_SIDEBAR (nautilus_sidebar_get_type ()) +#define NAUTILUS_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_SIDEBAR, NautilusSidebar)) +#define NAUTILUS_IS_SIDEBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_SIDEBAR)) +#define NAUTILUS_SIDEBAR_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NAUTILUS_TYPE_SIDEBAR, NautilusSidebarIface)) + +typedef struct _NautilusSidebar NautilusSidebar; /* dummy typedef */ +typedef struct _NautilusSidebarIface NautilusSidebarIface; + +/* Must also be a GtkWidget */ +struct _NautilusSidebarIface +{ + GTypeInterface g_iface; + + /* Signals: */ + void (* tab_icon_changed) (NautilusSidebar *sidebar); + + /* VTable: */ + const char * (* get_sidebar_id) (NautilusSidebar *sidebar); + char * (* get_tab_label) (NautilusSidebar *sidebar); + GdkPixbuf * (* get_tab_icon) (NautilusSidebar *sidebar); + void (* is_visible_changed) (NautilusSidebar *sidebar, + gboolean is_visible); + + + /* Padding for future expansion */ + void (*_reserved1) (void); + void (*_reserved2) (void); + void (*_reserved3) (void); + void (*_reserved4) (void); + void (*_reserved5) (void); + void (*_reserved6) (void); + void (*_reserved7) (void); + void (*_reserved8) (void); +}; + +GType nautilus_sidebar_get_type (void); + +const char *nautilus_sidebar_get_sidebar_id (NautilusSidebar *sidebar); +char * nautilus_sidebar_get_tab_label (NautilusSidebar *sidebar); +GdkPixbuf * nautilus_sidebar_get_tab_icon (NautilusSidebar *sidebar); +void nautilus_sidebar_is_visible_changed (NautilusSidebar *sidebar, + gboolean is_visible); + +G_END_DECLS + +#endif /* NAUTILUS_VIEW_H */ diff --git a/libnautilus-private/nautilus-undo-context.c b/libnautilus-private/nautilus-undo-context.c deleted file mode 100644 index e4a55c3c0..000000000 --- a/libnautilus-private/nautilus-undo-context.c +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* NautilusUndoContext - Used internally by undo machinery. - * Not public. - * - * Copyright (C) 2000 Eazel, Inc. - * - * Author: Gene Z. Ragan <gzr@eazel.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <config.h> -#include "nautilus-undo-context.h" - -#include <eel/eel-gtk-macros.h> -#include <bonobo/bonobo-main.h> -#include <gtk/gtksignal.h> - -BONOBO_CLASS_BOILERPLATE_FULL (NautilusUndoContext, nautilus_undo_context, - Nautilus_Undo_Context, - BonoboObject, BONOBO_OBJECT_TYPE) - -static Nautilus_Undo_Manager -impl_Nautilus_Undo_Context__get_undo_manager (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - NautilusUndoContext *context; - - context = NAUTILUS_UNDO_CONTEXT (bonobo_object_from_servant (servant)); - return CORBA_Object_duplicate (context->undo_manager, ev); -} - -NautilusUndoContext * -nautilus_undo_context_new (Nautilus_Undo_Manager undo_manager) -{ - NautilusUndoContext *context; - - context = NAUTILUS_UNDO_CONTEXT (g_object_new (nautilus_undo_context_get_type (), NULL)); - context->undo_manager = CORBA_Object_duplicate (undo_manager, NULL); - return context; -} - -static void -nautilus_undo_context_instance_init (NautilusUndoContext *context) -{ -} - -static void -finalize (GObject *object) -{ - NautilusUndoContext *context; - - context = NAUTILUS_UNDO_CONTEXT (object); - - CORBA_Object_release (context->undo_manager, NULL); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -nautilus_undo_context_class_init (NautilusUndoContextClass *klass) -{ - G_OBJECT_CLASS (klass)->finalize = finalize; - - klass->epv._get_undo_manager = impl_Nautilus_Undo_Context__get_undo_manager; -} diff --git a/libnautilus-private/nautilus-undo-context.h b/libnautilus-private/nautilus-undo-context.h deleted file mode 100644 index 9aea27bce..000000000 --- a/libnautilus-private/nautilus-undo-context.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* NautilusUndoContext - Used internally by undo machinery. - * Not public. - * - * Copyright (C) 2000 Eazel, Inc. - * - * Author: Gene Z. Ragan <gzr@eazel.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef NAUTILUS_UNDO_CONTEXT_H -#define NAUTILUS_UNDO_CONTEXT_H - -#include <bonobo/bonobo-object.h> -#include <libnautilus/nautilus-distributed-undo.h> - -#define NAUTILUS_TYPE_UNDO_CONTEXT \ - (nautilus_undo_context_get_type ()) -#define NAUTILUS_UNDO_CONTEXT(obj) \ - (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_UNDO_CONTEXT, NautilusUndoContext)) -#define NAUTILUS_UNDO_CONTEXT_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_UNDO_CONTEXT, NautilusUndoContextClass)) -#define NAUTILUS_IS_UNDO_CONTEXT(obj) \ - (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_UNDO_CONTEXT)) -#define NAUTILUS_IS_UNDO_CONTEXT_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_UNDO_CONTEXT)) - -typedef struct { - BonoboObject parent_slot; - Nautilus_Undo_Manager undo_manager; -} NautilusUndoContext; - -typedef struct { - BonoboObjectClass parent_slot; - POA_Nautilus_Undo_Context__epv epv; -} NautilusUndoContextClass; - -GType nautilus_undo_context_get_type (void); -NautilusUndoContext *nautilus_undo_context_new (Nautilus_Undo_Manager undo_manager); - -#endif /* NAUTILUS_UNDO_CONTEXT_H */ diff --git a/libnautilus-private/nautilus-undo-manager.c b/libnautilus-private/nautilus-undo-manager.c index 0d17a0ed4..2be72abc0 100644 --- a/libnautilus-private/nautilus-undo-manager.c +++ b/libnautilus-private/nautilus-undo-manager.c @@ -23,17 +23,17 @@ */ #include <config.h> -#include "nautilus-undo-manager.h" +#include <libnautilus-private/nautilus-undo-manager.h> +#include <libnautilus-private/nautilus-undo-transaction.h> #include <eel/eel-gtk-macros.h> #include <eel/eel-gtk-extensions.h> #include <gtk/gtksignal.h> #include <bonobo/bonobo-main.h> -#include <libnautilus/nautilus-undo-private.h> -#include "nautilus-undo-context.h" +#include "nautilus-undo-private.h" struct NautilusUndoManagerDetails { - Nautilus_Undo_Transaction transaction; + NautilusUndoTransaction *transaction; /* These are used to tell undo from redo. */ gboolean current_transaction_is_redo; @@ -61,39 +61,27 @@ typedef struct { char *no_undo_menu_item_hint; } UndoMenuHandlerConnection; -BONOBO_CLASS_BOILERPLATE_FULL (NautilusUndoManager, - nautilus_undo_manager, - Nautilus_Undo_Manager, - BonoboObject, - BONOBO_OBJECT_TYPE) +G_DEFINE_TYPE (NautilusUndoManager, + nautilus_undo_manager, + G_TYPE_OBJECT) static void release_transaction (NautilusUndoManager *manager) { - Nautilus_Undo_Transaction transaction; - - CORBA_Environment ev; - - CORBA_exception_init (&ev); + NautilusUndoTransaction *transaction; transaction = manager->details->transaction; - manager->details->transaction = CORBA_OBJECT_NIL; - if (!CORBA_Object_is_nil (transaction, &ev)) { - bonobo_object_release_unref (transaction, &ev); + manager->details->transaction = NULL; + if (transaction != NULL) { + g_object_unref (transaction); } - - CORBA_exception_free (&ev); } -static void -corba_append (PortableServer_Servant servant, - Nautilus_Undo_Transaction transaction, - CORBA_Environment *ev) +void +nautilus_undo_manager_append (NautilusUndoManager *manager, + NautilusUndoTransaction *transaction) { - NautilusUndoManager *manager; - Nautilus_Undo_Transaction duplicate_transaction; - - manager = NAUTILUS_UNDO_MANAGER (bonobo_object_from_servant (servant)); + NautilusUndoTransaction *duplicate_transaction; /* Check, complain, and ignore the passed-in transaction if we * get more than one within a single undo operation. The single @@ -105,11 +93,10 @@ corba_append (PortableServer_Servant servant, g_return_if_fail (manager->details->num_transactions_during_undo == 1); } - g_return_if_fail (!CORBA_Object_is_nil (transaction, ev)); + g_return_if_fail (transaction != NULL); /* Keep a copy of this transaction (dump the old one). */ - duplicate_transaction = CORBA_Object_duplicate (transaction, ev); - Nautilus_Undo_Transaction_ref (duplicate_transaction, ev); + duplicate_transaction = g_object_ref (transaction); release_transaction (manager); manager->details->transaction = duplicate_transaction; manager->details->current_transaction_is_redo = @@ -119,19 +106,14 @@ corba_append (PortableServer_Servant servant, g_signal_emit (manager, signals[CHANGED], 0); } -static void -corba_forget (PortableServer_Servant servant, - Nautilus_Undo_Transaction transaction, - CORBA_Environment *ev) +void +nautilus_undo_manager_forget (NautilusUndoManager *manager, + NautilusUndoTransaction *transaction) { - NautilusUndoManager *manager; - - manager = NAUTILUS_UNDO_MANAGER (bonobo_object_from_servant (servant)); - /* Nothing to forget unless the item we are passed is the * transaction we are currently holding. */ - if (!CORBA_Object_is_equivalent (manager->details->transaction, transaction, ev)) { + if (transaction != manager->details->transaction) { return; } @@ -142,16 +124,6 @@ corba_forget (PortableServer_Servant servant, g_signal_emit (manager, signals[CHANGED], 0); } -static void -corba_undo (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - NautilusUndoManager *manager; - - manager = NAUTILUS_UNDO_MANAGER (bonobo_object_from_servant (servant)); - nautilus_undo_manager_undo (manager); -} - NautilusUndoManager * nautilus_undo_manager_new (void) { @@ -159,7 +131,7 @@ nautilus_undo_manager_new (void) } static void -nautilus_undo_manager_instance_init (NautilusUndoManager *manager) +nautilus_undo_manager_init (NautilusUndoManager *manager) { manager->details = g_new0 (NautilusUndoManagerDetails, 1); } @@ -167,16 +139,13 @@ nautilus_undo_manager_instance_init (NautilusUndoManager *manager) void nautilus_undo_manager_undo (NautilusUndoManager *manager) { - CORBA_Environment ev; - Nautilus_Undo_Transaction transaction; + NautilusUndoTransaction *transaction; g_return_if_fail (NAUTILUS_IS_UNDO_MANAGER (manager)); - CORBA_exception_init (&ev); - transaction = manager->details->transaction; - manager->details->transaction = CORBA_OBJECT_NIL; - if (!CORBA_Object_is_nil (transaction, &ev)) { + manager->details->transaction = NULL; + if (transaction != NULL) { /* Perform the undo. New transactions that come in * during an undo are redo transactions. New * transactions that come in during a redo are undo @@ -187,18 +156,16 @@ nautilus_undo_manager_undo (NautilusUndoManager *manager) !manager->details->current_transaction_is_redo; manager->details->undo_in_progress = TRUE; manager->details->num_transactions_during_undo = 0; - Nautilus_Undo_Transaction_undo (transaction, &ev); + nautilus_undo_transaction_undo (transaction); manager->details->undo_in_progress = FALSE; manager->details->new_transaction_is_redo = FALSE; /* Let go of the transaction. */ - bonobo_object_release_unref (transaction, &ev); + g_object_unref (transaction); /* Fire off signal indicating the undo state has changed. */ g_signal_emit (manager, signals[CHANGED], 0); } - - CORBA_exception_free (&ev); } static void @@ -211,8 +178,10 @@ finalize (GObject *object) release_transaction (manager); g_free (manager->details); - - EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object)); + + if (G_OBJECT_CLASS (nautilus_undo_manager_parent_class)->finalize) { + (* G_OBJECT_CLASS (nautilus_undo_manager_parent_class)->finalize) (object); + } } void @@ -221,19 +190,7 @@ nautilus_undo_manager_attach (NautilusUndoManager *manager, GObject *target) g_return_if_fail (NAUTILUS_IS_UNDO_MANAGER (manager)); g_return_if_fail (G_IS_OBJECT (target)); - nautilus_undo_attach_undo_manager (G_OBJECT (target), BONOBO_OBJREF (manager)); -} - -void -nautilus_undo_manager_add_interface (NautilusUndoManager *manager, BonoboObject *object) -{ - NautilusUndoContext *context; - - g_return_if_fail (NAUTILUS_IS_UNDO_MANAGER (manager)); - g_return_if_fail (BONOBO_IS_OBJECT (object)); - - context = nautilus_undo_context_new (BONOBO_OBJREF (manager)); - bonobo_object_add_interface (object, BONOBO_OBJECT (context)); + nautilus_undo_attach_undo_manager (G_OBJECT (target), manager); } #ifdef UIH @@ -347,8 +304,4 @@ nautilus_undo_manager_class_init (NautilusUndoManagerClass *class) NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); - - class->epv.append = corba_append; - class->epv.forget = corba_forget; - class->epv.undo = corba_undo; } diff --git a/libnautilus-private/nautilus-undo-manager.h b/libnautilus-private/nautilus-undo-manager.h index 2f2e0cbf3..0e8b9ac38 100644 --- a/libnautilus-private/nautilus-undo-manager.h +++ b/libnautilus-private/nautilus-undo-manager.h @@ -27,7 +27,7 @@ #define NAUTILUS_UNDO_MANAGER_H #include <bonobo/bonobo-object.h> -#include <libnautilus/nautilus-distributed-undo.h> +#include <libnautilus-private/nautilus-undo.h> #define NAUTILUS_TYPE_UNDO_MANAGER \ (nautilus_undo_manager_get_type ()) @@ -43,13 +43,12 @@ typedef struct NautilusUndoManagerDetails NautilusUndoManagerDetails; typedef struct { - BonoboObject parent; + GObject parent; NautilusUndoManagerDetails *details; } NautilusUndoManager; typedef struct { - BonoboObjectClass parent_slot; - POA_Nautilus_Undo_Manager__epv epv; + GObjectClass parent_slot; void (* changed) (GObject *object, gpointer data); } NautilusUndoManagerClass; @@ -73,8 +72,9 @@ void nautilus_undo_manager_set_up_bonobo_ui_handler_undo_item (N void nautilus_undo_manager_attach (NautilusUndoManager *manager, GObject *object); -/* Attach the undo manager to a Bonobo object so another component can find it. */ -void nautilus_undo_manager_add_interface (NautilusUndoManager *manager, - BonoboObject *object); +void nautilus_undo_manager_append (NautilusUndoManager *manager, + NautilusUndoTransaction *transaction); +void nautilus_undo_manager_forget (NautilusUndoManager *manager, + NautilusUndoTransaction *transaction); #endif /* NAUTILUS_UNDO_MANAGER_H */ diff --git a/libnautilus-private/nautilus-undo-private.h b/libnautilus-private/nautilus-undo-private.h new file mode 100644 index 000000000..3e6d75f95 --- /dev/null +++ b/libnautilus-private/nautilus-undo-private.h @@ -0,0 +1,36 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* xxx + * + * Copyright (C) 2000 Eazel, Inc. + * + * Author: Gene Z. Ragan <gzr@eazel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef NAUTILUS_UNDO_PRIVATE_H +#define NAUTILUS_UNDO_PRIVATE_H + +#include <libnautilus-private/nautilus-undo.h> +#include <libnautilus-private/nautilus-undo-manager.h> +#include <glib-object.h> + +NautilusUndoManager * nautilus_undo_get_undo_manager (GObject *attached_object); +void nautilus_undo_attach_undo_manager (GObject *object, + NautilusUndoManager *manager); + +#endif /* NAUTILUS_UNDO_PRIVATE_H */ diff --git a/libnautilus-private/nautilus-undo-transaction.c b/libnautilus-private/nautilus-undo-transaction.c new file mode 100644 index 000000000..a3ace2fe3 --- /dev/null +++ b/libnautilus-private/nautilus-undo-transaction.c @@ -0,0 +1,333 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* NautilusUndoTransaction - An object for an undoable transaction. + * Used internally by undo machinery. + * Not public. + * + * Copyright (C) 2000 Eazel, Inc. + * + * Author: Gene Z. Ragan <gzr@eazel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include <config.h> +#include <libnautilus-private/nautilus-undo.h> +#include <libnautilus-private/nautilus-undo-manager.h> +#include <libnautilus-private/nautilus-undo-transaction.h> + +#include "nautilus-undo-private.h" +#include <gtk/gtksignal.h> + +#define NAUTILUS_UNDO_TRANSACTION_LIST_DATA "Nautilus undo transaction list" + +/* undo atoms */ +static void undo_atom_list_free (GList *list); +static void undo_atom_list_undo_and_free (GList *list); + +G_DEFINE_TYPE (NautilusUndoTransaction, nautilus_undo_transaction, + G_TYPE_OBJECT); + +#ifdef UIH +static Nautilus_Undo_MenuItem * +impl_Nautilus_Undo_Transaction__get_undo_menu_item (PortableServer_Servant servant, + CORBA_Environment *ev) +{ + NautilusUndoTransaction *transaction; + Nautilus_Undo_MenuItem *item; + + transaction = NAUTILUS_UNDO_TRANSACTION (bonobo_object_from_servant (servant)); + + item = Nautilus_Undo_MenuItem__alloc (); + item->label = CORBA_string_dup (transaction->undo_menu_item_label); + item->hint = CORBA_string_dup (transaction->undo_menu_item_hint); + + return item; +} + +static Nautilus_Undo_MenuItem * +impl_Nautilus_Undo_Transaction__get_redo_menu_item (PortableServer_Servant servant, + CORBA_Environment *ev) +{ + NautilusUndoTransaction *transaction; + Nautilus_Undo_MenuItem *item; + + transaction = NAUTILUS_UNDO_TRANSACTION (bonobo_object_from_servant (servant)); + + item = Nautilus_Undo_MenuItem__alloc (); + item->label = CORBA_string_dup (transaction->redo_menu_item_label); + item->hint = CORBA_string_dup (transaction->redo_menu_item_hint); + + return item; +} + +static CORBA_char * +impl_Nautilus_Undo_Transaction__get_operation_name (PortableServer_Servant servant, + CORBA_Environment *ev) +{ + NautilusUndoTransaction *transaction; + + transaction = NAUTILUS_UNDO_TRANSACTION (bonobo_object_from_servant (servant)); + return CORBA_string_dup (transaction->operation_name); +} +#endif + + +NautilusUndoTransaction * +nautilus_undo_transaction_new (const char *operation_name, + const char *undo_menu_item_label, + const char *undo_menu_item_hint, + const char *redo_menu_item_label, + const char *redo_menu_item_hint) +{ + NautilusUndoTransaction *transaction; + + transaction = NAUTILUS_UNDO_TRANSACTION (g_object_new (nautilus_undo_transaction_get_type (), NULL)); + + transaction->operation_name = g_strdup (operation_name); + transaction->undo_menu_item_label = g_strdup (undo_menu_item_label); + transaction->undo_menu_item_hint = g_strdup (undo_menu_item_hint); + transaction->redo_menu_item_label = g_strdup (redo_menu_item_label); + transaction->redo_menu_item_hint = g_strdup (redo_menu_item_hint); + + return transaction; +} + +static void +nautilus_undo_transaction_init (NautilusUndoTransaction *transaction) +{ +} + +static void +remove_transaction_from_object (gpointer list_data, gpointer callback_data) +{ + NautilusUndoAtom *atom; + NautilusUndoTransaction *transaction; + GList *list; + + g_assert (list_data != NULL); + atom = list_data; + transaction = NAUTILUS_UNDO_TRANSACTION (callback_data); + + /* Remove the transaction from the list on the atom. */ + list = g_object_get_data (atom->target, NAUTILUS_UNDO_TRANSACTION_LIST_DATA); + + if (list != NULL) { + list = g_list_remove (list, transaction); + g_object_set_data (atom->target, NAUTILUS_UNDO_TRANSACTION_LIST_DATA, list); + } +} + +static void +remove_transaction_from_atom_targets (NautilusUndoTransaction *transaction) +{ + + g_list_foreach (transaction->atom_list, + remove_transaction_from_object, + transaction); +} + +static void +nautilus_undo_transaction_finalize (GObject *object) +{ + NautilusUndoTransaction *transaction; + + transaction = NAUTILUS_UNDO_TRANSACTION (object); + + remove_transaction_from_atom_targets (transaction); + undo_atom_list_free (transaction->atom_list); + + g_free (transaction->operation_name); + g_free (transaction->undo_menu_item_label); + g_free (transaction->undo_menu_item_hint); + g_free (transaction->redo_menu_item_label); + g_free (transaction->redo_menu_item_hint); + + if (transaction->owner != NULL) { + g_object_unref (transaction->owner); + } + + G_OBJECT_CLASS (nautilus_undo_transaction_parent_class)->finalize (object); +} + +void +nautilus_undo_transaction_add_atom (NautilusUndoTransaction *transaction, + const NautilusUndoAtom *atom) +{ + GList *list; + + g_return_if_fail (NAUTILUS_IS_UNDO_TRANSACTION (transaction)); + g_return_if_fail (atom != NULL); + g_return_if_fail (GTK_IS_OBJECT (atom->target)); + + /* Add the atom to the atom list in the transaction. */ + transaction->atom_list = g_list_append + (transaction->atom_list, g_memdup (atom, sizeof (*atom))); + + /* Add the transaction to the list on the atoms target object. */ + list = g_object_get_data (atom->target, NAUTILUS_UNDO_TRANSACTION_LIST_DATA); + if (g_list_find (list, transaction) != NULL) { + return; + } + + /* If it's not already on that atom, this object is new. */ + list = g_list_prepend (list, transaction); + g_object_set_data (atom->target, NAUTILUS_UNDO_TRANSACTION_LIST_DATA, list); + + /* Connect a signal handler to the atom so it will unregister + * itself when it's destroyed. + */ + g_signal_connect (atom->target, "destroy", + G_CALLBACK (nautilus_undo_transaction_unregister_object), + NULL); +} + +void +nautilus_undo_transaction_undo (NautilusUndoTransaction *transaction) +{ + g_return_if_fail (NAUTILUS_IS_UNDO_TRANSACTION (transaction)); + + remove_transaction_from_atom_targets (transaction); + undo_atom_list_undo_and_free (transaction->atom_list); + + transaction->atom_list = NULL; +} + +void +nautilus_undo_transaction_add_to_undo_manager (NautilusUndoTransaction *transaction, + NautilusUndoManager *manager) +{ + g_return_if_fail (NAUTILUS_IS_UNDO_TRANSACTION (transaction)); + g_return_if_fail (transaction->owner == NULL); + + if (manager != NULL) { + nautilus_undo_manager_append (manager, transaction); + transaction->owner = g_object_ref (manager); + } +} + +static void +remove_atoms (NautilusUndoTransaction *transaction, + GObject *object) +{ + GList *p, *next; + NautilusUndoAtom *atom; + + g_assert (NAUTILUS_IS_UNDO_TRANSACTION (transaction)); + g_assert (G_IS_OBJECT (object)); + + /* Destroy any atoms for this object. */ + for (p = transaction->atom_list; p != NULL; p = next) { + atom = p->data; + next = p->next; + + if (atom->target == object) { + transaction->atom_list = g_list_remove_link + (transaction->atom_list, p); + undo_atom_list_free (p); + } + } + + /* If all the atoms are gone, forget this transaction. + * This may end up freeing the transaction. + */ + if (transaction->atom_list == NULL) { + nautilus_undo_manager_forget ( + transaction->owner, transaction); + } +} + +static void +remove_atoms_cover (gpointer list_data, gpointer callback_data) +{ + if (NAUTILUS_IS_UNDO_TRANSACTION (list_data)) { + remove_atoms (NAUTILUS_UNDO_TRANSACTION (list_data), G_OBJECT (callback_data)); + } +} + +void +nautilus_undo_transaction_unregister_object (GObject *object) +{ + GList *list; + + g_return_if_fail (G_IS_OBJECT (object)); + + /* Remove atoms from each transaction on the list. */ + list = g_object_get_data (object, NAUTILUS_UNDO_TRANSACTION_LIST_DATA); + if (list != NULL) { + g_list_foreach (list, remove_atoms_cover, object); + g_list_free (list); + g_object_set_data (object, NAUTILUS_UNDO_TRANSACTION_LIST_DATA, NULL); + } +} + +static void +undo_atom_free (NautilusUndoAtom *atom) +{ + /* Call the destroy-notify function if it's present. */ + if (atom->callback_data_destroy_notify != NULL) { + (* atom->callback_data_destroy_notify) (atom->callback_data); + } + + /* Free the atom storage. */ + g_free (atom); +} + +static void +undo_atom_undo_and_free (NautilusUndoAtom *atom) +{ + /* Call the function that does the actual undo. */ + (* atom->callback) (atom->target, atom->callback_data); + + /* Get rid of the atom now that it's spent. */ + undo_atom_free (atom); +} + +static void +undo_atom_free_cover (gpointer atom, gpointer callback_data) +{ + g_assert (atom != NULL); + g_assert (callback_data == NULL); + undo_atom_free (atom); +} + +static void +undo_atom_undo_and_free_cover (gpointer atom, gpointer callback_data) +{ + g_assert (atom != NULL); + g_assert (callback_data == NULL); + undo_atom_undo_and_free (atom); +} + +static void +undo_atom_list_free (GList *list) +{ + g_list_foreach (list, undo_atom_free_cover, NULL); + g_list_free (list); +} + +static void +undo_atom_list_undo_and_free (GList *list) +{ + g_list_foreach (list, undo_atom_undo_and_free_cover, NULL); + g_list_free (list); +} + +static void +nautilus_undo_transaction_class_init (NautilusUndoTransactionClass *klass) +{ + G_OBJECT_CLASS (klass)->finalize = nautilus_undo_transaction_finalize; +} diff --git a/libnautilus-private/nautilus-undo-transaction.h b/libnautilus-private/nautilus-undo-transaction.h new file mode 100644 index 000000000..26d407457 --- /dev/null +++ b/libnautilus-private/nautilus-undo-transaction.h @@ -0,0 +1,77 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* NautilusUndoTransaction - An object for an undoable transaction. + * Used internally by undo machinery. + * Not public. + * + * Copyright (C) 2000 Eazel, Inc. + * + * Author: Gene Z. Ragan <gzr@eazel.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef NAUTILUS_UNDO_TRANSACTION_H +#define NAUTILUS_UNDO_TRANSACTION_H + +#include <libnautilus-private/nautilus-undo.h> + +#define NAUTILUS_TYPE_UNDO_TRANSACTION \ + (nautilus_undo_transaction_get_type ()) +#define NAUTILUS_UNDO_TRANSACTION(obj) \ + (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_UNDO_TRANSACTION, NautilusUndoTransaction)) +#define NAUTILUS_UNDO_TRANSACTION_CLASS(klass) \ + (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_UNDO_TRANSACTION, NautilusUndoTransactionClass)) +#define NAUTILUS_IS_UNDO_TRANSACTION(obj) \ + (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_UNDO_TRANSACTION)) +#define NAUTILUS_IS_UNDO_TRANSACTION_CLASS(klass) \ + (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_UNDO_TRANSACTION)) + +/* The typedef for NautilusUndoTransaction is in nautilus-undo.h + to avoid circular deps */ +typedef struct _NautilusUndoTransactionClass NautilusUndoTransactionClass; + +struct _NautilusUndoTransaction { + GObject parent_slot; + + char *operation_name; + char *undo_menu_item_label; + char *undo_menu_item_hint; + char *redo_menu_item_label; + char *redo_menu_item_hint; + GList *atom_list; + + NautilusUndoManager *owner; +}; + +struct _NautilusUndoTransactionClass { + GObjectClass parent_slot; +}; + +GType nautilus_undo_transaction_get_type (void); +NautilusUndoTransaction *nautilus_undo_transaction_new (const char *operation_name, + const char *undo_menu_item_label, + const char *undo_menu_item_hint, + const char *redo_menu_item_label, + const char *redo_menu_item_hint); +void nautilus_undo_transaction_add_atom (NautilusUndoTransaction *transaction, + const NautilusUndoAtom *atom); +void nautilus_undo_transaction_add_to_undo_manager (NautilusUndoTransaction *transaction, + NautilusUndoManager *manager); +void nautilus_undo_transaction_unregister_object (GObject *atom_target); +void nautilus_undo_transaction_undo (NautilusUndoTransaction *transaction); + +#endif /* NAUTILUS_UNDO_TRANSACTION_H */ diff --git a/libnautilus-private/nautilus-undo.c b/libnautilus-private/nautilus-undo.c new file mode 100644 index 000000000..29b172b6b --- /dev/null +++ b/libnautilus-private/nautilus-undo.c @@ -0,0 +1,215 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* nautilus-undo.c - public interface for objects that implement + * undoable actions -- works across components + * + * Copyright (C) 2000 Eazel, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Darin Adler <darin@bentspoon.com> + */ + +#include <config.h> +#include "nautilus-undo.h" + +#include "nautilus-undo-private.h" +#include "nautilus-undo-transaction.h" +#include <gtk/gtksignal.h> +#include <gtk/gtkwindow.h> +#include <libgnomecanvas/gnome-canvas.h> + +#define NAUTILUS_UNDO_MANAGER_DATA "Nautilus undo manager" + +/* Register a simple undo action by calling nautilus_undo_register_full. */ +void +nautilus_undo_register (GObject *target, + NautilusUndoCallback callback, + gpointer callback_data, + GDestroyNotify callback_data_destroy_notify, + const char *operation_name, + const char *undo_menu_item_label, + const char *undo_menu_item_hint, + const char *redo_menu_item_label, + const char *redo_menu_item_hint) +{ + NautilusUndoAtom atom; + GList single_atom_list; + + g_return_if_fail (G_IS_OBJECT (target)); + g_return_if_fail (callback != NULL); + + /* Make an atom. */ + atom.target = target; + atom.callback = callback; + atom.callback_data = callback_data; + atom.callback_data_destroy_notify = callback_data_destroy_notify; + + /* Make a single-atom list. */ + single_atom_list.data = &atom; + single_atom_list.next = NULL; + single_atom_list.prev = NULL; + + /* Call the full version of the registration function, + * using the undo target as the place to search for the + * undo manager. + */ + nautilus_undo_register_full (&single_atom_list, + target, + operation_name, + undo_menu_item_label, + undo_menu_item_hint, + redo_menu_item_label, + redo_menu_item_hint); +} + +/* Register an undo action. */ +void +nautilus_undo_register_full (GList *atoms, + GObject *undo_manager_search_start_object, + const char *operation_name, + const char *undo_menu_item_label, + const char *undo_menu_item_hint, + const char *redo_menu_item_label, + const char *redo_menu_item_hint) +{ + NautilusUndoTransaction *transaction; + GList *p; + + g_return_if_fail (atoms != NULL); + g_return_if_fail (G_IS_OBJECT (undo_manager_search_start_object)); + + /* Create an undo transaction */ + transaction = nautilus_undo_transaction_new (operation_name, + undo_menu_item_label, + undo_menu_item_hint, + redo_menu_item_label, + redo_menu_item_hint); + for (p = atoms; p != NULL; p = p->next) { + nautilus_undo_transaction_add_atom (transaction, p->data); + } + nautilus_undo_transaction_add_to_undo_manager + (transaction, + nautilus_undo_get_undo_manager (undo_manager_search_start_object)); + + /* Now we are done with the transaction. + * If the undo manager is holding it, then this will not destroy it. + */ + g_object_unref (transaction); +} + +/* Cover for forgetting about all undo relating to a particular target. */ +void +nautilus_undo_unregister (GObject *target) +{ + /* Perhaps this should also unregister all children if called on a + * GtkContainer? That might be handy. + */ + nautilus_undo_transaction_unregister_object (target); +} + +void +nautilus_undo (GObject *undo_manager_search_start_object) +{ + NautilusUndoManager *manager; + + g_return_if_fail (G_IS_OBJECT (undo_manager_search_start_object)); + + manager = nautilus_undo_get_undo_manager (undo_manager_search_start_object); + if (manager != NULL) { + nautilus_undo_manager_undo (manager); + } +} + +NautilusUndoManager * +nautilus_undo_get_undo_manager (GObject *start_object) +{ + NautilusUndoManager *manager; + GtkWidget *parent; + GtkWindow *transient_parent; + + if (start_object == NULL) { + return CORBA_OBJECT_NIL; + } + + g_return_val_if_fail (G_IS_OBJECT (start_object), NULL); + + /* Check for an undo manager right here. */ + manager = g_object_get_data (start_object, NAUTILUS_UNDO_MANAGER_DATA); + if (manager != NULL) { + return manager; + } + + /* Check for undo manager up the parent chain. */ + if (GTK_IS_WIDGET (start_object)) { + parent = GTK_WIDGET (start_object)->parent; + if (parent != NULL) { + manager = nautilus_undo_get_undo_manager (G_OBJECT (parent)); + if (manager != NULL) { + return manager; + } + } + + /* Check for undo manager in our window's parent. */ + if (GTK_IS_WINDOW (start_object)) { + transient_parent = GTK_WINDOW (start_object)->transient_parent; + if (transient_parent != NULL) { + manager = nautilus_undo_get_undo_manager (G_OBJECT (transient_parent)); + if (manager != NULL) { + return manager; + } + } + } + } + + /* In the case of a canvas item, try the canvas. */ + if (GNOME_IS_CANVAS_ITEM (start_object)) { + manager = nautilus_undo_get_undo_manager (G_OBJECT (GNOME_CANVAS_ITEM (start_object)->canvas)); + if (manager != NULL) { + return manager; + } + } + + /* Found nothing. I can live with that. */ + return NULL; +} + +void +nautilus_undo_attach_undo_manager (GObject *object, + NautilusUndoManager *manager) +{ + g_return_if_fail (G_IS_OBJECT (object)); + + if (manager == NULL) { + g_object_set_data (object, NAUTILUS_UNDO_MANAGER_DATA, NULL); + } else { + g_object_ref (manager); + g_object_set_data_full + (object, NAUTILUS_UNDO_MANAGER_DATA, + manager, g_object_unref); + } +} + +/* Copy a reference to the undo manager fromone object to another. */ +void +nautilus_undo_share_undo_manager (GObject *destination_object, + GObject *source_object) +{ + NautilusUndoManager *manager; + + manager = nautilus_undo_get_undo_manager (source_object); + nautilus_undo_attach_undo_manager (destination_object, manager); +} diff --git a/libnautilus-private/nautilus-undo.h b/libnautilus-private/nautilus-undo.h new file mode 100644 index 000000000..d1ad1355e --- /dev/null +++ b/libnautilus-private/nautilus-undo.h @@ -0,0 +1,76 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* nautilus-undo.h - public interface for objects that implement + * undoable actions -- works across components + * + * Copyright (C) 2000 Eazel, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library 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 + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Darin Adler <darin@bentspoon.com> + */ + +#ifndef NAUTILUS_UNDO_H +#define NAUTILUS_UNDO_H + +#include <glib-object.h> + +typedef struct _NautilusUndoTransaction NautilusUndoTransaction; + + +/* The basic undoable operation. */ +typedef void (* NautilusUndoCallback) (GObject *target, gpointer callback_data); + +/* Recipe for undo of a bit of work on an object. + * Create these atoms when you want to register more + * than one as a single undoable operation. + */ +typedef struct { + GObject *target; + NautilusUndoCallback callback; + gpointer callback_data; + GDestroyNotify callback_data_destroy_notify; +} NautilusUndoAtom; + +/* Registering something that can be undone. */ +void nautilus_undo_register (GObject *target, + NautilusUndoCallback callback, + gpointer callback_data, + GDestroyNotify callback_data_destroy_notify, + const char *operation_name, + const char *undo_menu_item_label, + const char *undo_menu_item_hint, + const char *redo_menu_item_label, + const char *redo_menu_item_hint); +void nautilus_undo_register_full (GList *atoms, + GObject *undo_manager_search_start_object, + const char *operation_name, + const char *undo_menu_item_label, + const char *undo_menu_item_hint, + const char *redo_menu_item_label, + const char *redo_menu_item_hint); +void nautilus_undo_unregister (GObject *target); + +/* Performing an undo explicitly. Only for use by objects "out in the field". + * The menu bar itself uses a richer API in the undo manager. + */ +void nautilus_undo (GObject *undo_manager_search_start_object); + +/* Connecting an undo manager. */ +void nautilus_undo_share_undo_manager (GObject *destination_object, + GObject *source_object); + +#endif /* NAUTILUS_UNDO_H */ diff --git a/libnautilus-private/nautilus-view-factory.c b/libnautilus-private/nautilus-view-factory.c new file mode 100644 index 000000000..11850cc6c --- /dev/null +++ b/libnautilus-private/nautilus-view-factory.c @@ -0,0 +1,110 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- + + nautilus-view-factory.c: register and create NautilusViews + + Copyright (C) 2004 Red Hat 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. + + Author: Alexander Larsson <alexl@redhat.com> +*/ + +#include "nautilus-view-factory.h" + +static GList *registered_views; + +void +nautilus_view_factory_register (NautilusViewInfo *view_info) +{ + g_return_if_fail (view_info != NULL); + g_return_if_fail (view_info->id != NULL); + g_return_if_fail (nautilus_view_factory_lookup (view_info->id) == NULL); + + registered_views = g_list_append (registered_views, view_info); +} + +const NautilusViewInfo * +nautilus_view_factory_lookup (const char *id) +{ + GList *l; + NautilusViewInfo *view_info; + + g_return_val_if_fail (id != NULL, NULL); + + + for (l = registered_views; l != NULL; l = l->next) { + view_info = l->data; + + if (strcmp (view_info->id, id) == 0) { + return view_info; + } + } + return NULL; +} + +NautilusView * +nautilus_view_factory_create (const char *id, + NautilusWindowInfo *window) +{ + const NautilusViewInfo *view_info; + + view_info = nautilus_view_factory_lookup (id); + if (view_info == NULL) { + return NULL; + } + + return view_info->create (window); +} + +gboolean +nautilus_view_factory_view_supports_uri (const char *id, + const char *uri, + GnomeVFSFileType file_type, + const char *mime_type) +{ + const NautilusViewInfo *view_info; + + view_info = nautilus_view_factory_lookup (id); + if (view_info == NULL) { + return FALSE; + } + + return view_info->supports_uri (uri, file_type, mime_type); + +} + +GList * +nautilus_view_factory_get_views_for_uri (const char *uri, + GnomeVFSFileType file_type, + const char *mime_type) +{ + GList *l, *res; + const NautilusViewInfo *view_info; + + res = NULL; + + for (l = registered_views; l != NULL; l = l->next) { + view_info = l->data; + + if (view_info->supports_uri (uri, file_type, mime_type)) { + res = g_list_prepend (res, g_strdup (view_info->id)); + } + } + + return g_list_reverse (res); +} + + diff --git a/libnautilus-private/nautilus-view-factory.h b/libnautilus-private/nautilus-view-factory.h new file mode 100644 index 000000000..2396ce3f5 --- /dev/null +++ b/libnautilus-private/nautilus-view-factory.h @@ -0,0 +1,67 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- + + nautilus-view-factory.h: register and create NautilusViews + + Copyright (C) 2004 Red Hat 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. + + Author: Alexander Larsson <alexl@redhat.com> +*/ + +#ifndef NAUTILUS_VIEW_FACTORY_H +#define NAUTILUS_VIEW_FACTORY_H + +#include <string.h> + +#include <libnautilus-private/nautilus-view.h> +#include <libnautilus-private/nautilus-window-info.h> +#include <libgnomevfs/gnome-vfs-file-info.h> + +G_BEGIN_DECLS + +typedef struct _NautilusViewInfo NautilusViewInfo; + +struct _NautilusViewInfo { + char *id; + char *label; + char *label_with_mnemonic; + NautilusView * (*create) (NautilusWindowInfo *window); + /* BONOBOTODO: More args here */ + gboolean (*supports_uri) (const char *uri, + GnomeVFSFileType file_type, + const char *mime_type); +}; + + +void nautilus_view_factory_register (NautilusViewInfo *view_info); +const NautilusViewInfo *nautilus_view_factory_lookup (const char *id); +NautilusView * nautilus_view_factory_create (const char *id, + NautilusWindowInfo *window); +gboolean nautilus_view_factory_view_supports_uri (const char *id, + const char *uri, + GnomeVFSFileType file_type, + const char *mime_type); +GList * nautilus_view_factory_get_views_for_uri (const char *uri, + GnomeVFSFileType file_type, + const char *mime_type); + + + + +G_END_DECLS + +#endif /* NAUTILUS_VIEW_FACTORY_H */ diff --git a/libnautilus-private/nautilus-view-identifier.c b/libnautilus-private/nautilus-view-identifier.c deleted file mode 100644 index c414b0639..000000000 --- a/libnautilus-private/nautilus-view-identifier.c +++ /dev/null @@ -1,237 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- - - nautilus-view-identifier.c: Unique ID/Human-readable name pairs for views - - 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. - - Author: Maciej Stachowiak <mjs@eazel.com> -*/ - -#include <config.h> -#include "nautilus-view-identifier.h" - -#include <libgnome/gnome-i18n.h> - - -#include <eel/eel-glib-extensions.h> -#include <eel/eel-string.h> -#include <glib.h> -#include <stdlib.h> - -static NautilusViewIdentifier * -nautilus_view_identifier_new (const char *iid, - const char *name, - const char *view_as_label, - const char *view_as_label_with_mnemonic, - const char *label_viewer); - - - -NautilusViewIdentifier * -nautilus_view_identifier_new (const char *iid, - const char *name, - const char *view_as_label, - const char *view_as_label_with_mnemonic, - const char *viewer_label) -{ - NautilusViewIdentifier *new_identifier; - - g_return_val_if_fail (iid != NULL, NULL); - g_return_val_if_fail (name != NULL, NULL); - - new_identifier = g_new0 (NautilusViewIdentifier, 1); - new_identifier->iid = g_strdup (iid); - new_identifier->name = g_strdup (name); - - new_identifier->view_as_label = view_as_label ? g_strdup (view_as_label) : - g_strdup_printf (_("View as %s"), name); - - new_identifier->view_as_label_with_mnemonic = view_as_label_with_mnemonic ? g_strdup (view_as_label_with_mnemonic) - : g_strdup (new_identifier->view_as_label); - - new_identifier->viewer_label = view_as_label ? g_strdup (viewer_label) : - g_strdup_printf (_("%s Viewer"), name); - - return new_identifier; -} - -NautilusViewIdentifier * -nautilus_view_identifier_copy (const NautilusViewIdentifier *identifier) -{ - if (identifier == NULL) { - return NULL; - } - - return nautilus_view_identifier_new (identifier->iid, - identifier->name, - identifier->view_as_label, - identifier->view_as_label_with_mnemonic, - identifier->viewer_label); -} - -/* Returns a list of languages, containing - the LANG or LANGUAGE environment setting (with and without region code). - The elements in the returned list must be freed */ -static GSList * -get_lang_list (void) -{ - GSList *retval; - const GList *l; - const char *lang; - - retval = NULL; - - for (l = gnome_i18n_get_language_list ("LC_MESSAGES"); - l != NULL; - l = g_list_next (l)) { - lang = l->data; - /* skip C locale */ - if (l->data && strcmp (lang, "C") == 0) { - continue; - } - - if (!eel_str_is_empty (lang)) { - retval = g_slist_prepend (retval, g_strdup (lang)); - } - } - return retval; -} - -NautilusViewIdentifier * -nautilus_view_identifier_new_from_bonobo_server_info (Bonobo_ServerInfo *server, char *name_attribute) -{ - const char *view_as_name; - const char *view_as_label; - const char *view_as_label_with_mnemonic; - const char *viewer_label; - GSList *langs; - - langs = get_lang_list (); - - view_as_name = bonobo_server_info_prop_lookup (server, name_attribute, langs); - view_as_label = bonobo_server_info_prop_lookup (server, "nautilus:view_as_label", langs); - view_as_label_with_mnemonic = bonobo_server_info_prop_lookup (server, "nautilus:view_as_label_with_mnemonic", langs); - viewer_label = bonobo_server_info_prop_lookup (server, "nautilus:viewer_label", langs); - - if (view_as_name == NULL) { - view_as_name = bonobo_server_info_prop_lookup (server, "name", langs); - } - if (view_as_name == NULL) { - view_as_name = server->iid; - } - - eel_g_slist_free_deep (langs); - - /* if the name is an OAFIID, clean it up for display */ - if (eel_str_has_prefix (view_as_name, "OAFIID:")) { - char *display_name, *colon_ptr; - NautilusViewIdentifier *new_identifier; - - display_name = g_strdup (view_as_name + 7); - colon_ptr = strchr (display_name, ':'); - if (colon_ptr) { - *colon_ptr = '\0'; - } - - new_identifier = nautilus_view_identifier_new (server->iid, display_name, - view_as_label, - view_as_label_with_mnemonic, - viewer_label); - g_free(display_name); - return new_identifier; - } - - return nautilus_view_identifier_new (server->iid, view_as_name, - view_as_label, - view_as_label_with_mnemonic, - viewer_label); -} - -NautilusViewIdentifier * -nautilus_view_identifier_new_from_content_view (Bonobo_ServerInfo *server) -{ - return nautilus_view_identifier_new_from_bonobo_server_info - (server, "nautilus:view_as_name"); -} - -NautilusViewIdentifier * -nautilus_view_identifier_new_from_property_page (Bonobo_ServerInfo *server) -{ - return nautilus_view_identifier_new_from_bonobo_server_info - (server, "nautilus:property_page_name"); -} - -NautilusViewIdentifier * -nautilus_view_identifier_new_from_sidebar_panel (Bonobo_ServerInfo *server) -{ - return nautilus_view_identifier_new_from_bonobo_server_info - (server, "nautilus:sidebar_panel_name"); -} - -void -nautilus_view_identifier_free (NautilusViewIdentifier *identifier) -{ - if (identifier != NULL) { - g_free (identifier->iid); - g_free (identifier->name); - g_free (identifier->view_as_label); - g_free (identifier->view_as_label_with_mnemonic); - g_free (identifier->viewer_label); - g_free (identifier); - } -} - -GList * -nautilus_view_identifier_list_copy (GList *list) -{ - GList *copy, *node; - - copy = NULL; - for (node = list; node != NULL; node = node->next) { - copy = g_list_prepend - (copy, nautilus_view_identifier_copy (node->data)); - } - return g_list_reverse (copy); -} - -static void -nautilus_view_identifier_free_callback (gpointer identifier, gpointer ignore) -{ - g_assert (ignore == NULL); - nautilus_view_identifier_free (identifier); -} - -void -nautilus_view_identifier_list_free (GList *list) -{ - eel_g_list_free_deep_custom - (list, nautilus_view_identifier_free_callback, NULL); -} - -int -nautilus_view_identifier_compare (const NautilusViewIdentifier *a, - const NautilusViewIdentifier *b) -{ - int result; - - result = strcmp (a->iid, b->iid); - if (result != 0) { - return result; - } - return strcmp (a->name, b->name); -} diff --git a/libnautilus-private/nautilus-view-identifier.h b/libnautilus-private/nautilus-view-identifier.h deleted file mode 100644 index 8cf61e1da..000000000 --- a/libnautilus-private/nautilus-view-identifier.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- - - nautilus-view-identifier.h: Unique ID/Human-readable name pairs for views - - 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. - - Author: Maciej Stachowiak <mjs@eazel.com> -*/ - -#ifndef NAUTILUS_VIEW_IDENTIFIER_H -#define NAUTILUS_VIEW_IDENTIFIER_H - -#include <bonobo-activation/bonobo-activation.h> - -typedef struct { - char *iid; /* Unique ID */ - char *name; /* human-readable name */ - char *view_as_label; /* "View as <name>" */ - char *view_as_label_with_mnemonic; /* "View as _<name>" */ - char *viewer_label; /* "<name> Viewer" */ -} NautilusViewIdentifier; - -NautilusViewIdentifier *nautilus_view_identifier_new_from_bonobo_server_info (Bonobo_ServerInfo *server, - char *name_attribute); -NautilusViewIdentifier *nautilus_view_identifier_new_from_content_view (Bonobo_ServerInfo *server); -NautilusViewIdentifier *nautilus_view_identifier_new_from_sidebar_panel (Bonobo_ServerInfo *server); -NautilusViewIdentifier *nautilus_view_identifier_new_from_property_page (Bonobo_ServerInfo *server); -NautilusViewIdentifier *nautilus_view_identifier_copy (const NautilusViewIdentifier *identifier); -void nautilus_view_identifier_free (NautilusViewIdentifier *identifier); -int nautilus_view_identifier_compare (const NautilusViewIdentifier *a, - const NautilusViewIdentifier *b); -/* lists of NautilusViewIdentifier */ -GList * nautilus_view_identifier_list_copy (GList *list); -void nautilus_view_identifier_list_free (GList *list); - -#endif /* NAUTILUS_VIEW_IDENTIFIER */ diff --git a/libnautilus-private/nautilus-view-query.c b/libnautilus-private/nautilus-view-query.c deleted file mode 100644 index bc0ce1614..000000000 --- a/libnautilus-private/nautilus-view-query.c +++ /dev/null @@ -1,889 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* nautilus-view-query.c - view queries for directories - - Copyright (C) 2000, 2001 Eazel, Inc. - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Authors: Maciej Stachowiak <mjs@eazel.com> -*/ - -#include <config.h> -#include "nautilus-view-query.h" - -#include "nautilus-file-attributes.h" -#include "nautilus-file.h" -#include "nautilus-metadata.h" -#include "nautilus-global-preferences.h" -#include "nautilus-mime-actions.h" -#include <bonobo-activation/bonobo-activation-activate.h> -#include <eel/eel-glib-extensions.h> -#include <eel/eel-string.h> -#include <libgnomevfs/gnome-vfs-application-registry.h> -#include <libgnomevfs/gnome-vfs-mime-handlers.h> -#include <stdio.h> - -static char *mime_type_get_supertype (const char *mime_type); -static gboolean server_has_content_requirements (Bonobo_ServerInfo *server); -static GList *nautilus_do_component_query (const char *mime_type, - const char *uri_scheme, - GList *content_mime_types, - gboolean ignore_content_mime_types, - char **extra_sort_criteria, - char *extra_requirements, - gboolean must_be_view); -static char **strv_concat (char **a, - char **b); - -static gboolean -is_known_mime_type (const char *mime_type) -{ - return eel_strcasecmp (mime_type, GNOME_VFS_MIME_TYPE_UNKNOWN) != 0; -} - -static gboolean -nautilus_view_query_check_if_minimum_attributes_ready (NautilusFile *file) -{ - NautilusFileAttributes attributes; - gboolean ready; - - attributes = nautilus_mime_actions_get_minimum_file_attributes (); - ready = nautilus_file_check_if_ready (file, attributes); - - return ready; -} - -static gboolean -nautilus_view_query_check_if_full_attributes_ready (NautilusFile *file) -{ - NautilusFileAttributes attributes; - gboolean ready; - - attributes = nautilus_mime_actions_get_full_file_attributes (); - ready = nautilus_file_check_if_ready (file, attributes); - - return ready; -} - -static NautilusFileAttributes -nautilus_view_query_get_popup_file_attributes (void) -{ - return NAUTILUS_FILE_ATTRIBUTE_VOLUMES | - NAUTILUS_FILE_ATTRIBUTE_ACTIVATION_URI | - NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE; -} - -static gboolean -nautilus_view_query_check_if_popup_attributes_ready (NautilusFile *file) -{ - NautilusFileAttributes attributes; - gboolean ready; - - attributes = nautilus_view_query_get_popup_file_attributes (); - ready = nautilus_file_check_if_ready (file, attributes); - - return ready; -} - -static char ** -nautilus_view_query_get_default_component_sort_conditions (NautilusFile *file, char *default_component_string) -{ - char **sort_conditions; - char *supertype; - char *mime_type; - - sort_conditions = g_new0 (char *, 4); - - mime_type = nautilus_file_get_mime_type (file); - - supertype = mime_type_get_supertype (mime_type); - - /* prefer the exact right IID */ - if (default_component_string != NULL) { - sort_conditions[0] = g_strconcat ("iid == '", default_component_string, "'", NULL); - } else { - sort_conditions[0] = g_strdup ("true"); - } - - /* Prefer something that matches the exact type to something - that matches the supertype */ - if (is_known_mime_type (mime_type)) { - sort_conditions[1] = g_strconcat ("bonobo:supported_mime_types.has ('",mime_type,"')", NULL); - } else { - sort_conditions[1] = g_strdup ("true"); - } - - /* Prefer something that matches the supertype to something that matches `*' */ - if (is_known_mime_type (mime_type) && supertype != NULL) { - sort_conditions[2] = g_strconcat ("bonobo:supported_mime_types.has ('",supertype,"')", NULL); - } else { - sort_conditions[2] = g_strdup ("true"); - } - - sort_conditions[3] = NULL; - - g_free (mime_type); - g_free (supertype); - - return sort_conditions; -} - -static Bonobo_ServerInfo * -nautilus_view_query_get_default_component_for_file_internal (NautilusFile *file, - gboolean fallback) -{ - GList *info_list; - char *default_component_string; - char *mime_type; - char *uri_scheme; - GList *item_mime_types; - Bonobo_ServerInfo *server; - char **sort_conditions; - char *extra_requirements; - gboolean metadata_default; - - if (!nautilus_view_query_check_if_minimum_attributes_ready (file)) { - return NULL; - } - - info_list = NULL; - - mime_type = nautilus_file_get_mime_type (file); - - uri_scheme = nautilus_file_get_uri_scheme (file); - - if (!nautilus_view_query_check_if_full_attributes_ready (file) || - !nautilus_file_get_directory_item_mime_types (file, &item_mime_types)) { - item_mime_types = NULL; - } - - default_component_string = NULL; - if (!fallback) { - default_component_string = nautilus_file_get_metadata - (file, NAUTILUS_METADATA_KEY_DEFAULT_COMPONENT, NULL); - } - - if (default_component_string == NULL) { - metadata_default = FALSE; - - if (nautilus_file_is_directory (file)) { - default_component_string = nautilus_global_preferences_get_default_folder_viewer_preference_as_iid (); - } else { - g_warning ("Trying to load view for non-directory"); - /* Default component chosen based only on type. */ - } - } else { - metadata_default = TRUE; - } - - sort_conditions = nautilus_view_query_get_default_component_sort_conditions (file, default_component_string); - - /* If the default is specified in the per-uri metadata, - respect the setting regardless of content type requirements */ - if (metadata_default) { - extra_requirements = g_strconcat ("iid == '", default_component_string, "'", NULL); - info_list = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, TRUE, - sort_conditions, extra_requirements, TRUE); - g_free (extra_requirements); - } - - if (info_list == NULL) { - info_list = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, FALSE, - sort_conditions, NULL, TRUE); - } - - if (info_list != NULL) { - server = Bonobo_ServerInfo_duplicate (info_list->data); - gnome_vfs_mime_component_list_free (info_list); - } else { - server = NULL; - } - - eel_g_list_free_deep (item_mime_types); - g_strfreev (sort_conditions); - - g_free (uri_scheme); - g_free (mime_type); - g_free (default_component_string); - - return server; -} - - -Bonobo_ServerInfo * -nautilus_view_query_get_default_component_for_file (NautilusFile *file) -{ - return nautilus_view_query_get_default_component_for_file_internal (file, FALSE); -} - -Bonobo_ServerInfo * -nautilus_view_query_get_fallback_component_for_file (NautilusFile *file) -{ - return nautilus_view_query_get_default_component_for_file_internal (file, TRUE); -} - - -GList * -nautilus_view_query_get_components_for_file (NautilusFile *file) -{ - char *mime_type; - char *uri_scheme; - GList *item_mime_types; - GList *info_list; - - if (!nautilus_view_query_check_if_minimum_attributes_ready (file)) { - return NULL; - } - - uri_scheme = nautilus_file_get_uri_scheme (file); - - mime_type = nautilus_file_get_mime_type (file); - - if (!nautilus_view_query_check_if_full_attributes_ready (file) || - !nautilus_file_get_directory_item_mime_types (file, &item_mime_types)) { - item_mime_types = NULL; - } - - info_list = nautilus_do_component_query (mime_type, uri_scheme, - item_mime_types, FALSE, - NULL, NULL, TRUE); - - eel_g_list_free_deep (item_mime_types); - - g_free (uri_scheme); - g_free (mime_type); - - return info_list; -} - -GnomeVFSResult -nautilus_view_query_set_default_component_for_file (NautilusFile *file, - const char *component_iid) -{ - g_return_val_if_fail (nautilus_view_query_check_if_minimum_attributes_ready (file), - GNOME_VFS_ERROR_GENERIC); - - nautilus_file_set_metadata - (file, NAUTILUS_METADATA_KEY_DEFAULT_COMPONENT, NULL, component_iid); - - return GNOME_VFS_OK; -} - -static char * -extract_prefix_add_suffix (const char *string, - const char *separator, - const char *suffix) -{ - const char *separator_position; - int prefix_length; - char *result; - - separator_position = strstr (string, separator); - prefix_length = separator_position == NULL - ? (int) strlen (string) - : separator_position - string; - - result = g_malloc (prefix_length + strlen(suffix) + 1); - - strncpy (result, string, prefix_length); - result[prefix_length] = '\0'; - - strcat (result, suffix); - - return result; -} - -static char * -mime_type_get_supertype (const char *mime_type) -{ - if (mime_type == NULL || mime_type == '\0') { - return g_strdup (mime_type); - } - return extract_prefix_add_suffix (mime_type, "/", "/*"); -} - -static char * -make_bonobo_activation_query_with_known_mime_type (const char *mime_type, - const char *uri_scheme, - const char *extra_requirements, - gboolean must_be_view) -{ - char *mime_supertype; - char *result; - const char *view_as_name_logic; - - mime_supertype = mime_type_get_supertype (mime_type); - - if (must_be_view) { - view_as_name_logic = "nautilus:view_as_name.defined ()"; - } else { - view_as_name_logic = "true"; - } - - result = g_strdup_printf - ( - - - - /* Check that the component either has a specific - * MIME type or URI scheme. If neither is specified, - * then we don't trust that to mean "all MIME types - * and all schemes". For that, you have to do a - * wildcard for the MIME type or for the scheme. - */ - "(bonobo:supported_mime_types.defined ()" - "OR bonobo:supported_uri_schemes.defined ()" - "OR bonobo:additional_uri_schemes.defined ())" - - /* One of two possibilties */ - - /* FIXME bugzilla.gnome.org 42542: this comment is not very clear. */ - /* 1 The mime type and URI scheme match the supported - attributes. */ - - "AND (" - - /* Check that the supported MIME types include the - * URI's MIME type or its supertype. - */ - "(NOT bonobo:supported_mime_types.defined ()" - "OR bonobo:supported_mime_types.has ('%s')" - "OR bonobo:supported_mime_types.has ('%s')" - "OR bonobo:supported_mime_types.has ('*/*'))" - - /* Check that the supported URI schemes include the - * URI's scheme. - */ - "AND (NOT bonobo:supported_uri_schemes.defined ()" - "OR bonobo:supported_uri_schemes.has ('%s')" - "OR bonobo:supported_uri_schemes.has ('*')))" - - /* 2 OR The additional URI schemes include this URI's - scheme; if that is the case, this view applies - whether or not the mime type is supported. */ - - "OR (bonobo:additional_uri_schemes.has ('%s')" - "OR bonobo:additional_uri_schemes.has ('*')))" - - /* Check that the component makes it clear that it's - * intended for Nautilus by providing a "view_as" - * name. We could instead support a default, but - * that would make components that are untested with - * Nautilus appear. */ - "AND %s)" - - /* Make it possible to add extra requirements */ - " AND (%s)" - - /* The MIME type, MIME supertype, and URI scheme for - * the %s above. - */ - , mime_type, mime_supertype, uri_scheme, uri_scheme, - - view_as_name_logic - - /* extra requirements */ - , extra_requirements != NULL ? extra_requirements : "true"); - - if (must_be_view) { - char *str; - - - /* Check if the component has the interfaces we need. - * We can work with either a Nautilus View, or - * with a Bonobo Control or Embeddable that supports - * one of the three persistence interfaces: - * PersistStream, ProgressiveDataSink, or - * PersistFile. - */ - str = g_strdup_printf ("(((repo_ids.has_all (['IDL:Bonobo/Control:1.0'," - "'IDL:Nautilus/View:1.0'])" - "OR (repo_ids.has_one (['IDL:Bonobo/Control:1.0'," - "'IDL:Bonobo/Embeddable:1.0'])" - "AND repo_ids.has_one (['IDL:Bonobo/PersistStream:1.0'," - "'IDL:Bonobo/ProgressiveDataSink:1.0'," - "'IDL:Bonobo/PersistFile:1.0']))) " - "AND %s", result); - g_free (result); - result = str; - } else { - char *str; - str = g_strdup_printf ("((%s", result); - g_free (result); - result = str; - } - - g_free (mime_supertype); - return result; -} - -static char * -make_bonobo_activation_query_with_uri_scheme_only (const char *uri_scheme, - const char *extra_requirements, - gboolean must_be_view) -{ - char *result; - const char *view_as_name_logic; - - if (must_be_view) { - view_as_name_logic = "nautilus:view_as_name.defined ()"; - } else { - view_as_name_logic = "true"; - } - - result = g_strdup_printf - ( - - /* Check if the component supports this particular - * URI scheme. - */ - "((bonobo:supported_uri_schemes.has ('%s')" - "OR bonobo:supported_uri_schemes.has ('*'))" - - /* Check that the component doesn't require - * particular MIME types. Note that even saying you support "all" - */ - "AND (NOT bonobo:supported_mime_types.defined ()))" - - /* FIXME bugzilla.gnome.org 42542: improve the comment explaining this. */ - - /* This attribute allows uri schemes to be supported - even for unsupported mime types or no mime type. */ - "OR (bonobo:additional_uri_schemes.has ('%s')" - "OR bonobo:additional_uri_schemes.has ('*')))" - - /* Check that the component makes it clear that it's - * intended for Nautilus by providing a "view_as" - * name. We could instead support a default, but - * that would make components that are untested with - * Nautilus appear. */ - "AND %s)" - - /* Make it possible to add extra requirements */ - " AND (%s)" - - /* The URI scheme for the %s above. */ - , uri_scheme, uri_scheme, view_as_name_logic - - /* The explicit metafile iid query for the %s above. */ - , extra_requirements != NULL ? extra_requirements : "true"); - - - if (must_be_view) { - char *str; - - - /* Check if the component has the interfaces we need. - * We can work with either a Nautilus View, or - * with a Bonobo Control or Embeddable that supports - * one of the three persistence interfaces: - * PersistStream, ProgressiveDataSink, or - * PersistFile. - */ - str = g_strdup_printf ("(((repo_ids.has_all (['IDL:Bonobo/Control:1.0'," - "'IDL:Nautilus/View:1.0'])" - "OR (repo_ids.has_one (['IDL:Bonobo/Control:1.0'," - "'IDL:Bonobo/Embeddable:1.0'])" - "AND repo_ids.has_one (['IDL:Bonobo/PersistStream:1.0'," - "'IDL:Bonobo/ProgressiveDataSink:1.0'," - "'IDL:Bonobo/PersistFile:1.0']))) " - "AND %s", result); - g_free (result); - result = str; - } else { - char *str; - str = g_strdup_printf ("((%s", result); - g_free (result); - result = str; - } - - return result; -} - - - -static GHashTable * -mime_type_list_to_hash_table (GList *types) -{ - GHashTable *result; - GList *p; - char *mime_type; - - result = g_hash_table_new (g_str_hash, g_str_equal); - - for (p = types; p != NULL; p = p->next) { - if (p->data != NULL) { - mime_type = (char *) (p->data); - - if (g_hash_table_lookup (result, mime_type) == NULL) { -#ifdef DEBUG_MJS - printf ("XXX content mime type: %s\n", mime_type); -#endif - g_hash_table_insert (result, g_strdup (mime_type), mime_type); - } - } - } - - return result; -} - -static void -free_key (gpointer key, - gpointer value, - gpointer user_data) -{ - g_free (key); -} - -static void -mime_type_hash_table_destroy (GHashTable *table) -{ - g_hash_table_foreach (table, free_key, NULL); - g_hash_table_destroy (table); -} - - - -static gboolean -server_has_content_requirements (Bonobo_ServerInfo *server) -{ - Bonobo_ActivationProperty *prop; - - prop = bonobo_server_info_prop_find (server, "nautilus:required_directory_content_mime_types"); - - if (prop == NULL || prop->v._d != Bonobo_ACTIVATION_P_STRINGV) { - return FALSE; - } else { - return TRUE; - } -} - -static gboolean -server_matches_content_requirements (Bonobo_ServerInfo *server, - GHashTable *type_table) -{ - Bonobo_ActivationProperty *prop; - Bonobo_StringList types; - guint i; - - if (!server_has_content_requirements (server)) { - return TRUE; - } else { - prop = bonobo_server_info_prop_find (server, "nautilus:required_directory_content_mime_types"); - - types = prop->v._u.value_stringv; - - for (i = 0; i < types._length; i++) { - if (g_hash_table_lookup (type_table, types._buffer[i]) != NULL) { - return TRUE; - } - } - } - - return FALSE; -} - - -/* FIXME: do we actually need this it would seem to me that the - * test_only attribute handles this - */ -static char *nautilus_sort_criteria[] = { - /* Prefer anything else over the loser view. */ - "iid != 'OAFIID:Nautilus_Content_Loser'", - /* Prefer anything else over the sample view. */ - "iid != 'OAFIID:Nautilus_Sample_Content_View'", - /* Sort alphabetically */ - "name", - NULL -}; - -static GList * -nautilus_do_component_query (const char *mime_type, - const char *uri_scheme, - GList *item_mime_types, - gboolean ignore_content_mime_types, - char **extra_sort_criteria, - char *extra_requirements, - gboolean must_be_view) -{ - Bonobo_ServerInfoList *bonobo_activation_result; - char *query; - GList *retval; - char **all_sort_criteria; - CORBA_Environment ev; - - bonobo_activation_result = NULL; - query = NULL; - - if (is_known_mime_type (mime_type)) { - query = make_bonobo_activation_query_with_known_mime_type (mime_type, uri_scheme, extra_requirements, must_be_view); - } else { - query = make_bonobo_activation_query_with_uri_scheme_only (uri_scheme, extra_requirements, must_be_view); - } - - all_sort_criteria = strv_concat (extra_sort_criteria, nautilus_sort_criteria); - - CORBA_exception_init (&ev); - - bonobo_activation_result = bonobo_activation_query (query, all_sort_criteria, &ev); - - g_free (all_sort_criteria); - g_free (query); - - retval = NULL; - - if (ev._major == CORBA_NO_EXCEPTION && bonobo_activation_result != NULL && bonobo_activation_result->_length > 0) { - GHashTable *content_types; - guint i; - - content_types = mime_type_list_to_hash_table (item_mime_types); - - for (i = 0; i < bonobo_activation_result->_length; i++) { - Bonobo_ServerInfo *server; - - server = &bonobo_activation_result->_buffer[i]; - - if (ignore_content_mime_types || - server_matches_content_requirements (server, content_types)) { - if (server->iid != NULL) { - retval = g_list_prepend - (retval, - Bonobo_ServerInfo_duplicate (server)); - } - } - } - - mime_type_hash_table_destroy (content_types); - } - - CORBA_free (bonobo_activation_result); - - CORBA_exception_free (&ev); - - return g_list_reverse (retval); -} - -static int -strv_length (char **a) -{ - int i; - - for (i = 0; a != NULL && a[i] != NULL; i++) { - } - - return i; -} - -static char ** -strv_concat (char **a, - char **b) -{ - int a_length; - int b_length; - int i; - int j; - - char **result; - - a_length = strv_length (a); - b_length = strv_length (b); - - result = g_new0 (char *, a_length + b_length + 1); - - j = 0; - - for (i = 0; a != NULL && a[i] != NULL; i++) { - result[j] = a[i]; - j++; - } - - for (i = 0; b != NULL && b[i] != NULL; i++) { - result[j] = b[i]; - j++; - } - - result[j] = NULL; - - return result; -} - -GList * -nautilus_view_query_get_popup_components_for_file (NautilusFile *file) -{ - char *mime_type; - char *uri_scheme; - char *extra_reqs; - GList *item_mime_types; - GList *info_list; - - if (!nautilus_view_query_check_if_popup_attributes_ready (file)) { - return NULL; - } - - uri_scheme = nautilus_file_get_uri_scheme (file); - - mime_type = nautilus_file_get_mime_type (file); - - if (!nautilus_view_query_check_if_full_attributes_ready (file) || - !nautilus_file_get_directory_item_mime_types (file, &item_mime_types)) { - item_mime_types = NULL; - } - - extra_reqs = "repo_ids.has ('IDL:Bonobo/Listener:1.0') AND (nautilus:context_menu_handler == true) AND nautilus:can_handle_multiple_files.defined()"; - - info_list = nautilus_do_component_query (mime_type, uri_scheme, - item_mime_types, FALSE, - NULL, extra_reqs, FALSE); - - eel_g_list_free_deep (item_mime_types); - - g_free (uri_scheme); - g_free (mime_type); - - return info_list; -} - -GList * -nautilus_view_query_get_property_components_for_file (NautilusFile *file) -{ - char *mime_type; - char *uri_scheme; - char *extra_reqs; - GList *item_mime_types; - GList *info_list; - - if (!nautilus_view_query_check_if_minimum_attributes_ready (file)) { - return NULL; - } - - uri_scheme = nautilus_file_get_uri_scheme (file); - - mime_type = nautilus_file_get_mime_type (file); - - if (!nautilus_view_query_check_if_full_attributes_ready (file) || - !nautilus_file_get_directory_item_mime_types (file, &item_mime_types -)) { - item_mime_types = NULL; - } - - extra_reqs = "repo_ids.has ('IDL:Bonobo/Control:1.0') AND nautilus:property_page_name.defined()"; - - info_list = nautilus_do_component_query (mime_type, uri_scheme, - item_mime_types, FALSE, - NULL, extra_reqs, FALSE); - - eel_g_list_free_deep (item_mime_types); - - g_free (uri_scheme); - g_free (mime_type); - - return info_list; -} - -static gboolean -has_server_info_in_list (GList *list, Bonobo_ServerInfo *info) -{ - for (; list; list = list->next) { - Bonobo_ServerInfo *tmp_info = list->data; - - if (strcmp (tmp_info->iid, info->iid) == 0) { - return TRUE; - } - } - - return FALSE; -} - -static GList * -server_info_list_intersection (GList *a, GList *b) -{ - GList *result = NULL; - - if (a == NULL || b == NULL) { - return NULL; - } - - while (b) { - Bonobo_ServerInfo *info; - - info = (Bonobo_ServerInfo *)b->data; - - if (has_server_info_in_list (a, info)) { - result = g_list_prepend (result, - Bonobo_ServerInfo_duplicate (info)); - - } - - b = b->next; - } - - return g_list_reverse (result); -} - -GList * -nautilus_view_query_get_property_components_for_files (GList *files) -{ - GList *result, *l; - - result = NULL; - - for (l = files; l; l = l->next) { - GList *components, *new_result; - - components = nautilus_view_query_get_property_components_for_file (l->data); - if (result != NULL) { - new_result = server_info_list_intersection (result, - components); - gnome_vfs_mime_component_list_free (result); - gnome_vfs_mime_component_list_free (components); - result = new_result; - } else { - result = components;; - } - - - } - - return result; -} - -GList * -nautilus_view_query_get_popup_components_for_files (GList *files) -{ - GList *result, *l; - - result = NULL; - - for (l = files; l; l = l->next) { - GList *components, *new_result; - - components = nautilus_view_query_get_popup_components_for_file (l->data); - if (result != NULL) { - new_result = server_info_list_intersection (result, - components); - gnome_vfs_mime_component_list_free (result); - gnome_vfs_mime_component_list_free (components); - result = new_result; - } else { - result = components;; - } - - - } - - return result; -} diff --git a/libnautilus-private/nautilus-view-query.h b/libnautilus-private/nautilus-view-query.h deleted file mode 100644 index 4907abbbf..000000000 --- a/libnautilus-private/nautilus-view-query.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* nautilus-mime-actions.h - uri-specific versions of mime action functions - - Copyright (C) 2000 Eazel, Inc. - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome Library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Authors: Maciej Stachowiak <mjs@eazel.com> -*/ - -#ifndef NAUTILUS_VIEW_QUERY_H -#define NAUTILUS_VIEW_QUERY_H - -#include <libgnomevfs/gnome-vfs-mime-handlers.h> - -#include <libnautilus-private/nautilus-file.h> - - -Bonobo_ServerInfo * nautilus_view_query_get_default_component_for_file (NautilusFile *file); -GnomeVFSResult nautilus_view_query_set_default_component_for_file - (NautilusFile *file, - const char *iid); -Bonobo_ServerInfo * nautilus_view_query_get_fallback_component_for_file (NautilusFile *file); -GList * nautilus_view_query_get_components_for_file - (NautilusFile *file); -gboolean nautilus_view_query_has_any_components_for_file (NautilusFile *file); - -gboolean nautilus_view_query_has_any_components_for_uri_scheme (const char *uri_scheme); - - -/* Bonobo components for popup menus and property pages - should probably - * be moved into the bonobo extensions */ -GList * nautilus_view_query_get_popup_components_for_file (NautilusFile *file); -GList * nautilus_view_query_get_popup_components_for_files (GList *files); -GList * nautilus_view_query_get_property_components_for_file (NautilusFile *file); -GList * nautilus_view_query_get_property_components_for_files (GList *files); - -#endif /* NAUTILUS_MIME_ACTIONS_H */ diff --git a/libnautilus-private/nautilus-view.c b/libnautilus-private/nautilus-view.c new file mode 100644 index 000000000..a9b694310 --- /dev/null +++ b/libnautilus-private/nautilus-view.c @@ -0,0 +1,353 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- + + nautilus-view.c: Interface for nautilus views + + Copyright (C) 2004 Red Hat 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. + + Author: Alexander Larsson <alexl@redhat.com> +*/ + +#include <config.h> +#include "nautilus-view.h" + +enum { + TITLE_CHANGED, + ZOOM_PARAMETERS_CHANGED, + ZOOM_LEVEL_CHANGED, + LAST_SIGNAL +}; + +static guint nautilus_view_signals[LAST_SIGNAL] = { 0 }; + +static void +nautilus_view_base_init (gpointer g_class) +{ + static gboolean initialized = FALSE; + + if (! initialized) { + nautilus_view_signals[TITLE_CHANGED] = + g_signal_new ("title_changed", + NAUTILUS_TYPE_VIEW, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (NautilusViewIface, title_changed), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + nautilus_view_signals[ZOOM_PARAMETERS_CHANGED] = + g_signal_new ("zoom_parameters_changed", + NAUTILUS_TYPE_VIEW, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (NautilusViewIface, zoom_parameters_changed), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + nautilus_view_signals[ZOOM_LEVEL_CHANGED] = + g_signal_new ("zoom_level_changed", + NAUTILUS_TYPE_VIEW, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (NautilusViewIface, zoom_level_changed), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + initialized = TRUE; + } +} + +GType +nautilus_view_get_type (void) +{ + static GType type = 0; + + if (!type) { + static const GTypeInfo info = { + sizeof (NautilusViewIface), + nautilus_view_base_init, + NULL, + NULL, + NULL, + NULL, + 0, + 0, + NULL + }; + + type = g_type_register_static (G_TYPE_INTERFACE, + "NautilusView", + &info, 0); + g_type_interface_add_prerequisite (type, G_TYPE_OBJECT); + } + + return type; +} + +const char * +nautilus_view_get_view_id (NautilusView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_VIEW (view), NULL); + + return (* NAUTILUS_VIEW_GET_IFACE (view)->get_view_id) (view); +} + +GtkWidget * +nautilus_view_get_widget (NautilusView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_VIEW (view), NULL); + + return (* NAUTILUS_VIEW_GET_IFACE (view)->get_widget) (view); +} + +void +nautilus_view_load_location (NautilusView *view, + const char *location_uri) +{ + g_return_if_fail (NAUTILUS_IS_VIEW (view)); + g_return_if_fail (location_uri != NULL); + + (* NAUTILUS_VIEW_GET_IFACE (view)->load_location) (view, + location_uri); +} + +void +nautilus_view_stop_loading (NautilusView *view) +{ + g_return_if_fail (NAUTILUS_IS_VIEW (view)); + + (* NAUTILUS_VIEW_GET_IFACE (view)->stop_loading) (view); +} + +int +nautilus_view_get_selection_count (NautilusView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_VIEW (view), 0); + + return (* NAUTILUS_VIEW_GET_IFACE (view)->get_selection_count) (view); +} + +GList * +nautilus_view_get_selection (NautilusView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_VIEW (view), NULL); + + return (* NAUTILUS_VIEW_GET_IFACE (view)->get_selection) (view); +} + +void +nautilus_view_set_selection (NautilusView *view, + GList *list) +{ + g_return_if_fail (NAUTILUS_IS_VIEW (view)); + + (* NAUTILUS_VIEW_GET_IFACE (view)->set_selection) (view, + list); +} + + +char * +nautilus_view_get_first_visible_file (NautilusView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_VIEW (view), NULL); + + return (* NAUTILUS_VIEW_GET_IFACE (view)->get_first_visible_file) (view); +} + +void +nautilus_view_scroll_to_file (NautilusView *view, + const char *uri) +{ + g_return_if_fail (NAUTILUS_IS_VIEW (view)); + + (* NAUTILUS_VIEW_GET_IFACE (view)->scroll_to_file) (view, uri); +} + +char * +nautilus_view_get_title (NautilusView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_VIEW (view), NULL); + + if (NAUTILUS_VIEW_GET_IFACE (view)->get_title != NULL) { + return (* NAUTILUS_VIEW_GET_IFACE (view)->get_title) (view); + } else { + return NULL; + } +} + +gboolean +nautilus_view_get_is_zoomable (NautilusView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_VIEW (view), FALSE); + + return (* NAUTILUS_VIEW_GET_IFACE (view)->get_is_zoomable) (view); +} + +float +nautilus_view_get_zoom_level (NautilusView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_VIEW (view), 1.0); + + return (* NAUTILUS_VIEW_GET_IFACE (view)->get_zoom_level) (view); +} + +void +nautilus_view_set_zoom_level (NautilusView *view, + float zoom_level) +{ + g_return_if_fail (NAUTILUS_IS_VIEW (view)); + + (* NAUTILUS_VIEW_GET_IFACE (view)->set_zoom_level) (view, + zoom_level); +} + +float +nautilus_view_get_min_zoom_level (NautilusView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_VIEW (view), 1.0); + + return (* NAUTILUS_VIEW_GET_IFACE (view)->get_min_zoom_level) (view); +} + +float +nautilus_view_get_max_zoom_level (NautilusView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_VIEW (view), 1.0); + + return (* NAUTILUS_VIEW_GET_IFACE (view)->get_max_zoom_level) (view); +} + +gboolean +nautilus_view_get_has_min_zoom_level (NautilusView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_VIEW (view), FALSE); + + return (* NAUTILUS_VIEW_GET_IFACE (view)->get_has_min_zoom_level) (view); +} + +gboolean +nautilus_view_get_has_max_zoom_level (NautilusView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_VIEW (view), FALSE); + + return (* NAUTILUS_VIEW_GET_IFACE (view)->get_has_max_zoom_level) (view); +} + +gboolean +nautilus_view_get_is_continuous (NautilusView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_VIEW (view), FALSE); + + return (* NAUTILUS_VIEW_GET_IFACE (view)->get_is_continuous) (view); +} + +gboolean +nautilus_view_get_can_zoom_in (NautilusView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_VIEW (view), FALSE); + + return (* NAUTILUS_VIEW_GET_IFACE (view)->get_can_zoom_in) (view); +} + +gboolean +nautilus_view_get_can_zoom_out (NautilusView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_VIEW (view), FALSE); + + return (* NAUTILUS_VIEW_GET_IFACE (view)->get_can_zoom_out) (view); +} + +GList * +nautilus_view_get_preferred_zoom_levels (NautilusView *view) +{ + g_return_val_if_fail (NAUTILUS_IS_VIEW (view), NULL); + + return (* NAUTILUS_VIEW_GET_IFACE (view)->get_preferred_zoom_levels) (view); +} + +void +nautilus_view_zoom_in (NautilusView *view) +{ + g_return_if_fail (NAUTILUS_IS_VIEW (view)); + + (* NAUTILUS_VIEW_GET_IFACE (view)->zoom_in) (view); +} + +void +nautilus_view_zoom_out (NautilusView *view) +{ + g_return_if_fail (NAUTILUS_IS_VIEW (view)); + + (* NAUTILUS_VIEW_GET_IFACE (view)->zoom_out) (view); +} + +void +nautilus_view_zoom_to_fit (NautilusView *view) +{ + g_return_if_fail (NAUTILUS_IS_VIEW (view)); + + (* NAUTILUS_VIEW_GET_IFACE (view)->zoom_to_fit) (view); +} + +static void +nautilus_ui_component_free (BonoboUIComponent *ui_component) +{ + bonobo_ui_component_unset_container (ui_component, NULL); + bonobo_object_unref (BONOBO_OBJECT (ui_component)); +} + +static BonoboUIComponent * +nautilus_view_get_ui_component (NautilusView *view) +{ + BonoboUIComponent *ui_component; + + ui_component = g_object_get_data (G_OBJECT (view), + "nautilus-view-ui-component"); + + if (ui_component == NULL) { + ui_component = bonobo_ui_component_new_default (); + g_object_set_data_full (G_OBJECT (view), + "nautilus-view-ui-component", + ui_component, + (GDestroyNotify) nautilus_ui_component_free); + } + + return ui_component; +} + + +BonoboUIComponent * +nautilus_view_set_up_ui (NautilusView *view, + Bonobo_UIContainer ui_container, + const char *datadir, + const char *ui_file_name, + const char *application_name) +{ + BonoboUIComponent *ui_component; + + /* Get the UI component that's pre-made by the control. */ + ui_component = nautilus_view_get_ui_component (view); + + /* Connect the UI component to the control frame's UI container. */ + bonobo_ui_component_set_container (ui_component, ui_container, NULL); + + /* Set up the UI from an XML file. */ + bonobo_ui_util_set_ui (ui_component, datadir, ui_file_name, application_name, NULL); + + return ui_component; +} + diff --git a/libnautilus-private/nautilus-view.h b/libnautilus-private/nautilus-view.h new file mode 100644 index 000000000..9539a4324 --- /dev/null +++ b/libnautilus-private/nautilus-view.h @@ -0,0 +1,166 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- + + nautilus-view.h: Interface for nautilus views + + Copyright (C) 2004 Red Hat 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. + + Author: Alexander Larsson <alexl@redhat.com> +*/ + +#ifndef NAUTILUS_VIEW_H +#define NAUTILUS_VIEW_H + +#include <glib-object.h> +#include <gtk/gtkwidget.h> +#include <bonobo/bonobo-ui-util.h> + +G_BEGIN_DECLS + +#define NAUTILUS_TYPE_VIEW (nautilus_view_get_type ()) +#define NAUTILUS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_VIEW, NautilusView)) +#define NAUTILUS_IS_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_VIEW)) +#define NAUTILUS_VIEW_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NAUTILUS_TYPE_VIEW, NautilusViewIface)) + + +typedef struct _NautilusView NautilusView; /* dummy typedef */ +typedef struct _NautilusViewIface NautilusViewIface; + +struct _NautilusViewIface +{ + GTypeInterface g_iface; + + /* Signals: */ + + /* emitted when the view-specific title as returned by get_title changes */ + void (* title_changed) (NautilusView *view); + + void (* zoom_parameters_changed)(NautilusView *view); + void (* zoom_level_changed) (NautilusView *view); + + /* VTable: */ + + /* Get the id string for this view. Its a constant string, not memory managed */ + const char * (* get_view_id) (NautilusView *view); + + /* Get the widget for this view, can be the same object or a different + object owned by the view. Doesn't ref the widget. */ + GtkWidget * (* get_widget) (NautilusView *view); + + /* Called to tell the view to start loading a location, or to reload it. + The view responds with a load_underway as soon as it starts loading, + and a load_complete when the location is completely read. */ + void (* load_location) (NautilusView *view, + const char *location_uri); + + /* Called to tell the view to stop loading the location its currently loading */ + void (* stop_loading) (NautilusView *view); + + /* Returns the number of selected items in the view */ + int (* get_selection_count) (NautilusView *view); + + /* Returns a list of uris for th selected items in the view, caller frees it */ + GList * (* get_selection) (NautilusView *view); + + /* This is called when the window wants to change the selection in the view */ + void (* set_selection) (NautilusView *view, + GList *list); + + /* Return the uri of the first visible file */ + char * (* get_first_visible_file) (NautilusView *view); + /* Scroll the view so that the file specified by the uri is at the top + of the view */ + void (* scroll_to_file) (NautilusView *view, + const char *uri); + + /* This function can supply a special window title, if you don't want one + have this function return NULL, or just don't supply a function */ + char * (* get_title) (NautilusView *view); + + + /* BONOBOTODO: re-think this interface later */ + gboolean (*get_is_zoomable) (NautilusView *view); + float (*get_zoom_level) (NautilusView *view); + void (*set_zoom_level) (NautilusView *view, + float zoom_level); + float (*get_min_zoom_level) (NautilusView *view); + float (*get_max_zoom_level) (NautilusView *view); + gboolean (*get_has_min_zoom_level) (NautilusView *view); + gboolean (*get_has_max_zoom_level) (NautilusView *view); + gboolean (*get_is_continuous) (NautilusView *view); + gboolean (*get_can_zoom_in) (NautilusView *view); + gboolean (*get_can_zoom_out) (NautilusView *view); + + GList * (*get_preferred_zoom_levels)(NautilusView *view); + void (*zoom_in) (NautilusView *view); + void (*zoom_out) (NautilusView *view); + void (*zoom_to_fit) (NautilusView *view); + + /* Padding for future expansion */ + void (*_reserved1) (void); + void (*_reserved2) (void); + void (*_reserved3) (void); + void (*_reserved4) (void); + void (*_reserved5) (void); + void (*_reserved6) (void); + void (*_reserved7) (void); + void (*_reserved8) (void); +}; + +GType nautilus_view_get_type (void); + +const char *nautilus_view_get_view_id (NautilusView *view); +GtkWidget * nautilus_view_get_widget (NautilusView *view); +void nautilus_view_load_location (NautilusView *view, + const char *location_uri); +void nautilus_view_stop_loading (NautilusView *view); +int nautilus_view_get_selection_count (NautilusView *view); +GList * nautilus_view_get_selection (NautilusView *view); +void nautilus_view_set_selection (NautilusView *view, + GList *list); +char * nautilus_view_get_first_visible_file (NautilusView *view); +void nautilus_view_scroll_to_file (NautilusView *view, + const char *uri); +char * nautilus_view_get_title (NautilusView *view); +gboolean nautilus_view_get_is_zoomable (NautilusView *view); +float nautilus_view_get_zoom_level (NautilusView *view); +void nautilus_view_set_zoom_level (NautilusView *view, + float zoom_level); +float nautilus_view_get_min_zoom_level (NautilusView *view); +float nautilus_view_get_max_zoom_level (NautilusView *view); +gboolean nautilus_view_get_has_min_zoom_level (NautilusView *view); +gboolean nautilus_view_get_has_max_zoom_level (NautilusView *view); +gboolean nautilus_view_get_is_continuous (NautilusView *view); +gboolean nautilus_view_get_can_zoom_in (NautilusView *view); +gboolean nautilus_view_get_can_zoom_out (NautilusView *view); +GList * nautilus_view_get_preferred_zoom_levels (NautilusView *view); +void nautilus_view_zoom_in (NautilusView *view); +void nautilus_view_zoom_out (NautilusView *view); +void nautilus_view_zoom_to_fit (NautilusView *view); + +/* Temporary bonoboui stuff: */ +BonoboUIComponent * nautilus_view_set_up_ui (NautilusView *view, + Bonobo_UIContainer ui_container, + const char *datadir, + const char *ui_file_name, + const char *application_name); + + + +G_END_DECLS + +#endif /* NAUTILUS_VIEW_H */ diff --git a/libnautilus-private/nautilus-window-info.c b/libnautilus-private/nautilus-window-info.c new file mode 100644 index 000000000..b66a8471a --- /dev/null +++ b/libnautilus-private/nautilus-window-info.c @@ -0,0 +1,227 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- + + nautilus-window-info.c: Interface for nautilus window + + Copyright (C) 2004 Red Hat 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. + + Author: Alexander Larsson <alexl@redhat.com> +*/ + +#include <config.h> +#include "nautilus-window-info.h" + +enum { + LOADING_URI, + SELECTION_CHANGED, + TITLE_CHANGED, + LAST_SIGNAL +}; + +static guint nautilus_window_info_signals[LAST_SIGNAL] = { 0 }; + +static void +nautilus_window_info_base_init (gpointer g_class) +{ + static gboolean initialized = FALSE; + + if (! initialized) { + nautilus_window_info_signals[LOADING_URI] = + g_signal_new ("loading_uri", + NAUTILUS_TYPE_WINDOW_INFO, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (NautilusWindowInfoIface, loading_uri), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, + G_TYPE_STRING); + + nautilus_window_info_signals[SELECTION_CHANGED] = + g_signal_new ("selection_changed", + NAUTILUS_TYPE_WINDOW_INFO, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (NautilusWindowInfoIface, selection_changed), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + nautilus_window_info_signals[TITLE_CHANGED] = + g_signal_new ("title_changed", + NAUTILUS_TYPE_WINDOW_INFO, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (NautilusWindowInfoIface, title_changed), + NULL, NULL, + g_cclosure_marshal_VOID__STRING, + G_TYPE_NONE, 1, + G_TYPE_STRING); + + initialized = TRUE; + } +} + +GType +nautilus_window_info_get_type (void) +{ + static GType type = 0; + + if (!type) { + static const GTypeInfo info = { + sizeof (NautilusWindowInfoIface), + nautilus_window_info_base_init, + NULL, + NULL, + NULL, + NULL, + 0, + 0, + NULL + }; + + type = g_type_register_static (G_TYPE_INTERFACE, + "NautilusWindowInfo", + &info, 0); + g_type_interface_add_prerequisite (type, G_TYPE_OBJECT); + } + + return type; +} + +void +nautilus_window_info_report_load_underway (NautilusWindowInfo *window, + NautilusView *view) +{ + g_return_if_fail (NAUTILUS_IS_WINDOW_INFO (window)); + g_return_if_fail (NAUTILUS_IS_VIEW (view)); + + (* NAUTILUS_WINDOW_INFO_GET_IFACE (window)->report_load_underway) (window, + view); +} + +void +nautilus_window_info_report_load_complete (NautilusWindowInfo *window, + NautilusView *view) +{ + g_return_if_fail (NAUTILUS_IS_WINDOW_INFO (window)); + g_return_if_fail (NAUTILUS_IS_VIEW (view)); + + (* NAUTILUS_WINDOW_INFO_GET_IFACE (window)->report_load_complete) (window, + view); +} + +void +nautilus_window_info_report_view_failed (NautilusWindowInfo *window, + NautilusView *view) +{ + g_return_if_fail (NAUTILUS_IS_WINDOW_INFO (window)); + g_return_if_fail (NAUTILUS_IS_VIEW (view)); + + (* NAUTILUS_WINDOW_INFO_GET_IFACE (window)->report_view_failed) (window, + view); +} + +void +nautilus_window_info_report_selection_changed (NautilusWindowInfo *window) +{ + g_return_if_fail (NAUTILUS_IS_WINDOW_INFO (window)); + + (* NAUTILUS_WINDOW_INFO_GET_IFACE (window)->report_selection_changed) (window); +} + +void +nautilus_window_info_open_location (NautilusWindowInfo *window, + const char *location, + NautilusWindowOpenMode mode, + NautilusWindowOpenFlags flags, + GList *selection) +{ + g_return_if_fail (NAUTILUS_IS_WINDOW_INFO (window)); + + (* NAUTILUS_WINDOW_INFO_GET_IFACE (window)->open_location) (window, + location, + mode, + flags, + selection); +} + +void +nautilus_window_info_close (NautilusWindowInfo *window) +{ + g_return_if_fail (NAUTILUS_IS_WINDOW_INFO (window)); + + (* NAUTILUS_WINDOW_INFO_GET_IFACE (window)->close_window) (window); +} + +void +nautilus_window_info_set_status (NautilusWindowInfo *window, + const char *status) +{ + g_return_if_fail (NAUTILUS_IS_WINDOW_INFO (window)); + + (* NAUTILUS_WINDOW_INFO_GET_IFACE (window)->set_status) (window, + status); +} + +NautilusWindowType +nautilus_window_info_get_window_type (NautilusWindowInfo *window) +{ + g_return_val_if_fail (NAUTILUS_IS_WINDOW_INFO (window), NAUTILUS_WINDOW_SPATIAL); + + return (* NAUTILUS_WINDOW_INFO_GET_IFACE (window)->get_window_type) (window); +} + +int +nautilus_window_info_get_selection_count (NautilusWindowInfo *window) +{ + g_return_val_if_fail (NAUTILUS_IS_WINDOW_INFO (window), 0); + + return (* NAUTILUS_WINDOW_INFO_GET_IFACE (window)->get_selection_count) (window); +} + +GList * +nautilus_window_info_get_selection (NautilusWindowInfo *window) +{ + g_return_val_if_fail (NAUTILUS_IS_WINDOW_INFO (window), NULL); + + return (* NAUTILUS_WINDOW_INFO_GET_IFACE (window)->get_selection) (window); +} + +NautilusWindowShowHiddenFilesMode +nautilus_window_info_get_hidden_files_mode (NautilusWindowInfo *window) +{ + g_return_val_if_fail (NAUTILUS_IS_WINDOW_INFO (window), NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_DEFAULT); + + return (* NAUTILUS_WINDOW_INFO_GET_IFACE (window)->get_hidden_files_mode) (window); +} + +void +nautilus_window_info_set_hidden_files_mode (NautilusWindowInfo *window, + NautilusWindowShowHiddenFilesMode mode) +{ + g_return_if_fail (NAUTILUS_IS_WINDOW_INFO (window)); + + (* NAUTILUS_WINDOW_INFO_GET_IFACE (window)->set_hidden_files_mode) (window, + mode); +} + +Bonobo_UIContainer +nautilus_window_info_get_ui_container (NautilusWindowInfo *window) +{ + g_return_val_if_fail (NAUTILUS_IS_WINDOW_INFO (window), CORBA_OBJECT_NIL); + + return (* NAUTILUS_WINDOW_INFO_GET_IFACE (window)->get_ui_container) (window); +} + diff --git a/libnautilus-private/nautilus-window-info.h b/libnautilus-private/nautilus-window-info.h new file mode 100644 index 000000000..98ad5202f --- /dev/null +++ b/libnautilus-private/nautilus-window-info.h @@ -0,0 +1,160 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- + + nautilus-window-info.h: Interface for nautilus windows + + Copyright (C) 2004 Red Hat 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. + + Author: Alexander Larsson <alexl@redhat.com> +*/ + +#ifndef NAUTILUS_WINDOW_INFO_H +#define NAUTILUS_WINDOW_INFO_H + +#include <glib-object.h> +#include <libnautilus-private/nautilus-view.h> +#include <bonobo/bonobo-ui-util.h> + +G_BEGIN_DECLS + +typedef enum +{ + NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_DEFAULT, + NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_ENABLE, + NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_DISABLE +} NautilusWindowShowHiddenFilesMode; + + +typedef enum { + NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE, + NAUTILUS_WINDOW_OPEN_IN_SPATIAL, + NAUTILUS_WINDOW_OPEN_IN_NAVIGATION +} NautilusWindowOpenMode; + +typedef enum { + NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND = 1<<0 +} NautilusWindowOpenFlags; + +typedef enum { + NAUTILUS_WINDOW_SPATIAL, + NAUTILUS_WINDOW_NAVIGATION, + NAUTILUS_WINDOW_DESKTOP +} NautilusWindowType; + +#define NAUTILUS_TYPE_WINDOW_INFO (nautilus_window_info_get_type ()) +#define NAUTILUS_WINDOW_INFO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_WINDOW_INFO, NautilusWindowInfo)) +#define NAUTILUS_IS_WINDOW_INFO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_WINDOW_INFO)) +#define NAUTILUS_WINDOW_INFO_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NAUTILUS_TYPE_WINDOW_INFO, NautilusWindowInfoIface)) + +#ifndef NAUTILUS_WINDOW_DEFINED +#define NAUTILUS_WINDOW_DEFINED +/* Using NautilusWindow for the vtable to make implementing this in + * NautilusWindow easier */ +typedef struct NautilusWindow NautilusWindow; +#endif + +typedef NautilusWindow NautilusWindowInfo; + +typedef struct _NautilusWindowInfoIface NautilusWindowInfoIface; + +struct _NautilusWindowInfoIface +{ + GTypeInterface g_iface; + + /* signals: */ + + void (* loading_uri) (NautilusWindowInfo *window, + char *uri); + /* Emitted when the view in the window changes the selection */ + void (* selection_changed) (NautilusWindowInfo *window); + void (* title_changed) (NautilusWindowInfo *window, + const char *title); + + /* VTable: */ + /* A view calls this once after a load_location, once it starts loading the + * directory. Might be called directly, or later on the mainloop. + * This can also be called at any other time if the view needs to + * re-load the location. But the view needs to call load_complete first if + * its currently loading. */ + void (* report_load_underway) (NautilusWindowInfo *window, + NautilusView *view); + /* A view calls this once after reporting load_underway, when the location + has been fully loaded, or when the load was stopped + (by an error or by the user). */ + void (* report_load_complete) (NautilusWindowInfo *window, + NautilusView *view); + /* This can be called at any time when there has been a catastrophic failure of + the view. It will result in the view being removed. */ + void (* report_view_failed) (NautilusWindowInfo *window, + NautilusView *view); + void (* report_selection_changed) (NautilusWindowInfo *window); + + /* Returns the number of selected items in the view */ + int (* get_selection_count) (NautilusWindowInfo *window); + + /* Returns a list of uris for th selected items in the view, caller frees it */ + GList *(* get_selection) (NautilusWindowInfo *window); + + void (* open_location) (NautilusWindowInfo *window, + const char *location, + NautilusWindowOpenMode mode, + NautilusWindowOpenFlags flags, + GList *selection); + void (* close_window) (NautilusWindowInfo *window); + void (* set_status) (NautilusWindowInfo *window, + const char *status); + NautilusWindowType + (* get_window_type) (NautilusWindowInfo *window); + NautilusWindowShowHiddenFilesMode + (* get_hidden_files_mode)(NautilusWindowInfo *window); + void (* set_hidden_files_mode)(NautilusWindowInfo *window, + NautilusWindowShowHiddenFilesMode mode); + + /* Temporary bonoboui stuff: */ + Bonobo_UIContainer (* get_ui_container) (NautilusWindowInfo *window); +}; + +GType nautilus_window_info_get_type (void); +void nautilus_window_info_report_load_underway (NautilusWindowInfo *window, + NautilusView *view); +void nautilus_window_info_report_load_complete (NautilusWindowInfo *window, + NautilusView *view); +void nautilus_window_info_report_view_failed (NautilusWindowInfo *window, + NautilusView *view); +void nautilus_window_info_report_selection_changed (NautilusWindowInfo *window); +void nautilus_window_info_open_location (NautilusWindowInfo *window, + const char *location, + NautilusWindowOpenMode mode, + NautilusWindowOpenFlags flags, + GList *selection); +void nautilus_window_info_close (NautilusWindowInfo *window); +void nautilus_window_info_set_status (NautilusWindowInfo *window, + const char *status); +NautilusWindowType nautilus_window_info_get_window_type (NautilusWindowInfo *window); +int nautilus_window_info_get_selection_count (NautilusWindowInfo *window); +GList * nautilus_window_info_get_selection (NautilusWindowInfo *window); +NautilusWindowShowHiddenFilesMode nautilus_window_info_get_hidden_files_mode (NautilusWindowInfo *window); +void nautilus_window_info_set_hidden_files_mode (NautilusWindowInfo *window, + NautilusWindowShowHiddenFilesMode mode); + +/* temporary BonoboUI stuff */ +Bonobo_UIContainer nautilus_window_info_get_ui_container (NautilusWindowInfo *window); + + +G_END_DECLS + +#endif /* NAUTILUS_WINDOW_INFO_H */ diff --git a/src/Makefile.am b/src/Makefile.am index 2d741fcaf..ecbe48385 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,8 +27,6 @@ INCLUDES = \ LDADD =\ $(top_builddir)/src/file-manager/libnautilus-file-manager.la \ - $(top_builddir)/libnautilus/libnautilus.la \ - $(top_builddir)/libnautilus-adapter/libnautilus-adapter.la \ $(top_builddir)/libnautilus-private/libnautilus-private.la \ $(top_builddir)/cut-n-paste-code/gsequence/libgsequence.la \ $(CORE_LIBS) \ @@ -52,13 +50,11 @@ nautilus_shell_interface_idl_sources = \ nautilus_SOURCES = \ $(nautilus_shell_interface_idl_sources) \ - nautilus-applicable-views.c \ nautilus-application.c \ nautilus-bookmark-list.c \ nautilus-bookmark-parsing.c \ nautilus-bookmarks-window.c \ nautilus-complex-search-bar.c \ - nautilus-component-adapter-factory.c \ nautilus-connect-server-dialog.c \ nautilus-desktop-window.c \ nautilus-first-time-druid.c \ @@ -84,19 +80,15 @@ nautilus_SOURCES = \ nautilus-switchable-navigation-bar.c \ nautilus-switchable-search-bar.c \ nautilus-window-toolbars.c \ - nautilus-view-frame-corba.c \ - nautilus-view-frame.c \ nautilus-window-manage-views.c \ nautilus-window-menus.c \ nautilus-window.c \ nautilus-zoom-control.c \ - nautilus-applicable-views.h \ nautilus-application.h \ nautilus-bookmark-list.h \ nautilus-bookmark-parsing.h \ nautilus-bookmarks-window.h \ nautilus-complex-search-bar.h \ - nautilus-component-adapter-factory.h \ nautilus-connect-server-dialog.h \ nautilus-desktop-window.h \ nautilus-first-time-druid.h \ @@ -122,8 +114,6 @@ nautilus_SOURCES = \ nautilus-spatial-window.h \ nautilus-switchable-navigation-bar.h \ nautilus-switchable-search-bar.h \ - nautilus-view-frame-private.h \ - nautilus-view-frame.h \ nautilus-window-manage-views.h \ nautilus-window-private.h \ nautilus-window.h \ diff --git a/src/file-manager/Makefile.am b/src/file-manager/Makefile.am index f34fdc8b5..8e9b94889 100644 --- a/src/file-manager/Makefile.am +++ b/src/file-manager/Makefile.am @@ -15,37 +15,36 @@ INCLUDES = \ libnautilus_file_manager_la_SOURCES= \ - fm-bonobo-provider.c \ fm-desktop-icon-view.c \ - fm-directory-view.c \ - fm-ditem-page.c \ - fm-error-reporting.c \ - fm-icon-container.c \ - fm-icon-view.c \ - fm-list-model.c \ - fm-list-view.c \ - fm-properties-window.c \ - fm-search-list-view.c \ - nautilus-indexing-info.c \ - fm-tree-model.c \ - fm-tree-view.c \ - fm-bonobo-provider.h \ fm-desktop-icon-view.h \ + fm-directory-view.c \ fm-directory-view.h \ + fm-ditem-page.c \ fm-ditem-page.h \ + fm-error-reporting.c \ fm-error-reporting.h \ + fm-icon-container.c \ fm-icon-container.h \ + fm-icon-view.c \ fm-icon-view.h \ + fm-list-model.c \ fm-list-model.h \ fm-list-view-private.h \ + fm-list-view.c \ fm-list-view.h \ + fm-properties-window.c \ fm-properties-window.h \ - fm-search-list-view.h \ - nautilus-indexing-info.h \ + fm-tree-model.c \ fm-tree-model.h \ - fm-tree-view.h \ + nautilus-indexing-info.c \ + nautilus-indexing-info.h \ $(NULL) +# temp commented out: +# fm-tree-view.c \ +# fm-tree-view.h \ + + uidir = $(datadir)/gnome-2.0/ui ui_DATA = \ nautilus-desktop-icon-view-ui.xml \ diff --git a/src/file-manager/fm-bonobo-provider.c b/src/file-manager/fm-bonobo-provider.c deleted file mode 100644 index af55a8d52..000000000 --- a/src/file-manager/fm-bonobo-provider.c +++ /dev/null @@ -1,635 +0,0 @@ -/* - * fm-bonobo-provider.h - Bonobo API support - * - * Copyright (C) 2002 James Willcox - * 2003 Novell, Inc. - * - * This library 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 library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Authors: James Willcox <jwillcox@gnome.org> - * Dave Camp <dave@ximian.com> - * - */ - -/* This object exports the bonobo context menus and property pages - * using the new extension interface. */ - -#include <config.h> -#include "fm-bonobo-provider.h" - -#include <string.h> - -#include <bonobo/bonobo-control.h> -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-property-bag-client.h> -#include <bonobo/bonobo-ui-util.h> -#include <bonobo/bonobo-widget.h> -#include <bonobo/bonobo-window.h> -#include <bonobo/bonobo-zoomable.h> -#include <eel/eel-glib-extensions.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtkimage.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkmessagedialog.h> -#include <gtk/gtkstock.h> -#include <gtk/gtkvbox.h> -#include <libgnome/gnome-i18n.h> -#include <libgnomeui/gnome-uidefs.h> -#include <libnautilus-extension/nautilus-extension-types.h> -#include <libnautilus-extension/nautilus-file-info.h> -#include <libnautilus-extension/nautilus-menu-provider.h> -#include <libnautilus-extension/nautilus-property-page-provider.h> -#include <libnautilus-private/nautilus-mime-actions.h> -#include <libnautilus-private/nautilus-view-identifier.h> -#include <libnautilus-private/nautilus-view-query.h> - -typedef struct { - char *id; - char *verb; - CORBA_sequence_CORBA_string *uri_list; -} BonoboMimeActionData; - - -typedef struct { - GList *files; - GtkWidget *vbox; - char *view_name; -} ActivationData; - -static void fm_bonobo_provider_instance_init (FMBonoboProvider *provider); -static void fm_bonobo_provider_class_init (FMBonoboProviderClass *class); - -static GObjectClass *parent_class; - -static BonoboMimeActionData * -bonobo_mime_action_data_new (const char *id, const char *verb, GList *files) -{ - BonoboMimeActionData *data; - CORBA_sequence_CORBA_string *uri_list; - int i; - - data = g_new (BonoboMimeActionData, 1); - data->id = g_strdup (id); - data->verb = g_strdup (verb); - - /* convert the GList of files into a CORBA sequence */ - - uri_list = CORBA_sequence_CORBA_string__alloc (); - uri_list->_maximum = g_list_length (files); - uri_list->_length = uri_list->_maximum; - uri_list->_buffer = CORBA_sequence_CORBA_string_allocbuf (uri_list->_length); - - for (i=0; files; files = files->next, i++) - { - NautilusFile *file; - char *uri; - - file = files->data; - uri = nautilus_file_get_uri (file); - - uri_list->_buffer[i] = CORBA_string_dup ((char*)uri); - - g_free (uri); - } - - CORBA_sequence_set_release (uri_list, CORBA_TRUE); - data->uri_list = uri_list; - - - return data; -} - -static void -bonobo_mime_action_data_free (BonoboMimeActionData *data) -{ - g_free (data->id); - g_free (data->verb); - g_free (data); -} - -static void -bonobo_mime_action_activate_callback (CORBA_Object obj, - const char *error_reason, - gpointer user_data) -{ - Bonobo_Listener listener; - CORBA_Environment ev; - BonoboMimeActionData *data; - CORBA_any any; - - data = user_data; - - if (obj == CORBA_OBJECT_NIL) { - GtkWidget *dialog; - - /* FIXME: make an error message that is not so lame */ - dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("Could not complete specified action: %s"), error_reason); - g_signal_connect (dialog, "response", - G_CALLBACK (gtk_widget_destroy), NULL); - gtk_widget_show (dialog); - return; - } - - CORBA_exception_init (&ev); - - listener = Bonobo_Unknown_queryInterface (obj, - "IDL:Bonobo/Listener:1.0", - &ev); - - if (!BONOBO_EX (&ev)) { - any._type = TC_CORBA_sequence_CORBA_string; - any._value = data->uri_list; - Bonobo_Listener_event (listener, data->verb, &any, &ev); - bonobo_object_release_unref (listener, &ev); - } else { - GtkWidget *dialog; - - /* FIXME: make an error message that is not so lame */ - dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR, - GTK_BUTTONS_OK, - _("Could not complete specified action.")); - g_signal_connect (dialog, "response", - G_CALLBACK (gtk_widget_destroy), NULL); - gtk_widget_show (dialog); - } - -} - -static void -bonobo_mime_action_callback (NautilusMenuItem *item, - gpointer callback_data) -{ - BonoboMimeActionData *data; - - data = callback_data; - - bonobo_activation_activate_from_id_async (data->id, 0, - bonobo_mime_action_activate_callback, - data, NULL); - -} - -static void -bonobo_mime_action_menu_data_destroy_callback (gpointer data, GClosure *closure) -{ - bonobo_mime_action_data_free ((BonoboMimeActionData *)data); -} - -static gboolean -no_locale_at_end (const char *str) -{ - int len; - - len = strlen (str); - if (len > 3 && - str[len-3] == '-' && - g_ascii_isalpha (str[len-2]) && - g_ascii_isalpha (str[len-1])) { - return FALSE; - } - if (len > 6 && - str[len-6] == '-' && - g_ascii_isalpha (str[len-5]) && - g_ascii_isalpha (str[len-4]) && - str[len-3] == '_' && - g_ascii_isalpha (str[len-2]) && - g_ascii_isalpha (str[len-1])) { - return FALSE; - } - return TRUE; -} - -static GList * -get_bonobo_menu_verb_names (Bonobo_ServerInfo *info) -{ - GList *l; - unsigned int i; - int offset; - - offset = strlen ("nautilusverb:"); - - l = NULL; - for (i = 0; i < info->props._length; i++) { - - /* look for properties that start with "nautilusverb:". The - * part following the colon is the verb name - */ - if (strstr (info->props._buffer[i].name, "nautilusverb:") && - no_locale_at_end (info->props._buffer[i].name)) { - l = g_list_prepend (l, - g_strdup (&info->props._buffer[i].name[offset])); - } - } - - return l; -} - -static gboolean -can_handle_multiple_files (Bonobo_ServerInfo *info) -{ - Bonobo_ActivationProperty *prop; - - prop = bonobo_server_info_prop_find (info, "nautilus:can_handle_multiple_files"); - - if (prop == NULL || prop->v._d != Bonobo_ACTIVATION_P_BOOLEAN) { - return FALSE; - } else { - return prop->v._u.value_boolean; - } -} - -static GList * -get_menu_items_for_server (Bonobo_ServerInfo *info, - GList *verb_names, - GList *files) -{ - GList *items; - GList *l; - const GList *langs; - GSList *langs_cpy; - - langs = gnome_i18n_get_language_list ("LANG"); - langs_cpy = NULL; - /* copy it to a singly linked list since bonobo wants that...sigh */ - for (; langs; langs = langs->next) { - langs_cpy = g_slist_append (langs_cpy, langs->data); - } - - items = NULL; - - /* build the commands */ - for (l = verb_names; l; l = l->next) { - NautilusMenuItem *item; - BonoboMimeActionData *data; - char *verb; - char *prop_name; - const char *label; - const char *icon_name; - GClosure *closure; - - verb = l->data; - - prop_name = g_strdup_printf ("nautilusverb:%s", verb); - label = bonobo_server_info_prop_lookup (info, prop_name, - langs_cpy); - g_free (prop_name); - - prop_name = g_strdup_printf ("nautilusverbicon:%s", verb); - icon_name = bonobo_server_info_prop_lookup (info, prop_name, - langs_cpy); - g_free (prop_name); - if (!icon_name) { - icon_name = bonobo_server_info_prop_lookup (info, "nautilus:icon", - langs_cpy); - } - - data = bonobo_mime_action_data_new (info->iid, - verb, files); - closure = g_cclosure_new - (G_CALLBACK (bonobo_mime_action_callback), - data, - bonobo_mime_action_menu_data_destroy_callback); - - item = nautilus_menu_item_new (verb, - label, - "", /* no tip for bonobo items */ - icon_name); - g_signal_connect_data (item, "activate", - G_CALLBACK (bonobo_mime_action_callback), - data, - bonobo_mime_action_menu_data_destroy_callback, - 0); - items = g_list_prepend (items, item); - } - items = g_list_reverse (items); - - g_slist_free (langs_cpy); - - /* if it doesn't handle multiple files, disable the menu items */ - if ((g_list_length (files) > 1) && - (can_handle_multiple_files (info) == FALSE)) { - GList *l; - - for (l = items; l != NULL; l = l->next) { - g_object_set (l->data, "sensitive", FALSE, NULL); - } - } - - return items; -} - -static GList * -fm_bonobo_provider_get_file_items (NautilusMenuProvider *provider, - GtkWidget *window, - GList *selection) -{ - GList *components; - GList *items; - GList *l; - - components = nautilus_view_query_get_popup_components_for_files (selection); - - items = NULL; - for (l = components; l; l = l->next) { - Bonobo_ServerInfo *info; - GList *verb_names; - - info = l->data; - verb_names = get_bonobo_menu_verb_names (info); - items = g_list_concat (items, - get_menu_items_for_server (info, verb_names, selection)); - eel_g_list_free_deep (verb_names); - - } - - if (components != NULL) { - gnome_vfs_mime_component_list_free (components); - } - - return items; -} - -static void -fm_bonobo_provider_menu_provider_iface_init (NautilusMenuProviderIface *iface) -{ - iface->get_file_items = fm_bonobo_provider_get_file_items; -} - -static GtkWidget * -bonobo_page_error_message (const char *view_name, - const char *msg) -{ - GtkWidget *hbox; - GtkWidget *label; - GtkWidget *image; - - hbox = gtk_hbox_new (FALSE, GNOME_PAD); - image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_ERROR, - GTK_ICON_SIZE_DIALOG); - - msg = g_strdup_printf ("There was an error while trying to create the view named `%s': %s", view_name, msg); - label = gtk_label_new (msg); - - gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); - - gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); - gtk_widget_show_all (hbox); - - return hbox; -} - -static CORBA_sequence_CORBA_string * -get_uri_list (GList *file_list) -{ - CORBA_sequence_CORBA_string *uri_list; - GList *l; - int i; - - uri_list = CORBA_sequence_CORBA_string__alloc (); - uri_list->_maximum = g_list_length (file_list); - uri_list->_length = uri_list->_maximum; - uri_list->_buffer = CORBA_sequence_CORBA_string_allocbuf (uri_list->_length); - for (i = 0, l = file_list; l != NULL; i++, l = l->next) { - char *uri; - - uri = nautilus_file_get_uri (NAUTILUS_FILE (l->data)); - uri_list->_buffer[i] = CORBA_string_dup (uri); - g_free (uri); - } - - return uri_list; -} - -static void -bonobo_page_activate_callback (CORBA_Object obj, - const char *error_reason, - gpointer user_data) -{ - ActivationData *data; - GtkWidget *widget; - CORBA_Environment ev; - - data = (ActivationData *)user_data; - - CORBA_exception_init (&ev); - widget = NULL; - - if (obj != CORBA_OBJECT_NIL) { - Bonobo_Control control; - Bonobo_PropertyBag pb; - GList *keys; - - control = Bonobo_Unknown_queryInterface - (obj, "IDL:Bonobo/Control:1.0", &ev); - - pb = Bonobo_Control_getProperties (control, &ev); - - if (!BONOBO_EX (&ev)) { - gboolean new_property; - - keys = bonobo_pbclient_get_keys (pb, NULL); - new_property = FALSE; - if (g_list_find_custom (keys, "uris", (GCompareFunc)strcmp)) { - new_property = TRUE; - } - bonobo_pbclient_free_keys (keys); - - if (new_property) { - /* Set the 'uris' property. */ - CORBA_sequence_CORBA_string *uri_list; - BonoboArg *arg; - - uri_list = get_uri_list (data->files); - arg = bonobo_arg_new (TC_CORBA_sequence_CORBA_string); - arg->_value = uri_list; - bonobo_pbclient_set_value_async (pb, "uris", arg, &ev); - bonobo_arg_release (arg); - } else { - /* Set the 'URI' property. */ - BonoboArg *arg; - char *uri; - - if (data->files->next != NULL) { - g_warning ("Multifile property page does not support the 'uris' property"); - bonobo_object_release_unref (pb, NULL); - bonobo_object_release_unref (control, NULL); - return; - } - - uri = nautilus_file_info_get_uri (NAUTILUS_FILE_INFO (data->files->data)); - - arg = bonobo_arg_new (BONOBO_ARG_STRING); - BONOBO_ARG_SET_STRING (arg, uri); - bonobo_pbclient_set_value_async (pb, "URI", arg, &ev); - bonobo_arg_release (arg); - g_free (uri); - } - - bonobo_object_release_unref (pb, NULL); - - if (!BONOBO_EX (&ev)) { - widget = bonobo_widget_new_control_from_objref - (control, CORBA_OBJECT_NIL); - bonobo_object_release_unref (control, &ev); - } - } - } - - if (widget == NULL) { - widget = bonobo_page_error_message (data->view_name, - error_reason); - } - - gtk_container_add (GTK_CONTAINER (data->vbox), widget); - gtk_widget_show (widget); - - g_free (data->view_name); - g_free (data); -} - -static GList * -fm_bonobo_provider_get_pages (NautilusPropertyPageProvider *provider, - GList *files) -{ - GList *all_components, *l; - GList *components; - CORBA_Environment ev; - GList *pages; - - /* find all the property pages for this file */ - all_components = nautilus_view_query_get_property_components_for_files - (files); - - /* filter out property pages that don't support multiple files */ - if (files->next) { - components = NULL; - for (l = all_components; l != NULL; l = l->next) { - if (can_handle_multiple_files (l->data)) { - components = g_list_prepend (components, - l->data); - } - } - components = g_list_reverse (components); - g_list_free (all_components); - } else { - components = all_components; - } - - CORBA_exception_init (&ev); - - pages = NULL; - - l = components; - while (l != NULL) { - NautilusViewIdentifier *view_id; - Bonobo_ServerInfo *server; - ActivationData *data; - GtkWidget *vbox; - NautilusPropertyPage *page; - - server = l->data; - l = l->next; - - view_id = nautilus_view_identifier_new_from_property_page (server); - vbox = gtk_vbox_new (FALSE, 0); - gtk_container_set_border_width (GTK_CONTAINER (vbox), - GNOME_PAD); - gtk_widget_show (vbox); - - page = nautilus_property_page_new (view_id->iid, - gtk_label_new (view_id->name), - vbox); - - pages = g_list_prepend (pages, page); - - data = g_new (ActivationData, 1); - data->files = nautilus_file_info_list_copy (files); - data->vbox = vbox; - data->view_name = g_strdup (view_id->name); - - bonobo_activation_activate_from_id_async - (view_id->iid, - 0, bonobo_page_activate_callback, - data, &ev); - } - - return g_list_reverse (pages); -} - -static void -fm_bonobo_provider_property_page_provider_iface_init (NautilusPropertyPageProviderIface *iface) -{ - iface->get_pages = fm_bonobo_provider_get_pages; -} - -static void -fm_bonobo_provider_instance_init (FMBonoboProvider *provider) -{ -} - -static void -fm_bonobo_provider_class_init (FMBonoboProviderClass *class) -{ - parent_class = g_type_class_peek_parent (class); -} - -GType -fm_bonobo_provider_get_type (void) -{ - static GType provider_type = 0; - - if (!provider_type) { - static const GTypeInfo type_info = { - sizeof (FMBonoboProviderClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) fm_bonobo_provider_class_init, - NULL, - NULL, - sizeof (FMBonoboProvider), - 0, - (GInstanceInitFunc) fm_bonobo_provider_instance_init, - }; - - static const GInterfaceInfo menu_provider_iface_info = { - (GInterfaceInitFunc) fm_bonobo_provider_menu_provider_iface_init, - NULL, - NULL - }; - - static const GInterfaceInfo property_page_provider_iface_info = { - (GInterfaceInitFunc) fm_bonobo_provider_property_page_provider_iface_init, - NULL, - NULL - }; - - provider_type = g_type_register_static (G_TYPE_OBJECT, - "FMBonoboProvider", - &type_info, 0); - - g_type_add_interface_static (provider_type, - NAUTILUS_TYPE_MENU_PROVIDER, - &menu_provider_iface_info); - g_type_add_interface_static (provider_type, - NAUTILUS_TYPE_PROPERTY_PAGE_PROVIDER, - &property_page_provider_iface_info); - } - - return provider_type; -} - diff --git a/src/file-manager/fm-bonobo-provider.h b/src/file-manager/fm-bonobo-provider.h deleted file mode 100644 index c30098dac..000000000 --- a/src/file-manager/fm-bonobo-provider.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * fm-bonobo-provider.h - Bonobo API support - * - * Copyright (C) 2002 James Willcox - * 2003 Novell, Inc. - * - * This library 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 library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Authors: Dave Camp <dave@ximian.com> - * James Willcox <jwillcox@gnome.org> - * - */ - -#ifndef FM_BONOBO_PROVIDER_H -#define FM_BONOBO_PROVIDER_H - -#include <glib-object.h> - -G_BEGIN_DECLS - -#define FM_TYPE_BONOBO_PROVIDER (fm_bonobo_provider_get_type ()) -#define FM_BONOBO_PROVIDER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), FM_TYPE_BONOBO_PROVIDER, FMBonoboProvider)) -#define FM_IS_BONOBO_PROVIDER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), FM_TYPE_BONOBO_PROVIDER)) -typedef struct _FMBonoboProvider FMBonoboProvider; -typedef struct _FMBonoboProviderClass FMBonoboProviderClass; - -struct _FMBonoboProvider { - GObject parent_slot; -}; - -struct _FMBonoboProviderClass { - GObjectClass parent_slot; -}; - -GType fm_bonobo_provider_get_type (void); - -G_END_DECLS - -#endif diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c index 4922e6cd3..1d8963c54 100644 --- a/src/file-manager/fm-desktop-icon-view.c +++ b/src/file-manager/fm-desktop-icon-view.c @@ -53,6 +53,7 @@ #include <libnautilus-private/nautilus-file-operations.h> #include <libnautilus-private/nautilus-file-utilities.h> #include <libnautilus-private/nautilus-global-preferences.h> +#include <libnautilus-private/nautilus-view-factory.h> #include <libnautilus-private/nautilus-link.h> #include <libnautilus-private/nautilus-metadata.h> #include <libnautilus-private/nautilus-monitor.h> @@ -740,3 +741,43 @@ real_supports_zooming (FMDirectoryView *view) */ return FALSE; } + +static NautilusView * +fm_desktop_icon_view_create (NautilusWindowInfo *window) +{ + FMIconView *view; + + view = g_object_new (FM_TYPE_DESKTOP_ICON_VIEW, "window", window, NULL); + g_object_ref (view); + gtk_object_sink (GTK_OBJECT (view)); + return NAUTILUS_VIEW (view); +} + +static gboolean +fm_desktop_icon_view_supports_uri (const char *uri, + GnomeVFSFileType file_type, + const char *mime_type) +{ + if (g_str_has_prefix (uri, "x-nautilus-desktop:")) { + return TRUE; + } + + return FALSE; +} + +static NautilusViewInfo fm_desktop_icon_view = { + FM_DESKTOP_ICON_VIEW_ID, + N_("Desktop"), + N_("_Desktop"), + fm_desktop_icon_view_create, + fm_desktop_icon_view_supports_uri +}; + +void +fm_desktop_icon_view_register (void) +{ + fm_desktop_icon_view.label = _(fm_desktop_icon_view.label); + fm_desktop_icon_view.label_with_mnemonic = _(fm_desktop_icon_view.label_with_mnemonic); + + nautilus_view_factory_register (&fm_desktop_icon_view); +} diff --git a/src/file-manager/fm-desktop-icon-view.h b/src/file-manager/fm-desktop-icon-view.h index 60d8635a5..866278daa 100644 --- a/src/file-manager/fm-desktop-icon-view.h +++ b/src/file-manager/fm-desktop-icon-view.h @@ -33,6 +33,8 @@ #define FM_IS_DESKTOP_ICON_VIEW(obj) (GTK_CHECK_TYPE ((obj), FM_TYPE_DESKTOP_ICON_VIEW)) #define FM_IS_DESKTOP_ICON_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), FM_TYPE_DESKTOP_ICON_VIEW)) +#define FM_DESKTOP_ICON_VIEW_ID "OAFIID:Nautilus_File_Manager_Desktop_Icon_View" + typedef struct FMDesktopIconViewDetails FMDesktopIconViewDetails; typedef struct { FMIconView parent; @@ -45,5 +47,6 @@ typedef struct { /* GObject support */ GType fm_desktop_icon_view_get_type (void); +void fm_desktop_icon_view_register (void); #endif /* FM_DESKTOP_ICON_VIEW_H */ diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c index 7eb7418c2..0341c25e7 100644 --- a/src/file-manager/fm-directory-view.c +++ b/src/file-manager/fm-directory-view.c @@ -92,8 +92,7 @@ #include <libnautilus-private/nautilus-program-choosing.h> #include <libnautilus-private/nautilus-trash-directory.h> #include <libnautilus-private/nautilus-trash-monitor.h> -#include <libnautilus-private/nautilus-view-identifier.h> -#include <libnautilus/nautilus-bonobo-ui.h> +#include <libnautilus-private/nautilus-bonobo-ui.h> #include <unistd.h> @@ -204,6 +203,13 @@ enum { LAST_SIGNAL }; +enum +{ + PROP_0, + PROP_WINDOW +}; + + static guint signals[LAST_SIGNAL]; static GdkAtom copied_files_atom; @@ -220,9 +226,7 @@ static int templates_directory_uri_length; struct FMDirectoryViewDetails { - NautilusView *nautilus_view; - BonoboZoomable *zoomable; - + NautilusWindowInfo *window; NautilusDirectory *model; NautilusFile *directory_as_file; BonoboUIComponent *ui; @@ -296,8 +300,8 @@ typedef enum { typedef struct { FMDirectoryView *view; NautilusFile *file; - Nautilus_ViewFrame_OpenMode mode; - Nautilus_ViewFrame_OpenFlags flags; + NautilusWindowOpenMode mode; + NautilusWindowOpenFlags flags; NautilusFileCallback callback; gboolean mounted; gboolean mounting; @@ -334,34 +338,20 @@ static void trash_or_delete_files (FMDirectoryView const GList *files); static void fm_directory_view_activate_file (FMDirectoryView *view, NautilusFile *file, - Nautilus_ViewFrame_OpenMode mode, - Nautilus_ViewFrame_OpenFlags flags); + NautilusWindowOpenMode mode, + NautilusWindowOpenFlags flags); static void load_directory (FMDirectoryView *view, NautilusDirectory *directory); static void fm_directory_view_merge_menus (FMDirectoryView *view); static void fm_directory_view_init_show_hidden_files (FMDirectoryView *view); static char * file_name_from_uri (const char *uri); -static void stop_loading_callback (NautilusView *nautilus_view, - FMDirectoryView *directory_view); -static void load_location_callback (NautilusView *nautilus_view, - const char *location, - FMDirectoryView *directory_view); +static void fm_directory_view_load_location (NautilusView *nautilus_view, + const char *location); +static void fm_directory_view_stop_loading (NautilusView *nautilus_view); static void clipboard_changed_callback (NautilusClipboardMonitor *monitor, FMDirectoryView *view); -static void selection_changed_callback (NautilusView *nautilus_view, - GList *selection, - FMDirectoryView *directory_view); static void open_one_in_new_window (gpointer data, gpointer callback_data); -static void zoomable_set_zoom_level_callback (BonoboZoomable *zoomable, - float level, - FMDirectoryView *view); -static void zoomable_zoom_in_callback (BonoboZoomable *zoomable, - FMDirectoryView *directory_view); -static void zoomable_zoom_out_callback (BonoboZoomable *zoomable, - FMDirectoryView *directory_view); -static void zoomable_zoom_to_fit_callback (BonoboZoomable *zoomable, - FMDirectoryView *directory_view); static void schedule_update_menus (FMDirectoryView *view); static void schedule_update_menus_callback (gpointer callback_data); static void remove_update_menus_timeout_callback (FMDirectoryView *view); @@ -499,6 +489,15 @@ create_templates_parameters_free (CreateTemplateParameters *parameters) g_free (parameters); } +NautilusWindowInfo * +fm_directory_view_get_nautilus_window (FMDirectoryView *view) +{ + g_assert (view->details->window != NULL); + + return view->details->window; +} + + /* Returns the GtkWindow that this directory view occupies, or NULL * if at the moment this directory view is not in a GtkWindow or the @@ -595,7 +594,7 @@ open_callback (BonoboUIComponent *component, gpointer callback_data, const char selection = fm_directory_view_get_selection (view); fm_directory_view_activate_files (view, selection, - Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE, + NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE, 0); nautilus_file_list_free (selection); } @@ -610,8 +609,8 @@ open_close_parent_callback (BonoboUIComponent *component, gpointer callback_data selection = fm_directory_view_get_selection (view); fm_directory_view_activate_files (view, selection, - Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE, - Nautilus_ViewFrame_OPEN_FLAG_CLOSE_BEHIND); + NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE, + NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND); nautilus_file_list_free (selection); } @@ -687,8 +686,8 @@ fm_directory_view_chose_application_callback (GnomeVFSMimeApplication *applicati static void open_location (FMDirectoryView *directory_view, const char *new_uri, - Nautilus_ViewFrame_OpenMode mode, - Nautilus_ViewFrame_OpenFlags flags) + NautilusWindowOpenMode mode, + NautilusWindowOpenFlags flags) { NautilusFile *file; @@ -706,8 +705,8 @@ open_location (FMDirectoryView *directory_view, } nautilus_file_unref (file); - nautilus_view_open_location (directory_view->details->nautilus_view, - new_uri, mode, flags, NULL); + nautilus_window_info_open_location (directory_view->details->window, + new_uri, mode, flags, NULL); } static void @@ -990,7 +989,7 @@ pattern_select_response_cb (GtkWidget *dialog, int response, gpointer user_data) gtk_entry_get_text (GTK_ENTRY (entry))); if (selection) { - fm_directory_view_set_selection(view, selection); + fm_directory_view_set_selection (view, selection); nautilus_file_list_free (selection); fm_directory_view_reveal_selection(view); @@ -1070,7 +1069,7 @@ show_hidden_files_toggle_callback (BonoboUIComponent *component, gpointer callback_data) { FMDirectoryView *directory_view; - Nautilus_ShowHiddenFilesMode mode; + NautilusWindowShowHiddenFilesMode mode; g_assert (FM_IS_DIRECTORY_VIEW (callback_data)); directory_view = FM_DIRECTORY_VIEW (callback_data); @@ -1082,11 +1081,11 @@ show_hidden_files_toggle_callback (BonoboUIComponent *component, directory_view->details->show_hidden_files = strcmp (state, "1") == 0; if (directory_view->details->show_hidden_files) { - mode = Nautilus_SHOW_HIDDEN_FILES_ENABLE; + mode = NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_ENABLE; } else { - mode = Nautilus_SHOW_HIDDEN_FILES_DISABLE; + mode = NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_DISABLE; } - nautilus_view_set_show_hidden_files_mode (directory_view->details->nautilus_view, mode); + nautilus_window_info_set_hidden_files_mode (directory_view->details->window, mode); if (directory_view->details->model != NULL) { load_directory (directory_view, directory_view->details->model); } @@ -1216,7 +1215,9 @@ we_are_in_vfolder_desktop_dir (FMDirectoryView *view) } static void -bonobo_control_activate_callback (BonoboObject *control, gboolean state, gpointer callback_data) +parent_set_callback (GtkWidget *widget, + GtkWidget *previous_parent, + gpointer callback_data) { FMDirectoryView *view; @@ -1224,7 +1225,7 @@ bonobo_control_activate_callback (BonoboObject *control, gboolean state, gpointe view = FM_DIRECTORY_VIEW (callback_data); - if (state) { + if (widget->parent != NULL) { /* Add new menu items and perhaps whole menus */ fm_directory_view_merge_menus (view); @@ -1303,16 +1304,6 @@ sort_directories_first_changed_callback (gpointer callback_data) } } -static float fm_directory_view_preferred_zoom_levels[] = { - (float) NAUTILUS_ICON_SIZE_SMALLEST / NAUTILUS_ICON_SIZE_STANDARD, - (float) NAUTILUS_ICON_SIZE_SMALLER / NAUTILUS_ICON_SIZE_STANDARD, - (float) NAUTILUS_ICON_SIZE_SMALL / NAUTILUS_ICON_SIZE_STANDARD, - (float) NAUTILUS_ICON_SIZE_STANDARD / NAUTILUS_ICON_SIZE_STANDARD, - (float) NAUTILUS_ICON_SIZE_LARGE / NAUTILUS_ICON_SIZE_STANDARD, - (float) NAUTILUS_ICON_SIZE_LARGER / NAUTILUS_ICON_SIZE_STANDARD, - (float) NAUTILUS_ICON_SIZE_LARGEST / NAUTILUS_ICON_SIZE_STANDARD -}; - static void set_up_scripts_directory_global (void) { @@ -1497,7 +1488,246 @@ remove_directory_from_templates_directory_list (FMDirectoryView *view, G_CALLBACK (templates_added_or_changed_callback)); } +static void +fm_directory_view_set_parent_window (FMDirectoryView *directory_view, + NautilusWindowInfo *window) +{ + directory_view->details->window = window; +} + +static GtkWidget * +fm_directory_view_get_widget (NautilusView *view) +{ + return GTK_WIDGET (view); +} + + +static float +fm_directory_view_get_zoom_level (NautilusView *view) +{ + /* BONOBOTODO: implement this*/ + return 1.0; +} +static float +fm_directory_view_get_min_zoom_level (NautilusView *view) +{ + /* BONOBOTODO: implement this*/ + return 0.0; +} + +static float +fm_directory_view_get_max_zoom_level (NautilusView *view) +{ + /* BONOBOTODO: implement this*/ + return 4.0; +} + +static gboolean +fm_directory_view_get_has_max_zoom_level (NautilusView *view) +{ + /* BONOBOTODO: implement this*/ + return TRUE; +} + +static gboolean +fm_directory_view_get_has_min_zoom_level (NautilusView *view) +{ + /* BONOBOTODO: implement this*/ + return TRUE; +} + +static gboolean +fm_directory_view_get_is_continuous (NautilusView *view) +{ + /* BONOBOTODO: implement this*/ + return FALSE; +} + +static NautilusZoomLevel +nautilus_zoom_level_from_float(float zoom_level) +{ + int icon_size = floor(zoom_level * NAUTILUS_ICON_SIZE_STANDARD + 0.5); + + if (icon_size <= NAUTILUS_ICON_SIZE_SMALLEST) { + return NAUTILUS_ZOOM_LEVEL_SMALLEST; + } else if (icon_size <= NAUTILUS_ICON_SIZE_SMALLER) { + return NAUTILUS_ZOOM_LEVEL_SMALLER; + } else if (icon_size <= NAUTILUS_ICON_SIZE_SMALL) { + return NAUTILUS_ZOOM_LEVEL_SMALL; + } else if (icon_size <= NAUTILUS_ICON_SIZE_STANDARD) { + return NAUTILUS_ZOOM_LEVEL_STANDARD; + } else if (icon_size <= NAUTILUS_ICON_SIZE_LARGE) { + return NAUTILUS_ZOOM_LEVEL_LARGE; + } else if (icon_size <= NAUTILUS_ICON_SIZE_LARGER) { + return NAUTILUS_ZOOM_LEVEL_LARGER; + } else { + return NAUTILUS_ZOOM_LEVEL_LARGEST; + } +} + +static void +fm_directory_view_set_zoom_level_float (NautilusView *view, float level) +{ + fm_directory_view_set_zoom_level (FM_DIRECTORY_VIEW (view), + nautilus_zoom_level_from_float (level)); +} + +static float fm_directory_view_preferred_zoom_levels[] = { + (float) NAUTILUS_ICON_SIZE_SMALLEST / NAUTILUS_ICON_SIZE_STANDARD, + (float) NAUTILUS_ICON_SIZE_SMALLER / NAUTILUS_ICON_SIZE_STANDARD, + (float) NAUTILUS_ICON_SIZE_SMALL / NAUTILUS_ICON_SIZE_STANDARD, + (float) NAUTILUS_ICON_SIZE_STANDARD / NAUTILUS_ICON_SIZE_STANDARD, + (float) NAUTILUS_ICON_SIZE_LARGE / NAUTILUS_ICON_SIZE_STANDARD, + (float) NAUTILUS_ICON_SIZE_LARGER / NAUTILUS_ICON_SIZE_STANDARD, + (float) NAUTILUS_ICON_SIZE_LARGEST / NAUTILUS_ICON_SIZE_STANDARD +}; + +static GList * +fm_directory_view_get_preferred_zoom_levels (NautilusView *view) +{ + int i; + float *p; + GList *l; + + l = NULL; + for (i = 0; i < G_N_ELEMENTS (fm_directory_view_preferred_zoom_levels); i++) { + p = g_new (float, 1); + *p = fm_directory_view_preferred_zoom_levels[i]; + l = g_list_prepend (l, p); + } + return g_list_reverse (l); +} + +static void +fm_directory_view_zoom_in (NautilusView *view) +{ + fm_directory_view_bump_zoom_level (FM_DIRECTORY_VIEW (view), 1); +} + +static void +fm_directory_view_zoom_out (NautilusView *view) +{ + fm_directory_view_bump_zoom_level (FM_DIRECTORY_VIEW (view), -1); +} + + +static void +fm_directory_view_zoom_to_fit (NautilusView *view) +{ + /* FIXME bugzilla.gnome.org 42388: + * Need to really implement "zoom to fit" + */ + fm_directory_view_restore_default_zoom_level (FM_DIRECTORY_VIEW (view)); +} + +static int +fm_directory_view_get_selection_count (NautilusView *view) +{ + /* FIXME: This could be faster if we special cased it in subclasses */ + GList *files; + int len; + + files = fm_directory_view_get_selection (FM_DIRECTORY_VIEW (view)); + len = g_list_length (files); + nautilus_file_list_free (files); + + return len; +} + +static GList * +fm_directory_view_get_selection_uris (NautilusView *view) +{ + GList *files; + GList *uris; + char *uri; + GList *l; + + files = fm_directory_view_get_selection (FM_DIRECTORY_VIEW (view)); + uris = NULL; + for (l = files; l != NULL; l = l->next) { + uri = nautilus_file_get_uri (NAUTILUS_FILE (l->data)); + uris = g_list_prepend (uris, uri); + } + nautilus_file_list_free (files); + + return g_list_reverse (uris); +} + +static GList * +file_list_from_uri_list (GList *uri_list) +{ + GList *file_list, *node; + + file_list = NULL; + for (node = uri_list; node != NULL; node = node->next) { + file_list = g_list_prepend + (file_list, + nautilus_file_get (node->data)); + } + return g_list_reverse (file_list); +} + +static void +fm_directory_view_set_selection_uris (NautilusView *nautilus_view, + GList *selection_uris) +{ + GList *selection; + FMDirectoryView *view; + + view = FM_DIRECTORY_VIEW (nautilus_view); + + if (!view->details->loading) { + /* If we aren't still loading, set the selection right now, + * and reveal the new selection. + */ + selection = file_list_from_uri_list (selection_uris); + view->details->selection_change_is_due_to_shell = TRUE; + fm_directory_view_set_selection (view, selection); + view->details->selection_change_is_due_to_shell = FALSE; + fm_directory_view_reveal_selection (view); + nautilus_file_list_free (selection); + } else { + /* If we are still loading, set the list of pending URIs instead. + * done_loading() will eventually select the pending URIs and reveal them. + */ + eel_g_list_free_deep (view->details->pending_uris_selected); + view->details->pending_uris_selected = NULL; + + view->details->pending_uris_selected = + g_list_concat (view->details->pending_uris_selected, + eel_g_str_list_copy (selection_uris)); + } +} + +void +fm_directory_view_init_view_iface (NautilusViewIface *iface) +{ + iface->get_widget = fm_directory_view_get_widget; + iface->load_location = fm_directory_view_load_location; + iface->stop_loading = fm_directory_view_stop_loading; + + iface->get_selection_count = fm_directory_view_get_selection_count; + iface->get_selection = fm_directory_view_get_selection_uris; + iface->set_selection = fm_directory_view_set_selection_uris; + + + /* BONOBOTODO: fix up the zoom crap */ + iface->get_is_zoomable = (gpointer)fm_directory_view_supports_zooming; + iface->get_zoom_level = fm_directory_view_get_zoom_level; + iface->set_zoom_level = fm_directory_view_set_zoom_level_float; + iface->get_min_zoom_level = fm_directory_view_get_min_zoom_level; + iface->get_max_zoom_level = fm_directory_view_get_max_zoom_level; + iface->get_has_min_zoom_level = fm_directory_view_get_has_min_zoom_level; + iface->get_has_max_zoom_level = fm_directory_view_get_has_max_zoom_level; + iface->get_is_continuous = fm_directory_view_get_is_continuous; + iface->get_can_zoom_in = (gpointer)fm_directory_view_can_zoom_in; + iface->get_can_zoom_out = (gpointer)fm_directory_view_can_zoom_out; + iface->get_preferred_zoom_levels = fm_directory_view_get_preferred_zoom_levels; + iface->zoom_in = fm_directory_view_zoom_in; + iface->zoom_out = fm_directory_view_zoom_out; + iface->zoom_to_fit = fm_directory_view_zoom_to_fit; +} static void fm_directory_view_init (FMDirectoryView *view) @@ -1524,8 +1754,6 @@ fm_directory_view_init (FMDirectoryView *view) gtk_scrolled_window_set_hadjustment (GTK_SCROLLED_WINDOW (view), NULL); gtk_scrolled_window_set_vadjustment (GTK_SCROLLED_WINDOW (view), NULL); - view->details->nautilus_view = nautilus_view_new (GTK_WIDGET (view)); - set_up_scripts_directory_global (); scripts_directory = nautilus_directory_get (scripts_directory_uri); add_directory_to_scripts_directory_list (view, scripts_directory); @@ -1536,38 +1764,18 @@ fm_directory_view_init (FMDirectoryView *view) add_directory_to_templates_directory_list (view, templates_directory); nautilus_directory_unref (templates_directory); - view->details->zoomable = bonobo_zoomable_new (); +#ifdef BONOBO_DONE bonobo_zoomable_set_parameters_full (view->details->zoomable, 0.0, .25, 4.0, TRUE, TRUE, FALSE, fm_directory_view_preferred_zoom_levels, NULL, G_N_ELEMENTS (fm_directory_view_preferred_zoom_levels)); - bonobo_object_add_interface (BONOBO_OBJECT (view->details->nautilus_view), - BONOBO_OBJECT (view->details->zoomable)); +#endif view->details->sort_directories_first = eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SORT_DIRECTORIES_FIRST); - g_signal_connect_object (view->details->nautilus_view, "stop_loading", - G_CALLBACK (stop_loading_callback), view, 0); - g_signal_connect_object (view->details->nautilus_view, "load_location", - G_CALLBACK (load_location_callback), view, 0); - - nautilus_view_set_listener_mask - (NAUTILUS_VIEW (view->details->nautilus_view), - NAUTILUS_VIEW_LISTEN_SELECTION); - - g_signal_connect_object (view->details->nautilus_view, "selection_changed", - G_CALLBACK (selection_changed_callback), view, 0); - g_signal_connect_object (fm_directory_view_get_bonobo_control (view), "activate", - G_CALLBACK (bonobo_control_activate_callback), view, 0); - g_signal_connect_object (view->details->zoomable, "zoom_in", - G_CALLBACK (zoomable_zoom_in_callback), view, 0); - g_signal_connect_object (view->details->zoomable, "zoom_out", - G_CALLBACK (zoomable_zoom_out_callback), view, 0); - g_signal_connect_object (view->details->zoomable, "set_zoom_level", - G_CALLBACK (zoomable_set_zoom_level_callback), view, 0); - g_signal_connect_object (view->details->zoomable, "zoom_to_fit", - G_CALLBACK (zoomable_zoom_to_fit_callback), view, 0); + g_signal_connect_object (view, "parent_set", + G_CALLBACK (parent_set_callback), view, 0); g_signal_connect_object (nautilus_trash_monitor_get (), "trash_state_changed", G_CALLBACK (fm_directory_view_trash_state_changed_callback), view, 0); @@ -1610,13 +1818,8 @@ fm_directory_view_destroy (GtkObject *object) disconnect_model_handlers (view); - /* Since we are owned by the NautilusView, if we're going it's - * gone. It would be even better to NULL this out when the - * NautilusView goes away, but this is good enough for our - * purposes. - */ - view->details->zoomable = NULL; - view->details->nautilus_view = NULL; + /* We don't own the window, so no unref */ + view->details->window = NULL; monitor_file_for_open_with (view, NULL); @@ -1861,95 +2064,37 @@ fm_directory_view_display_selection_info (FMDirectoryView *view) g_free (folder_item_count_str); g_free (non_folder_str); - nautilus_view_report_status (view->details->nautilus_view, - status_string); + nautilus_window_info_set_status (view->details->window, + status_string); g_free (status_string); } void fm_directory_view_send_selection_change (FMDirectoryView *view) { - GList *selection, *uris, *p; - - /* Collect a list of URIs. */ - selection = fm_directory_view_get_selection (view); - uris = NULL; - for (p = selection; p != NULL; p = p->next) { - uris = g_list_prepend (uris, nautilus_file_get_uri (p->data)); - } - nautilus_file_list_free (selection); - - /* Send the selection change. */ - nautilus_view_report_selection_change (view->details->nautilus_view, - uris); - - /* Free the URIs. */ - eel_g_list_free_deep (uris); + nautilus_window_info_report_selection_changed (view->details->window); view->details->send_selection_change_to_shell = FALSE; } static void -load_location_callback (NautilusView *nautilus_view, - const char *location, - FMDirectoryView *directory_view) +fm_directory_view_load_location (NautilusView *nautilus_view, + const char *location) { NautilusDirectory *directory; + FMDirectoryView *directory_view; + + directory_view = FM_DIRECTORY_VIEW (nautilus_view); directory = nautilus_directory_get (location); load_directory (directory_view, directory); nautilus_directory_unref (directory); } -static GList * -file_list_from_uri_list (GList *uri_list) -{ - GList *file_list, *node; - - file_list = NULL; - for (node = uri_list; node != NULL; node = node->next) { - file_list = g_list_prepend - (file_list, - nautilus_file_get (node->data)); - } - return g_list_reverse (file_list); -} - static void -selection_changed_callback (NautilusView *nautilus_view, - GList *selection_uris, - FMDirectoryView *view) +fm_directory_view_stop_loading (NautilusView *nautilus_view) { - GList *selection; - - if (!view->details->loading) { - /* If we aren't still loading, set the selection right now, - * and reveal the new selection. - */ - selection = file_list_from_uri_list (selection_uris); - view->details->selection_change_is_due_to_shell = TRUE; - fm_directory_view_set_selection (view, selection); - view->details->selection_change_is_due_to_shell = FALSE; - fm_directory_view_reveal_selection (view); - nautilus_file_list_free (selection); - } else { - /* If we are still loading, set the list of pending URIs instead. - * done_loading() will eventually select the pending URIs and reveal them. - */ - eel_g_list_free_deep (view->details->pending_uris_selected); - view->details->pending_uris_selected = NULL; - - view->details->pending_uris_selected = - g_list_concat (view->details->pending_uris_selected, - eel_g_str_list_copy (selection_uris)); - } -} - -static void -stop_loading_callback (NautilusView *nautilus_view, - FMDirectoryView *view) -{ - fm_directory_view_stop (view); + fm_directory_view_stop (FM_DIRECTORY_VIEW (nautilus_view)); } static void @@ -2009,10 +2154,11 @@ done_loading (FMDirectoryView *view) } /* This can be called during destruction, in which case there - * is no NautilusView any more. + * is no NautilusWindowInfo any more. + * BONOBOTODO: is this comment true now? */ - if (view->details->nautilus_view != NULL) { - nautilus_view_report_load_complete (view->details->nautilus_view); + if (view->details->window != NULL) { + nautilus_window_info_report_load_complete (view->details->window, NAUTILUS_VIEW (view)); schedule_update_menus (view); schedule_update_status (view); check_for_directory_hard_limit (view); @@ -2050,55 +2196,6 @@ reset_background_callback (BonoboUIComponent *component, gpointer callback_data, (FM_DIRECTORY_VIEW (callback_data))); } -static void -zoomable_zoom_in_callback (BonoboZoomable *zoomable, FMDirectoryView *directory_view) -{ - fm_directory_view_bump_zoom_level (directory_view, 1); -} - -static void -zoomable_zoom_out_callback (BonoboZoomable *zoomable, FMDirectoryView *directory_view) -{ - fm_directory_view_bump_zoom_level (directory_view, -1); -} - -static NautilusZoomLevel -nautilus_zoom_level_from_float(float zoom_level) -{ - int icon_size = floor(zoom_level * NAUTILUS_ICON_SIZE_STANDARD + 0.5); - - if (icon_size <= NAUTILUS_ICON_SIZE_SMALLEST) { - return NAUTILUS_ZOOM_LEVEL_SMALLEST; - } else if (icon_size <= NAUTILUS_ICON_SIZE_SMALLER) { - return NAUTILUS_ZOOM_LEVEL_SMALLER; - } else if (icon_size <= NAUTILUS_ICON_SIZE_SMALL) { - return NAUTILUS_ZOOM_LEVEL_SMALL; - } else if (icon_size <= NAUTILUS_ICON_SIZE_STANDARD) { - return NAUTILUS_ZOOM_LEVEL_STANDARD; - } else if (icon_size <= NAUTILUS_ICON_SIZE_LARGE) { - return NAUTILUS_ZOOM_LEVEL_LARGE; - } else if (icon_size <= NAUTILUS_ICON_SIZE_LARGER) { - return NAUTILUS_ZOOM_LEVEL_LARGER; - } else { - return NAUTILUS_ZOOM_LEVEL_LARGEST; - } -} - -static void -zoomable_set_zoom_level_callback (BonoboZoomable *zoomable, float level, FMDirectoryView *view) -{ - fm_directory_view_zoom_to_level (view, nautilus_zoom_level_from_float (level)); -} - -static void -zoomable_zoom_to_fit_callback (BonoboZoomable *zoomable, FMDirectoryView *view) -{ - /* FIXME bugzilla.gnome.org 42388: - * Need to really implement "zoom to fit" - */ - fm_directory_view_restore_default_zoom_level (view); -} - typedef struct { GHashTable *debuting_uris; GList *added_files; @@ -2818,8 +2915,10 @@ fm_directory_view_set_zoom_level (FMDirectoryView *view, int zoom_level) new_zoom_level = (float) nautilus_get_icon_size_for_zoom_level (zoom_level) / NAUTILUS_ICON_SIZE_STANDARD; +#ifdef BONOBO_DONE bonobo_zoomable_report_zoom_level_changed ( view->details->zoomable, new_zoom_level, NULL); +#endif } /** @@ -2967,48 +3066,11 @@ fm_directory_view_get_item_count (FMDirectoryView *view) Bonobo_UIContainer fm_directory_view_get_bonobo_ui_container (FMDirectoryView *view) { + Bonobo_UIContainer ui_container; g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), NULL); - - return bonobo_control_get_remote_ui_container - (fm_directory_view_get_bonobo_control (view), NULL); -} - -/** - * fm_directory_view_get_bonobo_control: - * - * Get the BonoboControl for this FMDirectoryView. - * This is normally called only by subclasses in order to - * help editables interact with the clipboard ui component - * @view: FMDirectoryView of interest. - * - * Return value: BonoboUIContainer for this view. - * - **/ -BonoboControl * -fm_directory_view_get_bonobo_control (FMDirectoryView *view) -{ - NautilusView *nautilus_view; - - nautilus_view = fm_directory_view_get_nautilus_view (view); - return nautilus_view_get_bonobo_control (nautilus_view); -} - -/** - * fm_directory_view_get_nautilus_view: - * - * Get the NautilusView for this FMDirectoryView. - * This is normally called only by the embedding framework. - * @view: FMDirectoryView of interest. - * - * Return value: NautilusView for this view. - * - **/ -NautilusView * -fm_directory_view_get_nautilus_view (FMDirectoryView *view) -{ - g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), NULL); - return view->details->nautilus_view; + ui_container = nautilus_window_info_get_ui_container (view->details->window); + return bonobo_object_dup_ref (ui_container, NULL); } /** @@ -3630,7 +3692,7 @@ open_one_in_new_window (gpointer data, gpointer callback_data) fm_directory_view_activate_file (FM_DIRECTORY_VIEW (callback_data), NAUTILUS_FILE (data), - Nautilus_ViewFrame_OPEN_IN_NAVIGATION, + NAUTILUS_WINDOW_OPEN_IN_NAVIGATION, 0); } @@ -4977,7 +5039,7 @@ open_scripts_folder_callback (BonoboUIComponent *component, view = FM_DIRECTORY_VIEW (callback_data); - open_location (view, scripts_directory_uri, Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE, 0); + open_location (view, scripts_directory_uri, NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE, 0); eel_show_info_dialog_with_details (_("All executable files in this folder will appear in the " @@ -5192,8 +5254,8 @@ copy_or_cut_files (FMDirectoryView *view, nautilus_file_list_free (clipboard_contents); - nautilus_view_report_status (view->details->nautilus_view, - status_string); + nautilus_window_info_set_status (view->details->window, + status_string); g_free (status_string); } @@ -5263,8 +5325,8 @@ paste_clipboard_data (FMDirectoryView *view, } if (item_uris == NULL|| destination_uri == NULL) { - nautilus_view_report_status (view->details->nautilus_view, - _("There is nothing on the clipboard to paste.")); + nautilus_window_info_set_status (view->details->window, + _("There is nothing on the clipboard to paste.")); } else { fm_directory_view_move_copy_items (item_uris, NULL, destination_uri, cut ? GDK_ACTION_MOVE : GDK_ACTION_COPY, @@ -5615,7 +5677,7 @@ connect_to_server_link_callback (BonoboUIComponent *component, static void fm_directory_view_init_show_hidden_files (FMDirectoryView *view) { - Nautilus_ShowHiddenFilesMode mode; + NautilusWindowShowHiddenFilesMode mode; gboolean show_hidden_changed; gboolean show_hidden_default_setting; @@ -5624,9 +5686,9 @@ fm_directory_view_init_show_hidden_files (FMDirectoryView *view) } show_hidden_changed = FALSE; - mode = nautilus_view_get_show_hidden_files_mode (view->details->nautilus_view); + mode = nautilus_window_info_get_hidden_files_mode (view->details->window); - if (mode == Nautilus_SHOW_HIDDEN_FILES_DEFAULT) { + if (mode == NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_DEFAULT) { show_hidden_default_setting = eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES); if (show_hidden_default_setting != view->details->show_hidden_files) { view->details->show_hidden_files = show_hidden_default_setting; @@ -5634,7 +5696,7 @@ fm_directory_view_init_show_hidden_files (FMDirectoryView *view) show_hidden_changed = TRUE; } } else { - if (mode == Nautilus_SHOW_HIDDEN_FILES_ENABLE) { + if (mode == NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_ENABLE) { show_hidden_changed = !view->details->show_hidden_files; view->details->show_hidden_files = TRUE; view->details->show_backup_files = TRUE; @@ -5689,7 +5751,8 @@ real_merge_menus (FMDirectoryView *view) BONOBO_UI_VERB_END }; - view->details->ui = nautilus_view_set_up_ui (view->details->nautilus_view, + view->details->ui = nautilus_view_set_up_ui (NAUTILUS_VIEW (view), + nautilus_window_info_get_ui_container (view->details->window), DATADIR, "nautilus-directory-view-ui.xml", "nautilus"); @@ -5773,7 +5836,7 @@ showing_trash_directory (FMDirectoryView *view) static gboolean should_show_empty_trash (FMDirectoryView *view) { - return (showing_trash_directory (view) || nautilus_view_get_window_type (view->details->nautilus_view) == Nautilus_WINDOW_NAVIGATION); + return (showing_trash_directory (view) || nautilus_window_info_get_window_type (view->details->window) == NAUTILUS_WINDOW_NAVIGATION); } static gboolean @@ -6064,7 +6127,7 @@ real_update_menus (FMDirectoryView *view) !can_open); g_free (label_with_underscore); - if (nautilus_view_get_window_type (view->details->nautilus_view) == Nautilus_WINDOW_NAVIGATION) { + if (nautilus_window_info_get_window_type (view->details->window) == NAUTILUS_WINDOW_NAVIGATION) { show_open_alternate = TRUE; label_with_underscore = g_strdup_printf (ngettext("Open in New Window", "Open in %d New Windows", @@ -6297,7 +6360,7 @@ schedule_update_menus (FMDirectoryView *view) g_assert (FM_IS_DIRECTORY_VIEW (view)); /* Make sure we haven't already destroyed it */ - g_assert (view->details->nautilus_view != NULL); + /*g_assert (view->details->window != NULL);*/ view->details->menu_states_untrustworthy = TRUE; @@ -6334,7 +6397,7 @@ schedule_update_status (FMDirectoryView *view) g_assert (FM_IS_DIRECTORY_VIEW (view)); /* Make sure we haven't already destroyed it */ - g_assert (view->details->nautilus_view != NULL); + g_assert (view->details->window != NULL); if (view->details->loading) { /* Don't update status bar while loading the dir */ @@ -6573,9 +6636,9 @@ activate_callback (NautilusFile *file, gpointer callback_data) nautilus_launch_show_file (file, fm_directory_view_get_containing_window (view)); - if ((parameters->flags & Nautilus_ViewFrame_OPEN_FLAG_CLOSE_BEHIND) != 0) { - if (nautilus_view_get_window_type (view->details->nautilus_view) == Nautilus_WINDOW_SPATIAL) { - nautilus_view_close_window (view->details->nautilus_view); + if ((parameters->flags & NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND) != 0) { + if (nautilus_window_info_get_window_type (view->details->window) == NAUTILUS_WINDOW_SPATIAL) { + nautilus_window_info_close (view->details->window); } } @@ -6723,8 +6786,8 @@ cancel_activate_callback (gpointer callback_data) static void fm_directory_view_activate_file (FMDirectoryView *view, NautilusFile *file, - Nautilus_ViewFrame_OpenMode mode, - Nautilus_ViewFrame_OpenFlags flags) + NautilusWindowOpenMode mode, + NautilusWindowOpenFlags flags) { ActivateParameters *parameters; NautilusFileAttributes attributes; @@ -6788,8 +6851,8 @@ fm_directory_view_activate_file (FMDirectoryView *view, void fm_directory_view_activate_files (FMDirectoryView *view, GList *files, - Nautilus_ViewFrame_OpenMode mode, - Nautilus_ViewFrame_OpenFlags flags) + NautilusWindowOpenMode mode, + NautilusWindowOpenFlags flags) { GList *node; int file_count; @@ -6806,10 +6869,10 @@ fm_directory_view_activate_files (FMDirectoryView *view, file_count = g_list_length (files); use_new_window = file_count > 1; - if (use_new_window && mode == Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE) { + if (use_new_window && mode == NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE) { #if !NEW_UI_COMPLETE /* Match the current window type */ - mode = Nautilus_ViewFrame_OPEN_IN_SPATIAL; + mode = NAUTILUS_WINDOW_OPEN_IN_SPATIAL; #endif } @@ -6917,7 +6980,8 @@ finish_loading (FMDirectoryView *view) { NautilusFileAttributes attributes; - nautilus_view_report_load_underway (view->details->nautilus_view); + nautilus_window_info_report_load_underway (view->details->window, + NAUTILUS_VIEW (view)); /* Tell interested parties that we've begun loading this directory now. * Subclasses use this to know that the new metadata is now available. @@ -7117,17 +7181,17 @@ disconnect_model_handlers (FMDirectoryView *view) void fm_directory_view_reset_to_defaults (FMDirectoryView *view) { - Nautilus_ShowHiddenFilesMode mode; + NautilusWindowShowHiddenFilesMode mode; g_return_if_fail (FM_IS_DIRECTORY_VIEW (view)); EEL_CALL_METHOD (FM_DIRECTORY_VIEW_CLASS, view, reset_to_defaults, (view)); - mode = nautilus_view_get_show_hidden_files_mode (view->details->nautilus_view); - if (mode != Nautilus_SHOW_HIDDEN_FILES_DEFAULT) { - nautilus_view_set_show_hidden_files_mode (view->details->nautilus_view, - Nautilus_SHOW_HIDDEN_FILES_DEFAULT); + mode = nautilus_window_info_get_hidden_files_mode (view->details->window); + if (mode != NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_DEFAULT) { + nautilus_window_info_set_hidden_files_mode (view->details->window, + NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_DEFAULT); fm_directory_view_init_show_hidden_files (view); } } @@ -7347,10 +7411,6 @@ fm_directory_view_supports_zooming (FMDirectoryView *view) { g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE); - if (!view->details->zoomable) { - return FALSE; - } - return EEL_CALL_METHOD_WITH_RETURN_VALUE (FM_DIRECTORY_VIEW_CLASS, view, supports_zooming, (view)); @@ -7393,15 +7453,15 @@ filtering_changed_callback (gpointer callback_data) { FMDirectoryView *directory_view; gboolean new_show_hidden; - Nautilus_ShowHiddenFilesMode mode; + NautilusWindowShowHiddenFilesMode mode; directory_view = FM_DIRECTORY_VIEW (callback_data); new_show_hidden = eel_preferences_get_boolean (NAUTILUS_PREFERENCES_SHOW_HIDDEN_FILES); - mode = nautilus_view_get_show_hidden_files_mode (directory_view->details->nautilus_view); + mode = nautilus_window_info_get_hidden_files_mode (directory_view->details->window); /* only apply global show hidden files pref if local setting has not been set for this window */ if (new_show_hidden != directory_view->details->show_hidden_files - && mode == Nautilus_SHOW_HIDDEN_FILES_DEFAULT) { + && mode == NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_DEFAULT) { directory_view->details->show_hidden_files = new_show_hidden; directory_view->details->show_backup_files = new_show_hidden; nautilus_bonobo_set_toggle_state (directory_view->details->ui, @@ -7620,6 +7680,29 @@ real_get_selected_icon_locations (FMDirectoryView *view) } static void +fm_directory_view_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + FMDirectoryView *directory_view; + + directory_view = FM_DIRECTORY_VIEW (object); + + switch (prop_id) { + case PROP_WINDOW: + g_assert (directory_view->details->window == NULL); + /* BONOBOTODO: does this ref? check out lifecycle here */ + fm_directory_view_set_parent_window (directory_view, NAUTILUS_WINDOW_INFO (g_value_get_object (value))); + + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void fm_directory_view_class_init (FMDirectoryViewClass *klass) { GtkWidgetClass *widget_class; @@ -7629,6 +7712,8 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass) scrolled_window_class = GTK_SCROLLED_WINDOW_CLASS (klass); G_OBJECT_CLASS (klass)->finalize = fm_directory_view_finalize; + G_OBJECT_CLASS (klass)->set_property = fm_directory_view_set_property; + GTK_OBJECT_CLASS (klass)->destroy = fm_directory_view_destroy; /* Get rid of the strange 3-pixel gap that GtkScrolledWindow @@ -7752,4 +7837,14 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass) copied_files_atom = gdk_atom_intern ("x-special/gnome-copied-files", FALSE); utf8_string_atom = gdk_atom_intern ("UTF8_STRING", FALSE); + + g_object_class_install_property (G_OBJECT_CLASS (klass), + PROP_WINDOW, + g_param_spec_object ("window", + "Window", + "The parent NautilusWindowInfo reference", + NAUTILUS_TYPE_WINDOW_INFO, + G_PARAM_WRITABLE | + G_PARAM_CONSTRUCT_ONLY)); + } diff --git a/src/file-manager/fm-directory-view.h b/src/file-manager/fm-directory-view.h index 6f138e9bb..cb2023152 100644 --- a/src/file-manager/fm-directory-view.h +++ b/src/file-manager/fm-directory-view.h @@ -38,7 +38,9 @@ #include <libnautilus-private/nautilus-icon-container.h> #include <libnautilus-private/nautilus-link.h> #include <eel/eel-string-list.h> -#include <libnautilus/nautilus-view.h> +#include <libnautilus-private/nautilus-view.h> +#include <libnautilus-private/nautilus-window-info.h> +#include <bonobo/bonobo-ui-component.h> typedef struct FMDirectoryView FMDirectoryView; typedef struct FMDirectoryViewClass FMDirectoryViewClass; @@ -289,10 +291,8 @@ struct FMDirectoryViewClass { /* GObject support */ GType fm_directory_view_get_type (void); -/* Component embedding support */ -NautilusView * fm_directory_view_get_nautilus_view (FMDirectoryView *view); - /* Functions callable from the user interface and elsewhere. */ +NautilusWindowInfo *fm_directory_view_get_nautilus_window (FMDirectoryView *view); char * fm_directory_view_get_uri (FMDirectoryView *view); char * fm_directory_view_get_backing_uri (FMDirectoryView *view); gboolean fm_directory_view_can_accept_item (NautilusFile *target_item, @@ -347,8 +347,8 @@ void fm_directory_view_end_loading (FMDirect */ void fm_directory_view_activate_files (FMDirectoryView *view, GList *files, - Nautilus_ViewFrame_OpenMode mode, - Nautilus_ViewFrame_OpenFlags flags); + NautilusWindowOpenMode mode, + NautilusWindowOpenFlags flags); void fm_directory_view_start_batching_selection_changes (FMDirectoryView *view); void fm_directory_view_stop_batching_selection_changes (FMDirectoryView *view); gboolean fm_directory_view_confirm_multiple_windows (FMDirectoryView *view, @@ -357,7 +357,6 @@ void fm_directory_view_queue_file_change (FMDirect NautilusFile *file); void fm_directory_view_notify_selection_changed (FMDirectoryView *view); Bonobo_UIContainer fm_directory_view_get_bonobo_ui_container (FMDirectoryView *view); -BonoboControl * fm_directory_view_get_bonobo_control (FMDirectoryView *view); EelStringList * fm_directory_view_get_emblem_names_to_exclude (FMDirectoryView *view); NautilusDirectory *fm_directory_view_get_model (FMDirectoryView *view); GtkWindow *fm_directory_view_get_containing_window (FMDirectoryView *view); @@ -376,5 +375,6 @@ void fm_directory_view_new_folder (FMDirect void fm_directory_view_new_file (FMDirectoryView *view, NautilusFile *source); void fm_directory_view_ignore_hidden_file_preferences (FMDirectoryView *view); +void fm_directory_view_init_view_iface (NautilusViewIface *iface); #endif /* FM_DIRECTORY_VIEW_H */ diff --git a/src/file-manager/fm-icon-view.c b/src/file-manager/fm-icon-view.c index 96a8bfa4b..4d2a6e2a4 100644 --- a/src/file-manager/fm-icon-view.c +++ b/src/file-manager/fm-icon-view.c @@ -68,9 +68,9 @@ #include <libnautilus-private/nautilus-link.h> #include <libnautilus-private/nautilus-metadata.h> #include <libnautilus-private/nautilus-sound.h> -#include <libnautilus/nautilus-bonobo-ui.h> -#include <libnautilus/nautilus-clipboard.h> -#include <libnautilus/nautilus-scroll-positionable.h> +#include <libnautilus-private/nautilus-bonobo-ui.h> +#include <libnautilus-private/nautilus-view-factory.h> +#include <libnautilus-private/nautilus-clipboard.h> #include <locale.h> #include <signal.h> #include <stdio.h> @@ -134,8 +134,6 @@ struct FMIconViewDetails const SortCriterion *sort; gboolean sort_reversed; - NautilusScrollPositionable *positionable; - BonoboUIComponent *ui; NautilusAudioPlayerData *audio_player_data; @@ -215,8 +213,11 @@ static void preview_audio ( gboolean start_flag); static void update_layout_menus (FMIconView *view); -GNOME_CLASS_BOILERPLATE (FMIconView, fm_icon_view, - FMDirectoryView, FM_TYPE_DIRECTORY_VIEW) +static void fm_icon_view_iface_init (NautilusViewIface *iface); + +G_DEFINE_TYPE_WITH_CODE (FMIconView, fm_icon_view, FM_TYPE_DIRECTORY_VIEW, + G_IMPLEMENT_INTERFACE (NAUTILUS_TYPE_VIEW, + fm_icon_view_iface_init)); static void fm_icon_view_destroy (GtkObject *object) @@ -247,7 +248,7 @@ fm_icon_view_destroy (GtkObject *object) icon_view->details->icons_not_positioned = NULL; } - EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); + GTK_OBJECT_CLASS (fm_icon_view_parent_class)->destroy (object); } @@ -260,7 +261,7 @@ fm_icon_view_finalize (GObject *object) g_free (icon_view->details); - EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object)); + G_OBJECT_CLASS (fm_icon_view_parent_class)->finalize (object); } static NautilusIconContainer * @@ -1108,7 +1109,7 @@ fm_icon_view_begin_loading (FMDirectoryView *view) } else { GdkDragAction default_action; - if (nautilus_view_get_window_type (fm_directory_view_get_nautilus_view (view)) == Nautilus_WINDOW_NAVIGATION) { + if (nautilus_window_info_get_window_type (fm_directory_view_get_nautilus_window (view)) == NAUTILUS_WINDOW_NAVIGATION) { default_action = NAUTILUS_DND_ACTION_SET_AS_GLOBAL_BACKGROUND; } else { default_action = NAUTILUS_DND_ACTION_SET_AS_FOLDER_BACKGROUND; @@ -1528,15 +1529,14 @@ fm_icon_view_can_rename_file (FMDirectoryView *view, NautilusFile *file) return FALSE; } - return EEL_CALL_PARENT_WITH_RETURN_VALUE ( - FM_DIRECTORY_VIEW_CLASS, can_rename_file, (view, file)); + return FM_DIRECTORY_VIEW_CLASS(fm_icon_view_parent_class)->can_rename_file (view, file); } static void fm_icon_view_start_renaming_file (FMDirectoryView *view, NautilusFile *file) { /* call parent class to make sure the right icon is selected */ - EEL_CALL_PARENT (FM_DIRECTORY_VIEW_CLASS, start_renaming_file, (view, file)); + FM_DIRECTORY_VIEW_CLASS(fm_icon_view_parent_class)->start_renaming_file (view, file); /* start renaming */ nautilus_icon_container_start_renaming_selected_item @@ -1570,7 +1570,7 @@ fm_icon_view_merge_menus (FMDirectoryView *view) g_assert (FM_IS_ICON_VIEW (view)); - EEL_CALL_PARENT (FM_DIRECTORY_VIEW_CLASS, merge_menus, (view)); + FM_DIRECTORY_VIEW_CLASS (fm_icon_view_parent_class)->merge_menus(view); icon_view = FM_ICON_VIEW (view); @@ -1641,7 +1641,7 @@ fm_icon_view_update_menus (FMDirectoryView *view) return; } - EEL_CALL_PARENT (FM_DIRECTORY_VIEW_CLASS, update_menus, (view)); + FM_DIRECTORY_VIEW_CLASS (fm_icon_view_parent_class)->update_menus(view); /* don't update if we have no remote BonoboUIContainer */ if (bonobo_ui_component_get_container (icon_view->details->ui) @@ -1767,7 +1767,7 @@ icon_container_activate_callback (NautilusIconContainer *container, fm_directory_view_activate_files (FM_DIRECTORY_VIEW (icon_view), file_list, - Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE, 0); + NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE, 0); } static void @@ -1780,8 +1780,8 @@ icon_container_activate_alternate_callback (NautilusIconContainer *container, fm_directory_view_activate_files (FM_DIRECTORY_VIEW (icon_view), file_list, - Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE, - Nautilus_ViewFrame_OPEN_FLAG_CLOSE_BEHIND); + NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE, + NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND); } static void @@ -2031,8 +2031,8 @@ icon_container_preview_callback (NautilusIconContainer *container, file_name = nautilus_file_get_display_name (file); message = g_strdup_printf (_("pointing at \"%s\""), file_name); g_free (file_name); - nautilus_view_report_status - (fm_directory_view_get_nautilus_view (FM_DIRECTORY_VIEW (icon_view)), + nautilus_window_info_set_status + (fm_directory_view_get_nautilus_window (FM_DIRECTORY_VIEW (icon_view)), message); g_free (message); } else { @@ -2051,10 +2051,12 @@ renaming_icon_callback (NautilusIconContainer *container, FMDirectoryView *directory_view; directory_view = FM_DIRECTORY_VIEW (callback_data); +#ifdef BONOBO_DONE nautilus_clipboard_set_up_editable_in_control (GTK_EDITABLE (widget), fm_directory_view_get_bonobo_control (directory_view), FALSE); +#endif } int @@ -2086,8 +2088,8 @@ fm_icon_view_screen_changed (GtkWidget *widget, NautilusFile *file; NautilusIconContainer *icon_container; - if (GTK_WIDGET_CLASS (parent_class)->screen_changed) { - GTK_WIDGET_CLASS (parent_class)->screen_changed (widget, previous_screen); + if (GTK_WIDGET_CLASS (fm_icon_view_parent_class)->screen_changed) { + GTK_WIDGET_CLASS (fm_icon_view_parent_class)->screen_changed (widget, previous_screen); } view = FM_DIRECTORY_VIEW (widget); @@ -2771,10 +2773,12 @@ icon_view_handle_uri_list (NautilusIconContainer *container, const char *item_ur } static char * -icon_view_get_first_visible_file_callback (NautilusScrollPositionable *positionable, - FMIconView *icon_view) +icon_view_get_first_visible_file (NautilusView *view) { NautilusFile *file; + FMIconView *icon_view; + + icon_view = FM_ICON_VIEW (view); file = NAUTILUS_FILE (nautilus_icon_container_get_first_visible_icon (get_icon_container (icon_view))); @@ -2786,12 +2790,14 @@ icon_view_get_first_visible_file_callback (NautilusScrollPositionable *positiona } static void -icon_view_scroll_to_file_callback (NautilusScrollPositionable *positionable, - const char *uri, - FMIconView *icon_view) +icon_view_scroll_to_file (NautilusView *view, + const char *uri) { NautilusFile *file; + FMIconView *icon_view; + icon_view = FM_ICON_VIEW (view); + if (uri != NULL) { file = nautilus_file_get (uri); if (file != NULL) { @@ -2862,11 +2868,30 @@ fm_icon_view_class_init (FMIconViewClass *klass) klass->set_directory_tighter_layout = fm_icon_view_real_set_directory_tighter_layout; } +static const char * +fm_icon_view_get_id (NautilusView *view) +{ + if (FM_IS_DESKTOP_ICON_VIEW (view)) { + return FM_DESKTOP_ICON_VIEW_ID; + } + return FM_ICON_VIEW_ID; +} + +static void +fm_icon_view_iface_init (NautilusViewIface *iface) +{ + fm_directory_view_init_view_iface (iface); + + iface->get_view_id = fm_icon_view_get_id; + iface->get_first_visible_file = icon_view_get_first_visible_file; + iface->scroll_to_file = icon_view_scroll_to_file; + iface->get_title = NULL; +} + static void -fm_icon_view_instance_init (FMIconView *icon_view) +fm_icon_view_init (FMIconView *icon_view) { static gboolean setup_sound_preview = FALSE; - NautilusView *nautilus_view; g_return_if_fail (GTK_BIN (icon_view)->child == NULL); @@ -2876,11 +2901,6 @@ fm_icon_view_instance_init (FMIconView *icon_view) create_icon_container (icon_view); - icon_view->details->positionable = nautilus_scroll_positionable_new (); - nautilus_view = fm_directory_view_get_nautilus_view (FM_DIRECTORY_VIEW (icon_view)); - bonobo_object_add_interface (BONOBO_OBJECT (nautilus_view), - BONOBO_OBJECT (icon_view->details->positionable)); - if (!setup_sound_preview) { eel_preferences_add_auto_enum (NAUTILUS_PREFERENCES_PREVIEW_SOUND, &preview_sound_auto_value); @@ -2913,8 +2933,47 @@ fm_icon_view_instance_init (FMIconView *icon_view) g_signal_connect_object (get_icon_container (icon_view), "handle_uri_list", G_CALLBACK (icon_view_handle_uri_list), icon_view, 0); - g_signal_connect_object (icon_view->details->positionable, "get_first_visible_file", - G_CALLBACK (icon_view_get_first_visible_file_callback), icon_view, 0); - g_signal_connect_object (icon_view->details->positionable, "scroll_to_file", - G_CALLBACK (icon_view_scroll_to_file_callback), icon_view, 0); +} + +static NautilusView * +fm_icon_view_create (NautilusWindowInfo *window) +{ + FMIconView *view; + + view = g_object_new (FM_TYPE_ICON_VIEW, "window", window, NULL); + g_object_ref (view); + gtk_object_sink (GTK_OBJECT (view)); + return NAUTILUS_VIEW (view); +} + +static gboolean +fm_icon_view_supports_uri (const char *uri, + GnomeVFSFileType file_type, + const char *mime_type) +{ + if (file_type == GNOME_VFS_FILE_TYPE_DIRECTORY) { + return TRUE; + } + if (g_str_has_prefix (uri, "trash:")) { + return TRUE; + } + + return FALSE; +} + +static NautilusViewInfo fm_icon_view = { + FM_ICON_VIEW_ID, + N_("Icons"), + N_("_Icons"), + fm_icon_view_create, + fm_icon_view_supports_uri +}; + +void +fm_icon_view_register (void) +{ + fm_icon_view.label = _(fm_icon_view.label); + fm_icon_view.label_with_mnemonic = _(fm_icon_view.label_with_mnemonic); + + nautilus_view_factory_register (&fm_icon_view); } diff --git a/src/file-manager/fm-icon-view.h b/src/file-manager/fm-icon-view.h index 64bcd0127..d3f2cbed8 100644 --- a/src/file-manager/fm-icon-view.h +++ b/src/file-manager/fm-icon-view.h @@ -36,6 +36,8 @@ typedef struct FMIconViewClass FMIconViewClass; #define FM_IS_ICON_VIEW(obj) (GTK_CHECK_TYPE ((obj), FM_TYPE_ICON_VIEW)) #define FM_IS_ICON_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), FM_TYPE_ICON_VIEW)) +#define FM_ICON_VIEW_ID "OAFIID:Nautilus_File_Manager_Icon_View" + typedef struct FMIconViewDetails FMIconViewDetails; struct FMIconView { @@ -104,4 +106,6 @@ int fm_icon_view_compare_files (FMIconView *icon_view, NautilusFile *b); void fm_icon_view_filter_by_screen (FMIconView *icon_view, gboolean filter); +void fm_icon_view_register (void); + #endif /* FM_ICON_VIEW_H */ diff --git a/src/file-manager/fm-list-view.c b/src/file-manager/fm-list-view.c index f5a877609..aa1779531 100644 --- a/src/file-manager/fm-list-view.c +++ b/src/file-manager/fm-list-view.c @@ -63,8 +63,8 @@ #include <libnautilus-private/nautilus-metadata.h> #include <libnautilus-private/nautilus-module.h> #include <libnautilus-private/nautilus-tree-view-drag-dest.h> -#include <libnautilus/nautilus-scroll-positionable.h> -#include <libnautilus/nautilus-clipboard.h> +#include <libnautilus-private/nautilus-view-factory.h> +#include <libnautilus-private/nautilus-clipboard.h> #include <libnautilus-private/nautilus-cell-renderer-pixbuf-emblem.h> /* Included for the typeselect flush delay */ @@ -88,8 +88,6 @@ struct FMListViewDetails { NautilusZoomLevel zoom_level; - NautilusScrollPositionable *positionable; - NautilusTreeViewDragDest *drag_dest; GtkTargetList *source_target_list; @@ -128,18 +126,25 @@ static NautilusZoomLevel default_zoom_level_auto_value; static GList * default_visible_columns_auto_value; static GList * default_column_order_auto_value; -static GList * fm_list_view_get_selection (FMDirectoryView *view); -static void fm_list_view_set_zoom_level (FMListView *view, - NautilusZoomLevel new_level, - gboolean always_set_level); -static void fm_list_view_scale_font_size (FMListView *view, - NautilusZoomLevel new_level, - gboolean update_size_table); -static void fm_list_view_scroll_to_file (FMListView *view, - NautilusFile *file); +static GList *fm_list_view_get_selection (FMDirectoryView *view); +static void fm_list_view_set_zoom_level (FMListView *view, + NautilusZoomLevel new_level, + gboolean always_set_level); +static void fm_list_view_scale_font_size (FMListView *view, + NautilusZoomLevel new_level, + gboolean update_size_table); +static void fm_list_view_scroll_to_file (FMListView *view, + NautilusFile *file); +static void fm_list_view_iface_init (NautilusViewIface *iface); + + -GNOME_CLASS_BOILERPLATE (FMListView, fm_list_view, - FMDirectoryView, FM_TYPE_DIRECTORY_VIEW) +G_DEFINE_TYPE_WITH_CODE (FMListView, fm_list_view, FM_TYPE_DIRECTORY_VIEW, + G_IMPLEMENT_INTERFACE (NAUTILUS_TYPE_VIEW, + fm_list_view_iface_init)); + +/* for EEL_CALL_PARENT */ +#define parent_class fm_list_view_parent_class static void list_selection_changed_callback (GtkTreeSelection *selection, gpointer user_data) @@ -188,7 +193,7 @@ activate_selected_items (FMListView *view) file_list = fm_list_view_get_selection (FM_DIRECTORY_VIEW (view)); fm_directory_view_activate_files (FM_DIRECTORY_VIEW (view), file_list, - Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE, + NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE, 0); nautilus_file_list_free (file_list); @@ -209,8 +214,8 @@ activate_selected_items_alternate (FMListView *view, } fm_directory_view_activate_files (FM_DIRECTORY_VIEW (view), file_list, - Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE, - Nautilus_ViewFrame_OPEN_FLAG_CLOSE_BEHIND); + NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE, + NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND); nautilus_file_list_free (file_list); } @@ -1869,10 +1874,12 @@ fm_list_view_start_renaming_file (FMDirectoryView *view, NautilusFile *file) gtk_tree_path_free (path); +#ifdef BONOBO_DONE nautilus_clipboard_set_up_editable_in_control (GTK_EDITABLE (entry), fm_directory_view_get_bonobo_control (view), FALSE); +#endif } static void @@ -2035,12 +2042,14 @@ fm_list_view_emblems_changed (FMDirectoryView *directory_view) } static char * -list_view_get_first_visible_file_callback (NautilusScrollPositionable *positionable, - FMListView *list_view) +fm_list_view_get_first_visible_file (NautilusView *view) { NautilusFile *file; GtkTreePath *path; GtkTreeIter iter; + FMListView *list_view; + + list_view = FM_LIST_VIEW (view); if (gtk_tree_view_get_path_at_pos (list_view->details->tree_view, 0, 0, @@ -2069,7 +2078,8 @@ list_view_get_first_visible_file_callback (NautilusScrollPositionable *positiona } static void -fm_list_view_scroll_to_file (FMListView *view, NautilusFile *file) +fm_list_view_scroll_to_file (FMListView *view, + NautilusFile *file) { GtkTreePath *path; GtkTreeIter iter; @@ -2088,15 +2098,14 @@ fm_list_view_scroll_to_file (FMListView *view, NautilusFile *file) } static void -list_view_scroll_to_file_callback (NautilusScrollPositionable *positionable, - const char *uri, - FMListView *list_view) +list_view_scroll_to_file (NautilusView *view, + const char *uri) { NautilusFile *file; if (uri != NULL) { file = nautilus_file_get (uri); - fm_list_view_scroll_to_file (list_view, file); + fm_list_view_scroll_to_file (FM_LIST_VIEW (view), file); nautilus_file_unref (file); } } @@ -2152,20 +2161,31 @@ fm_list_view_class_init (FMListViewClass *class) (const GList **) &default_column_order_auto_value); } +static const char * +fm_list_view_get_id (NautilusView *view) +{ + return FM_LIST_VIEW_ID; +} + + static void -fm_list_view_instance_init (FMListView *list_view) +fm_list_view_iface_init (NautilusViewIface *iface) { - NautilusView *nautilus_view; + fm_directory_view_init_view_iface (iface); - list_view->details = g_new0 (FMListViewDetails, 1); + iface->get_view_id = fm_list_view_get_id; + iface->get_first_visible_file = fm_list_view_get_first_visible_file; + iface->scroll_to_file = list_view_scroll_to_file; + iface->get_title = NULL; +} - create_and_set_up_tree_view (list_view); - list_view->details->positionable = nautilus_scroll_positionable_new (); - nautilus_view = fm_directory_view_get_nautilus_view (FM_DIRECTORY_VIEW (list_view)); - bonobo_object_add_interface (BONOBO_OBJECT (nautilus_view), - BONOBO_OBJECT (list_view->details->positionable)); +static void +fm_list_view_init (FMListView *list_view) +{ + list_view->details = g_new0 (FMListViewDetails, 1); + create_and_set_up_tree_view (list_view); eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_LIST_VIEW_DEFAULT_SORT_ORDER, default_sort_order_changed_callback, @@ -2192,10 +2212,49 @@ fm_list_view_instance_init (FMListView *list_view) "icons_changed", G_CALLBACK (icons_changed_callback), list_view, 0); - g_signal_connect_object (list_view->details->positionable, "get_first_visible_file", - G_CALLBACK (list_view_get_first_visible_file_callback), list_view, 0); - g_signal_connect_object (list_view->details->positionable, "scroll_to_file", - G_CALLBACK (list_view_scroll_to_file_callback), list_view, 0); list_view->details->type_select_state = NULL; } + +static NautilusView * +fm_list_view_create (NautilusWindowInfo *window) +{ + FMListView *view; + + view = g_object_new (FM_TYPE_LIST_VIEW, "window", window, NULL); + g_object_ref (view); + gtk_object_sink (GTK_OBJECT (view)); + return NAUTILUS_VIEW (view); +} + +static gboolean +fm_list_view_supports_uri (const char *uri, + GnomeVFSFileType file_type, + const char *mime_type) +{ + if (file_type == GNOME_VFS_FILE_TYPE_DIRECTORY) { + return TRUE; + } + if (g_str_has_prefix (uri, "trash:")) { + return TRUE; + } + + return FALSE; +} + +static NautilusViewInfo fm_list_view = { + FM_LIST_VIEW_ID, + N_("List"), + N_("_List"), + fm_list_view_create, + fm_list_view_supports_uri +}; + +void +fm_list_view_register (void) +{ + fm_list_view.label = _(fm_list_view.label); + fm_list_view.label_with_mnemonic = _(fm_list_view.label_with_mnemonic); + + nautilus_view_factory_register (&fm_list_view); +} diff --git a/src/file-manager/fm-list-view.h b/src/file-manager/fm-list-view.h index 5078dfa72..72dc07718 100644 --- a/src/file-manager/fm-list-view.h +++ b/src/file-manager/fm-list-view.h @@ -35,6 +35,8 @@ #define FM_IS_LIST_VIEW(obj) (GTK_CHECK_TYPE ((obj), FM_TYPE_LIST_VIEW)) #define FM_IS_LIST_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), FM_TYPE_LIST_VIEW)) +#define FM_LIST_VIEW_ID "OAFIID:Nautilus_File_Manager_List_View" + typedef struct FMListViewDetails FMListViewDetails; typedef struct { @@ -47,5 +49,6 @@ typedef struct { } FMListViewClass; GType fm_list_view_get_type (void); +void fm_list_view_register (void); #endif /* FM_LIST_VIEW_H */ diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c index cd4b23937..e25793163 100644 --- a/src/file-manager/fm-properties-window.c +++ b/src/file-manager/fm-properties-window.c @@ -76,9 +76,7 @@ #include <libnautilus-private/nautilus-module.h> #include <libnautilus-private/nautilus-undo-signal-handlers.h> #include <libnautilus-private/nautilus-mime-actions.h> -#include <libnautilus-private/nautilus-view-identifier.h> -#include <libnautilus/nautilus-undo.h> -#include <libnautilus/nautilus-view.h> +#include <libnautilus-private/nautilus-undo.h> #include <bonobo/bonobo-widget.h> #include <bonobo/bonobo-exception.h> #include <string.h> diff --git a/src/file-manager/fm-tree-view.h b/src/file-manager/fm-tree-view.h index 31ec9da54..4ae815456 100644 --- a/src/file-manager/fm-tree-view.h +++ b/src/file-manager/fm-tree-view.h @@ -40,12 +40,15 @@ typedef struct FMTreeViewDetails FMTreeViewDetails; typedef struct { - NautilusView parent; + /* BONOBOTODO: pick parent */ + /*NautilusView parent;*/ + GObject parent; + FMTreeViewDetails *details; } FMTreeView; typedef struct { - NautilusViewClass parent_class; + GObjectClass parent_class; } FMTreeViewClass; GType fm_tree_view_get_type (void); diff --git a/src/nautilus-applicable-views.c b/src/nautilus-applicable-views.c deleted file mode 100644 index 38accd6e8..000000000 --- a/src/nautilus-applicable-views.c +++ /dev/null @@ -1,195 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, 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 - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * Nautilus 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., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Authors: Elliot Lee <sopwith@redhat.com> - * Maciej Stachowiak <mjs@eazel.com> - * Darin Adler <darin@bentspoon.com> - * - */ - -/* nautilus-applicable-views.c: Implementation of routines for mapping a location - change request to a set of views and actual URL to be loaded. */ - -#include <config.h> -#include "nautilus-applicable-views.h" - -#include <libgnomevfs/gnome-vfs-result.h> -#include <libnautilus-private/nautilus-file.h> -#include <libnautilus-private/nautilus-mime-actions.h> -#include <libnautilus-private/nautilus-view-query.h> -#include <libnautilus-private/nautilus-view-identifier.h> - -struct NautilusDetermineViewHandle { - NautilusDetermineViewHandle **early_completion_hook; - NautilusDetermineViewCallback callback; - gpointer callback_data; - NautilusFile *file; - gboolean fallback; -}; - -static NautilusDetermineViewResult -get_view_result_from_gnome_vfs_result (GnomeVFSResult gnome_vfs_result) -{ - switch (gnome_vfs_result) { - case GNOME_VFS_OK: - return NAUTILUS_DETERMINE_VIEW_OK; - case GNOME_VFS_ERROR_NOT_FOUND: - return NAUTILUS_DETERMINE_VIEW_NOT_FOUND; - case GNOME_VFS_ERROR_INVALID_URI: - return NAUTILUS_DETERMINE_VIEW_INVALID_URI; - case GNOME_VFS_ERROR_NOT_SUPPORTED: - return NAUTILUS_DETERMINE_VIEW_UNSUPPORTED_SCHEME; - case GNOME_VFS_ERROR_LOGIN_FAILED: - return NAUTILUS_DETERMINE_VIEW_LOGIN_FAILED; - case GNOME_VFS_ERROR_SERVICE_NOT_AVAILABLE: - return NAUTILUS_DETERMINE_VIEW_SERVICE_NOT_AVAILABLE; - case GNOME_VFS_ERROR_ACCESS_DENIED: - return NAUTILUS_DETERMINE_VIEW_ACCESS_DENIED; - case GNOME_VFS_ERROR_HOST_NOT_FOUND: - return NAUTILUS_DETERMINE_VIEW_HOST_NOT_FOUND; - case GNOME_VFS_ERROR_HOST_HAS_NO_ADDRESS: - return NAUTILUS_DETERMINE_VIEW_HOST_HAS_NO_ADDRESS; - case GNOME_VFS_ERROR_NO_MASTER_BROWSER: - return NAUTILUS_DETERMINE_VIEW_NO_MASTER_BROWSER; - case GNOME_VFS_ERROR_GENERIC: - case GNOME_VFS_ERROR_INTERNAL: - /* These two have occurred at least once in the web browser component */ - return NAUTILUS_DETERMINE_VIEW_UNSPECIFIC_ERROR; - default: - /* Whenever this message fires, we should consider adding a specific case - * to make the error as comprehensible as possible to the user. Please - * bug me (sullivan@eazel.com) if you see this fire and don't have the - * inclination to immediately make a good message yourself (tell me - * what GnomeVFSResult code the message reported, and what caused it to - * fire). - */ - g_warning ("in nautilus-applicable-views.c, got unhandled GnomeVFSResult %d (%s). " - "If this is a legitimate get_file_info result, please tell " - "sullivan@eazel.com so he can " - "write a decent user-level error message for it.", - gnome_vfs_result, - gnome_vfs_result_to_string (gnome_vfs_result)); - return NAUTILUS_DETERMINE_VIEW_UNSPECIFIC_ERROR; - } -} - -static void -got_file_info_callback (NautilusFile *file, - gpointer callback_data) -{ - NautilusDetermineViewHandle *handle; - GnomeVFSResult vfs_result_code; - NautilusDetermineViewResult result_code; - NautilusViewIdentifier *default_id; - Bonobo_ServerInfo *default_component; - - handle = (NautilusDetermineViewHandle *) callback_data; - - g_assert (handle->file == file); - default_id = NULL; - - vfs_result_code = nautilus_file_get_file_info_result (file); - if (vfs_result_code == GNOME_VFS_OK - || vfs_result_code == GNOME_VFS_ERROR_NOT_SUPPORTED - || vfs_result_code == GNOME_VFS_ERROR_INVALID_URI) { - if (handle->fallback) { - default_component = nautilus_view_query_get_fallback_component_for_file (handle->file); - } else { - default_component = nautilus_view_query_get_default_component_for_file (handle->file); - } - if (default_component != NULL) { - default_id = nautilus_view_identifier_new_from_content_view (default_component); - CORBA_free (default_component); - if (default_id != NULL) { - vfs_result_code = GNOME_VFS_OK; - } - } - } - - if (vfs_result_code == GNOME_VFS_OK && default_id == NULL) { - result_code = NAUTILUS_DETERMINE_VIEW_NO_HANDLER_FOR_TYPE; - } else { - result_code = get_view_result_from_gnome_vfs_result (vfs_result_code); - } - - (* handle->callback) (handle, - result_code, - default_id, - handle->callback_data); - - nautilus_view_identifier_free (default_id); - - nautilus_determine_initial_view_cancel (handle); -} - -NautilusDetermineViewHandle * -nautilus_determine_initial_view (const char *location, - gboolean fallback, - NautilusDetermineViewCallback callback, - gpointer callback_data) -{ - NautilusDetermineViewHandle *handle; - NautilusFileAttributes attributes; - - g_return_val_if_fail (location != NULL, NULL); - g_return_val_if_fail (callback != NULL, NULL); - - handle = g_new0 (NautilusDetermineViewHandle, 1); - - handle->early_completion_hook = &handle; - - handle->callback = callback; - handle->callback_data = callback_data; - handle->fallback = fallback; - - handle->file = nautilus_file_get (location); - - attributes = nautilus_mime_actions_get_minimum_file_attributes (); - nautilus_file_call_when_ready (handle->file, attributes, - got_file_info_callback, handle); - - if (handle != NULL) { - handle->early_completion_hook = NULL; - } - - return handle; -} - -void -nautilus_determine_initial_view_cancel (NautilusDetermineViewHandle *handle) -{ - g_return_if_fail (handle != NULL); - g_return_if_fail (handle->early_completion_hook == NULL - || *handle->early_completion_hook == handle); - g_return_if_fail (handle->callback != NULL); - - if (handle->early_completion_hook != NULL) { - *handle->early_completion_hook = NULL; - } - - nautilus_file_cancel_call_when_ready - (handle->file, got_file_info_callback, handle); - - nautilus_file_unref (handle->file); - - g_free (handle); -} diff --git a/src/nautilus-applicable-views.h b/src/nautilus-applicable-views.h deleted file mode 100644 index da85cc0a3..000000000 --- a/src/nautilus-applicable-views.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Coypright (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 - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * Nautilus 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., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Authors: Elliot Lee <sopwith@redhat.com> - * Darin Adler <darin@bentspoon.com> - * Maciej Stachowiak <mjs@eazel.com> - * - */ - -/* nautilus-applicable-views.h: Interface for mapping a location - change request to a set of views and actual URL to be loaded. */ - -#ifndef NAUTILUS_APPLICABLE_VIEWS_H -#define NAUTILUS_APPLICABLE_VIEWS_H - -#include <libnautilus-private/nautilus-view-identifier.h> - -typedef struct NautilusDetermineViewHandle NautilusDetermineViewHandle; - -/* These are the different ways that Nautilus can fail to locate an - * initial view for a given location NAUTILUS_DETERMINE_VIEW_OK means - * the uri was displayed successfully. These are similar to - * GnomeVFSResults but there are Nautilus-specific codes and many of - * the GnomeVFSResults are treated the same here. - */ -typedef enum { - NAUTILUS_DETERMINE_VIEW_OK, - NAUTILUS_DETERMINE_VIEW_UNSPECIFIC_ERROR, - NAUTILUS_DETERMINE_VIEW_NO_HANDLER_FOR_TYPE, - NAUTILUS_DETERMINE_VIEW_NOT_FOUND, - NAUTILUS_DETERMINE_VIEW_UNSUPPORTED_SCHEME, - NAUTILUS_DETERMINE_VIEW_INVALID_URI, - NAUTILUS_DETERMINE_VIEW_LOGIN_FAILED, - NAUTILUS_DETERMINE_VIEW_SERVICE_NOT_AVAILABLE, - NAUTILUS_DETERMINE_VIEW_ACCESS_DENIED, - NAUTILUS_DETERMINE_VIEW_HOST_NOT_FOUND, - NAUTILUS_DETERMINE_VIEW_HOST_HAS_NO_ADDRESS, - NAUTILUS_DETERMINE_VIEW_NO_MASTER_BROWSER -} NautilusDetermineViewResult; - -typedef void (* NautilusDetermineViewCallback) (NautilusDetermineViewHandle *handle, - NautilusDetermineViewResult result, - const NautilusViewIdentifier *initial_view, - gpointer callback_data); - -NautilusDetermineViewHandle *nautilus_determine_initial_view (const char *location, - gboolean fallback, - NautilusDetermineViewCallback callback, - gpointer callback_data); -void nautilus_determine_initial_view_cancel (NautilusDetermineViewHandle *handle); - -#endif /* NAUTILUS_APPLICABLE_VIEWS_H */ diff --git a/src/nautilus-application.c b/src/nautilus-application.c index af4ad6d88..a769b728c 100644 --- a/src/nautilus-application.c +++ b/src/nautilus-application.c @@ -29,7 +29,6 @@ #include "nautilus-application.h" -#include "file-manager/fm-bonobo-provider.h" #include "file-manager/fm-ditem-page.h" #include "file-manager/fm-desktop-icon-view.h" #include "file-manager/fm-icon-view.h" @@ -121,28 +120,13 @@ create_object (PortableServer_Servant servant, CORBA_Environment *ev) { BonoboObject *object; - FMDirectoryView *directory_view; NautilusApplication *application; - if (strcmp (iid, NAUTILUS_ICON_VIEW_IID) == 0) { - directory_view = FM_DIRECTORY_VIEW (g_object_new (fm_icon_view_get_type (), NULL)); - object = BONOBO_OBJECT (fm_directory_view_get_nautilus_view (directory_view)); - } else if (strcmp (iid, NAUTILUS_DESKTOP_ICON_VIEW_IID) == 0) { - directory_view = FM_DIRECTORY_VIEW (g_object_new (fm_desktop_icon_view_get_type (), NULL)); - object = BONOBO_OBJECT (fm_directory_view_get_nautilus_view (directory_view)); - } else if (strcmp (iid, NAUTILUS_LIST_VIEW_IID) == 0) { - directory_view = FM_DIRECTORY_VIEW (g_object_new (fm_list_view_get_type (), NULL)); - object = BONOBO_OBJECT (fm_directory_view_get_nautilus_view (directory_view)); - } else if (strcmp (iid, SEARCH_LIST_VIEW_IID) == 0) { - directory_view = FM_DIRECTORY_VIEW (g_object_new (fm_search_list_view_get_type (), NULL)); - object = BONOBO_OBJECT (fm_directory_view_get_nautilus_view (directory_view)); - } else if (strcmp (iid, SHELL_IID) == 0) { + if (strcmp (iid, SHELL_IID) == 0) { application = NAUTILUS_APPLICATION (bonobo_object_from_servant (servant)); object = BONOBO_OBJECT (nautilus_shell_new (application)); } else if (strcmp (iid, METAFILE_FACTORY_IID) == 0) { object = BONOBO_OBJECT (nautilus_metafile_factory_get_instance ()); - } else if (strcmp (iid, TREE_VIEW_IID) == 0) { - object = BONOBO_OBJECT (g_object_new (fm_tree_view_get_type (), NULL)); } else { object = CORBA_OBJECT_NIL; } @@ -162,12 +146,6 @@ nautilus_application_get_spatial_window_list (void) return nautilus_application_spatial_window_list; } -static CORBA_Object -create_object_shortcut (const char *iid, - gpointer callback_data) -{ - return create_object (BONOBO_OBJREF (callback_data), iid, NULL); -} static void nautilus_application_instance_init (NautilusApplication *application) @@ -187,11 +165,10 @@ nautilus_application_instance_init (NautilusApplication *application) g_signal_connect_object (gnome_vfs_get_volume_monitor (), "volume_mounted", G_CALLBACK (volume_mounted_callback), application, 0); - nautilus_bonobo_register_activation_shortcut (NAUTILUS_ICON_VIEW_IID, create_object_shortcut, application); - nautilus_bonobo_register_activation_shortcut (NAUTILUS_DESKTOP_ICON_VIEW_IID, create_object_shortcut, application); - nautilus_bonobo_register_activation_shortcut (NAUTILUS_LIST_VIEW_IID, create_object_shortcut, application); - nautilus_bonobo_register_activation_shortcut (SEARCH_LIST_VIEW_IID, create_object_shortcut, application); - nautilus_bonobo_register_activation_shortcut (TREE_VIEW_IID, create_object_shortcut, application); + fm_icon_view_register (); + fm_desktop_icon_view_register (); + fm_list_view_register (); + } NautilusApplication * @@ -215,15 +192,9 @@ nautilus_application_destroy (BonoboObject *object) application = NAUTILUS_APPLICATION (object); - nautilus_bonobo_unregister_activation_shortcut (NAUTILUS_ICON_VIEW_IID); - nautilus_bonobo_unregister_activation_shortcut (NAUTILUS_DESKTOP_ICON_VIEW_IID); - nautilus_bonobo_unregister_activation_shortcut (NAUTILUS_LIST_VIEW_IID); - nautilus_bonobo_unregister_activation_shortcut (SEARCH_LIST_VIEW_IID); - nautilus_bonobo_unregister_activation_shortcut (TREE_VIEW_IID); - nautilus_bookmarks_exiting (); - bonobo_object_unref (application->undo_manager); + g_object_unref (application->undo_manager); EEL_CALL_PARENT (BONOBO_OBJECT_CLASS, destroy, (object)); } @@ -373,7 +344,6 @@ finish_startup (NautilusApplication *application) /* initialize nautilus modules */ nautilus_module_init (); - nautilus_module_add_type (FM_TYPE_BONOBO_PROVIDER); nautilus_module_add_type (FM_TYPE_DITEM_PAGE); /* initialize the sound machinery */ @@ -822,6 +792,9 @@ find_parent_spatial_window (NautilusSpatialWindow *window) char *desktop_directory; location = nautilus_window_get_location (NAUTILUS_WINDOW (window)); + if (location == NULL) { + return NULL; + } file = nautilus_file_get (location); g_free (location); @@ -974,10 +947,10 @@ nautilus_application_present_spatial_window (NautilusApplication *application, NautilusWindow * nautilus_application_present_spatial_window_with_selection (NautilusApplication *application, - NautilusWindow *requesting_window, - const char *location, - GList *new_selection, - GdkScreen *screen) + NautilusWindow *requesting_window, + const char *location, + GList *new_selection, + GdkScreen *screen) { NautilusWindow *window; GList *l; @@ -991,7 +964,7 @@ nautilus_application_present_spatial_window_with_selection (NautilusApplication existing_window = NAUTILUS_WINDOW (l->data); existing_location = existing_window->details->pending_location; - + if (existing_location == NULL) { existing_location = existing_window->details->location; } @@ -999,7 +972,7 @@ nautilus_application_present_spatial_window_with_selection (NautilusApplication if (eel_uris_match (existing_location, location)) { gtk_window_present (GTK_WINDOW (existing_window)); if (new_selection) { - nautilus_view_frame_selection_changed (existing_window->content_view, new_selection); + nautilus_view_set_selection (existing_window->content_view, new_selection); } return existing_window; } diff --git a/src/nautilus-bookmarks-window.c b/src/nautilus-bookmarks-window.c index 0776a0b01..3012704b7 100644 --- a/src/nautilus-bookmarks-window.c +++ b/src/nautilus-bookmarks-window.c @@ -28,7 +28,7 @@ #include <config.h> #include "nautilus-bookmarks-window.h" #include "nautilus-window.h" -#include <libnautilus/nautilus-undo.h> +#include <libnautilus-private/nautilus-undo.h> #include <libnautilus-private/nautilus-global-preferences.h> #include <eel/eel-gtk-extensions.h> #include <eel/eel-gnome-extensions.h> diff --git a/src/nautilus-complex-search-bar.c b/src/nautilus-complex-search-bar.c index 061e01a56..944343a20 100644 --- a/src/nautilus-complex-search-bar.c +++ b/src/nautilus-complex-search-bar.c @@ -47,7 +47,7 @@ #include <libgnomevfs/gnome-vfs-utils.h> #include <libnautilus-private/nautilus-global-preferences.h> #include <libnautilus-private/nautilus-undo-signal-handlers.h> -#include <libnautilus/nautilus-clipboard.h> +#include <libnautilus-private/nautilus-clipboard.h> struct NautilusComplexSearchBarDetails { GtkVBox *bar_container; @@ -432,10 +432,12 @@ nautilus_complex_search_bar_new (NautilusWindow *window) g_assert (first_criterion != NULL); g_assert (first_criterion->details->use_value_entry); +#ifdef BONOBO_DONE nautilus_clipboard_set_up_editable (GTK_EDITABLE (first_criterion->details->value_entry), nautilus_window_get_ui_container (window), TRUE); +#endif return bar; } @@ -450,9 +452,11 @@ nautilus_complex_search_bar_set_up_enclosed_entry_for_clipboard (NautilusComplex "associated_window"); g_assert (associated_window != NULL); +#ifdef BONOBO_DONE nautilus_clipboard_set_up_editable (GTK_EDITABLE (entry), nautilus_window_get_ui_container (associated_window), TRUE); +#endif } static void diff --git a/src/nautilus-component-adapter-factory.c b/src/nautilus-component-adapter-factory.c deleted file mode 100644 index 7cef35d19..000000000 --- a/src/nautilus-component-adapter-factory.c +++ /dev/null @@ -1,211 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 2000 Eazel, Inc. - * - * Nautilus 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. - * - * Nautilus 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* nautilus-component-adapter-factory.c - client wrapper for the - * special adapter component, which wraps Bonobo components as - * Nautilus Views and in the process keeps evil synchronous I/O out of - * the Nautilus process itself. - */ - -#include <config.h> -#include "nautilus-component-adapter-factory.h" - -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-moniker-util.h> -#include <bonobo/bonobo-object.h> -#include <eel/eel-debug.h> -#include <libgnome/gnome-macros.h> -#include <libnautilus-adapter/nautilus-adapter-factory.h> - -#define NAUTILUS_COMPONENT_ADAPTER_FACTORY_IID "OAFIID:Nautilus_Adapter_Factory" - -struct NautilusComponentAdapterFactoryDetails { - Nautilus_ComponentAdapterFactory corba_factory; -}; - -static NautilusComponentAdapterFactory *global_component_adapter_factory = NULL; - -GNOME_CLASS_BOILERPLATE (NautilusComponentAdapterFactory, nautilus_component_adapter_factory, - GtkObject, GTK_TYPE_OBJECT) - -static void -activate_factory (NautilusComponentAdapterFactory *factory) -{ - factory->details->corba_factory = bonobo_get_object - (NAUTILUS_COMPONENT_ADAPTER_FACTORY_IID, - "IDL:Nautilus/ComponentAdapterFactory:1.0", NULL); -} - -static void -unref_factory (NautilusComponentAdapterFactory *factory) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - Bonobo_Unknown_unref (factory->details->corba_factory, &ev); - CORBA_exception_free (&ev); -} - -static void -release_factory (NautilusComponentAdapterFactory *factory) -{ - CORBA_Object_release (factory->details->corba_factory, NULL); - factory->details->corba_factory = CORBA_OBJECT_NIL; -} - -static Nautilus_ComponentAdapterFactory -get_corba_factory (NautilusComponentAdapterFactory *factory) -{ - CORBA_Environment ev; - Nautilus_ComponentAdapterFactory result; - gboolean need_unref; - - CORBA_exception_init (&ev); - - need_unref = FALSE; - if (CORBA_Object_is_nil (factory->details->corba_factory, &ev) - || BONOBO_EX (&ev) - || CORBA_Object_non_existent (factory->details->corba_factory, &ev) - || BONOBO_EX (&ev)) { - release_factory (factory); - activate_factory (factory); - need_unref = TRUE; - } - - CORBA_exception_free (&ev); - - result = bonobo_object_dup_ref (factory->details->corba_factory, NULL); - - if (need_unref) { - unref_factory (factory); - } - - return result; -} - -static void -nautilus_component_adapter_factory_instance_init (NautilusComponentAdapterFactory *factory) -{ - factory->details = g_new0 (NautilusComponentAdapterFactoryDetails, 1); -} - -static void -nautilus_component_adapter_factory_destroy (GtkObject *object) -{ - NautilusComponentAdapterFactory *factory; - - factory = NAUTILUS_COMPONENT_ADAPTER_FACTORY (object); - - release_factory (factory); - g_free (factory->details); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -static void -nautilus_component_adapter_factory_class_init (NautilusComponentAdapterFactoryClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) klass; - object_class->destroy = nautilus_component_adapter_factory_destroy; -} - -static void -component_adapter_factory_at_exit_destructor (void) -{ - if (global_component_adapter_factory != NULL) { - g_object_unref (global_component_adapter_factory); - } -} - -NautilusComponentAdapterFactory * -nautilus_component_adapter_factory_get (void) -{ - NautilusComponentAdapterFactory *factory; - - if (global_component_adapter_factory == NULL) { - factory = NAUTILUS_COMPONENT_ADAPTER_FACTORY - (g_object_new (NAUTILUS_TYPE_COMPONENT_ADAPTER_FACTORY, NULL)); - - g_object_ref (factory); - gtk_object_sink (GTK_OBJECT (factory)); - - global_component_adapter_factory = factory; - eel_debug_call_at_shutdown (component_adapter_factory_at_exit_destructor); - } - - return global_component_adapter_factory; -} - -Nautilus_View -nautilus_component_adapter_factory_create_adapter (NautilusComponentAdapterFactory *factory, - Bonobo_Unknown component) -{ - Nautilus_View nautilus_view; - Bonobo_Control bonobo_control; - Nautilus_ComponentAdapterFactory corba_factory; - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - nautilus_view = Bonobo_Unknown_queryInterface - (component, "IDL:Nautilus/View:1.0", &ev); - if (BONOBO_EX (&ev)) { - nautilus_view = CORBA_OBJECT_NIL; - } - - if (nautilus_view != CORBA_OBJECT_NIL) { - /* Object has the View interface, great! We might not - * need to adapt it. - */ - bonobo_control = Bonobo_Unknown_queryInterface - (component, "IDL:Bonobo/Control:1.0", &ev); - if (BONOBO_EX (&ev)) { - bonobo_control = CORBA_OBJECT_NIL; - } - if (bonobo_control != CORBA_OBJECT_NIL) { - /* It has the control interface too, so all is peachy. */ - bonobo_object_release_unref (bonobo_control, NULL); - } else { - /* No control interface; we have no way to - * support a View that doesn't also support - * the Control interface, so fail. - */ - bonobo_object_release_unref (nautilus_view, NULL); - nautilus_view = CORBA_OBJECT_NIL; - } - } else { - /* No View interface, we must adapt the object */ - corba_factory = get_corba_factory (factory); - nautilus_view = Nautilus_ComponentAdapterFactory_create_adapter - (corba_factory, component, &ev); - if (BONOBO_EX (&ev)) { - nautilus_view = CORBA_OBJECT_NIL; - } - bonobo_object_release_unref (corba_factory, NULL); - } - - CORBA_exception_free (&ev); - - return nautilus_view; -} diff --git a/src/nautilus-component-adapter-factory.h b/src/nautilus-component-adapter-factory.h deleted file mode 100644 index 0931ac511..000000000 --- a/src/nautilus-component-adapter-factory.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 2000 Eazel, Inc. - * - * Nautilus 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. - * - * Nautilus 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., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -/* nautilus-component-adapter-factory.h - client wrapper for the - * special adapter component, which wraps Bonobo components as - * Nautilus Views and in the process keeps evil syncrhonous I/O out of - * the Nautilus process itself. - */ - -#ifndef NAUTILUS_COMPONENT_ADAPTER_FACTORY_H -#define NAUTILUS_COMPONENT_ADAPTER_FACTORY_H - -#include <gtk/gtkobject.h> -#include <libnautilus/nautilus-view-component.h> - -typedef struct NautilusComponentAdapterFactory NautilusComponentAdapterFactory; -typedef struct NautilusComponentAdapterFactoryClass NautilusComponentAdapterFactoryClass; - -typedef struct NautilusComponentAdapterFactoryDetails NautilusComponentAdapterFactoryDetails; - -#define NAUTILUS_TYPE_COMPONENT_ADAPTER_FACTORY \ - (nautilus_component_adapter_factory_get_type ()) -#define NAUTILUS_COMPONENT_ADAPTER_FACTORY(obj) \ - (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_COMPONENT_ADAPTER_FACTORY, NautilusComponentAdapterFactory)) -#define NAUTILUS_COMPONENT_ADAPTER_FACTORY_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_COMPONENT_ADAPTER_FACTORY, NautilusComponentAdapterFactoryClass)) -#define NAUTILUS_IS_COMPONENT_ADAPTER_FACTORY(obj) \ - (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_COMPONENT_ADAPTER_FACTORY)) -#define NAUTILUS_IS_COMPONENT_ADAPTER_FACTORY_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_COMPONENT_ADAPTER_FACTORY)) - -struct NautilusComponentAdapterFactory -{ - GtkObject object; - NautilusComponentAdapterFactoryDetails *details; -}; - -struct NautilusComponentAdapterFactoryClass -{ - GtkObjectClass parent_class; -}; - -GType nautilus_component_adapter_factory_get_type (void); -NautilusComponentAdapterFactory *nautilus_component_adapter_factory_get (void); -Nautilus_View nautilus_component_adapter_factory_create_adapter (NautilusComponentAdapterFactory *factory, - Bonobo_Unknown component); - -#endif /* NAUTILUS_COMPONENT_ADAPTER_FACTORY_H */ diff --git a/src/nautilus-desktop-window.c b/src/nautilus-desktop-window.c index 9d921ceed..99709f4d2 100644 --- a/src/nautilus-desktop-window.c +++ b/src/nautilus-desktop-window.c @@ -380,7 +380,7 @@ nautilus_desktop_window_class_init (NautilusDesktopWindowClass *class) GTK_WIDGET_CLASS (class)->map = map; - NAUTILUS_WINDOW_CLASS (class)->window_type = Nautilus_WINDOW_DESKTOP; + NAUTILUS_WINDOW_CLASS (class)->window_type = NAUTILUS_WINDOW_DESKTOP; NAUTILUS_WINDOW_CLASS (class)->add_current_location_to_history_list = real_add_current_location_to_history_list; diff --git a/src/nautilus-information-panel.c b/src/nautilus-information-panel.c index da68ba52b..e7e8f8406 100644 --- a/src/nautilus-information-panel.c +++ b/src/nautilus-information-panel.c @@ -64,7 +64,6 @@ #include <libnautilus-private/nautilus-metadata.h> #include <libnautilus-private/nautilus-mime-actions.h> #include <libnautilus-private/nautilus-program-choosing.h> -#include <libnautilus-private/nautilus-sidebar-functions.h> #include <libnautilus-private/nautilus-trash-monitor.h> #include <math.h> diff --git a/src/nautilus-information-panel.h b/src/nautilus-information-panel.h index 360458094..9660b4e76 100644 --- a/src/nautilus-information-panel.h +++ b/src/nautilus-information-panel.h @@ -30,8 +30,6 @@ #include <eel/eel-background-box.h> -#include "nautilus-view-frame.h" - #define NAUTILUS_TYPE_INFORMATION_PANEL \ (nautilus_information_panel_get_type ()) #define NAUTILUS_INFORMATION_PANEL(obj) \ @@ -60,10 +58,10 @@ typedef struct { GType nautilus_information_panel_get_type (void); NautilusInformationPanel *nautilus_information_panel_new (void); void nautilus_information_panel_set_uri (NautilusInformationPanel *information_panel, - const char *new_uri, - const char *initial_title); + const char *new_uri, + const char *initial_title); void nautilus_information_panel_set_title (NautilusInformationPanel *information_panel, - const char *new_title); + const char *new_title); void nautilus_information_panel_setup_width (NautilusInformationPanel *information_panel); #endif /* NAUTILUS_INFORMATION_PANEL_H */ diff --git a/src/nautilus-location-bar.c b/src/nautilus-location-bar.c index 54ee30457..eb63e1f6a 100644 --- a/src/nautilus-location-bar.c +++ b/src/nautilus-location-bar.c @@ -49,7 +49,7 @@ #include <libgnomeui/gnome-uidefs.h> #include <libgnomevfs/gnome-vfs.h> #include <libnautilus-private/nautilus-icon-dnd.h> -#include <libnautilus/nautilus-clipboard.h> +#include <libnautilus-private/nautilus-clipboard.h> #include <stdio.h> #include <string.h> @@ -434,10 +434,12 @@ nautilus_location_bar_new (NautilusNavigationWindow *window) location_bar = NAUTILUS_LOCATION_BAR (bar); /* Clipboard */ +#ifdef BONOBO_DONE nautilus_clipboard_set_up_editable (GTK_EDITABLE (location_bar->details->entry), nautilus_window_get_ui_container (NAUTILUS_WINDOW (window)), TRUE); +#endif return bar; } diff --git a/src/nautilus-location-dialog.c b/src/nautilus-location-dialog.c index 0b3b8cb80..843832234 100644 --- a/src/nautilus-location-dialog.c +++ b/src/nautilus-location-dialog.c @@ -197,12 +197,14 @@ nautilus_location_dialog_new (NautilusWindow *window) location = nautilus_window_get_location (window); - formatted_location = eel_format_uri_for_display (location); - nautilus_entry_set_text (NAUTILUS_ENTRY (NAUTILUS_LOCATION_DIALOG (dialog)->details->entry), formatted_location); - gtk_editable_select_region (GTK_EDITABLE (NAUTILUS_LOCATION_DIALOG (dialog)->details->entry), 0, -1); - gtk_editable_set_position (GTK_EDITABLE (NAUTILUS_LOCATION_DIALOG (dialog)->details->entry), -1); - g_free (formatted_location); - g_free (location); + if (location != NULL) { + formatted_location = eel_format_uri_for_display (location); + nautilus_entry_set_text (NAUTILUS_ENTRY (NAUTILUS_LOCATION_DIALOG (dialog)->details->entry), formatted_location); + gtk_editable_select_region (GTK_EDITABLE (NAUTILUS_LOCATION_DIALOG (dialog)->details->entry), 0, -1); + gtk_editable_set_position (GTK_EDITABLE (NAUTILUS_LOCATION_DIALOG (dialog)->details->entry), -1); + g_free (formatted_location); + g_free (location); + } return dialog; } diff --git a/src/nautilus-location-entry.c b/src/nautilus-location-entry.c index b9b344942..a2c8f504b 100644 --- a/src/nautilus-location-entry.c +++ b/src/nautilus-location-entry.c @@ -49,7 +49,7 @@ #include <libnautilus-private/nautilus-file-utilities.h> #include <libnautilus-private/nautilus-entry.h> #include <libnautilus-private/nautilus-icon-dnd.h> -#include <libnautilus/nautilus-clipboard.h> +#include <libnautilus-private/nautilus-clipboard.h> #include <stdio.h> #include <string.h> diff --git a/src/nautilus-navigation-window-menus.c b/src/nautilus-navigation-window-menus.c index d225c1f46..55d8a24c1 100644 --- a/src/nautilus-navigation-window-menus.c +++ b/src/nautilus-navigation-window-menus.c @@ -62,7 +62,7 @@ #include <libnautilus-private/nautilus-file-utilities.h> #include <libnautilus-private/nautilus-icon-factory.h> #include <libnautilus-private/nautilus-undo-manager.h> -#include <libnautilus/nautilus-bonobo-ui.h> +#include <libnautilus-private/nautilus-bonobo-ui.h> #ifdef ENABLE_PROFILER #include "nautilus-profiler.h" @@ -70,7 +70,7 @@ #define STATIC_BOOKMARKS_FILE_NAME "static_bookmarks.xml" -/* Private menu definitions; others are in <libnautilus/nautilus-bonobo-ui.h>. +/* Private menu definitions; others are in <libnautilus-private/nautilus-bonobo-ui.h>. * These are not part of the published set, either because they are * development-only or because we expect to change them and * don't want other code relying on their existence. @@ -299,71 +299,6 @@ bookmarks_menu_edit_bookmarks_callback (BonoboUIComponent *component, edit_bookmarks (NAUTILUS_NAVIGATION_WINDOW (user_data)); } -#ifdef WEB_NAVIGATION_ENABLED -static char * -get_static_bookmarks_file_path (void) -{ - char *update_xml_file_path, *built_in_xml_file_path; - char *update_uri, *built_in_uri; - char *user_directory_path; - gboolean update_exists, built_in_exists; - GnomeVFSFileInfo *update_info, *built_in_info; - char *result; - - /* see if there is a static bookmarks file in the updates directory and get its mod-date */ - user_directory_path = nautilus_get_user_directory (); - update_xml_file_path = g_strdup_printf ("%s/updates/%s", user_directory_path, STATIC_BOOKMARKS_FILE_NAME); - update_exists = g_file_test (update_xml_file_path, G_FILE_TEST_EXISTS); - g_free (user_directory_path); - - /* get the mod date of the built-in static bookmarks file */ - built_in_xml_file_path = g_build_filename (NAUTILUS_DATADIR, STATIC_BOOKMARKS_FILE_NAME, NULL); - built_in_exists = g_file_test (built_in_xml_file_path, G_FILE_TEST_EXISTS); - - /* if we only have one file, return its path as the one to use */ - if (built_in_exists && !update_exists) { - g_free (update_xml_file_path); - return built_in_xml_file_path; - } - - if (!built_in_exists && update_exists) { - g_free (built_in_xml_file_path); - return update_xml_file_path; - } - - /* if we have neither file, return NULL */ - if (!built_in_exists && !update_exists) { - g_free (built_in_xml_file_path); - g_free (update_xml_file_path); - return NULL; - } - - /* both files exist, so use the one with the most recent mod-date */ - update_uri = gnome_vfs_get_uri_from_local_path (update_xml_file_path); - update_info = gnome_vfs_file_info_new (); - gnome_vfs_get_file_info (update_uri, update_info, GNOME_VFS_FILE_INFO_FOLLOW_LINKS); - g_free (update_uri); - - built_in_uri = gnome_vfs_get_uri_from_local_path (built_in_xml_file_path); - built_in_info = gnome_vfs_file_info_new (); - gnome_vfs_get_file_info (built_in_uri, built_in_info, GNOME_VFS_FILE_INFO_FOLLOW_LINKS); - g_free (built_in_uri); - - /* see which is most recent */ - if (update_info->mtime <= built_in_info->mtime) { - result = built_in_xml_file_path; - g_free (update_xml_file_path); - } else { - result = update_xml_file_path; - g_free (built_in_xml_file_path); - } - - gnome_vfs_file_info_unref (update_info); - gnome_vfs_file_info_unref (built_in_info); - - return result; -} -#endif static void append_separator (NautilusNavigationWindow *window, const char *path) @@ -502,36 +437,6 @@ create_menu_item_from_node (NautilusNavigationWindow *window, nautilus_window_ui_thaw (NAUTILUS_WINDOW (window)); } -#ifdef WEB_NAVIGATION_ENABLED -static void -append_static_bookmarks (NautilusWindow *window, const char *menu_path) -{ - xmlDocPtr doc; - xmlNodePtr node; - char *file_path; - int index; - - /* Walk through XML tree creating bookmarks, folders, and separators. */ - file_path = get_static_bookmarks_file_path (); - - if (file_path == NULL) { - return; - } - - doc = xmlParseFile (file_path); - g_free (file_path); - - node = eel_xml_get_root_children (doc); - index = 0; - - for (index = 0; node != NULL; node = node->next) { - create_menu_item_from_node (window, node, menu_path, &index); - } - - xmlFreeDoc(doc); -} -#endif - static GtkWindow * get_or_create_bookmarks_window (GObject *undo_manager_source) { @@ -582,12 +487,6 @@ edit_bookmarks (NautilusNavigationWindow *window) gtk_window_present (dialog); } -void -nautilus_window_bookmarks_preference_changed_callback (gpointer user_data) -{ - refresh_bookmarks_menu (NAUTILUS_NAVIGATION_WINDOW (user_data)); -} - static void refresh_bookmarks_menu (NautilusNavigationWindow *window) { @@ -602,12 +501,6 @@ refresh_bookmarks_menu (NautilusNavigationWindow *window) nautilus_navigation_window_remove_bookmarks_menu_items (window); -#ifdef WEB_NAVIGATION_ENABLED - if (!eel_preferences_get_boolean (NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS)) { - append_static_bookmarks (window, MENU_PATH_BUILT_IN_BOOKMARKS_PLACEHOLDER); - } -#endif - append_dynamic_bookmarks (window); bonobo_ui_component_thaw (NAUTILUS_WINDOW (window)->details->shell_ui, NULL); @@ -628,14 +521,6 @@ nautilus_navigation_window_initialize_bookmarks_menu (NautilusNavigationWindow * /* Construct the initial set of bookmarks. */ refresh_bookmarks_menu (window); - /* Recreate static & dynamic part of menu if preference about - * showing static bookmarks changes. - */ - eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_HIDE_BUILT_IN_BOOKMARKS, - nautilus_window_bookmarks_preference_changed_callback, - window, - G_OBJECT (window)); - /* Recreate dynamic part of menu if bookmark list changes */ g_signal_connect_object (get_bookmark_list (), "contents_changed", G_CALLBACK (schedule_refresh_bookmarks_menu), diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c index 7d3fc26b3..c3d93b888 100644 --- a/src/nautilus-navigation-window.c +++ b/src/nautilus-navigation-window.c @@ -33,7 +33,6 @@ #include "nautilus-application.h" #include "nautilus-bookmarks-window.h" -#include "nautilus-information-panel.h" #include "nautilus-main.h" #include "nautilus-signaller.h" #include "nautilus-switchable-navigation-bar.h" @@ -76,11 +75,13 @@ #include <libnautilus-private/nautilus-metadata.h> #include <libnautilus-private/nautilus-mime-actions.h> #include <libnautilus-private/nautilus-program-choosing.h> -#include <libnautilus-private/nautilus-sidebar-functions.h> +#include <libnautilus-private/nautilus-sidebar.h> +#include <libnautilus-private/nautilus-sidebar-factory.h> #include <libnautilus-private/nautilus-theme.h> -#include <libnautilus/nautilus-bonobo-ui.h> -#include <libnautilus/nautilus-clipboard.h> -#include <libnautilus/nautilus-undo.h> +#include <libnautilus-private/nautilus-view-factory.h> +#include <libnautilus-private/nautilus-bonobo-ui.h> +#include <libnautilus-private/nautilus-clipboard.h> +#include <libnautilus-private/nautilus-undo.h> #include <math.h> #include <sys/time.h> @@ -114,12 +115,10 @@ enum { static int side_pane_width_auto_value = SIDE_PANE_MINIMUM_WIDTH; -static void add_sidebar_panels (NautilusNavigationWindow *window); -static void load_view_as_menu (NautilusWindow *window); -static void side_panel_view_loaded_callback (NautilusViewFrame *view, - gpointer user_data); -static void side_panel_view_failed_callback (NautilusViewFrame *view, - gpointer user_data); +static void add_sidebar_panels (NautilusNavigationWindow *window); +static void load_view_as_menu (NautilusWindow *window); +static void side_panel_image_changed_callback (NautilusSidebar *side_panel, + gpointer callback_data); GNOME_CLASS_BOILERPLATE (NautilusNavigationWindow, nautilus_navigation_window, NautilusWindow, NAUTILUS_TYPE_WINDOW) @@ -153,6 +152,8 @@ file_menu_new_window_callback (BonoboUIComponent *component, nautilus_window_open_location (window, uri, FALSE); } +#ifdef BONOBO_DONE +/* see below */ static void go_to_callback (GtkWidget *widget, const char *uri, @@ -162,6 +163,7 @@ go_to_callback (GtkWidget *widget, nautilus_window_go_to (NAUTILUS_WINDOW (window), uri); } +#endif static void navigation_bar_location_changed_callback (GtkWidget *widget, @@ -255,67 +257,41 @@ setup_side_pane_width (NautilusNavigationWindow *window) } static void -side_panel_set_open (GtkWidget *view, - gboolean open) -{ - CORBA_Environment ev; - Bonobo_PropertyBag property_bag; - Bonobo_Control control; - - if (!view || !NAUTILUS_IS_VIEW_FRAME (view)) { - return; - } - - control = nautilus_view_frame_get_control (NAUTILUS_VIEW_FRAME (view)); - - if (control != CORBA_OBJECT_NIL) { - CORBA_exception_init (&ev); - property_bag = Bonobo_Control_getProperties (control, &ev); - if (!BONOBO_EX (&ev) && property_bag != CORBA_OBJECT_NIL) { - /* For some reason this was implemented as 'close' - * before, but open seems more natural */ - bonobo_property_bag_client_set_value_gboolean - (property_bag, "close", !open, &ev); - bonobo_object_release_unref (property_bag, NULL); - } - } -} - -static void set_current_side_panel (NautilusNavigationWindow *window, - GtkWidget *panel) + NautilusSidebar *panel) { if (window->details->current_side_panel) { - side_panel_set_open (window->details->current_side_panel, - FALSE); + nautilus_sidebar_is_visible_changed (window->details->current_side_panel, + FALSE); eel_remove_weak_pointer (&window->details->current_side_panel); } - side_panel_set_open (panel, TRUE); + if (panel != NULL) { + nautilus_sidebar_is_visible_changed (panel, TRUE); + } window->details->current_side_panel = panel; eel_add_weak_pointer (&window->details->current_side_panel); } static void side_pane_switch_page_callback (NautilusSidePane *side_pane, - GtkWidget *panel, + GtkWidget *widget, NautilusNavigationWindow *window) { - const char *view_iid; + const char *id; + NautilusSidebar *sidebar; - set_current_side_panel (window, panel); + sidebar = NAUTILUS_SIDEBAR (widget); - if (NAUTILUS_IS_VIEW_FRAME (panel)) { - view_iid = nautilus_view_frame_get_view_iid (NAUTILUS_VIEW_FRAME (panel)); - if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW)) { - eel_preferences_set (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW, - view_iid); - } + if (sidebar == NULL) { + return; + } - } else { - if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW)) { - eel_preferences_set (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW, ""); - } + set_current_side_panel (window, sidebar); + + id = nautilus_sidebar_get_sidebar_id (sidebar); + if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW)) { + eel_preferences_set (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW, id); } } @@ -334,22 +310,10 @@ nautilus_navigation_window_set_up_sidebar (NautilusNavigationWindow *window) G_CALLBACK (side_pane_size_allocate_callback), window); - window->information_panel = nautilus_information_panel_new (); - - if (NAUTILUS_WINDOW (window)->details->location != NULL && - NAUTILUS_WINDOW (window)->details->title != NULL) { - nautilus_information_panel_set_uri (window->information_panel, - NAUTILUS_WINDOW (window)->details->location, - NAUTILUS_WINDOW (window)->details->title); - } - +#ifdef BONOBO_DONE g_signal_connect_object (window->information_panel, "location_changed", G_CALLBACK (go_to_callback), window, 0); - - /* Set up the sidebar panels. */ - nautilus_side_pane_add_panel (NAUTILUS_SIDE_PANE (window->sidebar), - GTK_WIDGET (window->information_panel), - _("Information")); +#endif add_sidebar_panels (window); @@ -363,8 +327,6 @@ nautilus_navigation_window_set_up_sidebar (NautilusNavigationWindow *window) G_CALLBACK (side_pane_switch_page_callback), window); - gtk_widget_show (GTK_WIDGET (window->information_panel)); - gtk_widget_show (GTK_WIDGET (window->sidebar)); } @@ -378,7 +340,6 @@ nautilus_navigation_window_tear_down_sidebar (NautilusNavigationWindow *window) nautilus_navigation_window_set_sidebar_panels (window, NULL); gtk_widget_destroy (GTK_WIDGET (window->sidebar)); window->sidebar = NULL; - window->information_panel = NULL; } static void @@ -404,7 +365,7 @@ nautilus_navigation_window_destroy (GtkObject *object) window = NAUTILUS_NAVIGATION_WINDOW (object); window->sidebar = NULL; - eel_g_object_list_free (window->sidebar_panels); + g_list_foreach (window->sidebar_panels, (GFunc)g_object_unref, NULL); window->sidebar_panels = NULL; window->view_as_option_menu = NULL; @@ -443,47 +404,60 @@ nautilus_navigation_window_finalize (GObject *object) void nautilus_navigation_window_add_sidebar_panel (NautilusNavigationWindow *window, - NautilusViewFrame *sidebar_panel) + NautilusSidebar *sidebar_panel) { + const char *sidebar_id; char *label; - const char *view_iid; - char *default_iid; + char *default_id; + GdkPixbuf *icon; g_return_if_fail (NAUTILUS_IS_NAVIGATION_WINDOW (window)); - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (sidebar_panel)); + g_return_if_fail (NAUTILUS_IS_SIDEBAR (sidebar_panel)); g_return_if_fail (NAUTILUS_IS_SIDE_PANE (window->sidebar)); g_return_if_fail (g_list_find (window->sidebar_panels, sidebar_panel) == NULL); - label = nautilus_view_frame_get_label (sidebar_panel); - + label = nautilus_sidebar_get_tab_label (sidebar_panel); nautilus_side_pane_add_panel (window->sidebar, GTK_WIDGET (sidebar_panel), label); g_free (label); + icon = nautilus_sidebar_get_tab_icon (sidebar_panel); + nautilus_side_pane_set_panel_image (NAUTILUS_NAVIGATION_WINDOW (window)->sidebar, + GTK_WIDGET (sidebar_panel), + icon); + g_object_unref (icon); + + g_signal_connect (sidebar_panel, "tab_icon_changed", + (GCallback)side_panel_image_changed_callback, window); + + g_object_ref (sidebar_panel); window->sidebar_panels = g_list_prepend (window->sidebar_panels, sidebar_panel); - view_iid = nautilus_view_frame_get_view_iid (sidebar_panel); - default_iid = eel_preferences_get (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW); - if (view_iid && default_iid && !strcmp (view_iid, default_iid)) { + /* Show if default */ + sidebar_id = nautilus_sidebar_get_sidebar_id (sidebar_panel); + default_id = eel_preferences_get (NAUTILUS_PREFERENCES_SIDE_PANE_VIEW); + if (sidebar_id && default_id && !strcmp (sidebar_id, default_id)) { nautilus_side_pane_show_panel (window->sidebar, GTK_WIDGET (sidebar_panel)); } - - g_free (default_iid); + g_free (default_id); } void -nautilus_navigation_window_remove_sidebar_panel (NautilusNavigationWindow *window, NautilusViewFrame *sidebar_panel) +nautilus_navigation_window_remove_sidebar_panel (NautilusNavigationWindow *window, + NautilusSidebar *sidebar_panel) { g_return_if_fail (NAUTILUS_IS_NAVIGATION_WINDOW (window)); - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (sidebar_panel)); + g_return_if_fail (NAUTILUS_IS_SIDEBAR (sidebar_panel)); if (g_list_find (window->sidebar_panels, sidebar_panel) == NULL) { return; } + + g_signal_handlers_disconnect_by_func (sidebar_panel, side_panel_image_changed_callback, window); nautilus_side_pane_remove_panel (window->sidebar, GTK_WIDGET (sidebar_panel)); @@ -529,11 +503,7 @@ nautilus_navigation_window_go_home (NautilusNavigationWindow *window) nautilus_navigation_window_set_search_mode (window, FALSE); -#ifdef WEB_NAVIGATION_ENABLED - home_uri = eel_preferences_get (NAUTILUS_PREFERENCES_HOME_URI); -#else home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ()); -#endif g_assert (home_uri != NULL); nautilus_window_go_to (NAUTILUS_WINDOW (window), home_uri); @@ -613,13 +583,17 @@ view_as_menu_switch_views_callback (GtkWidget *widget, gpointer data) static GtkWidget * create_view_as_menu_item (NautilusWindow *window, - NautilusViewIdentifier *identifier, + const char *identifier, guint index) { GtkWidget *menu_item; char *menu_label; + const NautilusViewInfo *info; + + info = nautilus_view_factory_lookup (identifier); - menu_label = g_strdup (_(identifier->view_as_label)); + /* BONOBOTODO: nicer way for the labels */ + menu_label = g_strdup_printf (_("View as %s"), _(info->label)); menu_item = gtk_menu_item_new_with_mnemonic (menu_label); g_free (menu_label); @@ -655,18 +629,17 @@ load_view_as_menu (NautilusWindow *window) menu_item = create_view_as_menu_item (window, node->data, index); gtk_menu_shell_append (GTK_MENU_SHELL (new_menu), menu_item); - if (nautilus_window_content_view_matches_iid (NAUTILUS_WINDOW (window), ((NautilusViewIdentifier *)node->data)->iid)) { + if (nautilus_window_content_view_matches_iid (NAUTILUS_WINDOW (window), (char *)node->data)) { selected_index = index; } } if (selected_index == -1) { - NautilusViewIdentifier *id; + const char *id; /* We're using an extra viewer, add a menu item for it */ id = nautilus_window_get_content_view_id (window); menu_item = create_view_as_menu_item (window, id, index); - nautilus_view_identifier_free (id); gtk_menu_shell_append (GTK_MENU_SHELL (new_menu), menu_item); selected_index = index; @@ -698,17 +671,13 @@ real_set_title (NautilusWindow *window, const char *title) EEL_CALL_PARENT (NAUTILUS_WINDOW_CLASS, set_title, (window, title)); + full_title = g_strdup_printf (_("File Browser: %s"), title); window_title = eel_str_middle_truncate (full_title, MAX_TITLE_LENGTH); gtk_window_set_title (GTK_WINDOW (window), window_title); g_free (window_title); g_free (full_title); - - if (NAUTILUS_NAVIGATION_WINDOW (window)->information_panel) { - nautilus_information_panel_set_title - (NAUTILUS_NAVIGATION_WINDOW (window)->information_panel, title); - } } static void @@ -840,7 +809,7 @@ real_merge_menus_2 (NautilusWindow *nautilus_window) } static void -zoom_level_changed_callback (NautilusViewFrame *view, +zoom_level_changed_callback (NautilusView *view, NautilusNavigationWindow *window) { g_assert (NAUTILUS_IS_WINDOW (window)); @@ -849,11 +818,11 @@ zoom_level_changed_callback (NautilusViewFrame *view, * a zooming operation. */ nautilus_zoom_control_set_zoom_level (NAUTILUS_ZOOM_CONTROL (window->zoom_control), - nautilus_view_frame_get_zoom_level (view)); + nautilus_view_get_zoom_level (view)); } static void -zoom_parameters_changed_callback (NautilusViewFrame *view, +zoom_parameters_changed_callback (NautilusView *view, NautilusNavigationWindow *window) { g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window)); @@ -881,11 +850,11 @@ zoom_parameters_changed_callback (NautilusViewFrame *view, nautilus_zoom_control_set_parameters (NAUTILUS_ZOOM_CONTROL (window->zoom_control), - nautilus_view_frame_get_min_zoom_level (view), - nautilus_view_frame_get_max_zoom_level (view), - nautilus_view_frame_get_has_min_zoom_level (view), - nautilus_view_frame_get_has_max_zoom_level (view), - nautilus_view_frame_get_preferred_zoom_levels (view)); + nautilus_view_get_min_zoom_level (view), + nautilus_view_get_max_zoom_level (view), + nautilus_view_get_has_min_zoom_level (view), + nautilus_view_get_has_max_zoom_level (view), + nautilus_view_get_preferred_zoom_levels (view)); /* "zoom_parameters_changed" always implies "zoom_level_changed", * but you won't get both signals, so we need to pass it down. @@ -894,7 +863,7 @@ zoom_parameters_changed_callback (NautilusViewFrame *view, } static void -connect_view (NautilusNavigationWindow *window, NautilusViewFrame *view) +connect_view (NautilusNavigationWindow *window, NautilusView *view) { g_signal_connect (view, "zoom_parameters_changed", G_CALLBACK (zoom_parameters_changed_callback), @@ -905,7 +874,7 @@ connect_view (NautilusNavigationWindow *window, NautilusViewFrame *view) } static void -disconnect_view (NautilusNavigationWindow *window, NautilusViewFrame *view) +disconnect_view (NautilusNavigationWindow *window, NautilusView *view) { if (!view) { return; @@ -923,7 +892,7 @@ disconnect_view (NautilusNavigationWindow *window, NautilusViewFrame *view) static void real_set_content_view_widget (NautilusWindow *nautilus_window, - NautilusViewFrame *new_view) + NautilusView *new_view) { NautilusNavigationWindow *window; @@ -946,7 +915,7 @@ real_set_content_view_widget (NautilusWindow *nautilus_window, NAUTILUS_HORIZONTAL_SPLITTER (window->details->content_paned), GTK_WIDGET (new_view)); - if (new_view != NULL && nautilus_view_frame_get_is_zoomable (new_view)) { + if (new_view != NULL && nautilus_view_get_is_zoomable (new_view)) { gtk_widget_show (window->zoom_control); } else { gtk_widget_hide (window->zoom_control); @@ -1005,174 +974,20 @@ nautilus_navigation_window_clear_back_list (NautilusNavigationWindow *window) window->back_list = NULL; } -static int -compare_view_identifier_with_iid (gconstpointer passed_view_identifier, - gconstpointer passed_iid) -{ - return strcmp (((NautilusViewIdentifier *) passed_view_identifier)->iid, - (char *) passed_iid); -} - static void -disconnect_and_destroy_sidebar_panel (NautilusNavigationWindow *window, - NautilusViewFrame *view) -{ - g_object_ref (view); - - g_signal_handlers_disconnect_by_func - (view, - G_CALLBACK (side_panel_view_failed_callback), - window); - g_signal_handlers_disconnect_by_func - (view, - G_CALLBACK (side_panel_view_loaded_callback), - window); - - nautilus_window_disconnect_extra_view (NAUTILUS_WINDOW (window), view); - nautilus_navigation_window_remove_sidebar_panel (window, view); - gtk_object_destroy (GTK_OBJECT (view)); - g_object_unref (view); -} - -static void -set_side_panel_image (NautilusWindow *window, - NautilusViewFrame *side_panel, - const char *image_name) -{ - GdkPixbuf *pixbuf; - char *image_path; - - pixbuf = NULL; - - if (image_name && image_name[0]) { - image_path = nautilus_theme_get_image_path (image_name); - if (image_path) { - pixbuf = gdk_pixbuf_new_from_file (image_path, NULL); - g_free (image_path); - } - } - - nautilus_side_pane_set_panel_image (NAUTILUS_NAVIGATION_WINDOW (window)->sidebar, - GTK_WIDGET (side_panel), - pixbuf); - - if (pixbuf) { - g_object_unref (pixbuf); - } -} - -static void -side_panel_image_changed_callback (BonoboListener *listener, - const char *event_name, - const CORBA_any *arg, - CORBA_Environment *ev, +side_panel_image_changed_callback (NautilusSidebar *side_panel, gpointer callback_data) { - NautilusViewFrame *side_panel; NautilusWindow *window; + GdkPixbuf *icon; - side_panel = NAUTILUS_VIEW_FRAME (callback_data); - window = NAUTILUS_WINDOW (g_object_get_data (G_OBJECT (side_panel), - "nautilus-window")); - - set_side_panel_image (window, side_panel, BONOBO_ARG_GET_STRING (arg)); -} - -static void -report_side_panel_failure_to_user (NautilusWindow *window, NautilusViewFrame *view_frame) -{ - char *message; - char *detail; - char *label; - - label = nautilus_window_get_view_frame_label (view_frame); - - if (label == NULL) { - message = g_strdup - (_("One of the side panels encountered an error and can't continue.")); - detail = _("Unfortunately I couldn't tell which one."); - } else { - message = g_strdup_printf - (_("The %s side panel encountered an error and can't continue."), label); - detail = _("If this keeps happening, you might want to turn this panel off."); - } - - eel_show_error_dialog (message, detail, _("Side Panel Failed"), GTK_WINDOW (window)); - - g_free (label); - g_free (message); -} - -static void -side_panel_view_failed_callback (NautilusViewFrame *view, - gpointer user_data) -{ - NautilusWindow *window; - const char *current_iid; - - g_warning ("A view failed. The UI will handle this with a dialog but this should be debugged."); - - window = NAUTILUS_WINDOW (user_data); - - report_side_panel_failure_to_user (window, view); - current_iid = nautilus_view_frame_get_view_iid (view); - disconnect_and_destroy_sidebar_panel (NAUTILUS_NAVIGATION_WINDOW (window), view); -} - -static void -connect_side_panel (NautilusWindow *window, - NautilusViewFrame *side_panel) -{ - Bonobo_Control control; - Bonobo_PropertyBag property_bag; - CORBA_Environment ev; - char *image_name; - - g_object_set_data (G_OBJECT (side_panel), - "nautilus-window", - window); - - control = nautilus_view_frame_get_control (side_panel); - - g_signal_connect_object (side_panel, - "failed", - G_CALLBACK (side_panel_view_failed_callback), - window, 0); + window = NAUTILUS_WINDOW (callback_data); - if (control != CORBA_OBJECT_NIL) { - CORBA_exception_init (&ev); - property_bag = Bonobo_Control_getProperties (control, &ev); - if (property_bag != CORBA_OBJECT_NIL) { - bonobo_event_source_client_add_listener - (property_bag, - side_panel_image_changed_callback, - "Bonobo/Property:change:tab_image", - NULL, - side_panel); - - /* Set the initial tab image */ - image_name = bonobo_property_bag_client_get_value_string - (property_bag, - "tab_image", - NULL); - set_side_panel_image (window, side_panel, image_name); - g_free (image_name); - - bonobo_object_release_unref (property_bag, NULL); - } - CORBA_exception_free (&ev); - } -} - -static void -side_panel_view_loaded_callback (NautilusViewFrame *view, - gpointer user_data) -{ - NautilusWindow *window; - - window = NAUTILUS_WINDOW (user_data); - - connect_side_panel (window, view); + icon = nautilus_sidebar_get_tab_icon (side_panel); + nautilus_side_pane_set_panel_image (NAUTILUS_NAVIGATION_WINDOW (window)->sidebar, + GTK_WIDGET (side_panel), + icon); + g_object_unref (icon); } void @@ -1181,9 +996,8 @@ nautilus_navigation_window_set_sidebar_panels (NautilusNavigationWindow *window, { GList *identifier_list; GList *node, *next, *found_node; - NautilusViewFrame *sidebar_panel; - NautilusViewIdentifier *identifier; - const char *current_iid; + NautilusSidebar *sidebar_panel; + char *identifier; g_return_if_fail (NAUTILUS_IS_WINDOW (window)); @@ -1194,22 +1008,16 @@ nautilus_navigation_window_set_sidebar_panels (NautilusNavigationWindow *window, for (node = window->sidebar_panels; node != NULL; node = next) { next = node->next; - sidebar_panel = NAUTILUS_VIEW_FRAME (node->data); + sidebar_panel = NAUTILUS_SIDEBAR (node->data); found_node = g_list_find_custom (identifier_list, - (char *) nautilus_view_frame_get_view_iid (sidebar_panel), - compare_view_identifier_with_iid); + (char *) nautilus_sidebar_get_sidebar_id (sidebar_panel), + (GCompareFunc)eel_strcmp); if (found_node == NULL) { - current_iid = nautilus_view_frame_get_view_iid (sidebar_panel); - disconnect_and_destroy_sidebar_panel (window, sidebar_panel); + nautilus_navigation_window_remove_sidebar_panel (window, + sidebar_panel); } else { - identifier = (NautilusViewIdentifier *) found_node->data; - - /* Right panel, make sure it has the right name. */ - /* FIXME: Is this set_label necessary? Shouldn't it already - * have the right label here? - */ - nautilus_view_frame_set_label (sidebar_panel, identifier->name); + identifier = (char *) found_node->data; /* Since this was found, there's no need to add it in the loop below. */ identifier_list = g_list_remove_link (identifier_list, found_node); @@ -1221,33 +1029,16 @@ nautilus_navigation_window_set_sidebar_panels (NautilusNavigationWindow *window, for (node = identifier_list; node != NULL; node = node->next) { g_assert (node->data != NULL); - identifier = (NautilusViewIdentifier *) node->data; + identifier = (char *) node->data; /* Create and load the panel. */ - sidebar_panel = nautilus_view_frame_new (NAUTILUS_WINDOW (window)->details->ui_container, - NAUTILUS_WINDOW (window)->application->undo_manager, - NAUTILUS_WINDOW_GET_CLASS (window)->window_type); - - eel_accessibility_set_name (sidebar_panel, _("Side Pane")); - eel_accessibility_set_description - (sidebar_panel, _("Contains a side pane view")); + sidebar_panel = nautilus_sidebar_factory_create (identifier, + NAUTILUS_WINDOW_INFO (window)); - - nautilus_view_frame_set_label (sidebar_panel, identifier->name); - nautilus_window_connect_extra_view (NAUTILUS_WINDOW (window), - sidebar_panel, - identifier); - g_signal_connect_object (sidebar_panel, - "view_loaded", - G_CALLBACK (side_panel_view_loaded_callback), - G_OBJECT (window), 0); - - nautilus_view_frame_load_view (sidebar_panel, identifier->iid); - - connect_side_panel (NAUTILUS_WINDOW (window), sidebar_panel); + nautilus_navigation_window_add_sidebar_panel (window, + sidebar_panel); - nautilus_navigation_window_add_sidebar_panel (window, sidebar_panel); - gtk_object_sink (GTK_OBJECT (sidebar_panel)); + g_object_unref (sidebar_panel); } g_list_free (identifier_list); @@ -1263,7 +1054,8 @@ nautilus_navigation_window_set_sidebar_panels (NautilusNavigationWindow *window, static void add_sidebar_panels (NautilusNavigationWindow *window) { - GList *identifier_list; + GList *sidebar_list; + GtkWidget *current; g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window)); @@ -1271,13 +1063,14 @@ add_sidebar_panels (NautilusNavigationWindow *window) return; } - identifier_list = nautilus_sidebar_get_all_sidebar_panel_view_identifiers (); - nautilus_navigation_window_set_sidebar_panels (window, identifier_list); - nautilus_view_identifier_list_free (identifier_list); - + sidebar_list = nautilus_sidebar_factory_enumerate_sidebars (); + nautilus_navigation_window_set_sidebar_panels (window, sidebar_list); + eel_g_list_free_deep (sidebar_list); + + current = nautilus_side_pane_get_current_panel (window->sidebar); set_current_side_panel (window, - nautilus_side_pane_get_current_panel (window->sidebar)); + NAUTILUS_SIDEBAR (current)); } static void @@ -1480,22 +1273,23 @@ real_window_close (NautilusWindow *window) } static void -real_get_default_size(NautilusWindow *window, guint *default_width, guint *default_height) +real_get_default_size (NautilusWindow *window, + guint *default_width, guint *default_height) { - if(default_width) { - *default_width = NAUTILUS_NAVIGATION_WINDOW_DEFAULT_WIDTH; + if (default_width) { + *default_width = NAUTILUS_NAVIGATION_WINDOW_DEFAULT_WIDTH; } - if(default_height) { - *default_height = NAUTILUS_NAVIGATION_WINDOW_DEFAULT_HEIGHT; + if (default_height) { + *default_height = NAUTILUS_NAVIGATION_WINDOW_DEFAULT_HEIGHT; } } static void nautilus_navigation_window_class_init (NautilusNavigationWindowClass *class) { - NAUTILUS_WINDOW_CLASS (class)->window_type = Nautilus_WINDOW_NAVIGATION; + NAUTILUS_WINDOW_CLASS (class)->window_type = NAUTILUS_WINDOW_NAVIGATION; G_OBJECT_CLASS (class)->finalize = nautilus_navigation_window_finalize; GTK_OBJECT_CLASS (class)->destroy = nautilus_navigation_window_destroy; diff --git a/src/nautilus-navigation-window.h b/src/nautilus-navigation-window.h index 5888ac28f..e9270c6a1 100644 --- a/src/nautilus-navigation-window.h +++ b/src/nautilus-navigation-window.h @@ -33,9 +33,7 @@ #include <bonobo/bonobo-window.h> #include <eel/eel-glib-extensions.h> #include <libnautilus-private/nautilus-bookmark.h> -#include <libnautilus-private/nautilus-view-identifier.h> -#include "nautilus-applicable-views.h" -#include "nautilus-view-frame.h" +#include <libnautilus-private/nautilus-sidebar.h> #include "nautilus-application.h" #include "nautilus-information-panel.h" #include "nautilus-side-pane.h" @@ -58,7 +56,6 @@ struct _NautilusNavigationWindow { /** UI stuff **/ NautilusSidePane *sidebar; - NautilusInformationPanel *information_panel; GtkWidget *view_as_option_menu; GtkWidget *navigation_bar; @@ -79,40 +76,34 @@ struct _NautilusNavigationWindowClass { NautilusWindowClass parent_spot; }; -GType nautilus_navigation_window_get_type (void); -gboolean nautilus_navigation_window_get_search_mode (NautilusNavigationWindow *window); -void nautilus_navigation_window_set_search_mode (NautilusNavigationWindow *window, - gboolean search_mode); -void nautilus_navigation_window_go_home (NautilusNavigationWindow *window); -void nautilus_navigation_window_allow_back (NautilusNavigationWindow *window, - gboolean allow); -void nautilus_navigation_window_allow_forward (NautilusNavigationWindow *window, - gboolean allow); -void nautilus_navigation_window_clear_back_list (NautilusNavigationWindow *window); -void nautilus_navigation_window_clear_forward_list (NautilusNavigationWindow *window); - -void nautilus_forget_history (void); -void nautilus_bookmarks_exiting (void); - -gint nautilus_navigation_window_get_base_page_index (NautilusNavigationWindow *window); - -void nautilus_navigation_window_hide_location_bar (NautilusNavigationWindow *window, - gboolean save_preference); -void nautilus_navigation_window_show_location_bar (NautilusNavigationWindow *window, - gboolean save_preference); -gboolean nautilus_navigation_window_location_bar_showing (NautilusNavigationWindow *window); - -void nautilus_navigation_window_hide_toolbar (NautilusNavigationWindow *window); -void nautilus_navigation_window_show_toolbar (NautilusNavigationWindow *window); -gboolean nautilus_navigation_window_toolbar_showing (NautilusNavigationWindow *window); - -void nautilus_navigation_window_hide_sidebar (NautilusNavigationWindow *window); -void nautilus_navigation_window_show_sidebar (NautilusNavigationWindow *window); -gboolean nautilus_navigation_window_sidebar_showing (NautilusNavigationWindow *window); - -void nautilus_navigation_window_add_sidebar_panel (NautilusNavigationWindow *window, - NautilusViewFrame *sidebar_panel); -void nautilus_navigation_window_remove_sidebar_panel (NautilusNavigationWindow *window, - NautilusViewFrame *sidebar_panel); +GType nautilus_navigation_window_get_type (void); +gboolean nautilus_navigation_window_get_search_mode (NautilusNavigationWindow *window); +void nautilus_navigation_window_set_search_mode (NautilusNavigationWindow *window, + gboolean search_mode); +void nautilus_navigation_window_go_home (NautilusNavigationWindow *window); +void nautilus_navigation_window_allow_back (NautilusNavigationWindow *window, + gboolean allow); +void nautilus_navigation_window_allow_forward (NautilusNavigationWindow *window, + gboolean allow); +void nautilus_navigation_window_clear_back_list (NautilusNavigationWindow *window); +void nautilus_navigation_window_clear_forward_list (NautilusNavigationWindow *window); +void nautilus_forget_history (void); +void nautilus_bookmarks_exiting (void); +gint nautilus_navigation_window_get_base_page_index (NautilusNavigationWindow *window); +void nautilus_navigation_window_hide_location_bar (NautilusNavigationWindow *window, + gboolean save_preference); +void nautilus_navigation_window_show_location_bar (NautilusNavigationWindow *window, + gboolean save_preference); +gboolean nautilus_navigation_window_location_bar_showing (NautilusNavigationWindow *window); +void nautilus_navigation_window_hide_toolbar (NautilusNavigationWindow *window); +void nautilus_navigation_window_show_toolbar (NautilusNavigationWindow *window); +gboolean nautilus_navigation_window_toolbar_showing (NautilusNavigationWindow *window); +void nautilus_navigation_window_hide_sidebar (NautilusNavigationWindow *window); +void nautilus_navigation_window_show_sidebar (NautilusNavigationWindow *window); +gboolean nautilus_navigation_window_sidebar_showing (NautilusNavigationWindow *window); +void nautilus_navigation_window_add_sidebar_panel (NautilusNavigationWindow *window, + NautilusSidebar *sidebar_panel); +void nautilus_navigation_window_remove_sidebar_panel (NautilusNavigationWindow *window, + NautilusSidebar *sidebar_panel); #endif diff --git a/src/nautilus-shell-interface.idl b/src/nautilus-shell-interface.idl index 9427e59a5..3b4649a92 100644 --- a/src/nautilus-shell-interface.idl +++ b/src/nautilus-shell-interface.idl @@ -4,9 +4,10 @@ #define NAUTILUS_SHELL_INTERFACE_IDL #include <Bonobo.idl> -#include <libnautilus/nautilus-view-component.idl> module Nautilus { + typedef string URI; + typedef sequence<URI> URIList; interface Shell : ::Bonobo::Unknown { void open_windows (in URIList uris, in string geometry, in boolean browser_window); diff --git a/src/nautilus-shell.c b/src/nautilus-shell.c index 1fbbc5e87..1967c7ff7 100644 --- a/src/nautilus-shell.c +++ b/src/nautilus-shell.c @@ -143,11 +143,7 @@ open_window (NautilusShell *shell, const char *uri, const char *geometry, } else { home_uri = NULL; if (uri == NULL) { -#ifdef WEB_NAVIGATION_ENABLED - home_uri = eel_preferences_get (NAUTILUS_PREFERENCES_HOME_URI); -#else home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ()); -#endif uri = home_uri; } diff --git a/src/nautilus-side-pane.h b/src/nautilus-side-pane.h index a4792e59e..9b39fccf8 100644 --- a/src/nautilus-side-pane.h +++ b/src/nautilus-side-pane.h @@ -28,11 +28,11 @@ G_BEGIN_DECLS -#define NAUTILUS_TYPE_SIDEBAR (nautilus_side_pane_get_type ()) -#define NAUTILUS_SIDE_PANE(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_SIDEBAR, NautilusSidePane)) -#define NAUTILUS_SIDE_PANE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_SIDEBAR, NautilusSidePaneClass)) -#define NAUTILUS_IS_SIDE_PANE(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_SIDEBAR)) -#define NAUTILUS_IS_SIDE_PANE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_SIDEBAR)) +#define NAUTILUS_TYPE_SIDE_PANE (nautilus_side_pane_get_type ()) +#define NAUTILUS_SIDE_PANE(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_SIDE_PANE, NautilusSidePane)) +#define NAUTILUS_SIDE_PANE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_SIDE_PANE, NautilusSidePaneClass)) +#define NAUTILUS_IS_SIDE_PANE(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_SIDE_PANE)) +#define NAUTILUS_IS_SIDE_PANE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_SIDE_PANE)) typedef struct _NautilusSidePaneDetails NautilusSidePaneDetails; diff --git a/src/nautilus-sidebar-title.c b/src/nautilus-sidebar-title.c index db4561a2e..b6a997345 100644 --- a/src/nautilus-sidebar-title.c +++ b/src/nautilus-sidebar-title.c @@ -54,6 +54,7 @@ #include <libnautilus-private/nautilus-metadata.h> #include <libnautilus-private/nautilus-search-uri.h> #include <libnautilus-private/nautilus-theme.h> +#include <libnautilus-private/nautilus-sidebar.h> #include <string.h> #include <stdlib.h> @@ -317,40 +318,8 @@ nautilus_sidebar_title_theme_changed (gpointer user_data) static char* get_property_from_component (NautilusSidebarTitle *sidebar_title, const char *property) { - GtkWidget *window; - Bonobo_Control control; - CORBA_Environment ev; - Bonobo_PropertyBag property_bag; - char* icon_name; - - window = gtk_widget_get_ancestor (GTK_WIDGET (sidebar_title), NAUTILUS_TYPE_WINDOW); - - if (window == NULL || NAUTILUS_WINDOW (window)->content_view == NULL) { - return NULL; - } - - - control = nautilus_view_frame_get_control (NAUTILUS_VIEW_FRAME (NAUTILUS_WINDOW (window)->content_view)); - if (control == NULL) { - return NULL; - } - - CORBA_exception_init (&ev); - property_bag = Bonobo_Control_getProperties (control, &ev); - if (BONOBO_EX (&ev)) { - property_bag = CORBA_OBJECT_NIL; - } - CORBA_exception_free (&ev); - - if (property_bag == CORBA_OBJECT_NIL) { - return NULL; - } - - icon_name = bonobo_property_bag_client_get_value_string - (property_bag, property, NULL); - bonobo_object_release_unref (property_bag, NULL); - - return icon_name; + /* BONOBOTODO: way to get icon and summary_text from main view */ + return NULL; } /* set up the icon image */ diff --git a/src/nautilus-simple-search-bar.c b/src/nautilus-simple-search-bar.c index 7efef4218..c927111fd 100644 --- a/src/nautilus-simple-search-bar.c +++ b/src/nautilus-simple-search-bar.c @@ -32,7 +32,7 @@ #include "nautilus-window-private.h" #include <libgnome/gnome-i18n.h> #include <libgnomevfs/gnome-vfs-utils.h> -#include <libnautilus/nautilus-clipboard.h> +#include <libnautilus-private/nautilus-clipboard.h> #include <libnautilus-private/nautilus-entry.h> #include <eel/eel-gtk-extensions.h> #include <eel/eel-gtk-macros.h> @@ -127,10 +127,12 @@ nautilus_simple_search_bar_new (NautilusWindow *window) bar->details->entry = NAUTILUS_ENTRY (nautilus_entry_new ()); nautilus_undo_set_up_nautilus_entry_for_undo (bar->details->entry); nautilus_undo_editable_set_undo_key (GTK_EDITABLE (bar->details->entry), TRUE); +#ifdef BONOBO_DONE nautilus_clipboard_set_up_editable (GTK_EDITABLE (bar->details->entry), nautilus_window_get_ui_container (window), TRUE); +#endif g_signal_connect_object (bar->details->entry, "activate", G_CALLBACK (gtk_widget_activate), bar->details->find_button, G_CONNECT_SWAPPED); diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c index 7a2419f1f..3e63c1e5e 100644 --- a/src/nautilus-spatial-window.c +++ b/src/nautilus-spatial-window.c @@ -75,10 +75,9 @@ #include <libnautilus-private/nautilus-metadata.h> #include <libnautilus-private/nautilus-mime-actions.h> #include <libnautilus-private/nautilus-program-choosing.h> -#include <libnautilus-private/nautilus-sidebar-functions.h> -#include <libnautilus/nautilus-bonobo-ui.h> -#include <libnautilus/nautilus-clipboard.h> -#include <libnautilus/nautilus-undo.h> +#include <libnautilus-private/nautilus-bonobo-ui.h> +#include <libnautilus-private/nautilus-clipboard.h> +#include <libnautilus-private/nautilus-undo.h> #include <math.h> #include <sys/time.h> @@ -219,6 +218,9 @@ nautilus_spatial_window_finalize (GObject *object) if (window->details->location != NULL) { gnome_vfs_uri_unref (window->details->location); } + + g_free (window->details); + window->details = NULL; G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -255,7 +257,12 @@ nautilus_spatial_window_save_scroll_position (NautilusSpatialWindow *window) char *scroll_string; parent = NAUTILUS_WINDOW(window); - scroll_string = nautilus_view_frame_get_first_visible_file (parent->content_view); + + if (parent->content_view == NULL) { + return; + } + + scroll_string = nautilus_view_get_first_visible_file (parent->content_view); nautilus_file_set_metadata (parent->details->viewed_file, NAUTILUS_METADATA_KEY_WINDOW_SCROLL_POSITION, NULL, @@ -267,11 +274,11 @@ void nautilus_spatial_window_save_show_hidden_files_mode (NautilusSpatialWindow *window) { char *show_hidden_file_setting; - Nautilus_ShowHiddenFilesMode mode; + NautilusWindowShowHiddenFilesMode mode; mode = NAUTILUS_WINDOW (window)->details->show_hidden_files_mode; - if (mode != Nautilus_SHOW_HIDDEN_FILES_DEFAULT) { - if (mode == Nautilus_SHOW_HIDDEN_FILES_ENABLE) { + if (mode != NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_DEFAULT) { + if (mode == NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_ENABLE) { show_hidden_file_setting = "1"; } else { show_hidden_file_setting = "0"; @@ -331,6 +338,9 @@ static void real_set_title (NautilusWindow *window, const char *title) { + EEL_CALL_PARENT (NAUTILUS_WINDOW_CLASS, + set_title, (window, title)); + if (title[0] == '\0') { gtk_window_set_title (GTK_WINDOW (window), _("Nautilus")); } else { @@ -376,13 +386,17 @@ real_merge_menus (NautilusWindow *nautilus_window) static void real_set_content_view_widget (NautilusWindow *window, - NautilusViewFrame *new_view) + NautilusView *new_view) { + GtkWidget *widget; + EEL_CALL_PARENT (NAUTILUS_WINDOW_CLASS, set_content_view_widget, (window, new_view)); + + widget = nautilus_view_get_widget (new_view); gtk_container_add (GTK_CONTAINER (NAUTILUS_SPATIAL_WINDOW (window)->details->content_box), - GTK_WIDGET (new_view)); + widget); } static void @@ -661,7 +675,7 @@ nautilus_spatial_window_instance_init (NautilusSpatialWindow *window) static void nautilus_spatial_window_class_init (NautilusSpatialWindowClass *class) { - NAUTILUS_WINDOW_CLASS (class)->window_type = Nautilus_WINDOW_SPATIAL; + NAUTILUS_WINDOW_CLASS (class)->window_type = NAUTILUS_WINDOW_SPATIAL; G_OBJECT_CLASS (class)->finalize = nautilus_spatial_window_finalize; GTK_OBJECT_CLASS (class)->destroy = nautilus_spatial_window_destroy; diff --git a/src/nautilus-view-frame-corba.c b/src/nautilus-view-frame-corba.c deleted file mode 100644 index f2aee1e8a..000000000 --- a/src/nautilus-view-frame-corba.c +++ /dev/null @@ -1,420 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 1999, 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 - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * Nautilus 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., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Authors: Elliot Lee <sopwith@redhat.com> - * Darin Adler <darin@bentspoon.com> - * - */ - -/* nautilus-view-frame-corba.c: CORBA server implementation of the object - representing a data view frame. */ - -#include <config.h> -#include "nautilus-view-frame-private.h" - -#include "nautilus-window.h" -#include <bonobo/bonobo-main.h> -#include <eel/eel-gtk-extensions.h> -#include <eel/eel-gtk-macros.h> -#include <gtk/gtksignal.h> -#include <libnautilus/nautilus-view.h> - -typedef struct { - BonoboObject parent; - NautilusViewFrame *widget; -} NautilusViewFrameCorbaPart; - -typedef struct { - BonoboObjectClass parent; - POA_Nautilus_ViewFrame__epv epv; -} NautilusViewFrameCorbaPartClass; - -typedef struct { - char *from_location; - char *location; - GList *selection; - char *title; - Nautilus_ViewFrame_OpenMode mode; - Nautilus_ViewFrame_OpenFlags flags; -} LocationPlus; - -static void -list_free_deep_callback (gpointer callback_data) -{ - eel_g_list_free_deep (callback_data); -} - -static void -free_location_plus_callback (gpointer callback_data) -{ - LocationPlus *location_plus; - - location_plus = callback_data; - g_free (location_plus->from_location); - g_free (location_plus->location); - eel_g_list_free_deep (location_plus->selection); - g_free (location_plus->title); - g_free (location_plus); -} - -static void -open_location (NautilusViewFrame *view, - gpointer callback_data) -{ - LocationPlus *location_plus; - - location_plus = callback_data; - nautilus_view_frame_open_location - (view, - location_plus->location, - location_plus->mode, - location_plus->flags, - location_plus->selection); -} - -static void -report_location_change (NautilusViewFrame *view, - gpointer callback_data) -{ - LocationPlus *location_plus; - - location_plus = callback_data; - nautilus_view_frame_report_location_change - (view, - location_plus->location, - location_plus->selection, - location_plus->title); -} - -static void -report_redirect (NautilusViewFrame *view, - gpointer callback_data) -{ - LocationPlus *location_plus; - - location_plus = callback_data; - nautilus_view_frame_report_redirect - (view, - location_plus->from_location, - location_plus->location, - location_plus->selection, - location_plus->title); -} - -static void -report_selection_change (NautilusViewFrame *view, - gpointer callback_data) -{ - nautilus_view_frame_report_selection_change (view, callback_data); -} - -static void -report_status (NautilusViewFrame *view, - gpointer callback_data) -{ - nautilus_view_frame_report_status (view, callback_data); -} - -static void -report_load_underway (NautilusViewFrame *view, - gpointer callback_data) -{ - nautilus_view_frame_report_load_underway (view); -} - -static void -report_load_progress (NautilusViewFrame *view, - gpointer callback_data) -{ - nautilus_view_frame_report_load_progress (view, * (float *) callback_data); -} - -static void -report_load_complete (NautilusViewFrame *view, - gpointer callback_data) -{ - nautilus_view_frame_report_load_complete (view); -} - -static void -report_load_failed (NautilusViewFrame *view, - gpointer callback_data) -{ - nautilus_view_frame_report_load_failed (view); -} - -static void -set_show_hidden_files_mode (NautilusViewFrame *view, gpointer callback_data) -{ - nautilus_view_frame_set_show_hidden_files_mode (view, - * (Nautilus_ShowHiddenFilesMode *) callback_data, - TRUE); -} - - -static void -set_title (NautilusViewFrame *view, - gpointer callback_data) -{ - nautilus_view_frame_set_title (view, callback_data); -} - -static void -go_back (NautilusViewFrame *view, - gpointer callback_data) -{ - nautilus_view_frame_go_back (view); -} - -static void -close_window (NautilusViewFrame *view, - gpointer callback_data) -{ - nautilus_view_frame_close_window (view); -} -static void -impl_Nautilus_ViewFrame_open_location (PortableServer_Servant servant, - const CORBA_char *location, - Nautilus_ViewFrame_OpenMode mode, - Nautilus_ViewFrame_OpenFlags flags, - const Nautilus_URIList *selection, - CORBA_Environment *ev) -{ - LocationPlus *location_plus; - - location_plus = g_new0 (LocationPlus, 1); - location_plus->location = g_strdup (location); - location_plus->selection = nautilus_g_list_from_uri_list (selection); - location_plus->mode = mode; - location_plus->flags = flags; - - nautilus_view_frame_queue_incoming_call - (servant, - open_location, - location_plus, - free_location_plus_callback); -} - -static void -impl_Nautilus_ViewFrame_report_location_change (PortableServer_Servant servant, - const CORBA_char *location, - const Nautilus_URIList *selection, - const CORBA_char *title, - CORBA_Environment *ev) -{ - LocationPlus *location_plus; - - location_plus = g_new0 (LocationPlus, 1); - location_plus->location = g_strdup (location); - location_plus->selection = nautilus_g_list_from_uri_list (selection); - location_plus->title = g_strdup (title); - - nautilus_view_frame_queue_incoming_call - (servant, - report_location_change, - location_plus, - free_location_plus_callback); -} - -static void -impl_Nautilus_ViewFrame_report_redirect (PortableServer_Servant servant, - const CORBA_char *from_location, - const CORBA_char *to_location, - const Nautilus_URIList *selection, - const CORBA_char *title, - CORBA_Environment *ev) -{ - LocationPlus *location_plus; - - location_plus = g_new0 (LocationPlus, 1); - location_plus->from_location = g_strdup (from_location); - location_plus->location = g_strdup (to_location); - location_plus->selection = nautilus_g_list_from_uri_list (selection); - location_plus->title = g_strdup (title); - - nautilus_view_frame_queue_incoming_call - (servant, - report_redirect, - location_plus, - free_location_plus_callback); -} - -static void -impl_Nautilus_ViewFrame_report_selection_change (PortableServer_Servant servant, - const Nautilus_URIList *selection, - CORBA_Environment *ev) -{ - nautilus_view_frame_queue_incoming_call - (servant, - report_selection_change, - nautilus_g_list_from_uri_list (selection), - list_free_deep_callback); -} - -static void -impl_Nautilus_ViewFrame_report_status (PortableServer_Servant servant, - const CORBA_char *status, - CORBA_Environment *ev) -{ - nautilus_view_frame_queue_incoming_call - (servant, - report_status, - g_strdup (status), - g_free); -} - -static void -impl_Nautilus_ViewFrame_report_load_underway (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - nautilus_view_frame_queue_incoming_call - (servant, - report_load_underway, - NULL, - NULL); -} - -static void -impl_Nautilus_ViewFrame_report_load_progress (PortableServer_Servant servant, - CORBA_float fraction_done, - CORBA_Environment *ev) -{ - float *copy; - - copy = g_new (float, 1); - *copy = fraction_done; - nautilus_view_frame_queue_incoming_call - (servant, - report_load_progress, - copy, - g_free); -} - -static void -impl_Nautilus_ViewFrame_report_load_complete (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - nautilus_view_frame_queue_incoming_call - (servant, - report_load_complete, - NULL, - NULL); -} - -static void -impl_Nautilus_ViewFrame_report_load_failed (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - nautilus_view_frame_queue_incoming_call - (servant, - report_load_failed, - NULL, - NULL); -} - -static void -impl_Nautilus_ViewFrame_set_show_hidden_files_mode (PortableServer_Servant servant, - const Nautilus_ShowHiddenFilesMode mode, - CORBA_Environment *ev) -{ - nautilus_view_frame_queue_incoming_call - (servant, - set_show_hidden_files_mode, - g_memdup (&mode, sizeof (Nautilus_ShowHiddenFilesMode)), - g_free); -} - -static void -impl_Nautilus_ViewFrame_set_title (PortableServer_Servant servant, - const CORBA_char *title, - CORBA_Environment *ev) -{ - nautilus_view_frame_queue_incoming_call - (servant, - set_title, - g_strdup (title), - g_free); -} - -static void -impl_Nautilus_ViewFrame_go_back (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - nautilus_view_frame_queue_incoming_call - (servant, go_back, NULL, NULL); -} - -static void -impl_Nautilus_ViewFrame_close_window (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - nautilus_view_frame_queue_incoming_call - (servant, close_window, NULL, NULL); -} - -static GType nautilus_view_frame_corba_part_get_type (void); - -BONOBO_CLASS_BOILERPLATE_FULL (NautilusViewFrameCorbaPart, nautilus_view_frame_corba_part, - Nautilus_ViewFrame, - BonoboObject, BONOBO_OBJECT_TYPE) - -#define NAUTILUS_TYPE_VIEW_FRAME_CORBA_PART nautilus_view_frame_corba_part_get_type () -#define NAUTILUS_VIEW_FRAME_CORBA_PART(object) G_TYPE_CHECK_INSTANCE_CAST ((object), NAUTILUS_TYPE_VIEW_FRAME_CORBA_PART, NautilusViewFrameCorbaPart) - -static void -nautilus_view_frame_corba_part_class_init (NautilusViewFrameCorbaPartClass *class) -{ - class->epv.open_location = impl_Nautilus_ViewFrame_open_location; - class->epv.report_location_change = impl_Nautilus_ViewFrame_report_location_change; - class->epv.report_redirect = impl_Nautilus_ViewFrame_report_redirect; - class->epv.report_selection_change = impl_Nautilus_ViewFrame_report_selection_change; - class->epv.report_status = impl_Nautilus_ViewFrame_report_status; - class->epv.report_load_underway = impl_Nautilus_ViewFrame_report_load_underway; - class->epv.report_load_progress = impl_Nautilus_ViewFrame_report_load_progress; - class->epv.report_load_complete = impl_Nautilus_ViewFrame_report_load_complete; - class->epv.report_load_failed = impl_Nautilus_ViewFrame_report_load_failed; - class->epv.set_show_hidden_files_mode = impl_Nautilus_ViewFrame_set_show_hidden_files_mode; - class->epv.set_title = impl_Nautilus_ViewFrame_set_title; - class->epv.go_back = impl_Nautilus_ViewFrame_go_back; - class->epv.close_window = impl_Nautilus_ViewFrame_close_window; -} - -static void -nautilus_view_frame_corba_part_instance_init (NautilusViewFrameCorbaPart *frame) -{ -} - -BonoboObject * -nautilus_view_frame_create_corba_part (NautilusViewFrame *widget) -{ - NautilusViewFrameCorbaPart *part; - - part = NAUTILUS_VIEW_FRAME_CORBA_PART (g_object_new (NAUTILUS_TYPE_VIEW_FRAME_CORBA_PART, NULL)); - part->widget = widget; - return BONOBO_OBJECT (part); -} - -NautilusViewFrame * -nautilus_view_frame_from_servant (PortableServer_Servant servant) -{ - return NAUTILUS_VIEW_FRAME_CORBA_PART (bonobo_object_from_servant (servant))->widget; -} diff --git a/src/nautilus-view-frame-private.h b/src/nautilus-view-frame-private.h deleted file mode 100644 index 914602f56..000000000 --- a/src/nautilus-view-frame-private.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 1999, 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 - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * Nautilus 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., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Authors: Elliot Lee <sopwith@redhat.com> - * Darin Adler <darin@bentspoon.com> - * - */ - -/* nautilus-view-frame-private.h: Internals of the view proxy that are shared between different implementation files */ - -#ifndef NAUTILUS_VIEW_FRAME_PRIVATE_H -#define NAUTILUS_VIEW_FRAME_PRIVATE_H - -#include "nautilus-view-frame.h" - -typedef void (* NautilusViewFrameFunction) (NautilusViewFrame *view_frame, - gpointer callback_data); - -void nautilus_view_frame_queue_incoming_call (PortableServer_Servant servant, - NautilusViewFrameFunction call, - gpointer callback_data, - GDestroyNotify destroy_callback_data); - -BonoboObject *nautilus_view_frame_create_corba_part (NautilusViewFrame *widget); -NautilusViewFrame *nautilus_view_frame_from_servant (PortableServer_Servant servant); - -void nautilus_view_frame_open_location (NautilusViewFrame *view, - const char *location, - Nautilus_ViewFrame_OpenMode mode, - Nautilus_ViewFrame_OpenFlags flags, - GList *selection); -void nautilus_view_frame_report_location_change (NautilusViewFrame *view, - const char *location, - GList *selection, - const char *title); -void nautilus_view_frame_report_redirect (NautilusViewFrame *view, - const char *from_location, - const char *to_location, - GList *selection, - const char *title); -void nautilus_view_frame_report_selection_change (NautilusViewFrame *view, - GList *selection); -void nautilus_view_frame_report_status (NautilusViewFrame *view, - const char *status); -void nautilus_view_frame_report_load_underway (NautilusViewFrame *view); -void nautilus_view_frame_report_load_progress (NautilusViewFrame *view, - double fraction_done); -void nautilus_view_frame_report_load_complete (NautilusViewFrame *view); -void nautilus_view_frame_report_load_failed (NautilusViewFrame *view); -void nautilus_view_frame_set_title (NautilusViewFrame *view, - const char *title); -void nautilus_view_frame_go_back (NautilusViewFrame *view); -void nautilus_view_frame_close_window (NautilusViewFrame *view); -void nautilus_view_frame_quit_nautilus (NautilusViewFrame *view); -void nautilus_view_frame_close_desktop (NautilusViewFrame *view); - -/* Zoomable */ -void nautilus_view_frame_zoom_level_changed (NautilusViewFrame *view, - double zoom_level); -void nautilus_view_frame_zoom_parameters_changed (NautilusViewFrame *view, - double zoom_level, - double min_zoom_level, - double max_zoom_level); - -#endif /* NAUTILUS_VIEW_FRAME_PRIVATE_H */ diff --git a/src/nautilus-view-frame.c b/src/nautilus-view-frame.c deleted file mode 100644 index c53f1a57a..000000000 --- a/src/nautilus-view-frame.c +++ /dev/null @@ -1,1708 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 1999, 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 - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * Nautilus 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., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Authors: Elliot Lee <sopwith@redhat.com> - * Darin Adler <darin@bentspoon.com> - * - */ - -/* nautilus-view-frame.c: Widget and CORBA machinery for hosting a NautilusView */ - -#include <config.h> -#include "nautilus-view-frame.h" - -#include "nautilus-application.h" -#include "nautilus-component-adapter-factory.h" -#include "nautilus-signaller.h" -#include "nautilus-view-frame-private.h" -#include "nautilus-window.h" -#include <bonobo/bonobo-control-frame.h> -#include <bonobo/bonobo-event-source.h> -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-zoomable-frame.h> -#include <bonobo/bonobo-zoomable.h> -#include <eel/eel-gtk-extensions.h> -#include <eel/eel-gtk-macros.h> -#include <eel/eel-marshal.h> -#include <gtk/gtkmain.h> -#include <gtk/gtksignal.h> -#include <libnautilus-private/nautilus-bonobo-extensions.h> -#include <libnautilus-private/nautilus-marshal.h> -#include <libnautilus-private/nautilus-undo-manager.h> -#include <libnautilus/nautilus-idle-queue.h> -#include <libnautilus/nautilus-view.h> -#include <nautilus-marshal.h> -#include <string.h> - -enum { - CHANGE_SELECTION, - CHANGE_STATUS, - FAILED, - GET_HISTORY_LIST, - GO_BACK, - CLOSE_WINDOW, - LOAD_COMPLETE, - LOAD_PROGRESS_CHANGED, - LOAD_UNDERWAY, - OPEN_LOCATION, - REPORT_LOCATION_CHANGE, - REPORT_REDIRECT, - TITLE_CHANGED, - VIEW_LOADED, - ZOOM_LEVEL_CHANGED, - ZOOM_PARAMETERS_CHANGED, - SHOW_HIDDEN_FILES_MODE_CHANGED, - LAST_SIGNAL -}; - -typedef enum { - VIEW_FRAME_EMPTY, - VIEW_FRAME_NO_LOCATION, - VIEW_FRAME_WAITING, - VIEW_FRAME_UNDERWAY, - VIEW_FRAME_LOADED, - VIEW_FRAME_FAILED -} NautilusViewFrameState; - -struct NautilusViewFrameDetails { - NautilusViewFrameState state; - char *title; - char *label; - char *view_iid; - - /* The view frame Bonobo objects. */ - BonoboObject *view_frame; - BonoboEventSource *event_source; - BonoboControlFrame *control_frame; - BonoboZoomableFrame *zoomable_frame; - - /* The view CORBA object. */ - Nautilus_View view; - - /* The positionable CORBA object. */ - Nautilus_ScrollPositionable positionable; - - /* A container to connect our clients to. */ - BonoboUIContainer *ui_container; - NautilusUndoManager *undo_manager; - - NautilusBonoboActivationHandle *activation_handle; - - NautilusIdleQueue *idle_queue; - - guint failed_idle_id; - guint socket_gone_idle_id; - - /* zoom data */ - float zoom_level; - float min_zoom_level; - float max_zoom_level; - gboolean has_min_zoom_level; - gboolean has_max_zoom_level; - GList *zoom_levels; - - Nautilus_WindowType window_type; - Nautilus_ShowHiddenFilesMode show_hidden_files_mode; -}; - -static void nautilus_view_frame_init (NautilusViewFrame *view); -static void nautilus_view_frame_class_init (NautilusViewFrameClass *klass); -static void send_history (NautilusViewFrame *view); - -static guint signals[LAST_SIGNAL]; - -EEL_CLASS_BOILERPLATE (NautilusViewFrame, - nautilus_view_frame, - GTK_TYPE_HBOX) - -void -nautilus_view_frame_queue_incoming_call (PortableServer_Servant servant, - NautilusViewFrameFunction call, - gpointer callback_data, - GDestroyNotify destroy_callback_data) -{ - NautilusViewFrame *view; - - view = nautilus_view_frame_from_servant (servant); - if (view == NULL) { - if (destroy_callback_data != NULL) { - (* destroy_callback_data) (callback_data); - } - return; - } - - nautilus_idle_queue_add (view->details->idle_queue, - (GFunc) call, - view, - callback_data, - destroy_callback_data); -} - -static void -nautilus_view_frame_init (NautilusViewFrame *view) -{ - GTK_WIDGET_SET_FLAGS (view, GTK_NO_WINDOW); - - view->details = g_new0 (NautilusViewFrameDetails, 1); - - view->details->idle_queue = nautilus_idle_queue_new (); - - g_signal_connect_object (nautilus_signaller_get_current (), - "history_list_changed", - G_CALLBACK (send_history), - view, G_CONNECT_SWAPPED); - g_signal_connect_object (nautilus_icon_factory_get (), - "icons_changed", - G_CALLBACK (send_history), - view, G_CONNECT_SWAPPED); -} - -static void -stop_activation (NautilusViewFrame *view) -{ - nautilus_bonobo_activate_cancel (view->details->activation_handle); - view->details->activation_handle = NULL; -} - -static void -destroy_view (NautilusViewFrame *view) -{ - BonoboUIEngine *engine; - - if (view->details->view == CORBA_OBJECT_NIL) { - return; - } - - g_free (view->details->view_iid); - view->details->view_iid = NULL; - - if (view->details->positionable != CORBA_OBJECT_NIL) { - bonobo_object_release_unref (view->details->positionable, NULL); - view->details->positionable = CORBA_OBJECT_NIL; - } - - CORBA_Object_release (view->details->view, NULL); - view->details->view = CORBA_OBJECT_NIL; - - bonobo_object_unref (view->details->view_frame); - view->details->view_frame = NULL; - view->details->control_frame = NULL; - view->details->zoomable_frame = NULL; - - engine = bonobo_ui_container_get_engine (view->details->ui_container); - if (engine != NULL) { - bonobo_ui_engine_deregister_dead_components (engine); - } - bonobo_object_unref (view->details->ui_container); - view->details->ui_container = NULL; -} - -static void -shut_down (NautilusViewFrame *view) -{ - /* It's good to be in "failed" state while shutting down - * (makes operations all be quiet no-ops). But we don't want - * to send out a "failed" signal. - */ - view->details->state = VIEW_FRAME_FAILED; - - stop_activation (view); - destroy_view (view); - - if (view->details->idle_queue != NULL) { - nautilus_idle_queue_destroy (view->details->idle_queue); - view->details->idle_queue = NULL; - } - - if (view->details->failed_idle_id != 0) { - g_source_remove (view->details->failed_idle_id); - view->details->failed_idle_id = 0; - } - if (view->details->socket_gone_idle_id != 0) { - g_source_remove (view->details->socket_gone_idle_id); - view->details->socket_gone_idle_id = 0; - } -} - -static void -nautilus_view_frame_unrealize (GtkWidget *widget) -{ - shut_down (NAUTILUS_VIEW_FRAME (widget)); - EEL_CALL_PARENT (GTK_WIDGET_CLASS, unrealize, (widget)); -} - -static void -nautilus_view_frame_destroy (GtkObject *object) -{ - shut_down (NAUTILUS_VIEW_FRAME (object)); - EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); -} - -static void -nautilus_view_frame_finalize (GObject *object) -{ - NautilusViewFrame *view; - - view = NAUTILUS_VIEW_FRAME (object); - - shut_down (view); - - g_free (view->details->title); - g_free (view->details->label); - g_free (view->details); - - EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object)); -} - -static void -emit_zoom_parameters_changed (NautilusViewFrame *view) -{ - eel_g_list_free_deep (view->details->zoom_levels); - - if (view->details->zoomable_frame) { - view->details->min_zoom_level = bonobo_zoomable_frame_get_min_zoom_level (view->details->zoomable_frame); - view->details->max_zoom_level = bonobo_zoomable_frame_get_max_zoom_level (view->details->zoomable_frame); - view->details->has_min_zoom_level = bonobo_zoomable_frame_has_min_zoom_level (view->details->zoomable_frame); - view->details->has_max_zoom_level = bonobo_zoomable_frame_has_max_zoom_level (view->details->zoomable_frame); - view->details->zoom_levels = bonobo_zoomable_frame_get_preferred_zoom_levels (view->details->zoomable_frame); - - g_signal_emit (view, signals[ZOOM_PARAMETERS_CHANGED], 0); - } else { - view->details->min_zoom_level = 0.0; - view->details->max_zoom_level = 0.0; - view->details->has_min_zoom_level = FALSE; - view->details->has_max_zoom_level = FALSE; - view->details->zoom_levels = NULL; - } -} - -/* stimulus: successful activated_component call */ -static void -view_frame_activated (NautilusViewFrame *view) -{ - g_assert (NAUTILUS_IS_VIEW_FRAME (view)); - - switch (view->details->state) { - case VIEW_FRAME_EMPTY: - view->details->state = VIEW_FRAME_NO_LOCATION; - g_signal_emit (view, signals[VIEW_LOADED], 0); - emit_zoom_parameters_changed (view); - send_history (view); - return; - case VIEW_FRAME_NO_LOCATION: - case VIEW_FRAME_UNDERWAY: - case VIEW_FRAME_LOADED: - case VIEW_FRAME_WAITING: - case VIEW_FRAME_FAILED: - g_assert_not_reached (); - return; - } - - g_assert_not_reached (); -} - -/* this corresponds to the load_location call stimulus */ -static void -view_frame_wait (NautilusViewFrame *view) -{ - g_assert (NAUTILUS_IS_VIEW_FRAME (view)); - - switch (view->details->state) { - case VIEW_FRAME_EMPTY: - g_warning ("tried to load location in an empty view frame"); - break; - case VIEW_FRAME_NO_LOCATION: - case VIEW_FRAME_UNDERWAY: - case VIEW_FRAME_LOADED: - view->details->state = VIEW_FRAME_WAITING; - return; - case VIEW_FRAME_WAITING: - return; - case VIEW_FRAME_FAILED: - g_assert_not_reached (); - return; - } - - g_assert_not_reached (); -} - -/* this corresponds to the load_underway and load_progress stimulus */ -static void -view_frame_underway (NautilusViewFrame *view) -{ - g_assert (NAUTILUS_IS_VIEW_FRAME (view)); - - switch (view->details->state) { - case VIEW_FRAME_EMPTY: - g_assert_not_reached (); - return; - case VIEW_FRAME_NO_LOCATION: - g_warning ("got signal from a view frame with no location"); - return; - case VIEW_FRAME_WAITING: - case VIEW_FRAME_LOADED: - view->details->state = VIEW_FRAME_UNDERWAY; - g_signal_emit (view, signals[LOAD_UNDERWAY], 0); - return; - case VIEW_FRAME_UNDERWAY: - case VIEW_FRAME_FAILED: - return; - } - - g_assert_not_reached (); -} - -/* stimulus - - open_location call from component - - report_selection_change - - report_status - - set_title -*/ -static void -view_frame_wait_is_over (NautilusViewFrame *view) -{ - g_assert (NAUTILUS_IS_VIEW_FRAME (view)); - - switch (view->details->state) { - case VIEW_FRAME_EMPTY: - case VIEW_FRAME_FAILED: - g_assert_not_reached (); - return; - case VIEW_FRAME_NO_LOCATION: - g_warning ("got signal from a view frame with no location"); - return; - case VIEW_FRAME_WAITING: - view_frame_underway (view); - return; - case VIEW_FRAME_UNDERWAY: - case VIEW_FRAME_LOADED: - return; - } - - g_assert_not_reached (); -} - -/* stimulus: report_load_complete */ -static void -view_frame_loaded (NautilusViewFrame *view) -{ - g_assert (NAUTILUS_IS_VIEW_FRAME (view)); - - switch (view->details->state) { - case VIEW_FRAME_EMPTY: - g_assert_not_reached (); - return; - case VIEW_FRAME_NO_LOCATION: - g_warning ("got signal from a view frame with no location"); - return; - case VIEW_FRAME_WAITING: - view_frame_underway (view); - /* fall through */ - case VIEW_FRAME_UNDERWAY: - view->details->state = VIEW_FRAME_LOADED; - g_signal_emit (view, signals[LOAD_COMPLETE], 0); - return; - case VIEW_FRAME_LOADED: - case VIEW_FRAME_FAILED: - return; - } - - g_assert_not_reached (); -} - -/* stimulus: report_load_failed */ -static void -view_frame_failed (NautilusViewFrame *view) -{ - g_assert (NAUTILUS_IS_VIEW_FRAME (view)); - - switch (view->details->state) { - case VIEW_FRAME_EMPTY: - case VIEW_FRAME_LOADED: - case VIEW_FRAME_NO_LOCATION: - case VIEW_FRAME_UNDERWAY: - case VIEW_FRAME_WAITING: - view->details->state = VIEW_FRAME_FAILED; - stop_activation (view); - destroy_view (view); - g_signal_emit (view, signals[FAILED], 0); - return; - case VIEW_FRAME_FAILED: - return; - } - - g_assert_not_reached (); -} - -NautilusViewFrame * -nautilus_view_frame_new (BonoboUIContainer *ui_container, - NautilusUndoManager *undo_manager, - Nautilus_WindowType window_type) -{ - NautilusViewFrame *view_frame; - - view_frame = NAUTILUS_VIEW_FRAME (gtk_widget_new (nautilus_view_frame_get_type (), NULL)); - - bonobo_object_ref (ui_container); - view_frame->details->ui_container = ui_container; - view_frame->details->undo_manager = undo_manager; - view_frame->details->window_type = window_type; - view_frame->details->show_hidden_files_mode = Nautilus_SHOW_HIDDEN_FILES_DEFAULT; - return view_frame; -} - -static void -emit_zoom_parameters_changed_callback (gpointer data, - gpointer callback_data) -{ - - - emit_zoom_parameters_changed (NAUTILUS_VIEW_FRAME (data)); -} - -static void -zoom_parameters_changed_callback (BonoboZoomableFrame *zframe, - NautilusViewFrame *view) -{ - g_assert (NAUTILUS_IS_VIEW_FRAME (view)); - - nautilus_idle_queue_add (view->details->idle_queue, - emit_zoom_parameters_changed_callback, - view, - NULL, - NULL); -} - -static void -emit_zoom_level_changed_callback (gpointer data, - gpointer callback_data) -{ - NautilusViewFrame *view; - - view = NAUTILUS_VIEW_FRAME (data); - - view->details->zoom_level = bonobo_zoomable_frame_get_zoom_level (view->details->zoomable_frame); - - g_signal_emit (view, - signals[ZOOM_LEVEL_CHANGED], 0, - * (float *) callback_data); -} - -static void -zoom_level_changed_callback (BonoboZoomableFrame *zframe, - float zoom_level, - NautilusViewFrame *view) -{ - float *copy; - - g_assert (NAUTILUS_IS_VIEW_FRAME (view)); - - copy = g_new (float, 1); - *copy = zoom_level; - nautilus_idle_queue_add (view->details->idle_queue, - emit_zoom_level_changed_callback, - view, - copy, - g_free); -} - -enum { - BONOBO_PROPERTY_TITLE, - BONOBO_PROPERTY_HISTORY, - BONOBO_PROPERTY_SELECTION, - BONOBO_PROPERTY_WINDOW_TYPE, - BONOBO_PROPERTY_SHOW_HIDDEN_FILES_MODE -}; - -static Nautilus_History * -get_history_list (NautilusViewFrame *view) -{ - Nautilus_History *history_list; - - history_list = NULL; - g_signal_emit (view, - signals[GET_HISTORY_LIST], 0, - &history_list); - return history_list; -} - -static void -nautilus_view_frame_get_prop (BonoboPropertyBag *bag, - BonoboArg *arg, - guint arg_id, - CORBA_Environment *ev, - gpointer user_data) -{ - NautilusViewFrame *view = user_data; - - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (user_data)); - - switch (arg_id) { - case BONOBO_PROPERTY_TITLE: - BONOBO_ARG_SET_STRING (arg, view->details->title); - break; - - case BONOBO_PROPERTY_HISTORY: - CORBA_free (arg->_value); - arg->_value = get_history_list (view); - break; - - case BONOBO_PROPERTY_SELECTION: - g_warning ("NautilusViewFrame: selection fetch not yet implemented"); - break; - - case BONOBO_PROPERTY_WINDOW_TYPE : - BONOBO_ARG_SET_GENERAL (arg, view->details->window_type, - TC_Nautilus_WindowType, - Nautilus_WindowType, - NULL); - break; - - case BONOBO_PROPERTY_SHOW_HIDDEN_FILES_MODE : - BONOBO_ARG_SET_GENERAL (arg, view->details->show_hidden_files_mode, - TC_Nautilus_ShowHiddenFilesMode, - Nautilus_ShowHiddenFilesMode, - NULL); - break; - default: - g_warning ("NautilusViewFrame: Unknown property idx %d", arg_id); - break; - } -} - -static BonoboPropertyBag * -create_ambient_properties (NautilusViewFrame *view) -{ - BonoboPropertyBag *bag; - - bag = bonobo_property_bag_new (nautilus_view_frame_get_prop, NULL, view); - - bonobo_property_bag_add - (bag, - "title", - BONOBO_PROPERTY_TITLE, - TC_CORBA_string, - NULL, - _("a title"), - BONOBO_PROPERTY_READABLE); - - bonobo_property_bag_add - (bag, - "history", - BONOBO_PROPERTY_HISTORY, - TC_Nautilus_History, - NULL, - _("the browse history"), - BONOBO_PROPERTY_READABLE); - - bonobo_property_bag_add - (bag, - "selection", - BONOBO_PROPERTY_SELECTION, - TC_Nautilus_URIList, - NULL, - _("the current selection"), - BONOBO_PROPERTY_READABLE); - - bonobo_property_bag_add - (bag, - "window-type", - BONOBO_PROPERTY_WINDOW_TYPE, - TC_Nautilus_WindowType, - NULL, - _("the type of window the view is embedded in"), - BONOBO_PROPERTY_READABLE); - - bonobo_property_bag_add - (bag, - "show-hidden-files-mode", - BONOBO_PROPERTY_SHOW_HIDDEN_FILES_MODE, - TC_Nautilus_ShowHiddenFilesMode, - NULL, - _("whether to show hidden files in the view"), - BONOBO_PROPERTY_READABLE); - - view->details->event_source = bag->es; - - return bag; -} - -static void -create_corba_objects (NautilusViewFrame *view) -{ - CORBA_Environment ev; - Bonobo_Control control; - Bonobo_Zoomable zoomable; - Nautilus_ScrollPositionable positionable; - BonoboPropertyBag *bag; - - CORBA_exception_init (&ev); - - /* Create a view frame. */ - view->details->view_frame = nautilus_view_frame_create_corba_part (view); - - /* Create a control frame. */ - control = Bonobo_Unknown_queryInterface - (view->details->view, "IDL:Bonobo/Control:1.0", &ev); - g_assert (! BONOBO_EX (&ev)); - - view->details->control_frame = bonobo_control_frame_new - (BONOBO_OBJREF (view->details->ui_container)); - - bag = create_ambient_properties (view); - bonobo_control_frame_set_propbag (view->details->control_frame, bag); - bonobo_object_unref (bag); - - bonobo_control_frame_bind_to_control (view->details->control_frame, control, NULL); - - bonobo_object_release_unref (control, NULL); - - /* Create a zoomable frame. */ - zoomable = Bonobo_Unknown_queryInterface - (view->details->view, "IDL:Bonobo/Zoomable:1.0", &ev); - if (!BONOBO_EX (&ev) - && !CORBA_Object_is_nil (zoomable, &ev) - && !BONOBO_EX (&ev)) { - view->details->zoomable_frame = bonobo_zoomable_frame_new (); - bonobo_zoomable_frame_bind_to_zoomable - (view->details->zoomable_frame, zoomable, NULL); - bonobo_object_release_unref (zoomable, NULL); - } - - CORBA_exception_free (&ev); - - CORBA_exception_init (&ev); - - positionable = Bonobo_Unknown_queryInterface - (view->details->view, "IDL:Nautilus/ScrollPositionable:1.0", &ev); - if (!BONOBO_EX (&ev) - && !CORBA_Object_is_nil (positionable, &ev) - && !BONOBO_EX (&ev)) { - view->details->positionable = positionable; - } - - CORBA_exception_free (&ev); - - /* Aggregate all the interfaces into one object. */ - bonobo_object_add_interface (BONOBO_OBJECT (view->details->view_frame), - BONOBO_OBJECT (view->details->control_frame)); - if (view->details->zoomable_frame != NULL) { - bonobo_object_add_interface (BONOBO_OBJECT (view->details->view_frame), - BONOBO_OBJECT (view->details->zoomable_frame)); - } - nautilus_undo_manager_add_interface (view->details->undo_manager, - BONOBO_OBJECT (view->details->view_frame)); -} - - -static gboolean -view_frame_failed_callback (gpointer callback_data) -{ - NautilusViewFrame *view; - - view = NAUTILUS_VIEW_FRAME (callback_data); - view->details->failed_idle_id = 0; - view_frame_failed (view); - return FALSE; -} - -static void -queue_view_frame_failed (NautilusViewFrame *view) -{ - g_assert (NAUTILUS_IS_VIEW_FRAME (view)); - - if (view->details->failed_idle_id == 0) { - view->details->failed_idle_id = - g_idle_add (view_frame_failed_callback, view); - } -} - -static gboolean -check_socket_gone_idle_callback (gpointer callback_data) -{ - NautilusViewFrame *frame; - GtkWidget *widget; - GList *children; - - frame = NAUTILUS_VIEW_FRAME (callback_data); - - frame->details->socket_gone_idle_id = 0; - - widget = bonobo_control_frame_get_widget (frame->details->control_frame); - - /* This relies on details of the BonoboControlFrame - * implementation, specifically that's there's one level of - * hierarchy between the widget returned by get_widget and the - * actual plug. - */ - children = gtk_container_get_children (GTK_CONTAINER (widget)); - g_list_free (children); - - /* If there's nothing inside the widget at all, that means - * that the socket went away because the remote plug went away. - */ - if (children == NULL) { - view_frame_failed (frame); - } - - return FALSE; -} - -static void -check_socket_gone_callback (GtkContainer *container, - GtkWidget *widget, - gpointer callback_data) -{ - NautilusViewFrame *frame; - - frame = NAUTILUS_VIEW_FRAME (callback_data); - - /* There are two times the socket will be destroyed in Bonobo. - * One is when a local control decides to not use the socket. - * The other is when the remote plug goes away. The way to - * tell these apart is to wait until idle time. At idle time, - * if there's nothing in the container, then that means the - * real socket went away. If it was just the local control - * deciding not to use the socket, there will be another - * widget in there. - */ - if (frame->details->socket_gone_idle_id == 0) { - frame->details->socket_gone_idle_id = g_idle_add - (check_socket_gone_idle_callback, callback_data); - } -} - -static void -attach_view (NautilusViewFrame *view, - Bonobo_Unknown component) -{ - CORBA_Environment ev; - GtkWidget *widget; - - /* Either create an adapter or query for the Nautilus:View - * interface. Either way, we don't need to keep the original - * reference around once that happens. - */ - view->details->view = nautilus_component_adapter_factory_create_adapter - (nautilus_component_adapter_factory_get (), component); - - /* Handle case where we don't know how to host this component. */ - if (view->details->view == CORBA_OBJECT_NIL) { - view_frame_failed (view); - return; - } - - create_corba_objects (view); - - CORBA_exception_init (&ev); - Bonobo_Unknown_unref (view->details->view, &ev); - CORBA_exception_free (&ev); - - widget = bonobo_control_frame_get_widget (view->details->control_frame); - - g_signal_connect_object (view->details->view_frame, "destroy", - G_CALLBACK (view_frame_failed), view, G_CONNECT_SWAPPED); - g_signal_connect_object (view->details->view_frame, "system_exception", - G_CALLBACK (queue_view_frame_failed), view, G_CONNECT_SWAPPED); - g_signal_connect_object (view->details->control_frame, "system_exception", - G_CALLBACK (queue_view_frame_failed), view, G_CONNECT_SWAPPED); - g_signal_connect_object (widget, "remove", - G_CALLBACK (check_socket_gone_callback), view, 0); - - if (view->details->zoomable_frame != NULL) { - g_signal_connect_object (view->details->zoomable_frame, "system_exception", - G_CALLBACK (queue_view_frame_failed), view, G_CONNECT_SWAPPED); - g_signal_connect_object (view->details->zoomable_frame, "zoom_parameters_changed", - G_CALLBACK (zoom_parameters_changed_callback), view, 0); - g_signal_connect_object (view->details->zoomable_frame, "zoom_level_changed", - G_CALLBACK (zoom_level_changed_callback), view, 0); - } - - gtk_widget_show (widget); - gtk_container_add (GTK_CONTAINER (view), widget); - - view_frame_activated (view); - - /* The frame might already be mapped when the view is activated. - * This means we won't get the mapped signal while its active, so - * activate it now. - */ - if (GTK_WIDGET_MAPPED (GTK_WIDGET (view))) { - bonobo_control_frame_control_activate (view->details->control_frame); - } -} - -static void -activation_callback (NautilusBonoboActivationHandle *handle, - Bonobo_Unknown activated_object, - gpointer callback_data) -{ - NautilusViewFrame *view; - - view = NAUTILUS_VIEW_FRAME (callback_data); - g_assert (view->details->activation_handle == handle); - - view->details->activation_handle = NULL; - - if (activated_object == CORBA_OBJECT_NIL) { - view_frame_failed (view); - } else { - attach_view (view, activated_object); - } -} - -void -nautilus_view_frame_load_view (NautilusViewFrame *view, - const char *view_iid) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - g_return_if_fail (view_iid != NULL); - - if (view->details->state == VIEW_FRAME_FAILED) { - return; - } - - g_return_if_fail (view->details->state == VIEW_FRAME_EMPTY); - g_assert (view->details->view_iid == NULL); - g_assert (view->details->activation_handle == NULL); - - view->details->view_iid = g_strdup (view_iid); - view->details->activation_handle = nautilus_bonobo_activate_from_id - (view_iid, activation_callback, view); -} - -void -nautilus_view_frame_load_location (NautilusViewFrame *view, - const char *location) -{ - CORBA_Environment ev; - - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - if (view->details->state == VIEW_FRAME_FAILED) { - return; - } - - g_free (view->details->title); - view->details->title = NULL; - g_signal_emit (view, signals[TITLE_CHANGED], 0); - - view_frame_wait (view); - - CORBA_exception_init (&ev); - Nautilus_View_load_location (view->details->view, location, &ev); - if (BONOBO_EX (&ev)) { - view_frame_failed (view); - } - CORBA_exception_free (&ev); -} - -void -nautilus_view_frame_stop (NautilusViewFrame *view) -{ - CORBA_Environment ev; - - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - if (view->details->state == VIEW_FRAME_FAILED) { - return; - } - - stop_activation (view); - - if (view->details->view != CORBA_OBJECT_NIL) { - CORBA_exception_init (&ev); - Nautilus_View_stop_loading (view->details->view, &ev); - if (BONOBO_EX (&ev)) { - view_frame_failed (view); - } - CORBA_exception_free (&ev); - } -} - -void -nautilus_view_frame_selection_changed (NautilusViewFrame *view, - GList *selection) -{ - BonoboArg *arg; - CORBA_Environment ev; - Nautilus_URIList *uri_list; - - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - if (view->details->view == CORBA_OBJECT_NIL) { - return; - } - - if (!bonobo_event_source_has_listener - (view->details->event_source, - "Bonobo/Property:change:selection")) { - return; - } - - uri_list = nautilus_uri_list_from_g_list (selection); - - CORBA_exception_init (&ev); - - arg = bonobo_arg_new_from (TC_Nautilus_URIList, uri_list); - CORBA_free (uri_list); - - bonobo_event_source_notify_listeners - (view->details->event_source, - "Bonobo/Property:change:selection", arg, &ev); - - CORBA_free (arg); - - if (BONOBO_EX (&ev)) { - view_frame_failed (view); - } - - CORBA_exception_free (&ev); -} - -void -nautilus_view_frame_title_changed (NautilusViewFrame *view, - const char *title) -{ - BonoboArg arg; - CORBA_Environment ev; - - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - if (view->details->view == CORBA_OBJECT_NIL) { - return; - } - - CORBA_exception_init (&ev); - - arg._type = TC_CORBA_string; - arg._value = &title; - - bonobo_event_source_notify_listeners - (view->details->event_source, - "Bonobo/Property:change:title", &arg, &ev); - - if (BONOBO_EX (&ev)) { - view_frame_failed (view); - } - - CORBA_exception_free (&ev); -} - -gboolean -nautilus_view_frame_get_is_zoomable (NautilusViewFrame *view) -{ - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), FALSE); - - return view->details->zoomable_frame != NULL; -} - -float -nautilus_view_frame_get_zoom_level (NautilusViewFrame *view) -{ - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), 0.0); - - if (view->details->zoomable_frame == NULL) { - return 0.0; - } - - return view->details->zoom_level; -} - -void -nautilus_view_frame_set_zoom_level (NautilusViewFrame *view, - float zoom_level) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - if (view->details->zoomable_frame == NULL) { - return; - } - - bonobo_zoomable_frame_set_zoom_level (view->details->zoomable_frame, zoom_level); -} - -float -nautilus_view_frame_get_min_zoom_level (NautilusViewFrame *view) -{ - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), 0.0); - - if (view->details->zoomable_frame == NULL) { - return 0.0; - } - - return view->details->min_zoom_level; -} - -float -nautilus_view_frame_get_max_zoom_level (NautilusViewFrame *view) -{ - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), 0.0); - - if (view->details->zoomable_frame == NULL) { - return 0.0; - } - - return view->details->max_zoom_level; -} - -gboolean -nautilus_view_frame_get_has_min_zoom_level (NautilusViewFrame *view) -{ - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), FALSE); - - if (view->details->zoomable_frame == NULL) { - return FALSE; - } - - return view->details->has_min_zoom_level; -} - -gboolean -nautilus_view_frame_get_has_max_zoom_level (NautilusViewFrame *view) -{ - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), FALSE); - - if (view->details->zoomable_frame == NULL) { - return FALSE; - } - - return view->details->has_max_zoom_level; -} - -gboolean -nautilus_view_frame_get_is_continuous (NautilusViewFrame *view) -{ - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), FALSE); - - if (view->details->zoomable_frame == NULL) { - return FALSE; - } - - return bonobo_zoomable_frame_is_continuous (view->details->zoomable_frame); -} - -gboolean -nautilus_view_frame_get_can_zoom_in (NautilusViewFrame *view) -{ - return !view->details->has_max_zoom_level || - (view->details->zoom_level - < view->details->max_zoom_level); - -} - -gboolean -nautilus_view_frame_get_can_zoom_out (NautilusViewFrame *view) -{ - return !view->details->has_min_zoom_level || - (view->details->zoom_level - > view->details->min_zoom_level); -} - - -GList * -nautilus_view_frame_get_preferred_zoom_levels (NautilusViewFrame *view) -{ - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), NULL); - - if (view->details->zoomable_frame == NULL) { - return NULL; - } - - return bonobo_zoomable_frame_get_preferred_zoom_levels (view->details->zoomable_frame); -} - -void -nautilus_view_frame_zoom_in (NautilusViewFrame *view) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - if (view->details->zoomable_frame == NULL) { - return; - } - - bonobo_zoomable_frame_zoom_in (view->details->zoomable_frame); -} - -void -nautilus_view_frame_zoom_out (NautilusViewFrame *view) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - if (view->details->zoomable_frame == NULL) { - return; - } - - bonobo_zoomable_frame_zoom_out (view->details->zoomable_frame); -} - -void -nautilus_view_frame_zoom_to_fit (NautilusViewFrame *view) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - if (view->details->zoomable_frame == NULL) { - return; - } - - bonobo_zoomable_frame_zoom_to_fit (view->details->zoomable_frame); -} - -char * -nautilus_view_frame_get_first_visible_file (NautilusViewFrame *view) -{ - Nautilus_URI uri; - char *ret; - - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), NULL); - - ret = NULL; - if (view->details->positionable) { - CORBA_Environment ev; - - CORBA_exception_init (&ev); - uri = Nautilus_ScrollPositionable_get_first_visible_file (view->details->positionable, &ev); - ret = g_strdup (uri); - CORBA_free (uri); - CORBA_exception_free (&ev); - } - - return ret; -} - -void -nautilus_view_frame_scroll_to_file (NautilusViewFrame *view, - const char *uri) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - if (view->details->positionable) { - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - Nautilus_ScrollPositionable_scroll_to_file (view->details->positionable, - uri, - &ev); - CORBA_exception_free (&ev); - } -} - - -const char * -nautilus_view_frame_get_view_iid (NautilusViewFrame *view) -{ - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), NULL); - - return view->details->view_iid; -} - -void -nautilus_view_frame_open_location (NautilusViewFrame *view, - const char *location, - Nautilus_ViewFrame_OpenMode mode, - Nautilus_ViewFrame_OpenFlags flags, - GList *selection) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - if (view->details->state == VIEW_FRAME_FAILED) { - return; - } - - view_frame_wait_is_over (view); - g_signal_emit (view, - signals[OPEN_LOCATION], 0, - location, mode, flags, selection); -} - -void -nautilus_view_frame_report_location_change (NautilusViewFrame *view, - const char *location, - GList *selection, - const char *title) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - if (view->details->state == VIEW_FRAME_FAILED) { - return; - } - - g_free (view->details->title); - view->details->title = g_strdup (title); - - view_frame_wait_is_over (view); - g_signal_emit (view, - signals[REPORT_LOCATION_CHANGE], 0, - location, selection, title); -} - -void -nautilus_view_frame_report_redirect (NautilusViewFrame *view, - const char *from_location, - const char *to_location, - GList *selection, - const char *title) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - if (view->details->state == VIEW_FRAME_FAILED) { - return; - } - - g_free (view->details->title); - view->details->title = g_strdup (title); - - view_frame_wait_is_over (view); - g_signal_emit (view, - signals[REPORT_REDIRECT], 0, - from_location, to_location, selection, title); -} - -void -nautilus_view_frame_report_selection_change (NautilusViewFrame *view, - GList *selection) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - if (view->details->state == VIEW_FRAME_FAILED) { - return; - } - - view_frame_wait_is_over (view); - g_signal_emit (view, - signals[CHANGE_SELECTION], 0, selection); -} - -void -nautilus_view_frame_report_status (NautilusViewFrame *view, - const char *status) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - if (view->details->state == VIEW_FRAME_FAILED) { - return; - } - - view_frame_wait_is_over (view); - g_signal_emit (view, - signals[CHANGE_STATUS], 0, status); -} - -void -nautilus_view_frame_report_load_underway (NautilusViewFrame *view) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - view_frame_underway (view); -} - -void -nautilus_view_frame_report_load_progress (NautilusViewFrame *view, - double fraction_done) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - if (view->details->state == VIEW_FRAME_FAILED) { - return; - } - - view_frame_underway (view); - g_signal_emit (view, - signals[LOAD_PROGRESS_CHANGED], 0); -} - -void -nautilus_view_frame_report_load_complete (NautilusViewFrame *view) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - view_frame_loaded (view); -} - -void -nautilus_view_frame_report_load_failed (NautilusViewFrame *view) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - view_frame_failed (view); -} - -/* return the Bonobo_Control CORBA object associated with the view frame */ -Bonobo_Control -nautilus_view_frame_get_control (NautilusViewFrame *view) -{ - if (view->details->control_frame == NULL) { - return CORBA_OBJECT_NIL; - } - return bonobo_control_frame_get_control (view->details->control_frame); -} - -void -nautilus_view_frame_go_back (NautilusViewFrame *view) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - g_signal_emit (view, signals[GO_BACK], 0); -} - -void -nautilus_view_frame_close_window (NautilusViewFrame *view) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - g_signal_emit (view, signals[CLOSE_WINDOW], 0); -} - -Nautilus_ShowHiddenFilesMode -nautilus_view_frame_get_show_hidden_files_mode (NautilusViewFrame *view) -{ - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), 0); - - return view->details->show_hidden_files_mode; -} - - -void -nautilus_view_frame_set_show_hidden_files_mode (NautilusViewFrame *view, - Nautilus_ShowHiddenFilesMode mode, - gboolean from_view) -{ - CORBA_Environment ev; - - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - view->details->show_hidden_files_mode = mode; - if (from_view) { - /* The call was from the the view, propagate to the window */ - g_signal_emit (view, signals[SHOW_HIDDEN_FILES_MODE_CHANGED], 0); - } else if (view->details->event_source) { - /* The call was from the window, propagate to all views */ - CORBA_exception_init (&ev); - - bonobo_event_source_notify_listeners - (view->details->event_source, - "Bonobo/Property:change:show-hidden-files-mode", NULL, &ev); - - if (BONOBO_EX (&ev)) { - g_warning ("show hidden mode notification failed"); - } - - CORBA_exception_free (&ev); - } -} - -void -nautilus_view_frame_set_title (NautilusViewFrame *view, - const char *title) -{ - gboolean changed; - - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - g_return_if_fail (title != NULL); - - if (view->details->state == VIEW_FRAME_FAILED) { - return; - } - - /* Only do work if the title actually changed. */ - changed = view->details->title == NULL - || strcmp (view->details->title, title) != 0; - - g_free (view->details->title); - view->details->title = g_strdup (title); - - view_frame_wait_is_over (view); - if (changed) { - g_signal_emit (view, signals[TITLE_CHANGED], 0); - } -} - -char * -nautilus_view_frame_get_title (NautilusViewFrame *view) -{ - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), NULL); - - return g_strdup (view->details->title); -} - -char * -nautilus_view_frame_get_label (NautilusViewFrame *view) -{ - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), NULL); - - return g_strdup (view->details->label); -} - -void -nautilus_view_frame_set_label (NautilusViewFrame *view, - const char *label) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - g_free (view->details->label); - view->details->label = g_strdup (label); -} - -/* Activate the underlying control frame whenever the view is mapped. - * This causes the view to merge its menu items, for example. For - * sidebar panels, it might be a little late to merge them at map - * time. What's a better time? - */ -static void -nautilus_view_frame_map (GtkWidget *view_as_widget) -{ - NautilusViewFrame *view; - - view = NAUTILUS_VIEW_FRAME (view_as_widget); - - EEL_CALL_PARENT (GTK_WIDGET_CLASS, map, (view_as_widget)); - - if (view->details->control_frame != NULL) { - bonobo_control_frame_control_activate (view->details->control_frame); - } -} - -static void -send_history (NautilusViewFrame *view) -{ - Nautilus_History *history; - CORBA_Environment ev; - BonoboArg *arg; - - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - if (view->details->view == CORBA_OBJECT_NIL) { - return; - } - - if (!bonobo_event_source_has_listener - (view->details->event_source, - "Bonobo/Property:change:history")) { - return; - } - - history = get_history_list (view); - if (history == CORBA_OBJECT_NIL) { - return; - } - - CORBA_exception_init (&ev); - - arg = bonobo_arg_new_from (TC_Nautilus_History, history); - - CORBA_free (history); - - bonobo_event_source_notify_listeners - (view->details->event_source, - "Bonobo/Property:change:history", arg, &ev); - - CORBA_free (arg); - - if (BONOBO_EX (&ev)) { - view_frame_failed (view); - } - - CORBA_exception_free (&ev); -} - -gboolean -nautilus_view_frame_get_is_view_loaded (NautilusViewFrame *view) -{ - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), FALSE); - - switch (view->details->state) { - case VIEW_FRAME_EMPTY: - case VIEW_FRAME_FAILED: - return FALSE; - case VIEW_FRAME_NO_LOCATION: - case VIEW_FRAME_WAITING: - case VIEW_FRAME_UNDERWAY: - case VIEW_FRAME_LOADED: - return TRUE; - } - - g_assert_not_reached (); - return FALSE; -} - -static void -nautilus_view_frame_class_init (NautilusViewFrameClass *class) -{ - G_OBJECT_CLASS (class)->finalize = nautilus_view_frame_finalize; - GTK_OBJECT_CLASS (class)->destroy = nautilus_view_frame_destroy; - GTK_WIDGET_CLASS (class)->unrealize = nautilus_view_frame_unrealize; - GTK_WIDGET_CLASS (class)->map = nautilus_view_frame_map; - - signals[CHANGE_SELECTION] = g_signal_new - ("change_selection", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusViewFrameClass, - change_selection), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); - signals[CHANGE_STATUS] = g_signal_new - ("change_status", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusViewFrameClass, - change_status), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, G_TYPE_STRING); - signals[FAILED] = g_signal_new - ("failed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusViewFrameClass, - failed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - signals[GET_HISTORY_LIST] = g_signal_new - ("get_history_list", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusViewFrameClass, - get_history_list), - NULL, NULL, - nautilus_marshal_POINTER__VOID, - G_TYPE_POINTER, 0); - signals[GO_BACK] = g_signal_new - ("go_back", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusViewFrameClass, - go_back), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - signals[CLOSE_WINDOW] = g_signal_new - ("close_window", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusViewFrameClass, - close_window), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - signals[LOAD_COMPLETE] = g_signal_new - ("load_complete", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusViewFrameClass, - load_complete), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - signals[LOAD_PROGRESS_CHANGED] = g_signal_new - ("load_progress_changed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusViewFrameClass, - load_progress_changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - signals[LOAD_UNDERWAY] = g_signal_new - ("load_underway", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusViewFrameClass, - load_underway), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - signals[OPEN_LOCATION] = g_signal_new - ("open_location", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusViewFrameClass, - open_location), - NULL, NULL, - eel_marshal_VOID__STRING_LONG_LONG_POINTER, - G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_LONG, G_TYPE_LONG, G_TYPE_POINTER); - signals[REPORT_LOCATION_CHANGE] = g_signal_new - ("report_location_change", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusViewFrameClass, - report_location_change), - NULL, NULL, - eel_marshal_VOID__STRING_POINTER_STRING, - G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_STRING); - signals[REPORT_REDIRECT] = g_signal_new - ("report_redirect", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusViewFrameClass, - report_redirect), - NULL, NULL, - eel_marshal_VOID__STRING_STRING_POINTER_STRING, - G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_STRING); - signals[SHOW_HIDDEN_FILES_MODE_CHANGED] = g_signal_new - ("show_hidden_files_mode_changed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusViewFrameClass, - show_hidden_files_mode_changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - signals[TITLE_CHANGED] = g_signal_new - ("title_changed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusViewFrameClass, - title_changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - signals[VIEW_LOADED] = g_signal_new - ("view_loaded", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusViewFrameClass, - view_loaded), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - signals[ZOOM_LEVEL_CHANGED] = g_signal_new - ("zoom_level_changed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusViewFrameClass, - zoom_level_changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - signals[ZOOM_PARAMETERS_CHANGED] = g_signal_new - ("zoom_parameters_changed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusViewFrameClass, - zoom_parameters_changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); -} diff --git a/src/nautilus-view-frame.h b/src/nautilus-view-frame.h deleted file mode 100644 index de1d4bb26..000000000 --- a/src/nautilus-view-frame.h +++ /dev/null @@ -1,152 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 1999, 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 - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * Nautilus 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., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Authors: Elliot Lee <sopwith@redhat.com> - * Darin Adler <darin@bentspoon.com> - * - */ - -/* nautilus-view-frame.h: Interface of the object representing a data - * view. This is actually the widget for the view frame rather than - * the view frame itself. - */ - -#ifndef NAUTILUS_VIEW_FRAME_H -#define NAUTILUS_VIEW_FRAME_H - -#include <bonobo/bonobo-ui-container.h> -#include <bonobo/bonobo-zoomable-frame.h> -#include <gtk/gtkhbox.h> -#include <libnautilus-private/nautilus-undo-manager.h> -#include <libnautilus/nautilus-view-component.h> - -#define NAUTILUS_TYPE_VIEW_FRAME (nautilus_view_frame_get_type ()) -#define NAUTILUS_VIEW_FRAME(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_VIEW_FRAME, NautilusViewFrame)) -#define NAUTILUS_VIEW_FRAME_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_VIEW_FRAME, NautilusViewFrameClass)) -#define NAUTILUS_IS_VIEW_FRAME(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_VIEW_FRAME)) -#define NAUTILUS_IS_VIEW_FRAME_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_VIEW_FRAME)) - -typedef struct NautilusViewFrameDetails NautilusViewFrameDetails; - -typedef struct { - GtkHBox parent; - NautilusViewFrameDetails *details; -} NautilusViewFrame; - -typedef struct { - GtkHBoxClass parent_spot; - - /* These roughly correspond to CORBA calls, but in some cases they are higher level. */ - - /* This happens only just after load_view. */ - void (* view_loaded) (NautilusViewFrame *view); - - /* These can happen pretty much any time. */ - void (* load_underway) (NautilusViewFrame *view); - void (* failed) (NautilusViewFrame *view); - - /* These will only happen after load_underway (guaranteed). */ - void (* open_location) (NautilusViewFrame *view, - const char *location, - Nautilus_ViewFrame_OpenMode mode, - Nautilus_ViewFrame_OpenFlags flags, - GList *selection); /* list of char * */ - void (* report_location_change) (NautilusViewFrame *view, - const char *location, - GList *selection, /* list of char * */ - const char *title); - void (* report_redirect) (NautilusViewFrame *view, - const char *from_location, - const char *to_location, - GList *selection, /* list of char * */ - const char *title); - void (* change_selection) (NautilusViewFrame *view, - GList *selection); /* list of char * */ - void (* change_status) (NautilusViewFrame *view, - const char *status); - void (* load_progress_changed) (NautilusViewFrame *view); - void (* load_complete) (NautilusViewFrame *view); - void (* title_changed) (NautilusViewFrame *view); - void (* zoom_level_changed) (NautilusViewFrame *view); - void (* zoom_parameters_changed) (NautilusViewFrame *view); - Nautilus_History * (* get_history_list) (NautilusViewFrame *view); - void (* go_back) (NautilusViewFrame *view); - void (* close_window) (NautilusViewFrame *view); - void (* show_hidden_files_mode_changed) (NautilusViewFrame *view); -} NautilusViewFrameClass; - -/* basic view management */ -GType nautilus_view_frame_get_type (void); -NautilusViewFrame *nautilus_view_frame_new (BonoboUIContainer *ui_container, - NautilusUndoManager *undo_manager, - Nautilus_WindowType window_type); -Bonobo_Control nautilus_view_frame_get_control (NautilusViewFrame *view); - -/* connecting to a Nautilus:View */ -void nautilus_view_frame_load_view (NautilusViewFrame *view, - const char *view_iid); -void nautilus_view_frame_stop (NautilusViewFrame *view); - -/* calls to Nautilus:View functions */ -void nautilus_view_frame_load_location (NautilusViewFrame *view, - const char *location); -void nautilus_view_frame_selection_changed (NautilusViewFrame *view, - GList *selection); -void nautilus_view_frame_title_changed (NautilusViewFrame *view, - const char *title); - -/* calls to Bonobo:Zoomable functions */ -float nautilus_view_frame_get_zoom_level (NautilusViewFrame *view); -void nautilus_view_frame_set_zoom_level (NautilusViewFrame *view, - float zoom_level); -float nautilus_view_frame_get_min_zoom_level (NautilusViewFrame *view); -float nautilus_view_frame_get_max_zoom_level (NautilusViewFrame *view); -gboolean nautilus_view_frame_get_has_min_zoom_level (NautilusViewFrame *view); -gboolean nautilus_view_frame_get_has_max_zoom_level (NautilusViewFrame *view); -gboolean nautilus_view_frame_get_is_continuous (NautilusViewFrame *view); -gboolean nautilus_view_frame_get_can_zoom_in (NautilusViewFrame *view); -gboolean nautilus_view_frame_get_can_zoom_out (NautilusViewFrame *view); - -GList * nautilus_view_frame_get_preferred_zoom_levels (NautilusViewFrame *view); -void nautilus_view_frame_zoom_in (NautilusViewFrame *view); -void nautilus_view_frame_zoom_out (NautilusViewFrame *view); -void nautilus_view_frame_zoom_to_fit (NautilusViewFrame *view); - -/* calls to Nautilus::ScrollPositionable */ -char * nautilus_view_frame_get_first_visible_file (NautilusViewFrame *view); -void nautilus_view_frame_scroll_to_file (NautilusViewFrame *view, - const char *uri); - -/* Other. */ -gboolean nautilus_view_frame_get_is_view_loaded (NautilusViewFrame *view); -const char * nautilus_view_frame_get_view_iid (NautilusViewFrame *view); -gboolean nautilus_view_frame_get_is_zoomable (NautilusViewFrame *view); -Nautilus_ShowHiddenFilesMode nautilus_view_frame_get_show_hidden_files_mode (NautilusViewFrame *view); -void nautilus_view_frame_set_show_hidden_files_mode (NautilusViewFrame *viev, - Nautilus_ShowHiddenFilesMode mode, - gboolean signal); -char * nautilus_view_frame_get_title (NautilusViewFrame *view); -char * nautilus_view_frame_get_label (NautilusViewFrame *view); -void nautilus_view_frame_set_label (NautilusViewFrame *view, - const char *label); - -#endif /* NAUTILUS_VIEW_FRAME_H */ diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c index c2257f4f6..6a83ea441 100644 --- a/src/nautilus-window-manage-views.c +++ b/src/nautilus-window-manage-views.c @@ -28,9 +28,7 @@ #include <config.h> #include "nautilus-window-manage-views.h" -#include "nautilus-applicable-views.h" #include "nautilus-application.h" -#include "nautilus-information-panel.h" #include "nautilus-location-bar.h" #include "nautilus-main.h" #include "nautilus-window-private.h" @@ -65,7 +63,8 @@ #include <libnautilus-private/nautilus-monitor.h> #include <libnautilus-private/nautilus-search-uri.h> #include <libnautilus-private/nautilus-theme.h> -#include <libnautilus-private/nautilus-view-query.h> +#include <libnautilus-private/nautilus-view-factory.h> +#include <libnautilus-private/nautilus-window-info.h> /* FIXME bugzilla.gnome.org 41243: * We should use inheritance instead of these special cases @@ -80,139 +79,41 @@ */ #define MAX_URI_IN_DIALOG_LENGTH 60 -typedef struct { - gboolean is_sidebar_panel; - NautilusViewIdentifier *id; -} ViewFrameInfo; +static void connect_view (NautilusWindow *window, + NautilusView *view); +static void disconnect_view (NautilusWindow *window, + NautilusView *view); +static void begin_location_change (NautilusWindow *window, + const char *location, + GList *new_selection, + NautilusLocationChangeType type, + guint distance, + const char *scroll_pos); +static void free_location_change (NautilusWindow *window); +static void end_location_change (NautilusWindow *window); +static void cancel_location_change (NautilusWindow *window); +static void got_file_info_for_view_selection_callback (NautilusFile *file, + gpointer callback_data); +static void create_content_view (NautilusWindow *window, + const char *view_id); +static void display_view_selection_failure (NautilusWindow *window, + NautilusFile *file, + const char *location); +static void load_new_location (NautilusWindow *window, + const char *location, + GList *selection, + gboolean tell_current_content_view, + gboolean tell_new_content_view); +static void location_has_really_changed (NautilusWindow *window); +static void update_for_new_location (NautilusWindow *window); -typedef struct { - NautilusWindow *window; - NautilusViewIdentifier *id; -} ViewFrameWindowInfo; - -static void connect_view (NautilusWindow *window, - NautilusViewFrame *view, - gboolean content_view); -static void disconnect_view (NautilusWindow *window, - NautilusViewFrame *view); -static void begin_location_change (NautilusWindow *window, - const char *location, - NautilusLocationChangeType type, - guint distance, - const char *scroll_pos); -static void free_location_change (NautilusWindow *window); -static void end_location_change (NautilusWindow *window); -static void cancel_location_change (NautilusWindow *window); -static void load_directory_metadata_callback (NautilusFile *file, - gpointer callback_data); - -static void -change_selection (NautilusWindow *window, - GList *selection, - NautilusViewFrame *requesting_view) -{ - GList *sorted; - GList *views; - GList *node; - NautilusViewFrame *view; - - /* Sort list into canonical order and check if it's the same as - * the selection we already have. - */ - sorted = eel_g_str_list_alphabetize (eel_g_str_list_copy (selection)); - if (eel_g_str_list_equal (sorted, window->details->selection)) { - eel_g_list_free_deep (sorted); - return; - } - - /* Store the new selection. */ - eel_g_list_free_deep (window->details->selection); - window->details->selection = sorted; - - /* Tell all the view frames about it, except the one that changed it. - * Copy the list before traversing it, because during a failure in - * selection_changed, list could be modified and bad things would - * happen - */ - views = g_list_copy (window->views); - for (node = views; node != NULL; node = node->next) { - view = NAUTILUS_VIEW_FRAME (node->data); - if (view != requesting_view) { - nautilus_view_frame_selection_changed (view, sorted); - } - } - g_list_free (views); -} - -/* update_title: - * - * Update the non-NautilusViewFrame objects that use the location's user-displayable - * title in some way. Called when the location or title has changed. - * @window: The NautilusWindow in question. - * @title: The new user-displayable title. - * - */ -static void -update_title (NautilusWindow *window) -{ - GList *views; - GList *node; - - nautilus_window_update_title (window); - - /* Copy the list before traversing it, because during a failure in - * title_change, list could be modified and bad things would happen - */ - views = g_list_copy (window->views); - for (node = views; node != NULL; node = node->next) { - nautilus_view_frame_title_changed (node->data, - window->details->title); - } - - g_list_free (views); -} - -/* nautilus_window_update_icon: - * - * Update the non-NautilusViewFrame objects that use the location's user-displayable - * icon in some way. Called when the location or icon-theme has changed. - * @window: The NautilusWindow in question. - * - */ void -nautilus_window_update_icon (NautilusWindow *window) +nautilus_window_report_selection_changed (NautilusWindowInfo *window) { - GdkPixbuf *pixbuf; - GtkIconTheme *icon_theme; - - pixbuf = NULL; - - /* Desktop window special icon */ - if (NAUTILUS_IS_DESKTOP_WINDOW (window)) { - icon_theme = nautilus_icon_factory_get_icon_theme (); - pixbuf = gtk_icon_theme_load_icon (icon_theme, - "gnome-fs-desktop", 48, - 0, NULL); - g_object_unref(icon_theme); - - } else { - pixbuf = nautilus_icon_factory_get_pixbuf_for_file (window->details->viewed_file, - "open", - NAUTILUS_ICON_SIZE_STANDARD); - } - - if (pixbuf != NULL) { - gtk_window_set_icon (GTK_WINDOW (window), pixbuf); - g_object_unref (pixbuf); - } + g_signal_emit_by_name (window, "selection_changed"); } /* set_displayed_location: - * - * Update the non-NautilusViewFrame objects that use the location's user-displayable - * title in some way. Called when the location or title has changed. - * @window: The NautilusWindow in question. - * @title: The new user-displayable title. */ static void set_displayed_location (NautilusWindow *window, const char *location) @@ -234,10 +135,10 @@ set_displayed_location (NautilusWindow *window, const char *location) g_object_unref (window->last_location_bookmark); } window->last_location_bookmark = window->current_location_bookmark; - window->current_location_bookmark = location == NULL ? NULL + window->current_location_bookmark = (location == NULL) ? NULL : nautilus_bookmark_new (location, location); } - update_title (window); + nautilus_window_update_title (window); nautilus_window_update_icon (window); } @@ -411,6 +312,7 @@ viewed_file_changed_callback (NautilusFile *file, * need to cancel it before closing the window * or things break. */ + /* BONOBOTODO: remove this? */ /* FIXME: It makes no sense that this call is * needed. When the window is destroyed, it * calls nautilus_window_manage_views_destroy, @@ -466,26 +368,12 @@ viewed_file_changed_callback (NautilusFile *file, g_free (new_location); } - update_title (window); + nautilus_window_update_title (window); nautilus_window_update_icon (window); } } static void -cancel_viewed_file_changed_callback (NautilusWindow *window) -{ - NautilusFile *file; - - file = window->details->viewed_file; - if (file != NULL) { - g_signal_handlers_disconnect_by_func (G_OBJECT (file), - G_CALLBACK (viewed_file_changed_callback), - window); - nautilus_file_monitor_remove (file, &window->details->viewed_file); - } -} - -static void update_history (NautilusWindow *window, NautilusLocationChangeType type, const char *new_location) @@ -516,125 +404,18 @@ update_history (NautilusWindow *window, g_return_if_fail (FALSE); } -/* Handle the changes for the NautilusWindow itself. */ static void -update_for_new_location (NautilusWindow *window) +cancel_viewed_file_changed_callback (NautilusWindow *window) { - char *new_location; NautilusFile *file; - - new_location = window->details->pending_location; - window->details->pending_location = NULL; - - update_history (window, window->details->location_change_type, new_location); - - /* Set the new location. */ - g_free (window->details->location); - window->details->location = new_location; - - /* Create a NautilusFile for this location, so we can catch it - * if it goes away. - */ - cancel_viewed_file_changed_callback (window); - file = nautilus_file_get (window->details->location); - nautilus_window_set_viewed_file (window, file); - window->details->viewed_file_seen = !nautilus_file_is_not_yet_confirmed (file); - nautilus_file_monitor_add (file, &window->details->viewed_file, 0); - g_signal_connect_object (file, "changed", - G_CALLBACK (viewed_file_changed_callback), window, 0); - nautilus_file_unref (file); - - /* Check if we can go up. */ - update_up_button (window); - - /* Set up the content view menu for this new location. */ - nautilus_window_load_view_as_menus (window); - - /* Load menus from nautilus extensions for this location */ - nautilus_window_load_extension_menus (window); - -#if !NEW_UI_COMPLETE - if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) { - /* Check if the back and forward buttons need enabling or disabling. */ - nautilus_navigation_window_allow_back (NAUTILUS_NAVIGATION_WINDOW (window), NAUTILUS_NAVIGATION_WINDOW (window)->back_list != NULL); - nautilus_navigation_window_allow_forward (NAUTILUS_NAVIGATION_WINDOW (window), NAUTILUS_NAVIGATION_WINDOW (window)->forward_list != NULL); - - /* Change the location bar to match the current location. */ - nautilus_navigation_bar_set_location (NAUTILUS_NAVIGATION_BAR (NAUTILUS_NAVIGATION_WINDOW (window)->navigation_bar), - window->details->location); - - nautilus_navigation_window_load_extension_toolbar_items (NAUTILUS_NAVIGATION_WINDOW (window)); - } - - /* Notify the information panel of the location change. */ - /* FIXME bugzilla.gnome.org 40211: - * Eventually, this will not be necessary when we restructure the - * sidebar itself to be a NautilusViewFrame. - */ - if (NAUTILUS_IS_NAVIGATION_WINDOW (window) - && NAUTILUS_NAVIGATION_WINDOW (window)->information_panel) { - nautilus_information_panel_set_uri (NAUTILUS_NAVIGATION_WINDOW (window)->information_panel, - window->details->location, - window->details->title); - } - - if (NAUTILUS_IS_SPATIAL_WINDOW (window)) { - /* Change the location button to match the current location. */ - nautilus_spatial_window_set_location_button - (NAUTILUS_SPATIAL_WINDOW (window), - window->details->location); - } -#endif -} - -static gboolean -unref_callback (gpointer callback_data) -{ - g_object_unref (callback_data); - return FALSE; -} - -static void -ref_now_unref_at_idle_time (GObject *object) -{ - g_object_ref (object); - g_idle_add (unref_callback, object); -} -/* This is called when we have decided we can actually change to the new view/location situation. */ -static void -location_has_really_changed (NautilusWindow *window) -{ - /* Switch to the new content view. */ - if (GTK_WIDGET (window->new_content_view)->parent == NULL) { - /* If we don't unref the old view until idle - * time, we avoid certain kinds of problems in - * in-process components, since they won't - * lose their ViewFrame in the middle of some - * operation. This still doesn't necessarily - * help for out of process components. - */ - if (window->content_view != NULL) { - ref_now_unref_at_idle_time (G_OBJECT (window->content_view)); - } - - disconnect_view (window, window->content_view); - nautilus_window_set_content_view_widget (window, window->new_content_view); - } - g_object_unref (window->new_content_view); - window->new_content_view = NULL; - - if (window->details->pending_location != NULL) { - /* Tell the window we are finished. */ - update_for_new_location (window); + file = window->details->viewed_file; + if (file != NULL) { + g_signal_handlers_disconnect_by_func (G_OBJECT (file), + G_CALLBACK (viewed_file_changed_callback), + window); + nautilus_file_monitor_remove (file, &window->details->viewed_file); } - - free_location_change (window); - - update_title (window); - nautilus_window_update_icon (window); - - gtk_widget_show (GTK_WIDGET (window)); } static void @@ -653,12 +434,12 @@ new_window_show_callback (GtkWidget *widget, } -static void -open_location (NautilusWindow *window, - const char *location, - Nautilus_ViewFrame_OpenMode mode, - Nautilus_ViewFrame_OpenFlags flags, - GList *new_selection) +void +nautilus_window_open_location_full (NautilusWindow *window, + const char *location, + NautilusWindowOpenMode mode, + NautilusWindowOpenFlags flags, + GList *new_selection) { NautilusWindow *target_window; gboolean do_load_location = TRUE; @@ -666,7 +447,7 @@ open_location (NautilusWindow *window, target_window = NULL; switch (mode) { - case Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE : + case NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE : if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) { target_window = window; if (NAUTILUS_IS_SPATIAL_WINDOW (window)) { @@ -695,14 +476,14 @@ open_location (NautilusWindow *window, target_window = window; } break; - case Nautilus_ViewFrame_OPEN_IN_SPATIAL : + case NAUTILUS_WINDOW_OPEN_IN_SPATIAL : target_window = nautilus_application_present_spatial_window ( window->application, window, location, gtk_window_get_screen (GTK_WINDOW (window))); break; - case Nautilus_ViewFrame_OPEN_IN_NAVIGATION : + case NAUTILUS_WINDOW_OPEN_IN_NAVIGATION : target_window = nautilus_application_create_navigation_window (window->application, gtk_window_get_screen (GTK_WINDOW (window))); @@ -714,7 +495,7 @@ open_location (NautilusWindow *window, g_assert (target_window != NULL); - if ((flags & Nautilus_ViewFrame_OPEN_FLAG_CLOSE_BEHIND) != 0) { + if ((flags & NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND) != 0) { if (NAUTILUS_IS_SPATIAL_WINDOW (window) && !NAUTILUS_IS_DESKTOP_WINDOW (window)) { if (GTK_WIDGET_VISIBLE (target_window)) { nautilus_window_close (window); @@ -732,14 +513,11 @@ open_location (NautilusWindow *window, return; } - eel_g_list_free_deep (target_window->details->pending_selection); - target_window->details->pending_selection = eel_g_str_list_copy (new_selection); - if (!eel_is_valid_uri (location)) g_warning ("Possibly invalid new URI '%s'\n" "This can cause subtle evils like #48423", location); - begin_location_change (target_window, location, + begin_location_change (target_window, location, new_selection, NAUTILUS_LOCATION_CHANGE_STANDARD, 0, NULL); } @@ -748,16 +526,16 @@ nautilus_window_open_location (NautilusWindow *window, const char *location, gboolean close_behind) { - Nautilus_ViewFrame_OpenFlags flags; + NautilusWindowOpenFlags flags; flags = 0; if (close_behind) { - flags = Nautilus_ViewFrame_OPEN_FLAG_CLOSE_BEHIND; + flags = NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND; } - open_location (window, location, - Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE, - flags, NULL); + nautilus_window_open_location_full (window, location, + NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE, + flags, NULL); } void @@ -766,80 +544,36 @@ nautilus_window_open_location_with_selection (NautilusWindow *window, GList *selection, gboolean close_behind) { - Nautilus_ViewFrame_OpenFlags flags; + NautilusWindowOpenFlags flags; flags = 0; if (close_behind) { - flags = Nautilus_ViewFrame_OPEN_FLAG_CLOSE_BEHIND; + flags = NAUTILUS_WINDOW_OPEN_FLAG_CLOSE_BEHIND; } - open_location (window, location, - Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE, - flags, selection); + nautilus_window_open_location_full (window, location, + NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE, + flags, selection); } - -static ViewFrameInfo * -view_frame_info_new (const NautilusViewIdentifier *id) -{ - ViewFrameInfo *new_info; - - g_return_val_if_fail (id != NULL, NULL); - - new_info = g_new (ViewFrameInfo, 1); - new_info->id = nautilus_view_identifier_copy (id); - - return new_info; -} - -static void -view_frame_info_free (ViewFrameInfo *info) -{ - if (info != NULL) { - nautilus_view_identifier_free (info->id); - g_free (info); - } -} - -static void -set_view_frame_info (NautilusViewFrame *view_frame, - const NautilusViewIdentifier *id) -{ - g_object_set_data_full (G_OBJECT (view_frame), - "info", - view_frame_info_new (id), - (GtkDestroyNotify) view_frame_info_free); -} - char * -nautilus_window_get_view_frame_label (NautilusViewFrame *view_frame) +nautilus_window_get_view_label (NautilusWindow *window) { - ViewFrameInfo *info; + const NautilusViewInfo *info; - info = (ViewFrameInfo *) g_object_get_data - (G_OBJECT (view_frame), "info"); - return g_strdup (info->id->name); -} - - -static NautilusViewIdentifier * -view_frame_get_id (NautilusViewFrame *view_frame) -{ - ViewFrameInfo *info; + info = nautilus_view_factory_lookup (nautilus_window_get_content_view_id (window)); - info = (ViewFrameInfo *) g_object_get_data - (G_OBJECT (view_frame), "info"); - return nautilus_view_identifier_copy (info->id); + return g_strdup (info->label); } static void report_content_view_failure_to_user_internal (NautilusWindow *window, - NautilusViewFrame *view_frame, + NautilusView *view, const char *message, const char *detail) { char *label; - label = nautilus_window_get_view_frame_label (view_frame); + label = nautilus_window_get_view_label (window); message = g_strdup_printf (message, label); eel_show_error_dialog (message, detail, _("View Failed"), GTK_WINDOW (window)); g_free (label); @@ -847,127 +581,374 @@ report_content_view_failure_to_user_internal (NautilusWindow *window, static void report_current_content_view_failure_to_user (NautilusWindow *window, - NautilusViewFrame *view_frame) + NautilusView *view) { report_content_view_failure_to_user_internal (window, - view_frame, + view, _("The %s view encountered an error and can't continue."), _("You can choose another view or go to a different location.")); } static void report_nascent_content_view_failure_to_user (NautilusWindow *window, - NautilusViewFrame *view_frame) + NautilusView *view) { report_content_view_failure_to_user_internal (window, - view_frame, + view, _("The %s view encountered an error while starting up."), _("The location cannot be displayed with this viewer.")); } -static void -load_new_location_in_one_view (NautilusViewFrame *view, - const char *new_location, - GList *new_selection) + +const char * +nautilus_window_get_content_view_id (NautilusWindow *window) +{ + if (window->content_view == NULL) { + return NULL; + } + return nautilus_view_get_view_id (window->content_view); +} + +gboolean +nautilus_window_content_view_matches_iid (NautilusWindow *window, + const char *iid) +{ + if (window->content_view == NULL) { + return FALSE; + } + return eel_strcmp (nautilus_view_get_view_id (window->content_view), + iid) == 0; +} + + +static gboolean +another_navigation_window_already_showing (NautilusWindow *the_window) +{ + GList *list, *item; + + list = nautilus_application_get_window_list (); + for (item = list; item != NULL; item = item->next) { + if (item->data != the_window && + NAUTILUS_IS_NAVIGATION_WINDOW (item->data)) { + return TRUE; + } + } + + return FALSE; +} + +/* utility routine that returns true if there's one or fewer windows in the window list */ +static gboolean +just_one_window (void) { - nautilus_view_frame_load_location (view, new_location); - nautilus_view_frame_selection_changed (view, new_selection); + return !eel_g_list_more_than_one_item + (nautilus_application_get_window_list ()); } + +/* + * begin_location_change + * + * Change a window's location. + * @window: The NautilusWindow whose location should be changed. + * @location: A url specifying the location to load + * @new_selection: The initial selection to present after loading the location + * @type: Which type of location change is this? Standard, back, forward, or reload? + * @distance: If type is back or forward, the index into the back or forward chain. If + * type is standard or reload, this is ignored, and must be 0. + * @scroll_pos: The file to scroll to when the location is loaded. + * + * This is the core function for changing the location of a window. Every change to the + * location begins here. + */ static void -load_new_location_in_all_views (NautilusWindow *window, - const char *location, - GList *selection, - NautilusViewFrame *view_to_skip) +begin_location_change (NautilusWindow *window, + const char *location, + GList *new_selection, + NautilusLocationChangeType type, + guint distance, + const char *scroll_pos) { - GList *views; - GList *l; - NautilusViewFrame *view; + NautilusDirectory *directory; + NautilusFile *file; + gboolean force_reload; + char *current_pos; + + g_assert (NAUTILUS_IS_WINDOW (window)); + g_assert (location != NULL); + g_assert (type == NAUTILUS_LOCATION_CHANGE_BACK + || type == NAUTILUS_LOCATION_CHANGE_FORWARD + || distance == 0); + + g_object_ref (window); + + end_location_change (window); - g_assert (NAUTILUS_IS_WINDOW (window)); - g_assert (location != NULL); + nautilus_window_allow_stop (window, TRUE); + nautilus_window_set_status (window, " "); - set_displayed_location (window, location); + g_assert (window->details->pending_location == NULL); + g_assert (window->details->pending_selection == NULL); + + window->details->pending_location = g_strdup (location); + window->details->location_change_type = type; + window->details->location_change_distance = distance; + window->details->pending_selection = eel_g_str_list_copy (new_selection); - if (window->new_content_view != view_to_skip - && window->new_content_view != NULL) { - load_new_location_in_one_view (window->new_content_view, - location, - selection); - } + + window->details->pending_scroll_to = g_strdup (scroll_pos); + + directory = nautilus_directory_get (location); - /* Copy the list before traversing it, because during a failure in - * load_new..., list could be modified and bad things would happen - * also reference each object in case of re-enterency eg. window close. + /* The code to force a reload is here because if we do it + * after determining an initial view (in the components), then + * we end up fetching things twice. */ - views = NULL; - for (l = window->views; l; l = l->next) { - if (l->data != view_to_skip && - l->data != window->content_view && - l->data != window->new_content_view) { - views = g_list_prepend (views, g_object_ref (l->data)); - } - } + if (type == NAUTILUS_LOCATION_CHANGE_RELOAD) { + force_reload = TRUE; + } else if (!nautilus_monitor_active ()) { + force_reload = TRUE; + } else { + force_reload = !nautilus_directory_is_local (directory); + } - for (l = views; l != NULL; l = l->next) { - view = l->data; - load_new_location_in_one_view (view, location, selection); - } + if (force_reload) { + nautilus_directory_force_reload (directory); + file = nautilus_directory_get_corresponding_file (directory); + nautilus_file_invalidate_all_attributes (file); + nautilus_file_unref (file); + } + + nautilus_directory_unref (directory); - for (l = views; l; l = l->next) { - g_object_unref (l->data); + /* Set current_bookmark scroll pos */ + if (window->current_location_bookmark != NULL && + window->content_view != NULL) { + current_pos = nautilus_view_get_first_visible_file (window->content_view); + nautilus_bookmark_set_scroll_pos (window->current_location_bookmark, current_pos); + g_free (current_pos); } - g_list_free (views); + /* Get the info needed for view selection */ + + window->details->determine_view_file = nautilus_file_get (location); + + g_assert (window->details->determine_view_file != NULL); + + nautilus_file_call_when_ready (window->details->determine_view_file, + NAUTILUS_FILE_ATTRIBUTE_IS_DIRECTORY | + NAUTILUS_FILE_ATTRIBUTE_MIME_TYPE | + NAUTILUS_FILE_ATTRIBUTE_METADATA, + got_file_info_for_view_selection_callback, + window); + + g_object_unref (window); } static void -set_to_pending_location_and_selection (NautilusWindow *window) +setup_new_window (NautilusWindow *window, NautilusFile *file) { - g_assert (window->new_content_view != NULL); - - if (window->details->pending_location == NULL) { - g_assert (window->details->pending_selection == NULL); - return; - } + char *show_hidden_file_setting; + char *geometry_string; + char *scroll_string; + + if (NAUTILUS_IS_SPATIAL_WINDOW (window) && !NAUTILUS_IS_DESKTOP_WINDOW (window)) { + /* load show hidden state */ + show_hidden_file_setting = nautilus_file_get_metadata + (file, NAUTILUS_METADATA_KEY_WINDOW_SHOW_HIDDEN_FILES, + NULL); + if (show_hidden_file_setting != NULL) { + if (strcmp (show_hidden_file_setting, "1") == 0) { + NAUTILUS_WINDOW (window)->details->show_hidden_files_mode = NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_ENABLE; + } else { + NAUTILUS_WINDOW (window)->details->show_hidden_files_mode = NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_DISABLE; + } + } else { + NAUTILUS_WINDOW (window)->details->show_hidden_files_mode = NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_DEFAULT; + } + g_free (show_hidden_file_setting); + + /* load the saved window geometry */ + geometry_string = nautilus_file_get_metadata + (file, NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY, NULL); + if (geometry_string != NULL) { + eel_gtk_window_set_initial_geometry_from_string + (GTK_WINDOW (window), + geometry_string, + NAUTILUS_SPATIAL_WINDOW_MIN_WIDTH, + NAUTILUS_SPATIAL_WINDOW_MIN_HEIGHT, + FALSE); + } + g_free (geometry_string); - load_new_location_in_all_views (window, - window->details->pending_location, - window->details->pending_selection, - NULL); - - eel_g_list_free_deep (window->details->pending_selection); - window->details->pending_selection = NULL; -} + if (window->details->pending_selection == NULL) { + /* If there is no pending selection, then load the saved scroll position. */ + scroll_string = nautilus_file_get_metadata + (file, NAUTILUS_METADATA_KEY_WINDOW_SCROLL_POSITION, + NULL); + } else { + /* If there is a pending selection, we want to scroll to an item in + * the pending selection list. */ + scroll_string = g_strdup (window->details->pending_selection->data); + } -NautilusViewIdentifier * -nautilus_window_get_content_view_id (NautilusWindow *window) -{ - if (window->content_view == NULL) { - return NULL; + /* scroll_string might be NULL if there was no saved scroll position. */ + if (scroll_string != NULL) { + window->details->pending_scroll_to = scroll_string; + } } - return view_frame_get_id (window->content_view); + + if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) { + geometry_string = eel_preferences_get + (NAUTILUS_PREFERENCES_NAVIGATION_WINDOW_SAVED_GEOMETRY); + if (geometry_string != NULL && + geometry_string[0] != 0) { + /* Ignore saved window position if a window with the same + * location is already showing. That way the two windows + * wont appear at the exact same location on the screen. + */ + eel_gtk_window_set_initial_geometry_from_string + (GTK_WINDOW (window), + geometry_string, + NAUTILUS_WINDOW_MIN_WIDTH, + NAUTILUS_WINDOW_MIN_HEIGHT, + another_navigation_window_already_showing (window)); + } + g_free (geometry_string); + } } -gboolean -nautilus_window_content_view_matches_iid (NautilusWindow *window, - const char *iid) +static void +got_file_info_for_view_selection_callback (NautilusFile *file, + gpointer callback_data) { - if (window->content_view == NULL) { - return FALSE; - } - return eel_strcmp (nautilus_view_frame_get_view_iid (window->content_view), - iid) == 0; + GnomeVFSResult vfs_result_code; + char *view_id; + char *mimetype; + NautilusWindow *window; + char *location; + char *home_uri; + + window = callback_data; + + g_assert (window->details->determine_view_file == file); + window->details->determine_view_file = NULL; + + location = window->details->pending_location; + + view_id = NULL; + + vfs_result_code = nautilus_file_get_file_info_result (file); + if (vfs_result_code == GNOME_VFS_OK + || vfs_result_code == GNOME_VFS_ERROR_NOT_SUPPORTED + || vfs_result_code == GNOME_VFS_ERROR_INVALID_URI) { + /* We got the information we need, now pick what view to use: */ + + mimetype = nautilus_file_get_mime_type (file); + + /* If fallback, don't use view from metadata */ + if (window->details->location_change_type != NAUTILUS_LOCATION_CHANGE_FALLBACK) { + /* Look in metadata for view */ + view_id = nautilus_file_get_metadata + (file, NAUTILUS_METADATA_KEY_DEFAULT_COMPONENT, NULL); + if (view_id != NULL && + !nautilus_view_factory_view_supports_uri (view_id, + location, + nautilus_file_get_file_type (file), + mimetype)) { + g_free (view_id); + view_id = NULL; + } + } + + /* Otherwise, use default */ + if (view_id == NULL) { + view_id = nautilus_global_preferences_get_default_folder_viewer_preference_as_iid (); + + if (view_id != NULL && + !nautilus_view_factory_view_supports_uri (view_id, + location, + nautilus_file_get_file_type (file), + mimetype)) { + g_free (view_id); + view_id = NULL; + } + } + + g_free (mimetype); + } + + if (view_id != NULL) { + if (!GTK_WIDGET_VISIBLE (window)) { + /* We now have the metadata to set up the window position, etc */ + setup_new_window (window, file); + } + create_content_view (window, view_id); + g_free (view_id); + } else { + display_view_selection_failure (window, file, + location); + + if (!GTK_WIDGET_VISIBLE (GTK_WIDGET (window))) { + /* Destroy never-had-a-chance-to-be-seen window. This case + * happens when a new window cannot display its initial URI. + */ + /* if this is the only window, we don't want to quit, so we redirect it to home */ + if (just_one_window ()) { + /* Make sure we re-use this window */ + if (NAUTILUS_IS_SPATIAL_WINDOW (window)) { + NAUTILUS_SPATIAL_WINDOW (window)->affect_spatial_window_on_next_location_change = TRUE; + } + /* the user could have typed in a home directory that doesn't exist, + in which case going home would cause an infinite loop, so we + better test for that */ + + if (!eel_uris_match (location, "file:///")) { + home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ()); + if (!eel_uris_match (home_uri, location)) { + nautilus_window_go_home (NAUTILUS_WINDOW (window)); + } else { + /* the last fallback is to go to a known place that can't be deleted! */ + nautilus_window_go_to (NAUTILUS_WINDOW (window), "file:///"); + } + g_free (home_uri); + } else { + gtk_object_destroy (GTK_OBJECT (window)); + } + } else { + /* Since this is a window, destroying it will also unref it. */ + gtk_object_destroy (GTK_OBJECT (window)); + } + } else { + /* Clean up state of already-showing window */ + end_location_change (window); + + /* Leave the location bar showing the bad location that the user + * typed (or maybe achieved by dragging or something). Many times + * the mistake will just be an easily-correctable typo. The user + * can choose "Refresh" to get the original URI back in the location bar. + */ + } + } + + nautilus_file_unref (file); } +/* Load a view into the window, either reusing the old one or creating + * a new one. This happens when you want to load a new location, or just + * switch to a different view. + * If pending_location is set we're loading a new location and + * pending_location/selection will be used. If not, we're just switching + * view, and the current location will be used. + */ static void -load_content_view (NautilusWindow *window, - const NautilusViewIdentifier *id) +create_content_view (NautilusWindow *window, + const char *view_id) { - const char *iid; - NautilusViewFrame *view; + NautilusView *view; + GList *selection; /* FIXME bugzilla.gnome.org 41243: * We should use inheritance instead of these special cases @@ -978,11 +959,8 @@ load_content_view (NautilusWindow *window, * to fix it here than trying to make it pick the right view in * the first place. */ - iid = NAUTILUS_DESKTOP_ICON_VIEW_IID; - } else { - g_return_if_fail (id != NULL); - iid = id->iid; - } + view_id = NAUTILUS_DESKTOP_ICON_VIEW_IID; + } nautilus_window_ui_freeze (window); @@ -999,120 +977,225 @@ load_content_view (NautilusWindow *window, bonobo_ui_component_thaw (window->details->shell_ui, NULL); - if (nautilus_window_content_view_matches_iid (window, iid)) { + if (window->content_view != NULL && + eel_strcmp (nautilus_view_get_view_id (window->content_view), + view_id) == 0) { /* reuse existing content view */ view = window->content_view; window->new_content_view = view; g_object_ref (view); - set_to_pending_location_and_selection (window); } else { /* create a new content view */ - view = nautilus_view_frame_new (window->details->ui_container, - window->application->undo_manager, - NAUTILUS_WINDOW_GET_CLASS (window)->window_type); + view = nautilus_view_factory_create (view_id, + NAUTILUS_WINDOW_INFO (window)); eel_accessibility_set_name (view, _("Content View")); - eel_accessibility_set_description (view, _("View of the current file or folder")); + eel_accessibility_set_description (view, _("View of the current folder")); + connect_view (window, view); + window->new_content_view = view; - g_object_ref (view); - gtk_object_sink (GTK_OBJECT (view)); - set_view_frame_info (view, id); - nautilus_view_frame_set_show_hidden_files_mode (view, NAUTILUS_WINDOW (window)->details->show_hidden_files_mode, FALSE); - connect_view (window, view, TRUE); - nautilus_view_frame_load_view (view, iid); } + /* Actually load the pending location and selection: */ + + if (window->details->pending_location != NULL) { + load_new_location (window, + window->details->pending_location, + window->details->pending_selection, + FALSE, + TRUE); + + eel_g_list_free_deep (window->details->pending_selection); + window->details->pending_selection = NULL; + } else if (window->details->location != NULL) { + selection = nautilus_view_get_selection (window->content_view); + load_new_location (window, + window->details->location, + selection, + FALSE, + TRUE); + eel_g_list_free_deep (selection); + } else { + /* Something is busted, there was no location to load. + Just load the homedir. */ + nautilus_window_go_home (NAUTILUS_WINDOW (window)); + + } nautilus_window_ui_thaw (window); } static void -handle_view_failure (NautilusWindow *window, - NautilusViewFrame *view) -{ - gboolean do_close_window; - char *fallback_load_location; - g_warning ("A view failed. The UI will handle this with a dialog but this should be debugged."); +load_new_location (NautilusWindow *window, + const char *location, + GList *selection, + gboolean tell_current_content_view, + gboolean tell_new_content_view) +{ + char *location_copy; + GList *selection_copy; + NautilusView *view; + + g_assert (NAUTILUS_IS_WINDOW (window)); + g_assert (location != NULL); + set_displayed_location (window, location); - do_close_window = FALSE; - fallback_load_location = NULL; + selection_copy = eel_g_str_list_copy (selection); + + view = NULL; - if (view == window->content_view) { - disconnect_view(window, window->content_view); - nautilus_window_set_content_view_widget (window, NULL); - - /* FIXME bugzilla.gnome.org 45039: We need a - * way to report the specific error that - * happens in this case - adapter factory not - * found, component failed to load, etc. - */ - report_current_content_view_failure_to_user (window, view); + /* Note, these may recurse into report_load_underway */ + if (window->content_view != NULL && tell_current_content_view) { + view = window->content_view; + nautilus_view_load_location (window->content_view, location); + } + + if (window->new_content_view != NULL && tell_new_content_view && + (!tell_current_content_view || + window->new_content_view != window->content_view) ) { + view = window->new_content_view; + nautilus_view_load_location (window->new_content_view, location); + } + if (view != NULL) { + /* window->new_content_view might have changed here if + report_load_underway was called from load_location */ + nautilus_view_set_selection (view, selection_copy); + } + + eel_g_list_free_deep (selection_copy); + + location_copy = g_strdup (location); + g_signal_emit_by_name (window, "loading_uri", + location_copy); + g_free (location_copy); + +} + +/* A view started to load the location its viewing, either due to + * a load_location request, or some internal reason. Expect + * a matching load_compete later + */ +void +nautilus_window_report_load_underway (NautilusWindow *window, + NautilusView *view) +{ + g_assert (NAUTILUS_IS_WINDOW (window)); + + if (view == window->new_content_view) { + location_has_really_changed (window); + } else if (view == window->content_view) { + nautilus_window_allow_stop (window, TRUE); } else { - /* Only report error on first try */ - if (window->details->location_change_type != NAUTILUS_LOCATION_CHANGE_FALLBACK) { - /* FIXME bugzilla.gnome.org 45039: We need a - * way to report the specific error that - * happens in this case - adapter factory not - * found, component failed to load, etc. - */ - report_nascent_content_view_failure_to_user (window, view); + g_warning ("Got load_underway report from unknown view"); + } +} - fallback_load_location = g_strdup (window->details->pending_location); - } else { - if (!GTK_WIDGET_VISIBLE (window)) { - do_close_window = TRUE; - } +/* This is called when we have decided we can actually change to the new view/location situation. */ +static void +location_has_really_changed (NautilusWindow *window) +{ + GtkWidget *widget; + + if (window->new_content_view != NULL) { + widget = nautilus_view_get_widget (window->new_content_view); + /* Switch to the new content view. */ + if (widget->parent == NULL) { + disconnect_view (window, window->content_view); + nautilus_window_set_content_view_widget (window, window->new_content_view); } - } + g_object_unref (window->new_content_view); + window->new_content_view = NULL; + } - cancel_location_change (window); + if (window->details->pending_location != NULL) { + /* Tell the window we are finished. */ + update_for_new_location (window); + } - if (fallback_load_location != NULL) { - begin_location_change (window, fallback_load_location, - NAUTILUS_LOCATION_CHANGE_FALLBACK, 0, NULL); - g_free (fallback_load_location); - } + free_location_change (window); - if (do_close_window) { - NautilusFile *file; - - if (window->details->pending_file_for_position != NULL) { - file = window->details->pending_file_for_position; - window->details->pending_file_for_position = NULL; - - nautilus_file_cancel_call_when_ready (file, - load_directory_metadata_callback, - window); - nautilus_file_unref (file); - } + nautilus_window_update_title (window); + nautilus_window_update_icon (window); - gtk_widget_destroy (GTK_WIDGET (window)); - } + gtk_widget_show (GTK_WIDGET (window)); } +/* Handle the changes for the NautilusWindow itself. */ static void -free_location_change (NautilusWindow *window) +update_for_new_location (NautilusWindow *window) { - g_free (window->details->pending_location); + char *new_location; + NautilusFile *file; + + new_location = window->details->pending_location; window->details->pending_location = NULL; - - /* Don't free pending_scroll_to, since thats needed until - * the load_complete callback. + + update_history (window, window->details->location_change_type, new_location); + + /* Set the new location. */ + g_free (window->details->location); + window->details->location = new_location; + + /* Create a NautilusFile for this location, so we can catch it + * if it goes away. */ + cancel_viewed_file_changed_callback (window); + file = nautilus_file_get (window->details->location); + nautilus_window_set_viewed_file (window, file); + window->details->viewed_file_seen = !nautilus_file_is_not_yet_confirmed (file); + nautilus_file_monitor_add (file, &window->details->viewed_file, 0); + g_signal_connect_object (file, "changed", + G_CALLBACK (viewed_file_changed_callback), window, 0); + nautilus_file_unref (file); + + /* Check if we can go up. */ + update_up_button (window); + + /* Set up the content view menu for this new location. */ + nautilus_window_load_view_as_menus (window); + + /* Load menus from nautilus extensions for this location */ + nautilus_window_load_extension_menus (window); + +#if !NEW_UI_COMPLETE + if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) { + /* Check if the back and forward buttons need enabling or disabling. */ + nautilus_navigation_window_allow_back (NAUTILUS_NAVIGATION_WINDOW (window), NAUTILUS_NAVIGATION_WINDOW (window)->back_list != NULL); + nautilus_navigation_window_allow_forward (NAUTILUS_NAVIGATION_WINDOW (window), NAUTILUS_NAVIGATION_WINDOW (window)->forward_list != NULL); + + /* Change the location bar to match the current location. */ + nautilus_navigation_bar_set_location (NAUTILUS_NAVIGATION_BAR (NAUTILUS_NAVIGATION_WINDOW (window)->navigation_bar), + window->details->location); - if (window->details->determine_view_handle != NULL) { - nautilus_determine_initial_view_cancel (window->details->determine_view_handle); - window->details->determine_view_handle = NULL; + nautilus_navigation_window_load_extension_toolbar_items (NAUTILUS_NAVIGATION_WINDOW (window)); } + + if (NAUTILUS_IS_SPATIAL_WINDOW (window)) { + /* Change the location button to match the current location. */ + nautilus_spatial_window_set_location_button + (NAUTILUS_SPATIAL_WINDOW (window), + window->details->location); + } +#endif +} - if (window->new_content_view != NULL) { - if (window->new_content_view != window->content_view) { - disconnect_view (window, window->new_content_view); - gtk_widget_destroy (GTK_WIDGET (window->new_content_view)); - } - g_object_unref (window->new_content_view); - window->new_content_view = NULL; +/* A location load previously announced by load_underway + * has been finished */ +void +nautilus_window_report_load_complete (NautilusWindow *window, + NautilusView *view) +{ + g_assert (NAUTILUS_IS_WINDOW (window)); + + /* Only handle this if we're expecting it. + * Don't handle it if its from an old view we've switched from */ + if (view == window->content_view) { + if (window->details->pending_scroll_to != NULL) { + nautilus_view_scroll_to_file (window->content_view, + window->details->pending_scroll_to); + } + end_location_change (window); } } @@ -1131,316 +1214,190 @@ end_location_change (NautilusWindow *window) } static void +free_location_change (NautilusWindow *window) +{ + g_free (window->details->pending_location); + window->details->pending_location = NULL; + + eel_g_list_free_deep (window->details->pending_selection); + window->details->pending_selection = NULL; + + /* Don't free pending_scroll_to, since thats needed until + * the load_complete callback. + */ + + if (window->details->determine_view_file != NULL) { + nautilus_file_cancel_call_when_ready + (window->details->determine_view_file, + got_file_info_for_view_selection_callback, window); + window->details->determine_view_file = NULL; + } + + if (window->new_content_view != NULL) { + disconnect_view (window, window->new_content_view); + g_object_unref (window->new_content_view); + window->new_content_view = NULL; + } +} + +static void cancel_location_change (NautilusWindow *window) { + GList *selection; + if (window->details->pending_location != NULL && window->details->location != NULL - && window->content_view != NULL - && nautilus_view_frame_get_is_view_loaded (window->content_view)) { + && window->content_view != NULL) { /* No need to tell the new view - either it is the * same as the old view, in which case it will already * be told, or it is the very pending change we wish * to cancel. */ - - load_new_location_in_all_views (window, - window->details->location, - window->details->selection, - window->new_content_view); + selection = nautilus_view_get_selection (window->new_content_view); + load_new_location (window, + window->details->location, + selection, + TRUE, + FALSE); + eel_g_list_free_deep (selection); + } end_location_change (window); } -static gboolean -pending_location_already_showing (NautilusWindow *window) -{ - char *temp; - char *location; - GList *list, *item; - - temp = window->details->pending_location; - list = nautilus_application_get_window_list (); - for (item = list; item != NULL; item = item->next) { - location = nautilus_window_get_location (NAUTILUS_WINDOW (item->data)); - - if (!NAUTILUS_IS_DESKTOP_WINDOW (item->data) - && location != NULL - && item->data != window - && !strcmp (temp, location)) { - g_free (location); - return TRUE; - } - - g_free (location); - } - - return FALSE; -} - -static gboolean -another_navigation_window_already_showing (NautilusWindow *the_window) +void +nautilus_window_report_view_failed (NautilusWindow *window, + NautilusView *view) { - GList *list, *item; - - list = nautilus_application_get_window_list (); - for (item = list; item != NULL; item = item->next) { - if (item->data != the_window && - NAUTILUS_IS_NAVIGATION_WINDOW (item->data)) { - return TRUE; - } - } - - return FALSE; -} + gboolean do_close_window; + char *fallback_load_location; + g_warning ("A view failed. The UI will handle this with a dialog but this should be debugged."); -static void -load_directory_metadata_callback (NautilusFile *file, - gpointer callback_data) -{ - NautilusWindow *window; - char *geometry_string; - char *scroll_string; - char *show_hidden_file_setting; - ViewFrameWindowInfo *new_info; - NautilusViewIdentifier *initial_view; - - new_info = callback_data; - window = NAUTILUS_WINDOW (new_info->window); - initial_view = new_info->id; - g_assert (window->details->pending_file_for_position == file); + do_close_window = FALSE; + fallback_load_location = NULL; -#if !NEW_UI_COMPLETE - if (NAUTILUS_IS_SPATIAL_WINDOW (window) && !NAUTILUS_IS_DESKTOP_WINDOW (window)) { - - /* load show hidden state */ - show_hidden_file_setting = nautilus_file_get_metadata - (file, NAUTILUS_METADATA_KEY_WINDOW_SHOW_HIDDEN_FILES, - NULL); - if (show_hidden_file_setting != NULL) { - if (strcmp (show_hidden_file_setting, "1") == 0) { - NAUTILUS_WINDOW (window)->details->show_hidden_files_mode = Nautilus_SHOW_HIDDEN_FILES_ENABLE; - } else { - NAUTILUS_WINDOW (window)->details->show_hidden_files_mode = Nautilus_SHOW_HIDDEN_FILES_DISABLE; - } - } else { - NAUTILUS_WINDOW (window)->details->show_hidden_files_mode = Nautilus_SHOW_HIDDEN_FILES_DEFAULT; - } - g_free (show_hidden_file_setting); - - /* load the saved window geometry */ - geometry_string = nautilus_file_get_metadata - (file, NAUTILUS_METADATA_KEY_WINDOW_GEOMETRY, NULL); - if (geometry_string != NULL) { - /* Ignore saved window position if a window with the same - * location is already showing. That way the two windows - * wont appear at the exact same location on the screen. - */ - eel_gtk_window_set_initial_geometry_from_string - (GTK_WINDOW (window), - geometry_string, - NAUTILUS_SPATIAL_WINDOW_MIN_WIDTH, - NAUTILUS_SPATIAL_WINDOW_MIN_HEIGHT, - pending_location_already_showing (window)); - } - g_free (geometry_string); + if (view == window->content_view) { + disconnect_view (window, window->content_view); + nautilus_window_set_content_view_widget (window, NULL); + + report_current_content_view_failure_to_user (window, view); + } else { + /* Only report error on first try */ + if (window->details->location_change_type != NAUTILUS_LOCATION_CHANGE_FALLBACK) { + report_nascent_content_view_failure_to_user (window, view); - if (window->details->pending_selection == NULL) { - /* If there is no pending selection, then load the saved scroll position. */ - scroll_string = nautilus_file_get_metadata - (file, NAUTILUS_METADATA_KEY_WINDOW_SCROLL_POSITION, - NULL); + fallback_load_location = g_strdup (window->details->pending_location); } else { - /* If there is a pending selection, we want to scroll to an item in - * the pending selection list. */ - scroll_string = g_strdup (window->details->pending_selection->data); - } - - /* scroll_string might be NULL if there was no saved scroll position. */ - if (scroll_string != NULL) { - window->details->pending_scroll_to = scroll_string; + if (!GTK_WIDGET_VISIBLE (window)) { + do_close_window = TRUE; + } } } -#endif - if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) { - geometry_string = eel_preferences_get - (NAUTILUS_PREFERENCES_NAVIGATION_WINDOW_SAVED_GEOMETRY); - if (geometry_string != NULL && - geometry_string[0] != 0) { - /* Ignore saved window position if a window with the same - * location is already showing. That way the two windows - * wont appear at the exact same location on the screen. - */ - eel_gtk_window_set_initial_geometry_from_string - (GTK_WINDOW (window), - geometry_string, - NAUTILUS_WINDOW_MIN_WIDTH, - NAUTILUS_WINDOW_MIN_HEIGHT, - another_navigation_window_already_showing (window)); - } - g_free (geometry_string); - } - - - /* finish loading the view */ - load_content_view (window, initial_view); + + cancel_location_change (window); - nautilus_view_identifier_free (initial_view); - g_free (new_info); - - /* This object was ref'd when starting the callback. */ - nautilus_file_unref (file); - window->details->pending_file_for_position = NULL; -} + if (fallback_load_location != NULL) { + /* We loose the pending selection change here, but who cares... */ + begin_location_change (window, fallback_load_location, NULL, + NAUTILUS_LOCATION_CHANGE_FALLBACK, 0, NULL); + g_free (fallback_load_location); + } -/* utility routine that returns true if there's one or fewer windows in the window list */ -static gboolean -just_one_window (void) -{ - return !eel_g_list_more_than_one_item - (nautilus_application_get_window_list ()); + if (do_close_window) { + gtk_widget_destroy (GTK_WIDGET (window)); + } } static void -determined_initial_view_callback (NautilusDetermineViewHandle *handle, - NautilusDetermineViewResult result_code, - const NautilusViewIdentifier *initial_view, - gpointer data) -{ - NautilusWindow *window; - NautilusFile *file; - char *full_uri_for_display; - char *uri_for_display; - char *error_message; - char *detail_message; - char *scheme_string; - char *type_string; - char *dialog_title; - char *home_uri; - const char *host_name; - const char *location; +display_view_selection_failure (NautilusWindow *window, NautilusFile *file, + const char *location) +{ + GnomeVFSResult result_code; + char *full_uri_for_display; + char *uri_for_display; + char *error_message; + char *detail_message; + char *scheme_string; + char *dialog_title; + const char *host_name; GtkDialog *dialog; - NautilusFileAttributes attributes; - GnomeVFSURI *vfs_uri; - ViewFrameWindowInfo *new_info; - - window = NAUTILUS_WINDOW (data); - - g_assert (window->details->determine_view_handle == handle - || window->details->determine_view_handle == NULL); - window->details->determine_view_handle = NULL; - - location = window->details->pending_location; - - if (result_code == NAUTILUS_DETERMINE_VIEW_OK) { - /* If the window is not yet showing (as is the case for nascent - * windows), position and show it only after we've got the - * metadata (since position info is stored there). - */ - if (!GTK_WIDGET_VISIBLE (window)) { - file = nautilus_file_get (location); - window->details->pending_file_for_position = file; - new_info = g_new (ViewFrameWindowInfo, 1); - new_info->window = window; - new_info->id = nautilus_view_identifier_copy (initial_view); - attributes = NAUTILUS_FILE_ATTRIBUTE_METADATA; - nautilus_file_call_when_ready (file, - attributes, - load_directory_metadata_callback, - new_info); - } else { - load_content_view (window, initial_view); - } + GnomeVFSURI *vfs_uri; - return; - } - - /* Some sort of failure occurred. How 'bout we tell the user? */ - full_uri_for_display = eel_format_uri_for_display (location); + result_code = nautilus_file_get_file_info_result (file); + + /* Some sort of failure occurred. How 'bout we tell the user? */ + full_uri_for_display = eel_format_uri_for_display (location); /* Truncate the URI so it doesn't get insanely wide. Note that even * though the dialog uses wrapped text, if the URI doesn't contain * white space then the text-wrapping code is too stupid to wrap it. */ - uri_for_display = eel_str_middle_truncate - (full_uri_for_display, MAX_URI_IN_DIALOG_LENGTH); + uri_for_display = eel_str_middle_truncate + (full_uri_for_display, MAX_URI_IN_DIALOG_LENGTH); g_free (full_uri_for_display); - + dialog_title = NULL; - switch (result_code) { - - case NAUTILUS_DETERMINE_VIEW_NOT_FOUND: - error_message = g_strdup_printf - (_("Couldn't find \"%s\"."), - uri_for_display); - detail_message = g_strdup - (_("Please check the spelling and try again.")); - break; - - case NAUTILUS_DETERMINE_VIEW_INVALID_URI: - error_message = g_strdup_printf - (_("\"%s\" is not a valid location."), - uri_for_display); - detail_message = g_strdup - (_("Please check the spelling and try again.")); - break; - - case NAUTILUS_DETERMINE_VIEW_NO_HANDLER_FOR_TYPE: - /* FIXME bugzilla.gnome.org 40866: Can't expect to read the - * permissions instantly here. We might need to wait for - * a stat first. - */ - file = nautilus_file_get (location); - type_string = nautilus_file_get_string_attribute (file, "type"); - nautilus_file_unref (file); - if (type_string == NULL) { - error_message = g_strdup_printf - (_("Couldn't display \"%s\"."), - uri_for_display); + switch (result_code) { + case GNOME_VFS_OK: + if (nautilus_file_is_directory (file)) { + error_message = g_strdup_printf + (_("Couldn't display \"%s\"."), + uri_for_display); detail_message = g_strdup - (_("Nautilus cannot determine what type of file it is.")); - } else { - /* FIXME bugzilla.gnome.org 44932: - * Should distinguish URIs with no handlers at all from remote URIs - * with local-only handlers. - */ + (_("Nautilus has no installed viewer capable of displaying the folder.")); + } else { error_message = g_strdup_printf - (_("Couldn't display \"%s\"."), - uri_for_display); + (_("Couldn't display \"%s\"."), + uri_for_display); detail_message = g_strdup - (_("Nautilus has no installed viewer capable of displaying the file.")); - g_free (type_string); - } - break; - - case NAUTILUS_DETERMINE_VIEW_UNSUPPORTED_SCHEME: - /* Can't create a vfs_uri and get the method from that, because - * gnome_vfs_uri_new might return NULL. - */ - scheme_string = eel_str_get_prefix (location, ":"); - g_assert (scheme_string != NULL); /* Shouldn't have gotten this error unless there's a : separator. */ - error_message = g_strdup_printf (_("Couldn't display \"%s\"."), - uri_for_display); - detail_message = g_strdup_printf (_("Nautilus cannot handle %s: locations."), - scheme_string); - g_free (scheme_string); - break; - - case NAUTILUS_DETERMINE_VIEW_LOGIN_FAILED: - error_message = g_strdup_printf (_("Couldn't display \"%s\"."), - uri_for_display); - detail_message = g_strdup (_("The attempt to log in failed.")); + (_("The location is not a folder.")); + } break; - - case NAUTILUS_DETERMINE_VIEW_ACCESS_DENIED: - error_message = g_strdup_printf (_("Couldn't display \"%s\"."), - uri_for_display); + case GNOME_VFS_ERROR_NOT_FOUND: + error_message = g_strdup_printf + (_("Couldn't find \"%s\"."), + uri_for_display); + detail_message = g_strdup + (_("Please check the spelling and try again.")); + break; + + case GNOME_VFS_ERROR_INVALID_URI: + error_message = g_strdup_printf + (_("\"%s\" is not a valid location."), + uri_for_display); + detail_message = g_strdup + (_("Please check the spelling and try again.")); + break; + + case GNOME_VFS_ERROR_NOT_SUPPORTED: + /* Can't create a vfs_uri and get the method from that, because + * gnome_vfs_uri_new might return NULL. + */ + scheme_string = eel_str_get_prefix (location, ":"); + g_assert (scheme_string != NULL); /* Shouldn't have gotten this error unless there's a : separator. */ + error_message = g_strdup_printf (_("Couldn't display \"%s\"."), + uri_for_display); + detail_message = g_strdup_printf (_("Nautilus cannot handle %s: locations."), + scheme_string); + g_free (scheme_string); + break; + + case GNOME_VFS_ERROR_LOGIN_FAILED: + error_message = g_strdup_printf (_("Couldn't display \"%s\"."), + uri_for_display); + detail_message = g_strdup (_("The attempt to log in failed.")); + break; + + case GNOME_VFS_ERROR_ACCESS_DENIED: + error_message = g_strdup_printf (_("Couldn't display \"%s\"."), + uri_for_display); detail_message = g_strdup (_("Access was denied.")); break; - - case NAUTILUS_DETERMINE_VIEW_HOST_NOT_FOUND: + + case GNOME_VFS_ERROR_HOST_NOT_FOUND: /* This case can be hit for user-typed strings like "foo" due to * the code that guesses web addresses when there's no initial "/". * But this case is also hit for legitimate web addresses when @@ -1448,264 +1405,109 @@ determined_initial_view_callback (NautilusDetermineViewHandle *handle, */ vfs_uri = gnome_vfs_uri_new (location); host_name = gnome_vfs_uri_get_host_name (vfs_uri); - error_message = g_strdup_printf (_("Couldn't display \"%s\", because no host \"%s\" could be found."), - uri_for_display, - host_name ? host_name : ""); - detail_message = g_strdup (_("Check that the spelling is correct and that your proxy settings are correct.")); - gnome_vfs_uri_unref (vfs_uri); + error_message = g_strdup_printf (_("Couldn't display \"%s\", because no host \"%s\" could be found."), + uri_for_display, + host_name ? host_name : ""); + detail_message = g_strdup (_("Check that the spelling is correct and that your proxy settings are correct.")); + gnome_vfs_uri_unref (vfs_uri); break; - - case NAUTILUS_DETERMINE_VIEW_HOST_HAS_NO_ADDRESS: - error_message = g_strdup_printf (_("Couldn't display \"%s\"."), - uri_for_display); - detail_message = g_strdup (_("Check that your proxy settings are correct.")); + + case GNOME_VFS_ERROR_HOST_HAS_NO_ADDRESS: + error_message = g_strdup_printf (_("Couldn't display \"%s\"."), + uri_for_display); + detail_message = g_strdup (_("Check that your proxy settings are correct.")); break; - - case NAUTILUS_DETERMINE_VIEW_NO_MASTER_BROWSER: - error_message = g_strdup_printf - (_("Couldn't display \"%s\", because Nautilus cannot contact the SMB master browser."), - uri_for_display); - detail_message = g_strdup - (_("Check that an SMB server is running in the local network.")); - break; - - case NAUTILUS_DETERMINE_VIEW_SERVICE_NOT_AVAILABLE: + + case GNOME_VFS_ERROR_NO_MASTER_BROWSER: + error_message = g_strdup_printf + (_("Couldn't display \"%s\", because Nautilus cannot contact the SMB master browser."), + uri_for_display); + detail_message = g_strdup + (_("Check that an SMB server is running in the local network.")); + break; + + case GNOME_VFS_ERROR_SERVICE_NOT_AVAILABLE: if (nautilus_is_search_uri (location)) { /* FIXME bugzilla.gnome.org 42458: Need to give - * the user better advice about what to do - * here. - */ + * the user better advice about what to do + * here. + */ error_message = g_strdup_printf - (_("Searching is unavailable right now, because you either have no index, " - "or the search service isn't running.")); + (_("Searching is unavailable right now, because you either have no index, " + "or the search service isn't running.")); detail_message = g_strdup (_("Be sure that you have started the Medusa search service, and if you " - "don't have an index, that the Medusa indexer is running.")); + "don't have an index, that the Medusa indexer is running.")); dialog_title = g_strdup (_("Searching Unavailable")); break; } /* else fall through */ - default: - error_message = g_strdup_printf (_("Nautilus cannot display \"%s\"."), - uri_for_display); - detail_message = g_strdup (_("Please select another viewer and try again.")); - } - - if (dialog_title == NULL) { + default: + error_message = g_strdup_printf (_("Nautilus cannot display \"%s\"."), + uri_for_display); + detail_message = g_strdup (_("Please select another viewer and try again.")); + } + + if (dialog_title == NULL) { dialog_title = g_strdup (_("Can't Display Location")); - } - - if (!GTK_WIDGET_VISIBLE (GTK_WIDGET (window))) { - /* Destroy never-had-a-chance-to-be-seen window. This case - * happens when a new window cannot display its initial URI. - */ - - dialog = eel_show_error_dialog (error_message, detail_message, dialog_title, NULL); - - /* if this is the only window, we don't want to quit, so we redirect it to home */ - if (just_one_window ()) { - /* the user could have typed in a home directory that doesn't exist, - in which case going home would cause an infinite loop, so we - better test for that */ - - if (!eel_uris_match (location, "file:///")) { -#ifdef WEB_NAVIGATION_ENABLED - home_uri = eel_preferences_get (NAUTILUS_PREFERENCES_HOME_URI); -#else - home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ()); -#endif - if (!eel_uris_match (home_uri, location)) { - nautilus_window_go_home (NAUTILUS_WINDOW (window)); - } else { - /* the last fallback is to go to a known place that can't be deleted! */ - nautilus_window_go_to (NAUTILUS_WINDOW (window), "file:///"); - } - g_free (home_uri); - } - } else { - /* Since this is a window, destroying it will also unref it. */ - gtk_object_destroy (GTK_OBJECT (window)); - } - } else { - /* Clean up state of already-showing window */ - nautilus_window_allow_stop (window, FALSE); - eel_show_error_dialog (error_message, detail_message, dialog_title, GTK_WINDOW (window)); - - /* Leave the location bar showing the bad location that the user - * typed (or maybe achieved by dragging or something). Many times - * the mistake will just be an easily-correctable typo. The user - * can choose "Refresh" to get the original URI back in the location bar. - */ - } + } + dialog = eel_show_error_dialog (error_message, detail_message, dialog_title, NULL); + g_free (dialog_title); g_free (uri_for_display); - g_free (error_message); - g_free (detail_message); + g_free (error_message); + g_free (detail_message); } -/* - * begin_location_change - * - * Change a window's location. - * @window: The NautilusWindow whose location should be changed. - * @loc: A Nautilus_NavigationRequestInfo specifying info about this transition. - * @type: Which type of location change is this? Standard, back, forward, or reload? - * @distance: If type is back or forward, the index into the back or forward chain. If - * type is standard or reload, this is ignored, and must be 0. - * @scroll_pos: The file to scroll to when the location is loaded. - */ -static void -begin_location_change (NautilusWindow *window, - const char *location, - NautilusLocationChangeType type, - guint distance, - const char *scroll_pos) -{ - NautilusDirectory *directory; - NautilusFile *file; - gboolean force_reload; - char *current_pos; - - g_assert (NAUTILUS_IS_WINDOW (window)); - g_assert (location != NULL); - g_assert (type == NAUTILUS_LOCATION_CHANGE_BACK - || type == NAUTILUS_LOCATION_CHANGE_FORWARD - || distance == 0); - - g_object_ref (window); - - end_location_change (window); - - nautilus_window_allow_stop (window, TRUE); - nautilus_window_set_status (window, " "); - - window->details->pending_location = g_strdup (location); - window->details->location_change_type = type; - window->details->location_change_distance = distance; - - window->details->pending_scroll_to = g_strdup (scroll_pos); - - directory = nautilus_directory_get (location); - - /* The code to force a reload is here because if we do it - * after determining an initial view (in the components), then - * we end up fetching things twice. - */ - if (type == NAUTILUS_LOCATION_CHANGE_RELOAD) { - force_reload = TRUE; - } else if (!nautilus_monitor_active ()) { - force_reload = TRUE; - } else { - force_reload = !nautilus_directory_is_local (directory); - } - - if (force_reload) { - nautilus_directory_force_reload (directory); - file = nautilus_directory_get_corresponding_file (directory); - nautilus_file_invalidate_all_attributes (file); - nautilus_file_unref (file); - } - - nautilus_directory_unref (directory); - - /* Set current_bookmark scroll pos */ - if (window->current_location_bookmark != NULL && - window->content_view != NULL) { - current_pos = nautilus_view_frame_get_first_visible_file (window->content_view); - nautilus_bookmark_set_scroll_pos (window->current_location_bookmark, current_pos); - g_free (current_pos); - } - - window->details->determine_view_handle = nautilus_determine_initial_view - (location, type == NAUTILUS_LOCATION_CHANGE_FALLBACK, - determined_initial_view_callback, window); - - g_object_unref (window); -} - -static void -stop_loading (NautilusViewFrame *view) -{ - if (view != NULL) { - nautilus_view_frame_stop (view); - } -} - -static void -stop_loading_cover (gpointer data, gpointer callback_data) -{ - g_assert (callback_data == NULL); - stop_loading (NAUTILUS_VIEW_FRAME (data)); -} void nautilus_window_stop_loading (NautilusWindow *window) { - GList *views; - - /* Copy the list before traversing it, because during a failure in - * stop_loading_cover, list could be modified and bad things would - * happen - */ - views = g_list_copy (window->views); - g_list_foreach (views, stop_loading_cover, NULL); - g_list_free (views); + nautilus_view_stop_loading (window->content_view); + + if (window->new_content_view != NULL) { + nautilus_view_stop_loading (window->new_content_view); + } cancel_location_change (window); } void nautilus_window_set_content_view (NautilusWindow *window, - NautilusViewIdentifier *id) + const char *id) { NautilusFile *file; - + g_return_if_fail (NAUTILUS_IS_WINDOW (window)); g_return_if_fail (window->details->location != NULL); g_return_if_fail (id != NULL); - if (nautilus_window_content_view_matches_iid (window, id->iid)) { + if (nautilus_window_content_view_matches_iid (window, id)) { return; } end_location_change (window); file = nautilus_file_get (window->details->location); - nautilus_view_query_set_default_component_for_file - (file, id->iid); + nautilus_file_set_metadata + (file, NAUTILUS_METADATA_KEY_DEFAULT_COMPONENT, NULL, id); nautilus_file_unref (file); nautilus_window_allow_stop (window, TRUE); - if (window->details->selection == NULL) { + if (nautilus_view_get_selection_count (window->content_view) == 0) { /* If there is no selection, queue a scroll to the same icon that * is currently visible */ - window->details->pending_scroll_to = nautilus_view_frame_get_first_visible_file (window->content_view); + window->details->pending_scroll_to = nautilus_view_get_first_visible_file (window->content_view); } - - load_content_view (window, id); -} - -void -nautilus_window_connect_extra_view (NautilusWindow *window, - NautilusViewFrame *view_frame, - NautilusViewIdentifier *id) -{ - connect_view (window, view_frame, FALSE); - set_view_frame_info (view_frame, id); - nautilus_view_frame_set_show_hidden_files_mode (view_frame, NAUTILUS_WINDOW (window)->details->show_hidden_files_mode, FALSE); -} - -void -nautilus_window_disconnect_extra_view (NautilusWindow *window, - NautilusViewFrame *view_frame) -{ - disconnect_view (window, view_frame); + window->details->location_change_type = NAUTILUS_LOCATION_CHANGE_RELOAD; + + create_content_view (window, id); } static void -zoom_level_changed_callback (NautilusViewFrame *view, +zoom_level_changed_callback (NautilusView *view, NautilusWindow *window) { g_assert (NAUTILUS_IS_WINDOW (window)); @@ -1718,10 +1520,10 @@ zoom_level_changed_callback (NautilusViewFrame *view, nautilus_bonobo_set_sensitive (window->details->shell_ui, NAUTILUS_COMMAND_ZOOM_IN, - nautilus_view_frame_get_can_zoom_in (view)); + nautilus_view_get_can_zoom_in (view)); nautilus_bonobo_set_sensitive (window->details->shell_ui, NAUTILUS_COMMAND_ZOOM_OUT, - nautilus_view_frame_get_can_zoom_out (view)); + nautilus_view_get_can_zoom_out (view)); nautilus_bonobo_set_sensitive (window->details->shell_ui, NAUTILUS_COMMAND_ZOOM_NORMAL, TRUE); @@ -1732,7 +1534,7 @@ zoom_level_changed_callback (NautilusViewFrame *view, } static void -zoom_parameters_changed_callback (NautilusViewFrame *view, +zoom_parameters_changed_callback (NautilusView *view, NautilusWindow *window) { float zoom_level; @@ -1745,7 +1547,7 @@ zoom_parameters_changed_callback (NautilusViewFrame *view, * (the component is just temporarily unable to zoom, but the * zoom control will "do the right thing" here). */ - zoom_level = nautilus_view_frame_get_zoom_level (view); + zoom_level = nautilus_view_get_zoom_level (view); if (zoom_level == 0.0) { nautilus_window_ui_freeze (window); @@ -1771,362 +1573,54 @@ zoom_parameters_changed_callback (NautilusViewFrame *view, zoom_level_changed_callback (view, window); } -static Nautilus_History * -get_history_list_callback (NautilusViewFrame *view, - NautilusWindow *window) -{ - Nautilus_History *list; - NautilusBookmark *bookmark; - int length, i; - GList *node; - char *name, *location; - - /* Get total number of history items */ - length = g_list_length (nautilus_get_history_list ()); - - list = Nautilus_History__alloc (); - - list->_length = length; - list->_maximum = length; - list->_buffer = CORBA_sequence_Nautilus_HistoryItem_allocbuf (length); - CORBA_sequence_set_release (list, CORBA_TRUE); - - /* Iterate through list and copy item data */ - for (i = 0, node = nautilus_get_history_list (); i < length; i++, node = node->next) { - bookmark = node->data; - - name = nautilus_bookmark_get_name (bookmark); - location = nautilus_bookmark_get_uri (bookmark); - - list->_buffer[i].title = CORBA_string_dup (name); - list->_buffer[i].location = CORBA_string_dup (location); - - g_free (name); - g_free (location); - } - - return list; -} - -static void -go_back_callback (NautilusViewFrame *view, - NautilusWindow *window) -{ -#if !NEW_UI_COMPLETE - g_assert (NAUTILUS_IS_WINDOW (window)); - - if (NAUTILUS_IS_NAVIGATION_WINDOW (window)) { - if (NAUTILUS_NAVIGATION_WINDOW (window)->back_list != NULL) { - nautilus_navigation_window_go_back (NAUTILUS_NAVIGATION_WINDOW (window)); - } else { - nautilus_window_go_home (window); - } - } -#endif -} - -static void -close_window_callback (NautilusViewFrame *view, - NautilusWindow *window) -{ - g_assert (NAUTILUS_IS_WINDOW (window)); - - nautilus_window_close (window); -} - -static void -change_selection_callback (NautilusViewFrame *view, - GList *selection, - NautilusWindow *window) -{ - g_assert (NAUTILUS_IS_WINDOW (window)); - - change_selection (window, selection, view); -} - static void -change_status_callback (NautilusViewFrame *view, - const char *status, +title_changed_callback (NautilusView *view, NautilusWindow *window) { g_assert (NAUTILUS_IS_WINDOW (window)); - nautilus_window_set_status (window, status); -} - -static void -content_view_failed_callback (NautilusViewFrame *view, - NautilusWindow *window) -{ - g_assert (NAUTILUS_IS_WINDOW (window)); - - handle_view_failure (window, view); -} - -static void -load_underway_callback (NautilusViewFrame *view, - NautilusWindow *window) -{ - g_assert (NAUTILUS_IS_WINDOW (window)); - - /* FIXME bugzilla.gnome.org 42460: We intentionally ignore - * progress from sidebar panels. Some sidebar panels may get - * their own progress indicators later. - */ - - if (view == window->new_content_view) { - location_has_really_changed (window); - } else if (view == window->content_view) { - nautilus_window_allow_stop (window, TRUE); - } -} - -static void -load_complete_callback (NautilusViewFrame *view, - NautilusWindow *window) -{ - g_assert (NAUTILUS_IS_WINDOW (window)); - - /* FIXME bugzilla.gnome.org 42460: We intentionally ignore - * progress from sidebar panels. Some sidebar panels may get - * their own progress indicators later. - */ - - if (view == window->content_view) { - if (window->details->pending_scroll_to != NULL) { - nautilus_view_frame_scroll_to_file (window->content_view, - window->details->pending_scroll_to); - } - end_location_change (window); - } -} - -static void -open_location_callback (NautilusViewFrame *view, - const char *location, - Nautilus_ViewFrame_OpenMode mode, - Nautilus_ViewFrame_OpenFlags flags, - GList *selection, - NautilusWindow *window) -{ - g_assert (NAUTILUS_IS_WINDOW (window)); - - /* Open in a new navigation window */ - open_location (window, location, mode, flags, selection); -} - -static void -report_location_change_callback (NautilusViewFrame *view, - const char *location, - GList *selection, - const char *title, - NautilusWindow *window) -{ - g_assert (NAUTILUS_IS_WINDOW (window)); - - if (view != window->content_view) { - /* Do we need to do anything in this case? */ - return; - } - - end_location_change (window); - - load_new_location_in_all_views (window, - location, - selection, - view); - - window->details->location_change_type = NAUTILUS_LOCATION_CHANGE_STANDARD; - window->details->pending_location = g_strdup (location); - update_for_new_location (window); -} - -static void -report_redirect_callback (NautilusViewFrame *view, - const char *from_location, - const char *to_location, - GList *selection, - const char *title, - NautilusWindow *window) -{ - const char *existing_location; - - g_assert (NAUTILUS_IS_WINDOW (window)); - - if (view != window->content_view) { - /* Do we need to do anything in this case? */ - return; - } - - /* Ignore redirect if we aren't already at "from_location". */ - existing_location = window->details->pending_location; - if (existing_location == NULL) { - existing_location = window->details->location; - } - if (existing_location == NULL - || !eel_uris_match (existing_location, from_location)) { - return; - } - - end_location_change (window); - - load_new_location_in_all_views (window, - to_location, - selection, - view); - - nautilus_remove_from_history_list_no_notify (from_location); - nautilus_window_add_current_location_to_history_list (window); - - window->details->location_change_type = NAUTILUS_LOCATION_CHANGE_REDIRECT; - window->details->pending_location = g_strdup (to_location); - update_for_new_location (window); -} - -static void -show_hidden_files_mode_changed_callback (NautilusViewFrame *requesting_view, - NautilusWindow *window) -{ - Nautilus_ShowHiddenFilesMode mode; - NautilusViewFrame *view; - GList *views, *node; - - g_assert (NAUTILUS_IS_WINDOW (window)); - - /* sync NautilusWindow and ViewFrame show hidden files modes */ - mode = nautilus_view_frame_get_show_hidden_files_mode (requesting_view); - NAUTILUS_WINDOW (window)->details->show_hidden_files_mode = mode; - - views = g_list_copy (window->views); - for (node = views; node != NULL; node = node->next) { - view = NAUTILUS_VIEW_FRAME (node->data); - if (view != requesting_view) { - nautilus_view_frame_set_show_hidden_files_mode (view, mode, FALSE); - } - } - g_list_free (views); -} - -static void -title_changed_callback (NautilusViewFrame *view, - NautilusWindow *window) -{ - g_assert (NAUTILUS_IS_WINDOW (window)); - - update_title (window); + nautilus_window_update_title (window); nautilus_window_update_icon (window); } static void -view_loaded_callback (NautilusViewFrame *view, - NautilusWindow *window) +connect_view (NautilusWindow *window, + NautilusView *view) { - g_assert (NAUTILUS_IS_WINDOW (window)); - - if (view == window->new_content_view - && window->details->pending_location != NULL) { - set_to_pending_location_and_selection (window); - } else { - /* It's a sidebar panel being loaded, or a content view - * being switched (with unchanged location and selection). - */ - if (window->details->location != NULL) { - load_new_location_in_one_view (view, - window->details->location, - window->details->selection); - } - } - - if (window->details->title != NULL) { - nautilus_view_frame_title_changed (view, window->details->title); - } -} - -#define FOR_EACH_NAUTILUS_WINDOW_SIGNAL(macro) \ - macro (change_selection) \ - macro (change_status) \ - macro (get_history_list) \ - macro (go_back) \ - macro (close_window) \ - macro (load_complete) \ - macro (load_underway) \ - macro (open_location) \ - macro (report_location_change) \ - macro (report_redirect) \ - macro (show_hidden_files_mode_changed) \ - macro (title_changed) \ - macro (view_loaded) \ - macro (zoom_level_changed) \ - macro (zoom_parameters_changed) - -static void -connect_view (NautilusWindow *window, - NautilusViewFrame *view, - gboolean is_content_view) -{ - window->views = g_list_prepend (window->views, view); - - if (is_content_view) { - g_signal_connect (view, "failed", - G_CALLBACK (content_view_failed_callback), - window); - g_object_set_data (G_OBJECT (view), "is_content_view", - GINT_TO_POINTER (1)); - } - - #define CONNECT(signal) g_signal_connect \ - (view, #signal, \ - G_CALLBACK (signal##_callback), window); - FOR_EACH_NAUTILUS_WINDOW_SIGNAL (CONNECT) - #undef CONNECT + g_signal_connect (view, "title_changed", + G_CALLBACK (title_changed_callback), window); + g_signal_connect (view, "zoom_level_changed", + G_CALLBACK (zoom_level_changed_callback), window); + g_signal_connect (view, "zoom_parameters_changed", + G_CALLBACK (zoom_parameters_changed_callback), window); } static void -disconnect_view (NautilusWindow *window, NautilusViewFrame *view) +disconnect_view (NautilusWindow *window, + NautilusView *view) { - g_assert (NAUTILUS_IS_WINDOW (window)); - if (view == NULL) { return; } - - g_assert (NAUTILUS_IS_VIEW_FRAME (view)); - - window->views = g_list_remove (window->views, view); - - if (g_object_get_data (G_OBJECT (view), "is_content_view")) { - g_signal_handlers_disconnect_by_func (view, - G_CALLBACK (content_view_failed_callback), - window); - } - -#define DISCONNECT(signal) g_signal_handlers_disconnect_by_func \ - (view, \ - G_CALLBACK (signal##_callback), window); - FOR_EACH_NAUTILUS_WINDOW_SIGNAL (DISCONNECT) -#undef DISCONNECT -} - -static void -disconnect_view_callback (gpointer list_item_data, gpointer callback_data) -{ - disconnect_view (NAUTILUS_WINDOW (callback_data), - NAUTILUS_VIEW_FRAME (list_item_data)); + + g_signal_handlers_disconnect_by_func (view, title_changed_callback, window); + g_signal_handlers_disconnect_by_func (view, zoom_level_changed_callback, window); + g_signal_handlers_disconnect_by_func (view, zoom_parameters_changed_callback, window); } void nautilus_window_manage_views_destroy (NautilusWindow *window) { - GList *views; /* Disconnect view signals here so they don't trigger when * views are destroyed. */ - views = g_list_copy (window->views); - - g_list_foreach (views, disconnect_view_callback, window); - - g_list_free (views); + if (window->content_view != NULL) { + disconnect_view (window, window->content_view); + } + if (window->new_content_view != NULL) { + disconnect_view (window, window->new_content_view); + } } void @@ -2164,7 +1658,7 @@ nautilus_navigation_window_back_or_forward (NautilusNavigationWindow *window, scroll_pos = nautilus_bookmark_get_scroll_pos (bookmark); begin_location_change (NAUTILUS_WINDOW (window), - uri, + uri, NULL, back ? NAUTILUS_LOCATION_CHANGE_BACK : NAUTILUS_LOCATION_CHANGE_FORWARD, distance, scroll_pos); @@ -2182,13 +1676,19 @@ nautilus_window_reload (NautilusWindow *window) g_return_if_fail (NAUTILUS_IS_WINDOW (window)); + if (window->details->location == NULL) { + return; + } + /* window->details->location can be free'd during the processing * of begin_location_change, so make a copy */ location = g_strdup (window->details->location); - current_pos = nautilus_view_frame_get_first_visible_file (window->content_view); + current_pos = NULL; + if (window->content_view != NULL) + current_pos = nautilus_view_get_first_visible_file (window->content_view); begin_location_change - (window, location, + (window, location, NULL, NAUTILUS_LOCATION_CHANGE_RELOAD, 0, current_pos); g_free (current_pos); g_free (location); diff --git a/src/nautilus-window-manage-views.h b/src/nautilus-window-manage-views.h index a5874571e..0c436b8b1 100644 --- a/src/nautilus-window-manage-views.h +++ b/src/nautilus-window-manage-views.h @@ -30,33 +30,41 @@ #include "nautilus-window.h" #include "nautilus-navigation-window.h" -void nautilus_window_manage_views_destroy (NautilusWindow *window); -void nautilus_window_manage_views_finalize (NautilusWindow *window); -void nautilus_window_open_location (NautilusWindow *window, - const char *location, - gboolean close_behind); -void nautilus_window_open_location_with_selection (NautilusWindow *window, - const char *location, - GList *selection, - gboolean close_behind); -void nautilus_window_stop_loading (NautilusWindow *window); -void nautilus_window_set_content_view (NautilusWindow *window, - NautilusViewIdentifier *id); +void nautilus_window_manage_views_destroy (NautilusWindow *window); +void nautilus_window_manage_views_finalize (NautilusWindow *window); +void nautilus_window_open_location (NautilusWindow *window, + const char *location, + gboolean close_behind); +void nautilus_window_open_location_with_selection (NautilusWindow *window, + const char *location, + GList *selection, + gboolean close_behind); +void nautilus_window_open_location_full (NautilusWindow *window, + const char *location, + NautilusWindowOpenMode mode, + NautilusWindowOpenFlags flags, + GList *new_selection); +void nautilus_window_stop_loading (NautilusWindow *window); +void nautilus_window_set_content_view (NautilusWindow *window, + const char *id); +gboolean nautilus_window_content_view_matches_iid (NautilusWindow *window, + const char *iid); +const char *nautilus_window_get_content_view_id (NautilusWindow *window); +char *nautilus_window_get_view_label (NautilusWindow *window); +void nautilus_navigation_window_set_sidebar_panels (NautilusNavigationWindow *window, + GList *view_identifier_list); +void nautilus_navigation_window_back_or_forward (NautilusNavigationWindow *window, + gboolean back, + guint distance); -gboolean nautilus_window_content_view_matches_iid (NautilusWindow *window, - const char *iid); -NautilusViewIdentifier *nautilus_window_get_content_view_id (NautilusWindow *window); -void nautilus_window_connect_extra_view (NautilusWindow *window, - NautilusViewFrame *view, - NautilusViewIdentifier *id); -void nautilus_window_disconnect_extra_view (NautilusWindow *window, - NautilusViewFrame *view); -char *nautilus_window_get_view_frame_label (NautilusViewFrame *view); - -void nautilus_navigation_window_set_sidebar_panels (NautilusNavigationWindow *window, - GList *view_identifier_list); -void nautilus_navigation_window_back_or_forward (NautilusNavigationWindow *window, - gboolean back, - guint distance); + +/* NautilusWindowInfo implementation: */ +void nautilus_window_report_load_underway (NautilusWindow *window, + NautilusView *view); +void nautilus_window_report_selection_changed (NautilusWindowInfo *window); +void nautilus_window_report_view_failed (NautilusWindow *window, + NautilusView *view); +void nautilus_window_report_load_complete (NautilusWindow *window, + NautilusView *view); #endif /* NAUTILUS_WINDOW_MANAGE_VIEWS_H */ diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c index 568f38328..31a20db42 100644 --- a/src/nautilus-window-menus.c +++ b/src/nautilus-window-menus.c @@ -64,13 +64,13 @@ #include <libnautilus-private/nautilus-icon-factory.h> #include <libnautilus-private/nautilus-module.h> #include <libnautilus-private/nautilus-undo-manager.h> -#include <libnautilus/nautilus-bonobo-ui.h> +#include <libnautilus-private/nautilus-bonobo-ui.h> #ifdef ENABLE_PROFILER #include "nautilus-profiler.h" #endif -/* Private menu definitions; others are in <libnautilus/nautilus-bonobo-ui.h>. +/* Private menu definitions; others are in <libnautilus-private/nautilus-bonobo-ui.h>. * These are not part of the published set, either because they are * development-only or because we expect to change them and * don't want other code relying on their existence. @@ -140,7 +140,7 @@ bookmark_holder_free (BookmarkHolder *bookmark_holder) g_free (bookmark_holder); } -/* Private menu definitions; others are in <libnautilus/nautilus-bonobo-ui.h>. +/* Private menu definitions; others are in <libnautilus-private/nautilus-bonobo-ui.h>. * These are not part of the published set, either because they are * development-only or because we expect to change them and * don't want other code relying on their existence. diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h index cc23de672..ec46b24af 100644 --- a/src/nautilus-window-private.h +++ b/src/nautilus-window-private.h @@ -65,7 +65,6 @@ struct NautilusWindowDetails /* Current location. */ char *location; - GList *selection; char *title; NautilusFile *viewed_file; gboolean viewed_file_seen; @@ -76,18 +75,17 @@ struct NautilusWindowDetails char *pending_location; char *pending_scroll_to; GList *pending_selection; - NautilusDetermineViewHandle *determine_view_handle; - NautilusFile *pending_file_for_position; + NautilusFile *determine_view_file; /* View As choices */ GList *short_list_viewers; - NautilusViewIdentifier *extra_viewer; + char *extra_viewer; /* Deferred location change. */ char *location_to_change_to_at_idle; guint location_change_at_idle_id; - Nautilus_ShowHiddenFilesMode show_hidden_files_mode; + NautilusWindowShowHiddenFilesMode show_hidden_files_mode; }; struct _NautilusNavigationWindowDetails { @@ -98,7 +96,7 @@ struct _NautilusNavigationWindowDetails { /* Side Pane */ int side_pane_width; - GtkWidget *current_side_panel; + NautilusSidebar *current_side_panel; /* Menus */ guint refresh_bookmarks_menu_idle_id; @@ -187,7 +185,7 @@ void nautilus_window_zoom_to_level (Nautil void nautilus_window_zoom_to_fit (NautilusWindow *window); void nautilus_window_show_view_as_dialog (NautilusWindow *window); void nautilus_window_set_content_view_widget (NautilusWindow *window, - NautilusViewFrame *content_view); + NautilusView *content_view); Bonobo_UIContainer nautilus_window_get_ui_container (NautilusWindow *window); void nautilus_window_set_viewed_file (NautilusWindow *window, NautilusFile *file); @@ -216,4 +214,5 @@ void nautilus_navigation_window_set_throbber_active void nautilus_navigation_window_go_back (NautilusNavigationWindow *window); void nautilus_navigation_window_go_forward (NautilusNavigationWindow *window); + #endif /* NAUTILUS_WINDOW_PRIVATE_H */ diff --git a/src/nautilus-window.c b/src/nautilus-window.c index 5ea1b672f..3050dbaa4 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -75,11 +75,10 @@ #include <libnautilus-private/nautilus-metadata.h> #include <libnautilus-private/nautilus-mime-actions.h> #include <libnautilus-private/nautilus-program-choosing.h> -#include <libnautilus-private/nautilus-sidebar-functions.h> -#include <libnautilus-private/nautilus-view-query.h> -#include <libnautilus/nautilus-bonobo-ui.h> -#include <libnautilus/nautilus-clipboard.h> -#include <libnautilus/nautilus-undo.h> +#include <libnautilus-private/nautilus-view-factory.h> +#include <libnautilus-private/nautilus-bonobo-ui.h> +#include <libnautilus-private/nautilus-clipboard.h> +#include <libnautilus-private/nautilus-undo.h> #include <math.h> #include <sys/time.h> @@ -117,11 +116,13 @@ enum { }; static void cancel_view_as_callback (NautilusWindow *window); +static void nautilus_window_info_iface_init (NautilusWindowInfoIface *iface); static GList *history_list; -GNOME_CLASS_BOILERPLATE (NautilusWindow, nautilus_window, - BonoboWindow, BONOBO_TYPE_WINDOW) +G_DEFINE_TYPE_WITH_CODE (NautilusWindow, nautilus_window, BONOBO_TYPE_WINDOW, + G_IMPLEMENT_INTERFACE (NAUTILUS_TYPE_WINDOW_INFO, + nautilus_window_info_iface_init)); static void set_up_default_icon_list (void) @@ -162,11 +163,11 @@ icons_changed_callback (GObject *factory, NautilusWindow *window) } static void -nautilus_window_instance_init (NautilusWindow *window) +nautilus_window_init (NautilusWindow *window) { window->details = g_new0 (NautilusWindowDetails, 1); - window->details->show_hidden_files_mode = Nautilus_SHOW_HIDDEN_FILES_DEFAULT; + window->details->show_hidden_files_mode = NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_DEFAULT; /* CORBA and Bonobo setup, which must be done before the location bar setup */ window->details->ui_container = bonobo_window_get_ui_container (BONOBO_WINDOW (window)); @@ -449,11 +450,7 @@ nautilus_window_go_home (NautilusWindow *window) } #endif -#ifdef WEB_NAVIGATION_ENABLED - home_uri = eel_preferences_get (NAUTILUS_PREFERENCES_HOME_URI); -#else home_uri = gnome_vfs_get_uri_from_local_path (g_get_home_dir ()); -#endif g_assert (home_uri != NULL); nautilus_window_go_to (window, home_uri); @@ -481,7 +478,7 @@ void nautilus_window_zoom_in (NautilusWindow *window) { if (window->content_view != NULL) { - nautilus_view_frame_zoom_in (window->content_view); + nautilus_view_zoom_in (window->content_view); } } @@ -489,7 +486,7 @@ void nautilus_window_zoom_to_level (NautilusWindow *window, float level) { if (window->content_view != NULL) { - nautilus_view_frame_set_zoom_level (window->content_view, level); + nautilus_view_set_zoom_level (window->content_view, level); } } @@ -497,7 +494,7 @@ void nautilus_window_zoom_out (NautilusWindow *window) { if (window->content_view != NULL) { - nautilus_view_frame_zoom_out (window->content_view); + nautilus_view_zoom_out (window->content_view); } } @@ -505,7 +502,7 @@ void nautilus_window_zoom_to_fit (NautilusWindow *window) { if (window->content_view != NULL) { - nautilus_view_frame_zoom_to_fit (window->content_view); + nautilus_view_zoom_to_fit (window->content_view); } } @@ -683,10 +680,10 @@ static void free_stored_viewers (NautilusWindow *window) { eel_g_list_free_deep_custom (window->details->short_list_viewers, - (GFunc) nautilus_view_identifier_free, + (GFunc) g_free, NULL); window->details->short_list_viewers = NULL; - nautilus_view_identifier_free (window->details->extra_viewer); + g_free (window->details->extra_viewer); window->details->extra_viewer = NULL; } @@ -700,11 +697,11 @@ nautilus_window_destroy (GtkObject *object) nautilus_window_manage_views_destroy (window); if (window->content_view) { - gtk_object_destroy (GTK_OBJECT (window->content_view)); + g_object_unref (window->content_view); window->content_view = NULL; } - GTK_OBJECT_CLASS (parent_class)->destroy (object); + GTK_OBJECT_CLASS (nautilus_window_parent_class)->destroy (object); } static void @@ -740,7 +737,6 @@ nautilus_window_finalize (GObject *object) free_stored_viewers (window); g_free (window->details->location); - eel_g_list_free_deep (window->details->selection); eel_g_list_free_deep (window->details->pending_selection); if (window->current_location_bookmark != NULL) { @@ -760,7 +756,7 @@ nautilus_window_finalize (GObject *object) g_free (window->details); - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (nautilus_window_parent_class)->finalize (object); } void @@ -785,7 +781,7 @@ nautilus_window_size_request (GtkWidget *widget, g_assert (NAUTILUS_IS_WINDOW (widget)); g_assert (requisition != NULL); - GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition); + GTK_WIDGET_CLASS (nautilus_window_parent_class)->size_request (widget, requisition); screen = gtk_window_get_screen (GTK_WINDOW (widget)); @@ -835,7 +831,7 @@ activate_extra_viewer (NautilusWindow *window) g_assert (NAUTILUS_IS_WINDOW (window)); g_assert (window->details->extra_viewer != NULL); - nautilus_window_set_content_view (window, window->details->extra_viewer); + nautilus_window_set_content_view (window, window->details->extra_viewer); } static void @@ -875,21 +871,30 @@ nautilus_window_handle_ui_event_callback (BonoboUIComponent *ui, static void add_view_as_bonobo_menu_item (NautilusWindow *window, const char *placeholder_path, - NautilusViewIdentifier *identifier, + const char *identifier, int index) { char *tip; char *item_path; + const NautilusViewInfo *info; + char *label; + + info = nautilus_view_factory_lookup (identifier); + /* BONOBOTODO: nicer way for labels */ + label = g_strdup_printf (_("View as %s"), _(info->label_with_mnemonic)); + nautilus_bonobo_add_numbered_radio_menu_item (window->details->shell_ui, placeholder_path, index, - identifier->view_as_label_with_mnemonic, + label, "viewers group"); + g_free (label); + /* BONOBOTODO: nicer way for labels */ tip = g_strdup_printf (_("Display this location with \"%s\""), - identifier->viewer_label); + _(info->label)); item_path = nautilus_bonobo_get_numbered_menu_item_path (window->details->shell_ui, placeholder_path, @@ -905,7 +910,7 @@ add_view_as_bonobo_menu_item (NautilusWindow *window, */ static void update_extra_viewer_in_view_as_menus (NautilusWindow *window, - const NautilusViewIdentifier *id) + const char *id) { gboolean had_extra_viewer; @@ -917,12 +922,12 @@ update_extra_viewer_in_view_as_menus (NautilusWindow *window, } } else { if (had_extra_viewer - && nautilus_view_identifier_compare (window->details->extra_viewer, id) == 0) { + && strcmp (window->details->extra_viewer, id) == 0) { return; } } - nautilus_view_identifier_free (window->details->extra_viewer); - window->details->extra_viewer = nautilus_view_identifier_copy (id); + g_free (window->details->extra_viewer); + window->details->extra_viewer = g_strdup (id); /* Also update the Bonobo View menu item */ if (id == NULL) { @@ -945,11 +950,10 @@ remove_extra_viewer_in_view_as_menus (NautilusWindow *window) static void replace_extra_viewer_in_view_as_menus (NautilusWindow *window) { - NautilusViewIdentifier *id; + const char *id; id = nautilus_window_get_content_view_id (window); update_extra_viewer_in_view_as_menus (window, id); - nautilus_view_identifier_free (id); } /** @@ -978,7 +982,7 @@ nautilus_window_synch_view_as_menus (NautilusWindow *window) for (node = window->details->short_list_viewers, index = 0; node != NULL; node = node->next, ++index) { - if (nautilus_window_content_view_matches_iid (window, ((NautilusViewIdentifier *)node->data)->iid)) { + if (nautilus_window_content_view_matches_iid (window, (char *)node->data)) { break; } } @@ -1006,19 +1010,19 @@ nautilus_window_synch_view_as_menus (NautilusWindow *window) static void refresh_stored_viewers (NautilusWindow *window) { - GList *components, *node, *viewers; - NautilusViewIdentifier *identifier; + GList *viewers; + char *uri, *mimetype; - components = nautilus_view_query_get_components_for_file (window->details->viewed_file); - viewers = NULL; - for (node = components; node != NULL; node = node->next) { - identifier = nautilus_view_identifier_new_from_content_view (node->data); - viewers = g_list_prepend (viewers, identifier); - } - gnome_vfs_mime_component_list_free (components); + uri = nautilus_file_get_uri (window->details->viewed_file); + mimetype = nautilus_file_get_mime_type (window->details->viewed_file); + viewers = nautilus_view_factory_get_views_for_uri (uri, + nautilus_file_get_file_type (window->details->viewed_file), + mimetype); + g_free (uri); + g_free (mimetype); free_stored_viewers (window); - window->details->short_list_viewers = g_list_reverse (viewers); + window->details->short_list_viewers = viewers; } static void @@ -1145,9 +1149,9 @@ real_get_title (NautilusWindow *window) title = NULL; if (window->new_content_view != NULL) { - title = nautilus_view_frame_get_title (window->new_content_view); + title = nautilus_view_get_title (window->new_content_view); } else if (window->content_view != NULL) { - title = nautilus_view_frame_get_title (window->content_view); + title = nautilus_view_get_title (window->content_view); } if (title == NULL) { @@ -1168,6 +1172,8 @@ static void real_set_title (NautilusWindow *window, const char *title) { + char *copy; + g_free (window->details->title); window->details->title = g_strdup (title); @@ -1176,13 +1182,15 @@ real_set_title (NautilusWindow *window, /* Name of item in history list changed, tell listeners. */ nautilus_send_history_list_changed (); } - - /* warn all views and sidebar panels of the potential title change */ - if (window->content_view != NULL) { - nautilus_view_frame_title_changed (window->content_view, title); - } + + copy = g_strdup (window->details->title); + g_signal_emit_by_name (window, "title_changed", + copy); + g_free (copy); } +/* Sets window->details->title, and the actual GtkWindow title which + * might look a bit different (e.g. with "file browser:" added) */ static void nautilus_window_set_title (NautilusWindow *window, const char *title) @@ -1191,11 +1199,19 @@ nautilus_window_set_title (NautilusWindow *window, && strcmp (title, window->details->title) == 0) { return; } - + EEL_CALL_METHOD (NAUTILUS_WINDOW_CLASS, window, set_title, (window, title)); + } +/* update_title: + * + * Re-calculate the window title. + * Called when the location or view has changed. + * @window: The NautilusWindow in question. + * + */ void nautilus_window_update_title (NautilusWindow *window) { @@ -1207,24 +1223,65 @@ nautilus_window_update_title (NautilusWindow *window) g_free (title); } +/* nautilus_window_update_icon: + * + * Re-calculate the window icon + * Called when the location or view or icon set has changed. + * @window: The NautilusWindow in question. + * + */ +void +nautilus_window_update_icon (NautilusWindow *window) +{ + GdkPixbuf *pixbuf; + GtkIconTheme *icon_theme; + + pixbuf = NULL; + + /* Desktop window special icon */ + if (NAUTILUS_IS_DESKTOP_WINDOW (window)) { + icon_theme = nautilus_icon_factory_get_icon_theme (); + pixbuf = gtk_icon_theme_load_icon (icon_theme, + "gnome-fs-desktop", 48, + 0, NULL); + g_object_unref(icon_theme); + + } else { + pixbuf = nautilus_icon_factory_get_pixbuf_for_file (window->details->viewed_file, + "open", + NAUTILUS_ICON_SIZE_STANDARD); + } + + if (pixbuf != NULL) { + gtk_window_set_icon (GTK_WINDOW (window), pixbuf); + g_object_unref (pixbuf); + } +} + + static void real_set_content_view_widget (NautilusWindow *window, - NautilusViewFrame *new_view) + NautilusView *new_view) { + GtkWidget *widget; + g_return_if_fail (NAUTILUS_IS_WINDOW (window)); - g_return_if_fail (new_view == NULL || NAUTILUS_IS_VIEW_FRAME (new_view)); + g_return_if_fail (new_view == NULL || NAUTILUS_IS_VIEW (new_view)); if (new_view == window->content_view) { return; } if (window->content_view != NULL) { - gtk_object_destroy (GTK_OBJECT (window->content_view)); + widget = nautilus_view_get_widget (window->content_view); + gtk_widget_destroy (widget); + g_object_unref (window->content_view); window->content_view = NULL; } if (new_view != NULL) { - gtk_widget_show (GTK_WIDGET (new_view)); + widget = nautilus_view_get_widget (new_view); + gtk_widget_show (widget); /* When creating the desktop window the UI needs to * be in sync. Otherwise I get failed assertions in @@ -1235,6 +1292,7 @@ real_set_content_view_widget (NautilusWindow *window, } window->content_view = new_view; + g_object_ref (window->content_view); /* Update displayed view in menu. Only do this if we're not switching * locations though, because if we are switching locations we'll @@ -1248,7 +1306,7 @@ real_set_content_view_widget (NautilusWindow *window, void nautilus_window_set_content_view_widget (NautilusWindow *window, - NautilusViewFrame *frame) + NautilusView *frame) { g_assert (NAUTILUS_IS_WINDOW (window)); @@ -1338,7 +1396,7 @@ nautilus_window_show (GtkWidget *widget) window = NAUTILUS_WINDOW (widget); - GTK_WIDGET_CLASS (parent_class)->show (widget); + GTK_WIDGET_CLASS (nautilus_window_parent_class)->show (widget); nautilus_window_ui_update (window); } @@ -1541,6 +1599,61 @@ nautilus_get_history_list (void) return history_list; } +static NautilusWindowType +nautilus_window_get_window_type (NautilusWindow *window) +{ + return NAUTILUS_WINDOW_GET_CLASS (window)->window_type; +} + +static int +nautilus_window_get_selection_count (NautilusWindow *window) +{ + if (window->content_view != NULL) { + return nautilus_view_get_selection_count (window->content_view); + } + return 0; +} + +static GList * +nautilus_window_get_selection (NautilusWindow *window) +{ + if (window->content_view != NULL) { + return nautilus_view_get_selection (window->content_view); + } + return NULL; +} + +static NautilusWindowShowHiddenFilesMode +nautilus_window_get_hidden_files_mode (NautilusWindow *window) +{ + return window->details->show_hidden_files_mode; +} + +static void +nautilus_window_set_hidden_files_mode (NautilusWindowInfo *window, + NautilusWindowShowHiddenFilesMode mode) +{ + window->details->show_hidden_files_mode = mode; +} + +static void +nautilus_window_info_iface_init (NautilusWindowInfoIface *iface) +{ + iface->report_load_underway = nautilus_window_report_load_underway; + iface->report_load_complete = nautilus_window_report_load_complete; + iface->report_selection_changed = nautilus_window_report_selection_changed; + iface->report_view_failed = nautilus_window_report_view_failed; + iface->open_location = nautilus_window_open_location_full; + iface->close_window = nautilus_window_close; + iface->set_status = nautilus_window_set_status; + iface->get_window_type = nautilus_window_get_window_type; + iface->get_ui_container = nautilus_window_get_ui_container; + iface->get_selection_count = nautilus_window_get_selection_count; + iface->get_selection = nautilus_window_get_selection; + iface->get_hidden_files_mode = nautilus_window_get_hidden_files_mode; + iface->set_hidden_files_mode = nautilus_window_set_hidden_files_mode; +} + static void nautilus_window_class_init (NautilusWindowClass *class) { diff --git a/src/nautilus-window.h b/src/nautilus-window.h index 2f6283c9f..af6c5b19d 100644 --- a/src/nautilus-window.h +++ b/src/nautilus-window.h @@ -32,9 +32,7 @@ #include <bonobo/bonobo-window.h> #include <eel/eel-glib-extensions.h> #include <libnautilus-private/nautilus-bookmark.h> -#include <libnautilus-private/nautilus-view-identifier.h> -#include "nautilus-applicable-views.h" -#include "nautilus-view-frame.h" +#include <libnautilus-private/nautilus-window-info.h> #include "nautilus-application.h" #include "nautilus-information-panel.h" #include "nautilus-side-pane.h" @@ -54,7 +52,7 @@ typedef struct NautilusWindow NautilusWindow; typedef struct { BonoboWindowClass parent_spot; - Nautilus_WindowType window_type; + NautilusWindowType window_type; /* Function pointers for overriding, without corresponding signals */ @@ -72,7 +70,7 @@ typedef struct { void (* merge_menus_2) (NautilusWindow *window); void (* load_view_as_menu) (NautilusWindow *window); void (* set_content_view_widget) (NautilusWindow *window, - NautilusViewFrame *frame); + NautilusView *new_view); void (* set_throbber_active) (NautilusWindow *window, gboolean active); void (* prompt_for_location) (NautilusWindow *window); @@ -103,13 +101,10 @@ struct NautilusWindow { NautilusBookmark *last_location_bookmark; /* Current views stuff */ - NautilusViewFrame *content_view; + NautilusView *content_view; /* Pending changes */ - NautilusViewFrame *new_content_view; - - /* All views */ - GList *views; + NautilusView *new_content_view; }; GType nautilus_window_get_type (void); |