bonobo property page fix



Hi,

So I've finally got around to converting the bonobo property page stuff to use regular bonobo controls (with a "URI" property) instead of NautilusView.  Ok to commit?

Thanks,
James
Index: components/image_properties/nautilus-image-properties-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/components/image_properties/nautilus-image-properties-view.c,v
retrieving revision 1.1
diff -u -r1.1 nautilus-image-properties-view.c
--- components/image_properties/nautilus-image-properties-view.c	24 Oct 2002 15:54:32 -0000	1.1
+++ components/image_properties/nautilus-image-properties-view.c	8 Nov 2002 01:39:29 -0000
@@ -44,8 +44,9 @@
 	char buffer[LOAD_BUFFER_SIZE];
 };
 
-BONOBO_CLASS_BOILERPLATE (NautilusImagePropertiesView, nautilus_image_properties_view,
-			  NautilusView, NAUTILUS_TYPE_VIEW)
+enum {
+	PROP_URI,
+};
 
 static void
 nautilus_image_properties_view_finalize (GObject *object)
@@ -194,23 +195,31 @@
 }
 
 static void
-image_load_location_callback (NautilusView *nautilus_view, 
-			      const char *location,
-			      gpointer user_data)
+get_property (BonoboPropertyBag *bag,
+	      BonoboArg         *arg,
+	      guint              arg_id,
+	      CORBA_Environment *ev,
+	      gpointer           user_data)
 {
-	NautilusImagePropertiesView *view;
-	
-	g_assert (NAUTILUS_IS_VIEW (nautilus_view));
-	g_assert (location != NULL);
-	
-	view = NAUTILUS_IMAGE_PROPERTIES_VIEW (nautilus_view);
-	
-	nautilus_view_report_load_underway (nautilus_view);
-	
-	/* Do the actual load. */
-	load_location (view, location);
-	
-	nautilus_view_report_load_complete (nautilus_view);
+	NautilusImagePropertiesView *view = user_data;
+
+	if (arg_id == PROP_URI) {
+		BONOBO_ARG_SET_STRING (arg, view->details->location);
+	}
+}
+
+static void
+set_property (BonoboPropertyBag *bag,
+	      const BonoboArg   *arg,
+	      guint              arg_id,
+	      CORBA_Environment *ev,
+	      gpointer           user_data)
+{
+	NautilusImagePropertiesView *view = user_data;
+
+	if (arg_id == PROP_URI) {
+		load_location (view, BONOBO_ARG_GET_STRING (arg));
+	}
 }
 
 static void
@@ -220,8 +229,10 @@
 }
 
 static void
-nautilus_image_properties_view_instance_init (NautilusImagePropertiesView *view)
+nautilus_image_properties_view_init (NautilusImagePropertiesView *view)
 {
+	BonoboPropertyBag *pb;
+
 	view->details = g_new0 (NautilusImagePropertiesViewDetails, 1);
 
 	view->details->vbox = gtk_vbox_new (FALSE, 2);
@@ -233,9 +244,14 @@
 	
 	gtk_widget_show_all (view->details->vbox);
 	
-	nautilus_view_construct (NAUTILUS_VIEW (view), view->details->vbox);
-	
-	g_signal_connect (view, "load_location",
-			  G_CALLBACK (image_load_location_callback), NULL);
+	bonobo_control_construct (BONOBO_CONTROL (view), view->details->vbox);
 
+	pb = bonobo_property_bag_new (get_property, set_property,
+				      view);
+	bonobo_property_bag_add (pb, "URI", 0, BONOBO_ARG_STRING,
+				 NULL, _("URI currently displayed"), 0);
+	bonobo_control_set_properties (BONOBO_CONTROL (view),
+				       BONOBO_OBJREF (pb), NULL);
 }
+
+BONOBO_TYPE_FUNC (NautilusImagePropertiesView, BONOBO_TYPE_CONTROL, nautilus_image_properties_view);
Index: components/image_properties/nautilus-image-properties-view.h
===================================================================
RCS file: /cvs/gnome/nautilus/components/image_properties/nautilus-image-properties-view.h,v
retrieving revision 1.1
diff -u -r1.1 nautilus-image-properties-view.h
--- components/image_properties/nautilus-image-properties-view.h	24 Oct 2002 15:54:32 -0000	1.1
+++ components/image_properties/nautilus-image-properties-view.h	8 Nov 2002 01:39:29 -0000
@@ -35,12 +35,12 @@
 typedef struct NautilusImagePropertiesViewDetails NautilusImagePropertiesViewDetails;
 
 typedef struct {
-	NautilusView parent;
+	BonoboControl parent;
 	NautilusImagePropertiesViewDetails *details;
 } NautilusImagePropertiesView;
 
 typedef struct {
-	NautilusViewClass parent;
+	BonoboControlClass parent;
 } NautilusImagePropertiesViewClass;
 
 GType nautilus_image_properties_view_get_type (void);
Index: components/notes/nautilus-notes.c
===================================================================
RCS file: /cvs/gnome/nautilus/components/notes/nautilus-notes.c,v
retrieving revision 1.86
diff -u -r1.86 nautilus-notes.c
--- components/notes/nautilus-notes.c	19 Jul 2002 20:27:27 -0000	1.86
+++ components/notes/nautilus-notes.c	8 Nov 2002 01:39:30 -0000
@@ -58,6 +58,7 @@
 /* property bag getting and setting routines */
 enum {
 	TAB_IMAGE,
+	NOTES_URI,
 };
 
 typedef struct {
@@ -75,6 +76,9 @@
 static char *notes_get_indicator_image   (const char *notes_text);
 static void  notify_listeners_if_changed (Notes      *notes,
                                           char       *new_notes);
+static void  notes_load_location         (NautilusView *view,
+					  const char *location,
+					  Notes *notes);
 
 static void
 get_bonobo_properties (BonoboPropertyBag *bag,
@@ -111,7 +115,11 @@
 			CORBA_Environment *ev,
 			gpointer callback_data)
 {
-	g_warning ("Can't set note property %u", arg_id);
+	if (arg_id == NOTES_URI) {
+		notes_load_location (NULL,
+				     BONOBO_ARG_GET_STRING (arg),
+				     (Notes *)callback_data);
+	}
 }
 
 static gboolean
@@ -353,7 +361,7 @@
 static BonoboObject *
 make_notes_view ()
 {
-        GtkWidget *vbox;
+        GtkWidget *vbox, *viewport;
         Notes *notes;
         notes = g_new0 (Notes, 1);
         notes->uri = g_strdup ("");
@@ -373,7 +381,11 @@
 	gtk_text_view_set_editable (GTK_TEXT_VIEW (notes->note_text_field), TRUE);	
         gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (notes->note_text_field),
                                      GTK_WRAP_WORD);
-        gtk_box_pack_start (GTK_BOX (vbox), notes->note_text_field, TRUE, TRUE, 0);
+	viewport = gtk_viewport_new (NULL, NULL);
+	gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport),
+				      GTK_SHADOW_IN);
+	gtk_container_add (GTK_CONTAINER (viewport), notes->note_text_field);
+        gtk_box_pack_start (GTK_BOX (vbox), viewport, TRUE, TRUE, 0);
 
 	g_signal_connect (notes->note_text_field, "focus_out_event",
                           G_CALLBACK (on_text_field_focus_out_event), notes);
@@ -391,6 +403,9 @@
 	bonobo_control_set_properties (nautilus_view_get_bonobo_control (notes->view), BONOBO_OBJREF (notes->property_bag), NULL);
 	bonobo_property_bag_add (notes->property_bag, "tab_image", TAB_IMAGE, BONOBO_ARG_STRING, NULL,
 				 "image indicating that a note is present", 0);
+	bonobo_property_bag_add (notes->property_bag, "URI",
+				 NOTES_URI, BONOBO_ARG_STRING,
+				 NULL, "URI of selected file", 0);
         /* handle events */
         g_signal_connect (notes->view, "load_location",
                           G_CALLBACK (notes_load_location), notes);
Index: libnautilus-private/nautilus-mime-actions.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-mime-actions.c,v
retrieving revision 1.103
diff -u -r1.103 nautilus-mime-actions.c
--- libnautilus-private/nautilus-mime-actions.c	7 Nov 2002 19:20:39 -0000	1.103
+++ libnautilus-private/nautilus-mime-actions.c	8 Nov 2002 01:39:31 -0000
@@ -842,6 +842,44 @@
 	return info_list;
 }
 
+GList *
+nautilus_mime_get_property_components_for_file (NautilusFile *file)
+{
+        char *mime_type;
+        char *uri_scheme;
+        char *extra_reqs;
+        GList *item_mime_types;
+        GList *info_list;
+
+        if (!nautilus_mime_actions_check_if_minimum_attributes_ready (file)) {
+                return NULL;
+        }
+
+        uri_scheme = nautilus_file_get_uri_scheme (file);
+
+        mime_type = nautilus_file_get_mime_type (file);
+
+        if (!nautilus_mime_actions_check_if_full_attributes_ready (file) ||
+            !nautilus_file_get_directory_item_mime_types (file, &item_mime_types
+)) {
+                item_mime_types = NULL;
+        }
+
+        extra_reqs = "repo_ids.has ('IDL:Bonobo/Control:1.0') AND nautilus:property_page_name.defined()";
+
+        info_list = nautilus_do_component_query (mime_type, uri_scheme,
+                                                 item_mime_types, FALSE,
+                                                 NULL, NULL,
+                                                 extra_reqs, FALSE);
+
+        eel_g_list_free_deep (item_mime_types);
+
+        g_free (uri_scheme);
+        g_free (mime_type);
+
+        return info_list;
+}     
+
 static gboolean
 has_server_info_in_list (GList *list, Bonobo_ServerInfo *info)
 {
Index: libnautilus-private/nautilus-mime-actions.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-mime-actions.h,v
retrieving revision 1.26
diff -u -r1.26 nautilus-mime-actions.h
--- libnautilus-private/nautilus-mime-actions.h	7 Nov 2002 19:20:39 -0000	1.26
+++ libnautilus-private/nautilus-mime-actions.h	8 Nov 2002 01:39:31 -0000
@@ -46,6 +46,7 @@
 GList *                  nautilus_mime_get_all_components_for_file_extended        (NautilusFile           *file, char *extra_requirements);
 GList *                  nautilus_mime_get_popup_components_for_file               (NautilusFile           *file);
 GList *                  nautilus_mime_get_popup_components_for_files              (GList                  *files);
+GList *                  nautilus_mime_get_property_components_for_file            (NautilusFile           *file);
  gboolean                 nautilus_mime_has_any_components_for_file                 (NautilusFile           *file);
  gboolean                 nautilus_mime_has_any_components_for_file_extended        (NautilusFile           *file, char *extra_requirements);
 gboolean                 nautilus_mime_has_any_applications_for_file               (NautilusFile           *file);
Index: src/file-manager/fm-properties-window.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-properties-window.c,v
retrieving revision 1.161
diff -u -r1.161 fm-properties-window.c
--- src/file-manager/fm-properties-window.c	6 Nov 2002 10:39:12 -0000	1.161
+++ src/file-manager/fm-properties-window.c	8 Nov 2002 01:39:32 -0000
@@ -2206,22 +2206,26 @@
 
 	if (obj != CORBA_OBJECT_NIL) {
 		Bonobo_Control control;
-		Nautilus_View view;
+		Bonobo_PropertyBag pb;
+		BonoboArg *arg;
 		char *uri;
 		
+		uri = nautilus_file_get_uri (window->details->target_file);
+
 		control = Bonobo_Unknown_queryInterface
 				(obj, "IDL:Bonobo/Control:1.0", &ev);
 
-		view = Bonobo_Unknown_queryInterface
-				(control, "IDL:Nautilus/View:1.0", &ev);
-
-		uri = nautilus_file_get_uri (window->details->target_file);
+		arg = bonobo_arg_new (BONOBO_ARG_STRING);
+		BONOBO_ARG_SET_STRING (arg, uri);
 
-		Nautilus_View_load_location (view, uri, &ev);
+		pb = Bonobo_Control_getProperties (control, &ev);
+		bonobo_pbclient_set_value_async (pb, "URI", arg, &ev);
+		bonobo_arg_release (arg);
 		
 		if (!BONOBO_EX (&ev)) {
 			widget = bonobo_widget_new_control_from_objref
 						(control, CORBA_OBJECT_NIL);
+			bonobo_object_release_unref (control, NULL);
 		}
 
 		g_free (uri);
@@ -2245,10 +2249,9 @@
 	GList *components, *l;
 	CORBA_Environment ev;
 
-	/* find all the property page views for this file */
-	components = nautilus_mime_get_all_components_for_file_extended
-		(window->details->target_file,
-		 "nautilus:property_page_name.defined()");
+	/* find all the property pages for this file */
+	components = nautilus_mime_get_property_components_for_file
+					(window->details->target_file);
 	
 	CORBA_exception_init (&ev);
 


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