From 8f535d303b8985db357abc54cb4d3fe1ff7e84bd Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Mon, 4 Jul 2005 22:49:27 +0000 Subject: [PATCH] Implement nautilus plugin for properties. Works only for pdf atm, I need 2005-07-05 Marco Pesenti Gritti * configure.ac: * properties/Makefile.am: * properties/ev-properties-view.c: (ev_properties_view_register_type): * properties/ev-properties-view.h: * properties/ev-properties-main.h: Implement nautilus plugin for properties. Works only for pdf atm, I need to rework the document types stuff to get this to work for all backends... --- ChangeLog | 14 +++ configure.ac | 23 +++++ properties/Makefile.am | 25 +++++- properties/ev-properties-main.c | 152 ++++++++++++++++++++++++++++++++ properties/ev-properties-view.c | 6 ++ properties/ev-properties-view.h | 9 +- 6 files changed, 224 insertions(+), 5 deletions(-) create mode 100644 properties/ev-properties-main.c diff --git a/ChangeLog b/ChangeLog index 11bd6b9b..2653ffa4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2005-07-05 Marco Pesenti Gritti + + * configure.ac: + * properties/Makefile.am: + * properties/ev-properties-view.c: + (ev_properties_view_register_type): + * properties/ev-properties-view.h: + * properties/ev-properties-main.h: + + Implement nautilus plugin for properties. + Works only for pdf atm, I need to rework the + document types stuff to get this to work + for all backends... + 2005-07-04 Martin Kretzschmar * shell/ev-properties-fonts.c (enum): kill redundant columns enum diff --git a/configure.ac b/configure.ac index 8b75a808..bd567133 100644 --- a/configure.ac +++ b/configure.ac @@ -41,6 +41,7 @@ PKG_CHECK_MODULES(RECENT_FILES, gtk+-2.0 >= 2.4.0 libgnomeui-2.0 >= 2.4.0) PKG_CHECK_MODULES(ZOOM_CONTROL, gtk+-2.0 >= 2.4.0) PKG_CHECK_MODULES(SHELL, gtk+-2.0 >= 2.6.0 libgnomeui-2.0 >= 2.6.0 gnome-vfs-2.0 libgnomeprint-2.2 >= 2.5.1 libgnomeprintui-2.2 libglade-2.0 gconf-2.0 poppler-glib >= $POPPLER_REQUIRED) PKG_CHECK_MODULES(THUMBNAILER, gtk+-2.0 >= 2.6.0 gnome-vfs-2.0 poppler-glib >= $POPPLER_REQUIRED) +PKG_CHECK_MODULES(PROPERTIES, gtk+-2.0 >= 2.6.0 libglade-2.0 poppler-glib >= $POPPLER_REQUIRED) PKG_CHECK_MODULES(DVI, gtk+-2.0 >= 2.6.0) PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.6.0) PKG_CHECK_MODULES(PS, gtk+-2.0 >= 2.6.0 gnome-vfs-2.0 libgnomeui-2.0) @@ -65,6 +66,28 @@ fi AM_CONDITIONAL([ENABLE_DBUS], [test "x$enable_dbus" = "xyes"]) AM_CONDITIONAL([ENABLE_METADATA], [test "x$enable_dbus" = "xyes"]) +dnl Check for Nautilus property page build +AC_ARG_ENABLE(nautilus, + AC_HELP_STRING([--enable-nautilus],[compile the nautilus plugin]), + [case "${enableval}" in + yes) ENABLE_NAUTILUS=yes ;; + no) ENABLE_NAUTILUS=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-nautilus) ;; + esac], + [ENABLE_NAUTILUS=yes]) dnl Default value + +if test x$ENABLE_NAUTILUS = "xyes" ; then + PKG_CHECK_MODULES(NAUTILUS, gtk+-x11-2.0 $MM gthread-2.0 libnautilus-extension, + [HAVE_NAUTILUS=yes], [HAVE_NAUTILUS=no]) +fi + +AC_SUBST(NAUTILUS_CFLAGS) +AC_SUBST(NAUTILUS_LIBS) +if test x$HAVE_NAUTILUS = "xyes"; then + AC_DEFINE(HAVE_NAUTILUS, 1, [defined if you build the nautilus plugin]) +fi +AM_CONDITIONAL(HAVE_NAUTILUS, test x$HAVE_NAUTILUS = "xyes") + dnl Compile with disable-deprecated switches AC_ARG_ENABLE(deprecated, diff --git a/properties/Makefile.am b/properties/Makefile.am index bac8f359..597fb5a8 100644 --- a/properties/Makefile.am +++ b/properties/Makefile.am @@ -2,8 +2,11 @@ NULL= INCLUDES= \ -DDATADIR=\"$(pkgdatadir)\" \ + -DGNOMELOCALEDIR=\"$(datadir)/locale\" \ -I$(top_srcdir)/backend \ - $(SHELL_CFLAGS) \ + -I$(top_srcdir)/pdf \ + $(PROPERTIES_CFLAGS) \ + $(NAUTILUS_CFLAGS) \ $(EVINCE_DISABLE_DEPRECATED) \ $(NULL) @@ -13,3 +16,23 @@ libevproperties_la_SOURCES= \ ev-properties-view.c \ ev-properties-view.h \ $(NULL) + +if HAVE_NAUTILUS +EVINCE_PROPERTIES_PAGE = libevince-properties-page.la +else +EVINCE_PROPERTIES_PAGE = +endif + +nautilus_LTLIBRARIES = $(EVINCE_PROPERTIES_PAGE) + +nautilusdir = $(libdir)/nautilus/extensions-1.0/ +libevince_properties_page_la_CFLAGS = -I$(top_srcdir) +libevince_properties_page_la_SOURCES = \ + ev-properties-main.c + +libevince_properties_page_la_LIBADD = \ + $(PROPERTIES_LIBS) \ + libevproperties.la \ + $(top_builddir)/pdf/libpdfdocument.la \ + $(top_builddir)/backend/libevbackend.la \ + $(top_builddir)/lib/libev.la diff --git a/properties/ev-properties-main.c b/properties/ev-properties-main.c new file mode 100644 index 00000000..87f4a590 --- /dev/null +++ b/properties/ev-properties-main.c @@ -0,0 +1,152 @@ +/* + * Copyright (C) 2000, 2001 Eazel Inc. + * Copyright (C) 2003 Andrew Sobala + * Copyright (C) 2005 Bastien Nocera + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2.1 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * The Ev project hereby grant permission for non-gpl compatible GStreamer + * plugins to be used and distributed together with GStreamer and Ev. This + * permission are above and beyond the permissions granted by the GPL license + * Ev is covered by. + * + * Monday 7th February 2005: Christian Schaller: Add excemption clause. + * See license_change file for details. + * + */ + +#include "ev-properties-view.h" +#include "pdf-document.h" + +#include +#include +#include +#include +#include +#include + +static GType epp_type = 0; +static void property_page_provider_iface_init + (NautilusPropertyPageProviderIface *iface); +static GList *ev_properties_get_pages + (NautilusPropertyPageProvider *provider, GList *files); + +static void +ev_properties_plugin_register_type (GTypeModule *module) +{ + static const GTypeInfo info = { + sizeof (GObjectClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) NULL, + NULL, + NULL, + sizeof (GObject), + 0, + (GInstanceInitFunc) NULL + }; + static const GInterfaceInfo property_page_provider_iface_info = { + (GInterfaceInitFunc)property_page_provider_iface_init, + NULL, + NULL + }; + + epp_type = g_type_module_register_type (module, G_TYPE_OBJECT, + "EvPropertiesPlugin", + &info, 0); + g_type_module_add_interface (module, + epp_type, + NAUTILUS_TYPE_PROPERTY_PAGE_PROVIDER, + &property_page_provider_iface_info); +} + +static void +property_page_provider_iface_init (NautilusPropertyPageProviderIface *iface) +{ + iface->get_pages = ev_properties_get_pages; +} + +static GList * +ev_properties_get_pages (NautilusPropertyPageProvider *provider, + GList *files) +{ + GError *error; + EvDocument *document; + GList *pages = NULL; + NautilusFileInfo *file; + char *uri = NULL; + GtkWidget *page, *label; + NautilusPropertyPage *property_page; + + /* only add properties page if a single file is selected */ + if (files == NULL || files->next != NULL) + goto end; + file = files->data; + + if (!nautilus_file_info_is_mime_type (file, "application/pdf")) { + goto end; + } + + /* okay, make the page */ + document = EV_DOCUMENT (pdf_document_new ()); + uri = nautilus_file_info_get_uri (file); + if (!ev_document_load (document, uri, &error)) { + g_error_free (error); + goto end; + } + label = gtk_label_new (_("Document")); + page = ev_properties_view_new (); + ev_properties_view_set_info (EV_PROPERTIES_VIEW (page), + ev_document_get_info (document)); + gtk_widget_show (page); + property_page = nautilus_property_page_new ("document-properties", + label, page); + g_object_unref (document); + + pages = g_list_prepend (pages, property_page); + +end: + g_free (uri); + return pages; +} + +/* --- extension interface --- */ +void +nautilus_module_initialize (GTypeModule *module) +{ + ev_properties_plugin_register_type (module); + ev_properties_view_register_type (module); + + /* set up translation catalog */ + bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); +} + +void +nautilus_module_shutdown (void) +{ +} + +void +nautilus_module_list_types (const GType **types, + int *num_types) +{ + static GType type_list[1]; + + type_list[0] = epp_type; + *types = type_list; + *num_types = G_N_ELEMENTS (type_list); +} + diff --git a/properties/ev-properties-view.c b/properties/ev-properties-view.c index 297cbc5d..70c337e2 100644 --- a/properties/ev-properties-view.c +++ b/properties/ev-properties-view.c @@ -251,6 +251,12 @@ ev_properties_view_init (EvPropertiesView *properties) TRUE, TRUE, 0); } +void +ev_properties_view_register_type (GTypeModule *module) +{ + ev_properties_view_get_type (); +} + GtkWidget * ev_properties_view_new (void) { diff --git a/properties/ev-properties-view.h b/properties/ev-properties-view.h index d95520fc..0f3b4632 100644 --- a/properties/ev-properties-view.h +++ b/properties/ev-properties-view.h @@ -38,10 +38,11 @@ typedef struct _EvPropertiesViewPrivate EvPropertiesViewPrivate; #define EV_IS_PROPERTIES_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), EV_TYPE_PROPERTIES)) #define EV_PROPERTIES_VIEW_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), EV_TYPE_PROPERTIES, EvPropertiesViewClass)) -GType ev_properties_view_get_type (void); -GtkWidget *ev_properties_view_new (void); -void ev_properties_view_set_info (EvPropertiesView *properties, - const EvDocumentInfo *info); +GType ev_properties_view_get_type (void); +void ev_properties_view_register_type (GTypeModule *module); +GtkWidget *ev_properties_view_new (void); +void ev_properties_view_set_info (EvPropertiesView *properties, + const EvDocumentInfo *info); G_END_DECLS -- 2.43.5