[gnome-games] libgames-support: add missing code for new private code, finalize GamesScores
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] libgames-support: add missing code for new private code, finalize GamesScores
- Date: Fri, 21 Jan 2011 01:43:03 +0000 (UTC)
commit 3151b704b850dd2a105866838b9cd89e6c18c1d2
Author: Robert Ancell <robert ancell canonical com>
Date: Fri Jan 21 12:42:54 2011 +1100
libgames-support: add missing code for new private code, finalize GamesScores
libgames-support/games-clock.c | 2 +
libgames-support/games-controls.c | 2 +-
libgames-support/games-files.c | 1 +
libgames-support/games-frame.c | 2 +
libgames-support/games-gridframe.c | 2 +
libgames-support/games-preimage.c | 1 +
libgames-support/games-score.c | 2 +
libgames-support/games-scores-dialog.c | 2 +-
libgames-support/games-scores.c | 45 +++++++++++++++++++------------
9 files changed, 39 insertions(+), 20 deletions(-)
---
diff --git a/libgames-support/games-clock.c b/libgames-support/games-clock.c
index dca49d7..c48139b 100644
--- a/libgames-support/games-clock.c
+++ b/libgames-support/games-clock.c
@@ -94,6 +94,8 @@ games_clock_class_init (GamesClockClass * klass)
static void
games_clock_init (GamesClock *clock_widget)
{
+ clock_widget->priv = G_TYPE_INSTANCE_GET_PRIVATE (clock_widget, GAMES_TYPE_CLOCK, GamesClockPrivate);
+
clock_widget->priv->update_timeout_id = 0;
clock_widget->priv->start_time = clock_widget->priv->stop_time = 0;
clock_widget->priv->started = FALSE;
diff --git a/libgames-support/games-controls.c b/libgames-support/games-controls.c
index e97a53e..3238e76 100644
--- a/libgames-support/games-controls.c
+++ b/libgames-support/games-controls.c
@@ -167,6 +167,7 @@ conf_value_changed_cb (GamesConf *conf,
static void
games_controls_list_init (GamesControlsList *list)
{
+ list->priv = G_TYPE_INSTANCE_GET_PRIVATE (list, GAMES_TYPE_CONTROLS_LIST, GamesControlsListPrivate);
}
static GObject *
@@ -241,7 +242,6 @@ games_controls_list_constructor (GType type,
static void
games_controls_list_finalize (GObject *object)
-
{
GamesControlsList *list = GAMES_CONTROLS_LIST (object);
diff --git a/libgames-support/games-files.c b/libgames-support/games-files.c
index 7f8e483..11cb83b 100644
--- a/libgames-support/games-files.c
+++ b/libgames-support/games-files.c
@@ -437,4 +437,5 @@ games_file_list_class_init (GamesFileListClass * class)
static void
games_file_list_init (GamesFileList * filelist)
{
+ filelist->priv = G_TYPE_INSTANCE_GET_PRIVATE (filelist, GAMES_FILE_LIST_TYPE, GamesFileListPrivate);
}
diff --git a/libgames-support/games-frame.c b/libgames-support/games-frame.c
index 7d11e03..7fe2123 100644
--- a/libgames-support/games-frame.c
+++ b/libgames-support/games-frame.c
@@ -46,6 +46,8 @@ games_frame_init (GamesFrame * frame)
PangoAttrList *attr_list;
PangoAttribute *attr;
+ frame->priv = G_TYPE_INSTANCE_GET_PRIVATE (frame, GAMES_TYPE_FRAME, GamesFramePrivate);
+
gtk_box_set_spacing (box, 6);
gtk_box_set_homogeneous (box, FALSE);
gtk_orientable_set_orientation (GTK_ORIENTABLE (frame), GTK_ORIENTATION_VERTICAL);
diff --git a/libgames-support/games-gridframe.c b/libgames-support/games-gridframe.c
index e328fb2..43c85f2 100644
--- a/libgames-support/games-gridframe.c
+++ b/libgames-support/games-gridframe.c
@@ -270,6 +270,8 @@ games_grid_frame_class_init (GamesGridFrameClass * class)
static void
games_grid_frame_init (GamesGridFrame * frame)
{
+ frame->priv = G_TYPE_INSTANCE_GET_PRIVATE (frame, GAMES_TYPE_GRID_FRAME, GamesGridFramePrivate);
+
frame->priv->xmult = 1;
frame->priv->ymult = 1;
diff --git a/libgames-support/games-preimage.c b/libgames-support/games-preimage.c
index 0e3e6c9..e1ff632 100644
--- a/libgames-support/games-preimage.c
+++ b/libgames-support/games-preimage.c
@@ -59,6 +59,7 @@ struct GamesPreimagePrivate {
static void
games_preimage_init (GamesPreimage * preimage)
{
+ preimage->priv = G_TYPE_INSTANCE_GET_PRIVATE (preimage, GAMES_TYPE_PREIMAGE, GamesPreimagePrivate);
preimage->priv->scalable = FALSE;
preimage->priv->width = 0;
preimage->priv->height = 0;
diff --git a/libgames-support/games-score.c b/libgames-support/games-score.c
index f9d279a..392d471 100644
--- a/libgames-support/games-score.c
+++ b/libgames-support/games-score.c
@@ -176,6 +176,8 @@ games_score_init (GamesScore *score)
{
const gchar* name;
+ score->priv = G_TYPE_INSTANCE_GET_PRIVATE (score, GAMES_TYPE_SCORE, GamesScorePrivate);
+
score->priv->time = time (NULL);
/* FIXME: We don't handle the "Unknown" case. */
name = g_get_real_name ();
diff --git a/libgames-support/games-scores-dialog.c b/libgames-support/games-scores-dialog.c
index 1997484..fd43d83 100644
--- a/libgames-support/games-scores-dialog.c
+++ b/libgames-support/games-scores-dialog.c
@@ -480,7 +480,7 @@ static void games_scores_dialog_init (GamesScoresDialog *self)
GtkCellRenderer *renderer;
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GAMES_TYPE_SCORES_DIALOG,
- GamesScoresDialogPrivate);
+ GamesScoresDialogPrivate);
self->priv->style = GAMES_SCORES_STYLE_PLAIN_DESCENDING;
/* These two hashes are the reverse of each other. As an optimisation
diff --git a/libgames-support/games-scores.c b/libgames-support/games-scores.c
index c2bcdc6..3532f75 100644
--- a/libgames-support/games-scores.c
+++ b/libgames-support/games-scores.c
@@ -21,8 +21,6 @@
/* FIXME: Document */
-/* FIXME: Add a finaliser to get rid of some of the strings. */
-
#include <config.h>
#include <fcntl.h>
@@ -125,20 +123,18 @@ games_scores_new (const char *app_name,
GamesScoreStyle style)
{
GamesScores *self;
- GamesScoresPrivate *priv;
self = GAMES_SCORES (g_object_new (GAMES_TYPE_SCORES, NULL));
- priv = self->priv;
/* FIXME: Input sanity checks. */
- priv->categories = g_hash_table_new_full (g_str_hash, g_str_equal,
- g_free,
- (GDestroyNotify) games_scores_category_free);
+ self->priv->categories = g_hash_table_new_full (g_str_hash, g_str_equal,
+ g_free,
+ (GDestroyNotify) games_scores_category_free);
/* catsordered is a record of the ordering of the categories.
* Its data is shared with the hash table. */
- priv->catsordered = NULL;
+ self->priv->catsordered = NULL;
if (n_categories > 0) {
int i;
@@ -158,22 +154,18 @@ games_scores_new (const char *app_name,
games_scores_add_category (self, category->key, display_name);
}
- priv->defcat = g_strdup (categories[default_category_index].key);
- priv->currentcat = g_strdup (priv->defcat);
- } else {
- priv->currentcat = NULL;
- priv->defcat = NULL;
+ self->priv->defcat = g_strdup (categories[default_category_index].key);
+ self->priv->currentcat = g_strdup (self->priv->defcat);
}
- priv->basename = g_strdup (app_name);
+ self->priv->basename = g_strdup (app_name);
/* FIXME: Do some sanity checks on the default and the like. */
- priv->style = style;
+ self->priv->style = style;
/* Set up the anonymous category for use when no categories are specified. */
- priv->dummycat.category.key = (char *) "";
- priv->dummycat.category.name = (char *) "";
- priv->dummycat.backend = NULL;
+ self->priv->dummycat.category.key = (char *) "";
+ self->priv->dummycat.category.name = (char *) "";
return self;
}
@@ -505,7 +497,24 @@ games_scores_init (GamesScores * self)
}
static void
+games_scores_finalize (GObject * object)
+{
+ GamesScores *scores = GAMES_SCORES (object);
+
+ g_hash_table_unref (scores->priv->categories);
+ g_free (scores->priv->catsordered);
+ g_free (scores->priv->currentcat);
+ g_free (scores->priv->defcat);
+ g_free (scores->priv->basename);
+ g_object_unref (scores->priv->last_score);
+
+ G_OBJECT_CLASS (games_scores_parent_class)->finalize (object);
+}
+
+static void
games_scores_class_init (GamesScoresClass * klass)
{
+ GObjectClass *object_class = (GObjectClass *) klass;
+ object_class->finalize = games_scores_finalize;
g_type_class_add_private (klass, sizeof (GamesScoresPrivate));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]