2
* Copyright (C) 2002 Ricardo Fern�ndez Pascual
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, or (at your option)
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.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
#include <glib/gi18n.h>
24
#include "bookmarks-import-druid-konqueror.h"
25
#include "gul-gobject-misc.h"
26
#include "gul-string.h"
27
#include "gul-general.h"
34
struct _GbImportDruidKonquerorPrivate {
38
static GHashTable *strings = NULL;
41
* Private functions, only availble from this file
43
static void gb_import_druid_konqueror_class_init (GbImportDruidKonquerorClass *klass);
44
static void gb_import_druid_konqueror_init (GbImportDruidKonqueror *e);
45
static void gb_import_druid_konqueror_finalize_impl (GObject *o);
46
static void gb_import_druid_konqueror_init_strings (void);
47
static const char * gb_import_druid_konqueror_get_string_impl (GbImportDruid *d,
48
const char *string_id);
49
static GSList * gb_import_druid_konqueror_get_locations_impl (GbImportDruid *d);
50
static GbIO * gb_import_druid_konqueror_get_io_impl (GbImportDruid *d);
52
static gpointer gb_import_druid_class;
55
* ImportDruidKonqueror object
58
MAKE_GET_TYPE (gb_import_druid_konqueror, "GbImportDruidKonqueror", GbImportDruidKonqueror,
59
gb_import_druid_konqueror_class_init,
60
gb_import_druid_konqueror_init, GB_TYPE_IMPORT_DRUID);
63
gb_import_druid_konqueror_class_init (GbImportDruidKonquerorClass *klass)
65
GB_IMPORT_DRUID_CLASS (klass)->get_locations = gb_import_druid_konqueror_get_locations_impl;
66
GB_IMPORT_DRUID_CLASS (klass)->get_io = gb_import_druid_konqueror_get_io_impl;
67
GB_IMPORT_DRUID_CLASS (klass)->get_string = gb_import_druid_konqueror_get_string_impl;
68
G_OBJECT_CLASS (klass)->finalize = gb_import_druid_konqueror_finalize_impl;
69
gb_import_druid_class = g_type_class_peek_parent (klass);
73
gb_import_druid_konqueror_init (GbImportDruidKonqueror *e)
75
GbImportDruidKonquerorPrivate *p = g_new0 (GbImportDruidKonquerorPrivate, 1);
81
gb_import_druid_konqueror_finalize_impl (GObject *o)
83
GbImportDruidKonqueror *e = GB_IMPORT_DRUID_KONQUEROR (o);
84
GbImportDruidKonquerorPrivate *p = e->priv;
88
G_OBJECT_CLASS (gb_import_druid_class)->finalize (o);
92
GbImportDruidKonqueror *
93
gb_import_druid_konqueror_new (void)
95
GbImportDruidKonqueror *ret = g_object_new (GB_TYPE_IMPORT_DRUID_KONQUEROR, NULL);
100
gb_import_druid_konqueror_get_string_impl (GbImportDruid *d,
101
const char *string_id)
103
gb_import_druid_konqueror_init_strings ();
104
return _(g_hash_table_lookup (strings, string_id));
108
gb_import_druid_konqueror_init_strings (void)
117
{ "window title", N_("XBEL (Galeon and Konqueror) Bookmarks Import Druid") },
118
{ "page 1 title", N_("XBEL (Galeon and Konqueror) Bookmarks Import") },
122
strings = g_hash_table_new (g_str_hash, g_str_equal);
123
for (i = 0; strs[i].id != NULL; ++i)
125
g_hash_table_insert (strings, (gpointer) strs[i].id, (gpointer) strs[i].text);
131
gb_import_druid_konqueror_get_locations_impl (GbImportDruid *druid)
139
static const gchar *galeon_dirs[] = { ".galeon", ".galeon1" , ".galeon2" };
140
static const gchar *kde_dirs[] = { ".kde", ".kde2", ".kde3", ".konqueror" };
142
/* galeon locations */
143
for (i = 0; i < G_N_ELEMENTS (galeon_dirs); ++i)
146
dir = g_build_filename (g_get_home_dir (), galeon_dirs[i], NULL);
147
l = gul_find_file (dir, "bookmarks.xbel", 5);
148
ret = g_slist_concat (ret, l);
149
for (j = 0; j < 10; ++j)
151
fname = g_strdup_printf ("bookmarks.xbel.%d", j);
152
l = gul_find_file (dir, fname, 5);
153
ret = g_slist_concat (ret, l);
159
fname = g_build_filename (SHARE_DIR, "default-bookmarks.xbel", NULL);
160
ret = g_slist_append (ret, fname);
162
/* konqueror locations */
163
for (i = 0; i < G_N_ELEMENTS (kde_dirs); ++i)
165
dir = g_build_filename (g_get_home_dir (), kde_dirs[i], NULL);
166
l = gul_find_file (dir, "bookmarks.xbel", 5);
167
ret = g_slist_concat (ret, l);
168
l = gul_find_file (dir, "bookmarks.xml", 5);
169
ret = g_slist_concat (ret, l);
177
gb_import_druid_konqueror_get_io_impl (GbImportDruid *druid)
179
GbXBEL *io = gb_xbel_new ();