nautilus/components/mozilla/nautilus-mozilla-content-view.c

1543 lines
42 KiB
C
Raw Normal View History

/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2000 Eazel, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Authors: Ramiro Estrugo <ramiro@eazel.com>
* Mike Fleming <mfleming@eazel.com>
*
*/
/*
* nautilus-mozilla-content-view.c - Mozilla content view component.
*
* This component uses the mozilla gecko layout engine via the gtk_moz_embed
* widget to display and munge html.
*/
#define nopeDEBUG_ramiro 1
#define nopeDEBUG_mfleming 1
#include <config.h>
#include "nautilus-mozilla-content-view.h"
#include "gtkmozembed.h"
#include "mozilla-preferences.h"
#include "mozilla-components.h"
#include "mozilla-events.h"
#include <bonobo/bonobo-control.h>
#include <gtk/gtksignal.h>
#include <libgnome/gnome-i18n.h>
#include <libgnomeui/gnome-stock.h>
#include <libgnomevfs/gnome-vfs.h>
#include <stdlib.h>
#include <libgnomeui/gnome-dialog.h>
#include <libgnomeui/gnome-dialog-util.h>
#ifdef EAZEL_SERVICES
#include <libtrilobite/libammonite-gtk.h>
#endif
#define NUM_ELEMENTS_IN_ARRAY(_a) (sizeof (_a) / sizeof ((_a)[0]))
#ifdef EAZEL_SERVICES
EazelProxy_UserControl nautilus_mozilla_content_view_user_control = CORBA_OBJECT_NIL;
#endif
struct NautilusMozillaContentViewDetails {
char *uri;
GtkWidget *mozilla;
NautilusView *nautilus_view;
GdkCursor *busy_cursor;
gboolean got_called_by_nautilus;
};
static void nautilus_mozilla_content_view_initialize_class (NautilusMozillaContentViewClass *klass);
static void nautilus_mozilla_content_view_initialize (NautilusMozillaContentView *view);
static void nautilus_mozilla_content_view_destroy (GtkObject *object);
Some build fixes. * acconfig.h: * configure.in: Removed the NAUTILUS_PREFIX that I added. I did it wrong. * libnautilus-extensions/nautilus-file-utilities.h: * libnautilus-extensions/nautilus-file-utilities.c: (nautilus_pixmap_file): * components/hardware/nautilus-hardware-view.c: (setup_overview_form): * components/services/startup/nautilus-view/nautilus-service-startup-view.c: (setup_form_title), (setup_signup_form), (setup_config_form): * libnautilus-extensions/nautilus-icon-canvas-item.c: (map_pixbuf): * libnautilus-extensions/nautilus-icon-factory.c: (make_full_icon_path): * src/nautilus-application.c: (display_caveat): * src/nautilus-property-browser.c: (nautilus_property_browser_initialize), (nautilus_emblem_dialog_new), (make_category_link): * src/nautilus-zoom-control.c: (nautilus_zoom_control_initialize): Replaced most uses of gnome_pixmap_file on "nautilus/" with a call to a new nautilus_pixmap_file in an attempt to make installations where nautilus has a different prefix from gnome-libs work. I now think this is a waste of time, but Mathieu Lacage says this is still an improvement. * components/help/Makefile.am: * components/help/hyperbola-filefmt.c: (fmt_map_entry): Use HYPERBOLA_DATADIR instead of NAUTILUS_PREFIX. * components/websearch/ntl-web-search.c: (web_search_populate_engines): Use WEB_SEARCH_DATADIR instead of NAUTILUS_PREFIX. * components/mozilla/nautilus-mozilla-content-view.c: (nautilus_mozilla_content_view_initialize), (mozilla_content_view_set_busy_cursor), (mozilla_content_view_request_progress_change), (mozilla_content_view_clear_busy_cursor), (mozilla_load_location_callback), (bonobo_mozilla_callback), (mozilla_merge_bonobo_items_callback), (mozilla_title_changed_callback), (mozilla_location_changed_callback), (mozilla_net_status_callback), (mozilla_link_message_callback), (mozilla_progress_callback), (mozilla_open_uri_callback): Took a cut at fixing the Mozilla component for the new API. Ramiro will have to take care of the rest. * components/services/install/lib/Makefile.am: * components/services/time/command-line/Makefile.am: * components/services/time/nautilus-view/Makefile.am: * components/services/time/service/Makefile.am: * components/services/trilobite/libtrilobite/Makefile.am: * components/services/trilobite/sample/command-line/Makefile.am: * components/services/trilobite/sample/service/Makefile.am: * libnautilus/Makefile.am: Updated all ORBit IDL compiles to use IDL_CFLAGS as suggested in the form of a patch by Martijn van Beers. * libnautilus-extensions/Makefile.am: * libnautilus-extensions/nautilus-file-utilities.c: (nautilus_get_user_main_directory), (nautilus_get_pixmap_directory): * libnautilus-extensions/nautilus-link-set.c: (get_link_set_document): * src/Makefile.am: * src/nautilus-property-browser.c: (nautilus_property_browser_drag_data_get), (make_drag_image), (get_xml_path), (make_properties_from_directory): * src/nautilus-link-set-window.c: (get_link_set_names): * src/file-manager/Makefile.am: * src/file-manager/fm-properties-window.c: (get_property_names): Used NAUTILUS_DATADIR and DATADIR instead of NAUTILUS_PREFIX. * libnautilus-extensions/nautilus-file-utilities.h: * libnautilus-extensions/nautilus-file-utilities.c: (nautilus_get_uri_from_local_path): Added a new helper function for use when you have a path and need a URI. This does a better job than just adding a "file://" on the front. * libnautilus-extensions/nautilus-gtk-extensions.h: * libnautilus-extensions/nautilus-gtk-extensions.c: (get_first_callback), (nautilus_gtk_container_get_first_child): * src/nautilus-window-toolbars.c: (setup_button): * src/nautilus-window.c: (replace_special_current_view_in_content_view_menu): Implemented the first_child function and used it where appropriate. * libnautilus-extensions/nautilus-preferences-item.c: (add_icon_themes): Use nautilus_get_pixmap_directory intead of misusing gnome_pixmap_file by calling it on a directory name. * nautilus-installer/src/support.c: (create_pixmap), (create_image): Added FIXMEs since it isn't clear if this code will work with a Nautilus prefix that's not the same as the gnome-libs prefix. * Makefile.am: Tweaked white space.
2000-06-13 19:05:33 +00:00
static void mozilla_load_location_callback (NautilusView *nautilus_view,
const char *location,
NautilusMozillaContentView *view);
/* Mozilla embed widget callbacks */
static void mozilla_title_changed_callback (GtkMozEmbed *mozilla,
gpointer user_data);
static void mozilla_location_changed_callback (GtkMozEmbed *mozilla,
gpointer user_data);
static void mozilla_net_state_callback (GtkMozEmbed *mozilla,
gint state,
guint status,
gpointer user_data);
static void mozilla_net_stop_callback (GtkMozEmbed *mozilla,
gpointer user_data);
static void mozilla_link_message_callback (GtkMozEmbed *mozilla,
gpointer user_data);
static void mozilla_progress_callback (GtkMozEmbed *mozilla,
gint max_progress,
gint current_progress,
gpointer user_data);
static gint mozilla_open_uri_callback (GtkMozEmbed *mozilla,
const char *uri,
gpointer user_data);
static gint mozilla_dom_key_press_callback (GtkMozEmbed *mozilla,
gpointer dom_event,
gpointer user_data);
static gint mozilla_dom_mouse_click_callback (GtkMozEmbed *mozilla,
gpointer dom_event,
gpointer user_data);
/* Other mozilla content view functions */
static void mozilla_content_view_set_busy_cursor (NautilusMozillaContentView *view);
static void mozilla_content_view_clear_busy_cursor (NautilusMozillaContentView *view);
static gboolean mozilla_is_uri_handled_by_nautilus (const char *uri);
static gboolean mozilla_is_uri_handled_by_mozilla (const char *uri);
static char * mozilla_translate_uri_if_needed (NautilusMozillaContentView *view,
const char *uri);
static char * mozilla_untranslate_uri_if_needed (NautilusMozillaContentView *view,
const char *uri);
static void mozilla_content_view_one_time_happenings (void);
static void mozilla_content_view_setup_profile_directory (void);
#ifdef EAZEL_SERVICES
/*
* URL scheme hack for the eazel-services: scheme
*/
static char *
eazel_services_scheme_translate (NautilusMozillaContentView *view,
const char *uri,
gboolean is_retry);
static char *
eazel_services_scheme_untranslate (NautilusMozillaContentView *view,
const char *uri);
#ifdef EAZEL_SERVICES_MOZILLA_MODAL_LOGIN
typedef struct {
NautilusMozillaContentView *view;
char *uri;
} LoginAsyncState;
static void /* AmmonitePromptLoginCb */
eazel_services_prompt_login_cb (
gpointer user_data,
const EazelProxy_User *user,
const EazelProxy_AuthnFailInfo *fail_info
);
#endif /* EAZEL_SERVICES_MOZILLA_MODAL_LOGIN */
#endif /* EAZEL_SERVICES */
static GtkVBoxClass *parent_class = NULL;
static void
nautilus_mozilla_content_view_initialize_class (NautilusMozillaContentViewClass *klass)
{
GtkObjectClass *object_class;
object_class = GTK_OBJECT_CLASS (klass);
parent_class = gtk_type_class (GTK_TYPE_VBOX);
object_class->destroy = nautilus_mozilla_content_view_destroy;
mozilla_content_view_setup_profile_directory ();
}
static void
nautilus_mozilla_content_view_initialize (NautilusMozillaContentView *view)
{
view->details = g_new0 (NautilusMozillaContentViewDetails, 1);
/* Conjure up the beast. May God have mercy on our souls. */
view->details->mozilla = gtk_moz_embed_new ();
/* Do preference/environment setup that needs to happen only once.
* We need to do this right after the first gtkmozembed widget gets
* created, otherwise the mozilla runtime environment is not properly
* setup.
*/
mozilla_content_view_one_time_happenings ();
/* Add callbacks to the beast */
gtk_signal_connect_while_alive (GTK_OBJECT (view->details->mozilla),
"title",
GTK_SIGNAL_FUNC (mozilla_title_changed_callback),
view,
GTK_OBJECT (view->details->mozilla));
gtk_signal_connect_while_alive (GTK_OBJECT (view->details->mozilla),
"location",
GTK_SIGNAL_FUNC (mozilla_location_changed_callback),
view,
GTK_OBJECT (view->details->mozilla));
gtk_signal_connect_while_alive (GTK_OBJECT (view->details->mozilla),
"net_state",
GTK_SIGNAL_FUNC (mozilla_net_state_callback),
view,
GTK_OBJECT (view->details->mozilla));
gtk_signal_connect_while_alive (GTK_OBJECT (view->details->mozilla),
"net_stop",
GTK_SIGNAL_FUNC (mozilla_net_stop_callback),
view,
GTK_OBJECT (view->details->mozilla));
gtk_signal_connect_while_alive (GTK_OBJECT (view->details->mozilla),
"link_message",
GTK_SIGNAL_FUNC (mozilla_link_message_callback),
view,
GTK_OBJECT (view->details->mozilla));
gtk_signal_connect_while_alive (GTK_OBJECT (view->details->mozilla),
"progress",
GTK_SIGNAL_FUNC (mozilla_progress_callback),
view,
GTK_OBJECT (view->details->mozilla));
gtk_signal_connect_while_alive (GTK_OBJECT (view->details->mozilla),
"open_uri",
GTK_SIGNAL_FUNC (mozilla_open_uri_callback),
view,
GTK_OBJECT (view->details->mozilla));
gtk_signal_connect_while_alive (GTK_OBJECT (view->details->mozilla),
"dom_key_press",
GTK_SIGNAL_FUNC (mozilla_dom_key_press_callback),
view,
GTK_OBJECT (view->details->mozilla));
gtk_signal_connect_while_alive (GTK_OBJECT (view->details->mozilla),
"dom_mouse_click",
GTK_SIGNAL_FUNC (mozilla_dom_mouse_click_callback),
view,
GTK_OBJECT (view->details->mozilla));
gtk_box_pack_start (GTK_BOX (view), view->details->mozilla, TRUE, TRUE, 1);
gtk_widget_show (view->details->mozilla);
[removed] [removed] * components/hardware/nautilus-hardware-view.c: (nautilus_hardware_view_initialize), (hardware_view_notify_location_change_callback): * components/hardware/nautilus-hardware-view.h: * components/help/hyperbola-nav-index.c: (hyperbola_navigation_index_select_row): * components/help/hyperbola-nav-search.c: (hyperbola_navigation_search_select_row), (hyperbola_navigation_search_new): * components/html/ntl-web-browser.c: (browser_url_load_done), (browser_vfs_callback), (browser_goto_url_real), (browser_goto_url), (browser_select_url), (browser_title_changed), (browser_notify_location_change), (make_obj): * components/loser/content/main.c: (loser_make_object): * components/loser/content/nautilus-content-loser.c: (nautilus_content_loser_initialize), (loser_notify_location_change_callback): * components/loser/content/nautilus-content-loser.h: * components/loser/sidebar/main.c: (loser_make_object): * components/loser/sidebar/nautilus-sidebar-loser.c: (nautilus_sidebar_loser_initialize), (loser_notify_location_change_callback): * components/mozilla/main.c: (mozilla_make_object): * components/mozilla/nautilus-mozilla-content-view.c: (nautilus_mozilla_content_view_initialize), (mozilla_content_view_request_progress_change), (mozilla_content_view_request_location_change), (mozilla_notify_location_change_callback), (mozilla_title_changed_callback), (mozilla_link_message_callback): * components/mozilla/nautilus-mozilla-content-view.h: * components/music/main.c: (music_view_make_object): * components/music/nautilus-music-view.c: (nautilus_music_view_initialize), (click_column_callback), (music_view_notify_location_change_callback), (nautilus_music_view_drag_data_received): * components/music/nautilus-music-view.h: * components/rpmview/main.c: (rpm_view_make_object): * components/rpmview/nautilus-rpm-view.c: (nautilus_rpm_view_initialize), (rpm_view_notify_location_change_callback): * components/rpmview/nautilus-rpm-view.h: * components/sample/main.c: (sample_make_object): * components/sample/nautilus-sample-content-view.c: (nautilus_sample_content_view_initialize), (sample_notify_location_change_callback): * components/sample/nautilus-sample-content-view.h: * components/services/startup/nautilus-view/main.c: (services_make_object): * components/services/startup/nautilus-view/nautilus-service-startup-view.c: (go_to_uri), (nautilus_service_startup_view_initialize), (service_main_notify_location_change_cb): * components/services/startup/nautilus-view/nautilus-service-startup-view.h: * libnautilus/Makefile.am: * libnautilus/libnautilus.h: * libnautilus/nautilus-content-view-frame.c: [removed] * libnautilus/nautilus-content-view-frame.h: [removed] * libnautilus/nautilus-view-component.idl: * libnautilus/nautilus-view-frame-private.h: * libnautilus/nautilus-view-frame.c: (impl_Nautilus_View_save_state), (impl_Nautilus_View_load_state), (impl_Nautilus_View_notify_location_change), (impl_Nautilus_View_show_properties), (impl_Nautilus_View_notify_selection_change), (impl_Nautilus_View_stop_location_change), (impl_Nautilus_View__destroy), (impl_Nautilus_View__create), (nautilus_view_initialize_class), (nautilus_view_initialize), (nautilus_view_new), (nautilus_view_new_from_bonobo_control), (get_view_frame), (nautilus_view_request_location_change), (nautilus_view_request_selection_change), (nautilus_view_request_status_change), (nautilus_view_request_progress_change), (nautilus_view_request_title_change), (nautilus_view_get_bonobo_control), (nautilus_view_get_main_window): * libnautilus/nautilus-view-frame.h: * src/Makefile.am: * src/file-manager/fm-directory-view.c: (get_bonobo_control), (fm_directory_view_initialize), (display_selection_info), (fm_directory_view_send_selection_change), (notify_location_change_callback), (stop_location_change_callback), (done_loading), (fm_directory_view_activate_file_internal), (finish_loading_uri): * src/file-manager/fm-directory-view.h: * src/ntl-app.c: (impl_Nautilus_Application_create_object): * src/ntl-content-view.c: [removed] * src/ntl-content-view.h: [removed] * src/ntl-uri-map.c: (make_oaf_query_with_known_mime_type), (make_oaf_query_with_uri_scheme_only): * src/ntl-view-frame-svr.c: (impl_Nautilus_ViewFrame__destroy), (impl_Nautilus_ViewFrame__create), (impl_Nautilus_ViewFrame__get_main_window), (impl_Nautilus_ViewFrame_request_location_change), (impl_Nautilus_ViewFrame_request_selection_change), (impl_Nautilus_ViewFrame_request_status_change), (impl_Nautilus_ViewFrame_request_progress_change), (impl_Nautilus_ViewFrame_request_title_change): * src/ntl-view-private.h: * src/ntl-view.c: (nautilus_view_frame_class_init), (nautilus_view_frame_set_arg), (nautilus_view_frame_get_arg), (nautilus_view_frame_request_location_change), (nautilus_view_frame_request_selection_change), (nautilus_view_frame_request_status_change), (nautilus_view_frame_request_progress_change), (nautilus_view_frame_request_title_change), (nautilus_view_frame_set_label), (nautilus_view_frame_activate): * src/ntl-view.h: * src/ntl-window-msgs.c: (nautilus_window_request_title_change), (nautilus_window_load_meta_view), (nautilus_window_request_location_change), (nautilus_window_load_content_view): * src/ntl-window-msgs.h: * src/ntl-window-private.h: * src/ntl-window.c: (nautilus_window_request_title_change_callback), (nautilus_window_connect_content_view), (nautilus_window_real_set_content_view): Got rid of ContentView and ContentViewFrame.
2000-05-25 01:49:32 +00:00
view->details->nautilus_view = nautilus_view_new (GTK_WIDGET (view));
gtk_signal_connect_while_alive (GTK_OBJECT (view->details->nautilus_view),
"load_location",
GTK_SIGNAL_FUNC (mozilla_load_location_callback),
view,
GTK_OBJECT (view->details->mozilla));
gtk_widget_show_all (GTK_WIDGET (view));
}
static void
nautilus_mozilla_content_view_destroy (GtkObject *object)
{
NautilusMozillaContentView *view;
#ifdef DEBUG_ramiro
g_print ("%s()\n", __FUNCTION__);
#endif
view = NAUTILUS_MOZILLA_CONTENT_VIEW (object);
Removed a bunch of incorrect calls to bonobo_object_unref. An error in the * components/hardware/nautilus-hardware-view.c: (nautilus_hardware_view_destroy): * components/loser/content/nautilus-content-loser.c: (nautilus_content_loser_destroy): * components/loser/sidebar/nautilus-sidebar-loser.c: (nautilus_sidebar_loser_destroy): * components/mozilla/nautilus-mozilla-content-view.c: (nautilus_mozilla_content_view_destroy): * components/music/nautilus-music-view.c: (nautilus_music_view_destroy): * components/rpmview/nautilus-rpm-view.c: (nautilus_rpm_view_destroy): * components/sample/nautilus-sample-content-view.c: (nautilus_sample_content_view_destroy): * components/services/time/nautilus-view/trilobite-eazel-time-view.c: (trilobite_eazel_time_view_destroy): * components/tree/nautilus-tree-view.c: (nautilus_tree_view_destroy): Removed a bunch of incorrect calls to bonobo_object_unref. An error in the sample can be an insidious thing. * components/tree/main.c: (tree_object_destroyed), (tree_make_object), (main): Removed some stray debugging stuff. * libnautilus-extensions/Makefile.am: Got rid of the grid * libnautilus-extensions/nautilus-icon-private.h: Got rid of the grid. * libnautilus-extensions/nautilus-icon-container.c: (keyboard_icon_reveal_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (get_all_icon_bounds): Added shared function. (update_scroll_region): Renamed set_scroll_region and made it use the shared function. Also got rid of grid code. (resort): Got rid of grid code. (lay_down_icons): Got rid of grid code. (relayout): Made it lay down new icons before doing any layout work. Also made sure it doesn't do the resort while stretching. (reload_icon_positions): Got rid of grid code. (rubberband_select): Got rid of grid code. This was the one place that it might have made things a little faster but probably not due to the complexity of what it was doing. (rubberband_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (destroy): Got rid of grid code. (world_width_changed): Got rid of grid code. (nautilus_icon_container_initialize): Got rid of grid code and an extra idle cycle that wasn't needed. (nautilus_icon_container_clear): Got rid of grid code and added code to update the scroll region on clear. (icon_destroy): Got rid of grid code. (assign_icon_position), (finish_adding_icon), (finish_adding_new_icons), (finish_adding_new_icons_callback), (nautilus_icon_container_add): Replaced old idle code with something specific to adding new icons. This does the proper layout for manual as well as automatic layout cases. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_initialize_class): Made two signals instead of one. One for when the background's settings change and another for when the appearance changes. (nautilus_background_set_color): Emit both signals. (load_image_callback): Emit only the appearance change signal. (nautilus_background_set_tile_image_uri): Emit both signals. (nautilus_get_widget_background): Connect to the appearance_changed signal. * libnautilus-extensions/nautilus-directory-background.c: (nautilus_connect_background_to_directory_metadata): Connect to the settings_changed signal. * src/file-manager/fm-directory-view.c: (fm_directory_view_real_merge_menus): Connect to the settings_changed signal. * src/nautilus-sidebar.c: (nautilus_sidebar_update_info): Connect to the appearance_changed signal. * components/music/nautilus-music-view.c: (nautilus_music_view_set_up_background): Connect to the settings_changed signal. * HACKING: Gratuitious reformatting. * RENAMING: Added notes about how we do renaming, at the request of one of the hackers. * nautilus-clean.sh: Added nautilus-tree-view to the things that are killed, and made gratuitous changes to the script.
2000-06-27 00:52:50 +00:00
g_free (view->details->uri);
Removed a bunch of incorrect calls to bonobo_object_unref. An error in the * components/hardware/nautilus-hardware-view.c: (nautilus_hardware_view_destroy): * components/loser/content/nautilus-content-loser.c: (nautilus_content_loser_destroy): * components/loser/sidebar/nautilus-sidebar-loser.c: (nautilus_sidebar_loser_destroy): * components/mozilla/nautilus-mozilla-content-view.c: (nautilus_mozilla_content_view_destroy): * components/music/nautilus-music-view.c: (nautilus_music_view_destroy): * components/rpmview/nautilus-rpm-view.c: (nautilus_rpm_view_destroy): * components/sample/nautilus-sample-content-view.c: (nautilus_sample_content_view_destroy): * components/services/time/nautilus-view/trilobite-eazel-time-view.c: (trilobite_eazel_time_view_destroy): * components/tree/nautilus-tree-view.c: (nautilus_tree_view_destroy): Removed a bunch of incorrect calls to bonobo_object_unref. An error in the sample can be an insidious thing. * components/tree/main.c: (tree_object_destroyed), (tree_make_object), (main): Removed some stray debugging stuff. * libnautilus-extensions/Makefile.am: Got rid of the grid * libnautilus-extensions/nautilus-icon-private.h: Got rid of the grid. * libnautilus-extensions/nautilus-icon-container.c: (keyboard_icon_reveal_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (get_all_icon_bounds): Added shared function. (update_scroll_region): Renamed set_scroll_region and made it use the shared function. Also got rid of grid code. (resort): Got rid of grid code. (lay_down_icons): Got rid of grid code. (relayout): Made it lay down new icons before doing any layout work. Also made sure it doesn't do the resort while stretching. (reload_icon_positions): Got rid of grid code. (rubberband_select): Got rid of grid code. This was the one place that it might have made things a little faster but probably not due to the complexity of what it was doing. (rubberband_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (destroy): Got rid of grid code. (world_width_changed): Got rid of grid code. (nautilus_icon_container_initialize): Got rid of grid code and an extra idle cycle that wasn't needed. (nautilus_icon_container_clear): Got rid of grid code and added code to update the scroll region on clear. (icon_destroy): Got rid of grid code. (assign_icon_position), (finish_adding_icon), (finish_adding_new_icons), (finish_adding_new_icons_callback), (nautilus_icon_container_add): Replaced old idle code with something specific to adding new icons. This does the proper layout for manual as well as automatic layout cases. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_initialize_class): Made two signals instead of one. One for when the background's settings change and another for when the appearance changes. (nautilus_background_set_color): Emit both signals. (load_image_callback): Emit only the appearance change signal. (nautilus_background_set_tile_image_uri): Emit both signals. (nautilus_get_widget_background): Connect to the appearance_changed signal. * libnautilus-extensions/nautilus-directory-background.c: (nautilus_connect_background_to_directory_metadata): Connect to the settings_changed signal. * src/file-manager/fm-directory-view.c: (fm_directory_view_real_merge_menus): Connect to the settings_changed signal. * src/nautilus-sidebar.c: (nautilus_sidebar_update_info): Connect to the appearance_changed signal. * components/music/nautilus-music-view.c: (nautilus_music_view_set_up_background): Connect to the settings_changed signal. * HACKING: Gratuitious reformatting. * RENAMING: Added notes about how we do renaming, at the request of one of the hackers. * nautilus-clean.sh: Added nautilus-tree-view to the things that are killed, and made gratuitous changes to the script.
2000-06-27 00:52:50 +00:00
if (view->details->busy_cursor != NULL) {
gdk_cursor_destroy (view->details->busy_cursor);
}
g_free (view->details);
Removed a bunch of incorrect calls to bonobo_object_unref. An error in the * components/hardware/nautilus-hardware-view.c: (nautilus_hardware_view_destroy): * components/loser/content/nautilus-content-loser.c: (nautilus_content_loser_destroy): * components/loser/sidebar/nautilus-sidebar-loser.c: (nautilus_sidebar_loser_destroy): * components/mozilla/nautilus-mozilla-content-view.c: (nautilus_mozilla_content_view_destroy): * components/music/nautilus-music-view.c: (nautilus_music_view_destroy): * components/rpmview/nautilus-rpm-view.c: (nautilus_rpm_view_destroy): * components/sample/nautilus-sample-content-view.c: (nautilus_sample_content_view_destroy): * components/services/time/nautilus-view/trilobite-eazel-time-view.c: (trilobite_eazel_time_view_destroy): * components/tree/nautilus-tree-view.c: (nautilus_tree_view_destroy): Removed a bunch of incorrect calls to bonobo_object_unref. An error in the sample can be an insidious thing. * components/tree/main.c: (tree_object_destroyed), (tree_make_object), (main): Removed some stray debugging stuff. * libnautilus-extensions/Makefile.am: Got rid of the grid * libnautilus-extensions/nautilus-icon-private.h: Got rid of the grid. * libnautilus-extensions/nautilus-icon-container.c: (keyboard_icon_reveal_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (get_all_icon_bounds): Added shared function. (update_scroll_region): Renamed set_scroll_region and made it use the shared function. Also got rid of grid code. (resort): Got rid of grid code. (lay_down_icons): Got rid of grid code. (relayout): Made it lay down new icons before doing any layout work. Also made sure it doesn't do the resort while stretching. (reload_icon_positions): Got rid of grid code. (rubberband_select): Got rid of grid code. This was the one place that it might have made things a little faster but probably not due to the complexity of what it was doing. (rubberband_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (destroy): Got rid of grid code. (world_width_changed): Got rid of grid code. (nautilus_icon_container_initialize): Got rid of grid code and an extra idle cycle that wasn't needed. (nautilus_icon_container_clear): Got rid of grid code and added code to update the scroll region on clear. (icon_destroy): Got rid of grid code. (assign_icon_position), (finish_adding_icon), (finish_adding_new_icons), (finish_adding_new_icons_callback), (nautilus_icon_container_add): Replaced old idle code with something specific to adding new icons. This does the proper layout for manual as well as automatic layout cases. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_initialize_class): Made two signals instead of one. One for when the background's settings change and another for when the appearance changes. (nautilus_background_set_color): Emit both signals. (load_image_callback): Emit only the appearance change signal. (nautilus_background_set_tile_image_uri): Emit both signals. (nautilus_get_widget_background): Connect to the appearance_changed signal. * libnautilus-extensions/nautilus-directory-background.c: (nautilus_connect_background_to_directory_metadata): Connect to the settings_changed signal. * src/file-manager/fm-directory-view.c: (fm_directory_view_real_merge_menus): Connect to the settings_changed signal. * src/nautilus-sidebar.c: (nautilus_sidebar_update_info): Connect to the appearance_changed signal. * components/music/nautilus-music-view.c: (nautilus_music_view_set_up_background): Connect to the settings_changed signal. * HACKING: Gratuitious reformatting. * RENAMING: Added notes about how we do renaming, at the request of one of the hackers. * nautilus-clean.sh: Added nautilus-tree-view to the things that are killed, and made gratuitous changes to the script.
2000-06-27 00:52:50 +00:00
if (GTK_OBJECT_CLASS (parent_class)->destroy) {
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
Removed a bunch of incorrect calls to bonobo_object_unref. An error in the * components/hardware/nautilus-hardware-view.c: (nautilus_hardware_view_destroy): * components/loser/content/nautilus-content-loser.c: (nautilus_content_loser_destroy): * components/loser/sidebar/nautilus-sidebar-loser.c: (nautilus_sidebar_loser_destroy): * components/mozilla/nautilus-mozilla-content-view.c: (nautilus_mozilla_content_view_destroy): * components/music/nautilus-music-view.c: (nautilus_music_view_destroy): * components/rpmview/nautilus-rpm-view.c: (nautilus_rpm_view_destroy): * components/sample/nautilus-sample-content-view.c: (nautilus_sample_content_view_destroy): * components/services/time/nautilus-view/trilobite-eazel-time-view.c: (trilobite_eazel_time_view_destroy): * components/tree/nautilus-tree-view.c: (nautilus_tree_view_destroy): Removed a bunch of incorrect calls to bonobo_object_unref. An error in the sample can be an insidious thing. * components/tree/main.c: (tree_object_destroyed), (tree_make_object), (main): Removed some stray debugging stuff. * libnautilus-extensions/Makefile.am: Got rid of the grid * libnautilus-extensions/nautilus-icon-private.h: Got rid of the grid. * libnautilus-extensions/nautilus-icon-container.c: (keyboard_icon_reveal_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (get_all_icon_bounds): Added shared function. (update_scroll_region): Renamed set_scroll_region and made it use the shared function. Also got rid of grid code. (resort): Got rid of grid code. (lay_down_icons): Got rid of grid code. (relayout): Made it lay down new icons before doing any layout work. Also made sure it doesn't do the resort while stretching. (reload_icon_positions): Got rid of grid code. (rubberband_select): Got rid of grid code. This was the one place that it might have made things a little faster but probably not due to the complexity of what it was doing. (rubberband_timeout_callback): Took out unneeded use of thread locking macros. Maybe someday I'll regret this, but we can add them back then. (destroy): Got rid of grid code. (world_width_changed): Got rid of grid code. (nautilus_icon_container_initialize): Got rid of grid code and an extra idle cycle that wasn't needed. (nautilus_icon_container_clear): Got rid of grid code and added code to update the scroll region on clear. (icon_destroy): Got rid of grid code. (assign_icon_position), (finish_adding_icon), (finish_adding_new_icons), (finish_adding_new_icons_callback), (nautilus_icon_container_add): Replaced old idle code with something specific to adding new icons. This does the proper layout for manual as well as automatic layout cases. * libnautilus-extensions/nautilus-background.h: * libnautilus-extensions/nautilus-background.c: (nautilus_background_initialize_class): Made two signals instead of one. One for when the background's settings change and another for when the appearance changes. (nautilus_background_set_color): Emit both signals. (load_image_callback): Emit only the appearance change signal. (nautilus_background_set_tile_image_uri): Emit both signals. (nautilus_get_widget_background): Connect to the appearance_changed signal. * libnautilus-extensions/nautilus-directory-background.c: (nautilus_connect_background_to_directory_metadata): Connect to the settings_changed signal. * src/file-manager/fm-directory-view.c: (fm_directory_view_real_merge_menus): Connect to the settings_changed signal. * src/nautilus-sidebar.c: (nautilus_sidebar_update_info): Connect to the appearance_changed signal. * components/music/nautilus-music-view.c: (nautilus_music_view_set_up_background): Connect to the settings_changed signal. * HACKING: Gratuitious reformatting. * RENAMING: Added notes about how we do renaming, at the request of one of the hackers. * nautilus-clean.sh: Added nautilus-tree-view to the things that are killed, and made gratuitous changes to the script.
2000-06-27 00:52:50 +00:00
}
}
/**
* nautilus_mozilla_content_view_get_nautilus_view:
*
* Return the NautilusView object associated with this view; this
* is needed to export the view via CORBA/Bonobo.
* @view: NautilusMozillaContentView to get the nautilus_view from..
*
**/
[removed] [removed] * components/hardware/nautilus-hardware-view.c: (nautilus_hardware_view_initialize), (hardware_view_notify_location_change_callback): * components/hardware/nautilus-hardware-view.h: * components/help/hyperbola-nav-index.c: (hyperbola_navigation_index_select_row): * components/help/hyperbola-nav-search.c: (hyperbola_navigation_search_select_row), (hyperbola_navigation_search_new): * components/html/ntl-web-browser.c: (browser_url_load_done), (browser_vfs_callback), (browser_goto_url_real), (browser_goto_url), (browser_select_url), (browser_title_changed), (browser_notify_location_change), (make_obj): * components/loser/content/main.c: (loser_make_object): * components/loser/content/nautilus-content-loser.c: (nautilus_content_loser_initialize), (loser_notify_location_change_callback): * components/loser/content/nautilus-content-loser.h: * components/loser/sidebar/main.c: (loser_make_object): * components/loser/sidebar/nautilus-sidebar-loser.c: (nautilus_sidebar_loser_initialize), (loser_notify_location_change_callback): * components/mozilla/main.c: (mozilla_make_object): * components/mozilla/nautilus-mozilla-content-view.c: (nautilus_mozilla_content_view_initialize), (mozilla_content_view_request_progress_change), (mozilla_content_view_request_location_change), (mozilla_notify_location_change_callback), (mozilla_title_changed_callback), (mozilla_link_message_callback): * components/mozilla/nautilus-mozilla-content-view.h: * components/music/main.c: (music_view_make_object): * components/music/nautilus-music-view.c: (nautilus_music_view_initialize), (click_column_callback), (music_view_notify_location_change_callback), (nautilus_music_view_drag_data_received): * components/music/nautilus-music-view.h: * components/rpmview/main.c: (rpm_view_make_object): * components/rpmview/nautilus-rpm-view.c: (nautilus_rpm_view_initialize), (rpm_view_notify_location_change_callback): * components/rpmview/nautilus-rpm-view.h: * components/sample/main.c: (sample_make_object): * components/sample/nautilus-sample-content-view.c: (nautilus_sample_content_view_initialize), (sample_notify_location_change_callback): * components/sample/nautilus-sample-content-view.h: * components/services/startup/nautilus-view/main.c: (services_make_object): * components/services/startup/nautilus-view/nautilus-service-startup-view.c: (go_to_uri), (nautilus_service_startup_view_initialize), (service_main_notify_location_change_cb): * components/services/startup/nautilus-view/nautilus-service-startup-view.h: * libnautilus/Makefile.am: * libnautilus/libnautilus.h: * libnautilus/nautilus-content-view-frame.c: [removed] * libnautilus/nautilus-content-view-frame.h: [removed] * libnautilus/nautilus-view-component.idl: * libnautilus/nautilus-view-frame-private.h: * libnautilus/nautilus-view-frame.c: (impl_Nautilus_View_save_state), (impl_Nautilus_View_load_state), (impl_Nautilus_View_notify_location_change), (impl_Nautilus_View_show_properties), (impl_Nautilus_View_notify_selection_change), (impl_Nautilus_View_stop_location_change), (impl_Nautilus_View__destroy), (impl_Nautilus_View__create), (nautilus_view_initialize_class), (nautilus_view_initialize), (nautilus_view_new), (nautilus_view_new_from_bonobo_control), (get_view_frame), (nautilus_view_request_location_change), (nautilus_view_request_selection_change), (nautilus_view_request_status_change), (nautilus_view_request_progress_change), (nautilus_view_request_title_change), (nautilus_view_get_bonobo_control), (nautilus_view_get_main_window): * libnautilus/nautilus-view-frame.h: * src/Makefile.am: * src/file-manager/fm-directory-view.c: (get_bonobo_control), (fm_directory_view_initialize), (display_selection_info), (fm_directory_view_send_selection_change), (notify_location_change_callback), (stop_location_change_callback), (done_loading), (fm_directory_view_activate_file_internal), (finish_loading_uri): * src/file-manager/fm-directory-view.h: * src/ntl-app.c: (impl_Nautilus_Application_create_object): * src/ntl-content-view.c: [removed] * src/ntl-content-view.h: [removed] * src/ntl-uri-map.c: (make_oaf_query_with_known_mime_type), (make_oaf_query_with_uri_scheme_only): * src/ntl-view-frame-svr.c: (impl_Nautilus_ViewFrame__destroy), (impl_Nautilus_ViewFrame__create), (impl_Nautilus_ViewFrame__get_main_window), (impl_Nautilus_ViewFrame_request_location_change), (impl_Nautilus_ViewFrame_request_selection_change), (impl_Nautilus_ViewFrame_request_status_change), (impl_Nautilus_ViewFrame_request_progress_change), (impl_Nautilus_ViewFrame_request_title_change): * src/ntl-view-private.h: * src/ntl-view.c: (nautilus_view_frame_class_init), (nautilus_view_frame_set_arg), (nautilus_view_frame_get_arg), (nautilus_view_frame_request_location_change), (nautilus_view_frame_request_selection_change), (nautilus_view_frame_request_status_change), (nautilus_view_frame_request_progress_change), (nautilus_view_frame_request_title_change), (nautilus_view_frame_set_label), (nautilus_view_frame_activate): * src/ntl-view.h: * src/ntl-window-msgs.c: (nautilus_window_request_title_change), (nautilus_window_load_meta_view), (nautilus_window_request_location_change), (nautilus_window_load_content_view): * src/ntl-window-msgs.h: * src/ntl-window-private.h: * src/ntl-window.c: (nautilus_window_request_title_change_callback), (nautilus_window_connect_content_view), (nautilus_window_real_set_content_view): Got rid of ContentView and ContentViewFrame.
2000-05-25 01:49:32 +00:00
NautilusView *
nautilus_mozilla_content_view_get_nautilus_view (NautilusMozillaContentView *view)
{
return view->details->nautilus_view;
}
/**
* mozilla_vfs_read_callback:
*
* Read data from buffer and copy into mozilla stream.
**/
static char vfs_read_buf[40960];
static void
mozilla_vfs_read_callback (GnomeVFSAsyncHandle *handle, GnomeVFSResult result, gpointer buffer,
GnomeVFSFileSize bytes_requested,
GnomeVFSFileSize bytes_read,
gpointer data)
{
NautilusMozillaContentView *view = data;
#ifdef DEBUG_ramiro
g_print ("mozilla_vfs_read_callback: %ld/%ld bytes\n", (long) bytes_read, (long) bytes_requested);
#endif
nautilus_view_report_load_underway (view->details->nautilus_view);
if (bytes_read != 0) {
gtk_moz_embed_append_data (GTK_MOZ_EMBED (view->details->mozilla), buffer, bytes_read);
}
if (bytes_read == 0 || result != GNOME_VFS_OK) {
gtk_moz_embed_close_stream (GTK_MOZ_EMBED (view->details->mozilla));
gnome_vfs_async_close (handle, (GnomeVFSAsyncCloseCallback) gtk_true, NULL);
nautilus_view_report_load_complete (view->details->nautilus_view);
return;
}
gnome_vfs_async_read (handle, vfs_read_buf, sizeof (vfs_read_buf), mozilla_vfs_read_callback, view);
}
/**
* mozilla_vfs_callback:
*
* Callback for gnome_vfs_async_open. Attempt to read data from handle
* and pass to mozilla streaming callback.
*
**/
static void
mozilla_vfs_callback (GnomeVFSAsyncHandle *handle, GnomeVFSResult result, gpointer data)
{
NautilusMozillaContentView *view = data;
#ifdef DEBUG_ramiro
g_print ("mozilla_vfs_callback, result was %s\n", gnome_vfs_result_to_string (result));
#endif
if (result != GNOME_VFS_OK)
{
nautilus_view_report_load_failed (view->details->nautilus_view);
gtk_moz_embed_close_stream (GTK_MOZ_EMBED (view->details->mozilla));
} else {
gtk_moz_embed_open_stream (GTK_MOZ_EMBED (view->details->mozilla), "file://", "text/html");
gnome_vfs_async_read (handle, vfs_read_buf, sizeof (vfs_read_buf), mozilla_vfs_read_callback, view);
}
}
#if 0
/* Check whether two uris are "equal". Equal means:
*
* Same uri regardless of mozilla canonicalization
*
* What happens is that mozilla internall canonicalizes
* uris and appends trailing slashes to those that it
* knows to be directories. Unfortunately this is
* different from Nautilus.
*/
static gboolean
uris_are_equal (const char *uri_one, const char *uri_two)
{
guint length_one;
guint length_two;
if (uri_one == NULL && uri_two == NULL) {
return TRUE;
}
if (uri_one == NULL || uri_two == NULL) {
return FALSE;
}
length_one = strlen (uri_one);
length_two = strlen (uri_two);
if (length_one == 0 && length_two == 0) {
return TRUE;
}
if (length_one == 0 || length_two == 0) {
return FALSE;
}
/* Drop the trailing slashes */
if (uri_one[length_one - 1] == '/') {
length_one--;
}
if (uri_two[length_two - 1] == '/') {
length_two--;
}
if (length_one != length_two) {
return FALSE;
}
return strncmp (uri_one, uri_two, MIN (length_one, length_two)) == 0;
}
#endif
/**
* nautilus_mozilla_content_view_load_uri:
*
* Load the resource pointed to by the specified URI.
* @view: NautilusMozillaContentView to get the nautilus_view from.
*
**/
void
nautilus_mozilla_content_view_load_uri (NautilusMozillaContentView *view,
const char *uri)
{
GnomeVFSAsyncHandle *async_handle;
gboolean same_uri = FALSE;
g_assert (uri != NULL);
view->details->got_called_by_nautilus = TRUE;
/* Check whether its the same uri. Ignore the mozilla
* added canonicalization.
*/
/* FIXME bugzilla.eazel.com 2780:
* Reload is broken.
*/
/* same_uri = uris_are_equal (view->details->uri, uri); */
same_uri = FALSE;
if (view->details->uri) {
g_free (view->details->uri);
}
view->details->uri = g_strdup (uri);
#ifdef DEBUG_ramiro
g_print ("nautilus_mozilla_content_view_load_uri (uri = %s, same = %d)\n",
view->details->uri, same_uri);
#endif
/* If the request can be handled by mozilla, pass the uri as is. Otherwise,
* use gnome-vfs to open the uri and later stream the data into the gtkmozembed
* widget.
*/
if (mozilla_is_uri_handled_by_mozilla (uri)) {
if (same_uri) {
gtk_moz_embed_reload (GTK_MOZ_EMBED (view->details->mozilla),
GTK_MOZ_EMBED_FLAG_RELOADBYPASSCACHE);
}
else {
gtk_moz_embed_load_url (GTK_MOZ_EMBED (view->details->mozilla),
view->details->uri);
}
} else {
nautilus_view_report_load_underway (view->details->nautilus_view);
gnome_vfs_async_open (&async_handle, uri, GNOME_VFS_OPEN_READ, mozilla_vfs_callback, view);
}
}
static void
mozilla_content_view_set_busy_cursor (NautilusMozillaContentView *view)
{
g_return_if_fail (NAUTILUS_IS_MOZILLA_CONTENT_VIEW (view));
if (!view->details->busy_cursor) {
view->details->busy_cursor = gdk_cursor_new (GDK_WATCH);
}
g_assert (view->details->busy_cursor != NULL);
g_assert (GTK_WIDGET_REALIZED (GTK_WIDGET (view->details->mozilla)));
gdk_window_set_cursor (GTK_WIDGET (view->details->mozilla)->window,
view->details->busy_cursor);
gdk_flush ();
}
static void
mozilla_content_view_clear_busy_cursor (NautilusMozillaContentView *view)
{
g_return_if_fail (NAUTILUS_IS_MOZILLA_CONTENT_VIEW (view));
g_assert (GTK_WIDGET_REALIZED (GTK_WIDGET (view->details->mozilla)));
gdk_window_set_cursor (GTK_WIDGET (view->details->mozilla)->window, NULL);
}
static void
Some build fixes. * acconfig.h: * configure.in: Removed the NAUTILUS_PREFIX that I added. I did it wrong. * libnautilus-extensions/nautilus-file-utilities.h: * libnautilus-extensions/nautilus-file-utilities.c: (nautilus_pixmap_file): * components/hardware/nautilus-hardware-view.c: (setup_overview_form): * components/services/startup/nautilus-view/nautilus-service-startup-view.c: (setup_form_title), (setup_signup_form), (setup_config_form): * libnautilus-extensions/nautilus-icon-canvas-item.c: (map_pixbuf): * libnautilus-extensions/nautilus-icon-factory.c: (make_full_icon_path): * src/nautilus-application.c: (display_caveat): * src/nautilus-property-browser.c: (nautilus_property_browser_initialize), (nautilus_emblem_dialog_new), (make_category_link): * src/nautilus-zoom-control.c: (nautilus_zoom_control_initialize): Replaced most uses of gnome_pixmap_file on "nautilus/" with a call to a new nautilus_pixmap_file in an attempt to make installations where nautilus has a different prefix from gnome-libs work. I now think this is a waste of time, but Mathieu Lacage says this is still an improvement. * components/help/Makefile.am: * components/help/hyperbola-filefmt.c: (fmt_map_entry): Use HYPERBOLA_DATADIR instead of NAUTILUS_PREFIX. * components/websearch/ntl-web-search.c: (web_search_populate_engines): Use WEB_SEARCH_DATADIR instead of NAUTILUS_PREFIX. * components/mozilla/nautilus-mozilla-content-view.c: (nautilus_mozilla_content_view_initialize), (mozilla_content_view_set_busy_cursor), (mozilla_content_view_request_progress_change), (mozilla_content_view_clear_busy_cursor), (mozilla_load_location_callback), (bonobo_mozilla_callback), (mozilla_merge_bonobo_items_callback), (mozilla_title_changed_callback), (mozilla_location_changed_callback), (mozilla_net_status_callback), (mozilla_link_message_callback), (mozilla_progress_callback), (mozilla_open_uri_callback): Took a cut at fixing the Mozilla component for the new API. Ramiro will have to take care of the rest. * components/services/install/lib/Makefile.am: * components/services/time/command-line/Makefile.am: * components/services/time/nautilus-view/Makefile.am: * components/services/time/service/Makefile.am: * components/services/trilobite/libtrilobite/Makefile.am: * components/services/trilobite/sample/command-line/Makefile.am: * components/services/trilobite/sample/service/Makefile.am: * libnautilus/Makefile.am: Updated all ORBit IDL compiles to use IDL_CFLAGS as suggested in the form of a patch by Martijn van Beers. * libnautilus-extensions/Makefile.am: * libnautilus-extensions/nautilus-file-utilities.c: (nautilus_get_user_main_directory), (nautilus_get_pixmap_directory): * libnautilus-extensions/nautilus-link-set.c: (get_link_set_document): * src/Makefile.am: * src/nautilus-property-browser.c: (nautilus_property_browser_drag_data_get), (make_drag_image), (get_xml_path), (make_properties_from_directory): * src/nautilus-link-set-window.c: (get_link_set_names): * src/file-manager/Makefile.am: * src/file-manager/fm-properties-window.c: (get_property_names): Used NAUTILUS_DATADIR and DATADIR instead of NAUTILUS_PREFIX. * libnautilus-extensions/nautilus-file-utilities.h: * libnautilus-extensions/nautilus-file-utilities.c: (nautilus_get_uri_from_local_path): Added a new helper function for use when you have a path and need a URI. This does a better job than just adding a "file://" on the front. * libnautilus-extensions/nautilus-gtk-extensions.h: * libnautilus-extensions/nautilus-gtk-extensions.c: (get_first_callback), (nautilus_gtk_container_get_first_child): * src/nautilus-window-toolbars.c: (setup_button): * src/nautilus-window.c: (replace_special_current_view_in_content_view_menu): Implemented the first_child function and used it where appropriate. * libnautilus-extensions/nautilus-preferences-item.c: (add_icon_themes): Use nautilus_get_pixmap_directory intead of misusing gnome_pixmap_file by calling it on a directory name. * nautilus-installer/src/support.c: (create_pixmap), (create_image): Added FIXMEs since it isn't clear if this code will work with a Nautilus prefix that's not the same as the gnome-libs prefix. * Makefile.am: Tweaked white space.
2000-06-13 19:05:33 +00:00
mozilla_load_location_callback (NautilusView *nautilus_view,
const char *location,
NautilusMozillaContentView *view)
{
char *translated_location;
g_assert (nautilus_view == view->details->nautilus_view);
translated_location = mozilla_translate_uri_if_needed (view, location);
if (translated_location) {
#ifdef DEBUG_ramiro
g_print ("%s(%s,%s)\n", __FUNCTION__, location, translated_location);
#endif
nautilus_view_report_load_underway (nautilus_view);
nautilus_mozilla_content_view_load_uri (view, translated_location);
g_free (translated_location);
} else {
nautilus_view_report_load_failed ( nautilus_view);
}
}
/* Mozilla embed widget callbacks */
static void
mozilla_title_changed_callback (GtkMozEmbed *mozilla, gpointer user_data)
{
NautilusMozillaContentView *view;
char *new_title;
view = NAUTILUS_MOZILLA_CONTENT_VIEW (user_data);
g_assert (GTK_MOZ_EMBED (mozilla) == GTK_MOZ_EMBED (view->details->mozilla));
new_title = gtk_moz_embed_get_title (GTK_MOZ_EMBED (view->details->mozilla));
if (new_title != NULL && strcmp (new_title, "") != 0) {
nautilus_view_set_title (view->details->nautilus_view,
new_title);
}
g_free (new_title);
}
static gboolean
mozilla_uris_differ_only_by_fragment_identifier (const char *uri1, const char *uri2)
{
char *uri1_hash;
char *uri2_hash;
gboolean ret = FALSE;
uri1_hash = strchr (uri1, '#');
uri2_hash = strchr (uri2, '#');
if (uri1_hash == NULL && uri2_hash == NULL) {
/* neither has a fragment identifier - return true
* only if they match exactly
*/
ret = (strcasecmp (uri1, uri2) == 0);
} else if (uri1_hash == NULL) {
/* only the second has an fragment identifier - return
* true only if the part before the fragment
* identifier matches the first URI
*/
ret = (strncasecmp (uri1, uri2, uri2_hash - uri2) == 0);
} else if (uri2_hash == NULL) {
/* only the first has a fragment identifier - return
* true only if the part before the fragment
* identifier matches the second URI
*/
ret = (strncasecmp (uri1, uri2, uri1_hash - uri1) == 0);
} else if (uri1_hash - uri1 == uri2_hash - uri2) {
/* both have a fragment identifier - return true only
* if the parts before the fragment identifier match
*/
ret = (strncasecmp (uri1, uri2, uri1_hash - uri1) == 0);
}
#ifdef DEBUG_ramiro
if (ret) {
g_print("%s: returning TRUE for URI's '%s' and '%s'\n", __FUNCTION__, uri1, uri2);
}
#endif
return ret;
}
static void
mozilla_location_changed_callback (GtkMozEmbed *mozilla, gpointer user_data)
{
NautilusMozillaContentView *view;
char *new_location;
view = NAUTILUS_MOZILLA_CONTENT_VIEW (user_data);
g_assert (GTK_MOZ_EMBED (mozilla) == GTK_MOZ_EMBED (view->details->mozilla));
new_location = gtk_moz_embed_get_location (GTK_MOZ_EMBED (view->details->mozilla));
#ifdef DEBUG_ramiro
g_print ("mozilla_location_changed_callback (%s)\n", new_location);
#endif
/* If we only changed anchors in the same page, we should
report some fake progress to Nautilus. */
if (mozilla_uris_differ_only_by_fragment_identifier (view->details->uri,
new_location)) {
nautilus_view_report_load_underway (view->details->nautilus_view);
nautilus_view_report_load_complete (view->details->nautilus_view);
}
if (view->details->uri) {
g_free (view->details->uri);
}
view->details->uri = new_location;
}
#if defined(DEBUG_ramiro)
#define PRINT_FLAG(bits, mask, message) \
G_STMT_START { \
if ((bits) & (mask)) { \
g_print ("%s ", (message)); \
} \
} G_STMT_END
static void
debug_print_state_flags (gint state_flags)
{
g_print ("state_flags = ");
PRINT_FLAG (state_flags, GTK_MOZ_EMBED_FLAG_START, "start");
PRINT_FLAG (state_flags, GTK_MOZ_EMBED_FLAG_REDIRECTING, "redirecting");
PRINT_FLAG (state_flags, GTK_MOZ_EMBED_FLAG_TRANSFERRING, "transferring");
PRINT_FLAG (state_flags, GTK_MOZ_EMBED_FLAG_NEGOTIATING, "negotiating");
PRINT_FLAG (state_flags, GTK_MOZ_EMBED_FLAG_STOP, "stop");
PRINT_FLAG (state_flags, GTK_MOZ_EMBED_FLAG_IS_REQUEST, "is_request");
PRINT_FLAG (state_flags, GTK_MOZ_EMBED_FLAG_IS_DOCUMENT, "is_document");
PRINT_FLAG (state_flags, GTK_MOZ_EMBED_FLAG_IS_NETWORK, "is_network");
PRINT_FLAG (state_flags, GTK_MOZ_EMBED_FLAG_IS_WINDOW, "is_window");
g_print ("\n");
}
static void
debug_print_status_flags (guint status_flags)
{
g_print ("status_flags = ");
PRINT_FLAG (status_flags, GTK_MOZ_EMBED_STATUS_FAILED_DNS, "failed_dns");
PRINT_FLAG (status_flags, GTK_MOZ_EMBED_STATUS_FAILED_CONNECT, "failed_connect");
PRINT_FLAG (status_flags, GTK_MOZ_EMBED_STATUS_FAILED_TIMEOUT, "failed_timeout");
PRINT_FLAG (status_flags, GTK_MOZ_EMBED_STATUS_FAILED_USERCANCELED, "failed_usercanceled");
g_print ("\n");
}
#endif
static void
mozilla_net_state_callback (GtkMozEmbed *mozilla,
gint state_flags,
guint status_flags,
gpointer user_data)
{
NautilusMozillaContentView *view;
view = NAUTILUS_MOZILLA_CONTENT_VIEW (user_data);
g_assert (GTK_MOZ_EMBED (mozilla) == GTK_MOZ_EMBED (view->details->mozilla));
#if defined(DEBUG_mfleming)
g_print ("gtkembedmoz signal: 'net_state'\n");
#endif
#if defined(DEBUG_ramiro)
g_print ("%s\n", __FUNCTION__);
debug_print_state_flags (state_flags);
debug_print_status_flags (status_flags);
g_print ("\n\n");
#endif
/* win_start */
if (state_flags & GTK_MOZ_EMBED_FLAG_START) {
mozilla_content_view_set_busy_cursor (view);
}
/* win_stop */
if (state_flags & GTK_MOZ_EMBED_FLAG_STOP) {
mozilla_content_view_clear_busy_cursor (view);
}
}
static void
mozilla_net_stop_callback (GtkMozEmbed *mozilla,
gpointer user_data)
{
NautilusMozillaContentView *view;
view = NAUTILUS_MOZILLA_CONTENT_VIEW (user_data);
g_assert (GTK_MOZ_EMBED (mozilla) == GTK_MOZ_EMBED (view->details->mozilla));
#if defined(DEBUG_mfleming)
g_print ("gtkembedmoz signal: 'net_stop'\n");
#endif
nautilus_view_report_load_complete (view->details->nautilus_view);
}
static void
mozilla_link_message_callback (GtkMozEmbed *mozilla, gpointer user_data)
{
NautilusMozillaContentView *view;
char *link_message;
char *translated_link_message;
view = NAUTILUS_MOZILLA_CONTENT_VIEW (user_data);
g_assert (GTK_MOZ_EMBED (mozilla) == GTK_MOZ_EMBED (view->details->mozilla));
link_message = gtk_moz_embed_get_link_message (GTK_MOZ_EMBED (view->details->mozilla));
/* This is actually not that efficient */
translated_link_message = mozilla_untranslate_uri_if_needed (view, link_message);
Some build fixes. * acconfig.h: * configure.in: Removed the NAUTILUS_PREFIX that I added. I did it wrong. * libnautilus-extensions/nautilus-file-utilities.h: * libnautilus-extensions/nautilus-file-utilities.c: (nautilus_pixmap_file): * components/hardware/nautilus-hardware-view.c: (setup_overview_form): * components/services/startup/nautilus-view/nautilus-service-startup-view.c: (setup_form_title), (setup_signup_form), (setup_config_form): * libnautilus-extensions/nautilus-icon-canvas-item.c: (map_pixbuf): * libnautilus-extensions/nautilus-icon-factory.c: (make_full_icon_path): * src/nautilus-application.c: (display_caveat): * src/nautilus-property-browser.c: (nautilus_property_browser_initialize), (nautilus_emblem_dialog_new), (make_category_link): * src/nautilus-zoom-control.c: (nautilus_zoom_control_initialize): Replaced most uses of gnome_pixmap_file on "nautilus/" with a call to a new nautilus_pixmap_file in an attempt to make installations where nautilus has a different prefix from gnome-libs work. I now think this is a waste of time, but Mathieu Lacage says this is still an improvement. * components/help/Makefile.am: * components/help/hyperbola-filefmt.c: (fmt_map_entry): Use HYPERBOLA_DATADIR instead of NAUTILUS_PREFIX. * components/websearch/ntl-web-search.c: (web_search_populate_engines): Use WEB_SEARCH_DATADIR instead of NAUTILUS_PREFIX. * components/mozilla/nautilus-mozilla-content-view.c: (nautilus_mozilla_content_view_initialize), (mozilla_content_view_set_busy_cursor), (mozilla_content_view_request_progress_change), (mozilla_content_view_clear_busy_cursor), (mozilla_load_location_callback), (bonobo_mozilla_callback), (mozilla_merge_bonobo_items_callback), (mozilla_title_changed_callback), (mozilla_location_changed_callback), (mozilla_net_status_callback), (mozilla_link_message_callback), (mozilla_progress_callback), (mozilla_open_uri_callback): Took a cut at fixing the Mozilla component for the new API. Ramiro will have to take care of the rest. * components/services/install/lib/Makefile.am: * components/services/time/command-line/Makefile.am: * components/services/time/nautilus-view/Makefile.am: * components/services/time/service/Makefile.am: * components/services/trilobite/libtrilobite/Makefile.am: * components/services/trilobite/sample/command-line/Makefile.am: * components/services/trilobite/sample/service/Makefile.am: * libnautilus/Makefile.am: Updated all ORBit IDL compiles to use IDL_CFLAGS as suggested in the form of a patch by Martijn van Beers. * libnautilus-extensions/Makefile.am: * libnautilus-extensions/nautilus-file-utilities.c: (nautilus_get_user_main_directory), (nautilus_get_pixmap_directory): * libnautilus-extensions/nautilus-link-set.c: (get_link_set_document): * src/Makefile.am: * src/nautilus-property-browser.c: (nautilus_property_browser_drag_data_get), (make_drag_image), (get_xml_path), (make_properties_from_directory): * src/nautilus-link-set-window.c: (get_link_set_names): * src/file-manager/Makefile.am: * src/file-manager/fm-properties-window.c: (get_property_names): Used NAUTILUS_DATADIR and DATADIR instead of NAUTILUS_PREFIX. * libnautilus-extensions/nautilus-file-utilities.h: * libnautilus-extensions/nautilus-file-utilities.c: (nautilus_get_uri_from_local_path): Added a new helper function for use when you have a path and need a URI. This does a better job than just adding a "file://" on the front. * libnautilus-extensions/nautilus-gtk-extensions.h: * libnautilus-extensions/nautilus-gtk-extensions.c: (get_first_callback), (nautilus_gtk_container_get_first_child): * src/nautilus-window-toolbars.c: (setup_button): * src/nautilus-window.c: (replace_special_current_view_in_content_view_menu): Implemented the first_child function and used it where appropriate. * libnautilus-extensions/nautilus-preferences-item.c: (add_icon_themes): Use nautilus_get_pixmap_directory intead of misusing gnome_pixmap_file by calling it on a directory name. * nautilus-installer/src/support.c: (create_pixmap), (create_image): Added FIXMEs since it isn't clear if this code will work with a Nautilus prefix that's not the same as the gnome-libs prefix. * Makefile.am: Tweaked white space.
2000-06-13 19:05:33 +00:00
nautilus_view_report_status (view->details->nautilus_view,
translated_link_message);
g_free (translated_link_message);
g_free (link_message);
}
static void
mozilla_progress_callback (GtkMozEmbed *mozilla,
gint current_progress,
gint max_progress,
gpointer user_data)
{
NautilusMozillaContentView *view;
view = NAUTILUS_MOZILLA_CONTENT_VIEW (user_data);
g_assert (GTK_MOZ_EMBED (mozilla) == GTK_MOZ_EMBED (view->details->mozilla));
#ifdef DEBUG_ramiro
g_print ("mozilla_progress_callback (max = %d, current = %d)\n", max_progress, current_progress);
#endif
/* NOTE:
* "max_progress" will be -1 if the filesize cannot be determined
* On occasion, it appears that current_progress may actuall exceed max_progress
*/
if (max_progress == -1 || max_progress == 0) {
nautilus_view_report_load_progress (view->details->nautilus_view,
0);
} else if (max_progress < current_progress) {
nautilus_view_report_load_progress (view->details->nautilus_view,
1.0);
Some build fixes. * acconfig.h: * configure.in: Removed the NAUTILUS_PREFIX that I added. I did it wrong. * libnautilus-extensions/nautilus-file-utilities.h: * libnautilus-extensions/nautilus-file-utilities.c: (nautilus_pixmap_file): * components/hardware/nautilus-hardware-view.c: (setup_overview_form): * components/services/startup/nautilus-view/nautilus-service-startup-view.c: (setup_form_title), (setup_signup_form), (setup_config_form): * libnautilus-extensions/nautilus-icon-canvas-item.c: (map_pixbuf): * libnautilus-extensions/nautilus-icon-factory.c: (make_full_icon_path): * src/nautilus-application.c: (display_caveat): * src/nautilus-property-browser.c: (nautilus_property_browser_initialize), (nautilus_emblem_dialog_new), (make_category_link): * src/nautilus-zoom-control.c: (nautilus_zoom_control_initialize): Replaced most uses of gnome_pixmap_file on "nautilus/" with a call to a new nautilus_pixmap_file in an attempt to make installations where nautilus has a different prefix from gnome-libs work. I now think this is a waste of time, but Mathieu Lacage says this is still an improvement. * components/help/Makefile.am: * components/help/hyperbola-filefmt.c: (fmt_map_entry): Use HYPERBOLA_DATADIR instead of NAUTILUS_PREFIX. * components/websearch/ntl-web-search.c: (web_search_populate_engines): Use WEB_SEARCH_DATADIR instead of NAUTILUS_PREFIX. * components/mozilla/nautilus-mozilla-content-view.c: (nautilus_mozilla_content_view_initialize), (mozilla_content_view_set_busy_cursor), (mozilla_content_view_request_progress_change), (mozilla_content_view_clear_busy_cursor), (mozilla_load_location_callback), (bonobo_mozilla_callback), (mozilla_merge_bonobo_items_callback), (mozilla_title_changed_callback), (mozilla_location_changed_callback), (mozilla_net_status_callback), (mozilla_link_message_callback), (mozilla_progress_callback), (mozilla_open_uri_callback): Took a cut at fixing the Mozilla component for the new API. Ramiro will have to take care of the rest. * components/services/install/lib/Makefile.am: * components/services/time/command-line/Makefile.am: * components/services/time/nautilus-view/Makefile.am: * components/services/time/service/Makefile.am: * components/services/trilobite/libtrilobite/Makefile.am: * components/services/trilobite/sample/command-line/Makefile.am: * components/services/trilobite/sample/service/Makefile.am: * libnautilus/Makefile.am: Updated all ORBit IDL compiles to use IDL_CFLAGS as suggested in the form of a patch by Martijn van Beers. * libnautilus-extensions/Makefile.am: * libnautilus-extensions/nautilus-file-utilities.c: (nautilus_get_user_main_directory), (nautilus_get_pixmap_directory): * libnautilus-extensions/nautilus-link-set.c: (get_link_set_document): * src/Makefile.am: * src/nautilus-property-browser.c: (nautilus_property_browser_drag_data_get), (make_drag_image), (get_xml_path), (make_properties_from_directory): * src/nautilus-link-set-window.c: (get_link_set_names): * src/file-manager/Makefile.am: * src/file-manager/fm-properties-window.c: (get_property_names): Used NAUTILUS_DATADIR and DATADIR instead of NAUTILUS_PREFIX. * libnautilus-extensions/nautilus-file-utilities.h: * libnautilus-extensions/nautilus-file-utilities.c: (nautilus_get_uri_from_local_path): Added a new helper function for use when you have a path and need a URI. This does a better job than just adding a "file://" on the front. * libnautilus-extensions/nautilus-gtk-extensions.h: * libnautilus-extensions/nautilus-gtk-extensions.c: (get_first_callback), (nautilus_gtk_container_get_first_child): * src/nautilus-window-toolbars.c: (setup_button): * src/nautilus-window.c: (replace_special_current_view_in_content_view_menu): Implemented the first_child function and used it where appropriate. * libnautilus-extensions/nautilus-preferences-item.c: (add_icon_themes): Use nautilus_get_pixmap_directory intead of misusing gnome_pixmap_file by calling it on a directory name. * nautilus-installer/src/support.c: (create_pixmap), (create_image): Added FIXMEs since it isn't clear if this code will work with a Nautilus prefix that's not the same as the gnome-libs prefix. * Makefile.am: Tweaked white space.
2000-06-13 19:05:33 +00:00
} else {
nautilus_view_report_load_progress (view->details->nautilus_view,
current_progress / max_progress);
}
}
static gint
mozilla_open_uri_callback (GtkMozEmbed *mozilla,
const char *uri,
gpointer user_data)
{
gint abort_uri_open;
NautilusMozillaContentView *view;
static gboolean do_nothing = FALSE;
view = NAUTILUS_MOZILLA_CONTENT_VIEW (user_data);
g_assert (GTK_MOZ_EMBED (mozilla) == GTK_MOZ_EMBED (view->details->mozilla));
/* Determine whether we want to abort this uri load */
abort_uri_open = mozilla_is_uri_handled_by_nautilus (uri);
/* FIXME: I believe that this will cause a navigation from
* a page containing a specific iframe URL to that same URL
* to fail.
*
* This check is here because we get an "open_uri" call from GtkEmbedMoz
* in M18 when mozilla opens locations that appear as IFRAME's
* within the current document. If we didn't do this check, we would
* cause Nautilus to navigate to these IFRAME url's
*/
if ( mozilla_events_is_url_in_iframe (mozilla, uri)) {
#ifdef DEBUG_mfleming
g_print ("URI is in an iframe;ignoring '%s'\n", uri);
#endif
return FALSE;
}
#ifdef DEBUG_ramiro
g_print ("mozilla_open_uri_callback (uri = %s) abort = %s\n",
uri,
abort_uri_open ? "TRUE" : "FALSE");
#endif
if (do_nothing == TRUE) {
do_nothing = FALSE;
view->details->got_called_by_nautilus = FALSE;
} else if (view->details->got_called_by_nautilus == TRUE) {
view->details->got_called_by_nautilus = FALSE;
} else {
char *untranslated_uri;
/* set it so that we load next time we are called. */
do_nothing = TRUE;
abort_uri_open = TRUE;
bonobo_object_ref (BONOBO_OBJECT (view->details->nautilus_view));
/*do untranslate here*/
untranslated_uri = mozilla_untranslate_uri_if_needed (view, uri);
reviewed by: John Sullivan <sullivan@eazel.com> Fixed bug 1948 ("Open in New Window" menu item reuses existing window if it exists) by separating the explicit "open in new window" feature (always gives a new window) from the "open all items in new windows" preference (reuses window if one with the right location already exists). * libnautilus/nautilus-view-component.idl: Added new open_location_prefer_existing_window call. Renamed open_location to open_location_in_this_window and open_location_in_new_window to open_location_force_new_window for clarity. * libnautilus/nautilus-view.h: * libnautilus/nautilus-view.c: (nautilus_view_open_location_in_this_window), (nautilus_view_open_location_prefer_existing_window), (nautilus_view_open_location_force_new_window): * src/nautilus-view-frame-corba.c: (impl_Nautilus_ViewFrame_open_location_in_this_window), (impl_Nautilus_ViewFrame_open_location_prefer_existing_window), (impl_Nautilus_ViewFrame_open_location_force_new_window): * src/nautilus-view-frame-private.h: * src/nautilus-view-frame.c: (nautilus_view_frame_initialize_class), (nautilus_view_frame_open_location_in_this_window), (nautilus_view_frame_open_location_prefer_existing_window), (nautilus_view_frame_open_location_force_new_window): * src/nautilus-view-frame.h: Add new call, rename old ones. * src/file-manager/fm-directory-view.c: (open_callback): Pass parameter to tell the open code to respect the "use new windows" preference. (open_location): Take new WindowChoice parameter to respect preference as appropriate. (switch_location_and_view): Tell the code to respect the preference in this case (opening from Open With). (show_trash_callback): Use code that respects the preference instead of always opening in this case. (open_one_in_new_window): Always force a new window (used by Open in New Window command). (activate_callback): Pass through new WindowChoice instead of boolean. (fm_directory_view_activate_file): Pass through new WindowChoice instead of boolean., (fm_directory_view_activate_files): Respect the user preference if opening only one file, do the "use existing window or make new one" mode if opening more than one. * src/nautilus-window-manage-views.c: (handle_unreadable_location): Move check for empty location string in here. (open_location): Moved the code for reusing existing windows out of here. Also changed code structure to avoid redoing the handle_unreadable_location check. (open_location_in_this_window_callback): Renamed. (open_location_prefer_existing_window_callback): Here's where the code for reusing existing windows went. New callback for the new call/signal. (open_location_force_new_window_callback): Renamed. * src/file-manager/fm-search-list-view.c: (reveal_selected_items_callback): Change to use nautilus_view_open_location_force_new_window by its new name. * src/nautilus-window-manage-views.h: Got rid of nautilus_window_open_location_in_new_window, which was public and unused. * components/adapter/nautilus-adapter.c: (nautilus_adapter_open_location_callback): * components/help/hyperbola-nav-index.c: (hyperbola_navigation_index_select_row): * components/help/hyperbola-nav-search.c: (hyperbola_navigation_search_select_row): * components/help/hyperbola-nav-tree.c: (hyperbola_navigation_tree_select_row): * components/history/nautilus-history-view.c: (history_button_release): * components/mozilla/nautilus-mozilla-content-view.c: (mozilla_open_uri_callback), (mozilla_dom_mouse_click_callback): * components/rpmview/nautilus-rpm-view.c: (go_to_button_callback): * components/services/login/nautilus-view/nautilus-change-password-view.c: (run_away_timer), (authn_failed), (maintenance_button_cb): * components/services/summary/nautilus-view/nautilus-summary-callbacks.c: (logged_in_callback), (logged_out_callback), (preferences_button_cb), (forgot_password_button_cb), (register_button_cb): * components/services/summary/nautilus-view/nautilus-summary-dialogs.c: (error_dialog_cancel_cb): * components/services/summary/nautilus-view/nautilus-summary-footer.c: (footer_item_clicked_callback): * components/services/summary/nautilus-view/nautilus-summary-view.c: (goto_service_cb), (goto_update_cb): * components/text/nautilus-text-view.c: (handle_service_menu_item): * components/tree/nautilus-tree-view.c: (tree_select_row_callback): Change to use new nautilus_view_open_location_in_this_window name. It's better because it's more explicit, but also, it's the new name! * libnautilus-extensions/nautilus-gdk-extensions.c: (nautilus_gdk_window_bring_to_front): Fixed indentation. * libnautilus-extensions/nautilus-gtk-extensions.c: (nautilus_gtk_window_present): Put in a new implementation that uses nautilus_gdk_window_bring_to_front instead of the old one that did a hide followed by a show. Corrected an assert that should have been a return_if_fail.
2000-12-13 01:16:58 +00:00
nautilus_view_open_location_in_this_window
(view->details->nautilus_view, untranslated_uri);
g_free (untranslated_uri);
bonobo_object_unref (BONOBO_OBJECT (view->details->nautilus_view));
}
return abort_uri_open;
}
static gboolean
is_uri_partial (const char *uri)
{
const char *current;
/* RFC 2396 section 3.1 */
for (current = uri ;
*current
&& ((*current >= 'a' && *current <= 'z')
|| (*current >= 'A' && *current <= 'Z')
|| (*current >= '0' && *current <= '9')
|| ('-' == *current)
|| ('+' == *current)
|| ('.' == *current)) ;
current++);
return !(':' == *current);
}
/*
* Remove "./" segments
* Compact "../" segments inside the URI
* Remove "." at the end of the URL
* Leave any ".."'s at the beginning of the URI
*/
/* in case if you were wondering, this is probably one of the least time-efficient ways to do this*/
static void
remove_internal_relative_components (char *uri_current)
{
char *segment_prev, *segment_cur;
size_t len_prev, len_cur;
len_prev = len_cur = 0;
segment_prev = NULL;
segment_cur = uri_current;
while (*segment_cur) {
len_cur = strcspn (segment_cur, "/");
if (len_cur == 1 && segment_cur[0] == '.') {
/* Remove "." 's */
if (segment_cur[1] == '\0') {
segment_cur[0] = '\0';
break;
} else {
memmove (segment_cur, segment_cur + 2, strlen (segment_cur + 2) + 1);
continue;
}
} else if (len_cur == 2 && segment_cur[0] == '.' && segment_cur[1] == '.' ) {
/* Remove ".."'s (and the component to the left of it) that aren't at the
* beginning or to the right of other ..'s
*/
if (segment_prev) {
if (! (len_prev == 2
&& segment_prev[0] == '.'
&& segment_prev[1] == '.')) {
if (segment_cur[2] == '\0') {
segment_prev[0] = '\0';
break;
} else {
memmove (segment_prev, segment_cur + 3, strlen (segment_cur + 3) + 1);
segment_cur = segment_prev;
len_cur = len_prev;
/* now we find the previous segment_prev */
if (segment_prev == uri_current) {
segment_prev = NULL;
} else if (segment_prev - uri_current >= 2) {
segment_prev -= 2;
for ( ; segment_prev > uri_current && segment_prev[0] != '/'
; segment_prev-- );
if (segment_prev[0] == '/') {
segment_prev++;
}
}
continue;
}
}
}
}
/*Forward to next segment */
if (segment_cur [len_cur] == '\0') {
break;
}
segment_prev = segment_cur;
len_prev = len_cur;
segment_cur += len_cur + 1;
}
}
/* If I had known this relative uri code would have ended up this long, I would
* have done it a different way
*/
static char *
make_full_uri_from_relative (const char *base_uri, const char *uri)
{
char *result = NULL;
/* See section 5.2 in RFC 2396 */
Some FIXME cleanup. * components/help/converters/gnome-db2html2/sect-elements.c: (sect_article_end_element), (sect_inlinegraphic_start_element): * components/help/converters/gnome-db2html2/toc-elements.c: (toc_sect_end_element): * components/mozilla/mozilla-events.cpp: * components/mozilla/nautilus-mozilla-content-view.c: (make_full_uri_from_relative), (eazel_services_scheme_translate): * components/music/nautilus-music-view.c: (nautilus_music_view_initialize), (music_view_set_selected_song_title), (reset_playtime), (play_status_display), (slider_moved_callback), (add_play_controls): * components/notes/nautilus-notes.c: (notes_load_metainfo): * components/services/install/lib/eazel-install-logic.c: (eazel_install_check_for_file_conflicts), (eazel_install_do_transaction_all_files_check), (eazel_install_prune_packages_helper), (eazel_install_check_existing_packages): * libnautilus-extensions/nautilus-string.c: (nautilus_strcmp), (nautilus_strcasecmp), (nautilus_strcmp_case_breaks_ties), (nautilus_strcoll), (nautilus_str_is_equal), (nautilus_istr_is_equal), (nautilus_strcmp_compare_func), (nautilus_strcoll_compare_func), (nautilus_strcasecmp_compare_func): * src/file-manager/fm-directory-view.c: (open_location): * src/nautilus-first-time-druid.c: (make_anti_aliased_label), (make_hbox_user_level_radio_button), (set_up_user_level_page): Added bug numbers to FIXMEs. At one point Josh made some bugs for FIXMEs but never got around to checking in the bug numbers in the source code. And I wrote one bug report. * components/music/nautilus-music-view.c: (nautilus_music_view_initialize): Removed a fixed FIXME. Also got rid of a hard-coded constant and took excess spaces out of some string constants. * components/services/install/lib/eazel-install-object.c: (eazel_install_emit_dependency_check_default): Changed a FIXME into a non-FIXME comment, now the the bug is fixed. * components/services/install/lib/eazel-package-system-rpm3.c: (rpm_packagedata_fill_from_file): Removed an incorrect bug number from a FIXME. * components/services/install/nautilus-view/nautilus-service-install-view.h: * components/services/install/nautilus-view/nautilus-service-install-view.c: (nautilus_service_install_installing): Removed the FIXME from a comment that's about how a bug was fixed. * components/services/trilobite/libtrilobite/trilobite-md5-tools.h: * components/services/trilobite/libtrilobite/trilobite-md5-tools.c: * docs/style-guide.html: Removed FIXME and corrected misunderstanding about whether use of the guchar typedef is recommended in Nautilus coding style. * libnautilus-extensions/nautilus-gdk-font-extensions.h: * libnautilus-extensions/nautilus-gdk-font-extensions.c: Removed misguided use of const in here. Gdk and Gtk object types just aren't suitable for const, and you end up doing type casts that defeat the purpose. * src/nautilus-window-manage-views.c: (load_underway_callback): Remove a FIXME for a fixed bug.
2001-01-05 02:03:34 +00:00
/* FIXME bugzilla.eazel.com 4413: This function does not take
* into account a BASE tag in an HTML document, so its
* functionality differs from what Mozilla itself would do.
*/
if (is_uri_partial (uri)) {
char *mutable_base_uri;
char *mutable_uri;
char *uri_current;
size_t base_uri_length;
char *separator;
mutable_base_uri = g_strdup (base_uri);
uri_current = mutable_uri = g_strdup (uri);
/* Chew off Fragment and Query from the base_url */
separator = strrchr (mutable_base_uri, '#');
if (separator) {
*separator = '\0';
}
separator = strrchr (mutable_base_uri, '?');
if (separator) {
*separator = '\0';
}
if ('/' == uri_current[0] && '/' == uri_current [1]) {
/* Relative URI's beginning with the authority
* component inherit only the scheme from their parents
*/
separator = strchr (mutable_base_uri, ':');
if (separator) {
separator[1] = '\0';
}
} else if ('/' == uri_current[0]) {
/* Relative URI's beginning with '/' absolute-path based
* at the root of the base uri
*/
separator = strchr (mutable_base_uri, ':');
/* g_assert (separator), really */
if (separator) {
/* If we start with //, skip past the authority section */
if ('/' == separator[1] && '/' == separator[2]) {
separator = strchr (separator + 3, '/');
if (separator) {
separator[0] = '\0';
}
} else {
/* If there's no //, just assume the scheme is the root */
separator[1] = '\0';
}
}
} else if ('#' != uri_current[0]) {
/* Handle the ".." convention for relative uri's */
/* If there's a trailing '/' on base_url, treat base_url
* as a directory path.
* Otherwise, treat it as a file path, and chop off the filename
*/
base_uri_length = strlen (mutable_base_uri);
if ('/' == mutable_base_uri[base_uri_length-1]) {
/* Trim off '/' for the operation below */
mutable_base_uri[base_uri_length-1] = 0;
} else {
separator = strrchr (mutable_base_uri, '/');
if (separator) {
*separator = '\0';
}
}
remove_internal_relative_components (uri_current);
/* handle the "../"'s at the beginning of the relative URI */
while (0 == strncmp ("../", uri_current, 3)) {
uri_current += 3;
separator = strrchr (mutable_base_uri, '/');
if (separator) {
*separator = '\0';
} else {
/* <shrug> */
break;
}
}
/* handle a ".." at the end */
if (uri_current[0] == '.' && uri_current[1] == '.'
&& uri_current[2] == '\0') {
uri_current += 2;
separator = strrchr (mutable_base_uri, '/');
if (separator) {
*separator = '\0';
}
}
/* Re-append the '/' */
mutable_base_uri [strlen(mutable_base_uri)+1] = '\0';
mutable_base_uri [strlen(mutable_base_uri)] = '/';
}
result = g_strconcat (mutable_base_uri, uri_current, NULL);
g_free (mutable_base_uri);
g_free (mutable_uri);
#ifdef DEBUG_mfleming
g_print ("Relative URI converted base '%s' uri '%s' to '%s'", base_uri, uri, result);
#endif
} else {
result = g_strdup (uri);
}
return result;
}
static gint
mozilla_dom_key_press_callback (GtkMozEmbed *mozilla,
gpointer dom_event,
gpointer user_data)
{
g_return_val_if_fail (dom_event != NULL, 0);
#ifdef DEBUG_mfleming
g_print ("%s (%p)\n", __FUNCTION__, dom_event);
#endif
/* If this keyboard event is going to trigger a URL navigation, we need
* to fake it out like the mouse event below
*/
if (mozilla_events_is_key_return (dom_event)) {
return mozilla_dom_mouse_click_callback (mozilla, dom_event, user_data);
} else {
return 0;
}
}
static gint
mozilla_dom_mouse_click_callback (GtkMozEmbed *mozilla,
gpointer dom_event,
gpointer user_data)
{
NautilusMozillaContentView *view;
char *href;
g_return_val_if_fail (GTK_IS_MOZ_EMBED (mozilla), TRUE);
g_return_val_if_fail (dom_event != NULL, TRUE);
g_return_val_if_fail (NAUTILUS_IS_MOZILLA_CONTENT_VIEW (user_data), TRUE);
view = NAUTILUS_MOZILLA_CONTENT_VIEW (user_data);
g_return_val_if_fail (GTK_MOZ_EMBED (mozilla) == GTK_MOZ_EMBED (view->details->mozilla), TRUE);
#ifdef DEBUG_ramiro
g_print ("%s (%p)\n", __FUNCTION__, dom_event);
#endif
if (mozilla_events_is_in_form_POST_submit (dom_event)) {
#ifdef DEBUG_mfleming
g_print ("%s: is a POST submit\n", __FUNCTION__);
#endif
/* So that the post event can be properly submitted without
* the Nautilus shell history/navigation framework breaking
* its context, we use a hack. The hack is to lie Nautilus
* that the POST event was instigated by Nautilus. Nautilus
* will the call our load_location() away without having
* gnome-vfs try and do the post and thus spoling it.
*/
view->details->got_called_by_nautilus = TRUE;
} else {
href = mozilla_events_get_href_for_event (dom_event);
/*
* The return value over here needs to be psycho-analyzed some.
* In theory, a return value of NS_OK, which is 0 (yes, zero)
* in the Mozilla universe means that the dom event got handled
*
* Need to look at the gtkmozembed.cpp code more carefully.
*/
if (href) {
char * href_full = NULL;
href_full = make_full_uri_from_relative (view->details->uri, href);
g_free (href);
href = href_full;
href_full = NULL;
#if 0
/* FIXME mfleming I think I should do this here, but I'm not sure */
href_full = mozilla_untranslate_uri_if_needed (view, href);
g_free (href);
href = href_full;
href_full = NULL;
#endif
#ifdef DEBUG_ramiro
g_print ("%s() href = %s\n", __FUNCTION__, href);
#endif
bonobo_object_ref (BONOBO_OBJECT (view->details->nautilus_view));
reviewed by: John Sullivan <sullivan@eazel.com> Fixed bug 1948 ("Open in New Window" menu item reuses existing window if it exists) by separating the explicit "open in new window" feature (always gives a new window) from the "open all items in new windows" preference (reuses window if one with the right location already exists). * libnautilus/nautilus-view-component.idl: Added new open_location_prefer_existing_window call. Renamed open_location to open_location_in_this_window and open_location_in_new_window to open_location_force_new_window for clarity. * libnautilus/nautilus-view.h: * libnautilus/nautilus-view.c: (nautilus_view_open_location_in_this_window), (nautilus_view_open_location_prefer_existing_window), (nautilus_view_open_location_force_new_window): * src/nautilus-view-frame-corba.c: (impl_Nautilus_ViewFrame_open_location_in_this_window), (impl_Nautilus_ViewFrame_open_location_prefer_existing_window), (impl_Nautilus_ViewFrame_open_location_force_new_window): * src/nautilus-view-frame-private.h: * src/nautilus-view-frame.c: (nautilus_view_frame_initialize_class), (nautilus_view_frame_open_location_in_this_window), (nautilus_view_frame_open_location_prefer_existing_window), (nautilus_view_frame_open_location_force_new_window): * src/nautilus-view-frame.h: Add new call, rename old ones. * src/file-manager/fm-directory-view.c: (open_callback): Pass parameter to tell the open code to respect the "use new windows" preference. (open_location): Take new WindowChoice parameter to respect preference as appropriate. (switch_location_and_view): Tell the code to respect the preference in this case (opening from Open With). (show_trash_callback): Use code that respects the preference instead of always opening in this case. (open_one_in_new_window): Always force a new window (used by Open in New Window command). (activate_callback): Pass through new WindowChoice instead of boolean. (fm_directory_view_activate_file): Pass through new WindowChoice instead of boolean., (fm_directory_view_activate_files): Respect the user preference if opening only one file, do the "use existing window or make new one" mode if opening more than one. * src/nautilus-window-manage-views.c: (handle_unreadable_location): Move check for empty location string in here. (open_location): Moved the code for reusing existing windows out of here. Also changed code structure to avoid redoing the handle_unreadable_location check. (open_location_in_this_window_callback): Renamed. (open_location_prefer_existing_window_callback): Here's where the code for reusing existing windows went. New callback for the new call/signal. (open_location_force_new_window_callback): Renamed. * src/file-manager/fm-search-list-view.c: (reveal_selected_items_callback): Change to use nautilus_view_open_location_force_new_window by its new name. * src/nautilus-window-manage-views.h: Got rid of nautilus_window_open_location_in_new_window, which was public and unused. * components/adapter/nautilus-adapter.c: (nautilus_adapter_open_location_callback): * components/help/hyperbola-nav-index.c: (hyperbola_navigation_index_select_row): * components/help/hyperbola-nav-search.c: (hyperbola_navigation_search_select_row): * components/help/hyperbola-nav-tree.c: (hyperbola_navigation_tree_select_row): * components/history/nautilus-history-view.c: (history_button_release): * components/mozilla/nautilus-mozilla-content-view.c: (mozilla_open_uri_callback), (mozilla_dom_mouse_click_callback): * components/rpmview/nautilus-rpm-view.c: (go_to_button_callback): * components/services/login/nautilus-view/nautilus-change-password-view.c: (run_away_timer), (authn_failed), (maintenance_button_cb): * components/services/summary/nautilus-view/nautilus-summary-callbacks.c: (logged_in_callback), (logged_out_callback), (preferences_button_cb), (forgot_password_button_cb), (register_button_cb): * components/services/summary/nautilus-view/nautilus-summary-dialogs.c: (error_dialog_cancel_cb): * components/services/summary/nautilus-view/nautilus-summary-footer.c: (footer_item_clicked_callback): * components/services/summary/nautilus-view/nautilus-summary-view.c: (goto_service_cb), (goto_update_cb): * components/text/nautilus-text-view.c: (handle_service_menu_item): * components/tree/nautilus-tree-view.c: (tree_select_row_callback): Change to use new nautilus_view_open_location_in_this_window name. It's better because it's more explicit, but also, it's the new name! * libnautilus-extensions/nautilus-gdk-extensions.c: (nautilus_gdk_window_bring_to_front): Fixed indentation. * libnautilus-extensions/nautilus-gtk-extensions.c: (nautilus_gtk_window_present): Put in a new implementation that uses nautilus_gdk_window_bring_to_front instead of the old one that did a hide followed by a show. Corrected an assert that should have been a return_if_fail.
2000-12-13 01:16:58 +00:00
nautilus_view_open_location_in_this_window
(view->details->nautilus_view, href);
bonobo_object_unref (BONOBO_OBJECT (view->details->nautilus_view));
g_free (href);
return 0;
}
}
return TRUE;
}
#define STRING_LIST_NOT_FOUND -1
static gint
string_list_get_index_of_string (const char *string_list[], guint num_strings, const char *string)
{
reviewed by: Darin Adler <darin@eazel.com> 2000-11-13 Pavel Cisler <pavel@eazel.com> reviewed by: Darin Adler <darin@eazel.com> * configure.in: Enable the sign-compare and cast-align warnings. * components/help/converters/gnome-db2html2/gdb3html.c: (find_first_element): * components/help/hyperbola-filefmt.c: (fmt_free_tree_info): * components/help/hyperbola-nav-index.c: (hyperbola_navigation_index_update_clist), (despace), (end_element): * components/history/nautilus-history-view.c: (history_load_location): * components/mozilla/nautilus-mozilla-content-view.c: (string_list_get_index_of_string): * components/services/install/lib/eazel-install-corba-types.c: (corba_string_sequence_to_glist), (corba_packagedatastructlist_from_packagedata_list), (packagedata_list_from_corba_packagedatastructlist), (categorydata_list_from_corba_categorystructlist): * components/services/install/lib/eazel-install-query.c: (eazel_install_simple_rpm_query): * components/services/install/lib/eazel-install-rpm-glue.c: (eazel_install_monitor_rpm_process_pipe): * components/services/install/lib/eazel-install-rpm-signature.c: (read_rpm_lead), (read_rpm_signature): * components/services/trilobite/libtrilobite/trilobite-root-helper. c: (trilobite_root_helper_run_program), (trilobite_root_helper_set_time): * cut-n-paste-code/widgets/nautilusclist/nautilusclist.c: (nautilus_clist_get_arg), (nautilus_clist_construct): * helper-utilities/authenticate/nautilus-authenticate.c: (main): * libnautilus-extensions/nautilus-background.c: (set_image_and_color_image_loading_done_callback): * libnautilus-extensions/nautilus-buffered-widget.c: (nautilus_gdk_pixbuf_tile_alpha): * libnautilus-extensions/nautilus-caption-table.c: (entry_activate): * libnautilus-extensions/nautilus-caption-table.h: * libnautilus-extensions/nautilus-ctree.c: (nautilus_ctree_node_nth), (nautilus_ctree_drag_motion): * libnautilus-extensions/nautilus-ctree.h: * libnautilus-extensions/nautilus-directory-async.c: (metafile_write): * libnautilus-extensions/nautilus-file-changes-queue.c: (nautilus_file_changes_consume_changes): * libnautilus-extensions/nautilus-file-operations-progress.c: (truncate_string_from_start): * libnautilus-extensions/nautilus-file-operations.c: (extract_string_until): * libnautilus-extensions/nautilus-file-utilities.c: (nautilus_read_entire_file): * libnautilus-extensions/nautilus-gdk-extensions.c: (nautilus_get_largest_fitting_font): * libnautilus-extensions/nautilus-global-preferences.c: (global_preferences_get_sidebar_panel_view_identifiers): * libnautilus-extensions/nautilus-gtk-extensions.c: (nautilus_gtk_window_set_initial_geometry_from_string), (nautilus_gtk_menu_set_item_visibility): * libnautilus-extensions/nautilus-icon-canvas-item.c: (draw_or_measure_label_text), (draw_or_measure_label_text_aa): * libnautilus-extensions/nautilus-icon-container.c: (rubberband_timeout_callback), (destroy), (compute_stretch): * libnautilus-extensions/nautilus-icon-container.h: (nautilus_icon_container_find_drop_target): * libnautilus-extensions/nautilus-icon-factory.c: (check_recently_used_list), (get_themed_icon_file_path), (revise_scale_factors_if_too_big): * libnautilus-extensions/nautilus-icon-text-item.c: (recompute_bounding_box), (iti_draw), (iti_selection_motion): * libnautilus-extensions/nautilus-label.c: (nautilus_label_size_allocate), (label_recompute_line_geometries): * libnautilus-extensions/nautilus-list.c: (draw_cell), (nautilus_list_drag_data_received): * libnautilus-extensions/nautilus-mime-actions.c: (server_matches_content_requirements), (nautilus_do_component_query): * libnautilus-extensions/nautilus-password-dialog.c: (caption_table_activate_callback): * libnautilus-extensions/nautilus-preferences-item.c: (has_image_file): * libnautilus-extensions/nautilus-scalable-font.c: (file_as_string), (parse_font_description_file), (nautilus_text_layout_new): * libnautilus-extensions/nautilus-scalable-font.h: * libnautilus-extensions/nautilus-volume-monitor.c: (check_permissions): * libnautilus/nautilus-view.c: (nautilus_shallow_g_list_from_uri_list): * libnautilus/nautilus-zoomable.c: (nautilus_g_list_from_ZoomLevelList): * librsvg/rsvg-ft.c: (rsvg_ft_measure_or_render_string): * librsvg/rsvg.c: (rsvg_parse_transform): * src/file-manager/fm-icon-view.c: (fm_icon_view_create_background_context_menu_items), (get_sort_criterion_by_metadata_text), (get_sort_criterion_by_id): * src/file-manager/fm-list-view.c: (select_row_common), (select_matching_name_callback), (select_previous_next_common), (fm_list_view_bump_zoom_level): * src/nautilus-search-bar-criterion.c: (nautilus_search_bar_criterion_update_valid_criteria_choices): * src/nautilus-shell.c: (corba_open_windows), (corba_open_default_window): * src/nautilus-sidebar.c: (nautilus_sidebar_add_panel_items): * src/nautilus-window-menus.c: (nautilus_window_disable_keyboard_navigation_for_menus): * src/nautilus-window.c: (nautilus_window_size_request): Fix all sign-compare violations.
2000-11-14 02:46:02 +00:00
guint i;
g_return_val_if_fail (string != NULL, STRING_LIST_NOT_FOUND);
g_return_val_if_fail (string_list != NULL, STRING_LIST_NOT_FOUND);
g_return_val_if_fail (num_strings > 0, STRING_LIST_NOT_FOUND);
for (i = 0; i < num_strings; i++) {
g_assert (string_list[i] != NULL);
if (strlen (string) >= strlen (string_list[i])
&& (strncmp (string, string_list[i], strlen (string_list[i])) == 0)) {
return i;
}
}
return STRING_LIST_NOT_FOUND;
}
/*
* The issue here is that mozilla handles some protocols "natively" just as nautilus
* does thanks to gnome-vfs magic.
*
* The embedded mozilla beast provides a mechanism for aborting url loading (ie, the
* thing that happens when a user boinks on a hyperlink).
*
* We use this feature to abort uri loads for the following protocol(s):
*
*/
static gboolean
mozilla_is_uri_handled_by_nautilus (const char *uri)
{
static const char *handled_by_nautilus[] =
{
"ftp",
"eazel",
"eazel-install",
"eazel-pw",
"eazel-services",
"man",
"info",
"help",
"gnome-help",
"ghelp"
};
g_return_val_if_fail (uri != NULL, FALSE);
return string_list_get_index_of_string (handled_by_nautilus, NUM_ELEMENTS_IN_ARRAY (handled_by_nautilus),
uri) != STRING_LIST_NOT_FOUND;
}
/*
* Conversly, this a list of protocols handled by mozilla. The strategy is to check
* uris for these protocols and pass them through to mozilla as as. For other uris,
* we try to use gnome-vfs and later stream the information into the gtkmozembed
* widget. For example, this is how the man: protocol works.
*/
static gboolean
mozilla_is_uri_handled_by_mozilla (const char *uri)
{
static const char *handled_by_mozilla[] =
{
"http",
"file"
};
return string_list_get_index_of_string (handled_by_mozilla, NUM_ELEMENTS_IN_ARRAY (handled_by_mozilla),
uri) != STRING_LIST_NOT_FOUND;
}
/* A NULL return from this function must trigger a nautilus load error */
static char *
mozilla_translate_uri_if_needed (NautilusMozillaContentView *view, const char *uri)
{
/* gint i; */
char *ret;
g_return_val_if_fail (uri != NULL, NULL);
#ifdef EAZEL_SERVICES
if (0 == strncmp (uri, "eazel-services:", strlen ("eazel-services:"))) {
ret = eazel_services_scheme_translate (view, uri, FALSE);
#ifdef DEBUG_mfleming
g_message ("Mozilla: translated uri '%s' to '%s'", uri, ret ? ret : "<no such page>");
#endif
} else
#endif /* EAZEL_SERVICES */
{
ret = g_strdup (uri);
}
return ret;
}
static char *
mozilla_untranslate_uri_if_needed (NautilusMozillaContentView *view, const char *uri)
{
#ifdef EAZEL_SERVICES
return eazel_services_scheme_untranslate (view, uri);
#else
return g_strdup (uri);
#endif /* EAZEL_SERVICES */
}
GtkType
nautilus_mozilla_content_view_get_type (void)
{
static GtkType mozilla_content_view_type = 0;
if (!mozilla_content_view_type)
{
static const GtkTypeInfo mozilla_content_view_info =
{
"NautilusMozillaContentView",
sizeof (NautilusMozillaContentView),
sizeof (NautilusMozillaContentViewClass),
(GtkClassInitFunc) nautilus_mozilla_content_view_initialize_class,
(GtkObjectInitFunc) nautilus_mozilla_content_view_initialize,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
};
mozilla_content_view_type = gtk_type_unique (GTK_TYPE_VBOX, &mozilla_content_view_info);
}
return mozilla_content_view_type;
}
#ifdef EAZEL_SERVICES
/* A NULL return from this function must trigger a nautilus load error */
static char *
eazel_services_scheme_translate (NautilusMozillaContentView *view,
const char *uri,
gboolean is_retry)
{
const char *uri_minus_scheme;
char *new_uri = NULL;
char *ret = NULL;
AmmoniteError err;
if (CORBA_OBJECT_NIL == nautilus_mozilla_content_view_user_control) {
return NULL;
}
/* Chew off the the scheme, leave the colon */
uri_minus_scheme = strchr (uri, (unsigned char)':');
g_assert (uri_minus_scheme);
err = ammonite_http_url_for_eazel_url (uri_minus_scheme, &new_uri);
switch (err) {
case ERR_Success:
ret = g_strconcat ("http", new_uri, NULL);
g_free (new_uri);
new_uri = NULL;
break;
#ifdef EAZEL_SERVICES_MOZILLA_MODAL_LOGIN
case ERR_UserNotLoggedIn:
if (is_retry) {
/* We already tried this once and it didn't work */
ret = NULL;
} else {
AmmoniteParsedURL *parsed = NULL;
LoginAsyncState *p_state;
p_state = g_new0 (LoginAsyncState, 1);
p_state->uri = strdup (uri);
p_state->view = view;
parsed = ammonite_url_parse (uri);
g_assert (parsed);
Some FIXME cleanup. * components/help/converters/gnome-db2html2/sect-elements.c: (sect_article_end_element), (sect_inlinegraphic_start_element): * components/help/converters/gnome-db2html2/toc-elements.c: (toc_sect_end_element): * components/mozilla/mozilla-events.cpp: * components/mozilla/nautilus-mozilla-content-view.c: (make_full_uri_from_relative), (eazel_services_scheme_translate): * components/music/nautilus-music-view.c: (nautilus_music_view_initialize), (music_view_set_selected_song_title), (reset_playtime), (play_status_display), (slider_moved_callback), (add_play_controls): * components/notes/nautilus-notes.c: (notes_load_metainfo): * components/services/install/lib/eazel-install-logic.c: (eazel_install_check_for_file_conflicts), (eazel_install_do_transaction_all_files_check), (eazel_install_prune_packages_helper), (eazel_install_check_existing_packages): * libnautilus-extensions/nautilus-string.c: (nautilus_strcmp), (nautilus_strcasecmp), (nautilus_strcmp_case_breaks_ties), (nautilus_strcoll), (nautilus_str_is_equal), (nautilus_istr_is_equal), (nautilus_strcmp_compare_func), (nautilus_strcoll_compare_func), (nautilus_strcasecmp_compare_func): * src/file-manager/fm-directory-view.c: (open_location): * src/nautilus-first-time-druid.c: (make_anti_aliased_label), (make_hbox_user_level_radio_button), (set_up_user_level_page): Added bug numbers to FIXMEs. At one point Josh made some bugs for FIXMEs but never got around to checking in the bug numbers in the source code. And I wrote one bug report. * components/music/nautilus-music-view.c: (nautilus_music_view_initialize): Removed a fixed FIXME. Also got rid of a hard-coded constant and took excess spaces out of some string constants. * components/services/install/lib/eazel-install-object.c: (eazel_install_emit_dependency_check_default): Changed a FIXME into a non-FIXME comment, now the the bug is fixed. * components/services/install/lib/eazel-package-system-rpm3.c: (rpm_packagedata_fill_from_file): Removed an incorrect bug number from a FIXME. * components/services/install/nautilus-view/nautilus-service-install-view.h: * components/services/install/nautilus-view/nautilus-service-install-view.c: (nautilus_service_install_installing): Removed the FIXME from a comment that's about how a bug was fixed. * components/services/trilobite/libtrilobite/trilobite-md5-tools.h: * components/services/trilobite/libtrilobite/trilobite-md5-tools.c: * docs/style-guide.html: Removed FIXME and corrected misunderstanding about whether use of the guchar typedef is recommended in Nautilus coding style. * libnautilus-extensions/nautilus-gdk-font-extensions.h: * libnautilus-extensions/nautilus-gdk-font-extensions.c: Removed misguided use of const in here. Gdk and Gtk object types just aren't suitable for const, and you end up doing type casts that defeat the purpose. * src/nautilus-window-manage-views.c: (load_underway_callback): Remove a FIXME for a fixed bug.
2001-01-05 02:03:34 +00:00
/* FIXME bugzilla.eazel.com 4412: it's possible that "view" will be gone by the time the reponse comes back */
if (! ammonite_do_prompt_login_async (parsed->user, NULL, NULL, p_state, prompt_login_cb) ) {
ret = NULL;
g_free (p_state->uri);
g_free (p_state);
}
ammonite_url_free (parsed);
}
break;
#endif /* EAZEL_SERVICES_MOZILLA_MODAL_LOGIN */
default:
ret = NULL;
break;
}
return ret;
}
static char *
eazel_services_scheme_untranslate (NautilusMozillaContentView *view,
const char *uri)
{
AmmoniteError err;
char *ret;
err = ammonite_eazel_url_for_http_url (uri, &ret);
if (ERR_Success == err) {
#ifdef DEBUG_mfleming
g_message ("Mozilla: untranslated uri '%s' to '%s'", uri, ret );
#endif
} else {
ret = g_strdup (uri);
}
return ret;
}
#ifdef EAZEL_SERVICES_MOZILLA_MODAL_LOGIN
static void /* AmmonitePromptLoginCb */
eazel_services_prompt_login_cb (
gpointer user_data,
const EazelProxy_User *user,
const EazelProxy_AuthnFailInfo *fail_info
) {
LoginAsyncState *p_state;
p_state = (LoginAsyncState *) user_data;
/* Are we still at the same location? If not, forget about it */
if ( 0 == strcmp (p_state->uri, p_state->view->details->uri)) {
goto error;
}
if (fail_info) {
/*fail_info is non-NULL on failure */
nautilus_view_report_load_failed (p_state->view->details->nautilus_view);
goto error;
} else {
eazel_services_scheme_translate (p_state->view, p_state->uri, TRUE);
}
error:
g_free (p_state->uri);
g_free (p_state);
}
#endif /* EAZEL_SERVICES_MOZILLA_MODAL_LOGIN */
#endif /* EAZEL_SERVICES */
#define TEST_PARTIAL(partial, expected) \
tmp = make_full_uri_from_relative (base_uri, partial); \
if ( 0 != strcmp (tmp, expected) ) { \
g_message ("Test failed: partial '%s' expected '%s' got '%s'", partial, expected, tmp); \
success = FALSE; \
g_free (tmp); \
}
gboolean test_make_full_uri_from_relative (void);
gboolean
test_make_full_uri_from_relative (void)
{
const char * base_uri = "http://a/b/c/d;p?q";
char *tmp;
gboolean success = TRUE;
/* Commented out cases do no t work and should; they are marked above
* as fixmes
*/
/* From the RFC */
TEST_PARTIAL ("g", "http://a/b/c/g");
TEST_PARTIAL ("./g", "http://a/b/c/g");
TEST_PARTIAL ("g/", "http://a/b/c/g/");
TEST_PARTIAL ("/g", "http://a/g");
TEST_PARTIAL ("//g", "http://g");
TEST_PARTIAL ("?y", "http://a/b/c/?y");
TEST_PARTIAL ("g?y", "http://a/b/c/g?y");
TEST_PARTIAL ("#s", "http://a/b/c/d;p#s");
TEST_PARTIAL ("g#s", "http://a/b/c/g#s");
TEST_PARTIAL ("g?y#s", "http://a/b/c/g?y#s");
TEST_PARTIAL (";x", "http://a/b/c/;x");
TEST_PARTIAL ("g;x", "http://a/b/c/g;x");
TEST_PARTIAL ("g;x?y#s", "http://a/b/c/g;x?y#s");
TEST_PARTIAL (".", "http://a/b/c/");
TEST_PARTIAL ("./", "http://a/b/c/");
TEST_PARTIAL ("..", "http://a/b/");
TEST_PARTIAL ("../g", "http://a/b/g");
TEST_PARTIAL ("../..", "http://a/");
TEST_PARTIAL ("../../", "http://a/");
TEST_PARTIAL ("../../g", "http://a/g");
/* Others */
TEST_PARTIAL ("g/..", "http://a/b/c/");
TEST_PARTIAL ("g/../", "http://a/b/c/");
TEST_PARTIAL ("g/../g", "http://a/b/c/g");
return success;
}
static void
ensure_profile_dir (void)
{
char *profile_dir;
profile_dir = g_strdup_printf ("%s/.nautilus/MozillaProfile", g_get_home_dir ());
/* Make sure the profile directory exists */
mkdir (profile_dir, 0777);
g_free (profile_dir);
}
static void
ensure_cache_dir (void)
{
char *cache_dir;
ensure_profile_dir ();
cache_dir = g_strdup_printf ("%s/.nautilus/MozillaProfile/Cache", g_get_home_dir ());
/* Make sure the cache directory exists */
mkdir (cache_dir, 0777);
mozilla_preference_set ("browser.cache.directory", cache_dir);
g_free (cache_dir);
}
static void
mozilla_content_view_one_time_happenings (void)
{
static gboolean once = FALSE;
if (once == TRUE) {
return;
}
once = TRUE;
/* Tell the security manager to allow ftp:// and file:// content through. */
mozilla_preference_set_boolean ("security.checkloaduri", FALSE);
/* Change http protocol user agent to include the string 'Nautilus' */
mozilla_preference_set ("general.useragent.misc", "Nautilus/1.0");
/* We dont want to use the proxy for localhost */
mozilla_preference_set ("network.proxy.no_proxies_on", "localhost");
/* Setup routing of proxy preferences from gconf to mozilla */
mozilla_gconf_listen_for_proxy_changes ();
ensure_cache_dir ();
}
/* The "Mozilla Profile" directory is the place where mozilla stores
* things like cookies and cache. Here we tell the mozilla embedding
* widget to use ~/.nautilus/MozillaProfile for this purpose.
*
* We need mozilla M19 to support this feature.
*/
static void
mozilla_content_view_setup_profile_directory (void)
{
#if (MOZILLA_MILESTONE >= 19)
const char *profile_name = "MozillaProfile";
char *profile_dir;
profile_dir = g_strdup_printf ("%s/.nautilus", g_get_home_dir ());
/* Its a bug in mozilla embedding that we need to cast the const away */
gtk_moz_embed_set_profile_path (profile_dir, (char *) profile_name);
#endif
}