1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
5 * Copyright (C) 2006 Jonathan Matthew
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
27 #include <glib/gi18n-lib.h>
31 #include <glib-object.h>
33 #include "rb-plugin.h"
36 #include "rb-dialog.h"
37 #include "rb-iradio-source.h"
38 #include "rb-file-helpers.h"
41 #define RB_TYPE_IRADIO_PLUGIN (rb_iradio_plugin_get_type ())
42 #define RB_IRADIO_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), RB_TYPE_IRADIO_PLUGIN, RBIRadioPlugin))
43 #define RB_IRADIO_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), RB_TYPE_IRADIO_PLUGIN, RBIRadioPluginClass))
44 #define RB_IS_IRADIO_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), RB_TYPE_IRADIO_PLUGIN))
45 #define RB_IS_IRADIO_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), RB_TYPE_IRADIO_PLUGIN))
46 #define RB_IRADIO_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), RB_TYPE_IRADIO_PLUGIN, RBIRadioPluginClass))
57 RBPluginClass parent_class
;
58 } RBIRadioPluginClass
;
61 G_MODULE_EXPORT GType
register_rb_plugin (GTypeModule
*module
);
62 GType
rb_iradio_plugin_get_type (void) G_GNUC_CONST
;
65 static void impl_activate (RBPlugin
*plugin
, RBShell
*shell
);
66 static void impl_deactivate (RBPlugin
*plugin
, RBShell
*shell
);
68 RB_PLUGIN_REGISTER(RBIRadioPlugin
, rb_iradio_plugin
)
71 rb_iradio_plugin_init (RBIRadioPlugin
*plugin
)
73 rb_debug ("RBIRadioPlugin initialising");
77 rb_iradio_plugin_finalize (GObject
*object
)
80 RBIRadioPlugin *plugin = RB_IRADIO_PLUGIN (object);
82 rb_debug ("RBIRadioPlugin finalising");
84 G_OBJECT_CLASS (rb_iradio_plugin_parent_class
)->finalize (object
);
90 impl_activate (RBPlugin
*plugin
,
93 RBIRadioPlugin
*pi
= RB_IRADIO_PLUGIN (plugin
);
94 GtkUIManager
*uimanager
;
97 pi
->source
= rb_iradio_source_new (shell
);
98 rb_shell_append_source (shell
, pi
->source
, NULL
);
100 g_object_get (shell
, "ui-manager", &uimanager
, NULL
);
101 filename
= rb_plugin_find_file (plugin
, "iradio-ui.xml");
102 if (filename
!= NULL
) {
103 pi
->ui_merge_id
= gtk_ui_manager_add_ui_from_file (uimanager
,
107 g_warning ("Unable to find file: iradio-ui.xml");
111 g_object_unref (uimanager
);
115 impl_deactivate (RBPlugin
*plugin
,
118 RBIRadioPlugin
*pi
= RB_IRADIO_PLUGIN (plugin
);
119 GtkUIManager
*uimanager
;
121 g_object_get (shell
, "ui-manager", &uimanager
, NULL
);
122 gtk_ui_manager_remove_ui (uimanager
, pi
->ui_merge_id
);
123 g_object_unref (uimanager
);
125 rb_source_delete_thyself (pi
->source
);
131 rb_iradio_plugin_class_init (RBIRadioPluginClass
*klass
)
133 GObjectClass
*object_class
= G_OBJECT_CLASS (klass
);
134 RBPluginClass
*plugin_class
= RB_PLUGIN_CLASS (klass
);
136 object_class
->finalize
= rb_iradio_plugin_finalize
;
138 plugin_class
->activate
= impl_activate
;
139 plugin_class
->deactivate
= impl_deactivate
;