2
* arch-tag: Implementation of removable media source object (based of the ipod source)
4
* Copyright (C) 2004 Christophe Fergeau <teuf@gnome.org>
5
* Copyright (C) 2005 James Livingston <jrl@ids.org.au>
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
#include <gtk/gtktreeview.h>
26
#include <gtk/gtkicontheme.h>
27
#include <gtk/gtkiconfactory.h>
30
#include <libgnome/gnome-i18n.h>
31
#include <libgnomevfs/gnome-vfs-volume.h>
32
#include <libgnomevfs/gnome-vfs-volume-monitor.h>
33
#include "eel-gconf-extensions.h"
34
#include "rb-removable-media-source.h"
35
#include "rb-stock-icons.h"
37
#include "rb-dialog.h"
40
static void rb_removable_media_source_dispose (GObject *object);
42
static void rb_removable_media_source_set_property (GObject *object,
46
static void rb_removable_media_source_get_property (GObject *object,
51
static GdkPixbuf *impl_get_pixbuf (RBSource *source);
52
static void impl_delete_thyself (RBSource *source);
57
GnomeVFSVolume *volume;
58
} RBRemovableMediaSourcePrivate;
60
G_DEFINE_TYPE (RBRemovableMediaSource, rb_removable_media_source, RB_TYPE_LIBRARY_SOURCE)
61
#define REMOVABLE_MEDIA_SOURCE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RB_TYPE_REMOVABLE_MEDIA_SOURCE, RBRemovableMediaSourcePrivate))
72
rb_removable_media_source_class_init (RBRemovableMediaSourceClass *klass)
74
GObjectClass *object_class = G_OBJECT_CLASS (klass);
75
RBSourceClass *source_class = RB_SOURCE_CLASS (klass);
76
RBLibrarySourceClass *library_source_class = RB_LIBRARY_SOURCE_CLASS (klass);
78
object_class->dispose = rb_removable_media_source_dispose;
79
object_class->set_property = rb_removable_media_source_set_property;
80
object_class->get_property = rb_removable_media_source_get_property;
82
source_class->impl_get_pixbuf = impl_get_pixbuf;
83
source_class->impl_delete_thyself = impl_delete_thyself;
84
source_class->impl_can_cut = (RBSourceFeatureFunc) rb_false_function;
85
source_class->impl_can_copy = (RBSourceFeatureFunc) rb_false_function;
86
source_class->impl_can_delete = (RBSourceFeatureFunc) rb_false_function;
87
source_class->impl_receive_drag = NULL;
88
source_class->impl_paste = NULL;
89
source_class->impl_delete = NULL;
90
source_class->impl_get_config_widget = NULL;
91
source_class->impl_show_popup = (RBSourceFeatureFunc) rb_false_function;
93
library_source_class->impl_get_paned_key = NULL;
94
library_source_class->impl_has_first_added_column = (RBLibrarySourceFeatureFunc) rb_false_function;
95
library_source_class->impl_has_drop_support = (RBLibrarySourceFeatureFunc) rb_false_function;
97
g_object_class_install_property (object_class,
99
g_param_spec_object ("volume",
102
GNOME_VFS_TYPE_VOLUME,
103
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
105
g_type_class_add_private (klass, sizeof (RBRemovableMediaSourcePrivate));
109
rb_removable_media_source_init (RBRemovableMediaSource *self)
115
rb_removable_media_source_dispose (GObject *object)
117
RBRemovableMediaSourcePrivate *priv = REMOVABLE_MEDIA_SOURCE_GET_PRIVATE (object);
120
gnome_vfs_volume_unref (priv->volume);
124
G_OBJECT_CLASS (rb_removable_media_source_parent_class)->dispose (object);
128
rb_removable_media_source_set_property (GObject *object,
133
RBRemovableMediaSourcePrivate *priv = REMOVABLE_MEDIA_SOURCE_GET_PRIVATE (object);
139
gnome_vfs_volume_unref (priv->volume);
141
priv->volume = g_value_get_object (value);
142
gnome_vfs_volume_ref (priv->volume);
145
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
151
rb_removable_media_source_get_property (GObject *object,
156
RBRemovableMediaSourcePrivate *priv = REMOVABLE_MEDIA_SOURCE_GET_PRIVATE (object);
161
gnome_vfs_volume_ref (priv->volume);
162
g_value_take_object (value, priv->volume);
165
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
171
impl_get_pixbuf (RBSource *source)
173
RBRemovableMediaSourcePrivate *priv = REMOVABLE_MEDIA_SOURCE_GET_PRIVATE (source);
176
char *icon_name = gnome_vfs_volume_get_icon (priv->volume);
177
GtkIconTheme *theme = gtk_icon_theme_get_default ();
178
gtk_icon_size_lookup (GTK_ICON_SIZE_LARGE_TOOLBAR, &size, NULL);
179
GdkPixbuf *icon = gtk_icon_theme_load_icon (theme, icon_name, size, 0, NULL);
186
impl_delete_thyself (RBSource *source)
190
RhythmDBEntryType entry_type;
192
g_object_get (G_OBJECT (source), "shell", &shell, NULL);
193
g_object_get (G_OBJECT (shell), "db", &db, NULL);
194
g_object_unref (G_OBJECT (shell));
196
g_object_get (G_OBJECT (source), "entry-type", &entry_type, NULL);
197
rhythmdb_entry_delete_by_type (db, entry_type);
198
rhythmdb_commit (db);