Commit 6a3a43dd authored by Matthias Clasen's avatar Matthias Clasen Committed by Matthias Clasen

Add a way to specify accumulative margins. (#344499, Nate Nielsen)

2007-04-28  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtktexttag.[hc]: Add a way to specify accumulative
        margins.  (#344499, Nate Nielsen)



svn path=/trunk/; revision=17685
parent 8dd48ab1
2007-04-28 Matthias Clasen <mclasen@redhat.com>
* gtk/gtktexttag.[hc]: Add a way to specify accumulative
margins. (#344499, Nate Nielsen)
2007-04-28 Matthias Clasen <mclasen@redhat.com>
* gtk/gtkeventbox.c (gtk_event_box_realize): Fix the offsets
......
......@@ -106,6 +106,9 @@ enum {
PROP_INVISIBLE,
PROP_PARAGRAPH_BACKGROUND,
PROP_PARAGRAPH_BACKGROUND_GDK,
/* Behavior args */
PROP_ACCUMULATIVE_MARGIN,
/* Whether-a-style-arg-is-set args */
PROP_BACKGROUND_SET,
......@@ -534,6 +537,25 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
GDK_TYPE_COLOR,
GTK_PARAM_READWRITE));
/**
* GtkTextTag:accumulative-margin:
*
* Whether the margins accumulate or override each other.
*
* When set to %TRUE the margins of this tag are added to the margins
* of any other non-accumulative margins present. When set to %FALSE
* the margins override one another (the default).
*
* Since: 2.12
*/
g_object_class_install_property (object_class,
PROP_ACCUMULATIVE_MARGIN,
g_param_spec_boolean ("accumulative-margin",
P_("Margin Accumulates"),
P_("Whether left and right margins accumulate."),
FALSE,
GTK_PARAM_READWRITE));
/* Style props are set or not */
#define ADD_SET_PROP(propname, propval, nick, blurb) g_object_class_install_property (object_class, propval, g_param_spec_boolean (propname, nick, blurb, FALSE, GTK_PARAM_READWRITE))
......@@ -1290,6 +1312,12 @@ gtk_text_tag_set_property (GObject *object,
}
break;
case PROP_ACCUMULATIVE_MARGIN:
text_tag->accumulative_margin = g_value_get_boolean (value);
g_object_notify (object, "accumulative-margin");
size_changed = TRUE;
break;
/* Whether the value should be used... */
case PROP_BACKGROUND_SET:
......@@ -1616,6 +1644,10 @@ gtk_text_tag_get_property (GObject *object,
g_value_set_boxed (value, tag->values->pg_bg_color);
break;
case PROP_ACCUMULATIVE_MARGIN:
g_value_set_boolean (value, tag->accumulative_margin);
break;
case PROP_BACKGROUND_SET:
g_value_set_boolean (value, tag->bg_color_set);
break;
......@@ -2148,6 +2180,9 @@ _gtk_text_attributes_fill_from_tags (GtkTextAttributes *dest,
{
guint n = 0;
guint left_margin_accumulative = 0;
guint right_margin_accumulative = 0;
g_return_if_fail (!dest->realized);
while (n < n_tags)
......@@ -2209,8 +2244,13 @@ _gtk_text_attributes_fill_from_tags (GtkTextAttributes *dest,
if (vals->direction != GTK_TEXT_DIR_NONE)
dest->direction = vals->direction;
if (tag->left_margin_set)
dest->left_margin = vals->left_margin;
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;
......@@ -2218,8 +2258,13 @@ _gtk_text_attributes_fill_from_tags (GtkTextAttributes *dest,
if (tag->rise_set)
dest->appearance.rise = vals->appearance.rise;
if (tag->right_margin_set)
dest->right_margin = vals->right_margin;
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;
......@@ -2260,6 +2305,9 @@ _gtk_text_attributes_fill_from_tags (GtkTextAttributes *dest,
++n;
}
dest->left_margin += left_margin_accumulative;
dest->right_margin += right_margin_accumulative;
}
gboolean
......
......@@ -125,8 +125,11 @@ struct _GtkTextTag
guint editable_set : 1;
guint language_set : 1;
guint pg_bg_color_set : 1;
/* Whether these margins accumulate or override */
guint accumulative_margin : 1;
guint pad1 : 1;
guint pad2 : 1;
};
struct _GtkTextTagClass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment