~ubuntu-branches/debian/squeeze/galeon/squeeze

« back to all changes in this revision

Viewing changes to bookmarks/bookmarks-import-druid-konqueror.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Howard
  • Date: 2004-06-06 09:02:01 UTC
  • Revision ID: james.westby@ubuntu.com-20040606090201-yhx6ruhq8um7ggs2
Tags: upstream-1.3.15
Import upstream version 1.3.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  Copyright (C) 2002  Ricardo Fern�ndez Pascual
 
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, or (at your option)
 
7
 *  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, write to the Free Software
 
16
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
17
 */
 
18
 
 
19
#ifdef HAVE_CONFIG_H
 
20
#include "config.h"
 
21
#endif
 
22
 
 
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"
 
28
 
 
29
#include "xbel.h"
 
30
 
 
31
/**
 
32
 * Private data
 
33
 */
 
34
struct _GbImportDruidKonquerorPrivate {
 
35
 
 
36
};
 
37
 
 
38
static GHashTable *strings = NULL;
 
39
 
 
40
/**
 
41
 * Private functions, only availble from this file
 
42
 */
 
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);
 
51
 
 
52
static gpointer gb_import_druid_class;
 
53
 
 
54
/**
 
55
 * ImportDruidKonqueror object
 
56
 */
 
57
 
 
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);
 
61
 
 
62
static void
 
63
gb_import_druid_konqueror_class_init (GbImportDruidKonquerorClass *klass)
 
64
{
 
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);
 
70
}
 
71
 
 
72
static void 
 
73
gb_import_druid_konqueror_init (GbImportDruidKonqueror *e)
 
74
{
 
75
        GbImportDruidKonquerorPrivate *p = g_new0 (GbImportDruidKonquerorPrivate, 1);
 
76
        e->priv = p;
 
77
        
 
78
}
 
79
 
 
80
static void
 
81
gb_import_druid_konqueror_finalize_impl (GObject *o)
 
82
{
 
83
        GbImportDruidKonqueror *e = GB_IMPORT_DRUID_KONQUEROR (o);
 
84
        GbImportDruidKonquerorPrivate *p = e->priv;
 
85
 
 
86
        g_free (p);
 
87
        
 
88
        G_OBJECT_CLASS (gb_import_druid_class)->finalize (o);
 
89
 
 
90
}
 
91
 
 
92
GbImportDruidKonqueror *
 
93
gb_import_druid_konqueror_new (void)
 
94
{
 
95
        GbImportDruidKonqueror *ret = g_object_new (GB_TYPE_IMPORT_DRUID_KONQUEROR, NULL);
 
96
        return ret;
 
97
}
 
98
 
 
99
static const char *
 
100
gb_import_druid_konqueror_get_string_impl (GbImportDruid *d, 
 
101
                                         const char *string_id)
 
102
{
 
103
        gb_import_druid_konqueror_init_strings ();
 
104
        return _(g_hash_table_lookup (strings, string_id));
 
105
}
 
106
 
 
107
static void
 
108
gb_import_druid_konqueror_init_strings (void)
 
109
{
 
110
        if (!strings)
 
111
        {
 
112
                static struct 
 
113
                {
 
114
                        const char *id;
 
115
                        const char *text;
 
116
                } strs[] = {
 
117
                        { "window title", N_("XBEL (Galeon and Konqueror) Bookmarks Import Druid") },
 
118
                        { "page 1 title", N_("XBEL (Galeon and Konqueror) Bookmarks Import") },
 
119
                        {NULL, NULL}
 
120
                };                      
 
121
                int i;
 
122
                strings = g_hash_table_new (g_str_hash, g_str_equal);
 
123
                for (i = 0; strs[i].id != NULL; ++i)
 
124
                {
 
125
                        g_hash_table_insert (strings, (gpointer) strs[i].id, (gpointer) strs[i].text);
 
126
                }
 
127
        }
 
128
}
 
129
 
 
130
static GSList *
 
131
gb_import_druid_konqueror_get_locations_impl (GbImportDruid *druid)
 
132
{
 
133
        GSList *l;
 
134
        GSList *ret = NULL;
 
135
        gchar *dir;
 
136
        gchar *fname;
 
137
        guint i;
 
138
        
 
139
        static const gchar *galeon_dirs[] = { ".galeon", ".galeon1" , ".galeon2" };
 
140
        static const gchar *kde_dirs[] = { ".kde", ".kde2", ".kde3", ".konqueror" };
 
141
        
 
142
        /* galeon locations */
 
143
        for (i = 0; i < G_N_ELEMENTS (galeon_dirs); ++i)
 
144
        {
 
145
                guint j;
 
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)
 
150
                {
 
151
                        fname = g_strdup_printf ("bookmarks.xbel.%d", j);
 
152
                        l = gul_find_file  (dir, fname, 5);
 
153
                        ret = g_slist_concat (ret, l);
 
154
                        g_free (fname);
 
155
                }
 
156
                g_free (dir);
 
157
        }
 
158
        
 
159
        fname = g_build_filename (SHARE_DIR, "default-bookmarks.xbel", NULL);
 
160
        ret = g_slist_append (ret, fname);
 
161
        
 
162
        /* konqueror locations */
 
163
        for (i = 0; i < G_N_ELEMENTS (kde_dirs); ++i)
 
164
        {
 
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);
 
170
                g_free (dir);
 
171
        }
 
172
 
 
173
        return ret;
 
174
}
 
175
 
 
176
static GbIO *
 
177
gb_import_druid_konqueror_get_io_impl (GbImportDruid *druid)
 
178
{
 
179
        GbXBEL *io = gb_xbel_new ();
 
180
        return GB_IO (io);
 
181
}
 
182