~ubuntu-branches/ubuntu/maverick/brasero/maverick

« back to all changes in this revision

Viewing changes to src/brasero-project.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Ancell
  • Date: 2009-11-26 16:20:01 UTC
  • mto: This revision was merged to the branch mainline in revision 58.
  • Revision ID: james.westby@ubuntu.com-20091126162001-5iw2jzxdx8l31okz
Tags: upstream-2.29.2
ImportĀ upstreamĀ versionĀ 2.29.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
#include <gio/gio.h>
38
38
 
39
39
#include <gtk/gtk.h>
 
40
#include <gdk/gdkx.h>
40
41
 
41
42
#include <gst/gst.h>
42
43
 
44
45
 
45
46
#include "brasero-misc.h"
46
47
#include "brasero-jacket-edit.h"
 
48
#include "brasero-pk.h"
47
49
 
48
50
#include "brasero-tags.h"
49
51
#include "brasero-session.h"
67
69
#include "brasero-video-options.h"
68
70
#include "brasero-drive-properties.h"
69
71
#include "brasero-image-properties.h"
 
72
#include "burn-plugin-manager.h"
70
73
 
71
74
#include "brasero-project-type-chooser.h"
72
75
#include "brasero-app.h"
164
167
 
165
168
        BraseroURIContainer *current_source;
166
169
 
 
170
        GCancellable *cancel;
 
171
 
167
172
        GtkWidget *chooser;
168
173
        gulong selected_id;
169
174
        gulong activated_id;
652
657
        gtk_container_add (GTK_CONTAINER (frame), event_box);
653
658
 
654
659
        /* The alignment to set properly the position of the GtkTextView */
655
 
        alignment = gtk_alignment_new (0.5, 0.3, 0.0, 0.0);
 
660
        alignment = gtk_alignment_new (0.5, 0.5, 1.0, 0.0);
656
661
        gtk_container_set_border_width (GTK_CONTAINER (alignment), 10);
657
662
        gtk_widget_show (alignment);
658
663
        gtk_container_add (GTK_CONTAINER (event_box), alignment);
660
665
        /* The TreeView for the message */
661
666
        buffer = gtk_text_buffer_new (NULL);
662
667
        gtk_text_buffer_create_tag (buffer, "Title",
663
 
                                    "scale", 1.2,
664
 
                                    "justification", GTK_JUSTIFY_LEFT,
665
 
                                    "foreground", "grey50",
666
 
                                    NULL);
667
 
 
668
 
        gtk_text_buffer_create_tag (buffer, "TextBody",
669
 
                                    "justification", GTK_JUSTIFY_LEFT,
670
 
                                    "foreground", "grey50",
 
668
                                    "scale", 1.1,
 
669
                                    "justification", GTK_JUSTIFY_CENTER,
 
670
                                    "foreground", "grey50",
 
671
                                    "wrap-mode", GTK_WRAP_WORD,
671
672
                                    NULL);
672
673
 
673
674
        gtk_text_buffer_get_start_iter (buffer, &iter);
674
 
 
675
 
        /* Translators: this messages will appear as a list of possible
676
 
         * actions, like:
677
 
         *   To add/remove files you can:
678
 
         *      * perform action one
679
 
         *      * perform action two
680
 
         * The full message will be showed in the main area of an empty
681
 
         * project, suggesting users how to add and remove items to project.
682
 
         * You simply have to translate messages in the best form
683
 
         * for a list of actions. */
684
 
        gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, _("To add files to this project you can:"), -1, "Title", NULL);
685
 
        gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "\n\t* ", -1, "TextBody", NULL);
686
 
 
687
 
        gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, _("click the \"Add\" button to show a selection dialog"), -1, "TextBody", NULL);
688
 
        gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "\n\t* ", -1, "TextBody", NULL);
689
 
        gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, _("select files in the selection pane and click the \"Add\" button"), -1, "TextBody", NULL);
690
 
        gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "\n\t* ", -1, "TextBody", NULL);
691
 
        gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, _("drag files in this area from the selection pane or from the file manager"), -1, "TextBody", NULL);
692
 
        gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "\n\t* ", -1, "TextBody", NULL);
693
 
        gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, _("double-click on files in the selection pane"), -1, "TextBody", NULL);
694
 
        gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "\n\t* ", -1, "TextBody", NULL);
695
 
        gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, _("copy files (from file manager for example) and paste in this area"), -1, "TextBody", NULL);
 
675
        gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, _("To add files to this project click the \"Add\" button or drag files to this area"), -1, "Title", NULL);
696
676
        gtk_text_buffer_insert (buffer, &iter, "\n\n\n", -1);
697
 
 
698
 
        gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, _("To remove files from this project you can:"), -1, "Title", NULL);
699
 
        gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "\n\t* ", -1, "TextBody", NULL);
700
 
 
701
 
        gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, _("click on the \"Remove\" button to remove selected items in this area"), -1, "TextBody", NULL);
702
 
        gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "\n\t* ", -1, "TextBody", NULL);
703
 
        gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, _("select items in this area, and choose \"Remove\" from context menu"), -1, "TextBody", NULL);
704
 
        gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, "\n\t* ", -1, "TextBody", NULL);
705
 
        gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, _("select items in this area, and press \"Delete\" key"), -1, "TextBody", NULL);
 
677
        gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, _("To remove files select them then click on the \"Remove\" button or press \"Delete\" key"), -1, "Title", NULL);
706
678
 
707
679
        textview = gtk_text_view_new_with_buffer (buffer);
708
680
        gtk_text_view_set_editable (GTK_TEXT_VIEW (textview), FALSE);
890
862
                          BraseroProject *project)
891
863
{
892
864
        BraseroSessionError valid;
893
 
        BraseroStatus *status;
894
865
        GdkWindow *window;
895
866
        GdkCursor *cursor;
896
867
        GtkAction *action;
897
868
 
898
869
        /* Update the cursor */
899
 
        status = brasero_status_new ();
900
 
        brasero_burn_session_get_status (BRASERO_BURN_SESSION (session), status);
901
 
 
902
870
        window = gtk_widget_get_window (GTK_WIDGET (project));
903
871
        if (window) {
 
872
                BraseroStatus *status;
 
873
 
 
874
                status = brasero_status_new ();
 
875
                brasero_burn_session_get_status (BRASERO_BURN_SESSION (session), status);
904
876
                if (brasero_status_get_result (status) == BRASERO_BURN_NOT_READY) {
905
877
                        cursor = gdk_cursor_new (GDK_WATCH);
906
878
                        gdk_window_set_cursor (window, cursor);
908
880
                }
909
881
                else
910
882
                        gdk_window_set_cursor (window, NULL);
 
883
 
 
884
                g_object_unref (status);
911
885
        }
912
886
 
913
 
        brasero_status_free (status);
914
 
 
915
887
        valid = brasero_session_cfg_get_error (project->priv->session);
916
888
 
917
889
        /* Update burn button state */
942
914
                min_disc_size = brasero_session_span_get_max_space (BRASERO_SESSION_SPAN (session));
943
915
 
944
916
                /* One rule should be that the maximum batch size should not exceed the disc size
945
 
                 * FIXME: we could change it into a dialog telling the user what is the maximum
 
917
                 * FIXME! we could change it into a dialog telling the user what is the maximum
946
918
                 * size required. */
947
919
                available_space = brasero_burn_session_get_available_medium_space (BRASERO_BURN_SESSION (session));
948
920
 
1010
982
                project->priv->empty = FALSE;
1011
983
                brasero_notify_message_add (BRASERO_NOTIFY (project->priv->message),
1012
984
                                            _("Please replace the disc with a supported CD or DVD."),
1013
 
                                            _("It is not possible to write with the current set of plugins."),
 
985
                                            NULL,
1014
986
                                            -1,
1015
987
                                            BRASERO_NOTIFY_CONTEXT_SIZE);
1016
988
        }
1190
1162
        BraseroProject *cobj;
1191
1163
        cobj = BRASERO_PROJECT(object);
1192
1164
 
 
1165
        if (cobj->priv->cancel) {
 
1166
                g_cancellable_cancel (cobj->priv->cancel);
 
1167
                cobj->priv->cancel = NULL;
 
1168
        }
 
1169
 
1193
1170
        if (cobj->priv->session) {
1194
1171
                g_object_unref (cobj->priv->session);
1195
1172
                cobj->priv->session = NULL;
1293
1270
        status = brasero_status_new ();
1294
1271
        brasero_burn_session_get_status (BRASERO_BURN_SESSION (project->priv->session), status);
1295
1272
        result = brasero_status_get_result (status);
1296
 
        brasero_status_free (status);
 
1273
        g_object_unref (status);
1297
1274
 
1298
1275
        if (result == BRASERO_BURN_ERR) {
1299
1276
                /* At the moment the only error possible is an empty project */
1300
 
                if (BRASERO_IS_AUDIO_DISC (project->priv->current))
1301
 
                        brasero_project_no_song_dialog (project);
1302
 
                else
1303
 
                        brasero_project_no_file_dialog (project);
1304
 
 
1305
 
                return BRASERO_BURN_ERR;
1306
 
        }
1307
 
 
1308
 
        if (result == BRASERO_BURN_OK)
1309
 
                return BRASERO_BURN_OK;
 
1277
                if (BRASERO_IS_AUDIO_DISC (project->priv->current))
 
1278
                        brasero_project_no_song_dialog (project);
 
1279
                else
 
1280
                        brasero_project_no_file_dialog (project);
 
1281
 
 
1282
                return BRASERO_BURN_ERR;
 
1283
        }
 
1284
 
 
1285
        if (result == BRASERO_BURN_OK)
 
1286
                return BRASERO_BURN_OK;
1310
1287
 
1311
1288
        dialog = brasero_status_dialog_new (BRASERO_BURN_SESSION (project->priv->session),
1312
1289
                                                                  gtk_widget_get_toplevel (GTK_WIDGET (project)));
1318
1295
        return (response == GTK_RESPONSE_OK)? BRASERO_BURN_OK:BRASERO_BURN_CANCEL;
1319
1296
}
1320
1297
 
 
1298
static BraseroBurnResult
 
1299
brasero_project_install_missing (BraseroPluginErrorType type,
 
1300
                                 const gchar *detail,
 
1301
                                 gpointer user_data)
 
1302
{
 
1303
        BraseroProject *project = BRASERO_PROJECT (user_data);
 
1304
        GCancellable *cancel;
 
1305
        BraseroPK *package;
 
1306
        GtkWidget *parent;
 
1307
        gboolean res;
 
1308
        int xid = 0;
 
1309
 
 
1310
        /* Get the xid */
 
1311
        parent = gtk_widget_get_toplevel (GTK_WIDGET (project));
 
1312
        xid = gdk_x11_drawable_get_xid (GDK_DRAWABLE (GTK_WIDGET (parent)->window));
 
1313
 
 
1314
        package = brasero_pk_new ();
 
1315
        cancel = g_cancellable_new ();
 
1316
        project->priv->cancel = cancel;
 
1317
        switch (type) {
 
1318
                case BRASERO_PLUGIN_ERROR_MISSING_APP:
 
1319
                        res = brasero_pk_install_missing_app (package, detail, xid, cancel);
 
1320
                        break;
 
1321
 
 
1322
                case BRASERO_PLUGIN_ERROR_MISSING_LIBRARY:
 
1323
                        res = brasero_pk_install_missing_library (package, detail, xid, cancel);
 
1324
                        break;
 
1325
 
 
1326
                case BRASERO_PLUGIN_ERROR_MISSING_GSTREAMER_PLUGIN:
 
1327
                        res = brasero_pk_install_gstreamer_plugin (package, detail, xid, cancel);
 
1328
                        break;
 
1329
 
 
1330
                default:
 
1331
                        res = FALSE;
 
1332
                        break;
 
1333
        }
 
1334
 
 
1335
        if (package) {
 
1336
                g_object_unref (package);
 
1337
                package = NULL;
 
1338
        }
 
1339
 
 
1340
        if (g_cancellable_is_cancelled (cancel)) {
 
1341
                g_object_unref (cancel);
 
1342
                return BRASERO_BURN_CANCEL;
 
1343
        }
 
1344
 
 
1345
        project->priv->cancel = NULL;
 
1346
        g_object_unref (cancel);
 
1347
 
 
1348
        if (!res)
 
1349
                return BRASERO_BURN_ERR;
 
1350
 
 
1351
        return BRASERO_BURN_RETRY;
 
1352
}
 
1353
 
 
1354
static BraseroBurnResult
 
1355
brasero_project_list_missing (BraseroPluginErrorType type,
 
1356
                              const gchar *detail,
 
1357
                              gpointer user_data)
 
1358
{
 
1359
        GString *string = user_data;
 
1360
 
 
1361
        if (type == BRASERO_PLUGIN_ERROR_MISSING_APP) {
 
1362
                g_string_append_c (string, '\n');
 
1363
                /* Translators: %s is the name of a missing application */
 
1364
                g_string_append_printf (string, _("%s (application)"), detail);
 
1365
        }
 
1366
        else if (type == BRASERO_PLUGIN_ERROR_MISSING_LIBRARY) {
 
1367
                g_string_append_c (string, '\n');
 
1368
                /* Translators: %s is the name of a missing library */
 
1369
                g_string_append_printf (string, _("%s (library)"), detail);
 
1370
        }
 
1371
        else if (type == BRASERO_PLUGIN_ERROR_MISSING_GSTREAMER_PLUGIN) {
 
1372
                g_string_append_c (string, '\n');
 
1373
                /* Translators: %s is the name of a missing Gstreamer plugin */
 
1374
                g_string_append_printf (string, _("%s (Gstreamer plugin)"), detail);
 
1375
        }
 
1376
 
 
1377
        return BRASERO_BURN_OK;
 
1378
}
 
1379
 
 
1380
static BraseroBurnResult
 
1381
brasero_project_check_plugins_not_ready (BraseroProject *project,
 
1382
                                         BraseroBurnSession *session)
 
1383
{
 
1384
        BraseroBurnResult result;
 
1385
        GtkWidget *parent;
 
1386
        GString *string;
 
1387
 
 
1388
        parent = gtk_widget_get_toplevel (GTK_WIDGET (project));
 
1389
        gtk_widget_set_sensitive (parent, FALSE);
 
1390
 
 
1391
        result = brasero_session_foreach_plugin_error (session,
 
1392
                                                       brasero_project_install_missing,
 
1393
                                                       project);
 
1394
        if (result == BRASERO_BURN_CANCEL)
 
1395
                return result;
 
1396
 
 
1397
        gtk_widget_set_sensitive (parent, TRUE);
 
1398
 
 
1399
        if (result == BRASERO_BURN_OK)
 
1400
                return result;
 
1401
 
 
1402
        string = g_string_new (_("Please install the following manually and try again:"));
 
1403
        brasero_session_foreach_plugin_error (session,
 
1404
                                              brasero_project_list_missing,
 
1405
                                              string);
 
1406
 
 
1407
        brasero_utils_message_dialog (parent,
 
1408
                                      _("All required applications and libraries are not installed."),
 
1409
                                      string->str,
 
1410
                                      GTK_MESSAGE_ERROR);
 
1411
        g_string_free (string, TRUE);
 
1412
 
 
1413
        return BRASERO_BURN_ERR;
 
1414
}
 
1415
 
1321
1416
/******************************** burning **************************************/
1322
1417
static void
1323
1418
brasero_project_setup_session (BraseroProject *project,
1478
1573
        gboolean res = FALSE;
1479
1574
        BraseroDisc *current_disc;
1480
1575
 
 
1576
        /* Check that we are ready */
 
1577
        if (brasero_project_check_status (project) != BRASERO_BURN_OK)
 
1578
                return;
 
1579
 
 
1580
        /* Check that we are not missing any plugin */
 
1581
        if (brasero_project_check_plugins_not_ready (project, BRASERO_BURN_SESSION (project->priv->session)) != BRASERO_BURN_OK)
 
1582
                return;
 
1583
 
1481
1584
        if (!brasero_burn_session_is_dest_file (BRASERO_BURN_SESSION (project->priv->session)))
1482
1585
                res = brasero_project_drive_properties (project);
1483
1586
        else
1609
1712
        else
1610
1713
                project->priv->session = brasero_session_cfg_new ();
1611
1714
 
 
1715
        brasero_burn_session_set_strict_support (BRASERO_BURN_SESSION (project->priv->session), FALSE);
 
1716
 
1612
1717
        /* NOTE: "is-valid" is emitted whenever there is a change in the
1613
1718
         * contents of the session. So no need to connect to track-added, ... */
1614
1719
        g_signal_connect (project->priv->session,