Hi, I've attached a patch that makes it possible to have mime-type-sensitive pages in the properties dialog. It uses the good 'ol NautilusView stuff people are used to, so there wasn't much required to make it happen. I've also attached a sample view that lets you see metadata contained in audio files (mp3, ogg, etc). Let me know what you think. Thanks, James Oh, here's a screenshot: http://www.cs.indiana.edu/~jwillcox/files/screenshots/nautilus-music-properties.png
Index: configure.in
===================================================================
RCS file: /cvs/gnome/nautilus/configure.in,v
retrieving revision 1.477
diff -u -r1.477 configure.in
--- configure.in 19 Oct 2002 22:38:47 -0000 1.477
+++ configure.in 24 Oct 2002 02:50:43 -0000
@@ -298,6 +298,13 @@
EMBLEM_COMPONENT_LIBS="`$PKG_CONFIG --libs $EMBLEM_COMPONENT_MODULES`"
AC_SUBST(EMBLEM_COMPONENT_LIBS)
+dnl music properties component
+MUSIC_PROPERTIES_COMPONENT_MODULES="$COMPONENT_MODULES monkey-media"
+MUSIC_PROPERTIES_COMPONENT_CFLAGS="`$PKG_CONFIG --cflags $MUSIC_PROPERTIES_COMPONENT_MODULES`"
+AC_SUBST(MUSIC_PROPERTIES_COMPONENT_CFLAGS)
+MUSIC_PROPERTIES_COMPONENT_LIBS="`$PKG_CONFIG --libs $MUSIC_PROPERTIES_COMPONENT_MODULES`"
+AC_SUBST(MUSIC_PROPERTIES_COMPONENT_LIBS)
+
DISABLE_DEPRECATED_CFLAGS=" \
-DG_DISABLE_DEPRECATED \
-DGDK_DISABLE_DEPRECATED \
@@ -357,6 +364,7 @@
components/throbber/Makefile
components/tree/Makefile
components/emblem/Makefile
+components/music_properties/Makefile
cut-n-paste-code/Makefile
cut-n-paste-code/widgets/Makefile
cut-n-paste-code/widgets/gimphwrapbox/Makefile
Index: components/Makefile.am
===================================================================
RCS file: /cvs/gnome/nautilus/components/Makefile.am,v
retrieving revision 1.41
diff -u -r1.41 Makefile.am
--- components/Makefile.am 4 Oct 2002 10:42:00 -0000 1.41
+++ components/Makefile.am 24 Oct 2002 02:50:44 -0000
@@ -12,6 +12,7 @@
throbber \
tree \
emblem \
+ music_properties \
$(NULL)
Index: libnautilus-private/nautilus-mime-actions.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-mime-actions.c,v
retrieving revision 1.100
diff -u -r1.100 nautilus-mime-actions.c
--- libnautilus-private/nautilus-mime-actions.c 9 May 2002 20:21:34 -0000 1.100
+++ libnautilus-private/nautilus-mime-actions.c 24 Oct 2002 02:50:45 -0000
@@ -767,7 +767,8 @@
GList *
-nautilus_mime_get_all_components_for_file (NautilusFile *file)
+nautilus_mime_get_all_components_for_file_extended (NautilusFile *file,
+ char *extra_reqs)
{
char *mime_type;
char *uri_scheme;
@@ -789,8 +790,10 @@
item_mime_types = NULL;
}
- info_list = nautilus_do_component_query (mime_type, uri_scheme, item_mime_types, FALSE,
- explicit_iids, NULL, NULL);
+ info_list = nautilus_do_component_query (mime_type, uri_scheme,
+ item_mime_types, FALSE,
+ explicit_iids, NULL,
+ extra_reqs);
eel_g_list_free_deep (explicit_iids);
eel_g_list_free_deep (item_mime_types);
@@ -799,6 +802,12 @@
g_free (mime_type);
return info_list;
+}
+
+GList *
+nautilus_mime_get_all_components_for_file (NautilusFile *file)
+{
+ return nautilus_mime_get_all_components_for_file_extended (file, NULL);
}
gboolean
Index: libnautilus-private/nautilus-mime-actions.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-mime-actions.h,v
retrieving revision 1.23
diff -u -r1.23 nautilus-mime-actions.h
--- libnautilus-private/nautilus-mime-actions.h 30 Oct 2001 00:26:25 -0000 1.23
+++ libnautilus-private/nautilus-mime-actions.h 24 Oct 2002 02:50:45 -0000
@@ -43,7 +43,8 @@
GList * nautilus_mime_get_short_list_components_for_file (NautilusFile *file);
GList * nautilus_mime_get_all_applications_for_file (NautilusFile *file);
GList * nautilus_mime_get_all_components_for_file (NautilusFile *file);
-gboolean nautilus_mime_has_any_components_for_file (NautilusFile *file);
+GList * nautilus_mime_get_all_components_for_file_extended (NautilusFile *file, char *extra_requirements);
+ gboolean nautilus_mime_has_any_components_for_file (NautilusFile *file);
gboolean nautilus_mime_has_any_applications_for_file (NautilusFile *file);
gboolean nautilus_mime_has_any_applications_for_file_type (NautilusFile *file);
GnomeVFSResult nautilus_mime_set_default_action_type_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.157
diff -u -r1.157 fm-properties-window.c
--- src/file-manager/fm-properties-window.c 4 Oct 2002 16:05:55 -0000 1.157
+++ src/file-manager/fm-properties-window.c 24 Oct 2002 02:50:45 -0000
@@ -68,7 +68,12 @@
#include <libnautilus-private/nautilus-link.h>
#include <libnautilus-private/nautilus-metadata.h>
#include <libnautilus-private/nautilus-undo-signal-handlers.h>
+#include <libnautilus-private/nautilus-mime-actions.h>
+#include <libnautilus-private/nautilus-view-identifier.h>
#include <libnautilus/nautilus-undo.h>
+#include <libnautilus/nautilus-view.h>
+#include <bonobo/bonobo-widget.h>
+#include <bonobo/bonobo-exception.h>
#include <string.h>
static GHashTable *windows;
@@ -2101,6 +2106,100 @@
}
}
+static GtkWidget *
+bonobo_page_error_message (NautilusViewIdentifier *view_id,
+ CORBA_Environment *ev)
+{
+ GtkWidget *hbox;
+ GtkWidget *label;
+ GtkWidget *image;
+ char *msg;
+
+ hbox = gtk_hbox_new (FALSE, GNOME_PAD);
+ image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_ERROR,
+ GTK_ICON_SIZE_DIALOG);
+
+ msg = g_strdup_printf ("There was an error while trying to create the view named `%s': %s", view_id->name, CORBA_exception_id (ev));
+ label = gtk_label_new (msg);
+ g_free (msg);
+
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+
+ gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ return hbox;
+}
+
+static void
+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()");
+
+ CORBA_exception_init (&ev);
+
+ l = components;
+ while (l != NULL) {
+ NautilusViewIdentifier *view_id;
+ Bonobo_ServerInfo *server;
+ GtkWidget *vbox, *widget;
+ Bonobo_Unknown obj;
+
+ widget = NULL;
+
+ server = l->data;
+ l = l->next;
+
+ view_id = nautilus_view_identifier_new_from_property_page (server);
+
+ obj = bonobo_activation_activate_from_id (view_id->iid,
+ 0, NULL, &ev);
+
+ if (!BONOBO_EX (&ev)) {
+ Bonobo_Control control;
+ Nautilus_View view;
+ char *uri;
+
+ 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);
+
+ Nautilus_View_load_location (view, uri, &ev);
+
+ if (!BONOBO_EX (&ev)) {
+ widget = bonobo_widget_new_control_from_objref
+ (control, CORBA_OBJECT_NIL);
+ }
+
+ g_free (uri);
+ }
+
+ if (widget == NULL) {
+ widget = bonobo_page_error_message (view_id, &ev);
+ }
+
+
+ vbox = create_page_with_vbox (window->details->notebook,
+ view_id->name);
+ gtk_container_add (GTK_CONTAINER (vbox), widget);
+ gtk_widget_show_all (vbox);
+
+ nautilus_view_identifier_free (view_id);
+ }
+
+}
+
static gboolean
should_show_emblems (FMPropertiesWindow *window)
{
@@ -2222,6 +2321,9 @@
if (should_show_permissions (window)) {
create_permissions_page (window);
}
+
+ /* append pages from available views */
+ append_bonobo_pages (window);
/* Create box for close button. */
hbox = gtk_hbutton_box_new ();
Attachment:
music_properties.tar.gz
Description: GNU Zip compressed data