~mfisch/brasero/update-to-3.8.0

« back to all changes in this revision

Viewing changes to src/brasero-data-vfs.c

  • Committer: Bazaar Package Importer
  • Author(s): Pedro Fragoso
  • Date: 2008-11-18 11:30:50 UTC
  • mto: (1.4.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: james.westby@ubuntu.com-20081118113050-yhrskmatlel0gzfm
Tags: upstream-0.8.3
ImportĀ upstreamĀ versionĀ 0.8.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
enum {
69
69
        UNREADABLE_SIGNAL,
70
70
        RECURSIVE_SIGNAL,
 
71
        IMAGE_SIGNAL,
71
72
        FILTERED_SIGNAL,
72
73
        ACTIVITY_SIGNAL,
73
74
        UNKNOWN_SIGNAL,
603
604
                               g_hash_table_size (priv->directories));
604
605
}
605
606
 
 
607
static BraseroBurnResult
 
608
brasero_data_vfs_emit_image_signal (BraseroDataVFS *self,
 
609
                                    const gchar *uri)
 
610
{
 
611
        GValue instance_and_params [2];
 
612
        GValue return_value;
 
613
        GValue *params;
 
614
 
 
615
        /* object which signalled */
 
616
        instance_and_params->g_type = 0;
 
617
        g_value_init (instance_and_params, G_TYPE_FROM_INSTANCE (self));
 
618
        g_value_set_instance (instance_and_params, self);
 
619
 
 
620
        /* arguments of signal (name) */
 
621
        params = instance_and_params + 1;
 
622
        params->g_type = 0;
 
623
        g_value_init (params, G_TYPE_STRING);
 
624
        g_value_set_string (params, uri);
 
625
 
 
626
        /* default to FALSE */
 
627
        return_value.g_type = 0;
 
628
        g_value_init (&return_value, G_TYPE_INT);
 
629
        g_value_set_int (&return_value, BRASERO_BURN_CANCEL);
 
630
 
 
631
        g_signal_emitv (instance_and_params,
 
632
                        brasero_data_vfs_signals [IMAGE_SIGNAL],
 
633
                        0,
 
634
                        &return_value);
 
635
 
 
636
        g_value_unset (instance_and_params);
 
637
        g_value_unset (params);
 
638
 
 
639
        return g_value_get_int (&return_value);
 
640
}
 
641
 
606
642
static void
607
643
brasero_data_vfs_loading_node_result (GObject *owner,
608
644
                                      GError *error,
612
648
{
613
649
        GSList *iter;
614
650
        GSList *nodes;
 
651
        BraseroFileNode *root;
 
652
        BraseroFileTreeStats *stats;
615
653
        gchar *registered = callback_data;
616
654
        BraseroDataVFS *self = BRASERO_DATA_VFS (owner);
617
655
        BraseroDataVFSPrivate *priv = BRASERO_DATA_VFS_PRIVATE (self);
636
674
                return;
637
675
        }
638
676
 
 
677
        /* It can happen that the user made a mistake out of ignorance or for
 
678
         * whatever other reason and dropped an image he wanted to burn.
 
679
         * So if our file is the only one in the project and if that's an image
 
680
         * check it is an image. If so, ask him if that's he really want to do. */
 
681
        root = brasero_data_project_get_root (BRASERO_DATA_PROJECT (self));
 
682
        stats = BRASERO_FILE_NODE_STATS (root);
 
683
 
 
684
        if (stats && !stats->children
 
685
        && (!strcmp (g_file_info_get_content_type (info), "application/x-toc")
 
686
        ||  !strcmp (g_file_info_get_content_type (info), "application/x-cdrdao-toc")
 
687
        ||  !strcmp (g_file_info_get_content_type (info), "application/x-cue")
 
688
        ||  !strcmp (g_file_info_get_content_type (info), "application/x-cd-image"))) {
 
689
                BraseroBurnResult result;
 
690
 
 
691
                result = brasero_data_vfs_emit_image_signal (self, uri);
 
692
                if (result == BRASERO_BURN_CANCEL) {
 
693
                        for (iter = nodes; iter; iter = iter->next) {
 
694
                                BraseroFileNode *node;
 
695
                                guint reference;
 
696
 
 
697
                                reference = GPOINTER_TO_INT (iter->data);
 
698
                                node = brasero_data_project_reference_get (BRASERO_DATA_PROJECT (self), reference);
 
699
 
 
700
                                /* the node could have been removed in the mean time */
 
701
                                if (node)
 
702
                                        brasero_data_project_remove_node (BRASERO_DATA_PROJECT (self), node);
 
703
                        }
 
704
 
 
705
                        return;
 
706
                }
 
707
        }
 
708
 
639
709
        /* NOTE: we don't check for a broken symlink here since the  user chose
640
710
         * to add it. So even if it were we would have to add it. The same for
641
711
         * hidden files. */
877
947
        nodes = g_hash_table_lookup (priv->loading, uri);
878
948
        if (nodes) {
879
949
                gchar *registered;
 
950
                GSList *iter;
880
951
 
881
952
                registered = brasero_utils_register_string (uri);
882
953
                g_free (uri);
883
954
 
884
 
                for (; nodes; nodes = nodes->next) {
 
955
                for (iter = nodes; iter; iter = iter->next) {
885
956
                        guint reference;
886
957
                        BraseroFileNode *ref_node;
887
958
 
888
 
                        reference = GPOINTER_TO_INT (nodes->data);
 
959
                        reference = GPOINTER_TO_INT (iter->data);
889
960
                        ref_node = brasero_data_project_reference_get (BRASERO_DATA_PROJECT (self), reference);
890
961
                        if (ref_node == node) {
891
 
                                /* 1sk for a higher priority */
 
962
                                /* Ask for a higher priority */
892
963
                                brasero_io_find_urgent (priv->io,
893
964
                                                        priv->load_uri,
894
965
                                                        brasero_data_vfs_increase_priority_cb,
901
972
                /* It's loading, wait for the results */
902
973
                reference = brasero_data_project_reference_new (BRASERO_DATA_PROJECT (self), node);
903
974
                nodes = g_slist_prepend (nodes, GINT_TO_POINTER (reference));
904
 
                g_hash_table_insert (priv->loading, (gchar *) uri, nodes);
 
975
                g_hash_table_insert (priv->loading, registered, nodes);
905
976
 
906
977
                /* Yet, ask for a higher priority */
907
978
                brasero_io_find_urgent (priv->io,
1163
1234
        brasero_data_vfs_clear (BRASERO_DATA_VFS (object));
1164
1235
 
1165
1236
        priv = BRASERO_DATA_VFS_PRIVATE (object);
 
1237
 
1166
1238
        if (priv->loading) {
1167
1239
                g_hash_table_destroy (priv->loading);
1168
1240
                priv->loading = NULL;
1216
1288
                          1,
1217
1289
                          G_TYPE_BOOLEAN);
1218
1290
 
 
1291
        brasero_data_vfs_signals [IMAGE_SIGNAL] = 
 
1292
            g_signal_new ("image_uri",
 
1293
                          G_TYPE_FROM_CLASS (klass),
 
1294
                          G_SIGNAL_RUN_LAST|G_SIGNAL_NO_RECURSE,
 
1295
                          0,
 
1296
                          NULL, NULL,
 
1297
                          brasero_marshal_INT__STRING,
 
1298
                          G_TYPE_INT,
 
1299
                          1,
 
1300
                          G_TYPE_STRING);
 
1301
 
1219
1302
        brasero_data_vfs_signals [FILTERED_SIGNAL] = 
1220
1303
            g_signal_new ("filtered_uri",
1221
1304
                          G_TYPE_FROM_CLASS (klass),