tracker-0.16.2/src/plugins/nautilus/tracker-tags-extension.c

No issues found

  1 /*
  2  * Copyright (C) 2009, Debarshi Ray <debarshir@src.gnome.org>
  3  * Copyright (C) 2009, Martyn Russell <martyn@lanedo.com>
  4  *
  5  * This program is free software; you can redistribute it and/or
  6  * modify it under the terms of the GNU General Public License
  7  * as published by the Free Software Foundation; either version 2
  8  * of the License, or (at your option) any later version.
  9  *
 10  * This program is distributed in the hope that it will be useful,
 11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  * GNU General Public License for more details.
 14  *
 15  * You should have received a copy of the GNU General Public License
 16  * along with this program; if not, write to the Free Software
 17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 18  * 02110-1301, USA.
 19  */
 20 
 21 #include "config.h"
 22 
 23 #include <gtk/gtk.h>
 24 #include <glib/gi18n.h>
 25 
 26 #include <libnautilus-extension/nautilus-property-page-provider.h>
 27 
 28 #include <libtracker-sparql/tracker-sparql.h>
 29 
 30 #include "tracker-tags-utils.h"
 31 #include "tracker-tags-view.h"
 32 
 33 #define TRACKER_TYPE_TAGS_EXTENSION (tracker_tags_extension_get_type ())
 34 #define TRACKER_TAGS_EXTENSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRACKER_TYPE_TAGS_EXTENSION, TrackerTagsExtension))
 35 #define TRACKER_TAGS_EXTENSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TRACKER_TYPE_TAGS_EXTENSION, TrackerTagsExtensionClass))
 36 
 37 #define TRACKER_IS_TAGS_EXTENSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TRACKER_TYPE_TAGS_EXTENSION))
 38 #define TRACKER_IS_TAGS_EXTENSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TRACKER_TYPE_TAGS_EXTENSION))
 39 
 40 typedef struct _TrackerTagsExtension TrackerTagsExtension;
 41 typedef struct _TrackerTagsExtensionClass TrackerTagsExtensionClass;
 42 
 43 struct _TrackerTagsExtension {
 44 	GObject parent;
 45 };
 46 
 47 struct _TrackerTagsExtensionClass {
 48 	GObjectClass parent;
 49 };
 50 
 51 GType        tracker_tags_extension_get_type                          (void);
 52 static void  tracker_tags_extension_property_page_provider_iface_init (NautilusPropertyPageProviderIface *iface);
 53 
 54 G_DEFINE_DYNAMIC_TYPE_EXTENDED (TrackerTagsExtension, tracker_tags_extension, G_TYPE_OBJECT, 0,
 55                                 G_IMPLEMENT_INTERFACE (NAUTILUS_TYPE_PROPERTY_PAGE_PROVIDER,
 56                                                        tracker_tags_extension_property_page_provider_iface_init));
 57 
 58 static GList *
 59 extension_get_pages (NautilusPropertyPageProvider *provider,
 60                      GList                        *files)
 61 {
 62 	GList *property_pages = NULL;
 63 	GtkWidget *label;
 64 	GtkWidget *view;
 65 	NautilusPropertyPage *property_page;
 66 
 67 	if (files == NULL) {
 68 		return NULL;
 69 	}
 70 
 71 	label = gtk_label_new (_("Tags"));
 72 	view = tracker_tags_view_new (files);
 73 	gtk_widget_show (view);
 74 	property_page = nautilus_property_page_new ("tracker-tags", label, view);
 75 	property_pages = g_list_prepend (property_pages, property_page);
 76 
 77 	return property_pages;
 78 }
 79 
 80 static void
 81 tracker_tags_extension_property_page_provider_iface_init (NautilusPropertyPageProviderIface *iface)
 82 {
 83 	iface->get_pages = extension_get_pages;
 84 }
 85 
 86 static void
 87 tracker_tags_extension_class_init (TrackerTagsExtensionClass *klass)
 88 {
 89 }
 90 
 91 static void
 92 tracker_tags_extension_class_finalize (TrackerTagsExtensionClass *klass)
 93 {
 94 }
 95 
 96 static void
 97 tracker_tags_extension_init (TrackerTagsExtension *self)
 98 {
 99 }
100 
101 void
102 nautilus_module_initialize (GTypeModule *module)
103 {
104 	g_debug ("Initializing tracker-tags extension\n");
105 	tracker_tags_extension_register_type (module);
106 	tracker_tags_view_register_types (module);
107 }
108 
109 void
110 nautilus_module_shutdown (void)
111 {
112 	g_debug ("Shutting down tracker-tags extension\n");
113 }
114 
115 void
116 nautilus_module_list_types (const GType **types,
117                             gint         *num_types)
118 {
119 	static GType type_list[1];
120 
121 	type_list[0] = tracker_tags_extension_type_id;
122 	*types = type_list;
123 	*num_types = G_N_ELEMENTS (type_list);
124 }