I've improved my patch by allowing plugin widgets to request a new location. Also, I've coded two additional small examples (one showing the load_uri signal, the other a simple tracker tags integration): http://diuf.unifr.ch/pai/people/broccoa/dev/simple-sidebar-plugin-v2.tar.gz (load_uri callback) http://diuf.unifr.ch/pai/people/broccoa/dev/tracker-sidebar-plugin.tar.gz (tracker sidebar for showing tags associated with files) A+A. -- Amos Brocco | Ph.D Student | Computer Science Department - DIUF | University of Fribourg | A406 Pérolles 21 | Bd. Pérolles 90 | CH-1700 Fribourg | http://diuf.unifr.ch/pai/people/broccoa
--- nautilus-2.22.0/libnautilus-extension/nautilus-sidebar-widget-provider.h 1970-01-01 01:00:00.000000000 +0100
+++ nautilus-2.22.0-workspace/libnautilus-extension/nautilus-sidebar-widget-provider.h 2008-03-23 16:56:51.000000000 +0100
@@ -0,0 +1,62 @@
+/*
+ * nautilus-sidebar-widget-provider.c - Interface for Nautilus extensions that
+ * provide sidebar widgets.
+ *
+ * Copyright (C) 2008 Amos Brocco
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+/* This interface is implemented by Nautilus extensions that want to
+ * provide information sidebar widgets. Those widges are created along
+ * with the Information sidebar.
+ */
+
+#ifndef NAUTILUS_SIDEBAR_WIDGET_PROVIDER_H
+#define NAUTILUS_SIDEBAR_WIDGET_PROVIDER_H
+
+#include <glib-object.h>
+#include <gtk/gtkwidget.h>
+#include "nautilus-extension-types.h"
+#include "nautilus-sidebar-widget.h"
+
+G_BEGIN_DECLS
+
+#define NAUTILUS_TYPE_SIDEBAR_WIDGET_PROVIDER (nautilus_sidebar_widget_provider_get_type ())
+#define NAUTILUS_SIDEBAR_WIDGET_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_SIDEBAR_WIDGET_PROVIDER, NautilusSidebarWidgetProvider))
+#define NAUTILUS_IS_SIDEBAR_WIDGET_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_SIDEBAR_WIDGET_PROVIDER))
+#define NAUTILUS_SIDEBAR_WIDGET_PROVIDER_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NAUTILUS_TYPE_SIDEBAR_WIDGET_PROVIDER, NautilusSidebarWidgetProviderIface))
+
+typedef struct _NautilusSidebarWidgetProvider NautilusSidebarWidgetProvider;
+typedef struct _NautilusSidebarWidgetProviderIface NautilusSidebarWidgetProviderIface;
+
+struct _NautilusSidebarWidgetProviderIface {
+ GTypeInterface g_iface;
+
+ NautilusSidebarWidget* (*get_widget) (NautilusSidebarWidgetProvider *provider);
+ char* (*get_name) (NautilusSidebarWidgetProvider *provider);
+ int (*get_order) (NautilusSidebarWidgetProvider *provider);
+};
+
+/* Interface Functions */
+GType nautilus_sidebar_widget_provider_get_type (void);
+NautilusSidebarWidget* nautilus_sidebar_widget_provider_get_widget (NautilusSidebarWidgetProvider* provider);
+gchar* nautilus_sidebar_widget_provider_get_name (NautilusSidebarWidgetProvider* provider);
+int nautilus_sidebar_widget_provider_get_order (NautilusSidebarWidgetProvider* provider);
+
+G_END_DECLS
+
+#endif
--- nautilus-2.22.0/libnautilus-extension/Makefile.in 2008-03-11 00:28:38.000000000 +0100
+++ nautilus-2.22.0-workspace/libnautilus-extension/Makefile.in 2008-03-23 17:06:40.000000000 +0100
@@ -64,6 +64,7 @@ am__objects_1 =
am_libnautilus_extension_la_OBJECTS = nautilus-column-provider.lo \
nautilus-column.lo nautilus-extension-types.lo \
nautilus-file-info.lo nautilus-info-provider.lo \
+ nautilus-sidebar-widget.lo nautilus-sidebar-widget-provider.lo \
nautilus-location-widget-provider.lo nautilus-menu-item.lo \
nautilus-menu-provider.lo nautilus-property-page-provider.lo \
nautilus-property-page.lo nautilus-menu.lo $(am__objects_1)
@@ -326,6 +327,8 @@ libnautilus_extension_include_HEADERS =
nautilus-menu-provider.h \
nautilus-property-page-provider.h \
nautilus-property-page.h \
+ nautilus-sidebar-widget.h \
+ nautilus-sidebar-widget-provider.h \
nautilus-menu.h \
$(NULL)
@@ -341,6 +344,8 @@ libnautilus_extension_la_SOURCES = \
nautilus-menu-provider.c \
nautilus-property-page-provider.c \
nautilus-property-page.c \
+ nautilus-sidebar-widget.c \
+ nautilus-sidebar-widget-provider.c \
nautilus-menu.c \
$(NULL)
@@ -434,6 +439,9 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote /$(DEPDIR)/nautilus-menu Plo am__quote@
@AMDEP_TRUE@@am__include@ @am__quote /$(DEPDIR)/nautilus-property-page-provider Plo am__quote@
@AMDEP_TRUE@@am__include@ @am__quote /$(DEPDIR)/nautilus-property-page Plo am__quote@
+ AMDEP_TRUE@@am__include@ @am__quote /$(DEPDIR)/nautilus-sidebar-widget-provider Plo am__quote@
+ AMDEP_TRUE@@am__include@ @am__quote /$(DEPDIR)/nautilus-sidebar-widget Plo am__quote@
+
.c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
--- nautilus-2.22.0/libnautilus-extension/nautilus-sidebar-widget-provider.c 1970-01-01 01:00:00.000000000 +0100
+++ nautilus-2.22.0-workspace/libnautilus-extension/nautilus-sidebar-widget-provider.c 2008-03-23 17:09:18.000000000 +0100
@@ -0,0 +1,85 @@
+/*
+ * nautilus-sidebar-widget-provider.c - Interface for Nautilus
+ extensions that provide extra widgets for the Information sidebar.
+ *
+ * Copyright (C) 2008 Amos Brocco
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <config.h>
+#include "nautilus-sidebar-widget-provider.h"
+
+#include <glib-object.h>
+
+static void
+nautilus_sidebar_widget_provider_base_init (gpointer g_class)
+{
+}
+
+GType
+nautilus_sidebar_widget_provider_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type) {
+ const GTypeInfo info = {
+ sizeof (NautilusSidebarWidgetProviderIface),
+ nautilus_sidebar_widget_provider_base_init,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ 0,
+ 0,
+ NULL
+ };
+
+ type = g_type_register_static (G_TYPE_INTERFACE,
+ "NautilusSidebarWidgetProvider",
+ &info, 0);
+ g_type_interface_add_prerequisite (type, G_TYPE_OBJECT);
+ }
+
+ return type;
+}
+
+NautilusSidebarWidget*
+nautilus_sidebar_widget_provider_get_widget (NautilusSidebarWidgetProvider* provider)
+{
+ g_return_val_if_fail (NAUTILUS_IS_SIDEBAR_WIDGET_PROVIDER (provider), NULL);
+
+ return NAUTILUS_SIDEBAR_WIDGET_PROVIDER_GET_IFACE (provider)->get_widget (provider);
+
+}
+
+gchar*
+nautilus_sidebar_widget_provider_get_name (NautilusSidebarWidgetProvider* provider)
+{
+ g_return_val_if_fail (NAUTILUS_IS_SIDEBAR_WIDGET_PROVIDER (provider), NULL);
+
+ return NAUTILUS_SIDEBAR_WIDGET_PROVIDER_GET_IFACE (provider)->get_name (provider);
+
+}
+
+int
+nautilus_sidebar_widget_provider_get_order (NautilusSidebarWidgetProvider* provider)
+{
+ g_return_val_if_fail (NAUTILUS_IS_SIDEBAR_WIDGET_PROVIDER (provider), -1);
+
+ return NAUTILUS_SIDEBAR_WIDGET_PROVIDER_GET_IFACE (provider)->get_order (provider);
+
+}
--- nautilus-2.22.0/libnautilus-extension/nautilus-sidebar-widget.c 1970-01-01 01:00:00.000000000 +0100
+++ nautilus-2.22.0-workspace/libnautilus-extension/nautilus-sidebar-widget.c 2008-03-24 18:56:42.000000000 +0100
@@ -0,0 +1,105 @@
+/*
+ * nautilus-sidebar-widget-.c - Interface for Nautilus
+ extensions that provide extra widgets for the Information sidebar.
+ *
+ * Copyright (C) 2008 Amos Brocco
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <config.h>
+#include "nautilus-sidebar-widget.h"
+#include <glib-object.h>
+
+
+static void
+nautilus_sidebar_widget_base_init (gpointer g_class)
+{
+ static gboolean initialized = FALSE;
+
+ if (! initialized) {
+ g_signal_new ("load_uri",
+ NAUTILUS_TYPE_SIDEBAR_WIDGET,
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__STRING,
+ G_TYPE_NONE, 1,
+ G_TYPE_STRING);
+ initialized = TRUE;
+ }
+}
+
+GType
+nautilus_sidebar_widget_get_type (void)
+{
+ static GType type = 0;
+
+ if (!type) {
+ const GTypeInfo info = {
+ sizeof (NautilusSidebarWidgetIface),
+ nautilus_sidebar_widget_base_init,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ 0,
+ 0,
+ NULL
+ };
+
+ type = g_type_register_static (G_TYPE_INTERFACE,
+ "NautilusSidebarWidget",
+ &info, 0);
+ g_type_interface_add_prerequisite (type, GTK_TYPE_WIDGET);
+ }
+
+ return type;
+}
+
+GtkWidget*
+nautilus_sidebar_widget_get_widget (NautilusSidebarWidget* widget)
+{
+ g_return_val_if_fail (NAUTILUS_IS_SIDEBAR_WIDGET (widget), NULL);
+
+ return NAUTILUS_SIDEBAR_WIDGET_GET_IFACE (widget)->get_widget (widget);
+
+}
+
+void
+nautilus_sidebar_widget_selection_changed (NautilusSidebarWidget* widget, const GList* uris)
+{
+ g_return_if_fail (NAUTILUS_IS_SIDEBAR_WIDGET (widget));
+
+ NAUTILUS_SIDEBAR_WIDGET_GET_IFACE (widget)->selection_changed (widget, uris);
+}
+
+void
+nautilus_sidebar_widget_location_changed (NautilusSidebarWidget* widget, const char* uri)
+{
+ g_return_if_fail (NAUTILUS_IS_SIDEBAR_WIDGET (widget));
+
+ NAUTILUS_SIDEBAR_WIDGET_GET_IFACE (widget)->location_changed (widget, uri);
+}
+
+void
+nautilus_sidebar_widget_emit_load_uri (NautilusSidebarWidget* widget, const char* uri)
+{
+ g_return_if_fail (NAUTILUS_IS_SIDEBAR_WIDGET (widget));
+
+ g_signal_emit_by_name (widget, "load_uri", uri);
+}
+
--- nautilus-2.22.0/libnautilus-extension/nautilus-sidebar-widget.h 1970-01-01 01:00:00.000000000 +0100
+++ nautilus-2.22.0-workspace/libnautilus-extension/nautilus-sidebar-widget.h 2008-03-24 18:24:28.000000000 +0100
@@ -0,0 +1,61 @@
+/*
+ * nautilus-sidebar-widget.c - Interface for Nautilus sidebar widgets.
+ *
+ * Copyright (C) 2008 Amos Brocco
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+/* This interface is implemented by Nautilus extensions that want to
+ * provide information sidebar widgets. Those widges are created along
+ * with the Information sidebar.
+ */
+
+#ifndef NAUTILUS_SIDEBAR_WIDGET_H
+#define NAUTILUS_SIDEBAR_WIDGET_H
+
+#include <glib-object.h>
+#include <gtk/gtkwidget.h>
+#include "nautilus-extension-types.h"
+
+G_BEGIN_DECLS
+
+#define NAUTILUS_TYPE_SIDEBAR_WIDGET (nautilus_sidebar_widget_get_type ())
+#define NAUTILUS_SIDEBAR_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_SIDEBAR_WIDGET, NautilusSidebarWidget))
+#define NAUTILUS_IS_SIDEBAR_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_SIDEBAR_WIDGET))
+#define NAUTILUS_SIDEBAR_WIDGET_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), NAUTILUS_TYPE_SIDEBAR_WIDGET, NautilusSidebarWidgetIface))
+
+typedef struct _NautilusSidebarWidget NautilusSidebarWidget;
+typedef struct _NautilusSidebarWidgetIface NautilusSidebarWidgetIface;
+
+struct _NautilusSidebarWidgetIface {
+ GTypeInterface g_iface;
+
+ GtkWidget* (*get_widget) (NautilusSidebarWidget* widget);
+ void (*location_changed) (NautilusSidebarWidget* widget, const char* uri);
+ void (*selection_changed) (NautilusSidebarWidget* widget, const GList* uris);
+};
+
+/* Interface Functions */
+GType nautilus_sidebar_widget_get_type (void);
+GtkWidget* nautilus_sidebar_widget_get_widget (NautilusSidebarWidget* widget);
+void nautilus_sidebar_widget_selection_changed (NautilusSidebarWidget* widget, const GList* uris);
+void nautilus_sidebar_widget_location_changed (NautilusSidebarWidget* widget, const char* uri);
+void nautilus_sidebar_widget_emit_load_uri (NautilusSidebarWidget* widget, const char* uri);
+
+G_END_DECLS
+
+#endif
--- nautilus-2.22.0/libnautilus-extension/Makefile.am 2008-03-07 16:28:46.000000000 +0100
+++ nautilus-2.22.0-workspace/libnautilus-extension/Makefile.am 2008-03-23 15:56:17.000000000 +0100
@@ -30,6 +30,8 @@ libnautilus_extension_include_HEADERS=
nautilus-menu-provider.h \
nautilus-property-page-provider.h \
nautilus-property-page.h \
+ nautilus-sidebar-widget-provider.h \
+ nautilus-sidebar-widget.h \
nautilus-menu.h \
$(NULL)
@@ -45,6 +47,8 @@ libnautilus_extension_la_SOURCES= \
nautilus-menu-provider.c \
nautilus-property-page-provider.c \
nautilus-property-page.c \
+ nautilus-sidebar-widget-provider.c \
+ nautilus-sidebar-widget.c \
nautilus-menu.c \
$(NULL)
--- nautilus-2.22.0/src/nautilus-information-panel.c 2008-03-07 16:28:03.000000000 +0100
+++ nautilus-2.22.0-workspace/src/nautilus-information-panel.c 2008-03-24 18:55:58.000000000 +0100
@@ -51,6 +51,9 @@
#include <libnautilus-private/nautilus-program-choosing.h>
#include <libnautilus-private/nautilus-sidebar-provider.h>
#include <libnautilus-private/nautilus-module.h>
+#include <libnautilus-extension/nautilus-sidebar-widget-provider.h>
+#include <libnautilus-extension/nautilus-sidebar-widget.h>
+#include <gio/gio.h>
struct NautilusInformationPanelDetails {
GtkVBox *container;
@@ -67,6 +70,8 @@ struct NautilusInformationPanelDetails {
char *default_background_image;
char *current_background_color;
char *current_background_image;
+
+ GList* widgets;
};
/* button assignments */
@@ -96,6 +101,17 @@ static void nautilus_information_pan
static void sidebar_provider_iface_init (NautilusSidebarProviderIface *iface);
static GType nautilus_information_panel_provider_get_type (void);
+/* Extension widgets */
+
+static gint sort_widget_providers_by_position (gconstpointer a, gconstpointer b);
+static void load_sidebar_extension_widgets (NautilusInformationPanel *panel);
+static void add_sidebar_widget (NautilusInformationPanel *panel, NautilusSidebarWidget* widget);
+static void sidebar_extension_widget_location_changed (NautilusInformationPanel *panel, const gchar* uri);
+static void sidebar_extension_widget_selection_changed (NautilusInformationPanel *panel, const GList* uris);
+static void widget_load_uri_callback (NautilusSidebarWidget *widget, char *uri, NautilusInformationPanel *panel);
+static void init_sidebar_extension_widgets (NautilusInformationPanel *panel);
+static void dispose_sidebar_extension_widgets (NautilusInformationPanel *panel);
+
enum {
LOCATION_CHANGED,
LAST_SIGNAL
@@ -258,13 +274,18 @@ nautilus_information_panel_init (Nautilu
gtk_widget_show (GTK_WIDGET (information_panel->details->container));
gtk_container_add (GTK_CONTAINER (information_panel),
GTK_WIDGET (information_panel->details->container));
-
+
/* allocate and install the index title widget */
information_panel->details->title = NAUTILUS_SIDEBAR_TITLE (nautilus_sidebar_title_new ());
gtk_widget_show (GTK_WIDGET (information_panel->details->title));
gtk_box_pack_start (GTK_BOX (information_panel->details->container),
GTK_WIDGET (information_panel->details->title),
FALSE, FALSE, GNOME_PAD);
+
+ /* Install extra widgets */
+ information_panel->details->widgets = NULL;
+ load_sidebar_extension_widgets (information_panel);
+ init_sidebar_extension_widgets (information_panel);
/* allocate and install the command button container */
make_button_box (information_panel);
@@ -278,7 +299,7 @@ nautilus_information_panel_init (Nautilu
gtk_drag_dest_set (GTK_WIDGET (information_panel),
GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,
target_table, G_N_ELEMENTS (target_table),
- GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK);
+ GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_ASK);
}
static void
@@ -287,6 +308,8 @@ nautilus_information_panel_finalize (GOb
NautilusInformationPanel *information_panel;
information_panel = NAUTILUS_INFORMATION_PANEL (object);
+
+ dispose_sidebar_extension_widgets (information_panel);
if (information_panel->details->file != NULL) {
nautilus_file_monitor_remove (information_panel->details->file, information_panel);
@@ -1071,6 +1094,8 @@ nautilus_information_panel_set_uri (Naut
nautilus_sidebar_title_set_file (information_panel->details->title,
information_panel->details->file,
initial_title);
+
+ sidebar_extension_widget_location_changed (information_panel, new_uri);
}
static void
@@ -1094,6 +1119,15 @@ nautilus_information_panel_style_set (Gt
}
static void
+selection_changed_callback (NautilusWindowInfo *window,
+ NautilusInformationPanel *panel)
+{
+ GList* selection = nautilus_window_info_get_selection (window);
+ sidebar_extension_widget_selection_changed (panel, selection);
+ g_list_free (selection);
+}
+
+static void
loading_uri_callback (NautilusWindowInfo *window,
char *uri,
NautilusInformationPanel *panel)
@@ -1104,6 +1138,8 @@ loading_uri_callback (NautilusWindowInfo
nautilus_information_panel_set_uri (panel,
uri,
title);
+
+ sidebar_extension_widget_location_changed (panel, uri);
g_free (title);
}
@@ -1119,6 +1155,8 @@ nautilus_information_panel_set_parent_wi
G_CALLBACK (loading_uri_callback), panel, 0);
g_signal_connect_object (window, "title_changed",
G_CALLBACK (title_changed_callback), panel, 0);
+ g_signal_connect_object (window, "selection_changed",
+ G_CALLBACK (selection_changed_callback), panel, 0);
title = nautilus_window_info_get_title (window);
location = nautilus_window_info_get_current_location (window);
@@ -1165,3 +1203,110 @@ nautilus_information_panel_register (voi
nautilus_module_add_type (nautilus_information_panel_provider_get_type ());
}
+/* Begin extension widget management */
+
+static gint
+sort_widget_providers_by_position (gconstpointer a, gconstpointer b)
+{
+ NautilusSidebarWidgetProvider* provider_a = (NautilusSidebarWidgetProvider*) a;
+ NautilusSidebarWidgetProvider* provider_b = (NautilusSidebarWidgetProvider*) b;
+
+ int p_a = nautilus_sidebar_widget_provider_get_order (provider_a);
+ int p_b = nautilus_sidebar_widget_provider_get_order (provider_b);
+
+ return p_a < p_b ? -1 : p_a == p_b ? 0 : 1;
+}
+
+static void
+load_sidebar_extension_widgets (NautilusInformationPanel *panel)
+{
+ GList *providers, *l;
+ NautilusSidebarWidget *widget;
+
+ providers = nautilus_module_get_extensions_for_type (NAUTILUS_TYPE_SIDEBAR_WIDGET_PROVIDER);
+ providers = g_list_sort (providers, sort_widget_providers_by_position);
+
+ for (l = providers; l != NULL; l = l->next) {
+ NautilusSidebarWidgetProvider *provider;
+
+ provider = NAUTILUS_SIDEBAR_WIDGET_PROVIDER (l->data);
+ widget = nautilus_sidebar_widget_provider_get_widget (provider);
+
+ if (widget != NULL) {
+ add_sidebar_widget (panel, widget);
+ }
+ }
+
+ nautilus_module_extension_list_free (providers);
+}
+
+static void
+add_sidebar_widget (NautilusInformationPanel *panel, NautilusSidebarWidget* widget)
+{
+ GList* widgets = panel->details->widgets;
+
+ panel->details->widgets = g_list_prepend (widgets, widget);
+}
+
+static void
+sidebar_extension_widget_location_changed (NautilusInformationPanel *panel, const gchar* uri)
+{
+ GList* widgets = panel->details->widgets;
+ GList* w;
+
+ for (w = widgets; w != NULL; w = w->next) {
+ NautilusSidebarWidget* widget = NAUTILUS_SIDEBAR_WIDGET (w->data);
+ nautilus_sidebar_widget_location_changed (widget, uri);
+ }
+}
+
+static void
+sidebar_extension_widget_selection_changed (NautilusInformationPanel *panel, const GList* uris)
+{
+ GList* widgets = panel->details->widgets;
+ GList* w;
+
+ for (w = widgets; w != NULL; w = w->next) {
+ NautilusSidebarWidget* widget = NAUTILUS_SIDEBAR_WIDGET (w->data);
+ nautilus_sidebar_widget_selection_changed (widget, uris);
+ }
+}
+
+static void
+widget_load_uri_callback (NautilusSidebarWidget *widget, char *uri, NautilusInformationPanel *panel)
+{
+ GFile *location;
+
+ location = g_file_new_for_uri (uri);
+ nautilus_window_info_open_location (panel->details->window, location,
+ NAUTILUS_WINDOW_OPEN_ACCORDING_TO_MODE, 0, NULL);
+
+ g_object_unref (location);
+}
+
+static void
+init_sidebar_extension_widgets (NautilusInformationPanel *panel)
+{
+ GList* widgets = panel->details->widgets;
+ GList* w;
+
+ for (w = widgets; w != NULL; w = w->next) {
+ NautilusSidebarWidget* widget = NAUTILUS_SIDEBAR_WIDGET (w->data);
+ g_signal_connect_after (widget, "load_uri",
+ G_CALLBACK (widget_load_uri_callback), panel);
+ GtkWidget* actual_widget = nautilus_sidebar_widget_get_widget (widget);
+ gtk_box_pack_start (GTK_BOX (panel->details->container),
+ GTK_WIDGET (actual_widget), FALSE, FALSE, GNOME_PAD);
+ }
+}
+
+static void
+dispose_sidebar_extension_widgets (NautilusInformationPanel *panel)
+{
+ GList* widgets = panel->details->widgets;
+
+ g_list_foreach (widgets, (GFunc) g_object_unref, NULL);
+
+ g_list_free (widgets);
+}
+
Attachment:
signature.asc
Description: Questa =?ISO-8859-1?Q?=E8?= una parte del messaggio firmata digitalmente