diff options
author | Alexander Larsson <alexl@redhat.com> | 2004-11-22 15:24:38 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2004-11-22 15:24:38 +0000 |
commit | 67e2a42fea65f2685580b119b98a058c8e81ac4e (patch) | |
tree | 19bc7c578c9f1a47f299d012ac4775010e06661e /libnautilus | |
parent | 8dc115c33951754d75b57c67e4d918900a795468 (diff) | |
download | nautilus-67e2a42fea65f2685580b119b98a058c8e81ac4e.tar.gz |
Merge bonobo-slay-branch
2004-11-22 Alexander Larsson <alexl@redhat.com>
* Merge bonobo-slay-branch
Diffstat (limited to 'libnautilus')
23 files changed, 0 insertions, 4210 deletions
diff --git a/libnautilus/Makefile.am b/libnautilus/Makefile.am deleted file mode 100644 index ac57623d9..000000000 --- a/libnautilus/Makefile.am +++ /dev/null @@ -1,105 +0,0 @@ -include $(top_srcdir)/Makefile.shared - -lib_LTLIBRARIES=libnautilus.la - -INCLUDES=\ - -I$(top_srcdir) \ - -I$(top_builddir) \ - $(LIBNAUTILUS_CFLAGS) \ - $(DISABLE_DEPRECATED_CFLAGS) \ - -DDATADIR=\""$(datadir)"\" \ - $(NULL) - -libnautilus_la_LDFLAGS=\ - -version-info 2:0:0 \ - $(LIBNAUTILUS_LIBS) \ - -no-undefined \ - $(NULL) - -nautilus_view_component_idl_sources = \ - nautilus-view-component-stubs.c \ - nautilus-view-component-skels.c \ - nautilus-view-component.h \ - nautilus-view-component-common.c - -nautilus_distributed_undo_idl_sources = \ - nautilus-distributed-undo-stubs.c \ - nautilus-distributed-undo-skels.c \ - nautilus-distributed-undo.h \ - nautilus-distributed-undo-common.c - -libnautilusincludedir=$(includedir)/libnautilus - -libnautilusinclude_HEADERS= \ - libnautilus.h \ - nautilus-bonobo-ui.h \ - nautilus-clipboard.h \ - nautilus-distributed-undo.h \ - nautilus-idle-queue.h \ - nautilus-scroll-positionable.h \ - nautilus-view-component.h \ - nautilus-view.h \ - nautilus-view-standard-main.h \ - nautilus-undo.h \ - nautilus-undo-private.h \ - $(NULL) - -libnautilus_la_SOURCES= \ - $(nautilus_view_component_idl_sources) \ - $(nautilus_distributed_undo_idl_sources) \ - nautilus-clipboard.c \ - nautilus-idle-queue.c \ - nautilus-scroll-positionable.c \ - nautilus-undo-transaction.c \ - nautilus-undo-transaction.h \ - nautilus-undo.c \ - nautilus-view.c \ - nautilus-view-standard-main.c \ - $(NULL) - -$(nautilus_view_component_idl_sources): nautilus_view_component_idl_stamp -nautilus_view_component_idl_stamp: nautilus-view-component.idl $(ORBIT_IDL) - $(ORBIT_IDL) $(LIBNAUTILUS_IDL_INCLUDES) --define=__nautilus_view_component_COMPILATION $< - touch $@ - -$(nautilus_distributed_undo_idl_sources): nautilus_distributed_undo_idl_stamp -nautilus_distributed_undo_idl_stamp: nautilus-distributed-undo.idl $(ORBIT_IDL) - $(ORBIT_IDL) $(LIBNAUTILUS_IDL_INCLUDES) $< - touch $@ - -$(libnautilus_la_OBJECTS): nautilus_view_component_idl_stamp nautilus_distributed_undo_idl_stamp - -uidir = $(datadir)/gnome-2.0/ui -ui_DATA = \ - nautilus-clipboard-ui.xml \ - $(NULL) - -idldir = $(datadir)/idl -idl_DATA = \ - nautilus-view-component.idl \ - nautilus-distributed-undo.idl \ - $(NULL) - -pkgconfigdir=$(libdir)/pkgconfig -pkgconfig_DATA=libnautilus.pc - -EXTRA_DIST = \ - $(ui_DATA) \ - $(idl_DATA) \ - libnautilus.pc.in \ - $(NULL) - -BUILT_SOURCES = \ - $(nautilus_view_component_idl_sources) \ - $(nautilus_distributed_undo_idl_sources) \ - $(NULL) - -CLEANFILES = \ - $(nautilus_view_component_idl_sources) \ - nautilus_view_component_idl_stamp \ - $(nautilus_distributed_undo_idl_sources) \ - nautilus_distributed_undo_idl_stamp \ - $(NULL) - -dist-hook: - cd $(distdir); rm -f $(CLEANFILES) diff --git a/libnautilus/README b/libnautilus/README deleted file mode 100644 index 992cf548e..000000000 --- a/libnautilus/README +++ /dev/null @@ -1,5 +0,0 @@ -README for nautilus/libnautilus - -This library, libnautilus, is ALL you need to link with to create -a nautilus component. - diff --git a/libnautilus/libnautilus.h b/libnautilus/libnautilus.h deleted file mode 100644 index ed3acf202..000000000 --- a/libnautilus/libnautilus.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 2 -*- */ - -/* - * libnautilus: A library for nautilus view components. - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 2000 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Elliot Lee <sopwith@redhat.com> - * - */ - -/* libnautilus.h: Main library header file */ - -#ifndef LIBNAUTILUS_H -#define LIBNAUTILUS_H - -#include <libnautilus/nautilus-view-component.h> -#include <libnautilus/nautilus-view.h> - -#endif /* LIBNAUTILUS_H */ diff --git a/libnautilus/libnautilus.pc.in b/libnautilus/libnautilus.pc.in deleted file mode 100644 index 3bfd6c1a1..000000000 --- a/libnautilus/libnautilus.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libnautilus -Description: A library to create Nautilus components -Version: @VERSION@ -Requires: eel-2.0 bonobo-activation-2.0 libbonobo-2.0 libbonoboui-2.0 -Libs: -L${libdir} -lnautilus -Cflags: -I${includedir} diff --git a/libnautilus/nautilus-bonobo-ui.h b/libnautilus/nautilus-bonobo-ui.h deleted file mode 100644 index 41fa3747d..000000000 --- a/libnautilus/nautilus-bonobo-ui.h +++ /dev/null @@ -1,130 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */ - -/* - * libnautilus: A library for nautilus view implementations. - * - * Copyright (C) 2000 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - * - */ - -/* nautilus-bonobo-ui.h: bonobo UI paths usable by Nautilus components - * for merging menus and toolbars. - */ - -#ifndef NAUTILUS_BONOBO_UI_H -#define NAUTILUS_BONOBO_UI_H - -/** - * Components can use these menu paths with BonoboUIContainer calls to - * place entire new menus. - */ - -#define NAUTILUS_MENU_PATH_FILE_MENU "/menu/File" -#define NAUTILUS_MENU_PATH_EDIT_MENU "/menu/Edit" -#define NAUTILUS_MENU_PATH_VIEW_MENU "/menu/View" -#define NAUTILUS_MENU_PATH_GO_MENU "/menu/Go" -#define NAUTILUS_MENU_PATH_BOOKMARKS_MENU "/menu/Bookmarks" -#define NAUTILUS_MENU_PATH_PROFILER "/menu/Profiler" -#define NAUTILUS_MENU_PATH_HELP_MENU "/menu/Help" - -/** - * Components can use these menu item paths with BonoboUIContainer calls to - * merge over certain existing items. Only items that we expect to be - * merged over are listed here, to avoid making public details that might - * change later. - */ - -#define NAUTILUS_MENU_PATH_CUT_ITEM "/menu/Edit/Cut" -#define NAUTILUS_MENU_PATH_COPY_ITEM "/menu/Edit/Copy" -#define NAUTILUS_MENU_PATH_PASTE_ITEM "/menu/Edit/Paste" -#define NAUTILUS_MENU_PATH_CLEAR_ITEM "/menu/Edit/Clear" -#define NAUTILUS_MENU_PATH_SELECT_ALL_ITEM "/menu/Edit/Select All" - -#define NAUTILUS_COMMAND_CUT "/commands/Cut" -#define NAUTILUS_COMMAND_COPY "/commands/Copy" -#define NAUTILUS_COMMAND_PASTE "/commands/Paste" -#define NAUTILUS_COMMAND_CLEAR "/commands/Clear" -#define NAUTILUS_COMMAND_SELECT_ALL "/commands/Select All" - -/** - * Components can use these placeholder paths with BonoboUIContainer calls to - * insert new items in well-defined positions. - */ - -/* Use the "new items" placeholder to insert menu items like "New xxx" */ -#define NAUTILUS_MENU_PATH_NEW_ITEMS_PLACEHOLDER "/menu/File/New Items Placeholder" - -/** - * Use the "open" placeholder to insert menu items dealing with opening the - * selected item, like "Open", "Open in New Window", etc. - */ -#define NAUTILUS_MENU_PATH_OPEN_PLACEHOLDER "/menu/File/Open Placeholder" - -/** - * Use the "file items" placeholder to insert other File menu items dealing with - * individual files, such as "Show Properties" and "Rename" - */ -#define NAUTILUS_MENU_PATH_FILE_ITEMS_PLACEHOLDER "/menu/File/File Items Placeholder" - -/** - * Use the "global file items" placeholder to insert other File menu items - * dealing with nautilus as a whole, such as "Empty Trash". - */ -#define NAUTILUS_MENU_PATH_GLOBAL_FILE_ITEMS_PLACEHOLDER "/menu/File/Global File Items Placeholder" - -/** - * Use the "global edit items" placeholder to insert other Edit menu items - * dealing with nautilus as a whole, such as "Icon Captions...". - */ -#define NAUTILUS_MENU_PATH_GLOBAL_EDIT_ITEMS_PLACEHOLDER "/menu/Edit/Global Edit Items Placeholder" - -/** - * Use the "edit items" placeholder to insert other Edit menu items dealing with - * individual files, such as "Remove Custom Image" - */ -#define NAUTILUS_MENU_PATH_EDIT_ITEMS_PLACEHOLDER "/menu/Edit/Edit Items Placeholder" - -/** - * Use the "show/hide" placeholder to insert other View menu items that - * control the visibility of some piece of the UI, such as "Show/Hide Status Bar". - */ -#define NAUTILUS_MENU_PATH_SHOW_HIDE_PLACEHOLDER "/menu/View/Show Hide Placeholder" - -/** - * Use the "view items" placeholder to insert other View menu items that - * are specific to a component, such as the Icon View's layout options. - */ -#define NAUTILUS_MENU_PATH_VIEW_ITEMS_PLACEHOLDER "/menu/View/View Items Placeholder" - -/* Use the "extra help items" placeholder to add help-related items */ -#define NAUTILUS_MENU_PATH_EXTRA_HELP_ITEMS_PLACEHOLDER "/menu/Help/Extra Help Items" - -/* This holds the zooming-related items in the context menu */ -#define NAUTILUS_POPUP_PATH_ZOOM_ITEMS_PLACEHOLDER "/popups/background/Zoom Items" - -/* Components can use these paths with BonoboUIHandler calls to - * locate toolbars and toolbar items for the purpose of merging. - * Note: Not all Nautilus toolbars or toolbar items are necessarily published - * here; these are the ones whose existence components can count on. - */ - -/* Main toolbar */ -#define NAUTILUS_TOOLBAR_PATH_MAIN_TOOLBAR "/Main" - -#endif /* NAUTILUS_BONOBO_UI_H */ diff --git a/libnautilus/nautilus-clipboard-ui.xml b/libnautilus/nautilus-clipboard-ui.xml deleted file mode 100644 index a6f4ebfed..000000000 --- a/libnautilus/nautilus-clipboard-ui.xml +++ /dev/null @@ -1,49 +0,0 @@ -<Root> - -<commands> - <cmd name="Cut" - _label="Cut Text" - accel="*Control*x" - _tip="Cut the selected text to the clipboard"/> - <cmd name="Copy" - _label="_Copy Text" - accel="*Control*c" - _tip="Copy the selected text to the clipboard"/> - <cmd name="Paste" - _label="_Paste Text" - _tip="Paste the text stored on the clipboard" - accel="*Control*v"/> - <cmd name="Clear" - _tip="Remove the selected text without putting it on the clipboard" - _label="C_lear Text"/> - <cmd name="Select All" - _label="Select _All" - _tip="Select all the text in a text field" - accel="*Control*a"/> -</commands> - -<menu> - <submenu name="Edit"> - <menuitem name="Cut" - _label="Cut _Text" - pixtype="stock" pixname="gtk-cut" - verb="Cut"/> - <menuitem name="Copy" - _label="_Copy Text" - pixtype="stock" pixname="gtk-copy" - verb="Copy"/> - <menuitem name="Paste" - _label="_Paste Text" - pixtype="stock" pixname="gtk-paste" - verb="Paste"/> - <menuitem name="Clear" - _label="C_lear Text" - pixtype="stock" pixname="gtk-clear" - verb="Clear"/> - <menuitem name="Select All" - _label="Select _All" - verb="Select All"/> - </submenu> -</menu> - -</Root> diff --git a/libnautilus/nautilus-clipboard.c b/libnautilus/nautilus-clipboard.c deleted file mode 100644 index 9e595e103..000000000 --- a/libnautilus/nautilus-clipboard.c +++ /dev/null @@ -1,512 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* nautilus-clipboard.c - * - * Nautilus Clipboard support. For now, routines to support component cut - * and paste. - * - * Copyright (C) 1999, 2000 Free Software Foundaton - * Copyright (C) 2000, 2001 Eazel, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: Rebecca Schulman <rebecka@eazel.com>, - * Darin Adler <darin@bentspoon.com> - */ - -#include <config.h> -#include "nautilus-clipboard.h" - -#include "nautilus-bonobo-ui.h" -#include <bonobo/bonobo-ui-util.h> -#include <gtk/gtkinvisible.h> -#include <gtk/gtkmain.h> -#include <gtk/gtksignal.h> -#include <gtk/gtktext.h> -#include <string.h> - -typedef void (* EditableFunction) (GtkEditable *editable); - -static void disconnect_set_up_in_control_handlers (GtkObject *object, - gpointer callback_data); -static void selection_changed_callback (GtkWidget *widget, - gpointer callback_data); - -static void -cut_callback (BonoboUIComponent *ui, - gpointer callback_data, - const char *command_name) -{ - g_assert (BONOBO_IS_UI_COMPONENT (ui)); - g_assert (strcmp (command_name, "Cut") == 0); - - gtk_editable_cut_clipboard (GTK_EDITABLE (callback_data)); -} - -static void -copy_callback (BonoboUIComponent *ui, - gpointer callback_data, - const char *command_name) -{ - g_assert (BONOBO_IS_UI_COMPONENT (ui)); - g_assert (strcmp (command_name, "Copy") == 0); - - gtk_editable_copy_clipboard (GTK_EDITABLE (callback_data)); -} - -static void -paste_callback (BonoboUIComponent *ui, - gpointer callback_data, - const char *command_name) -{ - g_assert (BONOBO_IS_UI_COMPONENT (ui)); - g_assert (strcmp (command_name, "Paste") == 0); - - gtk_editable_paste_clipboard (GTK_EDITABLE (callback_data)); -} - -static void -clear_callback (BonoboUIComponent *ui, - gpointer callback_data, - const char *command_name) -{ - g_assert (BONOBO_IS_UI_COMPONENT (ui)); - g_assert (strcmp (command_name, "Clear") == 0); - - gtk_editable_delete_selection (GTK_EDITABLE (callback_data)); -} - -static void -select_all (GtkEditable *editable) -{ - gtk_editable_set_position (editable, -1); - gtk_editable_select_region (editable, 0, -1); -} - -static void -idle_source_destroy_callback (gpointer data, - GObject *where_the_object_was) -{ - g_source_destroy (data); -} - -static gboolean -select_all_idle_callback (gpointer callback_data) -{ - GtkEditable *editable; - GSource *source; - - editable = GTK_EDITABLE (callback_data); - - source = g_object_get_data (G_OBJECT (editable), - "clipboard-select-all-source"); - - g_object_weak_unref (G_OBJECT (editable), - idle_source_destroy_callback, - source); - - g_object_set_data (G_OBJECT (editable), - "clipboard-select-all-source", - NULL); - - select_all (editable); - - return FALSE; -} - -static void -select_all_callback (BonoboUIComponent *ui, - gpointer callback_data, - const char *command_name) -{ - GSource *source; - GtkEditable *editable; - - g_assert (BONOBO_IS_UI_COMPONENT (ui)); - g_assert (strcmp (command_name, "Select All") == 0); - - editable = GTK_EDITABLE (callback_data); - - if (g_object_get_data (G_OBJECT (editable), - "clipboard-select-all-source")) { - return; - } - - source = g_idle_source_new (); - g_source_set_callback (source, select_all_idle_callback, editable, NULL); - g_object_weak_ref (G_OBJECT (editable), - idle_source_destroy_callback, - source); - g_source_attach (source, NULL); - g_source_unref (source); - - g_object_set_data (G_OBJECT (editable), - "clipboard-select-all-source", - source); -} - -static void -set_menu_item_sensitive (BonoboUIComponent *component, - const char *path, - gboolean sensitive) -{ - bonobo_ui_component_set_prop (component, path, - "sensitive", sensitive ? "1" : "0", NULL); - -} - -#if 0 -static void -set_paste_sensitive_if_clipboard_contains_data (BonoboUIComponent *component) -{ - gboolean clipboard_contains_data; - - /* FIXME: This check is wrong, because gdk_selection_owner_get - * will only return non-null if the clipboard owner is in - * process, which may not be the case, and we may still be - * able to paste data. - */ - /* FIXME: PRIMARY is wrong here. We are interested in - * CLIPBOARD, not PRIMARY. - */ - /* FIXME: This doesn't tell us what kind of data is on the - * clipboard, and we only want to be sensitive if it's text. - */ - clipboard_contains_data = - (gdk_selection_owner_get (GDK_SELECTION_PRIMARY) != NULL); - - set_menu_item_sensitive (component, - NAUTILUS_COMMAND_PASTE, - clipboard_contains_data); -} -#endif - -static void -set_clipboard_menu_items_sensitive (BonoboUIComponent *component) -{ - set_menu_item_sensitive (component, - NAUTILUS_COMMAND_CUT, - TRUE); - set_menu_item_sensitive (component, - NAUTILUS_COMMAND_COPY, - TRUE); - set_menu_item_sensitive (component, - NAUTILUS_COMMAND_CLEAR, - TRUE); -} - -static void -set_clipboard_menu_items_insensitive (BonoboUIComponent *component) -{ - set_menu_item_sensitive (component, - NAUTILUS_COMMAND_CUT, - FALSE); - set_menu_item_sensitive (component, - NAUTILUS_COMMAND_COPY, - FALSE); - set_menu_item_sensitive (component, - NAUTILUS_COMMAND_CLEAR, - FALSE); -} - -typedef struct { - BonoboUIComponent *component; - Bonobo_UIContainer container; - gboolean editable_shares_selection_changes; -} TargetCallbackData; - -static gboolean -clipboard_items_are_merged_in (GtkWidget *widget) -{ - return GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), - "Nautilus:clipboard_menu_items_merged")); -} - -static void -set_clipboard_items_are_merged_in (GObject *widget_as_object, - gboolean merged_in) -{ - g_object_set_data (widget_as_object, - "Nautilus:clipboard_menu_items_merged", - GINT_TO_POINTER (merged_in)); -} - -static void -merge_in_clipboard_menu_items (GObject *widget_as_object, - TargetCallbackData *target_data) -{ - BonoboUIComponent *ui; - Bonobo_UIContainer container; - gboolean add_selection_callback; - - g_assert (target_data != NULL); - ui = target_data->component; - container = target_data->container; - add_selection_callback = target_data->editable_shares_selection_changes; - - if (ui == NULL || container == CORBA_OBJECT_NIL) { - return; - } - - bonobo_ui_component_set_container (ui, container, NULL); - bonobo_ui_component_freeze (ui, NULL); - bonobo_ui_util_set_ui (ui, - DATADIR, - "nautilus-clipboard-ui.xml", - "nautilus", NULL); - - if (add_selection_callback) { - g_signal_connect_after (widget_as_object, "selection_changed", - G_CALLBACK (selection_changed_callback), target_data); - selection_changed_callback (GTK_WIDGET (widget_as_object), - target_data); - - } else { - /* If we don't use sensitivity, everything should be on */ - set_clipboard_menu_items_sensitive (ui); - } - set_clipboard_items_are_merged_in (widget_as_object, TRUE); - bonobo_ui_component_thaw (ui, NULL); -} - -static void -merge_out_clipboard_menu_items (GObject *widget_as_object, - TargetCallbackData *target_data) - -{ - BonoboUIComponent *ui; - gboolean selection_callback_was_added; - - g_assert (target_data != NULL); - ui = BONOBO_UI_COMPONENT (target_data->component); - selection_callback_was_added = target_data->editable_shares_selection_changes; - - if (ui == NULL) { - return; - } - - bonobo_ui_component_unset_container (ui, NULL); - - if (selection_callback_was_added) { - g_signal_handlers_disconnect_matched (widget_as_object, - G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, - 0, 0, NULL, - G_CALLBACK (selection_changed_callback), - target_data); - } - set_clipboard_items_are_merged_in (widget_as_object, FALSE); -} - -static gboolean -focus_changed_callback (GtkWidget *widget, - GdkEventAny *event, - gpointer callback_data) -{ - /* Connect the component to the container if the widget has focus. */ - if (GTK_WIDGET_HAS_FOCUS (widget)) { - if (!clipboard_items_are_merged_in (widget)) { - merge_in_clipboard_menu_items (G_OBJECT (widget), callback_data); - } - } else { - if (clipboard_items_are_merged_in (widget)) { - merge_out_clipboard_menu_items (G_OBJECT (widget), callback_data); - } - } - - return FALSE; -} - -static void -selection_changed_callback (GtkWidget *widget, - gpointer callback_data) -{ - TargetCallbackData *target_data; - BonoboUIComponent *component; - GtkEditable *editable; - int start, end; - - target_data = (TargetCallbackData *) callback_data; - g_assert (target_data != NULL); - - component = target_data->component; - editable = GTK_EDITABLE (widget); - - if (gtk_editable_get_selection_bounds (editable, &start, &end) && start != end) { - set_clipboard_menu_items_sensitive (component); - } else { - set_clipboard_menu_items_insensitive (component); - } -} - -static void -target_destroy_callback (GtkObject *object, - gpointer callback_data) -{ - TargetCallbackData *target_data; - - g_assert (callback_data != NULL); - target_data = callback_data; - - if (target_data->component != NULL) { - bonobo_ui_component_unset_container (target_data->component, NULL); - bonobo_object_unref (target_data->component); - target_data->component = NULL; - } - bonobo_object_release_unref (target_data->container, NULL); - target_data->container = CORBA_OBJECT_NIL; -} - -static TargetCallbackData * -initialize_clipboard_component_with_callback_data (GtkEditable *target, - Bonobo_UIContainer ui_container, - gboolean shares_selection_changes) -{ - BonoboUIVerb verbs [] = { - BONOBO_UI_VERB ("Cut", cut_callback), - BONOBO_UI_VERB ("Copy", copy_callback), - BONOBO_UI_VERB ("Paste", paste_callback), - BONOBO_UI_VERB ("Clear", clear_callback), - BONOBO_UI_VERB ("Select All", select_all_callback), - BONOBO_UI_VERB_END - }; - BonoboUIComponent *ui; - TargetCallbackData *target_data; - - /* Create the UI component and set up the verbs. */ - ui = bonobo_ui_component_new_default (); - bonobo_ui_component_add_verb_list_with_data (ui, verbs, target); - - /* Do the actual connection of the UI to the container at - * focus time, and disconnect at both focus and destroy - * time. - */ - target_data = g_new (TargetCallbackData, 1); - target_data->component = ui; - target_data->container = bonobo_object_dup_ref (ui_container, NULL); - target_data->editable_shares_selection_changes = shares_selection_changes; - - return target_data; -} - -void -nautilus_clipboard_set_up_editable (GtkEditable *target, - Bonobo_UIContainer ui_container, - gboolean shares_selection_changes) -{ - TargetCallbackData *target_data; - - g_return_if_fail (GTK_IS_EDITABLE (target)); - g_return_if_fail (ui_container != CORBA_OBJECT_NIL); - - target_data = initialize_clipboard_component_with_callback_data - (target, - ui_container, - shares_selection_changes); - - g_signal_connect (target, "focus_in_event", - G_CALLBACK (focus_changed_callback), target_data); - g_signal_connect (target, "focus_out_event", - G_CALLBACK (focus_changed_callback), target_data); - g_signal_connect (target, "destroy", - G_CALLBACK (target_destroy_callback), target_data); - - g_object_weak_ref (G_OBJECT (target), (GWeakNotify) g_free, target_data); - - /* Call the focus changed callback once to merge if the window is - * already in focus. - */ - focus_changed_callback (GTK_WIDGET (target), NULL, target_data); -} - -static gboolean -widget_was_set_up_with_selection_sensitivity (GtkWidget *widget) -{ - return GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), - "Nautilus:shares_selection_changes")); -} - -static gboolean -first_focus_callback (GtkWidget *widget, - GdkEventAny *event, - gpointer callback_data) -{ - /* Don't set up the clipboard again on future focus_in's. This - * is one-time work. - */ - disconnect_set_up_in_control_handlers (GTK_OBJECT (widget), callback_data); - - /* Do the rest of the setup. */ - nautilus_clipboard_set_up_editable - (GTK_EDITABLE (widget), - bonobo_control_get_remote_ui_container (BONOBO_CONTROL (callback_data), NULL), - widget_was_set_up_with_selection_sensitivity (widget)); - - return FALSE; -} - -static void -control_destroyed_callback (GtkObject *object, - gpointer callback_data) -{ - disconnect_set_up_in_control_handlers (object, callback_data); -} - -void -nautilus_clipboard_set_up_editable_in_control (GtkEditable *target, - BonoboControl *control, - gboolean shares_selection_changes) -{ - g_return_if_fail (GTK_IS_EDITABLE (target)); - g_return_if_fail (BONOBO_IS_CONTROL (control)); - - if (GTK_WIDGET_HAS_FOCUS (target)) { - nautilus_clipboard_set_up_editable - (target, - bonobo_control_get_remote_ui_container (control, NULL), - shares_selection_changes); - return; - } - - /* Use lazy initialization, so that we wait until after - * embedding. At that point, the UI container will be set up, - * but it's not necessarily set up now. - */ - /* We'd like to use gtk_signal_connect_while_alive, but it's - * not compatible with gtk_signal_disconnect calls. - */ - g_object_set_data (G_OBJECT (target), "Nautilus:shares_selection_changes", - GINT_TO_POINTER (shares_selection_changes)); - g_signal_connect (target, "focus_in_event", - G_CALLBACK (first_focus_callback), control); - g_signal_connect (target, "destroy", - G_CALLBACK (control_destroyed_callback), control); -} - -static void -disconnect_set_up_in_control_handlers (GtkObject *object, - gpointer callback_data) -{ - g_signal_handlers_disconnect_matched (object, - G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, - 0, 0, NULL, - G_CALLBACK (first_focus_callback), - callback_data); - g_signal_handlers_disconnect_matched (object, - G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, - 0, 0, NULL, - G_CALLBACK (control_destroyed_callback), - callback_data); -} diff --git a/libnautilus/nautilus-clipboard.h b/libnautilus/nautilus-clipboard.h deleted file mode 100644 index 20b15511d..000000000 --- a/libnautilus/nautilus-clipboard.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* fm-directory-view.h - * - * Copyright (C) 1999, 2000 Free Software Foundaton - * Copyright (C) 2000 Eazel, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Rebecca Schulman <rebecka@eazel.com> - */ - -#ifndef NAUTILUS_CLIPBOARD_H -#define NAUTILUS_CLIPBOARD_H - -#include <gtk/gtkeditable.h> -#include <bonobo/bonobo-control.h> - -/* This makes this editable put clipboard commands into the passed UI - * container when the editable is in focus. Callers in Nautilus - * normally get the UI container from - * nautilus_window_get_bonobo_ui_container. */ -/* The shares selection changes argument should be set to true if the - * editable is a widget that uses the signal "selection_changed" to - * tell others about text selection changes. The NautilusEntry widget - * is currently the only widget in nautilus that shares selection - * changes. */ -void nautilus_clipboard_set_up_editable (GtkEditable *target, - Bonobo_UIContainer container, - gboolean shares_selection_changes); - -/* Components should use this convenient cover instead of the call - * above. This cover waits until the UI container shows up, so it can be - * called even before the control has a UI container. Set the - */ -/* Set the shares_selection changes as for the nautilus_clipboard_set_up_editable */ -void nautilus_clipboard_set_up_editable_in_control (GtkEditable *target, - BonoboControl *control, - gboolean shares_selection_changes); - -#endif /* NAUTILUS_CLIPBOARD_H */ diff --git a/libnautilus/nautilus-distributed-undo.idl b/libnautilus/nautilus-distributed-undo.idl deleted file mode 100644 index 5a68056e0..000000000 --- a/libnautilus/nautilus-distributed-undo.idl +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */ - -/* nautilus-undo.idl - Interface for view components that - * support undo, used internally by the - * undo support classes. - * - * 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. - */ - -#ifndef NAUTILUS_UNDO_IDL_INCLUDED -#define NAUTILUS_UNDO_IDL_INCLUDED - -#include <Bonobo.idl> - -module Nautilus { - - module Undo { - - /* The specifications for a menu item. */ - struct MenuItem { - string label; - string hint; - }; - - /* A single undoable operation is represented by a - * transaction. This is the interface a transaction - * must supply for use by an undo manager. - */ - interface Transaction : ::Bonobo::Unknown { - /* These menu items are used to display undo - * or redo menu items for this transaction. - * The operation name is for lists of undoable - * operations that are listed somewhere other - * than an undo or redo object. - */ - readonly attribute MenuItem undo_menu_item; - readonly attribute MenuItem redo_menu_item; - readonly attribute string operation_name; - - /* Here's how you actually perform an undo. - * Once it's performed, calling this again is - * safe; it's guaranteed to do nothing. - */ - void undo (); - }; - - /* An undo manager deals with a list of transactions - * for a particular application or window. This is the - * interface of the manager from the transaction's - * point of view only. - */ - interface Manager : ::Bonobo::Unknown { - /* Add a new transaction. This is normally called - * by the code that creates the transaction. - */ - void append (in Transaction transaction); - - /* Forget a transaction. This is typically called - * when the operation that the transaction does - * undo for no longer makes sense. - */ - void forget (in Transaction transaction); - - /* Sometimes an undo has to be "forced" from the - * client side when it recognizes an undo key - * equivalent. - */ - void undo (); - - /* FIXME bugzilla.gnome.org 41292: - * We may need additional interface so the - * client can include an appropriate undo item in - * a contextual menu. - */ - }; - - /* To locate the appropriate manager, a view component - * can query for this interface on its Bonobo control - * frame. This is done automatically by functions in - * the undo manager. - */ - interface Context : ::Bonobo::Unknown { - readonly attribute Manager undo_manager; - }; - }; -}; - -#endif /* NAUTILUS_UNDO_IDL_INCLUDED */ diff --git a/libnautilus/nautilus-idle-queue.c b/libnautilus/nautilus-idle-queue.c deleted file mode 100644 index 431b8d39a..000000000 --- a/libnautilus/nautilus-idle-queue.c +++ /dev/null @@ -1,144 +0,0 @@ -/* -*- 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/nautilus-idle-queue.h b/libnautilus/nautilus-idle-queue.h deleted file mode 100644 index 3446973d3..000000000 --- a/libnautilus/nautilus-idle-queue.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- 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/nautilus-scroll-positionable.c b/libnautilus/nautilus-scroll-positionable.c deleted file mode 100644 index 7ad9eb9c8..000000000 --- a/libnautilus/nautilus-scroll-positionable.c +++ /dev/null @@ -1,155 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* nautilus-scroll-positionable.c - public interface for objects that implement - * scroll positioning - * - * Copyright (C) 2003 Red Hat, 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: Alexander Larsson <alexl@redhat.com> - */ - -#include "nautilus-scroll-positionable.h" - -#include <config.h> -#include <string.h> -#include <bonobo/bonobo-i18n.h> -#include <bonobo/bonobo-exception.h> -#include <eel/eel-marshal.h> - -enum { - GET_FIRST_VISIBLE_FILE, - SCROLL_TO_FILE, - LAST_SIGNAL -}; - -static guint signals [LAST_SIGNAL]; - -BONOBO_CLASS_BOILERPLATE_FULL (NautilusScrollPositionable, nautilus_scroll_positionable, Nautilus_ScrollPositionable, - BonoboObject, BONOBO_OBJECT_TYPE) - - -static Nautilus_URI -impl_Nautilus_Scroll_Positionable_get_first_visible_file (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - NautilusScrollPositionable *positionable; - char *uri; - char *ret; - - positionable = NAUTILUS_SCROLL_POSITIONABLE (bonobo_object_from_servant (servant)); - - uri = NULL; - g_signal_emit (G_OBJECT (positionable), signals [GET_FIRST_VISIBLE_FILE], - 0, &uri); - if (uri) { - ret = CORBA_string_dup (uri); - g_free (uri); - } else { - ret = CORBA_string_dup (""); - } - - return ret; -} - -static void -impl_Nautilus_Scroll_Positionable_scroll_to_file (PortableServer_Servant servant, - const CORBA_char *uri, - CORBA_Environment *ev) -{ - NautilusScrollPositionable *positionable; - - positionable = NAUTILUS_SCROLL_POSITIONABLE (bonobo_object_from_servant (servant)); - - g_signal_emit (G_OBJECT (positionable), - signals [SCROLL_TO_FILE], 0, - uri); -} - - - -static char * -nautilus_scroll_positionable_get_first_visible_file (NautilusScrollPositionable *positionable) -{ - return NULL; -} - -static void -nautilus_scroll_positionable_instance_init (NautilusScrollPositionable *positionable) -{ -} - -static void -nautilus_scroll_positionable_finalize (GObject *object) -{ - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static gboolean -single_string_accumulator (GSignalInvocationHint *ihint, - GValue *return_accu, - const GValue *handler_return, - gpointer dummy) -{ - gboolean continue_emission; - const gchar *str; - - str = g_value_get_string (handler_return); - g_value_set_string (return_accu, str); - continue_emission = str == NULL; - - return continue_emission; -} - -static void -nautilus_scroll_positionable_class_init (NautilusScrollPositionableClass *klass) -{ - POA_Nautilus_ScrollPositionable__epv *epv = &klass->epv; - GObjectClass *object_class; - - object_class = (GObjectClass *) klass; - - klass->get_first_visible_file = nautilus_scroll_positionable_get_first_visible_file; - - object_class->finalize = nautilus_scroll_positionable_finalize; - - signals [GET_FIRST_VISIBLE_FILE] = - g_signal_new ("get_first_visible_file", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusScrollPositionableClass, get_first_visible_file), - single_string_accumulator, NULL, - eel_marshal_STRING__VOID, - G_TYPE_STRING, 0); - signals [SCROLL_TO_FILE] = - g_signal_new ("scroll_to_file", - G_TYPE_FROM_CLASS (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusScrollPositionableClass, scroll_to_file), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, G_TYPE_STRING); - - epv->scroll_to_file = impl_Nautilus_Scroll_Positionable_scroll_to_file; - epv->get_first_visible_file = impl_Nautilus_Scroll_Positionable_get_first_visible_file; -} - -NautilusScrollPositionable * -nautilus_scroll_positionable_new (void) -{ - return g_object_new (nautilus_scroll_positionable_get_type (), NULL); -} diff --git a/libnautilus/nautilus-scroll-positionable.h b/libnautilus/nautilus-scroll-positionable.h deleted file mode 100644 index 75b494a33..000000000 --- a/libnautilus/nautilus-scroll-positionable.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* nautilus-scroll-positionable.h - public interface for objects that implement - * scroll positioning - * - * Copyright (C) 2003 Red Hat, 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: Alexander Larsson <alexl@redhat.com> - */ - -#ifndef NAUTILUS_SCROLL_POSITIONABLE_H -#define NAUTILUS_SCROLL_POSITIONABLE_H - -#include <libnautilus/nautilus-view-component.h> -#include <bonobo/bonobo-object.h> - -G_BEGIN_DECLS - -#define NAUTILUS_TYPE_SCROLL_POSITIONABLE (nautilus_scroll_positionable_get_type ()) -#define NAUTILUS_SCROLL_POSITIONABLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NAUTILUS_TYPE_SCROLL_POSITIONABLE, NautilusScrollPositionable)) -#define NAUTILUS_SCROLL_POSITIONABLE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NAUTILUS_TYPE_SCROLL_POSITIONABLE, NautilusScrollPositionableClass)) -#define BONOBO_IS_POSITIONABLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NAUTILUS_TYPE_SCROLL_POSITIONABLE)) -#define BONOBO_IS_POSITIONABLE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NAUTILUS_TYPE_SCROLL_POSITIONABLE)) -#define NAUTILUS_SCROLL_POSITIONABLE_GET_CLASS(o)(G_TYPE_INSTANCE_GET_CLASS ((o), NAUTILUS_TYPE_SCROLL_POSITIONABLE, NautilusScrollPositionableClass)) - -typedef struct _NautilusScrollPositionablePrivate NautilusScrollPositionablePrivate; - -typedef struct { - BonoboObject object; -} NautilusScrollPositionable; - -typedef struct { - BonoboObjectClass parent; - POA_Nautilus_ScrollPositionable__epv epv; - - char * (*get_first_visible_file) (NautilusScrollPositionable *positionable); - void (*scroll_to_file) (NautilusScrollPositionable *positionable, - const char *uri); - - gpointer dummy[4]; -} NautilusScrollPositionableClass; - -GType nautilus_scroll_positionable_get_type (void) G_GNUC_CONST; - -NautilusScrollPositionable *nautilus_scroll_positionable_new (void); - -G_END_DECLS - -#endif /* NAUTILUS_SCROLL_POSITIONABLE_H */ diff --git a/libnautilus/nautilus-undo-private.h b/libnautilus/nautilus-undo-private.h deleted file mode 100644 index 3bfa171b4..000000000 --- a/libnautilus/nautilus-undo-private.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- 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/nautilus-distributed-undo.h> -#include <glib-object.h> - -Nautilus_Undo_Manager nautilus_undo_get_undo_manager (GObject *attached_object); -void nautilus_undo_attach_undo_manager (GObject *object, - Nautilus_Undo_Manager manager); - -#endif /* NAUTILUS_UNDO_PRIVATE_H */ diff --git a/libnautilus/nautilus-undo-transaction.c b/libnautilus/nautilus-undo-transaction.c deleted file mode 100644 index e1c7ea697..000000000 --- a/libnautilus/nautilus-undo-transaction.c +++ /dev/null @@ -1,359 +0,0 @@ -/* -*- 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 "nautilus-undo-transaction.h" - -#include "nautilus-undo-private.h" -#include <bonobo/bonobo-main.h> -#include <gtk/gtksignal.h> -#include <eel/eel-gtk-macros.h> - -#define NAUTILUS_UNDO_TRANSACTION_LIST_DATA "Nautilus undo transaction list" - -static void nautilus_undo_transaction_undo (NautilusUndoTransaction *transaction); - -/* undo atoms */ -static void undo_atom_list_free (GList *list); -static void undo_atom_list_undo_and_free (GList *list); - -BONOBO_CLASS_BOILERPLATE_FULL (NautilusUndoTransaction, nautilus_undo_transaction, - Nautilus_Undo_Transaction, - BonoboObject, BONOBO_OBJECT_TYPE) - -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); -} - -static void -impl_Nautilus_Undo_Transaction__undo (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - NautilusUndoTransaction *transaction; - - transaction = NAUTILUS_UNDO_TRANSACTION (bonobo_object_from_servant (servant)); - nautilus_undo_transaction_undo (transaction); -} - -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_instance_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); - - CORBA_Object_release (transaction->owner, NULL); - - G_OBJECT_CLASS (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, - Nautilus_Undo_Manager manager) -{ - CORBA_Environment ev; - - g_return_if_fail (NAUTILUS_IS_UNDO_TRANSACTION (transaction)); - g_return_if_fail (transaction->owner == CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - if (!CORBA_Object_is_nil (manager, &ev)) { - Nautilus_Undo_Manager_append (manager, BONOBO_OBJREF (transaction), &ev); - transaction->owner = CORBA_Object_duplicate (manager, &ev); - } - - CORBA_exception_free (&ev); -} - -static void -remove_atoms (NautilusUndoTransaction *transaction, - GObject *object) -{ - CORBA_Environment ev; - GList *p, *next; - NautilusUndoAtom *atom; - - g_assert (NAUTILUS_IS_UNDO_TRANSACTION (transaction)); - g_assert (G_IS_OBJECT (object)); - - CORBA_exception_init (&ev); - - /* 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, BONOBO_OBJREF (transaction), &ev); - } - - CORBA_exception_free (&ev); -} - -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) -{ - POA_Nautilus_Undo_Transaction__epv *epv = &klass->epv; - - G_OBJECT_CLASS (klass)->finalize = nautilus_undo_transaction_finalize; - - epv->_get_undo_menu_item = &impl_Nautilus_Undo_Transaction__get_undo_menu_item; - epv->_get_redo_menu_item = &impl_Nautilus_Undo_Transaction__get_redo_menu_item; - epv->_get_operation_name = &impl_Nautilus_Undo_Transaction__get_operation_name; - epv->undo = &impl_Nautilus_Undo_Transaction__undo; -} diff --git a/libnautilus/nautilus-undo-transaction.h b/libnautilus/nautilus-undo-transaction.h deleted file mode 100644 index a077ecf45..000000000 --- a/libnautilus/nautilus-undo-transaction.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- 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/nautilus-undo.h> -#include <libnautilus/nautilus-distributed-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)) - -typedef struct { - BonoboObject 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; - - Nautilus_Undo_Manager owner; -} NautilusUndoTransaction; - -typedef struct { - BonoboObjectClass parent_slot; - POA_Nautilus_Undo_Transaction__epv epv; -} NautilusUndoTransactionClass; - -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, - Nautilus_Undo_Manager manager); -void nautilus_undo_transaction_unregister_object (GObject *atom_target); - -#endif /* NAUTILUS_UNDO_TRANSACTION_H */ diff --git a/libnautilus/nautilus-undo.c b/libnautilus/nautilus-undo.c deleted file mode 100644 index ae4fa9e43..000000000 --- a/libnautilus/nautilus-undo.c +++ /dev/null @@ -1,278 +0,0 @@ -/* -*- 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. - */ - bonobo_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) -{ - Nautilus_Undo_Manager manager; - CORBA_Environment ev; - - g_return_if_fail (G_IS_OBJECT (undo_manager_search_start_object)); - - CORBA_exception_init (&ev); - - manager = nautilus_undo_get_undo_manager (undo_manager_search_start_object); - if (!CORBA_Object_is_nil (manager, &ev)) { - Nautilus_Undo_Manager_undo (manager, &ev); - } - - CORBA_exception_free (&ev); -} - -Nautilus_Undo_Manager -nautilus_undo_get_undo_manager (GObject *start_object) -{ - Nautilus_Undo_Manager 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 CORBA_OBJECT_NIL; -} - -static void -undo_manager_unref_cover (gpointer manager) -{ - bonobo_object_release_unref (manager, NULL); -} - -void -nautilus_undo_attach_undo_manager (GObject *object, - Nautilus_Undo_Manager manager) -{ - g_return_if_fail (G_IS_OBJECT (object)); - - if (manager == NULL) { - g_object_set_data (object, NAUTILUS_UNDO_MANAGER_DATA, NULL); - } else { - bonobo_object_dup_ref (manager, NULL); - g_object_set_data_full - (object, NAUTILUS_UNDO_MANAGER_DATA, - manager, undo_manager_unref_cover); - } -} - -/* Copy a reference to the undo manager fromone object to another. */ -void -nautilus_undo_share_undo_manager (GObject *destination_object, - GObject *source_object) -{ - Nautilus_Undo_Manager manager; - - manager = nautilus_undo_get_undo_manager (source_object); - nautilus_undo_attach_undo_manager (destination_object, manager); - CORBA_Object_release (manager, NULL); -} - -/* Locates an undo manager for this bonobo control. - * The undo manager is supplied by an interface on - * the control frame. The put that undo manager on - * the Bonobo control's widget. - */ -static void -set_up_bonobo_control (BonoboControl *control) -{ - Nautilus_Undo_Manager manager; - Bonobo_ControlFrame control_frame; - CORBA_Environment ev; - Nautilus_Undo_Context undo_context; - GtkWidget *widget; - - g_assert (BONOBO_IS_CONTROL (control)); - - manager = CORBA_OBJECT_NIL; - - CORBA_exception_init (&ev); - - /* Find the undo manager. */ - control_frame = bonobo_control_get_control_frame (control, &ev); - if (!CORBA_Object_is_nil (control_frame, &ev)) { - undo_context = Bonobo_Control_queryInterface - (control_frame, "IDL:Nautilus/Undo/Context:1.0", &ev); - if (!CORBA_Object_is_nil (undo_context, &ev)) { - manager = Nautilus_Undo_Context__get_undo_manager (undo_context, &ev); - Bonobo_Control_unref (undo_context, &ev); - } - CORBA_Object_release (undo_context, &ev); - } - CORBA_Object_release (control_frame, &ev); - - /* Attach the undo manager to the widget, or detach the old one. */ - widget = bonobo_control_get_widget (control); - nautilus_undo_attach_undo_manager (G_OBJECT (widget), manager); - CORBA_Object_release (manager, &ev); - - CORBA_exception_free (&ev); -} - -void -nautilus_undo_set_up_bonobo_control (BonoboControl *control) -{ - g_return_if_fail (BONOBO_IS_CONTROL (control)); - - set_up_bonobo_control (control); - g_signal_connect (control, "set_frame", - G_CALLBACK (set_up_bonobo_control), NULL); -} diff --git a/libnautilus/nautilus-undo.h b/libnautilus/nautilus-undo.h deleted file mode 100644 index c72ef5368..000000000 --- a/libnautilus/nautilus-undo.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- 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 <bonobo/bonobo-control.h> - -/* 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); -void nautilus_undo_set_up_bonobo_control (BonoboControl *control); - -#endif /* NAUTILUS_UNDO_H */ diff --git a/libnautilus/nautilus-view-component.idl b/libnautilus/nautilus-view-component.idl deleted file mode 100644 index f40e76339..000000000 --- a/libnautilus/nautilus-view-component.idl +++ /dev/null @@ -1,190 +0,0 @@ -/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */ - -/* - * libnautilus: A library for nautilus view implementations. - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 2000, 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. - * - * Authors: Elliot Lee <sopwith@redhat.com> - * Darin Adler <darin@bentspoon.com> - * Maciej Stachowiak <mjs@eazel.com> - * - */ - - -#ifndef NAUTILUS_VIEW_COMPONENT_IDL -#define NAUTILUS_VIEW_COMPONENT_IDL - -#if !defined(__nautilus_view_component_COMPILATION) && defined(__ORBIT_IDL__) -%{ -#pragma include_defs libnautilus/nautilus-view-component.h -%} -#pragma inhibit push -#endif - -#include <Bonobo.idl> - -module Nautilus { - - /* URIs are just plain strings, but we use a typedef to make - * the interface definitions clearer. - */ - typedef string URI; - typedef sequence<URI> URIList; - - struct HistoryItem { - string title; - URI location; - }; - typedef sequence<HistoryItem> History; - - enum WindowType { - WINDOW_SPATIAL, - WINDOW_NAVIGATION, - WINDOW_DESKTOP - }; - - enum ShowHiddenFilesMode { - SHOW_HIDDEN_FILES_DEFAULT, - SHOW_HIDDEN_FILES_ENABLE, - SHOW_HIDDEN_FILES_DISABLE - }; - - /* The View interface is used by the Nautilus shell to control - * the view. A view that is a Bonobo::Control can choose to - * implement the View interface for additional finer control - * by Nautilus. - */ - interface View : ::Bonobo::Unknown { - /* Called to tell the view about location changes. - * Called again with the same location again to request a - * reload. - */ - oneway void load_location (in URI location); - oneway void stop_loading (); - }; - - - /* An interface that allows the shell to query the current - * scrolled position of views, and later return to that - * position. Typically used when going back/forward. - */ - interface ScrollPositionable : ::Bonobo::Unknown { - URI get_first_visible_file (); - void scroll_to_file (in URI position); - }; - - /* The ViewFrame interface is used by the view to communicate - * with the Nautilus shell. It's implemented as an interface - * on the Bonobo::ControlFrame for the view. - * - * The Ambient properties on the ControlFrame are: - * 'title' - ro - string - the title - * 'history' - ro - Nautilus::History - the history list - * 'selection' - ro - URIList - the selection - * 'show-hidden-files-mode' -ro - Nautilus::ShowHiddenFilesMode - show hidden files setting - * 'window-type' - ro - Nautilus::WindowType - the window type - */ - interface ViewFrame : ::Bonobo::Unknown { - enum OpenMode { - OPEN_ACCORDING_TO_MODE, - OPEN_IN_SPATIAL, - OPEN_IN_NAVIGATION - }; - - typedef long OpenFlags; - const OpenFlags OPEN_FLAG_CLOSE_BEHIND = 1; - - oneway void open_location (in URI location, - in OpenMode mode, - in OpenFlags flags, - in URIList selection); - - /* Called by a view component when the location - * changes, but the view component is handling it - * directly. This differs from - * "open_location_in_this_window" in that it - * understands that the same component is reused, and - * also it treats the load as "already underway" and - * does not send a "load_location", - * "selection_changed", or "title_changed" to the view - * that initiates this. The redirect version should be - * used when the location change does not deserve its - * own element in history. - */ - oneway void report_location_change (in URI location, - in URIList selection, - in string title); - oneway void report_redirect (in URI from_location, - in URI to_location, - in URIList selection, - in string title); - - /* Called by a view component to announce a change in the - * selection. This selection change will be reported back - * to the original view along with the others. - */ - oneway void report_selection_change (in URIList selection); - - /* Called by a view component to change the contents - * of the status bar. - */ - oneway void report_status (in string status); - - /* Called by a view component to give an update about - * progress loading the view for the current - * location. Calling underway repeatedly tells the - * shell that the view is making progress. For views - * that know how far along they are, calling - * report_load_progress (instead of - * report_load_underway) with a number from 0.0 to 1.0 - * expresses how much of the total is done. When the - * load is complete or has failed, either - * report_load_failed or report_load_complete - * indicates that. - */ - oneway void report_load_underway (); - oneway void report_load_progress (in float fraction_done); - oneway void report_load_complete (); - oneway void report_load_failed (); - - /* Called by a view component to change the title. */ - oneway void set_title (in string new_title); - - /* Called by a view component to change the show hidden files mode. */ - oneway void set_show_hidden_files_mode (in ShowHiddenFilesMode new_mode); - - /* Called when a view component wants to make the - * window it's in "go back". At some point we may add a more - * complete set of operations. This one is very useful for - * components that do something and then return. - * If there's nowhere to go back to, it goes home, which - * is not quite the same as the "back" button in the UI, - * which does nothing if there's nowhere to go. - */ - oneway void go_back (); - oneway void close_window (); - }; - -}; - -#if !defined(__nautilus_view_component_COMPILATION) && defined(__ORBIT_IDL__) -#pragma inhibit pop -#endif - -#endif /* NAUTILUS_VIEW_COMPONENT_IDL */ diff --git a/libnautilus/nautilus-view-standard-main.c b/libnautilus/nautilus-view-standard-main.c deleted file mode 100644 index d0ddd3e47..000000000 --- a/libnautilus/nautilus-view-standard-main.c +++ /dev/null @@ -1,422 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * libnautilus: A library for nautilus view implementations. - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 2000 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Authors: Maciej Stachowiak <mjs@eazel.com> - * - */ - -/* nautilus-view-standard-main.c: Standard main functions for Nautilus - views, to reduce boilerplate code. */ - -#include <config.h> -#include "nautilus-view-standard-main.h" - -#include <X11/Xlib.h> -#include <bonobo/bonobo-generic-factory.h> -#include <bonobo/bonobo-main.h> -#include <bonobo/bonobo-control.h> -#include <bonobo/bonobo-ui-main.h> -#include <gdk/gdkx.h> -#include <gtk/gtkmain.h> -#include <gtk/gtksignal.h> -#include <libgnome/gnome-i18n.h> -#include <libgnomeui/gnome-client.h> -#include <libgnomeui/gnome-ui-init.h> -#include <libgnomevfs/gnome-vfs-init.h> -#include <eel/eel-gnome-extensions.h> -#include <stdlib.h> -#include <string.h> - -#define N_IDLE_SECONDS_BEFORE_QUIT 5 - -typedef struct { - int object_count; - GList *view_iids; - NautilusViewCreateFunction create_function; - void *user_data; - guint delayed_quit_timeout_id; -} CallbackData; - -static gboolean -delayed_quit_timeout_callback (gpointer data) -{ - CallbackData *callback_data; - - callback_data = (CallbackData *) data; - callback_data->delayed_quit_timeout_id = 0; - gtk_main_quit (); - - return FALSE; -} - -static void -view_object_destroy (GObject *object, - CallbackData *callback_data) -{ - g_assert (G_IS_OBJECT (object)); - - if (!g_object_get_data (object, "standard_main_destroy_accounted")) { - g_object_set_data (object, "standard_main_destroy_accounted", - GUINT_TO_POINTER (TRUE)); - - callback_data->object_count--; - - if (callback_data->object_count <= 0 && - callback_data->delayed_quit_timeout_id == 0) { - /* Connect a handler that will get us out of the - * main loop when there are no more objects outstanding. - */ - callback_data->delayed_quit_timeout_id = - g_timeout_add (N_IDLE_SECONDS_BEFORE_QUIT * 1000, - delayed_quit_timeout_callback, - callback_data); - } - } -} - -/* - * Time we're prepared to wait without a ControlFrame - * before terminating the Control. This can happen if the - * container activates us but crashes before the set_frame. - * - * NB. if we don't get a frame in 30 seconds, something - * is badly wrong, or Gnome performance needs improving - * markedly ! - */ -#define NAUTILUS_VIEW_NEVER_GOT_FRAME_TIMEOUT (30 * 1000) -#define CALLBACK_DATA_KEY "standard_main_callback_data_key" - -static void -nautilus_view_cnx_broken_callback (GObject *control) -{ - view_object_destroy (control, - g_object_get_data (G_OBJECT (control), - CALLBACK_DATA_KEY)); -} - -static gboolean -nautilus_view_never_got_frame_timeout (gpointer user_data) -{ - g_warning ("Never got frame, container died - abnormal exit condition"); - - nautilus_view_cnx_broken_callback (user_data); - - return FALSE; -} - -static void -nautilus_view_set_frame_callback (BonoboControl *control, - gpointer user_data) -{ - Bonobo_ControlFrame remote_frame; - - remote_frame = bonobo_control_get_control_frame (control, NULL); - - if (remote_frame != CORBA_OBJECT_NIL) { - ORBitConnectionStatus status; - - g_source_remove (GPOINTER_TO_UINT (user_data)); - - status = ORBit_small_get_connection_status (remote_frame); - - /* Only track out of proc controls */ - if (status != ORBIT_CONNECTION_IN_PROC) { - g_signal_connect_closure ( - ORBit_small_get_connection (remote_frame), - "broken", - g_cclosure_new_object_swap ( - G_CALLBACK (nautilus_view_cnx_broken_callback), - G_OBJECT (control)), - FALSE); - g_signal_connect ( - control, "destroy", - G_CALLBACK (nautilus_view_cnx_broken_callback), - NULL); - } - } -} - -/* - * This code is somewhat duplicated in gnome-panel/libpanel-applet - * and is ripe for abstracting in an intermediate library. - */ -static void -nautilus_view_instrument_for_failure (BonoboObject *control, - CallbackData *callback_data) -{ - guint no_frame_timeout_id; - - g_object_set_data (G_OBJECT (control), - CALLBACK_DATA_KEY, callback_data); - - no_frame_timeout_id = g_timeout_add ( - NAUTILUS_VIEW_NEVER_GOT_FRAME_TIMEOUT, - nautilus_view_never_got_frame_timeout, - control); - g_signal_connect_closure ( - control, "destroy", - g_cclosure_new_swap ( - G_CALLBACK (g_source_remove), - GUINT_TO_POINTER (no_frame_timeout_id), NULL), - 0); - g_signal_connect ( - control, "set_frame", - G_CALLBACK (nautilus_view_set_frame_callback), - GUINT_TO_POINTER (no_frame_timeout_id)); -} - -static BonoboObject * -make_object (BonoboGenericFactory *factory, - const char *iid, - gpointer data) -{ - BonoboObject *view; - BonoboObject *control; - CallbackData *callback_data; - - callback_data = (CallbackData *) data; - - g_assert (BONOBO_IS_GENERIC_FACTORY (factory)); - g_assert (iid != NULL); - g_assert (callback_data != NULL); - - /* Check that this is one of the types of object we know how to create. */ - if (g_list_find_custom (callback_data->view_iids, - (gpointer) iid, (GCompareFunc) strcmp) == NULL) { - return NULL; - } - - view = callback_data->create_function (iid, callback_data->user_data); - - callback_data->object_count++; - if (callback_data->delayed_quit_timeout_id != 0) { - g_source_remove (callback_data->delayed_quit_timeout_id); - callback_data->delayed_quit_timeout_id = 0; - } - g_signal_connect (view, "destroy", - G_CALLBACK (view_object_destroy), - callback_data); - - /* We can do some more agressive tracking of controls */ - if ((control = bonobo_object_query_local_interface - (view, "IDL:Bonobo/Control:1.0"))) { - nautilus_view_instrument_for_failure (control, callback_data); - bonobo_object_unref (control); - } - - return BONOBO_OBJECT (view); -} - -/** - * nautilus_view_standard_main_multi - * - * A version of nautilus_view_standard_main that accepts multiple view - * IIDs. - * - * @executable_name: The name of the executable binary. - * @version: Component version. Usually VERSION. - * @gettext_package_name: Package name for gettext support. Usually PACKAGE. - * Can be NULL, in which case the component will not - * have gettext support and translations might not - * work - * @gettext_locale_directory: Locale directory for gettext support. Usually - * GNOMELOCALEDIR. Must not be NULL if - * @gettext_package_name is not NULL. - * @argc: Command line argument count. - * @argv: Command line argument vector. - * @factory_iid: The components's factory IID. - * @view_iids: A GList of NautilusView IIDs. - * @create_function: Function called to create the NautilusView instance. - * @post_initialize_callback: An optional callback which is invoked after - * all modules have been initialized (gtk, bonobo, - * gnome-vfs, etc.) but before the execution of - * the main event loop or the creation of the - * component's factory. - * @user_data: User data for @create_function. - **/ -int -nautilus_view_standard_main_multi (const char *executable_name, - const char *version, - const char *gettext_package_name, - const char *gettext_locale_directory, - int argc, - char **argv, - const char *factory_iid, - GList *view_iids, - NautilusViewCreateFunction create_function, - GVoidFunc post_initialize_callback, - void *user_data) -{ - BonoboGenericFactory *factory; - CallbackData callback_data; - char *registration_id; - - g_return_val_if_fail (executable_name != NULL, EXIT_FAILURE); - g_return_val_if_fail (version != NULL, EXIT_FAILURE); - g_return_val_if_fail (argc > 0, EXIT_FAILURE); - g_return_val_if_fail (argv != NULL, EXIT_FAILURE); - g_return_val_if_fail (argv[0] != NULL, EXIT_FAILURE); - g_return_val_if_fail (factory_iid != NULL, EXIT_FAILURE); - g_return_val_if_fail (g_list_length (view_iids) > 0, EXIT_FAILURE); - g_return_val_if_fail (create_function != NULL, EXIT_FAILURE); - - if (gettext_package_name != NULL) { - g_return_val_if_fail (gettext_locale_directory != NULL, EXIT_FAILURE); - } - if (gettext_locale_directory != NULL) { - g_return_val_if_fail (gettext_package_name != NULL, EXIT_FAILURE); - } - - /* Initialize gettext support if needed */ - if (gettext_package_name != NULL - && gettext_locale_directory != NULL) { - bindtextdomain (gettext_package_name, gettext_locale_directory); - bind_textdomain_codeset (gettext_package_name, "UTF-8"); - textdomain (gettext_package_name); - } - - /* Initialize libraries. */ - gnome_program_init (executable_name, version, - LIBGNOMEUI_MODULE, - argc, argv, - /* Disable session manager connection */ - GNOME_CLIENT_PARAM_SM_CONNECT, FALSE, - NULL); - - bonobo_ui_init (executable_name, version, &argc, argv); - - if (post_initialize_callback != NULL) { - (* post_initialize_callback) (); - } - - /* Fill in the callback data */ - callback_data.object_count = 0; - callback_data.view_iids = view_iids; - callback_data.create_function = create_function; - callback_data.user_data = user_data; - callback_data.delayed_quit_timeout_id = 0; - - /* Create the factory. */ - registration_id = eel_bonobo_make_registration_id (factory_iid); - factory = bonobo_generic_factory_new (registration_id, - make_object, - &callback_data); - g_free (registration_id); - - if (factory != NULL) { - /* Loop until we have no more objects. */ - bonobo_activate (); - do { - gtk_main (); - } while (callback_data.object_count > 0 || - callback_data.delayed_quit_timeout_id != 0); - bonobo_object_unref (factory); - } - - gnome_vfs_shutdown (); - - return EXIT_SUCCESS; -} - -/** - * nautilus_view_standard_main - * - * An implementation of most of a typical main.c file for Nautilus views. - * Just call the function from main and pass it the right arguments. This - * should make writing Nautilus views simpler. - * - * @executable_name: The name of the executable binary. - * @version: Component version. Usually VERSION. - * @gettext_package_name: Package name for gettext support. Usually PACKAGE. - * Can be NULL, in which case the component will not - * have gettext support and translations might not - * work - * @gettext_locale_directory: Locale directory for gettext support. Usually - * GNOMELOCALEDIR. Must not be NULL if - * @gettext_package_name is not NULL. - * @argc: Command line argument count. - * @argv: Command line argument vector. - * @factory_iid: The components's factory IID. - * @view_iid: The component's NautilusView IID. - * @create_function: Function called to create the NautilusView instance. - * @post_initialize_callback: An optional callback which is invoked after - * all modules have been initialized (gtk, bonobo, - * gnome-vfs, etc.) but before the execution of - * the main event loop or the creation of the - * component's factory. - * @user_data: User data for @create_function. - **/ -int -nautilus_view_standard_main (const char *executable_name, - const char *version, - const char *gettext_package_name, - const char *gettext_locale_directory, - int argc, - char **argv, - const char *factory_iid, - const char *view_iid, - NautilusViewCreateFunction create_function, - GVoidFunc post_initialize_callback, - void *user_data) -{ - GList node; - - g_return_val_if_fail (executable_name != NULL, EXIT_FAILURE); - g_return_val_if_fail (version != NULL, EXIT_FAILURE); - g_return_val_if_fail (argc > 0, EXIT_FAILURE); - g_return_val_if_fail (argv != NULL, EXIT_FAILURE); - g_return_val_if_fail (argv[0] != NULL, EXIT_FAILURE); - g_return_val_if_fail (factory_iid != NULL, EXIT_FAILURE); - g_return_val_if_fail (view_iid != NULL, EXIT_FAILURE); - g_return_val_if_fail (create_function != NULL, EXIT_FAILURE); - - if (gettext_package_name != NULL) { - g_return_val_if_fail (gettext_locale_directory != NULL, EXIT_FAILURE); - } - if (gettext_locale_directory != NULL) { - g_return_val_if_fail (gettext_package_name != NULL, EXIT_FAILURE); - } - - node.data = (gpointer) view_iid; - node.next = NULL; - node.prev = NULL; - - return nautilus_view_standard_main_multi (executable_name, - version, - gettext_package_name, - gettext_locale_directory, - argc, - argv, - factory_iid, - &node, - create_function, - post_initialize_callback, - user_data); -} - -typedef GType (* TypeFunc) (void); - -BonoboObject * -nautilus_view_create_from_get_type_function (const char *iid, void *user_data) -{ - return BONOBO_OBJECT (g_object_new (((TypeFunc) (user_data)) (), NULL)); -} diff --git a/libnautilus/nautilus-view-standard-main.h b/libnautilus/nautilus-view-standard-main.h deleted file mode 100644 index 99fc88f47..000000000 --- a/libnautilus/nautilus-view-standard-main.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */ - -/* - * libnautilus: A library for nautilus view implementations. - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 2000 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - * - */ - -/* nautilus-view-standard-main.h - An implementation of most of a - * typical main.c file for Nautilus views. Just call the function from - * main and pass it the right arguments. This should make writing - * Nautilus views simpler. - */ - -#ifndef NAUTILUS_VIEW_STANDARD_MAIN_H -#define NAUTILUS_VIEW_STANDARD_MAIN_H - -#include <bonobo/bonobo-object.h> - -G_BEGIN_DECLS - -typedef BonoboObject * (*NautilusViewCreateFunction) (const char *iid, void *user_data); - -int nautilus_view_standard_main (const char *executable_name, - const char *version, - const char *gettext_package_name, - const char *gettext_locale_directory, - int argc, - char **argv, - const char *factory_iid, - const char *view_iid, - NautilusViewCreateFunction create_function, - GVoidFunc post_initialize_callback, - void *user_data); - -int nautilus_view_standard_main_multi (const char *executable_name, - const char *version, - const char *gettext_package_name, - const char *gettext_locale_directory, - int argc, - char **argv, - const char *factory_iid, - GList *view_iids, /* GList<const char *> */ - NautilusViewCreateFunction create_function, - GVoidFunc post_initialize_callback, - void *user_data); - -/* standard handy create function (pass the _get_type function for the - * class as the user_data) - */ -BonoboObject *nautilus_view_create_from_get_type_function (const char *iid, void *user_data); - -G_END_DECLS - -#endif /* NAUTILUS_VIEW_STANDARD_MAIN_H */ diff --git a/libnautilus/nautilus-view.c b/libnautilus/nautilus-view.c deleted file mode 100644 index 363678ef7..000000000 --- a/libnautilus/nautilus-view.c +++ /dev/null @@ -1,1152 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * libnautilus: A library for nautilus view implementations. - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 2000, 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. - * - * Authors: Elliot Lee <sopwith@redhat.com> - * Maciej Stachowiak <mjs@eazel.com> - * Darin Adler <darin@bentspoon.com> - * - */ - -/* nautilus-view.c: Implementation for object that represents a - nautilus view implementation. */ - -#include <config.h> -#include "nautilus-view.h" - -#include "nautilus-idle-queue.h" -#include "nautilus-undo.h" -#include <bonobo/bonobo-control.h> -#include <bonobo/bonobo-event-source.h> -#include <bonobo/bonobo-exception.h> -#include <bonobo/bonobo-listener.h> -#include <bonobo/bonobo-main.h> -#include <bonobo/bonobo-ui-util.h> -#include <libgnome/gnome-macros.h> -#include <libgnomevfs/gnome-vfs-utils.h> -#include <string.h> - -enum { - HISTORY_CHANGED, - LOAD_LOCATION, - SELECTION_CHANGED, - STOP_LOADING, - TITLE_CHANGED, - SHOW_HIDDEN_FILES_MODE_CHANGED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL]; - -struct NautilusViewDetails { - BonoboControl *control; - - Nautilus_ViewFrame cached_view_frame; - - NautilusViewListenerMask listener_mask; - BonoboListener *listener; - Bonobo_EventSource listener_event_source; - - NautilusIdleQueue *incoming_queue; - NautilusIdleQueue *outgoing_queue; - - gboolean have_window_type; - Nautilus_WindowType window_type; - - gboolean have_show_hidden_files_mode; - Nautilus_ShowHiddenFilesMode show_hidden_files_mode; -}; - -typedef void (* ViewFunction) (NautilusView *view, - gpointer callback_data); - -typedef struct { - char *from_location; - char *location; - GList *selection; - char *title; - Nautilus_ViewFrame_OpenMode mode; - Nautilus_ViewFrame_OpenFlags flags; -} LocationPlus; - -BONOBO_CLASS_BOILERPLATE_FULL (NautilusView, nautilus_view, Nautilus_View, - BonoboObject, BONOBO_OBJECT_TYPE) - -static void -queue_incoming_call (PortableServer_Servant servant, - ViewFunction call, - gpointer callback_data, - GDestroyNotify destroy_callback_data) -{ - NautilusView *view; - - view = NAUTILUS_VIEW (bonobo_object_from_servant (servant)); - nautilus_idle_queue_add (view->details->incoming_queue, - (GFunc) call, - view, - callback_data, - destroy_callback_data); -} - -static void -queue_outgoing_call (NautilusView *view, - ViewFunction call, - gpointer callback_data, - GDestroyNotify destroy_callback_data) -{ - g_return_if_fail (NAUTILUS_IS_VIEW (view)); - - nautilus_idle_queue_add (view->details->outgoing_queue, - (GFunc) call, - view, - callback_data, - destroy_callback_data); -} - -GList * -nautilus_g_list_from_uri_list (const Nautilus_URIList *uri_list) -{ - GList *list; - guint i; - - list = NULL; - for (i = 0; i < uri_list->_length; i++) { - list = g_list_prepend - (list, g_strdup (uri_list->_buffer[i])); - } - return g_list_reverse (list); -} - -/* Must CORBA_free this list before destroying the URI's in - * the source list. - */ -Nautilus_URIList * -nautilus_uri_list_from_g_list (GList *list) -{ - int length; - Nautilus_URIList *uri_list; - int i; - GList *p; - - length = g_list_length (list); - - uri_list = Nautilus_URIList__alloc (); - uri_list->_maximum = length; - uri_list->_length = length; - uri_list->_buffer = CORBA_sequence_Nautilus_URI_allocbuf (length); - for (i = 0, p = list; i < length; i++, p = p->next) { - g_assert (p != NULL); - uri_list->_buffer[i] = CORBA_string_dup (p->data); - } - CORBA_sequence_set_release (uri_list, CORBA_TRUE); - - return uri_list; -} - -static void -call_load_location (NautilusView *view, - gpointer callback_data) -{ - g_signal_emit (view, - signals[LOAD_LOCATION], 0, - callback_data); -} - -static void -call_stop_loading (NautilusView *view, - gpointer callback_data) -{ - g_signal_emit (view, - signals[STOP_LOADING], 0); -} - -static void -call_selection_changed (NautilusView *view, - gpointer callback_data) -{ - g_signal_emit (view, - signals[SELECTION_CHANGED], 0, - callback_data); -} - -static void -call_title_changed (NautilusView *view, - gpointer callback_data) -{ - g_signal_emit (view, - signals[TITLE_CHANGED], 0, - callback_data); -} - -static void -call_history_changed (NautilusView *view, - gpointer callback_data) -{ - g_signal_emit (view, - signals[HISTORY_CHANGED], 0, - callback_data); -} - -static void -call_show_hidden_files_mode_changed (NautilusView *view, - gpointer callback_data) -{ - view->details->have_show_hidden_files_mode = FALSE; - g_signal_emit (view, - signals[SHOW_HIDDEN_FILES_MODE_CHANGED], 0, - callback_data); -} - - -static void -list_deep_free_cover (gpointer callback_data) -{ - gnome_vfs_list_deep_free (callback_data); -} - -static Nautilus_History * -history_dup (const Nautilus_History *history) -{ - Nautilus_History *dup; - int length, i; - - length = history->_length; - - dup = Nautilus_History__alloc (); - dup->_maximum = length; - dup->_length = length; - dup->_buffer = CORBA_sequence_Nautilus_HistoryItem_allocbuf (length); - for (i = 0; i < length; i++) { - dup->_buffer[i].title = CORBA_string_dup (history->_buffer[i].title); - dup->_buffer[i].location = CORBA_string_dup (history->_buffer[i].location); - } - CORBA_sequence_set_release (dup, CORBA_TRUE); - - return dup; -} - -static void -impl_Nautilus_View_load_location (PortableServer_Servant servant, - const CORBA_char *location, - CORBA_Environment *ev) -{ - queue_incoming_call (servant, - call_load_location, - g_strdup (location), - g_free); -} - -static void -impl_Nautilus_View_stop_loading (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - queue_incoming_call (servant, - call_stop_loading, - NULL, - NULL); -} - -static void -nautilus_view_frame_property_changed_callback (BonoboListener *listener, - const char *event_name, - const CORBA_any *any, - CORBA_Environment *ev, - gpointer user_data) -{ - NautilusView *view; - ViewFunction callback; - gpointer callback_data; - GDestroyNotify destroy_callback_data; - - view = NAUTILUS_VIEW (user_data); - - if (strcmp (event_name, "Bonobo/Property:change:title") == 0) { - callback = call_title_changed; - callback_data = g_strdup (BONOBO_ARG_GET_STRING (any)); - destroy_callback_data = g_free; - } else if (strcmp (event_name, "Bonobo/Property:change:history") == 0) { - callback = call_history_changed; - callback_data = history_dup (any->_value); - destroy_callback_data = CORBA_free; - } else if (strcmp (event_name, "Bonobo/Property:change:selection") == 0) { - callback = call_selection_changed; - callback_data = nautilus_g_list_from_uri_list (any->_value); - destroy_callback_data = list_deep_free_cover; - } else if (strcmp (event_name, "Bonobo/Property:change:show-hidden-files-mode") == 0) { - callback = call_show_hidden_files_mode_changed; - callback_data = NULL; - destroy_callback_data = NULL; - } else { - g_warning ("Unknown event '%s'", event_name); - return; - } - - nautilus_idle_queue_add (view->details->incoming_queue, - (GFunc) callback, - view, - callback_data, - destroy_callback_data); -} - -static void -remove_listener (NautilusView *view) -{ - BonoboListener *listener; - Bonobo_EventSource es; - CORBA_Environment ev; - - listener = view->details->listener; - if (listener == NULL) { - g_assert (view->details->listener_event_source == CORBA_OBJECT_NIL); - return; - } - - es = view->details->listener_event_source; - - view->details->listener = NULL; - view->details->listener_event_source = CORBA_OBJECT_NIL; - - CORBA_exception_init (&ev); - - bonobo_event_source_client_remove_listener (es, BONOBO_OBJREF (listener), &ev); - - CORBA_Object_release (es, &ev); - bonobo_object_unref (listener); - - CORBA_exception_free (&ev); -} - -static void -append_mask (GString *str, const char *mask_element) -{ - if (str->len != 0) { - g_string_append_c (str, ','); - } - g_string_append (str, mask_element); -} - -static void -update_listener (NautilusView *view) -{ - BonoboListener *listener; - CORBA_Environment ev; - Bonobo_EventSource es; - Bonobo_PropertyBag pbag; - GString *mask; - - remove_listener (view); - - if (view->details->listener_mask == 0) { - return; - } - - pbag = nautilus_view_get_ambient_properties (view, NULL); - if (pbag == CORBA_OBJECT_NIL) { - return; - } - - CORBA_exception_init (&ev); - - es = Bonobo_Unknown_queryInterface (pbag, "IDL:Bonobo/EventSource:1.0", &ev); - if (BONOBO_EX (&ev)) { - es = CORBA_OBJECT_NIL; - } - if (es == CORBA_OBJECT_NIL) { - g_warning ("Contractual breakage - NautilusViewFrame's " - "ambient property bag has no event source"); - goto failed; - } - - listener = bonobo_listener_new (nautilus_view_frame_property_changed_callback, view); - - mask = g_string_sized_new (128); - if (view->details->listener_mask & NAUTILUS_VIEW_LISTEN_TITLE) { - append_mask (mask, "Bonobo/Property:change:title"); - } - if (view->details->listener_mask & NAUTILUS_VIEW_LISTEN_HISTORY) { - append_mask (mask, "Bonobo/Property:change:history"); - } - if (view->details->listener_mask & NAUTILUS_VIEW_LISTEN_SELECTION) { - append_mask (mask, "Bonobo/Property:change:selection"); - } - if (view->details->listener_mask & NAUTILUS_VIEW_LISTEN_SHOW_HIDDEN_FILES_MODE) { - append_mask (mask, "Bonobo/Property:change:show-hidden-files-mode"); - } - - Bonobo_EventSource_addListenerWithMask (es, BONOBO_OBJREF (listener), mask->str, &ev); - - g_string_free (mask, TRUE); - - view->details->listener = listener; - view->details->listener_event_source = es; - - Bonobo_Unknown_unref (es, &ev); - - failed: - bonobo_object_release_unref (pbag, NULL); - CORBA_exception_free (&ev); -} - -static void -forget_cached_view_frame (NautilusView *view) -{ - CORBA_Object_release (view->details->cached_view_frame, NULL); - view->details->cached_view_frame = CORBA_OBJECT_NIL; -} - -static void -nautilus_view_set_frame_callback (BonoboControl *control, - NautilusView *view) -{ - g_return_if_fail (NAUTILUS_IS_VIEW (view)); - - forget_cached_view_frame (view); - update_listener (view); -} - -static void -nautilus_view_instance_init (NautilusView *view) -{ - view->details = g_new0 (NautilusViewDetails, 1); - - view->details->incoming_queue = nautilus_idle_queue_new (); - view->details->outgoing_queue = nautilus_idle_queue_new (); -} - -NautilusView * -nautilus_view_new (GtkWidget *widget) -{ - g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); - - return nautilus_view_new_from_bonobo_control (bonobo_control_new (widget)); -} - -NautilusView * -nautilus_view_new_from_bonobo_control (BonoboControl *control) -{ - g_return_val_if_fail (BONOBO_IS_CONTROL (control), NULL); - - return nautilus_view_construct_from_bonobo_control - (NAUTILUS_VIEW (g_object_new (NAUTILUS_TYPE_VIEW, NULL)), control); -} - -NautilusView * -nautilus_view_construct (NautilusView *view, - GtkWidget *widget) -{ - g_return_val_if_fail (NAUTILUS_IS_VIEW (view), view); - g_return_val_if_fail (GTK_IS_WIDGET (widget), view); - - return nautilus_view_construct_from_bonobo_control - (view, bonobo_control_new (widget)); -} - -NautilusView * -nautilus_view_construct_from_bonobo_control (NautilusView *view, - BonoboControl *control) -{ - g_return_val_if_fail (NAUTILUS_IS_VIEW (view), view); - g_return_val_if_fail (BONOBO_IS_CONTROL (control), view); - - view->details->control = control; - bonobo_object_add_interface (BONOBO_OBJECT (view), BONOBO_OBJECT (control)); - nautilus_undo_set_up_bonobo_control (control); - - g_signal_connect_object (control, "set_frame", - G_CALLBACK (nautilus_view_set_frame_callback), view, 0); - - return view; -} - -static void -nautilus_view_finalize (GObject *object) -{ - NautilusView *view; - - view = NAUTILUS_VIEW (object); - - forget_cached_view_frame (view); - remove_listener (view); - - nautilus_idle_queue_destroy (view->details->incoming_queue); - nautilus_idle_queue_destroy (view->details->outgoing_queue); - - g_free (view->details); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -nautilus_view_dispose (GObject *object) -{ - NautilusView *view; - - view = NAUTILUS_VIEW (object); - - forget_cached_view_frame (view); - remove_listener (view); - - GNOME_CALL_PARENT (G_OBJECT_CLASS, dispose, (object)); -} - -static Nautilus_ViewFrame -nautilus_view_get_view_frame (NautilusView *view, CORBA_Environment *ev) -{ - Nautilus_ViewFrame view_frame; - Bonobo_ControlFrame control_frame; - - g_return_val_if_fail (NAUTILUS_IS_VIEW (view), CORBA_OBJECT_NIL); - - if (view->details->cached_view_frame == CORBA_OBJECT_NIL) { - control_frame = bonobo_control_get_control_frame (view->details->control, ev); - if (! BONOBO_EX (ev) && control_frame != CORBA_OBJECT_NIL) { - view_frame = Bonobo_Unknown_queryInterface - (control_frame, "IDL:Nautilus/ViewFrame:1.0", ev); - if (! BONOBO_EX (ev) && view_frame != CORBA_OBJECT_NIL) { - Bonobo_Unknown_unref (view_frame, ev); - view->details->cached_view_frame = view_frame; - } - - CORBA_Object_release (control_frame, ev); - } - } - - return CORBA_Object_duplicate (view->details->cached_view_frame, ev); -} - -static Nautilus_ViewFrame -view_frame_call_begin (NautilusView *view, CORBA_Environment *ev) -{ - CORBA_exception_init (ev); - - return nautilus_view_get_view_frame (view, ev); -} - -static void -view_frame_call_end (Nautilus_ViewFrame frame, CORBA_Environment *ev) -{ - if (frame != CORBA_OBJECT_NIL) { - CORBA_Object_release (frame, NULL); - } - - CORBA_exception_free (ev); -} - -/* don't use the one in eel to avoid creating a dependency on eel */ -static GList * -str_list_copy (GList *original) -{ - GList *copy, *node; - - copy = NULL; - for (node = original; node != NULL; node = node->next) { - copy = g_list_prepend (copy, g_strdup (node->data)); - } - return g_list_reverse (copy); -} - -static void -list_free_deep_callback (gpointer callback_data) -{ - gnome_vfs_list_deep_free (callback_data); -} - -static void -free_location_plus_callback (gpointer callback_data) -{ - LocationPlus *location_plus; - - location_plus = callback_data; - g_free (location_plus->from_location); - g_free (location_plus->location); - gnome_vfs_list_deep_free (location_plus->selection); - g_free (location_plus->title); - g_free (location_plus); -} - -static void -call_open_location (NautilusView *view, - gpointer callback_data) -{ - LocationPlus *location_plus; - CORBA_Environment ev; - Nautilus_ViewFrame view_frame; - Nautilus_URIList *uri_list; - - location_plus = callback_data; - - view_frame = view_frame_call_begin (view, &ev); - if (view_frame != CORBA_OBJECT_NIL) { - uri_list = nautilus_uri_list_from_g_list (location_plus->selection); - Nautilus_ViewFrame_open_location - (view_frame, location_plus->location, location_plus->mode, location_plus->flags, uri_list, &ev); - CORBA_free (uri_list); - } - view_frame_call_end (view_frame, &ev); -} - - -static void -call_report_location_change (NautilusView *view, - gpointer callback_data) -{ - LocationPlus *location_plus; - CORBA_Environment ev; - Nautilus_ViewFrame view_frame; - Nautilus_URIList *uri_list; - - location_plus = callback_data; - - view_frame = view_frame_call_begin (view, &ev); - if (view_frame != CORBA_OBJECT_NIL) { - uri_list = nautilus_uri_list_from_g_list (location_plus->selection); - Nautilus_ViewFrame_report_location_change - (view_frame, - location_plus->location, - uri_list, - location_plus->title, - &ev); - CORBA_free (uri_list); - } - view_frame_call_end (view_frame, &ev); -} - -static void -call_report_redirect (NautilusView *view, - gpointer callback_data) -{ - LocationPlus *location_plus; - CORBA_Environment ev; - Nautilus_ViewFrame view_frame; - Nautilus_URIList *uri_list; - - location_plus = callback_data; - - view_frame = view_frame_call_begin (view, &ev); - if (view_frame != CORBA_OBJECT_NIL) { - uri_list = nautilus_uri_list_from_g_list (location_plus->selection); - Nautilus_ViewFrame_report_redirect - (view_frame, - location_plus->from_location, - location_plus->location, - uri_list, - location_plus->title, - &ev); - CORBA_free (uri_list); - } - view_frame_call_end (view_frame, &ev); -} - -static void -call_report_selection_change (NautilusView *view, - gpointer callback_data) -{ - CORBA_Environment ev; - Nautilus_ViewFrame view_frame; - Nautilus_URIList *uri_list; - - view_frame = view_frame_call_begin (view, &ev); - if (view_frame != CORBA_OBJECT_NIL) { - uri_list = nautilus_uri_list_from_g_list (callback_data); - Nautilus_ViewFrame_report_selection_change (view_frame, uri_list, &ev); - CORBA_free (uri_list); - } - view_frame_call_end (view_frame, &ev); -} - -static void -call_report_status (NautilusView *view, - gpointer callback_data) -{ - CORBA_Environment ev; - Nautilus_ViewFrame view_frame; - - view_frame = view_frame_call_begin (view, &ev); - if (view_frame != CORBA_OBJECT_NIL) { - Nautilus_ViewFrame_report_status (view_frame, callback_data, &ev); - } - view_frame_call_end (view_frame, &ev); -} - -static void -call_report_load_underway (NautilusView *view, - gpointer callback_data) -{ - CORBA_Environment ev; - Nautilus_ViewFrame view_frame; - - view_frame = view_frame_call_begin (view, &ev); - if (view_frame != CORBA_OBJECT_NIL) { - Nautilus_ViewFrame_report_load_underway (view_frame, &ev); - } - view_frame_call_end (view_frame, &ev); -} - -static void -call_report_load_progress (NautilusView *view, - gpointer callback_data) -{ - CORBA_Environment ev; - Nautilus_ViewFrame view_frame; - - view_frame = view_frame_call_begin (view, &ev); - if (view_frame != CORBA_OBJECT_NIL) { - Nautilus_ViewFrame_report_load_progress - (view_frame, * (double *) callback_data, &ev); - } - view_frame_call_end (view_frame, &ev); -} - -static void -call_report_load_complete (NautilusView *view, - gpointer callback_data) -{ - CORBA_Environment ev; - Nautilus_ViewFrame view_frame; - - view_frame = view_frame_call_begin (view, &ev); - if (view_frame != CORBA_OBJECT_NIL) { - Nautilus_ViewFrame_report_load_complete (view_frame, &ev); - } - view_frame_call_end (view_frame, &ev); -} - -static void -call_report_load_failed (NautilusView *view, - gpointer callback_data) -{ - CORBA_Environment ev; - Nautilus_ViewFrame view_frame; - - view_frame = view_frame_call_begin (view, &ev); - if (view_frame != CORBA_OBJECT_NIL) { - Nautilus_ViewFrame_report_load_failed (view_frame, &ev); - } - view_frame_call_end (view_frame, &ev); -} - -static void -call_set_title (NautilusView *view, - gpointer callback_data) -{ - CORBA_Environment ev; - Nautilus_ViewFrame view_frame; - - view_frame = view_frame_call_begin (view, &ev); - if (view_frame != CORBA_OBJECT_NIL) { - Nautilus_ViewFrame_set_title (view_frame, callback_data, &ev); - } - view_frame_call_end (view_frame, &ev); -} - -static void -call_set_show_hidden_files_mode (NautilusView *view, - gpointer callback_data) -{ - CORBA_Environment ev; - Nautilus_ViewFrame view_frame; - - view_frame = view_frame_call_begin (view, &ev); - if (view_frame != CORBA_OBJECT_NIL) { - Nautilus_ViewFrame_set_show_hidden_files_mode (view_frame, * (Nautilus_ShowHiddenFilesMode *) callback_data, &ev); - } - view_frame_call_end (view_frame, &ev); -} - -static void -call_go_back (NautilusView *view, - gpointer callback_data) -{ - CORBA_Environment ev; - Nautilus_ViewFrame view_frame; - - view_frame = view_frame_call_begin (view, &ev); - if (view_frame != CORBA_OBJECT_NIL) { - Nautilus_ViewFrame_go_back (view_frame, &ev); - } - view_frame_call_end (view_frame, &ev); -} - - -static void -call_close_window (NautilusView *view, - gpointer callback_data) -{ - CORBA_Environment ev; - Nautilus_ViewFrame view_frame; - - view_frame = view_frame_call_begin (view, &ev); - if (view_frame != CORBA_OBJECT_NIL) { - Nautilus_ViewFrame_close_window (view_frame, &ev); - } - view_frame_call_end (view_frame, &ev); -} - -void -nautilus_view_open_location (NautilusView *view, - const char *location, - Nautilus_ViewFrame_OpenMode mode, - Nautilus_ViewFrame_OpenFlags flags, - GList *selection) -{ - LocationPlus *location_plus; - - location_plus = g_new0 (LocationPlus, 1); - location_plus->location = g_strdup (location); - location_plus->selection = str_list_copy (selection); - location_plus->mode = mode; - location_plus->flags = flags; - - queue_outgoing_call (view, - call_open_location, - location_plus, - free_location_plus_callback); -} - -void -nautilus_view_report_location_change (NautilusView *view, - const char *location, - GList *selection, - const char *title) -{ - LocationPlus *location_plus; - - location_plus = g_new0 (LocationPlus, 1); - location_plus->location = g_strdup (location); - location_plus->selection = str_list_copy (selection); - location_plus->title = g_strdup (title); - - queue_outgoing_call (view, - call_report_location_change, - location_plus, - free_location_plus_callback); -} - -void -nautilus_view_report_redirect (NautilusView *view, - const char *from_location, - const char *to_location, - GList *selection, - const char *title) -{ - LocationPlus *location_plus; - - location_plus = g_new0 (LocationPlus, 1); - location_plus->from_location = g_strdup (from_location); - location_plus->location = g_strdup (to_location); - location_plus->selection = str_list_copy (selection); - location_plus->title = g_strdup (title); - - queue_outgoing_call (view, - call_report_redirect, - location_plus, - free_location_plus_callback); -} - -void -nautilus_view_report_selection_change (NautilusView *view, - GList *selection) -{ - queue_outgoing_call (view, - call_report_selection_change, - str_list_copy (selection), - list_free_deep_callback); -} - -void -nautilus_view_report_status (NautilusView *view, - const char *status) -{ - queue_outgoing_call (view, - call_report_status, - g_strdup (status), - g_free); -} - -void -nautilus_view_report_load_underway (NautilusView *view) -{ - queue_outgoing_call (view, - call_report_load_underway, - NULL, - NULL); -} - -void -nautilus_view_report_load_progress (NautilusView *view, - double fraction_done) -{ - queue_outgoing_call (view, - call_report_load_progress, - g_memdup (&fraction_done, sizeof (double)), - g_free); -} - -void -nautilus_view_report_load_complete (NautilusView *view) -{ - queue_outgoing_call (view, - call_report_load_complete, - NULL, - NULL); -} - -void -nautilus_view_report_load_failed (NautilusView *view) -{ - queue_outgoing_call (view, - call_report_load_failed, - NULL, - NULL); -} - -void -nautilus_view_set_title (NautilusView *view, - const char *title) -{ - queue_outgoing_call (view, - call_set_title, - g_strdup (title), - g_free); -} - -void -nautilus_view_set_show_hidden_files_mode (NautilusView *view, - Nautilus_ShowHiddenFilesMode mode) -{ - view->details->have_show_hidden_files_mode = TRUE; - view->details->show_hidden_files_mode = mode; - - queue_outgoing_call (view, - call_set_show_hidden_files_mode, - g_memdup (&mode, sizeof (Nautilus_ShowHiddenFilesMode)), - g_free); -} - -void -nautilus_view_go_back (NautilusView *view) -{ - queue_outgoing_call (view, - call_go_back, - NULL, - NULL); -} - -void -nautilus_view_close_window (NautilusView *view) -{ - queue_outgoing_call (view, - call_close_window, - NULL, - NULL); -} - -BonoboControl * -nautilus_view_get_bonobo_control (NautilusView *view) -{ - g_return_val_if_fail (NAUTILUS_IS_VIEW (view), NULL); - - return view->details->control; -} - -BonoboUIComponent * -nautilus_view_set_up_ui (NautilusView *view, - const char *datadir, - const char *ui_file_name, - const char *application_name) -{ - BonoboUIComponent *ui_component; - Bonobo_UIContainer ui_container; - - /* Get the UI component that's pre-made by the control. */ - ui_component = bonobo_control_get_ui_component (view->details->control); - - /* Connect the UI component to the control frame's UI container. */ - ui_container = bonobo_control_get_remote_ui_container (view->details->control, NULL); - bonobo_ui_component_set_container (ui_component, ui_container, NULL); - bonobo_object_release_unref (ui_container, NULL); - - /* Set up the UI from an XML file. */ - bonobo_ui_util_set_ui (ui_component, datadir, ui_file_name, application_name, NULL); - - return ui_component; -} - -static void -nautilus_view_class_init (NautilusViewClass *class) -{ - G_OBJECT_CLASS (class)->finalize = nautilus_view_finalize; - G_OBJECT_CLASS (class)->dispose = nautilus_view_dispose; - - signals[LOAD_LOCATION] = - g_signal_new ("load_location", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusViewClass, load_location), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, G_TYPE_STRING); - signals[STOP_LOADING] = - g_signal_new ("stop_loading", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusViewClass, stop_loading), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - signals[SELECTION_CHANGED] = - g_signal_new ("selection_changed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusViewClass, selection_changed), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); - signals[TITLE_CHANGED] = - g_signal_new ("title_changed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusViewClass, title_changed), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, G_TYPE_STRING); - signals[HISTORY_CHANGED] = - g_signal_new ("history_changed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusViewClass, history_changed), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); - signals[SHOW_HIDDEN_FILES_MODE_CHANGED] = - g_signal_new ("show_hidden_files_mode_changed", - G_TYPE_FROM_CLASS (class), - G_SIGNAL_RUN_LAST, - 0, /* No offset to keep binary compat */ - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - class->epv.load_location = impl_Nautilus_View_load_location; - class->epv.stop_loading = impl_Nautilus_View_stop_loading; -} - -Bonobo_PropertyBag -nautilus_view_get_ambient_properties (NautilusView *view, - CORBA_Environment *opt_ev) -{ - g_return_val_if_fail (NAUTILUS_IS_VIEW (view), NULL); - - return bonobo_control_get_ambient_properties (view->details->control, opt_ev); -} - -void -nautilus_view_set_listener_mask (NautilusView *view, - NautilusViewListenerMask mask) -{ - g_return_if_fail (NAUTILUS_IS_VIEW (view)); - - view->details->listener_mask = mask; - update_listener (view); -} - -Nautilus_WindowType -nautilus_view_get_window_type (NautilusView *view) -{ - Bonobo_PropertyBag bag; - BonoboArg *arg; - CORBA_Environment ev; - - if (view->details->have_window_type) { - return view->details->window_type; - } - - view->details->have_window_type = TRUE; - - CORBA_exception_init (&ev); - - bag = nautilus_view_get_ambient_properties (view, &ev); - - view->details->window_type = Nautilus_WINDOW_SPATIAL; - - if (!BONOBO_EX (&ev)) { - arg = Bonobo_PropertyBag_getValue (bag, "window-type", &ev); - - if (!BONOBO_EX (&ev)) { - view->details->window_type = BONOBO_ARG_GET_GENERAL (arg, - TC_Nautilus_WindowType, - Nautilus_WindowType, - NULL); - CORBA_free (arg); - } else { - g_warning ("Window type not found in view frame properties."); - } - - bonobo_object_release_unref (bag, &ev); - } else { - g_warning ("Couldn't get ambient properties for the view frame."); - } - CORBA_exception_free (&ev); - - return view->details->window_type; -} - -Nautilus_ShowHiddenFilesMode -nautilus_view_get_show_hidden_files_mode (NautilusView *view) -{ - Bonobo_PropertyBag bag; - BonoboArg *arg; - CORBA_Environment ev; - - if (view->details->have_show_hidden_files_mode) { - return view->details->show_hidden_files_mode; - } - - - CORBA_exception_init (&ev); - - bag = nautilus_view_get_ambient_properties (view, &ev); - - view->details->show_hidden_files_mode = Nautilus_SHOW_HIDDEN_FILES_DEFAULT; - - if (!BONOBO_EX (&ev)) { - arg = Bonobo_PropertyBag_getValue (bag, "show-hidden-files-mode", &ev); - - if (!BONOBO_EX (&ev)) { - view->details->show_hidden_files_mode = BONOBO_ARG_GET_GENERAL - (arg, - TC_Nautilus_ShowHiddenFilesMode, - Nautilus_ShowHiddenFilesMode, - NULL); - CORBA_free (arg); - } else { - g_warning ("Show Hidden Files Mode not found in view frame properties."); - } - - bonobo_object_release_unref (bag, &ev); - } else { - g_warning ("Couldn't get ambient properties for the view frame."); - } - CORBA_exception_free (&ev); - - view->details->have_show_hidden_files_mode = TRUE; - return view->details->show_hidden_files_mode; -} diff --git a/libnautilus/nautilus-view.h b/libnautilus/nautilus-view.h deleted file mode 100644 index 5e6818759..000000000 --- a/libnautilus/nautilus-view.h +++ /dev/null @@ -1,141 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */ - -/* - * libnautilus: A library for nautilus view implementations. - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 2000 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Authors: Elliot Lee <sopwith@redhat.com> - * Maciej Stachowiak <mjs@eazel.com> - * Darin Adler <darin@bentspoon.com> - * - */ - -#ifndef NAUTILUS_VIEW_H -#define NAUTILUS_VIEW_H - -#include <libnautilus/nautilus-view-component.h> -#include <bonobo/bonobo-control.h> - -G_BEGIN_DECLS - -#define NAUTILUS_TYPE_VIEW (nautilus_view_get_type ()) -#define NAUTILUS_VIEW(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_VIEW, NautilusView)) -#define NAUTILUS_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_VIEW, NautilusViewClass)) -#define NAUTILUS_IS_VIEW(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_VIEW)) -#define NAUTILUS_IS_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_VIEW)) - -typedef struct NautilusViewDetails NautilusViewDetails; - -typedef struct { - BonoboObject parent_spot; - NautilusViewDetails *details; -} NautilusView; - -typedef struct { - BonoboObjectClass parent_spot; - POA_Nautilus_View__epv epv; - - void (* load_location) (NautilusView *view, - const char *location_uri); - void (* stop_loading) (NautilusView *view); - - /* These signals need to be enabled with nautilus_view_set_listener_mask */ - void (* title_changed) (NautilusView *view, - const char *title); - void (* history_changed) (NautilusView *view, - const Nautilus_History *history); - void (* selection_changed) (NautilusView *view, - GList *selection); -} NautilusViewClass; - -GType nautilus_view_get_type (void); -NautilusView * nautilus_view_new (GtkWidget *widget); -NautilusView * nautilus_view_new_from_bonobo_control (BonoboControl *bonobo_control); -BonoboControl * nautilus_view_get_bonobo_control (NautilusView *view); - -/* Calls to the Nautilus shell via the view frame. See the IDL for detailed comments. */ -void nautilus_view_open_location (NautilusView *view, - const char *location_uri, - Nautilus_ViewFrame_OpenMode mode, - Nautilus_ViewFrame_OpenFlags flags, - GList *selection); -void nautilus_view_report_location_change (NautilusView *view, - const char *location_uri, - GList *selection, /* list of URI char *s */ - const char *title); -void nautilus_view_report_redirect (NautilusView *view, - const char *from_location_uri, - const char *to_location_uri, - GList *selection, /* list of URI char *s */ - const char *title); -void nautilus_view_report_selection_change (NautilusView *view, - GList *selection); /* list of URI char *s */ -void nautilus_view_report_status (NautilusView *view, - const char *status); -void nautilus_view_report_load_underway (NautilusView *view); -void nautilus_view_report_load_progress (NautilusView *view, - double fraction_done); -void nautilus_view_report_load_complete (NautilusView *view); -void nautilus_view_report_load_failed (NautilusView *view); -void nautilus_view_set_title (NautilusView *view, - const char *title); -void nautilus_view_go_back (NautilusView *view); -void nautilus_view_close_window (NautilusView *view); - -/* call from the view component to indicate a change in this setting has occured*/ -void nautilus_view_set_show_hidden_files_mode (NautilusView *view, - Nautilus_ShowHiddenFilesMode mode); - -/* Some utility functions useful for doing the CORBA work directly. - * Not needed by most components, but shared with the view frame code, - * which is why they are public. - */ -Nautilus_URIList * nautilus_uri_list_from_g_list (GList *list); -GList * nautilus_g_list_from_uri_list (const Nautilus_URIList *uri_list); - -/* Simpler API for setting up and getting the UI component. */ -BonoboUIComponent *nautilus_view_set_up_ui (NautilusView *view, - const char *datadir, - const char *ui_xml_file_name, - const char *application_name); - - -typedef enum { - NAUTILUS_VIEW_LISTEN_TITLE = 1<<0, - NAUTILUS_VIEW_LISTEN_HISTORY = 1<<1, - NAUTILUS_VIEW_LISTEN_SELECTION = 1<<2, - NAUTILUS_VIEW_LISTEN_SHOW_HIDDEN_FILES_MODE = 1<<3 -} NautilusViewListenerMask; - -Bonobo_PropertyBag nautilus_view_get_ambient_properties (NautilusView *view, - CORBA_Environment *opt_ev); -void nautilus_view_set_listener_mask (NautilusView *view, - NautilusViewListenerMask mask); -Nautilus_WindowType nautilus_view_get_window_type (NautilusView *view); -Nautilus_ShowHiddenFilesMode nautilus_view_get_show_hidden_files_mode (NautilusView *view); - -/* `protected' functions for use by subclasses only. */ -NautilusView * nautilus_view_construct (NautilusView *view, - GtkWidget *widget); -NautilusView * nautilus_view_construct_from_bonobo_control (NautilusView *view, - BonoboControl *bonobo_control); - -G_END_DECLS - -#endif /* NAUTILUS_VIEW_H */ |