~ubuntu-branches/debian/wheezy/brasero/wheezy

« back to all changes in this revision

Viewing changes to src/brasero-data-tree-model.c

  • Committer: Bazaar Package Importer
  • Author(s): Josselin Mouette, Pedro Fragoso, Luca Bruno, Josselin Mouette, Emilio Pozuelo Monfort
  • Date: 2009-06-24 18:59:46 UTC
  • mfrom: (1.2.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20090624185946-iyxkgf3gjptir5y3
Tags: 2.26.2-1
[ Pedro Fragoso ]
* Add myself to Maintainer field
  - Thanks Ondřej Surý
* New upstream version (Closes: #528945)
  - Split package into brasero, libbrasero-media0 and libbrasero-dev
  - Add Replaces to libbrasero-media0
  - Bump libgtk to 2.14.0
  - Remove libnotify Build-dep
  - Add Build-dep libnautilus-extension-dev (>= 2.22.2)
    and install it.
  - Add Build-dep to libsm-dev
  - Add Build-dep on intltool
* Install omf files to prevent crash on Help
* Move gstreamer0.10-plugins-bad to Suggests, and add
  dvdauthor and vcdimager
* Recommends gvfs (Closes: #491827)
* Pass --disable-scrollkeeper in DEB_CONFIGURE_EXTRA_FLAGS
* debian/patches/007-fix-gnome-doc-utils-path.patch:
  - Removed, not needed anymore
* debian/patches/008-fix-volume-identifier-crash.patch:
  - Removed, merged upstream
* debian/patches/011_nautilus_menu_move.patch:
 - Move CD/DVD Creator Menu to Acessories, taken from Ubuntu

[ Luca Bruno ]
* debian/control.in:
  - Add Build-Depend gtk-doc-tools 1.9.
* debian/patches/006-fix-libdvdcss.patch:
  - Removed as applied upstream.

[ Josselin Mouette ]
* New upstream release.
* Update build-dependencies.
* Move the translations and data to a new brasero-common package.
* Rewrite the descriptions.
* Add -dev depends to the development package.
* Remove inappropriate recommends in the library package.
* Let’s not forget dvd+rw-tools so that we can write DVDs too.
* Rework dependencies accordingly.
* Put the nautilus extension in brasero.
* Conflict against nautilus-cd-burner to avoid having two burning 
  extensions.
* Include clean-la.mk and gnome-version.mk; build-depend on 
  gnome-pkg-tools 0.7.
* Don’t run dh_makeshlibs on brasero and libbrasero-plugins.
* 011_nautilus_menu_move.patch: add NoDisplay=true, this icon is 
  duplicating existing functionality (brasero icon in sound&video 
  menu, and nautilus autorun).
* Update list of copyright holders.

[ Emilio Pozuelo Monfort ]
* debian/copyright: updated.

[ Josselin Mouette ]
* copyright: improve indentation, and point to versioned LGPL.
* 090_relibtoolize.patch: add a relibtoolization patch to avoid the 
  rpath crap.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 * brasero
4
4
 * Copyright (C) Philippe Rouquier 2007-2008 <bonfire-app@wanadoo.fr>
5
5
 * 
6
 
 * brasero is free software.
7
 
 * 
8
 
 * You may redistribute it and/or modify it under the terms of the
9
 
 * GNU General Public License, as published by the Free Software
10
 
 * Foundation; either version 2 of the License, or (at your option)
11
 
 * any later version.
 
6
 *  Brasero is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; either version 2 of the License, or
 
9
 *  (at your option) any later version.
12
10
 * 
13
11
 * brasero is distributed in the hope that it will be useful,
14
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29
27
#include <glib.h>
30
28
#include <glib/gi18n-lib.h>
31
29
 
32
 
#include <gtk/gtktreemodel.h>
33
 
#include <gtk/gtktreednd.h>
34
 
#include <gtk/gtktreesortable.h>
35
 
#include <gtk/gtkicontheme.h>
 
30
#include <gtk/gtk.h>
36
31
 
37
32
#include "burn-basics.h"
38
33
 
214
209
        }
215
210
 
216
211
        node = iter->user_data;
 
212
 
 
213
        /* This is a workaround for a warning in gailtreeview.c line 2946 where
 
214
         * gail uses the GtkTreePath and not a copy which if the node inserted
 
215
         * declares to have children and is not expanded leads to the path being
 
216
         * upped and therefore wrong. */
 
217
        if (node->is_inserting)
 
218
                return FALSE;
 
219
 
217
220
        if (node->is_file)
218
221
                return FALSE;
219
222
 
220
 
        if (!BRASERO_FILE_NODE_CHILDREN (node)) {
221
 
                /* It has children but only a bogus one. */
222
 
                return TRUE;
223
 
        }
224
 
 
225
223
        /* always return TRUE here when it's a directory since even if
226
224
         * it's empty we'll add a row written empty underneath it
227
225
         * anyway. */
243
241
 
244
242
                /* This is for the top directory */
245
243
                root = brasero_data_project_get_root (BRASERO_DATA_PROJECT (model));
246
 
                if (!BRASERO_FILE_NODE_CHILDREN (root))
 
244
                if (!root || !BRASERO_FILE_NODE_CHILDREN (root))
247
245
                        return FALSE;
248
246
 
249
247
                iter->stamp = priv->stamp;
346
344
 
347
345
        node->is_visible ++;
348
346
 
349
 
        if (node->is_imported)
 
347
        if (node->is_imported) {
 
348
                if (node->is_fake && !node->is_file) {
 
349
                        /* we don't load all nodes when importing a session do it now */
 
350
                        brasero_data_session_load_directory_contents (BRASERO_DATA_SESSION (model), node, NULL);
 
351
                }
 
352
 
350
353
                return;
 
354
        }
351
355
 
352
356
        if (node->is_visible > 1)
353
357
                return;
427
431
                        if (node->is_exploring)
428
432
                                g_value_set_string (value, _("(loading ...)"));
429
433
                        else
430
 
                                g_value_set_string (value, _("empty"));
 
434
                                g_value_set_string (value, _("Empty"));
431
435
 
432
436
                        return;
433
437
 
476
480
                g_value_set_boolean (value, (node->is_imported == FALSE) && node->is_selected);
477
481
                return;
478
482
 
479
 
        case BRASERO_DATA_TREE_MODEL_NAME:
 
483
        case BRASERO_DATA_TREE_MODEL_NAME: {
 
484
                gchar *filename;
 
485
 
480
486
                g_value_init (value, G_TYPE_STRING);
481
 
                g_value_set_string (value, BRASERO_FILE_NODE_NAME (node));
 
487
                filename = g_filename_to_utf8 (BRASERO_FILE_NODE_NAME (node),
 
488
                                               -1,
 
489
                                               NULL,
 
490
                                               NULL,
 
491
                                               NULL);
 
492
                if (!filename)
 
493
                        filename = brasero_utils_validate_utf8 (BRASERO_FILE_NODE_NAME (node));
 
494
 
 
495
                if (filename)
 
496
                        g_value_set_string (value, filename);
 
497
                else    /* Glib section on g_convert advise to use a string like
 
498
                         * "Invalid Filename". */
 
499
                        g_value_set_string (value, BRASERO_FILE_NODE_NAME (node));
 
500
 
 
501
                g_free (filename);
482
502
                return;
 
503
        }
483
504
 
484
505
        case BRASERO_DATA_TREE_MODEL_MIME_DESC:
485
506
                g_value_init (value, G_TYPE_STRING);
567
588
 
568
589
                        nb_items = brasero_file_node_get_n_children (node);
569
590
                        if (!nb_items)
570
 
                                g_value_set_string (value, _("empty"));
571
 
                        else if (nb_items == 1)
572
 
                                g_value_set_string (value, _("1 item"));
 
591
                                g_value_set_string (value, _("Empty"));
573
592
                        else {
574
593
                                gchar *text;
575
594
 
581
600
                else {
582
601
                        gchar *text;
583
602
 
584
 
                        text = brasero_utils_get_size_string (BRASERO_FILE_NODE_SECTORS (node) * 2048, TRUE, TRUE);
 
603
                        text = g_format_size_for_display (BRASERO_FILE_NODE_SECTORS (node) * 2048);
585
604
                        g_value_set_string (value, text);
586
605
                        g_free (text);
587
606
                }
610
629
                        else
611
630
                                node_size = BRASERO_FILE_NODE_SECTORS (node);
612
631
                        if (size)
613
 
                                g_value_set_int (value, node_size * 100 / size);
 
632
                                g_value_set_int (value, MAX (0, MIN (node_size * 100 / size, 100)));
614
633
                        else
615
634
                                g_value_set_int (value, 0);
616
635
                }
640
659
        return;
641
660
}
642
661
 
643
 
/**
644
 
 * This is a function mainly used at project load time. In this context there
645
 
 * can be nodes that have been added to the data project tree but not added 
646
 
 * through the model. Don't count those nodes.
647
 
 */
648
 
static guint
649
 
brasero_data_tree_model_node_index (BraseroFileNode *node)
650
 
{
651
 
        BraseroFileNode *parent;
652
 
        BraseroFileNode *peers;
653
 
        guint pos = 0;
654
 
 
655
 
        parent = node->parent;
656
 
        for (peers = BRASERO_FILE_NODE_CHILDREN (parent); peers; peers = peers->next) {
657
 
                if (peers == node)
658
 
                        break;
659
 
                if (!peers->is_visible)
660
 
                        continue;
661
 
                pos ++;
662
 
        }
663
 
 
664
 
        return pos;
665
 
}
666
 
 
667
662
GtkTreePath *
668
663
brasero_data_tree_model_node_to_path (BraseroDataTreeModel *self,
669
664
                                      BraseroFileNode *node)
677
672
        for (; node->parent && !node->is_root; node = node->parent) {
678
673
                guint nth;
679
674
 
680
 
                nth = brasero_data_tree_model_node_index (node);
 
675
                nth = brasero_file_node_get_pos_as_child (node);
681
676
                gtk_tree_path_prepend_index (path, nth);
682
677
        }
683
678
 
755
750
        depth = gtk_tree_path_get_depth (path);
756
751
 
757
752
        root = brasero_data_project_get_root (BRASERO_DATA_PROJECT (model));
 
753
        /* NOTE: if we're in reset, then root won't exist anymore */
 
754
        if (!root)
 
755
                return FALSE;
 
756
                
758
757
        node = brasero_file_node_nth_child (root, indices [0]);
759
758
        if (!node)
760
759
                return FALSE;
1207
1206
        }
1208
1207
 
1209
1208
        /* Add the row itself */
 
1209
        /* This is a workaround for a warning in gailtreeview.c line 2946 where
 
1210
         * gail uses the GtkTreePath and not a copy which if the node inserted
 
1211
         * declares to have children and is not expanded leads to the path being
 
1212
         * upped and therefore wrong. */
 
1213
        node->is_inserting = 1;
1210
1214
        gtk_tree_model_row_inserted (GTK_TREE_MODEL (project),
1211
1215
                                     path,
1212
1216
                                     &iter);
 
1217
        node->is_inserting = 0;
1213
1218
        gtk_tree_path_free (path);
1214
1219
 
1215
1220
        parent = node->parent;
1245
1250
        /* we also have to set the is_visible property as all nodes added to 
1246
1251
         * root are always visible but ref_node is not necessarily called on
1247
1252
         * these nodes. */
1248
 
        if (parent->is_root)
1249
 
                node->is_visible = TRUE;
 
1253
//      if (parent->is_root)
 
1254
//              node->is_visible = TRUE;
1250
1255
 
1251
1256
end:
1252
1257
        /* chain up this function */
1354
1359
                /* emit child-toggled. Thanks to bogus rows we only need to emit
1355
1360
                 * this signal once since a directory will always have a child
1356
1361
                 * in the tree */
1357
 
                gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (project), path, &iter);
 
1362
                gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (project),
 
1363
                                                      path,
 
1364
                                                      &iter);
 
1365
 
 
1366
                /* The problem is that without that, the folder contents on disc
 
1367
                 * won't be added to the tree if the node it replaced was
 
1368
                 * already visible. */
 
1369
                if (node->is_imported
 
1370
                &&  node->is_visible
 
1371
                &&  node->is_fake)
 
1372
                        brasero_data_session_load_directory_contents (BRASERO_DATA_SESSION (project),
 
1373
                                                                      node,
 
1374
                                                                      NULL);
1358
1375
 
1359
1376
                /* add the row */
1360
1377
                if (!BRASERO_FILE_NODE_CHILDREN (node))  {