~ubuntu-branches/ubuntu/trusty/unity-control-center/trusty

« back to all changes in this revision

Viewing changes to panels/appearance/bg-source.c

  • Committer: Package Import Robot
  • Author(s): Robert Ancell
  • Date: 2014-01-08 16:29:18 UTC
  • Revision ID: package-import@ubuntu.com-20140108162918-g29dd08tr913y2qh
Tags: upstream-14.04.0
ImportĀ upstreamĀ versionĀ 14.04.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2010 Intel, Inc
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2 of the License, or
 
7
 * (at your option) any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
16
 *
 
17
 * Author: Thomas Wood <thomas.wood@intel.com>
 
18
 *
 
19
 */
 
20
 
 
21
#include "bg-source.h"
 
22
#include "cc-appearance-item.h"
 
23
 
 
24
G_DEFINE_ABSTRACT_TYPE (BgSource, bg_source, G_TYPE_OBJECT)
 
25
 
 
26
#define SOURCE_PRIVATE(o) \
 
27
  (G_TYPE_INSTANCE_GET_PRIVATE ((o), BG_TYPE_SOURCE, BgSourcePrivate))
 
28
 
 
29
struct _BgSourcePrivate
 
30
{
 
31
  GtkListStore *store;
 
32
};
 
33
 
 
34
enum
 
35
{
 
36
  PROP_LISTSTORE = 1
 
37
};
 
38
 
 
39
 
 
40
static void
 
41
bg_source_get_property (GObject    *object,
 
42
                        guint       property_id,
 
43
                        GValue     *value,
 
44
                        GParamSpec *pspec)
 
45
{
 
46
  BgSource *source = BG_SOURCE (object);
 
47
 
 
48
  switch (property_id)
 
49
    {
 
50
    case PROP_LISTSTORE:
 
51
      g_value_set_object (value, bg_source_get_liststore (source));
 
52
      break;
 
53
 
 
54
    default:
 
55
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
56
    }
 
57
}
 
58
 
 
59
static void
 
60
bg_source_set_property (GObject      *object,
 
61
                        guint         property_id,
 
62
                        const GValue *value,
 
63
                        GParamSpec   *pspec)
 
64
{
 
65
  switch (property_id)
 
66
    {
 
67
    default:
 
68
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
69
    }
 
70
}
 
71
 
 
72
static void
 
73
bg_source_dispose (GObject *object)
 
74
{
 
75
  BgSourcePrivate *priv = BG_SOURCE (object)->priv;
 
76
 
 
77
  if (priv->store)
 
78
    {
 
79
      g_object_unref (priv->store);
 
80
      priv->store = NULL;
 
81
    }
 
82
 
 
83
  G_OBJECT_CLASS (bg_source_parent_class)->dispose (object);
 
84
}
 
85
 
 
86
static void
 
87
bg_source_finalize (GObject *object)
 
88
{
 
89
  G_OBJECT_CLASS (bg_source_parent_class)->finalize (object);
 
90
}
 
91
 
 
92
static void
 
93
bg_source_class_init (BgSourceClass *klass)
 
94
{
 
95
  GParamSpec *pspec;
 
96
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
97
 
 
98
  g_type_class_add_private (klass, sizeof (BgSourcePrivate));
 
99
 
 
100
  object_class->get_property = bg_source_get_property;
 
101
  object_class->set_property = bg_source_set_property;
 
102
  object_class->dispose = bg_source_dispose;
 
103
  object_class->finalize = bg_source_finalize;
 
104
 
 
105
  pspec = g_param_spec_object ("liststore",
 
106
                               "Liststore",
 
107
                               "Liststore used in the source",
 
108
                               GTK_TYPE_LIST_STORE,
 
109
                               G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
 
110
  g_object_class_install_property (object_class, PROP_LISTSTORE, pspec);
 
111
}
 
112
 
 
113
static void
 
114
bg_source_init (BgSource *self)
 
115
{
 
116
  BgSourcePrivate *priv;
 
117
 
 
118
  priv = self->priv = SOURCE_PRIVATE (self);
 
119
 
 
120
  priv->store = gtk_list_store_new (3, G_TYPE_ICON, G_TYPE_OBJECT, G_TYPE_STRING);
 
121
}
 
122
 
 
123
GtkListStore*
 
124
bg_source_get_liststore (BgSource *source)
 
125
{
 
126
  g_return_val_if_fail (BG_IS_SOURCE (source), NULL);
 
127
 
 
128
  return source->priv->store;
 
129
}