hythmbox-2.98/sample-plugins/sample/rb-sample-plugin.c

No issues found

 1 /*
 2  * rb-sample-plugin.h
 3  * 
 4  * Copyright (C) 2002-2005 - Paolo Maggi
 5  *
 6  * This program is free software; you can redistribute it and/or modify
 7  * it under the terms of the GNU General Public License as published by
 8  * the Free Software Foundation; either version 2, or (at your option)
 9  * any later version.
10  *
11  * The Rhythmbox authors hereby grant permission for non-GPL compatible
12  * GStreamer plugins to be used and distributed together with GStreamer
13  * and Rhythmbox. This permission is above and beyond the permissions granted
14  * by the GPL license by which Rhythmbox is covered. If you modify this code
15  * you may extend this exception to your version of the code, but you are not
16  * obligated to do so. If you do not wish to do so, delete this exception
17  * statement from your version.
18  * 
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA.
27  */
28 
29 #ifdef HAVE_CONFIG_H
30 #include <config.h>
31 #endif
32 
33 #include <string.h> /* For strlen */
34 #include <glib/gi18n-lib.h>
35 #include <gmodule.h>
36 #include <gtk/gtk.h>
37 #include <glib.h>
38 #include <glib-object.h>
39 
40 #include "rb-plugin-macros.h"
41 #include "rb-debug.h"
42 #include "rb-shell.h"
43 #include "rb-dialog.h"
44 
45 
46 #define RB_TYPE_SAMPLE_PLUGIN		(rb_sample_plugin_get_type ())
47 #define RB_SAMPLE_PLUGIN(o)			(G_TYPE_CHECK_INSTANCE_CAST ((o), RB_TYPE_SAMPLE_PLUGIN, RBSamplePlugin))
48 #define RB_SAMPLE_PLUGIN_CLASS(k)		(G_TYPE_CHECK_CLASS_CAST((k), RB_TYPE_SAMPLE_PLUGIN, RBSamplePluginClass))
49 #define RB_IS_SAMPLE_PLUGIN(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), RB_TYPE_SAMPLE_PLUGIN))
50 #define RB_IS_SAMPLE_PLUGIN_CLASS(k)		(G_TYPE_CHECK_CLASS_TYPE ((k), RB_TYPE_SAMPLE_PLUGIN))
51 #define RB_SAMPLE_PLUGIN_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), RB_TYPE_SAMPLE_PLUGIN, RBSamplePluginClass))
52 
53 typedef struct
54 {
55 	PeasExtensionBase parent;
56 } RBSamplePlugin;
57 
58 typedef struct
59 {
60 	PeasExtensionBaseClass parent_class;
61 } RBSamplePluginClass;
62 
63 
64 G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);
65 
66 static void rb_sample_plugin_init (RBSamplePlugin *plugin);
67 
68 RB_DEFINE_PLUGIN(RB_TYPE_SAMPLE_PLUGIN, RBSamplePlugin, rb_sample_plugin,)
69 
70 static void
71 rb_sample_plugin_init (RBSamplePlugin *plugin)
72 {
73 	rb_debug ("RBSamplePlugin initialising");
74 }
75 
76 static void
77 impl_activate (PeasActivatable *plugin)
78 {
79 	RBShell *shell;
80 
81 	g_object_get (plugin, "object", &shell, NULL);
82 	rb_error_dialog (NULL, _("Sample Plugin"), "Sample plugin activated, with shell %p", shell);
83 	g_object_unref (shell);
84 }
85 
86 static void
87 impl_deactivate	(PeasActivatable *plugin)
88 {
89 	rb_error_dialog (NULL, _("Sample Plugin"), "Sample plugin deactivated");
90 }
91 
92 G_MODULE_EXPORT void
93 peas_register_types (PeasObjectModule *module)
94 {
95 	rb_sample_plugin_register_type (G_TYPE_MODULE (module));
96 	peas_object_module_register_extension_type (module,
97 						    PEAS_TYPE_ACTIVATABLE,
98 						    RB_TYPE_SAMPLE_PLUGIN);
99 }