diff options
author | James Willcox <jwillcox@gnome.org> | 2002-11-08 20:54:45 +0000 |
---|---|---|
committer | James Willcox <jwillcox@src.gnome.org> | 2002-11-08 20:54:45 +0000 |
commit | c64f0a3a0f643f1e9217432f78e9b0d4513acb19 (patch) | |
tree | b2e85654adae1b9d1a6524ad02a23f462ff0c847 | |
parent | 78c433e00e6d9dfcde9ff54f860982fb1194da29 (diff) | |
download | nautilus-c64f0a3a0f643f1e9217432f78e9b0d4513acb19.tar.gz |
Make bonobo property pages regular controls instead of NautilusViews.
2002-11-08 James Willcox <jwillcox@gnome.org>
* components/image_properties/nautilus-image-properties-view.c:
(get_property), (set_property),
(nautilus_image_properties_view_init):
* components/image_properties/nautilus-image-properties-view.h:
* components/notes/nautilus-notes.c: (set_bonobo_properties),
(make_notes_view):
* libnautilus-private/nautilus-mime-actions.c:
(nautilus_mime_get_property_components_for_file):
* libnautilus-private/nautilus-mime-actions.h:
* src/file-manager/fm-properties-window.c:
(bonobo_page_activate_callback), (append_bonobo_pages):
Make bonobo property pages regular controls instead of NautilusViews.
-rw-r--r-- | ChangeLog | 17 | ||||
-rw-r--r-- | components/image_properties/nautilus-image-properties-view.c | 65 | ||||
-rw-r--r-- | components/image_properties/nautilus-image-properties-view.h | 4 | ||||
-rw-r--r-- | components/notes/nautilus-notes.c | 25 | ||||
-rw-r--r-- | libnautilus-private/nautilus-mime-actions.c | 38 | ||||
-rw-r--r-- | libnautilus-private/nautilus-mime-actions.h | 1 | ||||
-rw-r--r-- | src/file-manager/fm-properties-window.c | 32 |
7 files changed, 141 insertions, 41 deletions
@@ -1,3 +1,20 @@ +2002-11-08 James Willcox <jwillcox@gnome.org> + + * components/image_properties/nautilus-image-properties-view.c: + (get_property), (set_property), + (nautilus_image_properties_view_init): + * components/image_properties/nautilus-image-properties-view.h: + * components/notes/nautilus-notes.c: (set_bonobo_properties), + (make_notes_view): + * libnautilus-private/nautilus-mime-actions.c: + (nautilus_mime_get_property_components_for_file): + * libnautilus-private/nautilus-mime-actions.h: + * src/file-manager/fm-properties-window.c: + (bonobo_page_activate_callback), (append_bonobo_pages): + + Make bonobo property pages regular controls instead of NautilusViews. + + 2002-11-07 James Willcox <jwillcox@gnome.org> * libnautilus-private/nautilus-mime-actions.c: diff --git a/components/image_properties/nautilus-image-properties-view.c b/components/image_properties/nautilus-image-properties-view.c index f16445c7c..1049a2116 100644 --- a/components/image_properties/nautilus-image-properties-view.c +++ b/components/image_properties/nautilus-image-properties-view.c @@ -44,8 +44,9 @@ struct NautilusImagePropertiesViewDetails { 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 @@ load_location (NautilusImagePropertiesView *view, } 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 @@ nautilus_image_properties_view_class_init (NautilusImagePropertiesViewClass *cla } 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,15 @@ nautilus_image_properties_view_instance_init (NautilusImagePropertiesView *view) 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_object_release_unref (BONOBO_OBJREF (pb), NULL); } + +BONOBO_TYPE_FUNC (NautilusImagePropertiesView, BONOBO_TYPE_CONTROL, nautilus_image_properties_view); diff --git a/components/image_properties/nautilus-image-properties-view.h b/components/image_properties/nautilus-image-properties-view.h index 5e9f9626f..4844c537c 100644 --- a/components/image_properties/nautilus-image-properties-view.h +++ b/components/image_properties/nautilus-image-properties-view.h @@ -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); diff --git a/components/notes/nautilus-notes.c b/components/notes/nautilus-notes.c index 80da5ace7..05e0501f9 100644 --- a/components/notes/nautilus-notes.c +++ b/components/notes/nautilus-notes.c @@ -37,6 +37,7 @@ #include <gtk/gtktextbuffer.h> #include <gtk/gtktextview.h> #include <gtk/gtkvbox.h> +#include <gtk/gtkscrolledwindow.h> #include <bonobo/bonobo-property-bag.h> #include <libnautilus-private/nautilus-file-attributes.h> #include <libnautilus-private/nautilus-file.h> @@ -58,6 +59,7 @@ /* property bag getting and setting routines */ enum { TAB_IMAGE, + NOTES_URI, }; typedef struct { @@ -75,6 +77,9 @@ static void notes_save_metainfo (Notes *notes); 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 +116,11 @@ set_bonobo_properties (BonoboPropertyBag *bag, 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 +362,7 @@ notes_get_indicator_image (const char *notes_text) static BonoboObject * make_notes_view () { - GtkWidget *vbox; + GtkWidget *vbox, *scroll; Notes *notes; notes = g_new0 (Notes, 1); notes->uri = g_strdup (""); @@ -373,7 +382,14 @@ make_notes_view () 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); + scroll = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), + GTK_POLICY_NEVER, + GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), + GTK_SHADOW_IN); + gtk_container_add (GTK_CONTAINER (scroll), notes->note_text_field); + gtk_box_pack_start (GTK_BOX (vbox), scroll, TRUE, TRUE, 0); g_signal_connect (notes->note_text_field, "focus_out_event", G_CALLBACK (on_text_field_focus_out_event), notes); @@ -391,6 +407,9 @@ make_notes_view () 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); diff --git a/libnautilus-private/nautilus-mime-actions.c b/libnautilus-private/nautilus-mime-actions.c index 001d734e8..0eda7ef5c 100644 --- a/libnautilus-private/nautilus-mime-actions.c +++ b/libnautilus-private/nautilus-mime-actions.c @@ -842,6 +842,44 @@ nautilus_mime_get_popup_components_for_file (NautilusFile *file) 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) { diff --git a/libnautilus-private/nautilus-mime-actions.h b/libnautilus-private/nautilus-mime-actions.h index f10920d61..6939cdabf 100644 --- a/libnautilus-private/nautilus-mime-actions.h +++ b/libnautilus-private/nautilus-mime-actions.h @@ -46,6 +46,7 @@ GList * nautilus_mime_get_all_components_for_file 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); diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c index 4ada1d38d..d6ac2f854 100644 --- a/src/file-manager/fm-properties-window.c +++ b/src/file-manager/fm-properties-window.c @@ -2206,22 +2206,31 @@ bonobo_page_activate_callback (CORBA_Object obj, 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); + pb = Bonobo_Control_getProperties (control, &ev); - Nautilus_View_load_location (view, uri, &ev); - if (!BONOBO_EX (&ev)) { - widget = bonobo_widget_new_control_from_objref - (control, CORBA_OBJECT_NIL); + arg = bonobo_arg_new (BONOBO_ARG_STRING); + BONOBO_ARG_SET_STRING (arg, uri); + + bonobo_pbclient_set_value_async (pb, "URI", arg, &ev); + bonobo_arg_release (arg); + bonobo_object_release_unref (pb, NULL); + + if (!BONOBO_EX (&ev)) { + widget = bonobo_widget_new_control_from_objref + (control, CORBA_OBJECT_NIL); + bonobo_object_release_unref (control, &ev); + } } g_free (uri); @@ -2245,10 +2254,9 @@ append_bonobo_pages (FMPropertiesWindow *window) 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); |