brasero r1904 - in trunk: . src
- From: philippr svn gnome org
- To: svn-commits-list gnome org
- Subject: brasero r1904 - in trunk: . src
- Date: Thu, 12 Feb 2009 14:03:44 +0000 (UTC)
Author: philippr
Date: Thu Feb 12 14:03:44 2009
New Revision: 1904
URL: http://svn.gnome.org/viewvc/brasero?rev=1904&view=rev
Log:
2009-02-12 Philippe Rouquier <ykw localhost localdomain>
Fix a lot of small things with cover editor
Also fix crash #571218 â Brasero crashes from Cover Editor
It happened because a view was set (since we wrote to the buffer) but
no buffer was selected since grab_focus was inefficiently used. So turn
off any change notification by blocking signals while we initially set
up the buffers contents.
* src/brasero-jacket-buffer.c
(_gtk_text_attributes_fill_from_tags),
(brasero_jacket_buffer_add_default_tag),
(brasero_jacket_buffer_get_attributes),
(brasero_jacket_buffer_cursor_position_changed_cb):
* src/brasero-jacket-buffer.h:
* src/brasero-jacket-edit.c
(brasero_jacket_edit_center_pressed_cb),
(brasero_jacket_edit_font_changed_cb),
(brasero_jacket_edit_update_button_state),
(brasero_jacket_edit_init), (brasero_jacket_edit_set_audio_tracks),
(brasero_jacket_edit_dialog_new):
* src/brasero-jacket-font.c (brasero_jacket_font_get_family),
(brasero_jacket_font_get_size):
* src/brasero-jacket-font.h:
* src/brasero-jacket-view.c
(brasero_jacket_view_cursor_position_changed_cb),
(brasero_jacket_view_get_attributes), (brasero_jacket_view_init):
* src/brasero-jacket-view.h:
* src/brasero-tool-color-picker.c
(brasero_tool_color_picker_ok_clicked):
Modified:
trunk/ChangeLog
trunk/src/brasero-jacket-buffer.c
trunk/src/brasero-jacket-buffer.h
trunk/src/brasero-jacket-edit.c
trunk/src/brasero-jacket-font.c
trunk/src/brasero-jacket-font.h
trunk/src/brasero-jacket-view.c
trunk/src/brasero-jacket-view.h
trunk/src/brasero-tool-color-picker.c
Modified: trunk/src/brasero-jacket-buffer.c
==============================================================================
--- trunk/src/brasero-jacket-buffer.c (original)
+++ trunk/src/brasero-jacket-buffer.c Thu Feb 12 14:03:44 2009
@@ -56,6 +56,139 @@
return gtk_text_buffer_get_text (GTK_TEXT_BUFFER (self), start, end, invisible_chars);
}
+/* As the name suggests it is copied from GTK 2.14.3
+ * It was changed to use GSList * as arguments */
+static void
+_gtk_text_attributes_fill_from_tags (GtkTextAttributes *dest,
+ GSList *tags)
+{
+ guint left_margin_accumulative = 0;
+ guint right_margin_accumulative = 0;
+
+ g_return_if_fail (!dest->realized);
+
+ for (; tags; tags = tags->next)
+ {
+ GtkTextTag *tag;
+ GtkTextAttributes *vals;
+
+ tag = tags->data;
+ vals = tag->values;
+
+ if (tag->bg_color_set)
+ {
+ dest->appearance.bg_color = vals->appearance.bg_color;
+
+ dest->appearance.draw_bg = TRUE;
+ }
+ if (tag->fg_color_set)
+ dest->appearance.fg_color = vals->appearance.fg_color;
+
+ if (tag->pg_bg_color_set)
+ {
+ dest->pg_bg_color = gdk_color_copy (vals->pg_bg_color);
+ }
+
+ if (tag->bg_stipple_set)
+ {
+ g_object_ref (vals->appearance.bg_stipple);
+ if (dest->appearance.bg_stipple)
+ g_object_unref (dest->appearance.bg_stipple);
+ dest->appearance.bg_stipple = vals->appearance.bg_stipple;
+
+ dest->appearance.draw_bg = TRUE;
+ }
+
+ if (tag->fg_stipple_set)
+ {
+ g_object_ref (vals->appearance.fg_stipple);
+ if (dest->appearance.fg_stipple)
+ g_object_unref (dest->appearance.fg_stipple);
+ dest->appearance.fg_stipple = vals->appearance.fg_stipple;
+ }
+
+ if (vals->font)
+ {
+ if (dest->font)
+ pango_font_description_merge (dest->font, vals->font, TRUE);
+ else
+ dest->font = pango_font_description_copy (vals->font);
+ }
+
+ /* multiply all the scales together to get a composite */
+ if (tag->scale_set)
+ dest->font_scale *= vals->font_scale;
+
+ if (tag->justification_set)
+ dest->justification = vals->justification;
+
+ if (vals->direction != GTK_TEXT_DIR_NONE)
+ dest->direction = vals->direction;
+
+ if (tag->left_margin_set)
+ {
+ if (tag->accumulative_margin)
+ left_margin_accumulative += vals->left_margin;
+ else
+ dest->left_margin = vals->left_margin;
+ }
+
+ if (tag->indent_set)
+ dest->indent = vals->indent;
+
+ if (tag->rise_set)
+ dest->appearance.rise = vals->appearance.rise;
+
+ if (tag->right_margin_set)
+ {
+ if (tag->accumulative_margin)
+ right_margin_accumulative += vals->right_margin;
+ else
+ dest->right_margin = vals->right_margin;
+ }
+
+ if (tag->pixels_above_lines_set)
+ dest->pixels_above_lines = vals->pixels_above_lines;
+
+ if (tag->pixels_below_lines_set)
+ dest->pixels_below_lines = vals->pixels_below_lines;
+
+ if (tag->pixels_inside_wrap_set)
+ dest->pixels_inside_wrap = vals->pixels_inside_wrap;
+
+ if (tag->tabs_set)
+ {
+ if (dest->tabs)
+ pango_tab_array_free (dest->tabs);
+ dest->tabs = pango_tab_array_copy (vals->tabs);
+ }
+
+ if (tag->wrap_mode_set)
+ dest->wrap_mode = vals->wrap_mode;
+
+ if (tag->underline_set)
+ dest->appearance.underline = vals->appearance.underline;
+
+ if (tag->strikethrough_set)
+ dest->appearance.strikethrough = vals->appearance.strikethrough;
+
+ if (tag->invisible_set)
+ dest->invisible = vals->invisible;
+
+ if (tag->editable_set)
+ dest->editable = vals->editable;
+
+ if (tag->bg_full_height_set)
+ dest->bg_full_height = vals->bg_full_height;
+
+ if (tag->language_set)
+ dest->language = vals->language;
+ }
+
+ dest->left_margin += left_margin_accumulative;
+ dest->right_margin += right_margin_accumulative;
+}
+
void
brasero_jacket_buffer_add_default_tag (BraseroJacketBuffer *self,
GtkTextTag *tag)
@@ -63,7 +196,24 @@
BraseroJacketBufferPrivate *priv;
priv = BRASERO_JACKET_BUFFER_PRIVATE (self);
- priv->tags = g_slist_prepend (priv->tags, tag);
+
+ g_object_ref (tag);
+ priv->tags = g_slist_append (priv->tags, tag);
+}
+
+void
+brasero_jacket_buffer_get_attributes (BraseroJacketBuffer *self,
+ GtkTextAttributes *attributes)
+{
+ BraseroJacketBufferPrivate *priv;
+
+ priv = BRASERO_JACKET_BUFFER_PRIVATE (self);
+
+ /* Now also merge changes that are 'on hold', that is non applied tags */
+ if (!priv->tags)
+ return;
+
+ _gtk_text_attributes_fill_from_tags (attributes, priv->tags);
}
static void
@@ -92,8 +242,12 @@
else
gtk_text_buffer_get_iter_at_offset (GTK_TEXT_BUFFER (buffer), &iter, pos);
+ g_slist_foreach (priv->tags, (GFunc) g_object_unref, NULL);
g_slist_free (priv->tags);
+ priv->tags = NULL;
+
priv->tags = gtk_text_iter_get_tags (&iter);
+ g_slist_foreach (priv->tags, (GFunc) g_object_ref, NULL);
}
static void
Modified: trunk/src/brasero-jacket-buffer.h
==============================================================================
--- trunk/src/brasero-jacket-buffer.h (original)
+++ trunk/src/brasero-jacket-buffer.h Thu Feb 12 14:03:44 2009
@@ -52,10 +52,14 @@
brasero_jacket_buffer_new (void);
void
-brasero_jacket_buffer_add_default_tag (BraseroJacketBuffer *buffer,
+brasero_jacket_buffer_add_default_tag (BraseroJacketBuffer *self,
GtkTextTag *tag);
void
+brasero_jacket_buffer_get_attributes (BraseroJacketBuffer *self,
+ GtkTextAttributes *attributes);
+
+void
brasero_jacket_buffer_set_default_text (BraseroJacketBuffer *self,
const gchar *default_text);
Modified: trunk/src/brasero-jacket-edit.c
==============================================================================
--- trunk/src/brasero-jacket-edit.c (original)
+++ trunk/src/brasero-jacket-edit.c Thu Feb 12 14:03:44 2009
@@ -241,7 +241,6 @@
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);
@@ -359,12 +358,12 @@
BraseroJacketEdit *self)
{
BraseroJacketEditPrivate *priv;
- PangoFontDescription *desc;
- const gchar *font_name;
+ gchar *font_family = NULL;
+ GtkTextTag *tag_family;
GtkTextBuffer *buffer;
+ GtkTextTag *tag_size;
GtkTextIter start;
GtkTextIter end;
- GtkTextTag *tag;
priv = BRASERO_JACKET_EDIT_PRIVATE (self);
@@ -375,21 +374,27 @@
if (!buffer)
return;
- font_name = brasero_jacket_font_get_name (button);
- if (!font_name)
- return;
+ /* Create two tags, one for the family, one for the size */
+ font_family = brasero_jacket_font_get_family (button);
+ if (font_family) {
+ tag_family = gtk_text_buffer_create_tag (buffer, NULL,
+ "family", font_family,
+ NULL);
+ g_free (font_family);
+ }
- desc = pango_font_description_from_string (font_name);
- tag = gtk_text_buffer_create_tag (buffer, NULL,
- "font-desc", desc,
- NULL);
+ tag_size = gtk_text_buffer_create_tag (buffer, NULL,
+ "size", brasero_jacket_font_get_size (button),
+ 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);
+ gtk_text_buffer_apply_tag (buffer, tag_size, &start, &end);
+ gtk_text_buffer_apply_tag (buffer, tag_family, &start, &end);
}
- else
- brasero_jacket_buffer_add_default_tag (BRASERO_JACKET_BUFFER (buffer), tag);
+
+ brasero_jacket_buffer_add_default_tag (BRASERO_JACKET_BUFFER (buffer), tag_size);
+ brasero_jacket_buffer_add_default_tag (BRASERO_JACKET_BUFFER (buffer), tag_family);
}
static void
@@ -415,14 +420,20 @@
priv = BRASERO_JACKET_EDIT_PRIVATE (self);
- if (priv->current_view) {
+ if (priv->current_view)
buffer = brasero_jacket_view_get_active_buffer (BRASERO_JACKET_VIEW (priv->current_view));
- gtk_widget_set_sensitive (priv->background, TRUE);
- }
- else {
+ else
buffer = NULL;
- gtk_widget_set_sensitive (priv->background, FALSE);
- }
+
+ gtk_widget_set_sensitive (priv->background, buffer != NULL);
+ gtk_widget_set_sensitive (priv->bold, buffer != NULL);
+ gtk_widget_set_sensitive (priv->italic, buffer != NULL);
+ gtk_widget_set_sensitive (priv->underline, buffer != NULL);
+ gtk_widget_set_sensitive (priv->right, buffer != NULL);
+ gtk_widget_set_sensitive (priv->left, buffer != NULL);
+ gtk_widget_set_sensitive (priv->center, buffer != NULL);
+ gtk_widget_set_sensitive (priv->fonts, buffer != NULL);
+ gtk_widget_set_sensitive (priv->colours, buffer != NULL);
if (!buffer)
return;
@@ -436,8 +447,7 @@
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);
+ attributes = brasero_jacket_view_get_attributes (BRASERO_JACKET_VIEW (priv->current_view), &iter);
brasero_tool_color_picker_set_color (BRASERO_TOOL_COLOR_PICKER (priv->colours), &attributes->appearance.fg_color);
@@ -712,8 +722,6 @@
sprintf (string, "%i", size);
brasero_jacket_font_set_name (BRASERO_JACKET_FONT (priv->fonts), "Sans 12");
}
-
- gtk_widget_grab_focus (priv->front);
}
#define BRASERO_JACKET_EDIT_INSERT_TAGGED_TEXT(buffer_MACRO, text_MACRO, tag_MACRO, start_MACRO) \
@@ -732,7 +740,10 @@
priv = BRASERO_JACKET_EDIT_PRIVATE (self);
- /* Set background for front cover */
+ g_signal_handlers_block_by_func (priv->front, brasero_jacket_edit_tags_changed_cb, self);
+ g_signal_handlers_block_by_func (priv->back, brasero_jacket_edit_tags_changed_cb, self);
+
+ /* set background for front cover */
if (cover) {
gchar *path;
@@ -744,49 +755,45 @@
brasero_jacket_view_set_image (BRASERO_JACKET_VIEW (priv->front), path);
g_free (path);
}
- else {
- /* Otherwise we create a very rough one */
+
+ /* create the tags for front cover */
+ if (label) {
buffer = brasero_jacket_view_get_body_buffer (BRASERO_JACKET_VIEW (priv->front));
- /* create the tags */
gtk_text_buffer_create_tag (buffer,
"Title",
"justification", GTK_JUSTIFY_CENTER,
"weight", PANGO_WEIGHT_BOLD,
- "scale", PANGO_SCALE_X_LARGE,
- "stretch", PANGO_STRETCH_ULTRA_EXPANDED,
+ "size", 14 * PANGO_SCALE,
NULL);
gtk_text_buffer_get_start_iter (buffer, &start);
- if (label) {
- BRASERO_JACKET_EDIT_INSERT_TAGGED_TEXT (buffer, "\n\n\n\n", "Title", &start);
- BRASERO_JACKET_EDIT_INSERT_TAGGED_TEXT (buffer, label, "Title", &start);
- }
+ BRASERO_JACKET_EDIT_INSERT_TAGGED_TEXT (buffer, "\n\n\n\n", "Title", &start);
+ BRASERO_JACKET_EDIT_INSERT_TAGGED_TEXT (buffer, label, "Title", &start);
}
+ /* create the tags for back cover */
buffer = brasero_jacket_view_get_body_buffer (BRASERO_JACKET_VIEW (priv->back));
- /* create the tags */
gtk_text_buffer_create_tag (buffer,
"Title",
"justification", GTK_JUSTIFY_CENTER,
"weight", PANGO_WEIGHT_BOLD,
- "scale", PANGO_SCALE_LARGE,
- "stretch", PANGO_STRETCH_ULTRA_EXPANDED,
+ "size", 12 * PANGO_SCALE,
NULL);
gtk_text_buffer_create_tag (buffer,
"Subtitle",
"justification", GTK_JUSTIFY_LEFT,
"weight", PANGO_WEIGHT_NORMAL,
+ "size", 10 * PANGO_SCALE,
NULL);
gtk_text_buffer_create_tag (buffer,
"Artist",
"weight", PANGO_WEIGHT_NORMAL,
"justification", GTK_JUSTIFY_LEFT,
- "stretch", PANGO_STRETCH_NORMAL,
+ "size", 8 * PANGO_SCALE,
"style", PANGO_STYLE_ITALIC,
- "scale", PANGO_SCALE_SMALL,
NULL);
gtk_text_buffer_get_start_iter (buffer, &start);
@@ -856,12 +863,12 @@
/* side */
buffer = brasero_jacket_view_get_side_buffer (BRASERO_JACKET_VIEW (priv->back));
- /* create the tags */
+ /* create the tags for sides */
gtk_text_buffer_create_tag (buffer,
"Title",
"justification", GTK_JUSTIFY_CENTER,
"weight", PANGO_WEIGHT_BOLD,
- "stretch", PANGO_STRETCH_ULTRA_EXPANDED,
+ "size", 10 * PANGO_SCALE,
NULL);
gtk_text_buffer_get_start_iter (buffer, &start);
@@ -869,6 +876,9 @@
if (label) {
BRASERO_JACKET_EDIT_INSERT_TAGGED_TEXT (buffer, label, "Title", &start);
}
+
+ g_signal_handlers_unblock_by_func (priv->front, brasero_jacket_edit_tags_changed_cb, self);
+ g_signal_handlers_unblock_by_func (priv->back, brasero_jacket_edit_tags_changed_cb, self);
}
static void
@@ -917,6 +927,8 @@
if (contents_ret)
*contents_ret = BRASERO_JACKET_EDIT (contents);
+ brasero_jacket_edit_update_button_state (BRASERO_JACKET_EDIT (contents));
+
return window;
}
Modified: trunk/src/brasero-jacket-font.c
==============================================================================
--- trunk/src/brasero-jacket-font.c (original)
+++ trunk/src/brasero-jacket-font.c Thu Feb 12 14:03:44 2009
@@ -173,44 +173,45 @@
}
gchar *
-brasero_jacket_font_get_name (BraseroJacketFont *self)
+brasero_jacket_font_get_family (BraseroJacketFont *self)
{
- gint size;
- gchar *string;
GtkTreeIter iter;
GtkTreeModel *model;
- PangoFontFamily *family;
- PangoFontDescription *desc;
+ gchar *family = NULL;
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
+ if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->family), &iter))
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;
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->family));
+ gtk_tree_model_get (model, &iter,
+ FAMILY_STRING_COL, &family,
+ -1);
+ return family;
}
+guint
+brasero_jacket_font_get_size (BraseroJacketFont *self)
+{
+ guint size;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ BraseroJacketFontPrivate *priv;
+
+ priv = BRASERO_JACKET_FONT_PRIVATE (self);
+
+ if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (priv->size), &iter))
+ return 0;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (priv->size));
+ gtk_tree_model_get (model, &iter,
+ SIZE_COL, &size,
+ -1);
+
+ return size * PANGO_SCALE;
+}
static void
brasero_jacket_fill_sizes (BraseroJacketFont *self)
{
Modified: trunk/src/brasero-jacket-font.h
==============================================================================
--- trunk/src/brasero-jacket-font.h (original)
+++ trunk/src/brasero-jacket-font.h Thu Feb 12 14:03:44 2009
@@ -56,7 +56,10 @@
const gchar *name);
gchar *
-brasero_jacket_font_get_name (BraseroJacketFont *font);
+brasero_jacket_font_get_family (BraseroJacketFont *font);
+
+guint
+brasero_jacket_font_get_size (BraseroJacketFont *font);
G_END_DECLS
Modified: trunk/src/brasero-jacket-view.c
==============================================================================
--- trunk/src/brasero-jacket-view.c (original)
+++ trunk/src/brasero-jacket-view.c Thu Feb 12 14:03:44 2009
@@ -584,6 +584,9 @@
GParamSpec *spec,
BraseroJacketView *self)
{
+ BraseroJacketViewPrivate *priv;
+
+ priv = BRASERO_JACKET_VIEW_PRIVATE (self);
g_signal_emit (self,
jacket_view_signals [TAGS_CHANGED],
0);
@@ -1148,12 +1151,27 @@
}
GtkTextAttributes *
-brasero_jacket_view_get_default_attributes (BraseroJacketView *self)
+brasero_jacket_view_get_attributes (BraseroJacketView *self,
+ GtkTextIter *iter)
{
BraseroJacketViewPrivate *priv;
+ GtkTextAttributes *attributes;
+ GtkTextBuffer *buffer;
priv = BRASERO_JACKET_VIEW_PRIVATE (self);
- return gtk_text_view_get_default_attributes (GTK_TEXT_VIEW (priv->edit));
+
+ attributes = gtk_text_view_get_default_attributes (GTK_TEXT_VIEW (priv->edit));
+
+ if (iter)
+ gtk_text_iter_get_attributes (iter, attributes);
+
+ /* Now also merge changes that are 'on hold', that is non applied tags */
+ buffer = brasero_jacket_view_get_active_buffer (self);
+ if (!buffer)
+ return attributes;
+
+ brasero_jacket_buffer_get_attributes (BRASERO_JACKET_BUFFER (buffer), attributes);
+ return attributes;
}
GtkTextBuffer *
@@ -1526,6 +1544,7 @@
G_CALLBACK (brasero_jacket_view_scrolled_cb),
priv->edit);
+ gtk_container_set_focus_child (GTK_CONTAINER (object), priv->edit);
gtk_widget_set_scroll_adjustments (priv->edit,
GTK_ADJUSTMENT (hadj),
GTK_ADJUSTMENT (vadj));
Modified: trunk/src/brasero-jacket-view.h
==============================================================================
--- trunk/src/brasero-jacket-view.h (original)
+++ trunk/src/brasero-jacket-view.h Thu Feb 12 14:03:44 2009
@@ -79,6 +79,10 @@
brasero_jacket_view_new (void);
void
+brasero_jacket_view_add_default_tag (BraseroJacketView *self,
+ GtkTextTag *tag);
+
+void
brasero_jacket_view_set_side (BraseroJacketView *view,
BraseroJacketSide side);
@@ -123,7 +127,8 @@
brasero_jacket_view_get_side_buffer (BraseroJacketView *view);
GtkTextAttributes *
-brasero_jacket_view_get_default_attributes (BraseroJacketView *view);
+brasero_jacket_view_get_attributes (BraseroJacketView *view,
+ GtkTextIter *iter);
G_END_DECLS
Modified: trunk/src/brasero-tool-color-picker.c
==============================================================================
--- trunk/src/brasero-tool-color-picker.c (original)
+++ trunk/src/brasero-tool-color-picker.c Thu Feb 12 14:03:44 2009
@@ -135,8 +135,6 @@
gtk_widget_destroy (priv->dialog);
priv->dialog = NULL;
- gtk_widget_queue_draw (priv->icon);
-
g_signal_emit (self,
tool_color_picker_signals[COLOR_SET_SIGNAL],
0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]