You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

160 lines
4.0 KiB

  1. /*
  2. * Copyright (C) 2000, 2001 Eazel Inc.
  3. * Copyright (C) 2003 Andrew Sobala <aes@gnome.org>
  4. * Copyright (C) 2005 Bastien Nocera <hadess@hadess.net>
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. *
  20. * The Ev project hereby grant permission for non-gpl compatible GStreamer
  21. * plugins to be used and distributed together with GStreamer and Ev. This
  22. * permission are above and beyond the permissions granted by the GPL license
  23. * Ev is covered by.
  24. *
  25. * Monday 7th February 2005: Christian Schaller: Add excemption clause.
  26. * See license_change file for details.
  27. *
  28. */
  29. #include <config.h>
  30. #include <string.h>
  31. #include <glib/gi18n-lib.h>
  32. #include <gtk/gtk.h>
  33. #include <libnemo-extension/nemo-extension-types.h>
  34. #include <libnemo-extension/nemo-property-page-provider.h>
  35. #include <xreader-document.h>
  36. #include "ev-properties-view.h"
  37. static GType epp_type = 0;
  38. static void property_page_provider_iface_init
  39. (NemoPropertyPageProviderIface *iface);
  40. static GList *ev_properties_get_pages
  41. (NemoPropertyPageProvider *provider, GList *files);
  42. static void
  43. ev_properties_plugin_register_type (GTypeModule *module)
  44. {
  45. const GTypeInfo info = {
  46. sizeof (GObjectClass),
  47. (GBaseInitFunc) NULL,
  48. (GBaseFinalizeFunc) NULL,
  49. (GClassInitFunc) NULL,
  50. NULL,
  51. NULL,
  52. sizeof (GObject),
  53. 0,
  54. (GInstanceInitFunc) NULL
  55. };
  56. const GInterfaceInfo property_page_provider_iface_info = {
  57. (GInterfaceInitFunc)property_page_provider_iface_init,
  58. NULL,
  59. NULL
  60. };
  61. epp_type = g_type_module_register_type (module, G_TYPE_OBJECT,
  62. "EvPropertiesPlugin",
  63. &info, 0);
  64. g_type_module_add_interface (module,
  65. epp_type,
  66. NEMO_TYPE_PROPERTY_PAGE_PROVIDER,
  67. &property_page_provider_iface_info);
  68. }
  69. static void
  70. property_page_provider_iface_init (NemoPropertyPageProviderIface *iface)
  71. {
  72. iface->get_pages = ev_properties_get_pages;
  73. }
  74. static GList *
  75. ev_properties_get_pages (NemoPropertyPageProvider *provider,
  76. GList *files)
  77. {
  78. GError *error = NULL;
  79. EvDocument *document;
  80. GList *pages = NULL;
  81. NemoFileInfo *file;
  82. gchar *uri = NULL;
  83. gchar *mime_type = NULL;
  84. GtkWidget *page, *label;
  85. NemoPropertyPage *property_page;
  86. /* only add properties page if a single file is selected */
  87. if (files == NULL || files->next != NULL)
  88. goto end;
  89. file = files->data;
  90. /* okay, make the page */
  91. uri = nemo_file_info_get_uri (file);
  92. mime_type = nemo_file_info_get_mime_type (file);
  93. document = ev_backends_manager_get_document (mime_type);
  94. if (!document)
  95. goto end;
  96. ev_document_load (document, uri, &error);
  97. if (error) {
  98. g_error_free (error);
  99. goto end;
  100. }
  101. label = gtk_label_new (_("Document"));
  102. page = ev_properties_view_new (uri);
  103. ev_properties_view_set_info (EV_PROPERTIES_VIEW (page),
  104. ev_document_get_info (document));
  105. gtk_widget_show (page);
  106. property_page = nemo_property_page_new ("document-properties",
  107. label, page);
  108. g_object_unref (document);
  109. pages = g_list_prepend (pages, property_page);
  110. end:
  111. g_free (uri);
  112. g_free (mime_type);
  113. return pages;
  114. }
  115. /* --- extension interface --- */
  116. void
  117. nemo_module_initialize (GTypeModule *module)
  118. {
  119. ev_properties_plugin_register_type (module);
  120. ev_properties_view_register_type (module);
  121. ev_init ();
  122. }
  123. void
  124. nemo_module_shutdown (void)
  125. {
  126. ev_shutdown ();
  127. }
  128. void
  129. nemo_module_list_types (const GType **types,
  130. int *num_types)
  131. {
  132. static GType type_list[1];
  133. type_list[0] = epp_type;
  134. *types = type_list;
  135. *num_types = G_N_ELEMENTS (type_list);
  136. }