~ubuntu-branches/ubuntu/lucid/brasero/lucid-updates

« back to all changes in this revision

Viewing changes to libbrasero-utils/brasero-jacket-view.c

  • Committer: Bazaar Package Importer
  • Author(s): Didier Roche
  • Date: 2010-06-24 11:22:46 UTC
  • mfrom: (1.3.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100624112246-s5ubbf8tafqkir0m
Tags: 2.30.2-0ubuntu1
* New upstream release
  - Lot's of memleak fixes
  - Fixed a runtime warning related to cancelling tracker searches
  - Crash in brasero_data_project_node_removed at
    brasero-data-project.c:1163
  - brasero crashed with SIGSEGV in brasero_data_project_remove_node()
    (LP: #561319)
  - Fix a few runtime warnings with the Cover Editor
  - Text in cover editor does not show up automatically (LP: #469459)
  - Removed use of deprecated flags
  - Use accessor functions instead direct access (use GSEAL GnomeGoal)
  - Fix a bug in the layout on first start (side pane was hidden and
    remained so until the user moved it)
  - Save printer settings for cover printing
  - Write the contents of the GtkTextBuffer displayed line by displayed
    line which should improve the layout
  - "Write to Disc" button sensitivity regression
  - Fix flaw in mask that led libburn plugin not to work (not to be picked
    up actually) in some circumstances
  - Fails to burn ANY audio project
  - Move columns doesn't work (LP: #581759)
  - Brasero does not correctly handle double clicking on column separators
    (LP: #581885)
  - Bad info when burning, high CPU usage and slow burn
  - Change the priority for cdrdao and raised the one of cdda2wav plugin
  - brasero crashed with SIGSEGV in
    brasero_mmc3_get_performa nce_wrt_spd_desc() (LP: #564766)
  - brasero crashed with SIGSEGV in brasero_scsi_command_issue_sync()
    (LP: #444832)
  - Do not check for symlinks on cdda2wav so the plugin can use icedax.
  - Brasero's failure with some file names (LP: #380643)
  - Pressing create audio cd does nothing
  - Empty project not available
  - can't actually save error logs
  - doesn't handle incorrect temp dirs properly
  - Fix multi DND in GtkFileChooser
  - Displays "starting to record" during whole burn process
  - Fix wrong report of speed with both cdrecord and wodim
  - Disk project doesn't save the disk title (LP: #587924)
  - Brasero reports outdated cdrtools on cdrtools-3.00 (LP: #592075)
  - misc bug fixes
  - Updated Translations
* Removed upstream patches:
  - debian/patches/90_git_audio_project_creation.patch,
    debian/patches/91_git_audio_project_creation.patch,
    debian/patches/92_git_audio_cd_recording.patch,
    debian/patches/93_git_new_caps_function_definition.patch
* debian/patches/99_autoconf.patch:
  - refreshed

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
brasero_jacket_view_tag_begins (GtkTextIter *iter,
88
88
                                GtkTextAttributes *attributes)
89
89
{
 
90
        gint index;
90
91
        PangoAttribute *attr;
91
92
        GSList *open_attr = NULL;
92
93
 
 
94
        index = gtk_text_iter_get_visible_line_index (iter);
93
95
        attr = pango_attr_foreground_new (attributes->appearance.fg_color.red,
94
96
                                          attributes->appearance.fg_color.green,
95
97
                                          attributes->appearance.fg_color.blue);
96
 
        attr->start_index = gtk_text_iter_get_visible_line_index (iter);
 
98
        attr->start_index = index;
97
99
        open_attr = g_slist_prepend (open_attr, attr);
98
100
 
99
101
        attr = pango_attr_font_desc_new (attributes->font);
100
 
        attr->start_index = gtk_text_iter_get_visible_line_index (iter);
 
102
        attr->start_index = index;
101
103
        open_attr = g_slist_prepend (open_attr, attr);
102
104
 
103
105
        attr = pango_attr_underline_new (attributes->appearance.underline);
104
 
        attr->start_index = gtk_text_iter_get_visible_line_index (iter);
 
106
        attr->start_index = index;
105
107
        open_attr = g_slist_prepend (open_attr, attr);
106
108
 
107
109
        return open_attr;
126
128
static void
127
129
brasero_jacket_view_set_line_attributes (GtkTextView *view,
128
130
                                         PangoLayout *layout,
129
 
                                         guint line_num)
 
131
                                         GtkTextIter *start,
 
132
                                         GtkTextIter *end)
130
133
{
131
134
        PangoAttrList *attributes = NULL;
132
135
        GtkTextAttributes *text_attr;
134
137
        PangoAlignment alignment;
135
138
        GtkTextBuffer *buffer;
136
139
        GtkTextIter iter;
137
 
        GtkTextIter end;
138
140
 
139
141
        attributes = pango_attr_list_new ();
140
142
 
141
143
        buffer = gtk_text_view_get_buffer (view);
142
 
        gtk_text_buffer_get_iter_at_line (buffer, &iter, line_num);
 
144
        iter = *start;
143
145
 
144
146
        text_attr = gtk_text_view_get_default_attributes (view);
145
147
        gtk_text_iter_get_attributes (&iter, text_attr);
163
165
        gtk_text_attributes_unref (text_attr);
164
166
 
165
167
        while (gtk_text_iter_forward_to_tag_toggle (&iter, NULL) &&
166
 
               gtk_text_iter_get_line (&iter) == line_num &&
 
168
               gtk_text_iter_compare (&iter, end) < 0 &&
167
169
              !gtk_text_iter_is_end (&iter)) {
168
170
 
169
171
                brasero_jacket_view_tag_ends (&iter, attributes, open_attr);
190
192
                gtk_text_attributes_unref (text_attr);
191
193
        }
192
194
 
193
 
        /* Safer to do this in case one tag finishes on next line */
194
 
        gtk_text_buffer_get_iter_at_line (buffer, &end, line_num);
195
 
        gtk_text_iter_forward_to_line_end (&end);
196
 
 
197
195
        /* go through all still opened attributes */
198
 
        brasero_jacket_view_tag_ends (&end, attributes, open_attr);
 
196
        brasero_jacket_view_tag_ends (end, attributes, open_attr);
199
197
        g_slist_free (open_attr);
200
198
 
201
199
        pango_layout_set_attributes (layout, attributes);
209
207
                                      cairo_t *ctx,
210
208
                                      PangoLayout *layout,
211
209
                                      gdouble resolution,
212
 
                                      guint x,
213
 
                                      guint y)
 
210
                                      gdouble x,
 
211
                                      gdouble y)
214
212
{
215
 
        guint y_left;
216
 
        guint y_right;
217
 
        guint width;
218
 
        guint x_left;
219
 
        guint x_right;
220
 
        guint line_num;
221
 
        guint line_max;
 
213
        gdouble y_left;
 
214
        gdouble x_left;
 
215
        gdouble x_right;
 
216
        gdouble y_right;
222
217
        GtkTextBuffer *buffer;
 
218
        GtkTextIter start, end;
 
219
        PangoContext *pango_ctx;
223
220
        BraseroJacketViewPrivate *priv;
 
221
        cairo_font_options_t *font_options;
224
222
 
225
223
        priv = BRASERO_JACKET_VIEW_PRIVATE (self);
226
224
 
 
225
        cairo_set_source_rgb (ctx, 0.0, 0.0, 0.0);
 
226
 
 
227
        /* This is vital to get the exact same layout when printing. By default
 
228
         * this is off for printing and on for screen display */
 
229
        font_options = cairo_font_options_create ();
 
230
        cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_GRAY);
 
231
        cairo_font_options_set_hint_metrics (font_options, CAIRO_HINT_METRICS_ON);
 
232
        cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_SLIGHT);
 
233
        cairo_set_font_options (ctx, font_options);
 
234
 
 
235
        pango_ctx = pango_layout_get_context (layout);
 
236
        pango_cairo_context_set_font_options (pango_ctx, font_options);
 
237
        cairo_font_options_destroy (font_options);
 
238
 
 
239
        pango_layout_set_width (layout, resolution * COVER_HEIGHT_SIDE_INCH * PANGO_SCALE);
 
240
 
 
241
        x_left = x + 0.5;
 
242
        y_left = y + COVER_HEIGHT_SIDE_INCH * resolution - 0.5;
 
243
 
 
244
        x_right = x + COVER_WIDTH_BACK_INCH * resolution - 0.5;
 
245
        y_right = y + 0.5;
 
246
 
227
247
        buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->sides));
228
 
        line_max = gtk_text_buffer_get_line_count (buffer);
229
 
 
230
 
        width = resolution * COVER_HEIGHT_SIDE_INCH;
231
 
        x_left = x;
232
 
        y_left = y + COVER_HEIGHT_SIDE_INCH * resolution;
233
 
 
234
 
        x_right = x + COVER_WIDTH_BACK_INCH * resolution;
235
 
        y_right = y;
236
 
 
237
 
        for (line_num = 0; line_num < line_max; line_num ++) {
 
248
        gtk_text_buffer_get_start_iter (buffer, &start);
 
249
        end = start;
 
250
 
 
251
        while (!gtk_text_iter_is_end (&start)) {
238
252
                gchar *text;
239
253
                PangoRectangle rect;
240
 
                GtkTextIter start, end;
241
 
 
242
 
                cairo_set_source_rgb (ctx, 0.0, 0.0, 0.0);
243
 
 
244
 
                gtk_text_buffer_get_iter_at_line (buffer, &start, line_num);
245
 
                gtk_text_buffer_get_iter_at_line (buffer, &end, line_num);
246
 
                gtk_text_iter_forward_to_line_end (&end);
 
254
 
 
255
                gtk_text_view_forward_display_line_end (GTK_TEXT_VIEW (priv->sides), &end);
247
256
 
248
257
                text = brasero_jacket_buffer_get_text (BRASERO_JACKET_BUFFER (buffer), &start, &end, FALSE, FALSE);
249
258
                if (text && text [0] != '\0' && text [0] != '\n') {
253
262
                else
254
263
                        pango_layout_set_text (layout, " ", -1);
255
264
 
256
 
                pango_layout_set_width (layout, width * PANGO_SCALE);
257
 
                pango_layout_set_wrap (layout, PANGO_WRAP_CHAR);
258
 
                brasero_jacket_view_set_line_attributes (GTK_TEXT_VIEW (priv->sides), layout, line_num);
259
 
 
260
 
                pango_layout_get_pixel_extents (layout, NULL, &rect);
 
265
                brasero_jacket_view_set_line_attributes (GTK_TEXT_VIEW (priv->sides), layout, &start, &end);
261
266
 
262
267
                cairo_save (ctx);
263
268
 
277
282
 
278
283
                cairo_restore (ctx);
279
284
 
 
285
                pango_layout_get_pixel_extents (layout, NULL, &rect);
 
286
 
280
287
                x_right -= rect.height;
281
288
                x_left += rect.height;
 
289
 
 
290
                gtk_text_view_forward_display_line (GTK_TEXT_VIEW (priv->sides), &end);
 
291
                start = end;
 
292
        }
 
293
}
 
294
 
 
295
static void
 
296
brasero_jacket_view_render_body (BraseroJacketView *self,
 
297
                                 cairo_t *ctx,
 
298
                                 PangoLayout *layout,
 
299
                                 gdouble resolution_x,
 
300
                                 gdouble resolution_y,
 
301
                                 guint x,
 
302
                                 guint y,
 
303
                                 gboolean render_if_empty)
 
304
{
 
305
        GtkTextBuffer *buffer;
 
306
        GtkTextIter start, end;
 
307
        PangoContext *pango_ctx;
 
308
        BraseroJacketViewPrivate *priv;
 
309
        cairo_font_options_t *font_options;
 
310
 
 
311
        priv = BRASERO_JACKET_VIEW_PRIVATE (self);
 
312
 
 
313
        /* This is vital to get the exact same layout when printing. By default
 
314
         * this is off for printing and on for screen display */
 
315
        font_options = cairo_font_options_create ();
 
316
        cairo_font_options_set_antialias (font_options, CAIRO_ANTIALIAS_GRAY);
 
317
        cairo_font_options_set_hint_metrics (font_options, CAIRO_HINT_METRICS_OFF);
 
318
        cairo_font_options_set_hint_style (font_options, CAIRO_HINT_STYLE_SLIGHT);
 
319
        cairo_set_font_options (ctx, font_options);
 
320
 
 
321
        pango_ctx = pango_layout_get_context (layout);
 
322
        pango_cairo_context_set_font_options (pango_ctx, font_options);
 
323
        cairo_font_options_destroy (font_options);
 
324
 
 
325
        /* This is necessary for the alignment of text */
 
326
        if (priv->side == BRASERO_JACKET_BACK)
 
327
                pango_layout_set_width (layout, (COVER_WIDTH_BACK_INCH - (COVER_WIDTH_SIDE_INCH + COVER_TEXT_MARGIN) * 2.0) * resolution_x * PANGO_SCALE);
 
328
        else
 
329
                pango_layout_set_width (layout, (COVER_WIDTH_FRONT_INCH - COVER_TEXT_MARGIN * 2.0) * resolution_x * PANGO_SCALE);
 
330
 
 
331
        buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->edit));
 
332
        gtk_text_buffer_get_start_iter (buffer, &start);
 
333
        end = start;
 
334
 
 
335
        while (!gtk_text_iter_is_end (&start)) {
 
336
                gchar *text;
 
337
                PangoRectangle rect;
 
338
 
 
339
                gtk_text_view_forward_display_line_end (GTK_TEXT_VIEW (priv->edit), &end);
 
340
 
 
341
                text = brasero_jacket_buffer_get_text (BRASERO_JACKET_BUFFER (buffer), &start, &end, FALSE, render_if_empty);
 
342
                if (text && text [0] != '\0' && text [0] != '\n') {
 
343
                        pango_layout_set_text (layout, text, -1);
 
344
                        g_free (text);
 
345
                }
 
346
                else
 
347
                        pango_layout_set_text (layout, " ", -1);
 
348
 
 
349
                brasero_jacket_view_set_line_attributes (GTK_TEXT_VIEW (priv->edit), layout, &start, &end);
 
350
                pango_cairo_update_layout (ctx, layout);
 
351
 
 
352
                if (priv->side == BRASERO_JACKET_BACK)
 
353
                        cairo_move_to (ctx,
 
354
                                       x + (COVER_WIDTH_SIDE_INCH + COVER_TEXT_MARGIN) * resolution_x + 0.5,
 
355
                                       y + COVER_TEXT_MARGIN * resolution_y);
 
356
                else
 
357
                        cairo_move_to (ctx,
 
358
                                       x + COVER_TEXT_MARGIN * resolution_x + 0.5,
 
359
                                       y + COVER_TEXT_MARGIN * resolution_y);
 
360
 
 
361
                pango_cairo_show_layout (ctx, layout);
 
362
                pango_layout_get_pixel_extents (layout, NULL, &rect);
 
363
                y += rect.height;
 
364
 
 
365
                gtk_text_view_forward_display_line (GTK_TEXT_VIEW (priv->edit), &end);
 
366
                start = end;
282
367
        }
283
368
}
284
369
 
295
380
                            gboolean render_if_empty)
296
381
{
297
382
        BraseroJacketViewPrivate *priv;
298
 
        gint height, width;
 
383
        int height, width;
299
384
 
300
385
        priv = BRASERO_JACKET_VIEW_PRIVATE (self);
301
386
 
318
403
        cairo_paint (ctx);
319
404
 
320
405
        /* draw background */
321
 
        cairo_rectangle (ctx, x, y, width, height);
 
406
        cairo_rectangle (ctx, x, y, width + 2.0, height + 2.0);
322
407
        cairo_clip (ctx);
323
408
 
324
409
        if (priv->pattern) {
333
418
                if (priv->image_style == BRASERO_JACKET_IMAGE_CENTER)
334
419
                        gdk_cairo_set_source_pixbuf (ctx,
335
420
                                                     scaled,
336
 
                                                     x + (width - gdk_pixbuf_get_width (scaled))/ 2.0,
 
421
                                                     x + (width - gdk_pixbuf_get_width (scaled)) / 2.0,
337
422
                                                     y + (height - gdk_pixbuf_get_height (scaled)) / 2.0);
338
423
                else
339
424
                        gdk_cairo_set_source_pixbuf (ctx, scaled, x, y);
349
434
        }
350
435
 
351
436
        if (priv->side == BRASERO_JACKET_BACK) {
 
437
                gdouble line_x, line_y;
 
438
 
352
439
                cairo_save (ctx);
353
440
 
354
441
                /* Draw the rectangle */
355
 
                cairo_set_antialias (ctx, CAIRO_ANTIALIAS_DEFAULT);
356
 
                cairo_set_source_rgb (ctx, 0.5, 0.5, 0.5);
357
 
                cairo_set_line_width (ctx, 0.5);
358
 
                cairo_set_line_cap (ctx, CAIRO_LINE_CAP_ROUND);
359
 
 
360
 
                cairo_move_to (ctx,
361
 
                               x + COVER_WIDTH_SIDE_INCH * resolution_x,
362
 
                               y);
363
 
                cairo_line_to (ctx,
364
 
                               x + COVER_WIDTH_SIDE_INCH * resolution_x,
365
 
                               y + (COVER_HEIGHT_SIDE_INCH * resolution_y));
366
 
 
367
 
                cairo_move_to (ctx,
368
 
                               x + (COVER_WIDTH_BACK_INCH - COVER_WIDTH_SIDE_INCH) * resolution_x,
369
 
                               y);
370
 
                cairo_line_to (ctx,
371
 
                               x + (COVER_WIDTH_BACK_INCH - COVER_WIDTH_SIDE_INCH) * resolution_x,
372
 
                               y + (COVER_HEIGHT_SIDE_INCH * resolution_y));
 
442
                cairo_set_source_rgb (ctx, 0.0, 0.0, 0.0);
 
443
                cairo_set_line_width (ctx, 1.0);
 
444
 
 
445
                line_y = y + (COVER_HEIGHT_SIDE_INCH * resolution_y) - 0.5;
 
446
 
 
447
                line_x = (int) (x + (COVER_WIDTH_SIDE_INCH * resolution_x)) + 0.5;
 
448
                cairo_move_to (ctx,
 
449
                               line_x,
 
450
                               y + 0.5);
 
451
                cairo_line_to (ctx,
 
452
                               line_x,
 
453
                               line_y);
 
454
 
 
455
                line_x = (int) (x + ((COVER_WIDTH_BACK_INCH - COVER_WIDTH_SIDE_INCH) * resolution_x)) + 0.5;
 
456
                cairo_move_to (ctx,
 
457
                               line_x,
 
458
                               y + 0.5);
 
459
                cairo_line_to (ctx,
 
460
                               line_x,
 
461
                               line_y);
373
462
 
374
463
                cairo_stroke (ctx);
375
464
 
388
477
        }
389
478
 
390
479
        /* Draw the rectangle */
391
 
        cairo_set_source_rgb (ctx, 0.5, 0.5, 0.5);
392
 
        cairo_set_line_width (ctx, 0.5);
393
 
        cairo_set_line_cap (ctx, CAIRO_LINE_CAP_ROUND);
 
480
        cairo_set_source_rgb (ctx, 0.0, 0.0, 0.0);
 
481
        cairo_set_line_width (ctx, 1.0);
394
482
 
395
483
        cairo_rectangle (ctx,
396
 
                         x,
397
 
                         y,
 
484
                         x + 0.5,
 
485
                         y + 0.5,
398
486
                         width,
399
487
                         height);
400
488
        cairo_stroke (ctx);
401
489
}
402
490
 
403
 
static void
404
 
brasero_jacket_view_render_body (BraseroJacketView *self,
405
 
                                 cairo_t *ctx,
406
 
                                 gdouble resolution_x,
407
 
                                 gdouble resolution_y,
408
 
                                 guint x,
409
 
                                 guint y,
410
 
                                 gboolean render_if_empty)
411
 
{
412
 
        guint width;
413
 
        gint line_max;
414
 
        gint line_num = 0;
415
 
        PangoLayout *layout;
416
 
        GtkTextBuffer *buffer;
417
 
        BraseroJacketViewPrivate *priv;
418
 
 
419
 
        priv = BRASERO_JACKET_VIEW_PRIVATE (self);
420
 
 
421
 
        buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->edit));
422
 
        line_max = gtk_text_buffer_get_line_count (buffer);
423
 
 
424
 
        if (priv->side == BRASERO_JACKET_BACK)
425
 
                width = ((COVER_WIDTH_BACK_INCH - COVER_WIDTH_SIDE_INCH * 2) * resolution_x - COVER_TEXT_MARGIN * resolution_x * 2) * PANGO_SCALE;
426
 
        else
427
 
                width = (COVER_WIDTH_FRONT_INCH * resolution_x - COVER_TEXT_MARGIN * resolution_x * 2) * PANGO_SCALE;
428
 
 
429
 
        for (line_num = 0; line_num < line_max; line_num ++) {
430
 
                gchar *text;
431
 
                PangoRectangle rect;
432
 
                PangoContext *context;
433
 
                GtkTextIter start, end;
434
 
 
435
 
                cairo_set_source_rgb (ctx, 0.0, 0.0, 0.0);
436
 
                layout = pango_cairo_create_layout (ctx);
437
 
 
438
 
                context = pango_layout_get_context (layout);
439
 
                pango_cairo_context_set_resolution (context, resolution_x);
440
 
 
441
 
                gtk_text_buffer_get_iter_at_line (buffer, &start, line_num);
442
 
                gtk_text_buffer_get_iter_at_line (buffer, &end, line_num);
443
 
                gtk_text_iter_forward_to_line_end (&end);
444
 
 
445
 
                text = brasero_jacket_buffer_get_text (BRASERO_JACKET_BUFFER (buffer), &start, &end, FALSE, render_if_empty);
446
 
                if (text && text [0] != '\0' && text [0] != '\n') {
447
 
                        pango_layout_set_text (layout, text, -1);
448
 
                        g_free (text);
449
 
                }
450
 
                else
451
 
                        pango_layout_set_text (layout, " ", -1);
452
 
 
453
 
                pango_layout_set_width (layout, width);
454
 
                pango_layout_set_wrap (layout, PANGO_WRAP_CHAR);
455
 
                brasero_jacket_view_set_line_attributes (GTK_TEXT_VIEW (priv->edit), layout, line_num);
456
 
 
457
 
                if (priv->side == BRASERO_JACKET_BACK)
458
 
                        cairo_move_to (ctx,
459
 
                                       x + COVER_WIDTH_SIDE_INCH * resolution_x + COVER_TEXT_MARGIN * resolution_x,
460
 
                                       y + COVER_TEXT_MARGIN * resolution_y);
461
 
                else
462
 
                        cairo_move_to (ctx,
463
 
                                       x + COVER_TEXT_MARGIN * resolution_x,
464
 
                                       y + COVER_TEXT_MARGIN * resolution_y);
465
 
                pango_cairo_show_layout (ctx, layout);
466
 
 
467
 
                pango_layout_get_pixel_extents (layout, NULL, &rect);
468
 
                y += rect.height;
469
 
 
470
 
                g_object_unref (layout);
471
 
        }
472
 
}
473
 
 
474
491
static GdkPixbuf *
475
492
brasero_jacket_view_scale_image (BraseroJacketView *self,
476
493
                                 gdouble resolution_x,
499
516
guint
500
517
brasero_jacket_view_print (BraseroJacketView *self,
501
518
                           GtkPrintContext *context,
502
 
                           guint x,
503
 
                           guint y)
 
519
                           gdouble x,
 
520
                           gdouble y)
504
521
{
505
522
        cairo_t *ctx;
506
523
        GdkRectangle rect;
521
538
        rect.y = y;
522
539
 
523
540
        if (priv->side == BRASERO_JACKET_BACK) {
524
 
                rect.width = resolution_x * COVER_WIDTH_BACK_INCH;
525
 
                rect.height = resolution_y * COVER_HEIGHT_BACK_INCH;
 
541
                rect.width = (resolution_x * COVER_WIDTH_BACK_INCH) + 1.0;
 
542
                rect.height = (resolution_y * COVER_HEIGHT_BACK_INCH) + 1.0;
526
543
        }
527
544
        else {
528
 
                rect.width = resolution_x * COVER_WIDTH_FRONT_INCH;
529
 
                rect.height = resolution_y * COVER_HEIGHT_FRONT_INCH;
 
545
                rect.width = (resolution_x * COVER_WIDTH_FRONT_INCH) + 1.0;
 
546
                rect.height = (resolution_y * COVER_HEIGHT_FRONT_INCH) + 1.0;
530
547
        }
531
548
 
532
549
        /* Make sure we scale the image with the correct resolution */
552
569
        /* Now let's render the text in main buffer */
553
570
        brasero_jacket_view_render_body (self,
554
571
                                         ctx,
 
572
                                         layout,
555
573
                                         resolution_x,
556
574
                                         resolution_y,
557
575
                                         x,
566
584
        return rect.height;
567
585
}
568
586
 
569
 
cairo_surface_t *
570
 
brasero_jacket_view_snapshot (BraseroJacketView *self)
571
 
{
572
 
        BraseroJacketViewPrivate *priv;
573
 
        cairo_surface_t *surface;
574
 
        PangoLayout *layout;
575
 
        GtkWidget *toplevel;
576
 
        gdouble resolution;
577
 
        GdkPixbuf *scaled;
578
 
        GdkRectangle area;
579
 
        cairo_t *ctx;
580
 
        guint height;
581
 
        guint width;
582
 
 
583
 
        priv = BRASERO_JACKET_VIEW_PRIVATE (self);
584
 
 
585
 
        toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
586
 
        if (!GTK_IS_WINDOW (toplevel))
587
 
                return NULL;
588
 
 
589
 
        resolution = gdk_screen_get_resolution (gtk_window_get_screen (GTK_WINDOW (toplevel)));
590
 
 
591
 
        layout = gtk_widget_create_pango_layout (GTK_WIDGET (self), NULL);
592
 
 
593
 
        if (priv->side == BRASERO_JACKET_BACK) {
594
 
                width = resolution * COVER_WIDTH_BACK_INCH + 1;
595
 
                height = resolution * COVER_HEIGHT_BACK_INCH + 1;
596
 
        }
597
 
        else {
598
 
                width = resolution * COVER_WIDTH_FRONT_INCH + 1;
599
 
                height = resolution * COVER_HEIGHT_FRONT_INCH + 1;
600
 
        }
601
 
 
602
 
        surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
603
 
                                              width,
604
 
                                              height);
605
 
        ctx = cairo_create (surface);
606
 
 
607
 
        /* make sure the image is scaled with the correct resolution */
608
 
        if (priv->image_style == BRASERO_JACKET_IMAGE_STRETCH)
609
 
                scaled = brasero_jacket_view_scale_image (self,
610
 
                                                          resolution,
611
 
                                                          resolution);
612
 
        else
613
 
                scaled = g_object_ref (priv->scaled);
614
 
 
615
 
        gtk_widget_get_allocation (GTK_WIDGET (self), &area);
616
 
        area.x = 0;
617
 
        area.y = 0;
618
 
        brasero_jacket_view_render (self,
619
 
                                    ctx,
620
 
                                    layout,
621
 
                                    scaled,
622
 
                                    resolution,
623
 
                                    resolution,
624
 
                                    0,
625
 
                                    0,
626
 
                                    &area,
627
 
                                    FALSE);
628
 
 
629
 
        /* Now let's render the text in main buffer */
630
 
        brasero_jacket_view_render_body (self,
631
 
                                         ctx,
632
 
                                         resolution,
633
 
                                         resolution,
634
 
                                         0,
635
 
                                         0,
636
 
                                         FALSE);
637
 
 
638
 
        g_object_unref (layout);
639
 
        cairo_destroy (ctx);
640
 
        return surface;
641
 
}
642
 
 
643
587
static void
644
588
brasero_jacket_view_cursor_position_changed_cb (GObject *buffer,
645
589
                                                GParamSpec *spec,
680
624
{
681
625
        GtkTextView *text_view = GTK_TEXT_VIEW (view);
682
626
        GtkTextBuffer *buffer;
683
 
 
684
 
        if (gtk_text_view_get_editable (text_view)) {
685
 
                text_view->need_im_reset = TRUE;
686
 
                gtk_im_context_focus_in (text_view->im_context);
687
 
        }
688
 
 
 
627
        
689
628
        buffer = gtk_text_view_get_buffer (text_view);
690
629
        brasero_jacket_buffer_show_default_text (BRASERO_JACKET_BUFFER (buffer), FALSE);
691
630
 
701
640
{
702
641
        GtkTextView *text_view = GTK_TEXT_VIEW (view);
703
642
        GtkTextBuffer *buffer;
704
 
 
705
 
        if (gtk_text_view_get_editable (text_view)) {
706
 
                text_view->need_im_reset = TRUE;
707
 
                gtk_im_context_focus_out (text_view->im_context);
708
 
        }
709
 
 
 
643
        
710
644
        buffer = gtk_text_view_get_buffer (text_view);
711
645
        brasero_jacket_buffer_show_default_text (BRASERO_JACKET_BUFFER (buffer), TRUE);
712
646
 
713
647
        g_signal_emit (self,
714
648
                       jacket_view_signals [TAGS_CHANGED],
715
 
                       0);
 
649
                       0);
716
650
}
717
651
 
718
652
static void
1265
1199
        return gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->sides));
1266
1200
}
1267
1201
 
 
1202
static void
 
1203
brasero_jacket_expose_textview (GtkWidget *widget,
 
1204
                                GtkWidget *textview,
 
1205
                                GdkEventExpose *event)
 
1206
{
 
1207
        GdkRectangle child_area;
 
1208
 
 
1209
        if (gtk_widget_intersect (textview, &event->area, &child_area)) {
 
1210
                GdkWindow *window;
 
1211
 
 
1212
                window = gtk_text_view_get_window (GTK_TEXT_VIEW (textview), GTK_TEXT_WINDOW_WIDGET);
 
1213
 
 
1214
                g_object_ref (window);
 
1215
                gdk_window_invalidate_rect (window, &child_area, TRUE);
 
1216
                gdk_window_process_updates (window, TRUE);
 
1217
                g_object_unref (window);
 
1218
 
 
1219
                /* Reminder: the following would not work...
 
1220
                 * gtk_container_propagate_expose (GTK_CONTAINER (widget), textview, &child_event); */
 
1221
        }
 
1222
}
 
1223
 
1268
1224
static gboolean
1269
1225
brasero_jacket_view_expose (GtkWidget *widget,
1270
1226
                            GdkEventExpose *event)
1274
1230
        cairo_t *ctx;
1275
1231
        gdouble resolution;
1276
1232
        GtkWidget *toplevel;
 
1233
        PangoLayout *layout;
1277
1234
        GtkAllocation allocation, sides_allocation;
1278
 
        PangoLayout *layout;
1279
1235
        BraseroJacketViewPrivate *priv;
1280
1236
 
1281
1237
        priv = BRASERO_JACKET_VIEW_PRIVATE (widget);
1282
1238
 
1283
1239
        ctx = gdk_cairo_create (GDK_DRAWABLE (gtk_widget_get_window (widget)));
1284
 
 
1285
1240
        toplevel = gtk_widget_get_toplevel (widget);
1286
1241
        if (!GTK_IS_WINDOW (toplevel))
1287
1242
                return FALSE;
1314
1269
                cairo_move_to (ctx, 0., 0.);
1315
1270
 
1316
1271
                cairo_set_antialias (ctx, CAIRO_ANTIALIAS_DEFAULT);
1317
 
                cairo_set_source_rgb (ctx, 0.5, 0.5, 0.5);
1318
 
                cairo_set_line_width (ctx, 0.5);
 
1272
                cairo_set_source_rgb (ctx, 0.0, 0.0, 0.0);
 
1273
                cairo_set_line_width (ctx, 1.0);
1319
1274
                cairo_set_line_cap (ctx, CAIRO_LINE_CAP_ROUND);
1320
1275
 
1321
1276
                gtk_widget_get_allocation (priv->sides, &sides_allocation);
1322
1277
                cairo_rectangle (ctx,
1323
 
                                 sides_allocation.x - 1,
1324
 
                                 sides_allocation.y - 1,
 
1278
                                 sides_allocation.x - 1 + 0.5,
 
1279
                                 sides_allocation.y - 1 + 0.5,
1325
1280
                                 sides_allocation.width + 2,
1326
1281
                                 sides_allocation.height + 2);
1327
1282
                cairo_stroke (ctx);
1328
 
 
1329
 
                gtk_container_propagate_expose (GTK_CONTAINER (widget),
1330
 
                                                priv->sides,
1331
 
                                                event);
1332
1283
        }
1333
1284
        else {
1334
1285
                x = (allocation.width - resolution * COVER_WIDTH_FRONT_INCH) / 2;
1346
1297
                                            TRUE);
1347
1298
        }
1348
1299
 
1349
 
        gtk_container_propagate_expose (GTK_CONTAINER (widget),
1350
 
                                        priv->edit,
1351
 
                                        event);
 
1300
        if (priv->sides)
 
1301
                brasero_jacket_expose_textview (widget, priv->sides, event);
1352
1302
 
 
1303
        brasero_jacket_expose_textview (widget, priv->edit, event);
 
1304
        
1353
1305
        g_object_unref (layout);
1354
1306
        cairo_destroy (ctx);
 
1307
 
1355
1308
        return FALSE;
1356
1309
}
1357
1310
 
1385
1338
        window = gtk_widget_get_window (widget);
1386
1339
        gdk_window_set_user_data (window, widget);
1387
1340
 
 
1341
        gtk_widget_set_realized (widget, TRUE);
 
1342
 
1388
1343
        gtk_widget_style_attach (widget);
1389
 
        GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
1390
1344
 
1391
1345
        gdk_window_show (gtk_widget_get_window (widget));
1392
1346
}
1411
1365
        resolution = gdk_screen_get_resolution (gtk_window_get_screen (GTK_WINDOW (toplevel)));
1412
1366
 
1413
1367
        if (priv->side == BRASERO_JACKET_FRONT) {
1414
 
                request->width = COVER_WIDTH_FRONT_INCH * resolution + BRASERO_JACKET_VIEW_MARGIN * 2;
1415
 
                request->height = COVER_HEIGHT_FRONT_INCH * resolution + BRASERO_JACKET_VIEW_MARGIN * 2;
 
1368
                request->width = COVER_WIDTH_FRONT_INCH * resolution + BRASERO_JACKET_VIEW_MARGIN * 2.0;
 
1369
                request->height = COVER_HEIGHT_FRONT_INCH * resolution + BRASERO_JACKET_VIEW_MARGIN * 2.0;
1416
1370
        }
1417
1371
        else if (priv->side == BRASERO_JACKET_BACK) {
1418
1372
                request->width = COVER_WIDTH_BACK_INCH * resolution +
1419
 
                                 BRASERO_JACKET_VIEW_MARGIN * 2;
 
1373
                                 BRASERO_JACKET_VIEW_MARGIN * 2.0;
1420
1374
                request->height = COVER_HEIGHT_BACK_INCH * resolution +
1421
1375
                                  COVER_WIDTH_SIDE_INCH * resolution +
1422
 
                                  BRASERO_JACKET_VIEW_MARGIN * 3;
 
1376
                                  BRASERO_JACKET_VIEW_MARGIN * 3.0;
1423
1377
        }
1424
1378
}
1425
1379
 
1430
1384
        BraseroJacketViewPrivate *priv;
1431
1385
        GtkAllocation view_alloc;
1432
1386
        GtkWidget *toplevel;
1433
 
        gint resolution;
 
1387
        gdouble resolution;
1434
1388
 
1435
1389
        toplevel = gtk_widget_get_toplevel (widget);
1436
1390
        if (!GTK_IS_WINDOW (toplevel))
1467
1421
                                BRASERO_JACKET_VIEW_MARGIN +
1468
1422
                                COVER_TEXT_MARGIN * resolution;
1469
1423
 
1470
 
                view_alloc.width = COVER_WIDTH_BACK_INCH * resolution -
1471
 
                                   COVER_TEXT_MARGIN * resolution * 2 - 
1472
 
                                   COVER_WIDTH_SIDE_INCH * resolution * 2;
1473
 
                view_alloc.height = COVER_HEIGHT_BACK_INCH * resolution -
1474
 
                                    COVER_TEXT_MARGIN * resolution * 2;
 
1424
                view_alloc.width = (COVER_WIDTH_BACK_INCH - (COVER_TEXT_MARGIN + COVER_WIDTH_SIDE_INCH) * 2.0) * resolution;
 
1425
                view_alloc.height = (COVER_HEIGHT_BACK_INCH - COVER_TEXT_MARGIN * 2.0) * resolution;
1475
1426
        }
1476
1427
        else {
1477
 
                view_alloc.x = (allocation->width - COVER_WIDTH_FRONT_INCH * resolution) / 2 +
 
1428
                view_alloc.x = (allocation->width - COVER_WIDTH_FRONT_INCH * resolution) / 2.0 +
1478
1429
                                COVER_TEXT_MARGIN * resolution;
1479
 
                view_alloc.y = (allocation->height - resolution * COVER_HEIGHT_FRONT_INCH) / 2 +
 
1430
                view_alloc.y = (allocation->height - resolution * COVER_HEIGHT_FRONT_INCH) / 2.0 +
1480
1431
                                COVER_TEXT_MARGIN * resolution;
1481
1432
 
1482
 
                view_alloc.width = COVER_WIDTH_FRONT_INCH * resolution -
1483
 
                                   COVER_TEXT_MARGIN * resolution * 2;
1484
 
                view_alloc.height = COVER_HEIGHT_FRONT_INCH * resolution -
1485
 
                                    COVER_TEXT_MARGIN * resolution * 2;
 
1433
                view_alloc.width = (gdouble) (COVER_WIDTH_FRONT_INCH - COVER_TEXT_MARGIN * 2.0) * resolution;
 
1434
                view_alloc.height = (gdouble) (COVER_HEIGHT_FRONT_INCH - COVER_TEXT_MARGIN * 2.0) * resolution;
1486
1435
        }
1487
1436
 
1488
1437
        brasero_jacket_view_update_edit_image (BRASERO_JACKET_VIEW (widget));