diff options
109 files changed, 287 insertions, 12469 deletions
@@ -1,3 +1,60 @@ +2000-05-27 Maciej Stachowiak <set EMAIL_ADDRESS environment variable> + + * Renamed files as follows, as per RENAMING: + components/history/ntl-history-view.c -> components/history/nautilus-history-view.c + components/history/ntl-history-view.oafinfo -> components/history/nautilus-history-view.oafinfo + components/notes/ntl-notes.c -> components/notes/nautilus-notes.c + components/notes/ntl-notes.oafinfo -> components/notes/nautilus-notes.oafinfo + libnautilus-extensions/gtkscrollframe.c -> libnautilus-extensions/nautilus-scroll-frame.c + libnautilus-extensions/gtkscrollframe.h -> libnautilus-extensions/nautilus-scroll-frame.h + libnautilus/nautilus-view-frame.c -> libnautilus/nautilus-view.c + libnautilus/nautilus-view-frame.h -> libnautilus/nautilus-view.h + src/nautilus-index-tabs.c -> src/nautilus-sidebar-tabs.c + src/nautilus-index-tabs.h -> src/nautilus-sidebar-tabs.h + src/nautilus-index-title.c -> src/nautilus-sidebar-title.c + src/nautilus-index-title.h -> src/nautilus-sidebar-title.h + src/nautilus-zoomable-frame-svr.c -> src/nautilus-zoomable-frame-corba.c + src/ntl-app.c -> src/nautilus-application.c + src/ntl-app.h -> src/nautilus-application.h + src/ntl-index-panel.c -> src/nautilus-sidebar.c + src/ntl-index-panel.h -> src/nautilus-sidebar.h + src/ntl-main.c -> src/nautilus-main.c + src/ntl-miniicon.c -> libnautilus-extensions/nautilus-mini-icon.c + src/ntl-miniicon.h -> libnautilus-extensions/nautilus-mini-icon.h + src/ntl-uri-map.c -> src/nautilus-applicable-views.c + src/ntl-uri-map.h -> src/nautilus-applicable-views.h + src/ntl-view-bonobo-control.c -> src/nautilus-view-frame-bonobo-control.c + src/ntl-view-bonobo-subdoc.c -> src/nautilus-view-frame-bonobo-embeddable.c + src/ntl-view-frame-svr.c -> src/nautilus-view-frame-corba.c + src/ntl-view-nautilus.c -> src/nautilus-view-frame-nautilus-view.c + src/ntl-view-private.h -> src/nautilus-view-frame-private.h + src/ntl-view.c -> src/nautilus-view-frame.c + src/ntl-view.h -> src/nautilus-view-frame.h + src/ntl-window-msgs.c -> src/nautilus-window-manage-views.c + src/ntl-window-msgs.h -> src/nautilus-window-manage-views.h + src/ntl-window-private.h -> src/nautilus-window-private.h + src/ntl-window-state.c -> src/nautilus-window-state.c + src/ntl-window-state.h -> src/nautilus-window-state.h + src/ntl-window.c -> src/nautilus-window.c + src/ntl-window.h -> src/nautilus-window.h + + * components/history/Makefile.am, components/notes/Makefile.am, + libnautilus-extensions/Makefile.am, libnautilus/Makefile.am, + po/POTFILES.in, src/Makefile.am, + components/hardware/nautilus-hardware-view.h, + components/loser/content/nautilus-content-loser.h, + components/loser/sidebar/nautilus-sidebar-loser.h, + components/mozilla/nautilus-mozilla-content-view.h, + components/music/nautilus-music-view.h, + components/rpmview/nautilus-rpm-view.h, + components/sample/nautilus-sample-content-view.h, + components/services/startup/nautilus-view/nautilus-service-startup-view.h, + libnautilus/libnautilus.h, src/nautilus-desktop-window.h, + src/nautilus-window-menus.c, src/nautilus-window-toolbars.c, + src/file-manager/fm-directory-view.h : Updated for renamings. + + * RENAMING: removed old renamings + 2000-05-26 Eskil Heyn Olsen <eskil@eazel.com> * nautilus-installer/Makefile: @@ -5,43 +5,9 @@ some functions and files too. ---------- file names ---------- -components/history/ntl-history-view.c -> components/history/nautilus-history-view.c -components/notes/ntl-notes.c -> components/notes/nautilus-notes.c -libnautilus-extensions/gtkscrollframe.c -> libnautilus-extensions/nautilus-scroll-frame.c -libnautilus-extensions/gtkscrollframe.h -> libnautilus-extensions/nautilus-scroll-frame.h -libnautilus/nautilus-view-frame.c -> libnautilus/nautilus-view.c -libnautilus/nautilus-view-frame.h -> libnautilus/nautilus-view.h -src/nautilus-index-tabs.c -> src/nautilus-sidebar-tabs.c -src/nautilus-index-tabs.h -> src/nautilus-sidebar-tabs.h -src/nautilus-index-title.c -> src/nautilus-sidebar-title.c -src/nautilus-index-title.h -> src/nautilus-sidebar-title.h -src/nautilus-zoomable-frame-svr.c -> src/nautilus-zoomable-frame-corba.c -src/ntl-app.c -> src/nautilus-application.c -src/ntl-app.h -> src/nautilus-application.h -src/ntl-index-panel.c -> src/nautilus-sidebar.c -src/ntl-index-panel.h -> src/nautilus-sidebar.h -src/ntl-main.c -> src/nautilus-main.c -src/ntl-miniicon.c -> libnautilus-extensions/nautilus-mini-icon.c -src/ntl-miniicon.h -> libnautilus-extensions/nautilus-mini-icon.h -src/ntl-uri-map.c -> src/nautilus-applicable-views.c -src/ntl-uri-map.h -> src/nautilus-applicable-views.h -src/ntl-view-bonobo-control.c -> src/nautilus-view-frame-bonobo-control.c -src/ntl-view-bonobo-subdoc.c -> src/nautilus-view-frame-bonobo-embeddable.c -src/ntl-view-frame-svr.c -> src/nautilus-view-frame-corba.c -src/ntl-view-nautilus.c -> src/nautilus-view-frame-nautilus-view.c -src/ntl-view-private.h -> src/nautilus-view-frame-private.h -src/ntl-view.c -> src/nautilus-view-frame.c -src/ntl-view.h -> src/nautilus-view-frame.h -src/ntl-window-msgs.c -> src/nautilus-window-manage-views.c -src/ntl-window-msgs.h -> src/nautilus-window-manage-views.h -src/ntl-window-private.h -> src/nautilus-window-private.h -src/ntl-window-state.c -> src/nautilus-window-state.c -src/ntl-window-state.h -> src/nautilus-window-state.h -src/ntl-window.c -> src/nautilus-window.c -src/ntl-window.h -> src/nautilus-window.h components/html/ntl-web-browser.c -> ? -components/websearch/ntl-web-search.c -> ? +components/websearch/ntl-web-search.c -> nautilus-web-search.c ---------------------------- classes and other data types @@ -58,5 +24,6 @@ NautilusApp -> NautilusApplication -------------- function names -------------- + nautilus_index_panel_add_meta_view -> nautilus_sidebar_add_panel nautilus_index_panel_remove_meta_view -> nautilus_sidebar_remove_panel diff --git a/components/hardware/nautilus-hardware-view.h b/components/hardware/nautilus-hardware-view.h index 54c17c706..27f32d21c 100644 --- a/components/hardware/nautilus-hardware-view.h +++ b/components/hardware/nautilus-hardware-view.h @@ -25,7 +25,7 @@ #ifndef NAUTILUS_HARDWARE_VIEW_H #define NAUTILUS_HARDWARE_VIEW_H -#include <libnautilus/nautilus-view-frame.h> +#include <libnautilus/nautilus-view.h> #include <gtk/gtkeventbox.h> diff --git a/components/history/Makefile.am b/components/history/Makefile.am index 0b2eca09e..d7c2bc499 100644 --- a/components/history/Makefile.am +++ b/components/history/Makefile.am @@ -1,4 +1,4 @@ -bin_PROGRAMS=ntl-history-view +bin_PROGRAMS=nautilus-history-view INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GNOMEUI_CFLAGS) $(GCONF_CFLAGS) $(BONOBO_CFLAGS) $(WERROR) @@ -11,8 +11,8 @@ LDADD=\ $(GCONF_LIBS) \ $(GNOMEUI_LIBS) -ntl_history_view_SOURCES=ntl-history-view.c +nautilus_history_view_SOURCES=nautilus-history-view.c oafdir=$(datadir)/oaf -oaf_DATA=ntl-history-view.oafinfo +oaf_DATA=nautilus-history-view.oafinfo EXTRA_DIST=$(oaf_DATA) diff --git a/components/history/Nautilus_View_history.oaf.in b/components/history/Nautilus_View_history.oaf.in index 20c62ee0d..579092e0a 100644 --- a/components/history/Nautilus_View_history.oaf.in +++ b/components/history/Nautilus_View_history.oaf.in @@ -1,13 +1,13 @@ <oaf_info> -<oaf_server iid="OAFIID:ntl_history_view_factory:912d6634-d18f-40b6-bb83-bdfe16f1d15e" type="exe" location="ntl-history-view"> +<oaf_server iid="OAFIID:nautilus_history_view_factory:912d6634-d18f-40b6-bb83-bdfe16f1d15e" type="exe" location="nautilus-history-view"> <oaf_attribute name="repo_ids" type="stringv"> <item value="IDL:GNOME/GenericFactory:1.0"/> </oaf_attribute> <oaf_attribute name="description" type="string" value="Factory for history views"/> </oaf_server> -<oaf_server iid="OAFIID:ntl_history_view:a7a85bdd-2ecf-4bc1-be7c-ed328a29aacb" type="factory" location="OAFIID:ntl_history_view_factory:912d6634-d18f-40b6-bb83-bdfe16f1d15e"> +<oaf_server iid="OAFIID:nautilus_history_view:a7a85bdd-2ecf-4bc1-be7c-ed328a29aacb" type="factory" location="OAFIID:nautilus_history_view_factory:912d6634-d18f-40b6-bb83-bdfe16f1d15e"> <oaf_attribute name="repo_ids" type="stringv"> <item value="IDL:Bonobo/Control:1.0"/> <item value="IDL:Bonobo/Unknown:1.0"/> diff --git a/components/history/Nautilus_View_history.server.in b/components/history/Nautilus_View_history.server.in index 20c62ee0d..579092e0a 100644 --- a/components/history/Nautilus_View_history.server.in +++ b/components/history/Nautilus_View_history.server.in @@ -1,13 +1,13 @@ <oaf_info> -<oaf_server iid="OAFIID:ntl_history_view_factory:912d6634-d18f-40b6-bb83-bdfe16f1d15e" type="exe" location="ntl-history-view"> +<oaf_server iid="OAFIID:nautilus_history_view_factory:912d6634-d18f-40b6-bb83-bdfe16f1d15e" type="exe" location="nautilus-history-view"> <oaf_attribute name="repo_ids" type="stringv"> <item value="IDL:GNOME/GenericFactory:1.0"/> </oaf_attribute> <oaf_attribute name="description" type="string" value="Factory for history views"/> </oaf_server> -<oaf_server iid="OAFIID:ntl_history_view:a7a85bdd-2ecf-4bc1-be7c-ed328a29aacb" type="factory" location="OAFIID:ntl_history_view_factory:912d6634-d18f-40b6-bb83-bdfe16f1d15e"> +<oaf_server iid="OAFIID:nautilus_history_view:a7a85bdd-2ecf-4bc1-be7c-ed328a29aacb" type="factory" location="OAFIID:nautilus_history_view_factory:912d6634-d18f-40b6-bb83-bdfe16f1d15e"> <oaf_attribute name="repo_ids" type="stringv"> <item value="IDL:Bonobo/Control:1.0"/> <item value="IDL:Bonobo/Unknown:1.0"/> diff --git a/components/history/Nautilus_View_history.server.in.in b/components/history/Nautilus_View_history.server.in.in index 20c62ee0d..579092e0a 100644 --- a/components/history/Nautilus_View_history.server.in.in +++ b/components/history/Nautilus_View_history.server.in.in @@ -1,13 +1,13 @@ <oaf_info> -<oaf_server iid="OAFIID:ntl_history_view_factory:912d6634-d18f-40b6-bb83-bdfe16f1d15e" type="exe" location="ntl-history-view"> +<oaf_server iid="OAFIID:nautilus_history_view_factory:912d6634-d18f-40b6-bb83-bdfe16f1d15e" type="exe" location="nautilus-history-view"> <oaf_attribute name="repo_ids" type="stringv"> <item value="IDL:GNOME/GenericFactory:1.0"/> </oaf_attribute> <oaf_attribute name="description" type="string" value="Factory for history views"/> </oaf_server> -<oaf_server iid="OAFIID:ntl_history_view:a7a85bdd-2ecf-4bc1-be7c-ed328a29aacb" type="factory" location="OAFIID:ntl_history_view_factory:912d6634-d18f-40b6-bb83-bdfe16f1d15e"> +<oaf_server iid="OAFIID:nautilus_history_view:a7a85bdd-2ecf-4bc1-be7c-ed328a29aacb" type="factory" location="OAFIID:nautilus_history_view_factory:912d6634-d18f-40b6-bb83-bdfe16f1d15e"> <oaf_attribute name="repo_ids" type="stringv"> <item value="IDL:Bonobo/Control:1.0"/> <item value="IDL:Bonobo/Unknown:1.0"/> diff --git a/components/history/nautilus-history-view.c b/components/history/nautilus-history-view.c index 5d35a4d68..b07d98a9f 100644 --- a/components/history/nautilus-history-view.c +++ b/components/history/nautilus-history-view.c @@ -216,7 +216,7 @@ make_obj(BonoboGenericFactory *Factory, const char *goad_id, gpointer closure) GtkCList *clist; HistoryView *hview; - g_return_val_if_fail(!strcmp(goad_id, "OAFIID:ntl_history_view:a7a85bdd-2ecf-4bc1-be7c-ed328a29aacb"), NULL); + g_return_val_if_fail(!strcmp(goad_id, "OAFIID:nautilus_history_view:a7a85bdd-2ecf-4bc1-be7c-ed328a29aacb"), NULL); hview = g_new0(HistoryView, 1); @@ -261,7 +261,7 @@ int main(int argc, char *argv[]) BonoboGenericFactory *factory; CORBA_ORB orb; - gnome_init_with_popt_table("ntl-history-view", VERSION, + gnome_init_with_popt_table("nautilus-history-view", VERSION, argc, argv, oaf_popt_options, 0, NULL); orb = oaf_init (argc, argv); @@ -276,7 +276,7 @@ int main(int argc, char *argv[]) bonobo_init(orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL); gnome_vfs_init (); - factory = bonobo_generic_factory_new_multi("OAFIID:ntl_history_view_factory:912d6634-d18f-40b6-bb83-bdfe16f1d15e", make_obj, NULL); + factory = bonobo_generic_factory_new_multi("OAFIID:nautilus_history_view_factory:912d6634-d18f-40b6-bb83-bdfe16f1d15e", make_obj, NULL); do { bonobo_main(); diff --git a/components/history/nautilus-history-view.oafinfo b/components/history/nautilus-history-view.oafinfo index 20c62ee0d..579092e0a 100644 --- a/components/history/nautilus-history-view.oafinfo +++ b/components/history/nautilus-history-view.oafinfo @@ -1,13 +1,13 @@ <oaf_info> -<oaf_server iid="OAFIID:ntl_history_view_factory:912d6634-d18f-40b6-bb83-bdfe16f1d15e" type="exe" location="ntl-history-view"> +<oaf_server iid="OAFIID:nautilus_history_view_factory:912d6634-d18f-40b6-bb83-bdfe16f1d15e" type="exe" location="nautilus-history-view"> <oaf_attribute name="repo_ids" type="stringv"> <item value="IDL:GNOME/GenericFactory:1.0"/> </oaf_attribute> <oaf_attribute name="description" type="string" value="Factory for history views"/> </oaf_server> -<oaf_server iid="OAFIID:ntl_history_view:a7a85bdd-2ecf-4bc1-be7c-ed328a29aacb" type="factory" location="OAFIID:ntl_history_view_factory:912d6634-d18f-40b6-bb83-bdfe16f1d15e"> +<oaf_server iid="OAFIID:nautilus_history_view:a7a85bdd-2ecf-4bc1-be7c-ed328a29aacb" type="factory" location="OAFIID:nautilus_history_view_factory:912d6634-d18f-40b6-bb83-bdfe16f1d15e"> <oaf_attribute name="repo_ids" type="stringv"> <item value="IDL:Bonobo/Control:1.0"/> <item value="IDL:Bonobo/Unknown:1.0"/> diff --git a/components/history/ntl-history-view.c b/components/history/ntl-history-view.c deleted file mode 100644 index 5d35a4d68..000000000 --- a/components/history/ntl-history-view.c +++ /dev/null @@ -1,286 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Elliot Lee <sopwith@redhat.com> - * - */ - -#include <config.h> - -#include <gnome.h> -#include <libnautilus/libnautilus.h> -#include <libnautilus-extensions/nautilus-bookmark.h> -#include <libnautilus-extensions/nautilus-icon-factory.h> -#include <nautilus-widgets/nautilus-preferences.h> -#include <libgnome/gnome-i18n.h> -#include <libgnomevfs/gnome-vfs-init.h> -#include <libgnomevfs/gnome-vfs-uri.h> -#include <liboaf/liboaf.h> - -typedef struct { - NautilusView *view; - - GtkCList *clist; - - gint notify_count; - - BonoboUIHandler *uih; -} HistoryView; - -#define HISTORY_VIEW_COLUMN_ICON 0 -#define HISTORY_VIEW_COLUMN_NAME 1 -#define HISTORY_VIEW_COLUMN_COUNT 2 - -static const NautilusBookmark * -get_bookmark_from_row (GtkCList *clist, int row) -{ - g_assert (NAUTILUS_IS_BOOKMARK (gtk_clist_get_row_data (clist, row))); - return NAUTILUS_BOOKMARK (gtk_clist_get_row_data (clist, row)); -} - -static const char * -get_uri_from_row (GtkCList *clist, int row) -{ - return nautilus_bookmark_get_uri (get_bookmark_from_row (clist, row)); -} - - -static void -install_icon (GtkCList *clist, gint row) -{ - GdkPixmap *pixmap; - GdkBitmap *bitmap; - const NautilusBookmark *bookmark; - - bookmark = get_bookmark_from_row (clist, row); - if (!nautilus_bookmark_get_pixmap_and_mask (bookmark, - NAUTILUS_ICON_SIZE_SMALLER, - &pixmap, - &bitmap)) - { - return; - } - - gtk_clist_set_pixmap (clist, - row, - HISTORY_VIEW_COLUMN_ICON, - pixmap, - bitmap); -} - -static void -history_view_update_icons (GtkCList *clist) -{ - int row; - - for (row = 0; row < clist->rows; ++row) - { - install_icon (clist, row); - } -} - -static void -hyperbola_navigation_history_notify_location_change (NautilusView *view, - Nautilus_NavigationInfo *loci, - HistoryView *hview) -{ - char *cols[HISTORY_VIEW_COLUMN_COUNT]; - int new_rownum; - GtkCList *clist; - NautilusBookmark *bookmark; - int i; - GnomeVFSURI *vfs_uri; - char *short_name; - - hview->notify_count++; - - clist = hview->clist; - gtk_clist_freeze(clist); - - /* FIXME bugzilla.eazel.com 206: - * Get the bookmark info from the Nautilus window instead of - * keeping a parallel mechanism here. That will get us the right - * short name for different locations. - */ - vfs_uri = gnome_vfs_uri_new (loci->requested_uri); - if (vfs_uri == NULL) { - short_name = g_strdup (loci->requested_uri); - } else { - short_name = gnome_vfs_uri_extract_short_name (vfs_uri); - gnome_vfs_uri_unref (vfs_uri); - } - bookmark = nautilus_bookmark_new (loci->requested_uri, short_name); - g_free (short_name); - - - - /* If a bookmark for this location was already in list, remove it - * (no duplicates in list, new one goes at top) - */ - for (i = 0; i < clist->rows; ++i) - { - if (nautilus_bookmark_compare_with (get_bookmark_from_row (clist, i), - bookmark) - == 0) - { - gtk_clist_remove (clist, i); - /* Since we check with each insertion, no need to check further */ - break; - } - } - - cols[HISTORY_VIEW_COLUMN_ICON] = NULL; - /* Ugh. Gotta cast away the const */ - cols[HISTORY_VIEW_COLUMN_NAME] = (char *)nautilus_bookmark_get_name (bookmark); - new_rownum = gtk_clist_prepend(clist, cols); - gtk_clist_set_row_data_full (clist, - new_rownum, - bookmark, - (GtkDestroyNotify)gtk_object_unref); - install_icon (clist, new_rownum); - - gtk_clist_columns_autosize(clist); - - if(gtk_clist_row_is_visible(clist, new_rownum) != GTK_VISIBILITY_FULL) - gtk_clist_moveto(clist, new_rownum, -1, 0.5, 0.0); - - gtk_clist_select_row(clist, new_rownum, 0); - - gtk_clist_thaw(clist); - - hview->notify_count--; -} - -static void -hyperbola_navigation_history_select_row(GtkCList *clist, gint row, gint column, GdkEvent *event, - HistoryView *hview) -{ - Nautilus_NavigationRequestInfo reqi; - - if(hview->notify_count > 0) - return; - - /* First row is always current location, by definition, so don't activate */ - if (row == 0) - return; - - /* FIXME bugzilla.eazel.com 702: There are bugs here if you drag up & down */ - - gtk_clist_freeze(clist); - - if(gtk_clist_row_is_visible(clist, row) != GTK_VISIBILITY_FULL) - gtk_clist_moveto(clist, row, -1, 0.5, 0.0); - - /* FIXME bugzilla.eazel.com 706: - * gotta cast away const because requested_uri isn't defined correctly */ - reqi.requested_uri = (char *)get_uri_from_row (clist, row); - reqi.new_window_requested = FALSE; - - nautilus_view_request_location_change(hview->view, &reqi); - - gtk_clist_thaw(clist); -} - -static int object_count = 0; - -static void -do_destroy(GtkObject *obj, HistoryView *hview) -{ - object_count--; - if(object_count <= 0) - gtk_main_quit(); -} - -static BonoboObject * -make_obj(BonoboGenericFactory *Factory, const char *goad_id, gpointer closure) -{ - GtkWidget *wtmp; - GtkCList *clist; - HistoryView *hview; - - g_return_val_if_fail(!strcmp(goad_id, "OAFIID:ntl_history_view:a7a85bdd-2ecf-4bc1-be7c-ed328a29aacb"), NULL); - - hview = g_new0(HistoryView, 1); - - /* create interface */ - clist = GTK_CLIST (gtk_clist_new (HISTORY_VIEW_COLUMN_COUNT)); - gtk_clist_column_titles_hide (clist); - gtk_clist_set_row_height (clist, NAUTILUS_ICON_SIZE_SMALLER); - gtk_clist_set_selection_mode(clist, GTK_SELECTION_BROWSE); - gtk_clist_columns_autosize(clist); - wtmp = gtk_scrolled_window_new(gtk_clist_get_hadjustment(clist), - gtk_clist_get_vadjustment(clist)); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(wtmp), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_container_add(GTK_CONTAINER(wtmp), GTK_WIDGET (clist)); - - gtk_widget_show_all(wtmp); - - /* create object */ - hview->view = nautilus_view_new (wtmp); - gtk_signal_connect (GTK_OBJECT (hview->view), "destroy", do_destroy, hview); - object_count++; - - hview->clist = (GtkCList *)clist; - - /* handle events */ - gtk_signal_connect(GTK_OBJECT(hview->view), "notify_location_change", hyperbola_navigation_history_notify_location_change, hview); - gtk_signal_connect(GTK_OBJECT(clist), "select_row", hyperbola_navigation_history_select_row, hview); - - gtk_signal_connect_object_while_alive (nautilus_icon_factory_get (), - "icons_changed", - history_view_update_icons, - GTK_OBJECT (hview->clist)); - - - return BONOBO_OBJECT (hview->view); -} - -int main(int argc, char *argv[]) -{ - gboolean preferences_succeeded; - BonoboGenericFactory *factory; - CORBA_ORB orb; - - gnome_init_with_popt_table("ntl-history-view", VERSION, - argc, argv, - oaf_popt_options, 0, NULL); - orb = oaf_init (argc, argv); - - /* FIXME bugzilla.eazel.com 672: Need better error reporting if this - * fails. But is it too early to post a dialog here? Does every user - * of NautilusPreferences have to deal with this; - */ - preferences_succeeded = nautilus_preferences_initialize (argc, argv); - g_assert (preferences_succeeded); - - bonobo_init(orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL); - gnome_vfs_init (); - - factory = bonobo_generic_factory_new_multi("OAFIID:ntl_history_view_factory:912d6634-d18f-40b6-bb83-bdfe16f1d15e", make_obj, NULL); - - do { - bonobo_main(); - } while(object_count > 0); - - return 0; -} diff --git a/components/history/ntl-history-view.oafinfo b/components/history/ntl-history-view.oafinfo deleted file mode 100644 index 20c62ee0d..000000000 --- a/components/history/ntl-history-view.oafinfo +++ /dev/null @@ -1,26 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:ntl_history_view_factory:912d6634-d18f-40b6-bb83-bdfe16f1d15e" type="exe" location="ntl-history-view"> -<oaf_attribute name="repo_ids" type="stringv"> -<item value="IDL:GNOME/GenericFactory:1.0"/> -</oaf_attribute> -<oaf_attribute name="description" type="string" value="Factory for history views"/> -</oaf_server> - -<oaf_server iid="OAFIID:ntl_history_view:a7a85bdd-2ecf-4bc1-be7c-ed328a29aacb" type="factory" location="OAFIID:ntl_history_view_factory:912d6634-d18f-40b6-bb83-bdfe16f1d15e"> -<oaf_attribute name="repo_ids" type="stringv"> -<item value="IDL:Bonobo/Control:1.0"/> -<item value="IDL:Bonobo/Unknown:1.0"/> -<item value="IDL:Nautilus/MetaView:1.0"/> -<item value="IDL:Nautilus/View:1.0"/> -</oaf_attribute> -<oaf_attribute name="description" type="string" value="History sidebar panel for Nautilus"/> -<oaf_attribute name="name" type="string" value="History sidebar panel"/> -<oaf_attribute name="nautilus:sidebar_panel_name" type="string" value="History"/> -<oaf_attribute name="nautilus:recommended_uri_schemes" type="stringv"> -<item value="*"/> -</oaf_attribute> - -</oaf_server> - -</oaf_info> diff --git a/components/loser/content/nautilus-content-loser.h b/components/loser/content/nautilus-content-loser.h index 75304cf09..71a09f2c0 100644 --- a/components/loser/content/nautilus-content-loser.h +++ b/components/loser/content/nautilus-content-loser.h @@ -28,7 +28,7 @@ #ifndef NAUTILUS_CONTENT_LOSER_H #define NAUTILUS_CONTENT_LOSER_H -#include <libnautilus/nautilus-view-frame.h> +#include <libnautilus/nautilus-view.h> #include <gtk/gtklabel.h> typedef struct NautilusContentLoser NautilusContentLoser; diff --git a/components/loser/sidebar/nautilus-sidebar-loser.h b/components/loser/sidebar/nautilus-sidebar-loser.h index e8caee1d5..602c122b4 100644 --- a/components/loser/sidebar/nautilus-sidebar-loser.h +++ b/components/loser/sidebar/nautilus-sidebar-loser.h @@ -28,7 +28,7 @@ #ifndef NAUTILUS_SIDEBAR_LOSER_H #define NAUTILUS_SIDEBAR_LOSER_H -#include <libnautilus/nautilus-view-frame.h> +#include <libnautilus/nautilus-view.h> #include <gtk/gtklabel.h> typedef struct NautilusSidebarLoser NautilusSidebarLoser; diff --git a/components/mozilla/nautilus-mozilla-content-view.h b/components/mozilla/nautilus-mozilla-content-view.h index c1bda4db4..321554f35 100644 --- a/components/mozilla/nautilus-mozilla-content-view.h +++ b/components/mozilla/nautilus-mozilla-content-view.h @@ -26,7 +26,7 @@ #ifndef NAUTILUS_MOZILLA_CONTENT_VIEW_H #define NAUTILUS_MOZILLA_CONTENT_VIEW_H -#include <libnautilus/nautilus-view-frame.h> +#include <libnautilus/nautilus-view.h> #include <gtk/gtkvbox.h> typedef struct NautilusMozillaContentView NautilusMozillaContentView; diff --git a/components/music/nautilus-music-view.h b/components/music/nautilus-music-view.h index 3406ceecf..f46a46a51 100644 --- a/components/music/nautilus-music-view.h +++ b/components/music/nautilus-music-view.h @@ -25,7 +25,7 @@ #ifndef NAUTILUS_MUSIC_VIEW_H #define NAUTILUS_MUSIC_VIEW_H -#include <libnautilus/nautilus-view-frame.h> +#include <libnautilus/nautilus-view.h> #include <gtk/gtkeventbox.h> diff --git a/components/notes/Makefile.am b/components/notes/Makefile.am index aec441838..a0f6186cb 100644 --- a/components/notes/Makefile.am +++ b/components/notes/Makefile.am @@ -1,4 +1,4 @@ -bin_PROGRAMS=ntl-notes +bin_PROGRAMS=nautilus-notes INCLUDES=\ -I$(top_srcdir) \ @@ -19,9 +19,9 @@ LDADD=\ $(GCONF_LIBS) \ $(GNOMEUI_LIBS) -ntl_notes_SOURCES=ntl-notes.c +nautilus_notes_SOURCES=nautilus-notes.c oafdir=$(datadir)/oaf -oaf_DATA=ntl-notes.oafinfo +oaf_DATA=nautilus-notes.oafinfo EXTRA_DIST=$(oaf_DATA) diff --git a/components/notes/Nautilus_View_notes.oaf.in b/components/notes/Nautilus_View_notes.oaf.in index 33cb97cfa..cfdea0873 100644 --- a/components/notes/Nautilus_View_notes.oaf.in +++ b/components/notes/Nautilus_View_notes.oaf.in @@ -1,13 +1,13 @@ <oaf_info> -<oaf_server iid="OAFIID:ntl_notes_view_factory:4b39e388-3ca2-4d68-9f3d-c137ee62d5b0" type="exe" location="ntl-notes"> +<oaf_server iid="OAFIID:nautilus_notes_view_factory:4b39e388-3ca2-4d68-9f3d-c137ee62d5b0" type="exe" location="nautilus-notes"> <oaf_attribute name="repo_ids" type="stringv"> <item value="IDL:GNOME/GenericFactory:1.0"/> </oaf_attribute> <oaf_attribute name="description" type="string" value="Factory for annotation view"/> </oaf_server> -<oaf_server iid="OAFIID:ntl_notes_view:7f04c3cb-df79-4b9a-a577-38b19ccd4185" type="factory" location="OAFIID:ntl_notes_view_factory:4b39e388-3ca2-4d68-9f3d-c137ee62d5b0"> +<oaf_server iid="OAFIID:nautilus_notes_view:7f04c3cb-df79-4b9a-a577-38b19ccd4185" type="factory" location="OAFIID:nautilus_notes_view_factory:4b39e388-3ca2-4d68-9f3d-c137ee62d5b0"> <oaf_attribute name="repo_ids" type="stringv"> <item value="IDL:Bonobo/Control:1.0"/> <item value="IDL:Bonobo/Unknown:1.0"/> diff --git a/components/notes/Nautilus_View_notes.server.in b/components/notes/Nautilus_View_notes.server.in index 33cb97cfa..cfdea0873 100644 --- a/components/notes/Nautilus_View_notes.server.in +++ b/components/notes/Nautilus_View_notes.server.in @@ -1,13 +1,13 @@ <oaf_info> -<oaf_server iid="OAFIID:ntl_notes_view_factory:4b39e388-3ca2-4d68-9f3d-c137ee62d5b0" type="exe" location="ntl-notes"> +<oaf_server iid="OAFIID:nautilus_notes_view_factory:4b39e388-3ca2-4d68-9f3d-c137ee62d5b0" type="exe" location="nautilus-notes"> <oaf_attribute name="repo_ids" type="stringv"> <item value="IDL:GNOME/GenericFactory:1.0"/> </oaf_attribute> <oaf_attribute name="description" type="string" value="Factory for annotation view"/> </oaf_server> -<oaf_server iid="OAFIID:ntl_notes_view:7f04c3cb-df79-4b9a-a577-38b19ccd4185" type="factory" location="OAFIID:ntl_notes_view_factory:4b39e388-3ca2-4d68-9f3d-c137ee62d5b0"> +<oaf_server iid="OAFIID:nautilus_notes_view:7f04c3cb-df79-4b9a-a577-38b19ccd4185" type="factory" location="OAFIID:nautilus_notes_view_factory:4b39e388-3ca2-4d68-9f3d-c137ee62d5b0"> <oaf_attribute name="repo_ids" type="stringv"> <item value="IDL:Bonobo/Control:1.0"/> <item value="IDL:Bonobo/Unknown:1.0"/> diff --git a/components/notes/Nautilus_View_notes.server.in.in b/components/notes/Nautilus_View_notes.server.in.in index 33cb97cfa..cfdea0873 100644 --- a/components/notes/Nautilus_View_notes.server.in.in +++ b/components/notes/Nautilus_View_notes.server.in.in @@ -1,13 +1,13 @@ <oaf_info> -<oaf_server iid="OAFIID:ntl_notes_view_factory:4b39e388-3ca2-4d68-9f3d-c137ee62d5b0" type="exe" location="ntl-notes"> +<oaf_server iid="OAFIID:nautilus_notes_view_factory:4b39e388-3ca2-4d68-9f3d-c137ee62d5b0" type="exe" location="nautilus-notes"> <oaf_attribute name="repo_ids" type="stringv"> <item value="IDL:GNOME/GenericFactory:1.0"/> </oaf_attribute> <oaf_attribute name="description" type="string" value="Factory for annotation view"/> </oaf_server> -<oaf_server iid="OAFIID:ntl_notes_view:7f04c3cb-df79-4b9a-a577-38b19ccd4185" type="factory" location="OAFIID:ntl_notes_view_factory:4b39e388-3ca2-4d68-9f3d-c137ee62d5b0"> +<oaf_server iid="OAFIID:nautilus_notes_view:7f04c3cb-df79-4b9a-a577-38b19ccd4185" type="factory" location="OAFIID:nautilus_notes_view_factory:4b39e388-3ca2-4d68-9f3d-c137ee62d5b0"> <oaf_attribute name="repo_ids" type="stringv"> <item value="IDL:Bonobo/Control:1.0"/> <item value="IDL:Bonobo/Unknown:1.0"/> diff --git a/components/notes/nautilus-notes.c b/components/notes/nautilus-notes.c index 22356a39c..c91027baa 100644 --- a/components/notes/nautilus-notes.c +++ b/components/notes/nautilus-notes.c @@ -144,7 +144,7 @@ make_notes_view (BonoboGenericFactory *Factory, const char *goad_id, gpointer cl Notes *notes; NautilusBackground *background; - g_return_val_if_fail (strcmp (goad_id, "OAFIID:ntl_notes_view:7f04c3cb-df79-4b9a-a577-38b19ccd4185") == 0, NULL); + g_return_val_if_fail (strcmp (goad_id, "OAFIID:nautilus_notes_view:7f04c3cb-df79-4b9a-a577-38b19ccd4185") == 0, NULL); notes = g_new0 (Notes, 1); notes->uri = g_strdup (""); @@ -202,7 +202,7 @@ main(int argc, char *argv[]) /* initialize CORBA and Bonobo */ - gnome_init_with_popt_table("ntl-notes", VERSION, + gnome_init_with_popt_table("nautilus-notes", VERSION, argc, argv, oaf_popt_options, 0, NULL); orb = oaf_init (argc, argv); @@ -214,7 +214,7 @@ main(int argc, char *argv[]) gnome_vfs_init (); factory = bonobo_generic_factory_new_multi - ("OAFIID:ntl_notes_view_factory:4b39e388-3ca2-4d68-9f3d-c137ee62d5b0", + ("OAFIID:nautilus_notes_view_factory:4b39e388-3ca2-4d68-9f3d-c137ee62d5b0", make_notes_view, NULL); do { diff --git a/components/notes/nautilus-notes.oafinfo b/components/notes/nautilus-notes.oafinfo index 33cb97cfa..cfdea0873 100644 --- a/components/notes/nautilus-notes.oafinfo +++ b/components/notes/nautilus-notes.oafinfo @@ -1,13 +1,13 @@ <oaf_info> -<oaf_server iid="OAFIID:ntl_notes_view_factory:4b39e388-3ca2-4d68-9f3d-c137ee62d5b0" type="exe" location="ntl-notes"> +<oaf_server iid="OAFIID:nautilus_notes_view_factory:4b39e388-3ca2-4d68-9f3d-c137ee62d5b0" type="exe" location="nautilus-notes"> <oaf_attribute name="repo_ids" type="stringv"> <item value="IDL:GNOME/GenericFactory:1.0"/> </oaf_attribute> <oaf_attribute name="description" type="string" value="Factory for annotation view"/> </oaf_server> -<oaf_server iid="OAFIID:ntl_notes_view:7f04c3cb-df79-4b9a-a577-38b19ccd4185" type="factory" location="OAFIID:ntl_notes_view_factory:4b39e388-3ca2-4d68-9f3d-c137ee62d5b0"> +<oaf_server iid="OAFIID:nautilus_notes_view:7f04c3cb-df79-4b9a-a577-38b19ccd4185" type="factory" location="OAFIID:nautilus_notes_view_factory:4b39e388-3ca2-4d68-9f3d-c137ee62d5b0"> <oaf_attribute name="repo_ids" type="stringv"> <item value="IDL:Bonobo/Control:1.0"/> <item value="IDL:Bonobo/Unknown:1.0"/> diff --git a/components/notes/ntl-notes.c b/components/notes/ntl-notes.c deleted file mode 100644 index 22356a39c..000000000 --- a/components/notes/ntl-notes.c +++ /dev/null @@ -1,225 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 2000 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Andy Hertzfeld <andy@eazel.com> - * - */ - -/* annotation metaview - allows you to annotate a directory or file */ - -#include <config.h> - -#include <libnautilus/libnautilus.h> -#include <libnautilus-extensions/nautilus-metadata.h> -#include <gnome.h> -#include <libgnomevfs/gnome-vfs.h> -#include <liboaf/liboaf.h> -#include <limits.h> -#include <ctype.h> -#include <libnautilus-extensions/nautilus-background.h> -#include <libnautilus-extensions/nautilus-file.h> -#include <libnautilus-extensions/nautilus-debug.h> -#include <libnautilus/nautilus-clipboard.h> - -#define NOTES_DEFAULT_BACKGROUND_COLOR "rgb:FFFF/FFFF/BBBB" - - -typedef struct { - NautilusView *view; - GtkWidget *note_text_field; - char *uri; - NautilusFile *file; -} Notes; - -static int notes_object_count = 0; - -static void -finish_loading_note (NautilusFile *file, - gpointer callback_data) -{ - Notes *notes; - int position; - char *notes_text; - - g_assert (NAUTILUS_IS_FILE (file)); - - notes = callback_data; - g_assert (notes->file == file); - - notes_text = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_ANNOTATION, ""); - position = 0; - gtk_editable_insert_text (GTK_EDITABLE (notes->note_text_field), - notes_text, - strlen (notes_text), - &position); - g_free (notes_text); -} - -static void -done_with_file (Notes *notes) -{ - nautilus_file_cancel_callback (notes->file, finish_loading_note, notes); - nautilus_file_unref (notes->file); -} - -static void -notes_load_metainfo (Notes *notes) -{ - gtk_editable_delete_text (GTK_EDITABLE (notes->note_text_field), 0, -1); - - done_with_file (notes); - notes->file = nautilus_file_get (notes->uri); - if (notes->file == NULL) { - return; - } - nautilus_file_call_when_ready (notes->file, NULL, TRUE, finish_loading_note, notes); -} - -/* save the metainfo corresponding to the current uri, if any, into the text field */ - -static void -notes_save_metainfo (Notes *notes) -{ - char *notes_text; - - if (notes->file == NULL) { - return; - } - - notes_text = gtk_editable_get_chars (GTK_EDITABLE (notes->note_text_field), 0 , -1); - nautilus_file_set_metadata (notes->file, NAUTILUS_METADATA_KEY_ANNOTATION, NULL, notes_text); - g_free (notes_text); -} - -static void -notes_notify_location_change (NautilusView *view, - Nautilus_NavigationInfo *loci, - Notes *notes) -{ - if (strcmp (notes->uri, loci->requested_uri) != 0) { - notes_save_metainfo (notes); - g_free (notes->uri); - notes->uri = g_strdup (loci->requested_uri); - notes_load_metainfo (notes); - } -} - - - -static void -do_destroy (GtkObject *obj, Notes *notes) -{ - done_with_file (notes); - g_free (notes->uri); - g_free (notes); - - notes_object_count--; - if (notes_object_count <= 0) { - gtk_main_quit(); - } -} - -static BonoboObject * -make_notes_view (BonoboGenericFactory *Factory, const char *goad_id, gpointer closure) -{ - GtkWidget *vbox; - Notes *notes; - NautilusBackground *background; - - g_return_val_if_fail (strcmp (goad_id, "OAFIID:ntl_notes_view:7f04c3cb-df79-4b9a-a577-38b19ccd4185") == 0, NULL); - notes = g_new0 (Notes, 1); - notes->uri = g_strdup (""); - - /* allocate a vbox to hold all of the UI elements */ - - vbox = gtk_vbox_new (FALSE, 0); - - /* create the text container */ - - notes->note_text_field = gtk_text_new (NULL, NULL); - gtk_text_set_editable (GTK_TEXT (notes->note_text_field), TRUE); - gtk_box_pack_start (GTK_BOX (vbox), notes->note_text_field, TRUE, TRUE, 0); - background = nautilus_get_widget_background (notes->note_text_field); - nautilus_background_set_color (background, NOTES_DEFAULT_BACKGROUND_COLOR); - - gtk_widget_show_all (vbox); - - /* Create CORBA object. */ - notes->view = nautilus_view_new (vbox); - gtk_signal_connect (GTK_OBJECT (notes->view), "destroy", do_destroy, notes); - - notes_object_count++; - - /* handle events */ - gtk_signal_connect (GTK_OBJECT (notes->view), "notify_location_change", - notes_notify_location_change, notes); - - /* handle selections */ - nautilus_clipboard_set_up_editable - (GTK_EDITABLE (notes->note_text_field), - nautilus_view_get_bonobo_control (notes->view)); - - return BONOBO_OBJECT (notes->view); -} - -int -main(int argc, char *argv[]) -{ - BonoboGenericFactory *factory; - CORBA_ORB orb; - - /* Make criticals and warnings stop in the debugger if NAUTILUS_DEBUG is set. - * Unfortunately, this has to be done explicitly for each domain. - */ - if (getenv("NAUTILUS_DEBUG") != NULL) { - nautilus_make_warnings_and_criticals_stop_in_debugger - (G_LOG_DOMAIN, g_log_domain_glib, "Gdk", "Gtk", "GnomeVFS", "GnomeUI", "Bonobo", NULL); - } - - /* Initialize gettext support */ -#ifdef ENABLE_NLS /* sadly we need this ifdef because otherwise the following get empty statement warnings */ - bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE); -#endif - - /* initialize CORBA and Bonobo */ - - gnome_init_with_popt_table("ntl-notes", VERSION, - argc, argv, - oaf_popt_options, 0, NULL); - orb = oaf_init (argc, argv); - - bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL); - - /* initialize gnome-vfs, etc */ - g_thread_init (NULL); - gnome_vfs_init (); - - factory = bonobo_generic_factory_new_multi - ("OAFIID:ntl_notes_view_factory:4b39e388-3ca2-4d68-9f3d-c137ee62d5b0", - make_notes_view, NULL); - - do { - bonobo_main(); - } while (notes_object_count > 0); - - return EXIT_SUCCESS; -} diff --git a/components/notes/ntl-notes.oafinfo b/components/notes/ntl-notes.oafinfo deleted file mode 100644 index 33cb97cfa..000000000 --- a/components/notes/ntl-notes.oafinfo +++ /dev/null @@ -1,25 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:ntl_notes_view_factory:4b39e388-3ca2-4d68-9f3d-c137ee62d5b0" type="exe" location="ntl-notes"> -<oaf_attribute name="repo_ids" type="stringv"> -<item value="IDL:GNOME/GenericFactory:1.0"/> -</oaf_attribute> -<oaf_attribute name="description" type="string" value="Factory for annotation view"/> -</oaf_server> - -<oaf_server iid="OAFIID:ntl_notes_view:7f04c3cb-df79-4b9a-a577-38b19ccd4185" type="factory" location="OAFIID:ntl_notes_view_factory:4b39e388-3ca2-4d68-9f3d-c137ee62d5b0"> -<oaf_attribute name="repo_ids" type="stringv"> -<item value="IDL:Bonobo/Control:1.0"/> -<item value="IDL:Bonobo/Unknown:1.0"/> -<item value="IDL:Nautilus/MetaView:1.0"/> -<item value="IDL:Nautilus/View:1.0"/> -</oaf_attribute> -<oaf_attribute name="description" type="string" value="Notes sidebar panel for Nautilus"/> -<oaf_attribute name="name" type="string" value="Notes sidebar panel"/> -<oaf_attribute name="nautilus:sidebar_panel_name" type="string" value="Notes"/> -<oaf_attribute name="nautilus:recommended_uri_schemes" type="stringv"> -<item value="*"/> -</oaf_attribute> -</oaf_server> - -</oaf_info> diff --git a/components/rpmview/nautilus-rpm-view.h b/components/rpmview/nautilus-rpm-view.h index 7281c132c..31f80f2f6 100644 --- a/components/rpmview/nautilus-rpm-view.h +++ b/components/rpmview/nautilus-rpm-view.h @@ -25,7 +25,7 @@ #ifndef NAUTILUS_RPM_VIEW_H #define NAUTILUS_RPM_VIEW_H -#include <libnautilus/nautilus-view-frame.h> +#include <libnautilus/nautilus-view.h> #include <gtk/gtkeventbox.h> diff --git a/components/sample/nautilus-sample-content-view.h b/components/sample/nautilus-sample-content-view.h index 2a8a89150..58dc91763 100644 --- a/components/sample/nautilus-sample-content-view.h +++ b/components/sample/nautilus-sample-content-view.h @@ -29,7 +29,7 @@ #ifndef NAUTILUS_SAMPLE_CONTENT_VIEW_H #define NAUTILUS_SAMPLE_CONTENT_VIEW_H -#include <libnautilus/nautilus-view-frame.h> +#include <libnautilus/nautilus-view.h> #include <gtk/gtklabel.h> typedef struct NautilusSampleContentView NautilusSampleContentView; diff --git a/components/services/startup/nautilus-view/nautilus-service-startup-view.h b/components/services/startup/nautilus-view/nautilus-service-startup-view.h index 4d6b088a3..c18bdb203 100644 --- a/components/services/startup/nautilus-view/nautilus-service-startup-view.h +++ b/components/services/startup/nautilus-view/nautilus-service-startup-view.h @@ -28,7 +28,7 @@ #ifndef NAUTILUS_SERVICE_STARTUP_VIEW_H #define NAUTILUS_SERVICE_STARTUP_VIEW_H -#include <libnautilus/nautilus-view-frame.h> +#include <libnautilus/nautilus-view.h> #include <gtk/gtk.h> typedef struct _NautilusServicesContentView NautilusServicesContentView; diff --git a/libnautilus-extensions/Makefile.am b/libnautilus-extensions/Makefile.am index 0e851e531..ba2dcae5d 100644 --- a/libnautilus-extensions/Makefile.am +++ b/libnautilus-extensions/Makefile.am @@ -31,7 +31,7 @@ libnautilus_extensionsinclude_HEADERS= \ nautilus-icon-dnd.h \ nautilus-icon-grid.h \ bonobo-stream-vfs.h \ - gtkscrollframe.h \ + nautilus-scroll-frame.h \ libnautilus-extensions.h \ nautilus-alloc.h \ nautilus-background.h \ @@ -61,6 +61,7 @@ libnautilus_extensionsinclude_HEADERS= \ nautilus-list.h \ nautilus-metadata.h \ nautilus-mime-type.h \ + nautilus-mini-icon.h \ nautilus-program-chooser.h \ nautilus-program-choosing.h \ nautilus-self-checks.h \ @@ -78,7 +79,7 @@ libnautilus_extensions_la_SOURCES = \ nautilus-directory-metafile.h \ nautilus-lib-self-check-functions.h \ bonobo-stream-vfs.c \ - gtkscrollframe.c \ + nautilus-scroll-frame.c \ nautilus-background-canvas-group.c \ nautilus-background.c \ nautilus-bonobo-extensions.c \ @@ -113,6 +114,7 @@ libnautilus_extensions_la_SOURCES = \ nautilus-list-column-title.c \ nautilus-list.c \ nautilus-mime-type.c \ + nautilus-mini-icon.c \ nautilus-program-chooser.c \ nautilus-program-choosing.c \ nautilus-self-checks.c \ diff --git a/libnautilus-extensions/gtkscrollframe.c b/libnautilus-extensions/gtkscrollframe.c deleted file mode 100644 index d8fed9059..000000000 --- a/libnautilus-extensions/gtkscrollframe.c +++ /dev/null @@ -1,1203 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * 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. - */ - -/* - * Modified by the GTK+ Team and others 1997-1999, 2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#include <config.h> -#include <gtk/gtkhscrollbar.h> -#include <gtk/gtkvscrollbar.h> -#include <gtk/gtksignal.h> -#include <gtk/gtkviewport.h> -#include "gtkscrollframe.h" - - -/* scrolled window policy and size requisition handling: - * - * gtk size requisition works as follows: - * a widget upon size-request reports the width and height that it finds - * to be best suited to display its contents, including children. - * the width and/or height reported from a widget upon size requisition - * may be overidden by the user by specifying a width and/or height - * other than 0 through gtk_widget_set_usize(). - * - * a scrolled window needs (for imlementing all three policy types) to - * request its width and height based on two different rationales. - * 1) the user wants the scrolled window to just fit into the space - * that it gets allocated for a specifc dimension. - * 1.1) this does not apply if the user specified a concrete value - * value for that specific dimension by either specifying usize for the - * scrolled window or for its child. - * 2) the user wants the scrolled window to take as much space up as - * is desired by the child for a specifc dimension (i.e. POLICY_NEVER). - * - * also, kinda obvious: - * 3) a user would certainly not have choosen a scrolled window as a container - * for the child, if the resulting allocation takes up more space than the - * child would have allocated without the scrolled window. - * - * conclusions: - * A) from 1) follows: the scrolled window shouldn't request more space for a - * specifc dimension than is required at minimum. - * B) from 1.1) follows: the requisition may be overidden by usize of the scrolled - * window (done automatically) or by usize of the child (needs to be checked). - * C) from 2) follows: for POLICY_NEVER, the scrolled window simply reports the - * child's dimension. - * D) from 3) follows: the scrolled window child's minimum width and minimum height - * under A) at least correspond to the space taken up by its scrollbars. - */ - -/* Object argument IDs */ -enum { - ARG_0, - ARG_HADJUSTMENT, - ARG_VADJUSTMENT, - ARG_HSCROLLBAR_POLICY, - ARG_VSCROLLBAR_POLICY, - ARG_FRAME_PLACEMENT, - ARG_SHADOW_TYPE, - ARG_SCROLLBAR_SPACING -}; - -/* Private part of the NautilusScrollFrame structure */ -struct NautilusScrollFrameDetails { - /* Horizontal and vertical scrollbars */ - GtkWidget *hsb; - GtkWidget *vsb; - - /* Space between scrollbars and frame */ - guint sb_spacing; - - /* Allocation for frame */ - guint frame_x; - guint frame_y; - guint frame_w; - guint frame_h; - - /* Scrollbar policy */ - guint hsb_policy : 2; - guint vsb_policy : 2; - - /* Whether scrollbars are visible */ - guint hsb_visible : 1; - guint vsb_visible : 1; - - /* Placement of frame wrt scrollbars */ - guint frame_placement : 2; - - /* Shadow type for frame */ - guint shadow_type : 3; -}; - - -static void nautilus_scroll_frame_class_init (NautilusScrollFrameClass *class); -static void nautilus_scroll_frame_init (NautilusScrollFrame *sf); -static void nautilus_scroll_frame_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void nautilus_scroll_frame_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void nautilus_scroll_frame_destroy (GtkObject *object); -static void nautilus_scroll_frame_finalize (GtkObject *object); - -static void nautilus_scroll_frame_map (GtkWidget *widget); -static void nautilus_scroll_frame_unmap (GtkWidget *widget); -static void nautilus_scroll_frame_draw (GtkWidget *widget, GdkRectangle *area); -static void nautilus_scroll_frame_size_request (GtkWidget *widget, GtkRequisition *requisition); -static void nautilus_scroll_frame_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -static gint nautilus_scroll_frame_expose (GtkWidget *widget, GdkEventExpose *event); - -static void nautilus_scroll_frame_add (GtkContainer *container, GtkWidget *widget); -static void nautilus_scroll_frame_remove (GtkContainer *container, GtkWidget *widget); -static void nautilus_scroll_frame_forall (GtkContainer *container, gboolean include_internals, - GtkCallback callback, gpointer callback_data); - -static GtkBinClass *parent_class; - - -/** - * nautilus_scroll_frame_get_type: - * @void: - * - * Registers the &NautilusScrollFrame class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &NautilusScrollFrame class. - **/ -GtkType -nautilus_scroll_frame_get_type (void) -{ - static GtkType scroll_frame_type = 0; - - if (!scroll_frame_type) { - static const GtkTypeInfo scroll_frame_info = { - "NautilusScrollFrame", - sizeof (NautilusScrollFrame), - sizeof (NautilusScrollFrameClass), - (GtkClassInitFunc) nautilus_scroll_frame_class_init, - (GtkObjectInitFunc) nautilus_scroll_frame_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - scroll_frame_type = gtk_type_unique (GTK_TYPE_BIN, &scroll_frame_info); - } - - return scroll_frame_type; -} - -/* Class initialization function for the scroll frame widget */ -static void -nautilus_scroll_frame_class_init (NautilusScrollFrameClass *class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - container_class = (GtkContainerClass *) class; - - parent_class = gtk_type_class (GTK_TYPE_BIN); - - gtk_object_add_arg_type ("NautilusScrollFrame::hadjustment", - GTK_TYPE_ADJUSTMENT, - GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT, - ARG_HADJUSTMENT); - gtk_object_add_arg_type ("NautilusScrollFrame::vadjustment", - GTK_TYPE_ADJUSTMENT, - GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT, - ARG_VADJUSTMENT); - gtk_object_add_arg_type ("NautilusScrollFrame::hscrollbar_policy", - GTK_TYPE_POLICY_TYPE, - GTK_ARG_READWRITE, - ARG_HSCROLLBAR_POLICY); - gtk_object_add_arg_type ("NautilusScrollFrame::vscrollbar_policy", - GTK_TYPE_POLICY_TYPE, - GTK_ARG_READWRITE, - ARG_VSCROLLBAR_POLICY); - gtk_object_add_arg_type ("NautilusScrollFrame::frame_placement", - GTK_TYPE_CORNER_TYPE, - GTK_ARG_READWRITE, - ARG_FRAME_PLACEMENT); - gtk_object_add_arg_type ("NautilusScrollFrame::shadow_type", - GTK_TYPE_SHADOW_TYPE, - GTK_ARG_READWRITE, - ARG_SHADOW_TYPE); - gtk_object_add_arg_type ("NautilusScrollFrame::scrollbar_spacing", - GTK_TYPE_UINT, - GTK_ARG_READWRITE, - ARG_SCROLLBAR_SPACING); - - object_class->set_arg = nautilus_scroll_frame_set_arg; - object_class->get_arg = nautilus_scroll_frame_get_arg; - object_class->destroy = nautilus_scroll_frame_destroy; - object_class->finalize = nautilus_scroll_frame_finalize; - - widget_class->map = nautilus_scroll_frame_map; - widget_class->unmap = nautilus_scroll_frame_unmap; - widget_class->draw = nautilus_scroll_frame_draw; - widget_class->size_request = nautilus_scroll_frame_size_request; - widget_class->size_allocate = nautilus_scroll_frame_size_allocate; - widget_class->expose_event = nautilus_scroll_frame_expose; - - container_class->add = nautilus_scroll_frame_add; - container_class->remove = nautilus_scroll_frame_remove; - container_class->forall = nautilus_scroll_frame_forall; -} - -/* Object initialization function for the scroll frame widget */ -static void -nautilus_scroll_frame_init (NautilusScrollFrame *sf) -{ - NautilusScrollFrameDetails *details; - - details = g_new0 (NautilusScrollFrameDetails, 1); - sf->details = details; - - GTK_WIDGET_SET_FLAGS (sf, GTK_NO_WINDOW); - - gtk_container_set_resize_mode (GTK_CONTAINER (sf), GTK_RESIZE_QUEUE); - - details->sb_spacing = 3; - details->hsb_policy = GTK_POLICY_ALWAYS; - details->vsb_policy = GTK_POLICY_ALWAYS; - details->frame_placement = GTK_CORNER_TOP_LEFT; - details->shadow_type = GTK_SHADOW_NONE; -} - -/* Set_arg handler for the scroll frame widget */ -static void -nautilus_scroll_frame_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - - sf = NAUTILUS_SCROLL_FRAME (object); - details = sf->details; - - switch (arg_id) { - case ARG_HADJUSTMENT: - nautilus_scroll_frame_set_hadjustment (sf, GTK_VALUE_POINTER (*arg)); - break; - - case ARG_VADJUSTMENT: - nautilus_scroll_frame_set_vadjustment (sf, GTK_VALUE_POINTER (*arg)); - break; - - case ARG_HSCROLLBAR_POLICY: - nautilus_scroll_frame_set_policy (sf, GTK_VALUE_ENUM (*arg), details->vsb_policy); - break; - - case ARG_VSCROLLBAR_POLICY: - nautilus_scroll_frame_set_policy (sf, details->hsb_policy, GTK_VALUE_ENUM (*arg)); - break; - - case ARG_FRAME_PLACEMENT: - nautilus_scroll_frame_set_placement (sf, GTK_VALUE_ENUM (*arg)); - break; - - case ARG_SHADOW_TYPE: - nautilus_scroll_frame_set_shadow_type (sf, GTK_VALUE_ENUM (*arg)); - break; - - case ARG_SCROLLBAR_SPACING: - nautilus_scroll_frame_set_scrollbar_spacing (sf, GTK_VALUE_UINT (*arg)); - break; - - default: - break; - } -} - -/* Get_arg handler for the scroll frame widget */ -static void -nautilus_scroll_frame_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - - sf = NAUTILUS_SCROLL_FRAME (object); - details = sf->details; - - switch (arg_id) { - case ARG_HADJUSTMENT: - GTK_VALUE_POINTER (*arg) = nautilus_scroll_frame_get_hadjustment (sf); - break; - - case ARG_VADJUSTMENT: - GTK_VALUE_POINTER (*arg) = nautilus_scroll_frame_get_vadjustment (sf); - break; - - case ARG_HSCROLLBAR_POLICY: - GTK_VALUE_ENUM (*arg) = details->hsb_policy; - break; - - case ARG_VSCROLLBAR_POLICY: - GTK_VALUE_ENUM (*arg) = details->vsb_policy; - break; - - case ARG_FRAME_PLACEMENT: - GTK_VALUE_ENUM (*arg) = details->frame_placement; - break; - - case ARG_SHADOW_TYPE: - GTK_VALUE_ENUM (*arg) = details->shadow_type; - break; - - case ARG_SCROLLBAR_SPACING: - GTK_VALUE_UINT (*arg) = details->sb_spacing; - break; - - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -/* Destroy handler for the scroll frame widget */ -static void -nautilus_scroll_frame_destroy (GtkObject *object) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (object)); - - sf = NAUTILUS_SCROLL_FRAME (object); - details = sf->details; - - gtk_widget_unparent (details->hsb); - gtk_widget_unparent (details->vsb); - gtk_widget_destroy (details->hsb); - gtk_widget_destroy (details->vsb); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - -/* Finalize handler for the scroll frame widget */ -static void -nautilus_scroll_frame_finalize (GtkObject *object) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - - sf = NAUTILUS_SCROLL_FRAME (object); - details = sf->details; - - gtk_widget_unref (details->hsb); - gtk_widget_unref (details->vsb); - - g_free (details); - - if (GTK_OBJECT_CLASS (parent_class)->finalize) - (* GTK_OBJECT_CLASS (parent_class)->finalize) (object); -} - -/* Map handler for the scroll frame widget */ -static void -nautilus_scroll_frame_map (GtkWidget *widget) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (widget)); - - sf = NAUTILUS_SCROLL_FRAME (widget); - details = sf->details; - - /* chain parent class handler to map self and child */ - if (GTK_WIDGET_CLASS (parent_class)->map) - (* GTK_WIDGET_CLASS (parent_class)->map) (widget); - - if (GTK_WIDGET_VISIBLE (details->hsb) && !GTK_WIDGET_MAPPED (details->hsb)) - gtk_widget_map (details->hsb); - - if (GTK_WIDGET_VISIBLE (details->vsb) && !GTK_WIDGET_MAPPED (details->vsb)) - gtk_widget_map (details->vsb); -} - -/* Unmap handler for the scroll frame widget */ -static void -nautilus_scroll_frame_unmap (GtkWidget *widget) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (widget)); - - sf = NAUTILUS_SCROLL_FRAME (widget); - details = sf->details; - - /* chain parent class handler to unmap self and child */ - if (GTK_WIDGET_CLASS (parent_class)->unmap) - (* GTK_WIDGET_CLASS (parent_class)->unmap) (widget); - - if (GTK_WIDGET_MAPPED (details->hsb)) - gtk_widget_unmap (details->hsb); - - if (GTK_WIDGET_MAPPED (details->vsb)) - gtk_widget_unmap (details->vsb); -} - -/* Draws the shadow of a scroll frame widget */ -static void -draw_shadow (NautilusScrollFrame *sf, GdkRectangle *area) -{ - NautilusScrollFrameDetails *details; - - g_assert (area != NULL); - - details = sf->details; - - gtk_paint_shadow (GTK_WIDGET (sf)->style, - GTK_WIDGET (sf)->window, - GTK_STATE_NORMAL, details->shadow_type, - area, GTK_WIDGET (sf), - "scroll_frame", - details->frame_x, details->frame_y, - details->frame_w, details->frame_h); -} - -/* Draw handler for the scroll frame widget */ -static void -nautilus_scroll_frame_draw (GtkWidget *widget, GdkRectangle *area) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - GtkBin *bin; - GdkRectangle child_area; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (widget)); - g_return_if_fail (area != NULL); - - sf = NAUTILUS_SCROLL_FRAME (widget); - details = sf->details; - bin = GTK_BIN (widget); - - if (GTK_WIDGET_DRAWABLE (widget)) - draw_shadow (sf, area); - - if (bin->child && GTK_WIDGET_VISIBLE (bin->child) - && gtk_widget_intersect (bin->child, area, &child_area)) - gtk_widget_draw (bin->child, &child_area); - - if (GTK_WIDGET_VISIBLE (details->hsb) - && gtk_widget_intersect (details->hsb, area, &child_area)) - gtk_widget_draw (details->hsb, &child_area); - - if (GTK_WIDGET_VISIBLE (details->vsb) - && gtk_widget_intersect (details->vsb, area, &child_area)) - gtk_widget_draw (details->vsb, &child_area); -} - -/* Forall handler for the scroll frame widget */ -static void -nautilus_scroll_frame_forall (GtkContainer *container, gboolean include_internals, - GtkCallback callback, gpointer callback_data) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (container)); - g_return_if_fail (callback != NULL); - - sf = NAUTILUS_SCROLL_FRAME (container); - details = sf->details; - - if (GTK_CONTAINER_CLASS (parent_class)->forall) - (* GTK_CONTAINER_CLASS (parent_class)->forall) ( - container, include_internals, - callback, callback_data); - - if (include_internals) { - if (details->vsb) - (* callback) (details->vsb, callback_data); - - if (details->hsb) - (* callback) (details->hsb, callback_data); - } -} - -/* Size_request handler for the scroll frame widget */ -static void -nautilus_scroll_frame_size_request (GtkWidget *widget, GtkRequisition *requisition) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - GtkBin *bin; - gint extra_width; - gint extra_height; - GtkRequisition hsb_requisition; - GtkRequisition vsb_requisition; - GtkRequisition child_requisition; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (widget)); - g_return_if_fail (requisition != NULL); - - sf = NAUTILUS_SCROLL_FRAME (widget); - details = sf->details; - bin = GTK_BIN (widget); - - extra_width = 0; - extra_height = 0; - - requisition->width = GTK_CONTAINER (widget)->border_width * 2; - requisition->height = GTK_CONTAINER (widget)->border_width * 2; - - if (details->shadow_type != GTK_SHADOW_NONE) { - requisition->width += 2 * widget->style->klass->xthickness; - requisition->height += 2 * widget->style->klass->ythickness; - } - - gtk_widget_size_request (details->hsb, &hsb_requisition); - gtk_widget_size_request (details->vsb, &vsb_requisition); - - if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { - static guint quark_aux_info; - - if (!quark_aux_info) - quark_aux_info = g_quark_from_static_string ("gtk-aux-info"); - - gtk_widget_size_request (bin->child, &child_requisition); - - if (details->hsb_policy == GTK_POLICY_NEVER) - requisition->width += child_requisition.width; - else { - GtkWidgetAuxInfo *aux_info; - - aux_info = gtk_object_get_data_by_id (GTK_OBJECT (bin->child), - quark_aux_info); - if (aux_info && aux_info->width > 0) { - requisition->width += aux_info->width; - extra_width = -1; - } else - requisition->width += vsb_requisition.width; - } - - if (details->vsb_policy == GTK_POLICY_NEVER) - requisition->height += child_requisition.height; - else { - GtkWidgetAuxInfo *aux_info; - - aux_info = gtk_object_get_data_by_id (GTK_OBJECT (bin->child), - quark_aux_info); - if (aux_info && aux_info->height > 0) { - requisition->height += aux_info->height; - extra_height = -1; - } else - requisition->height += hsb_requisition.height; - } - } - - if (details->hsb_policy == GTK_POLICY_AUTOMATIC || GTK_WIDGET_VISIBLE (details->hsb)) { - requisition->width = MAX (requisition->width, hsb_requisition.width); - if (!extra_height || GTK_WIDGET_VISIBLE (details->hsb)) - extra_height = details->sb_spacing + hsb_requisition.height; - } - - if (details->vsb_policy == GTK_POLICY_AUTOMATIC || GTK_WIDGET_VISIBLE (details->vsb)) { - requisition->height = MAX (requisition->height, vsb_requisition.height); - if (!extra_width || GTK_WIDGET_VISIBLE (details->vsb)) - extra_width = details->sb_spacing + vsb_requisition.width; - } - - requisition->width += MAX (0, extra_width); - requisition->height += MAX (0, extra_height); -} - -/* Computes the relative allocation for the scroll frame widget */ -static void -compute_relative_allocation (GtkWidget *widget, GtkAllocation *allocation) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - - g_assert (NAUTILUS_IS_SCROLL_FRAME (widget)); - g_assert (allocation != NULL); - - sf = NAUTILUS_SCROLL_FRAME (widget); - details = sf->details; - - allocation->x = GTK_CONTAINER (widget)->border_width; - allocation->y = GTK_CONTAINER (widget)->border_width; - allocation->width = MAX (1, (gint) widget->allocation.width - allocation->x * 2); - allocation->height = MAX (1, (gint) widget->allocation.height - allocation->y * 2); - - if (details->vsb_visible) { - GtkRequisition vsb_requisition; - gint possible_new_width; - - gtk_widget_get_child_requisition (details->vsb, &vsb_requisition); - - if (details->frame_placement == GTK_CORNER_TOP_RIGHT - || details->frame_placement == GTK_CORNER_BOTTOM_RIGHT) - allocation->x += vsb_requisition.width + details->sb_spacing; - - possible_new_width = ((gint) allocation->width - - ((gint) vsb_requisition.width + details->sb_spacing)); - allocation->width = MAX (0, possible_new_width); - } - - if (details->hsb_visible) { - GtkRequisition hsb_requisition; - gint possible_new_height; - - gtk_widget_get_child_requisition (details->hsb, &hsb_requisition); - - if (details->frame_placement == GTK_CORNER_BOTTOM_LEFT - || details->frame_placement == GTK_CORNER_BOTTOM_RIGHT) - allocation->y += hsb_requisition.height + details->sb_spacing; - - possible_new_height = - ( ((gint)allocation->height) - - ((gint)hsb_requisition.height) + ((gint)details->sb_spacing)); - allocation->height = MAX (0, possible_new_height); - } -} - -/* Size_allocate handler for the scroll frame widget */ -static void -nautilus_scroll_frame_size_allocate (GtkWidget *widget, GtkAllocation *allocation) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - GtkBin *bin; - GtkAllocation relative_allocation; - GtkAllocation child_allocation; - gint xthickness, ythickness; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (widget)); - g_return_if_fail (allocation != NULL); - - sf = NAUTILUS_SCROLL_FRAME (widget); - details = sf->details; - bin = GTK_BIN (widget); - - widget->allocation = *allocation; - - if (details->hsb_policy == GTK_POLICY_ALWAYS) - details->hsb_visible = TRUE; - else if (details->hsb_policy == GTK_POLICY_NEVER) - details->hsb_visible = FALSE; - - if (details->vsb_policy == GTK_POLICY_ALWAYS) - details->vsb_visible = TRUE; - else if (details->vsb_policy == GTK_POLICY_NEVER) - details->vsb_visible = FALSE; - - if (details->shadow_type == GTK_SHADOW_NONE) { - xthickness = 0; - ythickness = 0; - } else { - xthickness = widget->style->klass->xthickness; - ythickness = widget->style->klass->ythickness; - } - - if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { - gboolean previous_hvis; - gboolean previous_vvis; - guint count = 0; - - do { - gint16 possible_new_size; - - compute_relative_allocation (widget, &relative_allocation); - - details->frame_x = relative_allocation.x + allocation->x; - details->frame_y = relative_allocation.y + allocation->y; - details->frame_w = relative_allocation.width; - details->frame_h = relative_allocation.height; - - child_allocation.x = details->frame_x + xthickness; - child_allocation.y = details->frame_y + ythickness; - possible_new_size = details->frame_w - 2 * xthickness; - child_allocation.width = MAX(1, possible_new_size); - possible_new_size = details->frame_h - 2 * ythickness; - child_allocation.height = MAX(1, possible_new_size); - - previous_hvis = details->hsb_visible; - previous_vvis = details->vsb_visible; - - gtk_widget_size_allocate (bin->child, &child_allocation); - - /* If, after the first iteration, the hscrollbar and the - * vscrollbar flip visiblity, then we need both. - */ - if (count - && previous_hvis != details->hsb_visible - && previous_vvis != details->vsb_visible) { - details->hsb_visible = TRUE; - details->vsb_visible = TRUE; - - /* a new resize is already queued at this point, - * so we will immediatedly get reinvoked - */ - return; - } - - count++; - } while (previous_hvis != details->hsb_visible - || previous_vvis != details->vsb_visible); - } else - compute_relative_allocation (widget, &relative_allocation); - - if (details->hsb_visible) { - GtkRequisition hscrollbar_requisition; - - gtk_widget_get_child_requisition (details->hsb, &hscrollbar_requisition); - - if (!GTK_WIDGET_VISIBLE (details->hsb)) - gtk_widget_show (details->hsb); - - child_allocation.x = relative_allocation.x; - if (details->frame_placement == GTK_CORNER_TOP_LEFT - || details->frame_placement == GTK_CORNER_TOP_RIGHT) - child_allocation.y = (relative_allocation.y -#if 0 - + relative_allocation.height - + details->sb_spacing); -#else - + relative_allocation.height); -#endif - else - child_allocation.y = GTK_CONTAINER (sf)->border_width; - - child_allocation.width = relative_allocation.width; - child_allocation.height = hscrollbar_requisition.height; - child_allocation.x += allocation->x; - child_allocation.y += allocation->y; - - gtk_widget_size_allocate (details->hsb, &child_allocation); - } else if (GTK_WIDGET_VISIBLE (details->hsb)) - gtk_widget_hide (details->hsb); - - if (details->vsb_visible) { - GtkRequisition vscrollbar_requisition; - - if (!GTK_WIDGET_VISIBLE (details->vsb)) - gtk_widget_show (details->vsb); - - gtk_widget_get_child_requisition (details->vsb, &vscrollbar_requisition); - - if (details->frame_placement == GTK_CORNER_TOP_LEFT - || details->frame_placement == GTK_CORNER_BOTTOM_LEFT) - child_allocation.x = (relative_allocation.x - + relative_allocation.width - + details->sb_spacing); - else - child_allocation.x = GTK_CONTAINER (sf)->border_width; - - child_allocation.y = relative_allocation.y; - child_allocation.width = vscrollbar_requisition.width; - child_allocation.height = relative_allocation.height; - child_allocation.x += allocation->x; - child_allocation.y += allocation->y; - - gtk_widget_size_allocate (details->vsb, &child_allocation); - } else if (GTK_WIDGET_VISIBLE (details->vsb)) - gtk_widget_hide (details->vsb); -} - -/* Expose handler for the scroll frame widget */ -static gint -nautilus_scroll_frame_expose (GtkWidget *widget, GdkEventExpose *event) -{ - NautilusScrollFrame *sf; - - g_return_val_if_fail (NAUTILUS_IS_SCROLL_FRAME (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - sf = NAUTILUS_SCROLL_FRAME (widget); - - if (GTK_WIDGET_DRAWABLE (widget)) - draw_shadow (sf, &event->area); - - if (GTK_WIDGET_CLASS (parent_class)->expose_event) - (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event); - - return FALSE; -} - -/* Add handler for the scroll frame widget */ -static void -nautilus_scroll_frame_add (GtkContainer *container, GtkWidget *child) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - GtkBin *bin; - - sf = NAUTILUS_SCROLL_FRAME (container); - details = sf->details; - bin = GTK_BIN (container); - g_return_if_fail (bin->child == NULL); - - bin->child = child; - gtk_widget_set_parent (child, GTK_WIDGET (bin)); - - /* this is a temporary message */ - if (!gtk_widget_set_scroll_adjustments (child, - gtk_range_get_adjustment (GTK_RANGE (details->hsb)), - gtk_range_get_adjustment (GTK_RANGE (details->vsb)))) - g_warning ("nautilus_scroll_frame_add(): cannot add non scrollable widget " - "use nautilus_scroll_frame_add_with_viewport() instead"); - - if (GTK_WIDGET_REALIZED (child->parent)) - gtk_widget_realize (child); - - if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child)) { - if (GTK_WIDGET_MAPPED (child->parent)) - gtk_widget_map (child); - - gtk_widget_queue_resize (child); - } -} - -/* Remove method for the scroll frame widget */ -static void -nautilus_scroll_frame_remove (GtkContainer *container, GtkWidget *child) -{ - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (container)); - g_return_if_fail (child != NULL); - g_return_if_fail (GTK_BIN (container)->child == child); - - gtk_widget_set_scroll_adjustments (child, NULL, NULL); - - /* chain parent class handler to remove child */ - if (GTK_CONTAINER_CLASS (parent_class)->remove) - (* GTK_CONTAINER_CLASS (parent_class)->remove) (container, child); -} - -/** - * nautilus_scroll_frame_new: - * @hadj: If non-NULL, the adjustment to use for horizontal scrolling. - * @vadj: If non-NULL, the adjustment to use for vertical scrolling. - * - * Creates a new scroll frame widget. - * - * Return value: The newly-created scroll frame widget. - **/ -GtkWidget * -nautilus_scroll_frame_new (GtkAdjustment *hadj, GtkAdjustment *vadj) -{ - if (hadj) - g_return_val_if_fail (GTK_IS_ADJUSTMENT (hadj), NULL); - - if (vadj) - g_return_val_if_fail (GTK_IS_ADJUSTMENT (vadj), NULL); - - return gtk_widget_new (NAUTILUS_TYPE_SCROLL_FRAME, - "hadjustment", hadj, - "vadjustment", vadj, - NULL); -} - -/* Callback used when one of the scroll frame widget's adjustments changes */ -static void -adjustment_changed (GtkAdjustment *adj, gpointer data) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - - g_return_if_fail (GTK_IS_ADJUSTMENT (adj)); - g_return_if_fail (data != NULL); - - sf = NAUTILUS_SCROLL_FRAME (data); - details = sf->details; - - if (adj == gtk_range_get_adjustment (GTK_RANGE (details->hsb))) { - if (details->hsb_policy == GTK_POLICY_AUTOMATIC) { - gboolean visible; - - visible = details->hsb_visible; - details->hsb_visible = (adj->upper - adj->lower > adj->page_size); - if (details->hsb_visible != visible) - gtk_widget_queue_resize (GTK_WIDGET (sf)); - } - } else if (adj == gtk_range_get_adjustment (GTK_RANGE (details->vsb))) { - if (details->vsb_policy == GTK_POLICY_AUTOMATIC) { - gboolean visible; - - visible = details->vsb_visible; - details->vsb_visible = (adj->upper - adj->lower > adj->page_size); - if (details->vsb_visible != visible) - gtk_widget_queue_resize (GTK_WIDGET (sf)); - } - } -} - -/** - * nautilus_scroll_frame_set_hadjustment: - * @sf: A scroll frame widget. - * @adj: An adjustment. - * - * Sets the adjustment to be used for horizontal scrolling in a scroll frame - * widget. - **/ -void -nautilus_scroll_frame_set_hadjustment (NautilusScrollFrame *sf, GtkAdjustment *adj) -{ - NautilusScrollFrameDetails *details; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (sf)); - - details = sf->details; - - if (adj) - g_return_if_fail (GTK_IS_ADJUSTMENT (adj)); - else - adj = GTK_ADJUSTMENT (gtk_object_new (GTK_TYPE_ADJUSTMENT, NULL)); - - if (!details->hsb) { - gtk_widget_push_composite_child (); - details->hsb = gtk_hscrollbar_new (adj); - gtk_widget_set_composite_name (details->hsb, "hscrollbar"); - gtk_widget_pop_composite_child (); - - gtk_widget_set_parent (details->hsb, GTK_WIDGET (sf)); - gtk_widget_ref (details->hsb); - gtk_widget_show (details->hsb); - } else { - GtkAdjustment *old_adj; - - old_adj = gtk_range_get_adjustment (GTK_RANGE (details->hsb)); - if (old_adj == adj) - return; - - gtk_signal_disconnect_by_func (GTK_OBJECT (old_adj), - GTK_SIGNAL_FUNC (adjustment_changed), - sf); - gtk_range_set_adjustment (GTK_RANGE (details->hsb), adj); - } - - adj = gtk_range_get_adjustment (GTK_RANGE (details->hsb)); - gtk_signal_connect (GTK_OBJECT (adj), - "changed", - GTK_SIGNAL_FUNC (adjustment_changed), - sf); - adjustment_changed (adj, sf); - - if (GTK_BIN (sf)->child) - gtk_widget_set_scroll_adjustments ( - GTK_BIN (sf)->child, - gtk_range_get_adjustment (GTK_RANGE (details->hsb)), - gtk_range_get_adjustment (GTK_RANGE (details->vsb))); -} - -/** - * nautilus_scroll_frame_set_vadjustment: - * @sf: A scroll frame widget. - * @adj: An adjustment. - * - * Sets the adjustment to be used for vertical scrolling in a scroll frame - * widget. - **/ -void -nautilus_scroll_frame_set_vadjustment (NautilusScrollFrame *sf, GtkAdjustment *adj) -{ - NautilusScrollFrameDetails *details; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (sf)); - - details = sf->details; - - if (adj) - g_return_if_fail (GTK_IS_ADJUSTMENT (adj)); - else - adj = GTK_ADJUSTMENT (gtk_object_new (GTK_TYPE_ADJUSTMENT, NULL)); - - if (!details->vsb) { - gtk_widget_push_composite_child (); - details->vsb = gtk_vscrollbar_new (adj); - gtk_widget_set_composite_name (details->vsb, "vscrollbar"); - gtk_widget_pop_composite_child (); - - gtk_widget_set_parent (details->vsb, GTK_WIDGET (sf)); - gtk_widget_ref (details->vsb); - gtk_widget_show (details->vsb); - } else { - GtkAdjustment *old_adj; - - old_adj = gtk_range_get_adjustment (GTK_RANGE (details->vsb)); - if (old_adj == adj) - return; - - gtk_signal_disconnect_by_func (GTK_OBJECT (old_adj), - GTK_SIGNAL_FUNC (adjustment_changed), - sf); - gtk_range_set_adjustment (GTK_RANGE (details->vsb), adj); - } - - adj = gtk_range_get_adjustment (GTK_RANGE (details->vsb)); - gtk_signal_connect (GTK_OBJECT (adj), - "changed", - GTK_SIGNAL_FUNC (adjustment_changed), - sf); - adjustment_changed (adj, sf); - - if (GTK_BIN (sf)->child) - gtk_widget_set_scroll_adjustments ( - GTK_BIN (sf)->child, - gtk_range_get_adjustment (GTK_RANGE (details->hsb)), - gtk_range_get_adjustment (GTK_RANGE (details->vsb))); -} - -/** - * nautilus_scroll_frame_get_hadjustment: - * @sf: A scroll frame widget. - * - * Queries the horizontal adjustment of a scroll frame widget. - * - * Return value: The horizontal adjustment of the scroll frame, or NULL if none. - **/ -GtkAdjustment * -nautilus_scroll_frame_get_hadjustment (NautilusScrollFrame *sf) -{ - NautilusScrollFrameDetails *details; - - g_return_val_if_fail (NAUTILUS_IS_SCROLL_FRAME (sf), NULL); - - details = sf->details; - - return details->hsb ? gtk_range_get_adjustment (GTK_RANGE (details->hsb)) : NULL; -} - -/** - * nautilus_scroll_frame_get_vadjustment: - * @sf: A scroll frame widget. - * - * Queries the vertical adjustment of a scroll frame widget. - * - * Return value: The vertical adjustment of the scroll frame, or NULL if none. - **/ -GtkAdjustment * -nautilus_scroll_frame_get_vadjustment (NautilusScrollFrame *sf) -{ - NautilusScrollFrameDetails *details; - - g_return_val_if_fail (NAUTILUS_IS_SCROLL_FRAME (sf), NULL); - - details = sf->details; - - return details->vsb ? gtk_range_get_adjustment (GTK_RANGE (details->vsb)) : NULL; -} - -/** - * nautilus_scroll_frame_set_policy: - * @sf: A scroll frame widget. - * @hsb_policy: Policy for the horizontal scrollbar. - * @vsb_policy: Policy for the vertical scrollbar. - * - * Sets the scrollbar policies of a scroll frame widget. These determine when - * the scrollbars are to be shown or hidden. - **/ -void -nautilus_scroll_frame_set_policy (NautilusScrollFrame *sf, - GtkPolicyType hsb_policy, - GtkPolicyType vsb_policy) -{ - NautilusScrollFrameDetails *details; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (sf)); - - details = sf->details; - - if (details->hsb_policy == hsb_policy && details->vsb_policy == vsb_policy) - return; - - details->hsb_policy = hsb_policy; - details->vsb_policy = vsb_policy; - - gtk_widget_queue_resize (GTK_WIDGET (sf)); -} - -/** - * nautilus_scroll_frame_set_placement: - * @sf: A scroll frame widget. - * @frame_placement: Placement for the frame. - * - * Sets the placement of a scroll frame widget's frame with respect to its - * scrollbars. - **/ -void -nautilus_scroll_frame_set_placement (NautilusScrollFrame *sf, GtkCornerType frame_placement) -{ - NautilusScrollFrameDetails *details; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (sf)); - - details = sf->details; - - if (details->frame_placement == frame_placement) - return; - - details->frame_placement = frame_placement; - gtk_widget_queue_resize (GTK_WIDGET (sf)); -} - -/** - * nautilus_scroll_frame_set_shadow_type: - * @sf: A scroll frame widget. - * @shadow_type: A shadow type. - * - * Sets the shadow type of a scroll frame widget. You can use this when you - * insert a child that does not paint a frame on its own. - **/ -void -nautilus_scroll_frame_set_shadow_type (NautilusScrollFrame *sf, GtkShadowType shadow_type) -{ - NautilusScrollFrameDetails *details; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (sf)); - g_return_if_fail (shadow_type <= GTK_SHADOW_ETCHED_OUT); - - details = sf->details; - - if (details->shadow_type == shadow_type) - return; - - details->shadow_type = shadow_type; - gtk_widget_queue_resize (GTK_WIDGET (sf)); -} - -/** - * nautilus_scroll_frame_set_scrollbar_spacing: - * @sf: A scroll frame widget. - * @spacing: Desired spacing in pixels. - * - * Sets the spacing between the frame and the scrollbars of a scroll frame - * widget. - **/ -void -nautilus_scroll_frame_set_scrollbar_spacing (NautilusScrollFrame *sf, guint spacing) -{ - NautilusScrollFrameDetails *details; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (sf)); - - details = sf->details; - - if (details->sb_spacing == spacing) - return; - - details->sb_spacing = spacing; - gtk_widget_queue_resize (GTK_WIDGET (sf)); -} - -/** - * nautilus_scroll_frame_add_with_viewport: - * @sf: A scroll frame widget. - * @child: A widget. - * - * Creates a &GtkViewport and puts the specified child inside it, thus allowing - * the viewport to be scrolled by the scroll frame widget. This is meant to be - * used only when a child does not support the scrolling interface. - **/ -void -nautilus_scroll_frame_add_with_viewport (NautilusScrollFrame *sf, GtkWidget *child) -{ - NautilusScrollFrameDetails *details; - GtkBin *bin; - GtkWidget *viewport; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (sf)); - g_return_if_fail (GTK_IS_WIDGET (child)); - g_return_if_fail (child->parent == NULL); - - details = sf->details; - bin = GTK_BIN (sf); - - if (bin->child != NULL) { - g_return_if_fail (GTK_IS_VIEWPORT (bin->child)); - g_return_if_fail (GTK_BIN (bin->child)->child == NULL); - - viewport = bin->child; - } else { - viewport = gtk_viewport_new (nautilus_scroll_frame_get_hadjustment (sf), - nautilus_scroll_frame_get_vadjustment (sf)); - gtk_container_add (GTK_CONTAINER (sf), viewport); - } - - gtk_widget_show (viewport); - gtk_container_add (GTK_CONTAINER (viewport), child); -} diff --git a/libnautilus-extensions/gtkscrollframe.h b/libnautilus-extensions/gtkscrollframe.h deleted file mode 100644 index 2807b24fd..000000000 --- a/libnautilus-extensions/gtkscrollframe.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * 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. - */ - -/* - * Modified by the GTK+ Team and others 1997-1999, 2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef GTK_SCROLL_FRAME_H -#define GTK_SCROLL_FRAME_H - -#include <gtk/gtkbin.h> - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define NAUTILUS_TYPE_SCROLL_FRAME (nautilus_scroll_frame_get_type ()) -#define NAUTILUS_SCROLL_FRAME(obj) (GTK_CHECK_CAST ((obj), \ - NAUTILUS_TYPE_SCROLL_FRAME, NautilusScrollFrame)) -#define NAUTILUS_SCROLL_FRAME_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), \ - NAUTILUS_TYPE_SCROLL_FRAME, NautilusScrollFrameClass)) -#define NAUTILUS_IS_SCROLL_FRAME(obj) (GTK_CHECK_TYPE ((obj), \ - NAUTILUS_TYPE_SCROLL_FRAME)) -#define NAUTILUS_IS_SCROLL_FRAME_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), \ - NAUTILUS_TYPE_SCROLL_FRAME)) - -typedef struct NautilusScrollFrame NautilusScrollFrame; -typedef struct NautilusScrollFrameClass NautilusScrollFrameClass; -typedef struct NautilusScrollFrameDetails NautilusScrollFrameDetails; - -struct NautilusScrollFrame -{ - GtkBin bin; - NautilusScrollFrameDetails *details; -}; -struct NautilusScrollFrameClass -{ - GtkBinClass parent_class; -}; - -GtkType nautilus_scroll_frame_get_type (void); -GtkWidget * nautilus_scroll_frame_new (GtkAdjustment *h_adjustment, - GtkAdjustment *v_adjustment); -void nautilus_scroll_frame_set_hadjustment (NautilusScrollFrame *frame, - GtkAdjustment *adj); -void nautilus_scroll_frame_set_vadjustment (NautilusScrollFrame *frame, - GtkAdjustment *adj); -GtkAdjustment *nautilus_scroll_frame_get_hadjustment (NautilusScrollFrame *frame); -GtkAdjustment *nautilus_scroll_frame_get_vadjustment (NautilusScrollFrame *frame); -void nautilus_scroll_frame_set_policy (NautilusScrollFrame *frame, - GtkPolicyType h_scroll_policy, - GtkPolicyType v_scroll_policy); -void nautilus_scroll_frame_set_placement (NautilusScrollFrame *frame, - GtkCornerType frame_placement); -void nautilus_scroll_frame_set_shadow_type (NautilusScrollFrame *frame, - GtkShadowType shadow_type); -void nautilus_scroll_frame_set_scrollbar_spacing (NautilusScrollFrame *frame, - guint spacing); -void nautilus_scroll_frame_add_with_viewport (NautilusScrollFrame *frame, - GtkWidget *child); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* GTK_SCROLL_FRAME_H */ diff --git a/libnautilus-extensions/nautilus-mini-icon.c b/libnautilus-extensions/nautilus-mini-icon.c index 33dc63002..fa740915b 100644 --- a/libnautilus-extensions/nautilus-mini-icon.c +++ b/libnautilus-extensions/nautilus-mini-icon.c @@ -20,7 +20,7 @@ */ #include <config.h> -#include "ntl-miniicon.h" +#include "nautilus-mini-icon.h" #include <gdk/gdkprivate.h> #include <gdk/gdkx.h> diff --git a/libnautilus-extensions/nautilus-scroll-frame.c b/libnautilus-extensions/nautilus-scroll-frame.c index d8fed9059..d1a04cf66 100644 --- a/libnautilus-extensions/nautilus-scroll-frame.c +++ b/libnautilus-extensions/nautilus-scroll-frame.c @@ -30,7 +30,7 @@ #include <gtk/gtkvscrollbar.h> #include <gtk/gtksignal.h> #include <gtk/gtkviewport.h> -#include "gtkscrollframe.h" +#include "nautilus-scroll-frame.h" /* scrolled window policy and size requisition handling: diff --git a/libnautilus-private/Makefile.am b/libnautilus-private/Makefile.am index 0e851e531..ba2dcae5d 100644 --- a/libnautilus-private/Makefile.am +++ b/libnautilus-private/Makefile.am @@ -31,7 +31,7 @@ libnautilus_extensionsinclude_HEADERS= \ nautilus-icon-dnd.h \ nautilus-icon-grid.h \ bonobo-stream-vfs.h \ - gtkscrollframe.h \ + nautilus-scroll-frame.h \ libnautilus-extensions.h \ nautilus-alloc.h \ nautilus-background.h \ @@ -61,6 +61,7 @@ libnautilus_extensionsinclude_HEADERS= \ nautilus-list.h \ nautilus-metadata.h \ nautilus-mime-type.h \ + nautilus-mini-icon.h \ nautilus-program-chooser.h \ nautilus-program-choosing.h \ nautilus-self-checks.h \ @@ -78,7 +79,7 @@ libnautilus_extensions_la_SOURCES = \ nautilus-directory-metafile.h \ nautilus-lib-self-check-functions.h \ bonobo-stream-vfs.c \ - gtkscrollframe.c \ + nautilus-scroll-frame.c \ nautilus-background-canvas-group.c \ nautilus-background.c \ nautilus-bonobo-extensions.c \ @@ -113,6 +114,7 @@ libnautilus_extensions_la_SOURCES = \ nautilus-list-column-title.c \ nautilus-list.c \ nautilus-mime-type.c \ + nautilus-mini-icon.c \ nautilus-program-chooser.c \ nautilus-program-choosing.c \ nautilus-self-checks.c \ diff --git a/libnautilus-private/gtkscrollframe.c b/libnautilus-private/gtkscrollframe.c deleted file mode 100644 index d8fed9059..000000000 --- a/libnautilus-private/gtkscrollframe.c +++ /dev/null @@ -1,1203 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * 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. - */ - -/* - * Modified by the GTK+ Team and others 1997-1999, 2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#include <config.h> -#include <gtk/gtkhscrollbar.h> -#include <gtk/gtkvscrollbar.h> -#include <gtk/gtksignal.h> -#include <gtk/gtkviewport.h> -#include "gtkscrollframe.h" - - -/* scrolled window policy and size requisition handling: - * - * gtk size requisition works as follows: - * a widget upon size-request reports the width and height that it finds - * to be best suited to display its contents, including children. - * the width and/or height reported from a widget upon size requisition - * may be overidden by the user by specifying a width and/or height - * other than 0 through gtk_widget_set_usize(). - * - * a scrolled window needs (for imlementing all three policy types) to - * request its width and height based on two different rationales. - * 1) the user wants the scrolled window to just fit into the space - * that it gets allocated for a specifc dimension. - * 1.1) this does not apply if the user specified a concrete value - * value for that specific dimension by either specifying usize for the - * scrolled window or for its child. - * 2) the user wants the scrolled window to take as much space up as - * is desired by the child for a specifc dimension (i.e. POLICY_NEVER). - * - * also, kinda obvious: - * 3) a user would certainly not have choosen a scrolled window as a container - * for the child, if the resulting allocation takes up more space than the - * child would have allocated without the scrolled window. - * - * conclusions: - * A) from 1) follows: the scrolled window shouldn't request more space for a - * specifc dimension than is required at minimum. - * B) from 1.1) follows: the requisition may be overidden by usize of the scrolled - * window (done automatically) or by usize of the child (needs to be checked). - * C) from 2) follows: for POLICY_NEVER, the scrolled window simply reports the - * child's dimension. - * D) from 3) follows: the scrolled window child's minimum width and minimum height - * under A) at least correspond to the space taken up by its scrollbars. - */ - -/* Object argument IDs */ -enum { - ARG_0, - ARG_HADJUSTMENT, - ARG_VADJUSTMENT, - ARG_HSCROLLBAR_POLICY, - ARG_VSCROLLBAR_POLICY, - ARG_FRAME_PLACEMENT, - ARG_SHADOW_TYPE, - ARG_SCROLLBAR_SPACING -}; - -/* Private part of the NautilusScrollFrame structure */ -struct NautilusScrollFrameDetails { - /* Horizontal and vertical scrollbars */ - GtkWidget *hsb; - GtkWidget *vsb; - - /* Space between scrollbars and frame */ - guint sb_spacing; - - /* Allocation for frame */ - guint frame_x; - guint frame_y; - guint frame_w; - guint frame_h; - - /* Scrollbar policy */ - guint hsb_policy : 2; - guint vsb_policy : 2; - - /* Whether scrollbars are visible */ - guint hsb_visible : 1; - guint vsb_visible : 1; - - /* Placement of frame wrt scrollbars */ - guint frame_placement : 2; - - /* Shadow type for frame */ - guint shadow_type : 3; -}; - - -static void nautilus_scroll_frame_class_init (NautilusScrollFrameClass *class); -static void nautilus_scroll_frame_init (NautilusScrollFrame *sf); -static void nautilus_scroll_frame_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void nautilus_scroll_frame_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); -static void nautilus_scroll_frame_destroy (GtkObject *object); -static void nautilus_scroll_frame_finalize (GtkObject *object); - -static void nautilus_scroll_frame_map (GtkWidget *widget); -static void nautilus_scroll_frame_unmap (GtkWidget *widget); -static void nautilus_scroll_frame_draw (GtkWidget *widget, GdkRectangle *area); -static void nautilus_scroll_frame_size_request (GtkWidget *widget, GtkRequisition *requisition); -static void nautilus_scroll_frame_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -static gint nautilus_scroll_frame_expose (GtkWidget *widget, GdkEventExpose *event); - -static void nautilus_scroll_frame_add (GtkContainer *container, GtkWidget *widget); -static void nautilus_scroll_frame_remove (GtkContainer *container, GtkWidget *widget); -static void nautilus_scroll_frame_forall (GtkContainer *container, gboolean include_internals, - GtkCallback callback, gpointer callback_data); - -static GtkBinClass *parent_class; - - -/** - * nautilus_scroll_frame_get_type: - * @void: - * - * Registers the &NautilusScrollFrame class if necessary, and returns the type ID - * associated to it. - * - * Return value: The type ID of the &NautilusScrollFrame class. - **/ -GtkType -nautilus_scroll_frame_get_type (void) -{ - static GtkType scroll_frame_type = 0; - - if (!scroll_frame_type) { - static const GtkTypeInfo scroll_frame_info = { - "NautilusScrollFrame", - sizeof (NautilusScrollFrame), - sizeof (NautilusScrollFrameClass), - (GtkClassInitFunc) nautilus_scroll_frame_class_init, - (GtkObjectInitFunc) nautilus_scroll_frame_init, - NULL, /* reserved_1 */ - NULL, /* reserved_2 */ - (GtkClassInitFunc) NULL - }; - - scroll_frame_type = gtk_type_unique (GTK_TYPE_BIN, &scroll_frame_info); - } - - return scroll_frame_type; -} - -/* Class initialization function for the scroll frame widget */ -static void -nautilus_scroll_frame_class_init (NautilusScrollFrameClass *class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - container_class = (GtkContainerClass *) class; - - parent_class = gtk_type_class (GTK_TYPE_BIN); - - gtk_object_add_arg_type ("NautilusScrollFrame::hadjustment", - GTK_TYPE_ADJUSTMENT, - GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT, - ARG_HADJUSTMENT); - gtk_object_add_arg_type ("NautilusScrollFrame::vadjustment", - GTK_TYPE_ADJUSTMENT, - GTK_ARG_READWRITE | GTK_ARG_CONSTRUCT, - ARG_VADJUSTMENT); - gtk_object_add_arg_type ("NautilusScrollFrame::hscrollbar_policy", - GTK_TYPE_POLICY_TYPE, - GTK_ARG_READWRITE, - ARG_HSCROLLBAR_POLICY); - gtk_object_add_arg_type ("NautilusScrollFrame::vscrollbar_policy", - GTK_TYPE_POLICY_TYPE, - GTK_ARG_READWRITE, - ARG_VSCROLLBAR_POLICY); - gtk_object_add_arg_type ("NautilusScrollFrame::frame_placement", - GTK_TYPE_CORNER_TYPE, - GTK_ARG_READWRITE, - ARG_FRAME_PLACEMENT); - gtk_object_add_arg_type ("NautilusScrollFrame::shadow_type", - GTK_TYPE_SHADOW_TYPE, - GTK_ARG_READWRITE, - ARG_SHADOW_TYPE); - gtk_object_add_arg_type ("NautilusScrollFrame::scrollbar_spacing", - GTK_TYPE_UINT, - GTK_ARG_READWRITE, - ARG_SCROLLBAR_SPACING); - - object_class->set_arg = nautilus_scroll_frame_set_arg; - object_class->get_arg = nautilus_scroll_frame_get_arg; - object_class->destroy = nautilus_scroll_frame_destroy; - object_class->finalize = nautilus_scroll_frame_finalize; - - widget_class->map = nautilus_scroll_frame_map; - widget_class->unmap = nautilus_scroll_frame_unmap; - widget_class->draw = nautilus_scroll_frame_draw; - widget_class->size_request = nautilus_scroll_frame_size_request; - widget_class->size_allocate = nautilus_scroll_frame_size_allocate; - widget_class->expose_event = nautilus_scroll_frame_expose; - - container_class->add = nautilus_scroll_frame_add; - container_class->remove = nautilus_scroll_frame_remove; - container_class->forall = nautilus_scroll_frame_forall; -} - -/* Object initialization function for the scroll frame widget */ -static void -nautilus_scroll_frame_init (NautilusScrollFrame *sf) -{ - NautilusScrollFrameDetails *details; - - details = g_new0 (NautilusScrollFrameDetails, 1); - sf->details = details; - - GTK_WIDGET_SET_FLAGS (sf, GTK_NO_WINDOW); - - gtk_container_set_resize_mode (GTK_CONTAINER (sf), GTK_RESIZE_QUEUE); - - details->sb_spacing = 3; - details->hsb_policy = GTK_POLICY_ALWAYS; - details->vsb_policy = GTK_POLICY_ALWAYS; - details->frame_placement = GTK_CORNER_TOP_LEFT; - details->shadow_type = GTK_SHADOW_NONE; -} - -/* Set_arg handler for the scroll frame widget */ -static void -nautilus_scroll_frame_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - - sf = NAUTILUS_SCROLL_FRAME (object); - details = sf->details; - - switch (arg_id) { - case ARG_HADJUSTMENT: - nautilus_scroll_frame_set_hadjustment (sf, GTK_VALUE_POINTER (*arg)); - break; - - case ARG_VADJUSTMENT: - nautilus_scroll_frame_set_vadjustment (sf, GTK_VALUE_POINTER (*arg)); - break; - - case ARG_HSCROLLBAR_POLICY: - nautilus_scroll_frame_set_policy (sf, GTK_VALUE_ENUM (*arg), details->vsb_policy); - break; - - case ARG_VSCROLLBAR_POLICY: - nautilus_scroll_frame_set_policy (sf, details->hsb_policy, GTK_VALUE_ENUM (*arg)); - break; - - case ARG_FRAME_PLACEMENT: - nautilus_scroll_frame_set_placement (sf, GTK_VALUE_ENUM (*arg)); - break; - - case ARG_SHADOW_TYPE: - nautilus_scroll_frame_set_shadow_type (sf, GTK_VALUE_ENUM (*arg)); - break; - - case ARG_SCROLLBAR_SPACING: - nautilus_scroll_frame_set_scrollbar_spacing (sf, GTK_VALUE_UINT (*arg)); - break; - - default: - break; - } -} - -/* Get_arg handler for the scroll frame widget */ -static void -nautilus_scroll_frame_get_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - - sf = NAUTILUS_SCROLL_FRAME (object); - details = sf->details; - - switch (arg_id) { - case ARG_HADJUSTMENT: - GTK_VALUE_POINTER (*arg) = nautilus_scroll_frame_get_hadjustment (sf); - break; - - case ARG_VADJUSTMENT: - GTK_VALUE_POINTER (*arg) = nautilus_scroll_frame_get_vadjustment (sf); - break; - - case ARG_HSCROLLBAR_POLICY: - GTK_VALUE_ENUM (*arg) = details->hsb_policy; - break; - - case ARG_VSCROLLBAR_POLICY: - GTK_VALUE_ENUM (*arg) = details->vsb_policy; - break; - - case ARG_FRAME_PLACEMENT: - GTK_VALUE_ENUM (*arg) = details->frame_placement; - break; - - case ARG_SHADOW_TYPE: - GTK_VALUE_ENUM (*arg) = details->shadow_type; - break; - - case ARG_SCROLLBAR_SPACING: - GTK_VALUE_UINT (*arg) = details->sb_spacing; - break; - - default: - arg->type = GTK_TYPE_INVALID; - break; - } -} - -/* Destroy handler for the scroll frame widget */ -static void -nautilus_scroll_frame_destroy (GtkObject *object) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (object)); - - sf = NAUTILUS_SCROLL_FRAME (object); - details = sf->details; - - gtk_widget_unparent (details->hsb); - gtk_widget_unparent (details->vsb); - gtk_widget_destroy (details->hsb); - gtk_widget_destroy (details->vsb); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - -/* Finalize handler for the scroll frame widget */ -static void -nautilus_scroll_frame_finalize (GtkObject *object) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - - sf = NAUTILUS_SCROLL_FRAME (object); - details = sf->details; - - gtk_widget_unref (details->hsb); - gtk_widget_unref (details->vsb); - - g_free (details); - - if (GTK_OBJECT_CLASS (parent_class)->finalize) - (* GTK_OBJECT_CLASS (parent_class)->finalize) (object); -} - -/* Map handler for the scroll frame widget */ -static void -nautilus_scroll_frame_map (GtkWidget *widget) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (widget)); - - sf = NAUTILUS_SCROLL_FRAME (widget); - details = sf->details; - - /* chain parent class handler to map self and child */ - if (GTK_WIDGET_CLASS (parent_class)->map) - (* GTK_WIDGET_CLASS (parent_class)->map) (widget); - - if (GTK_WIDGET_VISIBLE (details->hsb) && !GTK_WIDGET_MAPPED (details->hsb)) - gtk_widget_map (details->hsb); - - if (GTK_WIDGET_VISIBLE (details->vsb) && !GTK_WIDGET_MAPPED (details->vsb)) - gtk_widget_map (details->vsb); -} - -/* Unmap handler for the scroll frame widget */ -static void -nautilus_scroll_frame_unmap (GtkWidget *widget) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (widget)); - - sf = NAUTILUS_SCROLL_FRAME (widget); - details = sf->details; - - /* chain parent class handler to unmap self and child */ - if (GTK_WIDGET_CLASS (parent_class)->unmap) - (* GTK_WIDGET_CLASS (parent_class)->unmap) (widget); - - if (GTK_WIDGET_MAPPED (details->hsb)) - gtk_widget_unmap (details->hsb); - - if (GTK_WIDGET_MAPPED (details->vsb)) - gtk_widget_unmap (details->vsb); -} - -/* Draws the shadow of a scroll frame widget */ -static void -draw_shadow (NautilusScrollFrame *sf, GdkRectangle *area) -{ - NautilusScrollFrameDetails *details; - - g_assert (area != NULL); - - details = sf->details; - - gtk_paint_shadow (GTK_WIDGET (sf)->style, - GTK_WIDGET (sf)->window, - GTK_STATE_NORMAL, details->shadow_type, - area, GTK_WIDGET (sf), - "scroll_frame", - details->frame_x, details->frame_y, - details->frame_w, details->frame_h); -} - -/* Draw handler for the scroll frame widget */ -static void -nautilus_scroll_frame_draw (GtkWidget *widget, GdkRectangle *area) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - GtkBin *bin; - GdkRectangle child_area; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (widget)); - g_return_if_fail (area != NULL); - - sf = NAUTILUS_SCROLL_FRAME (widget); - details = sf->details; - bin = GTK_BIN (widget); - - if (GTK_WIDGET_DRAWABLE (widget)) - draw_shadow (sf, area); - - if (bin->child && GTK_WIDGET_VISIBLE (bin->child) - && gtk_widget_intersect (bin->child, area, &child_area)) - gtk_widget_draw (bin->child, &child_area); - - if (GTK_WIDGET_VISIBLE (details->hsb) - && gtk_widget_intersect (details->hsb, area, &child_area)) - gtk_widget_draw (details->hsb, &child_area); - - if (GTK_WIDGET_VISIBLE (details->vsb) - && gtk_widget_intersect (details->vsb, area, &child_area)) - gtk_widget_draw (details->vsb, &child_area); -} - -/* Forall handler for the scroll frame widget */ -static void -nautilus_scroll_frame_forall (GtkContainer *container, gboolean include_internals, - GtkCallback callback, gpointer callback_data) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (container)); - g_return_if_fail (callback != NULL); - - sf = NAUTILUS_SCROLL_FRAME (container); - details = sf->details; - - if (GTK_CONTAINER_CLASS (parent_class)->forall) - (* GTK_CONTAINER_CLASS (parent_class)->forall) ( - container, include_internals, - callback, callback_data); - - if (include_internals) { - if (details->vsb) - (* callback) (details->vsb, callback_data); - - if (details->hsb) - (* callback) (details->hsb, callback_data); - } -} - -/* Size_request handler for the scroll frame widget */ -static void -nautilus_scroll_frame_size_request (GtkWidget *widget, GtkRequisition *requisition) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - GtkBin *bin; - gint extra_width; - gint extra_height; - GtkRequisition hsb_requisition; - GtkRequisition vsb_requisition; - GtkRequisition child_requisition; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (widget)); - g_return_if_fail (requisition != NULL); - - sf = NAUTILUS_SCROLL_FRAME (widget); - details = sf->details; - bin = GTK_BIN (widget); - - extra_width = 0; - extra_height = 0; - - requisition->width = GTK_CONTAINER (widget)->border_width * 2; - requisition->height = GTK_CONTAINER (widget)->border_width * 2; - - if (details->shadow_type != GTK_SHADOW_NONE) { - requisition->width += 2 * widget->style->klass->xthickness; - requisition->height += 2 * widget->style->klass->ythickness; - } - - gtk_widget_size_request (details->hsb, &hsb_requisition); - gtk_widget_size_request (details->vsb, &vsb_requisition); - - if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { - static guint quark_aux_info; - - if (!quark_aux_info) - quark_aux_info = g_quark_from_static_string ("gtk-aux-info"); - - gtk_widget_size_request (bin->child, &child_requisition); - - if (details->hsb_policy == GTK_POLICY_NEVER) - requisition->width += child_requisition.width; - else { - GtkWidgetAuxInfo *aux_info; - - aux_info = gtk_object_get_data_by_id (GTK_OBJECT (bin->child), - quark_aux_info); - if (aux_info && aux_info->width > 0) { - requisition->width += aux_info->width; - extra_width = -1; - } else - requisition->width += vsb_requisition.width; - } - - if (details->vsb_policy == GTK_POLICY_NEVER) - requisition->height += child_requisition.height; - else { - GtkWidgetAuxInfo *aux_info; - - aux_info = gtk_object_get_data_by_id (GTK_OBJECT (bin->child), - quark_aux_info); - if (aux_info && aux_info->height > 0) { - requisition->height += aux_info->height; - extra_height = -1; - } else - requisition->height += hsb_requisition.height; - } - } - - if (details->hsb_policy == GTK_POLICY_AUTOMATIC || GTK_WIDGET_VISIBLE (details->hsb)) { - requisition->width = MAX (requisition->width, hsb_requisition.width); - if (!extra_height || GTK_WIDGET_VISIBLE (details->hsb)) - extra_height = details->sb_spacing + hsb_requisition.height; - } - - if (details->vsb_policy == GTK_POLICY_AUTOMATIC || GTK_WIDGET_VISIBLE (details->vsb)) { - requisition->height = MAX (requisition->height, vsb_requisition.height); - if (!extra_width || GTK_WIDGET_VISIBLE (details->vsb)) - extra_width = details->sb_spacing + vsb_requisition.width; - } - - requisition->width += MAX (0, extra_width); - requisition->height += MAX (0, extra_height); -} - -/* Computes the relative allocation for the scroll frame widget */ -static void -compute_relative_allocation (GtkWidget *widget, GtkAllocation *allocation) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - - g_assert (NAUTILUS_IS_SCROLL_FRAME (widget)); - g_assert (allocation != NULL); - - sf = NAUTILUS_SCROLL_FRAME (widget); - details = sf->details; - - allocation->x = GTK_CONTAINER (widget)->border_width; - allocation->y = GTK_CONTAINER (widget)->border_width; - allocation->width = MAX (1, (gint) widget->allocation.width - allocation->x * 2); - allocation->height = MAX (1, (gint) widget->allocation.height - allocation->y * 2); - - if (details->vsb_visible) { - GtkRequisition vsb_requisition; - gint possible_new_width; - - gtk_widget_get_child_requisition (details->vsb, &vsb_requisition); - - if (details->frame_placement == GTK_CORNER_TOP_RIGHT - || details->frame_placement == GTK_CORNER_BOTTOM_RIGHT) - allocation->x += vsb_requisition.width + details->sb_spacing; - - possible_new_width = ((gint) allocation->width - - ((gint) vsb_requisition.width + details->sb_spacing)); - allocation->width = MAX (0, possible_new_width); - } - - if (details->hsb_visible) { - GtkRequisition hsb_requisition; - gint possible_new_height; - - gtk_widget_get_child_requisition (details->hsb, &hsb_requisition); - - if (details->frame_placement == GTK_CORNER_BOTTOM_LEFT - || details->frame_placement == GTK_CORNER_BOTTOM_RIGHT) - allocation->y += hsb_requisition.height + details->sb_spacing; - - possible_new_height = - ( ((gint)allocation->height) - - ((gint)hsb_requisition.height) + ((gint)details->sb_spacing)); - allocation->height = MAX (0, possible_new_height); - } -} - -/* Size_allocate handler for the scroll frame widget */ -static void -nautilus_scroll_frame_size_allocate (GtkWidget *widget, GtkAllocation *allocation) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - GtkBin *bin; - GtkAllocation relative_allocation; - GtkAllocation child_allocation; - gint xthickness, ythickness; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (widget)); - g_return_if_fail (allocation != NULL); - - sf = NAUTILUS_SCROLL_FRAME (widget); - details = sf->details; - bin = GTK_BIN (widget); - - widget->allocation = *allocation; - - if (details->hsb_policy == GTK_POLICY_ALWAYS) - details->hsb_visible = TRUE; - else if (details->hsb_policy == GTK_POLICY_NEVER) - details->hsb_visible = FALSE; - - if (details->vsb_policy == GTK_POLICY_ALWAYS) - details->vsb_visible = TRUE; - else if (details->vsb_policy == GTK_POLICY_NEVER) - details->vsb_visible = FALSE; - - if (details->shadow_type == GTK_SHADOW_NONE) { - xthickness = 0; - ythickness = 0; - } else { - xthickness = widget->style->klass->xthickness; - ythickness = widget->style->klass->ythickness; - } - - if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) { - gboolean previous_hvis; - gboolean previous_vvis; - guint count = 0; - - do { - gint16 possible_new_size; - - compute_relative_allocation (widget, &relative_allocation); - - details->frame_x = relative_allocation.x + allocation->x; - details->frame_y = relative_allocation.y + allocation->y; - details->frame_w = relative_allocation.width; - details->frame_h = relative_allocation.height; - - child_allocation.x = details->frame_x + xthickness; - child_allocation.y = details->frame_y + ythickness; - possible_new_size = details->frame_w - 2 * xthickness; - child_allocation.width = MAX(1, possible_new_size); - possible_new_size = details->frame_h - 2 * ythickness; - child_allocation.height = MAX(1, possible_new_size); - - previous_hvis = details->hsb_visible; - previous_vvis = details->vsb_visible; - - gtk_widget_size_allocate (bin->child, &child_allocation); - - /* If, after the first iteration, the hscrollbar and the - * vscrollbar flip visiblity, then we need both. - */ - if (count - && previous_hvis != details->hsb_visible - && previous_vvis != details->vsb_visible) { - details->hsb_visible = TRUE; - details->vsb_visible = TRUE; - - /* a new resize is already queued at this point, - * so we will immediatedly get reinvoked - */ - return; - } - - count++; - } while (previous_hvis != details->hsb_visible - || previous_vvis != details->vsb_visible); - } else - compute_relative_allocation (widget, &relative_allocation); - - if (details->hsb_visible) { - GtkRequisition hscrollbar_requisition; - - gtk_widget_get_child_requisition (details->hsb, &hscrollbar_requisition); - - if (!GTK_WIDGET_VISIBLE (details->hsb)) - gtk_widget_show (details->hsb); - - child_allocation.x = relative_allocation.x; - if (details->frame_placement == GTK_CORNER_TOP_LEFT - || details->frame_placement == GTK_CORNER_TOP_RIGHT) - child_allocation.y = (relative_allocation.y -#if 0 - + relative_allocation.height - + details->sb_spacing); -#else - + relative_allocation.height); -#endif - else - child_allocation.y = GTK_CONTAINER (sf)->border_width; - - child_allocation.width = relative_allocation.width; - child_allocation.height = hscrollbar_requisition.height; - child_allocation.x += allocation->x; - child_allocation.y += allocation->y; - - gtk_widget_size_allocate (details->hsb, &child_allocation); - } else if (GTK_WIDGET_VISIBLE (details->hsb)) - gtk_widget_hide (details->hsb); - - if (details->vsb_visible) { - GtkRequisition vscrollbar_requisition; - - if (!GTK_WIDGET_VISIBLE (details->vsb)) - gtk_widget_show (details->vsb); - - gtk_widget_get_child_requisition (details->vsb, &vscrollbar_requisition); - - if (details->frame_placement == GTK_CORNER_TOP_LEFT - || details->frame_placement == GTK_CORNER_BOTTOM_LEFT) - child_allocation.x = (relative_allocation.x - + relative_allocation.width - + details->sb_spacing); - else - child_allocation.x = GTK_CONTAINER (sf)->border_width; - - child_allocation.y = relative_allocation.y; - child_allocation.width = vscrollbar_requisition.width; - child_allocation.height = relative_allocation.height; - child_allocation.x += allocation->x; - child_allocation.y += allocation->y; - - gtk_widget_size_allocate (details->vsb, &child_allocation); - } else if (GTK_WIDGET_VISIBLE (details->vsb)) - gtk_widget_hide (details->vsb); -} - -/* Expose handler for the scroll frame widget */ -static gint -nautilus_scroll_frame_expose (GtkWidget *widget, GdkEventExpose *event) -{ - NautilusScrollFrame *sf; - - g_return_val_if_fail (NAUTILUS_IS_SCROLL_FRAME (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - sf = NAUTILUS_SCROLL_FRAME (widget); - - if (GTK_WIDGET_DRAWABLE (widget)) - draw_shadow (sf, &event->area); - - if (GTK_WIDGET_CLASS (parent_class)->expose_event) - (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event); - - return FALSE; -} - -/* Add handler for the scroll frame widget */ -static void -nautilus_scroll_frame_add (GtkContainer *container, GtkWidget *child) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - GtkBin *bin; - - sf = NAUTILUS_SCROLL_FRAME (container); - details = sf->details; - bin = GTK_BIN (container); - g_return_if_fail (bin->child == NULL); - - bin->child = child; - gtk_widget_set_parent (child, GTK_WIDGET (bin)); - - /* this is a temporary message */ - if (!gtk_widget_set_scroll_adjustments (child, - gtk_range_get_adjustment (GTK_RANGE (details->hsb)), - gtk_range_get_adjustment (GTK_RANGE (details->vsb)))) - g_warning ("nautilus_scroll_frame_add(): cannot add non scrollable widget " - "use nautilus_scroll_frame_add_with_viewport() instead"); - - if (GTK_WIDGET_REALIZED (child->parent)) - gtk_widget_realize (child); - - if (GTK_WIDGET_VISIBLE (child->parent) && GTK_WIDGET_VISIBLE (child)) { - if (GTK_WIDGET_MAPPED (child->parent)) - gtk_widget_map (child); - - gtk_widget_queue_resize (child); - } -} - -/* Remove method for the scroll frame widget */ -static void -nautilus_scroll_frame_remove (GtkContainer *container, GtkWidget *child) -{ - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (container)); - g_return_if_fail (child != NULL); - g_return_if_fail (GTK_BIN (container)->child == child); - - gtk_widget_set_scroll_adjustments (child, NULL, NULL); - - /* chain parent class handler to remove child */ - if (GTK_CONTAINER_CLASS (parent_class)->remove) - (* GTK_CONTAINER_CLASS (parent_class)->remove) (container, child); -} - -/** - * nautilus_scroll_frame_new: - * @hadj: If non-NULL, the adjustment to use for horizontal scrolling. - * @vadj: If non-NULL, the adjustment to use for vertical scrolling. - * - * Creates a new scroll frame widget. - * - * Return value: The newly-created scroll frame widget. - **/ -GtkWidget * -nautilus_scroll_frame_new (GtkAdjustment *hadj, GtkAdjustment *vadj) -{ - if (hadj) - g_return_val_if_fail (GTK_IS_ADJUSTMENT (hadj), NULL); - - if (vadj) - g_return_val_if_fail (GTK_IS_ADJUSTMENT (vadj), NULL); - - return gtk_widget_new (NAUTILUS_TYPE_SCROLL_FRAME, - "hadjustment", hadj, - "vadjustment", vadj, - NULL); -} - -/* Callback used when one of the scroll frame widget's adjustments changes */ -static void -adjustment_changed (GtkAdjustment *adj, gpointer data) -{ - NautilusScrollFrame *sf; - NautilusScrollFrameDetails *details; - - g_return_if_fail (GTK_IS_ADJUSTMENT (adj)); - g_return_if_fail (data != NULL); - - sf = NAUTILUS_SCROLL_FRAME (data); - details = sf->details; - - if (adj == gtk_range_get_adjustment (GTK_RANGE (details->hsb))) { - if (details->hsb_policy == GTK_POLICY_AUTOMATIC) { - gboolean visible; - - visible = details->hsb_visible; - details->hsb_visible = (adj->upper - adj->lower > adj->page_size); - if (details->hsb_visible != visible) - gtk_widget_queue_resize (GTK_WIDGET (sf)); - } - } else if (adj == gtk_range_get_adjustment (GTK_RANGE (details->vsb))) { - if (details->vsb_policy == GTK_POLICY_AUTOMATIC) { - gboolean visible; - - visible = details->vsb_visible; - details->vsb_visible = (adj->upper - adj->lower > adj->page_size); - if (details->vsb_visible != visible) - gtk_widget_queue_resize (GTK_WIDGET (sf)); - } - } -} - -/** - * nautilus_scroll_frame_set_hadjustment: - * @sf: A scroll frame widget. - * @adj: An adjustment. - * - * Sets the adjustment to be used for horizontal scrolling in a scroll frame - * widget. - **/ -void -nautilus_scroll_frame_set_hadjustment (NautilusScrollFrame *sf, GtkAdjustment *adj) -{ - NautilusScrollFrameDetails *details; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (sf)); - - details = sf->details; - - if (adj) - g_return_if_fail (GTK_IS_ADJUSTMENT (adj)); - else - adj = GTK_ADJUSTMENT (gtk_object_new (GTK_TYPE_ADJUSTMENT, NULL)); - - if (!details->hsb) { - gtk_widget_push_composite_child (); - details->hsb = gtk_hscrollbar_new (adj); - gtk_widget_set_composite_name (details->hsb, "hscrollbar"); - gtk_widget_pop_composite_child (); - - gtk_widget_set_parent (details->hsb, GTK_WIDGET (sf)); - gtk_widget_ref (details->hsb); - gtk_widget_show (details->hsb); - } else { - GtkAdjustment *old_adj; - - old_adj = gtk_range_get_adjustment (GTK_RANGE (details->hsb)); - if (old_adj == adj) - return; - - gtk_signal_disconnect_by_func (GTK_OBJECT (old_adj), - GTK_SIGNAL_FUNC (adjustment_changed), - sf); - gtk_range_set_adjustment (GTK_RANGE (details->hsb), adj); - } - - adj = gtk_range_get_adjustment (GTK_RANGE (details->hsb)); - gtk_signal_connect (GTK_OBJECT (adj), - "changed", - GTK_SIGNAL_FUNC (adjustment_changed), - sf); - adjustment_changed (adj, sf); - - if (GTK_BIN (sf)->child) - gtk_widget_set_scroll_adjustments ( - GTK_BIN (sf)->child, - gtk_range_get_adjustment (GTK_RANGE (details->hsb)), - gtk_range_get_adjustment (GTK_RANGE (details->vsb))); -} - -/** - * nautilus_scroll_frame_set_vadjustment: - * @sf: A scroll frame widget. - * @adj: An adjustment. - * - * Sets the adjustment to be used for vertical scrolling in a scroll frame - * widget. - **/ -void -nautilus_scroll_frame_set_vadjustment (NautilusScrollFrame *sf, GtkAdjustment *adj) -{ - NautilusScrollFrameDetails *details; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (sf)); - - details = sf->details; - - if (adj) - g_return_if_fail (GTK_IS_ADJUSTMENT (adj)); - else - adj = GTK_ADJUSTMENT (gtk_object_new (GTK_TYPE_ADJUSTMENT, NULL)); - - if (!details->vsb) { - gtk_widget_push_composite_child (); - details->vsb = gtk_vscrollbar_new (adj); - gtk_widget_set_composite_name (details->vsb, "vscrollbar"); - gtk_widget_pop_composite_child (); - - gtk_widget_set_parent (details->vsb, GTK_WIDGET (sf)); - gtk_widget_ref (details->vsb); - gtk_widget_show (details->vsb); - } else { - GtkAdjustment *old_adj; - - old_adj = gtk_range_get_adjustment (GTK_RANGE (details->vsb)); - if (old_adj == adj) - return; - - gtk_signal_disconnect_by_func (GTK_OBJECT (old_adj), - GTK_SIGNAL_FUNC (adjustment_changed), - sf); - gtk_range_set_adjustment (GTK_RANGE (details->vsb), adj); - } - - adj = gtk_range_get_adjustment (GTK_RANGE (details->vsb)); - gtk_signal_connect (GTK_OBJECT (adj), - "changed", - GTK_SIGNAL_FUNC (adjustment_changed), - sf); - adjustment_changed (adj, sf); - - if (GTK_BIN (sf)->child) - gtk_widget_set_scroll_adjustments ( - GTK_BIN (sf)->child, - gtk_range_get_adjustment (GTK_RANGE (details->hsb)), - gtk_range_get_adjustment (GTK_RANGE (details->vsb))); -} - -/** - * nautilus_scroll_frame_get_hadjustment: - * @sf: A scroll frame widget. - * - * Queries the horizontal adjustment of a scroll frame widget. - * - * Return value: The horizontal adjustment of the scroll frame, or NULL if none. - **/ -GtkAdjustment * -nautilus_scroll_frame_get_hadjustment (NautilusScrollFrame *sf) -{ - NautilusScrollFrameDetails *details; - - g_return_val_if_fail (NAUTILUS_IS_SCROLL_FRAME (sf), NULL); - - details = sf->details; - - return details->hsb ? gtk_range_get_adjustment (GTK_RANGE (details->hsb)) : NULL; -} - -/** - * nautilus_scroll_frame_get_vadjustment: - * @sf: A scroll frame widget. - * - * Queries the vertical adjustment of a scroll frame widget. - * - * Return value: The vertical adjustment of the scroll frame, or NULL if none. - **/ -GtkAdjustment * -nautilus_scroll_frame_get_vadjustment (NautilusScrollFrame *sf) -{ - NautilusScrollFrameDetails *details; - - g_return_val_if_fail (NAUTILUS_IS_SCROLL_FRAME (sf), NULL); - - details = sf->details; - - return details->vsb ? gtk_range_get_adjustment (GTK_RANGE (details->vsb)) : NULL; -} - -/** - * nautilus_scroll_frame_set_policy: - * @sf: A scroll frame widget. - * @hsb_policy: Policy for the horizontal scrollbar. - * @vsb_policy: Policy for the vertical scrollbar. - * - * Sets the scrollbar policies of a scroll frame widget. These determine when - * the scrollbars are to be shown or hidden. - **/ -void -nautilus_scroll_frame_set_policy (NautilusScrollFrame *sf, - GtkPolicyType hsb_policy, - GtkPolicyType vsb_policy) -{ - NautilusScrollFrameDetails *details; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (sf)); - - details = sf->details; - - if (details->hsb_policy == hsb_policy && details->vsb_policy == vsb_policy) - return; - - details->hsb_policy = hsb_policy; - details->vsb_policy = vsb_policy; - - gtk_widget_queue_resize (GTK_WIDGET (sf)); -} - -/** - * nautilus_scroll_frame_set_placement: - * @sf: A scroll frame widget. - * @frame_placement: Placement for the frame. - * - * Sets the placement of a scroll frame widget's frame with respect to its - * scrollbars. - **/ -void -nautilus_scroll_frame_set_placement (NautilusScrollFrame *sf, GtkCornerType frame_placement) -{ - NautilusScrollFrameDetails *details; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (sf)); - - details = sf->details; - - if (details->frame_placement == frame_placement) - return; - - details->frame_placement = frame_placement; - gtk_widget_queue_resize (GTK_WIDGET (sf)); -} - -/** - * nautilus_scroll_frame_set_shadow_type: - * @sf: A scroll frame widget. - * @shadow_type: A shadow type. - * - * Sets the shadow type of a scroll frame widget. You can use this when you - * insert a child that does not paint a frame on its own. - **/ -void -nautilus_scroll_frame_set_shadow_type (NautilusScrollFrame *sf, GtkShadowType shadow_type) -{ - NautilusScrollFrameDetails *details; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (sf)); - g_return_if_fail (shadow_type <= GTK_SHADOW_ETCHED_OUT); - - details = sf->details; - - if (details->shadow_type == shadow_type) - return; - - details->shadow_type = shadow_type; - gtk_widget_queue_resize (GTK_WIDGET (sf)); -} - -/** - * nautilus_scroll_frame_set_scrollbar_spacing: - * @sf: A scroll frame widget. - * @spacing: Desired spacing in pixels. - * - * Sets the spacing between the frame and the scrollbars of a scroll frame - * widget. - **/ -void -nautilus_scroll_frame_set_scrollbar_spacing (NautilusScrollFrame *sf, guint spacing) -{ - NautilusScrollFrameDetails *details; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (sf)); - - details = sf->details; - - if (details->sb_spacing == spacing) - return; - - details->sb_spacing = spacing; - gtk_widget_queue_resize (GTK_WIDGET (sf)); -} - -/** - * nautilus_scroll_frame_add_with_viewport: - * @sf: A scroll frame widget. - * @child: A widget. - * - * Creates a &GtkViewport and puts the specified child inside it, thus allowing - * the viewport to be scrolled by the scroll frame widget. This is meant to be - * used only when a child does not support the scrolling interface. - **/ -void -nautilus_scroll_frame_add_with_viewport (NautilusScrollFrame *sf, GtkWidget *child) -{ - NautilusScrollFrameDetails *details; - GtkBin *bin; - GtkWidget *viewport; - - g_return_if_fail (NAUTILUS_IS_SCROLL_FRAME (sf)); - g_return_if_fail (GTK_IS_WIDGET (child)); - g_return_if_fail (child->parent == NULL); - - details = sf->details; - bin = GTK_BIN (sf); - - if (bin->child != NULL) { - g_return_if_fail (GTK_IS_VIEWPORT (bin->child)); - g_return_if_fail (GTK_BIN (bin->child)->child == NULL); - - viewport = bin->child; - } else { - viewport = gtk_viewport_new (nautilus_scroll_frame_get_hadjustment (sf), - nautilus_scroll_frame_get_vadjustment (sf)); - gtk_container_add (GTK_CONTAINER (sf), viewport); - } - - gtk_widget_show (viewport); - gtk_container_add (GTK_CONTAINER (viewport), child); -} diff --git a/libnautilus-private/gtkscrollframe.h b/libnautilus-private/gtkscrollframe.h deleted file mode 100644 index 2807b24fd..000000000 --- a/libnautilus-private/gtkscrollframe.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* GTK - The GIMP Toolkit - * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald - * - * 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. - */ - -/* - * Modified by the GTK+ Team and others 1997-1999, 2000. See the AUTHORS - * file for a list of people on the GTK+ Team. See the ChangeLog - * files for a list of changes. These files are distributed with - * GTK+ at ftp://ftp.gtk.org/pub/gtk/. - */ - -#ifndef GTK_SCROLL_FRAME_H -#define GTK_SCROLL_FRAME_H - -#include <gtk/gtkbin.h> - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define NAUTILUS_TYPE_SCROLL_FRAME (nautilus_scroll_frame_get_type ()) -#define NAUTILUS_SCROLL_FRAME(obj) (GTK_CHECK_CAST ((obj), \ - NAUTILUS_TYPE_SCROLL_FRAME, NautilusScrollFrame)) -#define NAUTILUS_SCROLL_FRAME_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), \ - NAUTILUS_TYPE_SCROLL_FRAME, NautilusScrollFrameClass)) -#define NAUTILUS_IS_SCROLL_FRAME(obj) (GTK_CHECK_TYPE ((obj), \ - NAUTILUS_TYPE_SCROLL_FRAME)) -#define NAUTILUS_IS_SCROLL_FRAME_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), \ - NAUTILUS_TYPE_SCROLL_FRAME)) - -typedef struct NautilusScrollFrame NautilusScrollFrame; -typedef struct NautilusScrollFrameClass NautilusScrollFrameClass; -typedef struct NautilusScrollFrameDetails NautilusScrollFrameDetails; - -struct NautilusScrollFrame -{ - GtkBin bin; - NautilusScrollFrameDetails *details; -}; -struct NautilusScrollFrameClass -{ - GtkBinClass parent_class; -}; - -GtkType nautilus_scroll_frame_get_type (void); -GtkWidget * nautilus_scroll_frame_new (GtkAdjustment *h_adjustment, - GtkAdjustment *v_adjustment); -void nautilus_scroll_frame_set_hadjustment (NautilusScrollFrame *frame, - GtkAdjustment *adj); -void nautilus_scroll_frame_set_vadjustment (NautilusScrollFrame *frame, - GtkAdjustment *adj); -GtkAdjustment *nautilus_scroll_frame_get_hadjustment (NautilusScrollFrame *frame); -GtkAdjustment *nautilus_scroll_frame_get_vadjustment (NautilusScrollFrame *frame); -void nautilus_scroll_frame_set_policy (NautilusScrollFrame *frame, - GtkPolicyType h_scroll_policy, - GtkPolicyType v_scroll_policy); -void nautilus_scroll_frame_set_placement (NautilusScrollFrame *frame, - GtkCornerType frame_placement); -void nautilus_scroll_frame_set_shadow_type (NautilusScrollFrame *frame, - GtkShadowType shadow_type); -void nautilus_scroll_frame_set_scrollbar_spacing (NautilusScrollFrame *frame, - guint spacing); -void nautilus_scroll_frame_add_with_viewport (NautilusScrollFrame *frame, - GtkWidget *child); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* GTK_SCROLL_FRAME_H */ diff --git a/libnautilus-private/nautilus-mini-icon.c b/libnautilus-private/nautilus-mini-icon.c index 33dc63002..fa740915b 100644 --- a/libnautilus-private/nautilus-mini-icon.c +++ b/libnautilus-private/nautilus-mini-icon.c @@ -20,7 +20,7 @@ */ #include <config.h> -#include "ntl-miniicon.h" +#include "nautilus-mini-icon.h" #include <gdk/gdkprivate.h> #include <gdk/gdkx.h> diff --git a/libnautilus-private/nautilus-scroll-frame.c b/libnautilus-private/nautilus-scroll-frame.c index d8fed9059..d1a04cf66 100644 --- a/libnautilus-private/nautilus-scroll-frame.c +++ b/libnautilus-private/nautilus-scroll-frame.c @@ -30,7 +30,7 @@ #include <gtk/gtkvscrollbar.h> #include <gtk/gtksignal.h> #include <gtk/gtkviewport.h> -#include "gtkscrollframe.h" +#include "nautilus-scroll-frame.h" /* scrolled window policy and size requisition handling: diff --git a/libnautilus/Makefile.am b/libnautilus/Makefile.am index 6b77bc88f..8d254069d 100644 --- a/libnautilus/Makefile.am +++ b/libnautilus/Makefile.am @@ -44,7 +44,7 @@ libnautilusinclude_HEADERS= \ nautilus-bonobo-ui.h \ nautilus-clipboard.h \ nautilus-view-component.h \ - nautilus-view-frame.h \ + nautilus-view.h \ nautilus-undo-context.h \ nautilus-undo-manager.h \ nautilus-undo-transaction.h \ @@ -54,11 +54,10 @@ libnautilusinclude_HEADERS= \ libnautilus_la_SOURCES= \ nautilus-undo-manager-private.h \ - nautilus-view-frame-private.h \ $(nautilus_view_component_idl_sources) \ $(nautilus_undo_idl_sources) \ nautilus-clipboard.c \ - nautilus-view-frame.c \ + nautilus-view.c \ nautilus-undo-context.c \ nautilus-undo-manager.c \ nautilus-undo-transaction.c \ diff --git a/libnautilus/libnautilus.h b/libnautilus/libnautilus.h index 1e6bdb9bc..2fd53d99b 100644 --- a/libnautilus/libnautilus.h +++ b/libnautilus/libnautilus.h @@ -31,6 +31,6 @@ #include <bonobo.h> #include <libnautilus/nautilus-view-component.h> -#include <libnautilus/nautilus-view-frame.h> +#include <libnautilus/nautilus-view.h> #endif /* LIBNAUTILUS_H */ diff --git a/libnautilus/nautilus-view-frame.c b/libnautilus/nautilus-view-frame.c deleted file mode 100644 index 0eba1c9b7..000000000 --- a/libnautilus/nautilus-view-frame.c +++ /dev/null @@ -1,433 +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. - * - * Author: Elliot Lee <sopwith@redhat.com> - * - */ - -/* nautilus-view-frame.c: Implementation for object that represents a - nautilus view implementation. */ - -#include <config.h> -#include "nautilus-view-frame.h" - -#include <gtk/gtksignal.h> -#include <bonobo/bonobo-main.h> -#include <bonobo/bonobo-control.h> -#include <libnautilus-extensions/nautilus-gtk-macros.h> -#include <libnautilus/nautilus-undo-context.h> -#include <libnautilus/nautilus-undo-manager.h> - -enum { - NOTIFY_LOCATION_CHANGE, - NOTIFY_SELECTION_CHANGE, - LOAD_STATE, - SAVE_STATE, - SHOW_PROPERTIES, - STOP_LOCATION_CHANGE, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL]; - -struct NautilusViewDetails { - BonoboControl *control; -}; - -typedef struct { - POA_Nautilus_View servant; - gpointer bonobo_object; - - NautilusView *view; -} impl_POA_Nautilus_View; - -static void impl_Nautilus_View_save_state (PortableServer_Servant servant, - const CORBA_char *config_path, - CORBA_Environment *ev); -static void impl_Nautilus_View_load_state (PortableServer_Servant servant, - const CORBA_char *config_path, - CORBA_Environment *ev); -static void impl_Nautilus_View_notify_location_change (PortableServer_Servant servant, - const Nautilus_NavigationInfo *navinfo, - CORBA_Environment *ev); -static void impl_Nautilus_View_stop_location_change (PortableServer_Servant servant, - CORBA_Environment *ev); -static void impl_Nautilus_View_notify_selection_change (PortableServer_Servant servant, - const Nautilus_SelectionInfo *selinfo, - CORBA_Environment *ev); -static void impl_Nautilus_View_show_properties (PortableServer_Servant servant, - CORBA_Environment *ev); -static void nautilus_view_initialize (NautilusView *view); -static void nautilus_view_destroy (NautilusView *view); -static void nautilus_view_initialize_class (NautilusViewClass *klass); - -POA_Nautilus_View__epv libnautilus_Nautilus_View_epv = -{ - NULL, /* _private */ - &impl_Nautilus_View_save_state, - &impl_Nautilus_View_load_state, - &impl_Nautilus_View_notify_location_change, - &impl_Nautilus_View_stop_location_change, - &impl_Nautilus_View_notify_selection_change, - &impl_Nautilus_View_show_properties -}; - -static PortableServer_ServantBase__epv base_epv; -static POA_Nautilus_View__vepv impl_Nautilus_View_vepv = -{ - &base_epv, - NULL, - &libnautilus_Nautilus_View_epv -}; - -static void -impl_Nautilus_View_save_state (PortableServer_Servant servant, - const CORBA_char *config_path, - CORBA_Environment *ev) -{ - gtk_signal_emit (GTK_OBJECT (((impl_POA_Nautilus_View *) servant)->view), - signals[SAVE_STATE], config_path); -} - -static void -impl_Nautilus_View_load_state (PortableServer_Servant servant, - const CORBA_char *config_path, - CORBA_Environment *ev) -{ - gtk_signal_emit (GTK_OBJECT (((impl_POA_Nautilus_View *) servant)->view), - signals[LOAD_STATE], config_path); -} - -static void -impl_Nautilus_View_notify_location_change (PortableServer_Servant servant, - const Nautilus_NavigationInfo *navinfo, - CORBA_Environment *ev) -{ - gtk_signal_emit (GTK_OBJECT (((impl_POA_Nautilus_View *) servant)->view), - signals[NOTIFY_LOCATION_CHANGE], navinfo); -} - -static void -impl_Nautilus_View_show_properties (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - gtk_signal_emit (GTK_OBJECT (((impl_POA_Nautilus_View *) servant)->view), - signals[SHOW_PROPERTIES]); -} - -static void -impl_Nautilus_View_notify_selection_change (PortableServer_Servant servant, - const Nautilus_SelectionInfo *selinfo, - CORBA_Environment *ev) -{ - gtk_signal_emit (GTK_OBJECT (((impl_POA_Nautilus_View *) servant)->view), - signals[NOTIFY_SELECTION_CHANGE], selinfo); -} - -static void -impl_Nautilus_View_stop_location_change (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - gtk_signal_emit (GTK_OBJECT (((impl_POA_Nautilus_View *) servant)->view), - signals[STOP_LOCATION_CHANGE]); -} - -static void -impl_Nautilus_View__destroy (BonoboObject *obj, impl_POA_Nautilus_View *servant) -{ - PortableServer_ObjectId *objid; - CORBA_Environment ev; - void (* servant_destroy_func) (PortableServer_Servant servant, CORBA_Environment *ev); - - CORBA_exception_init(&ev); - - servant_destroy_func = NAUTILUS_VIEW_CLASS (GTK_OBJECT (servant->view)->klass)->servant_destroy_func; - objid = PortableServer_POA_servant_to_id (bonobo_poa (), servant, &ev); - PortableServer_POA_deactivate_object (bonobo_poa (), objid, &ev); - CORBA_free (objid); - obj->servant = NULL; - - servant_destroy_func ((PortableServer_Servant) servant, &ev); - g_free (servant); - CORBA_exception_free(&ev); -} - -static Nautilus_ViewFrame -impl_Nautilus_View__create (NautilusView *view, CORBA_Environment * ev) -{ - Nautilus_ViewFrame retval; - - impl_POA_Nautilus_View *newservant; - void (*servant_init_func) (PortableServer_Servant servant, CORBA_Environment *ev); - NautilusViewClass *view_class = NAUTILUS_VIEW_CLASS (GTK_OBJECT(view)->klass); - - servant_init_func = view_class->servant_init_func; - newservant = g_new0 (impl_POA_Nautilus_View, 1); - newservant->servant.vepv = view_class->vepv; - if (!newservant->servant.vepv->Bonobo_Unknown_epv) - newservant->servant.vepv->Bonobo_Unknown_epv = bonobo_object_get_epv (); - servant_init_func ((PortableServer_Servant) newservant, ev); - - newservant->view = view; - - retval = bonobo_object_activate_servant (BONOBO_OBJECT (view), newservant); - - gtk_signal_connect (GTK_OBJECT (view), "destroy", - GTK_SIGNAL_FUNC (impl_Nautilus_View__destroy), newservant); - - return retval; -} - -NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusView, nautilus_view, BONOBO_OBJECT_TYPE) - -static void -nautilus_view_initialize_class (NautilusViewClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass*) klass; - object_class->destroy = (void (*)(GtkObject *)) nautilus_view_destroy; - - klass->parent_class = gtk_type_class (gtk_type_parent (object_class->type)); - klass->servant_init_func = POA_Nautilus_View__init; - klass->servant_destroy_func = POA_Nautilus_View__fini; - klass->vepv = &impl_Nautilus_View_vepv; - - signals[NOTIFY_LOCATION_CHANGE] = - gtk_signal_new ("notify_location_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (NautilusViewClass, notify_location_change), - gtk_marshal_NONE__BOXED, - GTK_TYPE_NONE, 1, GTK_TYPE_BOXED); - signals[NOTIFY_SELECTION_CHANGE] = - gtk_signal_new ("notify_selection_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (NautilusViewClass, notify_selection_change), - gtk_marshal_NONE__BOXED, - GTK_TYPE_NONE, 1, GTK_TYPE_BOXED); - signals[LOAD_STATE] = - gtk_signal_new ("load_state", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (NautilusViewClass, load_state), - gtk_marshal_NONE__STRING, - GTK_TYPE_NONE, 1, GTK_TYPE_STRING); - signals[SAVE_STATE] = - gtk_signal_new ("save_state", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (NautilusViewClass, save_state), - gtk_marshal_NONE__STRING, - GTK_TYPE_NONE, 1, GTK_TYPE_STRING); - signals[SHOW_PROPERTIES] = - gtk_signal_new ("show_properties", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (NautilusViewClass, show_properties), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - signals[STOP_LOCATION_CHANGE] = - gtk_signal_new ("stop_location_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (NautilusViewClass, stop_location_change), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); -} - -static void -nautilus_view_initialize (NautilusView *view) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - view->details = g_new0 (NautilusViewDetails, 1); - - bonobo_object_construct - (BONOBO_OBJECT (view), - impl_Nautilus_View__create (view, &ev)); - - CORBA_exception_free (&ev); -} - -NautilusView * -nautilus_view_new (GtkWidget *widget) -{ - return nautilus_view_new_from_bonobo_control - (bonobo_control_new (widget)); -} - -NautilusView * -nautilus_view_new_from_bonobo_control (BonoboControl *control) -{ - NautilusView *view; - - view = NAUTILUS_VIEW (gtk_type_new (NAUTILUS_TYPE_VIEW)); - view->details->control = control; - bonobo_object_add_interface (BONOBO_OBJECT (view), BONOBO_OBJECT (control)); - nautilus_undo_set_up_bonobo_control (control); - - return view; -} - -static void -nautilus_view_destroy (NautilusView *view) -{ - NautilusViewClass *klass; - - klass = NAUTILUS_VIEW_CLASS (GTK_OBJECT (view)->klass); - - g_free (view->details); - - NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, GTK_OBJECT (view)); -} - -static Nautilus_ViewFrame -get_view_frame (NautilusView *view, CORBA_Environment *ev) -{ - return Bonobo_Unknown_query_interface - (bonobo_control_get_control_frame (nautilus_view_get_bonobo_control (view)), - "IDL:Nautilus/ViewFrame:1.0", ev); -} - -void -nautilus_view_request_location_change (NautilusView *view, - Nautilus_NavigationRequestInfo *request) -{ - CORBA_Environment ev; - Nautilus_ViewFrame view_frame; - - g_return_if_fail (NAUTILUS_IS_VIEW (view)); - - CORBA_exception_init (&ev); - - view_frame = get_view_frame (view, &ev); - Nautilus_ViewFrame_request_location_change (view_frame, request, &ev); - CORBA_Object_release (view_frame, &ev); - - CORBA_exception_free (&ev); -} - -void -nautilus_view_request_selection_change (NautilusView *view, - Nautilus_SelectionRequestInfo *request) -{ - CORBA_Environment ev; - Nautilus_ViewFrame view_frame; - - g_return_if_fail (NAUTILUS_IS_VIEW (view)); - - CORBA_exception_init (&ev); - - view_frame = get_view_frame (view, &ev); - Nautilus_ViewFrame_request_selection_change (view_frame, request, &ev); - CORBA_Object_release (view_frame, &ev); - - CORBA_exception_free(&ev); -} - -void -nautilus_view_request_status_change (NautilusView *view, - Nautilus_StatusRequestInfo *request) -{ - CORBA_Environment ev; - Nautilus_ViewFrame view_frame; - - g_return_if_fail (NAUTILUS_IS_VIEW (view)); - - CORBA_exception_init (&ev); - - view_frame = get_view_frame (view, &ev); - Nautilus_ViewFrame_request_status_change (view_frame, request, &ev); - CORBA_Object_release (view_frame, &ev); - - CORBA_exception_free (&ev); -} - -void -nautilus_view_request_progress_change(NautilusView *view, - Nautilus_ProgressRequestInfo *request) -{ - CORBA_Environment ev; - Nautilus_ViewFrame view_frame; - - g_return_if_fail (NAUTILUS_IS_VIEW (view)); - - CORBA_exception_init (&ev); - - view_frame = get_view_frame (view, &ev); - Nautilus_ViewFrame_request_progress_change (view_frame, request, &ev); - CORBA_Object_release (view_frame, &ev); - - CORBA_exception_free (&ev); -} - - -void -nautilus_view_request_title_change (NautilusView *view, - const char *new_title) -{ - CORBA_Environment ev; - Nautilus_ViewFrame view_frame; - - g_return_if_fail (NAUTILUS_IS_VIEW (view)); - - CORBA_exception_init (&ev); - - view_frame = get_view_frame (view, &ev); - Nautilus_ViewFrame_request_title_change (view_frame, new_title, &ev); - CORBA_Object_release (view_frame, &ev); - - CORBA_exception_free (&ev); -} - -BonoboControl * -nautilus_view_get_bonobo_control (NautilusView *view) -{ - g_return_val_if_fail (NAUTILUS_IS_VIEW (view), NULL); - - return view->details->control; -} - -CORBA_Object -nautilus_view_get_main_window (NautilusView *view) -{ - CORBA_Environment ev; - Nautilus_ViewFrame view_frame; - Nautilus_ViewWindow window; - - g_return_val_if_fail (NAUTILUS_IS_VIEW (view), CORBA_OBJECT_NIL); - - CORBA_exception_init (&ev); - - view_frame = get_view_frame (view, &ev); - window = Nautilus_ViewFrame__get_main_window (view_frame, &ev); - CORBA_Object_release (view_frame, &ev); - - CORBA_exception_free (&ev); - - return window; -} diff --git a/libnautilus/nautilus-view-frame.h b/libnautilus/nautilus-view-frame.h deleted file mode 100644 index 1913e3b2d..000000000 --- a/libnautilus/nautilus-view-frame.h +++ /dev/null @@ -1,95 +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: Elliot Lee <sopwith@redhat.com> - * - */ - -/* nautilus-view-frame.h: Interface of the object representing the frame a - data view plugs into. */ - -#ifndef NAUTILUS_VIEW_FRAME_H -#define NAUTILUS_VIEW_FRAME_H - -#include <libnautilus/nautilus-view-component.h> -#include <bonobo/bonobo-control.h> -#include <gtk/gtkwidget.h> - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#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 ((obj), NAUTILUS_TYPE_VIEW)) - -typedef struct NautilusView NautilusView; -typedef struct NautilusViewClass NautilusViewClass; - -struct NautilusViewClass -{ - BonoboObjectClass parent_spot; - - void (*save_state) (NautilusView *view, const char *config_path); - void (*load_state) (NautilusView *view, const char *config_path); - void (*notify_location_change) (NautilusView *view, - Nautilus_NavigationInfo *nav_context); - void (*stop_location_change) (NautilusView *view); - void (*notify_selection_change) (NautilusView *view, - Nautilus_SelectionInfo *nav_context); - void (*show_properties) (NautilusView *view); - - BonoboObjectClass *parent_class; - - gpointer servant_init_func, servant_destroy_func, vepv; -}; - -typedef struct NautilusViewDetails NautilusViewDetails; - -struct NautilusView { - BonoboObject parent; - NautilusViewDetails *details; -}; - -GtkType nautilus_view_get_type (void); -NautilusView * nautilus_view_new (GtkWidget *widget); -NautilusView * nautilus_view_new_from_bonobo_control (BonoboControl *bonobo_control); -void nautilus_view_request_location_change (NautilusView *view, - Nautilus_NavigationRequestInfo *loc); -void nautilus_view_request_selection_change (NautilusView *view, - Nautilus_SelectionRequestInfo *loc); -void nautilus_view_request_status_change (NautilusView *view, - Nautilus_StatusRequestInfo *loc); -void nautilus_view_request_progress_change (NautilusView *view, - Nautilus_ProgressRequestInfo *loc); -void nautilus_view_request_title_change (NautilusView *view, - const char *title); -BonoboControl *nautilus_view_get_bonobo_control (NautilusView *view); -CORBA_Object nautilus_view_get_main_window (NautilusView *view); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif diff --git a/libnautilus/nautilus-view.c b/libnautilus/nautilus-view.c index 0eba1c9b7..1c8944191 100644 --- a/libnautilus/nautilus-view.c +++ b/libnautilus/nautilus-view.c @@ -24,11 +24,11 @@ * */ -/* nautilus-view-frame.c: Implementation for object that represents a +/* nautilus-view.c: Implementation for object that represents a nautilus view implementation. */ #include <config.h> -#include "nautilus-view-frame.h" +#include "nautilus-view.h" #include <gtk/gtksignal.h> #include <bonobo/bonobo-main.h> diff --git a/libnautilus/nautilus-view.h b/libnautilus/nautilus-view.h index 1913e3b2d..7345ebb97 100644 --- a/libnautilus/nautilus-view.h +++ b/libnautilus/nautilus-view.h @@ -24,11 +24,11 @@ * */ -/* nautilus-view-frame.h: Interface of the object representing the frame a +/* nautilus-view.h: Interface of the object representing the frame a data view plugs into. */ -#ifndef NAUTILUS_VIEW_FRAME_H -#define NAUTILUS_VIEW_FRAME_H +#ifndef NAUTILUS_VIEW_H +#define NAUTILUS_VIEW_H #include <libnautilus/nautilus-view-component.h> #include <bonobo/bonobo-control.h> diff --git a/po/POTFILES.in b/po/POTFILES.in index 12f73cb65..f345fae1e 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -2,10 +2,10 @@ src/nautilus-bookmarks-window.c src/nautilus-location-bar.c src/nautilus-window-menus.c src/nautilus-window-toolbars.c -src/ntl-main.c -src/ntl-view-bonobo-control.c -src/ntl-window-msgs.c -src/ntl-window.c +src/nautilus-main.c +src/nautilus-view-frame-bonobo-control.c +src/nautilus-window-manage-views.c +src/nautilus-window.c src/file-manager/dfos-corba.c src/file-manager/dfos-xfer-progress-dialog.c src/file-manager/dfos-xfer.c @@ -19,11 +19,11 @@ libnautilus-extensions/nautilus-file.c libnautilus-extensions/nautilus-global-preferences.c components/help/hyperbola-filefmt.c components/help/hyperbola-nav-index.c -components/history/ntl-history-view.c +components/history/nautilus-history-view.c components/html/gnome-dialogs.c components/html/ntl-web-browser.c components/music/nautilus-music-view.c -components/notes/ntl-notes.c +components/notes/nautilus-notes.c components/rpmview/nautilus-rpm-view.c components/sample/nautilus-sample-content-view.c components/websearch/ntl-web-search.c diff --git a/src/Makefile.am b/src/Makefile.am index 5fa334000..3b6425ca8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -36,54 +36,51 @@ LDADD =\ $(NULL) nautilus_SOURCES =\ - nautilus-bookmark-list.c \ - nautilus-bookmark-list.h \ - nautilus-bookmarks-window.c \ - nautilus-bookmarks-window.h \ - nautilus-desktop-window.c \ - nautilus-desktop-window.h \ - nautilus-index-tabs.c \ - nautilus-index-tabs.h \ - nautilus-index-title.c \ - nautilus-index-title.h \ - nautilus-location-bar.c \ - nautilus-location-bar.h \ - nautilus-property-browser.c \ - nautilus-property-browser.h \ - nautilus-self-check-functions.c \ - nautilus-self-check-functions.h \ - nautilus-signaller.c \ - nautilus-signaller.h \ - nautilus-window-menus.c \ - nautilus-window-toolbars.c \ - nautilus-zoom-control.c \ - nautilus-zoom-control.h \ - nautilus-zoomable-frame-svr.c \ - nautilus.h \ - ntl-app.c \ - ntl-app.h \ - ntl-index-panel.c \ - ntl-index-panel.h \ - ntl-main.c \ - ntl-miniicon.c \ - ntl-miniicon.h \ - ntl-types.h \ - ntl-uri-map.c \ - ntl-uri-map.h \ - ntl-view-bonobo-control.c \ - ntl-view-bonobo-subdoc.c \ - ntl-view-frame-svr.c \ - ntl-view-nautilus.c \ - ntl-view-private.h \ - ntl-view.c \ - ntl-view.h \ - ntl-window-msgs.c \ - ntl-window-msgs.h \ - ntl-window-private.h \ - ntl-window-state.c \ - ntl-window-state.h \ - ntl-window.c \ - ntl-window.h \ + nautilus-bookmark-list.c \ + nautilus-bookmark-list.h \ + nautilus-bookmarks-window.c \ + nautilus-bookmarks-window.h \ + nautilus-desktop-window.c \ + nautilus-desktop-window.h \ + nautilus-sidebar-tabs.c \ + nautilus-sidebar-tabs.h \ + nautilus-sidebar-title.c \ + nautilus-sidebar-title.h \ + nautilus-location-bar.c \ + nautilus-location-bar.h \ + nautilus-property-browser.c \ + nautilus-property-browser.h \ + nautilus-self-check-functions.c \ + nautilus-self-check-functions.h \ + nautilus-signaller.c \ + nautilus-signaller.h \ + nautilus-window-menus.c \ + nautilus-window-toolbars.c \ + nautilus-zoom-control.c \ + nautilus-zoom-control.h \ + nautilus-zoomable-frame-corba.c \ + nautilus.h \ + nautilus-application.c \ + nautilus-application.h \ + nautilus-sidebar.c \ + nautilus-sidebar.h \ + nautilus-main.c \ + nautilus-applicable-views.c \ + nautilus-applicable-views.h \ + nautilus-view-frame-bonobo-control.c \ + nautilus-view-frame-bonobo-embeddable.c \ + nautilus-view-frame-corba.c \ + nautilus-view-frame-nautilus-view.c \ + nautilus-view-frame-private.h \ + nautilus-view-frame.c \ + nautilus-view.h \ + nautilus-window-manage-views.c \ + nautilus-window-manage-views.h \ + nautilus-window-private.h \ + nautilus-window-state.c \ + nautlus-window-state.h \ + nautilus-window.c \ + nautilus-window.h \ $(NULL) TESTS=check-nautilus diff --git a/src/file-manager/fm-directory-view.h b/src/file-manager/fm-directory-view.h index 89f4b0d21..f7a5724b5 100644 --- a/src/file-manager/fm-directory-view.h +++ b/src/file-manager/fm-directory-view.h @@ -28,7 +28,7 @@ #include <bonobo/bonobo-ui-handler.h> #include <gtk/gtkmenu.h> #include <gtk/gtkscrolledwindow.h> -#include <libnautilus/nautilus-view-frame.h> +#include <libnautilus/nautilus-view.h> #include <libnautilus-extensions/nautilus-directory.h> #include <libnautilus-extensions/nautilus-file.h> #include <libnautilus-extensions/nautilus-icon-container.h> diff --git a/src/nautilus-applicable-views.c b/src/nautilus-applicable-views.c index fb7f7d2b3..1131c820c 100644 --- a/src/nautilus-applicable-views.c +++ b/src/nautilus-applicable-views.c @@ -27,11 +27,11 @@ /* #define DEBUG_MJS 1 */ -/* ntl-uri-map.c: Implementation of routines for mapping a location +/* nautilus-applicable-views.c: Implementation of routines for mapping a location change request to a set of views and actual URL to be loaded. */ #include <config.h> -#include "ntl-uri-map.h" +#include "nautilus-applicable-views.h" #include <libnautilus-extensions/nautilus-directory.h> #include <libnautilus-extensions/nautilus-metadata.h> diff --git a/src/nautilus-applicable-views.h b/src/nautilus-applicable-views.h index c05ed220c..3eab81985 100644 --- a/src/nautilus-applicable-views.h +++ b/src/nautilus-applicable-views.h @@ -23,7 +23,7 @@ * */ -/* ntl-uri-map.h: Interface for mapping a location change request to a set of views and actual URL to be loaded. */ +/* nautilus-applicable-views.h: Interface for mapping a location change request to a set of views and actual URL to be loaded. */ #ifndef NAUTILUS_URI_MAP_H #define NAUTILUS_URI_MAP_H diff --git a/src/nautilus-application.c b/src/nautilus-application.c index 6a41d524a..4d4dd8bfb 100644 --- a/src/nautilus-application.c +++ b/src/nautilus-application.c @@ -25,9 +25,9 @@ */ #include <config.h> -#include "ntl-app.h" +#include "nautilus-application.h" -#include "ntl-window-state.h" +#include "nautilus-window-state.h" #include <libnautilus/libnautilus.h> #include <bonobo.h> #include "file-manager/fm-icon-view.h" diff --git a/src/nautilus-application.h b/src/nautilus-application.h index 4adb67f2c..e5831fa1b 100644 --- a/src/nautilus-application.h +++ b/src/nautilus-application.h @@ -19,10 +19,10 @@ * Boston, MA 02111-1307, USA. */ -#ifndef NTL_APP_H -#define NTL_APP_H +#ifndef NAUTILUS_APPLICATION_H +#define NAUTILUS_APPLICATION_H -#include "ntl-window.h" +#include "nautilus-window.h" #ifdef __cplusplus extern "C" { diff --git a/src/nautilus-desktop-window.h b/src/nautilus-desktop-window.h index 37ec79947..7029415ee 100644 --- a/src/nautilus-desktop-window.h +++ b/src/nautilus-desktop-window.h @@ -25,7 +25,7 @@ #ifndef NAUTILUS_DESKTOP_WINDOW_H #define NAUTILUS_DESKTOP_WINDOW_H -#include "ntl-app.h" +#include "nautilus-application.h" #define NAUTILUS_TYPE_DESKTOP_WINDOW (nautilus_desktop_window_get_type()) #define NAUTILUS_DESKTOP_WINDOW(object) (GTK_CHECK_CAST ((object), NAUTILUS_TYPE_DESKTOP_WINDOW, NautilusDesktopWindow)) diff --git a/src/nautilus-index-tabs.c b/src/nautilus-index-tabs.c deleted file mode 100644 index e9ba58a47..000000000 --- a/src/nautilus-index-tabs.c +++ /dev/null @@ -1,725 +0,0 @@ -/* -*- mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* Nautilus - * Copyright (C) 2000 Eazel, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Andy Hertzfeld <andy@eazel.com> - * - * This is the tabs widget for the index panel, which represents metaviews as nice tabs as specified - */ - -#include <config.h> -#include "nautilus-index-tabs.h" - -#include <math.h> -#include <stdio.h> -#include <string.h> -#include <libnautilus-extensions/nautilus-gtk-macros.h> -#include <gdk-pixbuf/gdk-pixbuf.h> -#include <libgnome/gnome-defs.h> -#include <libgnome/gnome-util.h> - -/* data structures */ - -typedef struct { - gboolean visible; - gboolean prelit; - char *tab_text; - int notebook_page; - GtkWidget *tab_view; -} TabItem; - -struct NautilusIndexTabsDetails { - int tab_count; - int total_height; - gboolean title_mode; - - GdkColor tab_color; - GdkColor background_color; - GdkColor line_color; - GdkColor hilight_color; - GdkColor prelight_color; - GdkColor text_color; - GdkColor prelit_text_color; - - char *title; - gboolean title_prelit; - GList *tab_items; -}; - -/* constants */ -#define TAB_MARGIN 8 -#define TITLE_TAB_OFFSET 8 -#define TAB_HEIGHT 18 -#define TAB_H_GAP 8 -#define TAB_TOP_GAP 3 -#define TAB_ROW_V_OFFSET 3 - -/* headers */ - -static void nautilus_index_tabs_initialize_class (NautilusIndexTabsClass *klass); -static void nautilus_index_tabs_initialize (NautilusIndexTabs *pixmap); -static int nautilus_index_tabs_expose (GtkWidget *widget, - GdkEventExpose *event); -static void nautilus_index_tabs_destroy (GtkObject *object); -static void nautilus_index_tabs_size_allocate (GtkWidget *widget, - GtkAllocation *allocatoin); -static void nautilus_index_tabs_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static int draw_or_hit_test_all_tabs (NautilusIndexTabs *index_tabs, - gboolean draw_flag, - int test_x, - int test_y); -static TabItem* tab_item_find_by_name (NautilusIndexTabs *index_tabs, - const char *name); - -/* static variables */ - -static GdkFont *tab_font; - -NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusIndexTabs, nautilus_index_tabs, GTK_TYPE_WIDGET) - -static void -nautilus_index_tabs_initialize_class (NautilusIndexTabsClass *class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - object_class->destroy = nautilus_index_tabs_destroy; - widget_class->expose_event = nautilus_index_tabs_expose; - widget_class->size_request = nautilus_index_tabs_size_request; - widget_class->size_allocate = nautilus_index_tabs_size_allocate; - - /* load the font */ - /* FIXME bugzilla.eazel.com 667: - * this shouldn't be hardwired - it should be fetched from preferences - */ - tab_font = gdk_font_load ("-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*"); -} - -/* utilities to set up the text color alternatives */ - -static void -setup_light_text(NautilusIndexTabs *index_tabs) -{ - gdk_color_parse ("rgb:ff/ff/ff", &index_tabs->details->text_color); - gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (index_tabs)), - &index_tabs->details->text_color, FALSE, TRUE); -} - -static void -setup_dark_text(NautilusIndexTabs *index_tabs) -{ - gdk_color_parse ("rgb:00/00/00", &index_tabs->details->text_color); - gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (index_tabs)), - &index_tabs->details->text_color, FALSE, TRUE); -} - -static void -nautilus_index_tabs_initialize (NautilusIndexTabs *index_tabs) -{ - GTK_WIDGET_SET_FLAGS (GTK_WIDGET(index_tabs), GTK_NO_WINDOW); - - index_tabs->details = g_new0 (NautilusIndexTabsDetails, 1); - - /* Initialize private members */ - index_tabs->details->tab_items = NULL; - index_tabs->details->tab_count = 0; - index_tabs->details->total_height = 0; - index_tabs->details->title_mode = FALSE; - index_tabs->details->title = NULL; - index_tabs->details->title_prelit = FALSE; - - /* set up the colors */ - gdk_color_parse ("rgb:99/99/99", &index_tabs->details->tab_color); - gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (index_tabs)), - &index_tabs->details->tab_color, FALSE, TRUE); - - gdk_color_parse ("rgb:ee/ee/ee", &index_tabs->details->prelight_color); - gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (index_tabs)), - &index_tabs->details->prelight_color, FALSE, TRUE); - - gdk_color_parse ("rgb:ff/ff/ff", &index_tabs->details->background_color); - gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (index_tabs)), - &index_tabs->details->background_color, FALSE, TRUE); - - gdk_color_parse ("rgb:00/00/00", &index_tabs->details->line_color); - gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (index_tabs)), - &index_tabs->details->line_color, FALSE, TRUE); - - gdk_color_parse ("rgb:d6/d6/d6", &index_tabs->details->hilight_color); - gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (index_tabs)), - &index_tabs->details->hilight_color, FALSE, TRUE); - - setup_light_text(index_tabs); - - index_tabs->details->title_prelit = FALSE; -} - -GtkWidget* -nautilus_index_tabs_new (void) -{ - return GTK_WIDGET (gtk_type_new (nautilus_index_tabs_get_type ())); -} - -/* utility to destroy all the storage used by a tab item */ - -static void -tab_item_destroy (TabItem *item) -{ - g_free (item->tab_text); - g_free (item); -} - -static void -nautilus_index_tabs_destroy (GtkObject *object) -{ - NautilusIndexTabs *index_tabs = NAUTILUS_INDEX_TABS(object); - - /* release the tab list, if any */ - if (index_tabs->details->tab_items != NULL) { - GList *next_tab; - for (next_tab = index_tabs->details->tab_items; next_tab != NULL; next_tab = next_tab->next) { - tab_item_destroy ((TabItem*)next_tab->data); - } - - g_list_free (index_tabs->details->tab_items); - } - - g_free (index_tabs->details->title); - - g_free (index_tabs->details); - - NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object)); -} - -/* determine the tab associated with the passed-in coordinates, and pass back the notebook - page index associated with it */ - -int nautilus_index_tabs_hit_test(NautilusIndexTabs *index_tabs, int x, int y) -{ - return draw_or_hit_test_all_tabs (index_tabs, FALSE, x, y); -} - -/* resize the widget based on the number of tabs */ - -static void -recalculate_size(NautilusIndexTabs *index_tabs) -{ - GtkWidget *widget = GTK_WIDGET (index_tabs); - - /* dummy hit test to make sure height measurement is valid */ - draw_or_hit_test_all_tabs(index_tabs, FALSE, -1000, -1000); - - widget->requisition.width = widget->parent ? widget->parent->allocation.width: 136; - if (index_tabs->details->title_mode) - widget->requisition.height = TAB_HEIGHT; - else - widget->requisition.height = index_tabs->details->total_height + TAB_TOP_GAP; - gtk_widget_queue_resize (widget); -} - -static void -nautilus_index_tabs_size_allocate(GtkWidget *widget, GtkAllocation *allocation) -{ - NautilusIndexTabs *index_tabs = NAUTILUS_INDEX_TABS(widget); - - NAUTILUS_CALL_PARENT_CLASS (GTK_WIDGET_CLASS, size_allocate, (widget, allocation)); - - /* dummy hit test to mesure height */ - draw_or_hit_test_all_tabs(index_tabs, FALSE, -1000, -1000); - - if (!index_tabs->details->title_mode) { - gint delta_height = widget->allocation.height - (index_tabs->details->total_height + TAB_TOP_GAP); - widget->allocation.height -= delta_height; - widget->allocation.y += delta_height; - } -} - -static void -nautilus_index_tabs_size_request (GtkWidget *widget, GtkRequisition *requisition) -{ - NautilusIndexTabs *index_tabs = NAUTILUS_INDEX_TABS(widget); - - /* dummy hit test to make sure height measurement is valid */ - draw_or_hit_test_all_tabs(index_tabs, FALSE, -1000, -1000); - requisition->width = widget->parent ? widget->parent->allocation.width: 136; - if (index_tabs->details->title_mode) - requisition->height = TAB_HEIGHT; - else - requisition->height = index_tabs->details->total_height + TAB_TOP_GAP; -} - -/* draw a single tab at the passed-in position, return the total width */ - -static int -draw_one_tab (NautilusIndexTabs *index_tabs, GdkGC *gc, - char *tab_name, int x, int y, gboolean prelight_flag) -{ - int text_y_offset; - int tab_bottom; - int tab_right; - int name_width; - int total_width; - GtkWidget *widget; - - g_assert (index_tabs != NULL); - g_assert (NAUTILUS_IS_INDEX_TABS (index_tabs)); - - /* measure the name and compute the bounding box */ - name_width = gdk_string_width (tab_font, tab_name); - total_width = name_width + 2*TAB_MARGIN; - - widget = GTK_WIDGET (index_tabs); - - /* FIXME bugzilla.eazel.com 668: - * we must "ellipsize" the name if it doesn't fit, for now, assume it does - */ - - /* fill the tab rectangle with the tab color */ - - gdk_gc_set_foreground (gc, prelight_flag ? &index_tabs->details->prelight_color : &index_tabs->details->tab_color); - gdk_draw_rectangle (widget->window, gc, TRUE, x, y + 1, total_width, TAB_HEIGHT - 1); - - /* draw the border */ - gdk_gc_set_foreground (gc, &index_tabs->details->line_color); - gdk_draw_line(widget->window, gc, x + 1, y, x + total_width - 2, y); - gdk_draw_line(widget->window, gc, x, y + 1, x, y + TAB_HEIGHT - 1); - gdk_draw_line(widget->window, gc, x + total_width - 1, y + 1, x + total_width - 1, y + TAB_HEIGHT - 1); - - /* draw the highlights for extra dimensionality */ - gdk_gc_set_foreground (gc, &index_tabs->details->hilight_color); - gdk_draw_line(widget->window, gc, x + 2, y + 2, x + total_width - 3, y + 2); - gdk_draw_line(widget->window, gc, x + 2, y + 2, x + 2, y + TAB_HEIGHT - 1); - - /* draw the metaview name */ - text_y_offset = y + (TAB_HEIGHT >> 1) + 5; - gdk_gc_set_foreground (gc, prelight_flag ? &index_tabs->details->prelit_text_color : &index_tabs->details->text_color); - gdk_draw_string (widget->window, tab_font, gc, x + TAB_MARGIN, text_y_offset, tab_name); - - - /* draw the bottom lines */ - tab_bottom = y + TAB_HEIGHT - 1; - gdk_gc_set_foreground (gc, &index_tabs->details->line_color); - tab_right = x + 2*TAB_MARGIN + name_width; - gdk_gc_set_foreground (gc, &index_tabs->details->line_color); - gdk_draw_line(widget->window, gc, tab_right, tab_bottom, widget->parent->allocation.width, tab_bottom); - gdk_draw_line(widget->window, gc, 0, tab_bottom, x, tab_bottom); - - return name_width + 2*TAB_MARGIN; -} - -/* draw or hit test all of the currently visible tabs */ - -static int -draw_or_hit_test_all_tabs (NautilusIndexTabs *index_tabs, gboolean draw_flag, int test_x, int test_y) -{ - GdkGC *temp_gc; - int name_width; - int tab_width; - GList *next_tab; - GtkWidget *widget; - int x_pos; - int y_pos; - int total_height; - - g_assert (index_tabs != NULL); - g_assert (NAUTILUS_IS_INDEX_TABS (index_tabs)); - - next_tab = index_tabs->details->tab_items; - - widget = GTK_WIDGET (index_tabs); - - x_pos = widget->allocation.x + 4; - y_pos = widget->allocation.y + widget->allocation.height - TAB_HEIGHT; - total_height = TAB_HEIGHT; - - /* handle hit-testing for title mode */ - if (index_tabs->details->title_mode && !draw_flag) { - int edge_width = 2 * TAB_MARGIN; - if (index_tabs->details->title == NULL) { - return -1; - } - name_width = gdk_string_width (tab_font, index_tabs->details->title); - index_tabs->details->total_height = total_height; - if ((test_x >= TITLE_TAB_OFFSET) && (test_x < (TITLE_TAB_OFFSET + name_width + edge_width))) { - return 0; - } - return -1; - } - - /* allocate a graphic context and clear the space below the top tabs to the background color */ - if (draw_flag) { - int y_top = widget->allocation.y + TAB_HEIGHT + TAB_TOP_GAP; - int fill_height = widget->allocation.y + widget->allocation.height - y_top; - temp_gc = gdk_gc_new(widget->window); - gdk_gc_set_foreground (temp_gc, &index_tabs->details->background_color); - gdk_draw_rectangle (widget->window, temp_gc, TRUE, widget->allocation.x, y_top, widget->allocation.width, fill_height); - } - - /* draw as many tabs per row as will fit */ - - while (next_tab != NULL) { - TabItem *this_item = next_tab->data; - - if (draw_flag && this_item->visible) - tab_width = draw_one_tab(index_tabs, temp_gc, this_item->tab_text, x_pos, y_pos, this_item->prelit); - else { - int edge_width = 2 * TAB_MARGIN; - name_width = gdk_string_width(tab_font, this_item->tab_text); - tab_width = name_width + edge_width; - if (!draw_flag && (test_y >= y_pos) && (test_y <= (y_pos + TAB_HEIGHT)) && - (test_x >= x_pos) && (test_x <= x_pos + tab_width)) - return this_item->notebook_page; - } - - next_tab = next_tab->next; - if (next_tab != NULL) - this_item = (TabItem*) next_tab->data; - - /* bump the x-position, and see if it fits */ - x_pos += tab_width + TAB_H_GAP; - - if (x_pos > (widget->allocation.x + widget->allocation.width - 48)) { - /* wrap to the next line */ - x_pos = widget->allocation.x + 4; - y_pos -= TAB_HEIGHT + TAB_ROW_V_OFFSET; - if ((next_tab != NULL) && ((next_tab->next != NULL) || this_item->visible)) - total_height += TAB_HEIGHT + TAB_ROW_V_OFFSET; - } - } - - if (draw_flag) - gdk_gc_unref(temp_gc); - index_tabs->details->total_height = total_height; - return -1; -} - -/* find a tab with a given name, or return NULL if we can't find one */ -static TabItem * -tab_item_find_by_name (NautilusIndexTabs *index_tabs, const char *name) -{ - GList *iterator; - - g_return_val_if_fail (index_tabs != NULL, NULL); - g_return_val_if_fail (NAUTILUS_IS_INDEX_TABS (index_tabs), NULL); - g_return_val_if_fail (name != NULL, NULL); - - for (iterator = index_tabs->details->tab_items; iterator != NULL; iterator = iterator->next) { - TabItem *tab_item = iterator->data; - - g_assert (tab_item != NULL); - g_assert (tab_item->tab_text != NULL); - - if (strcmp (tab_item->tab_text, name) == 0) { - return tab_item; - } - } - - return NULL; -} - -/* handle an expose event by drawing the tabs */ - -static int -nautilus_index_tabs_expose (GtkWidget *widget, GdkEventExpose *event) -{ - NautilusIndexTabs *index_tabs; - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_INDEX_TABS (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - if (widget->window == NULL) { - return FALSE; - } - - index_tabs = NAUTILUS_INDEX_TABS (widget); - - /* draw the tabs */ - if (index_tabs->details->title_mode) { - GdkGC* temp_gc = gdk_gc_new(widget->window); - int x_pos = widget->allocation.x; - int y_pos = widget->allocation.y; - - draw_one_tab (index_tabs, temp_gc, index_tabs->details->title, x_pos + TITLE_TAB_OFFSET, y_pos, index_tabs->details->title_prelit); - gdk_gc_unref (temp_gc); - } else { - if (index_tabs->details->tab_count > 0) { - draw_or_hit_test_all_tabs (index_tabs, TRUE, 0, 0); - } - } - - return FALSE; -} - -/* add a new tab entry, return TRUE if we succeed */ - -gboolean -nautilus_index_tabs_add_view (NautilusIndexTabs *index_tabs, const char *name, GtkWidget *new_view, int page_num) -{ - TabItem *new_tab_item; - - g_return_val_if_fail (index_tabs != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_INDEX_TABS (index_tabs), FALSE); - g_return_val_if_fail (name != NULL, FALSE); - g_return_val_if_fail (new_view != NULL, FALSE); - - /* Check to see if we already have one with this name, if so, refuse to add it */ - if (tab_item_find_by_name (index_tabs, name)) { - g_warning ("nautilus_index_tabs_add_view: Trying to add duplicate item '%s'\n", name); - return FALSE; - } - - /* allocate a new entry, and initialize it */ - new_tab_item = g_new0 (TabItem, 1); - new_tab_item->tab_text = g_strdup (name); - new_tab_item->visible = TRUE; - new_tab_item->prelit = FALSE; - new_tab_item->tab_view = new_view; - new_tab_item->notebook_page = page_num; - - /* add it to the list */ - index_tabs->details->tab_items = g_list_append(index_tabs->details->tab_items, new_tab_item); - - index_tabs->details->tab_count += 1; - recalculate_size (index_tabs); - gtk_widget_queue_draw (GTK_WIDGET (index_tabs)); - - return TRUE; -} - -/* return the name of the tab with the passed in index */ - -char* -nautilus_index_tabs_get_title_from_index (NautilusIndexTabs *index_tabs, int which_tab) -{ - GList *next_tab; - - g_return_val_if_fail (index_tabs != NULL, NULL); - g_return_val_if_fail (NAUTILUS_IS_INDEX_TABS (index_tabs), NULL); - - for (next_tab = index_tabs->details->tab_items; next_tab != NULL; next_tab = next_tab->next) { - TabItem *item = next_tab->data; - if (item->notebook_page == which_tab) - return g_strdup (item->tab_text); - } - - /* shouldn't ever get here... */ - return g_strdup (""); -} - -/* remove the specified tab entry */ - -void -nautilus_index_tabs_remove_view (NautilusIndexTabs *index_tabs, const char *name) -{ - TabItem *tab_item; - - g_return_if_fail (index_tabs != NULL); - g_return_if_fail (NAUTILUS_IS_INDEX_TABS (index_tabs)); - g_return_if_fail (name != NULL); - - /* Look up the item */ - tab_item = tab_item_find_by_name (index_tabs, name); - - if (tab_item == NULL) { - g_warning ("nautilus_index_tabs_remove_view: Trying to remove a non-existing item '%s'\n", name); - return; - } - - /* Remove the item from the list */ - index_tabs->details->tab_items = g_list_remove (index_tabs->details->tab_items, tab_item); - - tab_item_destroy (tab_item); - - index_tabs->details->tab_count -= 1; - - recalculate_size (index_tabs); - gtk_widget_queue_draw (GTK_WIDGET (index_tabs)); -} - -/* prelight a tab, from its associated notebook page number, by setting the prelight flag of - the proper tab and clearing the others */ - -void -nautilus_index_tabs_prelight_tab (NautilusIndexTabs *index_tabs, int which_tab) -{ - GList *next_tab; - gboolean is_prelit; - gboolean changed = FALSE; - - g_return_if_fail (index_tabs != NULL); - g_return_if_fail (NAUTILUS_IS_INDEX_TABS (index_tabs)); - - if (index_tabs->details->title_mode) { - gboolean is_prelit = which_tab != -1; - if (index_tabs->details->title_prelit != is_prelit) { - index_tabs->details->title_prelit = is_prelit; - changed = TRUE; - } - } - else - for (next_tab = index_tabs->details->tab_items; next_tab != NULL; next_tab = next_tab->next) { - TabItem *item = next_tab->data; - is_prelit = (item->notebook_page == which_tab); - if (item->prelit != is_prelit) { - item->prelit = is_prelit; - changed = TRUE; - } - } - - if (changed) - gtk_widget_queue_draw(GTK_WIDGET(index_tabs)); -} - -/* select a tab, from its associated notebook page number, by making it invisible - and all the others visible */ - -void -nautilus_index_tabs_select_tab (NautilusIndexTabs *index_tabs, int which_tab) -{ - GList *next_tab; - - g_return_if_fail (index_tabs != NULL); - g_return_if_fail (NAUTILUS_IS_INDEX_TABS (index_tabs)); - - for (next_tab = index_tabs->details->tab_items; next_tab != NULL; next_tab = next_tab->next) { - TabItem *item = next_tab->data; - item->visible = (item->notebook_page != which_tab); - item->prelit = FALSE; - } - - recalculate_size(index_tabs); - gtk_widget_queue_draw(GTK_WIDGET(index_tabs)); -} - -/* utility routine that returns true if the passed-in color is lighter than average - this could be more sophisticated by weighting the components for luminosity, but the simple adding - should suffice, since either way is OK for the middle ground */ - -static gboolean -is_light_color(GdkColor *color) -{ - int total_color = color->red + color->green + color->blue; - return total_color > 160*4096*3; /* biased slightly so the default of 99/99/99 uses light text */ -} - -/* set the background color associated with a tab */ - -void -nautilus_index_tabs_set_color (NautilusIndexTabs *index_tabs, - const char *color_spec) -{ - g_return_if_fail (index_tabs != NULL); - g_return_if_fail (NAUTILUS_IS_INDEX_TABS (index_tabs)); - g_return_if_fail (color_spec != NULL); - - gdk_color_parse (color_spec, &index_tabs->details->tab_color); - gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (index_tabs)), - &index_tabs->details->tab_color, FALSE, TRUE); - - if (is_light_color(&index_tabs->details->tab_color)) - setup_dark_text(index_tabs); - else - setup_light_text(index_tabs); - - gtk_widget_queue_draw (GTK_WIDGET(index_tabs)); -} - -/* receive a dropped color */ - -void -nautilus_index_tabs_receive_dropped_color (NautilusIndexTabs *index_tabs, - int x, int y, - GtkSelectionData *selection_data) -{ - guint16 *channels; - char *color_spec; - - g_return_if_fail (index_tabs != NULL); - g_return_if_fail (NAUTILUS_IS_INDEX_TABS (index_tabs)); - g_return_if_fail (selection_data != NULL); - - /* Convert the selection data into a color spec. */ - if (selection_data->length != 8 || selection_data->format != 16) { - g_warning ("received invalid color data"); - return; - } - - channels = (guint16 *) selection_data->data; - color_spec = g_strdup_printf ("rgb:%04hX/%04hX/%04hX", channels[0], channels[1], channels[2]); - nautilus_index_tabs_set_color(index_tabs, color_spec); - g_free (color_spec); -} - -/* set the title (used in title mode only) */ - -void -nautilus_index_tabs_set_title (NautilusIndexTabs *index_tabs, const char *new_title) -{ - g_return_if_fail (index_tabs != NULL); - g_return_if_fail (NAUTILUS_IS_INDEX_TABS (index_tabs)); - g_return_if_fail (new_title != NULL); - - g_free(index_tabs->details->title); - index_tabs->details->title = g_strdup (new_title); -} - -/* set the title mode boolean */ -void -nautilus_index_tabs_set_title_mode (NautilusIndexTabs *index_tabs, gboolean is_title_mode) -{ - g_return_if_fail (index_tabs != NULL); - g_return_if_fail (NAUTILUS_IS_INDEX_TABS (index_tabs)); - - if (index_tabs->details->title_mode != !!is_title_mode) { - index_tabs->details->title_mode = !!is_title_mode; - recalculate_size (index_tabs); - gtk_widget_queue_draw (GTK_WIDGET (index_tabs)); - } -} - -/* set the visibility of the selected tab */ - -void -nautilus_index_tabs_set_visible (NautilusIndexTabs *index_tabs, - const char *name, - gboolean is_visible) -{ - TabItem *tab_item; - - g_return_if_fail (index_tabs != NULL); - g_return_if_fail (NAUTILUS_IS_INDEX_TABS (index_tabs)); - g_return_if_fail (name != NULL); - - /* Look up the item */ - tab_item = tab_item_find_by_name (index_tabs, name); - - if (tab_item == NULL) { - g_warning ("nautilus_index_tabs_set_visible: Trying to munge a non-existing item '%s'\n", name); - return; - } - - if (tab_item->visible != is_visible) { - tab_item->visible = is_visible; - gtk_widget_queue_draw (GTK_WIDGET (index_tabs)); - } -} diff --git a/src/nautilus-index-tabs.h b/src/nautilus-index-tabs.h deleted file mode 100644 index fc2e4b39b..000000000 --- a/src/nautilus-index-tabs.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* Nautilus - * Copyright (C) 2000 Eazel, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Andy Hertzfeld <andy@eazel.com> - * - * This is the header file for the tabs widget for the index panel. - */ - -#ifndef NAUTILUS_INDEX_TABS_H -#define NAUTILUS_INDEX_TABS_H - -#include <gtk/gtkmisc.h> - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define NAUTILUS_TYPE_INDEX_TABS (nautilus_index_tabs_get_type ()) -#define NAUTILUS_INDEX_TABS(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_INDEX_TABS, NautilusIndexTabs)) -#define NAUTILUS_INDEX_TABS_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_INDEX_TABS, NautilusIndexTabsClass)) -#define NAUTILUS_IS_INDEX_TABS(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_INDEX_TABS)) -#define NAUTILUS_IS_INDEX_TABS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_INDEX_TABS)) - -typedef struct NautilusIndexTabs NautilusIndexTabs; -typedef struct NautilusIndexTabsClass NautilusIndexTabsClass; -typedef struct NautilusIndexTabsDetails NautilusIndexTabsDetails; - -struct NautilusIndexTabs -{ - GtkMisc base; - NautilusIndexTabsDetails *details; -}; - -struct NautilusIndexTabsClass -{ - GtkMiscClass parent_class; -}; - -GtkType nautilus_index_tabs_get_type (void); -GtkWidget *nautilus_index_tabs_new (void); -gboolean nautilus_index_tabs_add_view (NautilusIndexTabs *index_tabs, - const char *name, - GtkWidget *new_view, - int page_number); -char * nautilus_index_tabs_get_title_from_index (NautilusIndexTabs *index_tabs, - int which_tab); -int nautilus_index_tabs_hit_test (NautilusIndexTabs *index_tabs, - int x, - int y); -void nautilus_index_tabs_set_color (NautilusIndexTabs *index_tabs, - const char *color_spec); - -void nautilus_index_tabs_receive_dropped_color (NautilusIndexTabs *index_tabs, - int x, - int y, - GtkSelectionData *selection_data); -void nautilus_index_tabs_remove_view (NautilusIndexTabs *index_tabs, - const char *name); -void nautilus_index_tabs_prelight_tab (NautilusIndexTabs *index_tabs, - int which_tab); -void nautilus_index_tabs_select_tab (NautilusIndexTabs *index_tabs, - int which_tab); -void nautilus_index_tabs_set_title (NautilusIndexTabs *index_tabs, - const char *new_title); -void nautilus_index_tabs_set_title_mode (NautilusIndexTabs *index_tabs, - gboolean is_title_mode); -void nautilus_index_tabs_set_visible (NautilusIndexTabs *index_tabs, - const char *name, - gboolean is_visible); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* NAUTILUS_INDEX_TABS_H */ diff --git a/src/nautilus-index-title.c b/src/nautilus-index-title.c deleted file mode 100644 index 9c1a64f94..000000000 --- a/src/nautilus-index-title.c +++ /dev/null @@ -1,455 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* Nautilus - * Copyright (C) 2000 Eazel, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Andy Hertzfeld <andy@eazel.com> - * - * This is the index title widget, which is the title part of the index panel - * - */ - -#include <config.h> -#include "nautilus-index-title.h" - -#include <ctype.h> -#include <string.h> -#include <math.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkpixmap.h> -#include <gtk/gtksignal.h> -#include <libgnomevfs/gnome-vfs-types.h> -#include <libgnomevfs/gnome-vfs-uri.h> -#include <libnautilus-extensions/nautilus-file-attributes.h> -#include <libnautilus-extensions/nautilus-gdk-extensions.h> -#include <libnautilus-extensions/nautilus-glib-extensions.h> -#include <libnautilus-extensions/nautilus-gtk-extensions.h> -#include <libnautilus-extensions/nautilus-gtk-macros.h> -#include <libnautilus-extensions/nautilus-directory.h> -#include <libnautilus-extensions/nautilus-icon-factory.h> -#include <libnautilus-extensions/nautilus-metadata.h> - -static void nautilus_index_title_initialize_class (NautilusIndexTitleClass *klass); -static void nautilus_index_title_destroy (GtkObject *object); -static void nautilus_index_title_initialize (NautilusIndexTitle *pixmap); -static gboolean nautilus_index_title_button_press_event (GtkWidget *widget, - GdkEventButton *event); -static void nautilus_index_title_update_icon (NautilusIndexTitle *index_title); -static void nautilus_index_title_update_label (NautilusIndexTitle *index_title); -static void nautilus_index_title_update_info (NautilusIndexTitle *index_title); - -struct NautilusIndexTitleDetails { - NautilusFile *file; - guint file_changed_connection; - char *requested_text; - GtkWidget *icon; - GtkWidget *title; - GtkWidget *more_info; - GtkWidget *emblem_box; - GtkWidget *notes; -}; - -/* constants */ - -#define MAX_ICON_WIDTH 100 -#define MAX_ICON_HEIGHT 120 - -/* button assignments */ - -NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusIndexTitle, nautilus_index_title, gtk_vbox_get_type ()) - -static void -nautilus_index_title_initialize_class (NautilusIndexTitleClass *class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass*) class; - widget_class = (GtkWidgetClass*) class; - - object_class->destroy = nautilus_index_title_destroy; - widget_class->button_press_event = nautilus_index_title_button_press_event; -} - -static void -nautilus_index_title_initialize (NautilusIndexTitle *index_title) -{ - index_title->details = g_new0 (NautilusIndexTitleDetails, 1); - - /* Register to find out about icon theme changes */ - gtk_signal_connect_object_while_alive (nautilus_icon_factory_get (), - "icons_changed", - nautilus_index_title_update_icon, - GTK_OBJECT (index_title)); -} - -/* destroy by throwing away private storage */ - -static void -release_file (NautilusIndexTitle *index_title) -{ - if (index_title->details->file_changed_connection != 0) { - gtk_signal_disconnect (GTK_OBJECT (index_title->details->file), - index_title->details->file_changed_connection); - index_title->details->file_changed_connection = 0; - } - - if (index_title->details->file != NULL) { - if (nautilus_file_is_directory (index_title->details->file)) { - nautilus_file_monitor_remove (index_title->details->file, index_title); - } - nautilus_file_unref (index_title->details->file); - index_title->details->file = NULL; - } -} - -static void -nautilus_index_title_destroy (GtkObject *object) -{ - NautilusIndexTitle *index_title; - - index_title = NAUTILUS_INDEX_TITLE (object); - - release_file (index_title); - - g_free (index_title->details->requested_text); - g_free (index_title->details); - - NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object)); -} - -/* return a new index title object */ - -GtkWidget * -nautilus_index_title_new (void) -{ - return GTK_WIDGET (gtk_type_new (nautilus_index_title_get_type ())); -} - -/* set up the icon image */ -static void -nautilus_index_title_update_icon (NautilusIndexTitle *index_title) -{ - GdkPixmap *pixmap; - GdkBitmap *mask; - GdkPixbuf *pixbuf; - - /* NULL can happen because nautilus_file_get returns NULL for the root. */ - if (index_title->details->file == NULL) { - return; - } - pixbuf = nautilus_icon_factory_get_pixbuf_for_file (index_title->details->file, - NAUTILUS_ICON_SIZE_STANDARD); - - /* make a pixmap and mask to pass to the widget */ - gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &mask, 128); - gdk_pixbuf_unref (pixbuf); - - /* if there's no pixmap so far, so allocate one */ - if (index_title->details->icon != NULL) { - gtk_pixmap_set (GTK_PIXMAP (index_title->details->icon), - pixmap, mask); - } else { - index_title->details->icon = GTK_WIDGET (gtk_pixmap_new (pixmap, mask)); - gtk_widget_show (index_title->details->icon); - gtk_box_pack_start (GTK_BOX (index_title), index_title->details->icon, 0, 0, 0); - gtk_box_reorder_child (GTK_BOX (index_title), index_title->details->icon, 0); - } -} - -/* set up the filename label */ -static void -nautilus_index_title_update_label (NautilusIndexTitle *index_title) -{ - GdkFont *label_font; - char *displayed_text; - - if (index_title->details->requested_text == NULL) { - /* Use empty string to replace previous contents. */ - displayed_text = g_strdup (""); - } else { - displayed_text = g_strdup (index_title->details->requested_text); - } - - /* split the filename into two lines if necessary */ - if (strlen(displayed_text) >= 16) { - /* find an appropriate split point if we can */ - int index; - int mid_point = strlen(displayed_text) >> 1; - int quarter_point = mid_point >> 1; - for (index = 0; index < quarter_point; index++) { - int split_offset = 0; - - if (!isalnum(displayed_text[mid_point + index])) - split_offset = mid_point + index; - else if (!isalnum(displayed_text[mid_point - index])) - split_offset = mid_point - index; - - if (split_offset != 0) { - char *buffer = g_malloc(strlen(displayed_text) + 2); - - /* build the new string, with a blank inserted, also remembering them separately for measuring */ - memcpy(buffer, displayed_text, split_offset); - buffer[split_offset] = '\n'; - strcpy(&buffer[split_offset + 1], &displayed_text[split_offset]); - - /* free up the old string and replace it with the new one with the return inserted */ - - g_free(displayed_text); - displayed_text = buffer; - break; - } - } - } - - if (index_title->details->title != NULL) { - gtk_label_set_text (GTK_LABEL (index_title->details->title), displayed_text); - } else { - index_title->details->title = GTK_WIDGET (gtk_label_new (displayed_text)); - gtk_label_set_line_wrap (GTK_LABEL (index_title->details->title), TRUE); - gtk_widget_show (index_title->details->title); - gtk_box_pack_start (GTK_BOX (index_title), index_title->details->title, 0, 0, 0); - gtk_box_reorder_child (GTK_BOX (index_title), index_title->details->title, 1); - } - - /* FIXME bugzilla.eazel.com 667: - * don't use hardwired font like this - get it from preferences - */ - label_font = nautilus_get_largest_fitting_font (displayed_text, GTK_WIDGET (index_title)->allocation.width - 4, - "-*-helvetica-medium-r-normal-*-%d-*-*-*-*-*-*-*"); - - nautilus_gtk_widget_set_font (index_title->details->title, label_font); - g_free (displayed_text); -} - -/* add a pixbuf to the emblem box */ -static void -nautilus_index_title_add_pixbuf(NautilusIndexTitle *index_title, GdkPixbuf *pixbuf) -{ - GdkPixmap *pixmap; - GdkBitmap *mask; - GtkWidget *pixmap_widget; - - if (index_title->details->emblem_box == NULL) { - /* alllocate a new emblem box */ - index_title->details->emblem_box = gtk_hbox_new(FALSE, 0); - gtk_widget_show(index_title->details->emblem_box); - gtk_box_pack_start(GTK_BOX (index_title), index_title->details->emblem_box, 0, 0, 0); - } - - gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &mask, 128); - pixmap_widget = GTK_WIDGET (gtk_pixmap_new (pixmap, mask)); - gtk_widget_show (pixmap_widget); - gtk_container_add(GTK_CONTAINER(index_title->details->emblem_box), pixmap_widget); -} - -/* set up more info about the file */ - -void -nautilus_index_title_update_info (NautilusIndexTitle *index_title) -{ - NautilusFile *file; - GList *emblem_icons, *current_emblem; - char *notes_text; - char *temp_string; - char *info_string; - - /* NULL can happen because nautilus_file_get returns NULL for the root. */ - file = index_title->details->file; - if (file == NULL) { - return; - } - - info_string = nautilus_file_get_string_attribute(file, "type"); - if (info_string == NULL) { - return; - } - - /* combine the type and the size */ - temp_string = nautilus_file_get_string_attribute(file, "size"); - if (temp_string != NULL) { - char *new_info_string = g_strconcat(info_string, ", ", temp_string, NULL); - g_free (info_string); - g_free (temp_string); - info_string = new_info_string; - } - - /* append the date modified */ - temp_string = nautilus_file_get_string_attribute(file, "date_modified"); - if (temp_string != NULL) { - char *new_info_string = g_strconcat(info_string, "\n", temp_string, NULL); - g_free (info_string); - g_free (temp_string); - info_string = new_info_string; - } - - /* set up the emblems if necessary. First, deallocate any existing ones */ - if (index_title->details->emblem_box) { - gtk_widget_destroy(index_title->details->emblem_box); - index_title->details->emblem_box = NULL; - } - - /* fetch the emblem icons from metadata */ - emblem_icons = nautilus_icon_factory_get_emblem_icons_for_file (file); - if (emblem_icons) { - GdkPixbuf *emblem_pixbuf; - - /* loop through the list of emblems, installing them in the box */ - for (current_emblem = emblem_icons; current_emblem != NULL; current_emblem = current_emblem->next) { - emblem_pixbuf = nautilus_icon_factory_get_pixbuf_for_icon - (current_emblem->data, - NAUTILUS_ICON_SIZE_STANDARD, NAUTILUS_ICON_SIZE_STANDARD, - NAUTILUS_ICON_SIZE_STANDARD, NAUTILUS_ICON_SIZE_STANDARD); - if (emblem_pixbuf != NULL) { - nautilus_index_title_add_pixbuf (index_title, emblem_pixbuf); - gdk_pixbuf_unref (emblem_pixbuf); - } - } - - nautilus_scalable_icon_list_free (emblem_icons); - } - - /* set up the additional text info */ - - if (index_title->details->more_info) - gtk_label_set_text(GTK_LABEL(index_title->details->more_info), info_string); - else { - index_title->details->more_info = GTK_WIDGET(gtk_label_new(info_string)); - gtk_widget_show (index_title->details->more_info); - gtk_box_pack_start (GTK_BOX (index_title), index_title->details->more_info, 0, 0, 0); - gtk_box_reorder_child (GTK_BOX (index_title), index_title->details->more_info, 2); - } - - /* FIXME bugzilla.eazel.com 667: - * don't use hardwired font like this - get it from preferences - */ - nautilus_gtk_widget_set_font_by_name (index_title->details->more_info, - "-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*"); - - g_free(info_string); - - /* see if there are any notes for this file. If so, display them */ - notes_text = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_NOTES, NULL); - if (notes_text != NULL) { - if (index_title->details->notes != NULL) - gtk_label_set_text(GTK_LABEL(index_title->details->notes), notes_text); - else { - index_title->details->notes = GTK_WIDGET(gtk_label_new(notes_text)); - gtk_label_set_line_wrap(GTK_LABEL(index_title->details->notes), TRUE); - gtk_widget_show (index_title->details->notes); - gtk_box_pack_start (GTK_BOX (index_title), index_title->details->notes, 0, 0, 0); - gtk_box_reorder_child (GTK_BOX (index_title), index_title->details->notes, 3); - } - - /* FIXME bugzilla.eazel.com 667: - * don't use hardwired font like this - get it from preferences - */ - nautilus_gtk_widget_set_font_by_name (index_title->details->notes, - "-*-helvetica-medium-r-normal-*-12-*-*-*-*-*-*-*"); - - g_free (notes_text); - } else if (index_title->details->notes != NULL) { - gtk_label_set_text (GTK_LABEL (index_title->details->notes), ""); - } -} - -/* return the filename text */ - -char * -nautilus_index_title_get_text(NautilusIndexTitle *index_title) -{ - if (index_title->details->requested_text) - return g_strdup(index_title->details->requested_text); - return NULL; -} - -/* set up the filename text */ - -void -nautilus_index_title_set_text (NautilusIndexTitle *index_title, const char* new_text) -{ - g_free (index_title->details->requested_text); - index_title->details->requested_text = g_strdup (new_text); - - /* Recompute the displayed text. */ - nautilus_index_title_update_label (index_title); -} - -static void -update (NautilusIndexTitle *index_title) -{ - /* add the icon */ - nautilus_index_title_update_icon (index_title); - - /* add the name, in a variable-sized label */ - nautilus_index_title_update_label (index_title); - - /* add various info */ - nautilus_index_title_update_info (index_title); -} - -void -nautilus_index_title_set_uri (NautilusIndexTitle *index_title, - const char* new_uri, - const char* initial_text) -{ - GList *attributes; - - release_file (index_title); - - index_title->details->file = nautilus_file_get (new_uri); - if (index_title->details->file != NULL) { - index_title->details->file_changed_connection = - gtk_signal_connect_object (GTK_OBJECT (index_title->details->file), - "changed", - update, - GTK_OBJECT (index_title)); - /* Monitor the item count so we can update when it is known. */ - if (nautilus_file_is_directory (index_title->details->file)) { - attributes = g_list_prepend (NULL, - NAUTILUS_FILE_ATTRIBUTE_DIRECTORY_ITEM_COUNT); - nautilus_file_monitor_add (index_title->details->file, index_title, - attributes, FALSE); - g_list_free (attributes); - } - } - - g_free (index_title->details->requested_text); - index_title->details->requested_text = g_strdup (initial_text); - - update (index_title); -} - -/* handle a button press */ - -static gboolean -nautilus_index_title_button_press_event (GtkWidget *widget, GdkEventButton *event) -{ - /* - NautilusIndexTitle *index_title = NAUTILUS_INDEX_TITLE (widget); - */ - g_message ("button press"); - - return TRUE; -} - -gboolean -nautilus_index_title_hit_test_icon (NautilusIndexTitle *title, int x, int y) -{ - return nautilus_point_in_widget (title->details->icon, x, y); -} diff --git a/src/nautilus-index-title.h b/src/nautilus-index-title.h deleted file mode 100644 index 5b29d6c9e..000000000 --- a/src/nautilus-index-title.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* Nautilus - * Copyright (C) 2000 Eazel, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Andy Hertzfeld <andy@eazel.com> - * - * This is the header file for the index title panel, which is part of the index panel - * - */ - -#ifndef NAUTILUS_INDEX_TITLE_H -#define NAUTILUS_INDEX_TITLE_H - -#include <gtk/gtkvbox.h> - -#define NAUTILUS_TYPE_INDEX_TITLE (nautilus_index_title_get_type ()) -#define NAUTILUS_INDEX_TITLE(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_INDEX_TITLE, NautilusIndexTitle)) -#define NAUTILUS_INDEX_TITLE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_INDEX_TITLE, NautilusIndexTitleClass)) -#define NAUTILUS_IS_INDEX_TITLE(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_INDEX_TITLE)) -#define NAUTILUS_IS_INDEX_TITLE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_INDEX_TITLE)) - -typedef struct NautilusIndexTitle NautilusIndexTitle; -typedef struct NautilusIndexTitleClass NautilusIndexTitleClass; -typedef struct NautilusIndexTitleDetails NautilusIndexTitleDetails; - -struct NautilusIndexTitle -{ - GtkVBox box; - NautilusIndexTitleDetails *details; -}; - -struct NautilusIndexTitleClass -{ - GtkVBoxClass parent_class; -}; - -GtkType nautilus_index_title_get_type (void); -GtkWidget *nautilus_index_title_new (void); -void nautilus_index_title_set_uri (NautilusIndexTitle *index_title, - const char *new_uri, - const char *initial_text); -void nautilus_index_title_set_text (NautilusIndexTitle *index_title, - const char *new_title); -char* nautilus_index_title_get_text (NautilusIndexTitle *index_title); -gboolean nautilus_index_title_hit_test_icon (NautilusIndexTitle *index_title, - int x, - int y); - -#endif /* NAUTILUS_INDEX_TITLE_H */ diff --git a/src/nautilus-information-panel.c b/src/nautilus-information-panel.c index e3d0a4031..5dfdae025 100644 --- a/src/nautilus-information-panel.c +++ b/src/nautilus-information-panel.c @@ -25,7 +25,7 @@ */ #include <config.h> -#include "ntl-index-panel.h" +#include "nautilus-sidebar.h" #include <math.h> #include <libgnomeui/gnome-uidefs.h> @@ -45,8 +45,8 @@ #include <libnautilus-extensions/nautilus-program-choosing.h> #include <libnautilus-extensions/nautilus-string.h> #include <nautilus-widgets/nautilus-preferences.h> -#include "nautilus-index-tabs.h" -#include "nautilus-index-title.h" +#include "nautilus-sidebar-tabs.h" +#include "nautilus-sidebar-title.h" struct NautilusIndexPanelDetails { GtkVBox *container; diff --git a/src/nautilus-information-panel.h b/src/nautilus-information-panel.h index 6a6dc2ef4..87e43a2c2 100644 --- a/src/nautilus-information-panel.h +++ b/src/nautilus-information-panel.h @@ -23,11 +23,11 @@ * in a vertical panel and hosts the meta-views. */ -#ifndef NTL_INDEX_PANEL_H -#define NTL_INDEX_PANEL_H +#ifndef NAUTILUS_SIDEBAR_H +#define NAUTILUS_SIDEBAR_H #include <gtk/gtkeventbox.h> -#include "ntl-view.h" +#include "nautilus-view-frame.h" typedef struct NautilusIndexPanel NautilusIndexPanel; typedef struct NautilusIndexPanelClass NautilusIndexPanelClass; @@ -68,4 +68,4 @@ void nautilus_index_panel_set_uri (NautilusIndexPanel *p void nautilus_index_panel_set_title (NautilusIndexPanel *panel, const char *new_title); -#endif /* NTL_INDEX_PANEL_H */ +#endif /* NAUTILUS_SIDEBAR_H */ diff --git a/src/nautilus-main.c b/src/nautilus-main.c index 55cd45e2a..2a90b6778 100644 --- a/src/nautilus-main.c +++ b/src/nautilus-main.c @@ -31,7 +31,7 @@ #include <config.h> #include "nautilus-self-check-functions.h" -#include "ntl-app.h" +#include "nautilus-application.h" #include <libnautilus-extensions/nautilus-debug.h> #include <libnautilus-extensions/nautilus-lib-self-check-functions.h> #include <libnautilus-extensions/nautilus-self-checks.h> diff --git a/src/nautilus-navigation-window-menus.c b/src/nautilus-navigation-window-menus.c index a87a72de7..24ad05317 100644 --- a/src/nautilus-navigation-window-menus.c +++ b/src/nautilus-navigation-window-menus.c @@ -28,8 +28,8 @@ #include "nautilus-bookmark-list.h" #include "nautilus-bookmarks-window.h" #include "nautilus-signaller.h" -#include "ntl-app.h" -#include "ntl-window-private.h" +#include "nautilus-application.h" +#include "nautilus-window-private.h" #include "nautilus-property-browser.h" #include <libnautilus/nautilus-undo-manager.h> diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c index f4e12b0da..ca9f39cd2 100644 --- a/src/nautilus-navigation-window.c +++ b/src/nautilus-navigation-window.c @@ -25,22 +25,21 @@ * */ -/* ntl-window.c: Implementation of the main window object */ +/* nautilus-window.c: Implementation of the main window object */ #include <config.h> -#include "ntl-window-private.h" +#include "nautilus-window-private.h" -#include "ntl-window-msgs.h" -#include "ntl-window-state.h" -#include "ntl-app.h" +#include "nautilus-window-manage-views.h" +#include "nautilus-window-state.h" +#include "nautilus-application.h" #include <gnome.h> #include <math.h> #include "nautilus-bookmarks-window.h" #include "nautilus-signaller.h" #include "nautilus-location-bar.h" -#include "ntl-index-panel.h" -#include "ntl-miniicon.h" +#include "nautilus-sidebar.h" #include <gdk-pixbuf/gdk-pixbuf.h> @@ -53,6 +52,7 @@ #include <libnautilus-extensions/nautilus-program-choosing.h> #include <libnautilus-extensions/nautilus-string.h> #include <libnautilus-extensions/nautilus-view-identifier.h> +#include <libnautilus-extensions/nautilus-mini-icon.h> #include <libnautilus/nautilus-undo-manager.h> #include "nautilus-zoom-control.h" #include <ctype.h> diff --git a/src/nautilus-navigation-window.h b/src/nautilus-navigation-window.h index aae66d71f..2b235d156 100644 --- a/src/nautilus-navigation-window.h +++ b/src/nautilus-navigation-window.h @@ -23,17 +23,17 @@ * Author: Elliot Lee <sopwith@redhat.com> * */ -/* ntl-window.h: Interface of the main window object */ +/* nautilus-window.h: Interface of the main window object */ -#ifndef NTL_WINDOW_H -#define NTL_WINDOW_H +#ifndef NAUTILUS_WINDOW_H +#define NAUTILUS_WINDOW_H #include <libgnomeui/gnome-app.h> #include <libnautilus-extensions/nautilus-glib-extensions.h> #include <libnautilus-extensions/nautilus-bookmark.h> -#include "ntl-uri-map.h" -#include "ntl-view.h" -#include "ntl-index-panel.h" +#include "nautilus-applicable-views.h" +#include "nautilus-view-frame.h" +#include "nautilus-sidebar.h" #define NAUTILUS_TYPE_WINDOW (nautilus_window_get_type()) #define NAUTILUS_WINDOW(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_WINDOW, NautilusWindow)) diff --git a/src/nautilus-object-window.c b/src/nautilus-object-window.c index f4e12b0da..ca9f39cd2 100644 --- a/src/nautilus-object-window.c +++ b/src/nautilus-object-window.c @@ -25,22 +25,21 @@ * */ -/* ntl-window.c: Implementation of the main window object */ +/* nautilus-window.c: Implementation of the main window object */ #include <config.h> -#include "ntl-window-private.h" +#include "nautilus-window-private.h" -#include "ntl-window-msgs.h" -#include "ntl-window-state.h" -#include "ntl-app.h" +#include "nautilus-window-manage-views.h" +#include "nautilus-window-state.h" +#include "nautilus-application.h" #include <gnome.h> #include <math.h> #include "nautilus-bookmarks-window.h" #include "nautilus-signaller.h" #include "nautilus-location-bar.h" -#include "ntl-index-panel.h" -#include "ntl-miniicon.h" +#include "nautilus-sidebar.h" #include <gdk-pixbuf/gdk-pixbuf.h> @@ -53,6 +52,7 @@ #include <libnautilus-extensions/nautilus-program-choosing.h> #include <libnautilus-extensions/nautilus-string.h> #include <libnautilus-extensions/nautilus-view-identifier.h> +#include <libnautilus-extensions/nautilus-mini-icon.h> #include <libnautilus/nautilus-undo-manager.h> #include "nautilus-zoom-control.h" #include <ctype.h> diff --git a/src/nautilus-object-window.h b/src/nautilus-object-window.h index aae66d71f..2b235d156 100644 --- a/src/nautilus-object-window.h +++ b/src/nautilus-object-window.h @@ -23,17 +23,17 @@ * Author: Elliot Lee <sopwith@redhat.com> * */ -/* ntl-window.h: Interface of the main window object */ +/* nautilus-window.h: Interface of the main window object */ -#ifndef NTL_WINDOW_H -#define NTL_WINDOW_H +#ifndef NAUTILUS_WINDOW_H +#define NAUTILUS_WINDOW_H #include <libgnomeui/gnome-app.h> #include <libnautilus-extensions/nautilus-glib-extensions.h> #include <libnautilus-extensions/nautilus-bookmark.h> -#include "ntl-uri-map.h" -#include "ntl-view.h" -#include "ntl-index-panel.h" +#include "nautilus-applicable-views.h" +#include "nautilus-view-frame.h" +#include "nautilus-sidebar.h" #define NAUTILUS_TYPE_WINDOW (nautilus_window_get_type()) #define NAUTILUS_WINDOW(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_WINDOW, NautilusWindow)) diff --git a/src/nautilus-sidebar-tabs.c b/src/nautilus-sidebar-tabs.c index e9ba58a47..8408b6bda 100644 --- a/src/nautilus-sidebar-tabs.c +++ b/src/nautilus-sidebar-tabs.c @@ -23,7 +23,7 @@ */ #include <config.h> -#include "nautilus-index-tabs.h" +#include "nautilus-sidebar-tabs.h" #include <math.h> #include <stdio.h> diff --git a/src/nautilus-sidebar-title.c b/src/nautilus-sidebar-title.c index 9c1a64f94..c49f1f17b 100644 --- a/src/nautilus-sidebar-title.c +++ b/src/nautilus-sidebar-title.c @@ -24,7 +24,7 @@ */ #include <config.h> -#include "nautilus-index-title.h" +#include "nautilus-sidebar-title.h" #include <ctype.h> #include <string.h> diff --git a/src/nautilus-sidebar.c b/src/nautilus-sidebar.c index e3d0a4031..5dfdae025 100644 --- a/src/nautilus-sidebar.c +++ b/src/nautilus-sidebar.c @@ -25,7 +25,7 @@ */ #include <config.h> -#include "ntl-index-panel.h" +#include "nautilus-sidebar.h" #include <math.h> #include <libgnomeui/gnome-uidefs.h> @@ -45,8 +45,8 @@ #include <libnautilus-extensions/nautilus-program-choosing.h> #include <libnautilus-extensions/nautilus-string.h> #include <nautilus-widgets/nautilus-preferences.h> -#include "nautilus-index-tabs.h" -#include "nautilus-index-title.h" +#include "nautilus-sidebar-tabs.h" +#include "nautilus-sidebar-title.h" struct NautilusIndexPanelDetails { GtkVBox *container; diff --git a/src/nautilus-sidebar.h b/src/nautilus-sidebar.h index 6a6dc2ef4..87e43a2c2 100644 --- a/src/nautilus-sidebar.h +++ b/src/nautilus-sidebar.h @@ -23,11 +23,11 @@ * in a vertical panel and hosts the meta-views. */ -#ifndef NTL_INDEX_PANEL_H -#define NTL_INDEX_PANEL_H +#ifndef NAUTILUS_SIDEBAR_H +#define NAUTILUS_SIDEBAR_H #include <gtk/gtkeventbox.h> -#include "ntl-view.h" +#include "nautilus-view-frame.h" typedef struct NautilusIndexPanel NautilusIndexPanel; typedef struct NautilusIndexPanelClass NautilusIndexPanelClass; @@ -68,4 +68,4 @@ void nautilus_index_panel_set_uri (NautilusIndexPanel *p void nautilus_index_panel_set_title (NautilusIndexPanel *panel, const char *new_title); -#endif /* NTL_INDEX_PANEL_H */ +#endif /* NAUTILUS_SIDEBAR_H */ diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c index f4e12b0da..ca9f39cd2 100644 --- a/src/nautilus-spatial-window.c +++ b/src/nautilus-spatial-window.c @@ -25,22 +25,21 @@ * */ -/* ntl-window.c: Implementation of the main window object */ +/* nautilus-window.c: Implementation of the main window object */ #include <config.h> -#include "ntl-window-private.h" +#include "nautilus-window-private.h" -#include "ntl-window-msgs.h" -#include "ntl-window-state.h" -#include "ntl-app.h" +#include "nautilus-window-manage-views.h" +#include "nautilus-window-state.h" +#include "nautilus-application.h" #include <gnome.h> #include <math.h> #include "nautilus-bookmarks-window.h" #include "nautilus-signaller.h" #include "nautilus-location-bar.h" -#include "ntl-index-panel.h" -#include "ntl-miniicon.h" +#include "nautilus-sidebar.h" #include <gdk-pixbuf/gdk-pixbuf.h> @@ -53,6 +52,7 @@ #include <libnautilus-extensions/nautilus-program-choosing.h> #include <libnautilus-extensions/nautilus-string.h> #include <libnautilus-extensions/nautilus-view-identifier.h> +#include <libnautilus-extensions/nautilus-mini-icon.h> #include <libnautilus/nautilus-undo-manager.h> #include "nautilus-zoom-control.h" #include <ctype.h> diff --git a/src/nautilus-spatial-window.h b/src/nautilus-spatial-window.h index aae66d71f..2b235d156 100644 --- a/src/nautilus-spatial-window.h +++ b/src/nautilus-spatial-window.h @@ -23,17 +23,17 @@ * Author: Elliot Lee <sopwith@redhat.com> * */ -/* ntl-window.h: Interface of the main window object */ +/* nautilus-window.h: Interface of the main window object */ -#ifndef NTL_WINDOW_H -#define NTL_WINDOW_H +#ifndef NAUTILUS_WINDOW_H +#define NAUTILUS_WINDOW_H #include <libgnomeui/gnome-app.h> #include <libnautilus-extensions/nautilus-glib-extensions.h> #include <libnautilus-extensions/nautilus-bookmark.h> -#include "ntl-uri-map.h" -#include "ntl-view.h" -#include "ntl-index-panel.h" +#include "nautilus-applicable-views.h" +#include "nautilus-view-frame.h" +#include "nautilus-sidebar.h" #define NAUTILUS_TYPE_WINDOW (nautilus_window_get_type()) #define NAUTILUS_WINDOW(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_WINDOW, NautilusWindow)) diff --git a/src/nautilus-view-frame-bonobo-control.c b/src/nautilus-view-frame-bonobo-control.c index d37a93f28..23c568e73 100644 --- a/src/nautilus-view-frame-bonobo-control.c +++ b/src/nautilus-view-frame-bonobo-control.c @@ -26,8 +26,8 @@ #include <config.h> -#include "ntl-view-private.h" -#include "ntl-window.h" +#include "nautilus-view-frame-private.h" +#include "nautilus-window.h" typedef struct { BonoboObject *control_frame; diff --git a/src/nautilus-view-frame-bonobo-embeddable.c b/src/nautilus-view-frame-bonobo-embeddable.c index fd869a168..998d66c58 100644 --- a/src/nautilus-view-frame-bonobo-embeddable.c +++ b/src/nautilus-view-frame-bonobo-embeddable.c @@ -26,8 +26,8 @@ #include <config.h> -#include "ntl-view-private.h" -#include "ntl-window.h" +#include "nautilus-view-frame-private.h" +#include "nautilus-window.h" #include <libnautilus-extensions/bonobo-stream-vfs.h> typedef struct { diff --git a/src/nautilus-view-frame-corba.c b/src/nautilus-view-frame-corba.c index 184ee0091..e455c3c5c 100644 --- a/src/nautilus-view-frame-corba.c +++ b/src/nautilus-view-frame-corba.c @@ -23,13 +23,13 @@ * Author: Elliot Lee <sopwith@redhat.com> * */ -/* ntl-view-frame-svr.c: CORBA server implementation of the object +/* nautilus-view-frame-corba.c: CORBA server implementation of the object representing a data view frame. */ #include <config.h> -#include "ntl-view-private.h" -#include "ntl-window.h" +#include "nautilus-view-frame-private.h" +#include "nautilus-window.h" static Nautilus_ViewWindow impl_Nautilus_ViewFrame__get_main_window (PortableServer_Servant servant, CORBA_Environment *ev); diff --git a/src/nautilus-view-frame-nautilus-view.c b/src/nautilus-view-frame-nautilus-view.c index 6465c7276..a8bb15b6e 100644 --- a/src/nautilus-view-frame-nautilus-view.c +++ b/src/nautilus-view-frame-nautilus-view.c @@ -26,8 +26,8 @@ #include <config.h> -#include "ntl-view-private.h" -#include "ntl-window.h" +#include "nautilus-view-frame-private.h" +#include "nautilus-window.h" typedef struct { BonoboObject *control_frame; diff --git a/src/nautilus-view-frame-private.h b/src/nautilus-view-frame-private.h index 14e55144e..b36abfea4 100644 --- a/src/nautilus-view-frame-private.h +++ b/src/nautilus-view-frame-private.h @@ -24,12 +24,12 @@ * */ -/* ntl-view-private.h: Internals of the view proxy that are shared between different implementation files */ +/* nautilus-view-frame-private.h: Internals of the view proxy that are shared between different implementation files */ -#ifndef NTL_VIEW_PRIVATE_H -#define NTL_VIEW_PRIVATE_H +#ifndef NAUTILUS_VIEW_FRAME_PRIVATE_H +#define NAUTILUS_VIEW_FRAME_PRIVATE_H -#include "ntl-view.h" +#include "nautilus-view-frame.h" typedef struct { POA_Nautilus_ViewFrame servant; diff --git a/src/nautilus-view-frame.c b/src/nautilus-view-frame.c index 44d18c86e..2e5d52b43 100644 --- a/src/nautilus-view-frame.c +++ b/src/nautilus-view-frame.c @@ -29,8 +29,8 @@ #include <config.h> -#include "ntl-view-private.h" -#include "ntl-window.h" +#include "nautilus-view-frame-private.h" +#include "nautilus-window.h" #include <libnautilus-extensions/nautilus-gtk-extensions.h> #include <gtk/gtksignal.h> #include <gtk/gtk.h> diff --git a/src/nautilus-view-frame.h b/src/nautilus-view-frame.h index b232c993a..0a8e0ef2d 100644 --- a/src/nautilus-view-frame.h +++ b/src/nautilus-view-frame.h @@ -24,11 +24,11 @@ * */ -/* ntl-view.h: Interface of the object representing a data +/* nautilus-view-frame.h: Interface of the object representing a data view. */ -#ifndef NTL_VIEW_H -#define NTL_VIEW_H +#ifndef NAUTILUS_VIEW_FRAME_H +#define NAUTILUS_VIEW_FRAME_H #include <gtk/gtkwidget.h> #include <gtk/gtkbin.h> @@ -149,4 +149,4 @@ void nautilus_view_frame_construct_arg_set (NautilusViewFrame } #endif /* __cplusplus */ -#endif /* NTL_VIEW_H */ +#endif /* NAUTILUS_VIEW_FRAME_H */ diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c index 38aafaed2..275aa3cdc 100644 --- a/src/nautilus-window-manage-views.c +++ b/src/nautilus-window-manage-views.c @@ -31,7 +31,7 @@ */ #include <config.h> -#include "ntl-window-msgs.h" +#include "nautilus-window-manage-views.h" #include <stdarg.h> #include <libgnome/gnome-i18n.h> @@ -45,10 +45,10 @@ #include <libnautilus-extensions/nautilus-gnome-extensions.h> #include <libnautilus-extensions/nautilus-view-identifier.h> #include <libnautilus-extensions/nautilus-global-preferences.h> -#include "ntl-app.h" -#include "ntl-uri-map.h" -#include "ntl-window-private.h" -#include "ntl-window-state.h" +#include "nautilus-application.h" +#include "nautilus-applicable-views.h" +#include "nautilus-window-private.h" +#include "nautilus-window-state.h" #include "nautilus-location-bar.h" /*#define EXTREME_DEBUGGING*/ diff --git a/src/nautilus-window-manage-views.h b/src/nautilus-window-manage-views.h index 2b4308812..1e80d54b7 100644 --- a/src/nautilus-window-manage-views.h +++ b/src/nautilus-window-manage-views.h @@ -24,10 +24,10 @@ * */ -#ifndef NTL_WINDOW_MSGS_H -#define NTL_WINDOW_MSGS_H +#ifndef NAUTILUS_WINDOW_MANAGE_VIEWS_H +#define NAUTILUS_WINDOW_MANAGE_VIEWS_H -#include "ntl-window.h" +#include "nautilus-window.h" void nautilus_window_request_location_change (NautilusWindow *window, Nautilus_NavigationRequestInfo *loc, diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c index a87a72de7..24ad05317 100644 --- a/src/nautilus-window-menus.c +++ b/src/nautilus-window-menus.c @@ -28,8 +28,8 @@ #include "nautilus-bookmark-list.h" #include "nautilus-bookmarks-window.h" #include "nautilus-signaller.h" -#include "ntl-app.h" -#include "ntl-window-private.h" +#include "nautilus-application.h" +#include "nautilus-window-private.h" #include "nautilus-property-browser.h" #include <libnautilus/nautilus-undo-manager.h> diff --git a/src/nautilus-window-private.h b/src/nautilus-window-private.h index f896d4e67..6ec8c9ac3 100644 --- a/src/nautilus-window-private.h +++ b/src/nautilus-window-private.h @@ -1,7 +1,7 @@ -#ifndef NTL_WINDOW_PRIVATE_H -#define NTL_WINDOW_PRIVATE_H +#ifndef NAUTILUS_WINDOW_PRIVATE_H +#define NAUTILUS_WINDOW_PRIVATE_H -#include "ntl-window.h" +#include "nautilus-window.h" #include <libnautilus/libnautilus.h> #include <libnautilus/nautilus-undo-manager.h> #include <gtk/gtk.h> diff --git a/src/nautilus-window-state.c b/src/nautilus-window-state.c index af6a05e7a..fa7ed3061 100644 --- a/src/nautilus-window-state.c +++ b/src/nautilus-window-state.c @@ -25,7 +25,7 @@ */ #include <config.h> -#include "ntl-window-state.h" +#include "nautilus-window-state.h" #include <libnautilus-extensions/nautilus-file-utilities.h> #include <libnautilus-extensions/nautilus-global-preferences.h> diff --git a/src/nautilus-window-state.h b/src/nautilus-window-state.h index c925d8323..a10cd8b83 100644 --- a/src/nautilus-window-state.h +++ b/src/nautilus-window-state.h @@ -1,7 +1,7 @@ -#ifndef NTL_WINDOW_STATE_H -#define NTL_WINDOW_STATE_H 1 +#ifndef NAUTILUS_WINDOW_STATE_H +#define NAUTILUS_WINDOW_STATE_H 1 -#include "ntl-window.h" +#include "nautilus-window.h" void nautilus_window_set_initial_state(NautilusWindow *window, const char *initial_url); diff --git a/src/nautilus-window-toolbars.c b/src/nautilus-window-toolbars.c index d1a72800c..e43a04b75 100644 --- a/src/nautilus-window-toolbars.c +++ b/src/nautilus-window-toolbars.c @@ -24,8 +24,8 @@ */ #include <config.h> -#include "ntl-window-private.h" -#include "ntl-app.h" +#include "nautilus-window-private.h" +#include "nautilus-application.h" #include <gnome.h> #include <libnautilus-extensions/nautilus-bookmark.h> diff --git a/src/nautilus-window.c b/src/nautilus-window.c index f4e12b0da..ca9f39cd2 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -25,22 +25,21 @@ * */ -/* ntl-window.c: Implementation of the main window object */ +/* nautilus-window.c: Implementation of the main window object */ #include <config.h> -#include "ntl-window-private.h" +#include "nautilus-window-private.h" -#include "ntl-window-msgs.h" -#include "ntl-window-state.h" -#include "ntl-app.h" +#include "nautilus-window-manage-views.h" +#include "nautilus-window-state.h" +#include "nautilus-application.h" #include <gnome.h> #include <math.h> #include "nautilus-bookmarks-window.h" #include "nautilus-signaller.h" #include "nautilus-location-bar.h" -#include "ntl-index-panel.h" -#include "ntl-miniicon.h" +#include "nautilus-sidebar.h" #include <gdk-pixbuf/gdk-pixbuf.h> @@ -53,6 +52,7 @@ #include <libnautilus-extensions/nautilus-program-choosing.h> #include <libnautilus-extensions/nautilus-string.h> #include <libnautilus-extensions/nautilus-view-identifier.h> +#include <libnautilus-extensions/nautilus-mini-icon.h> #include <libnautilus/nautilus-undo-manager.h> #include "nautilus-zoom-control.h" #include <ctype.h> diff --git a/src/nautilus-window.h b/src/nautilus-window.h index aae66d71f..2b235d156 100644 --- a/src/nautilus-window.h +++ b/src/nautilus-window.h @@ -23,17 +23,17 @@ * Author: Elliot Lee <sopwith@redhat.com> * */ -/* ntl-window.h: Interface of the main window object */ +/* nautilus-window.h: Interface of the main window object */ -#ifndef NTL_WINDOW_H -#define NTL_WINDOW_H +#ifndef NAUTILUS_WINDOW_H +#define NAUTILUS_WINDOW_H #include <libgnomeui/gnome-app.h> #include <libnautilus-extensions/nautilus-glib-extensions.h> #include <libnautilus-extensions/nautilus-bookmark.h> -#include "ntl-uri-map.h" -#include "ntl-view.h" -#include "ntl-index-panel.h" +#include "nautilus-applicable-views.h" +#include "nautilus-view-frame.h" +#include "nautilus-sidebar.h" #define NAUTILUS_TYPE_WINDOW (nautilus_window_get_type()) #define NAUTILUS_WINDOW(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_WINDOW, NautilusWindow)) diff --git a/src/nautilus-zoomable-frame-corba.c b/src/nautilus-zoomable-frame-corba.c index 213018bf1..df084ef92 100644 --- a/src/nautilus-zoomable-frame-corba.c +++ b/src/nautilus-zoomable-frame-corba.c @@ -24,11 +24,11 @@ * */ -/* ntl-zoomable-frame-svr.c: CORBA server implementation of +/* nautilus-zoomable-frame-corba.c: CORBA server implementation of Nautilus::ZoomableFrame interface of a nautilus ViewFrame. */ #include <config.h> -#include "ntl-view-private.h" +#include "nautilus-view-frame-private.h" typedef struct { POA_Nautilus_ZoomableFrame servant; diff --git a/src/nautilus-zoomable-frame-svr.c b/src/nautilus-zoomable-frame-svr.c deleted file mode 100644 index 213018bf1..000000000 --- a/src/nautilus-zoomable-frame-svr.c +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 1999, 2000 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Elliot Lee <sopwith@redhat.com> - * - */ - -/* ntl-zoomable-frame-svr.c: CORBA server implementation of - Nautilus::ZoomableFrame interface of a nautilus ViewFrame. */ - -#include <config.h> -#include "ntl-view-private.h" - -typedef struct { - POA_Nautilus_ZoomableFrame servant; - gpointer bonobo_object; - - NautilusViewFrame *view; -} impl_POA_Nautilus_ZoomableFrame; - -static void impl_Nautilus_ZoomableFrame_notify_zoom_level (impl_POA_Nautilus_ZoomableFrame *servant, - CORBA_double level, - CORBA_Environment *ev); - - -POA_Nautilus_ZoomableFrame__epv impl_Nautilus_ZoomableFrame_epv = -{ - NULL, /* _private */ - (void(*))&impl_Nautilus_ZoomableFrame_notify_zoom_level, -}; - -static PortableServer_ServantBase__epv base_epv = { NULL, NULL, NULL }; - -POA_Nautilus_ZoomableFrame__vepv impl_Nautilus_ZoomableFrame_vepv = -{ - &base_epv, - NULL, - &impl_Nautilus_ZoomableFrame_epv -}; - -static void -impl_Nautilus_ZoomableFrame__destroy (BonoboObject *obj, - impl_POA_Nautilus_ZoomableFrame *servant) -{ - PortableServer_ObjectId *objid; - CORBA_Environment ev; - NautilusViewFrameClass *klass; - void (*servant_destroy_func) (PortableServer_Servant, CORBA_Environment *); - - klass = NAUTILUS_VIEW_FRAME_CLASS (GTK_OBJECT (servant->view)->klass); - - CORBA_exception_init(&ev); - - objid = PortableServer_POA_servant_to_id (bonobo_poa (), servant, &ev); - PortableServer_POA_deactivate_object (bonobo_poa (), objid, &ev); - CORBA_free (objid); - obj->servant = NULL; - - servant_destroy_func = klass->zoomable_servant_destroy_func; - servant_destroy_func ((PortableServer_Servant) servant, &ev); - g_free (servant); - CORBA_exception_free (&ev); -} - -BonoboObject * -impl_Nautilus_ZoomableFrame__create (NautilusViewFrame *view, - CORBA_Environment * ev) -{ - BonoboObject *retval; - impl_POA_Nautilus_ZoomableFrame *newservant; - NautilusViewFrameClass *klass; - void (*servant_init_func) (PortableServer_Servant, CORBA_Environment *); - - klass = NAUTILUS_VIEW_FRAME_CLASS (GTK_OBJECT (view)->klass); - newservant = g_new0 (impl_POA_Nautilus_ZoomableFrame, 1); - - newservant->servant.vepv = klass->vepv; - - if(!newservant->servant.vepv->Bonobo_Unknown_epv) - newservant->servant.vepv->Bonobo_Unknown_epv = bonobo_object_get_epv(); - - newservant->view = view; - servant_init_func = klass->zoomable_servant_init_func; - servant_init_func ((PortableServer_Servant) newservant, ev); - - retval = bonobo_object_new_from_servant (newservant); - - gtk_signal_connect (GTK_OBJECT (retval), "destroy", - GTK_SIGNAL_FUNC (impl_Nautilus_ZoomableFrame__destroy), newservant); - - return retval; -} - -static void -impl_Nautilus_ZoomableFrame_notify_zoom_level (impl_POA_Nautilus_ZoomableFrame *servant, - CORBA_double level, - CORBA_Environment *ev) -{ - nautilus_view_frame_notify_zoom_level (servant->view, level); -} diff --git a/src/ntl-app.c b/src/ntl-app.c deleted file mode 100644 index 6a41d524a..000000000 --- a/src/ntl-app.c +++ /dev/null @@ -1,427 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 2000 Eazel, Inc. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Elliot Lee <sopwith@redhat.com>, - * - */ - -#include <config.h> -#include "ntl-app.h" - -#include "ntl-window-state.h" -#include <libnautilus/libnautilus.h> -#include <bonobo.h> -#include "file-manager/fm-icon-view.h" -#include "file-manager/fm-list-view.h" -#include <libgnomevfs/gnome-vfs-init.h> -#include <libnautilus-extensions/nautilus-gnome-extensions.h> -#include <libnautilus-extensions/nautilus-global-preferences.h> -#include <libnautilus/nautilus-undo-manager.h> -#include <liboaf/liboaf.h> -#include "nautilus-desktop-window.h" - -typedef struct { - POA_Nautilus_Application servant; - NautilusApp *app; - - Nautilus_ViewWindowList attr_view_windows; -} impl_POA_Nautilus_Application; - -static Nautilus_ViewWindowList * -impl_Nautilus_Application__get_view_windows(impl_POA_Nautilus_Application* servant, - CORBA_Environment * ev); -static Nautilus_ViewWindow -impl_Nautilus_Application_new_view_window(impl_POA_Nautilus_Application *servant, - CORBA_Environment * ev); -static CORBA_boolean -impl_Nautilus_Application_supports(impl_POA_Nautilus_Application * servant, - CORBA_char *obj_iid, - CORBA_Environment * ev); -static CORBA_Object -impl_Nautilus_Application_create_object(impl_POA_Nautilus_Application *servant, - CORBA_char *obj_iid, - GNOME_stringlist * params, - CORBA_Environment * ev); -static POA_Nautilus_Application__epv impl_Nautilus_Application_epv = { - NULL, /* _private */ - (gpointer) &impl_Nautilus_Application__get_view_windows, - (gpointer) &impl_Nautilus_Application_new_view_window - -}; -static POA_Bonobo_GenericFactory__epv impl_Nautilus_Application_Bonobo_GenericFactory_epv = { - NULL, /* _private */ - (gpointer) &impl_Nautilus_Application_supports, - (gpointer) &impl_Nautilus_Application_create_object -}; -static PortableServer_ServantBase__epv impl_Nautilus_Application_base_epv = { - NULL, /* _private data */ - NULL, /* finalize routine */ - NULL, /* default_POA routine */ -}; -static POA_Nautilus_Application__vepv impl_Nautilus_Application_vepv = { - &impl_Nautilus_Application_base_epv, - &impl_Nautilus_Application_Bonobo_GenericFactory_epv, - NULL, - &impl_Nautilus_Application_epv, -}; - -static Nautilus_ViewWindowList * -impl_Nautilus_Application__get_view_windows(impl_POA_Nautilus_Application *servant, - CORBA_Environment * ev) -{ - Nautilus_ViewWindowList *retval; - int i; - GSList *ltmp; - - retval = Nautilus_ViewWindowList__alloc (); - retval->_length = g_slist_length (servant->app->windows); - - retval->_buffer = CORBA_sequence_Nautilus_ViewWindow_allocbuf (retval->_length); - for(i = 0, ltmp = servant->app->windows; ltmp; ltmp = ltmp->next, i++) { - CORBA_Object obj; - obj = bonobo_object_corba_objref(NAUTILUS_WINDOW(ltmp->data)->ntl_viewwindow); - retval->_buffer[i] = CORBA_Object_duplicate(obj, ev); - } - - CORBA_sequence_set_release (retval, CORBA_TRUE); - - return retval; -} - - -static Nautilus_ViewWindow -impl_Nautilus_Application_new_view_window (impl_POA_Nautilus_Application *servant, - CORBA_Environment * ev) -{ - NautilusWindow *win; - - win = nautilus_app_create_window (servant->app); - return CORBA_Object_duplicate (bonobo_object_corba_objref (BONOBO_OBJECT (win)), ev); -} - -static CORBA_boolean -impl_Nautilus_Application_supports (impl_POA_Nautilus_Application * servant, - CORBA_char * obj_iid, - CORBA_Environment * ev) -{ - return strcmp(obj_iid, "OAFIID:ntl_file_manager_icon_view:42681b21-d5ca-4837-87d2-394d88ecc058") == 0 - || strcmp(obj_iid, "OAFIID:ntl_file_manager_list_view:521e489d-0662-4ad7-ac3a-832deabe111c") == 0 - || strcmp(obj_iid, "OAFIID:ntl_window:88e8b2e4-b627-4221-b566-5ba32185c88d") == 0; -} - -static CORBA_Object -impl_Nautilus_Application_create_object (impl_POA_Nautilus_Application *servant, - CORBA_char *obj_iid, - GNOME_stringlist * params, - CORBA_Environment * ev) -{ - FMDirectoryView *dir_view; - NautilusView *view; - - if (!impl_Nautilus_Application_supports (servant, obj_iid, ev)) { - return CORBA_OBJECT_NIL; - } - - if (strcmp (obj_iid, "OAFIID:ntl_file_manager_icon_view:42681b21-d5ca-4837-87d2-394d88ecc058") == 0) { - dir_view = FM_DIRECTORY_VIEW (gtk_object_new (fm_icon_view_get_type (), NULL)); - } else if (strcmp (obj_iid, "OAFIID:ntl_file_manager_list_view:521e489d-0662-4ad7-ac3a-832deabe111c") == 0) { - dir_view = FM_DIRECTORY_VIEW (gtk_object_new (fm_list_view_get_type (), NULL)); - } else if (strcmp (obj_iid,"OAFIID:ntl_window:88e8b2e4-b627-4221-b566-5ba32185c88d") == 0) { - return impl_Nautilus_Application_new_view_window (servant, ev); - } else { - return CORBA_OBJECT_NIL; - } - - view = fm_directory_view_get_nautilus_view (dir_view); - return CORBA_Object_duplicate (bonobo_object_corba_objref (BONOBO_OBJECT (view)), ev); -} - - -static CORBA_Object -impl_Nautilus_Application__create(PortableServer_POA poa, - NautilusApp *app, - CORBA_Environment * ev) -{ - impl_POA_Nautilus_Application *newservant; - - newservant = g_new0(impl_POA_Nautilus_Application, 1); - newservant->servant.vepv = &impl_Nautilus_Application_vepv; - newservant->servant.vepv->Bonobo_Unknown_epv = NAUTILUS_APP_CLASS(GTK_OBJECT(app)->klass)->unknown_epv; - POA_Nautilus_Application__init((PortableServer_Servant) newservant, ev); - return bonobo_object_activate_servant(BONOBO_OBJECT(app), newservant); -} - -static void nautilus_app_init (NautilusApp *app); -static void nautilus_app_class_init (NautilusAppClass *klass); -static void nautilus_app_destroy (GtkObject *object); - -static GtkObjectClass *app_parent_class = NULL; - -GtkType -nautilus_app_get_type (void) -{ - static GtkType App_type = 0; - - if (!App_type) - { - static const GtkTypeInfo App_info = - { - "NautilusApp", - sizeof (NautilusApp), - sizeof (NautilusAppClass), - (GtkClassInitFunc) nautilus_app_class_init, - (GtkObjectInitFunc) nautilus_app_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - App_type = gtk_type_unique (bonobo_object_get_type (), &App_info); - } - - return App_type; -} - -static void -nautilus_app_class_init (NautilusAppClass *klass) -{ - GtkObjectClass *object_class; - - klass->unknown_epv = bonobo_object_get_epv(); - - object_class = (GtkObjectClass*) klass; - object_class->destroy = nautilus_app_destroy; - - app_parent_class = gtk_type_class (gtk_object_get_type ()); - - /* Startup preferences. This call is needed so that preferences have - * decent defaults. Not calling this function would cause some - * preferences to have "not nice" defaults. Things would still work - * because it is legal to use nautilus preferences implicitly. - */ - nautilus_global_preferences_startup (); -} - -static void -nautilus_app_init (NautilusApp *app) -{ - CORBA_Environment ev; - CORBA_Object objref; - Nautilus_Undo_Manager undo_manager; - - CORBA_exception_init (&ev); - - objref = impl_Nautilus_Application__create (bonobo_poa (), app, &ev); - oaf_active_server_register ("OAFIID:ntl_file_manager_factory:bd1e1862-92d7-4391-963e-37583f0daef3", - objref); - bonobo_object_construct (BONOBO_OBJECT(app), objref); - - /* Init undo manager */ - app->undo_manager = BONOBO_OBJECT (nautilus_undo_manager_new ()); - undo_manager = bonobo_object_corba_objref (BONOBO_OBJECT (app->undo_manager)); - - /* Stash a global reference to the object */ - nautilus_undo_manager_stash_global_undo (undo_manager); - - /* Add it to the application object */ - nautilus_attach_undo_manager (GTK_OBJECT (app), undo_manager); - - CORBA_exception_free (&ev); -} - -GtkObject * -nautilus_app_new (void) -{ - return gtk_object_new (nautilus_app_get_type (), NULL); -} - -static void -nautilus_app_destroy (GtkObject *object) -{ - /* Shut down preferences. This is needed so that the global - * preferences object and all its allocations are freed. Not - * calling this function would have NOT cause the user to lose - * preferences. The only effect would be to leak those - * objects - which would be collected at exit() time anyway, - * but it adds noice to memory profile tool runs. - */ - nautilus_global_preferences_shutdown (); - - nautilus_bookmarks_exiting (); - GTK_OBJECT_CLASS(app_parent_class)->destroy (object); -} - - -static void -display_caveat (GtkWindow *parent_window) -{ - GtkWidget *dialog; - GtkWidget *frame; - GtkWidget *pixmap; - GtkWidget *hbox; - GtkWidget *text; - char *file_name; - - dialog = gnome_dialog_new (_("Nautilus: caveat"), - GNOME_STOCK_BUTTON_OK, - NULL); - gtk_container_set_border_width (GTK_CONTAINER (dialog), GNOME_PAD); - gtk_window_set_policy (GTK_WINDOW (dialog), FALSE, FALSE, FALSE); - - hbox = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (hbox), GNOME_PAD); - gtk_widget_show (hbox); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), - hbox, - FALSE, FALSE, 0); - - frame = gtk_frame_new (NULL); - gtk_widget_show (frame); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); - gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0); - - file_name = gnome_pixmap_file ("nautilus/About_Image.png"); - pixmap = gnome_pixmap_new_from_file (file_name); - g_free (file_name); - gtk_widget_show (pixmap); - gtk_container_add (GTK_CONTAINER (frame), pixmap); - - text = gtk_label_new - (_("The Nautilus shell is under development; it's not " - "ready for daily use. Many features, including some " - "of the best ones, are not yet done, partly done, or " - "unstable. The program doesn't look or act the way " - "it will in version 1.0." - "\n\n" - "If you do decide to test this version of Nautilus, " - "beware. The program could do something " - "unpredictable and may even delete or overwrite " - "files on your computer." - "\n\n" - "For more information, visit http://nautilus.eazel.com.")); - gtk_label_set_line_wrap (GTK_LABEL (text), TRUE); - gtk_widget_show (text); - gtk_box_pack_start (GTK_BOX (hbox), text, FALSE, FALSE, 0); - - gnome_dialog_set_close (GNOME_DIALOG (dialog), TRUE); - - gnome_dialog_set_parent (GNOME_DIALOG (dialog), parent_window); - - gtk_widget_show (GTK_WIDGET (dialog)); -} - -void -nautilus_app_startup (NautilusApp *app, - const char *initial_url, - gboolean handle_desktop) -{ - NautilusWindow *window; - - if (handle_desktop) { - gtk_widget_show (GTK_WIDGET (nautilus_desktop_window_new (app))); - } - - /* Set default configuration */ - window = nautilus_app_create_window (app); - bonobo_activate (); - nautilus_window_set_initial_state (window, initial_url); - - /* Show the "not ready for prime time" dialog after this - * window appears, so it's on top. - */ - if (getenv ("NAUTILUS_NO_CAVEAT_DIALOG") == NULL) { - gtk_signal_connect (GTK_OBJECT (window), "show", - display_caveat, window); - } -} - -static void -nautilus_app_destroy_window (GtkObject *obj, NautilusApp *app) -{ - app->windows = g_slist_remove (app->windows, obj); - if (app->windows == NULL) { - nautilus_app_quit(); - } -} - -/* FIXME: If we are really going to use this, it should probably be - * moved to the gnome vfs public interface (which would change its - * name to not include "debug"). - */ -extern int gnome_vfs_debug_get_thread_count (void); -int quit_counter_hack; - -/* FIXME: This waiting for quit is needed by anyone who uses gnome-vfs, - * especially users or NautilusDirectory. So we need to provide it for - * others who are not using NautilusApp. - */ -static gboolean -nautilus_app_real_quit (void *unused) -{ - int count; - - count = gnome_vfs_debug_get_thread_count (); - if (count == 0) { - /* g_message ("no more gnome vfs threads, ready to quit"); */ - gtk_main_quit (); - return FALSE; - } - if (--quit_counter_hack == 0) { - g_message ("gnome vfs threads not going away, trying to quit anyway"); - gtk_main_quit (); - return FALSE; - } - /* g_message ("%d gnome vfs threads left, will try to quit later", count); */ - usleep(200000); /* 1/5 second */ - - return TRUE; -} - -void -nautilus_app_quit (void) -{ - quit_counter_hack = 20; /* 20 * 1/5 second == 4 seconds */ - - /* wait for gnome vfs slave threads to go away before quitting */ - gtk_idle_add ((GtkFunction)nautilus_app_real_quit, NULL); -} - -NautilusWindow * -nautilus_app_create_window (NautilusApp *app) -{ - NautilusWindow *window; - - window = NAUTILUS_WINDOW (gtk_object_new (nautilus_window_get_type(), - "app", BONOBO_OBJECT(app), - "app_id", "nautilus", NULL)); - - gtk_signal_connect (GTK_OBJECT (window), - "destroy", nautilus_app_destroy_window, app); - - /* Do not yet show the window. It will be shown later on if it can - * successfully display its initial URI. Otherwise it will be destroyed - * without ever having seen the light of day. - */ - app->windows = g_slist_prepend (app->windows, window); - - return window; -} diff --git a/src/ntl-app.h b/src/ntl-app.h deleted file mode 100644 index 4adb67f2c..000000000 --- a/src/ntl-app.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* ntl-app.h - * Copyright (C) 2000 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef NTL_APP_H -#define NTL_APP_H - -#include "ntl-window.h" - -#ifdef __cplusplus -extern "C" { -#pragma } -#endif /* __cplusplus */ - -#define NAUTILUS_TYPE_APP (nautilus_app_get_type ()) -#define NAUTILUS_APP(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_APP, NautilusApp)) -#define NAUTILUS_APP_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_APP, NautilusAppClass)) -#define NAUTILUS_IS_APP(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_APP)) -#define NAUTILUS_IS_APP_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), NAUTILUS_TYPE_APP)) - - -typedef struct { - BonoboObject parent; - GSList *windows; - BonoboObject *undo_manager; -} NautilusApp; - -typedef struct { - BonoboObjectClass parent_class; - gpointer servant; - gpointer unknown_epv; -} NautilusAppClass; - -GtkType nautilus_app_get_type (void); -GtkObject * nautilus_app_new (void); -void nautilus_app_startup (NautilusApp *app, - const char *initial_url, - gboolean handle_desktop); -NautilusWindow *nautilus_app_create_window (NautilusApp *app); -void nautilus_app_quit (void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* NTL_APP_H */ diff --git a/src/ntl-index-panel.c b/src/ntl-index-panel.c deleted file mode 100644 index e3d0a4031..000000000 --- a/src/ntl-index-panel.c +++ /dev/null @@ -1,928 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* Nautilus - * Copyright (C) 1999, 2000 Eazel, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Andy Hertzfeld <andy@eazel.com> - * - * This is the index panel widget, which displays overview information - * in a vertical panel and hosts the meta-views. - * - */ - -#include <config.h> -#include "ntl-index-panel.h" - -#include <math.h> -#include <libgnomeui/gnome-uidefs.h> -#include <libgnomevfs/gnome-vfs-types.h> -#include <libgnomevfs/gnome-vfs-uri.h> -#include <gdk-pixbuf/gdk-pixbuf.h> -#include <libnautilus-extensions/nautilus-background.h> -#include <libnautilus-extensions/nautilus-directory.h> -#include <libnautilus-extensions/nautilus-file.h> -#include <libnautilus-extensions/nautilus-glib-extensions.h> -#include <libnautilus-extensions/nautilus-global-preferences.h> -#include <libnautilus-extensions/nautilus-gtk-extensions.h> -#include <libnautilus-extensions/nautilus-gtk-macros.h> -#include <libnautilus-extensions/nautilus-keep-last-vertical-box.h> -#include <libnautilus-extensions/nautilus-metadata.h> -#include <libnautilus-extensions/nautilus-mime-type.h> -#include <libnautilus-extensions/nautilus-program-choosing.h> -#include <libnautilus-extensions/nautilus-string.h> -#include <nautilus-widgets/nautilus-preferences.h> -#include "nautilus-index-tabs.h" -#include "nautilus-index-title.h" - -struct NautilusIndexPanelDetails { - GtkVBox *container; - NautilusIndexTitle *title; - GtkNotebook *notebook; - NautilusIndexTabs *index_tabs; - NautilusIndexTabs *title_tab; - GtkHBox *button_box_centerer; - GtkVBox *button_box; - gboolean has_buttons; - char *uri; - int selected_index; - NautilusDirectory *directory; - int background_connection; - int old_width; -}; - -static void nautilus_index_panel_initialize_class (GtkObjectClass *object_klass); -static void nautilus_index_panel_initialize (GtkObject *object); -static gboolean nautilus_index_panel_press_event (GtkWidget *widget, - GdkEventButton *event); -static gboolean nautilus_index_panel_leave_event (GtkWidget *widget, - GdkEventCrossing *event); -static gboolean nautilus_index_panel_motion_event (GtkWidget *widget, - GdkEventMotion *event); -static void nautilus_index_panel_destroy (GtkObject *object); -static void nautilus_index_panel_drag_data_received (GtkWidget *widget, - GdkDragContext *context, - int x, - int y, - GtkSelectionData *selection_data, - guint info, - guint time); -static void nautilus_index_panel_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static void nautilus_index_panel_update_info (NautilusIndexPanel *index_panel, - const char *title); -static void nautilus_index_panel_update_buttons (NautilusIndexPanel *index_panel); -static void add_command_buttons (NautilusIndexPanel *index_panel, - GList *command_list); - -#define DEFAULT_BACKGROUND_COLOR "rgb:DDDD/DDDD/FFFF" -#define DEFAULT_TAB_COLOR "rgb:9999/9999/9999" - -#define INDEX_PANEL_WIDTH 136 -#define INDEX_PANEL_HEIGHT 400 - -/* drag and drop definitions */ - -enum { - TARGET_URI_LIST, - TARGET_COLOR, - TARGET_BGIMAGE, - TARGET_KEYWORD, - TARGET_GNOME_URI_LIST -}; - -static GtkTargetEntry target_table[] = { - { "text/uri-list", 0, TARGET_URI_LIST }, - { "application/x-color", 0, TARGET_COLOR }, - { "property/bgimage", 0, TARGET_BGIMAGE }, - { "property/keyword", 0, TARGET_KEYWORD }, - { "special/x-gnome-icon-list", 0, TARGET_GNOME_URI_LIST } -}; - -typedef enum { - NO_PART, - BACKGROUND_PART, - ICON_PART, - TITLE_TAB_PART, - TABS_PART -} IndexPanelPart; - -NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusIndexPanel, nautilus_index_panel, GTK_TYPE_EVENT_BOX) - -/* initializing the class object by installing the operations we override */ -static void -nautilus_index_panel_initialize_class (GtkObjectClass *object_klass) -{ - GtkWidgetClass *widget_class; - NautilusIndexPanelClass *klass; - - widget_class = GTK_WIDGET_CLASS (object_klass); - klass = NAUTILUS_INDEX_PANEL_CLASS (object_klass); - - object_klass->destroy = nautilus_index_panel_destroy; - - widget_class->drag_data_received = nautilus_index_panel_drag_data_received; - widget_class->motion_notify_event = nautilus_index_panel_motion_event; - widget_class->leave_notify_event = nautilus_index_panel_leave_event; - widget_class->button_press_event = nautilus_index_panel_press_event; - widget_class->size_allocate = nautilus_index_panel_size_allocate; -} - -/* utility routine to allocate the box the holds the command buttons */ -static void -make_button_box (NautilusIndexPanel *index_panel) -{ - index_panel->details->button_box_centerer = GTK_HBOX (gtk_hbox_new (FALSE, 0)); - gtk_widget_show (GTK_WIDGET (index_panel->details->button_box_centerer)); - gtk_box_pack_start_defaults (GTK_BOX (index_panel->details->container), - GTK_WIDGET (index_panel->details->button_box_centerer)); - - index_panel->details->button_box = GTK_VBOX (nautilus_keep_last_vertical_box_new (GNOME_PAD_SMALL)); - gtk_container_set_border_width (GTK_CONTAINER (index_panel->details->button_box), GNOME_PAD); - gtk_widget_show (GTK_WIDGET (index_panel->details->button_box)); - gtk_box_pack_start (GTK_BOX (index_panel->details->button_box_centerer), - GTK_WIDGET (index_panel->details->button_box), - TRUE, FALSE, 0); - index_panel->details->has_buttons = FALSE; -} - -/* initialize the instance's fields, create the necessary subviews, etc. */ - -static void -nautilus_index_panel_initialize (GtkObject *object) -{ - NautilusIndexPanel *index_panel; - GtkWidget* widget; - - index_panel = NAUTILUS_INDEX_PANEL (object); - widget = GTK_WIDGET (object); - - index_panel->details = g_new0 (NautilusIndexPanelDetails, 1); - - /* set the size of the index panel */ - gtk_widget_set_usize (widget, INDEX_PANEL_WIDTH, INDEX_PANEL_HEIGHT); - - /* create the container box */ - index_panel->details->container = GTK_VBOX (gtk_vbox_new (FALSE, 0)); - gtk_container_set_border_width (GTK_CONTAINER (index_panel->details->container), 0); - gtk_widget_show (GTK_WIDGET (index_panel->details->container)); - gtk_container_add (GTK_CONTAINER (index_panel), - GTK_WIDGET (index_panel->details->container)); - - /* allocate and install the index title widget */ - index_panel->details->title = NAUTILUS_INDEX_TITLE (nautilus_index_title_new ()); - gtk_widget_show (GTK_WIDGET (index_panel->details->title)); - gtk_box_pack_start (GTK_BOX (index_panel->details->container), - GTK_WIDGET (index_panel->details->title), - FALSE, FALSE, GNOME_PAD); - - /* first, allocate the index tabs */ - index_panel->details->index_tabs = NAUTILUS_INDEX_TABS (nautilus_index_tabs_new ()); - index_panel->details->selected_index = -1; - - /* also, allocate the title tab */ - index_panel->details->title_tab = NAUTILUS_INDEX_TABS (nautilus_index_tabs_new ()); - nautilus_index_tabs_set_title_mode (index_panel->details->title_tab, TRUE); - - gtk_widget_show (GTK_WIDGET (index_panel->details->index_tabs)); - gtk_box_pack_end (GTK_BOX (index_panel->details->container), - GTK_WIDGET (index_panel->details->index_tabs), - FALSE, FALSE, 0); - - index_panel->details->old_width = widget->allocation.width; - - /* allocate and install the meta-tabs */ - index_panel->details->notebook = GTK_NOTEBOOK (gtk_notebook_new ()); - gtk_object_ref (GTK_OBJECT (index_panel->details->notebook)); - gtk_object_sink (GTK_OBJECT (index_panel->details->notebook)); - - gtk_notebook_set_show_tabs (index_panel->details->notebook, FALSE); - - /* allocate and install the command button container */ - make_button_box (index_panel); - - /* prepare ourselves to receive dropped objects */ - gtk_drag_dest_set (GTK_WIDGET (index_panel), - GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP, - target_table, NAUTILUS_N_ELEMENTS (target_table), - GDK_ACTION_COPY | GDK_ACTION_MOVE); -} - -static void -nautilus_index_panel_destroy (GtkObject *object) -{ - NautilusIndexPanel *index_panel; - - index_panel = NAUTILUS_INDEX_PANEL (object); - - gtk_object_unref (GTK_OBJECT (index_panel->details->notebook)); - - nautilus_directory_unref (index_panel->details->directory); - - g_free (index_panel->details->uri); - g_free (index_panel->details); - - NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object)); -} - -/* create a new instance */ -NautilusIndexPanel * -nautilus_index_panel_new (void) -{ - return NAUTILUS_INDEX_PANEL (gtk_type_new (nautilus_index_panel_get_type ())); -} - -static IndexPanelPart -hit_test (NautilusIndexPanel *index_panel, - int x, int y) -{ - if (nautilus_point_in_widget (GTK_WIDGET (index_panel->details->index_tabs), x, y)) { - return TABS_PART; - } - - if (nautilus_point_in_widget (GTK_WIDGET (index_panel->details->title_tab), x, y)) { - return TITLE_TAB_PART; - } - - if (nautilus_index_title_hit_test_icon (index_panel->details->title, x, y)) { - return ICON_PART; - } - - if (nautilus_point_in_widget (GTK_WIDGET (index_panel), x, y)) { - return BACKGROUND_PART; - } - - return NO_PART; -} - -/* FIXME bugzilla.eazel.com 606: - * If passed a bogus URI this could block for a long time. - */ -static gboolean -uri_is_local_image (const char *uri) -{ - GdkPixbuf *pixbuf; - - /* FIXME bugzilla.eazel.com 607: - * Perhaps this should not be hardcoded like this. - */ - if (!nautilus_str_has_prefix (uri, "file://")) { - return FALSE; - } - pixbuf = gdk_pixbuf_new_from_file (uri + 7); - if (pixbuf == NULL) { - return FALSE; - } - gdk_pixbuf_unref (pixbuf); - return TRUE; -} - -static void -receive_dropped_uri_list (NautilusIndexPanel *index_panel, - int x, int y, - GtkSelectionData *selection_data) -{ - char **uris; - gboolean exactly_one; - NautilusFile *file; - - uris = g_strsplit (selection_data->data, "\r\n", 0); - exactly_one = uris[0] != NULL && uris[1] == NULL; - - /* FIXME bugzilla.eazel.com 604: handle files by setting the location to the file */ - - switch (hit_test (index_panel, x, y)) { - case NO_PART: - case BACKGROUND_PART: - if (exactly_one && uri_is_local_image (uris[0])) { - nautilus_background_set_tile_image_uri - (nautilus_get_widget_background (GTK_WIDGET (index_panel)), - uris[0]); - } - break; - case TABS_PART: - case TITLE_TAB_PART: - break; - case ICON_PART: - /* handle images dropped on the logo specially */ - /* FIXME bugzilla.eazel.com 605: - * Need feedback for cases where there is more than one URI - * and where the URI is not alocal image. - */ - if (exactly_one && uri_is_local_image (uris[0])) { - file = nautilus_file_get (index_panel->details->uri); - if (file != NULL) { - nautilus_file_set_metadata (file, - NAUTILUS_METADATA_KEY_CUSTOM_ICON, - NULL, - uris[0]); - nautilus_file_unref (file); - } - } - break; - } - - g_strfreev (uris); -} - -static void -receive_dropped_color (NautilusIndexPanel *index_panel, - int x, int y, - GtkSelectionData *selection_data) -{ - guint16 *channels; - char *color_spec; - - if (selection_data->length != 8 || selection_data->format != 16) { - g_warning ("received invalid color data"); - return; - } - - channels = (guint16 *) selection_data->data; - color_spec = g_strdup_printf ("rgb:%04hX/%04hX/%04hX", channels[0], channels[1], channels[2]); - - switch (hit_test (index_panel, x, y)) { - case NO_PART: - g_warning ("dropped color, but not on any part of sidebar"); - break; - case TABS_PART: - /* color dropped on main tabs */ - nautilus_index_tabs_receive_dropped_color - (index_panel->details->index_tabs, - x, y, selection_data); - - nautilus_directory_set_metadata (index_panel->details->directory, - NAUTILUS_METADATA_KEY_SIDEBAR_TAB_COLOR, - DEFAULT_TAB_COLOR, - color_spec); - - break; - case TITLE_TAB_PART: - /* color dropped on title tab */ - nautilus_index_tabs_receive_dropped_color - (index_panel->details->title_tab, - x, y, selection_data); - - nautilus_directory_set_metadata (index_panel->details->directory, - NAUTILUS_METADATA_KEY_SIDEBAR_TITLE_TAB_COLOR, - DEFAULT_TAB_COLOR, - color_spec); - break; - case ICON_PART: - case BACKGROUND_PART: - /* Let the background change based on the dropped color. */ - nautilus_background_receive_dropped_color - (nautilus_get_widget_background (GTK_WIDGET (index_panel)), - GTK_WIDGET (index_panel), x, y, selection_data); - break; - } - g_free(color_spec); -} - -/* handle receiving a dropped keyword */ - -static void -receive_dropped_keyword (NautilusIndexPanel *index_panel, - int x, int y, - GtkSelectionData *selection_data) -{ - NautilusFile *file; - GList *keywords, *word; - char *title; - - /* OK, now we've got the keyword, so add it to the metadata */ - - file = nautilus_file_get (index_panel->details->uri); - if (file == NULL) - return; - - /* Check and see if it's already there. */ - keywords = nautilus_file_get_keywords (file); - word = g_list_find_custom (keywords, selection_data->data, (GCompareFunc) strcmp); - if (word == NULL) - keywords = g_list_append (keywords, g_strdup (selection_data->data)); - else - keywords = g_list_remove_link (keywords, word); - - nautilus_file_set_keywords (file, keywords); - nautilus_file_unref(file); - - /* regenerate the display */ - title = nautilus_index_title_get_text(index_panel->details->title); - nautilus_index_panel_update_info (index_panel, title); - g_free(title); -} - -static void -nautilus_index_panel_drag_data_received (GtkWidget *widget, GdkDragContext *context, - int x, int y, - GtkSelectionData *selection_data, - guint info, guint time) -{ - NautilusIndexPanel *index_panel; - - g_return_if_fail (NAUTILUS_IS_INDEX_PANEL (widget)); - - index_panel = NAUTILUS_INDEX_PANEL (widget); - - switch (info) { - case TARGET_GNOME_URI_LIST: - case TARGET_URI_LIST: - receive_dropped_uri_list (index_panel, x, y, selection_data); - break; - - case TARGET_COLOR: - receive_dropped_color (index_panel, x, y, selection_data); - break; - case TARGET_BGIMAGE: - - if (hit_test (index_panel, x, y) == BACKGROUND_PART) - receive_dropped_uri_list (index_panel, x, y, selection_data); - break; - case TARGET_KEYWORD: - receive_dropped_keyword(index_panel, x, y, selection_data); - break; - default: - g_warning ("unknown drop type"); - } -} - -/* add a new meta-view to the index panel */ -void -nautilus_index_panel_add_meta_view (NautilusIndexPanel *index_panel, NautilusViewFrame *meta_view) -{ - GtkWidget *label; - char *description; - int page_num; - - g_return_if_fail (NAUTILUS_IS_INDEX_PANEL (index_panel)); - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (meta_view)); - - description = nautilus_view_frame_get_label (meta_view); - - label = gtk_label_new (description); - - gtk_widget_show (label); - - gtk_notebook_append_page (GTK_NOTEBOOK (index_panel->details->notebook), - GTK_WIDGET (meta_view), label); - page_num = gtk_notebook_page_num (GTK_NOTEBOOK (index_panel->details->notebook), - GTK_WIDGET (meta_view)); - - /* tell the index tabs about it */ - nautilus_index_tabs_add_view (index_panel->details->index_tabs, - description, GTK_WIDGET (meta_view), page_num); - - g_free (description); - - gtk_widget_show (GTK_WIDGET (meta_view)); -} - -/* remove the passed-in meta-view from the index panel */ -void -nautilus_index_panel_remove_meta_view (NautilusIndexPanel *index_panel, - NautilusViewFrame *meta_view) -{ - int page_num; - char *description; - - page_num = gtk_notebook_page_num (GTK_NOTEBOOK (index_panel->details->notebook), - GTK_WIDGET (meta_view)); - g_return_if_fail (page_num >= 0); - - gtk_notebook_remove_page (GTK_NOTEBOOK (index_panel->details->notebook), - page_num); - - description = nautilus_view_frame_get_label (meta_view); - - /* Remove the tab associated with this meta view */ - nautilus_index_tabs_remove_view (index_panel->details->index_tabs, description); - - g_free (description); -} - -/* utility to activate the metaview corresponding to the passed in index */ -static void -nautilus_index_panel_activate_meta_view (NautilusIndexPanel *index_panel, int which_view) -{ - char *title; - GtkNotebook *notebook; - - notebook = index_panel->details->notebook; - if (index_panel->details->selected_index < 0) { - gtk_widget_show (GTK_WIDGET (notebook)); - if (GTK_WIDGET (notebook)->parent == NULL) { - gtk_box_pack_end (GTK_BOX (index_panel->details->container), - GTK_WIDGET (notebook), - TRUE, TRUE, 0); - } - - gtk_widget_show (GTK_WIDGET (index_panel->details->title_tab)); - if (GTK_WIDGET (index_panel->details->title_tab)->parent == NULL) { - gtk_box_pack_end (GTK_BOX (index_panel->details->container), - GTK_WIDGET (index_panel->details->title_tab), - FALSE, FALSE, 0); - } - } - - index_panel->details->selected_index = which_view; - title = nautilus_index_tabs_get_title_from_index (index_panel->details->index_tabs, - which_view); - nautilus_index_tabs_set_title (index_panel->details->title_tab, title); - nautilus_index_tabs_prelight_tab (index_panel->details->title_tab, -1); - - g_free (title); - - /* hide the buttons, since they look confusing when partially overlapped */ - gtk_widget_hide (GTK_WIDGET (index_panel->details->button_box)); - - gtk_notebook_set_page (notebook, which_view); -} - -/* utility to deactivate the active metaview */ -static void -nautilus_index_panel_deactivate_meta_view(NautilusIndexPanel *index_panel) -{ - if (index_panel->details->selected_index >= 0) { - gtk_widget_hide (GTK_WIDGET (index_panel->details->notebook)); - gtk_widget_hide (GTK_WIDGET (index_panel->details->title_tab)); - } - - gtk_widget_show (GTK_WIDGET (index_panel->details->button_box)); - index_panel->details->selected_index = -1; - nautilus_index_tabs_select_tab (index_panel->details->index_tabs, -1); -} - -/* handle mouse motion events by passing it to the tabs if necessary for pre-lighting */ -static gboolean -nautilus_index_panel_motion_event (GtkWidget *widget, GdkEventMotion *event) -{ - int x, y; - int which_tab; - int title_top, title_bottom; - NautilusIndexPanel *index_panel; - NautilusIndexTabs *index_tabs, *title_tab; - - index_panel = NAUTILUS_INDEX_PANEL (widget); - - gtk_widget_get_pointer(widget, &x, &y); - - /* if the click is in the main tabs, tell them about it */ - index_tabs = index_panel->details->index_tabs; - if (y >= GTK_WIDGET (index_tabs)->allocation.y) { - which_tab = nautilus_index_tabs_hit_test (index_tabs, x, y); - nautilus_index_tabs_prelight_tab (index_tabs, which_tab); - } - - /* also handle prelighting in the title tab if necessary */ - if (index_panel->details->selected_index >= 0) { - title_tab = index_panel->details->title_tab; - title_top = GTK_WIDGET (title_tab)->allocation.y; - title_bottom = title_top + GTK_WIDGET (title_tab)->allocation.height; - if (y >= title_top && y < title_bottom) { - which_tab = nautilus_index_tabs_hit_test (title_tab, x, y); - } else { - which_tab = -1; - } - nautilus_index_tabs_prelight_tab (title_tab, which_tab); - } - - return TRUE; -} - -/* handle the leave event by turning off the preliting */ - -static gboolean -nautilus_index_panel_leave_event (GtkWidget *widget, GdkEventCrossing *event) -{ - NautilusIndexPanel *index_panel; - NautilusIndexTabs *index_tabs; - - index_panel = NAUTILUS_INDEX_PANEL (widget); - index_tabs = index_panel->details->index_tabs; - nautilus_index_tabs_prelight_tab (index_tabs, -1); - - return TRUE; -} - -/* hit-test the index tabs and activate if necessary */ - -static gboolean -nautilus_index_panel_press_event (GtkWidget *widget, GdkEventButton *event) -{ - int title_top, title_bottom; - NautilusIndexPanel *index_panel; - NautilusIndexTabs *index_tabs; - NautilusIndexTabs *title_tab; - int rounded_y; - int which_tab; - - index_panel = NAUTILUS_INDEX_PANEL (widget); - index_tabs = index_panel->details->index_tabs; - title_tab = index_panel->details->title_tab; - rounded_y = floor (event->y + .5); - - /* if the click is in the main tabs, tell them about it */ - if (rounded_y >= GTK_WIDGET (index_panel->details->index_tabs)->allocation.y) { - which_tab = nautilus_index_tabs_hit_test (index_tabs, event->x, event->y); - if (which_tab >= 0) { - nautilus_index_tabs_select_tab (index_tabs, which_tab); - nautilus_index_panel_activate_meta_view (index_panel, which_tab); - gtk_widget_queue_draw (widget); - } - } - - /* also handle clicks in the title tab if necessary */ - if (index_panel->details->selected_index >= 0) { - title_top = GTK_WIDGET (index_panel->details->title_tab)->allocation.y; - title_bottom = title_top + GTK_WIDGET (index_panel->details->title_tab)->allocation.height; - if (rounded_y >= title_top && rounded_y <= title_bottom) { - which_tab = nautilus_index_tabs_hit_test (title_tab, event->x, event->y); - if (which_tab >= 0) { - /* the user clicked in the title tab, so deactivate the metaview */ - nautilus_index_panel_deactivate_meta_view (index_panel); - } - } - } - return TRUE; -} - -static void -nautilus_index_panel_background_changed (NautilusIndexPanel *index_panel) -{ - NautilusBackground *background; - char *color_spec, *image; - - if (index_panel->details->directory == NULL) { - return; - } - - background = nautilus_get_widget_background (GTK_WIDGET (index_panel)); - - color_spec = nautilus_background_get_color (background); - nautilus_directory_set_metadata (index_panel->details->directory, - NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_COLOR, - DEFAULT_BACKGROUND_COLOR, - color_spec); - g_free (color_spec); - - image = nautilus_background_get_tile_image_uri (background); - nautilus_directory_set_metadata (index_panel->details->directory, - NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE, - NULL, - image); - g_free (image); -} - -static void -command_button_callback (GtkWidget *button, char *command_str) -{ - NautilusIndexPanel *index_panel; - - index_panel = NAUTILUS_INDEX_PANEL (gtk_object_get_user_data (GTK_OBJECT (button))); - - nautilus_launch_application (command_str, index_panel->details->uri); -} - -static void -nautilus_index_panel_chose_application_callback (const char *command_string, - gpointer callback_data) -{ - g_assert (NAUTILUS_IS_INDEX_PANEL (callback_data)); - - if (command_string != NULL) { - nautilus_launch_application - (command_string, - NAUTILUS_INDEX_PANEL (callback_data)->details->uri); - } -} - -static void -open_with_callback (GtkWidget *button, gpointer ignored) -{ - NautilusIndexPanel *index_panel; - NautilusFile *file; - - index_panel = NAUTILUS_INDEX_PANEL (gtk_object_get_user_data (GTK_OBJECT (button))); - - file = nautilus_file_get (index_panel->details->uri); - g_return_if_fail (file != NULL); - - nautilus_choose_application_for_file - (file, - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (index_panel))), - nautilus_index_panel_chose_application_callback, - index_panel); - - nautilus_file_unref (file); -} - -/* utility routine that allocates the command buttons from the command list */ - -static void -add_command_buttons (NautilusIndexPanel *index_panel, GList *command_list) -{ - char *command_string, *temp_str; - GList *p; - GtkWidget *temp_button; - NautilusCommandInfo *info; - - for (p = command_list; p != NULL; p = p->next) { - info = p->data; - - index_panel->details->has_buttons = TRUE; - - temp_str = g_strdup_printf (_("Open with %s"), info->display_name); - temp_button = gtk_button_new_with_label (temp_str); - gtk_box_pack_start (GTK_BOX (index_panel->details->button_box), - temp_button, - FALSE, FALSE, - 0); - - temp_str = g_strdup_printf("'%s'", - nautilus_str_has_prefix (index_panel->details->uri, "file://") ? - index_panel->details->uri + 7 : index_panel->details->uri); - - command_string = g_strdup_printf (info->command_string, temp_str); - g_free(temp_str); - - nautilus_gtk_signal_connect_free_data - (GTK_OBJECT (temp_button), "clicked", - GTK_SIGNAL_FUNC (command_button_callback), command_string); - gtk_object_set_user_data (GTK_OBJECT (temp_button), index_panel); - - gtk_widget_show (temp_button); - } - - /* Catch-all button after all the others. */ - temp_button = gtk_button_new_with_label (_("Open with ...")); - gtk_signal_connect (GTK_OBJECT (temp_button), "clicked", - open_with_callback, NULL); - gtk_object_set_user_data (GTK_OBJECT (temp_button), index_panel); - gtk_widget_show (temp_button); - gtk_box_pack_start (GTK_BOX (index_panel->details->button_box), - temp_button, FALSE, FALSE, 0); -} - -/* here's where we set up the command buttons, based on the mime-type of the associated URL */ -/* FIXME bugzilla.eazel.com 596: eventually, we need a way to - * override/augment the type from info in the metadata. - */ -void -nautilus_index_panel_update_buttons (NautilusIndexPanel *index_panel) -{ - NautilusFile *file; - GList *command_list; - char *mime_type; - - /* dispose any existing buttons */ - if (index_panel->details->has_buttons) { - gtk_container_remove (GTK_CONTAINER (index_panel->details->container), - GTK_WIDGET (index_panel->details->button_box_centerer)); - make_button_box (index_panel); - } - - /* allocate a file object and fetch the associated mime-type */ - - file = nautilus_file_get (index_panel->details->uri); - if (file != NULL) { - mime_type = nautilus_file_get_mime_type (file); - - /* generate a command list from the mime-type */ - if (mime_type != NULL) { - command_list = nautilus_mime_type_get_commands (mime_type); - g_free (mime_type); - - /* install a button for each command in the list */ - if (command_list != NULL) { - add_command_buttons (index_panel, command_list); - nautilus_mime_type_dispose_list (command_list); - - if (index_panel->details->selected_index != -1) - gtk_widget_hide (GTK_WIDGET (index_panel->details->button_box)); - } - } - - nautilus_file_unref (file); - } -} - -/* this routine populates the index panel with the per-uri information */ - -void -nautilus_index_panel_update_info (NautilusIndexPanel *index_panel, - const char* initial_title) -{ - NautilusDirectory *directory; - NautilusBackground *background; - char *background_color, *color_spec; - char *background_image; - - directory = nautilus_directory_get (index_panel->details->uri); - nautilus_directory_unref (index_panel->details->directory); - index_panel->details->directory = directory; - - /* Connect the background changed signal to code that writes the color. */ - background = nautilus_get_widget_background (GTK_WIDGET (index_panel)); - if (index_panel->details->background_connection == 0) { - index_panel->details->background_connection = - gtk_signal_connect_object (GTK_OBJECT (background), - "changed", - nautilus_index_panel_background_changed, - GTK_OBJECT (index_panel)); - } - - /* Set up the background color and image from the metadata. */ - background_color = nautilus_directory_get_metadata (directory, - NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_COLOR, - DEFAULT_BACKGROUND_COLOR); - background_image = nautilus_directory_get_metadata (directory, - NAUTILUS_METADATA_KEY_SIDEBAR_BACKGROUND_IMAGE, - NULL); - - nautilus_background_set_color (background, background_color); - g_free (background_color); - - nautilus_background_set_tile_image_uri (background, background_image); - g_free (background_image); - - /* set up the color for the tabs */ - color_spec = nautilus_directory_get_metadata (directory, - NAUTILUS_METADATA_KEY_SIDEBAR_TAB_COLOR, - DEFAULT_TAB_COLOR); - nautilus_index_tabs_set_color(index_panel->details->index_tabs, color_spec); - g_free (color_spec); - - color_spec = nautilus_directory_get_metadata (directory, - NAUTILUS_METADATA_KEY_SIDEBAR_TITLE_TAB_COLOR, - DEFAULT_TAB_COLOR); - nautilus_index_tabs_set_color(index_panel->details->title_tab, color_spec); - g_free (color_spec); - - - /* tell the title widget about it */ - nautilus_index_title_set_uri (index_panel->details->title, - index_panel->details->uri, - initial_title); - - /* set up the command buttons */ - nautilus_index_panel_update_buttons (index_panel); -} - -/* here is the key routine that populates the index panel with the appropriate information when the uri changes */ - -void -nautilus_index_panel_set_uri (NautilusIndexPanel *index_panel, - const char* new_uri, - const char* initial_title) -{ - /* there's nothing to do if the uri is the same as the current one */ - if (nautilus_strcmp (index_panel->details->uri, new_uri) == 0) { - return; - } - - g_free (index_panel->details->uri); - index_panel->details->uri = g_strdup (new_uri); - - /* populate the per-uri box with the info */ - nautilus_index_panel_update_info (index_panel, initial_title); -} - -void -nautilus_index_panel_set_title (NautilusIndexPanel *index_panel, const char* new_title) -{ - nautilus_index_title_set_text (index_panel->details->title, - new_title); -} - -/* we override size allocate so we can remember our size when it changes, since the paned widget - doesn't generate a signal */ - -static void -nautilus_index_panel_size_allocate(GtkWidget *widget, GtkAllocation *allocation) -{ - NautilusIndexPanel *index_panel = NAUTILUS_INDEX_PANEL(widget); - - NAUTILUS_CALL_PARENT_CLASS (GTK_WIDGET_CLASS, size_allocate, (widget, allocation)); - - /* remember the size if it changed */ - - if (widget->allocation.width != index_panel->details->old_width) { - index_panel->details->old_width = widget->allocation.width; - nautilus_preferences_set_enum(NAUTILUS_PREFERENCES_SIDEBAR_WIDTH, widget->allocation.width); - - } -} diff --git a/src/ntl-index-panel.h b/src/ntl-index-panel.h deleted file mode 100644 index 6a6dc2ef4..000000000 --- a/src/ntl-index-panel.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* Nautilus - * Copyright (C) 1999, 2000 Eazel, Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Andy Hertzfeld <andy@eazel.com> - * - * This is the header file for the index panel widget, which displays overview information - * in a vertical panel and hosts the meta-views. - */ - -#ifndef NTL_INDEX_PANEL_H -#define NTL_INDEX_PANEL_H - -#include <gtk/gtkeventbox.h> -#include "ntl-view.h" - -typedef struct NautilusIndexPanel NautilusIndexPanel; -typedef struct NautilusIndexPanelClass NautilusIndexPanelClass; - -#define NAUTILUS_TYPE_INDEX_PANEL \ - (nautilus_index_panel_get_type ()) -#define NAUTILUS_INDEX_PANEL(obj) \ - (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_INDEX_PANEL, NautilusIndexPanel)) -#define NAUTILUS_INDEX_PANEL_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_INDEX_PANEL, NautilusIndexPanelClass)) -#define NAUTILUS_IS_INDEX_PANEL(obj) \ - (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_INDEX_PANEL)) -#define NAUTILUS_IS_INDEX_PANEL_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_INDEX_PANEL)) - -typedef struct NautilusIndexPanelDetails NautilusIndexPanelDetails; - -struct NautilusIndexPanel -{ - GtkEventBox event_box; - NautilusIndexPanelDetails *details; -}; - -struct NautilusIndexPanelClass -{ - GtkEventBoxClass parent_class; -}; - -GtkType nautilus_index_panel_get_type (void); -NautilusIndexPanel *nautilus_index_panel_new (void); -void nautilus_index_panel_add_meta_view (NautilusIndexPanel *panel, - NautilusViewFrame *meta_view); -void nautilus_index_panel_remove_meta_view (NautilusIndexPanel *panel, - NautilusViewFrame *meta_view); -void nautilus_index_panel_set_uri (NautilusIndexPanel *panel, - const char *new_uri, - const char *initial_title); -void nautilus_index_panel_set_title (NautilusIndexPanel *panel, - const char *new_title); - -#endif /* NTL_INDEX_PANEL_H */ diff --git a/src/ntl-main.c b/src/ntl-main.c deleted file mode 100644 index 55cd45e2a..000000000 --- a/src/ntl-main.c +++ /dev/null @@ -1,117 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: 8; c-basic-offset: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 1999, 2000 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Authors: Elliot Lee <sopwith@redhat.com>, - * Darin Adler <darin@eazel.com>, - * John Sullivan <sullivan@eazel.com> - * - */ - -/* ntl-main.c: Implementation of the routines that drive program lifecycle and main window creation/destruction. */ - -#include <config.h> - -#include "nautilus-self-check-functions.h" -#include "ntl-app.h" -#include <libnautilus-extensions/nautilus-debug.h> -#include <libnautilus-extensions/nautilus-lib-self-check-functions.h> -#include <libnautilus-extensions/nautilus-self-checks.h> -#include <nautilus-widgets/nautilus-preferences.h> -#include <nautilus-widgets/nautilus-widgets-self-check-functions.h> -#include <popt.h> -#include <libgnome/gnome-i18n.h> -#include <libgnomeui/gnome-init.h> - -#include <libgnomevfs/gnome-vfs-init.h> -#include <liboaf/liboaf.h> - -int -main(int argc, char *argv[]) -{ - gboolean perform_self_check; - gboolean handle_desktop; - poptContext popt_context; - CORBA_ORB orb; - gboolean preferences_initialized; - NautilusApp *application; - const char **args; - struct poptOption options[] = { -#ifndef NAUTILUS_OMIT_SELF_CHECK - { "check", '\0', POPT_ARG_NONE, &perform_self_check, 0, N_("Perform high-speed self-check tests."), NULL }, -#endif - { "desktop", '\0', POPT_ARG_NONE, &handle_desktop, 0, N_("Draw background and icons on desktop."), NULL }, - { NULL, '\0', POPT_ARG_INCLUDE_TABLE, &oaf_popt_options, 0, NULL, NULL }, - POPT_AUTOHELP - { NULL, '\0', 0, NULL, 0, NULL, NULL } - }; - - /* Make criticals and warnings stop in the debugger if NAUTILUS_DEBUG is set. - * Unfortunately, this has to be done explicitly for each domain. - */ - if (getenv ("NAUTILUS_DEBUG") != NULL) { - nautilus_make_warnings_and_criticals_stop_in_debugger - (G_LOG_DOMAIN, g_log_domain_glib, "Gdk", "Gtk", "GnomeVFS", "GnomeUI", "Bonobo", NULL); - } - - /* Initialize gettext support */ -#ifdef ENABLE_NLS /* sadly we need this ifdef because otherwise the following get empty statement warnings */ - bindtextdomain (PACKAGE, GNOMELOCALEDIR); - textdomain (PACKAGE); -#endif - - /* Initialize the services that we use. */ - perform_self_check = FALSE; - handle_desktop = FALSE; - gnome_init_with_popt_table ("nautilus", VERSION, argc, argv, options, 0, &popt_context); - g_thread_init (NULL); - orb = oaf_init (argc, argv); - gnome_vfs_init (); - bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL); - - /* Initialize parts of Nautilus (move to NautilusApplication?). */ - preferences_initialized = nautilus_preferences_initialize (argc, argv); - /* FIXME bugzilla.eazel.com 672: - * Need error reporting if this fails instead of a core dump. - */ - g_assert (preferences_initialized); - - if (perform_self_check) { -#ifndef NAUTILUS_OMIT_SELF_CHECK - /* Run the checks for nautilus and libnautilus. */ - nautilus_run_self_checks (); - nautilus_run_lib_self_checks (); - nautilus_widgets_run_self_checks (); - nautilus_exit_if_self_checks_failed (); -#endif - } else { - /* Run the nautilus application. */ - application = NAUTILUS_APP (nautilus_app_new ()); - args = poptGetArgs (popt_context); - nautilus_app_startup (application, - args == NULL ? NULL : args[0], - handle_desktop); - bonobo_main (); - bonobo_object_unref (BONOBO_OBJECT (application)); - } - - return EXIT_SUCCESS; -} diff --git a/src/ntl-miniicon.c b/src/ntl-miniicon.c deleted file mode 100644 index 33dc63002..000000000 --- a/src/ntl-miniicon.c +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C; c-set-style: linux; indent-tabs-mode: nil; c-basic-offset: 8 -*- - * Nautilus shell - mini icon setting routine - * - * Copyright (C) 1999, 2000 Anders Carlsson - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#include <config.h> -#include "ntl-miniicon.h" - -#include <gdk/gdkprivate.h> -#include <gdk/gdkx.h> -#include <X11/Xlib.h> - -void -nautilus_set_mini_icon(GdkWindow *window, - GdkPixmap *pixmap, - GdkBitmap *mask) -{ - GdkAtom icon_atom; - long data[2]; - - g_return_if_fail (window != NULL); - g_return_if_fail (pixmap != NULL); - - data[0] = ((GdkPixmapPrivate *)pixmap)->xwindow; - if (mask) - data[1] = ((GdkPixmapPrivate *)mask)->xwindow; - else - data[1] = 0; - - icon_atom = gdk_atom_intern ("KWM_WIN_ICON", FALSE); - gdk_property_change (window, icon_atom, icon_atom, - 32,GDK_PROP_MODE_REPLACE, - (guchar *)data, 2); - -} diff --git a/src/ntl-miniicon.h b/src/ntl-miniicon.h deleted file mode 100644 index 00a64ab7e..000000000 --- a/src/ntl-miniicon.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: C; c-set-style: linux; indent-tabs-mode: nil; c-basic-offset: 8 -*- - * Nautilus shell - mini icon setting routine - * - * Copyright (C) 1999, 2000 Anders Carlsson - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -#ifndef NTL_MINIICON_H -#define NTL_MINIICON_H - -#include <gdk/gdk.h> - -/* In GNOME 2.0 this function will be in the libraries */ -void -nautilus_set_mini_icon(GdkWindow *window, - GdkPixmap *pixmap, - GdkBitmap *mask); - - -#endif diff --git a/src/ntl-uri-map.c b/src/ntl-uri-map.c deleted file mode 100644 index fb7f7d2b3..000000000 --- a/src/ntl-uri-map.c +++ /dev/null @@ -1,771 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 2000 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Elliot Lee <sopwith@redhat.com> - * - */ - - -/* #define DEBUG_MJS 1 */ - -/* ntl-uri-map.c: Implementation of routines for mapping a location - change request to a set of views and actual URL to be loaded. */ - -#include <config.h> -#include "ntl-uri-map.h" - -#include <libnautilus-extensions/nautilus-directory.h> -#include <libnautilus-extensions/nautilus-metadata.h> -#include <libnautilus-extensions/nautilus-global-preferences.h> -#include <libnautilus-extensions/nautilus-string.h> -#include <libnautilus-extensions/nautilus-file-attributes.h> -#include <libnautilus-extensions/nautilus-file.h> -#include <libnautilus-extensions/nautilus-view-identifier.h> -#include <libnautilus-extensions/nautilus-glib-extensions.h> - -#include <libgnomevfs/gnome-vfs-file-info.h> -#include <libgnomevfs/gnome-vfs-async-ops.h> - -#include <liboaf/liboaf.h> - -#include <sys/types.h> -#include <dirent.h> -#include <limits.h> -#include <ctype.h> -#include <string.h> - -/* forward declarations */ -static void async_get_file_info_text (GnomeVFSAsyncHandle **handle, - const char *text_uri, - GnomeVFSFileInfoOptions options, - GnomeVFSAsyncGetFileInfoCallback callback, - gpointer callback_data); - -/* Nautilus View Identifiers associate a component name with a user displayable name */ - -static NautilusNavigationResult -get_nautilus_navigation_result_from_gnome_vfs_result (GnomeVFSResult gnome_vfs_result) -{ - switch (gnome_vfs_result) { - case GNOME_VFS_OK: - return NAUTILUS_NAVIGATION_RESULT_OK; - case GNOME_VFS_ERROR_NOTFOUND: - case GNOME_VFS_ERROR_HOSTNOTFOUND: - return NAUTILUS_NAVIGATION_RESULT_NOT_FOUND; - case GNOME_VFS_ERROR_INVALIDURI: - return NAUTILUS_NAVIGATION_RESULT_INVALID_URI; - case GNOME_VFS_ERROR_NOTSUPPORTED: - return NAUTILUS_NAVIGATION_RESULT_UNSUPPORTED_SCHEME; - case GNOME_VFS_ERROR_GENERIC: - /* This one has occurred at least once in the web browser component */ - return NAUTILUS_NAVIGATION_RESULT_UNSPECIFIC_ERROR; - default: - /* Whenever this message fires, we should consider adding a specific case - * to make the error as comprehensible as possible to the user. Please - * bug me (sullivan@eazel.com) if you see this fire and don't have the - * inclination to immediately make a good message yourself (tell me - * what GnomeVFSResult code the message reported, and what caused it to - * fire). - */ - g_message ("in ntl-uri-map.c, got unhandled GnomeVFSResult %d", gnome_vfs_result); - return NAUTILUS_NAVIGATION_RESULT_UNSPECIFIC_ERROR; - } -} - -/* GCompareFunc-style function for checking whether a given string matches - * the iid of a NautilusViewIdentifier. Returns 0 if there is a match. - */ -static int -check_iid (gconstpointer a, gconstpointer b) -{ - NautilusViewIdentifier *identifier; - char *string; - - identifier = (NautilusViewIdentifier *)a; - string = (char *)b; - - return strcmp (identifier->iid, string) != 0; -} - -/** - * set_initial_content_iid: - * - * Sets the iid that will determine which content view to use when - * a URI is displayed. - * - * @navinfo: The NautilusNavigationInfo representing the URI that's about - * to be displayed. - * @fallback_value: The iid to use for the content view if no better - * one can be determined. - */ -static void -set_initial_content_iid (NautilusNavigationInfo *navinfo, - const char *fallback_value) -{ - char *remembered_value = NULL; - const char *value = NULL; - - g_assert (fallback_value != NULL); - g_assert (g_list_length (navinfo->content_identifiers) > 0); - - /* NOTE: Darin doesn't like the unpredictability of this three-choice system. - * He'd prefer a global setting and perhaps an explicit location-specific - * setting that doesn't affect any other locations. Maybe we should change - * this to work that way. - */ - remembered_value = nautilus_directory_get_metadata - (navinfo->directory, NAUTILUS_METADATA_KEY_INITIAL_VIEW, NULL); - - /* Use the remembered value if it's non-NULL and in the list of choices. */ - if (remembered_value != NULL) { - if (g_list_find_custom (navinfo->content_identifiers, - remembered_value, check_iid)) { - value = remembered_value; - } else { - g_message ("Unknown iid \"%s\" stored for %s", - remembered_value, - navinfo->navinfo.requested_uri); - } - } - - if (value == NULL) { - /* Can't use remembered value, use referring value if - * it's non-NULL and in the list of choices. - */ - if (navinfo->referring_iid != NULL) { - if (g_list_find_custom (navinfo->content_identifiers, - navinfo->referring_iid, check_iid)) { - value = navinfo->referring_iid; - } - } - - /* Can't use remembered or referring value, use fallback value. */ - if (value == NULL) { - value = fallback_value; - } - } - - navinfo->initial_content_iid = g_strdup (value); - - g_free (remembered_value); -} - - -static char * const nautilus_sort_criteria[] = { - /* Prefer the html view most */ - "iid == 'OAFIID:ntl_web_browser:0ce1a736-c939-4ac7-b12c-19d72bf1510b'", - /* Prefer the icon view next */ - "iid == 'OAFIID:ntl_file_manager_icon_view:42681b21-d5ca-4837-87d2-394d88ecc058'", - /* Prefer anything else over the loser view. */ - "iid != 'OAFIID:nautilus_content_loser:95901458-c68b-43aa-aaca-870ced11062d'", - /* Prefer anything else over the sample view. */ - "iid != 'OAFIID:nautilus_sample_content_view:45c746bc-7d64-4346-90d5-6410463b43ae'", - NULL}; - -/* It might be worth moving this to nautilus-string.h at some point. */ -static char * -extract_prefix_add_suffix (const char *string, const char *separator, const char *suffix) -{ - const char *separator_position; - int prefix_length; - char *result; - - separator_position = strstr (string, separator); - prefix_length = separator_position == NULL - ? strlen (string) - : separator_position - string; - - result = g_malloc (prefix_length + strlen(suffix) + 1); - - strncpy (result, string, prefix_length); - result[prefix_length] = '\0'; - - strcat (result, suffix); - - return result; -} - -static char * -mime_type_get_supertype (const char *mime_type) -{ - return extract_prefix_add_suffix (mime_type, "/", "/*"); -} - -static char * -uri_string_get_scheme (const char *uri_string) -{ - return extract_prefix_add_suffix (uri_string, ":", ""); -} - -/* - * The following routine uses metadata associated with the current url - * to add content view components specified in the metadata. The - * content views are specified in the string as <EXPLICIT_CONTENT_VIEW - * IID="iid"/> elements inside the appropriate <DIRECTORY> or <FILE> element. - */ - -static void -get_explicit_content_view_iids_from_metafile (NautilusNavigationInfo *navinfo) -{ - if (navinfo->directory != NULL) { - navinfo->explicit_iids = nautilus_directory_get_metadata_list - (navinfo->directory, "EXPLICIT_CONTENT_VIEW", "IID"); - } -} - -static char * -make_oaf_query_for_explicit_content_view_iids (GList *view_iids) -{ - GList *p; - char *iid; - char *query; - char *old_query; - - query = NULL; - - for (p = view_iids; p != NULL; p = p->next) { - iid = (char *) p->data; - if (query != NULL) { - old_query = query; - query = g_strconcat (query, " OR ", NULL); - g_free (old_query); - } else { - query = g_strdup ("("); - } - - old_query = query; - query = g_strdup_printf ("%s iid=='%s'", old_query, iid); - g_free (old_query); - } - - - if (query != NULL) { - old_query = query; - query = g_strconcat (old_query, ")", NULL); - g_free (old_query); - } else { - query = g_strdup ("false"); - } - - return query; -} - -static char * -make_oaf_query_with_known_mime_type (NautilusNavigationInfo *navinfo) -{ - const char *mime_type; - char *mime_supertype; - char *uri_scheme; - char *result; - char *explicit_iid_query; - - mime_type = navinfo->navinfo.content_type; - mime_supertype = mime_type_get_supertype (mime_type); - uri_scheme = uri_string_get_scheme (navinfo->navinfo.requested_uri); - - explicit_iid_query = make_oaf_query_for_explicit_content_view_iids (navinfo->explicit_iids); - - result = g_strdup_printf - ( - /* Check if the component has the interfaces we need. - * We can work with either a Nautilus View, or - * with a Bonobo Control or Embeddable that supports - * one of the three persistence interfaces: - * PersistStream, ProgressiveDataSink, or - * PersistFile. - */ - "((repo_ids.has_all(['IDL:Bonobo/Control:1.0'," - "'IDL:Nautilus/View:1.0'])" - "OR (repo_ids.has_one(['IDL:Bonobo/Control:1.0'," - "'IDL:Bonobo/Embeddable:1.0'])" - "AND repo_ids.has_one(['IDL:Bonobo/PersistStream:1.0'," - "'IDL:Bonobo/ProgressiveDataSink:1.0'," - "'IDL:Bonobo/PersistFile:1.0'])))" - - /* Check that the component either has a specific - * MIME type or URI scheme. If neither is specified, - * then we don't trust that to mean "all MIME types - * and all schemes". For that, you have to do a - * wildcard for the MIME type or for the scheme. - */ - "AND (bonobo:supported_mime_types.defined()" - "OR bonobo:supported_uri_schemes.defined ())" - - /* Check that the supported MIME types include the - * URI's MIME type or its supertype. - */ - "AND (NOT bonobo:supported_mime_types.defined()" - "OR bonobo:supported_mime_types.has('%s')" - "OR bonobo:supported_mime_types.has('%s')" - "OR bonobo:supported_mime_types.has('*/*'))" - - /* Check that the supported URI schemes include the - * URI's scheme. - */ - "AND (NOT bonobo:supported_uri_schemes.defined()" - "OR bonobo:supported_uri_schemes.has('%s')" - "OR bonobo:supported_uri_schemes.has('*'))" - - /* Check that the component makes it clear that it's - * intended for Nautilus by providing a "view_as" - * name. We could instead support a default, but - * that would make components that are untested with - * Nautilus appear. - */ - "AND nautilus:view_as_name.defined())" - - /* Also select iids that were specifically requested - for this location, even if they do not otherwise - meet the requirements. */ - "OR %s" - - /* The MIME type, MIME supertype, and URI scheme for - * the %s above. - */ - , mime_type, mime_supertype, uri_scheme - - /* The explicit metafile iid query for the %s above. */ - , explicit_iid_query -); - - g_free (mime_supertype); - g_free (uri_scheme); - g_free (explicit_iid_query); - return result; -} - -static char * -make_oaf_query_with_uri_scheme_only (NautilusNavigationInfo *navinfo) -{ - char *uri_scheme; - char *result; - char *explicit_iid_query; - - uri_scheme = uri_string_get_scheme (navinfo->navinfo.requested_uri); - - explicit_iid_query = make_oaf_query_for_explicit_content_view_iids (navinfo->explicit_iids); - - result = g_strdup_printf - ( - /* Check if the component has the interfaces we need. - * We can work with either a Nautilus tView, or - * with a Bonobo Control or Embeddable that works on - * a file, which is indicated by Bonobo PersistFile. - */ - "((repo_ids.has_all(['IDL:Bonobo/Control:1.0'," - "'IDL:Nautilus/View:1.0'])" - "OR (repo_ids.has_one(['IDL:Bonobo/Control:1.0'," - "'IDL:Bonobo/Embeddable:1.0'])" - "AND repo_ids.has('IDL:Bonobo/PersistFile:1.0')))" - - /* Check if the component supports this particular - * URI scheme. - */ - "AND (bonobo:supported_uri_schemes.has('%s')" - "OR bonobo:supported_uri_schemes.has('*'))" - - /* Check that the component doesn't require - * particular MIME types. Note that even saying you support "all" - */ - "AND (NOT bonobo:supported_mime_types.defined())" - - /* Check that the component makes it clear that it's - * intended for Nautilus by providing a "view_as" - * name. We could instead support a default, but - * that would make components that are untested with - * Nautilus appear. - */ - "AND nautilus:view_as_name.defined())" - - /* Also select iids that were specifically requested - for this location, even if they do not otherwise - meet the requirements. */ - - "OR %s" - - /* The URI scheme for the %s above. */ - , uri_scheme - - /* The explicit metafile iid query for the %s above. */ - , explicit_iid_query); - - - g_free (uri_scheme); - g_free (explicit_iid_query); - - return result; -} - - - - -static GHashTable * -file_list_to_mime_type_hash_table (GList *files) -{ - GHashTable *result; - GList *p; - char *mime_type; - - result = g_hash_table_new (g_str_hash, g_str_equal); - - for (p = files; p != NULL; p = p->next) { - if (p->data != NULL) { - mime_type = nautilus_file_get_mime_type ((NautilusFile *) p->data); - - if (NULL != mime_type) { - if (g_hash_table_lookup (result, mime_type) == NULL) { -#ifdef DEBUG_MJS - printf ("XXX content mime type: %s\n", mime_type); -#endif - g_hash_table_insert (result, mime_type, mime_type); - } else { - g_free (mime_type); - } - } - } - } - - return result; -} - -static void -free_key (gpointer key, gpointer value, gpointer user_data) -{ - g_free (key); -} - -static void -mime_type_hash_table_destroy (GHashTable *table) -{ - g_hash_table_foreach (table, free_key, NULL); - g_hash_table_destroy (table); -} - -static gboolean -server_matches_content_requirements (OAF_ServerInfo *server, GHashTable *type_table, GList *explicit_iids) -{ - OAF_Attribute *attr; - GNOME_stringlist types; - int i; - - /* Components explicitly requested in the metafile are not capability tested. */ - if (g_list_find_custom (explicit_iids, (gpointer) server->iid, (GCompareFunc) strcmp) != NULL) { - return TRUE; - } - - attr = oaf_server_info_attr_find (server, "nautilus:required_directory_content_mime_types"); - - if (attr == NULL || attr->v._d != OAF_A_STRINGV) { - return TRUE; - } else { - types = attr->v._u.value_stringv; - - for (i = 0; i < types._length; i++) { - if (g_hash_table_lookup (type_table, types._buffer[i]) != NULL) { - return TRUE; - } - } - } - - return FALSE; -} - - -static void -got_file_info_callback (GnomeVFSAsyncHandle *ah, - GList *result_list, - gpointer data) -{ - GnomeVFSGetFileInfoResult *file_result; - GnomeVFSResult vfs_result_code; - NautilusNavigationInfo *navinfo; - NautilusNavigationCallback notify_ready; - gpointer notify_ready_data; - NautilusNavigationResult result_code; - const char *fallback_iid; - const char *query; - OAF_ServerInfoList *oaf_result; - CORBA_Environment ev; - - g_assert (result_list != NULL); - g_assert (result_list->data != NULL); - g_assert (result_list->next == NULL); - - navinfo = data; - - navinfo->ah = NULL; - - notify_ready = navinfo->callback; - notify_ready_data = navinfo->callback_data; - - /* Get the content type. */ - file_result = result_list->data; - vfs_result_code = file_result->result; - - oaf_result = NULL; - query = NULL; - - get_explicit_content_view_iids_from_metafile (navinfo); - - if (vfs_result_code == GNOME_VFS_OK) { - /* FIXME bugzilla.eazel.com 697: disgusting hack to make rpm view work. Why - is the mime type not being detected properly in the - first place? */ - - if (nautilus_str_has_suffix (navinfo->navinfo.requested_uri, ".rpm")) { - navinfo->navinfo.content_type = g_strdup ("application/x-rpm"); - } else { - navinfo->navinfo.content_type = g_strdup - (gnome_vfs_file_info_get_mime_type (file_result->file_info)); - } - - /* FIXME bugzilla.eazel.com 699: - hack for lack of good type descriptions. Can - we remove this now? */ - - if (navinfo->navinfo.content_type == NULL) { - navinfo->navinfo.content_type = g_strdup ("text/plain"); - } - - /* activate by scheme and mime type */ - - query = make_oaf_query_with_known_mime_type (navinfo); - } else if (vfs_result_code == GNOME_VFS_ERROR_NOTSUPPORTED - || vfs_result_code == GNOME_VFS_ERROR_INVALIDURI) { - /* Activate by scheme only */ - - query = make_oaf_query_with_uri_scheme_only (navinfo); - } else { - goto out; - } - - CORBA_exception_init (&ev); - -#ifdef DEBUG_MJS - printf ("query: \"%s\"\n", query); -#endif - - oaf_result = oaf_query (query, nautilus_sort_criteria, &ev); - - if (ev._major == CORBA_NO_EXCEPTION && oaf_result != NULL && oaf_result->_length > 0) { - GHashTable *content_types; - int i; - - content_types = file_list_to_mime_type_hash_table (navinfo->files); - - CORBA_exception_free (&ev); - - vfs_result_code = GNOME_VFS_OK; - - for (i = 0; i < oaf_result->_length; i++) { - OAF_ServerInfo *server; - - server = &oaf_result->_buffer[i]; - - if (server_matches_content_requirements (server, content_types, navinfo->explicit_iids)) { - navinfo->content_identifiers = g_list_append - (navinfo->content_identifiers, - nautilus_view_identifier_new_from_content_view (server)); - } - } - - mime_type_hash_table_destroy (content_types); - } else { - CORBA_exception_free (&ev); - result_code = NAUTILUS_NAVIGATION_RESULT_NO_HANDLER_FOR_TYPE; - goto out; - } - - - /* Map GnomeVFSResult to one of the types that Nautilus knows how to handle. */ - result_code = get_nautilus_navigation_result_from_gnome_vfs_result (vfs_result_code); - - if (vfs_result_code != GNOME_VFS_OK) { - /* Leave navinfo intact so notify_ready function can access the uri. - * (notify_ready function is responsible for freeing navinfo). - */ - goto out; - } - - if (navinfo->content_identifiers) { - fallback_iid = ((NautilusViewIdentifier *) - (navinfo->content_identifiers->data))->iid; -#ifdef DEBUG_MJS - printf ("XXX - fallback_iid: %s\n", fallback_iid); -#endif - } - - /* Now that all the content_identifiers are in place, we're ready to choose - * the initial one. - */ - g_assert (fallback_iid != NULL); - set_initial_content_iid (navinfo, fallback_iid); - - out: - (* notify_ready) (result_code, navinfo, notify_ready_data); -} - -/* The following routine uses metadata associated with the current url to add content view components specified in the metadata */ - -static void -got_metadata_callback (NautilusDirectory *directory, - GList *files, - gpointer callback_data) -{ - NautilusNavigationInfo *info; - - info = callback_data; - g_assert (info->directory == directory); - - info->files = nautilus_file_list_copy (files); - async_get_file_info_text (&info->ah, - info->navinfo.requested_uri, - (GNOME_VFS_FILE_INFO_GETMIMETYPE - | GNOME_VFS_FILE_INFO_FOLLOWLINKS), - got_file_info_callback, - info); -} - -/* NautilusNavigationInfo */ - -NautilusNavigationInfo * -nautilus_navigation_info_new (Nautilus_NavigationRequestInfo *nri, - Nautilus_NavigationInfo *old_info, - NautilusNavigationCallback notify_when_ready, - gpointer notify_data, - const char *referring_iid) -{ - NautilusNavigationInfo *info; - GList *attributes; - - info = g_new0 (NautilusNavigationInfo, 1); - - info->callback = notify_when_ready; - info->callback_data = notify_data; - - if (old_info != NULL) { - info->navinfo.referring_uri = old_info->requested_uri; - info->navinfo.actual_referring_uri = old_info->actual_uri; - info->navinfo.referring_content_type = old_info->content_type; - } - - info->referring_iid = g_strdup (referring_iid); - info->navinfo.requested_uri = g_strdup (nri->requested_uri); - - info->directory = nautilus_directory_get (nri->requested_uri); - - /* Arrange for all the file attributes we will need. */ - attributes = NULL; - attributes = g_list_prepend (attributes, NAUTILUS_FILE_ATTRIBUTE_FAST_MIME_TYPE); - - nautilus_directory_call_when_ready - (info->directory, - attributes, TRUE, - got_metadata_callback, info); - - g_list_free (attributes); - - return info; -} - -void -nautilus_navigation_info_cancel (NautilusNavigationInfo *info) -{ - g_return_if_fail (info != NULL); - - if (info->ah != NULL) { - gnome_vfs_async_cancel (info->ah); - info->ah = NULL; - } - - nautilus_directory_cancel_callback - (info->directory, - got_metadata_callback, - info); -} - -void -nautilus_navigation_info_free (NautilusNavigationInfo *info) -{ - g_return_if_fail (info != NULL); - - nautilus_navigation_info_cancel (info); - - nautilus_view_identifier_free_list (info->content_identifiers); - nautilus_g_list_free_deep (info->explicit_iids); - - g_free (info->referring_iid); - g_free (info->initial_content_iid); - g_free (info->navinfo.requested_uri); - g_free (info->navinfo.actual_uri); - g_free (info->navinfo.content_type); - - nautilus_directory_unref (info->directory); - nautilus_file_list_free (info->files); - - g_free (info); -} - -/* Cover for getting file info for one file. */ -static void -async_get_file_info_text (GnomeVFSAsyncHandle **handle, - const char *text_uri, - GnomeVFSFileInfoOptions options, - GnomeVFSAsyncGetFileInfoCallback callback, - gpointer callback_data) -{ - GnomeVFSURI *vfs_uri; - GList uri_list; - GList result_list; - GnomeVFSGetFileInfoResult result_item; - - vfs_uri = gnome_vfs_uri_new (text_uri); - if (vfs_uri == NULL) { - /* Report the error. */ - - *handle = NULL; - - result_item.uri = NULL; - result_item.result = GNOME_VFS_ERROR_INVALIDURI; - result_item.file_info = NULL; - - result_list.data = &result_item; - result_list.next = NULL; - - (* callback) (NULL, &result_list, callback_data); - - return; - } - - /* Construct a simple URI list. */ - uri_list.data = vfs_uri; - uri_list.next = NULL; - - gnome_vfs_async_get_file_info (handle, - &uri_list, - options, - NULL, - callback, - callback_data); - - gnome_vfs_uri_unref (vfs_uri); -} diff --git a/src/ntl-uri-map.h b/src/ntl-uri-map.h deleted file mode 100644 index c05ed220c..000000000 --- a/src/ntl-uri-map.h +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Elliot Lee <sopwith@redhat.com> - * - */ - -/* ntl-uri-map.h: Interface for mapping a location change request to a set of views and actual URL to be loaded. */ - -#ifndef NAUTILUS_URI_MAP_H -#define NAUTILUS_URI_MAP_H - -#include <glib.h> -#include <libgnomevfs/gnome-vfs-types.h> -#include <libnautilus/nautilus-view-component.h> -#include <libnautilus-extensions/nautilus-directory.h> - -typedef struct NautilusNavigationInfo NautilusNavigationInfo; - -/* These are the different ways that Nautilus can fail to - * display the contents of a given uri. NAUTILUS_NAVIGATION_RESULT_OK - * means the uri was displayed successfully. These are similar to - * GnomeVFSResults but there are nautilus-specific codes and many of - * the GnomeVFSResults are treated the same here. - */ -typedef enum { - NAUTILUS_NAVIGATION_RESULT_OK, - NAUTILUS_NAVIGATION_RESULT_UNSPECIFIC_ERROR, - NAUTILUS_NAVIGATION_RESULT_NO_HANDLER_FOR_TYPE, - NAUTILUS_NAVIGATION_RESULT_NOT_FOUND, - NAUTILUS_NAVIGATION_RESULT_UNSUPPORTED_SCHEME, - NAUTILUS_NAVIGATION_RESULT_INVALID_URI -} NautilusNavigationResult; - -typedef void (*NautilusNavigationCallback) (NautilusNavigationResult result, - NautilusNavigationInfo *info, - gpointer callback_data); - -struct NautilusNavigationInfo { - Nautilus_NavigationInfo navinfo; - - char *referring_iid; /* iid of content view that we're coming from */ - char *initial_content_iid; /* iid to use for content view that we're going to display */ - GList *content_identifiers; /* list of NautilusViewIdentifiers */ - GList *files; /* NautilusFile's for files in the dir, if it is one. */ - GList *explicit_iids; /* IIDs explicitly mentioned in the metafile. */ - - /* internal usage */ - NautilusNavigationCallback callback; - gpointer callback_data; - GnomeVFSAsyncHandle *ah; - NautilusDirectory *directory; -}; - -NautilusNavigationInfo *nautilus_navigation_info_new (Nautilus_NavigationRequestInfo *request, - Nautilus_NavigationInfo *previous_location, - NautilusNavigationCallback ready_callback, - gpointer callback_data, - const char *referring_iid); -void nautilus_navigation_info_cancel (NautilusNavigationInfo *info); -void nautilus_navigation_info_free (NautilusNavigationInfo *info); - -#endif diff --git a/src/ntl-view-bonobo-control.c b/src/ntl-view-bonobo-control.c deleted file mode 100644 index d37a93f28..000000000 --- a/src/ntl-view-bonobo-control.c +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 1999, 2000 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Elliot Lee <sopwith@redhat.com> - * - */ - -#include <config.h> - -#include "ntl-view-private.h" -#include "ntl-window.h" - -typedef struct { - BonoboObject *control_frame; -} BonoboControlInfo; - -static void -destroy_bonobo_control_view(NautilusViewFrame *view, CORBA_Environment *ev) -{ - BonoboControlInfo *bci = view->component_data; - g_free(bci); -} - -static void -nautilus_view_frame_activate_uri(BonoboControlFrame *frame, const char *uri, gboolean relative, NautilusViewFrame *view) -{ - Nautilus_NavigationRequestInfo nri; - g_assert(!relative); - - memset(&nri, 0, sizeof(nri)); - nri.requested_uri = (char *)uri; - nautilus_view_frame_request_location_change(view, &nri); -} - -static gboolean -bonobo_control_try_load_client(NautilusViewFrame *view, CORBA_Object obj, CORBA_Environment *ev) -{ - BonoboControlInfo *bci; - Bonobo_UIHandler uih = bonobo_object_corba_objref(BONOBO_OBJECT(nautilus_window_get_uih(NAUTILUS_WINDOW(view->main_window)))); - - view->component_data = bci = g_new0(BonoboControlInfo, 1); - - bci->control_frame = BONOBO_OBJECT(bonobo_control_frame_new(uih)); - bonobo_object_add_interface(BONOBO_OBJECT(bci->control_frame), view->view_frame); - - bonobo_control_frame_bind_to_control(BONOBO_CONTROL_FRAME(bci->control_frame), obj); - - view->client_widget = bonobo_control_frame_get_widget(BONOBO_CONTROL_FRAME(bci->control_frame)); - - gtk_signal_connect(GTK_OBJECT(bci->control_frame), - "activate_uri", GTK_SIGNAL_FUNC(nautilus_view_frame_activate_uri), view); - - return TRUE; -} - -static void -bonobo_control_notify_location_change(NautilusViewFrame *view, Nautilus_NavigationInfo *real_nav_ctx, CORBA_Environment *ev) -{ - Nautilus_ProgressRequestInfo pri; - pri.amount = 0; - pri.type = Nautilus_PROGRESS_UNDERWAY; - nautilus_view_frame_request_progress_change(view, &pri); - pri.type = Nautilus_PROGRESS_DONE_OK; - nautilus_view_frame_request_progress_change(view, &pri); -} - -NautilusViewComponentType bonobo_control_component_type = { - "IDL:Bonobo/Control:1.0", - &bonobo_control_try_load_client, /* try_load */ - &destroy_bonobo_control_view, /* destroy */ - NULL, /* save_state */ - NULL, /* load_state */ - &bonobo_control_notify_location_change, /* notify_location_change */ - NULL, /* stop_location_change */ - NULL, /* notify_selection_change */ - NULL /* show_properties */ -}; diff --git a/src/ntl-view-bonobo-subdoc.c b/src/ntl-view-bonobo-subdoc.c deleted file mode 100644 index fd869a168..000000000 --- a/src/ntl-view-bonobo-subdoc.c +++ /dev/null @@ -1,129 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 1999, 2000 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Elliot Lee <sopwith@redhat.com> - * - */ - -#include <config.h> - -#include "ntl-view-private.h" -#include "ntl-window.h" -#include <libnautilus-extensions/bonobo-stream-vfs.h> - -typedef struct { - BonoboObject *container, *client_site, *view_frame; -} BonoboSubdocInfo; - -static void -destroy_bonobo_subdoc_view (NautilusViewFrame *view, CORBA_Environment *ev) -{ - BonoboSubdocInfo *bsi = view->component_data; - g_free(bsi); -} - -static void -bonobo_subdoc_notify_location_change (NautilusViewFrame *view, - Nautilus_NavigationInfo *real_nav_ctx, - CORBA_Environment *ev) -{ - Bonobo_PersistStream persist; - - if((persist = bonobo_object_client_query_interface(view->client_object, "IDL:Bonobo/PersistStream:1.0", - NULL)) - && !CORBA_Object_is_nil(persist, ev)) - { - BonoboStream *stream; - Nautilus_ProgressRequestInfo pri; - - stream = bonobo_stream_vfs_open(real_nav_ctx->actual_uri, Bonobo_Storage_READ); - pri.amount = 0; - if(stream) - pri.type = Nautilus_PROGRESS_UNDERWAY; - else - pri.type = Nautilus_PROGRESS_DONE_ERROR; - nautilus_view_frame_request_progress_change(view, &pri); - if (stream != NULL) - { - /* FIXME: Dan Winship points out that we should pass the - * MIME type here to work with new implementers of - * PersistStream that pay attention to the MIME type. It - * doesn't matter right now, but we should fix it - * eventually. Currently, we don't store the MIME type, but - * it should be easy to keep it around and pass it in here. - */ - Bonobo_PersistStream_load - (persist, - bonobo_object_corba_objref (BONOBO_OBJECT (stream)), - "", /* MIME type of stream */ - ev); - Bonobo_Unknown_unref(persist, ev); - CORBA_Object_release(persist, ev); - pri.type = Nautilus_PROGRESS_DONE_OK; - nautilus_view_frame_request_progress_change(view, &pri); - } - } -} - -static gboolean -bonobo_subdoc_try_load_client(NautilusViewFrame *view, CORBA_Object obj, CORBA_Environment *ev) -{ - BonoboSubdocInfo *bsi; - Bonobo_UIHandler uih = bonobo_object_corba_objref(BONOBO_OBJECT(nautilus_window_get_uih(NAUTILUS_WINDOW(view->main_window)))); - - - view->component_data = bsi = g_new0(BonoboSubdocInfo, 1); - - bsi->container = BONOBO_OBJECT(bonobo_container_new()); - - bsi->client_site = - BONOBO_OBJECT(bonobo_client_site_new(BONOBO_CONTAINER(bsi->container))); - bonobo_client_site_bind_embeddable(BONOBO_CLIENT_SITE(bsi->client_site), view->client_object); - bonobo_container_add(BONOBO_CONTAINER(bsi->container), bsi->client_site); - - bsi->view_frame = BONOBO_OBJECT (bonobo_client_site_new_view (BONOBO_CLIENT_SITE (bsi->client_site), uih)); - - g_assert(bsi->view_frame); - - bonobo_object_add_interface(BONOBO_OBJECT(bsi->view_frame), view->view_frame); - - view->client_widget = bonobo_view_frame_get_wrapper(BONOBO_VIEW_FRAME(bsi->view_frame)); - - bonobo_wrapper_set_visibility (BONOBO_WRAPPER (view->client_widget), FALSE); - - bonobo_view_frame_set_covered (BONOBO_VIEW_FRAME (bsi->view_frame), FALSE); - - return TRUE; -} - -NautilusViewComponentType bonobo_subdoc_component_type = { - "IDL:Bonobo/Embeddable:1.0", - &bonobo_subdoc_try_load_client, /* try_load */ - &destroy_bonobo_subdoc_view, /* destroy */ - NULL, /* save_state */ - NULL, /* load_state */ - &bonobo_subdoc_notify_location_change, /* notify_location_change */ - NULL, /* stop_location_change */ - NULL, /* notify_selection_change */ - NULL /* show_properties */ -}; - diff --git a/src/ntl-view-frame-svr.c b/src/ntl-view-frame-svr.c deleted file mode 100644 index 184ee0091..000000000 --- a/src/ntl-view-frame-svr.c +++ /dev/null @@ -1,172 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 1999, 2000 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Elliot Lee <sopwith@redhat.com> - * - */ -/* ntl-view-frame-svr.c: CORBA server implementation of the object - representing a data view frame. */ - -#include <config.h> - -#include "ntl-view-private.h" -#include "ntl-window.h" - -static Nautilus_ViewWindow impl_Nautilus_ViewFrame__get_main_window (PortableServer_Servant servant, - CORBA_Environment *ev); -static void impl_Nautilus_ViewFrame_request_location_change (PortableServer_Servant servant, - const Nautilus_NavigationRequestInfo *navinfo, - CORBA_Environment *ev); -static void impl_Nautilus_ViewFrame_request_selection_change (PortableServer_Servant servant, - const Nautilus_SelectionRequestInfo *selinfo, - CORBA_Environment *ev); -static void impl_Nautilus_ViewFrame_request_status_change (PortableServer_Servant servant, - const Nautilus_StatusRequestInfo *statinfo, - CORBA_Environment *ev); -static void impl_Nautilus_ViewFrame_request_progress_change (PortableServer_Servant servant, - const Nautilus_ProgressRequestInfo *proginfo, - CORBA_Environment *ev); -static void impl_Nautilus_ViewFrame_request_title_change (PortableServer_Servant servant, - const CORBA_char *new_title, - CORBA_Environment *ev); - -POA_Nautilus_ViewFrame__epv impl_Nautilus_ViewFrame_epv = -{ - NULL, - &impl_Nautilus_ViewFrame__get_main_window, - &impl_Nautilus_ViewFrame_request_status_change, - &impl_Nautilus_ViewFrame_request_location_change, - &impl_Nautilus_ViewFrame_request_selection_change, - &impl_Nautilus_ViewFrame_request_progress_change, - &impl_Nautilus_ViewFrame_request_title_change -}; - -static PortableServer_ServantBase__epv base_epv; -POA_Nautilus_ViewFrame__vepv impl_Nautilus_ViewFrame_vepv = -{ - &base_epv, - NULL, - &impl_Nautilus_ViewFrame_epv -}; - -static void -impl_Nautilus_ViewFrame__destroy (BonoboObject *obj, - impl_POA_Nautilus_ViewFrame *servant) -{ - PortableServer_ObjectId *objid; - CORBA_Environment ev; - NautilusViewFrameClass *klass; - void (*servant_destroy_func) (PortableServer_Servant, CORBA_Environment *); - - klass = NAUTILUS_VIEW_FRAME_CLASS (GTK_OBJECT (servant->view)->klass); - - CORBA_exception_init(&ev); - - objid = PortableServer_POA_servant_to_id (bonobo_poa (), servant, &ev); - PortableServer_POA_deactivate_object (bonobo_poa (), objid, &ev); - CORBA_free (objid); - obj->servant = NULL; - - servant_destroy_func = klass->servant_destroy_func; - servant_destroy_func ((PortableServer_Servant) servant, &ev); - g_free (servant); - CORBA_exception_free (&ev); -} - -BonoboObject * -impl_Nautilus_ViewFrame__create(NautilusViewFrame *view, CORBA_Environment *ev) -{ - BonoboObject *bonobo_object; - impl_POA_Nautilus_ViewFrame *servant; - NautilusViewFrameClass *klass; - void (*servant_init_func) (PortableServer_Servant, CORBA_Environment *); - - klass = NAUTILUS_VIEW_FRAME_CLASS (GTK_OBJECT (view)->klass); - servant = g_new0 (impl_POA_Nautilus_ViewFrame, 1); - servant->servant.vepv = klass->vepv; - servant->servant.vepv->Bonobo_Unknown_epv = bonobo_object_get_epv (); - servant->view = view; - servant_init_func = klass->servant_init_func; - servant_init_func ((PortableServer_Servant) servant, ev); - - bonobo_object = bonobo_object_new_from_servant (servant); - - gtk_signal_connect (GTK_OBJECT (bonobo_object), "destroy", - GTK_SIGNAL_FUNC (impl_Nautilus_ViewFrame__destroy), servant); - - return bonobo_object; -} - -static Nautilus_ViewWindow -impl_Nautilus_ViewFrame__get_main_window (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - NautilusWindow *window; - - window = NAUTILUS_WINDOW (((impl_POA_Nautilus_ViewFrame *) servant)->view->main_window); - return CORBA_Object_duplicate (bonobo_object_corba_objref (window->ntl_viewwindow), ev); -} - -static void -impl_Nautilus_ViewFrame_request_location_change (PortableServer_Servant servant, - const Nautilus_NavigationRequestInfo *navinfo, - CORBA_Environment *ev) -{ - nautilus_view_frame_request_location_change - (((impl_POA_Nautilus_ViewFrame *) servant)->view, navinfo); -} - -static void -impl_Nautilus_ViewFrame_request_selection_change (PortableServer_Servant servant, - const Nautilus_SelectionRequestInfo *selinfo, - CORBA_Environment *ev) -{ - nautilus_view_frame_request_selection_change - (((impl_POA_Nautilus_ViewFrame *) servant)->view, selinfo); -} - -static void -impl_Nautilus_ViewFrame_request_status_change (PortableServer_Servant servant, - const Nautilus_StatusRequestInfo *statinfo, - CORBA_Environment *ev) -{ - nautilus_view_frame_request_status_change - (((impl_POA_Nautilus_ViewFrame *) servant)->view, statinfo); -} - -static void -impl_Nautilus_ViewFrame_request_progress_change (PortableServer_Servant servant, - const Nautilus_ProgressRequestInfo *proginfo, - CORBA_Environment *ev) -{ - nautilus_view_frame_request_progress_change - (((impl_POA_Nautilus_ViewFrame *) servant)->view, proginfo); -} - -static void -impl_Nautilus_ViewFrame_request_title_change (PortableServer_Servant servant, - const CORBA_char *title, - CORBA_Environment *ev) -{ - nautilus_view_frame_request_title_change - (((impl_POA_Nautilus_ViewFrame *) servant)->view, title); -} diff --git a/src/ntl-view-nautilus.c b/src/ntl-view-nautilus.c deleted file mode 100644 index 6465c7276..000000000 --- a/src/ntl-view-nautilus.c +++ /dev/null @@ -1,152 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 1999, 2000 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Elliot Lee <sopwith@redhat.com> - * - */ - -#include <config.h> - -#include "ntl-view-private.h" -#include "ntl-window.h" - -typedef struct { - BonoboObject *control_frame; - CORBA_Object view_client; -} NautilusViewInfo; - -static gboolean -nautilus_view_try_load_client(NautilusViewFrame *view, CORBA_Object obj, CORBA_Environment *ev) -{ - Bonobo_Control control; - NautilusViewInfo *nvi; - Bonobo_UIHandler uih = bonobo_object_corba_objref(BONOBO_OBJECT(nautilus_window_get_uih(NAUTILUS_WINDOW(view->main_window)))); - nvi = view->component_data = g_new0(NautilusViewInfo, 1); - - control = Bonobo_Unknown_query_interface(obj, "IDL:Bonobo/Control:1.0", ev); - if(ev->_major != CORBA_NO_EXCEPTION) - control = CORBA_OBJECT_NIL; - - if(CORBA_Object_is_nil(control, ev)) - goto out; - - nvi->view_client = CORBA_Object_duplicate(obj, ev); - - nvi->control_frame = BONOBO_OBJECT(bonobo_control_frame_new(uih)); - bonobo_object_add_interface(BONOBO_OBJECT(nvi->control_frame), view->view_frame); - - bonobo_control_frame_bind_to_control(BONOBO_CONTROL_FRAME(nvi->control_frame), control); - view->client_widget = bonobo_control_frame_get_widget(BONOBO_CONTROL_FRAME(nvi->control_frame)); - - Bonobo_Unknown_unref(control, ev); - CORBA_Object_release(control, ev); - - return TRUE; - - out: - g_free(nvi); - - return FALSE; -} - -static void -destroy_nautilus_view(NautilusViewFrame *view, CORBA_Environment *ev) -{ - NautilusViewInfo *nvi = view->component_data; - - CORBA_Object_release(nvi->view_client, ev); - - g_free(nvi); -} - -static void -nv_show_properties(NautilusViewFrame *view, CORBA_Environment *ev) -{ - NautilusViewInfo *nvi = view->component_data; - - Nautilus_View_show_properties(nvi->view_client, ev); - if(ev->_major != CORBA_NO_EXCEPTION) - gtk_object_destroy(GTK_OBJECT(view)); -} - -static void -nv_save_state(NautilusViewFrame *view, const char *config_path, CORBA_Environment *ev) -{ - NautilusViewInfo *nvi = view->component_data; - - Nautilus_View_save_state(nvi->view_client, config_path, ev); - if(ev->_major != CORBA_NO_EXCEPTION) - gtk_object_destroy(GTK_OBJECT(view)); -} - -static void -nv_load_state(NautilusViewFrame *view, const char *config_path, CORBA_Environment *ev) -{ - NautilusViewInfo *nvi = view->component_data; - - Nautilus_View_load_state(nvi->view_client, config_path, ev); - if(ev->_major != CORBA_NO_EXCEPTION) - gtk_object_destroy(GTK_OBJECT(view)); -} - -static void -nv_notify_location_change(NautilusViewFrame *view, Nautilus_NavigationInfo *nav_ctx, CORBA_Environment *ev) -{ - NautilusViewInfo *nvi = view->component_data; - - Nautilus_View_notify_location_change(nvi->view_client, nav_ctx, ev); - if(ev->_major != CORBA_NO_EXCEPTION) - gtk_object_destroy(GTK_OBJECT(view)); -} - -static void -nv_notify_selection_change(NautilusViewFrame *view, Nautilus_SelectionInfo *nav_ctx, CORBA_Environment *ev) -{ - NautilusViewInfo *nvi = view->component_data; - - Nautilus_View_notify_selection_change(nvi->view_client, nav_ctx, ev); - - if(ev->_major != CORBA_NO_EXCEPTION) - gtk_object_destroy(GTK_OBJECT(view)); -} - -static void -nv_stop_location_change(NautilusViewFrame *view, CORBA_Environment *ev) -{ - NautilusViewInfo *nvi = view->component_data; - - Nautilus_View_stop_location_change(nvi->view_client, ev); - if(ev->_major != CORBA_NO_EXCEPTION) - gtk_object_destroy(GTK_OBJECT(view)); -} - -NautilusViewComponentType nautilus_view_component_type = { - "IDL:Nautilus/View:1.0", - &nautilus_view_try_load_client, /* try_load */ - &destroy_nautilus_view, /* destroy */ - &nv_save_state, /* save_state */ - &nv_load_state, /* load_state */ - &nv_notify_location_change, /* notify_location_change */ - &nv_stop_location_change, /*stop_location_change */ - &nv_notify_selection_change, /* notify_selection_change */ - &nv_show_properties /* show_properties */ -}; diff --git a/src/ntl-view-private.h b/src/ntl-view-private.h deleted file mode 100644 index 14e55144e..000000000 --- a/src/ntl-view-private.h +++ /dev/null @@ -1,74 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 1999, 2000 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Elliot Lee <sopwith@redhat.com> - * - */ - -/* ntl-view-private.h: Internals of the view proxy that are shared between different implementation files */ - -#ifndef NTL_VIEW_PRIVATE_H -#define NTL_VIEW_PRIVATE_H - -#include "ntl-view.h" - -typedef struct { - POA_Nautilus_ViewFrame servant; - gpointer bonobo_object; - - NautilusViewFrame *view; -} impl_POA_Nautilus_ViewFrame; - -extern POA_Nautilus_ViewFrame__vepv impl_Nautilus_ViewFrame_vepv; -extern POA_Nautilus_ZoomableFrame__vepv impl_Nautilus_ZoomableFrame_vepv; - -BonoboObject *impl_Nautilus_ViewFrame__create (NautilusViewFrame *view, - CORBA_Environment *ev); -BonoboObject *impl_Nautilus_ZoomableFrame__create (NautilusViewFrame *view, - CORBA_Environment *ev); -void nautilus_view_frame_request_location_change (NautilusViewFrame *view, - const Nautilus_NavigationRequestInfo *loc); -void nautilus_view_frame_request_selection_change (NautilusViewFrame *view, - const Nautilus_SelectionRequestInfo *loc); -void nautilus_view_frame_request_status_change (NautilusViewFrame *view, - const Nautilus_StatusRequestInfo *loc); -void nautilus_view_frame_request_progress_change (NautilusViewFrame *view, - const Nautilus_ProgressRequestInfo *loc); -void nautilus_view_frame_request_title_change (NautilusViewFrame *view, - const char *title); -void nautilus_view_frame_notify_zoom_level (NautilusViewFrame *view, - double level); - -struct NautilusViewComponentType { - const char *primary_repoid; - gboolean (* try_load)(NautilusViewFrame *view, CORBA_Object obj, CORBA_Environment *ev); - void (* destroy) (NautilusViewFrame *view, CORBA_Environment *ev); - void (* save_state)(NautilusViewFrame *view, const char *config_path, CORBA_Environment *ev); - void (* load_state)(NautilusViewFrame *view, const char *config_path, CORBA_Environment *ev); - void (* notify_location_change)(NautilusViewFrame *view, Nautilus_NavigationInfo *nav_ctx, CORBA_Environment *ev); - void (* stop_location_change)(NautilusViewFrame *view, CORBA_Environment *ev); - void (* notify_selection_change)(NautilusViewFrame *view, Nautilus_SelectionInfo *nav_ctx, CORBA_Environment *ev); - void (* show_properties)(NautilusViewFrame *view, CORBA_Environment *ev); -}; - -#endif /* NTL_VIEW_PRIVATE_H */ - diff --git a/src/ntl-view.c b/src/ntl-view.c deleted file mode 100644 index 44d18c86e..000000000 --- a/src/ntl-view.c +++ /dev/null @@ -1,868 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 1999, 2000 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Elliot Lee <sopwith@redhat.com> - * - */ -/* ntl-view.c: Implementation of the object representing a data view, - and its associated CORBA object for proxying requests into this - object. */ - -#include <config.h> - -#include "ntl-view-private.h" -#include "ntl-window.h" -#include <libnautilus-extensions/nautilus-gtk-extensions.h> -#include <gtk/gtksignal.h> -#include <gtk/gtk.h> -#include <libnautilus/nautilus-undo-manager.h> -#include <libnautilus/nautilus-undo-context.h> - -enum { - REQUEST_LOCATION_CHANGE, - REQUEST_SELECTION_CHANGE, - REQUEST_STATUS_CHANGE, - REQUEST_PROGRESS_CHANGE, - REQUEST_TITLE_CHANGE, - NOTIFY_ZOOM_LEVEL, - LAST_SIGNAL -}; - -enum { - ARG_0, - ARG_MAIN_WINDOW -}; - -static void nautilus_view_frame_init (NautilusViewFrame *view); -static void nautilus_view_frame_destroy (GtkObject *view); -static void nautilus_view_frame_constructed (NautilusViewFrame *view); -static void nautilus_view_frame_class_init (NautilusViewFrameClass *klass); -static void nautilus_view_frame_set_arg (GtkObject *object, - GtkArg *arg, - guint arg_id); -static void nautilus_view_frame_get_arg (GtkObject *object, - GtkArg *arg, - guint arg_id); -static void nautilus_view_frame_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void nautilus_view_frame_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); - -static guint signals[LAST_SIGNAL]; - -GtkType -nautilus_view_frame_get_type (void) -{ - static GtkType view_type = 0; - - if (!view_type) { - const GtkTypeInfo view_info = { - "NautilusViewFrame", - sizeof (NautilusViewFrame), - sizeof (NautilusViewFrameClass), - (GtkClassInitFunc) nautilus_view_frame_class_init, - (GtkObjectInitFunc) nautilus_view_frame_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - view_type = gtk_type_unique (gtk_bin_get_type(), &view_info); - } - - return view_type; -} - -static void -nautilus_view_frame_class_init (NautilusViewFrameClass *klass) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass*) klass; - object_class->destroy = nautilus_view_frame_destroy; - object_class->set_arg = nautilus_view_frame_set_arg; - object_class->get_arg = nautilus_view_frame_get_arg; - - widget_class = (GtkWidgetClass*) klass; - widget_class->size_request = nautilus_view_frame_size_request; - widget_class->size_allocate = nautilus_view_frame_size_allocate; - - klass->servant_init_func = POA_Nautilus_ViewFrame__init; - klass->servant_destroy_func = POA_Nautilus_ViewFrame__fini; - klass->vepv = &impl_Nautilus_ViewFrame_vepv; - - klass->zoomable_servant_init_func = POA_Nautilus_ZoomableFrame__init; - klass->zoomable_servant_destroy_func = POA_Nautilus_ZoomableFrame__fini; - klass->zoomable_vepv = &impl_Nautilus_ZoomableFrame_vepv; - - klass->parent_class = gtk_type_class (gtk_type_parent (object_class->type)); - /* klass->request_location_change = NULL; */ - /* klass->request_selection_change = NULL; */ - /* klass->request_status_change = NULL; */ - /* klass->request_progress_change = NULL; */ - klass->view_constructed = nautilus_view_frame_constructed; - - signals[REQUEST_LOCATION_CHANGE] = - gtk_signal_new ("request_location_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (NautilusViewFrameClass, - request_location_change), - gtk_marshal_NONE__BOXED, - GTK_TYPE_NONE, 1, GTK_TYPE_BOXED); - signals[REQUEST_SELECTION_CHANGE] = - gtk_signal_new ("request_selection_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (NautilusViewFrameClass, - request_selection_change), - gtk_marshal_NONE__BOXED, - GTK_TYPE_NONE, 1, GTK_TYPE_BOXED); - signals[REQUEST_STATUS_CHANGE] = - gtk_signal_new ("request_status_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (NautilusViewFrameClass, - request_status_change), - gtk_marshal_NONE__BOXED, - GTK_TYPE_NONE, 1, GTK_TYPE_BOXED); - signals[REQUEST_PROGRESS_CHANGE] = - gtk_signal_new ("request_progress_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (NautilusViewFrameClass, - request_progress_change), - gtk_marshal_NONE__STRING, - GTK_TYPE_NONE, 1, GTK_TYPE_STRING); - signals[REQUEST_TITLE_CHANGE] = - gtk_signal_new ("request_title_change", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (NautilusViewFrameClass, - request_title_change), - gtk_marshal_NONE__BOXED, - GTK_TYPE_NONE, 1, GTK_TYPE_BOXED); - - signals[NOTIFY_ZOOM_LEVEL] = - gtk_signal_new ("notify_zoom_level", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (NautilusViewFrameClass, - notify_zoom_level), - nautilus_gtk_marshal_NONE__DOUBLE, - GTK_TYPE_NONE, 1, GTK_TYPE_DOUBLE); - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); - - gtk_object_add_arg_type ("NautilusViewFrame::main_window", - GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, - ARG_MAIN_WINDOW); - - klass->num_construct_args++; -} - -static void -nautilus_view_frame_set_arg (GtkObject *object, - GtkArg *arg, - guint arg_id) -{ - NautilusViewFrame *view; - - view = NAUTILUS_VIEW_FRAME(object); - switch(arg_id) { - case ARG_MAIN_WINDOW: - view->main_window = GTK_WIDGET(GTK_VALUE_OBJECT(*arg)); - nautilus_view_frame_construct_arg_set(view); - break; - } -} - -static void -nautilus_view_frame_get_arg (GtkObject *object, - GtkArg *arg, - guint arg_id) -{ - switch(arg_id) { - case ARG_MAIN_WINDOW: - GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(NAUTILUS_VIEW_FRAME(object)->main_window); - break; - } -} - -static void -nautilus_view_frame_init (NautilusViewFrame *view) -{ - GTK_WIDGET_SET_FLAGS (view, GTK_NO_WINDOW); -} - -static void -nautilus_view_frame_destroy_client(NautilusViewFrame *view) -{ - CORBA_Environment ev; - CORBA_exception_init(&ev); - - if(!view->component_class) - return; - - g_free(view->iid); view->iid = NULL; - - bonobo_object_unref (BONOBO_OBJECT (view->client_object)); view->client_object = NULL; - - gtk_container_remove (GTK_CONTAINER(view), view->client_widget); view->client_widget = NULL; - - if (! CORBA_Object_is_nil (view->zoomable, &ev)) { - Bonobo_Unknown_unref (view->zoomable, &ev); - view->zoomable = CORBA_OBJECT_NIL; - } - - if(view->component_class->destroy) { - view->component_class->destroy(view, &ev); - } - - /* FIXME bugzilla.eazel.com 917: This should be bonobo_object_unref, - * but there is a circular reference that prevents it from working. - */ - bonobo_object_destroy (view->view_frame); - view->view_frame = NULL; - - view->component_class = NULL; - view->component_data = NULL; - - CORBA_exception_free(&ev); -} - -static void -nautilus_view_frame_destroy(GtkObject *view) -{ - NautilusViewFrameClass *klass = NAUTILUS_VIEW_FRAME_CLASS(view->klass); - NautilusViewFrame *nview = NAUTILUS_VIEW_FRAME(view); - - if(nview->timer_id) - { - g_source_remove(nview->timer_id); - nview->timer_id = 0; - } - - nautilus_view_frame_destroy_client(nview); - - if(GTK_OBJECT_CLASS(klass->parent_class)->destroy) - GTK_OBJECT_CLASS(klass->parent_class)->destroy(view); -} - -static void -nautilus_view_frame_constructed(NautilusViewFrame *view) -{ -} - -void -nautilus_view_frame_construct_arg_set(NautilusViewFrame *view) -{ - guint nca; - NautilusViewFrameClass *klass; - - klass = NAUTILUS_VIEW_FRAME_CLASS(((GtkObject *)view)->klass); - nca = klass->num_construct_args; - if(view->construct_arg_count >= nca) - return; - - view->construct_arg_count++; - if((view->construct_arg_count >= nca) && klass->view_constructed) { - klass->view_constructed(view); - } -} - -static void -nautilus_view_frame_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GtkBin *bin; - - bin = GTK_BIN (widget); - - requisition->width = 0; - requisition->height = 0; - - if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) - { - GtkRequisition child_requisition; - - gtk_widget_size_request (bin->child, &child_requisition); - - requisition->width += child_requisition.width; - requisition->height += child_requisition.height; - } -} - -static void -nautilus_view_frame_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkBin *bin; - GtkAllocation child_allocation; - - widget->allocation = child_allocation = *allocation; - bin = GTK_BIN (widget); - - if (bin->child && GTK_WIDGET_VISIBLE (bin->child)) - gtk_widget_size_allocate (bin->child, &child_allocation); -} - -extern NautilusViewComponentType nautilus_view_component_type; /* ntl-view-nautilus.c */ -extern NautilusViewComponentType bonobo_subdoc_component_type; /* ntl-view-bonobo-subdoc.c */ -extern NautilusViewComponentType bonobo_control_component_type; /* ntl-view-bonobo-control.c */ - -static gboolean -nautilus_view_frame_handle_client_destroy(GtkWidget *widget, NautilusViewFrame *view) -{ - gtk_object_destroy(GTK_OBJECT(view)); - return TRUE; -} - -static void -nautilus_view_frame_handle_client_destroy_2(GtkObject *object, CORBA_Object cobject, CORBA_Environment *ev, NautilusViewFrame *view) -{ - NautilusWindow *window; - - window = NAUTILUS_WINDOW (view->main_window); - nautilus_window_remove_meta_view (window, view); - if (view == window->content_view) - nautilus_window_set_content_view (window, NULL); -} - -gboolean /* returns TRUE if successful */ -nautilus_view_frame_load_client(NautilusViewFrame *view, const char *iid) -{ - CORBA_Object obj; - CORBA_Object zoomable; - Nautilus_Undo_Manager undo_manager; - NautilusUndoContext *undo_context; - CORBA_Environment ev; - int i; - - NautilusViewComponentType *component_types[] = { - &nautilus_view_component_type, - &bonobo_subdoc_component_type, - &bonobo_control_component_type, - NULL - }; - - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), FALSE); - - if (iid == NULL) - return FALSE; - - CORBA_exception_init(&ev); - - nautilus_view_frame_destroy_client(view); - - view->client_object = bonobo_object_activate(iid, 0); - if(!view->client_object) - return FALSE; - - view->view_frame = impl_Nautilus_ViewFrame__create(view, &ev); - view->zoomable_frame = impl_Nautilus_ZoomableFrame__create(view, &ev); - - /* Add undo manager to component */ - undo_manager = nautilus_undo_manager_get_global_undo (); - g_assert (undo_manager); - undo_context = nautilus_undo_context_new (undo_manager); - bonobo_object_add_interface (BONOBO_OBJECT (view->view_frame), BONOBO_OBJECT (undo_context)); - - /* Now figure out which type of embedded object it is: */ - for(i = 0; component_types[i] && !view->component_class; i++) - { - obj = Bonobo_Unknown_query_interface(bonobo_object_corba_objref(BONOBO_OBJECT(view->client_object)), - component_types[i]->primary_repoid, &ev); - if(ev._major != CORBA_NO_EXCEPTION) - obj = CORBA_OBJECT_NIL; - - if(CORBA_Object_is_nil(obj, &ev)) - continue; - - zoomable = bonobo_object_query_interface (BONOBO_OBJECT (view->client_object), - "IDL:Nautilus/Zoomable:1.0"); - - view->zoomable = zoomable; - - if(component_types[i]->try_load(view, obj, &ev)) - view->component_class = component_types[i]; - - Bonobo_Unknown_unref(obj, &ev); - CORBA_Object_release(obj, &ev); - - if (view->component_class) - break; - } - - if (!view->component_class) { - /* Nothing matched */ - nautilus_view_frame_destroy_client(view); - return FALSE; - } - - view->iid = g_strdup(iid); - - gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "destroy", - GTK_SIGNAL_FUNC(nautilus_view_frame_handle_client_destroy), view, - GTK_OBJECT(view)); - gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "object_gone", - GTK_SIGNAL_FUNC(nautilus_view_frame_handle_client_destroy_2), view, - GTK_OBJECT(view)); - gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "system_exception", - GTK_SIGNAL_FUNC(nautilus_view_frame_handle_client_destroy_2), view, - GTK_OBJECT(view)); - gtk_container_add(GTK_CONTAINER(view), view->client_widget); - gtk_widget_show(view->client_widget); - CORBA_exception_free(&ev); - - return TRUE; -} - -void -nautilus_view_frame_notify_location_change(NautilusViewFrame *view, - Nautilus_NavigationInfo *nav_context) -{ - Nautilus_NavigationInfo real_nav_ctx; - CORBA_Environment ev; - - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - g_return_if_fail(view->component_class); - - real_nav_ctx = *nav_context; - g_assert(real_nav_ctx.requested_uri); -#define DEFAULT_STRING(x) if(!real_nav_ctx.x) real_nav_ctx.x = "" - if(!real_nav_ctx.actual_uri) real_nav_ctx.actual_uri = real_nav_ctx.requested_uri; - DEFAULT_STRING(content_type); - - DEFAULT_STRING(referring_uri); - if(!real_nav_ctx.actual_referring_uri) real_nav_ctx.actual_referring_uri = real_nav_ctx.referring_uri; - DEFAULT_STRING(referring_content_type); - - CORBA_exception_init(&ev); - if(view->component_class->notify_location_change) - view->component_class->notify_location_change(view, &real_nav_ctx, &ev); - CORBA_exception_free(&ev); -} - -void -nautilus_view_frame_notify_selection_change(NautilusViewFrame *view, - Nautilus_SelectionInfo *nav_context) -{ - CORBA_Environment ev; - - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - g_return_if_fail(view->component_class); - - CORBA_exception_init(&ev); - - if(view->component_class->notify_selection_change) - view->component_class->notify_selection_change(view, nav_context, &ev); - - CORBA_exception_free(&ev); -} - -void -nautilus_view_frame_load_state(NautilusViewFrame *view, const char *config_path) -{ - CORBA_Environment ev; - - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - g_return_if_fail(view->component_class); - - CORBA_exception_init(&ev); - - if(view->component_class->load_state) - view->component_class->load_state(view, config_path, &ev); - - CORBA_exception_free(&ev); -} - -void -nautilus_view_frame_save_state(NautilusViewFrame *view, const char *config_path) -{ - CORBA_Environment ev; - - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - g_return_if_fail(view->component_class); - - CORBA_exception_init(&ev); - - if(view->component_class->save_state) - view->component_class->save_state(view, config_path, &ev); - - CORBA_exception_free(&ev); -} - -void -nautilus_view_frame_show_properties(NautilusViewFrame *view) -{ - CORBA_Environment ev; - - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - g_return_if_fail(view->component_class); - - CORBA_exception_init(&ev); - - if(view->component_class->show_properties) - view->component_class->show_properties(view, &ev); - - CORBA_exception_free(&ev); -} - -void -nautilus_view_frame_stop_location_change(NautilusViewFrame *view) -{ - CORBA_Environment ev; - - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - g_return_if_fail(view->component_class); - - CORBA_exception_init(&ev); - - if(view->component_class->stop_location_change) - view->component_class->stop_location_change(view, &ev); - - CORBA_exception_free(&ev); -} - - -gboolean -nautilus_view_frame_is_zoomable (NautilusViewFrame *view) -{ - CORBA_Environment ev; - gboolean retval; - - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), FALSE); - - CORBA_exception_init (&ev); - - retval = CORBA_Object_is_nil (view->zoomable, &ev); - - CORBA_exception_free (&ev); - - return retval; -} - -gdouble -nautilus_view_frame_get_zoom_level (NautilusViewFrame *view) -{ - CORBA_Environment ev; - gdouble retval; - - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), 0); - - CORBA_exception_init (&ev); - - if (!CORBA_Object_is_nil (view->zoomable, &ev)) { - retval = Nautilus_Zoomable__get_zoom_level (view->zoomable, &ev); - } else { - retval = 1.0; - } - - CORBA_exception_free (&ev); - - return retval; -} - -void -nautilus_view_frame_set_zoom_level (NautilusViewFrame *view, - gdouble zoom_level) -{ - CORBA_Environment ev; - - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - CORBA_exception_init (&ev); - - if (!CORBA_Object_is_nil (view->zoomable, &ev)) { - Nautilus_Zoomable__set_zoom_level (view->zoomable, zoom_level, &ev); - } else { - /* do nothing */ - } - - CORBA_exception_free (&ev); -} - -gdouble -nautilus_view_frame_get_min_zoom_level (NautilusViewFrame *view) -{ - CORBA_Environment ev; - gdouble retval; - - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), 0); - - CORBA_exception_init (&ev); - - if (!CORBA_Object_is_nil (view->zoomable, &ev)) { - retval = Nautilus_Zoomable__get_min_zoom_level (view->zoomable, &ev); - } else { - retval = 1.0; - } - - CORBA_exception_free (&ev); - - return retval; -} - -gdouble -nautilus_view_frame_get_max_zoom_level (NautilusViewFrame *view) -{ - CORBA_Environment ev; - gdouble retval; - - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), 0); - - CORBA_exception_init (&ev); - - if (!CORBA_Object_is_nil (view->zoomable, &ev)) { - retval = Nautilus_Zoomable__get_max_zoom_level (view->zoomable, &ev); - } else { - retval = 1.0; - } - - CORBA_exception_free (&ev); - - return retval; -} - -gboolean -nautilus_view_frame_get_is_continuous (NautilusViewFrame *view) -{ - CORBA_Environment ev; - gboolean retval; - - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), FALSE); - - CORBA_exception_init (&ev); - - if (!CORBA_Object_is_nil (view->zoomable, &ev)) { - retval = Nautilus_Zoomable__get_zoom_level (view->zoomable, &ev); - } else { - retval = FALSE; - } - - CORBA_exception_free (&ev); - - return retval; -} - - -void -nautilus_view_frame_zoom_in (NautilusViewFrame *view) -{ - CORBA_Environment ev; - - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - CORBA_exception_init (&ev); - - if (!CORBA_Object_is_nil (view->zoomable, &ev)) { - Nautilus_Zoomable_zoom_in (view->zoomable, &ev); - } else { - /* do nothing */ - } - - CORBA_exception_free (&ev); -} - - -void -nautilus_view_frame_zoom_out (NautilusViewFrame *view) -{ - CORBA_Environment ev; - - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - CORBA_exception_init (&ev); - - if (!CORBA_Object_is_nil (view->zoomable, &ev)) { - Nautilus_Zoomable_zoom_out (view->zoomable, &ev); - } else { - /* do nothing */ - } - - CORBA_exception_free (&ev); -} - - -void -nautilus_view_frame_zoom_to_fit (NautilusViewFrame *view) -{ - CORBA_Environment ev; - - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - - CORBA_exception_init (&ev); - - if (!CORBA_Object_is_nil (view->zoomable, &ev)) { - Nautilus_Zoomable_zoom_to_fit (view->zoomable, &ev); - } else { - /* do nothing */ - } - - CORBA_exception_free (&ev); -} - - -const char * -nautilus_view_frame_get_iid(NautilusViewFrame *view) -{ - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), NULL); - return view->iid; -} - -CORBA_Object -nautilus_view_frame_get_client_objref(NautilusViewFrame *view) -{ - g_return_val_if_fail (view == NULL || NAUTILUS_IS_VIEW_FRAME (view), NULL); - return view?bonobo_object_corba_objref(BONOBO_OBJECT(view->client_object)):NULL; -} - -CORBA_Object -nautilus_view_frame_get_objref(NautilusViewFrame *view) -{ - g_return_val_if_fail (view == NULL || NAUTILUS_IS_VIEW_FRAME (view), NULL); - return view?bonobo_object_corba_objref(view->view_frame):NULL; -} - - -void -nautilus_view_frame_request_location_change(NautilusViewFrame *view, - const Nautilus_NavigationRequestInfo *loc) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - gtk_signal_emit(GTK_OBJECT(view), signals[REQUEST_LOCATION_CHANGE], loc); -} - -void -nautilus_view_frame_request_selection_change (NautilusViewFrame *view, - const Nautilus_SelectionRequestInfo *loc) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - gtk_signal_emit(GTK_OBJECT(view), signals[REQUEST_SELECTION_CHANGE], loc); -} - -void -nautilus_view_frame_request_status_change (NautilusViewFrame *view, - const Nautilus_StatusRequestInfo *loc) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - gtk_signal_emit(GTK_OBJECT(view), signals[REQUEST_STATUS_CHANGE], loc); -} - -void -nautilus_view_frame_request_progress_change(NautilusViewFrame *view, - const Nautilus_ProgressRequestInfo *loc) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - gtk_signal_emit(GTK_OBJECT(view), signals[REQUEST_PROGRESS_CHANGE], loc); -} - -void -nautilus_view_frame_request_title_change (NautilusViewFrame *view, - const char *title) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - gtk_signal_emit (GTK_OBJECT (view), signals[REQUEST_TITLE_CHANGE], title); -} - -void -nautilus_view_frame_notify_zoom_level (NautilusViewFrame *view, - gdouble level) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - gtk_signal_emit (GTK_OBJECT (view), signals[NOTIFY_ZOOM_LEVEL], level); -} - - -static gboolean -check_object(NautilusViewFrame *view) -{ - CORBA_Environment ev; - gboolean retval = TRUE; - CORBA_exception_init(&ev); - - g_assert(!view->checking); - - view->checking++; - - if(CORBA_Object_non_existent(bonobo_object_corba_objref(BONOBO_OBJECT(view->client_object)), &ev)) - { - view->timer_id = 0; - gtk_object_destroy(GTK_OBJECT(view)); - retval = FALSE; - } - - CORBA_exception_free(&ev); - view->checking--; - - return retval; -} - -void -nautilus_view_frame_set_active_errors(NautilusViewFrame *view, gboolean enabled) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - if(enabled) - { - if(!view->timer_id) - view->timer_id = g_timeout_add(2000, (GSourceFunc)check_object, view); - } - else - { - if(view->timer_id) - { - g_source_remove(view->timer_id); - view->timer_id = 0; - } - } -} - -char * -nautilus_view_frame_get_label (NautilusViewFrame *view) -{ - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), NULL); - return g_strdup (view->label); -} - -void -nautilus_view_frame_set_label (NautilusViewFrame *view, - const char *label) -{ - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view)); - g_free (view->label); - view->label = g_strdup (label); -} - -/* Calls activate on the underlying control frame. */ -void -nautilus_view_frame_activate (NautilusViewFrame *view) -{ - BonoboControlFrame *control_frame; - - control_frame = BONOBO_CONTROL_FRAME (bonobo_object_query_local_interface - (view->view_frame, "IDL:Bonobo/ControlFrame:1.0")); - bonobo_control_frame_control_activate (control_frame); - bonobo_object_unref (BONOBO_OBJECT (control_frame)); -} diff --git a/src/ntl-view.h b/src/ntl-view.h deleted file mode 100644 index b232c993a..000000000 --- a/src/ntl-view.h +++ /dev/null @@ -1,152 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 1999, 2000 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Elliot Lee <sopwith@redhat.com> - * - */ - -/* ntl-view.h: Interface of the object representing a data - view. */ - -#ifndef NTL_VIEW_H -#define NTL_VIEW_H - -#include <gtk/gtkwidget.h> -#include <gtk/gtkbin.h> -#include <bonobo.h> -#include <libnautilus/nautilus-view-component.h> - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#define NAUTILUS_TYPE_VIEW_FRAME (nautilus_view_frame_get_type ()) -#define NAUTILUS_VIEW_FRAME(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_VIEW_FRAME, NautilusViewFrame)) -#define NAUTILUS_VIEW_FRAME_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_VIEW_FRAME, NautilusViewFrameClass)) -#define NAUTILUS_IS_VIEW_FRAME(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_VIEW_FRAME)) -#define NAUTILUS_IS_VIEW_FRAME_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), NAUTILUS_TYPE_VIEW_FRAME)) - -typedef struct NautilusViewFrame NautilusViewFrame; -typedef struct NautilusViewFrameClass NautilusViewFrameClass; - -struct NautilusViewFrameClass { - GtkBinClass parent_spot; - - /* These signals correspond to the Nautilus::ViewFrame CORBA interface. They - * are requests that the underlying view may make of the shell via the frame. - */ - void (*request_location_change) (NautilusViewFrame *view, - Nautilus_NavigationRequestInfo *navinfo); - void (*request_selection_change) (NautilusViewFrame *view, - Nautilus_SelectionRequestInfo *selinfo); - void (*request_status_change) (NautilusViewFrame *view, - Nautilus_StatusRequestInfo *loc); - void (*request_progress_change) (NautilusViewFrame *view, - Nautilus_ProgressRequestInfo *loc); - void (*request_title_change) (NautilusViewFrame *view, - const char *title); - - /* Part of Nautilus::ZoomableFrame CORBA interface. */ - void (*notify_zoom_level) (NautilusViewFrame *view, - gdouble zoom_level); - - /* Not a signal. Work-around for Gtk+'s lack of a 'constructed' operation */ - void (*view_constructed) (NautilusViewFrame *view); - - GtkBinClass *parent_class; - guint num_construct_args; - - gpointer servant_init_func, servant_destroy_func, vepv; - gpointer zoomable_servant_init_func, zoomable_servant_destroy_func, zoomable_vepv; -}; - -typedef struct NautilusViewComponentType NautilusViewComponentType; - -struct NautilusViewFrame { - GtkBin parent; - - GtkWidget *main_window; - - char *iid; - - BonoboObjectClient *client_object; - GtkWidget *client_widget; - - BonoboObject *view_frame; - BonoboObject *zoomable_frame; - - Nautilus_Zoomable zoomable; - NautilusViewComponentType *component_class; - gpointer component_data; - - guint construct_arg_count; - - guint timer_id; - guint checking; - - char *label; -}; - -GtkType nautilus_view_frame_get_type (void); -gboolean nautilus_view_frame_load_client (NautilusViewFrame *view, - const char *iid); -const char * nautilus_view_frame_get_iid (NautilusViewFrame *view); -CORBA_Object nautilus_view_frame_get_client_objref (NautilusViewFrame *view); -BonoboObject *nautilus_view_frame_get_control_frame (NautilusViewFrame *view); -CORBA_Object nautilus_view_frame_get_objref (NautilusViewFrame *view); - -/* These functions correspond to methods of the Nautilus:View CORBAinterface. */ -void nautilus_view_frame_notify_location_change (NautilusViewFrame *view, - Nautilus_NavigationInfo *nav_context); -void nautilus_view_frame_notify_selection_change (NautilusViewFrame *view, - Nautilus_SelectionInfo *sel_context); -void nautilus_view_frame_load_state (NautilusViewFrame *view, - const char *config_path); -void nautilus_view_frame_save_state (NautilusViewFrame *view, - const char *config_path); -void nautilus_view_frame_show_properties (NautilusViewFrame *view); -void nautilus_view_frame_stop_location_change (NautilusViewFrame *view); -void nautilus_view_frame_set_active_errors (NautilusViewFrame *view, - gboolean enabled); -gboolean nautilus_view_frame_is_zoomable (NautilusViewFrame *view); -gdouble nautilus_view_frame_get_zoom_level (NautilusViewFrame *view); -void nautilus_view_frame_set_zoom_level (NautilusViewFrame *view, - gdouble zoom_level); -gdouble nautilus_view_frame_get_min_zoom_level (NautilusViewFrame *view); -gdouble nautilus_view_frame_get_max_zoom_level (NautilusViewFrame *view); -gboolean nautilus_view_frame_get_is_continuous (NautilusViewFrame *view); -void nautilus_view_frame_zoom_in (NautilusViewFrame *view); -void nautilus_view_frame_zoom_out (NautilusViewFrame *view); -void nautilus_view_frame_zoom_to_fit (NautilusViewFrame *view); -char * nautilus_view_frame_get_label (NautilusViewFrame *view); -void nautilus_view_frame_set_label (NautilusViewFrame *view, - const char *label); -void nautilus_view_frame_activate (NautilusViewFrame *view); - -/* This is a "protected" operation */ -void nautilus_view_frame_construct_arg_set (NautilusViewFrame *view); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* NTL_VIEW_H */ diff --git a/src/ntl-window-msgs.c b/src/ntl-window-msgs.c deleted file mode 100644 index 38aafaed2..000000000 --- a/src/ntl-window-msgs.c +++ /dev/null @@ -1,1213 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 1999, 2000 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Authors: Elliot Lee <sopwith@redhat.com> - * John Sullivan <sullivan@eazel.com> - */ - -/* Main operations needed: - * Initiate location change - * Initiate content view change - * Cancel action - */ - -#include <config.h> -#include "ntl-window-msgs.h" - -#include <stdarg.h> -#include <libgnome/gnome-i18n.h> -#include <libgnomeui/gnome-dialog-util.h> -#include <libgnomevfs/gnome-vfs-uri.h> -#include <libgnomevfs/gnome-vfs-async-ops.h> -#include <libgnomevfs/gnome-vfs-utils.h> -#include <libnautilus-extensions/nautilus-file.h> -#include <libnautilus-extensions/nautilus-string.h> -#include <libnautilus-extensions/nautilus-gtk-extensions.h> -#include <libnautilus-extensions/nautilus-gnome-extensions.h> -#include <libnautilus-extensions/nautilus-view-identifier.h> -#include <libnautilus-extensions/nautilus-global-preferences.h> -#include "ntl-app.h" -#include "ntl-uri-map.h" -#include "ntl-window-private.h" -#include "ntl-window-state.h" -#include "nautilus-location-bar.h" - -/*#define EXTREME_DEBUGGING*/ - -#ifdef EXTREME_DEBUGGING -#define x_message(parameters) g_message parameters -#else -#define x_message(parameters) -#endif - -static void nautilus_window_notify_selection_change (NautilusWindow *window, - NautilusViewFrame *view, - Nautilus_SelectionInfo *loc, - NautilusViewFrame *requesting_view); - -typedef enum { PROGRESS_INITIAL, PROGRESS_VIEWS, PROGRESS_DONE, PROGRESS_ERROR } ProgressType; - -/* Indicate progress to user interface */ -static void -nautilus_window_progress_indicate (NautilusWindow *window, ProgressType type, double percent, - const char *msg) -{ - char *the_uri; - - if (type == PROGRESS_ERROR) { - nautilus_error_dialog_parented (msg, GTK_WINDOW (window)); - - /* If it was an error loading a URI that had been dragged to the location bar, we might - need to reset the URI */ - the_uri = window->ni == NULL ? "" : window->ni->requested_uri; - nautilus_location_bar_set_location (NAUTILUS_LOCATION_BAR (window->ent_uri), - the_uri); - } -} - -/* Stays alive */ -static void -Nautilus_SelectionInfo__copy(Nautilus_SelectionInfo *dest_si, Nautilus_SelectionInfo *src_si) -{ - int i, n; - - dest_si->selected_uris = src_si->selected_uris; - - n = dest_si->selected_uris._length; - dest_si->selected_uris._buffer = CORBA_sequence_CORBA_string_allocbuf (n); - for(i = 0; i < n; i++) { - dest_si->selected_uris._buffer[i] = CORBA_string_dup (src_si->selected_uris._buffer[i]); - } - - dest_si->content_view = CORBA_OBJECT_NIL; - dest_si->self_originated = CORBA_FALSE; -} - -static void -nautilus_window_notify_selection_change(NautilusWindow *window, - NautilusViewFrame *view, - Nautilus_SelectionInfo *loc, - NautilusViewFrame *requesting_view) -{ - loc->self_originated = (view == requesting_view); - nautilus_view_frame_notify_selection_change(view, loc); -} - -void -nautilus_window_request_selection_change(NautilusWindow *window, - Nautilus_SelectionRequestInfo *loc, - NautilusViewFrame *requesting_view) -{ - GList *p; - Nautilus_SelectionInfo selinfo; - CORBA_Environment environment; - - CORBA_exception_init (&environment); - selinfo.selected_uris = loc->selected_uris; - selinfo.content_view = CORBA_Object_duplicate - (nautilus_view_frame_get_objref (NAUTILUS_VIEW_FRAME (window->content_view)), - &environment); - CORBA_exception_free (&environment); - - CORBA_free (window->si); - - window->si = Nautilus_SelectionInfo__alloc(); - Nautilus_SelectionInfo__copy(window->si, &selinfo); - - nautilus_window_notify_selection_change(window, window->content_view, &selinfo, requesting_view); - - for (p = window->meta_views; p != NULL; p = p->next) { - nautilus_window_notify_selection_change(window, p->data, &selinfo, requesting_view); - } -} - -void -nautilus_window_request_status_change(NautilusWindow *window, - Nautilus_StatusRequestInfo *loc, - NautilusViewFrame *requesting_view) -{ - nautilus_window_set_status(window, loc->status_string); -} - -/* - * Since this is can be called while the window is still getting set up, it - * doesn't do any work directly. - */ -void -nautilus_window_request_progress_change(NautilusWindow *window, - Nautilus_ProgressRequestInfo *loc, - NautilusViewFrame *requesting_view) -{ - NautilusWindowStateItem item; - - if (requesting_view != window->new_content_view - && requesting_view != window->content_view) { - return; /* Only pay attention to progress information from the upcoming content view, for now */ - } - - /* If the progress indicates we are done, record that, otherwise - just record the fact that we have at least begun loading. - */ - switch(loc->type) { - case Nautilus_PROGRESS_DONE_OK: - item = CV_PROGRESS_DONE; - break; - case Nautilus_PROGRESS_DONE_ERROR: - item = CV_PROGRESS_ERROR; - break; - case Nautilus_PROGRESS_UNDERWAY: - item = CV_PROGRESS_INITIAL; - break; - default: - g_assert_not_reached(); - item = -1; - break; - } - - nautilus_window_set_state_info(window, item, (NautilusWindowStateItem) 0); -} - -static char * -compute_default_title (const char *text_uri) -{ - GnomeVFSURI *vfs_uri; - char *short_name; - - if (text_uri != NULL) { - vfs_uri = gnome_vfs_uri_new (text_uri); - if (vfs_uri != NULL) { - short_name = gnome_vfs_uri_extract_short_name (vfs_uri); - gnome_vfs_uri_unref (vfs_uri); - - g_assert (short_name != NULL); - return short_name; - } else { - gchar *colon_pos = strchr(text_uri, ':'); - if (colon_pos && colon_pos[1]) - return g_strdup(colon_pos + 1); - } - - } - - return g_strdup(_("Nautilus")); -} - -/* nautilus_window_get_current_location_title: - * - * Get a newly allocated copy of the user-displayable title for the current - * location. Note that the window title is related to this but might not - * be exactly this. - * @window: The NautilusWindow in question. - * - * Return value: A newly allocated string. Use g_free when done with it. - */ -static char * -nautilus_window_get_current_location_title (NautilusWindow *window) -{ - return window->requested_title != NULL - ? g_strdup (window->requested_title) - : g_strdup (window->default_title); -} - -/* nautilus_window_update_title_internal: - * - * Update the non-NautilusViewFrame objects that use the location's user-displayable - * title in some way. Called when the location or title has changed. - * @window: The NautilusWindow in question. - * @title: The new user-displayable title. - * - */ -static void -nautilus_window_update_title_internal (NautilusWindow *window, const char *title) -{ - char *window_title; - - if (strcmp (title, _("Nautilus")) == 0) { - gtk_window_set_title (GTK_WINDOW (window), _("Nautilus")); - } else { - window_title = g_strdup_printf (_("Nautilus: %s"), title); - gtk_window_set_title (GTK_WINDOW (window), window_title); - g_free (window_title); - } - - nautilus_index_panel_set_title (window->index_panel, title); - nautilus_bookmark_set_name (window->current_location_bookmark, title); - - /* Name of item in history list may have changed, tell listeners. */ - nautilus_send_history_list_changed (); -} - -/* nautilus_window_reset_title_internal: - * - * Update the non-NautilusViewFrame objects that use the location's user-displayable - * title in some way. Called when the location or title has changed. - * @window: The NautilusWindow in question. - * @title: The new user-displayable title. - */ -static void -nautilus_window_reset_title_internal (NautilusWindow *window, const char *uri) -{ - g_free (window->requested_title); - window->requested_title = NULL; - g_free (window->default_title); - window->default_title = compute_default_title (uri); - - if (window->current_location_bookmark == NULL || - strcmp (uri, nautilus_bookmark_get_uri (window->current_location_bookmark)) != 0) { - /* We've changed locations, must recreate bookmark for current location. */ - if (window->last_location_bookmark != NULL) { - gtk_object_unref (GTK_OBJECT (window->last_location_bookmark)); - } - window->last_location_bookmark = window->current_location_bookmark; - window->current_location_bookmark = nautilus_bookmark_new (uri, uri); - } - - nautilus_window_update_title_internal (window, window->default_title); -} - -void -nautilus_window_request_title_change (NautilusWindow *window, - const char *new_title, - NautilusViewFrame *requesting_view) -{ - g_return_if_fail (NAUTILUS_IS_WINDOW (window)); - g_return_if_fail (new_title != NULL); - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (requesting_view)); - - /* Only the content view can change the window title. */ - if (requesting_view != window->content_view) { - return; - } - - g_free (window->requested_title); - window->requested_title = g_strdup (new_title); - - nautilus_window_update_title_internal (window, new_title); -} - -/* The bulk of this file - location changing */ - -static void -Nautilus_NavigationInfo__copy (Nautilus_NavigationInfo *dest_ni, Nautilus_NavigationInfo *src_ni) -{ - dest_ni->requested_uri = CORBA_string_dup(src_ni->requested_uri); - dest_ni->actual_uri = CORBA_string_dup(src_ni->actual_uri); - dest_ni->content_type = CORBA_string_dup(src_ni->content_type); - dest_ni->referring_uri = CORBA_string_dup(src_ni->referring_uri); - dest_ni->actual_referring_uri = CORBA_string_dup(src_ni->actual_referring_uri); - dest_ni->referring_content_type = CORBA_string_dup(src_ni->referring_content_type); - dest_ni->content_view = CORBA_OBJECT_NIL; - dest_ni->self_originated = CORBA_FALSE; -} - -/* Handle the changes for the NautilusWindow itself. */ -static void -nautilus_window_update_internals (NautilusWindow *window, NautilusNavigationInfo *navi) -{ - GnomeVFSURI *new_uri; - char *current_title; - - if(navi) { - Nautilus_NavigationInfo *newni; - - /* Maintain history lists. */ - if (window->location_change_type != NAUTILUS_LOCATION_CHANGE_RELOAD) { - /* Always add new location to history list. */ - nautilus_add_to_history_list (window->current_location_bookmark); - - if (window->location_change_type == NAUTILUS_LOCATION_CHANGE_BACK) { - guint index; - - /* Going back. Move items from the back list to the forward list. */ - g_assert (g_slist_length (window->back_list) > window->location_change_distance); - g_assert (!strcmp(nautilus_bookmark_get_uri (NAUTILUS_BOOKMARK (g_slist_nth_data (window->back_list, window->location_change_distance))), navi->navinfo.requested_uri)); - g_assert (window->ni); - - /* Move current location to Forward list */ - g_assert (strcmp (nautilus_bookmark_get_uri (window->last_location_bookmark), window->ni->requested_uri) == 0); - /* Use the first bookmark in the history list rather than creating a new one. */ - window->forward_list = g_slist_prepend (window->forward_list, window->last_location_bookmark); - gtk_object_ref (GTK_OBJECT (window->forward_list->data)); - - /* Move extra links from Back to Forward list */ - for (index = 0; index < window->location_change_distance; ++index) { - NautilusBookmark *bookmark; - - bookmark = window->back_list->data; - window->back_list = g_slist_remove_link (window->back_list, window->back_list); - window->forward_list = g_slist_prepend (window->forward_list, bookmark); - } - - /* One bookmark falls out of back/forward lists and becomes viewed location */ - gtk_object_unref (window->back_list->data); - window->back_list = g_slist_remove_link (window->back_list, window->back_list); - - } else if (window->location_change_type == NAUTILUS_LOCATION_CHANGE_FORWARD) { - guint index; - - /* Going back. Move items from the forward list to the back list. */ - g_assert(g_slist_length (window->forward_list) > window->location_change_distance); - g_assert(!strcmp(nautilus_bookmark_get_uri (NAUTILUS_BOOKMARK (g_slist_nth_data (window->forward_list, window->location_change_distance))), navi->navinfo.requested_uri)); - g_assert(window->ni); - - /* Move current location to Back list */ - g_assert (strcmp (nautilus_bookmark_get_uri (window->last_location_bookmark), window->ni->requested_uri) == 0); - /* Use the first bookmark in the history list rather than creating a new one. */ - window->back_list = g_slist_prepend (window->back_list, window->last_location_bookmark); - gtk_object_ref (GTK_OBJECT (window->back_list->data)); - - /* Move extra links from Forward to Back list */ - for (index = 0; index < window->location_change_distance; ++index) { - NautilusBookmark *bookmark; - - bookmark = window->forward_list->data; - window->forward_list = g_slist_remove_link (window->forward_list, window->forward_list); - window->back_list = g_slist_prepend (window->back_list, bookmark); - } - - /* One bookmark falls out of back/forward lists and becomes viewed location */ - gtk_object_unref (window->forward_list->data); - window->forward_list = g_slist_remove_link (window->forward_list, window->forward_list); - } else { - g_assert (window->location_change_type == NAUTILUS_LOCATION_CHANGE_STANDARD); - /* Clobber the entire forward list, and move displayed location to back list */ - if (window->forward_list) { - g_slist_foreach(window->forward_list, (GFunc)gtk_object_unref, NULL); - g_slist_free(window->forward_list); window->forward_list = NULL; - } - - if (window->ni) { - /* - * If we're returning to the same uri somehow, don't put this uri on back list. - * This also avoids a problem where nautilus_window_reset_title_internal - * didn't update last_location_bookmark since the uri didn't change. - */ - if (strcmp (window->ni->requested_uri, navi->navinfo.requested_uri) != 0) { - /* Store bookmark for current location in back list, unless there is no current location */ - g_assert (strcmp (nautilus_bookmark_get_uri (window->last_location_bookmark), - window->ni->requested_uri) == 0); - /* Use the first bookmark in the history list rather than creating a new one. */ - window->back_list = g_slist_prepend (window->back_list, window->last_location_bookmark); - gtk_object_ref (GTK_OBJECT (window->back_list->data)); - } - } - } - } - - new_uri = gnome_vfs_uri_new (navi->navinfo.requested_uri); - if(!new_uri && navi->navinfo.actual_uri) - new_uri = gnome_vfs_uri_new (navi->navinfo.actual_uri); - if (new_uri) { - nautilus_window_allow_up(window, - gnome_vfs_uri_has_parent(new_uri)); - gnome_vfs_uri_unref(new_uri); - } else { - nautilus_window_allow_up(window, FALSE); - } - - newni = Nautilus_NavigationInfo__alloc(); - Nautilus_NavigationInfo__copy(newni, &navi->navinfo); - - CORBA_free(window->ni); - - window->ni = newni; - - CORBA_free(window->si); - window->si = NULL; - - nautilus_window_load_content_view_menu (window, navi); - } - - nautilus_window_allow_back(window, window->back_list != NULL); - nautilus_window_allow_forward(window, window->forward_list != NULL); - - nautilus_location_bar_set_location(NAUTILUS_LOCATION_BAR(window->ent_uri), - window->ni->requested_uri); - - /* Notify the index panel of the location change. */ - /* FIXME bugzilla.eazel.com 211: - * Eventually, this will not be necessary when we restructure the - * index panel to be a NautilusViewFrame. - */ - current_title = nautilus_window_get_current_location_title (window); - nautilus_index_panel_set_uri (window->index_panel, window->ni->requested_uri, current_title); - g_free (current_title); -} - -static void -nautilus_window_update_view (NautilusWindow *window, - NautilusViewFrame *view, - Nautilus_NavigationInfo *navi, - Nautilus_SelectionInfo *seli, - NautilusViewFrame *requesting_view, - NautilusViewFrame *content_view) -{ - CORBA_Environment environment; - - g_return_if_fail(view); - - navi->self_originated = (view == requesting_view); - - nautilus_view_frame_notify_location_change (view, navi); - - if(seli) { - CORBA_exception_init(&environment); - CORBA_Object_release(seli->content_view, &environment); - seli->content_view = CORBA_Object_duplicate - (nautilus_view_frame_get_client_objref(content_view), - &environment); - CORBA_exception_free(&environment); - - nautilus_window_notify_selection_change(window, view, seli, NULL); - } -} - -void -nautilus_window_view_destroyed (NautilusViewFrame *view, NautilusWindow *window) -{ - NautilusWindowStateItem item = VIEW_ERROR; - nautilus_window_set_state_info (window, item, view, (NautilusWindowStateItem) 0); -} - -/* This is called when we have decided we can actually change to the new view/location situation. */ -static void -nautilus_window_has_really_changed(NautilusWindow *window) -{ - GList *discard_views; - GList *p; - GList *new_meta_views; - - new_meta_views = window->new_meta_views; - window->new_meta_views = NULL; - - if (window->new_content_view) { - if (!GTK_WIDGET (window->new_content_view)->parent) { - if(window->content_view) - gtk_signal_disconnect_by_func(GTK_OBJECT(window->content_view), nautilus_window_view_destroyed, window); - nautilus_window_set_content_view(window, window->new_content_view); - } - gtk_object_unref(GTK_OBJECT(window->new_content_view)); - window->new_content_view = NULL; - } - - if (new_meta_views) { - /* Do lots of shuffling to make sure we don't remove views that were already there, but add new views */ - for (p = new_meta_views; p != NULL; p = p->next) { - if (!GTK_OBJECT_DESTROYED (p->data) && !GTK_WIDGET (p->data)->parent) - nautilus_window_add_meta_view (window, p->data); - gtk_object_unref (p->data); - } - - discard_views = NULL; - for (p = window->meta_views; p != NULL; p = p->next) { - if (!g_list_find (new_meta_views, p->data)) { - discard_views = g_list_prepend(discard_views, p->data); - } - } - g_list_free (new_meta_views); - - for (p = discard_views; p != NULL; p = p->next) { - nautilus_window_remove_meta_view (window, p->data); - } - g_list_free (discard_views); - } - - if (window->pending_ni != NULL) { - nautilus_window_update_internals (window, window->pending_ni); - nautilus_navigation_info_free (window->pending_ni); - if (window->pending_ni == window->cancel_tag) { - window->cancel_tag = NULL; - } - window->pending_ni = NULL; - } -} - -/* This is called when we are done loading to get rid of the load_info structure. */ -static void -nautilus_window_free_load_info (NautilusWindow *window) -{ - x_message (("-> FREE_LOAD_INFO <-")); - - if (window->pending_ni != NULL) { - nautilus_navigation_info_free (window->pending_ni); - window->pending_ni = NULL; - } - - window->error_views = NULL; - window->new_meta_views = NULL; - window->new_content_view = NULL; - window->cancel_tag = NULL; - window->action_tag = 0; - window->made_changes = 0; - window->state = NW_IDLE; - window->changes_pending = FALSE; - window->views_shown = FALSE; - window->view_bombed_out = FALSE; - window->view_activation_complete = FALSE; - window->cv_progress_initial = FALSE; - window->cv_progress_done = FALSE; - window->cv_progress_error = FALSE; - window->sent_update_view = FALSE; - window->reset_to_idle = FALSE; -} - -/* Meta view handling */ -static NautilusViewFrame * -nautilus_window_load_meta_view (NautilusWindow *window, - const char *iid, - NautilusViewFrame *requesting_view) -{ - NautilusViewFrame *meta_view; - GList *p; - - meta_view = NULL; - for (p = window->meta_views; p != NULL; p = p->next) { - meta_view = NAUTILUS_VIEW_FRAME (p->data); - if (!strcmp (nautilus_view_frame_get_iid (meta_view), iid)) - break; - } - - if (p == NULL) { - meta_view = NAUTILUS_VIEW_FRAME (gtk_widget_new (nautilus_view_frame_get_type(), - "main_window", window, NULL)); - nautilus_window_connect_view (window, meta_view); - if (!nautilus_view_frame_load_client (meta_view, iid)) { - gtk_widget_unref (GTK_WIDGET (meta_view)); - meta_view = NULL; - } - } - - if (meta_view != NULL) { - gtk_object_ref (GTK_OBJECT (meta_view)); - nautilus_view_frame_set_active_errors (meta_view, TRUE); - } - - return meta_view; -} - -static gboolean -handle_unreadable_location (NautilusWindow *window, const char *uri) { - NautilusFile *file; - gboolean unreadable; - char *file_name; - char *message; - - file = nautilus_file_get (uri); - - /* Can't make file object; can't check permissions; can't determine - * whether file is readable so return FALSE. - */ - if (file == NULL) { - return FALSE; - } - - unreadable = !nautilus_file_can_read (file); - nautilus_file_unref (file); - - if (unreadable) { - file_name = nautilus_file_get_name (file); - message = g_strdup_printf (_("You do not have the permissions necessary to view \"%s.\""), file_name); - gtk_widget_show (gnome_error_dialog_parented (message, - GTK_WINDOW (window))); - g_free (file_name); - g_free (message); - } - - return unreadable; -} - -void -nautilus_window_request_location_change (NautilusWindow *window, - Nautilus_NavigationRequestInfo *loc, - NautilusViewFrame *requesting_view) -{ - NautilusWindow *new_window; - - loc->requested_uri = gnome_vfs_unescape_string (loc->requested_uri); - - if (handle_unreadable_location (window, loc->requested_uri)) { - return; - } - - if (loc->new_window_requested) { - new_window = nautilus_app_create_window (NAUTILUS_APP(window->app)); - nautilus_window_set_initial_state (new_window, loc->requested_uri); - } else { - nautilus_window_begin_location_change (window, loc, - requesting_view, - NAUTILUS_LOCATION_CHANGE_STANDARD, 0); - } -} - -NautilusViewFrame * -nautilus_window_load_content_view (NautilusWindow *window, - const char *iid, - Nautilus_NavigationInfo *navinfo, - NautilusViewFrame **requesting_view) -{ - NautilusViewFrame *content_view = window->content_view; - NautilusViewFrame *new_view; - CORBA_Environment environment; - - g_return_val_if_fail(iid, NULL); - g_return_val_if_fail(navinfo, NULL); - - if (!NAUTILUS_IS_VIEW_FRAME (content_view) - || strcmp (nautilus_view_frame_get_iid (content_view), iid) != 0) { - - if (requesting_view != NULL && *requesting_view == window->content_view) { - /* If we are going to be zapping the old view, - * we definitely don't want any of the new views - * thinking they made the request - */ - *requesting_view = NULL; - } - - new_view = NAUTILUS_VIEW_FRAME (gtk_widget_new (nautilus_view_frame_get_type(), - "main_window", window, NULL)); - - nautilus_window_connect_content_view (window, new_view); - - if (!nautilus_view_frame_load_client (new_view, iid)) { - gtk_widget_unref(GTK_WIDGET(new_view)); - new_view = NULL; - } - - /* Avoid being fooled by extra done notifications from the last view. - This is a HACK because the state machine SUCKS. */ - window->cv_progress_done = FALSE; - window->cv_progress_error = FALSE; - } else { - new_view = window->content_view; - } - - if (!NAUTILUS_IS_VIEW_FRAME (new_view)) { - new_view = NULL; - } else { - gtk_object_ref (GTK_OBJECT (new_view)); - - CORBA_exception_init(&environment); - CORBA_Object_release(navinfo->content_view, &environment); - navinfo->content_view = CORBA_Object_duplicate - (nautilus_view_frame_get_client_objref (new_view), - &environment); - CORBA_exception_free(&environment); - - nautilus_view_frame_set_active_errors (new_view, TRUE); - } - - return new_view; -} - -static gboolean -nautilus_window_update_state (gpointer data) -{ - NautilusWindow *window; - GList *p; - gboolean result; - - window = data; - - if (window->making_changes) { - x_message (("In the middle of making changes %d (action_tag %d) - RETURNING", - window->making_changes, window->action_tag)); - return FALSE; - } - - window->made_changes = 0; - window->making_changes++; - -#ifdef EXTREME_DEBUGGING - g_message(">>> nautilus_window_update_state (action tag is %d):", window->action_tag); - g_print("made_changes %d, making_changes %d\n", window->made_changes, window->making_changes); - g_print("changes_pending %d, location_change_type %d, views_shown %d, view_bombed_out %d, view_activation_complete %d\n", - window->changes_pending, window->location_change_type, window->views_shown, - window->view_bombed_out, window->view_activation_complete); - g_print("sent_update_view %d, cv_progress_initial %d, cv_progress_done %d, cv_progress_error %d, reset_to_idle %d\n", - window->sent_update_view, window->cv_progress_initial, window->cv_progress_done, window->cv_progress_error, - window->reset_to_idle); -#endif - - /* Now make any needed state changes based on available information */ - if (window->view_bombed_out && window->error_views != NULL) { - for (p = window->error_views; p != NULL; p = p->next) { - NautilusViewFrame *error_view = p->data; - - if (error_view == window->new_content_view) { - window->made_changes++; - window->reset_to_idle = TRUE; - window->cv_progress_error = TRUE; - } - - if (error_view == window->content_view) { - if (GTK_WIDGET (window->content_view)->parent) { - gtk_container_remove (GTK_CONTAINER (GTK_WIDGET (window->content_view)->parent), - GTK_WIDGET (window->content_view)); - } - window->content_view = NULL; - window->made_changes++; - window->cv_progress_error = TRUE; - } - - if (g_list_find (window->new_meta_views, error_view) != NULL) { - window->new_meta_views = g_list_remove (window->new_meta_views, error_view); - gtk_widget_unref (GTK_WIDGET (error_view)); - } - - nautilus_window_remove_meta_view (window, error_view); - - gtk_widget_unref (GTK_WIDGET (error_view)); - } - g_list_free (window->error_views); - window->error_views = NULL; - - window->view_bombed_out = FALSE; - } - - if (window->reset_to_idle) { - x_message (("Reset to idle!")); - - window->changes_pending = FALSE; - window->made_changes++; - window->reset_to_idle = FALSE; - - if (window->cancel_tag != NULL) { - nautilus_navigation_info_cancel (window->cancel_tag); - window->cancel_tag = NULL; - } - - if (window->pending_ni != NULL) { - nautilus_window_reset_title_internal - (window, window->ni == NULL ? "" : window->ni->requested_uri); - - /* Tell previously-notified views to go back to the old page */ - for (p = window->meta_views; p != NULL; p = p->next) { - if (g_list_find (window->new_meta_views, p->data) != NULL) { - nautilus_window_update_view (window, p->data, window->ni, window->si, - NULL, window->content_view); - } - } - - if (window->new_content_view - && window->new_content_view == window->content_view) { - nautilus_window_update_view (window, window->content_view, - window->ni, window->si, - NULL, window->content_view); - } - } - - if (window->new_content_view) { - gtk_widget_unref (GTK_WIDGET (window->new_content_view)); - } - - for (p = window->new_meta_views; p != NULL; p = p->next) { - gtk_widget_unref (GTK_WIDGET (p->data)); - } - g_list_free (window->new_meta_views); - - nautilus_window_free_load_info (window); - - nautilus_window_allow_stop (window, FALSE); - } - - if (window->changes_pending) { - window->state = NW_LOADING_VIEWS; - - x_message (("Changes pending")); - - if (window->pending_ni && !window->new_content_view && !window->cv_progress_error - && !window->view_activation_complete) { - GList *sidebar_panel_identifiers = NULL; - - window->new_content_view = nautilus_window_load_content_view - (window, window->pending_ni->initial_content_iid, - &window->pending_ni->navinfo, - &window->new_requesting_view); - - sidebar_panel_identifiers = - nautilus_global_preferences_get_enabled_sidebar_panel_view_identifiers (); - - if (sidebar_panel_identifiers != NULL) { - for (p = sidebar_panel_identifiers; p != NULL; p = p->next) { - NautilusViewFrame *meta_view; - NautilusViewIdentifier *identifier; - - identifier = (NautilusViewIdentifier *) p->data; - - meta_view = nautilus_window_load_meta_view - (window, identifier->iid, window->new_requesting_view); - if (meta_view != NULL) { - nautilus_view_frame_set_label (meta_view, identifier->name); - window->new_meta_views = g_list_prepend (window->new_meta_views, meta_view); - } - } - - nautilus_view_identifier_free_list (sidebar_panel_identifiers); - } - - window->view_activation_complete = TRUE; - window->made_changes++; - } - - if (window->view_activation_complete - && !window->sent_update_view) { - - Nautilus_NavigationInfo *ni; - Nautilus_SelectionInfo *si; - - if (window->pending_ni) { - ni = &window->pending_ni->navinfo; - si = NULL; - } else { - ni = window->ni; - si = window->si; - } - - nautilus_window_reset_title_internal (window, ni->requested_uri); - - x_message (("!!! Sending update_view")); - - if (window->new_content_view) { - nautilus_window_update_view (window, window->new_content_view, ni, si, - window->new_requesting_view, window->new_content_view); - } else { - window->cv_progress_error = TRUE; - } - - for (p = window->new_meta_views; p != NULL; p = p->next) { - nautilus_window_update_view (window, p->data, ni, si, - window->new_requesting_view, - window->new_content_view); - } - - window->sent_update_view = TRUE; - window->made_changes++; - } - - if (!window->cv_progress_error - && window->view_activation_complete - && window->cv_progress_initial - && !window->views_shown) { - - nautilus_window_has_really_changed (window); - window->views_shown = TRUE; - window->made_changes++; - } - - if (window->cv_progress_error - || window->cv_progress_done) { - - x_message (("cv_progress_(error|done) kicking in")); - - window->made_changes++; - window->reset_to_idle = TRUE; - } - } - - if (window->made_changes) { - if (!window->action_tag) { - window->action_tag = g_idle_add_full (G_PRIORITY_LOW, - nautilus_window_update_state, - window, NULL); - } - - result = TRUE; - window->made_changes = 0; - } else { - result = FALSE; - window->action_tag = 0; - } - - window->making_changes--; - - x_message(("update_state done (new action tag is %d, making_changes is %d) <<<", - window->action_tag, window->making_changes)); - - return result; -} - -void -nautilus_window_set_state_info (NautilusWindow *window, ...) -{ - va_list args; - NautilusWindowStateItem item_type; - NautilusViewFrame *new_view; - gboolean do_sync; - - /* Ensure that changes happen in-order */ - if (window->made_changes != 0) { - if (window->action_tag != 0) { - g_source_remove(window->action_tag); - window->action_tag = 0; - } - nautilus_window_update_state(window); - } - - do_sync = FALSE; - - va_start (args, window); - - while ((item_type = va_arg (args, NautilusWindowStateItem)) != 0) { - switch (item_type) { - - case NAVINFO_RECEIVED: /* The information needed for a location change to continue has been received */ - x_message (("NAVINFO_RECEIVED")); - window->pending_ni = va_arg(args, NautilusNavigationInfo*); - window->cancel_tag = NULL; - window->changes_pending = TRUE; - break; - - case VIEW_ERROR: - new_view = va_arg (args, NautilusViewFrame*); - x_message (("VIEW_ERROR on %p", new_view)); - window->view_bombed_out = TRUE; - gtk_object_ref (GTK_OBJECT (new_view)); - window->error_views = g_list_prepend (window->error_views, new_view); - break; - - case NEW_CONTENT_VIEW_ACTIVATED: - x_message (("NEW_CONTENT_VIEW_ACTIVATED")); - g_return_if_fail (window->new_content_view == NULL); - new_view = va_arg (args, NautilusViewFrame*); - /* Don't ref here, reference is held by widget hierarchy. */ - window->new_content_view = new_view; - if (window->pending_ni == NULL) { - window->view_activation_complete = TRUE; - } - window->changes_pending = TRUE; - window->views_shown = FALSE; - break; - - case NEW_META_VIEW_ACTIVATED: - x_message (("NEW_META_VIEW_ACTIVATED")); - new_view = va_arg (args, NautilusViewFrame*); - /* Don't ref here, reference is held by widget hierarchy. */ - window->new_meta_views = g_list_prepend (window->new_meta_views, new_view); - window->changes_pending = TRUE; - window->views_shown = FALSE; - break; - - case CV_PROGRESS_INITIAL: /* We have received an "I am loading" indication from the content view */ - x_message (("CV_PROGRESS_INITIAL")); - window->cv_progress_initial = TRUE; - window->cv_progress_done = FALSE; - window->cv_progress_error = FALSE; - window->changes_pending = TRUE; - break; - - case CV_PROGRESS_ERROR: /* We have received a load error from the content view */ - x_message (("CV_PROGRESS_ERROR")); - window->cv_progress_error = TRUE; - break; - - case CV_PROGRESS_DONE: /* The content view is done loading */ - x_message (("CV_PROGRESS_DONE")); - window->cv_progress_done = TRUE; - break; - - case RESET_TO_IDLE: /* Someone pressed the stop button or something */ - x_message (("RESET_TO_IDLE")); - window->reset_to_idle = TRUE; - break; - - case SYNC_STATE: - x_message (("SYNC_STATE")); - do_sync = TRUE; - break; - - default: - break; - } - } - - va_end (args); - - window->made_changes++; - if (!window->making_changes) { - if (do_sync) { - if (window->action_tag != 0) { - x_message (("Doing sync - action_tag was %d", - window->action_tag)); - g_source_remove (window->action_tag); - window->action_tag = 0; - } - if (nautilus_window_update_state (window)) { - do_sync = FALSE; - } - } - - if (window->action_tag == 0 && !do_sync) { - window->action_tag = g_idle_add_full (G_PRIORITY_LOW, - nautilus_window_update_state, - window, NULL); - x_message (("Added callback to update_state - tag is %d", - window->action_tag)); - } - } -} - -static void -nautilus_window_end_location_change_callback (NautilusNavigationResult result_code, - NautilusNavigationInfo *navi, - gpointer data) -{ - NautilusWindow *window = data; - NautilusFile *file; - char *requested_uri; - char *error_message; - char *scheme_string; - char *type_string; - - g_assert (navi != NULL); - - window->cancel_tag = NULL; - - if (result_code == NAUTILUS_NAVIGATION_RESULT_OK) { - /* Navigation successful. Show the window to handle the - * new-window case. (Doesn't hurt if window is already showing.) - * Maybe this should go sometime later so the blank window isn't - * on screen so long. - */ - gtk_widget_show (GTK_WIDGET (window)); - nautilus_window_set_state_info (window, - (NautilusWindowStateItem)NAVINFO_RECEIVED, - navi, - (NautilusWindowStateItem)0); - return; - } - - /* Some sort of failure occurred. How 'bout we tell the user? */ - requested_uri = navi->navinfo.requested_uri; - - switch (result_code) { - - case NAUTILUS_NAVIGATION_RESULT_NOT_FOUND: - error_message = g_strdup_printf (_("Couldn't find \"%s\". Please check the spelling and try again."), requested_uri); - break; - - case NAUTILUS_NAVIGATION_RESULT_INVALID_URI: - error_message = g_strdup_printf (_("\"%s\" is not a valid location. Please check the spelling and try again."), requested_uri); - break; - - case NAUTILUS_NAVIGATION_RESULT_NO_HANDLER_FOR_TYPE: - file = nautilus_file_get (requested_uri); - if (file != NULL) { - type_string = nautilus_file_get_string_attribute (file, "type"); - error_message = g_strdup_printf (_("Couldn't display \"%s\", because Nautilus cannot handle items of type \"%s\"."), requested_uri, type_string); - nautilus_file_unref (file); - g_free (type_string); - } else { - error_message = g_strdup_printf (_("Couldn't display \"%s\", because Nautilus cannot handle items of this type."), requested_uri); - } - break; - - case NAUTILUS_NAVIGATION_RESULT_UNSUPPORTED_SCHEME: - /* Can't create a vfs_uri and get the method from that, because - * gnome_vfs_uri_new might return NULL. - */ - scheme_string = nautilus_str_get_prefix (requested_uri, ":"); - g_assert (scheme_string != NULL); /* Shouldn't have gotten this error unless there's a : separator. */ - error_message = g_strdup_printf (_("Couldn't display \"%s\", because Nautilus cannot handle %s: locations."), - requested_uri, scheme_string); - g_free (scheme_string); - break; - - default: - /* It is so sad that we can't say anything more useful than this. - * When this comes up, we should figure out what's really happening - * and add another specific case. - */ - error_message = g_strdup_printf (_("Nautilus cannot display \"%s\"."), requested_uri); - } - - if (navi != NULL) { - nautilus_navigation_info_free (navi); - } - - if (!GTK_WIDGET_VISIBLE (GTK_WIDGET (window))) { - /* Destroy never-had-a-chance-to-be-seen window. This case - * happens when a new window cannot display its initial URI. - */ - gtk_object_destroy (GTK_OBJECT (window)); - nautilus_error_dialog (error_message); - } else { - /* Clean up state of already-showing window */ - nautilus_window_allow_stop (window, FALSE); - nautilus_window_progress_indicate (window, PROGRESS_ERROR, 0, error_message); - } - - g_free (error_message); -} - -/* - * nautilus_window_begin_location_change - * - * Change a window's location. - * @window: The NautilusWindow whose location should be changed. - * @loc: A Nautilus_NavigationRequestInfo specifying info about this transition. - * @requesting_view: The view from which this location change originated, can be NULL. - * @type: Which type of location change is this? Standard, back, forward, or reload? - * @distance: If type is back or forward, the index into the back or forward chain. If - * type is standard or reload, this is ignored, and must be 0. - */ -void -nautilus_window_begin_location_change (NautilusWindow *window, - Nautilus_NavigationRequestInfo *loc, - NautilusViewFrame *requesting_view, - NautilusLocationChangeType type, - guint distance) -{ - const char *current_iid; - - g_assert (NAUTILUS_IS_WINDOW (window)); - g_assert (loc != NULL); - g_assert (type == NAUTILUS_LOCATION_CHANGE_BACK || - type == NAUTILUS_LOCATION_CHANGE_FORWARD || - distance == 0); - - nautilus_window_set_state_info (window, - (NautilusWindowStateItem)RESET_TO_IDLE, - (NautilusWindowStateItem)SYNC_STATE, - (NautilusWindowStateItem)0); - - while (gdk_events_pending()) { - gtk_main_iteration(); - } - - nautilus_window_progress_indicate (window, PROGRESS_INITIAL, 0, _("Gathering information")); - - window->location_change_type = type; - window->location_change_distance = distance; - window->new_requesting_view = requesting_view; - - nautilus_window_allow_stop (window, TRUE); - - current_iid = NULL; - if (window->content_view != NULL) { - current_iid = nautilus_view_frame_get_iid (window->content_view); - } - - window->cancel_tag = nautilus_navigation_info_new - (loc, window->ni, - nautilus_window_end_location_change_callback, - window, current_iid); -} diff --git a/src/ntl-window-msgs.h b/src/ntl-window-msgs.h deleted file mode 100644 index 2b4308812..000000000 --- a/src/ntl-window-msgs.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 1999, 2000 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Elliot Lee <sopwith@redhat.com> - * - */ - -#ifndef NTL_WINDOW_MSGS_H -#define NTL_WINDOW_MSGS_H - -#include "ntl-window.h" - -void nautilus_window_request_location_change (NautilusWindow *window, - Nautilus_NavigationRequestInfo *loc, - NautilusViewFrame *requesting_view); -void nautilus_window_request_selection_change (NautilusWindow *window, - Nautilus_SelectionRequestInfo *loc, - NautilusViewFrame *requesting_view); -void nautilus_window_request_status_change (NautilusWindow *window, - Nautilus_StatusRequestInfo *loc, - NautilusViewFrame *requesting_view); -void nautilus_window_request_progress_change (NautilusWindow *window, - Nautilus_ProgressRequestInfo *loc, - NautilusViewFrame *requesting_view); -void nautilus_window_request_title_change (NautilusWindow *window, - const char *new_title, - NautilusViewFrame *requesting_view); - -#endif /* NTL_WINDOW_MSGS_H */ diff --git a/src/ntl-window-private.h b/src/ntl-window-private.h deleted file mode 100644 index f896d4e67..000000000 --- a/src/ntl-window-private.h +++ /dev/null @@ -1,72 +0,0 @@ -#ifndef NTL_WINDOW_PRIVATE_H -#define NTL_WINDOW_PRIVATE_H - -#include "ntl-window.h" -#include <libnautilus/libnautilus.h> -#include <libnautilus/nautilus-undo-manager.h> -#include <gtk/gtk.h> - -typedef enum { - CV_PROGRESS_INITIAL = 1, - CV_PROGRESS_DONE, - CV_PROGRESS_ERROR, - VIEW_ERROR, - RESET_TO_IDLE, /* Not a real item - a command */ - NAVINFO_RECEIVED, - NEW_CONTENT_VIEW_ACTIVATED, - NEW_META_VIEW_ACTIVATED, - SYNC_STATE /* Not a real item - a flag */ -} NautilusWindowStateItem; - -void nautilus_window_set_state_info(NautilusWindow *window, ... /* things to set, plus optional params */); - -void nautilus_window_real_request_selection_change(NautilusWindow *window, - Nautilus_SelectionRequestInfo *loc, - NautilusViewFrame *requesting_view); - -void nautilus_window_real_request_status_change(NautilusWindow *window, - Nautilus_StatusRequestInfo *loc, - NautilusViewFrame *requesting_view); -void nautilus_window_real_request_location_change (NautilusWindow *window, - Nautilus_NavigationRequestInfo *loc, - NautilusViewFrame *requesting_view); -void nautilus_window_real_request_progress_change (NautilusWindow *window, - Nautilus_ProgressRequestInfo *loc, - NautilusViewFrame *requesting_view); -void nautilus_window_set_status(NautilusWindow *window, const char *txt); -void nautilus_window_back_or_forward (NautilusWindow *window, - gboolean back, - guint distance); -void nautilus_window_begin_location_change(NautilusWindow *window, - Nautilus_NavigationRequestInfo *loc, - NautilusViewFrame *requesting_view, - NautilusLocationChangeType type, - guint distance); -void nautilus_window_remove_meta_view_real(NautilusWindow *window, NautilusViewFrame *meta_view); -void nautilus_window_load_content_view_menu (NautilusWindow *window, NautilusNavigationInfo *ni); -NautilusViewFrame *nautilus_window_load_content_view(NautilusWindow *window, - const char *iid, - Nautilus_NavigationInfo *navinfo, - NautilusViewFrame **requesting_view); -void nautilus_window_connect_content_view (NautilusWindow *window, - NautilusViewFrame *view); -void nautilus_window_connect_view (NautilusWindow *window, - NautilusViewFrame *view); -void nautilus_window_view_destroyed(NautilusViewFrame *view, NautilusWindow *window); - -void nautilus_send_history_list_changed (void); -void nautilus_add_to_history_list (NautilusBookmark *bookmark); -GSList *nautilus_get_history_list (void); - -void nautilus_window_add_bookmark_for_current_location (NautilusWindow *window); -void nautilus_window_initialize_menus (NautilusWindow *window); -void nautilus_window_initialize_toolbars (NautilusWindow *window); - -void nautilus_window_go_back (NautilusWindow *window); -void nautilus_window_go_forward (NautilusWindow *window); -void nautilus_window_go_up (NautilusWindow *window); -void nautilus_window_go_home (NautilusWindow *window); - -NautilusUndoManager *nautilus_window_get_undo_manager (NautilusWindow *window); - -#endif diff --git a/src/ntl-window-state.c b/src/ntl-window-state.c deleted file mode 100644 index af6a05e7a..000000000 --- a/src/ntl-window-state.c +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 1999, 2000 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Elliot Lee <sopwith@redhat.com> - * - */ - -#include <config.h> -#include "ntl-window-state.h" - -#include <libnautilus-extensions/nautilus-file-utilities.h> -#include <libnautilus-extensions/nautilus-global-preferences.h> - -void -nautilus_window_set_initial_state (NautilusWindow *window, const char *initial_url) -{ - if (initial_url) - { - nautilus_window_goto_uri (window, initial_url); - } - else - { - char *home_uri; - char *default_home_uri = g_strdup_printf ("file://%s", g_get_home_dir()); - - home_uri = nautilus_preferences_get (NAUTILUS_PREFERENCES_HOME_URI, default_home_uri); - - g_assert (home_uri != NULL); - - nautilus_window_goto_uri (window, home_uri); - - g_free (home_uri); - g_free (default_home_uri); - } -} diff --git a/src/ntl-window-state.h b/src/ntl-window-state.h deleted file mode 100644 index c925d8323..000000000 --- a/src/ntl-window-state.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef NTL_WINDOW_STATE_H -#define NTL_WINDOW_STATE_H 1 - -#include "ntl-window.h" - -void nautilus_window_set_initial_state(NautilusWindow *window, const char *initial_url); - -#endif diff --git a/src/ntl-window.c b/src/ntl-window.c deleted file mode 100644 index f4e12b0da..000000000 --- a/src/ntl-window.c +++ /dev/null @@ -1,1348 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 1999, 2000 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Authors: Elliot Lee <sopwith@redhat.com> - * John Sullivan <sullivan@eazel.com> - * - */ - -/* ntl-window.c: Implementation of the main window object */ - -#include <config.h> -#include "ntl-window-private.h" - -#include "ntl-window-msgs.h" -#include "ntl-window-state.h" -#include "ntl-app.h" - -#include <gnome.h> -#include <math.h> -#include "nautilus-bookmarks-window.h" -#include "nautilus-signaller.h" -#include "nautilus-location-bar.h" -#include "ntl-index-panel.h" -#include "ntl-miniicon.h" - -#include <gdk-pixbuf/gdk-pixbuf.h> - -#include <libnautilus/nautilus-bonobo-ui.h> - -#include <libnautilus-extensions/nautilus-global-preferences.h> -#include <libnautilus-extensions/nautilus-gtk-extensions.h> -#include <libnautilus-extensions/nautilus-icon-factory.h> -#include <libnautilus-extensions/nautilus-metadata.h> -#include <libnautilus-extensions/nautilus-program-choosing.h> -#include <libnautilus-extensions/nautilus-string.h> -#include <libnautilus-extensions/nautilus-view-identifier.h> -#include <libnautilus/nautilus-undo-manager.h> -#include "nautilus-zoom-control.h" -#include <ctype.h> -#include <libgnomevfs/gnome-vfs-uri.h> - -enum -{ - LAST_SIGNAL -}; - -static void nautilus_window_realize (GtkWidget *widget); -static void nautilus_window_real_set_content_view (NautilusWindow *window, NautilusViewFrame *new_view); - -/* Object framework static variables */ -static GnomeAppClass *parent_class = NULL; -static guint window_signals[LAST_SIGNAL]; - -/* Other static variables */ -static GSList *history_list = NULL; - - -/* Stuff for handling the CORBA interface */ -typedef struct { - POA_Nautilus_ViewWindow servant; - gpointer bonobo_object; - - NautilusWindow *window; -} impl_POA_Nautilus_ViewWindow; - -/* Implementation functions */ -static const CORBA_char * impl_Nautilus_ViewWindow__get_current_uri (impl_POA_Nautilus_ViewWindow *servant, - CORBA_Environment *ev); -static Nautilus_Application impl_Nautilus_ViewWindow__get_application (impl_POA_Nautilus_ViewWindow *servant, - CORBA_Environment *ev); -static void impl_Nautilus_ViewWindow_open_uri (impl_POA_Nautilus_ViewWindow *servant, - CORBA_char *uri, - CORBA_Environment *ev); -static void impl_Nautilus_ViewWindow_close (impl_POA_Nautilus_ViewWindow *servant, - CORBA_Environment *ev); - -/* Private functions */ -static void nautilus_window_class_init (NautilusWindowClass *klass); -static void nautilus_window_init (NautilusWindow *window); -static void nautilus_window_destroy (NautilusWindow *window); -static void nautilus_window_set_arg (GtkObject *object, - GtkArg *arg, - guint arg_id); -static void nautilus_window_get_arg (GtkObject *object, - GtkArg *arg, - guint arg_id); -static void nautilus_window_goto_uri_callback (GtkWidget *widget, - const char *uri, - GtkWidget *window); -static void zoom_in_callback (NautilusZoomControl *zoom_control, - NautilusWindow *window); -static void zoom_out_callback (NautilusZoomControl *zoom_control, - NautilusWindow *window); -static void sidebar_panels_changed_callback (gpointer user_data); -static NautilusViewFrame *window_find_sidebar_panel_by_identifier (NautilusWindow *window, - NautilusViewIdentifier *identifier); -static void window_update_sidebar_panels_from_preferences (NautilusWindow *window); - -/* Milliseconds */ -#define STATUSBAR_CLEAR_TIMEOUT 5000 - -static POA_Nautilus_ViewWindow__epv impl_Nautilus_ViewWindow_epv = -{ - NULL, - (gpointer) &impl_Nautilus_ViewWindow__get_current_uri, - (gpointer) &impl_Nautilus_ViewWindow__get_application, - (gpointer) &impl_Nautilus_ViewWindow_open_uri, - (gpointer) &impl_Nautilus_ViewWindow_close -}; - -static PortableServer_ServantBase__epv base_epv = { NULL, NULL, NULL }; - -static POA_Nautilus_ViewWindow__vepv impl_Nautilus_ViewWindow_vepv = -{ - &base_epv, - NULL, - &impl_Nautilus_ViewWindow_epv -}; - -static const CORBA_char * -impl_Nautilus_ViewWindow__get_current_uri (impl_POA_Nautilus_ViewWindow *servant, - CORBA_Environment *ev) -{ - return nautilus_window_get_requested_uri (servant->window); -} - - -static Nautilus_Application -impl_Nautilus_ViewWindow__get_application (impl_POA_Nautilus_ViewWindow *servant, - CORBA_Environment *ev) -{ - return CORBA_Object_duplicate(bonobo_object_corba_objref(servant->window->app), ev); -} - -static void -impl_Nautilus_ViewWindow_open_uri (impl_POA_Nautilus_ViewWindow *servant, - CORBA_char *uri, - CORBA_Environment *ev) -{ - nautilus_window_goto_uri (servant->window, uri); -} - -static void -impl_Nautilus_ViewWindow_close (impl_POA_Nautilus_ViewWindow *servant, - CORBA_Environment *ev) -{ - nautilus_window_close (servant->window); -} - - -static void -impl_Nautilus_ViewWindow__destroy(BonoboObject *obj, impl_POA_Nautilus_ViewWindow *servant) -{ - PortableServer_ObjectId *objid; - CORBA_Environment ev; - - CORBA_exception_init(&ev); - - objid = PortableServer_POA_servant_to_id(bonobo_poa(), servant, &ev); - PortableServer_POA_deactivate_object(bonobo_poa(), objid, &ev); - CORBA_free(objid); - obj->servant = NULL; - - POA_Nautilus_ViewWindow__fini((PortableServer_Servant) servant, &ev); - g_free(servant); - - CORBA_exception_free(&ev); -} - -static BonoboObject * -impl_Nautilus_ViewWindow__create(NautilusWindow *window) -{ - BonoboObject *retval; - impl_POA_Nautilus_ViewWindow *newservant; - CORBA_Environment ev; - - CORBA_exception_init(&ev); - - newservant = g_new0(impl_POA_Nautilus_ViewWindow, 1); - newservant->servant.vepv = &impl_Nautilus_ViewWindow_vepv; - newservant->window = window; - POA_Nautilus_ViewWindow__init((PortableServer_Servant) newservant, &ev); - - retval = bonobo_object_new_from_servant(newservant); - - gtk_signal_connect(GTK_OBJECT(retval), "destroy", GTK_SIGNAL_FUNC(impl_Nautilus_ViewWindow__destroy), newservant); - CORBA_exception_free(&ev); - - return retval; -} - -GtkType -nautilus_window_get_type(void) -{ - static guint window_type = 0; - - if (!window_type) - { - GtkTypeInfo window_info = - { - "NautilusWindow", - sizeof(NautilusWindow), - sizeof(NautilusWindowClass), - (GtkClassInitFunc) nautilus_window_class_init, - (GtkObjectInitFunc) nautilus_window_init, - NULL, - NULL, - NULL - }; - - window_type = gtk_type_unique (gnome_app_get_type(), &window_info); - } - - return window_type; -} - -#if 0 -typedef void (*GtkSignal_NONE__BOXED_OBJECT) (GtkObject * object, - gpointer arg1, - GtkObject *arg2, - gpointer user_data); -static void -gtk_marshal_NONE__BOXED_OBJECT (GtkObject * object, - GtkSignalFunc func, - gpointer func_data, - GtkArg * args) -{ - GtkSignal_NONE__BOXED_OBJECT rfunc; - rfunc = (GtkSignal_NONE__BOXED_OBJECT) func; - (*rfunc) (object, - GTK_VALUE_BOXED (args[0]), - GTK_VALUE_OBJECT (args[1]), - func_data); -} -#endif - -enum { - ARG_0, - ARG_APP_ID, - ARG_APP, - ARG_CONTENT_VIEW -}; - -static void -nautilus_window_class_init (NautilusWindowClass *klass) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - parent_class = gtk_type_class(gnome_app_get_type()); - - object_class = (GtkObjectClass*) klass; - object_class->destroy = (void (*)(GtkObject *))nautilus_window_destroy; - object_class->get_arg = nautilus_window_get_arg; - object_class->set_arg = nautilus_window_set_arg; - - widget_class = (GtkWidgetClass*) klass; - klass->parent_class = gtk_type_class (gtk_type_parent (object_class->type)); - - gtk_object_class_add_signals (object_class, window_signals, LAST_SIGNAL); - - gtk_object_add_arg_type ("NautilusWindow::app_id", - GTK_TYPE_STRING, - GTK_ARG_READWRITE|GTK_ARG_CONSTRUCT, - ARG_APP_ID); - gtk_object_add_arg_type ("NautilusWindow::app", - GTK_TYPE_OBJECT, - GTK_ARG_READWRITE|GTK_ARG_CONSTRUCT, - ARG_APP); - gtk_object_add_arg_type ("NautilusWindow::content_view", - GTK_TYPE_OBJECT, - GTK_ARG_READWRITE, - ARG_CONTENT_VIEW); - impl_Nautilus_ViewWindow_vepv.Bonobo_Unknown_epv = bonobo_object_get_epv(); - - widget_class->realize = nautilus_window_realize; -} - -static void -nautilus_window_init (NautilusWindow *window) -{ - gtk_quit_add_destroy (1, GTK_OBJECT (window)); - - /* Keep track of sidebar panel changes */ - nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_SIDEBAR_PANELS_NAMESPACE, - sidebar_panels_changed_callback, - window); -} - -static gboolean -nautilus_window_clear_status(NautilusWindow *window) -{ - gtk_statusbar_pop(GTK_STATUSBAR(GNOME_APP(window)->statusbar), window->statusbar_ctx); - window->statusbar_clear_id = 0; - return FALSE; -} - -void -nautilus_window_set_status(NautilusWindow *window, const char *txt) -{ - if(window->statusbar_clear_id) - g_source_remove(window->statusbar_clear_id); - - gtk_statusbar_pop(GTK_STATUSBAR(GNOME_APP(window)->statusbar), window->statusbar_ctx); - if(txt && *txt) - { - window->statusbar_clear_id = g_timeout_add(STATUSBAR_CLEAR_TIMEOUT, (GSourceFunc)nautilus_window_clear_status, window); - gtk_statusbar_push(GTK_STATUSBAR(GNOME_APP(window)->statusbar), window->statusbar_ctx, txt); - } - else - window->statusbar_clear_id = 0; -} - -void -nautilus_window_goto_uri (NautilusWindow *window, const char *uri) -{ - Nautilus_NavigationRequestInfo navinfo; - - memset(&navinfo, 0, sizeof(navinfo)); - navinfo.requested_uri = (char *)uri; - navinfo.new_window_requested = FALSE; - - nautilus_window_request_location_change (window, &navinfo, NULL); -} - -static void -nautilus_window_goto_uri_callback (GtkWidget *widget, - const char *uri, - GtkWidget *window) -{ - nautilus_window_goto_uri(NAUTILUS_WINDOW(window), uri); -} - -static void -zoom_in_callback (NautilusZoomControl *zoom_control, - NautilusWindow *window) -{ - if (window->content_view != NULL) { - nautilus_view_frame_zoom_in (window->content_view); - } -} - -static void -zoom_out_callback (NautilusZoomControl *zoom_control, - NautilusWindow *window) -{ - if (window->content_view != NULL) { - nautilus_view_frame_zoom_out (window->content_view); - } -} - - -static void -nautilus_window_constructed (NautilusWindow *window) -{ - GnomeApp *app; - GtkWidget *location_bar_box, *statusbar; - GtkWidget *temp_frame; - GnomeDockItemBehavior behavior; - int sidebar_width; - NautilusUndoManager *app_undo_manager; - Nautilus_Undo_Manager undo_manager; - CORBA_Environment ev; - - CORBA_exception_init(&ev); - - - app = GNOME_APP(window); - - /* Set up undo manager */ - app_undo_manager = NAUTILUS_UNDO_MANAGER (NAUTILUS_APP (window->app)->undo_manager); - g_assert (app_undo_manager != NULL); - undo_manager = bonobo_object_corba_objref (BONOBO_OBJECT (app_undo_manager)); - Bonobo_Unknown_ref (undo_manager, &ev); - nautilus_attach_undo_manager (GTK_OBJECT (window), undo_manager); - - /* set up location bar */ - location_bar_box = gtk_hbox_new(FALSE, GNOME_PAD); - gtk_container_set_border_width(GTK_CONTAINER(location_bar_box), GNOME_PAD_SMALL); - - window->ent_uri = nautilus_location_bar_new(); - - gtk_signal_connect(GTK_OBJECT(window->ent_uri), "location_changed", - nautilus_window_goto_uri_callback, window); - gtk_box_pack_start(GTK_BOX(location_bar_box), window->ent_uri, TRUE, TRUE, GNOME_PAD_SMALL); - behavior = GNOME_DOCK_ITEM_BEH_EXCLUSIVE | GNOME_DOCK_ITEM_BEH_NEVER_VERTICAL; - if(!gnome_preferences_get_toolbar_detachable()) - behavior |= GNOME_DOCK_ITEM_BEH_LOCKED; - gnome_app_add_docked(app, location_bar_box, "uri-entry", behavior, GNOME_DOCK_TOP, 2, 0, 0); - - /* Option menu for content view types; it's empty here, filled in when a uri is set. */ - window->view_as_option_menu = gtk_option_menu_new(); - gtk_box_pack_end(GTK_BOX(location_bar_box), window->view_as_option_menu, FALSE, FALSE, GNOME_PAD_SMALL); - gtk_widget_show(window->view_as_option_menu); - - /* allocate the zoom control and place on the right next to the menu */ - window->zoom_control = nautilus_zoom_control_new (); - gtk_widget_show (window->zoom_control); - gtk_signal_connect (GTK_OBJECT (window->zoom_control), "zoom_in", zoom_in_callback, window); - gtk_signal_connect (GTK_OBJECT (window->zoom_control), "zoom_out", zoom_out_callback, window); - gtk_box_pack_end (GTK_BOX (location_bar_box), window->zoom_control, FALSE, FALSE, 0); - - gtk_widget_show_all(location_bar_box); - - /* set up status bar */ - gnome_app_set_statusbar(app, (statusbar = gtk_statusbar_new())); - - /* insert a little padding so text isn't jammed against frame */ - gtk_misc_set_padding(GTK_MISC ((GTK_STATUSBAR (statusbar))->label), GNOME_PAD, 0); - window->statusbar_ctx = gtk_statusbar_get_context_id(GTK_STATUSBAR(statusbar), "IhateGtkStatusbar"); - - /* set up window contents and policy */ - gtk_window_set_policy(GTK_WINDOW(window), FALSE, TRUE, FALSE); - gtk_window_set_default_size(GTK_WINDOW(window), 650, 400); - - window->content_hbox = gtk_hpaned_new(); - sidebar_width = nautilus_preferences_get_enum(NAUTILUS_PREFERENCES_SIDEBAR_WIDTH, 148); - gtk_paned_set_position(GTK_PANED(window->content_hbox), sidebar_width); - - gnome_app_set_contents(app, window->content_hbox); - - /* set up the index panel in a frame */ - temp_frame = gtk_frame_new(NULL); - gtk_frame_set_shadow_type(GTK_FRAME(temp_frame), GTK_SHADOW_OUT); - gtk_widget_show(temp_frame); - - window->index_panel = nautilus_index_panel_new(); - gtk_widget_show (GTK_WIDGET (window->index_panel)); - gtk_container_add(GTK_CONTAINER(temp_frame), GTK_WIDGET (window->index_panel)); - - gtk_paned_pack1(GTK_PANED(window->content_hbox), temp_frame, FALSE, FALSE); - - gtk_widget_show_all(window->content_hbox); - - /* enable mouse tracking for the index panel */ - gtk_widget_add_events(GTK_WIDGET (window->index_panel), GDK_POINTER_MOTION_MASK); - - /* CORBA and Bonobo setup */ - window->ntl_viewwindow = impl_Nautilus_ViewWindow__create(window); - window->uih = bonobo_ui_handler_new(); - bonobo_ui_handler_set_app(window->uih, app); - bonobo_ui_handler_set_statusbar(window->uih, statusbar); - - /* Create menus and toolbars */ - nautilus_window_initialize_menus (window); - nautilus_window_initialize_toolbars (window); - - /* Set initial sensitivity of some buttons & menu items - * now that they're all created. - */ - nautilus_window_allow_back(window, FALSE); - nautilus_window_allow_forward(window, FALSE); - nautilus_window_allow_stop(window, FALSE); - - CORBA_exception_free(&ev); -} - -static void -nautilus_window_set_arg (GtkObject *object, - GtkArg *arg, - guint arg_id) -{ - GnomeApp *app = (GnomeApp *) object; - char *old_app_name; - NautilusWindow *window = (NautilusWindow *) object; - - switch(arg_id) { - case ARG_APP_ID: - if(!GTK_VALUE_STRING(*arg)) - return; - - old_app_name = app->name; - g_free(app->name); - app->name = g_strdup(GTK_VALUE_STRING(*arg)); - g_assert(app->name); - g_free(app->prefix); - app->prefix = g_strconcat("/", app->name, "/", NULL); - if(!old_app_name) { - nautilus_window_constructed(NAUTILUS_WINDOW(object)); - } - break; - case ARG_APP: - window->app = BONOBO_OBJECT(GTK_VALUE_OBJECT(*arg)); - break; - case ARG_CONTENT_VIEW: - nautilus_window_real_set_content_view (window, (NautilusViewFrame *)GTK_VALUE_OBJECT(*arg)); - break; - } -} - -static void -nautilus_window_get_arg (GtkObject *object, - GtkArg *arg, - guint arg_id) -{ - GnomeApp *app = (GnomeApp *) object; - - switch(arg_id) { - case ARG_APP_ID: - GTK_VALUE_STRING(*arg) = app->name; - break; - case ARG_APP: - GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(NAUTILUS_WINDOW(object)->app); - break; - case ARG_CONTENT_VIEW: - GTK_VALUE_OBJECT(*arg) = GTK_OBJECT(((NautilusWindow *)object)->content_view); - break; - } -} - -static void -nautilus_window_destroy (NautilusWindow *window) -{ - NautilusWindowClass *klass = NAUTILUS_WINDOW_CLASS(GTK_OBJECT(window)->klass); - - /* Dont keep track of sidebar panel changes no more */ - nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_SIDEBAR_PANELS_NAMESPACE, - sidebar_panels_changed_callback, - NULL); - - g_list_free (window->meta_views); - - CORBA_free(window->ni); - CORBA_free(window->si); - g_slist_foreach(window->back_list, (GFunc)gtk_object_unref, NULL); - g_slist_foreach(window->forward_list, (GFunc)gtk_object_unref, NULL); - g_slist_free(window->back_list); - g_slist_free(window->forward_list); - - if(window->statusbar_clear_id) - g_source_remove(window->statusbar_clear_id); - - if(GTK_OBJECT_CLASS(klass->parent_class)->destroy) - GTK_OBJECT_CLASS(klass->parent_class)->destroy(GTK_OBJECT(window)); -} - -void -nautilus_window_close (NautilusWindow *window) -{ - g_return_if_fail (NAUTILUS_IS_WINDOW (window)); - gtk_widget_destroy (GTK_WIDGET (window)); -} - - -/* The reason for this function is that - `gdk_pixbuf_render_pixmap_and_mask', as currently implemented, will - fail on a pixbuf with no alpha channel. This function will instead - return with NULL in *mask_retval in such a case. If that ever gets - fixed, this function should be removed. -*/ - -static void -would_be_in_gdk_pixbuf_if_federico_wasnt_stubborn_pixbuf_render(GdkPixbuf *pixbuf, - GdkPixmap **pixmap, - GdkBitmap **mask_retval, - gint alpha_threshold) -{ - GdkBitmap *mask = NULL; - - g_return_if_fail(pixbuf != NULL); - - /* generate mask */ - if (gdk_pixbuf_get_has_alpha(pixbuf)) { - mask = gdk_pixmap_new(NULL, - gdk_pixbuf_get_width(pixbuf), - gdk_pixbuf_get_height(pixbuf), - 1); - - gdk_pixbuf_render_threshold_alpha(pixbuf, mask, - 0, 0, 0, 0, - gdk_pixbuf_get_width(pixbuf), - gdk_pixbuf_get_height(pixbuf), - alpha_threshold); - } - - /* Draw to pixmap */ - - if (pixmap != NULL) { - GdkGC* gc; - - *pixmap = gdk_pixmap_new(NULL, - gdk_pixbuf_get_width(pixbuf), - gdk_pixbuf_get_height(pixbuf), - gdk_rgb_get_visual()->depth); - - gc = gdk_gc_new(*pixmap); - - gdk_gc_set_clip_mask(gc, mask); - - gdk_pixbuf_render_to_drawable(pixbuf, *pixmap, - gc, - 0, 0, 0, 0, - gdk_pixbuf_get_width(pixbuf), - gdk_pixbuf_get_height(pixbuf), - GDK_RGB_DITHER_NORMAL, - 0, 0); - - gdk_gc_unref(gc); - } - - if (mask_retval) - *mask_retval = mask; - else - gdk_bitmap_unref(mask); -} - -static void -nautilus_window_realize (GtkWidget *widget) -{ - GdkPixmap *pixmap = NULL; - GdkBitmap *mask = NULL; - gchar *filename; - - /* Create our GdkWindow */ - if (GTK_WIDGET_CLASS(parent_class)->realize) - (* GTK_WIDGET_CLASS(parent_class)->realize) (widget); - - /* Set the mini icon */ - /* FIXME bugzilla.eazel.com 609: - * Need a real icon for Nautilus here. It should be 16x16. - */ - filename = gnome_pixmap_file("panel-arrow-down.png"); - - if (filename != NULL) { - GdkPixbuf *pixbuf; - - pixbuf = gdk_pixbuf_new_from_file(filename); - - if (pixbuf != NULL) { - would_be_in_gdk_pixbuf_if_federico_wasnt_stubborn_pixbuf_render(pixbuf, - &pixmap, - &mask, - 128); - } - } - - - if (pixmap != NULL) - nautilus_set_mini_icon(widget->window, - pixmap, - mask); - - /* FIXME bugzilla.eazel.com 610: - * I think we are leaking the pixmap/mask here. - */ -} - -/* - * Main API - */ - -#if 0 -static gboolean -nautilus_window_send_show_properties(GtkWidget *dockitem, GdkEventButton *event, NautilusViewFrame *meta_view) -{ - if(event->button != 3) - return FALSE; - - gtk_signal_emit_stop_by_name(GTK_OBJECT(dockitem), "button_press_event"); - - nautilus_view_show_properties(meta_view); - - return TRUE; -} -#endif - -static void -nautilus_window_switch_views (NautilusWindow *window, const char *iid) -{ - NautilusDirectory *directory; - NautilusViewFrame *view; - - g_return_if_fail (NAUTILUS_IS_WINDOW (window)); - g_return_if_fail (NAUTILUS_WINDOW (window)->ni != NULL); - g_return_if_fail (iid != NULL); - - directory = nautilus_directory_get (window->ni->requested_uri); - g_assert (directory != NULL); - nautilus_directory_set_metadata (directory, - NAUTILUS_METADATA_KEY_INITIAL_VIEW, - NULL, - iid); - nautilus_directory_unref (directory); - - nautilus_window_allow_stop (window, TRUE); - - view = nautilus_window_load_content_view (window, iid, window->ni, NULL); - nautilus_window_set_state_info (window, - (NautilusWindowStateItem)NEW_CONTENT_VIEW_ACTIVATED, view, - (NautilusWindowStateItem)0); -} - -/** - * synch_view_as_menu: - * - * Set the visible item of the "View as" option menu to - * match the current content view. - * - * @window: The NautilusWindow whose "View as" option menu should be synched. - */ -static void -synch_view_as_menu (NautilusWindow *window) -{ - GList *children, *child; - GtkWidget *menu; - const char *item_iid; - int index, matching_index; - - g_return_if_fail (NAUTILUS_IS_WINDOW (window)); - - menu = gtk_option_menu_get_menu (GTK_OPTION_MENU (window->view_as_option_menu)); - if (menu == NULL) { - return; - } - children = gtk_container_children (GTK_CONTAINER (menu)); - matching_index = -1; - - for (child = children, index = 0; child != NULL; child = child->next, ++index) { - item_iid = (const char *)(gtk_object_get_data (GTK_OBJECT (child->data), "iid")); - if (nautilus_strcmp (window->content_view->iid, item_iid) == 0) { - matching_index = index; - break; - } - } - - if (matching_index != -1) { - gtk_option_menu_set_history (GTK_OPTION_MENU (window->view_as_option_menu), - matching_index); - } else { - g_warning ("In synch_view_as_menu, couldn't find matching menu item."); - } - - g_list_free (children); -} - -static void -chose_component_callback (NautilusViewIdentifier *identifier, gpointer callback_data) -{ - g_return_if_fail (NAUTILUS_IS_WINDOW (callback_data)); - - if (identifier != NULL) { - /* FIXME: Need to add menu item for new identifier to "View as" menu. */ - nautilus_window_switch_views (NAUTILUS_WINDOW (callback_data), identifier->iid); - } - - nautilus_view_identifier_free (identifier); -} - -static void -view_menu_choose_view_callback (GtkWidget *widget, gpointer data) -{ - NautilusWindow *window; - NautilusFile *file; - - g_return_if_fail (GTK_IS_MENU_ITEM (widget)); - g_return_if_fail (NAUTILUS_IS_WINDOW (gtk_object_get_data (GTK_OBJECT (widget), "window"))); - - window = NAUTILUS_WINDOW (gtk_object_get_data (GTK_OBJECT (widget), "window")); - - /* Set the option menu back to its previous setting (Don't leave it - * on this dialog-producing "View as Other..." setting). If the menu choice - * causes a content view change, this will be updated again later, - * in nautilus_window_load_content_view_menu. Do this right away so - * the user never sees the option menu set to "View as Other...". - */ - synch_view_as_menu (window); - - file = nautilus_file_get (window->ni->requested_uri); - g_return_if_fail (NAUTILUS_IS_FILE (file)); - - nautilus_choose_component_for_file (file, - GTK_WINDOW (window), - chose_component_callback, - window); - - nautilus_file_unref (file); -} - -static void -view_menu_switch_views_callback (GtkWidget *widget, gpointer data) -{ - NautilusWindow *window; - const char *iid; - - g_return_if_fail (GTK_IS_MENU_ITEM (widget)); - g_return_if_fail (NAUTILUS_IS_WINDOW (gtk_object_get_data (GTK_OBJECT (widget), "window"))); - - window = NAUTILUS_WINDOW (gtk_object_get_data (GTK_OBJECT (widget), "window")); - iid = (const char *)gtk_object_get_data (GTK_OBJECT (widget), "iid"); - - nautilus_window_switch_views (window, iid); -} - -void -nautilus_window_load_content_view_menu (NautilusWindow *window, - NautilusNavigationInfo *ni) -{ - GList *p; - GtkWidget *new_menu; - int index; - GtkWidget *menu_item; - NautilusViewIdentifier *identifier; - char *menu_label; - - g_return_if_fail (NAUTILUS_IS_WINDOW (window)); - g_return_if_fail (GTK_IS_OPTION_MENU (window->view_as_option_menu)); - g_return_if_fail (ni != NULL); - - new_menu = gtk_menu_new (); - - /* Add a menu item for each available content view type */ - index = 0; - for (p = ni->content_identifiers; p != NULL; p = p->next) { - identifier = (NautilusViewIdentifier *) p->data; - menu_label = g_strdup_printf (_("View as %s"), identifier->name); - menu_item = gtk_menu_item_new_with_label (menu_label); - g_free (menu_label); - - gtk_signal_connect - (GTK_OBJECT (menu_item), - "activate", - GTK_SIGNAL_FUNC (view_menu_switch_views_callback), - NULL); - - /* Store copy of iid in item; free when item destroyed. */ - gtk_object_set_data_full (GTK_OBJECT (menu_item), - "iid", - g_strdup (identifier->iid), - g_free); - - /* Store reference to window in item; no need to free this. */ - gtk_object_set_data (GTK_OBJECT (menu_item), "window", window); - gtk_menu_append (GTK_MENU (new_menu), menu_item); - gtk_widget_show (menu_item); - - ++index; - } - - /* Add "View as Other..." extra bonus choice, with separator before it. */ - menu_item = gtk_menu_item_new (); - gtk_widget_show (menu_item); - gtk_menu_append (GTK_MENU (new_menu), menu_item); - - menu_item = gtk_menu_item_new_with_label (_("View as Other...")); - /* Store reference to window in item; no need to free this. */ - gtk_object_set_data (GTK_OBJECT (menu_item), "window", window); - gtk_signal_connect (GTK_OBJECT (menu_item), - "activate", - GTK_SIGNAL_FUNC (view_menu_choose_view_callback), - NULL); - gtk_widget_show (menu_item); - gtk_menu_append (GTK_MENU (new_menu), menu_item); - - /* - * We create and attach a new menu here because adding/removing - * items from existing menu screws up the size of the option menu. - */ - gtk_option_menu_set_menu (GTK_OPTION_MENU (window->view_as_option_menu), - new_menu); - - synch_view_as_menu (window); -} - -void -nautilus_window_set_content_view (NautilusWindow *window, NautilusViewFrame *content_view) -{ - nautilus_window_real_set_content_view (window, content_view); -} - -void -nautilus_window_add_meta_view(NautilusWindow *window, NautilusViewFrame *meta_view) -{ - g_return_if_fail (!g_list_find (window->meta_views, meta_view)); - g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (meta_view)); - - nautilus_index_panel_add_meta_view (window->index_panel, meta_view); - window->meta_views = g_list_prepend (window->meta_views, meta_view); -} - -void -nautilus_window_remove_meta_view (NautilusWindow *window, NautilusViewFrame *meta_view) -{ - if (!g_list_find(window->meta_views, meta_view)) - return; - - nautilus_index_panel_remove_meta_view (window->index_panel, meta_view); - window->meta_views = g_list_remove (window->meta_views, meta_view); -} - -void -nautilus_window_back_or_forward (NautilusWindow *window, gboolean back, guint distance) -{ - Nautilus_NavigationRequestInfo nri; - GSList *list; - - list = back ? window->back_list : window->forward_list; - g_assert (g_slist_length (list) > distance); - - memset(&nri, 0, sizeof(nri)); - /* FIXME bugzilla.eazel.com 608: - * Have to cast away the const for nri.requested_uri. This field should be - * declared const. - */ - nri.requested_uri = (char *)nautilus_bookmark_get_uri (g_slist_nth_data (list, distance)); - nri.new_window_requested = FALSE; - - nautilus_window_begin_location_change (window, &nri, NULL, back ? NAUTILUS_LOCATION_CHANGE_BACK : NAUTILUS_LOCATION_CHANGE_FORWARD, distance); -} - -void -nautilus_window_go_back (NautilusWindow *window) -{ - nautilus_window_back_or_forward (window, TRUE, 0); -} - -void -nautilus_window_go_forward (NautilusWindow *window) -{ - nautilus_window_back_or_forward (window, FALSE, 0); -} - -const char * -nautilus_window_get_requested_uri (NautilusWindow *window) -{ - return window->ni == NULL ? NULL : window->ni->requested_uri; -} - -BonoboUIHandler * -nautilus_window_get_uih(NautilusWindow *window) -{ - return window->uih; -} - -void -nautilus_window_go_up (NautilusWindow *window) -{ - const char *requested_uri; - GnomeVFSURI *current_uri; - GnomeVFSURI *parent_uri; - char *parent_uri_string; - - requested_uri = nautilus_window_get_requested_uri(window); - if (requested_uri == NULL) - return; - - current_uri = gnome_vfs_uri_new (requested_uri); - parent_uri = gnome_vfs_uri_get_parent (current_uri); - gnome_vfs_uri_unref (current_uri); - parent_uri_string = gnome_vfs_uri_to_string (parent_uri, GNOME_VFS_URI_HIDE_NONE); - gnome_vfs_uri_unref (parent_uri); - - nautilus_window_goto_uri (window, parent_uri_string); - - g_free (parent_uri_string); -} - -void -nautilus_window_go_home (NautilusWindow *window) -{ - nautilus_window_set_initial_state(window, NULL); -} - - -void -nautilus_window_allow_back (NautilusWindow *window, gboolean allow) -{ - gtk_widget_set_sensitive(window->back_button, allow); - bonobo_ui_handler_menu_set_sensitivity(window->uih, NAUTILUS_MENU_PATH_BACK_ITEM, allow); -} - -void -nautilus_window_allow_forward (NautilusWindow *window, gboolean allow) -{ - gtk_widget_set_sensitive(window->forward_button, allow); - bonobo_ui_handler_menu_set_sensitivity(window->uih, NAUTILUS_MENU_PATH_FORWARD_ITEM, allow); -} - -void -nautilus_window_allow_up (NautilusWindow *window, gboolean allow) -{ - gtk_widget_set_sensitive(window->up_button, allow); - bonobo_ui_handler_menu_set_sensitivity(window->uih, NAUTILUS_MENU_PATH_UP_ITEM, allow); -} - -void -nautilus_window_allow_reload (NautilusWindow *window, gboolean allow) -{ - gtk_widget_set_sensitive(window->reload_button, allow); -} - -void -nautilus_window_allow_stop (NautilusWindow *window, gboolean allow) -{ - gtk_widget_set_sensitive(window->stop_button, allow); -} - -void -nautilus_send_history_list_changed () -{ - gtk_signal_emit_by_name (GTK_OBJECT (nautilus_signaller_get_current ()), - "history_list_changed"); -} - -void -nautilus_add_to_history_list (NautilusBookmark *bookmark) -{ - /* Note that the history is shared amongst all windows so - * this is not a NautilusWindow function. Perhaps it belongs - * in its own file. - */ - GSList *found_link; - - g_return_if_fail (NAUTILUS_IS_BOOKMARK (bookmark)); - - found_link = g_slist_find_custom (history_list, - bookmark, - nautilus_bookmark_compare_with); - - /* Remove any older entry for this same item. There can be at most 1. */ - if (found_link != NULL) - { - gtk_object_unref (found_link->data); - history_list = g_slist_remove_link (history_list, found_link); - } - - /* New item goes first. */ - gtk_object_ref (GTK_OBJECT (bookmark)); - history_list = g_slist_prepend(history_list, bookmark); - - /* Tell world that history list has changed. At least all the - * NautilusWindows (not just this one) are listening. - */ - nautilus_send_history_list_changed (); -} - -GSList * -nautilus_get_history_list () -{ - return history_list; -} - - -static void -nautilus_window_request_location_change_callback (NautilusViewFrame *view, - Nautilus_NavigationRequestInfo *info, - NautilusWindow *window) -{ - nautilus_window_request_location_change(window, info, view); -} - - -static void -nautilus_window_request_selection_change_callback (NautilusViewFrame *view, - Nautilus_SelectionRequestInfo *info, - NautilusWindow *window) -{ - nautilus_window_request_selection_change(window, info, view); -} - -static void -nautilus_window_request_status_change_callback (NautilusViewFrame *view, - Nautilus_StatusRequestInfo *info, - NautilusWindow *window) -{ - nautilus_window_request_status_change(window, info, view); -} - -static void -nautilus_window_request_progress_change_callback (NautilusViewFrame *view, - Nautilus_ProgressRequestInfo *info, - NautilusWindow *window) -{ - nautilus_window_request_progress_change(window, info, view); -} - -static void -nautilus_window_request_title_change_callback (NautilusViewFrame *view, - const char *new_title, - NautilusWindow *window) -{ - nautilus_window_request_title_change(window, new_title, view); -} - -void -nautilus_window_connect_view(NautilusWindow *window, NautilusViewFrame *view) -{ - GtkObject *view_object; - - view_object = GTK_OBJECT(view); - gtk_signal_connect(view_object, - "request_location_change", - nautilus_window_request_location_change_callback, - window); - gtk_signal_connect(view_object, - "request_selection_change", - nautilus_window_request_selection_change_callback, - window); - gtk_signal_connect(view_object, - "request_status_change", - nautilus_window_request_status_change_callback, - window); - gtk_signal_connect(view_object, - "request_progress_change", - nautilus_window_request_progress_change_callback, - window); - gtk_signal_connect(view_object, - "destroy", - nautilus_window_view_destroyed, - window); -} - -void -nautilus_window_connect_content_view (NautilusWindow *window, NautilusViewFrame *view) -{ - GtkObject *view_object; - - /* First connect with NautilusViewFrame signals. */ - nautilus_window_connect_view (window, NAUTILUS_VIEW_FRAME (view)); - - /* Now connect with NautilusContentViewFrame signals. */ - view_object = GTK_OBJECT(view); - gtk_signal_connect (view_object, - "request_title_change", - nautilus_window_request_title_change_callback, - window); -} - -void -nautilus_window_display_error(NautilusWindow *window, const char *error_msg) -{ - GtkWidget *dialog; - - dialog = gnome_message_box_new(error_msg, GNOME_MESSAGE_BOX_ERROR, _("Close"), NULL); - gnome_dialog_set_close(GNOME_DIALOG(dialog), TRUE); - - gnome_dialog_set_default(GNOME_DIALOG(dialog), 0); - - gtk_widget_show(dialog); -} - -static void -nautilus_window_real_set_content_view (NautilusWindow *window, NautilusViewFrame *new_view) -{ - g_return_if_fail (NAUTILUS_IS_WINDOW (window)); - g_return_if_fail (new_view == NULL || NAUTILUS_IS_VIEW_FRAME (new_view)); - - if (new_view == window->content_view) - { - return; - } - - if (window->content_view != NULL) - { - gtk_container_remove (GTK_CONTAINER (window->content_hbox), GTK_WIDGET (window->content_view)); - } - - if (new_view != NULL) - { - nautilus_zoom_control_reset_zoom_level (NAUTILUS_ZOOM_CONTROL (window->zoom_control)); - - gtk_widget_show (GTK_WIDGET (new_view)); - - nautilus_view_frame_activate (new_view); - - gtk_paned_pack2 (GTK_PANED(window->content_hbox), GTK_WIDGET (new_view), TRUE, FALSE); - } - - gtk_widget_queue_resize(window->content_hbox); - window->content_view = new_view; -} - -/** - * window_find_sidebar_panel_by_identifier: - * @window: A NautilusWindow - * @identifier: The NautilusViewIdentifier to look for - * - * Search the list of sidebar panels in the given window for one that - * matches the given view identifier. - * - * Returns a referenced object, not a floating one. bonobo_object_unref - * it when done playing with it. - */ -static NautilusViewFrame * -window_find_sidebar_panel_by_identifier (NautilusWindow *window, NautilusViewIdentifier *identifier) -{ - GList *iterator; - - g_assert (window != NULL); - g_assert (NAUTILUS_IS_WINDOW (window)); - g_assert (identifier != NULL); - - for (iterator = window->meta_views; iterator != NULL; iterator = iterator->next) { - NautilusViewFrame *sidebar_panel; - - g_assert (iterator->data != NULL); - g_assert (NAUTILUS_IS_VIEW_FRAME (iterator->data)); - - sidebar_panel = NAUTILUS_VIEW_FRAME (iterator->data); - - if (strcmp (sidebar_panel->iid, identifier->iid) == 0) { - gtk_widget_ref (GTK_WIDGET (sidebar_panel)); - return sidebar_panel; - } - } - - return NULL; -} - -/** - * window_update_sidebar_panels_from_preferences: - * @window: A NautilusWindow - * - * Update the current list of sidebar panels from preferences. - * - * Disabled panels are removed if they are already in the list. - * - * Enabled panels are added if they are not already in the list. - * - */ -static void -window_update_sidebar_panels_from_preferences (NautilusWindow *window) -{ - GList *enabled_view_identifier_list = NULL; - GList *disabled_view_identifier_list = NULL; - GList *iterator = NULL; - - g_assert (window != NULL); - g_assert (NAUTILUS_IS_WINDOW (window)); - - /* Obtain list of disabled view identifiers */ - disabled_view_identifier_list = - nautilus_global_preferences_get_disabled_sidebar_panel_view_identifiers (); - - /* Remove disabled panels from the window as needed */ - for (iterator = disabled_view_identifier_list; iterator != NULL; iterator = iterator->next) { - NautilusViewIdentifier *identifier; - NautilusViewFrame *sidebar_panel; - - g_assert (iterator->data != NULL); - - identifier = (NautilusViewIdentifier *) iterator->data; - - sidebar_panel = window_find_sidebar_panel_by_identifier (window, identifier); - - if (sidebar_panel != NULL) { - nautilus_window_remove_meta_view (window, sidebar_panel); - - gtk_widget_unref (GTK_WIDGET (sidebar_panel)); - } - } - - if (disabled_view_identifier_list) { - nautilus_view_identifier_free_list (disabled_view_identifier_list); - } - - /* Obtain list of enabled view identifiers */ - enabled_view_identifier_list = - nautilus_global_preferences_get_enabled_sidebar_panel_view_identifiers (); - - /* Add enabled panels from the window as needed */ - for (iterator = enabled_view_identifier_list; iterator != NULL; iterator = iterator->next) { - NautilusViewIdentifier *identifier; - NautilusViewFrame *sidebar_panel; - - g_assert (iterator->data != NULL); - - identifier = (NautilusViewIdentifier *) iterator->data; - - sidebar_panel = window_find_sidebar_panel_by_identifier (window, identifier); - - if (sidebar_panel == NULL) { - gboolean load_result; - - sidebar_panel = NAUTILUS_VIEW_FRAME (gtk_widget_new (nautilus_view_frame_get_type(), - "main_window", - window, - NULL)); - - g_assert (sidebar_panel != NULL); - - nautilus_window_connect_view (window, sidebar_panel); - - load_result = nautilus_view_frame_load_client (sidebar_panel, identifier->iid); - - /* Make sure the load_client succeeded */ - if (load_result) { - gtk_object_ref (GTK_OBJECT (sidebar_panel)); - - nautilus_view_frame_set_active_errors (sidebar_panel, TRUE); - - nautilus_view_frame_set_label (sidebar_panel, identifier->name); - - nautilus_window_add_meta_view (window, sidebar_panel); - } - else { - g_warning ("sidebar_panels_changed_callback: Failed to load_client for '%s' meta view.\n", - identifier->iid); - - gtk_widget_unref (GTK_WIDGET (sidebar_panel)); - - sidebar_panel = NULL; - } - } - else { - gtk_widget_unref (GTK_WIDGET (sidebar_panel)); - } - } - - if (enabled_view_identifier_list) { - nautilus_view_identifier_free_list (enabled_view_identifier_list); - } -} - -/** - * sidebar_panels_changed_callback: - * @user_data: Callback data - * - * Called when enabled/disabled preferences change for any - * sidebar panel. - * - */ -static void -sidebar_panels_changed_callback (gpointer user_data) -{ - g_assert (user_data != NULL); - g_assert (NAUTILUS_IS_WINDOW (user_data)); - - window_update_sidebar_panels_from_preferences (NAUTILUS_WINDOW (user_data)); -} diff --git a/src/ntl-window.h b/src/ntl-window.h deleted file mode 100644 index aae66d71f..000000000 --- a/src/ntl-window.h +++ /dev/null @@ -1,155 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 1999, 2000 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Elliot Lee <sopwith@redhat.com> - * - */ -/* ntl-window.h: Interface of the main window object */ - -#ifndef NTL_WINDOW_H -#define NTL_WINDOW_H - -#include <libgnomeui/gnome-app.h> -#include <libnautilus-extensions/nautilus-glib-extensions.h> -#include <libnautilus-extensions/nautilus-bookmark.h> -#include "ntl-uri-map.h" -#include "ntl-view.h" -#include "ntl-index-panel.h" - -#define NAUTILUS_TYPE_WINDOW (nautilus_window_get_type()) -#define NAUTILUS_WINDOW(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_WINDOW, NautilusWindow)) -#define NAUTILUS_WINDOW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_WINDOW, NautilusWindowClass)) -#define NAUTILUS_IS_WINDOW(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_WINDOW)) -#define NAUTILUS_IS_WINDOW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_WINDOW)) - -typedef struct _NautilusWindow NautilusWindow; - -typedef struct { - GnomeAppClass parent_spot; - GnomeAppClass *parent_class; -} NautilusWindowClass; - -typedef struct _NautilusWindowStateInfo NautilusWindowStateInfo; - -typedef enum { - NAUTILUS_LOCATION_CHANGE_STANDARD, - NAUTILUS_LOCATION_CHANGE_BACK, - NAUTILUS_LOCATION_CHANGE_FORWARD, - NAUTILUS_LOCATION_CHANGE_RELOAD -} NautilusLocationChangeType; - -struct _NautilusWindow { - GnomeApp parent_object; - - /** UI stuff **/ - NautilusIndexPanel *index_panel; - GtkWidget *content_hbox; - GtkWidget *view_as_option_menu, *ent_uri; - - guint statusbar_ctx, statusbar_clear_id; - - /** CORBA-related elements **/ - BonoboObject *ntl_viewwindow; - BonoboUIHandler *uih; - BonoboObject *app; - - /** State information **/ - - /* Information about current location/selection */ - Nautilus_NavigationInfo *ni; - Nautilus_SelectionInfo *si; - char *requested_title; - char *default_title; - - /* Back/Forward chain, and history list. - * The data in these lists are NautilusBookmark pointers. - */ - GSList *back_list, *forward_list; - - NautilusBookmark *current_location_bookmark; - NautilusBookmark *last_location_bookmark; - - /* Current views stuff */ - NautilusViewFrame *content_view; - GList *meta_views; - - /* Widgets to keep track of (for state changes, etc) */ - GtkWidget *back_button; - GtkWidget *forward_button; - GtkWidget *up_button; - GtkWidget *reload_button; - GtkWidget *stop_button; - GtkWidget *zoom_control; - - /* Pending changes */ - NautilusNavigationInfo *pending_ni; - NautilusViewFrame *new_content_view, *new_requesting_view; - GList *new_meta_views; - GList *error_views; - - enum { NW_LOADING_INFO, NW_LOADING_VIEWS, NW_IDLE } state; - - NautilusNavigationInfo *cancel_tag; - guint action_tag; - guint16 made_changes, making_changes; - - NautilusLocationChangeType location_change_type; - guint location_change_distance; - - nautilus_boolean_bit changes_pending : 1; - nautilus_boolean_bit views_shown : 1; - nautilus_boolean_bit view_bombed_out : 1; - nautilus_boolean_bit view_activation_complete : 1; - nautilus_boolean_bit sent_update_view : 1; - nautilus_boolean_bit cv_progress_initial : 1; - nautilus_boolean_bit cv_progress_done : 1; - nautilus_boolean_bit cv_progress_error : 1; - nautilus_boolean_bit reset_to_idle : 1; -}; - -GtkType nautilus_window_get_type (void); -void nautilus_window_close (NautilusWindow *window); -void nautilus_window_set_content_view (NautilusWindow *window, - NautilusViewFrame *content_view); -void nautilus_window_add_meta_view (NautilusWindow *window, - NautilusViewFrame *meta_view); -void nautilus_window_remove_meta_view (NautilusWindow *window, - NautilusViewFrame *meta_view); -void nautilus_window_goto_uri (NautilusWindow *window, - const char *uri); -void nautilus_window_display_error (NautilusWindow *window, - const char *error_msg); -const char * nautilus_window_get_requested_uri (NautilusWindow *window); -BonoboUIHandler *nautilus_window_get_uih (NautilusWindow *window); -void nautilus_window_allow_back (NautilusWindow *window, - gboolean allow); -void nautilus_window_allow_forward (NautilusWindow *window, - gboolean allow); -void nautilus_window_allow_up (NautilusWindow *window, - gboolean allow); -void nautilus_window_allow_reload (NautilusWindow *window, - gboolean allow); -void nautilus_window_allow_stop (NautilusWindow *window, - gboolean allow); -void nautilus_bookmarks_exiting (void); - -#endif |