diff options
author | Gene Z. Ragan <gzr@eazel.com> | 2000-05-24 01:03:51 +0000 |
---|---|---|
committer | Gene Ragan <gzr@src.gnome.org> | 2000-05-24 01:03:51 +0000 |
commit | 539ae559dbcc4903c0dc02f58b40a035a03e0044 (patch) | |
tree | b2233196df987e9a0977fbee296e4f2265a3f1b7 /src | |
parent | 584b28c403136d1fc2ab57327b412729a672c231 (diff) | |
download | nautilus-539ae559dbcc4903c0dc02f58b40a035a03e0044.tar.gz |
Added call to CORBA_Object_duplicate(). This fixed an explosive bug.
2000-05-23 Gene Z. Ragan <gzr@eazel.com>
* libnautilus/nautilus-undo-context.c:
(impl_Nautilus_Undo_Context__get_undo_manager):
Added call to CORBA_Object_duplicate(). This
fixed an explosive bug.
* libnautilus/nautilus-undo-manager.c:
* libnautilus/nautilus-undo-manager.h:
(nautilus_undo_manager_stash_global_undo),
(nautilus_undo_manager_get_global_undo):
New functions to save application global instance of Nautilus_Undo_Manager
* src/ntl-app.c: (nautilus_app_init):
Add call to nautilus_undo_manager_stash_global_undo.
* src/ntl-view.c:
(nautilus_view_frame_load_client):
Coonected Nautilus_Undo_Context interface to view frame.
Diffstat (limited to 'src')
-rw-r--r-- | src/nautilus-application.c | 5 | ||||
-rw-r--r-- | src/nautilus-view-frame.c | 135 | ||||
-rw-r--r-- | src/ntl-app.c | 5 | ||||
-rw-r--r-- | src/ntl-view.c | 135 |
4 files changed, 150 insertions, 130 deletions
diff --git a/src/nautilus-application.c b/src/nautilus-application.c index c8d648ea7..31d3449de 100644 --- a/src/nautilus-application.c +++ b/src/nautilus-application.c @@ -234,8 +234,13 @@ nautilus_app_init (NautilusApp *app) /* Init undo manager */ app->undo_manager = BONOBO_OBJECT (nautilus_undo_manager_new ()); undo_manager = bonobo_object_corba_objref (BONOBO_OBJECT (app->undo_manager)); + /* Fix this */ Bonobo_Unknown_ref (undo_manager, &ev); + /* Stash a global reference to the object */ + nautilus_undo_manager_stash_global_undo (undo_manager); + + /* Add it to the application object*/ nautilus_attach_undo_manager ( GTK_OBJECT (app), undo_manager); CORBA_exception_free (&ev); diff --git a/src/nautilus-view-frame.c b/src/nautilus-view-frame.c index a56755ca0..e05ae0fd0 100644 --- a/src/nautilus-view-frame.c +++ b/src/nautilus-view-frame.c @@ -293,10 +293,10 @@ nautilus_view_frame_construct_arg_set(NautilusViewFrame *view) if(view->construct_arg_count >= nca) return; - view->construct_arg_count++; - if((view->construct_arg_count >= nca) - && klass->view_constructed) - klass->view_constructed(view); + view->construct_arg_count++; + if((view->construct_arg_count >= nca) && klass->view_constructed) { + klass->view_constructed(view); + } } static void @@ -359,85 +359,90 @@ nautilus_view_frame_handle_client_destroy_2(GtkObject *object, CORBA_Object cobj gboolean /* returns TRUE if successful */ nautilus_view_frame_load_client(NautilusViewFrame *view, const char *iid) { - CORBA_Object obj; - CORBA_Object zoomable; - - CORBA_Environment ev; - int i; - NautilusViewComponentType *component_types[] = { - &nautilus_view_component_type, - &bonobo_subdoc_component_type, - &bonobo_control_component_type, - NULL - }; - - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), FALSE); - - if (iid == NULL) - return FALSE; - - CORBA_exception_init(&ev); - - nautilus_view_frame_destroy_client(view); - - view->client_object = bonobo_object_activate(iid, 0); - if(!view->client_object) - return FALSE; - - view->view_frame = impl_Nautilus_ViewFrame__create(view, &ev); - view->zoomable_frame = impl_Nautilus_ZoomableFrame__create(view, &ev); - - /* Now figure out which type of embedded object it is: */ - - for(i = 0; component_types[i] && !view->component_class; i++) - { - obj = Bonobo_Unknown_query_interface(bonobo_object_corba_objref(BONOBO_OBJECT(view->client_object)), + CORBA_Object obj; + CORBA_Object zoomable; + Nautilus_Undo_Manager undo_manager; + NautilusUndoContext *undo_context; + CORBA_Environment ev; + int i; + + NautilusViewComponentType *component_types[] = { + &nautilus_view_component_type, + &bonobo_subdoc_component_type, + &bonobo_control_component_type, + NULL + }; + + g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), FALSE); + + if (iid == NULL) + return FALSE; + + CORBA_exception_init(&ev); + + nautilus_view_frame_destroy_client(view); + + view->client_object = bonobo_object_activate(iid, 0); + if(!view->client_object) + return FALSE; + + view->view_frame = impl_Nautilus_ViewFrame__create(view, &ev); + view->zoomable_frame = impl_Nautilus_ZoomableFrame__create(view, &ev); + + /* Add undo manager to component */ + undo_manager = nautilus_undo_manager_get_global_undo (); + g_assert (undo_manager); + undo_context = nautilus_undo_context_new (undo_manager); + bonobo_object_add_interface (BONOBO_OBJECT (view->view_frame), BONOBO_OBJECT (undo_context)); + + /* Now figure out which type of embedded object it is: */ + for(i = 0; component_types[i] && !view->component_class; i++) + { + obj = Bonobo_Unknown_query_interface(bonobo_object_corba_objref(BONOBO_OBJECT(view->client_object)), component_types[i]->primary_repoid, &ev); - if(ev._major != CORBA_NO_EXCEPTION) - obj = CORBA_OBJECT_NIL; + if(ev._major != CORBA_NO_EXCEPTION) + obj = CORBA_OBJECT_NIL; - if(CORBA_Object_is_nil(obj, &ev)) - continue; + if(CORBA_Object_is_nil(obj, &ev)) + continue; - zoomable = bonobo_object_query_interface (BONOBO_OBJECT (view->client_object), + zoomable = bonobo_object_query_interface (BONOBO_OBJECT (view->client_object), "IDL:Nautilus/Zoomable:1.0"); - view->zoomable = zoomable; + view->zoomable = zoomable; - if(component_types[i]->try_load(view, obj, &ev)) - view->component_class = component_types[i]; + if(component_types[i]->try_load(view, obj, &ev)) + view->component_class = component_types[i]; - Bonobo_Unknown_unref(obj, &ev); - CORBA_Object_release(obj, &ev); + Bonobo_Unknown_unref(obj, &ev); + CORBA_Object_release(obj, &ev); - if (view->component_class) - break; - } + if (view->component_class) + break; + } - if (!view->component_class) - { - /* Nothing matched */ - nautilus_view_frame_destroy_client(view); - - return FALSE; - } + if (!view->component_class) { + /* Nothing matched */ + nautilus_view_frame_destroy_client(view); + return FALSE; + } - view->iid = g_strdup(iid); + view->iid = g_strdup(iid); - gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "destroy", + gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "destroy", GTK_SIGNAL_FUNC(nautilus_view_frame_handle_client_destroy), view, GTK_OBJECT(view)); - gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "object_gone", + gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "object_gone", GTK_SIGNAL_FUNC(nautilus_view_frame_handle_client_destroy_2), view, GTK_OBJECT(view)); - gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "system_exception", + gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "system_exception", GTK_SIGNAL_FUNC(nautilus_view_frame_handle_client_destroy_2), view, GTK_OBJECT(view)); - gtk_container_add(GTK_CONTAINER(view), view->client_widget); - gtk_widget_show(view->client_widget); - CORBA_exception_free(&ev); + gtk_container_add(GTK_CONTAINER(view), view->client_widget); + gtk_widget_show(view->client_widget); + CORBA_exception_free(&ev); - return TRUE; + return TRUE; } void diff --git a/src/ntl-app.c b/src/ntl-app.c index c8d648ea7..31d3449de 100644 --- a/src/ntl-app.c +++ b/src/ntl-app.c @@ -234,8 +234,13 @@ nautilus_app_init (NautilusApp *app) /* Init undo manager */ app->undo_manager = BONOBO_OBJECT (nautilus_undo_manager_new ()); undo_manager = bonobo_object_corba_objref (BONOBO_OBJECT (app->undo_manager)); + /* Fix this */ Bonobo_Unknown_ref (undo_manager, &ev); + /* Stash a global reference to the object */ + nautilus_undo_manager_stash_global_undo (undo_manager); + + /* Add it to the application object*/ nautilus_attach_undo_manager ( GTK_OBJECT (app), undo_manager); CORBA_exception_free (&ev); diff --git a/src/ntl-view.c b/src/ntl-view.c index a56755ca0..e05ae0fd0 100644 --- a/src/ntl-view.c +++ b/src/ntl-view.c @@ -293,10 +293,10 @@ nautilus_view_frame_construct_arg_set(NautilusViewFrame *view) if(view->construct_arg_count >= nca) return; - view->construct_arg_count++; - if((view->construct_arg_count >= nca) - && klass->view_constructed) - klass->view_constructed(view); + view->construct_arg_count++; + if((view->construct_arg_count >= nca) && klass->view_constructed) { + klass->view_constructed(view); + } } static void @@ -359,85 +359,90 @@ nautilus_view_frame_handle_client_destroy_2(GtkObject *object, CORBA_Object cobj gboolean /* returns TRUE if successful */ nautilus_view_frame_load_client(NautilusViewFrame *view, const char *iid) { - CORBA_Object obj; - CORBA_Object zoomable; - - CORBA_Environment ev; - int i; - NautilusViewComponentType *component_types[] = { - &nautilus_view_component_type, - &bonobo_subdoc_component_type, - &bonobo_control_component_type, - NULL - }; - - g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), FALSE); - - if (iid == NULL) - return FALSE; - - CORBA_exception_init(&ev); - - nautilus_view_frame_destroy_client(view); - - view->client_object = bonobo_object_activate(iid, 0); - if(!view->client_object) - return FALSE; - - view->view_frame = impl_Nautilus_ViewFrame__create(view, &ev); - view->zoomable_frame = impl_Nautilus_ZoomableFrame__create(view, &ev); - - /* Now figure out which type of embedded object it is: */ - - for(i = 0; component_types[i] && !view->component_class; i++) - { - obj = Bonobo_Unknown_query_interface(bonobo_object_corba_objref(BONOBO_OBJECT(view->client_object)), + CORBA_Object obj; + CORBA_Object zoomable; + Nautilus_Undo_Manager undo_manager; + NautilusUndoContext *undo_context; + CORBA_Environment ev; + int i; + + NautilusViewComponentType *component_types[] = { + &nautilus_view_component_type, + &bonobo_subdoc_component_type, + &bonobo_control_component_type, + NULL + }; + + g_return_val_if_fail (NAUTILUS_IS_VIEW_FRAME (view), FALSE); + + if (iid == NULL) + return FALSE; + + CORBA_exception_init(&ev); + + nautilus_view_frame_destroy_client(view); + + view->client_object = bonobo_object_activate(iid, 0); + if(!view->client_object) + return FALSE; + + view->view_frame = impl_Nautilus_ViewFrame__create(view, &ev); + view->zoomable_frame = impl_Nautilus_ZoomableFrame__create(view, &ev); + + /* Add undo manager to component */ + undo_manager = nautilus_undo_manager_get_global_undo (); + g_assert (undo_manager); + undo_context = nautilus_undo_context_new (undo_manager); + bonobo_object_add_interface (BONOBO_OBJECT (view->view_frame), BONOBO_OBJECT (undo_context)); + + /* Now figure out which type of embedded object it is: */ + for(i = 0; component_types[i] && !view->component_class; i++) + { + obj = Bonobo_Unknown_query_interface(bonobo_object_corba_objref(BONOBO_OBJECT(view->client_object)), component_types[i]->primary_repoid, &ev); - if(ev._major != CORBA_NO_EXCEPTION) - obj = CORBA_OBJECT_NIL; + if(ev._major != CORBA_NO_EXCEPTION) + obj = CORBA_OBJECT_NIL; - if(CORBA_Object_is_nil(obj, &ev)) - continue; + if(CORBA_Object_is_nil(obj, &ev)) + continue; - zoomable = bonobo_object_query_interface (BONOBO_OBJECT (view->client_object), + zoomable = bonobo_object_query_interface (BONOBO_OBJECT (view->client_object), "IDL:Nautilus/Zoomable:1.0"); - view->zoomable = zoomable; + view->zoomable = zoomable; - if(component_types[i]->try_load(view, obj, &ev)) - view->component_class = component_types[i]; + if(component_types[i]->try_load(view, obj, &ev)) + view->component_class = component_types[i]; - Bonobo_Unknown_unref(obj, &ev); - CORBA_Object_release(obj, &ev); + Bonobo_Unknown_unref(obj, &ev); + CORBA_Object_release(obj, &ev); - if (view->component_class) - break; - } + if (view->component_class) + break; + } - if (!view->component_class) - { - /* Nothing matched */ - nautilus_view_frame_destroy_client(view); - - return FALSE; - } + if (!view->component_class) { + /* Nothing matched */ + nautilus_view_frame_destroy_client(view); + return FALSE; + } - view->iid = g_strdup(iid); + view->iid = g_strdup(iid); - gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "destroy", + gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "destroy", GTK_SIGNAL_FUNC(nautilus_view_frame_handle_client_destroy), view, GTK_OBJECT(view)); - gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "object_gone", + gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "object_gone", GTK_SIGNAL_FUNC(nautilus_view_frame_handle_client_destroy_2), view, GTK_OBJECT(view)); - gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "system_exception", + gtk_signal_connect_while_alive(GTK_OBJECT(view->client_object), "system_exception", GTK_SIGNAL_FUNC(nautilus_view_frame_handle_client_destroy_2), view, GTK_OBJECT(view)); - gtk_container_add(GTK_CONTAINER(view), view->client_widget); - gtk_widget_show(view->client_widget); - CORBA_exception_free(&ev); + gtk_container_add(GTK_CONTAINER(view), view->client_widget); + gtk_widget_show(view->client_widget); + CORBA_exception_free(&ev); - return TRUE; + return TRUE; } void |