Re: [Nautilus-list] closing nautlus windows



On Sun, 2002-01-06 at 22:30, Darin Adler wrote:
> On 1/6/02 12:44 PM, "Ricardo Fernández Pascual" <ric users sourceforge net>
> wrote:
> 
> >   I'm one of the galeon developers, and I have a small question about
> > the embedding interfaces of nautilus: can a NautilusView ask the
> > containing window to close itself? I need this for implementing things
> > like javascript:window.close() (and a close mouse gesture, but that's
> > another history...)
> 
> Sorry, there's currently no way to do this. We can consider adding it for a
> future version. I don't think it would be too difficult.
> 

Hello,

here's a patch that implements nautilus_view_close_window (). It's for
Nautilus HEAD though.

Darin, is this ok to commit?

//andersca
andersca gnu org
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.4901
diff -u -r1.4901 ChangeLog
--- ChangeLog	2002/01/08 09:41:09	1.4901
+++ ChangeLog	2002/01/08 15:05:56
@@ -1,3 +1,23 @@
+2002-01-08  Anders Carlsson  <andersca gnu org>
+
+	* libnautilus-private/nautilus-icon-container.c:
+	(nautilus_icon_container_update_icon):
+	* libnautilus/nautilus-view-component.idl:
+	* libnautilus/nautilus-view.c: (call_close_window),
+	(nautilus_view_close_window):
+	* libnautilus/nautilus-view.h:
+	* src/nautilus-profiler.c:
+	(nautilus_profiler_bonobo_ui_report_callback):
+	* src/nautilus-view-frame-corba.c: (close_window),
+	(impl_Nautilus_ViewFrame_close_window),
+	(nautilus_view_frame_corba_part_class_init):
+	* src/nautilus-view-frame-private.h:
+	* src/nautilus-view-frame.c: (nautilus_view_frame_close_window),
+	(nautilus_view_frame_class_init):
+	* src/nautilus-view-frame.h:
+	* src/nautilus-window-manage-views.c: (close_window_callback):
+	Implement nautilus_view_close_window ().
+	
 2002-01-08  Anders Carlsson  <andersca gnu org>
  
 	* src/nautilus-zoom-control.c (nautilus_zoom_control_finalize): Remove
Index: libnautilus/nautilus-view-component.idl
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus/nautilus-view-component.idl,v
retrieving revision 1.43
diff -u -r1.43 nautilus-view-component.idl
--- libnautilus/nautilus-view-component.idl	2001/12/21 11:32:20	1.43
+++ libnautilus/nautilus-view-component.idl	2002/01/08 15:05:57
@@ -151,6 +151,7 @@
 		 * which does nothing if there's nowhere to go.
 		 */
 		oneway void go_back ();
+		oneway void close_window ();
 	};
 
 };
Index: libnautilus/nautilus-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus/nautilus-view.c,v
retrieving revision 1.87
diff -u -r1.87 nautilus-view.c
--- libnautilus/nautilus-view.c	2001/12/21 11:32:20	1.87
+++ libnautilus/nautilus-view.c	2002/01/08 15:05:57
@@ -763,6 +763,22 @@
 	view_frame_call_end (view_frame, &ev);
 }
 
+
+static void
+call_close_window (NautilusView *view,
+		   gpointer callback_data)
+{
+	CORBA_Environment ev;
+	Nautilus_ViewFrame view_frame;
+	
+	view_frame = view_frame_call_begin (view, &ev);
+	if (view_frame != CORBA_OBJECT_NIL) {
+		Nautilus_ViewFrame_close_window (view_frame, &ev);
+	}
+	view_frame_call_end (view_frame, &ev);
+}
+
+
 void
 nautilus_view_open_location_in_this_window (NautilusView *view,
 					    const char *location)
@@ -915,6 +931,16 @@
 			     NULL,
 			     NULL);
 }
+
+void
+nautilus_view_close_window (NautilusView *view)
+{
+	queue_outgoing_call (view,
+			     call_close_window,
+			     NULL,
+			     NULL);
+}
+
 
 BonoboControl *
 nautilus_view_get_bonobo_control (NautilusView *view)
Index: libnautilus/nautilus-view.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus/nautilus-view.h,v
retrieving revision 1.46
diff -u -r1.46 nautilus-view.h
--- libnautilus/nautilus-view.h	2001/12/21 11:32:20	1.46
+++ libnautilus/nautilus-view.h	2002/01/08 15:05:57
@@ -98,6 +98,7 @@
 void               nautilus_view_set_title                            (NautilusView           *view,
 								       const char             *title);
 void               nautilus_view_go_back                              (NautilusView           *view);
+void               nautilus_view_close_window                         (NautilusView           *view);
 
 /* Some utility functions useful for doing the CORBA work directly.
  * Not needed by most components, but shared with the view frame code,
Index: src/nautilus-view-frame-corba.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-view-frame-corba.c,v
retrieving revision 1.40
diff -u -r1.40 nautilus-view-frame-corba.c
--- src/nautilus-view-frame-corba.c	2001/11/04 21:41:05	1.40
+++ src/nautilus-view-frame-corba.c	2002/01/08 15:05:57
@@ -187,6 +187,13 @@
 }
 
 static void
+close_window (NautilusViewFrame *view,
+	      gpointer callback_data)
+{
+	nautilus_view_frame_close_window (view);
+}
+
+static void
 impl_Nautilus_ViewFrame_open_location_in_this_window (PortableServer_Servant servant,
 						      const CORBA_char *location,
 						      CORBA_Environment *ev)
@@ -367,6 +374,14 @@
 }
 
 static void
+impl_Nautilus_ViewFrame_close_window (PortableServer_Servant servant,
+				      CORBA_Environment *ev)
+{
+	nautilus_view_frame_queue_incoming_call
+		(servant, close_window, NULL, NULL);
+}
+
+static void
 nautilus_view_frame_corba_part_class_init (NautilusViewFrameCorbaPartClass *class)
 {
 	class->epv.open_location_in_this_window = impl_Nautilus_ViewFrame_open_location_in_this_window;
@@ -382,6 +397,7 @@
 	class->epv.report_load_failed = impl_Nautilus_ViewFrame_report_load_failed;
 	class->epv.set_title = impl_Nautilus_ViewFrame_set_title;
 	class->epv.go_back = impl_Nautilus_ViewFrame_go_back;
+	class->epv.close_window = impl_Nautilus_ViewFrame_close_window;
 }
 
 static void
Index: src/nautilus-view-frame-private.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-view-frame-private.h,v
retrieving revision 1.34
diff -u -r1.34 nautilus-view-frame-private.h
--- src/nautilus-view-frame-private.h	2001/10/31 00:30:59	1.34
+++ src/nautilus-view-frame-private.h	2002/01/08 15:05:57
@@ -72,6 +72,7 @@
 void          nautilus_view_frame_set_title                            (NautilusViewFrame         *view,
                                                                         const char                *title);
 void          nautilus_view_frame_go_back                              (NautilusViewFrame         *view);
+void          nautilus_view_frame_close_window                         (NautilusViewFrame         *view);
 void          nautilus_view_frame_quit_nautilus                        (NautilusViewFrame         *view);
 void          nautilus_view_frame_close_desktop                        (NautilusViewFrame         *view);
 
Index: src/nautilus-view-frame.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-view-frame.c,v
retrieving revision 1.149
diff -u -r1.149 nautilus-view-frame.c
--- src/nautilus-view-frame.c	2001/12/21 11:32:26	1.149
+++ src/nautilus-view-frame.c	2002/01/08 15:05:57
@@ -58,6 +58,7 @@
 	FAILED,
 	GET_HISTORY_LIST,
 	GO_BACK,
+	CLOSE_WINDOW,
 	LOAD_COMPLETE,
 	LOAD_PROGRESS_CHANGED,
 	LOAD_UNDERWAY,
@@ -1254,6 +1255,14 @@
 }
 
 void
+nautilus_view_frame_close_window (NautilusViewFrame *view)
+{
+	g_return_if_fail (NAUTILUS_IS_VIEW_FRAME (view));
+
+	g_signal_emit (view, signals[CLOSE_WINDOW], 0);
+}
+
+void
 nautilus_view_frame_set_title (NautilusViewFrame *view,
                                const char *title)
 {
@@ -1428,6 +1437,15 @@
 		 G_SIGNAL_RUN_LAST,
 		 G_STRUCT_OFFSET (NautilusViewFrameClass, 
 				  go_back),
+		 NULL, NULL,
+		 gtk_marshal_VOID__VOID,
+		 G_TYPE_NONE, 0);
+	signals[CLOSE_WINDOW] = g_signal_new
+		("close_window",
+		 G_TYPE_FROM_CLASS (class),
+		 G_SIGNAL_RUN_LAST,
+		 G_STRUCT_OFFSET (NautilusViewFrameClass, 
+				  close_window),
 		 NULL, NULL,
 		 gtk_marshal_VOID__VOID,
 		 G_TYPE_NONE, 0);
Index: src/nautilus-view-frame.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-view-frame.h,v
retrieving revision 1.67
diff -u -r1.67 nautilus-view-frame.h
--- src/nautilus-view-frame.h	2001/10/28 20:21:48	1.67
+++ src/nautilus-view-frame.h	2002/01/08 15:05:57
@@ -92,6 +92,7 @@
         void               (* zoom_parameters_changed)              (NautilusViewFrame *view);
 	Nautilus_History * (* get_history_list)                     (NautilusViewFrame *view);
         void               (* go_back)                              (NautilusViewFrame *view);
+        void               (* close_window)                         (NautilusViewFrame *view);
 } NautilusViewFrameClass;
 
 /* basic view management */
Index: src/nautilus-window-manage-views.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/nautilus-window-manage-views.c,v
retrieving revision 1.278
diff -u -r1.278 nautilus-window-manage-views.c
--- src/nautilus-window-manage-views.c	2001/12/12 20:14:52	1.278
+++ src/nautilus-window-manage-views.c	2002/01/08 15:05:57
@@ -1704,6 +1704,15 @@
 }
 
 static void
+close_window_callback (NautilusViewFrame *view,
+                       NautilusWindow *window)
+{
+        g_assert (NAUTILUS_IS_WINDOW (window));
+
+        nautilus_window_close (window);
+}
+
+static void
 change_selection_callback (NautilusViewFrame *view,
                            GList *selection,
                            NautilusWindow *window)
@@ -1925,6 +1934,7 @@
 	macro (failed)					\
 	macro (get_history_list)			\
 	macro (go_back)					\
+        macro (close_window)                            \
 	macro (load_complete)				\
 	macro (load_underway)				\
 	macro (open_location_force_new_window)		\


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]