brasero r709 - in trunk: . po src
- From: philippr svn gnome org
- To: svn-commits-list gnome org
- Subject: brasero r709 - in trunk: . po src
- Date: Sun, 13 Apr 2008 16:55:28 +0100 (BST)
Author: philippr
Date: Sun Apr 13 16:55:27 2008
New Revision: 709
URL: http://svn.gnome.org/viewvc/brasero?rev=709&view=rev
Log:
Added a CD cover editor
* src/Makefile.am:
* src/brasero-jacket-background.c
(brasero_jacket_background_get_color_style),
(brasero_jacket_background_get_image_style),
(brasero_jacket_background_get_image_path),
(brasero_jacket_background_set_color_style),
(brasero_jacket_background_get_color),
(brasero_jacket_background_set_image_style),
(brasero_jacket_background_set_image_path),
(brasero_jacket_background_set_color),
(brasero_jacket_background_color_type_changed_cb),
(brasero_jacket_background_add_filters),
(brasero_jacket_background_init),
(brasero_jacket_background_finalize),
(brasero_jacket_background_class_init),
(brasero_jacket_background_new):
* src/brasero-jacket-background.h:
* src/brasero-jacket-buffer.c (brasero_jacket_buffer_get_text),
(brasero_jacket_buffer_add_default_tag),
(brasero_jacket_buffer_cursor_position_changed_cb),
(brasero_jacket_buffer_insert_text),
(brasero_jacket_buffer_show_default_text),
(brasero_jacket_buffer_set_default_text),
(brasero_jacket_buffer_init), (brasero_jacket_buffer_finalize),
(brasero_jacket_buffer_class_init), (brasero_jacket_buffer_new):
* src/brasero-jacket-buffer.h:
* src/brasero-jacket-edit.c (brasero_jacket_edit_print_page),
(brasero_jacket_edit_print_begin),
(brasero_jacket_edit_print_pressed_cb),
(brasero_jacket_edit_underline_pressed_cb),
(brasero_jacket_edit_italic_pressed_cb),
(brasero_jacket_edit_bold_pressed_cb),
(brasero_jacket_edit_center_pressed_cb),
(brasero_jacket_edit_right_pressed_cb),
(brasero_jacket_edit_left_pressed_cb),
(brasero_jacket_edit_colours_changed_cb),
(brasero_jacket_edit_font_changed_cb),
(brasero_jacket_edit_update_button_state),
(brasero_jacket_edit_tags_changed_cb), (brasero_jacket_edit_init),
(brasero_jacket_edit_finalize), (brasero_jacket_edit_class_init),
(brasero_jacket_edit_new):
* src/brasero-jacket-edit.h:
* src/brasero-jacket-font.c
(brasero_jacket_font_family_changed_cb),
(brasero_jacket_font_size_changed_cb),
(brasero_jacket_font_set_name), (brasero_jacket_font_get_name),
(brasero_jacket_fill_sizes), (brasero_jacket_fill_families),
(brasero_jacket_font_init), (brasero_jacket_font_finalize),
(brasero_jacket_font_class_init), (brasero_jacket_font_new):
* src/brasero-jacket-font.h:
* src/brasero-jacket-view.c (brasero_jacket_view_tag_begins),
(brasero_jacket_view_tag_ends),
(brasero_jacket_view_set_line_attributes),
(brasero_jacket_view_render_side_text),
(brasero_jacket_view_render), (brasero_jacket_view_render_body),
(brasero_jacket_view_print), (brasero_jacket_view_snapshot),
(brasero_jacket_view_cursor_position_changed_cb),
(brasero_jacket_view_apply_tag),
(brasero_jacket_view_side_buffer_changed),
(brasero_jacket_view_focus_in_cb),
(brasero_jacket_view_focus_out_cb),
(brasero_jacket_view_scrolled_cb),
(brasero_jacket_view_change_image_activated_cb),
(brasero_jacket_view_populate_popup_cb),
(brasero_jacket_view_set_side),
(brasero_jacket_view_update_edit_image),
(brasero_jacket_view_update_image),
(brasero_jacket_view_set_image_style),
(brasero_jacket_view_update_color),
(brasero_jacket_view_get_image), (brasero_jacket_view_set_image),
(brasero_jacket_view_set_color_background),
(brasero_jacket_view_set_color_style),
(brasero_jacket_view_get_default_attributes),
(brasero_jacket_view_get_active_buffer),
(brasero_jacket_view_expose), (brasero_jacket_view_realize),
(brasero_jacket_view_map), (brasero_jacket_view_unmap),
(brasero_jacket_view_size_request),
(brasero_jacket_view_size_allocate),
(brasero_jacket_view_container_forall),
(brasero_jacket_view_container_remove), (brasero_jacket_view_init),
(brasero_jacket_view_finalize), (brasero_jacket_view_class_init),
(brasero_jacket_view_new):
* src/brasero-jacket-view.h:
* src/brasero-menu.h:
* src/main.c (on_cover_cb):
Added:
trunk/src/brasero-jacket-background.c
trunk/src/brasero-jacket-background.h
trunk/src/brasero-jacket-buffer.c
trunk/src/brasero-jacket-buffer.h
trunk/src/brasero-jacket-edit.c
trunk/src/brasero-jacket-edit.h
trunk/src/brasero-jacket-font.c
trunk/src/brasero-jacket-font.h
trunk/src/brasero-jacket-view.c
trunk/src/brasero-jacket-view.h
Modified:
trunk/ChangeLog
trunk/po/ChangeLog
trunk/po/POTFILES.in
trunk/src/Makefile.am
trunk/src/brasero-menu.h
trunk/src/main.c
Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in (original)
+++ trunk/po/POTFILES.in Sun Apr 13 16:55:27 2008
@@ -95,3 +95,5 @@
src/burn-volume-obj.c
src/plugins/checksum/burn-checksum-files.c
src/plugins/checksum/burn-checksum-image.c
+src/brasero-jacket-background.c
+src/brasero-jacket-view.c
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Sun Apr 13 16:55:27 2008
@@ -241,7 +241,17 @@
scsi-mech-status.c \
scsi-mech-status.h \
burn-volume-read.h \
- burn-volume-read.c
+ burn-volume-read.c \
+ brasero-jacket-background.c \
+ brasero-jacket-background.h \
+ brasero-jacket-buffer.c \
+ brasero-jacket-buffer.h \
+ brasero-jacket-edit.c \
+ brasero-jacket-edit.h \
+ brasero-jacket-font.c \
+ brasero-jacket-font.h \
+ brasero-jacket-view.c \
+ brasero-jacket-view.h
if BUILD_INOTIFY
brasero_SOURCES += brasero-file-monitor.c brasero-file-monitor.h
Added: trunk/src/brasero-jacket-background.c
==============================================================================
--- (empty file)
+++ trunk/src/brasero-jacket-background.c Sun Apr 13 16:55:27 2008
@@ -0,0 +1,305 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * brasero
+ * Copyright (C) Philippe Rouquier 2008 <bonfire-app wanadoo fr>
+ *
+ * brasero is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * brasero is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <glib.h>
+#include <glib/gi18n-lib.h>
+
+#include <gtk/gtk.h>
+
+#include "brasero-jacket-background.h"
+
+typedef struct _BraseroJacketBackgroundPrivate BraseroJacketBackgroundPrivate;
+struct _BraseroJacketBackgroundPrivate
+{
+ gchar *path;
+
+ GtkWidget *image;
+ GtkWidget *image_style;
+
+ GtkWidget *color;
+ GtkWidget *color2;
+ GtkWidget *color_style;
+};
+
+#define BRASERO_JACKET_BACKGROUND_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_JACKET_BACKGROUND, BraseroJacketBackgroundPrivate))
+
+
+
+G_DEFINE_TYPE (BraseroJacketBackground, brasero_jacket_background, GTK_TYPE_DIALOG);
+
+BraseroJacketColorStyle
+brasero_jacket_background_get_color_style (BraseroJacketBackground *self)
+{
+ BraseroJacketBackgroundPrivate *priv;
+
+ priv = BRASERO_JACKET_BACKGROUND_PRIVATE (self);
+ return gtk_combo_box_get_active (GTK_COMBO_BOX (priv->color_style));
+}
+
+BraseroJacketImageStyle
+brasero_jacket_background_get_image_style (BraseroJacketBackground *self)
+{
+ BraseroJacketBackgroundPrivate *priv;
+
+ priv = BRASERO_JACKET_BACKGROUND_PRIVATE (self);
+ return gtk_combo_box_get_active (GTK_COMBO_BOX (priv->image_style));
+}
+
+gchar *
+brasero_jacket_background_get_image_path (BraseroJacketBackground *self)
+{
+ BraseroJacketBackgroundPrivate *priv;
+
+ priv = BRASERO_JACKET_BACKGROUND_PRIVATE (self);
+ return gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (priv->image));
+}
+
+void
+brasero_jacket_background_set_color_style (BraseroJacketBackground *self,
+ BraseroJacketColorStyle style)
+{
+ BraseroJacketBackgroundPrivate *priv;
+
+ priv = BRASERO_JACKET_BACKGROUND_PRIVATE (self);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (priv->color_style), style);
+}
+
+void
+brasero_jacket_background_get_color (BraseroJacketBackground *self,
+ GdkColor *color,
+ GdkColor *color2)
+{
+ BraseroJacketBackgroundPrivate *priv;
+
+ priv = BRASERO_JACKET_BACKGROUND_PRIVATE (self);
+ gtk_color_button_get_color (GTK_COLOR_BUTTON (priv->color), color);
+ gtk_color_button_get_color (GTK_COLOR_BUTTON (priv->color2), color2);
+}
+
+void
+brasero_jacket_background_set_image_style (BraseroJacketBackground *self,
+ BraseroJacketImageStyle style)
+{
+ BraseroJacketBackgroundPrivate *priv;
+
+ priv = BRASERO_JACKET_BACKGROUND_PRIVATE (self);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (priv->image_style), style);
+}
+
+void
+brasero_jacket_background_set_image_path (BraseroJacketBackground *self,
+ const gchar *path)
+{
+ BraseroJacketBackgroundPrivate *priv;
+
+ if (!path)
+ return;
+
+ priv = BRASERO_JACKET_BACKGROUND_PRIVATE (self);
+ gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (priv->image), path);
+}
+
+void
+brasero_jacket_background_set_color (BraseroJacketBackground *self,
+ GdkColor *color,
+ GdkColor *color2)
+{
+ BraseroJacketBackgroundPrivate *priv;
+
+ priv = BRASERO_JACKET_BACKGROUND_PRIVATE (self);
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (priv->color), color);
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (priv->color2), color2);
+}
+
+static void
+brasero_jacket_background_color_type_changed_cb (GtkComboBox *combo,
+ BraseroJacketBackground *self)
+{
+ BraseroJacketBackgroundPrivate *priv;
+
+ priv = BRASERO_JACKET_BACKGROUND_PRIVATE (self);
+
+ if (gtk_combo_box_get_active (combo) == BRASERO_JACKET_COLOR_SOLID) {
+ gtk_widget_hide (priv->color2);
+ return;
+ }
+
+ gtk_widget_show (priv->color2);
+}
+
+static void
+brasero_jacket_background_add_filters (BraseroJacketBackground *self)
+{
+ BraseroJacketBackgroundPrivate *priv;
+ GtkFileFilter *filter;
+
+ priv = BRASERO_JACKET_BACKGROUND_PRIVATE (self);
+
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_add_pixbuf_formats (filter);
+ gtk_file_filter_set_name (filter, _("Images"));
+ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (priv->image), filter);
+}
+
+static void
+brasero_jacket_background_init (BraseroJacketBackground *object)
+{
+ BraseroJacketBackgroundPrivate *priv;
+ GtkWidget *combo;
+ GtkWidget *hbox2;
+ GtkWidget *label;
+ GtkWidget *vbox2;
+ GtkWidget *vbox;
+ GtkWidget *hbox;
+
+ priv = BRASERO_JACKET_BACKGROUND_PRIVATE (object);
+
+ vbox = gtk_vbox_new (FALSE, 12);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
+ gtk_widget_show (vbox);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (object)->vbox), vbox, TRUE, TRUE, 0);
+
+ label = gtk_label_new_with_mnemonic (_("<b>_Image</b>"));
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
+
+ hbox = gtk_hbox_new (FALSE, 0);
+ gtk_widget_show (hbox);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
+
+ label = gtk_label_new ("\t");
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ vbox2 = gtk_vbox_new (FALSE, 6);
+ gtk_widget_show (vbox2);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0);
+
+ hbox2 = gtk_hbox_new (FALSE, 12);
+ gtk_widget_show (hbox2);
+ gtk_box_pack_start (GTK_BOX (vbox2), hbox2, TRUE, TRUE, 0);
+
+ label = gtk_label_new (_("Image path:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, TRUE, 0);
+
+ priv->image = gtk_file_chooser_button_new (_("Choose an image"), GTK_FILE_CHOOSER_ACTION_OPEN);
+ gtk_widget_show (priv->image);
+ gtk_box_pack_start (GTK_BOX (hbox2), priv->image, TRUE, TRUE, 0);
+
+ hbox2 = gtk_hbox_new (FALSE, 12);
+ gtk_widget_show (hbox2);
+ gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, TRUE, 0);
+
+ label = gtk_label_new (_("Image style:"));
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, TRUE, 0);
+
+ combo = gtk_combo_box_new_text ();
+ priv->image_style = combo;
+ gtk_widget_show (combo);
+ gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Centered"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Tiled"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Scaled"));
+ gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
+ gtk_box_pack_start (GTK_BOX (hbox2), combo, FALSE, TRUE, 0);
+
+ label = gtk_label_new_with_mnemonic (_("<b>_Color</b>"));
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, TRUE, 0);
+
+ hbox = gtk_hbox_new (FALSE, 0);
+ gtk_widget_show (hbox);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
+
+ label = gtk_label_new ("\t");
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, TRUE, 0);
+
+ vbox2 = gtk_vbox_new (FALSE, 6);
+ gtk_widget_show (vbox2);
+ gtk_box_pack_start (GTK_BOX (hbox), vbox2, FALSE, TRUE, 0);
+
+ hbox2 = gtk_hbox_new (FALSE, 12);
+ gtk_widget_show (hbox2);
+ gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, TRUE, 0);
+
+ combo = gtk_combo_box_new_text ();
+ priv->color_style = combo;
+ gtk_widget_show (combo);
+ gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Solid color"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Horizontal gradient"));
+ gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Vertical gradient"));
+ gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0);
+ gtk_box_pack_start (GTK_BOX (hbox2), combo, FALSE, TRUE, 0);
+ g_signal_connect (combo,
+ "changed",
+ G_CALLBACK (brasero_jacket_background_color_type_changed_cb),
+ object);
+
+ priv->color = gtk_color_button_new ();
+ gtk_widget_show (priv->color);
+ gtk_box_pack_start (GTK_BOX (hbox2), priv->color, FALSE, TRUE, 0);
+
+ priv->color2 = gtk_color_button_new ();
+ gtk_box_pack_start (GTK_BOX (hbox2), priv->color2, FALSE, TRUE, 0);
+
+ gtk_dialog_add_button (GTK_DIALOG (object),
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
+
+ brasero_jacket_background_add_filters (object);
+ gtk_window_set_default_size (GTK_WINDOW (object), 400, 240);
+}
+
+static void
+brasero_jacket_background_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (brasero_jacket_background_parent_class)->finalize (object);
+}
+
+static void
+brasero_jacket_background_class_init (BraseroJacketBackgroundClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (BraseroJacketBackgroundPrivate));
+
+ object_class->finalize = brasero_jacket_background_finalize;
+}
+
+GtkWidget *
+brasero_jacket_background_new (void)
+{
+ return g_object_new (BRASERO_TYPE_JACKET_BACKGROUND,
+ "title", _("Background properties"),
+ NULL);
+}
+
Added: trunk/src/brasero-jacket-background.h
==============================================================================
--- (empty file)
+++ trunk/src/brasero-jacket-background.h Sun Apr 13 16:55:27 2008
@@ -0,0 +1,98 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * brasero
+ * Copyright (C) Philippe Rouquier 2008 <bonfire-app wanadoo fr>
+ *
+ * brasero is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * brasero is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _BRASERO_JACKET_BACKGROUND_H_
+#define _BRASERO_JACKET_BACKGROUND_H_
+
+#include <glib-object.h>
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+typedef enum {
+ BRASERO_JACKET_IMAGE_CENTER = 0,
+ BRASERO_JACKET_IMAGE_TILE,
+ BRASERO_JACKET_IMAGE_STRETCH
+} BraseroJacketImageStyle;
+
+typedef enum {
+ BRASERO_JACKET_COLOR_SOLID = 0,
+ BRASERO_JACKET_COLOR_HGRADIENT = 1,
+ BRASERO_JACKET_COLOR_VGRADIENT = 2
+} BraseroJacketColorStyle;
+
+#define BRASERO_TYPE_JACKET_BACKGROUND (brasero_jacket_background_get_type ())
+#define BRASERO_JACKET_BACKGROUND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BRASERO_TYPE_JACKET_BACKGROUND, BraseroJacketBackground))
+#define BRASERO_JACKET_BACKGROUND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BRASERO_TYPE_JACKET_BACKGROUND, BraseroJacketBackgroundClass))
+#define BRASERO_IS_JACKET_BACKGROUND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BRASERO_TYPE_JACKET_BACKGROUND))
+#define BRASERO_IS_JACKET_BACKGROUND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BRASERO_TYPE_JACKET_BACKGROUND))
+#define BRASERO_JACKET_BACKGROUND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BRASERO_TYPE_JACKET_BACKGROUND, BraseroJacketBackgroundClass))
+
+typedef struct _BraseroJacketBackgroundClass BraseroJacketBackgroundClass;
+typedef struct _BraseroJacketBackground BraseroJacketBackground;
+
+struct _BraseroJacketBackgroundClass
+{
+ GtkDialogClass parent_class;
+};
+
+struct _BraseroJacketBackground
+{
+ GtkDialog parent_instance;
+};
+
+GType brasero_jacket_background_get_type (void) G_GNUC_CONST;
+
+GtkWidget *
+brasero_jacket_background_new (void);
+
+BraseroJacketColorStyle
+brasero_jacket_background_get_color_style (BraseroJacketBackground *back);
+
+BraseroJacketImageStyle
+brasero_jacket_background_get_image_style (BraseroJacketBackground *back);
+
+gchar *
+brasero_jacket_background_get_image_path (BraseroJacketBackground *back);
+
+void
+brasero_jacket_background_get_color (BraseroJacketBackground *back,
+ GdkColor *color,
+ GdkColor *color2);
+
+void
+brasero_jacket_background_set_color_style (BraseroJacketBackground *back,
+ BraseroJacketColorStyle style);
+
+void
+brasero_jacket_background_set_image_style (BraseroJacketBackground *back,
+ BraseroJacketImageStyle style);
+
+void
+brasero_jacket_background_set_image_path (BraseroJacketBackground *back,
+ const gchar *path);
+
+void
+brasero_jacket_background_set_color (BraseroJacketBackground *back,
+ GdkColor *color,
+ GdkColor *color2);
+G_END_DECLS
+
+#endif /* _BRASERO_JACKET_BACKGROUND_H_ */
Added: trunk/src/brasero-jacket-buffer.c
==============================================================================
--- (empty file)
+++ trunk/src/brasero-jacket-buffer.c Sun Apr 13 16:55:27 2008
@@ -0,0 +1,255 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * brasero
+ * Copyright (C) Philippe Rouquier 2008 <bonfire-app wanadoo fr>
+ *
+ * brasero is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * brasero is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gtk/gtk.h>
+
+#include "brasero-jacket-buffer.h"
+
+typedef struct _BraseroJacketBufferPrivate BraseroJacketBufferPrivate;
+struct _BraseroJacketBufferPrivate
+{
+ GSList *tags;
+
+ guint pos;
+
+ gchar *default_text;
+
+ guint inserting_text:1;
+ guint empty:1;
+};
+
+#define BRASERO_JACKET_BUFFER_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_JACKET_BUFFER, BraseroJacketBufferPrivate))
+
+#define BRASERO_JACKET_BUFFER_TAG "jacket-buffer-tag"
+
+G_DEFINE_TYPE (BraseroJacketBuffer, brasero_jacket_buffer, GTK_TYPE_TEXT_BUFFER);
+
+gchar *
+brasero_jacket_buffer_get_text (BraseroJacketBuffer *self,
+ GtkTextIter *start,
+ GtkTextIter *end,
+ gboolean invisible_chars,
+ gboolean get_default_text)
+{
+ BraseroJacketBufferPrivate *priv;
+
+ priv = BRASERO_JACKET_BUFFER_PRIVATE (self);
+ if (priv->empty && !get_default_text)
+ return NULL;
+
+ return gtk_text_buffer_get_text (GTK_TEXT_BUFFER (self), start, end, invisible_chars);
+}
+
+void
+brasero_jacket_buffer_add_default_tag (BraseroJacketBuffer *self,
+ GtkTextTag *tag)
+{
+ BraseroJacketBufferPrivate *priv;
+
+ priv = BRASERO_JACKET_BUFFER_PRIVATE (self);
+ priv->tags = g_slist_prepend (priv->tags, tag);
+}
+
+static void
+brasero_jacket_buffer_cursor_position_changed_cb (GObject *buffer,
+ GParamSpec *spec,
+ gpointer NULL_data)
+{
+ BraseroJacketBufferPrivate *priv;
+ GtkTextIter iter;
+ guint pos;
+
+ priv = BRASERO_JACKET_BUFFER_PRIVATE (buffer);
+
+ if (priv->inserting_text)
+ return;
+
+ g_object_get (buffer,
+ "cursor-position", &pos,
+ NULL);
+
+ if (priv->pos == pos)
+ return;
+
+ if (pos)
+ gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (buffer), &iter, pos - 1);
+ else
+ gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (buffer), &iter, pos);
+
+ g_slist_free (priv->tags);
+ priv->tags = gtk_text_iter_get_tags (&iter);
+}
+
+static void
+brasero_jacket_buffer_insert_text (GtkTextBuffer *buffer,
+ GtkTextIter *location,
+ const gchar *text,
+ gint length)
+{
+ GtkTextIter end;
+ GSList *tag_iter;
+ GtkTextIter start;
+ guint start_offset;
+ BraseroJacketBufferPrivate *priv;
+
+ priv = BRASERO_JACKET_BUFFER_PRIVATE (buffer);
+
+ start_offset = gtk_text_iter_get_offset (location);
+ priv->inserting_text = TRUE;
+
+ GTK_TEXT_BUFFER_CLASS (brasero_jacket_buffer_parent_class)->insert_text (buffer, location, text, length);
+
+ priv->inserting_text = FALSE;
+ gtk_text_buffer_get_iter_at_offset (buffer, &start, start_offset);
+ end = *location;
+
+ /* apply tags */
+ for (tag_iter = priv->tags; tag_iter; tag_iter = tag_iter->next) {
+ GtkTextTag *tag;
+
+ tag = tag_iter->data;
+ gtk_text_buffer_apply_tag (buffer, tag,
+ &start,
+ &end);
+ }
+}
+
+void
+brasero_jacket_buffer_show_default_text (BraseroJacketBuffer *self,
+ gboolean show)
+{
+ BraseroJacketBufferPrivate *priv;
+ GtkTextIter start, end;
+
+ priv = BRASERO_JACKET_BUFFER_PRIVATE (self);
+
+ if (show) {
+ if (gtk_text_buffer_get_char_count (GTK_TEXT_BUFFER (self)))
+ return;
+
+ gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER (self), &start);
+ GTK_TEXT_BUFFER_CLASS (brasero_jacket_buffer_parent_class)->insert_text (GTK_TEXT_BUFFER (self), &start, priv->default_text, -1);
+
+ gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER (self), &start);
+ gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (self), &end);
+ gtk_text_buffer_apply_tag_by_name (GTK_TEXT_BUFFER (self),
+ BRASERO_JACKET_BUFFER_TAG,
+ &start, &end);
+ priv->empty = 1;
+ }
+ else if (priv->empty) {
+ gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER (self), &start);
+ gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (self), &end);
+ gtk_text_buffer_remove_all_tags (GTK_TEXT_BUFFER (self), &start, &end);
+
+ gtk_text_buffer_set_text (GTK_TEXT_BUFFER (self), "", -1);
+ priv->empty = 0;
+ }
+}
+
+void
+brasero_jacket_buffer_set_default_text (BraseroJacketBuffer *self,
+ const gchar *default_text)
+{
+ BraseroJacketBufferPrivate *priv;
+ GtkTextIter start, end;
+ GtkTextTagTable *table;
+
+ priv = BRASERO_JACKET_BUFFER_PRIVATE (self);
+
+ table = gtk_text_buffer_get_tag_table (GTK_TEXT_BUFFER (self));
+ if (!gtk_text_tag_table_lookup (table, BRASERO_JACKET_BUFFER_TAG))
+ gtk_text_buffer_create_tag (GTK_TEXT_BUFFER (self),
+ BRASERO_JACKET_BUFFER_TAG,
+ "foreground", "grey",
+ "justification", GTK_JUSTIFY_CENTER,
+ "stretch", PANGO_STRETCH_EXPANDED,
+ NULL);
+
+ if (priv->default_text) {
+ g_free (priv->default_text);
+ priv->default_text = NULL;
+ }
+
+ if (!default_text)
+ return;
+
+ priv->default_text = g_strdup (default_text);
+
+ if (gtk_text_buffer_get_char_count (GTK_TEXT_BUFFER (self)))
+ return;
+
+ gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER (self), &start);
+ GTK_TEXT_BUFFER_CLASS (brasero_jacket_buffer_parent_class)->insert_text (GTK_TEXT_BUFFER (self), &start, default_text, -1);
+
+ gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER (self), &start);
+ gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (self), &end);
+ gtk_text_buffer_apply_tag_by_name (GTK_TEXT_BUFFER (self),
+ BRASERO_JACKET_BUFFER_TAG,
+ &start, &end);
+}
+
+static void
+brasero_jacket_buffer_init (BraseroJacketBuffer *object)
+{
+ BraseroJacketBufferPrivate *priv;
+
+ priv = BRASERO_JACKET_BUFFER_PRIVATE (object);
+
+ priv->empty = 1;
+ g_signal_connect (object,
+ "notify::cursor-position",
+ G_CALLBACK (brasero_jacket_buffer_cursor_position_changed_cb),
+ NULL);
+}
+
+static void
+brasero_jacket_buffer_finalize (GObject *object)
+{
+ BraseroJacketBufferPrivate *priv;
+
+ priv = BRASERO_JACKET_BUFFER_PRIVATE (object);
+
+ if (priv->default_text) {
+ g_free (priv->default_text);
+ priv->default_text = NULL;
+ }
+
+ G_OBJECT_CLASS (brasero_jacket_buffer_parent_class)->finalize (object);
+}
+
+static void
+brasero_jacket_buffer_class_init (BraseroJacketBufferClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+ GtkTextBufferClass* parent_class = GTK_TEXT_BUFFER_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (BraseroJacketBufferPrivate));
+
+ object_class->finalize = brasero_jacket_buffer_finalize;
+
+ parent_class->insert_text = brasero_jacket_buffer_insert_text;
+}
+
+BraseroJacketBuffer *
+brasero_jacket_buffer_new (void)
+{
+ return g_object_new (BRASERO_TYPE_JACKET_BUFFER, NULL);
+}
+
Added: trunk/src/brasero-jacket-buffer.h
==============================================================================
--- (empty file)
+++ trunk/src/brasero-jacket-buffer.h Sun Apr 13 16:55:27 2008
@@ -0,0 +1,75 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * brasero
+ * Copyright (C) Philippe Rouquier 2008 <bonfire-app wanadoo fr>
+ *
+ * brasero is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * brasero is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _BRASERO_JACKET_BUFFER_H_
+#define _BRASERO_JACKET_BUFFER_H_
+
+#include <glib-object.h>
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define BRASERO_TYPE_JACKET_BUFFER (brasero_jacket_buffer_get_type ())
+#define BRASERO_JACKET_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BRASERO_TYPE_JACKET_BUFFER, BraseroJacketBuffer))
+#define BRASERO_JACKET_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BRASERO_TYPE_JACKET_BUFFER, BraseroJacketBufferClass))
+#define BRASERO_IS_JACKET_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BRASERO_TYPE_JACKET_BUFFER))
+#define BRASERO_IS_JACKET_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BRASERO_TYPE_JACKET_BUFFER))
+#define BRASERO_JACKET_BUFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BRASERO_TYPE_JACKET_BUFFER, BraseroJacketBufferClass))
+
+typedef struct _BraseroJacketBufferClass BraseroJacketBufferClass;
+typedef struct _BraseroJacketBuffer BraseroJacketBuffer;
+
+struct _BraseroJacketBufferClass
+{
+ GtkTextBufferClass parent_class;
+};
+
+struct _BraseroJacketBuffer
+{
+ GtkTextBuffer parent_instance;
+};
+
+GType brasero_jacket_buffer_get_type (void) G_GNUC_CONST;
+
+BraseroJacketBuffer *
+brasero_jacket_buffer_new (void);
+
+void
+brasero_jacket_buffer_add_default_tag (BraseroJacketBuffer *buffer,
+ GtkTextTag *tag);
+
+void
+brasero_jacket_buffer_set_default_text (BraseroJacketBuffer *self,
+ const gchar *default_text);
+
+void
+brasero_jacket_buffer_show_default_text (BraseroJacketBuffer *self,
+ gboolean show);
+
+gchar *
+brasero_jacket_buffer_get_text (BraseroJacketBuffer *self,
+ GtkTextIter *start,
+ GtkTextIter *end,
+ gboolean invisible_chars,
+ gboolean get_default_text);
+
+G_END_DECLS
+
+#endif /* _BRASERO_JACKET_BUFFER_H_ */
Added: trunk/src/brasero-jacket-edit.c
==============================================================================
--- (empty file)
+++ trunk/src/brasero-jacket-edit.c Sun Apr 13 16:55:27 2008
@@ -0,0 +1,728 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * brasero
+ * Copyright (C) Rouquier Philippe 2008 <bonfire-app wanadoo fr>
+ *
+ * brasero is free software.
+ *
+ * You may redistribute it and/or modify it under the terms of the
+ * GNU General Public License, as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * brasero is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with brasero. If not, write to:
+ * The Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <glib.h>
+#include <glib/gi18n-lib.h>
+
+#include <gtk/gtk.h>
+
+#include "brasero-jacket-edit.h"
+#include "brasero-jacket-buffer.h"
+#include "brasero-jacket-view.h"
+#include "brasero-jacket-font.h"
+
+typedef struct _BraseroJacketEditPrivate BraseroJacketEditPrivate;
+struct _BraseroJacketEditPrivate
+{
+ GtkWidget *current_view;
+ GtkWidget *front;
+ GtkWidget *back;
+
+ GtkWidget *fonts;
+ GtkWidget *colours;
+
+ GtkWidget *center;
+ GtkWidget *right;
+ GtkWidget *left;
+
+ GtkWidget *underline;
+ GtkWidget *italic;
+ GtkWidget *bold;
+};
+
+#define BRASERO_JACKET_EDIT_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_JACKET_EDIT, BraseroJacketEditPrivate))
+
+enum {
+ SNAP_PIX_COL,
+ SNAP_TEXT_COL,
+ SNAP_TOOLTIP_COL,
+ SNAP_WIDGET_COL,
+ SNAP_NUM_COL
+};
+
+
+G_DEFINE_TYPE (BraseroJacketEdit, brasero_jacket_edit, GTK_TYPE_VBOX);
+
+static void
+brasero_jacket_edit_print_page (GtkPrintOperation *operation,
+ GtkPrintContext *context,
+ gint page_num,
+ BraseroJacketEdit *self)
+{
+ BraseroJacketEditPrivate *priv;
+/* cairo_surface_t *surface;
+ guint height, width;
+ cairo_t *ctx;*/
+ guint y;
+
+ priv = BRASERO_JACKET_EDIT_PRIVATE (self);
+
+/* ctx = gtk_print_context_get_cairo_context (context); */
+
+ /* front */
+/* surface = brasero_jacket_view_snapshot (BRASERO_JACKET_VIEW (priv->front),
+ gtk_print_context_get_dpi_x (context));
+
+ width = cairo_image_surface_get_width (surface);
+ height = cairo_image_surface_get_height (surface);
+ cairo_rectangle (ctx,
+ 0, 0,
+ width, height);
+ cairo_clip (ctx);
+
+ cairo_set_source_surface (ctx, surface, 0, 0);
+ cairo_paint (ctx);
+
+ cairo_surface_destroy (surface);*/
+
+ /* back */
+/* surface = brasero_jacket_view_snapshot (BRASERO_JACKET_VIEW (priv->back),
+ gtk_print_context_get_dpi_x (context));
+
+ y = height + 20;
+
+ cairo_reset_clip (ctx);
+ width = cairo_image_surface_get_width (surface);
+ height = cairo_image_surface_get_height (surface);
+ cairo_rectangle (ctx,
+ 0, y,
+ width, height);
+ cairo_clip (ctx);
+
+ cairo_set_source_surface (ctx, surface, 0, y);
+ cairo_paint (ctx);
+
+ cairo_surface_destroy (surface);
+
+ */
+ y = brasero_jacket_view_print (BRASERO_JACKET_VIEW (priv->front), context, 0, 0);
+ brasero_jacket_view_print (BRASERO_JACKET_VIEW (priv->back), context, 0, y + 20);
+}
+
+static void
+brasero_jacket_edit_print_begin (GtkPrintOperation *operation,
+ GtkPrintContext *context,
+ BraseroJacketEdit *self)
+{
+ gtk_print_operation_set_n_pages (operation, 1);
+}
+
+static void
+brasero_jacket_edit_print_pressed_cb (GtkButton *button,
+ BraseroJacketEdit *self)
+{
+ BraseroJacketEditPrivate *priv;
+ GtkPrintOperation *print;
+
+ priv = BRASERO_JACKET_EDIT_PRIVATE (self);
+ print = gtk_print_operation_new ();
+ g_signal_connect (print,
+ "draw-page",
+ G_CALLBACK (brasero_jacket_edit_print_page),
+ self);
+ g_signal_connect (print,
+ "begin-print",
+ G_CALLBACK (brasero_jacket_edit_print_begin),
+ self);
+ gtk_print_operation_run (print,
+ GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
+ GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))),
+ NULL);
+}
+
+static void
+brasero_jacket_edit_underline_pressed_cb (GtkToggleToolButton *button,
+ BraseroJacketEdit *self)
+{
+ BraseroJacketEditPrivate *priv;
+ GtkTextBuffer *buffer;
+ GtkTextIter start;
+ GtkTextIter end;
+ GtkTextTag *tag;
+
+ priv = BRASERO_JACKET_EDIT_PRIVATE (self);
+
+ if (!priv->current_view)
+ return;
+
+ buffer = brasero_jacket_view_get_active_buffer (BRASERO_JACKET_VIEW (priv->current_view));
+ tag = gtk_text_buffer_create_tag (buffer, NULL,
+ "underline", gtk_toggle_tool_button_get_active (button) ? PANGO_UNDERLINE_SINGLE:PANGO_UNDERLINE_NONE,
+ NULL);
+
+ if (gtk_text_buffer_get_has_selection (buffer)) {
+ gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
+ gtk_text_buffer_apply_tag (buffer, tag, &start, &end);
+ }
+ else
+ brasero_jacket_buffer_add_default_tag (BRASERO_JACKET_BUFFER (buffer), tag);
+}
+
+static void
+brasero_jacket_edit_italic_pressed_cb (GtkToggleToolButton *button,
+ BraseroJacketEdit *self)
+{
+ BraseroJacketEditPrivate *priv;
+ GtkTextBuffer *buffer;
+ GtkTextIter start;
+ GtkTextIter end;
+ GtkTextTag *tag;
+
+ priv = BRASERO_JACKET_EDIT_PRIVATE (self);
+
+ if (!priv->current_view)
+ return;
+
+ buffer = brasero_jacket_view_get_active_buffer (BRASERO_JACKET_VIEW (priv->current_view));
+ tag = gtk_text_buffer_create_tag (buffer, NULL,
+ "style", gtk_toggle_tool_button_get_active (button) ? PANGO_STYLE_ITALIC:PANGO_STYLE_NORMAL,
+ NULL);
+
+ if (gtk_text_buffer_get_has_selection (buffer)) {
+ gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
+ gtk_text_buffer_apply_tag (buffer, tag, &start, &end);
+ }
+ else
+ brasero_jacket_buffer_add_default_tag (BRASERO_JACKET_BUFFER (buffer), tag);
+}
+
+static void
+brasero_jacket_edit_bold_pressed_cb (GtkToggleToolButton *button,
+ BraseroJacketEdit *self)
+{
+ BraseroJacketEditPrivate *priv;
+ GtkTextBuffer *buffer;
+ GtkTextIter start;
+ GtkTextIter end;
+ GtkTextTag *tag;
+
+ priv = BRASERO_JACKET_EDIT_PRIVATE (self);
+
+ if (!priv->current_view)
+ return;
+
+ buffer = brasero_jacket_view_get_active_buffer (BRASERO_JACKET_VIEW (priv->current_view));
+ tag = gtk_text_buffer_create_tag (buffer, NULL,
+ "weight", gtk_toggle_tool_button_get_active (button) ? PANGO_WEIGHT_BOLD:PANGO_WEIGHT_NORMAL,
+ NULL);
+
+ if (gtk_text_buffer_get_has_selection (buffer)) {
+ gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
+ gtk_text_buffer_apply_tag (buffer, tag, &start, &end);
+ }
+ else
+ brasero_jacket_buffer_add_default_tag (BRASERO_JACKET_BUFFER (buffer), tag);
+}
+
+static void
+brasero_jacket_edit_center_pressed_cb (GtkToggleToolButton *button,
+ BraseroJacketEdit *self)
+{
+ BraseroJacketEditPrivate *priv;
+ GtkTextBuffer *buffer;
+ GtkTextIter start;
+ GtkTextIter end;
+ GtkTextTag *tag;
+
+ priv = BRASERO_JACKET_EDIT_PRIVATE (self);
+
+ if (!gtk_toggle_tool_button_get_active (button))
+ return;
+
+ if (!priv->current_view)
+ return;
+
+ buffer = brasero_jacket_view_get_active_buffer (BRASERO_JACKET_VIEW (priv->current_view));
+ tag = gtk_text_buffer_create_tag (buffer, NULL,
+ "justification", GTK_JUSTIFY_CENTER,
+ NULL);
+
+ if (!gtk_text_buffer_get_has_selection (buffer)) {
+ GtkTextMark *mark;
+
+ mark = gtk_text_buffer_get_insert (buffer);
+ gtk_text_buffer_get_iter_at_mark (buffer, &start, mark);
+ gtk_text_buffer_get_iter_at_mark (buffer, &end, mark);
+ brasero_jacket_buffer_add_default_tag (BRASERO_JACKET_BUFFER (buffer), tag);
+ }
+ else
+ gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
+
+
+ gtk_text_iter_set_line_index (&start, 0);
+ gtk_text_iter_forward_to_line_end (&end);
+ gtk_text_buffer_apply_tag (buffer, tag, &start, &end);
+}
+
+static void
+brasero_jacket_edit_right_pressed_cb (GtkToggleToolButton *button,
+ BraseroJacketEdit *self)
+{
+ BraseroJacketEditPrivate *priv;
+ GtkTextBuffer *buffer;
+ GtkTextIter start;
+ GtkTextIter end;
+ GtkTextTag *tag;
+
+ priv = BRASERO_JACKET_EDIT_PRIVATE (self);
+ if (!priv->current_view)
+ return;
+
+ if (!gtk_toggle_tool_button_get_active (button))
+ return;
+
+ buffer = brasero_jacket_view_get_active_buffer (BRASERO_JACKET_VIEW (priv->current_view));
+ tag = gtk_text_buffer_create_tag (buffer, NULL,
+ "justification", GTK_JUSTIFY_RIGHT,
+ NULL);
+
+ if (!gtk_text_buffer_get_has_selection (buffer)) {
+ GtkTextMark *mark;
+
+ mark = gtk_text_buffer_get_insert (buffer);
+ gtk_text_buffer_get_iter_at_mark (buffer, &start, mark);
+ gtk_text_buffer_get_iter_at_mark (buffer, &end, mark);
+ brasero_jacket_buffer_add_default_tag (BRASERO_JACKET_BUFFER (buffer), tag);
+ }
+ else
+ gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
+
+
+ gtk_text_iter_set_line_index (&start, 0);
+ gtk_text_iter_forward_to_line_end (&end);
+ gtk_text_buffer_apply_tag (buffer, tag, &start, &end);
+}
+
+static void
+brasero_jacket_edit_left_pressed_cb (GtkToggleToolButton *button,
+ BraseroJacketEdit *self)
+{
+ BraseroJacketEditPrivate *priv;
+ GtkTextBuffer *buffer;
+ GtkTextIter start;
+ GtkTextIter end;
+ GtkTextTag *tag;
+
+ priv = BRASERO_JACKET_EDIT_PRIVATE (self);
+ if (!priv->current_view)
+ return;
+
+ if (!gtk_toggle_tool_button_get_active (button))
+ return;
+
+ buffer = brasero_jacket_view_get_active_buffer (BRASERO_JACKET_VIEW (priv->current_view));
+ tag = gtk_text_buffer_create_tag (buffer, NULL,
+ "justification", GTK_JUSTIFY_LEFT,
+ NULL);
+
+ if (!gtk_text_buffer_get_has_selection (buffer)) {
+ GtkTextMark *mark;
+
+ mark = gtk_text_buffer_get_insert (buffer);
+ gtk_text_buffer_get_iter_at_mark (buffer, &start, mark);
+ gtk_text_buffer_get_iter_at_mark (buffer, &end, mark);
+ brasero_jacket_buffer_add_default_tag (BRASERO_JACKET_BUFFER (buffer), tag);
+ }
+ else
+ gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
+
+ gtk_text_iter_set_line_index (&start, 0);
+ gtk_text_iter_forward_to_line_end (&end);
+ gtk_text_buffer_apply_tag (buffer, tag, &start, &end);
+}
+
+static void
+brasero_jacket_edit_colours_changed_cb (GtkColorButton *button,
+ BraseroJacketEdit *self)
+{
+ BraseroJacketEditPrivate *priv;
+ GtkTextBuffer *buffer;
+ GtkTextIter start;
+ GtkTextIter end;
+ GdkColor color;
+ GtkTextTag *tag;
+
+ priv = BRASERO_JACKET_EDIT_PRIVATE (self);
+ if (!priv->current_view)
+ return;
+
+ gtk_color_button_get_color (button, &color);
+
+ buffer = brasero_jacket_view_get_active_buffer (BRASERO_JACKET_VIEW (priv->current_view));
+ tag = gtk_text_buffer_create_tag (buffer, NULL,
+ "foreground-gdk", &color,
+ NULL);
+ if (!gtk_text_buffer_get_has_selection (buffer)) {
+ brasero_jacket_buffer_add_default_tag (BRASERO_JACKET_BUFFER (buffer), tag);
+ return;
+ }
+
+ gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
+ gtk_text_buffer_apply_tag (buffer, tag, &start, &end);
+}
+
+static void
+brasero_jacket_edit_font_changed_cb (BraseroJacketFont *button,
+ BraseroJacketEdit *self)
+{
+ BraseroJacketEditPrivate *priv;
+ PangoFontDescription *desc;
+ const gchar *font_name;
+ GtkTextBuffer *buffer;
+ GtkTextIter start;
+ GtkTextIter end;
+ GtkTextTag *tag;
+
+ priv = BRASERO_JACKET_EDIT_PRIVATE (self);
+
+ if (!priv->current_view)
+ return;
+
+ font_name = brasero_jacket_font_get_name (button);
+ if (!font_name)
+ return;
+
+ desc = pango_font_description_from_string (font_name);
+
+ buffer = brasero_jacket_view_get_active_buffer (BRASERO_JACKET_VIEW (priv->current_view));
+ tag = gtk_text_buffer_create_tag (buffer, NULL,
+ "font-desc", desc,
+ NULL);
+
+ if (gtk_text_buffer_get_has_selection (buffer)) {
+ gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
+ gtk_text_buffer_apply_tag (buffer, tag, &start, &end);
+ }
+ else
+ brasero_jacket_buffer_add_default_tag (BRASERO_JACKET_BUFFER (buffer), tag);
+}
+
+static void
+brasero_jacket_edit_update_button_state (BraseroJacketEdit *self)
+{
+ gint pos;
+ GtkTextIter iter;
+ gchar *font_name;
+ GtkTextBuffer *buffer;
+ GtkTextAttributes *attributes;
+ BraseroJacketEditPrivate *priv;
+
+ priv = BRASERO_JACKET_EDIT_PRIVATE (self);
+
+ if (priv->current_view)
+ buffer = brasero_jacket_view_get_active_buffer (BRASERO_JACKET_VIEW (priv->current_view));
+ else
+ buffer = NULL;
+
+ if (!buffer)
+ return;
+
+ g_object_get (buffer,
+ "cursor-position", &pos,
+ NULL);
+
+ if (pos)
+ gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (buffer), &iter, pos - 1);
+ else
+ gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (buffer), &iter, pos);
+
+ attributes = brasero_jacket_view_get_default_attributes (BRASERO_JACKET_VIEW (priv->current_view));
+ gtk_text_iter_get_attributes (&iter, attributes);
+
+ gtk_color_button_set_color (GTK_COLOR_BUTTON (priv->colours), &attributes->appearance.fg_color);
+
+ font_name = pango_font_description_to_string (attributes->font);
+ brasero_jacket_font_set_name (BRASERO_JACKET_FONT (priv->fonts), font_name);
+ g_free (font_name);
+
+ g_signal_handlers_block_by_func (priv->bold,
+ brasero_jacket_edit_bold_pressed_cb,
+ self);
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (priv->bold),
+ (pango_font_description_get_weight (attributes->font) != PANGO_WEIGHT_NORMAL));
+ g_signal_handlers_unblock_by_func (priv->bold,
+ brasero_jacket_edit_bold_pressed_cb,
+ self);
+
+ g_signal_handlers_block_by_func (priv->italic,
+ brasero_jacket_edit_italic_pressed_cb,
+ self);
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (priv->italic),
+ (pango_font_description_get_style (attributes->font) == PANGO_STYLE_ITALIC));
+ g_signal_handlers_unblock_by_func (priv->italic,
+ brasero_jacket_edit_italic_pressed_cb,
+ self);
+
+ g_signal_handlers_block_by_func (priv->underline,
+ brasero_jacket_edit_underline_pressed_cb,
+ self);
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (priv->underline),
+ (attributes->appearance.underline != PANGO_UNDERLINE_NONE));
+ g_signal_handlers_unblock_by_func (priv->underline,
+ brasero_jacket_edit_underline_pressed_cb,
+ self);
+
+ g_signal_handlers_block_by_func (priv->right,
+ brasero_jacket_edit_right_pressed_cb,
+ self);
+ g_signal_handlers_block_by_func (priv->left,
+ brasero_jacket_edit_left_pressed_cb,
+ self);
+ g_signal_handlers_block_by_func (priv->center,
+ brasero_jacket_edit_center_pressed_cb,
+ self);
+ switch (attributes->justification) {
+ case GTK_JUSTIFY_CENTER:
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (priv->center), TRUE);
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (priv->right), FALSE);
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (priv->left), FALSE);
+ break;
+ case GTK_JUSTIFY_LEFT:
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (priv->center), FALSE);
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (priv->right), FALSE);
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (priv->left), TRUE);
+ break;
+ case GTK_JUSTIFY_RIGHT:
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (priv->center), FALSE);
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (priv->right), TRUE);
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (priv->left), FALSE);
+ break;
+ default:
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (priv->center), FALSE);
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (priv->right), TRUE);
+ gtk_toggle_tool_button_set_active (GTK_TOGGLE_TOOL_BUTTON (priv->left), FALSE);
+ break;
+ };
+ g_signal_handlers_unblock_by_func (priv->right,
+ brasero_jacket_edit_right_pressed_cb,
+ self);
+ g_signal_handlers_unblock_by_func (priv->left,
+ brasero_jacket_edit_left_pressed_cb,
+ self);
+ g_signal_handlers_unblock_by_func (priv->center,
+ brasero_jacket_edit_center_pressed_cb,
+ self);
+
+ gtk_text_attributes_unref (attributes);
+}
+
+static void
+brasero_jacket_edit_tags_changed_cb (BraseroJacketView *view,
+ BraseroJacketEdit *self)
+{
+ BraseroJacketEditPrivate *priv;
+
+ priv = BRASERO_JACKET_EDIT_PRIVATE (self);
+ priv->current_view = GTK_WIDGET (view);
+ brasero_jacket_edit_update_button_state (self);
+}
+
+static void
+brasero_jacket_edit_init (BraseroJacketEdit *object)
+{
+ BraseroJacketEditPrivate *priv;
+ GtkWidget *main_box;
+ GtkWidget *toolbar;
+ GtkWidget *scroll;
+ GtkWidget *vbox;
+ GtkWidget *item;
+ GtkWidget *view;
+
+ priv = BRASERO_JACKET_EDIT_PRIVATE (object);
+
+ /* Toolbar */
+ toolbar = gtk_toolbar_new ();
+ gtk_widget_show (toolbar);
+ gtk_box_pack_start (GTK_BOX (object), toolbar, FALSE, TRUE, 0);
+
+ item = GTK_WIDGET (gtk_tool_button_new_from_stock (GTK_STOCK_PRINT));
+ gtk_widget_show (item);
+ g_signal_connect (item,
+ "clicked",
+ G_CALLBACK (brasero_jacket_edit_print_pressed_cb),
+ object);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (item), 0);
+
+ item = GTK_WIDGET (gtk_radio_tool_button_new_from_stock (NULL, GTK_STOCK_JUSTIFY_RIGHT));
+ gtk_widget_show (item);
+ g_signal_connect (item,
+ "clicked",
+ G_CALLBACK (brasero_jacket_edit_right_pressed_cb),
+ object);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (item), 0);
+ priv->right = item;
+
+ item = GTK_WIDGET (gtk_radio_tool_button_new_from_stock (gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (priv->right)), GTK_STOCK_JUSTIFY_CENTER));
+ gtk_widget_show (item);
+ g_signal_connect (item,
+ "clicked",
+ G_CALLBACK (brasero_jacket_edit_center_pressed_cb),
+ object);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (item), 0);
+ priv->center = item;
+
+ item = GTK_WIDGET (gtk_radio_tool_button_new_from_stock (gtk_radio_tool_button_get_group (GTK_RADIO_TOOL_BUTTON (priv->right)), GTK_STOCK_JUSTIFY_LEFT));
+ gtk_widget_show (item);
+ g_signal_connect (item,
+ "clicked",
+ G_CALLBACK (brasero_jacket_edit_left_pressed_cb),
+ object);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (item), 0);
+ priv->left = item;
+
+ item = GTK_WIDGET (gtk_toggle_tool_button_new_from_stock (GTK_STOCK_UNDERLINE));
+ gtk_widget_show (item);
+ g_signal_connect (item,
+ "clicked",
+ G_CALLBACK (brasero_jacket_edit_underline_pressed_cb),
+ object);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (item), 0);
+ priv->underline = item;
+
+ item = GTK_WIDGET (gtk_toggle_tool_button_new_from_stock (GTK_STOCK_ITALIC));
+ gtk_widget_show (item);
+ g_signal_connect (item,
+ "clicked",
+ G_CALLBACK (brasero_jacket_edit_italic_pressed_cb),
+ object);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (item), 0);
+ priv->italic = item;
+
+ item = GTK_WIDGET (gtk_toggle_tool_button_new_from_stock (GTK_STOCK_BOLD));
+ gtk_widget_show (item);
+ g_signal_connect (item,
+ "clicked",
+ G_CALLBACK (brasero_jacket_edit_bold_pressed_cb),
+ object);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (item), 0);
+ priv->bold = item;
+
+ priv->fonts = brasero_jacket_font_new ();
+ gtk_widget_show (priv->fonts);
+ g_signal_connect (priv->fonts,
+ "font-changed",
+ G_CALLBACK (brasero_jacket_edit_font_changed_cb),
+ object);
+ g_signal_connect (priv->fonts,
+ "size-changed",
+ G_CALLBACK (brasero_jacket_edit_font_changed_cb),
+ object);
+
+ item = GTK_WIDGET (gtk_tool_item_new ());
+ gtk_widget_show (item);
+ gtk_container_add (GTK_CONTAINER (item), priv->fonts);
+ gtk_tool_item_set_expand (GTK_TOOL_ITEM (item), FALSE);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (item), 0);
+
+ priv->colours = gtk_color_button_new ();
+ gtk_button_set_focus_on_click (GTK_BUTTON (priv->colours), FALSE);
+ gtk_widget_show (priv->colours);
+ g_signal_connect (priv->colours,
+ "color-set",
+ G_CALLBACK (brasero_jacket_edit_colours_changed_cb),
+ object);
+
+ item = GTK_WIDGET (gtk_tool_item_new ());
+ gtk_widget_show (item);
+ gtk_container_add (GTK_CONTAINER (item), priv->colours);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (item), 1);
+
+ /* contents */
+ vbox = gtk_vbox_new (FALSE, 4);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
+ gtk_widget_show (vbox);
+ gtk_box_pack_start (GTK_BOX (object), vbox, TRUE, TRUE, 0);
+
+ scroll = gtk_scrolled_window_new (NULL, NULL);
+ gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
+ GTK_POLICY_AUTOMATIC,
+ GTK_POLICY_AUTOMATIC);
+ gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN);
+ gtk_widget_show (scroll);
+ gtk_box_pack_start (GTK_BOX (vbox), scroll, TRUE, TRUE, 0);
+
+ main_box = gtk_vbox_new (FALSE, 0);
+ gtk_widget_show (main_box);
+ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroll), main_box);
+
+ view = brasero_jacket_view_new ();
+ priv->front = view;
+ gtk_widget_show (view);
+ brasero_jacket_view_set_side (BRASERO_JACKET_VIEW (view), BRASERO_JACKET_FRONT);
+ g_signal_connect (view,
+ "tags-changed",
+ G_CALLBACK (brasero_jacket_edit_tags_changed_cb),
+ object);
+
+ gtk_box_pack_start (GTK_BOX (main_box), view, FALSE, FALSE, 0);
+
+ view = brasero_jacket_view_new ();
+ priv->back = view;
+ gtk_widget_show (view);
+ brasero_jacket_view_set_side (BRASERO_JACKET_VIEW (view), BRASERO_JACKET_BACK);
+
+ g_signal_connect (view,
+ "tags-changed",
+ G_CALLBACK (brasero_jacket_edit_tags_changed_cb),
+ object);
+
+ gtk_box_pack_start (GTK_BOX (main_box), view, FALSE, FALSE, 0);
+
+ if (pango_font_description_get_set_fields (priv->front->style->font_desc) & PANGO_FONT_MASK_SIZE) {
+ guint size;
+ gchar string [8] = { 0, };
+
+ size = pango_font_description_get_size (priv->front->style->font_desc);
+ sprintf (string, "%i", size);
+ brasero_jacket_font_set_name (BRASERO_JACKET_FONT (priv->fonts), "Sans 12");
+ }
+
+ gtk_widget_grab_focus (priv->front);
+}
+
+static void
+brasero_jacket_edit_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (brasero_jacket_edit_parent_class)->finalize (object);
+}
+
+static void
+brasero_jacket_edit_class_init (BraseroJacketEditClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (BraseroJacketEditPrivate));
+
+ object_class->finalize = brasero_jacket_edit_finalize;
+}
+
+GtkWidget *
+brasero_jacket_edit_new (void)
+{
+ return g_object_new (BRASERO_TYPE_JACKET_EDIT, NULL);
+}
Added: trunk/src/brasero-jacket-edit.h
==============================================================================
--- (empty file)
+++ trunk/src/brasero-jacket-edit.h Sun Apr 13 16:55:27 2008
@@ -0,0 +1,61 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * brasero
+ * Copyright (C) Rouquier Philippe 2008 <bonfire-app wanadoo fr>
+ *
+ * brasero is free software.
+ *
+ * You may redistribute it and/or modify it under the terms of the
+ * GNU General Public License, as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * brasero is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with brasero. If not, write to:
+ * The Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _BRASERO_JACKET_EDIT_H_
+#define _BRASERO_JACKET_EDIT_H_
+
+#include <glib-object.h>
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define BRASERO_TYPE_JACKET_EDIT (brasero_jacket_edit_get_type ())
+#define BRASERO_JACKET_EDIT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BRASERO_TYPE_JACKET_EDIT, BraseroJacketEdit))
+#define BRASERO_JACKET_EDIT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BRASERO_TYPE_JACKET_EDIT, BraseroJacketEditClass))
+#define BRASERO_IS_JACKET_EDIT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BRASERO_TYPE_JACKET_EDIT))
+#define BRASERO_IS_JACKET_EDIT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BRASERO_TYPE_JACKET_EDIT))
+#define BRASERO_JACKET_EDIT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BRASERO_TYPE_JACKET_EDIT, BraseroJacketEditClass))
+
+typedef struct _BraseroJacketEditClass BraseroJacketEditClass;
+typedef struct _BraseroJacketEdit BraseroJacketEdit;
+
+struct _BraseroJacketEditClass
+{
+ GtkVBoxClass parent_class;
+};
+
+struct _BraseroJacketEdit
+{
+ GtkVBox parent_instance;
+};
+
+GType brasero_jacket_edit_get_type (void) G_GNUC_CONST;
+
+GtkWidget *
+brasero_jacket_edit_new (void);
+
+G_END_DECLS
+
+#endif /* _BRASERO_JACKET_EDIT_H_ */
Added: trunk/src/brasero-jacket-font.c
==============================================================================
--- (empty file)
+++ trunk/src/brasero-jacket-font.c Sun Apr 13 16:55:27 2008
@@ -0,0 +1,364 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * brasero
+ * Copyright (C) Philippe Rouquier 2008 <bonfire-app wanadoo fr>
+ *
+ * brasero is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * brasero is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <string.h>
+
+#include <gtk/gtk.h>
+
+#include "brasero-jacket-font.h"
+
+typedef struct _BraseroJacketFontPrivate BraseroJacketFontPrivate;
+struct _BraseroJacketFontPrivate
+{
+ GtkWidget *family;
+ GtkWidget *size;
+
+ gint current_size;
+ gchar *current_family;
+};
+
+#define BRASERO_JACKET_FONT_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_JACKET_FONT, BraseroJacketFontPrivate))
+
+enum
+{
+ FONT_CHANGED,
+ SIZE_CHANGED,
+
+ LAST_SIGNAL
+};
+
+enum {
+ FAMILY_STRING_COL,
+ FAMILY_COL,
+ FAMILY_COL_NB
+};
+
+enum {
+ SIZE_STRING_COL,
+ SIZE_COL,
+ SIZE_COL_NB
+};
+
+static const guint16 font_sizes[] = {
+ 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 22, 24, 26, 28,
+ 32, 36, 40, 48, 56, 64, 72
+};
+
+static guint jacket_font_signals[LAST_SIGNAL] = { 0 };
+
+G_DEFINE_TYPE (BraseroJacketFont, brasero_jacket_font, GTK_TYPE_HBOX);
+
+static void
+brasero_jacket_font_family_changed_cb (GtkComboBox *combo,
+ BraseroJacketFont *self)
+{
+ g_signal_emit (self,
+ jacket_font_signals [FONT_CHANGED],
+ 0);
+}
+
+static void
+brasero_jacket_font_size_changed_cb (GtkComboBox *combo,
+ BraseroJacketFont *self)
+{
+ g_signal_emit (self,
+ jacket_font_signals [SIZE_CHANGED],
+ 0);
+}
+
+void
+brasero_jacket_font_set_name (BraseroJacketFont *self,
+ const gchar *string)
+{
+ BraseroJacketFontPrivate *priv;
+ PangoFontDescription *desc;
+ const gchar *family_name;
+ const gchar *name = NULL;
+ PangoFontFamily *family;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ guint font_size;
+ guint size;
+
+ priv = BRASERO_JACKET_FONT_PRIVATE (self);
+
+ desc = pango_font_description_from_string (string);
+ family_name = pango_font_description_get_family (desc);
+ font_size = pango_font_description_get_size (desc);
+
+ if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->family), &iter)) {
+ family = NULL;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->family));
+ gtk_tree_model_get (model, &iter,
+ FAMILY_COL, &family,
+ -1);
+ if (family)
+ name = pango_font_family_get_name (family);
+ }
+
+ if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->size), &iter)) {
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->size));
+ gtk_tree_model_get (model, &iter,
+ SIZE_COL, &size,
+ -1);
+ if (family_name && name && !strcmp (family_name, name) && size == font_size) {
+ pango_font_description_free (desc);
+ return;
+ }
+ }
+
+ g_signal_handlers_block_by_func (priv->family,
+ brasero_jacket_font_family_changed_cb,
+ self);
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->family));
+ gtk_tree_model_get_iter_first (model, &iter);
+ do {
+ gtk_tree_model_get (model, &iter,
+ FAMILY_COL, &family,
+ -1);
+
+ name = pango_font_family_get_name (family);
+ if (!strcmp (family_name, name)) {
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->family), &iter);
+ break;
+ }
+
+ } while (gtk_tree_model_iter_next (model, &iter));
+
+ g_signal_handlers_unblock_by_func (priv->family,
+ brasero_jacket_font_family_changed_cb,
+ self);
+
+ g_signal_handlers_block_by_func (priv->size,
+ brasero_jacket_font_size_changed_cb,
+ self);
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->size));
+ gtk_tree_model_get_iter_first (model, &iter);
+ do {
+ gtk_tree_model_get (model, &iter,
+ SIZE_COL, &size,
+ -1);
+
+ if (size == font_size / PANGO_SCALE) {
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (priv->size), &iter);
+ break;
+ }
+
+ } while (gtk_tree_model_iter_next (model, &iter));
+
+ g_signal_handlers_unblock_by_func (priv->size,
+ brasero_jacket_font_size_changed_cb,
+ self);
+
+ pango_font_description_free (desc);
+}
+
+gchar *
+brasero_jacket_font_get_name (BraseroJacketFont *self)
+{
+ gint size;
+ gchar *string;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ PangoFontFamily *family;
+ PangoFontDescription *desc;
+ BraseroJacketFontPrivate *priv;
+
+ priv = BRASERO_JACKET_FONT_PRIVATE (self);
+
+ if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->family), &iter)) {
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->family));
+ gtk_tree_model_get (model, &iter,
+ FAMILY_COL, &family,
+ -1);
+ }
+ else
+ return NULL;
+
+ if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->size), &iter)) {
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->size));
+ gtk_tree_model_get (model, &iter,
+ SIZE_COL, &size,
+ -1);
+ }
+ else
+ return NULL;
+
+ desc = pango_font_description_new ();
+ pango_font_description_set_family (desc, pango_font_family_get_name (family));
+ pango_font_description_set_size (desc, size * PANGO_SCALE);
+ string = pango_font_description_to_string (desc);
+ pango_font_description_free (desc);
+ return string;
+}
+
+static void
+brasero_jacket_fill_sizes (BraseroJacketFont *self)
+{
+ BraseroJacketFontPrivate *priv;
+ GtkTreeModel *model;
+ gint i;
+
+ priv = BRASERO_JACKET_FONT_PRIVATE (self);
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->size));
+ for (i = 0; i < G_N_ELEMENTS (font_sizes); i ++) {
+ GtkTreeIter iter;
+ gchar *string;
+
+ string = g_strdup_printf ("%i", font_sizes [i]);
+ gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ SIZE_STRING_COL, string,
+ SIZE_COL, font_sizes [i],
+ -1);
+ g_free (string);
+ }
+}
+
+static void
+brasero_jacket_fill_families (BraseroJacketFont *self)
+{
+ BraseroJacketFontPrivate *priv;
+ PangoFontFamily **families;
+ GtkTreeModel *model;
+ gint num = 0;
+ gint i;
+
+ priv = BRASERO_JACKET_FONT_PRIVATE (self);
+ pango_context_list_families (gtk_widget_get_pango_context (GTK_WIDGET (self)),
+ &families, &num);
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->family));
+ for (i = 0; i < num; i ++) {
+ const gchar *name;
+ GtkTreeIter iter;
+
+ name = pango_font_family_get_name (families [i]);
+ gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ FAMILY_COL, families [i],
+ FAMILY_STRING_COL, name,
+ -1);
+ }
+
+ g_free (families);
+}
+
+static void
+brasero_jacket_font_init (BraseroJacketFont *object)
+{
+ GtkListStore *store;
+ GtkCellRenderer *renderer;
+ BraseroJacketFontPrivate *priv;
+
+ priv = BRASERO_JACKET_FONT_PRIVATE (object);
+
+ gtk_box_set_homogeneous (GTK_BOX (object), FALSE);
+
+ store = gtk_list_store_new (FAMILY_COL_NB,
+ G_TYPE_STRING,
+ G_TYPE_POINTER);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), FAMILY_STRING_COL, GTK_SORT_ASCENDING);
+ priv->family = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
+ g_object_unref (store);
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->family), renderer, FALSE);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (priv->family), renderer,
+ "text", FAMILY_STRING_COL);
+
+ gtk_box_pack_start (GTK_BOX (object), priv->family, FALSE, FALSE, 0);
+ gtk_widget_show (priv->family);
+ gtk_combo_box_set_focus_on_click (GTK_COMBO_BOX (priv->family), FALSE);
+
+ g_signal_connect (priv->family,
+ "changed",
+ G_CALLBACK (brasero_jacket_font_family_changed_cb),
+ object);
+
+ store = gtk_list_store_new (SIZE_COL_NB,
+ G_TYPE_STRING,
+ G_TYPE_UINT);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store), SIZE_COL, GTK_SORT_ASCENDING);
+ priv->size = gtk_combo_box_new_with_model (GTK_TREE_MODEL (store));
+ g_object_unref (store);
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (priv->size), renderer, FALSE);
+ gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (priv->size), renderer,
+ "text", SIZE_COL);
+
+ gtk_box_pack_start (GTK_BOX (object), priv->size, FALSE, FALSE, 0);
+ gtk_widget_show (priv->size);
+ gtk_combo_box_set_focus_on_click (GTK_COMBO_BOX (priv->size), FALSE);
+
+ g_signal_connect (priv->size,
+ "changed",
+ G_CALLBACK (brasero_jacket_font_size_changed_cb),
+ object);
+
+ brasero_jacket_fill_families (object);
+ brasero_jacket_fill_sizes (object);
+}
+
+static void
+brasero_jacket_font_finalize (GObject *object)
+{
+ G_OBJECT_CLASS (brasero_jacket_font_parent_class)->finalize (object);
+}
+
+static void
+brasero_jacket_font_class_init (BraseroJacketFontClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (BraseroJacketFontPrivate));
+
+ object_class->finalize = brasero_jacket_font_finalize;
+
+ jacket_font_signals[FONT_CHANGED] =
+ g_signal_new ("font_changed",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_NO_RECURSE | G_SIGNAL_ACTION | G_SIGNAL_NO_HOOKS,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0,
+ G_TYPE_NONE);
+
+ jacket_font_signals[SIZE_CHANGED] =
+ g_signal_new ("size_changed",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_NO_RECURSE | G_SIGNAL_ACTION | G_SIGNAL_NO_HOOKS,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0,
+ G_TYPE_NONE);
+}
+
+GtkWidget *
+brasero_jacket_font_new (void)
+{
+ return g_object_new (BRASERO_TYPE_JACKET_FONT, NULL);
+}
Added: trunk/src/brasero-jacket-font.h
==============================================================================
--- (empty file)
+++ trunk/src/brasero-jacket-font.h Sun Apr 13 16:55:27 2008
@@ -0,0 +1,63 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * brasero
+ * Copyright (C) Philippe Rouquier 2008 <bonfire-app wanadoo fr>
+ *
+ * brasero is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * brasero is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _BRASERO_JACKET_FONT_H_
+#define _BRASERO_JACKET_FONT_H_
+
+#include <glib-object.h>
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define BRASERO_TYPE_JACKET_FONT (brasero_jacket_font_get_type ())
+#define BRASERO_JACKET_FONT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BRASERO_TYPE_JACKET_FONT, BraseroJacketFont))
+#define BRASERO_JACKET_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BRASERO_TYPE_JACKET_FONT, BraseroJacketFontClass))
+#define BRASERO_IS_JACKET_FONT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BRASERO_TYPE_JACKET_FONT))
+#define BRASERO_IS_JACKET_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BRASERO_TYPE_JACKET_FONT))
+#define BRASERO_JACKET_FONT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BRASERO_TYPE_JACKET_FONT, BraseroJacketFontClass))
+
+typedef struct _BraseroJacketFontClass BraseroJacketFontClass;
+typedef struct _BraseroJacketFont BraseroJacketFont;
+
+struct _BraseroJacketFontClass
+{
+ GtkHBoxClass parent_class;
+};
+
+struct _BraseroJacketFont
+{
+ GtkHBox parent_instance;
+};
+
+GType brasero_jacket_font_get_type (void) G_GNUC_CONST;
+
+GtkWidget *
+brasero_jacket_font_new (void);
+
+void
+brasero_jacket_font_set_name (BraseroJacketFont *font,
+ const gchar *name);
+
+gchar *
+brasero_jacket_font_get_name (BraseroJacketFont *font);
+
+G_END_DECLS
+
+#endif /* _BRASERO_JACKET_FONT_H_ */
Added: trunk/src/brasero-jacket-view.c
==============================================================================
--- (empty file)
+++ trunk/src/brasero-jacket-view.c Sun Apr 13 16:55:27 2008
@@ -0,0 +1,1573 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * brasero
+ * Copyright (C) Philippe Rouquier 2008 <bonfire-app wanadoo fr>
+ *
+ * brasero is free software.
+ *
+ * You may redistribute it and/or modify it under the terms of the
+ * GNU General Public License, as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * brasero is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with braserojacketview. If not, write to:
+ * The Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <glib.h>
+#include <glib/gi18n-lib.h>
+
+#include <gtk/gtk.h>
+
+#include <cairo.h>
+
+#include "brasero-jacket-view.h"
+#include "brasero-jacket-buffer.h"
+
+typedef struct _BraseroJacketViewPrivate BraseroJacketViewPrivate;
+struct _BraseroJacketViewPrivate
+{
+ BraseroJacketSide side;
+
+ GtkWidget *edit;
+ GtkWidget *sides;
+
+ GdkColor b_color;
+ GdkColor b_color2;
+ BraseroJacketColorStyle color_style;
+
+ cairo_pattern_t *pattern;
+
+ GdkPixbuf *image;
+ GdkPixbuf *scaled;
+
+ gchar *image_path;
+ BraseroJacketImageStyle image_style;
+};
+
+#define BRASERO_JACKET_VIEW_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), BRASERO_TYPE_JACKET_VIEW, BraseroJacketViewPrivate))
+
+enum
+{
+ PRINTED,
+ TAGS_CHANGED,
+ LAST_SIGNAL
+};
+
+
+static guint jacket_view_signals[LAST_SIGNAL] = { 0 };
+
+
+G_DEFINE_TYPE (BraseroJacketView, brasero_jacket_view, GTK_TYPE_CONTAINER);
+
+#define BRASERO_JACKET_VIEW_MARGIN 20
+
+
+static GSList *
+brasero_jacket_view_tag_begins (GtkTextIter *iter,
+ GtkTextAttributes *attributes)
+{
+ PangoAttribute *attr;
+ GSList *open_attr = NULL;
+
+ attr = pango_attr_foreground_new (attributes->appearance.fg_color.red,
+ attributes->appearance.fg_color.green,
+ attributes->appearance.fg_color.blue);
+ attr->start_index = gtk_text_iter_get_visible_line_index (iter);
+ open_attr = g_slist_prepend (open_attr, attr);
+
+ attr = pango_attr_font_desc_new (attributes->font);
+ attr->start_index = gtk_text_iter_get_visible_line_index (iter);
+ open_attr = g_slist_prepend (open_attr, attr);
+
+ attr = pango_attr_underline_new (attributes->appearance.underline);
+ attr->start_index = gtk_text_iter_get_visible_line_index (iter);
+ open_attr = g_slist_prepend (open_attr, attr);
+
+ return open_attr;
+}
+
+static void
+brasero_jacket_view_tag_ends (GtkTextIter *iter,
+ PangoAttrList *attributes,
+ GSList *open_attr)
+{
+ GSList *list;
+
+ for (list = open_attr; list; list = list->next) {
+ PangoAttribute *attr;
+
+ attr = list->data;
+ attr->end_index = gtk_text_iter_get_visible_line_index (iter);
+ pango_attr_list_insert (attributes, attr);
+ }
+}
+
+static void
+brasero_jacket_view_set_line_attributes (GtkTextView *view,
+ PangoLayout *layout,
+ guint line_num)
+{
+ PangoAttrList *attributes = NULL;
+ GtkTextAttributes *text_attr;
+ GSList *open_attr = NULL;
+ PangoAlignment alignment;
+ GtkTextBuffer *buffer;
+ GtkTextIter iter;
+ GtkTextIter end;
+
+ attributes = pango_attr_list_new ();
+
+ buffer = gtk_text_view_get_buffer (view);
+ gtk_text_buffer_get_iter_at_line (buffer, &iter, line_num);
+
+ text_attr = gtk_text_view_get_default_attributes (view);
+ gtk_text_iter_get_attributes (&iter, text_attr);
+
+ switch (text_attr->justification) {
+ case GTK_JUSTIFY_CENTER:
+ alignment = PANGO_ALIGN_CENTER;
+ break;
+ case GTK_JUSTIFY_LEFT:
+ alignment = PANGO_ALIGN_LEFT;
+ break;
+ case GTK_JUSTIFY_RIGHT:
+ alignment = PANGO_ALIGN_RIGHT;
+ break;
+ default:
+ alignment = PANGO_ALIGN_LEFT;
+ break;
+ };
+
+ open_attr = brasero_jacket_view_tag_begins (&iter, text_attr);
+ gtk_text_attributes_unref (text_attr);
+
+ while (gtk_text_iter_forward_to_tag_toggle (&iter, NULL) &&
+ gtk_text_iter_get_line (&iter) == line_num &&
+ !gtk_text_iter_is_end (&iter)) {
+
+ brasero_jacket_view_tag_ends (&iter, attributes, open_attr);
+ g_slist_free (open_attr);
+
+ text_attr = gtk_text_view_get_default_attributes (view);
+ gtk_text_iter_get_attributes (&iter, text_attr);
+
+ switch (text_attr->justification) {
+ case GTK_JUSTIFY_CENTER:
+ alignment = PANGO_ALIGN_CENTER;
+ break;
+ case GTK_JUSTIFY_LEFT:
+ alignment = PANGO_ALIGN_LEFT;
+ break;
+ case GTK_JUSTIFY_RIGHT:
+ alignment = PANGO_ALIGN_RIGHT;
+ break;
+ default:
+ alignment = PANGO_ALIGN_LEFT;
+ break;
+ };
+ open_attr = brasero_jacket_view_tag_begins (&iter, text_attr);
+ gtk_text_attributes_unref (text_attr);
+ }
+
+ /* Safer to do this in case one tag finishes on next line */
+ gtk_text_buffer_get_iter_at_line (buffer, &end, line_num);
+ gtk_text_iter_forward_to_line_end (&end);
+
+ /* go through all still opened attributes */
+ brasero_jacket_view_tag_ends (&end, attributes, open_attr);
+ g_slist_free (open_attr);
+
+ pango_layout_set_attributes (layout, attributes);
+ pango_attr_list_unref (attributes);
+
+ pango_layout_set_alignment (layout, alignment);
+}
+
+static void
+brasero_jacket_view_render_side_text (BraseroJacketView *self,
+ cairo_t *ctx,
+ PangoLayout *layout,
+ gdouble resolution,
+ guint x,
+ guint y)
+{
+ guint y_left;
+ guint y_right;
+ guint width;
+ guint x_left;
+ guint x_right;
+ guint line_num;
+ guint line_max;
+ GtkTextBuffer *buffer;
+ BraseroJacketViewPrivate *priv;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (self);
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->sides));
+ line_max = gtk_text_buffer_get_line_count (buffer);
+
+ width = resolution * COVER_HEIGHT_SIDE_INCH;
+ x_left = x;
+ y_left = y + COVER_HEIGHT_SIDE_INCH * resolution;
+
+ x_right = x + COVER_WIDTH_BACK_INCH * resolution;
+ y_right = y;
+
+ for (line_num = 0; line_num < line_max; line_num ++) {
+ gchar *text;
+ PangoRectangle rect;
+ GtkTextIter start, end;
+
+ cairo_set_source_rgb (ctx, 0.0, 0.0, 0.0);
+
+ gtk_text_buffer_get_iter_at_line (buffer, &start, line_num);
+ gtk_text_buffer_get_iter_at_line (buffer, &end, line_num);
+ gtk_text_iter_forward_to_line_end (&end);
+
+ text = brasero_jacket_buffer_get_text (BRASERO_JACKET_BUFFER (buffer), &start, &end, FALSE, FALSE);
+ if (text && text [0] != '\0' && text [0] != '\n') {
+ pango_layout_set_text (layout, text, -1);
+ g_free (text);
+ }
+ else
+ pango_layout_set_text (layout, " ", -1);
+
+ pango_layout_set_width (layout, width * PANGO_SCALE);
+ pango_layout_set_wrap (layout, PANGO_WRAP_CHAR);
+ brasero_jacket_view_set_line_attributes (GTK_TEXT_VIEW (priv->sides), layout, line_num);
+
+ pango_layout_get_pixel_extents (layout, NULL, &rect);
+
+ cairo_save (ctx);
+
+ cairo_move_to (ctx, x_left, y_left);
+ pango_cairo_update_layout (ctx, layout);
+ cairo_rotate (ctx, - G_PI_2);
+ pango_cairo_show_layout (ctx, layout);
+
+ cairo_restore (ctx);
+
+ cairo_save (ctx);
+
+ cairo_move_to (ctx, x_right, y_right);
+ pango_cairo_update_layout (ctx, layout);
+ cairo_rotate (ctx, G_PI_2);
+ pango_cairo_show_layout (ctx, layout);
+
+ cairo_restore (ctx);
+
+ x_right -= rect.height;
+ x_left += rect.height;
+ }
+}
+
+static void
+brasero_jacket_view_render (BraseroJacketView *self,
+ cairo_t *ctx,
+ PangoLayout *layout,
+ gdouble resolution_x,
+ gdouble resolution_y,
+ guint x,
+ guint y,
+ GdkRectangle *area,
+ gboolean render_if_empty)
+{
+ BraseroJacketViewPrivate *priv;
+ gint height, width;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (self);
+
+ if (priv->side == BRASERO_JACKET_BACK) {
+ width = COVER_WIDTH_BACK_INCH * resolution_x;
+ height = COVER_HEIGHT_BACK_INCH * resolution_y;
+ }
+ else {
+ width = COVER_WIDTH_FRONT_INCH * resolution_x;
+ height = COVER_HEIGHT_FRONT_INCH * resolution_y;
+ }
+
+ /* set clip */
+ cairo_reset_clip (ctx);
+ cairo_rectangle (ctx, area->x, area->y, area->width, area->height);
+ cairo_clip (ctx);
+
+ /* draw white surroundings */
+ cairo_set_source_rgb (ctx, 1.0, 1.0, 1.0);
+ cairo_paint (ctx);
+
+ /* draw background */
+ cairo_rectangle (ctx, x, y, width, height);
+ cairo_clip (ctx);
+
+ if (priv->pattern) {
+ cairo_set_source (ctx, priv->pattern);
+ cairo_paint (ctx);
+ }
+
+ if (priv->scaled) {
+ if (priv->image_style == BRASERO_JACKET_IMAGE_CENTER)
+ gdk_cairo_set_source_pixbuf (ctx,
+ priv->scaled,
+ x + (width - gdk_pixbuf_get_width (priv->scaled))/ 2.0,
+ y + (height - gdk_pixbuf_get_height (priv->scaled)) / 2.0);
+ else
+ gdk_cairo_set_source_pixbuf (ctx, priv->scaled, x, y);
+
+ if (priv->image_style == BRASERO_JACKET_IMAGE_TILE) {
+ cairo_pattern_t *pattern;
+
+ pattern = cairo_get_source (ctx);
+ cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
+ }
+
+ cairo_paint (ctx);
+ }
+
+ if (priv->side == BRASERO_JACKET_BACK) {
+ cairo_save (ctx);
+
+ /* Draw the rectangle */
+ cairo_set_antialias (ctx, CAIRO_ANTIALIAS_DEFAULT);
+ cairo_set_source_rgb (ctx, 0.5, 0.5, 0.5);
+ cairo_set_line_width (ctx, 0.5);
+ cairo_set_line_cap (ctx, CAIRO_LINE_CAP_ROUND);
+
+ cairo_move_to (ctx,
+ x + COVER_WIDTH_SIDE_INCH * resolution_x,
+ y);
+ cairo_line_to (ctx,
+ x + COVER_WIDTH_SIDE_INCH * resolution_x,
+ y + (COVER_HEIGHT_SIDE_INCH * resolution_y));
+
+ cairo_move_to (ctx,
+ x + (COVER_WIDTH_BACK_INCH - COVER_WIDTH_SIDE_INCH) * resolution_x,
+ y);
+ cairo_line_to (ctx,
+ x + (COVER_WIDTH_BACK_INCH - COVER_WIDTH_SIDE_INCH) * resolution_x,
+ y + (COVER_HEIGHT_SIDE_INCH * resolution_y));
+
+ cairo_stroke (ctx);
+
+ cairo_restore (ctx);
+ cairo_save (ctx);
+
+ /* also render text in the sides */
+ brasero_jacket_view_render_side_text (self,
+ ctx,
+ layout,
+ resolution_y,
+ x,
+ y);
+
+ cairo_restore (ctx);
+ }
+
+ /* Draw the rectangle */
+ cairo_set_source_rgb (ctx, 0.5, 0.5, 0.5);
+ cairo_set_line_width (ctx, 0.5);
+ cairo_set_line_cap (ctx, CAIRO_LINE_CAP_ROUND);
+
+ cairo_rectangle (ctx,
+ x,
+ y,
+ width,
+ height);
+ cairo_stroke (ctx);
+}
+
+static void
+brasero_jacket_view_render_body (BraseroJacketView *self,
+ cairo_t *ctx,
+ gdouble resolution_x,
+ gdouble resolution_y,
+ guint x,
+ guint y,
+ gboolean render_if_empty)
+{
+ guint width;
+ gint line_max;
+ gint line_num = 0;
+ PangoLayout *layout;
+ GtkTextBuffer *buffer;
+ BraseroJacketViewPrivate *priv;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (self);
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->edit));
+ line_max = gtk_text_buffer_get_line_count (buffer);
+
+ if (priv->side == BRASERO_JACKET_BACK)
+ width = ((COVER_WIDTH_BACK_INCH - COVER_WIDTH_SIDE_INCH * 2) * resolution_x - COVER_TEXT_MARGIN * resolution_x * 2) * PANGO_SCALE;
+ else
+ width = (COVER_WIDTH_FRONT_INCH * resolution_x - COVER_TEXT_MARGIN * resolution_x * 2) * PANGO_SCALE;
+
+ for (line_num = 0; line_num < line_max; line_num ++) {
+ gchar *text;
+ PangoRectangle rect;
+ PangoContext *context;
+ GtkTextIter start, end;
+
+ cairo_set_source_rgb (ctx, 0.0, 0.0, 0.0);
+ layout = pango_cairo_create_layout (ctx);
+
+ context = pango_layout_get_context (layout);
+ pango_cairo_context_set_resolution (context, resolution_x);
+
+ gtk_text_buffer_get_iter_at_line (buffer, &start, line_num);
+ gtk_text_buffer_get_iter_at_line (buffer, &end, line_num);
+ gtk_text_iter_forward_to_line_end (&end);
+
+ text = brasero_jacket_buffer_get_text (BRASERO_JACKET_BUFFER (buffer), &start, &end, FALSE, render_if_empty);
+ if (text && text [0] != '\0' && text [0] != '\n') {
+ pango_layout_set_text (layout, text, -1);
+ g_free (text);
+ }
+ else
+ pango_layout_set_text (layout, " ", -1);
+
+ pango_layout_set_width (layout, width);
+ pango_layout_set_wrap (layout, PANGO_WRAP_CHAR);
+ brasero_jacket_view_set_line_attributes (GTK_TEXT_VIEW (priv->edit), layout, line_num);
+
+ if (priv->side == BRASERO_JACKET_BACK)
+ cairo_move_to (ctx,
+ x + COVER_WIDTH_SIDE_INCH * resolution_x + COVER_TEXT_MARGIN * resolution_x,
+ y + COVER_TEXT_MARGIN * resolution_y);
+ else
+ cairo_move_to (ctx,
+ x + COVER_TEXT_MARGIN * resolution_x,
+ y + COVER_TEXT_MARGIN * resolution_y);
+ pango_cairo_show_layout (ctx, layout);
+
+ pango_layout_get_pixel_extents (layout, NULL, &rect);
+ y += rect.height;
+
+ g_object_unref (layout);
+ }
+}
+
+guint
+brasero_jacket_view_print (BraseroJacketView *self,
+ GtkPrintContext *context,
+ guint x,
+ guint y)
+{
+ cairo_t *ctx;
+ GdkRectangle rect;
+ PangoLayout *layout;
+ gdouble resolution_x;
+ gdouble resolution_y;
+ BraseroJacketViewPrivate *priv;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (self);
+
+ ctx = gtk_print_context_get_cairo_context (context);
+
+ /* set clip */
+ resolution_x = gtk_print_context_get_dpi_x (context);
+ resolution_y = gtk_print_context_get_dpi_y (context);
+ rect.x = x;
+ rect.y = y;
+
+ if (priv->side == BRASERO_JACKET_BACK) {
+ rect.width = resolution_x * COVER_WIDTH_BACK_INCH;
+ rect.height = resolution_y * COVER_HEIGHT_BACK_INCH;
+ }
+ else {
+ rect.width = resolution_x * COVER_WIDTH_FRONT_INCH;
+ rect.height = resolution_y * COVER_HEIGHT_FRONT_INCH;
+ }
+
+ layout = gtk_print_context_create_pango_layout (context);
+ brasero_jacket_view_render (self,
+ ctx,
+ layout,
+ resolution_x,
+ resolution_y,
+ x,
+ y,
+ &rect,
+ FALSE);
+
+ /* Now let's render the text in main buffer */
+ brasero_jacket_view_render_body (self,
+ ctx,
+ resolution_x,
+ resolution_y,
+ x,
+ y,
+ FALSE);
+
+ g_object_unref (layout);
+
+ return rect.height;
+}
+
+cairo_surface_t *
+brasero_jacket_view_snapshot (BraseroJacketView *self)
+{
+ BraseroJacketViewPrivate *priv;
+ cairo_surface_t *surface;
+ PangoLayout *layout;
+ GtkWidget *toplevel;
+ gdouble resolution;
+ GdkRectangle area;
+ cairo_t *ctx;
+ guint height;
+ guint width;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (self);
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
+ if (!GTK_IS_WINDOW (toplevel))
+ return NULL;
+
+ resolution = gdk_screen_get_resolution (gtk_window_get_screen (GTK_WINDOW (toplevel)));
+
+ layout = gtk_widget_create_pango_layout (GTK_WIDGET (self), NULL);
+
+ if (priv->side == BRASERO_JACKET_BACK) {
+ width = resolution * COVER_WIDTH_BACK_INCH + 1;
+ height = resolution * COVER_HEIGHT_BACK_INCH + 1;
+ }
+ else {
+ width = resolution * COVER_WIDTH_FRONT_INCH + 1;
+ height = resolution * COVER_HEIGHT_FRONT_INCH + 1;
+ }
+
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+ width,
+ height);
+ ctx = cairo_create (surface);
+
+ area = GTK_WIDGET (self)->allocation;
+ area.x = 0;
+ area.y = 0;
+ brasero_jacket_view_render (self,
+ ctx,
+ layout,
+ resolution,
+ resolution,
+ 0,
+ 0,
+ &area,
+ FALSE);
+
+ /* Now let's render the text in main buffer */
+ brasero_jacket_view_render_body (self,
+ ctx,
+ resolution,
+ resolution,
+ 0,
+ 0,
+ FALSE);
+
+ g_object_unref (layout);
+ cairo_destroy (ctx);
+ return surface;
+}
+
+static void
+brasero_jacket_view_cursor_position_changed_cb (GObject *buffer,
+ GParamSpec *spec,
+ BraseroJacketView *self)
+{
+ g_signal_emit (self,
+ jacket_view_signals [TAGS_CHANGED],
+ 0);
+}
+
+static void
+brasero_jacket_view_apply_tag (GtkTextBuffer *buffer,
+ GtkTextTag *tag,
+ GtkTextIter *start,
+ GtkTextIter *end,
+ BraseroJacketView *self)
+{
+ g_signal_emit (self,
+ jacket_view_signals [TAGS_CHANGED],
+ 0);
+ gtk_widget_queue_draw (GTK_WIDGET (self));
+}
+
+static void
+brasero_jacket_view_side_buffer_changed (GtkTextBuffer *buffer,
+ BraseroJacketView *self)
+{
+ gtk_widget_queue_draw (GTK_WIDGET (self));
+}
+
+static void
+brasero_jacket_view_focus_in_cb (GtkWidget *view,
+ GdkEventFocus *event,
+ BraseroJacketView *self)
+{
+ GtkTextBuffer *buffer;
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ brasero_jacket_buffer_show_default_text (BRASERO_JACKET_BUFFER (buffer), FALSE);
+
+ g_signal_emit (self,
+ jacket_view_signals [TAGS_CHANGED],
+ 0);
+}
+
+static void
+brasero_jacket_view_focus_out_cb (GtkWidget *view,
+ GdkEventFocus *event,
+ BraseroJacketView *self)
+{
+ GtkTextBuffer *buffer;
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ brasero_jacket_buffer_show_default_text (BRASERO_JACKET_BUFFER (buffer), TRUE);
+
+ g_signal_emit (self,
+ jacket_view_signals [TAGS_CHANGED],
+ 0);
+}
+
+static void
+brasero_jacket_view_scrolled_cb (GtkAdjustment *adj,
+ GtkTextView *view)
+{
+ gint trailing;
+ GtkTextIter end;
+ GtkTextIter start;
+ GdkRectangle rect;
+ GtkTextBuffer *buffer;
+
+ if (gtk_adjustment_get_value (adj) == 0.0)
+ return;
+
+ g_signal_stop_emission_by_name (adj, "value-changed");
+
+ buffer = gtk_text_view_get_buffer (view);
+
+ gtk_text_buffer_get_end_iter (buffer, &end);
+
+ gtk_text_view_get_visible_rect (view, &rect);
+ gtk_text_view_get_iter_at_position (view, &start, &trailing, rect.x + rect.width, rect.y + rect.height - gtk_adjustment_get_value (adj));
+ gtk_text_buffer_delete (buffer, &start, &end);
+
+ gtk_adjustment_set_value (adj, 0.0);
+}
+
+static void
+brasero_jacket_view_change_image_activated_cb (GtkMenuItem *item,
+ BraseroJacketView *self)
+{
+ BraseroJacketImageStyle image_style;
+ BraseroJacketColorStyle color_style;
+ BraseroJacketViewPrivate *priv;
+ GtkWidget *dialog;
+ GdkColor color2;
+ GdkColor color;
+ gchar *path;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (self);
+
+ dialog = brasero_jacket_background_new ();
+
+ brasero_jacket_background_set_image_path (BRASERO_JACKET_BACKGROUND (dialog), priv->image_path);
+ brasero_jacket_background_set_image_style (BRASERO_JACKET_BACKGROUND (dialog), priv->image_style);
+ brasero_jacket_background_set_color (BRASERO_JACKET_BACKGROUND (dialog),
+ &priv->b_color,
+ &priv->b_color2);
+ brasero_jacket_background_set_color_style (BRASERO_JACKET_BACKGROUND (dialog), priv->color_style);
+
+ gtk_dialog_run (GTK_DIALOG (dialog));
+
+ image_style = brasero_jacket_background_get_image_style (BRASERO_JACKET_BACKGROUND (dialog));
+ path = brasero_jacket_background_get_image_path (BRASERO_JACKET_BACKGROUND (dialog));
+ brasero_jacket_view_set_image_style (self, image_style);
+ brasero_jacket_view_set_image (self, path);
+ g_free (path);
+
+ brasero_jacket_background_get_color (BRASERO_JACKET_BACKGROUND (dialog), &color, &color2);
+ brasero_jacket_view_set_color_background (self, &color, &color2);
+
+ color_style = brasero_jacket_background_get_color_style (BRASERO_JACKET_BACKGROUND (dialog));
+ brasero_jacket_view_set_color_style (self, color_style);
+
+ gtk_widget_destroy (dialog);
+}
+
+static void
+brasero_jacket_view_populate_popup_cb (GtkTextView *view,
+ GtkMenu *menu,
+ BraseroJacketView *self)
+{
+ GtkWidget *item;
+
+ item = gtk_separator_menu_item_new ();
+ gtk_widget_show (item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+
+ item = gtk_menu_item_new_with_mnemonic (_("Set bac_kground properties"));
+ gtk_widget_show (item);
+ g_signal_connect (item,
+ "activate",
+ G_CALLBACK (brasero_jacket_view_change_image_activated_cb),
+ self);
+
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+}
+
+void
+brasero_jacket_view_set_side (BraseroJacketView *self,
+ BraseroJacketSide side)
+{
+ BraseroJacketViewPrivate *priv;
+ GtkTextBuffer *buffer;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (self);
+
+ priv->side = side;
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->edit));
+
+ if (priv->side == BRASERO_JACKET_BACK) {
+ GtkTextBuffer *sides_buffer;
+ GtkObject *vadj;
+ GtkObject *hadj;
+
+ sides_buffer = GTK_TEXT_BUFFER (brasero_jacket_buffer_new ());
+ g_signal_connect (sides_buffer,
+ "changed",
+ G_CALLBACK (brasero_jacket_view_side_buffer_changed),
+ self);
+ g_signal_connect (sides_buffer,
+ "notify::cursor-position",
+ G_CALLBACK (brasero_jacket_view_cursor_position_changed_cb),
+ self);
+ g_signal_connect_after (sides_buffer,
+ "apply-tag",
+ G_CALLBACK (brasero_jacket_view_apply_tag),
+ self);
+ brasero_jacket_buffer_set_default_text (BRASERO_JACKET_BUFFER (sides_buffer), _("SIDES"));
+
+ priv->sides = gtk_text_view_new_with_buffer (sides_buffer);
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (priv->sides), GTK_WRAP_CHAR);
+ gtk_widget_set_parent (priv->sides, GTK_WIDGET (self));
+ gtk_widget_show (priv->sides);
+
+ g_signal_connect (priv->sides,
+ "focus-in-event",
+ G_CALLBACK (brasero_jacket_view_focus_in_cb),
+ self);
+ g_signal_connect_after (priv->sides,
+ "focus-out-event",
+ G_CALLBACK (brasero_jacket_view_focus_out_cb),
+ self);
+
+ brasero_jacket_buffer_set_default_text (BRASERO_JACKET_BUFFER (buffer), _("BACK COVER"));
+
+ hadj = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
+ vadj = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
+
+ g_signal_connect (hadj,
+ "value-changed",
+ G_CALLBACK (brasero_jacket_view_scrolled_cb),
+ priv->sides);
+ g_signal_connect (vadj,
+ "value-changed",
+ G_CALLBACK (brasero_jacket_view_scrolled_cb),
+ priv->sides);
+
+ gtk_widget_set_scroll_adjustments (priv->sides, GTK_ADJUSTMENT (hadj), GTK_ADJUSTMENT (vadj));
+ }
+ else
+ brasero_jacket_buffer_set_default_text (BRASERO_JACKET_BUFFER (buffer), _("FRONT COVER"));
+}
+
+static void
+brasero_jacket_view_update_edit_image (BraseroJacketView *self)
+{
+ cairo_t *ctx;
+ guint resolution;
+ GdkWindow *window;
+ GdkPixmap *pixmap;
+ GtkWidget *toplevel;
+ guint width, height, x, y;
+ BraseroJacketViewPrivate *priv;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (self);
+
+ if (!priv->pattern && !priv->scaled)
+ return;
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
+ if (!GTK_IS_WINDOW (toplevel))
+ return;
+
+ resolution = gdk_screen_get_resolution (gtk_window_get_screen (GTK_WINDOW (toplevel)));
+ window = gtk_text_view_get_window (GTK_TEXT_VIEW (priv->edit), GTK_TEXT_WINDOW_TEXT);
+
+ if (!window)
+ return;
+
+ x = COVER_TEXT_MARGIN * resolution;
+ y = COVER_TEXT_MARGIN * resolution;
+ width = priv->edit->allocation.width;
+ height = priv->edit->allocation.height;
+
+ if (priv->side == BRASERO_JACKET_BACK)
+ x += COVER_WIDTH_SIDE_INCH * resolution;
+
+ pixmap = gdk_pixmap_new (GDK_DRAWABLE (window),
+ width,
+ height,
+ -1);
+
+ ctx = gdk_cairo_create (GDK_DRAWABLE (pixmap));
+
+ if (priv->pattern) {
+ cairo_rectangle (ctx,
+ 0,
+ 0,
+ width,
+ height);
+ cairo_clip (ctx);
+
+ cairo_set_source (ctx, priv->pattern);
+ cairo_paint (ctx);
+ }
+ else {
+ GdkGC *gc;
+
+ gc = gdk_gc_new (GDK_DRAWABLE (pixmap));
+ gdk_gc_set_fill (gc, GDK_SOLID);
+ gdk_gc_set_rgb_fg_color (gc, &priv->edit->style->bg [0]);
+ gdk_gc_set_rgb_bg_color (gc, &priv->edit->style->bg [0]);
+ gdk_draw_rectangle (GDK_DRAWABLE (pixmap),
+ gc,
+ TRUE,
+ 0,
+ 0,
+ width,
+ height);
+ g_object_unref (gc);
+ }
+
+ if (priv->scaled) {
+ if (priv->image_style == BRASERO_JACKET_IMAGE_CENTER) {
+ if (width < gdk_pixbuf_get_width (priv->scaled))
+ gdk_draw_pixbuf (GDK_DRAWABLE (pixmap),
+ NULL,
+ priv->scaled,
+ (gdk_pixbuf_get_width (priv->scaled) - width)/ 2,
+ (gdk_pixbuf_get_height (priv->scaled) - height) / 2,
+ 0, 0,
+ width,
+ height,
+ GDK_RGB_DITHER_NORMAL,
+ -1,
+ -1);
+ else
+ gdk_draw_pixbuf (GDK_DRAWABLE (pixmap),
+ NULL,
+ priv->scaled,
+ 0, 0,
+ width - gdk_pixbuf_get_width (priv->scaled) / 2,
+ height - gdk_pixbuf_get_height (priv->scaled) / 2,
+ -1,
+ -1,
+ GDK_RGB_DITHER_NORMAL,
+ -1,
+ -1);
+ }
+ else if (priv->image_style == BRASERO_JACKET_IMAGE_TILE) {
+ cairo_pattern_t *pattern;
+
+ gdk_cairo_set_source_pixbuf (ctx, priv->scaled, -x, -y);
+ pattern = cairo_get_source (ctx);
+ cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
+ cairo_paint (ctx);
+ }
+ else
+ gdk_draw_pixbuf (GDK_DRAWABLE (pixmap),
+ NULL,
+ priv->scaled,
+ x,
+ y,
+ 0, 0,
+ width,
+ height,
+ GDK_RGB_DITHER_NORMAL,
+ -1,
+ -1);
+ }
+
+ cairo_destroy (ctx);
+
+ gdk_window_set_back_pixmap (window, pixmap, FALSE);
+ g_object_unref (pixmap);
+}
+
+static void
+brasero_jacket_view_update_image (BraseroJacketView *self)
+{
+ BraseroJacketViewPrivate *priv;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (self);
+
+ if (!priv->image)
+ return;
+
+ if (priv->image_style == BRASERO_JACKET_IMAGE_CENTER) {
+ g_object_ref (priv->image);
+ priv->scaled = priv->image;
+ }
+ else if (priv->image_style == BRASERO_JACKET_IMAGE_TILE) {
+ g_object_ref (priv->image);
+ priv->scaled = priv->image;
+ }
+ else if (priv->image_style == BRASERO_JACKET_IMAGE_STRETCH) {
+ guint width;
+ guint height;
+ guint resolution;
+ GtkWidget *toplevel;
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
+ if (!GTK_IS_WINDOW (toplevel))
+ return;
+
+ resolution = gdk_screen_get_resolution (gtk_window_get_screen (GTK_WINDOW (toplevel)));
+
+ if (priv->side == BRASERO_JACKET_BACK) {
+ height = resolution * COVER_HEIGHT_BACK_INCH;
+ width = resolution * COVER_WIDTH_BACK_INCH;
+ }
+ else {
+ height = resolution * COVER_HEIGHT_FRONT_INCH;
+ width = resolution * COVER_WIDTH_FRONT_INCH;
+ }
+
+ priv->scaled = gdk_pixbuf_scale_simple (priv->image,
+ width,
+ height,
+ GDK_INTERP_HYPER);
+ }
+
+ brasero_jacket_view_update_edit_image (self);
+ gtk_widget_queue_draw (GTK_WIDGET (self));
+}
+
+void
+brasero_jacket_view_set_image_style (BraseroJacketView *self,
+ BraseroJacketImageStyle style)
+{
+ BraseroJacketViewPrivate *priv;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (self);
+
+ if (priv->scaled) {
+ g_object_unref (priv->scaled);
+ priv->scaled = NULL;
+ }
+
+ priv->image_style = style;
+ brasero_jacket_view_update_image (self);
+}
+
+static void
+brasero_jacket_view_update_color (BraseroJacketView *self)
+{
+ guint resolution;
+ GtkWidget *toplevel;
+ guint width, height;
+ cairo_pattern_t *pattern;
+ BraseroJacketViewPrivate *priv;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (self);
+
+ if (priv->pattern) {
+ cairo_pattern_destroy (priv->pattern);
+ priv->pattern = NULL;
+ }
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
+ if (!GTK_IS_WINDOW (toplevel))
+ return;
+
+ resolution = gdk_screen_get_resolution (gtk_window_get_screen (GTK_WINDOW (toplevel)));
+ if (priv->side == BRASERO_JACKET_BACK) {
+ height = resolution * COVER_HEIGHT_BACK_INCH;
+ width = resolution * COVER_WIDTH_BACK_INCH;
+ }
+ else {
+ height = resolution * COVER_HEIGHT_FRONT_INCH;
+ width = resolution * COVER_WIDTH_FRONT_INCH;
+ }
+
+ if (priv->color_style == BRASERO_JACKET_COLOR_SOLID) {
+ pattern = cairo_pattern_create_rgb (priv->b_color.red/G_MAXINT16,
+ priv->b_color.green/G_MAXINT16,
+ priv->b_color.blue/G_MAXINT16);
+ }
+ else {
+ if (priv->color_style == BRASERO_JACKET_COLOR_HGRADIENT)
+ pattern = cairo_pattern_create_linear (0.0,
+ 0.0,
+ width,
+ 0.0);
+ else if (priv->color_style == BRASERO_JACKET_COLOR_VGRADIENT)
+ pattern = cairo_pattern_create_linear (0.0,
+ 0.0,
+ 0.0,
+ height);
+
+ cairo_pattern_add_color_stop_rgb (pattern,
+ 0.0,
+ priv->b_color.red/G_MAXINT16,
+ priv->b_color.green/G_MAXINT16,
+ priv->b_color.blue/G_MAXINT16);
+
+ cairo_pattern_add_color_stop_rgb (pattern,
+ 1.0,
+ priv->b_color2.red/G_MAXINT16,
+ priv->b_color2.green/G_MAXINT16,
+ priv->b_color2.blue/G_MAXINT16);
+ }
+
+ priv->pattern = pattern;
+
+ brasero_jacket_view_update_edit_image (self);
+ gtk_widget_queue_draw (GTK_WIDGET (self));
+}
+
+const gchar *
+brasero_jacket_view_get_image (BraseroJacketView *self)
+{
+ BraseroJacketViewPrivate *priv;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (self);
+ return priv->image_path;
+}
+
+const gchar *
+brasero_jacket_view_set_image (BraseroJacketView *self,
+ const gchar *path)
+{
+ BraseroJacketViewPrivate *priv;
+ GdkPixbuf *image = NULL;
+ GError *error = NULL;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (self);
+
+ if (!path)
+ return priv->image_path;
+
+ image = gdk_pixbuf_new_from_file (path, &error);
+ if (error) {
+ GtkWidget *message;
+
+ message = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))),
+ GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("The image couldn't be loaded:"));
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (message),
+ error->message);
+ gtk_dialog_run (GTK_DIALOG (message));
+ gtk_widget_destroy (message);
+ return priv->image_path;
+ }
+
+ if (priv->image_path) {
+ g_free (priv->image_path);
+ priv->image_path = NULL;
+ }
+
+ if (priv->scaled) {
+ g_object_unref (priv->scaled);
+ priv->scaled = NULL;
+ }
+
+ if (priv->image) {
+ g_object_unref (priv->image);
+ priv->image = NULL;
+ }
+
+ priv->image_path = g_strdup (path);
+ priv->image = image;
+
+ brasero_jacket_view_update_image (self);
+ return priv->image_path;
+}
+
+void
+brasero_jacket_view_set_color_background (BraseroJacketView *self,
+ GdkColor *color,
+ GdkColor *color2)
+{
+ BraseroJacketViewPrivate *priv;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (self);
+ priv->b_color = *color;
+ priv->b_color2 = *color2;
+ brasero_jacket_view_update_color (self);
+}
+
+void
+brasero_jacket_view_set_color_style (BraseroJacketView *self,
+ BraseroJacketColorStyle style)
+{
+ BraseroJacketViewPrivate *priv;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (self);
+ priv->color_style = style;
+ brasero_jacket_view_update_color (self);
+}
+
+GtkTextAttributes *
+brasero_jacket_view_get_default_attributes (BraseroJacketView *self)
+{
+ BraseroJacketViewPrivate *priv;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (self);
+ return gtk_text_view_get_default_attributes (GTK_TEXT_VIEW (priv->edit));
+}
+
+GtkTextBuffer *
+brasero_jacket_view_get_active_buffer (BraseroJacketView *self)
+{
+ BraseroJacketViewPrivate *priv;
+ GtkWidget *current;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (self);
+
+ if (priv->sides && gtk_widget_is_focus (priv->sides))
+ current = priv->sides;
+ else if (gtk_widget_is_focus (priv->edit))
+ current = priv->edit;
+ else
+ return NULL;
+
+ return gtk_text_view_get_buffer (GTK_TEXT_VIEW (current));
+}
+
+static gboolean
+brasero_jacket_view_expose (GtkWidget *widget,
+ GdkEventExpose *event)
+{
+ guint x;
+ guint y;
+ cairo_t *ctx;
+ gdouble resolution;
+ GtkWidget *toplevel;
+ PangoLayout *layout;
+ BraseroJacketViewPrivate *priv;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (widget);
+
+ ctx = gdk_cairo_create (GDK_DRAWABLE (widget->window));
+
+ toplevel = gtk_widget_get_toplevel (widget);
+ if (!GTK_IS_WINDOW (toplevel))
+ return FALSE;
+
+ resolution = gdk_screen_get_resolution (gtk_window_get_screen (GTK_WINDOW (toplevel)));
+ layout = gtk_widget_create_pango_layout (widget, NULL);
+ if (priv->side == BRASERO_JACKET_BACK) {
+ x = (widget->allocation.width - resolution * COVER_WIDTH_BACK_INCH) / 2;
+ y = (widget->allocation.height - resolution * COVER_HEIGHT_BACK_INCH) - BRASERO_JACKET_VIEW_MARGIN;
+
+ brasero_jacket_view_render (BRASERO_JACKET_VIEW (widget),
+ ctx,
+ layout,
+ resolution,
+ resolution,
+ x,
+ y,
+ &event->area,
+ TRUE);
+
+ /* rectangle for side text */
+
+ /* set clip */
+ cairo_reset_clip (ctx);
+ cairo_rectangle (ctx, event->area.x, event->area.y, event->area.width, event->area.height);
+ cairo_clip (ctx);
+
+ cairo_move_to (ctx, 0., 0.);
+
+ cairo_set_antialias (ctx, CAIRO_ANTIALIAS_DEFAULT);
+ cairo_set_source_rgb (ctx, 0.5, 0.5, 0.5);
+ cairo_set_line_width (ctx, 0.5);
+ cairo_set_line_cap (ctx, CAIRO_LINE_CAP_ROUND);
+
+ cairo_rectangle (ctx,
+ priv->sides->allocation.x - 1,
+ priv->sides->allocation.y - 1,
+ priv->sides->allocation.width + 2,
+ priv->sides->allocation.height + 2);
+ cairo_stroke (ctx);
+
+ gtk_container_propagate_expose (GTK_CONTAINER (widget),
+ priv->sides,
+ event);
+ }
+ else {
+ x = (widget->allocation.width - resolution * COVER_WIDTH_FRONT_INCH) / 2;
+ y = (widget->allocation.height - resolution * COVER_HEIGHT_FRONT_INCH) / 2;
+
+ brasero_jacket_view_render (BRASERO_JACKET_VIEW (widget),
+ ctx,
+ layout,
+ resolution,
+ resolution,
+ x,
+ y,
+ &event->area,
+ TRUE);
+ }
+
+ gtk_container_propagate_expose (GTK_CONTAINER (widget),
+ priv->edit,
+ event);
+
+ g_object_unref (layout);
+ cairo_destroy (ctx);
+ return FALSE;
+}
+
+static void
+brasero_jacket_view_realize (GtkWidget *widget)
+{
+ BraseroJacketViewPrivate *priv;
+ GdkWindowAttr attributes;
+ gint attributes_mask;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (widget);
+
+ attributes.window_type = GDK_WINDOW_CHILD;
+ attributes.x = widget->allocation.x;
+ attributes.y = widget->allocation.y;
+ attributes.width = widget->allocation.width;
+ attributes.height = widget->allocation.height;
+ attributes.wclass = GDK_INPUT_OUTPUT;
+ attributes.visual = gtk_widget_get_visual (widget);
+ attributes.colormap = gtk_widget_get_colormap (widget);
+ attributes.event_mask = gtk_widget_get_events (widget);
+ attributes.event_mask |= GDK_EXPOSURE_MASK|GDK_BUTTON_PRESS_MASK|GDK_LEAVE_NOTIFY_MASK;
+ attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_COLORMAP;
+
+ widget->window = gdk_window_new (gtk_widget_get_parent_window (widget),
+ &attributes,
+ attributes_mask);
+ gdk_window_set_user_data (widget->window, widget);
+
+ widget->style = gtk_style_attach (widget->style, widget->window);
+ GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
+}
+
+static void
+brasero_jacket_view_map (GtkWidget *widget)
+{
+ g_return_if_fail (widget != NULL);
+ gdk_window_show (widget->window);
+
+ GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
+
+ if (GTK_WIDGET_CLASS (brasero_jacket_view_parent_class)->map)
+ GTK_WIDGET_CLASS (brasero_jacket_view_parent_class)->map (widget);
+}
+
+static void
+brasero_jacket_view_unmap (GtkWidget *widget)
+{
+ g_return_if_fail (widget != NULL);
+ gdk_window_hide (widget->window);
+
+ GTK_WIDGET_UNSET_FLAGS (widget, GTK_MAPPED);
+
+ if (GTK_WIDGET_CLASS (brasero_jacket_view_parent_class)->unmap)
+ GTK_WIDGET_CLASS (brasero_jacket_view_parent_class)->unmap (widget);
+}
+
+static void
+brasero_jacket_view_size_request (GtkWidget *widget,
+ GtkRequisition *request)
+{
+ BraseroJacketViewPrivate *priv;
+ GtkWidget *toplevel;
+ gdouble resolution;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (widget);
+
+ if (!widget->parent)
+ return;
+
+ toplevel = gtk_widget_get_toplevel (widget);
+ if (!GTK_IS_WINDOW (toplevel))
+ return;
+
+ resolution = gdk_screen_get_resolution (gtk_window_get_screen (GTK_WINDOW (toplevel)));
+
+ if (priv->side == BRASERO_JACKET_FRONT) {
+ request->width = COVER_WIDTH_FRONT_INCH * resolution + BRASERO_JACKET_VIEW_MARGIN * 2;
+ request->height = COVER_HEIGHT_FRONT_INCH * resolution + BRASERO_JACKET_VIEW_MARGIN * 2;
+ }
+ else if (priv->side == BRASERO_JACKET_BACK) {
+ request->width = COVER_WIDTH_BACK_INCH * resolution +
+ BRASERO_JACKET_VIEW_MARGIN * 2;
+ request->height = COVER_HEIGHT_BACK_INCH * resolution +
+ COVER_WIDTH_SIDE_INCH * resolution +
+ BRASERO_JACKET_VIEW_MARGIN * 3;
+ }
+}
+
+static void
+brasero_jacket_view_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation)
+{
+ BraseroJacketViewPrivate *priv;
+ GtkAllocation view_alloc;
+ GtkWidget *toplevel;
+ gint resolution;
+
+ toplevel = gtk_widget_get_toplevel (widget);
+ if (!GTK_IS_WINDOW (toplevel))
+ return;
+
+ resolution = gdk_screen_get_resolution (gtk_window_get_screen (GTK_WINDOW (toplevel)));
+ priv = BRASERO_JACKET_VIEW_PRIVATE (widget);
+
+ if (priv->image && priv->image_style == BRASERO_JACKET_IMAGE_STRETCH) {
+ if (priv->scaled) {
+ g_object_unref (priv->scaled);
+ priv->scaled = NULL;
+ }
+
+ /* scale pixbuf */
+ brasero_jacket_view_update_image (BRASERO_JACKET_VIEW (widget));
+ }
+
+ view_alloc.x = BRASERO_JACKET_VIEW_MARGIN + COVER_TEXT_MARGIN * resolution;
+ view_alloc.y = BRASERO_JACKET_VIEW_MARGIN + COVER_TEXT_MARGIN * resolution;
+
+ if (priv->side == BRASERO_JACKET_BACK) {
+ view_alloc.x = (allocation->width - COVER_HEIGHT_SIDE_INCH * resolution) / 2;
+ view_alloc.y = BRASERO_JACKET_VIEW_MARGIN;
+ view_alloc.width = COVER_HEIGHT_SIDE_INCH * resolution;
+ view_alloc.height = COVER_WIDTH_SIDE_INCH * resolution;
+
+ gtk_widget_size_allocate (priv->sides, &view_alloc);
+
+ view_alloc.x = (allocation->width - COVER_WIDTH_BACK_INCH * resolution) / 2 +
+ (COVER_TEXT_MARGIN + COVER_WIDTH_SIDE_INCH) * resolution;
+
+ view_alloc.y = (allocation->height - resolution * COVER_HEIGHT_BACK_INCH) -
+ BRASERO_JACKET_VIEW_MARGIN +
+ COVER_TEXT_MARGIN * resolution;
+
+ view_alloc.width = COVER_WIDTH_BACK_INCH * resolution -
+ COVER_TEXT_MARGIN * resolution * 2 -
+ COVER_WIDTH_SIDE_INCH * resolution * 2;
+ view_alloc.height = COVER_HEIGHT_BACK_INCH * resolution -
+ COVER_TEXT_MARGIN * resolution * 2;
+ }
+ else {
+ view_alloc.x = (allocation->width - COVER_WIDTH_FRONT_INCH * resolution) / 2 +
+ COVER_TEXT_MARGIN * resolution;
+ view_alloc.y = (allocation->height - resolution * COVER_HEIGHT_FRONT_INCH) / 2 +
+ COVER_TEXT_MARGIN * resolution;
+
+ view_alloc.width = COVER_WIDTH_FRONT_INCH * resolution -
+ COVER_TEXT_MARGIN * resolution * 2;
+ view_alloc.height = COVER_HEIGHT_FRONT_INCH * resolution -
+ COVER_TEXT_MARGIN * resolution * 2;
+ }
+
+ brasero_jacket_view_update_edit_image (BRASERO_JACKET_VIEW (widget));
+ gtk_widget_size_allocate (priv->edit, &view_alloc);
+
+ widget->allocation = *allocation;
+ if (GTK_WIDGET_REALIZED (widget) && !GTK_WIDGET_NO_WINDOW (widget)) {
+ gdk_window_move_resize (widget->window,
+ allocation->x,
+ allocation->y,
+ allocation->width,
+ allocation->height);
+ }
+}
+
+static void
+brasero_jacket_view_container_forall (GtkContainer *container,
+ gboolean include_internals,
+ GtkCallback callback,
+ gpointer callback_data)
+{
+ BraseroJacketViewPrivate *priv;
+
+ if (!include_internals)
+ return;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (container);
+ if (priv->edit)
+ callback (priv->edit, callback_data);
+ if (priv->sides)
+ callback (priv->sides, callback_data);
+}
+
+static void
+brasero_jacket_view_container_remove (GtkContainer *container,
+ GtkWidget *widget)
+{
+ BraseroJacketViewPrivate *priv;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (container);
+ if (priv->edit == widget)
+ priv->edit = NULL;
+
+ if (priv->sides == widget)
+ priv->sides = NULL;
+}
+
+static void
+brasero_jacket_view_init (BraseroJacketView *object)
+{
+ BraseroJacketViewPrivate *priv;
+ GtkTextBuffer *buffer;
+ GtkObject *vadj;
+ GtkObject *hadj;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (object);
+
+ buffer = GTK_TEXT_BUFFER (brasero_jacket_buffer_new ());
+ g_signal_connect (buffer,
+ "notify::cursor-position",
+ G_CALLBACK (brasero_jacket_view_cursor_position_changed_cb),
+ object);
+ g_signal_connect_after (buffer,
+ "apply-tag",
+ G_CALLBACK (brasero_jacket_view_apply_tag),
+ object);
+
+ priv->edit = gtk_text_view_new_with_buffer (buffer);
+ g_object_unref (buffer);
+
+ priv->b_color = priv->edit->style->bg [0];
+ priv->color_style = BRASERO_JACKET_COLOR_SOLID;
+
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (priv->edit), GTK_WRAP_CHAR);
+ gtk_widget_set_parent (priv->edit, GTK_WIDGET (object));
+ gtk_widget_show (priv->edit);
+
+ g_signal_connect (priv->edit,
+ "focus-in-event",
+ G_CALLBACK (brasero_jacket_view_focus_in_cb),
+ object);
+ g_signal_connect_after (priv->edit,
+ "focus-out-event",
+ G_CALLBACK (brasero_jacket_view_focus_out_cb),
+ object);
+ g_signal_connect_after (priv->edit,
+ "populate-popup",
+ G_CALLBACK (brasero_jacket_view_populate_popup_cb),
+ object);
+ hadj = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
+ vadj = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
+
+ g_signal_connect (hadj,
+ "value-changed",
+ G_CALLBACK (brasero_jacket_view_scrolled_cb),
+ priv->edit);
+ g_signal_connect (vadj,
+ "value-changed",
+ G_CALLBACK (brasero_jacket_view_scrolled_cb),
+ priv->edit);
+
+ gtk_widget_set_scroll_adjustments (priv->edit, GTK_ADJUSTMENT (hadj), GTK_ADJUSTMENT (vadj));
+}
+
+static void
+brasero_jacket_view_finalize (GObject *object)
+{
+ BraseroJacketViewPrivate *priv;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (object);
+ if (priv->image) {
+ g_object_unref (priv->image);
+ priv->image = NULL;
+ }
+
+ if (priv->scaled) {
+ g_object_unref (priv->scaled);
+ priv->scaled = NULL;
+ }
+
+ if (priv->pattern) {
+ cairo_pattern_destroy (priv->pattern);
+ priv->pattern = NULL;
+ }
+
+ if (priv->image_path) {
+ g_free (priv->image_path);
+ priv->image_path = NULL;
+ }
+
+ G_OBJECT_CLASS (brasero_jacket_view_parent_class)->finalize (object);
+}
+
+static void
+brasero_jacket_view_class_init (BraseroJacketViewClass *klass)
+{
+ GObjectClass* object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass* widget_class = GTK_WIDGET_CLASS (klass);
+ GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (BraseroJacketViewPrivate));
+
+ object_class->finalize = brasero_jacket_view_finalize;
+
+ widget_class->expose_event = brasero_jacket_view_expose;
+ widget_class->map = brasero_jacket_view_map;
+ widget_class->unmap = brasero_jacket_view_unmap;
+ widget_class->realize = brasero_jacket_view_realize;
+ widget_class->size_allocate = brasero_jacket_view_size_allocate;
+ widget_class->size_request = brasero_jacket_view_size_request;
+
+ container_class->forall = brasero_jacket_view_container_forall;
+ container_class->remove = brasero_jacket_view_container_remove;
+
+ jacket_view_signals[PRINTED] =
+ g_signal_new ("printed",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION | G_SIGNAL_NO_HOOKS,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0,
+ G_TYPE_NONE);
+ jacket_view_signals[TAGS_CHANGED] =
+ g_signal_new ("tags_changed",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION | G_SIGNAL_NO_HOOKS,
+ 0,
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0,
+ G_TYPE_NONE);
+}
+
+GtkWidget *
+brasero_jacket_view_new (void)
+{
+ return g_object_new (BRASERO_TYPE_JACKET_VIEW, NULL);
+}
Added: trunk/src/brasero-jacket-view.h
==============================================================================
--- (empty file)
+++ trunk/src/brasero-jacket-view.h Sun Apr 13 16:55:27 2008
@@ -0,0 +1,123 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * brasero
+ * Copyright (C) Philippe Rouquier 2008 <bonfire-app wanadoo fr>
+ *
+ * brasero is free software.
+ *
+ * You may redistribute it and/or modify it under the terms of the
+ * GNU General Public License, as published by the Free Software
+ * Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ *
+ * brasero is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with brasero. If not, write to:
+ * The Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef _BRASERO_JACKET_VIEW_H_
+#define _BRASERO_JACKET_VIEW_H_
+
+#include <glib-object.h>
+
+#include <gtk/gtk.h>
+
+#include "brasero-jacket-background.h"
+
+G_BEGIN_DECLS
+
+typedef enum {
+ BRASERO_JACKET_FRONT = 0,
+ BRASERO_JACKET_BACK = 1,
+} BraseroJacketSide;
+
+#define COVER_HEIGHT_FRONT_MM 120
+#define COVER_WIDTH_FRONT_MM 120
+#define COVER_WIDTH_FRONT_INCH 4.724
+#define COVER_HEIGHT_FRONT_INCH 4.724
+
+#define COVER_HEIGHT_BACK_MM 117.5
+#define COVER_WIDTH_BACK_MM 152
+#define COVER_HEIGHT_BACK_INCH 4.646
+#define COVER_WIDTH_BACK_INCH 5.984
+
+#define COVER_HEIGHT_SIDE_MM 117.5
+#define COVER_WIDTH_SIDE_MM 6
+#define COVER_HEIGHT_SIDE_INCH 4.625
+#define COVER_WIDTH_SIDE_INCH 0.235
+
+#define COVER_TEXT_MARGIN /*1.*/0.03 //0.079
+
+#define BRASERO_TYPE_JACKET_VIEW (brasero_jacket_view_get_type ())
+#define BRASERO_JACKET_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BRASERO_TYPE_JACKET_VIEW, BraseroJacketView))
+#define BRASERO_JACKET_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BRASERO_TYPE_JACKET_VIEW, BraseroJacketViewClass))
+#define BRASERO_IS_JACKET_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BRASERO_TYPE_JACKET_VIEW))
+#define BRASERO_IS_JACKET_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BRASERO_TYPE_JACKET_VIEW))
+#define BRASERO_JACKET_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BRASERO_TYPE_JACKET_VIEW, BraseroJacketViewClass))
+
+typedef struct _BraseroJacketViewClass BraseroJacketViewClass;
+typedef struct _BraseroJacketView BraseroJacketView;
+
+struct _BraseroJacketViewClass
+{
+ GtkContainerClass parent_class;
+};
+
+struct _BraseroJacketView
+{
+ GtkContainer parent_instance;
+};
+
+GType brasero_jacket_view_get_type (void) G_GNUC_CONST;
+
+GtkWidget *
+brasero_jacket_view_new (void);
+
+void
+brasero_jacket_view_set_side (BraseroJacketView *view,
+ BraseroJacketSide side);
+
+void
+brasero_jacket_view_set_image_style (BraseroJacketView *view,
+ BraseroJacketImageStyle style);
+
+void
+brasero_jacket_view_set_color_background (BraseroJacketView *view,
+ GdkColor *color,
+ GdkColor *color2);
+void
+brasero_jacket_view_set_color_style (BraseroJacketView *view,
+ BraseroJacketColorStyle style);
+
+const gchar *
+brasero_jacket_view_get_image (BraseroJacketView *self);
+
+const gchar *
+brasero_jacket_view_set_image (BraseroJacketView *view,
+ const gchar *path);
+
+guint
+brasero_jacket_view_print (BraseroJacketView *view,
+ GtkPrintContext *context,
+ guint x,
+ guint y);
+
+cairo_surface_t *
+brasero_jacket_view_snapshot (BraseroJacketView *self);
+
+GtkTextBuffer *
+brasero_jacket_view_get_active_buffer (BraseroJacketView *view);
+
+GtkTextAttributes *
+brasero_jacket_view_get_default_attributes (BraseroJacketView *view);
+
+G_END_DECLS
+
+#endif /* _BRASERO_JACKET_VIEW_H_ */
Modified: trunk/src/brasero-menu.h
==============================================================================
--- trunk/src/brasero-menu.h (original)
+++ trunk/src/brasero-menu.h Sun Apr 13 16:55:27 2008
@@ -41,6 +41,7 @@
#include "brasero-utils.h"
#include "brasero-app.h"
+void on_cover_cb (GtkAction *action, BraseroApp *app);
void on_prefs_cb (GtkAction *action, BraseroApp *app);
void on_eject_cb (GtkAction *action, BraseroApp *app);
void on_erase_cb (GtkAction *action, BraseroApp *app);
@@ -59,6 +60,9 @@
{"ToolMenu", NULL, N_("_Tools")},
{"HelpMenu", NULL, N_("_Help")},
+ {"Cover", NULL, N_("_Cover editor"), NULL,
+ N_("Design and print covers for CDs"), G_CALLBACK (on_cover_cb)},
+
{"Plugins", NULL, N_("P_lugins"), NULL,
N_("Choose plugins for brasero"), G_CALLBACK (on_prefs_cb)},
@@ -104,6 +108,8 @@
"<menuitem action='Eject'/>"
"<menuitem action='Erase'/>"
"<menuitem action='Check'/>"
+ "<separator/>"
+ "<menuitem action='Cover'/>"
"</menu>"
"<menu action='HelpMenu'>"
"<menuitem action='About'/>"
Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c (original)
+++ trunk/src/main.c Sun Apr 13 16:55:27 2008
@@ -48,6 +48,7 @@
#include "brasero-app.h"
#include "brasero-menu.h"
+#include "brasero-jacket-edit.h"
#include "brasero-multi-dnd.h"
#include "brasero-blank-dialog.h"
#include "brasero-sum-dialog.h"
@@ -143,6 +144,36 @@
g_slist_free (list); \
}
+void
+on_cover_cb (GtkAction *action, BraseroApp *app)
+{
+ GtkWidget *window;
+ GtkWidget *toplevel;
+ GtkWidget *contents;
+
+ toplevel = gtk_widget_get_toplevel (app->mainwin);
+ window = gtk_dialog_new_with_buttons (_("Cover editor"),
+ GTK_WINDOW (toplevel),
+ GTK_DIALOG_MODAL|
+ GTK_DIALOG_DESTROY_WITH_PARENT|
+ GTK_DIALOG_NO_SEPARATOR,
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
+ NULL);
+
+ gtk_window_set_default_size (GTK_WINDOW (window), 530, 640);
+ gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER_ON_PARENT);
+ g_signal_connect (window,
+ "response",
+ G_CALLBACK (gtk_widget_destroy),
+ NULL);
+
+ contents = brasero_jacket_edit_new ();
+ gtk_widget_show (contents);
+
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), contents, TRUE, TRUE, 0);
+ gtk_widget_show (window);
+}
+
static gboolean
on_delete_cb (GtkWidget *window, GdkEvent *event, BraseroApp *app)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]