[totem] Move all plugin init/finalisation into the activate/deactivate functions
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem] Move all plugin init/finalisation into the activate/deactivate functions
- Date: Sun, 5 Sep 2010 01:28:32 +0000 (UTC)
commit a4fa4a4000e543933287d0c7b5d588ced1acd7d3
Author: Philip Withnall <philip tecnocode co uk>
Date: Sun Sep 5 01:06:42 2010 +0100
Move all plugin init/finalisation into the activate/deactivate functions
That way, plugins only allocate resources when they're actually activated,
and free them as soon as they're deactivated.
src/plugins/galago/totem-galago.c | 48 +++++++-------------------
src/plugins/gromit/totem-gromit.c | 22 +++---------
src/plugins/mythtv/totem-mythtv.c | 29 ----------------
src/plugins/screensaver/totem-screensaver.c | 24 ++++---------
src/plugins/skipto/totem-skipto-plugin.c | 16 +--------
5 files changed, 28 insertions(+), 111 deletions(-)
---
diff --git a/src/plugins/galago/totem-galago.c b/src/plugins/galago/totem-galago.c
index 6c877bc..14eb134 100644
--- a/src/plugins/galago/totem-galago.c
+++ b/src/plugins/galago/totem-galago.c
@@ -62,9 +62,6 @@ typedef struct {
GType totem_galago_plugin_get_type (void) G_GNUC_CONST;
-static void totem_galago_plugin_dispose (GObject *object);
-static void totem_galago_plugin_finalize (GObject *object);
-
TOTEM_PLUGIN_REGISTER (TOTEM_TYPE_GALAGO_PLUGIN, TotemGalagoPlugin, totem_galago_plugin);
static void
@@ -74,8 +71,6 @@ totem_galago_plugin_class_init (TotemGalagoPluginClass *klass)
object_class->set_property = set_property;
object_class->get_property = get_property;
- object_class->dispose = totem_galago_plugin_dispose;
- object_class->finalize = totem_galago_plugin_finalize;
g_object_class_override_property (object_class, PROP_OBJECT, "object");
}
@@ -83,36 +78,6 @@ totem_galago_plugin_class_init (TotemGalagoPluginClass *klass)
static void
totem_galago_plugin_init (TotemGalagoPlugin *plugin)
{
- if (galago_init (PACKAGE_NAME, GALAGO_INIT_FEED) == FALSE
- || galago_is_connected () == FALSE) {
- g_warning ("Failed to initialise libgalago.");
- return;
- }
-
- /* Get "me" and list accounts */
- plugin->me = galago_get_me (GALAGO_REMOTE, TRUE);
-}
-
-static void
-totem_galago_plugin_dispose (GObject *object)
-{
- TotemGalagoPlugin *plugin = TOTEM_GALAGO_PLUGIN (object);
-
- if (plugin->me != NULL) {
- g_object_unref (plugin->me);
- plugin->me = NULL;
- }
-
- G_OBJECT_CLASS (totem_galago_plugin_parent_class)->dispose (object);
-}
-
-static void
-totem_galago_plugin_finalize (GObject *object)
-{
- if (galago_is_connected ())
- galago_uninit ();
-
- G_OBJECT_CLASS (totem_galago_plugin_parent_class)->finalize (object);
}
static void
@@ -161,6 +126,14 @@ impl_activate (PeasActivatable *plugin)
TotemGalagoPlugin *pi = TOTEM_GALAGO_PLUGIN (plugin);
TotemObject *totem;
+ if (galago_init (PACKAGE_NAME, GALAGO_INIT_FEED) == FALSE || galago_is_connected () == FALSE) {
+ g_warning ("Failed to initialise libgalago.");
+ return;
+ }
+
+ /* Get "me" and list accounts */
+ pi->me = galago_get_me (GALAGO_REMOTE, TRUE);
+
g_object_get (plugin, "object", &totem, NULL);
if (!galago_is_connected ()) {
@@ -205,4 +178,9 @@ impl_deactivate (PeasActivatable *plugin)
g_object_unref (totem);
totem_galago_set_idleness (pi, FALSE);
+
+ if (pi->me != NULL)
+ g_object_unref (pi->me);
+
+ galago_uninit ();
}
diff --git a/src/plugins/gromit/totem-gromit.c b/src/plugins/gromit/totem-gromit.c
index d7afa6e..c8f5cf6 100644
--- a/src/plugins/gromit/totem-gromit.c
+++ b/src/plugins/gromit/totem-gromit.c
@@ -96,8 +96,6 @@ static const char *visibility_cmd[] = { NULL, "-v", NULL };
GType totem_gromit_plugin_get_type (void) G_GNUC_CONST;
-static void totem_gromit_plugin_finalize (GObject *object);
-
TOTEM_PLUGIN_REGISTER(TOTEM_TYPE_GROMIT_PLUGIN, TotemGromitPlugin, totem_gromit_plugin)
static void
@@ -107,7 +105,6 @@ totem_gromit_plugin_class_init (TotemGromitPluginClass *klass)
object_class->set_property = set_property;
object_class->get_property = get_property;
- object_class->finalize = totem_gromit_plugin_finalize;
g_object_class_override_property (object_class, PROP_OBJECT, "object");
}
@@ -115,19 +112,6 @@ totem_gromit_plugin_class_init (TotemGromitPluginClass *klass)
static void
totem_gromit_plugin_init (TotemGromitPlugin *plugin)
{
- plugin->id = -1;
- plugin->pid = -1;
-}
-
-static void
-totem_gromit_plugin_finalize (GObject *object)
-{
- TotemGromitPlugin *plugin = TOTEM_GROMIT_PLUGIN (object);
-
- g_free (plugin->path);
- plugin->path = NULL;
-
- G_OBJECT_CLASS (totem_gromit_plugin_parent_class)->finalize (object);
}
static void
@@ -263,6 +247,9 @@ impl_activate (PeasActivatable *plugin)
TotemGromitPlugin *pi = TOTEM_GROMIT_PLUGIN (plugin);
GtkWindow *window;
+ pi->id = -1;
+ pi->pid = -1;
+
if (!totem_gromit_available (pi)) {
//FIXME
#if 0
@@ -293,5 +280,8 @@ impl_deactivate (PeasActivatable *plugin)
}
totem_gromit_clear (pi, TRUE);
+
+ g_free (pi->path);
+ pi->path = NULL;
}
diff --git a/src/plugins/mythtv/totem-mythtv.c b/src/plugins/mythtv/totem-mythtv.c
index 4027f5e..56ed174 100644
--- a/src/plugins/mythtv/totem-mythtv.c
+++ b/src/plugins/mythtv/totem-mythtv.c
@@ -88,7 +88,6 @@ typedef struct
GType totem_mythtv_plugin_get_type (void) G_GNUC_CONST;
-static void totem_mythtv_plugin_finalize (GObject *object);
TOTEM_PLUGIN_REGISTER(TOTEM_TYPE_MYTHTV_PLUGIN, TotemMythtvPlugin, totem_mythtv_plugin)
@@ -340,7 +339,6 @@ totem_mythtv_plugin_class_init (TotemMythtvPluginClass *klass)
object_class->set_property = set_property;
object_class->get_property = get_property;
- object_class->finalize = totem_mythtv_plugin_finalize;
g_object_class_override_property (object_class, PROP_OBJECT, "object");
}
@@ -443,33 +441,6 @@ refresh_cb (GtkWidget *button, TotemMythtvPlugin *tm)
static void
totem_mythtv_plugin_init (TotemMythtvPlugin *plugin)
{
- totem_mythtv_update_binfo (plugin);
-}
-
-static void
-totem_mythtv_plugin_finalize (GObject *object)
-{
- TotemMythtvPlugin *tm = TOTEM_MYTHTV_PLUGIN(object);
-
- if (tm->lst_b_info != NULL) {
- g_list_foreach (tm->lst_b_info, (GFunc ) g_object_unref, NULL);
- g_list_free (tm->lst_b_info);
- tm->lst_b_info = NULL;
- }
- if (tm->upnp != NULL) {
- g_object_unref (tm->upnp);
- tm->upnp = NULL;
- }
- if (tm->sidebar_recordings != NULL) {
- gtk_widget_destroy (tm->sidebar_recordings);
- tm->sidebar_recordings = NULL;
- }
- if (tm->sidebar_livetv != NULL) {
- gtk_widget_destroy (tm->sidebar_livetv);
- tm->sidebar_livetv = NULL;
- }
-
- G_OBJECT_CLASS (totem_mythtv_plugin_parent_class)->finalize (object);
}
static GtkWidget *
diff --git a/src/plugins/screensaver/totem-screensaver.c b/src/plugins/screensaver/totem-screensaver.c
index ce93528..50c75f8 100644
--- a/src/plugins/screensaver/totem-screensaver.c
+++ b/src/plugins/screensaver/totem-screensaver.c
@@ -67,8 +67,6 @@ typedef struct
GType totem_screensaver_plugin_get_type (void) G_GNUC_CONST;
-static void totem_screensaver_plugin_finalize (GObject *object);
-
TOTEM_PLUGIN_REGISTER(TOTEM_TYPE_SCREENSAVER_PLUGIN,
TotemScreensaverPlugin,
totem_screensaver_plugin)
@@ -80,7 +78,6 @@ totem_screensaver_plugin_class_init (TotemScreensaverPluginClass *klass)
object_class->set_property = set_property;
object_class->get_property = get_property;
- object_class->finalize = totem_screensaver_plugin_finalize;
g_object_class_override_property (object_class, PROP_OBJECT, "object");
}
@@ -88,20 +85,6 @@ totem_screensaver_plugin_class_init (TotemScreensaverPluginClass *klass)
static void
totem_screensaver_plugin_init (TotemScreensaverPlugin *plugin)
{
- plugin->scr = totem_scrsaver_new ();
- g_object_set (plugin->scr,
- "reason", _("Playing a movie"),
- NULL);
-}
-
-static void
-totem_screensaver_plugin_finalize (GObject *object)
-{
- TotemScreensaverPlugin *plugin = TOTEM_SCREENSAVER_PLUGIN (object);
-
- g_object_unref (plugin->scr);
-
- G_OBJECT_CLASS (totem_screensaver_plugin_parent_class)->finalize (object);
}
static void
@@ -150,6 +133,11 @@ impl_activate (PeasActivatable *plugin)
TotemScreensaverPlugin *pi = TOTEM_SCREENSAVER_PLUGIN (plugin);
TotemObject *totem;
+ pi->scr = totem_scrsaver_new ();
+ g_object_set (pi->scr,
+ "reason", _("Playing a movie"),
+ NULL);
+
totem = g_object_get_data (G_OBJECT (plugin), "object");
pi->bvw = BACON_VIDEO_WIDGET (totem_get_video_widget (totem));
@@ -193,5 +181,7 @@ impl_deactivate (PeasActivatable *plugin)
g_object_unref (pi->bvw);
totem_scrsaver_enable (pi->scr);
+
+ g_object_unref (pi->scr);
}
diff --git a/src/plugins/skipto/totem-skipto-plugin.c b/src/plugins/skipto/totem-skipto-plugin.c
index 80252d7..c2f9aaf 100644
--- a/src/plugins/skipto/totem-skipto-plugin.c
+++ b/src/plugins/skipto/totem-skipto-plugin.c
@@ -49,8 +49,6 @@ struct TotemSkiptoPluginPrivate
GtkActionGroup *action_group;
};
-static void totem_skipto_plugin_finalize (GObject *object);
-
TOTEM_PLUGIN_REGISTER(TOTEM_TYPE_SKIPTO_PLUGIN, TotemSkiptoPlugin, totem_skipto_plugin)
static void
@@ -60,7 +58,6 @@ totem_skipto_plugin_class_init (TotemSkiptoPluginClass *klass)
object_class->set_property = set_property;
object_class->get_property = get_property;
- object_class->finalize = totem_skipto_plugin_finalize;
g_type_class_add_private (klass, sizeof (TotemSkiptoPluginPrivate));
g_object_class_override_property (object_class, PROP_OBJECT, "object");
@@ -71,7 +68,6 @@ totem_skipto_plugin_init (TotemSkiptoPlugin *plugin)
plugin->priv = G_TYPE_INSTANCE_GET_PRIVATE (plugin,
TOTEM_TYPE_SKIPTO_PLUGIN,
TotemSkiptoPluginPrivate);
- plugin->priv->st = NULL;
}
static void
@@ -88,16 +84,6 @@ destroy_dialog (TotemSkiptoPlugin *plugin)
}
static void
-totem_skipto_plugin_finalize (GObject *object)
-{
- TotemSkiptoPlugin *plugin = TOTEM_SKIPTO_PLUGIN (object);
-
- destroy_dialog (plugin);
-
- G_OBJECT_CLASS (totem_skipto_plugin_parent_class)->finalize (object);
-}
-
-static void
totem_skipto_update_from_state (TotemObject *totem,
TotemSkiptoPlugin *plugin)
{
@@ -273,5 +259,7 @@ impl_deactivate (PeasActivatable *plugin)
manager = totem_get_ui_manager (totem);
gtk_ui_manager_remove_ui (manager, priv->ui_merge_id);
gtk_ui_manager_remove_action_group (manager, priv->action_group);
+
+ destroy_dialog (TOTEM_SKIPTO_PLUGIN (plugin));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]