~ubuntu-branches/ubuntu/quantal/libfm/quantal

« back to all changes in this revision

Viewing changes to src/gtk/fm-places-model.c

  • Committer: Bazaar Package Importer
  • Author(s): Julien Lavergne
  • Date: 2011-02-21 21:55:43 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20110221215543-m7gn2snkhpk1kk9u
Tags: 0.1.15+git-3625952cea-0ubuntu1
* New upstream snapshot (2011-02-15)
 - Use x-schemas-handler (LP: #683922)
* debian/patches/
 - 90_add_gobject_link.patch: Remove, merged upstream.
 - 02-libfm-0.1.14-API-changes.patch: Refresh.
 - 03_disable_deprecated_gio_module.patch: Refresh.
 - 04_fix_docs_linker.patch: Fix DSO linking in docs/.
* debian/libfm0.install:
 - Remove usr/lib/libfm/gnome-terminal, dropped upstream.
 - Remove gio module, dropped upstream.
* debian/rules:
 - Add --enable-gtk-doc to configure.
* debian/libfm-gtk0.symbols:
 - Update with new symbols.
* debian/apport/source_libfm.py
 - Fix location of pcmanfm config files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
static void update_sep_tp(FmPlacesModel* model)
32
32
{
33
33
    gtk_tree_path_free(model->sep_tp);
34
 
    model->sep_tp = gtk_tree_model_get_path(model, &model->sep_it);
 
34
    model->sep_tp = gtk_tree_model_get_path(GTK_TREE_MODEL(model), &model->sep_it);
35
35
}
36
36
 
37
37
static void place_item_free(FmPlaceItem* item)
57
57
    /* g_debug("file info job finished"); */
58
58
    model->jobs = g_slist_remove(model->jobs, job);
59
59
 
60
 
    if(!gtk_tree_model_get_iter_first(model, &it))
 
60
    if(!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &it))
61
61
        return;
62
62
 
63
63
    if(fm_list_is_empty(job->file_infos))
69
69
        fi = FM_FILE_INFO(fm_list_peek_head(job->file_infos));
70
70
        do {
71
71
            item = NULL;
72
 
            gtk_tree_model_get(model, &it, FM_PLACES_MODEL_COL_INFO, &item, -1);
 
72
            gtk_tree_model_get(GTK_TREE_MODEL(model), &it, FM_PLACES_MODEL_COL_INFO, &item, -1);
73
73
            if( item && item->fi && item->fi->path && fm_path_equal(item->fi->path, fi->path) )
74
74
            {
75
75
                fm_file_info_unref(item->fi);
76
76
                item->fi = fm_file_info_ref(fi);
77
77
                break;
78
78
            }
79
 
        }while(gtk_tree_model_iter_next(model, &it));
 
79
        }while(gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &it));
80
80
    }
81
81
    else
82
82
    {
83
83
        do {
84
84
            item = NULL;
85
 
            gtk_tree_model_get(model, &it, FM_PLACES_MODEL_COL_INFO, &item, -1);
 
85
            gtk_tree_model_get(GTK_TREE_MODEL(model), &it, FM_PLACES_MODEL_COL_INFO, &item, -1);
86
86
            if( item && item->fi && item->fi->path )
87
87
            {
88
88
                for(l = fm_list_peek_head_link(job->file_infos); l; l = l->next )
99
99
                    }
100
100
                }
101
101
            }
102
 
        }while(gtk_tree_model_iter_next(model, &it));
 
102
        }while(gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &it));
103
103
    }
104
104
}
105
105
 
127
127
        path = fm_path_new_for_gfile(gf);
128
128
        g_object_unref(gf);
129
129
        g_object_unref(mount);
 
130
        item->vol_mounted = TRUE;
130
131
    }
131
132
    else
 
133
    {
132
134
        path = NULL;
 
135
        item->vol_mounted = FALSE;
 
136
    }
133
137
 
134
138
    if(!fm_path_equal(item->fi->path, path))
135
139
    {
136
 
        if(item->fi->path)
137
 
            fm_path_unref(item->fi->path);
138
 
        item->fi->path = path ? fm_path_ref(path) : NULL;
 
140
        fm_file_info_set_path(item->fi, path);
139
141
        if(path)
140
142
        {
141
143
            if(job)
145
147
                job = fm_file_info_job_new(NULL, FM_FILE_INFO_JOB_FOLLOW_SYMLINK);
146
148
                model->jobs = g_slist_prepend(model->jobs, job);
147
149
                g_signal_connect(job, "finished", G_CALLBACK(on_file_info_job_finished), model);
148
 
                fm_job_run_async(job);
 
150
                fm_job_run_async(FM_JOB(job));
149
151
            }
 
152
            fm_path_unref(path);
150
153
        }
151
154
    }
152
155
 
153
156
    pix = fm_icon_get_pixbuf(item->fi->icon, fm_config->pane_icon_size);
154
 
    gtk_list_store_set(model, it, FM_PLACES_MODEL_COL_ICON, pix, FM_PLACES_MODEL_COL_LABEL, name, -1);
 
157
    gtk_list_store_set(GTK_LIST_STORE(model), it, FM_PLACES_MODEL_COL_ICON, pix, FM_PLACES_MODEL_COL_LABEL, name, -1);
155
158
    g_object_unref(pix);
156
159
    g_free(name);
157
160
}
164
167
    item->fi = fm_file_info_new();
165
168
    item->type = FM_PLACES_ITEM_VOL;
166
169
    item->vol = (GVolume*)g_object_ref(vol);
167
 
    gtk_list_store_insert_before(model, &it, &model->sep_it);
168
 
    gtk_list_store_set(model, &it, FM_PLACES_MODEL_COL_INFO, item, -1);
 
170
    gtk_list_store_insert_before(GTK_LIST_STORE(model), &it, &model->sep_it);
 
171
    gtk_list_store_set(GTK_LIST_STORE(model), &it, FM_PLACES_MODEL_COL_INFO, item, -1);
169
172
    update_vol(model, item, &it, job);
170
173
}
171
174
 
208
211
    /* g_debug("remove vol: %p, uuid: %s, udi: %s", vol, g_volume_get_identifier(vol, "uuid"), g_volume_get_identifier(vol, "hal-udi")); */
209
212
    if(item)
210
213
    {
211
 
        gtk_list_store_remove(model, &it);
 
214
        gtk_list_store_remove(GTK_LIST_STORE(model), &it);
212
215
        place_item_free(item);
213
216
        update_sep_tp(model);
214
217
    }
219
222
    FmPlacesModel* model = FM_PLACES_MODEL(user_data);
220
223
    FmPlaceItem* item;
221
224
    GtkTreeIter it;
 
225
    g_debug("vol-changed");
222
226
    item = find_vol(model, vol, &it);
223
227
    if(item)
224
228
        update_vol(model, item, &it, NULL);
235
239
        item = find_vol(model, vol, &it);
236
240
        if(item && item->type == FM_PLACES_ITEM_VOL && !item->fi->path)
237
241
        {
 
242
            GtkTreePath* tp;
238
243
            GFile* gf = g_mount_get_root(mount);
239
244
            FmPath* path = fm_path_new_for_gfile(gf);
240
245
            g_debug("mount path: %s", path->name);
241
246
            g_object_unref(gf);
242
 
            item->fi->path = path;
 
247
            fm_file_info_set_path(item->fi, path);
 
248
            if(path)
 
249
                fm_path_unref(path);
 
250
            item->vol_mounted = TRUE;
 
251
 
 
252
            /* inform the view to update mount indicator */
 
253
            tp = gtk_tree_model_get_path(GTK_TREE_MODEL(model), &it);
 
254
            gtk_tree_model_row_changed(GTK_TREE_MODEL(model), tp, &it);
 
255
            gtk_tree_path_free(tp);
243
256
        }
244
257
        g_object_unref(vol);
245
258
    }
281
294
            pix = remote_pix;
282
295
        }
283
296
        item->bm_item = bm;
284
 
        gtk_list_store_append(model, &it);
285
 
        gtk_list_store_set(model, &it, FM_PLACES_MODEL_COL_ICON, pix, FM_PLACES_MODEL_COL_LABEL, bm->name, FM_PLACES_MODEL_COL_INFO, item, -1);
 
297
        gtk_list_store_append(GTK_LIST_STORE(model), &it);
 
298
        gtk_list_store_set(GTK_LIST_STORE(model), &it, FM_PLACES_MODEL_COL_ICON, pix, FM_PLACES_MODEL_COL_LABEL, bm->name, FM_PLACES_MODEL_COL_INFO, item, -1);
286
299
    }
287
300
    g_object_unref(folder_pix);
288
301
    fm_icon_unref(icon);
302
315
    /* remove all old bookmarks */
303
316
    if(gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &it))
304
317
    {
305
 
        while(gtk_list_store_remove(model, &it))
 
318
        while(gtk_list_store_remove(GTK_LIST_STORE(model), &it))
306
319
            continue;
307
320
    }
308
321
    add_bookmarks(model, job);
309
322
 
310
323
    g_signal_connect(job, "finished", G_CALLBACK(on_file_info_job_finished), model);
311
324
    model->jobs = g_slist_prepend(model->jobs, job);
312
 
    fm_job_run_async(job);
 
325
    fm_job_run_async(FM_JOB(job));
313
326
}
314
327
 
315
328
static gboolean update_trash_item(gpointer user_data)
336
349
            item->fi->icon = icon;
337
350
            /* update the icon */
338
351
            pix = fm_icon_get_pixbuf(item->fi->icon, fm_config->pane_icon_size);
339
 
            gtk_list_store_set(model, &model->trash_it, FM_PLACES_MODEL_COL_ICON, pix, -1);
 
352
            gtk_list_store_set(GTK_LIST_STORE(model), &model->trash_it, FM_PLACES_MODEL_COL_ICON, pix, -1);
340
353
            g_object_unref(pix);
341
354
        }
342
355
    }
355
368
static void update_icons(FmPlacesModel* model)
356
369
{
357
370
    GtkTreeIter it;
 
371
    FmIcon* icon;
 
372
    GdkPixbuf* pix;
 
373
 
 
374
    /* update the eject icon */
 
375
    icon = fm_icon_from_name("media-eject");
 
376
    pix = fm_icon_get_pixbuf(icon, fm_config->pane_icon_size);
 
377
    fm_icon_unref(icon);
 
378
    if(model->eject_icon)
 
379
        g_object_unref(model->eject_icon);
 
380
    model->eject_icon = pix;
 
381
 
 
382
    /* reload icon for every item */
358
383
    gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &it);
359
384
    do{
360
385
        if(it.user_data != model->sep_it.user_data)
362
387
            FmPlaceItem* item;
363
388
            gtk_tree_model_get(GTK_TREE_MODEL(model), &it, FM_PLACES_MODEL_COL_INFO, &item, -1);
364
389
            /* FIXME: get icon size from FmConfig */
365
 
            GdkPixbuf* pix = fm_icon_get_pixbuf(item->fi->icon, fm_config->pane_icon_size);
366
 
            gtk_list_store_set(model, &it, FM_PLACES_MODEL_COL_ICON, pix, -1);
 
390
            pix = fm_icon_get_pixbuf(item->fi->icon, fm_config->pane_icon_size);
 
391
            gtk_list_store_set(GTK_LIST_STORE(model), &it, FM_PLACES_MODEL_COL_ICON, pix, -1);
367
392
            g_object_unref(pix);
368
393
        }
369
394
    }while( gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &it) );
421
446
    item->fi = fm_file_info_new();
422
447
    item->fi->path = fm_path_ref(fm_path_get_trash());
423
448
    item->fi->icon = fm_icon_from_name("user-trash");
424
 
    gtk_list_store_insert(model, &it, 2);
 
449
    gtk_list_store_insert(GTK_LIST_STORE(model), &it, 2);
425
450
    pix = fm_icon_get_pixbuf(item->fi->icon, fm_config->pane_icon_size);
426
 
    gtk_list_store_set(model, &it, FM_PLACES_MODEL_COL_ICON, pix, FM_PLACES_MODEL_COL_LABEL, _("Trash"), FM_PLACES_MODEL_COL_INFO, item, -1);
 
451
    gtk_list_store_set(GTK_LIST_STORE(model), &it, FM_PLACES_MODEL_COL_ICON, pix, FM_PLACES_MODEL_COL_LABEL, _("Trash"), FM_PLACES_MODEL_COL_INFO, item, -1);
427
452
    g_object_unref(pix);
428
453
    model->trash_it = it;
429
454
 
455
480
 
456
481
    self->pane_icon_size_change_handler = g_signal_connect(fm_config, "changed::pane_icon_size",
457
482
                                             G_CALLBACK(on_pane_icon_size_changed), self);
 
483
    icon = fm_icon_from_name("media-eject");
 
484
    pix = fm_icon_get_pixbuf(icon, fm_config->pane_icon_size);
 
485
    fm_icon_unref(icon);
 
486
    self->eject_icon = pix;
458
487
 
459
488
    item = g_slice_new0(FmPlaceItem);
460
489
    item->type = FM_PLACES_ITEM_PATH;
527
556
 
528
557
    g_signal_connect(job, "finished", G_CALLBACK(on_file_info_job_finished), self);
529
558
    self->jobs = g_slist_prepend(self->jobs, job);
530
 
    fm_job_run_async(job);
 
559
    fm_job_run_async(FM_JOB(job));
531
560
}
532
561
 
533
562
const GtkTreePath* fm_places_model_get_separator_path(FmPlacesModel* model)
639
668
{
640
669
    return g_object_new(FM_TYPE_PLACES_MODEL, NULL);
641
670
}
 
671
 
 
672
void fm_places_model_mount_indicator_cell_data_func(GtkCellLayout *cell_layout,
 
673
                                           GtkCellRenderer *render,
 
674
                                           GtkTreeModel *tree_model,
 
675
                                           GtkTreeIter *it,
 
676
                                           gpointer user_data)
 
677
{
 
678
    FmPlaceItem* item;
 
679
    GdkPixbuf* pix = NULL;
 
680
    gtk_tree_model_get(tree_model, it, FM_PLACES_MODEL_COL_INFO, &item, -1);
 
681
    if(item && item->vol_mounted)
 
682
        pix = FM_PLACES_MODEL(tree_model)->eject_icon;
 
683
    g_object_set(render, "pixbuf", pix, NULL);
 
684
}