~ubuntu-branches/ubuntu/saucy/libfm/saucy-proposed

« back to all changes in this revision

Viewing changes to src/base/fm-bookmarks.c

  • Committer: Bazaar Package Importer
  • Author(s): Julien Lavergne
  • Date: 2010-12-02 00:20:44 UTC
  • mfrom: (1.1.5 upstream) (0.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20101202002044-qhja03c1hk95b0q7
Tags: 0.1.14-2ubuntu1
* Sync with Debian unstable.
 - Fix crash on right click (LP: #617655)
* Ubuntu remaining changes:
 - debian/patches/90_add_gobject_link.patch:
  + From upstream, add "gobject-2.0" in configure.ac explicitly.
 - debian/patches/03_disable_deprecated_gio_module.patch:
  + Disable -DG_DISABLE_DEPRECATED for the gio module to build with glib
    2.27+.
 - debian/control:
  + Add Replaces/Conflicts for libfm0 and libfm-gtk0 (<= 0.1.11-1) to ensure
    migration from lucid.
  + Build-depends on dh-autoreconf.
 - debian/rules:
  + Use dh --with autoreconf.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
    N_SIGNALS
30
30
};
31
31
 
32
 
static FmBookmarks*     fm_bookmarks_new (void);
 
32
static FmBookmarks* fm_bookmarks_new (void);
33
33
 
34
 
static void fm_bookmarks_finalize                       (GObject *object);
 
34
static void fm_bookmarks_finalize           (GObject *object);
35
35
static GList* load_bookmarks(const char* fpath);
36
36
static void free_item(FmBookmarkItem* item);
37
37
static char* get_bookmarks_file();
45
45
 
46
46
static void fm_bookmarks_class_init(FmBookmarksClass *klass)
47
47
{
48
 
        GObjectClass *g_object_class;
49
 
        g_object_class = G_OBJECT_CLASS(klass);
50
 
        g_object_class->finalize = fm_bookmarks_finalize;
 
48
    GObjectClass *g_object_class;
 
49
    g_object_class = G_OBJECT_CLASS(klass);
 
50
    g_object_class->finalize = fm_bookmarks_finalize;
51
51
 
52
52
    signals[CHANGED] =
53
53
        g_signal_new("changed",
61
61
 
62
62
static void fm_bookmarks_finalize(GObject *object)
63
63
{
64
 
        FmBookmarks *self;
65
 
 
66
 
        g_return_if_fail(object != NULL);
67
 
        g_return_if_fail(IS_FM_BOOKMARKS(object));
68
 
 
69
 
        self = FM_BOOKMARKS(object);
 
64
    FmBookmarks *self;
 
65
 
 
66
    g_return_if_fail(object != NULL);
 
67
    g_return_if_fail(IS_FM_BOOKMARKS(object));
 
68
 
 
69
    self = FM_BOOKMARKS(object);
70
70
 
71
71
    if(idle_handler)
72
72
    {
79
79
 
80
80
    g_object_unref(self->mon);
81
81
 
82
 
        G_OBJECT_CLASS(fm_bookmarks_parent_class)->finalize(object);
 
82
    G_OBJECT_CLASS(fm_bookmarks_parent_class)->finalize(object);
83
83
}
84
84
 
85
85
char* get_bookmarks_file()
120
120
    if(sep)
121
121
        *sep = '\0';
122
122
 
123
 
    /* FIXME: this is no longer needed once fm_path_new can convert file:/// to / */
124
 
    if(g_str_has_prefix(line, "file:/"))
125
 
    {
126
 
        char* fpath = g_filename_from_uri(line, NULL, NULL);
127
 
        item->path = fm_path_new(fpath);
128
 
        g_free(fpath);
129
 
    }
130
 
    else
131
 
    {
132
 
        /* FIXME: is unescape needed? */
133
 
        item->path = fm_path_new(line);
134
 
    }
135
 
 
 
123
    item->path = fm_path_new_for_uri(line);
136
124
    if(sep)
137
125
        item->name = g_strdup(sep+1);
138
126
    else
165
153
{
166
154
    char* fpath = get_bookmarks_file();
167
155
    GFile* gf = g_file_new_for_path(fpath);
168
 
        self->mon = g_file_monitor_file(gf, 0, NULL, NULL);
 
156
    self->mon = g_file_monitor_file(gf, 0, NULL, NULL);
169
157
    g_object_unref(gf);
170
158
    g_signal_connect(self->mon, "changed", G_CALLBACK(on_changed), self);
171
159
 
175
163
 
176
164
FmBookmarks *fm_bookmarks_new(void)
177
165
{
178
 
        return g_object_new(FM_BOOKMARKS_TYPE, NULL);
 
166
    return g_object_new(FM_BOOKMARKS_TYPE, NULL);
179
167
}
180
168
 
181
169
FmBookmarks* fm_bookmarks_get(void)
253
241
    item->name = g_strdup(new_name);
254
242
    queue_save_bookmarks(bookmarks);
255
243
}
 
244
 
 
245
void fm_bookmarks_reorder(FmBookmarks* bookmarks, FmBookmarkItem* item, int pos)
 
246
{
 
247
    // GList* l = g_list_find(biikmarks->items, item);
 
248
    bookmarks->items = g_list_remove(bookmarks->items, item);
 
249
    bookmarks->items = g_list_insert(bookmarks->items, item, pos);
 
250
    queue_save_bookmarks(bookmarks);
 
251
}