summaryrefslogtreecommitdiff
path: root/stc/stcitem.c
blob: fda895bbb01194a57f1a66991a72e94b2352a8f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
 *
 * Copyright (C) 2007-2010 David Zeuthen <zeuthen@gmail.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the licence, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * Author: David Zeuthen <zeuthen@gmail.com>
 */

#include "config.h"

#include "stcitem.h"

/**
 * SECTION:stcitem
 * @title: StcItem
 * @short_description: Configuration Item
 *
 * Object corresponding to item. You cannot instantiate this type
 * yourself – you must use #StcMonitor.
 */

/**
 * StcItem:
 *
 * The #StcItem structure contains only private data and should
 * only be accessed using the provided API.
 */
struct _StcItem
{
  GObject parent_instance;

  StcItemType type;
  gchar *id;
  gchar *nick_name;
  gchar *target;
  gboolean can_apply;
  gboolean applied;
};

typedef struct _StcItemClass StcItemClass;

struct _StcItemClass
{
  GObjectClass parent_class;
};

G_DEFINE_TYPE (StcItem, stc_item, G_TYPE_OBJECT);

static void
stc_item_finalize (GObject *object)
{
  StcItem *item = STC_ITEM (object);

  g_free (item->id);
  g_free (item->nick_name);
  g_free (item->target);

  if (G_OBJECT_CLASS (stc_item_parent_class)->finalize)
    G_OBJECT_CLASS (stc_item_parent_class)->finalize (object);
}

static void
stc_item_init (StcItem *item)
{
}

static void
stc_item_class_init (StcItemClass *klass)
{
  GObjectClass *gobject_class;

  gobject_class = G_OBJECT_CLASS (klass);
  gobject_class->finalize = stc_item_finalize;
}

/**
 * stc_item_get_item_type:
 * @item: A #StcItem.
 *
 * Gets the #StcItemType for @item.
 *
 * Returns: A value from the #StcItemType enumeration.
 */
StcItemType
stc_item_get_item_type (StcItem *item)
{
  g_return_val_if_fail (STC_IS_ITEM (item), STC_ITEM_TYPE_INVALID);
  return item->type;
}

const gchar *
stc_item_get_id (StcItem *item)
{
  g_return_val_if_fail (STC_IS_ITEM (item), STC_ITEM_TYPE_INVALID);
  return item->id;
}

const gchar *
stc_item_get_nick_name (StcItem  *item)
{
  g_return_val_if_fail (STC_IS_ITEM (item), NULL);
  return item->nick_name;
}

const gchar *
stc_item_get_target (StcItem  *item)
{
  g_return_val_if_fail (STC_IS_ITEM (item), NULL);
  return item->target;
}

GList *
stc_item_get_dependencies (StcItem  *item)
{
  g_return_val_if_fail (STC_IS_ITEM (item), FALSE);
  /* TODO */
  return NULL;
}

gboolean
stc_item_get_can_apply (StcItem  *item)
{
  g_return_val_if_fail (STC_IS_ITEM (item), FALSE);
  return item->can_apply;
}

gboolean
stc_item_get_applied (StcItem  *item)
{
  g_return_val_if_fail (STC_IS_ITEM (item), FALSE);
  return item->applied;
}


#if 0
StcItem *
_stc_item_new (dev_t dev,
                   const gchar *item_path)
{
  StcItem *item;

  item = STC_ITEM (g_object_new (STC_TYPE_ITEM, NULL));
  item->dev = dev;
  item->item_path = g_strdup (item_path);

  return item;
}
#endif