summaryrefslogtreecommitdiff
path: root/libnautilus-private
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2004-11-22 15:24:38 +0000
committerAlexander Larsson <alexl@src.gnome.org>2004-11-22 15:24:38 +0000
commit67e2a42fea65f2685580b119b98a058c8e81ac4e (patch)
tree19bc7c578c9f1a47f299d012ac4775010e06661e /libnautilus-private
parent8dc115c33951754d75b57c67e4d918900a795468 (diff)
downloadnautilus-67e2a42fea65f2685580b119b98a058c8e81ac4e.tar.gz
Merge bonobo-slay-branch
2004-11-22 Alexander Larsson <alexl@redhat.com> * Merge bonobo-slay-branch
Diffstat (limited to 'libnautilus-private')
-rw-r--r--libnautilus-private/Makefile.am53
-rw-r--r--libnautilus-private/apps_nautilus_preferences.schemas.in15
-rw-r--r--libnautilus-private/nautilus-bonobo-extensions.c886
-rw-r--r--libnautilus-private/nautilus-bonobo-extensions.h131
-rw-r--r--libnautilus-private/nautilus-clipboard-monitor.c16
-rw-r--r--libnautilus-private/nautilus-clipboard.c457
-rw-r--r--libnautilus-private/nautilus-clipboard.h45
-rw-r--r--libnautilus-private/nautilus-desktop-link.c29
-rw-r--r--libnautilus-private/nautilus-directory-async.c93
-rw-r--r--libnautilus-private/nautilus-directory-background.c1
-rw-r--r--libnautilus-private/nautilus-directory-metafile-monitor.c1
-rw-r--r--libnautilus-private/nautilus-directory-private.h3
-rw-r--r--libnautilus-private/nautilus-drag-window.c393
-rw-r--r--libnautilus-private/nautilus-drag-window.h40
-rw-r--r--libnautilus-private/nautilus-file.c9
-rw-r--r--libnautilus-private/nautilus-global-preferences.c16
-rw-r--r--libnautilus-private/nautilus-global-preferences.h4
-rw-r--r--libnautilus-private/nautilus-icon-factory.c8
-rw-r--r--libnautilus-private/nautilus-icon-factory.h1
-rw-r--r--libnautilus-private/nautilus-idle-queue.c144
-rw-r--r--libnautilus-private/nautilus-idle-queue.h45
-rw-r--r--libnautilus-private/nautilus-lib-self-check-functions.h1
-rw-r--r--libnautilus-private/nautilus-medusa-support.c145
-rw-r--r--libnautilus-private/nautilus-medusa-support.h47
-rw-r--r--libnautilus-private/nautilus-metafile-server.idl2
-rw-r--r--libnautilus-private/nautilus-metafile.c5
-rw-r--r--libnautilus-private/nautilus-mime-actions.c1
-rw-r--r--libnautilus-private/nautilus-program-choosing.h3
-rw-r--r--libnautilus-private/nautilus-search-uri.c727
-rw-r--r--libnautilus-private/nautilus-search-uri.h42
-rw-r--r--libnautilus-private/nautilus-sidebar-functions.c91
-rw-r--r--libnautilus-private/nautilus-sidebar-functions.h33
-rw-r--r--libnautilus-private/nautilus-sidebar-provider.c72
-rw-r--r--libnautilus-private/nautilus-sidebar-provider.h56
-rw-r--r--libnautilus-private/nautilus-sidebar.c116
-rw-r--r--libnautilus-private/nautilus-sidebar.h78
-rw-r--r--libnautilus-private/nautilus-ui-utilities.c215
-rw-r--r--libnautilus-private/nautilus-ui-utilities.h43
-rw-r--r--libnautilus-private/nautilus-undo-context.c80
-rw-r--r--libnautilus-private/nautilus-undo-context.h56
-rw-r--r--libnautilus-private/nautilus-undo-manager.c111
-rw-r--r--libnautilus-private/nautilus-undo-manager.h14
-rw-r--r--libnautilus-private/nautilus-undo-private.h36
-rw-r--r--libnautilus-private/nautilus-undo-transaction.c333
-rw-r--r--libnautilus-private/nautilus-undo-transaction.h77
-rw-r--r--libnautilus-private/nautilus-undo.c215
-rw-r--r--libnautilus-private/nautilus-undo.h76
-rw-r--r--libnautilus-private/nautilus-view-factory.c110
-rw-r--r--libnautilus-private/nautilus-view-factory.h67
-rw-r--r--libnautilus-private/nautilus-view-identifier.c237
-rw-r--r--libnautilus-private/nautilus-view-identifier.h51
-rw-r--r--libnautilus-private/nautilus-view-query.c889
-rw-r--r--libnautilus-private/nautilus-view-query.h52
-rw-r--r--libnautilus-private/nautilus-view.c251
-rw-r--r--libnautilus-private/nautilus-view.h147
-rw-r--r--libnautilus-private/nautilus-window-info.c261
-rw-r--r--libnautilus-private/nautilus-window-info.h164
57 files changed, 3124 insertions, 4170 deletions
diff --git a/libnautilus-private/Makefile.am b/libnautilus-private/Makefile.am
index 52062cfc9..ea7b245ee 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,20 +42,19 @@ marshal_sources = \
nautilus-marshal-guts.c \
$(NULL)
-
libnautilus_private_la_SOURCES = \
$(nautilus_metafile_server_idl_sources) \
nautilus-audio-player.c \
nautilus-audio-player.h \
- nautilus-bonobo-extensions.c \
- nautilus-bonobo-extensions.h \
nautilus-bookmark.c \
nautilus-bookmark.h \
+ nautilus-cdrom-extensions.h \
nautilus-cell-renderer-pixbuf-emblem.c \
nautilus-cell-renderer-pixbuf-emblem.h \
- 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 \
@@ -65,16 +63,16 @@ libnautilus_private_la_SOURCES = \
nautilus-customization-data.h \
nautilus-default-file-icon.c \
nautilus-default-file-icon.h \
- nautilus-desktop-directory.c \
- nautilus-desktop-directory.h \
nautilus-desktop-directory-file.c \
nautilus-desktop-directory-file.h \
+ nautilus-desktop-directory.c \
+ nautilus-desktop-directory.h \
nautilus-desktop-icon-file.c \
nautilus-desktop-icon-file.h \
- nautilus-desktop-link.c \
- nautilus-desktop-link.h \
nautilus-desktop-link-monitor.c \
nautilus-desktop-link-monitor.h \
+ nautilus-desktop-link.c \
+ nautilus-desktop-link.h \
nautilus-directory-async.c \
nautilus-directory-background.c \
nautilus-directory-background.h \
@@ -88,8 +86,6 @@ libnautilus_private_la_SOURCES = \
nautilus-directory.h \
nautilus-dnd.c \
nautilus-dnd.h \
- nautilus-drag-window.c \
- nautilus-drag-window.h \
nautilus-emblem-utils.c \
nautilus-emblem-utils.h \
nautilus-entry.c \
@@ -99,9 +95,9 @@ libnautilus_private_la_SOURCES = \
nautilus-file-changes-queue.h \
nautilus-file-dnd.c \
nautilus-file-dnd.h \
+ nautilus-file-operations-progress-icons.h \
nautilus-file-operations-progress.c \
nautilus-file-operations-progress.h \
- nautilus-file-operations-progress-icons.h \
nautilus-file-operations.c \
nautilus-file-operations.h \
nautilus-file-private.h \
@@ -125,6 +121,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 \
@@ -138,8 +136,6 @@ libnautilus_private_la_SOURCES = \
nautilus-link.h \
nautilus-marshal.c \
nautilus-marshal.h \
- nautilus-medusa-support.c \
- nautilus-medusa-support.h \
nautilus-merged-directory.c \
nautilus-merged-directory.h \
nautilus-metadata.h \
@@ -155,12 +151,12 @@ libnautilus_private_la_SOURCES = \
nautilus-monitor.h \
nautilus-program-choosing.c \
nautilus-program-choosing.h \
- nautilus-recent.h \
nautilus-recent.c \
- nautilus-search-uri.c \
- nautilus-search-uri.h \
- nautilus-sidebar-functions.c \
- nautilus-sidebar-functions.h \
+ nautilus-recent.h \
+ nautilus-sidebar-provider.c \
+ nautilus-sidebar-provider.h \
+ nautilus-sidebar.c \
+ nautilus-sidebar.h \
nautilus-sound.c \
nautilus-sound.h \
nautilus-theme.c \
@@ -175,20 +171,27 @@ 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-ui-utilities.c \
+ nautilus-ui-utilities.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)
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-extensions.c b/libnautilus-private/nautilus-bonobo-extensions.c
deleted file mode 100644
index 9aacb5201..000000000
--- a/libnautilus-private/nautilus-bonobo-extensions.c
+++ /dev/null
@@ -1,886 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/* nautilus-bonobo-extensions.c - implementation of new functions that conceptually
- belong in bonobo. Perhaps some of these will be
- actually rolled into bonobo someday.
-
- 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: John Sullivan <sullivan@eazel.com>
- Darin Adler <darin@bentspoon.com>
-*/
-
-#include <config.h>
-#include "nautilus-bonobo-extensions.h"
-
-#include "nautilus-icon-factory.h"
-
-#include <eel/eel-string.h>
-#include <eel/eel-gnome-extensions.h>
-#include <eel/eel-debug.h>
-#include <bonobo/bonobo-ui-util.h>
-#include <gtk/gtkmain.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-
-struct NautilusBonoboActivationHandle {
- NautilusBonoboActivationHandle **early_completion_hook;
- NautilusBonoboActivationCallback callback;
- gpointer callback_data;
- Bonobo_Unknown activated_object;
- gboolean cancel;
- guint idle_id;
- guint timeout_id;
-};
-
-typedef enum {
- NUMBERED_MENU_ITEM_PLAIN,
- NUMBERED_MENU_ITEM_TOGGLE,
- NUMBERED_MENU_ITEM_RADIO
-} NumberedMenuItemType;
-
-void
-nautilus_bonobo_set_accelerator (BonoboUIComponent *ui,
- const char *path,
- const char *accelerator)
-{
- bonobo_ui_component_set_prop (ui, path, "accel", accelerator, NULL);
-}
-
-void
-nautilus_bonobo_set_label (BonoboUIComponent *ui,
- const char *path,
- const char *label)
-{
- bonobo_ui_component_set_prop (ui, path, "label", label, NULL);
-}
-
-void
-nautilus_bonobo_set_tip (BonoboUIComponent *ui,
- const char *path,
- const char *tip)
-{
- bonobo_ui_component_set_prop (ui, path, "tip", tip, NULL);
-}
-
-void
-nautilus_bonobo_set_sensitive (BonoboUIComponent *ui,
- const char *path,
- gboolean sensitive)
-{
- bonobo_ui_component_set_prop (ui, path, "sensitive", sensitive ? "1" : "0", NULL);
-}
-
-void
-nautilus_bonobo_set_toggle_state (BonoboUIComponent *ui,
- const char *path,
- gboolean state)
-{
- bonobo_ui_component_set_prop (ui, path, "state", state ? "1" : "0", NULL);
-}
-
-void
-nautilus_bonobo_set_hidden (BonoboUIComponent *ui,
- const char *path,
- gboolean hidden)
-{
- bonobo_ui_component_set_prop (ui, path, "hidden", hidden ? "1" : "0", NULL);
-}
-
-char *
-nautilus_bonobo_get_label (BonoboUIComponent *ui,
- const char *path)
-{
- return bonobo_ui_component_get_prop (ui, path, "label", NULL);
-}
-
-gboolean
-nautilus_bonobo_get_hidden (BonoboUIComponent *ui,
- const char *path)
-{
- char *value;
- gboolean hidden;
- CORBA_Environment ev;
-
- g_return_val_if_fail (BONOBO_IS_UI_COMPONENT (ui), FALSE);
- g_return_val_if_fail (path != NULL, FALSE);
-
- CORBA_exception_init (&ev);
- value = bonobo_ui_component_get_prop (ui, path, "hidden", &ev);
- CORBA_exception_free (&ev);
-
- if (value == NULL) {
- /* No hidden attribute means not hidden. */
- hidden = FALSE;
- } else {
- /* Anything other than "0" counts as TRUE */
- hidden = strcmp (value, "0") != 0;
- }
-
- g_free (value);
-
- return hidden;
-}
-
-static char *
-get_numbered_menu_item_name (guint index)
-{
- return g_strdup_printf ("%u", index);
-}
-
-char *
-nautilus_bonobo_get_numbered_menu_item_path (BonoboUIComponent *ui,
- const char *container_path,
- guint index)
-{
- char *item_name;
- char *item_path;
-
- g_return_val_if_fail (BONOBO_IS_UI_COMPONENT (ui), NULL);
- g_return_val_if_fail (container_path != NULL, NULL);
-
- item_name = get_numbered_menu_item_name (index);
- item_path = g_strconcat (container_path, "/", item_name, NULL);
- g_free (item_name);
-
- return item_path;
-}
-
-char *
-nautilus_bonobo_get_numbered_menu_item_command (BonoboUIComponent *ui,
- const char *container_path,
- guint index)
-{
- char *command_name;
- char *path;
-
- g_return_val_if_fail (BONOBO_IS_UI_COMPONENT (ui), NULL);
- g_return_val_if_fail (container_path != NULL, NULL);
-
- path = nautilus_bonobo_get_numbered_menu_item_path (ui, container_path, index);
- command_name = gnome_vfs_escape_string (path);
- g_free (path);
-
- return command_name;
-}
-
-guint
-nautilus_bonobo_get_numbered_menu_item_index_from_command (const char *command)
-{
- char *path;
- char *index_string;
- int index;
- gboolean got_index;
-
- path = gnome_vfs_unescape_string (command, NULL);
- index_string = strrchr (path, '/');
-
- if (index_string == NULL) {
- got_index = FALSE;
- } else {
- got_index = eel_str_to_int (index_string + 1, &index);
- }
- g_free (path);
-
- g_return_val_if_fail (got_index, 0);
-
- return index;
-}
-
-char *
-nautilus_bonobo_get_numbered_menu_item_container_path_from_command (const char *command)
-{
- char *path;
- char *index_string;
- char *container_path;
-
- path = gnome_vfs_unescape_string (command, NULL);
- index_string = strrchr (path, '/');
-
- container_path = index_string == NULL
- ? NULL
- : g_strndup (path, index_string - path);
- g_free (path);
-
- return container_path;
-}
-
-static void
-add_numbered_menu_item_internal (BonoboUIComponent *ui,
- const char *container_path,
- guint index,
- const char *label,
- NumberedMenuItemType type,
- GdkPixbuf *pixbuf,
- const char *radio_group_name)
-{
- char *xml_item, *xml_command;
- char *command_name;
- char *item_name, *pixbuf_data;
- char *path;
-
- g_assert (BONOBO_IS_UI_COMPONENT (ui));
- g_assert (container_path != NULL);
- g_assert (label != NULL);
- g_assert (type == NUMBERED_MENU_ITEM_PLAIN || pixbuf == NULL);
- g_assert (type == NUMBERED_MENU_ITEM_RADIO || radio_group_name == NULL);
- g_assert (type != NUMBERED_MENU_ITEM_RADIO || radio_group_name != NULL);
-
- item_name = get_numbered_menu_item_name (index);
- command_name = nautilus_bonobo_get_numbered_menu_item_command
- (ui, container_path, index);
-
- switch (type) {
- case NUMBERED_MENU_ITEM_TOGGLE:
- xml_item = g_strdup_printf ("<menuitem name=\"%s\" id=\"%s\" type=\"toggle\"/>\n",
- item_name, command_name);
- break;
- case NUMBERED_MENU_ITEM_RADIO:
- xml_item = g_strdup_printf ("<menuitem name=\"%s\" id=\"%s\" type=\"radio\" group=\"%s\"/>\n",
- item_name, command_name, radio_group_name);
- break;
- case NUMBERED_MENU_ITEM_PLAIN:
- if (pixbuf != NULL) {
- pixbuf_data = bonobo_ui_util_pixbuf_to_xml (pixbuf);
- xml_item = g_strdup_printf ("<menuitem name=\"%s\" verb=\"%s\" pixtype=\"pixbuf\" pixname=\"%s\"/>\n",
- item_name, command_name, pixbuf_data);
- g_free (pixbuf_data);
- } else {
- xml_item = g_strdup_printf ("<menuitem name=\"%s\" verb=\"%s\"/>\n",
- item_name, command_name);
- }
- break;
- default:
- g_assert_not_reached ();
- xml_item = NULL; /* keep compiler happy */
- }
-
- g_free (item_name);
-
- bonobo_ui_component_set (ui, container_path, xml_item, NULL);
-
- g_free (xml_item);
-
- path = nautilus_bonobo_get_numbered_menu_item_path (ui, container_path, index);
- nautilus_bonobo_set_label (ui, path, label);
- g_free (path);
-
- /* Make the command node here too, so callers can immediately set
- * properties on it (otherwise it doesn't get created until some
- * time later).
- */
- xml_command = g_strdup_printf ("<cmd name=\"%s\"/>\n", command_name);
- bonobo_ui_component_set (ui, "/commands", xml_command, NULL);
- g_free (xml_command);
-
- g_free (command_name);
-}
-
-/* Add a menu item specified by number into a given path. Used for
- * dynamically creating a related series of menu items. Each index
- * must be unique (normal use is to call this in a loop, and
- * increment the index for each item).
- */
-void
-nautilus_bonobo_add_numbered_menu_item (BonoboUIComponent *ui,
- const char *container_path,
- guint index,
- const char *label,
- GdkPixbuf *pixbuf)
-{
- g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui));
- g_return_if_fail (container_path != NULL);
- g_return_if_fail (label != NULL);
-
- add_numbered_menu_item_internal (ui, container_path, index, label,
- NUMBERED_MENU_ITEM_PLAIN, pixbuf, NULL);
-}
-
-/* Add a menu item specified by number into a given path. Used for
- * dynamically creating a related series of toggle menu items. Each index
- * must be unique (normal use is to call this in a loop, and
- * increment the index for each item).
- */
-void
-nautilus_bonobo_add_numbered_toggle_menu_item (BonoboUIComponent *ui,
- const char *container_path,
- guint index,
- const char *label)
-{
- g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui));
- g_return_if_fail (container_path != NULL);
- g_return_if_fail (label != NULL);
-
- add_numbered_menu_item_internal (ui, container_path, index, label,
- NUMBERED_MENU_ITEM_TOGGLE, NULL, NULL);
-}
-
-/* Add a menu item specified by number into a given path. Used for
- * dynamically creating a related series of radio menu items. Each index
- * must be unique (normal use is to call this in a loop, and
- * increment the index for each item).
- */
-void
-nautilus_bonobo_add_numbered_radio_menu_item (BonoboUIComponent *ui,
- const char *container_path,
- guint index,
- const char *label,
- const char *radio_group_name)
-{
- g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui));
- g_return_if_fail (container_path != NULL);
- g_return_if_fail (label != NULL);
-
- add_numbered_menu_item_internal (ui, container_path, index, label,
- NUMBERED_MENU_ITEM_RADIO, NULL, radio_group_name);
-}
-
-void
-nautilus_bonobo_add_submenu (BonoboUIComponent *ui,
- const char *path,
- const char *label,
- GdkPixbuf *pixbuf)
-{
- char *xml_string, *name, *pixbuf_data, *submenu_path;
-
- g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui));
- g_return_if_fail (path != NULL);
- g_return_if_fail (label != NULL);
- g_return_if_fail (pixbuf == NULL || GDK_IS_PIXBUF (pixbuf));
-
- /* Labels may contain characters that are illegal in names. So
- * we create the name by URI-encoding the label.
- */
- name = gnome_vfs_escape_string (label);
-
- if (pixbuf != NULL) {
- pixbuf_data = bonobo_ui_util_pixbuf_to_xml (pixbuf);
- xml_string = g_strdup_printf ("<submenu name=\"%s\" pixtype=\"pixbuf\" pixname=\"%s\"/>\n",
- name, pixbuf_data);
- g_free (pixbuf_data);
- } else {
- xml_string = g_strdup_printf ("<submenu name=\"%s\"/>\n", name);
- }
-
- bonobo_ui_component_set (ui, path, xml_string, NULL);
-
- g_free (xml_string);
-
- submenu_path = g_strconcat (path, "/", name, NULL);
- nautilus_bonobo_set_label (ui, submenu_path, label);
- g_free (submenu_path);
-
- g_free (name);
-}
-
-void
-nautilus_bonobo_add_menu_separator (BonoboUIComponent *ui, const char *path)
-{
- g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui));
- g_return_if_fail (path != NULL);
-
- bonobo_ui_component_set (ui, path, "<separator/>", NULL);
-}
-
-static void
-remove_commands (BonoboUIComponent *ui, const char *container_path)
-{
- BonoboUINode *path_node;
- BonoboUINode *child_node;
- char *verb_name;
- char *id_name;
-
- path_node = bonobo_ui_component_get_tree (ui, container_path, TRUE, NULL);
- if (path_node == NULL) {
- return;
- }
-
- bonobo_ui_component_freeze (ui, NULL);
-
- for (child_node = bonobo_ui_node_children (path_node);
- child_node != NULL;
- child_node = bonobo_ui_node_next (child_node)) {
- verb_name = bonobo_ui_node_get_attr (child_node, "verb");
- if (verb_name != NULL) {
- bonobo_ui_component_remove_verb (ui, verb_name);
- bonobo_ui_node_free_string (verb_name);
- } else {
- /* Only look for an id if there's no verb */
- id_name = bonobo_ui_node_get_attr (child_node, "id");
- if (id_name != NULL) {
- bonobo_ui_component_remove_listener (ui, id_name);
- bonobo_ui_node_free_string (id_name);
- }
- }
- }
-
- bonobo_ui_component_thaw (ui, NULL);
-
- bonobo_ui_node_free (path_node);
-}
-
-/**
- * nautilus_bonobo_remove_menu_items_and_verbs
- *
- * Removes all menu items contained in a menu or placeholder, and
- * their verbs.
- *
- * @uih: The BonoboUIHandler for this menu item.
- * @container_path: The standard bonobo-style path specifier for this placeholder or submenu.
- */
-void
-nautilus_bonobo_remove_menu_items_and_commands (BonoboUIComponent *ui,
- const char *container_path)
-{
- char *remove_wildcard;
-
- g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui));
- g_return_if_fail (container_path != NULL);
-
- remove_commands (ui, container_path);
-
- /* For speed, remove menu items themselves all in one fell swoop,
- * though we removed the verbs one-by-one.
- */
- remove_wildcard = g_strdup_printf ("%s/*", container_path);
- bonobo_ui_component_rm (ui, remove_wildcard, NULL);
- g_free (remove_wildcard);
-}
-
-/* Call to set the user-visible label of a command to a string
- * containing an underscore accelerator. The underscore is stripped
- * off before setting the label of the toolitem, because toolbar
- * button labels shouldn't have the underscore.
- */
-void
-nautilus_bonobo_set_label_for_toolitem_and_command (BonoboUIComponent *ui,
- const char *toolitem_path,
- const char *command_path,
- const char *label_with_underscore)
-{
- char *label_no_underscore;
-
- g_return_if_fail (BONOBO_IS_UI_COMPONENT (ui));
- g_return_if_fail (toolitem_path != NULL);
- g_return_if_fail (command_path != NULL);
- g_return_if_fail (label_with_underscore != NULL);
-
- label_no_underscore = eel_str_strip_chr (label_with_underscore, '_');
- nautilus_bonobo_set_label (ui,
- command_path,
- label_with_underscore);
- nautilus_bonobo_set_label (ui,
- toolitem_path,
- label_no_underscore);
-
- g_free (label_no_underscore);
-}
-
-static char *
-get_extension_menu_item_xml (NautilusMenuItem *item)
-{
- GString *ui_xml;
- char *pixbuf_data;
- GdkPixbuf *pixbuf;
- char *name;
- char *icon;
-
- ui_xml = g_string_new ("");
-
- g_object_get (G_OBJECT (item), "name", &name, "icon", &icon, NULL);
-
- g_string_append_printf (ui_xml,
- "<menuitem name=\"%s\" verb=\"%s\"",
- name, name);
-
- if (icon) {
- pixbuf = nautilus_icon_factory_get_pixbuf_from_name
- (icon,
- NULL,
- NAUTILUS_ICON_SIZE_FOR_MENUS,
- NULL);
- if (pixbuf) {
- pixbuf_data = bonobo_ui_util_pixbuf_to_xml (pixbuf);
- g_string_append_printf (ui_xml, " pixtype=\"pixbuf\" pixname=\"%s\"", pixbuf_data);
- g_free (pixbuf_data);
- g_object_unref (pixbuf);
- }
- }
- g_string_append (ui_xml, "/>");
-
- g_free (name);
- g_free (icon);
-
- return g_string_free (ui_xml, FALSE);
-}
-
-static void
-extension_action_callback (BonoboUIComponent *component,
- gpointer callback_data, const char *path)
-{
- nautilus_menu_item_activate (NAUTILUS_MENU_ITEM (callback_data));
-}
-
-char *
-nautilus_bonobo_get_extension_item_command_xml (NautilusMenuItem *item)
-{
- char *name;
- char *label;
- char *tip;
- gboolean sensitive;
- char *xml;
-
- g_object_get (G_OBJECT (item),
- "name", &name, "label", &label,
- "tip", &tip, "sensitive", &sensitive,
- NULL);
-
- xml = g_strdup_printf ("<cmd name=\"%s\" label=\"%s\" tip=\"%s\" sensitive=\"%s\"/>",
- name, label, tip, sensitive ? "1" : "0");
-
- g_free (name);
- g_free (label);
- g_free (tip);
-
- return xml;
-}
-
-void
-nautilus_bonobo_add_extension_item_command (BonoboUIComponent *ui,
- NautilusMenuItem *item)
-{
- char *xml;
- char *name;
- GClosure *closure;
-
- xml = nautilus_bonobo_get_extension_item_command_xml (item);
-
- bonobo_ui_component_set (ui, "/commands", xml, NULL);
-
- g_free (xml);
-
- g_object_get (G_OBJECT (item), "name", &name, NULL);
-
- closure = g_cclosure_new
- (G_CALLBACK (extension_action_callback),
- g_object_ref (item),
- (GClosureNotify)g_object_unref);
-
- bonobo_ui_component_add_verb_full (ui, name, closure);
-
- g_free (name);
-}
-
-void
-nautilus_bonobo_add_extension_item (BonoboUIComponent *ui,
- const char *path,
- NautilusMenuItem *item)
-{
- char *item_xml;
-
- item_xml = get_extension_menu_item_xml (item);
-
- bonobo_ui_component_set (ui, path, item_xml, NULL);
-
- g_free (item_xml);
-}
-
-static char *
-get_extension_toolbar_item_xml (NautilusMenuItem *item)
-{
- GString *ui_xml;
- char *pixbuf_data;
- GdkPixbuf *pixbuf;
- char *name;
- char *icon;
- gboolean priority;
-
- ui_xml = g_string_new ("");
-
-
- g_object_get (item,
- "name", &name, "priority", &priority,
- "icon", &icon,
- NULL);
- g_string_append_printf (ui_xml,
- "<toolitem name=\"%s\" verb=\"%s\"",
- name, name);
-
- if (priority) {
- g_string_append (ui_xml, " priority=\"1\"");
- }
-
- if (icon) {
- pixbuf = nautilus_icon_factory_get_pixbuf_from_name
- (icon,
- NULL,
- NAUTILUS_ICON_SIZE_FOR_MENUS,
- NULL);
- if (pixbuf) {
- pixbuf_data = bonobo_ui_util_pixbuf_to_xml (pixbuf);
- g_string_append_printf (ui_xml, " pixtype=\"pixbuf\" pixname=\"%s\"", pixbuf_data);
- g_free (pixbuf_data);
- g_object_unref (pixbuf);
- }
- }
- g_string_append (ui_xml, "/>");
-
- g_free (name);
- g_free (icon);
-
- return g_string_free (ui_xml, FALSE);
-}
-
-void
-nautilus_bonobo_add_extension_toolbar_item (BonoboUIComponent *ui,
- const char *path,
- NautilusMenuItem *item)
-{
- char *item_xml;
-
- item_xml = get_extension_toolbar_item_xml (item);
-
- bonobo_ui_component_set (ui, path, item_xml, NULL);
-
- g_free (item_xml);
-}
-
-static void
-activation_handle_done (NautilusBonoboActivationHandle *handle)
-{
- if (handle->early_completion_hook != NULL) {
- g_assert (*handle->early_completion_hook == handle);
- *handle->early_completion_hook = NULL;
- }
-}
-
-static void
-activation_handle_free (NautilusBonoboActivationHandle *handle)
-{
- activation_handle_done (handle);
-
- if (handle->activated_object != NULL) {
- bonobo_object_release_unref (handle->activated_object, NULL);
- }
-
- g_free (handle);
-}
-
-static GHashTable *nautilus_activation_shortcuts = NULL;
-
-struct CreateObjectData {
- NautilusBonoboCreateObject create_object;
- gpointer callback_data;
-};
-
-void
-nautilus_bonobo_register_activation_shortcut (const char *iid,
- NautilusBonoboCreateObject create_object_callback,
- gpointer callback_data)
-{
- struct CreateObjectData *data;
-
- if (nautilus_activation_shortcuts == NULL) {
- nautilus_activation_shortcuts = g_hash_table_new_full
- (g_str_hash, g_str_equal, g_free, g_free);
- eel_debug_call_at_shutdown_with_data ((GFreeFunc)g_hash_table_destroy,
- nautilus_activation_shortcuts);
- }
-
- data = g_new (struct CreateObjectData, 1);
- data->create_object = create_object_callback;
- data->callback_data = callback_data;
- g_hash_table_insert (nautilus_activation_shortcuts,
- g_strdup (iid), data);
-}
-
-void
-nautilus_bonobo_unregister_activation_shortcut (const char *iid)
-{
- if (nautilus_activation_shortcuts == NULL) {
- g_assert_not_reached ();
- return;
- }
- g_hash_table_remove (nautilus_activation_shortcuts, iid);
-}
-
-static gboolean
-activation_idle_callback (gpointer callback_data)
-{
- NautilusBonoboActivationHandle *handle;
-
- handle = (NautilusBonoboActivationHandle *) callback_data;
-
- (* handle->callback) (handle,
- handle->activated_object,
- handle->callback_data);
-
- activation_handle_free (handle);
-
- return FALSE;
-}
-
-static void
-activation_cancel (NautilusBonoboActivationHandle *handle)
-{
- activation_handle_free (handle);
-}
-
-static void
-bonobo_activation_activation_callback (Bonobo_Unknown activated_object,
- const char *error_reason,
- gpointer callback_data)
-{
- NautilusBonoboActivationHandle *handle;
-
- handle = (NautilusBonoboActivationHandle *) callback_data;
-
- if (handle->timeout_id != 0) {
- g_source_remove (handle->timeout_id);
- }
-
- if (activated_object == NULL) {
- g_warning ("activation failed: %s", error_reason);
- }
-
- handle->activated_object = activated_object;
-
- if (handle->cancel) {
- activation_cancel (handle);
- } else {
- handle->idle_id = g_idle_add (activation_idle_callback,
- handle);
- }
-}
-
-static gboolean
-activation_timed_out (gpointer callback_data)
-{
- NautilusBonoboActivationHandle *handle = callback_data;
-
- (* handle->callback) (handle,
- NULL,
- handle->callback_data);
-
- handle->timeout_id = 0;
- nautilus_bonobo_activate_cancel (handle);
- return FALSE;
-}
-
-/**
- * nautilus_bonobo_activate_from_id:
- * @iid: iid of component to activate.
- * @callback: callback to call when activation finished.
- * @user_data: data to pass to callback when activation finished.
- *
- * This function will return NULL if something bad happened during
- * activation.
- */
-NautilusBonoboActivationHandle *
-nautilus_bonobo_activate_from_id (const char *iid,
- NautilusBonoboActivationCallback callback,
- gpointer callback_data)
-{
- NautilusBonoboActivationHandle *handle;
- struct CreateObjectData *data;
- CORBA_Object activated_object;
-
- g_return_val_if_fail (iid != NULL, NULL);
- g_return_val_if_fail (callback != NULL, NULL);
-
- handle = g_new0 (NautilusBonoboActivationHandle, 1);
-
- handle->early_completion_hook = &handle;
- handle->callback = callback;
- handle->callback_data = callback_data;
-
- handle->activated_object = CORBA_OBJECT_NIL;
-
- if (nautilus_activation_shortcuts != NULL) {
- data = g_hash_table_lookup (nautilus_activation_shortcuts, iid);
- if (data != NULL) {
- activated_object = (*data->create_object) (iid, data->callback_data);
- if (activated_object != CORBA_OBJECT_NIL) {
- handle->activated_object = activated_object;
- handle->early_completion_hook = NULL;
- handle->idle_id = g_idle_add (activation_idle_callback,
- handle);
- return handle;
- }
- }
- }
-
- handle->timeout_id = g_timeout_add (4*1000, activation_timed_out, handle);
-
- bonobo_activation_activate_from_id_async ((char *) iid, 0,
- bonobo_activation_activation_callback,
- handle, NULL);
-
- if (handle != NULL) {
- handle->early_completion_hook = NULL;
- }
-
- return handle;
-}
-
-/**
- * nautilus_bonobo_activate_stop:
- * @iid: iid of component to activate.
- * @callback: callback to call when activation finished.
- * @user_data: data to pass to callback when activation finished.
- *
- * Stops activation of a component. Your callback will not be called
- * after this call.
- */
-void
-nautilus_bonobo_activate_cancel (NautilusBonoboActivationHandle *handle)
-{
- if (handle == NULL) {
- return;
- }
-
- if (handle->timeout_id != 0) {
- g_source_remove (handle->timeout_id);
- handle->timeout_id = 0;
- }
-
- activation_handle_done (handle);
-
- if (handle->idle_id == 0) {
- /* no way to cancel the underlying bonobo-activation call, so we just set a flag */
- handle->cancel = TRUE;
- } else {
- g_source_remove (handle->idle_id);
- activation_cancel (handle);
- }
-}
-
-Bonobo_RegistrationResult
-nautilus_bonobo_activation_register_for_display (const char *iid,
- Bonobo_Unknown ref)
-{
- const char *display_name;
- GSList *reg_env ;
- Bonobo_RegistrationResult result;
-
- display_name = gdk_display_get_name (gdk_display_get_default());
- reg_env = bonobo_activation_registration_env_set (NULL,
- "DISPLAY", display_name);
- result = bonobo_activation_register_active_server (iid, ref, reg_env);
- bonobo_activation_registration_env_free (reg_env);
- return result;
-}
diff --git a/libnautilus-private/nautilus-bonobo-extensions.h b/libnautilus-private/nautilus-bonobo-extensions.h
deleted file mode 100644
index 46c985150..000000000
--- a/libnautilus-private/nautilus-bonobo-extensions.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/* nautilus-bonobo-extensions.h - interface for new functions that conceptually
- belong in bonobo. Perhaps some of these will be
- actually rolled into bonobo someday.
-
- 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.
-
- Author: John Sullivan <sullivan@eazel.com>
-*/
-
-#ifndef NAUTILUS_BONOBO_EXTENSIONS_H
-#define NAUTILUS_BONOBO_EXTENSIONS_H
-
-#include <bonobo/bonobo-ui-component.h>
-#include <bonobo/bonobo-xobject.h>
-#include <bonobo/bonobo-generic-factory.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
-
-#include <libnautilus-extension/nautilus-menu-item.h>
-
-typedef struct NautilusBonoboActivationHandle NautilusBonoboActivationHandle;
-
-typedef void (*NautilusBonoboActivationCallback) (NautilusBonoboActivationHandle *handle,
- Bonobo_Unknown activated_object,
- gpointer callback_data);
-
-typedef CORBA_Object (*NautilusBonoboCreateObject) (const char *iid,
- gpointer callback_data);
-
-void nautilus_bonobo_set_accelerator (BonoboUIComponent *ui,
- const char *path,
- const char *accelerator);
-char * nautilus_bonobo_get_label (BonoboUIComponent *ui,
- const char *path);
-void nautilus_bonobo_set_label (BonoboUIComponent *ui,
- const char *path,
- const char *label);
-void nautilus_bonobo_set_tip (BonoboUIComponent *ui,
- const char *path,
- const char *tip);
-void nautilus_bonobo_set_sensitive (BonoboUIComponent *ui,
- const char *path,
- gboolean sensitive);
-void nautilus_bonobo_set_toggle_state (BonoboUIComponent *ui,
- const char *path,
- gboolean state);
-void nautilus_bonobo_set_hidden (BonoboUIComponent *ui,
- const char *path,
- gboolean hidden);
-gboolean nautilus_bonobo_get_hidden (BonoboUIComponent *ui,
- const char *path);
-void nautilus_bonobo_add_numbered_menu_item (BonoboUIComponent *ui,
- const char *container_path,
- guint index,
- const char *label,
- GdkPixbuf *pixbuf);
-void nautilus_bonobo_add_numbered_toggle_menu_item (BonoboUIComponent *ui,
- const char *container_path,
- guint index,
- const char *label);
-void nautilus_bonobo_add_numbered_radio_menu_item (BonoboUIComponent *ui,
- const char *container_path,
- guint index,
- const char *label,
- const char *radio_group_name);
-char * nautilus_bonobo_get_numbered_menu_item_command (BonoboUIComponent *ui,
- const char *container_path,
- guint index);
-char * nautilus_bonobo_get_numbered_menu_item_path (BonoboUIComponent *ui,
- const char *container_path,
- guint index);
-
-guint nautilus_bonobo_get_numbered_menu_item_index_from_command
-(const char *command);
-char * nautilus_bonobo_get_numbered_menu_item_container_path_from_command
-(const char *command);
-void nautilus_bonobo_add_submenu (BonoboUIComponent *ui,
- const char *container_path,
- const char *label,
- GdkPixbuf *pixbuf);
-void nautilus_bonobo_add_menu_separator (BonoboUIComponent *ui,
- const char *path);
-void nautilus_bonobo_remove_menu_items_and_commands (BonoboUIComponent *ui,
- const char *container_path);
-void nautilus_bonobo_set_label_for_toolitem_and_command (BonoboUIComponent *ui,
- const char *toolitem_path,
- const char *command_path,
- const char *label_with_underscore);
-void nautilus_bonobo_set_icon (BonoboUIComponent *ui,
- const char *path,
- const char *icon_relative_path);
-void nautilus_bonobo_add_extension_item_command (BonoboUIComponent *ui,
- NautilusMenuItem *item);
-char *nautilus_bonobo_get_extension_item_command_xml (NautilusMenuItem *item);
-
-void nautilus_bonobo_add_extension_item (BonoboUIComponent *ui,
- const char *path,
- NautilusMenuItem *item);
-void nautilus_bonobo_add_extension_toolbar_item (BonoboUIComponent *ui,
- const char *path,
- NautilusMenuItem *item);
-void nautilus_bonobo_register_activation_shortcut (const char *iid,
- NautilusBonoboCreateObject create_object_callback,
- gpointer callback_data);
-void nautilus_bonobo_unregister_activation_shortcut (const char *iid);
-NautilusBonoboActivationHandle *nautilus_bonobo_activate_from_id (const char *iid,
- NautilusBonoboActivationCallback callback,
- gpointer callback_data);
-void nautilus_bonobo_activate_cancel (NautilusBonoboActivationHandle *handle);
-Bonobo_RegistrationResult nautilus_bonobo_activation_register_for_display (const char *iid,
- Bonobo_Unknown ref);
-
-
-
-#endif /* NAUTILUS_BONOBO_EXTENSIONS_H */
diff --git a/libnautilus-private/nautilus-clipboard-monitor.c b/libnautilus-private/nautilus-clipboard-monitor.c
index ffe02d93c..3fb40ac04 100644
--- a/libnautilus-private/nautilus-clipboard-monitor.c
+++ b/libnautilus-private/nautilus-clipboard-monitor.c
@@ -28,6 +28,8 @@
#include <eel/eel-debug.h>
#include <eel/eel-gtk-macros.h>
#include <eel/eel-glib-extensions.h>
+#include <eel/eel-glib-extensions.h>
+#include <gtk/gtkclipboard.h>
/* X11 has a weakness when it comes to clipboard handling,
* there is no way to get told when the owner of the clipboard
@@ -36,8 +38,12 @@
* internally in an app by telling the clipboard monitor when
* we changed the clipboard. Unfortunately this doesn't give
* us perfect results, we still don't catch changes made by
- * other clients. The solution to that is to use the XFIXES
- * extension, which isn't availible yet.
+ * other clients
+ *
+ * This is fixed with the XFIXES extensions, which recent versions
+ * of Gtk+ supports as the owner_change signal on GtkClipboard. We
+ * use this now, but keep the old code since not all X servers support
+ * XFIXES.
*/
enum {
@@ -68,9 +74,15 @@ destroy_clipboard_monitor (void)
NautilusClipboardMonitor *
nautilus_clipboard_monitor_get (void)
{
+ GtkClipboard *clipboard;
+
if (clipboard_monitor == NULL) {
clipboard_monitor = NAUTILUS_CLIPBOARD_MONITOR (g_object_new (NAUTILUS_TYPE_CLIPBOARD_MONITOR, NULL));
eel_debug_call_at_shutdown (destroy_clipboard_monitor);
+
+ clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+ g_signal_connect (clipboard, "owner_change",
+ G_CALLBACK (nautilus_clipboard_monitor_emit_changed), NULL);
}
return clipboard_monitor;
}
diff --git a/libnautilus-private/nautilus-clipboard.c b/libnautilus-private/nautilus-clipboard.c
new file mode 100644
index 000000000..6863a9007
--- /dev/null
+++ b/libnautilus-private/nautilus-clipboard.c
@@ -0,0 +1,457 @@
+/* -*- 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-file-utilities.h"
+
+#include <libgnome/gnome-i18n.h>
+#include <gtk/gtkclipboard.h>
+#include <gtk/gtkstock.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 selection_changed_callback (GtkWidget *widget,
+ gpointer callback_data);
+static void owner_change_callback (GtkClipboard *clipboard,
+ GdkEventOwnerChange *event,
+ gpointer callback_data);
+
+static void
+action_cut_callback (GtkAction *action,
+ gpointer callback_data)
+{
+ gtk_editable_cut_clipboard (GTK_EDITABLE (callback_data));
+}
+
+static void
+action_copy_callback (GtkAction *action,
+ gpointer callback_data)
+{
+ gtk_editable_copy_clipboard (GTK_EDITABLE (callback_data));
+}
+
+static void
+action_paste_callback (GtkAction *action,
+ gpointer callback_data)
+{
+ gtk_editable_paste_clipboard (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
+action_select_all_callback (GtkAction *action,
+ gpointer callback_data)
+{
+ GSource *source;
+ GtkEditable *editable;
+
+ 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
+received_clipboard_contents (GtkClipboard *clipboard,
+ GtkSelectionData *selection_data,
+ gpointer data)
+{
+ GtkActionGroup *action_group;
+ GtkAction *action;
+
+ action_group = data;
+
+ action = gtk_action_group_get_action (action_group,
+ "Paste");
+ if (action != NULL) {
+ gtk_action_set_sensitive (action,
+ gtk_selection_data_targets_include_text (selection_data));
+ }
+
+ g_object_unref (action_group);
+}
+
+
+static void
+set_paste_sensitive_if_clipboard_contains_data (GtkActionGroup *action_group)
+{
+ GtkAction *action;
+ if (gdk_display_supports_selection_notification (gdk_display_get_default ())) {
+ gtk_clipboard_request_contents (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD),
+ gdk_atom_intern ("TARGETS", FALSE),
+ received_clipboard_contents,
+ g_object_ref (action_group));
+ } else {
+ /* If selection notification isn't supported, always activate Paste */
+ action = gtk_action_group_get_action (action_group,
+ "Paste");
+ gtk_action_set_sensitive (action, TRUE);
+ }
+}
+
+static void
+set_clipboard_menu_items_sensitive (GtkActionGroup *action_group)
+{
+ GtkAction *action;
+
+ action = gtk_action_group_get_action (action_group,
+ "Cut");
+ gtk_action_set_sensitive (action, TRUE);
+ action = gtk_action_group_get_action (action_group,
+ "Copy");
+ gtk_action_set_sensitive (action, TRUE);
+}
+
+static void
+set_clipboard_menu_items_insensitive (GtkActionGroup *action_group)
+{
+ GtkAction *action;
+
+ action = gtk_action_group_get_action (action_group,
+ "Cut");
+ gtk_action_set_sensitive (action, FALSE);
+ action = gtk_action_group_get_action (action_group,
+ "Copy");
+ gtk_action_set_sensitive (action, FALSE);
+}
+
+typedef struct {
+ GtkUIManager *ui_manager;
+ GtkActionGroup *action_group;
+ guint merge_id;
+ 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 char * clipboard_ui =
+"<ui>"
+"<menubar name='MenuBar'>"
+" <menu action='Edit'>"
+" <menuitem name='Cut' "
+" action='Cut'/>"
+" <menuitem name='Copy' "
+" action='Copy'/>"
+" <menuitem name='Paste' "
+" action='Paste'/>"
+" <menuitem name='Select All'"
+" action='Select All'/>"
+" </menu>"
+"</menubar>"
+"</ui>";
+
+
+static void
+merge_in_clipboard_menu_items (GObject *widget_as_object,
+ TargetCallbackData *target_data)
+{
+ gboolean add_selection_callback;
+
+ g_assert (target_data != NULL);
+
+ add_selection_callback = target_data->editable_shares_selection_changes;
+
+ gtk_ui_manager_insert_action_group (target_data->ui_manager,
+ target_data->action_group, 0);
+
+ target_data->merge_id = gtk_ui_manager_add_ui_from_string (target_data->ui_manager,
+ clipboard_ui, -1, NULL);
+
+ set_paste_sensitive_if_clipboard_contains_data (target_data->action_group);
+
+ g_signal_connect (gtk_clipboard_get (GDK_SELECTION_CLIPBOARD), "owner_change",
+ G_CALLBACK (owner_change_callback), target_data);
+
+ 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 (target_data->action_group);
+ }
+ set_clipboard_items_are_merged_in (widget_as_object, TRUE);
+}
+
+static void
+merge_out_clipboard_menu_items (GObject *widget_as_object,
+ TargetCallbackData *target_data)
+
+{
+ gboolean selection_callback_was_added;
+
+ g_assert (target_data != NULL);
+
+ gtk_ui_manager_remove_action_group (target_data->ui_manager,
+ target_data->action_group);
+
+ if (target_data->merge_id != 0) {
+ gtk_ui_manager_remove_ui (target_data->ui_manager,
+ target_data->merge_id);
+ target_data->merge_id = 0;
+ }
+
+ g_signal_handlers_disconnect_matched (widget_as_object,
+ G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL,
+ G_CALLBACK (owner_change_callback),
+ target_data);
+
+ selection_callback_was_added = target_data->editable_shares_selection_changes;
+
+ 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;
+ GtkEditable *editable;
+ int start, end;
+
+ target_data = (TargetCallbackData *) callback_data;
+ g_assert (target_data != NULL);
+
+ editable = GTK_EDITABLE (widget);
+
+ if (gtk_editable_get_selection_bounds (editable, &start, &end) && start != end) {
+ set_clipboard_menu_items_sensitive (target_data->action_group);
+ } else {
+ set_clipboard_menu_items_insensitive (target_data->action_group);
+ }
+}
+
+static void
+owner_change_callback (GtkClipboard *clipboard,
+ GdkEventOwnerChange *event,
+ gpointer callback_data)
+{
+ TargetCallbackData *target_data;
+
+ g_assert (callback_data != NULL);
+ target_data = callback_data;
+
+ set_paste_sensitive_if_clipboard_contains_data (target_data->action_group);
+}
+
+static void
+target_destroy_callback (GtkObject *object,
+ gpointer callback_data)
+{
+ TargetCallbackData *target_data;
+
+ g_assert (callback_data != NULL);
+ target_data = callback_data;
+
+ if (clipboard_items_are_merged_in (GTK_WIDGET(object))) {
+ merge_out_clipboard_menu_items (G_OBJECT (object), callback_data);
+ }
+}
+
+static void
+target_data_free (TargetCallbackData *target_data)
+{
+ g_object_unref (target_data->action_group);
+ g_free (target_data);
+}
+
+static GtkActionEntry clipboard_entries[] = {
+ { "Cut", GTK_STOCK_CUT, /* name, stock id */
+ N_("Cut _Text"), "<control>x", /* label, accelerator */
+ N_("Cut the selected text to the clipboard"), /* tooltip */
+ G_CALLBACK (action_cut_callback) },
+ { "Copy", GTK_STOCK_COPY, /* name, stock id */
+ N_("_Copy Text"), "<control>c", /* label, accelerator */
+ N_("Copy the selected text to the clipboard"), /* tooltip */
+ G_CALLBACK (action_copy_callback) },
+ { "Paste", GTK_STOCK_PASTE, /* name, stock id */
+ N_("_Paste Text"), "<control>v", /* label, accelerator */
+ N_("Paste the text stored on the clipboard"), /* tooltip */
+ G_CALLBACK (action_paste_callback) },
+ { "Select All", NULL, /* name, stock id */
+ N_("Select _All"), "<control>A", /* label, accelerator */
+ N_("Select all the text in a text field"), /* tooltip */
+ G_CALLBACK (action_select_all_callback) },
+};
+
+static TargetCallbackData *
+initialize_clipboard_component_with_callback_data (GtkEditable *target,
+ GtkUIManager *ui_manager,
+ gboolean shares_selection_changes)
+{
+ GtkActionGroup *action_group;
+ TargetCallbackData *target_data;
+
+ action_group = gtk_action_group_new ("ClipboardActions");
+ gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions (action_group,
+ clipboard_entries, G_N_ELEMENTS (clipboard_entries),
+ 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->ui_manager = ui_manager;
+ target_data->action_group = action_group;
+ target_data->editable_shares_selection_changes = shares_selection_changes;
+
+ return target_data;
+}
+
+void
+nautilus_clipboard_set_up_editable (GtkEditable *target,
+ GtkUIManager *ui_manager,
+ gboolean shares_selection_changes)
+{
+ TargetCallbackData *target_data;
+
+ g_return_if_fail (GTK_IS_EDITABLE (target));
+ g_return_if_fail (ui_manager != NULL);
+
+ target_data = initialize_clipboard_component_with_callback_data
+ (target,
+ ui_manager,
+ 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) target_data_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);
+}
diff --git a/libnautilus-private/nautilus-clipboard.h b/libnautilus-private/nautilus-clipboard.h
new file mode 100644
index 000000000..041e9c69c
--- /dev/null
+++ b/libnautilus-private/nautilus-clipboard.h
@@ -0,0 +1,45 @@
+/* -*- 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 <gtk/gtkuimanager.h>
+
+/* This makes this editable put clipboard commands into the passed UI
+ * manager when the editable is in focus. Callers in Nautilus
+ * normally get the UI manager from
+ * nautilus_window_get_ui_manager. */
+/* 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,
+ GtkUIManager *ui_manager,
+ 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-async.c b/libnautilus-private/nautilus-directory-async.c
index 685d9f693..394e09107 100644
--- a/libnautilus-private/nautilus-directory-async.c
+++ b/libnautilus-private/nautilus-directory-async.c
@@ -34,7 +34,6 @@
#include "nautilus-link.h"
#include "nautilus-marshal.h"
#include "nautilus-metafile.h"
-#include "nautilus-search-uri.h"
#include <eel/eel-glib-extensions.h>
#include <eel/eel-string.h>
#include <gtk/gtkmain.h>
@@ -1601,6 +1600,10 @@ nautilus_async_destroying_file (NautilusFile *file)
directory->details->link_info_read_state->file = NULL;
changed = TRUE;
}
+ if (directory->details->extension_info_file == file) {
+ directory->details->extension_info_file = NULL;
+ changed = TRUE;
+ }
/* Let the directory take care of the rest. */
if (changed) {
@@ -1941,75 +1944,6 @@ mark_all_files_unconfirmed (NautilusDirectory *directory)
}
}
-#if GNOME2_HAS_MEDUSA
-
-static gboolean
-should_display_file_name (const char *name,
- GnomeVFSDirectoryFilterOptions options)
-{
- /* Note that the name is URI-encoded, but this should not
- * affect the . or the ~.
- */
-
- if ((options & GNOME_VFS_DIRECTORY_FILTER_NODOTFILES) != 0
- && nautilus_file_name_matches_hidden_pattern (name)) {
- return FALSE;
- }
-
- if ((options & GNOME_VFS_DIRECTORY_FILTER_NOBACKUPFILES) != 0
- && nautilus_file_name_matches_backup_pattern (name)) {
- return FALSE;
- }
-
- /* Note that we don't bother to check for "." or ".." here, because
- * this function is used only for search results, which never include
- * those special files. If we later use this function more generally,
- * we might have to change this.
- */
- return TRUE;
-}
-
-/* Filter search results based on user preferences. This must be done
- * differently than filtering other files because the search results
- * are encoded: the entire file path is encoded and stored as the file
- * name.
- */
-static gboolean
-filter_search_uri (const GnomeVFSFileInfo *info, gpointer data)
-{
- GnomeVFSDirectoryFilterOptions options;
- char *real_file_uri, *filename;
- gboolean result;
-
- options = GPOINTER_TO_INT (data);
-
- real_file_uri = nautilus_get_target_uri_from_search_result_name (info->name);
- filename = g_path_get_basename (real_file_uri);
- result = should_display_file_name (filename, options);
- g_free (real_file_uri);
- g_free (filename);
-
- return result;
-}
-
-static GnomeVFSDirectoryFilter *
-get_file_count_filter (NautilusDirectory *directory)
-{
- if (nautilus_is_search_uri (directory->details->uri)) {
- return gnome_vfs_directory_filter_new_custom
- (filter_search_uri,
- GNOME_VFS_DIRECTORY_FILTER_NEEDS_NAME,
- GINT_TO_POINTER (get_filter_options_for_directory_count ()));
- }
-
- return gnome_vfs_directory_filter_new
- (GNOME_VFS_DIRECTORY_FILTER_NONE,
- get_filter_options_for_directory_count (),
- NULL);
-}
-
-#endif
-
static void
read_dot_hidden_file (NautilusDirectory *directory)
{
@@ -3219,13 +3153,18 @@ static void
extension_info_cancel (NautilusDirectory *directory)
{
if (directory->details->extension_info_in_progress != NULL) {
- nautilus_info_provider_cancel_update
- (directory->details->extension_info_provider,
- directory->details->extension_info_in_progress);
+ if (directory->details->extension_info_idle) {
+ g_source_remove (directory->details->extension_info_idle);
+ } else {
+ nautilus_info_provider_cancel_update
+ (directory->details->extension_info_provider,
+ directory->details->extension_info_in_progress);
+ }
directory->details->extension_info_in_progress = NULL;
directory->details->extension_info_file = NULL;
directory->details->extension_info_provider = NULL;
+ directory->details->extension_info_idle = 0;
async_job_end (directory, "extension info");
}
@@ -3290,7 +3229,8 @@ info_provider_idle_callback (gpointer user_data)
directory->details->extension_info_file = NULL;
directory->details->extension_info_provider = NULL;
directory->details->extension_info_in_progress = NULL;
-
+ directory->details->extension_info_idle = 0;
+
finish_info_provider (directory, file, response->provider);
}
@@ -3311,7 +3251,10 @@ info_provider_callback (NautilusInfoProvider *provider,
response->result = result;
response->directory = NAUTILUS_DIRECTORY (user_data);
- g_idle_add (info_provider_idle_callback, response);
+ response->directory->details->extension_info_idle =
+ g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
+ info_provider_idle_callback, response,
+ g_free);
}
static void
diff --git a/libnautilus-private/nautilus-directory-background.c b/libnautilus-private/nautilus-directory-background.c
index 75d7ddf56..9c4e60481 100644
--- a/libnautilus-private/nautilus-directory-background.c
+++ b/libnautilus-private/nautilus-directory-background.c
@@ -618,7 +618,6 @@ background_changed_callback (EelBackground *background,
action = default_drag_action;
- g_print ("checking action, default_drag_action is %d\n", action);
}
if (action == NAUTILUS_DND_ACTION_SET_AS_GLOBAL_BACKGROUND) {
diff --git a/libnautilus-private/nautilus-directory-metafile-monitor.c b/libnautilus-private/nautilus-directory-metafile-monitor.c
index 3cc32d56a..4297d0f18 100644
--- a/libnautilus-private/nautilus-directory-metafile-monitor.c
+++ b/libnautilus-private/nautilus-directory-metafile-monitor.c
@@ -28,7 +28,6 @@
#include <eel/eel-gtk-macros.h>
#include <eel/eel-glib-extensions.h>
-#include "nautilus-bonobo-extensions.h"
struct NautilusMetafileMonitorDetails {
NautilusDirectory *directory;
diff --git a/libnautilus-private/nautilus-directory-private.h b/libnautilus-private/nautilus-directory-private.h
index d60554ea1..4c0cf4e0c 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>
@@ -109,6 +109,7 @@ struct NautilusDirectoryDetails
NautilusFile *extension_info_file;
NautilusInfoProvider *extension_info_provider;
NautilusOperationHandle *extension_info_in_progress;
+ guint extension_info_idle;
TopLeftTextReadState *top_left_read_state;
diff --git a/libnautilus-private/nautilus-drag-window.c b/libnautilus-private/nautilus-drag-window.c
deleted file mode 100644
index 67771c35c..000000000
--- a/libnautilus-private/nautilus-drag-window.c
+++ /dev/null
@@ -1,393 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-
-/*
- * Nautilus
- *
- * Copyright (C) 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.
- *
- * Author: John Harper <jsh@eazel.com>
- *
- */
-
-/* Registering that a window may be used as a drag 'n drop source */
-
-#include <config.h>
-#include "nautilus-drag-window.h"
-
-#include <eel/eel-gdk-extensions.h>
-#include <gtk/gtk.h>
-#include <X11/Xatom.h>
-#include <gdk/gdkx.h>
-#include <gdk/gdkprivate.h>
-
-/* State for handling focus/raise */
-typedef struct NautilusDragWindowDetails NautilusDragWindowDetails;
-struct NautilusDragWindowDetails {
- gboolean in_button_press;
- gboolean pending_focus;
- gboolean pending_raise;
-
- Time focus_timestamp;
-
- guint focus_timeout_tag;
-};
-
-/* Delay in milliseconds between receiving a TAKE_FOCUS or RAISE_WINDOW
- * client message, and assuming that there's no following button-press
- * event. This seems to be large enough to work, but small enough to be
- * unnoticeable to the user.
- */
-#define WINDOW_FOCUS_TIMEOUT 50
-
-/* Key used to store a NautilusDragWindowDetails structure in each
- * registered window's object data hash
- */
-#define NAUTILUS_DRAG_WINDOW_DETAILS_KEY "nautilus-drag-window-details"
-
-/* Return the nearest ancestor of WIDGET that has type WIDGET_TYPE. But only
- * if there's no widget between the two with type BLOCKING_TYPE.
- */
-static GtkWidget *
-get_ancestor_blocked_by (GtkWidget *widget,
- GType widget_type,
- GType blocking_type)
-{
- g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
-
- while (widget != NULL)
- {
- if (g_type_is_a (GTK_WIDGET_TYPE (widget), widget_type))
- return widget;
-
- else if (g_type_is_a (GTK_WIDGET_TYPE (widget), blocking_type))
- return NULL;
-
- widget = widget->parent;
- }
-
- return NULL;
-}
-
-/* Returns the details structure associated with WINDOW, or a null pointer
- * if no such structure exists
- */
-static NautilusDragWindowDetails *
-get_details (GtkWindow *window)
-{
- NautilusDragWindowDetails *details;
-
- details = g_object_get_data (G_OBJECT (window),
- NAUTILUS_DRAG_WINDOW_DETAILS_KEY);
- return details;
-}
-
-/* Commit any pending focus/raise requests for WINDOW. */
-static void
-execute_pending_requests (GtkWindow *window,
- NautilusDragWindowDetails *details)
-{
- if (GTK_WIDGET_REALIZED (window)) {
- if (details->pending_focus) {
- eel_gdk_window_focus (GTK_WIDGET (window)->window,
- details->focus_timestamp);
- details->pending_focus = FALSE;
- }
- if (details->pending_raise) {
- gdk_window_raise (GTK_WIDGET (window)->window);
- details->pending_raise = FALSE;
- }
- }
-}
-
-/* Called when no button-press event arrived occurred shortly after
- * receiving a TAKE_FOCUS or RAISE_WINDOW request. So just commit
- * the pending requests.
- */
-static gint
-focus_timeout_callback (gpointer data)
-{
- GtkWindow *window;
- NautilusDragWindowDetails *details;
-
- window = GTK_WINDOW (data);
- details = get_details (window);
-
- if (details != NULL) {
- execute_pending_requests (window, details);
-
- details->focus_timeout_tag = 0;
- }
-
- /* Only ever a one-shot timeout */
- return FALSE;
-}
-
-
-static void
-remove_focus_timeout (GtkWindow *window)
-{
- NautilusDragWindowDetails *details;
-
- details = get_details (window);
-
- if (details != NULL && details->focus_timeout_tag != 0) {
- g_source_remove (details->focus_timeout_tag);
- details->focus_timeout_tag = 0;
- }
-}
-
-static void
-set_focus_timeout (GtkWindow *window)
-{
- NautilusDragWindowDetails *details;
-
- details = get_details (window);
-
- if (details != NULL) {
- remove_focus_timeout (window);
- details->focus_timeout_tag
- = g_timeout_add (WINDOW_FOCUS_TIMEOUT,
- focus_timeout_callback, window);
- }
-}
-
-/* Called for all button-press events; sets the `in_button_press' flag */
-static gboolean
-button_press_emission_callback (GSignalInvocationHint *ihint,
- guint n_params, const GValue *params,
- gpointer data)
-{
- GtkWidget *window;
- NautilusDragWindowDetails *details;
-
- /* This blocking is kind of a hack. But it seems necessary,
- * otherwise we can get duped into counting unbalanced
- * press/release events, which isn't healthy
- */
- window = get_ancestor_blocked_by (GTK_WIDGET (g_value_get_object (&params[0])),
- GTK_TYPE_WINDOW,
- GTK_TYPE_MENU_SHELL);
- if (window != NULL) {
- details = get_details (GTK_WINDOW (window));
- if (details != NULL) {
- remove_focus_timeout (GTK_WINDOW (window));
-
- if (!details->in_button_press) {
- details->in_button_press = TRUE;
- } else {
- /* We never got the last button
- * release. Adapt.
- */
- execute_pending_requests (GTK_WINDOW (window),
- details);
- details->in_button_press = FALSE;
- }
- }
- }
-
- return TRUE;
-}
-
-/* Called for button-release events; commits any pending focus/raise */
-static gboolean
-button_release_emission_callback (GSignalInvocationHint *ihint,
- guint n_params, const GValue *params,
- gpointer data)
-{
- GtkWidget *window;
- NautilusDragWindowDetails *details;
-
- window = get_ancestor_blocked_by (GTK_WIDGET (g_value_get_object (&params[0])),
- GTK_TYPE_WINDOW,
- GTK_TYPE_MENU_SHELL);
- if (window != NULL) {
- details = get_details (GTK_WINDOW (window));
- if (details != NULL) {
- execute_pending_requests (GTK_WINDOW (window),
- details);
- details->in_button_press = FALSE;
- }
- }
-
- return TRUE;
-}
-
-/* Called when a drag is started. If a drag-window is found above the
- * widget emitting the signal, cancel any pending focus/raise requests
- */
-static gboolean
-drag_begin_emission_callback (GSignalInvocationHint *ihint,
- guint n_params, const GValue *params,
- gpointer data)
-{
- GtkWidget *window;
- NautilusDragWindowDetails *details;
-
- window = gtk_widget_get_toplevel (GTK_WIDGET (g_value_get_object (&params[0])));
-
- if (window != NULL) {
- details = get_details (GTK_WINDOW (window));
- if (details != NULL) {
-
- details->pending_focus = FALSE;
- details->pending_raise = FALSE;
- }
- }
-
- return TRUE;
-}
-
-/* The process-wide filter for WM_PROTOCOLS client messages */
-static GdkFilterReturn
-wm_protocols_filter (GdkXEvent *xev, GdkEvent *event, gpointer data)
-{
- XEvent *xevent;
- GtkWindow *window;
- NautilusDragWindowDetails *details;
-
- xevent = (XEvent *)xev;
-
- gdk_window_get_user_data (event->any.window, (gpointer *) &window);
- if (window != NULL) {
- details = get_details (window);
- } else {
- details = NULL;
- }
-
- if ((Atom) xevent->xclient.data.l[0] == gdk_x11_get_xatom_by_name ("WM_DELETE_WINDOW")) {
-
- /* (copied from gdkevents.c) */
-
- /* The delete window request specifies a window
- * to delete. We don't actually destroy the
- * window because "it is only a request". (The
- * window might contain vital data that the
- * program does not want destroyed). Instead
- * the event is passed along to the program,
- * which should then destroy the window.
- */
-
- event->any.type = GDK_DELETE;
- return GDK_FILTER_TRANSLATE;
-
- } else if ((Atom) xevent->xclient.data.l[0] == gdk_x11_get_xatom_by_name ("WM_TAKE_FOCUS")) {
-
- if (details != NULL) {
- details->pending_focus = TRUE;
- details->focus_timestamp = xevent->xclient.data.l[1];
-
- /* Wait to see if a button-press event
- * is received in the near future.
- */
- set_focus_timeout (window);
- }
- return GDK_FILTER_REMOVE;
-
- } else if ((Atom) xevent->xclient.data.l[0] == gdk_x11_get_xatom_by_name ("_SAWFISH_WM_RAISE_WINDOW")) {
-
- if (details != NULL) {
- details->pending_raise = TRUE;
-
- /* Wait to see if a button-press event
- * is received in the near future.
- */
- set_focus_timeout (window);
- }
- return GDK_FILTER_REMOVE;
- }
- else {
- return GDK_FILTER_CONTINUE;
- }
-}
-
-static void
-nautilus_drag_window_destroy (GtkObject *object, gpointer data)
-{
- remove_focus_timeout (GTK_WINDOW (object));
-}
-
-static void
-nautilus_drag_window_realize (GtkWidget *widget, gpointer data)
-{
- GdkAtom protocols[3];
-
- /* Tell the window manager _not_ to focus this window by itself */
- eel_gdk_window_set_wm_hints_input (widget->window, FALSE);
-
- /* Set WM_PROTOCOLS to the usual two atoms plus something that tells
- * sawfish to send messages telling us when we might want to raise
- * the window. (This won't work with other wm's, but it won't
- * break anything either.)
- */
- protocols[0] = gdk_atom_intern ("WM_DELETE_WINDOW", FALSE);
- protocols[1] = gdk_atom_intern ("WM_TAKE_FOCUS", FALSE);
- protocols[2] = gdk_atom_intern ("_NET_WM_PING", FALSE);
- eel_gdk_window_set_wm_protocols (widget->window, protocols, 3);
-}
-
-/* Public entry point */
-
-/* initialize the instance's fields */
-void
-nautilus_drag_window_register (GtkWindow *window)
-{
- static gboolean initialized = FALSE;
-
- NautilusDragWindowDetails *details;
- guint signal_id;
-
- /* FIXME: This is disabled until we come up with a better
- * way to do this. Havoc had some ideas.
- */
- return;
-
- if (!initialized) {
- /* Add emission hooks for the signals we need to monitor
- */
- signal_id = g_signal_lookup ("button_press_event",
- GTK_TYPE_WIDGET);
- g_signal_add_emission_hook (signal_id, 0,
- button_press_emission_callback, NULL, NULL);
- signal_id = g_signal_lookup ("button_release_event",
- GTK_TYPE_WIDGET);
- g_signal_add_emission_hook (signal_id, 0,
- button_release_emission_callback, NULL, NULL);
- signal_id = g_signal_lookup ("drag_begin",
- GTK_TYPE_WIDGET);
- g_signal_add_emission_hook (signal_id, 0,
- drag_begin_emission_callback, NULL, NULL);
-
- /* Override the standard GTK filter for handling WM_PROTOCOLS
- * client messages
- */
- gdk_add_client_message_filter (gdk_atom_intern ("WM_PROTOCOLS", FALSE),
- wm_protocols_filter, NULL);
-
- initialized = TRUE;
- }
-
- details = g_new0 (NautilusDragWindowDetails, 1);
-
- g_object_set_data_full (G_OBJECT (window),
- NAUTILUS_DRAG_WINDOW_DETAILS_KEY,
- details, g_free);
-
- g_signal_connect (window, "realize",
- G_CALLBACK (nautilus_drag_window_realize), NULL);
- g_signal_connect (window, "destroy",
- G_CALLBACK (nautilus_drag_window_destroy), NULL);
-}
diff --git a/libnautilus-private/nautilus-drag-window.h b/libnautilus-private/nautilus-drag-window.h
deleted file mode 100644
index 81e7a9c52..000000000
--- a/libnautilus-private/nautilus-drag-window.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-
-/*
- * Nautilus
- *
- * Copyright (C) 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.
- *
- * Author: John Harper <jsh@eazel.com>
- *
- */
-
-#ifndef NAUTILUS_DRAG_WINDOW_H
-#define NAUTILUS_DRAG_WINDOW_H
-
-#include <gtk/gtkwindow.h>
-
-/* Call this function before WINDOW has been realized. It will hook
- * into the window so that it automatically supports the correct focus
- * policy when dragging objects from within the window. (This policy is
- * *not* to focus or raise the window when the activating click is used
- * to drag something)
- */
-
-void nautilus_drag_window_register (GtkWindow *window);
-
-#endif /* NAUTILUS_DRAG_WINDOW_H */
diff --git a/libnautilus-private/nautilus-file.c b/libnautilus-private/nautilus-file.c
index ba5ab5506..5bbf8fcec 100644
--- a/libnautilus-private/nautilus-file.c
+++ b/libnautilus-private/nautilus-file.c
@@ -811,8 +811,7 @@ nautilus_file_can_execute (NautilusFile *file)
static gboolean
is_desktop_file (NautilusFile *file)
{
- return nautilus_file_is_mime_type (file, "application/x-gnome-app-info") ||
- nautilus_file_is_mime_type (file, "application/x-desktop");
+ return nautilus_file_is_mime_type (file, "application/x-desktop");
}
static gboolean
@@ -5156,9 +5155,9 @@ nautilus_file_get_symbolic_link_target_uri (NautilusFile *file)
gboolean
nautilus_file_is_nautilus_link (NautilusFile *file)
{
- return nautilus_file_is_mime_type (file, "application/x-nautilus-link") ||
- nautilus_file_is_mime_type (file, "application/x-gnome-app-info") ||
- nautilus_file_is_mime_type (file, "application/x-desktop");
+ /* NOTE: I removed the historical link here, because i don't think we
+ even detect that mimetype anymore */
+ return nautilus_file_is_mime_type (file, "application/x-desktop");
}
/**
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-icon-factory.c b/libnautilus-private/nautilus-icon-factory.c
index aab5bbb58..abb659faf 100644
--- a/libnautilus-private/nautilus-icon-factory.c
+++ b/libnautilus-private/nautilus-icon-factory.c
@@ -1501,6 +1501,14 @@ nautilus_get_icon_size_for_zoom_level (NautilusZoomLevel zoom_level)
g_return_val_if_reached (NAUTILUS_ICON_SIZE_STANDARD);
}
+float
+nautilus_get_relative_icon_size_for_zoom_level (NautilusZoomLevel zoom_level)
+{
+ return (float)nautilus_get_icon_size_for_zoom_level (zoom_level) / NAUTILUS_ICON_SIZE_STANDARD;
+}
+
+
+
/* Convenience cover for nautilus_icon_factory_get_icon_for_file
* and nautilus_icon_factory_get_pixbuf_for_icon.
*/
diff --git a/libnautilus-private/nautilus-icon-factory.h b/libnautilus-private/nautilus-icon-factory.h
index 1b1a055c7..e83963d90 100644
--- a/libnautilus-private/nautilus-icon-factory.h
+++ b/libnautilus-private/nautilus-icon-factory.h
@@ -105,6 +105,7 @@ GObject * nautilus_icon_factory_get (void);
/* Relationship between zoom levels and icons sizes. */
guint nautilus_get_icon_size_for_zoom_level (NautilusZoomLevel zoom_level);
+float nautilus_get_relative_icon_size_for_zoom_level (NautilusZoomLevel zoom_level);
/* Choose the appropriate icon, but don't render it yet. */
char * nautilus_icon_factory_get_icon_for_file (NautilusFile *file,
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-lib-self-check-functions.h b/libnautilus-private/nautilus-lib-self-check-functions.h
index 3935595b1..b27db7b8a 100644
--- a/libnautilus-private/nautilus-lib-self-check-functions.h
+++ b/libnautilus-private/nautilus-lib-self-check-functions.h
@@ -39,7 +39,6 @@ void nautilus_run_lib_self_checks (void);
*/
#define NAUTILUS_LIB_FOR_EACH_SELF_CHECK_FUNCTION(macro) \
- macro (nautilus_self_check_search_uri) \
macro (nautilus_self_check_file_utilities) \
macro (nautilus_self_check_file_operations) \
macro (nautilus_self_check_directory) \
diff --git a/libnautilus-private/nautilus-medusa-support.c b/libnautilus-private/nautilus-medusa-support.c
deleted file mode 100644
index 92f5d23e1..000000000
--- a/libnautilus-private/nautilus-medusa-support.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/* nautilus-medusa-support.c - Covers for access to medusa
- from 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>
- Rebecca Schulman <rebecka@eazel.com>
-*/
-
-#include <config.h>
-#include "nautilus-medusa-support.h"
-#include <libgnome/gnome-i18n.h>
-
-#include <eel/eel-glib-extensions.h>
-#include <eel/eel-string.h>
-#include <dirent.h>
-#include <stdio.h>
-#include <sys/types.h>
-
-#ifdef HAVE_MEDUSA
-#include <libmedusa/medusa-system-state.h>
-#endif
-
-gboolean
-nautilus_medusa_services_are_enabled (void)
-{
-#ifdef HAVE_MEDUSA
- return medusa_system_services_are_enabled ();
-#else
- return FALSE;
-#endif
-}
-
-
-NautilusCronStatus
-nautilus_medusa_check_cron_is_enabled (void)
-{
- DIR *proc_directory;
- struct dirent *file;
- char *stat_file_name;
- FILE *stat_file;
- char stat_file_data[128];
- const char *stat_file_process_name;
- int process_number, bytes_read;
- NautilusCronStatus status;
-
- /* We figure out whether cron is running by reading the proc
- directory, and checking for a process named or ending with
- "crond" */
-
- proc_directory = opendir ("/proc");
- if (proc_directory == NULL) {
- return NAUTILUS_CRON_STATUS_UNKNOWN;
- }
-
- status = NAUTILUS_CRON_STATUS_UNKNOWN;
-
- while ((file = readdir (proc_directory)) != NULL) {
- /* Process files have numbers */
- if (!eel_str_to_int (file->d_name, &process_number)) {
- continue;
- }
-
- /* Since we've seen at least one process file, we can change our state
- * from "unknown" to "presumed off until proved otherwise".
- */
- status = NAUTILUS_CRON_STATUS_OFF;
-
- stat_file_name = g_strdup_printf ("/proc/%d/stat", process_number);
- stat_file = fopen (stat_file_name, "r");
- g_free (stat_file_name);
-
- if (stat_file == NULL) {
- continue;
- }
-
- bytes_read = fread (stat_file_data, 1, sizeof (stat_file_data) - 1, stat_file);
- fclose (stat_file);
- stat_file_data[bytes_read] = '\0';
-
- stat_file_process_name = strchr (stat_file_data, ' ');
-
- if (eel_str_has_prefix (stat_file_process_name, " (crond)") ||
- eel_str_has_prefix (stat_file_process_name, " (cron)")) {
- status = NAUTILUS_CRON_STATUS_ON;
- break;
- }
- }
-
- closedir (proc_directory);
- return status;
-}
-
-#ifdef HAVE_MEDUSA
-static const char *
-nautilus_medusa_get_configuration_file_path (void)
-{
- return medusa_get_configuration_file_path ();
-}
-#endif
-
-char *
-nautilus_medusa_get_explanation_of_enabling (void)
-{
-#ifdef HAVE_MEDUSA
- return g_strdup_printf (_("If you would like to enable fast searches, you can "
- "edit the file %s as root. "
- "Setting the enabled flag to \"yes\" will turn medusa "
- "services on.\n"
- "To start indexing and search services right away, you "
- "should also run the following commands as root:\n"
- "\n"
- "medusa-indexd\n"
- "medusa-searchd\n"
- "\n"
- "Fast searches will not be available until an initial "
- "index of your files has been created. This may take "
- "a long time."),
- nautilus_medusa_get_configuration_file_path ());
-#else
- return g_strdup_printf (_("Medusa, the application that performs searches, cannot be found on "
- "your system. If you have compiled nautilus yourself, "
- "you will need to install a copy of medusa and recompile nautilus. "
- "(A copy of Medusa may be available at ftp://ftp.gnome.org)\n"
- "If you are using a packaged version of Nautilus, fast searching is "
- "not available.\n"));
-#endif
-}
diff --git a/libnautilus-private/nautilus-medusa-support.h b/libnautilus-private/nautilus-medusa-support.h
deleted file mode 100644
index 048f7860e..000000000
--- a/libnautilus-private/nautilus-medusa-support.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/* nautilus-medusa-support.h - Covers for access to medusa
- from 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>
- Rebecca Schulman <rebecka@eazel.com>
-*/
-
-#ifndef NAUTILUS_MEDUSA_SUPPORT_H
-#define NAUTILUS_MEDUSA_SUPPORT_H
-
-#include <glib/gtypes.h>
-
-typedef void (* NautilusMedusaChangedCallback) (gpointer data);
-
-typedef enum {
- NAUTILUS_CRON_STATUS_ON,
- NAUTILUS_CRON_STATUS_OFF,
- NAUTILUS_CRON_STATUS_UNKNOWN
-} NautilusCronStatus;
-
-
-gboolean nautilus_medusa_services_are_enabled (void);
-NautilusCronStatus nautilus_medusa_check_cron_is_enabled (void);
-char * nautilus_medusa_get_explanation_of_enabling (void);
-
-#endif /* NAUTILUS_MEDUSA_SUPPORT_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-metafile.c b/libnautilus-private/nautilus-metafile.c
index a437b1833..97130e6d4 100644
--- a/libnautilus-private/nautilus-metafile.c
+++ b/libnautilus-private/nautilus-metafile.c
@@ -23,14 +23,12 @@
#include <config.h>
#include "nautilus-metafile.h"
-#include "nautilus-bonobo-extensions.h"
#include "nautilus-directory.h"
#include "nautilus-directory.h"
#include "nautilus-file-private.h"
#include "nautilus-file-utilities.h"
#include "nautilus-global-preferences.h"
#include "nautilus-metadata.h"
-#include "nautilus-search-uri.h"
#include "nautilus-thumbnails.h"
#include <eel/eel-glib-extensions.h>
#include <eel/eel-gtk-macros.h>
@@ -1645,8 +1643,7 @@ allow_metafile (NautilusMetafile *metafile)
* access inside gnome-vfs.
*/
uri = metafile->details->directory_uri;
- if (nautilus_is_search_uri (uri)
- || eel_istr_has_prefix (uri, "ghelp:")
+ if (eel_istr_has_prefix (uri, "ghelp:")
|| eel_istr_has_prefix (uri, "gnome-help:")
|| eel_istr_has_prefix (uri, "help:")
|| eel_istr_has_prefix (uri, "info:")
diff --git a/libnautilus-private/nautilus-mime-actions.c b/libnautilus-private/nautilus-mime-actions.c
index 830301535..dad4a4e18 100644
--- a/libnautilus-private/nautilus-mime-actions.c
+++ b/libnautilus-private/nautilus-mime-actions.c
@@ -28,7 +28,6 @@
#include "nautilus-file-attributes.h"
#include "nautilus-file.h"
#include "nautilus-metadata.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>
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-search-uri.c b/libnautilus-private/nautilus-search-uri.c
deleted file mode 100644
index 3e886c53a..000000000
--- a/libnautilus-private/nautilus-search-uri.c
+++ /dev/null
@@ -1,727 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/* Code to generate human-readable strings from search uris.
-
- 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; see the file COPYING. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Author: Mathieu Lacage <mathieu@eazel.com>
-*/
-
-#include <config.h>
-#include "nautilus-search-uri.h"
-
-/* Must be included before other libgnome headers. */
-
-#include "nautilus-lib-self-check-functions.h"
-#include <eel/eel-glib-extensions.h>
-#include <eel/eel-string.h>
-#include <libgnome/gnome-i18n.h>
-#include <libgnomevfs/gnome-vfs-utils.h>
-
-static const char *strip_uri_beginning (const char *location_uri);
-static GList * tokenize_uri (const char *string);
-static char * get_translated_criterion (GList *criterion);
-static char * get_nth_criterion_prefix (GList *criterion);
-static char * parse_uri (const char *search_uri);
-static void free_tokenized_uri (GList *list);
-
-/**
- * strip_uri_beginning:
- * @location_uri: search uri.
- *
- * strips the search:[file:///...] part of the input uri.
- *
- */
-static const char *
-strip_uri_beginning (const char *location_uri)
-{
- char **first_token;
- char *ptr;
- const char *ret_val;
-
- first_token = g_strsplit (location_uri, " ", 2);
- if (first_token[0] == NULL) {
- g_strfreev (first_token);
- return NULL;
- }
-
- /* parse the first token from the end to the beginning.
- to extract the search:[] part.
- */
- for (ptr = first_token[0]+strlen(first_token[0]);
- ptr != first_token[0] && *ptr != ']';
- ptr--) {}
-
- ret_val = location_uri + (ptr - first_token[0]) + 1;
-
- g_strfreev (first_token);
-
- return ret_val;
-}
-
-/**
- * free_tokenized_uri:
- * @list: tokenized uri to free
- *
- */
-static void
-free_tokenized_uri (GList *list)
-{
- GList *node;
-
- for (node = list; node != NULL; node = node->next) {
- eel_g_list_free_deep (node->data);
- }
- g_list_free (list);
-}
-
-
-/**
- * tokenize_uri
- * @string: string to parse
- *
- * This function tokenizes a subset of the grand medusa uri specification.
- * If it cannot, it returns NULL. CHECK FOR NULL upon return.
- *
- * Return value: a Singly linked list of singly linked lists.
- * each of the element of the root linked list is a complete criterion.
- * each criterin sinlgly linked list is made of the different tokens
- * of the criterion.
- */
-static GList *
-tokenize_uri (const char *string)
-{
- const char *temp_string;
- char **criteria;
- GList *criterion_list;
- int i, j;
-
- if (string == NULL) {
- return NULL;
- }
-
- string = strip_uri_beginning (string);
- if (string == NULL) {
- return NULL;
- }
-
- /* make sure we can handle this uri */
- if (strchr (string , '(') != NULL
- || strchr (string, ')') != NULL
- || strchr (string, '|') != NULL) {
- return NULL;
- }
-
- criterion_list = NULL;
-
- /* split the uri in different criteria */
- criteria = g_strsplit (string, " & ", 0);
- for (i = 0, temp_string = criteria[0];
- temp_string != NULL;
- i++, temp_string = criteria[i]) {
- char **tokens;
- char *token;
- GList *token_list;
-
- /* split a criterion in different tokens */
- token_list = NULL;
- tokens = g_strsplit (temp_string, " ", 0);
- for (j = 0, token = tokens[0]; token != NULL; j++, token = tokens[j]) {
- /* g_strstrip does not return a newly allocated string. */
- token_list = g_list_prepend (token_list, g_strdup (g_strstrip (token)));
- }
- criterion_list = g_list_prepend (criterion_list, g_list_reverse (token_list));
- g_strfreev (tokens);
- }
- g_strfreev (criteria);
-
- return g_list_reverse (criterion_list);
-}
-
-typedef struct _value_criterion_item value_criterion_item;
-typedef value_criterion_item *value_criterion_table;
-
-typedef struct _operand_criterion_item operand_criterion_item;
-typedef operand_criterion_item *operand_criterion_table;
-
-typedef struct _field_criterion_item field_criterion_item;
-typedef field_criterion_item *field_criterion_table;
-
-/* toplevel structure each entry points to a level 2 structure */
-struct _field_criterion_item {
- char *id;
- /* FIXME: This field is necessary so that
- the size of this structure is the same
- as the size of the other structures.
- see the comment in the definition of "value_criterion_item"
- to see what I mean. Yay, evil!
- someone should make this go away. */
- char *unused_field_for_hack_compatibility;
- operand_criterion_table items;
-};
-/* second level structure. if items is NULL, the entry is a leaf
- of our hierarchy. If it is not, it points to a level 3 leaf
-*/
-struct _operand_criterion_item {
- char *id;
- char *translation;
- value_criterion_table items;
-};
-/* third level structure. leaf */
-struct _value_criterion_item {
- char *id;
- char *translation;
- /* this field is there only to make the 3 structures similar enough
- so that you can safely cast between them it is a kind of evil hack
- but i like it. It is guaranteed to be always NULL. */
- value_criterion_table items;
-};
-
-
-/* -------------------------------------------------------
- - file name -
- -------------------------------------------------------
-*/
-
-static operand_criterion_item file_name2_table [] = {
- {"contains",
- /* Human readable description for a criterion in a search for
- files. Bracketed items are context, and are message
- strings elsewhere. You don't have to translate the whole
- string, and only the translation for "containing '%s' will
- be used. If you do translate the whole string, leave the
- translations of the rest of the text in brackets, so it
- will not be used.
- "%s" here is a pattern the file name
- matched, such as "nautilus" */
- N_("[Items ]containing \"%s\" in their names"),
- NULL},
- {"starts_with",
- /* "%s" here is a pattern the file name started with, such as
- "nautilus" */
- N_("[Items ]starting with \"%s\""),
- NULL},
- {"ends_with",
- /* "%s" here is a pattern the file name ended with, such as
- "mime" */
- N_("[Items ]ending with %s"),
- NULL},
- {"does_not_contain",
- /* "%s" here is a pattern the file name did not match, such
- as "nautilus" */
- N_("[Items ]not containing \"%s\" in their names"),
- NULL},
- {"regexp_matches",
- /* "%s" is a regular expression string, for example "[abc]" */
- N_("[Items ]matching the regular expression \"%s\""),
- NULL},
- {"matches",
- /* "%s" is a file glob, for example "*.txt" */
- N_("[Items ]matching the file pattern \"%s\""),
- NULL},
- {NULL, NULL, NULL}
-
-};
-
-
-/* -------------------------------------------------------
- - file type -
- -------------------------------------------------------
-*/
-static value_criterion_item file_type_options3_table [] = {
- {"file",
- N_("[Items that are ]regular files"),
- NULL},
- {"text_file",
- N_("[Items that are ]text files"),
- NULL},
- {"application",
- N_("[Items that are ]applications"),
- NULL},
- {"directory",
- N_("[Items that are ]folders"),
- NULL},
- {"music",
- N_("[Items that are ]music"),
- NULL},
- {NULL, NULL, NULL}
-};
-static operand_criterion_item file_type2_table [] = {
- {"is_not",
- /* "%s" here is a word describing a file type, for example
- "folder" */
- N_("[Items ]that are not %s"),
- file_type_options3_table},
- {"is",
- /* "%s" here is a word describing a file type, for example
- "folder" */
- N_("[Items ]that are %s"),
- file_type_options3_table},
- {NULL, NULL, NULL}
-};
-
-
-/* -------------------------------------------------------
- - owner -
- -------------------------------------------------------
-*/
-static operand_criterion_item owner2_table [] = {
- {"is_not",
- /* "%s" here is the name of user on a Linux machine, such as
- "root" */
- N_("[Items ]not owned by \"%s\""),
- NULL},
- {"is",
- /* "%s" here is the name of user on a Linux machine, such as
- "root" */
- N_("[Items ]owned by \"%s\""),
- NULL},
- {"has_uid",
- N_("[Items ]with owner UID \"%s\""),
- NULL},
- {"does_not_have_uid",
- N_("[Items ]with owner UID other than \"%s\""),
- NULL},
- {NULL, NULL, NULL}
-};
-
-/* -------------------------------------------------------
- - size -
- -------------------------------------------------------
-*/
-static operand_criterion_item size2_table [] = {
- {"larger_than",
- N_("[Items ]larger than %s bytes"),
- NULL},
- {"smaller_than",
- N_("[Items ]smaller than %s bytes"),
- NULL},
- {"is",
- N_("[Items ]of %s bytes"),
- NULL},
- {NULL, NULL, NULL}
-};
-
-/* -------------------------------------------------------
- - modified time -
- -------------------------------------------------------
-*/
-static operand_criterion_item mod_time2_table [] = {
- {"is today",
- N_("[Items ]modified today"),
- NULL},
- {"is yesterday",
- N_("[Items ]modified yesterday"),
- NULL},
- {"is",
- N_("[Items ]modified on %s"), NULL},
- {"is_not",
- N_("[Items ]not modified on %s"),
- NULL},
- {"is_before",
- N_("[Items ]modified before %s"),
- NULL},
- {"is_after",
- N_("[Items ]modified after %s"),
- NULL},
- {"is_within_a_week_of",
- N_("[Items ]modified within a week of %s"),
- NULL},
- {"is_within_a_month_of",
- N_("[Items ]modified within a month of %s"),
- NULL},
- {NULL, NULL, NULL}
-};
-
-/* -------------------------------------------------------
- - emblems -
- -------------------------------------------------------
-*/
-
-static operand_criterion_item emblem2_table [] = {
- { "include",
- /* "%s" here is the name of an Emblem */
- N_("[Items ]marked with \"%s\""),
- NULL},
- { "do_not_include",
- /* "%s" here is the name of an Emblem */
- N_("[Items ]not marked with \"%s\""),
- NULL},
- {NULL, NULL, NULL}
-};
-
-
-/* -------------------------------------------------------
- - contains -
- -------------------------------------------------------
-*/
-
-
-static operand_criterion_item contains2_table [] = {
- {"includes_all_of",
- /* "%s" here is a word or words present in the file, for
- example "nautilus" or "apple orange" */
- N_("[Items ]with all the words \"%s\""),
- NULL},
- {"includes_any_of",
- /* "%s" here is a word or words present in the file, for
- example "nautilus" or "apple orange" */
- N_("[Items ]containing one of the words \"%s\""),
- NULL},
- {"does_not_include_all_of",
- /* "%s" here is a word or words present in the file, for
- example "nautilus" or "apple orange" */
- N_("[Items ]without all the words \"%s\""),
- NULL},
- {"does_not_include_any_of",
- /* "%s" here is a word or words present in the file, for
- example "nautilus" or "apple orange" */
- N_("[Items ]without any of the words \"%s\""),
- NULL},
- {NULL, NULL, NULL},
-};
-
-
-
-/* -------------------------------------------------------
- - main table -
- ------------------------------------------------------- */
-static field_criterion_item main_table[] = {
- {"file_name",
- NULL,
- file_name2_table},
- {"file_type",
- NULL,
- file_type2_table},
- {"owner",
- NULL,
- owner2_table},
- {"size",
- NULL,
- size2_table},
- {"content",
- NULL,
- contains2_table},
- {"modified",
- NULL,
- mod_time2_table},
- {"keywords",
- NULL,
- emblem2_table},
- {NULL, NULL}
-};
-
-
-
-/**
- * get_item_number:
- * @current_table: the table to parse.
- * @item: the string to search into the table.
- *
- * Small helper function which allows whoich serches for @item
- * into the @current_table.
- * it returns -1 if it could not find it.
- * Yes, I know it is wrong to use the normal function return value
- * to pass error status. */
-static int
-get_item_number (field_criterion_item *current_table, char *item)
-{
- int i;
-
- i = 0;
- while (strcmp (current_table[i].id,
- item) != 0) {
- i++;
- if (current_table[i].id == NULL) {
- return -1;
- }
- }
-
- return i;
-}
-
-/**
- * get_translated_criterion:
- * @criterion: criterion uri to parse
- *
- * Returns a translated string for a given criterion uri.
- */
-static char *
-get_translated_criterion (GList *criterion)
-{
-
- int item_number, value_item_number;
- operand_criterion_item *operand_table;
- value_criterion_item *value_table;
- char *ret_val;
- char *context_stripped_operand, *context_stripped_value;
-
- /* make sure we got a valid criterion */
- if (g_list_length (criterion) != 3) {
- return NULL;
- }
-
-
- /* get through begening of criterion structure */
- item_number = get_item_number (main_table, (char *)criterion->data);
- if (item_number == -1) {
- return NULL;
- }
- operand_table = main_table[item_number].items;
- criterion = criterion->next;
-
- /* get through operanddle criterion structure */
- item_number = get_item_number ((field_criterion_item *)operand_table,
- (char *)criterion->data);
- if (item_number == -1) {
- return NULL;
- }
- value_table = operand_table[item_number].items;
- criterion = criterion->next;
-
- /* get through value criterion structure.
- The fun begins NOW. */
-
- if (value_table == NULL && operand_table[item_number].translation != NULL) {
- /* simplest case: if the pointer to the value criterion
- structure is NULL and we have a translation,
- we output a concat of the translation and the
- last part of the uri.
- */
- context_stripped_operand = eel_str_remove_bracketed_text (_(operand_table[item_number].translation));
- ret_val = g_strdup_printf (context_stripped_operand,
- (char *) criterion->data);
- g_free (context_stripped_operand);
- return ret_val;
- } else if (value_table != NULL) {
- /* get through level 3 structure */
-
- value_item_number = get_item_number ((field_criterion_item *) value_table,
- (char *) criterion->data);
- if (value_item_number == -1) {
- return NULL;
- }
-
- if (operand_table[item_number].translation == NULL) {
- /* if we had no translation in operand criterion table */
- ret_val = eel_str_remove_bracketed_text (_(value_table[value_item_number].translation));
- } else {
- /* if we have both some translation in level 2 and level 3 */
- context_stripped_operand = eel_str_remove_bracketed_text (_(operand_table[item_number].translation));
- context_stripped_value = eel_str_remove_bracketed_text (_(value_table[value_item_number].translation));
- ret_val = g_strdup_printf (context_stripped_operand, context_stripped_value);
- g_free (context_stripped_operand);
- g_free (context_stripped_value);
- }
- return ret_val;
- }
-
- return g_strdup ("");
-}
-
-
-/**
- * get_nth_criterion_prefix:
- * @criterion: The GList whose data field points to the criterion GList.
- *
- * calculates the "," or "and" prefix for any criterion.
- *
- * return value: the translated prefix.
- */
-static char *
-get_nth_criterion_prefix (GList *criterion)
-{
- /* if we are the last criterion, put it here. */
-
- /* Human readable description for a criterion in a search for
- files. Bracketed items are context, and are message
- strings elsewhere. Translate only the words "and" here. */
- if (criterion->next == NULL) {
-
- return eel_str_remove_bracketed_text (_("[Items larger than 400K] and [without all the words \"apple orange\"]"));
- }
- /* Human readable description for a criterion in a search for
- files. Bracketed items are context, and are message
- strings elsewhere. Translate only the words "and" here. */
- return eel_str_remove_bracketed_text (_("[Items larger than 400K], [owned by root and without all the words \"apple orange\"]"));
-}
-
-/**
- * parse_uri:
- * @search_uri: uri to translate.
- *
- * returns the translated version of the uri.
- */
-static char *
-parse_uri (const char *search_uri)
-{
- GList *criteria, *criterion;
- char *translated_criterion, *translated_prefix;
- char *ret_val, *temp;
-
- criteria = tokenize_uri (search_uri);
- if (criteria == NULL) {
- return NULL;
- }
-
- /* processes the first criterion and add the necessary "whose" prefix */
- translated_criterion = get_translated_criterion ((GList *)criteria->data);
- if (translated_criterion == NULL) {
- free_tokenized_uri (criteria);
- return NULL;
- }
- /* The beginning of the description of a search that has just been
- performed. The "%s" here is a description of a single criterion,
- which in english might be "that contain the word 'foo'" */
- ret_val = g_strdup_printf (_("Items %s"),
- translated_criterion);
- g_free (translated_criterion);
-
- /* processes the other criteria and add the necessary "and" prefixes */
- for (criterion = criteria->next; criterion != NULL; criterion = criterion->next) {
- translated_criterion = get_translated_criterion (criterion->data);
- if (translated_criterion == NULL) {
- g_free (ret_val);
- free_tokenized_uri (criteria);
- return NULL;
- }
- translated_prefix = get_nth_criterion_prefix (criterion);
- temp = g_strconcat (ret_val, translated_prefix,
- translated_criterion, NULL);
- g_free (ret_val);
- ret_val = temp;
- g_free (translated_criterion);
- g_free (translated_prefix);
- }
-
- free_tokenized_uri (criteria);
-
- return ret_val;
-}
-
-
-/**
- * nautilus_search_uri_to_human:
- * @search_uri: search uri to translate to human langage.
- *
- * The returned string is already localized.
- */
-char *
-nautilus_search_uri_to_human (const char *search_uri)
-{
- char *uri, *human;
-
- g_return_val_if_fail (search_uri != NULL, NULL);
-
- uri = gnome_vfs_unescape_string_for_display (search_uri);
- human = parse_uri (uri);
- if (human == NULL) {
- return uri;
- }
-
- g_free (uri);
-
- return human;
-}
-
-char *
-nautilus_get_target_uri_from_search_result_name (const char *search_result_name)
-{
- return gnome_vfs_unescape_string (search_result_name, NULL);
-}
-
-gboolean
-nautilus_is_search_uri (const char *uri)
-{
- g_return_val_if_fail (uri != NULL, FALSE);
-
- return eel_istr_has_prefix (uri, "search:")
- || eel_istr_has_prefix (uri, "gnome-search:");
-}
-
-#if !defined (NAUTILUS_OMIT_SELF_CHECK)
-
-void
-nautilus_self_check_search_uri (void)
-{
- /* search_uri_to_human */
-
- /* make sure that it does not accept non-supported uris.*/
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human (""), "");
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("s"), "s");
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human (" "), " ");
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human (" "), " ");
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human (" s"), " s");
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human (" s "), " s ");
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("xxx:yyy"), "xxx:yyy");
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]"), "search:[][]");
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]fi"), "search:[][]fi");
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name"),
- "search:[][]file_name");
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name cont"),
- "search:[][]file_name cont");
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name contains"),
- "search:[][]file_name contains");
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name c stuff"),
- "search:[][]file_name c stuff");
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]&"),
- "search:[][]&");
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]f & s"),
- "search:[][]f & s");
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name contains stuff & f"),
- "search:[][]file_name contains stuff & f");
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name contains stuff & file_type i"),
- "search:[][]file_name contains stuff & file_type i");
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name contains stuff & file_type is f"),
- "search:[][]file_name contains stuff & file_type is f");
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name contains stu)ff & file_type is file"),
- "search:[][]file_name contains stu)ff & file_type is file");
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name contains stu(ff & file_type is file"),
- "search:[][]file_name contains stu(ff & file_type is file");
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name contains stu|ff & file_type is file"),
- "search:[][]file_name contains stu|ff & file_type is file");
-
- /* make sure all the code paths work */
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name contains stuff"),
- _("Items containing \"stuff\" in their names"));
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_type is file"),
- _("Items that are regular files"));
- /* FIXME bugzilla.gnome.org 45088: This may be what the function calls "human", but it's bad grammar. */
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name contains stuff & file_type is file"),
- _("Items containing \"stuff\" in their names and that are regular files"));
- /* FIXME bugzilla.gnome.org 45088: This may be what the function calls "human", but it's bad grammar. */
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name contains stuff & file_type is file"
- " & size smaller_than 2000"),
- _("Items containing \"stuff\" in their names, that are regular files and "
- "smaller than 2000 bytes"));
- /* FIXME bugzilla.gnome.org 45088: This may be what the function calls "human", but it's bad grammar. */
- EEL_CHECK_STRING_RESULT (nautilus_search_uri_to_human ("search:[][]file_name contains medusa & file_type is directory"),
- _("Items containing \"medusa\" in their names and that are "
- "folders"));
-
- /* is_search_uri */
- EEL_CHECK_BOOLEAN_RESULT (nautilus_is_search_uri (""), FALSE);
- EEL_CHECK_BOOLEAN_RESULT (nautilus_is_search_uri ("search:"), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (nautilus_is_search_uri ("gnome-search:"), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (nautilus_is_search_uri ("xxx-search:"), FALSE);
- EEL_CHECK_BOOLEAN_RESULT (nautilus_is_search_uri ("search:xxx"), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (nautilus_is_search_uri ("gnome-search:xxx"), TRUE);
- EEL_CHECK_BOOLEAN_RESULT (nautilus_is_search_uri ("xxx-search:xxx"), FALSE);
-}
-
-#endif /* !NAUTILUS_OMIT_SELF_CHECK */
-
diff --git a/libnautilus-private/nautilus-search-uri.h b/libnautilus-private/nautilus-search-uri.h
deleted file mode 100644
index 6da105699..000000000
--- a/libnautilus-private/nautilus-search-uri.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/* Code to generate human-readable strings from search uris.
-
- 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; see the file COPYING. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Author: Mathieu Lacage <mathieu@eazel.com>
-*/
-
-#ifndef NAUTILUS_SEARCH_URI_H
-#define NAUTILUS_SEARCH_URI_H
-
-#include <glib/gtypes.h>
-
-/* These strings are used programatically; they must not be translated */
-#define NAUTILUS_SEARCH_URI_TEXT_NAME "file_name"
-#define NAUTILUS_SEARCH_URI_TEXT_CONTENT "content"
-#define NAUTILUS_SEARCH_URI_TEXT_TYPE "file_type"
-#define NAUTILUS_SEARCH_URI_TEXT_SIZE "size"
-#define NAUTILUS_SEARCH_URI_TEXT_EMBLEMS "keywords"
-#define NAUTILUS_SEARCH_URI_TEXT_DATE_MODIFIED "modified"
-#define NAUTILUS_SEARCH_URI_TEXT_OWNER "owner"
-
-gboolean nautilus_is_search_uri (const char *uri);
-char * nautilus_search_uri_to_human (const char *search_uri);
-char * nautilus_get_target_uri_from_search_result_name (const char *search_result_name);
-
-#endif /* NAUTILUS_SEARCH_URI_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-provider.c b/libnautilus-private/nautilus-sidebar-provider.c
new file mode 100644
index 000000000..f6442b04d
--- /dev/null
+++ b/libnautilus-private/nautilus-sidebar-provider.c
@@ -0,0 +1,72 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+
+ nautilus-sidebar-provider.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-provider.h"
+
+static void
+nautilus_sidebar_provider_base_init (gpointer g_class)
+{
+}
+
+GType
+nautilus_sidebar_provider_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type) {
+ static const GTypeInfo info = {
+ sizeof (NautilusSidebarProviderIface),
+ nautilus_sidebar_provider_base_init,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ 0,
+ 0,
+ NULL
+ };
+
+ type = g_type_register_static (G_TYPE_INTERFACE,
+ "NautilusSidebarProvider",
+ &info, 0);
+ g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
+ }
+
+ return type;
+}
+
+NautilusSidebar *
+nautilus_sidebar_provider_create (NautilusSidebarProvider *provider,
+ NautilusWindowInfo *window)
+{
+ return (* NAUTILUS_SIDEBAR_PROVIDER_GET_IFACE (provider)->create) (provider, window);
+}
+
+
+GList *
+nautilus_list_sidebar_providers (void)
+{
+ return NULL;
+}
diff --git a/libnautilus-private/nautilus-sidebar-provider.h b/libnautilus-private/nautilus-sidebar-provider.h
new file mode 100644
index 000000000..114988574
--- /dev/null
+++ b/libnautilus-private/nautilus-sidebar-provider.h
@@ -0,0 +1,56 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*-
+
+ nautilus-sidebar-provider.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_PROVIDER_H
+#define NAUTILUS_SIDEBAR_PROVIDER_H
+
+#include <libnautilus-private/nautilus-sidebar.h>
+#include <libnautilus-private/nautilus-window-info.h>
+
+G_BEGIN_DECLS
+
+#define NAUTILUS_TYPE_SIDEBAR_PROVIDER (nautilus_sidebar_provider_get_type ())
+#define NAUTILUS_SIDEBAR_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_SIDEBAR_PROVIDER, NautilusSidebarProvider))
+#define NAUTILUS_IS_SIDEBAR_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_SIDEBAR_PROVIDER))
+#define NAUTILUS_SIDEBAR_PROVIDER_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NAUTILUS_TYPE_SIDEBAR_PROVIDER, NautilusSidebarProviderIface))
+
+typedef struct _NautilusSidebarProvider NautilusSidebarProvider;
+typedef struct _NautilusSidebarProviderIface NautilusSidebarProviderIface;
+
+struct _NautilusSidebarProviderIface {
+ GTypeInterface g_iface;
+
+ NautilusSidebar * (*create) (NautilusSidebarProvider *provider,
+ NautilusWindowInfo *window);
+};
+
+/* Interface Functions */
+GType nautilus_sidebar_provider_get_type (void);
+NautilusSidebar * nautilus_sidebar_provider_create (NautilusSidebarProvider *provider,
+ NautilusWindowInfo *window);
+GList * nautilus_list_sidebar_providers (void);
+
+G_END_DECLS
+
+#endif /* NAUTILUS_SIDEBAR_PROVIDER_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-ui-utilities.c b/libnautilus-private/nautilus-ui-utilities.c
new file mode 100644
index 000000000..e806e945c
--- /dev/null
+++ b/libnautilus-private/nautilus-ui-utilities.c
@@ -0,0 +1,215 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
+/* nautilus-ui-utilities.c - helper functions for GtkUIManager stuff
+
+ Copyright (C) 2004 Red Hat, 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: Alexander Larsson <alexl@redhat.com>
+*/
+
+#include <config.h>
+#include "nautilus-ui-utilities.h"
+#include "nautilus-icon-factory.h"
+
+#include <eel/eel-debug.h>
+
+void
+nautilus_ui_unmerge_ui (GtkUIManager *ui_manager,
+ guint *merge_id,
+ GtkActionGroup **action_group)
+{
+ if (*merge_id != 0) {
+ gtk_ui_manager_remove_ui (ui_manager,
+ *merge_id);
+ *merge_id = 0;
+ }
+ if (*action_group != NULL) {
+ gtk_ui_manager_remove_action_group (ui_manager,
+ *action_group);
+ *action_group = NULL;
+ }
+}
+
+void
+nautilus_ui_prepare_merge_ui (GtkUIManager *ui_manager,
+ const char *name,
+ guint *merge_id,
+ GtkActionGroup **action_group)
+{
+ *merge_id = gtk_ui_manager_new_merge_id (ui_manager);
+ *action_group = gtk_action_group_new (name);
+ gtk_action_group_set_translation_domain (*action_group, GETTEXT_PACKAGE);
+ gtk_ui_manager_insert_action_group (ui_manager, *action_group, 0);
+ g_object_unref (*action_group); /* owned by ui manager */
+}
+
+
+char *
+nautilus_get_ui_directory (void)
+{
+ return g_strdup (DATADIR "/nautilus/ui");
+}
+
+char *
+nautilus_ui_file (const char *partial_path)
+{
+ char *path;
+
+ path = g_build_filename (DATADIR "/nautilus/ui", partial_path, NULL);
+ if (g_file_test (path, G_FILE_TEST_EXISTS)) {
+ return path;
+ }
+ g_free (path);
+ return NULL;
+}
+
+const char *
+nautilus_ui_string_get (const char *filename)
+{
+ static GHashTable *ui_cache = NULL;
+ char *ui;
+ char *path;
+
+ if (ui_cache == NULL) {
+ ui_cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+ eel_debug_call_at_shutdown_with_data ((GFreeFunc)g_hash_table_destroy, ui_cache);
+ }
+
+ ui = g_hash_table_lookup (ui_cache, filename);
+ if (ui == NULL) {
+ path = nautilus_ui_file (filename);
+ if (!g_file_get_contents (path, &ui, NULL, NULL)) {
+ g_warning ("Unable to load ui file %s\n", filename);
+ }
+ g_free (path);
+ g_hash_table_insert (ui_cache,
+ g_strdup (filename),
+ ui);
+ }
+
+ return ui;
+}
+
+static void
+extension_action_callback (GtkAction *action,
+ gpointer callback_data)
+{
+ nautilus_menu_item_activate (NAUTILUS_MENU_ITEM (callback_data));
+}
+
+GtkAction *
+nautilus_action_from_menu_item (NautilusMenuItem *item)
+{
+ char *name, *label, *tip, *icon;
+ gboolean sensitive, priority;
+ GtkAction *action;
+ GdkPixbuf *pixbuf;
+
+ g_object_get (G_OBJECT (item),
+ "name", &name, "label", &label,
+ "tip", &tip, "icon", &icon,
+ "sensitive", &sensitive,
+ "priority", &priority,
+ NULL);
+
+ action = gtk_action_new (name,
+ label,
+ tip,
+ icon);
+
+ /* TODO: This should really use themed icons, but that
+ doesn't work here yet */
+ if (icon != NULL) {
+ pixbuf = nautilus_icon_factory_get_pixbuf_from_name
+ (icon,
+ NULL,
+ NAUTILUS_ICON_SIZE_FOR_MENUS,
+ NULL);
+ if (pixbuf != NULL) {
+ g_object_set_data_full (G_OBJECT (action), "menu-icon",
+ pixbuf,
+ g_object_unref);
+ }
+ }
+
+ gtk_action_set_sensitive (action, sensitive);
+ g_object_set (action, "is-important", priority, NULL);
+
+ g_signal_connect_data (action, "activate",
+ G_CALLBACK (extension_action_callback),
+ g_object_ref (item),
+ (GClosureNotify)g_object_unref, 0);
+
+ g_free (name);
+ g_free (label);
+ g_free (tip);
+ g_free (icon);
+
+ return action;
+}
+
+GtkAction *
+nautilus_toolbar_action_from_menu_item (NautilusMenuItem *item)
+{
+ char *name, *label, *tip, *icon;
+ gboolean sensitive, priority;
+ GtkAction *action;
+ GdkPixbuf *pixbuf;
+
+ g_object_get (G_OBJECT (item),
+ "name", &name, "label", &label,
+ "tip", &tip, "icon", &icon,
+ "sensitive", &sensitive,
+ "priority", &priority,
+ NULL);
+
+ action = gtk_action_new (name,
+ label,
+ tip,
+ icon);
+
+ /* TODO: This should really use themed icons, but that
+ doesn't work here yet */
+ if (icon != NULL) {
+ pixbuf = nautilus_icon_factory_get_pixbuf_from_name
+ (icon,
+ NULL,
+ 24,
+ NULL);
+ if (pixbuf != NULL) {
+ g_object_set_data_full (G_OBJECT (action), "toolbar-icon",
+ pixbuf,
+ g_object_unref);
+ }
+ }
+
+ gtk_action_set_sensitive (action, sensitive);
+ g_object_set (action, "is-important", priority, NULL);
+
+ g_signal_connect_data (action, "activate",
+ G_CALLBACK (extension_action_callback),
+ g_object_ref (item),
+ (GClosureNotify)g_object_unref, 0);
+
+ g_free (name);
+ g_free (label);
+ g_free (tip);
+ g_free (icon);
+
+ return action;
+}
diff --git a/libnautilus-private/nautilus-ui-utilities.h b/libnautilus-private/nautilus-ui-utilities.h
new file mode 100644
index 000000000..9b7c6b066
--- /dev/null
+++ b/libnautilus-private/nautilus-ui-utilities.h
@@ -0,0 +1,43 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+
+/* nautilus-ui-utilities.h - helper functions for GtkUIManager stuff
+
+ Copyright (C) 2004 Red Hat, 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: Alexander Larsson <alexl@redhat.com>
+*/
+#ifndef NAUTILUS_UI_UTILITIES_H
+#define NAUTILUS_UI_UTILITIES_H
+
+#include <gtk/gtkuimanager.h>
+#include <libnautilus-extension/nautilus-menu-item.h>
+
+char * nautilus_get_ui_directory (void);
+char * nautilus_ui_file (const char *partial_path);
+void nautilus_ui_unmerge_ui (GtkUIManager *ui_manager,
+ guint *merge_id,
+ GtkActionGroup **action_group);
+void nautilus_ui_prepare_merge_ui (GtkUIManager *ui_manager,
+ const char *name,
+ guint *merge_id,
+ GtkActionGroup **action_group);
+GtkAction * nautilus_action_from_menu_item (NautilusMenuItem *item);
+GtkAction * nautilus_toolbar_action_from_menu_item (NautilusMenuItem *item);
+const char *nautilus_ui_string_get (const char *filename);
+
+#endif /* NAUTILUS_UI_UTILITIES_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..bad36efc8
--- /dev/null
+++ b/libnautilus-private/nautilus-view.c
@@ -0,0 +1,251 @@
+/* -*- 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_supports_zooming (NautilusView *view)
+{
+ g_return_val_if_fail (NAUTILUS_IS_VIEW (view), FALSE);
+
+ return (* NAUTILUS_VIEW_GET_IFACE (view)->supports_zooming) (view);
+}
+
+void
+nautilus_view_bump_zoom_level (NautilusView *view,
+ int zoom_increment)
+{
+ g_return_if_fail (NAUTILUS_IS_VIEW (view));
+
+ (* NAUTILUS_VIEW_GET_IFACE (view)->bump_zoom_level) (view,
+ zoom_increment);
+}
+
+void
+nautilus_view_zoom_to_level (NautilusView *view,
+ NautilusZoomLevel level)
+{
+ g_return_if_fail (NAUTILUS_IS_VIEW (view));
+
+ (* NAUTILUS_VIEW_GET_IFACE (view)->zoom_to_level) (view,
+ level);
+}
+
+void
+nautilus_view_restore_default_zoom_level (NautilusView *view)
+{
+ g_return_if_fail (NAUTILUS_IS_VIEW (view));
+
+ (* NAUTILUS_VIEW_GET_IFACE (view)->restore_default_zoom_level) (view);
+}
+
+gboolean
+nautilus_view_can_zoom_in (NautilusView *view)
+{
+ g_return_val_if_fail (NAUTILUS_IS_VIEW (view), FALSE);
+
+ return (* NAUTILUS_VIEW_GET_IFACE (view)->can_zoom_in) (view);
+}
+
+gboolean
+nautilus_view_can_zoom_out (NautilusView *view)
+{
+ g_return_val_if_fail (NAUTILUS_IS_VIEW (view), FALSE);
+
+ return (* NAUTILUS_VIEW_GET_IFACE (view)->can_zoom_out) (view);
+}
+
+NautilusZoomLevel
+nautilus_view_get_zoom_level (NautilusView *view)
+{
+ g_return_val_if_fail (NAUTILUS_IS_VIEW (view), NAUTILUS_ZOOM_LEVEL_STANDARD);
+
+ return (* NAUTILUS_VIEW_GET_IFACE (view)->get_zoom_level) (view);
+}
diff --git a/libnautilus-private/nautilus-view.h b/libnautilus-private/nautilus-view.h
new file mode 100644
index 000000000..b4b90fe39
--- /dev/null
+++ b/libnautilus-private/nautilus-view.h
@@ -0,0 +1,147 @@
+/* -*- 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>
+
+/* For NautilusZoomLevel */
+#include <libnautilus-private/nautilus-icon-factory.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);
+
+ /* BONOBOTODO: remove this? */
+ 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);
+
+
+ /* Zoom support */
+ gboolean (* supports_zooming) (NautilusView *view);
+ void (* bump_zoom_level) (NautilusView *view,
+ int zoom_increment);
+ void (* zoom_to_level) (NautilusView *view,
+ NautilusZoomLevel level);
+ NautilusZoomLevel (* get_zoom_level) (NautilusView *view);
+ void (* restore_default_zoom_level) (NautilusView *view);
+ gboolean (* can_zoom_in) (NautilusView *view);
+ gboolean (* can_zoom_out) (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_supports_zooming (NautilusView *view);
+void nautilus_view_bump_zoom_level (NautilusView *view,
+ int zoom_increment);
+void nautilus_view_zoom_to_level (NautilusView *view,
+ NautilusZoomLevel level);
+void nautilus_view_restore_default_zoom_level (NautilusView *view);
+gboolean nautilus_view_can_zoom_in (NautilusView *view);
+gboolean nautilus_view_can_zoom_out (NautilusView *view);
+NautilusZoomLevel nautilus_view_get_zoom_level (NautilusView *view);
+
+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..3ea5b89ac
--- /dev/null
+++ b/libnautilus-private/nautilus-window-info.c
@@ -0,0 +1,261 @@
+/* -*- 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,
+ HIDDEN_FILES_MODE_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);
+
+ nautilus_window_info_signals[HIDDEN_FILES_MODE_CHANGED] =
+ g_signal_new ("hidden_files_mode_changed",
+ NAUTILUS_TYPE_WINDOW_INFO,
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (NautilusWindowInfoIface, hidden_files_mode_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
+ 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);
+}
+
+char *
+nautilus_window_info_get_title (NautilusWindowInfo *window)
+{
+ g_return_val_if_fail (NAUTILUS_IS_WINDOW_INFO (window), NULL);
+
+ return (* NAUTILUS_WINDOW_INFO_GET_IFACE (window)->get_title) (window);
+}
+
+GList *
+nautilus_window_info_get_history (NautilusWindowInfo *window)
+{
+ g_return_val_if_fail (NAUTILUS_IS_WINDOW_INFO (window), NULL);
+
+ return (* NAUTILUS_WINDOW_INFO_GET_IFACE (window)->get_history) (window);
+}
+
+char *
+nautilus_window_info_get_current_location (NautilusWindowInfo *window)
+{
+ g_return_val_if_fail (NAUTILUS_IS_WINDOW_INFO (window), NULL);
+
+ return (* NAUTILUS_WINDOW_INFO_GET_IFACE (window)->get_current_location) (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);
+}
+
+GtkUIManager *
+nautilus_window_info_get_ui_manager (NautilusWindowInfo *window)
+{
+ g_return_val_if_fail (NAUTILUS_IS_WINDOW_INFO (window), NULL);
+
+ return (* NAUTILUS_WINDOW_INFO_GET_IFACE (window)->get_ui_manager) (window);
+}
+
diff --git a/libnautilus-private/nautilus-window-info.h b/libnautilus-private/nautilus-window-info.h
new file mode 100644
index 000000000..ba6bfe3c5
--- /dev/null
+++ b/libnautilus-private/nautilus-window-info.h
@@ -0,0 +1,164 @@
+/* -*- 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 <gtk/gtkuimanager.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,
+ const 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);
+ void (* hidden_files_mode_changed)(NautilusWindowInfo *window);
+
+ /* 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);
+
+ char * (* get_current_location) (NautilusWindowInfo *window);
+ void (* set_status) (NautilusWindowInfo *window,
+ const char *status);
+ char * (* get_title) (NautilusWindowInfo *window);
+ GList *(* get_history) (NautilusWindowInfo *window);
+ NautilusWindowType
+ (* get_window_type) (NautilusWindowInfo *window);
+ NautilusWindowShowHiddenFilesMode
+ (* get_hidden_files_mode) (NautilusWindowInfo *window);
+ void (* set_hidden_files_mode) (NautilusWindowInfo *window,
+ NautilusWindowShowHiddenFilesMode mode);
+
+ void (* open_location) (NautilusWindowInfo *window,
+ const char *location,
+ NautilusWindowOpenMode mode,
+ NautilusWindowOpenFlags flags,
+ GList *selection);
+ void (* close_window) (NautilusWindowInfo *window);
+ GtkUIManager * (* get_ui_manager) (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);
+char * nautilus_window_info_get_title (NautilusWindowInfo *window);
+GList * nautilus_window_info_get_history (NautilusWindowInfo *window);
+char * nautilus_window_info_get_current_location (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);
+GtkUIManager * nautilus_window_info_get_ui_manager (NautilusWindowInfo *window);
+
+
+G_END_DECLS
+
+#endif /* NAUTILUS_WINDOW_INFO_H */