summaryrefslogtreecommitdiff
path: root/src/nautilus-navigation-window.c
diff options
context:
space:
mode:
authorDarin Adler <darin@src.gnome.org>2001-01-30 01:47:21 +0000
committerDarin Adler <darin@src.gnome.org>2001-01-30 01:47:21 +0000
commite37c17c07c9cee4f97e1ac7afbd8c0cc6ccea82b (patch)
treef64c6bf685e37213ca6434a2663fee4976ebbc96 /src/nautilus-navigation-window.c
parent71d4af261454c4e8b49e84bd22fb63dea01030f9 (diff)
downloadnautilus-e37c17c07c9cee4f97e1ac7afbd8c0cc6ccea82b.tar.gz
reviewed by: Maciej Stachowiak <mjs@eazel.com>
Fixed bug 2131 (Change Nautilus to use OAF asynchronous activation interface). In making view activation work right, I also eliminated the state machine that was almost gone from NautilusWindow. There's still some additional simplification we can do, but it's simpler than it was. At the same time, made sure all incoming CORBA calls are deferred until idle time. This is most of what the old state machine was accomplishing, believe it or not, although it didn't do it 100%. Also fixes bug 2457 (Silent error loading content view), bug 2461 (progress from old and new content view sometimes confused), and bug 6109 (Assertion hit on clicking the refresh button many times very quickly). Perhaps others too, we need to test some old bugs to see if they have changed behavior. * libnautilus-extensions/nautilus-bonobo-extensions.c: (activation_handle_done), (activation_idle_callback), (activation_cancel), (oaf_activation_callback), (nautilus_bonobo_activate_cancel): Change implementation so that the actual callback happens at idle time, since CORBA callbacks can happen at almost any time. * libnautilus/Makefile.am: * libnautilus/nautilus-idle-queue.h: * libnautilus/nautilus-idle-queue.c: (execute_queued_functions), (nautilus_idle_queue_new), (nautilus_idle_queue_add), (nautilus_idle_queue_destroy): Factored out the idle queueing that I added to NautilusView so we can use it on the NautilusViewFrame side too. * libnautilus/nautilus-view.c: (queue_incoming_call), (nautilus_view_initialize), (nautilus_view_destroy): Change to use the new NautilusIdleQueue so we can share code. * src/nautilus-view-frame-private.h: * src/nautilus-view-frame-corba.c: (list_free_deep_callback), (free_location_and_selection_callback), (open_in_this_window), (open_prefer_existing_window), (open_force_new_window), (report_selection_change), (report_status), (report_load_underway), (report_load_progress), (report_load_complete), (report_load_failed), (set_title), (impl_Nautilus_ViewFrame_open_location_in_this_window), (impl_Nautilus_ViewFrame_open_location_prefer_existing_window), (impl_Nautilus_ViewFrame_open_location_force_new_window), (impl_Nautilus_ViewFrame_report_selection_change), (impl_Nautilus_ViewFrame_report_status), (impl_Nautilus_ViewFrame_report_load_underway), (impl_Nautilus_ViewFrame_report_load_progress), (impl_Nautilus_ViewFrame_report_load_complete), (impl_Nautilus_ViewFrame_report_load_failed), (impl_Nautilus_ViewFrame_set_title): Deal with all incoming CORBA calls through the idle queue. * src/nautilus-view-frame.h: Moved all the fields into details. Renamed client_loaded to view_loaded. Renamed load_client to load_view. Eliminated load_client_sync. Renamed get_iid to get_view_iid. Eliminated get_is_underway. Added get_is_view_loaded. * src/nautilus-view-frame.c: (nautilus_view_frame_queue_incoming_call): Simple cover for putting an incoming CORBA call on the idle queue. (nautilus_view_frame_initialize_class): Change client_loaded signal name to view_loaded. (nautilus_view_frame_initialize): Allocate the idle queue. (stop_activation): New function that stops a load_view that is underway. (destroy_view): Use the "view" field to tell if a view was loaded. The old code used the "iid" field, but now we set that even before the load is completed. (nautilus_view_frame_destroy): Destroy the idle queue. Also put the view into "failed" state once it's destroyed so additional calls are harmless. (nautilus_view_frame_finalize): Check that we're in the failed state. (emit_zoom_parameters_changed): New function so we can share more code. (view_frame_activated): Emit the zoom_parameters_changed signal here since a new view should always should get this signal. (view_frame_underway): Make this do nothing in the failed case instead of complaining. (view_frame_loaded): Make this do nothing in the failed case instead of complaining. (view_frame_failed): Stop whatever's in progress when the view fails. Also, allow calling this on a view that's already failed. (check_if_view_is_gone): Consolidate the calls to deregister_dead_components so we don't need an explicit call here. (emit_zoom_parameters_changed_callback), (zoom_parameters_changed_callback), (emit_zoom_level_changed_callback), (zoom_level_changed_callback): Redo these so they queue onto the idle queue, since they are triggered by incoming CORBA calls that can happen at any time. (create_corba_objects): Factor out the part of the code that makes the CORBA objects. Make error handling more complete and keep around pointers to the Bonobo objects for various parts of the aggregate so we can connect the appropriate signal handlers. (attach_view): Change code so it no longer connects signals to the BonoboObjectClient, since the signals won't go out on that GtkObject. Connect to the exception signals for all objects in the aggregate (any failure means "view failed"). Also connect to the "destroy" signal for one object (doesn't matter which since the entire aggregate goes away at once) and to the zoom-related signals. Report errors with signals rather than returning a boolean. (activation_callback): Add code to handle failure case. (nautilus_view_frame_load_view): Renamed. Got rid of "sync." version. (nautilus_view_frame_stop): Stop OAF activation of the view if it's in progress. (nautilus_view_frame_selection_changed): Make it a quiet no-op to send a selection change notice if no view is loaded. This helps keep the code simple for sidebars. Later we may make the view frame responsible for sending the selection on once the view is loaded. (nautilus_view_frame_title_changed): Same change as for selection, same idea. (nautilus_view_frame_get_is_zoomable), (nautilus_view_frame_get_zoom_level), (nautilus_view_frame_set_zoom_level), (nautilus_view_frame_get_min_zoom_level), (nautilus_view_frame_get_max_zoom_level), (nautilus_view_frame_get_has_min_zoom_level), (nautilus_view_frame_get_has_max_zoom_level), (nautilus_view_frame_get_is_continuous), (nautilus_view_frame_get_preferred_zoom_levels), (nautilus_view_frame_zoom_in), (nautilus_view_frame_zoom_out), (nautilus_view_frame_zoom_to_fit): Since a failed view has a zoomable_frame field set to NULL, got rid of all the explicit failure-case code for these functions. (nautilus_view_frame_get_view_iid): Renamed from get_iid. (nautilus_view_frame_report_load_underway), (nautilus_view_frame_report_load_complete), (nautilus_view_frame_report_load_failed): Moved the "quiet" handling of failed views down into the underlying functions, so these no longer need explicit failure-case code. (nautilus_view_frame_set_label): It's OK to allow this even for a failed view. (nautilus_view_frame_map): Use a kept-around reference to the control frame instead of relying on query_local_interface. (nautilus_view_frame_get_is_view_loaded): Add this so callers can tell when a sidebar view is not yet loaded. Might not need this when we clean things up more, but it's no big deal either way. * src/nautilus-window-manage-views.c: (update_title): No need to send the title change to the new content view -- it gets a title change once it comes up "for real". (set_displayed_location): Handle location of NULL here so we don't need to worry about it elsewhere. (check_bookmark_location_matches): Remove "uri" from name. (location_has_really_changed): Now that the state machine is gone, it's easy to see that this is never called with pending_ni equal to cancel_tag, so remove the code for that and add an assert. (set_view_location_and_selection): New name for what was called update_view. (set_sidebar_panels_location_and_selection): Cover since this loop occurs in two places. (update_for_new_location_and_selection): New name for what was called set_view_location_and_selection. Since it's now clear this can't be called with new_content_view equal to NULL, remove the code to handle that (fixes bug 2457). (load_content_view): Use async. view loading here. Get rid of "Avoid being fooled by extra done notifications from the last view. This is a HACK because the state machine SUCKS." by eliminating the "cv_progress_done" and "cv_progress_error" flags altogether. In the case where we reuse the same view, just call update_for_new_location_and_selection -- the old code set "view_activation_complete", but I eliminated that flag. (handle_view_failure): Remove the old view using nautilus_window_set_content_view_widget instead of having duplicate code here. Use a call to cancel_location_change instead of setting the "reset_to_idle" and "cv_progress_error" flags (both gone now). (free_location_change): No need to clean up "error_views" any more, because that field is gone. (end_location_change): New helper to stop the throbber from throbbing and then free the location change state. (cancel_location_change): Get rid of special case for NULL location now that set_displayed_location can handle it. (nautilus_window_end_location_change_callback): Remove "superstitiously" added call to update_state and call load_content_view_for_new_location directly. (nautilus_window_begin_location_change): Use a call to cancel_location_change to deal with the possibility that we may have a change already in progress. (nautilus_window_stop_loading): Use cancel_location_change to stop the loading. (nautilus_window_set_content_view): Remove calls to update_state -- there's no state to update any more. (nautilus_window_set_sidebar_panels): Do an async. load here and finish the setup in the view_loaded callback. (failed_callback): Do a handle_view_failed right here, now that we have no state machine to satisfy. (load_underway_callback): Change code to handle the two interesting cases separately without a state machine. When the new content view says "underway", it's time for location_has_really_changed. When an existing content view says "underway", we restart the throbber (fixes 1/2 of bug 2461). (load_complete_callback): Since view frames now ensure we get an underway call before a complete call, we can simplify the logic. If the main content view says "complete", it's time to stop the throbber (fixes other 1/2 of bug 2461). (view_loaded_callback): Renamed the client_loaded callback. Also made it update location and selection for sidebar panels when they are loaded. Also made it update the title for any view when it's loaded. * src/nautilus-window.h: * src/nautilus-window.c: (nautilus_window_synch_view_as_menu): Handle case of NULL content view. (nautilus_window_set_content_view_widget): Destroy the view when it's going away instead of removing it from the parent. Also make this function handle the NULL case so we can use it to remove the old view, not just to add the new one. * libnautilus-extensions/nautilus-bonobo-extensions.h: Whitespace tweak. * src/nautilus-sidebar.c: (nautilus_sidebar_active_panel_matches_id): Update for nautilus_view_frame_get_view_iid name change.
Diffstat (limited to 'src/nautilus-navigation-window.c')
-rw-r--r--src/nautilus-navigation-window.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c
index b629df7cd..96cbb5396 100644
--- a/src/nautilus-navigation-window.c
+++ b/src/nautilus-navigation-window.c
@@ -974,6 +974,7 @@ nautilus_window_synch_view_as_menu (NautilusWindow *window)
{
GList *children, *child;
GtkWidget *menu;
+ const char *content_view_iid;
NautilusViewIdentifier *item_id;
int index, matching_index;
@@ -987,11 +988,15 @@ nautilus_window_synch_view_as_menu (NautilusWindow *window)
children = gtk_container_children (GTK_CONTAINER (menu));
matching_index = -1;
- for (child = children, index = 0; child != NULL; child = child->next, ++index) {
- item_id = (NautilusViewIdentifier *)(gtk_object_get_data (GTK_OBJECT (child->data), "identifier"));
- if (item_id != NULL && strcmp (window->content_view->iid, item_id->iid) == 0) {
- matching_index = index;
- break;
+ if (window->content_view != NULL) {
+ content_view_iid = nautilus_view_frame_get_view_iid (window->content_view);
+
+ for (child = children, index = 0; child != NULL; child = child->next, ++index) {
+ item_id = (NautilusViewIdentifier *) gtk_object_get_data (GTK_OBJECT (child->data), "identifier");
+ if (item_id != NULL && strcmp (content_view_iid, item_id->iid) == 0) {
+ matching_index = index;
+ break;
+ }
}
}
@@ -1410,6 +1415,7 @@ static void
real_add_current_location_to_history_list (NautilusWindow *window)
{
g_assert (NAUTILUS_IS_WINDOW (window));
+
nautilus_add_to_history_list (window->current_location_bookmark);
}
@@ -1417,9 +1423,9 @@ void
nautilus_window_add_current_location_to_history_list (NautilusWindow *window)
{
g_assert (NAUTILUS_IS_WINDOW (window));
+
NAUTILUS_CALL_VIRTUAL (NAUTILUS_WINDOW_CLASS, window,
add_current_location_to_history_list, (window));
-
}
void
@@ -1546,8 +1552,7 @@ nautilus_window_set_content_view_widget (NautilusWindow *window,
}
if (window->content_view != NULL) {
- gtk_container_remove (GTK_CONTAINER (window->content_hbox),
- GTK_WIDGET (window->content_view));
+ gtk_object_destroy (GTK_OBJECT (window->content_view));
window->content_view = NULL;
}
@@ -1569,7 +1574,7 @@ nautilus_window_set_content_view_widget (NautilusWindow *window,
}
/* Display or hide zoom control */
- if (nautilus_view_frame_is_zoomable (new_view)) {
+ if (new_view != NULL && nautilus_view_frame_get_is_zoomable (new_view)) {
gtk_widget_show (window->zoom_control);
} else {
gtk_widget_hide (window->zoom_control);