1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
3
* Copyright (C) 2001 Ximian, Inc.
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as
7
* published by the Free Software Foundation; either version 2 of the
8
* License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
19
* Authors: Alvaro Pe�a Gonzalez <apg@esware.com>
20
* Carlos Garcia Campos <elkalmail@yahoo.es>
27
#include <glib/gi18n.h>
29
#include "disks-storage.h"
30
#include "disks-storage-disk.h"
31
#include "disks-gui.h"
33
#define PARENT_TYPE GST_TYPE_DISKS_STORAGE
40
struct _GstDisksStorageDiskPriv
46
static void storage_disk_init (GstDisksStorageDisk *storage);
47
static void storage_disk_class_init (GstDisksStorageDiskClass *klass);
48
static void storage_disk_finalize (GObject *object);
50
static void storage_set_property (GObject *object, guint prop_id,
51
const GValue *value, GParamSpec *spec);
52
static void storage_get_property (GObject *object, guint prop_id,
53
GValue *value, GParamSpec *spec);
55
static void storage_disk_setup_properties_widget (GstDisksStorage *storage);
57
static GObjectClass *parent_class = NULL;
60
gst_disks_storage_disk_get_type (void)
62
static GType type = 0;
65
static const GTypeInfo info = {
66
sizeof (GstDisksStorageDiskClass),
68
(GBaseFinalizeFunc) NULL,
69
(GClassInitFunc) storage_disk_class_init,
72
sizeof (GstDisksStorageDisk),
74
(GInstanceInitFunc) storage_disk_init
76
type = g_type_register_static (PARENT_TYPE, "GstDisksStorageDisk",
83
storage_disk_init (GstDisksStorageDisk *storage)
85
g_return_if_fail (GST_IS_DISKS_STORAGE_DISK (storage));
87
storage->priv = g_new0 (GstDisksStorageDiskPriv, 1);
88
/*storage->priv->use_dma = FALSE;*/
89
storage->priv->partitions = NULL;
91
g_object_set (G_OBJECT (storage),
92
"name", _("Hard Disk"),
93
"icon_name", "gnome-dev-harddisk",
98
storage_disk_class_init (GstDisksStorageDiskClass *klass)
100
GObjectClass *object_class = G_OBJECT_CLASS (klass);
101
GstDisksStorageClass *storage_class = GST_DISKS_STORAGE_CLASS (klass);
103
parent_class = g_type_class_peek_parent (klass);
105
object_class->set_property = storage_set_property;
106
object_class->get_property = storage_get_property;
108
storage_class->setup_properties_widget = storage_disk_setup_properties_widget;
110
g_object_class_install_property (object_class, PROP_PARTITIONS,
111
g_param_spec_pointer ("partitions", NULL, NULL,
114
object_class->finalize = storage_disk_finalize;
118
delete_object (gpointer object, gpointer gdata)
120
g_object_unref (G_OBJECT (object));
124
storage_disk_finalize (GObject *object)
126
GstDisksStorageDisk *storage = GST_DISKS_STORAGE_DISK (object);
127
g_return_if_fail (GST_IS_DISKS_STORAGE_DISK (storage));
130
if (storage->priv->partitions) {
131
g_list_foreach (storage->priv->partitions,
132
delete_object, NULL);
133
g_list_free (storage->priv->partitions);
134
storage->priv->partitions = NULL;
136
g_free (storage->priv);
137
storage->priv = NULL;
140
if (G_OBJECT_CLASS (parent_class)->finalize)
141
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
145
storage_set_property (GObject *object, guint prop_id, const GValue *value,
148
GstDisksStorageDisk *storage;
150
g_return_if_fail (GST_IS_DISKS_STORAGE_DISK (object));
152
storage = GST_DISKS_STORAGE_DISK (object);
155
case PROP_PARTITIONS:
156
storage->priv->partitions = g_value_get_pointer (value);
165
storage_get_property (GObject *object, guint prop_id, GValue *value,
168
GstDisksStorageDisk *storage;
170
g_return_if_fail (GST_IS_DISKS_STORAGE_DISK (object));
172
storage = GST_DISKS_STORAGE_DISK (object);
175
case PROP_PARTITIONS:
176
g_value_set_pointer (value, storage->priv->partitions);
179
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, spec);
184
gst_disks_storage_disk_new (void)
186
GstDisksStorageDisk *storage;
188
storage = g_object_new (GST_TYPE_DISKS_STORAGE_DISK, NULL);
190
return GST_DISKS_STORAGE (storage);
194
storage_disk_setup_properties_widget (GstDisksStorage *storage)
196
GstDisksStorageDisk *disk;
198
disk = GST_DISKS_STORAGE_DISK (storage);
200
gst_disks_gui_setup_disk_properties (disk);
202
GST_DISKS_STORAGE_GET_CLASS (storage)->setup_common_properties (storage);
206
gst_disks_storage_disk_get_partition (GstDisksStorageDisk *disk, const gchar *device)
209
GList *partitions = NULL;
210
GstDisksPartition *part;
213
g_return_val_if_fail (GST_IS_DISKS_STORAGE_DISK (disk), NULL);
215
g_object_get (G_OBJECT (disk), "partitions", &partitions, NULL);
218
list = g_list_first (partitions);
221
part = GST_DISKS_PARTITION (list->data);
222
g_object_get (G_OBJECT (part), "device", &part_device, NULL);
224
if (g_ascii_strcasecmp (part_device, device) == 0)
227
list = g_list_next (list);