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

« back to all changes in this revision

Viewing changes to src/brasero-player.c

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2010-01-04 17:45:17 UTC
  • mfrom: (1.1.36 upstream)
  • Revision ID: james.westby@ubuntu.com-20100104174517-vz0avr4o1vdfusrf
Tags: 2.29.4-0ubuntu1
* New upstream release:
  - Bug fixes
  - Fixes for Video DVD
  - Updated translations.
* Add 001_nautilus_lazy_init.patch: Do not call brasero_*_start() at
  nautilus startup, they are very expensive; lazily initialize those
  instead.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
 
2
 
1
3
/***************************************************************************
2
4
*            player.c
3
5
*
56
58
 
57
59
        GtkWidget *notebook;
58
60
        GtkWidget *bacon;
59
 
        GtkWidget *image_display;
60
61
        GtkWidget *controls;
61
62
 
62
63
        gint image_width;
63
64
        gint image_height;
64
65
        GdkPixbuf *pixbuf;
65
66
 
66
 
        GtkWidget *image;
 
67
 
 
68
        GtkWidget *image_display;
 
69
        GtkWidget *image_event;
67
70
        GtkWidget *image_zoom_in;
68
71
        GtkWidget *image_zoom_out;
69
72
 
117
120
        player->priv->progress = NULL;
118
121
        player->priv->header = NULL;
119
122
        player->priv->button = NULL;
120
 
        player->priv->image = NULL;
121
123
        player->priv->size = NULL;
122
124
        player->priv->video_zoom_in = NULL;
123
125
        player->priv->video_zoom_out = NULL;
134
136
        }
135
137
 
136
138
        gtk_alignment_set_padding (GTK_ALIGNMENT (player), 0, 0, 0, 0);
137
 
 
 
139
        
138
140
        gtk_widget_hide (player->priv->notebook);
139
141
 
140
142
        player->priv->length = 0;
143
145
}
144
146
 
145
147
static void
146
 
brasero_player_video_zoom_out (GtkButton *button,
147
 
                               BraseroPlayer *player)
 
148
brasero_player_video_zoom_out (BraseroPlayer *player)
148
149
{
149
150
        GtkWidget *parent;
 
151
        gint width, height;
150
152
        GtkAllocation player_allocation, bacon_allocation;
151
 
        gint width, height;
152
153
 
153
154
        gtk_widget_set_sensitive (GTK_WIDGET (player->priv->video_zoom_in), TRUE);
154
155
 
198
199
}
199
200
 
200
201
static void
201
 
brasero_player_video_zoom_in (GtkButton *button,
202
 
                              BraseroPlayer *player)
 
202
brasero_player_video_zoom_out_button_cb (GtkButton *button,
 
203
                                         BraseroPlayer *player)
 
204
{
 
205
        brasero_player_video_zoom_out (player);
 
206
}
 
207
 
 
208
static void
 
209
brasero_player_video_zoom_in (BraseroPlayer *player)
203
210
{
204
211
        GtkAllocation player_allocation, bacon_allocation;
205
212
        gint width, height;
251
258
}
252
259
 
253
260
static void
 
261
brasero_player_video_zoom_in_button_cb (GtkButton *button,
 
262
                                        BraseroPlayer *player)
 
263
{
 
264
        brasero_player_video_zoom_in (player);
 
265
}
 
266
 
 
267
static gboolean
 
268
brasero_player_video_scroll (BraseroPlayerBacon *bacon,
 
269
                             GdkEventScroll *event,
 
270
                             BraseroPlayer *player)
 
271
{
 
272
        if (event->direction == GDK_SCROLL_UP)
 
273
                brasero_player_video_zoom_in (player);
 
274
        else
 
275
                brasero_player_video_zoom_out (player);
 
276
 
 
277
        return TRUE;
 
278
}
 
279
 
 
280
static void
254
281
brasero_player_update_position (BraseroPlayer *player)
255
282
{
256
283
        gdouble value;
377
404
brasero_player_create_controls_stream (BraseroPlayer *player,
378
405
                                       gboolean video)
379
406
{
 
407
        GtkAllocation allocation;
380
408
        GtkWidget *box = NULL;
381
409
        GtkWidget *header_box;
382
410
        GtkWidget *alignment;
383
411
        GtkWidget *volume;
384
 
        GtkAllocation allocation;
385
 
 
 
412
        GtkWidget *image;
 
413
        
386
414
        if (player->priv->controls)
387
415
                brasero_player_destroy_controls (player);
388
416
 
438
466
                            0);
439
467
 
440
468
        alignment = gtk_alignment_new (0.0, 0.0, 0.0, 0.0);
441
 
        player->priv->button = gtk_button_new ();
 
469
        player->priv->button = gtk_toggle_button_new ();
442
470
        gtk_widget_set_tooltip_text (player->priv->button, _("Start and stop playing"));
443
471
        gtk_container_add (GTK_CONTAINER (alignment), player->priv->button);
444
472
        gtk_box_pack_start (GTK_BOX (box),
447
475
                            FALSE,
448
476
                            0);
449
477
 
450
 
        player->priv->image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_BUTTON);
451
 
        gtk_container_add (GTK_CONTAINER (player->priv->button), player->priv->image);
 
478
        image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_BUTTON);
 
479
        gtk_container_add (GTK_CONTAINER (player->priv->button), image);
452
480
        g_signal_connect (G_OBJECT (player->priv->button), "clicked",
453
481
                          G_CALLBACK (brasero_player_button_clicked_cb),
454
482
                          player);
507
535
 
508
536
                hbox = gtk_hbox_new (FALSE, 0);
509
537
                alignment = gtk_alignment_new (1.0, 0.0, 0.0, 0.0);
510
 
                player->priv->button = gtk_button_new ();
 
538
 
511
539
                gtk_container_add (GTK_CONTAINER (alignment), hbox);
512
540
                gtk_box_pack_start (GTK_BOX (box),
513
541
                                    alignment,
514
542
                                    TRUE,
515
543
                                    TRUE,
516
544
                                    0);
517
 
 
 
545
                
518
546
                image = gtk_image_new_from_stock (GTK_STOCK_ZOOM_OUT, GTK_ICON_SIZE_BUTTON);
519
547
                zoom = gtk_button_new ();
520
548
                gtk_button_set_image (GTK_BUTTON (zoom), image);
522
550
                gtk_button_set_focus_on_click (GTK_BUTTON (zoom), FALSE);
523
551
                g_signal_connect (zoom,
524
552
                                  "clicked",
525
 
                                  G_CALLBACK (brasero_player_video_zoom_out),
 
553
                                  G_CALLBACK (brasero_player_video_zoom_out_button_cb),
526
554
                                  player);
527
555
                gtk_box_pack_start (GTK_BOX (hbox),
528
556
                                    zoom,
538
566
                gtk_button_set_focus_on_click (GTK_BUTTON (zoom), FALSE);
539
567
                g_signal_connect (zoom,
540
568
                                  "clicked",
541
 
                                  G_CALLBACK (brasero_player_video_zoom_in),
 
569
                                  G_CALLBACK (brasero_player_video_zoom_in_button_cb),
542
570
                                  player);
543
571
                gtk_box_pack_start (GTK_BOX (hbox),
544
572
                                    zoom,
627
655
}
628
656
 
629
657
static void
630
 
brasero_player_image_zoom_in (GtkButton *button,
631
 
                              BraseroPlayer *player)
 
658
brasero_player_image_zoom_in (BraseroPlayer *player)
632
659
{
633
660
        gtk_widget_set_sensitive (player->priv->image_zoom_out, TRUE);
634
661
 
646
673
}
647
674
 
648
675
static void
649
 
brasero_player_image_zoom_out (GtkButton *button,
650
 
                               BraseroPlayer *player)
 
676
brasero_player_image_zoom_in_button_cb (GtkButton *button,
 
677
                                        BraseroPlayer *player)
 
678
{
 
679
        brasero_player_image_zoom_in (player);
 
680
}
 
681
 
 
682
static void
 
683
brasero_player_image_zoom_out (BraseroPlayer *player)
651
684
{
652
685
        gint min_height, min_width;
653
686
 
671
704
}
672
705
 
673
706
static void
 
707
brasero_player_image_zoom_out_button_cb (GtkButton *button,
 
708
                                         BraseroPlayer *player)
 
709
{
 
710
        brasero_player_image_zoom_out (player);
 
711
}
 
712
 
 
713
static gboolean
 
714
brasero_player_image_scroll (BraseroPlayerBacon *bacon,
 
715
                             GdkEventScroll *event,
 
716
                             BraseroPlayer *player)
 
717
{
 
718
        if (event->direction == GDK_SCROLL_UP)
 
719
                brasero_player_image_zoom_in (player);
 
720
        else
 
721
                brasero_player_image_zoom_out (player);
 
722
 
 
723
        return TRUE;
 
724
}
 
725
 
 
726
static void
674
727
brasero_player_create_controls_image (BraseroPlayer *player)
675
728
{
676
729
        GtkWidget *box, *zoom;
726
779
        gtk_button_set_focus_on_click (GTK_BUTTON (zoom), FALSE);
727
780
        g_signal_connect (zoom,
728
781
                          "clicked",
729
 
                          G_CALLBACK (brasero_player_image_zoom_out),
 
782
                          G_CALLBACK (brasero_player_image_zoom_out_button_cb),
730
783
                          player);
731
784
        gtk_box_pack_start (GTK_BOX (box),
732
785
                            zoom,
742
795
        gtk_button_set_focus_on_click (GTK_BUTTON (zoom), FALSE);
743
796
        g_signal_connect (zoom,
744
797
                          "clicked",
745
 
                          G_CALLBACK (brasero_player_image_zoom_in),
 
798
                          G_CALLBACK (brasero_player_image_zoom_in_button_cb),
746
799
                          player);
747
800
        gtk_box_pack_start (GTK_BOX (box),
748
801
                            zoom,
822
875
        g_free (string);
823
876
 
824
877
        gtk_widget_hide (player->priv->bacon);
825
 
        gtk_widget_show (player->priv->image_display);
 
878
        gtk_widget_show (player->priv->image_event);
826
879
        gtk_widget_show (player->priv->notebook);
827
880
        gtk_alignment_set_padding (GTK_ALIGNMENT (player), 12, 0, 0, 0);
828
881
 
908
961
                /* video */
909
962
                brasero_player_create_controls_stream (player, TRUE);
910
963
                gtk_range_set_value (GTK_RANGE (player->priv->progress), 0.0);
911
 
 
912
 
                if (g_file_info_get_attribute_boolean (info, BRASERO_IO_IS_SEEKABLE))
 
964
                if (g_file_info_get_attribute_boolean (info,BRASERO_IO_IS_SEEKABLE))
913
965
                        gtk_widget_set_sensitive (player->priv->progress, TRUE);
914
966
                else
915
967
                        gtk_widget_set_sensitive (player->priv->progress, FALSE);
916
968
 
917
969
                gtk_widget_show (player->priv->bacon);
918
 
                gtk_widget_hide (player->priv->image_display);
 
970
                gtk_widget_hide (player->priv->image_event);
919
971
                gtk_widget_show (player->priv->notebook);
920
972
        }
921
973
        else if (g_file_info_get_attribute_boolean (info, BRASERO_IO_HAS_AUDIO)) {
1092
1144
                if (player->priv->size)
1093
1145
                        gtk_label_set_text (GTK_LABEL (player->priv->size), NULL);
1094
1146
 
1095
 
                if (player->priv->button)
 
1147
                if (player->priv->button) {
1096
1148
                        gtk_widget_set_sensitive (player->priv->button, FALSE);
1097
 
 
1098
 
                if (player->priv->image) {
1099
 
                        gtk_image_set_from_stock (GTK_IMAGE (player->priv->image),
1100
 
                                                  GTK_STOCK_MEDIA_PLAY,
1101
 
                                                  GTK_ICON_SIZE_BUTTON);
 
1149
                        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (player->priv->button), FALSE);
1102
1150
                }
1103
 
 
 
1151
                
1104
1152
                if (player->priv->image_zoom_in)
1105
1153
                        gtk_widget_set_sensitive (player->priv->image_zoom_in, FALSE);
1106
1154
 
1123
1171
static void
1124
1172
brasero_player_eof_cb (BraseroPlayerBacon *bacon, BraseroPlayer *player)
1125
1173
{
1126
 
        gtk_image_set_from_stock (GTK_IMAGE (player->priv->image),
1127
 
                                  GTK_STOCK_MEDIA_PLAY,
1128
 
                                  GTK_ICON_SIZE_BUTTON);
1129
 
        
 
1174
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (player->priv->button), FALSE);
 
1175
 
1130
1176
        if (player->priv->update_scale_id) {
1131
1177
                g_source_remove (player->priv->update_scale_id);
1132
1178
                player->priv->update_scale_id = 0;
1152
1198
                break;
1153
1199
 
1154
1200
        case BACON_STATE_PAUSED:
1155
 
                gtk_image_set_from_stock (GTK_IMAGE (player->priv->image),
1156
 
                                          GTK_STOCK_MEDIA_PLAY,
1157
 
                                          GTK_ICON_SIZE_BUTTON);
1158
 
        
 
1201
                gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (player->priv->button), FALSE); 
1159
1202
                if (player->priv->update_scale_id) {
1160
1203
                        g_source_remove (player->priv->update_scale_id);
1161
1204
                        player->priv->update_scale_id = 0;
1168
1211
 
1169
1212
                        pos = gtk_range_get_value (GTK_RANGE (player->priv->progress));
1170
1213
                        brasero_player_bacon_set_pos (BRASERO_PLAYER_BACON (player->priv->bacon), pos + player->priv->start);
1171
 
                }
1172
 
 
1173
 
                gtk_image_set_from_stock (GTK_IMAGE (player->priv->image),
1174
 
                                          GTK_STOCK_MEDIA_PAUSE,
1175
 
                                          GTK_ICON_SIZE_BUTTON);
1176
 
 
1177
 
                if (!player->priv->update_scale_id)
 
1214
 
 
1215
                        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (player->priv->button), TRUE);
 
1216
 
 
1217
                        if (!player->priv->update_scale_id)
1178
1218
                        player->priv->update_scale_id = g_timeout_add (500,
1179
1219
                                                                       (GSourceFunc) brasero_player_update_progress_cb,
1180
1220
                                                                       player);
 
1221
                }
 
1222
 
1181
1223
                break;
1182
1224
 
1183
1225
        default:
1278
1320
                                   BRASERO_SETTING_VIDEO_SIZE_WIDTH,
1279
1321
                                   GINT_TO_POINTER (player->priv->video_width));
1280
1322
 
1281
 
        player->priv->image = NULL;
1282
 
 
1283
1323
        if (player->priv->pixbuf) {
1284
1324
                g_object_unref (player->priv->pixbuf);
1285
1325
                player->priv->pixbuf = NULL;
1352
1392
brasero_player_init (BraseroPlayer *obj)
1353
1393
{
1354
1394
        GtkWidget *alignment;
 
1395
        GtkWidget *event;
1355
1396
        gpointer value;
1356
1397
 
1357
1398
        obj->priv = g_new0 (BraseroPlayerPrivate, 1);
1383
1424
        gtk_notebook_set_show_tabs (GTK_NOTEBOOK (obj->priv->notebook), FALSE);
1384
1425
        gtk_notebook_set_show_border (GTK_NOTEBOOK (obj->priv->notebook), FALSE);
1385
1426
 
 
1427
        event = gtk_event_box_new ();
 
1428
        obj->priv->image_event = event;
 
1429
        gtk_event_box_set_above_child (GTK_EVENT_BOX (event), TRUE);
 
1430
        gtk_event_box_set_visible_window (GTK_EVENT_BOX (event), FALSE);
 
1431
        gtk_notebook_append_page (GTK_NOTEBOOK (obj->priv->notebook),
 
1432
                                  event,
 
1433
                                  NULL);
 
1434
        g_signal_connect (event,
 
1435
                          "scroll-event",
 
1436
                          G_CALLBACK (brasero_player_image_scroll),
 
1437
                          obj);
 
1438
        gtk_widget_show (event);
 
1439
 
1386
1440
        obj->priv->image_display = gtk_image_new ();
1387
1441
        gtk_widget_show (obj->priv->image_display);
1388
1442
        gtk_misc_set_alignment (GTK_MISC (obj->priv->image_display), 1.0, 0.0);
1389
 
        gtk_notebook_append_page (GTK_NOTEBOOK (obj->priv->notebook),
1390
 
                                  obj->priv->image_display,
1391
 
                                  NULL);
 
1443
        gtk_container_add (GTK_CONTAINER (event), obj->priv->image_display);
1392
1444
 
1393
1445
        obj->priv->bacon = brasero_player_bacon_new ();
1394
1446
        gtk_widget_show (obj->priv->bacon);
1400
1452
                          "eof",
1401
1453
                          G_CALLBACK (brasero_player_eof_cb),
1402
1454
                          obj);
 
1455
        g_signal_connect (obj->priv->bacon,
 
1456
                          "scroll-event",
 
1457
                          G_CALLBACK (brasero_player_video_scroll),
 
1458
                          obj);
 
1459
 
1403
1460
        gtk_notebook_append_page (GTK_NOTEBOOK (obj->priv->notebook),
1404
1461
                                  obj->priv->bacon,
1405
1462
                                  NULL);