hack on this a bit

2001-01-05  Havoc Pennington  <hp@redhat.com>

	* tests/testtreeview.c: hack on this a bit

	* gtk/gtktextlayout.c (gtk_text_layout_class_init):
	s/GTK_RUN_LAST/G_SIGNAL_RUN_LAST

	* gtk/gtktreemodelsimple.h (GTK_IS_TREE_MODEL_SIMPLE_CLASS):
	was spelled incorrectly
	(GTK_IS_TREE_MODEL_SIMPLE): ditto

	* gtk/gtktreeview.c (gtk_tree_view_set_headers_clickable): rename
	from gtk_tree_view_set_headers_active

	* gtk/gtktexttag.c:
	(gtk_text_tag_get_property): handle PROP_DIRECTION
	(gtk_text_tag_set_property): g_object_notify when we toggle the _set
	properties, bug 40235

	* gtk/gtktextiter.c (gtk_text_iter_forward_to_delimiters): rename
	forward_to_line_end
This commit is contained in:
Havoc Pennington 2001-01-06 01:31:58 +00:00 committed by Havoc Pennington
parent eb2fdbb176
commit 5c37906778
18 changed files with 1003 additions and 78 deletions

View File

@ -1,7 +1,29 @@
2001-01-05 Havoc Pennington <hp@redhat.com>
* tests/testtreeview.c: hack on this a bit
* gtk/gtktextlayout.c (gtk_text_layout_class_init):
s/GTK_RUN_LAST/G_SIGNAL_RUN_LAST
* gtk/gtktreemodelsimple.h (GTK_IS_TREE_MODEL_SIMPLE_CLASS):
was spelled incorrectly
(GTK_IS_TREE_MODEL_SIMPLE): ditto
* gtk/gtktreeview.c (gtk_tree_view_set_headers_clickable): rename
from gtk_tree_view_set_headers_active
* gtk/gtktexttag.c:
(gtk_text_tag_get_property): handle PROP_DIRECTION
(gtk_text_tag_set_property): g_object_notify when we toggle the _set
properties, bug 40235
* gtk/gtktextiter.c (gtk_text_iter_forward_to_delimiters): rename
forward_to_line_end
Fri Jan 5 16:16:29 2001 Owen Taylor <otaylor@redhat.com> Fri Jan 5 16:16:29 2001 Owen Taylor <otaylor@redhat.com>
* gtk/{gtkcalender.c,gtkfilesel.c,gtkimcontext.c}, * gtk/{gtkcalender.c,gtkfilesel.c,gtkimcontext.c},
modules/input/gtkimcontextxim.c: Adopt to new prototypes modules/input/gtkimcontextxim.c: Adapt to new prototypes
for unicode,locale,filename conversion functions. for unicode,locale,filename conversion functions.
2001-01-05 Havoc Pennington <hp@redhat.com> 2001-01-05 Havoc Pennington <hp@redhat.com>

View File

@ -1,7 +1,29 @@
2001-01-05 Havoc Pennington <hp@redhat.com>
* tests/testtreeview.c: hack on this a bit
* gtk/gtktextlayout.c (gtk_text_layout_class_init):
s/GTK_RUN_LAST/G_SIGNAL_RUN_LAST
* gtk/gtktreemodelsimple.h (GTK_IS_TREE_MODEL_SIMPLE_CLASS):
was spelled incorrectly
(GTK_IS_TREE_MODEL_SIMPLE): ditto
* gtk/gtktreeview.c (gtk_tree_view_set_headers_clickable): rename
from gtk_tree_view_set_headers_active
* gtk/gtktexttag.c:
(gtk_text_tag_get_property): handle PROP_DIRECTION
(gtk_text_tag_set_property): g_object_notify when we toggle the _set
properties, bug 40235
* gtk/gtktextiter.c (gtk_text_iter_forward_to_delimiters): rename
forward_to_line_end
Fri Jan 5 16:16:29 2001 Owen Taylor <otaylor@redhat.com> Fri Jan 5 16:16:29 2001 Owen Taylor <otaylor@redhat.com>
* gtk/{gtkcalender.c,gtkfilesel.c,gtkimcontext.c}, * gtk/{gtkcalender.c,gtkfilesel.c,gtkimcontext.c},
modules/input/gtkimcontextxim.c: Adopt to new prototypes modules/input/gtkimcontextxim.c: Adapt to new prototypes
for unicode,locale,filename conversion functions. for unicode,locale,filename conversion functions.
2001-01-05 Havoc Pennington <hp@redhat.com> 2001-01-05 Havoc Pennington <hp@redhat.com>

View File

@ -1,7 +1,29 @@
2001-01-05 Havoc Pennington <hp@redhat.com>
* tests/testtreeview.c: hack on this a bit
* gtk/gtktextlayout.c (gtk_text_layout_class_init):
s/GTK_RUN_LAST/G_SIGNAL_RUN_LAST
* gtk/gtktreemodelsimple.h (GTK_IS_TREE_MODEL_SIMPLE_CLASS):
was spelled incorrectly
(GTK_IS_TREE_MODEL_SIMPLE): ditto
* gtk/gtktreeview.c (gtk_tree_view_set_headers_clickable): rename
from gtk_tree_view_set_headers_active
* gtk/gtktexttag.c:
(gtk_text_tag_get_property): handle PROP_DIRECTION
(gtk_text_tag_set_property): g_object_notify when we toggle the _set
properties, bug 40235
* gtk/gtktextiter.c (gtk_text_iter_forward_to_delimiters): rename
forward_to_line_end
Fri Jan 5 16:16:29 2001 Owen Taylor <otaylor@redhat.com> Fri Jan 5 16:16:29 2001 Owen Taylor <otaylor@redhat.com>
* gtk/{gtkcalender.c,gtkfilesel.c,gtkimcontext.c}, * gtk/{gtkcalender.c,gtkfilesel.c,gtkimcontext.c},
modules/input/gtkimcontextxim.c: Adopt to new prototypes modules/input/gtkimcontextxim.c: Adapt to new prototypes
for unicode,locale,filename conversion functions. for unicode,locale,filename conversion functions.
2001-01-05 Havoc Pennington <hp@redhat.com> 2001-01-05 Havoc Pennington <hp@redhat.com>

View File

@ -1,7 +1,29 @@
2001-01-05 Havoc Pennington <hp@redhat.com>
* tests/testtreeview.c: hack on this a bit
* gtk/gtktextlayout.c (gtk_text_layout_class_init):
s/GTK_RUN_LAST/G_SIGNAL_RUN_LAST
* gtk/gtktreemodelsimple.h (GTK_IS_TREE_MODEL_SIMPLE_CLASS):
was spelled incorrectly
(GTK_IS_TREE_MODEL_SIMPLE): ditto
* gtk/gtktreeview.c (gtk_tree_view_set_headers_clickable): rename
from gtk_tree_view_set_headers_active
* gtk/gtktexttag.c:
(gtk_text_tag_get_property): handle PROP_DIRECTION
(gtk_text_tag_set_property): g_object_notify when we toggle the _set
properties, bug 40235
* gtk/gtktextiter.c (gtk_text_iter_forward_to_delimiters): rename
forward_to_line_end
Fri Jan 5 16:16:29 2001 Owen Taylor <otaylor@redhat.com> Fri Jan 5 16:16:29 2001 Owen Taylor <otaylor@redhat.com>
* gtk/{gtkcalender.c,gtkfilesel.c,gtkimcontext.c}, * gtk/{gtkcalender.c,gtkfilesel.c,gtkimcontext.c},
modules/input/gtkimcontextxim.c: Adopt to new prototypes modules/input/gtkimcontextxim.c: Adapt to new prototypes
for unicode,locale,filename conversion functions. for unicode,locale,filename conversion functions.
2001-01-05 Havoc Pennington <hp@redhat.com> 2001-01-05 Havoc Pennington <hp@redhat.com>

View File

@ -1,7 +1,29 @@
2001-01-05 Havoc Pennington <hp@redhat.com>
* tests/testtreeview.c: hack on this a bit
* gtk/gtktextlayout.c (gtk_text_layout_class_init):
s/GTK_RUN_LAST/G_SIGNAL_RUN_LAST
* gtk/gtktreemodelsimple.h (GTK_IS_TREE_MODEL_SIMPLE_CLASS):
was spelled incorrectly
(GTK_IS_TREE_MODEL_SIMPLE): ditto
* gtk/gtktreeview.c (gtk_tree_view_set_headers_clickable): rename
from gtk_tree_view_set_headers_active
* gtk/gtktexttag.c:
(gtk_text_tag_get_property): handle PROP_DIRECTION
(gtk_text_tag_set_property): g_object_notify when we toggle the _set
properties, bug 40235
* gtk/gtktextiter.c (gtk_text_iter_forward_to_delimiters): rename
forward_to_line_end
Fri Jan 5 16:16:29 2001 Owen Taylor <otaylor@redhat.com> Fri Jan 5 16:16:29 2001 Owen Taylor <otaylor@redhat.com>
* gtk/{gtkcalender.c,gtkfilesel.c,gtkimcontext.c}, * gtk/{gtkcalender.c,gtkfilesel.c,gtkimcontext.c},
modules/input/gtkimcontextxim.c: Adopt to new prototypes modules/input/gtkimcontextxim.c: Adapt to new prototypes
for unicode,locale,filename conversion functions. for unicode,locale,filename conversion functions.
2001-01-05 Havoc Pennington <hp@redhat.com> 2001-01-05 Havoc Pennington <hp@redhat.com>

View File

@ -1,7 +1,29 @@
2001-01-05 Havoc Pennington <hp@redhat.com>
* tests/testtreeview.c: hack on this a bit
* gtk/gtktextlayout.c (gtk_text_layout_class_init):
s/GTK_RUN_LAST/G_SIGNAL_RUN_LAST
* gtk/gtktreemodelsimple.h (GTK_IS_TREE_MODEL_SIMPLE_CLASS):
was spelled incorrectly
(GTK_IS_TREE_MODEL_SIMPLE): ditto
* gtk/gtktreeview.c (gtk_tree_view_set_headers_clickable): rename
from gtk_tree_view_set_headers_active
* gtk/gtktexttag.c:
(gtk_text_tag_get_property): handle PROP_DIRECTION
(gtk_text_tag_set_property): g_object_notify when we toggle the _set
properties, bug 40235
* gtk/gtktextiter.c (gtk_text_iter_forward_to_delimiters): rename
forward_to_line_end
Fri Jan 5 16:16:29 2001 Owen Taylor <otaylor@redhat.com> Fri Jan 5 16:16:29 2001 Owen Taylor <otaylor@redhat.com>
* gtk/{gtkcalender.c,gtkfilesel.c,gtkimcontext.c}, * gtk/{gtkcalender.c,gtkfilesel.c,gtkimcontext.c},
modules/input/gtkimcontextxim.c: Adopt to new prototypes modules/input/gtkimcontextxim.c: Adapt to new prototypes
for unicode,locale,filename conversion functions. for unicode,locale,filename conversion functions.
2001-01-05 Havoc Pennington <hp@redhat.com> 2001-01-05 Havoc Pennington <hp@redhat.com>

View File

@ -1,7 +1,29 @@
2001-01-05 Havoc Pennington <hp@redhat.com>
* tests/testtreeview.c: hack on this a bit
* gtk/gtktextlayout.c (gtk_text_layout_class_init):
s/GTK_RUN_LAST/G_SIGNAL_RUN_LAST
* gtk/gtktreemodelsimple.h (GTK_IS_TREE_MODEL_SIMPLE_CLASS):
was spelled incorrectly
(GTK_IS_TREE_MODEL_SIMPLE): ditto
* gtk/gtktreeview.c (gtk_tree_view_set_headers_clickable): rename
from gtk_tree_view_set_headers_active
* gtk/gtktexttag.c:
(gtk_text_tag_get_property): handle PROP_DIRECTION
(gtk_text_tag_set_property): g_object_notify when we toggle the _set
properties, bug 40235
* gtk/gtktextiter.c (gtk_text_iter_forward_to_delimiters): rename
forward_to_line_end
Fri Jan 5 16:16:29 2001 Owen Taylor <otaylor@redhat.com> Fri Jan 5 16:16:29 2001 Owen Taylor <otaylor@redhat.com>
* gtk/{gtkcalender.c,gtkfilesel.c,gtkimcontext.c}, * gtk/{gtkcalender.c,gtkfilesel.c,gtkimcontext.c},
modules/input/gtkimcontextxim.c: Adopt to new prototypes modules/input/gtkimcontextxim.c: Adapt to new prototypes
for unicode,locale,filename conversion functions. for unicode,locale,filename conversion functions.
2001-01-05 Havoc Pennington <hp@redhat.com> 2001-01-05 Havoc Pennington <hp@redhat.com>

View File

@ -2962,7 +2962,7 @@ gtk_text_iter_forward_to_end (GtkTextIter *iter)
} }
/** /**
* gtk_text_iter_forward_to_delimiters: * gtk_text_iter_forward_to_line_end:
* @iter: a #GtkTextIter * @iter: a #GtkTextIter
* *
* Moves the iterator to point to the paragraph delimiter characters, * Moves the iterator to point to the paragraph delimiter characters,
@ -2975,7 +2975,7 @@ gtk_text_iter_forward_to_end (GtkTextIter *iter)
* Return value: %TRUE if we moved and the new location is not the end iterator * Return value: %TRUE if we moved and the new location is not the end iterator
**/ **/
gboolean gboolean
gtk_text_iter_forward_to_delimiters (GtkTextIter *iter) gtk_text_iter_forward_to_line_end (GtkTextIter *iter)
{ {
gint current_offset; gint current_offset;
gint new_offset; gint new_offset;
@ -3001,7 +3001,7 @@ gtk_text_iter_forward_to_delimiters (GtkTextIter *iter)
* empty lines. * empty lines.
*/ */
if (!gtk_text_iter_ends_line (iter)) if (!gtk_text_iter_ends_line (iter))
gtk_text_iter_forward_to_delimiters (iter); gtk_text_iter_forward_to_line_end (iter);
return TRUE; return TRUE;
} }
else else

View File

@ -185,7 +185,7 @@ void gtk_text_iter_set_line_offset (GtkTextIter *iter,
void gtk_text_iter_set_line_index (GtkTextIter *iter, void gtk_text_iter_set_line_index (GtkTextIter *iter,
gint byte_on_line); gint byte_on_line);
void gtk_text_iter_forward_to_end (GtkTextIter *iter); void gtk_text_iter_forward_to_end (GtkTextIter *iter);
gboolean gtk_text_iter_forward_to_delimiters (GtkTextIter *iter); gboolean gtk_text_iter_forward_to_line_end (GtkTextIter *iter);
/* returns TRUE if a toggle was found; NULL for the tag pointer /* returns TRUE if a toggle was found; NULL for the tag pointer

View File

@ -174,7 +174,7 @@ gtk_text_layout_class_init (GtkTextLayoutClass *klass)
signals[INVALIDATED] = signals[INVALIDATED] =
g_signal_newc ("invalidated", g_signal_newc ("invalidated",
G_TYPE_FROM_CLASS (object_class), G_TYPE_FROM_CLASS (object_class),
GTK_RUN_LAST, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkTextLayoutClass, invalidated), G_STRUCT_OFFSET (GtkTextLayoutClass, invalidated),
NULL, NULL,
gtk_marshal_VOID__VOID, gtk_marshal_VOID__VOID,
@ -184,7 +184,7 @@ gtk_text_layout_class_init (GtkTextLayoutClass *klass)
signals[CHANGED] = signals[CHANGED] =
g_signal_newc ("changed", g_signal_newc ("changed",
G_TYPE_FROM_CLASS (object_class), G_TYPE_FROM_CLASS (object_class),
GTK_RUN_LAST, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkTextLayoutClass, changed), G_STRUCT_OFFSET (GtkTextLayoutClass, changed),
NULL, NULL,
gtk_marshal_VOID__INT_INT_INT, gtk_marshal_VOID__INT_INT_INT,
@ -197,7 +197,7 @@ gtk_text_layout_class_init (GtkTextLayoutClass *klass)
signals[ALLOCATE_CHILD] = signals[ALLOCATE_CHILD] =
g_signal_newc ("allocate_child", g_signal_newc ("allocate_child",
G_TYPE_FROM_CLASS (object_class), G_TYPE_FROM_CLASS (object_class),
GTK_RUN_LAST, G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GtkTextLayoutClass, allocate_child), G_STRUCT_OFFSET (GtkTextLayoutClass, allocate_child),
NULL, NULL,
gtk_marshal_VOID__OBJECT_INT_INT, gtk_marshal_VOID__OBJECT_INT_INT,
@ -1956,7 +1956,7 @@ line_display_index_to_iter (GtkTextLayout *layout,
iter, display->line, 0); iter, display->line, 0);
if (!gtk_text_iter_ends_line (iter)) if (!gtk_text_iter_ends_line (iter))
gtk_text_iter_forward_to_delimiters (iter); gtk_text_iter_forward_to_line_end (iter);
} }
/* FIXME should this be cursor positions? */ /* FIXME should this be cursor positions? */

View File

@ -682,13 +682,22 @@ static void
set_bg_color (GtkTextTag *tag, GdkColor *color) set_bg_color (GtkTextTag *tag, GdkColor *color)
{ {
if (color) if (color)
{
if (!tag->bg_color_set)
{ {
tag->bg_color_set = TRUE; tag->bg_color_set = TRUE;
g_object_notify (G_OBJECT (tag), "bg_color_set");
}
tag->values->appearance.bg_color = *color; tag->values->appearance.bg_color = *color;
} }
else else
{
if (tag->bg_color_set)
{ {
tag->bg_color_set = FALSE; tag->bg_color_set = FALSE;
g_object_notify (G_OBJECT (tag), "bg_color_set");
}
} }
} }
@ -696,13 +705,21 @@ static void
set_fg_color (GtkTextTag *tag, GdkColor *color) set_fg_color (GtkTextTag *tag, GdkColor *color)
{ {
if (color) if (color)
{
if (!tag->fg_color_set)
{ {
tag->fg_color_set = TRUE; tag->fg_color_set = TRUE;
g_object_notify (G_OBJECT (tag), "fg_color_set");
}
tag->values->appearance.fg_color = *color; tag->values->appearance.fg_color = *color;
} }
else else
{
if (tag->fg_color_set)
{ {
tag->fg_color_set = FALSE; tag->fg_color_set = FALSE;
g_object_notify (G_OBJECT (tag), "fg_color_set");
}
} }
} }
@ -734,13 +751,37 @@ set_font_description (GtkTextTag *text_tag,
NULL); NULL);
} }
else else
{
if (text_tag->family_set)
{ {
text_tag->family_set = FALSE; text_tag->family_set = FALSE;
g_object_notify (G_OBJECT (text_tag), "family_set");
}
if (text_tag->style_set)
{
text_tag->style_set = FALSE; text_tag->style_set = FALSE;
g_object_notify (G_OBJECT (text_tag), "style_set");
}
if (text_tag->variant_set)
{
text_tag->variant_set = FALSE; text_tag->variant_set = FALSE;
g_object_notify (G_OBJECT (text_tag), "variant_set");
}
if (text_tag->weight_set)
{
text_tag->weight_set = FALSE; text_tag->weight_set = FALSE;
g_object_notify (G_OBJECT (text_tag), "weight_set");
}
if (text_tag->stretch_set)
{
text_tag->stretch_set = FALSE; text_tag->stretch_set = FALSE;
g_object_notify (G_OBJECT (text_tag), "stretch_set");
}
if (text_tag->size_set)
{
text_tag->size_set = FALSE; text_tag->size_set = FALSE;
g_object_notify (G_OBJECT (text_tag), "size_set");
}
} }
} }
@ -806,6 +847,7 @@ gtk_text_tag_set_property (GObject *object,
GdkBitmap *bitmap = g_value_get_as_pointer (value); GdkBitmap *bitmap = g_value_get_as_pointer (value);
text_tag->bg_stipple_set = TRUE; text_tag->bg_stipple_set = TRUE;
g_object_notify (G_OBJECT (text_tag), "bg_stipple_set");
if (text_tag->values->appearance.bg_stipple != bitmap) if (text_tag->values->appearance.bg_stipple != bitmap)
{ {
@ -825,6 +867,7 @@ gtk_text_tag_set_property (GObject *object,
GdkBitmap *bitmap = g_value_get_as_pointer (value); GdkBitmap *bitmap = g_value_get_as_pointer (value);
text_tag->fg_stipple_set = TRUE; text_tag->fg_stipple_set = TRUE;
g_object_notify (G_OBJECT (text_tag), "fg_stipple_set");
if (text_tag->values->appearance.fg_stipple != bitmap) if (text_tag->values->appearance.fg_stipple != bitmap)
{ {
@ -875,77 +918,90 @@ gtk_text_tag_set_property (GObject *object,
g_free (text_tag->values->font.family_name); g_free (text_tag->values->font.family_name);
text_tag->values->font.family_name = g_strdup (g_value_get_string (value)); text_tag->values->font.family_name = g_strdup (g_value_get_string (value));
text_tag->family_set = TRUE; text_tag->family_set = TRUE;
g_object_notify (G_OBJECT (text_tag), "family_set");
size_changed = TRUE; size_changed = TRUE;
break; break;
case PROP_STYLE: case PROP_STYLE:
text_tag->values->font.style = g_value_get_enum (value); text_tag->values->font.style = g_value_get_enum (value);
text_tag->style_set = TRUE; text_tag->style_set = TRUE;
g_object_notify (G_OBJECT (text_tag), "style_set");
size_changed = TRUE; size_changed = TRUE;
break; break;
case PROP_VARIANT: case PROP_VARIANT:
text_tag->values->font.variant = g_value_get_enum (value); text_tag->values->font.variant = g_value_get_enum (value);
text_tag->variant_set = TRUE; text_tag->variant_set = TRUE;
g_object_notify (G_OBJECT (text_tag), "variant_set");
size_changed = TRUE; size_changed = TRUE;
break; break;
case PROP_WEIGHT: case PROP_WEIGHT:
text_tag->values->font.weight = g_value_get_int (value); text_tag->values->font.weight = g_value_get_int (value);
text_tag->weight_set = TRUE; text_tag->weight_set = TRUE;
g_object_notify (G_OBJECT (text_tag), "weight_set");
size_changed = TRUE; size_changed = TRUE;
break; break;
case PROP_STRETCH: case PROP_STRETCH:
text_tag->values->font.stretch = g_value_get_enum (value); text_tag->values->font.stretch = g_value_get_enum (value);
text_tag->stretch_set = TRUE; text_tag->stretch_set = TRUE;
g_object_notify (G_OBJECT (text_tag), "stretch_set");
size_changed = TRUE; size_changed = TRUE;
break; break;
case PROP_SIZE: case PROP_SIZE:
text_tag->values->font.size = g_value_get_int (value); text_tag->values->font.size = g_value_get_int (value);
text_tag->size_set = TRUE; text_tag->size_set = TRUE;
g_object_notify (G_OBJECT (text_tag), "size_set");
size_changed = TRUE; size_changed = TRUE;
break; break;
case PROP_SIZE_POINTS: case PROP_SIZE_POINTS:
text_tag->values->font.size = g_value_get_double (value) * PANGO_SCALE; text_tag->values->font.size = g_value_get_double (value) * PANGO_SCALE;
text_tag->size_set = TRUE; text_tag->size_set = TRUE;
g_object_notify (G_OBJECT (text_tag), "size_set");
size_changed = TRUE; size_changed = TRUE;
break; break;
case PROP_PIXELS_ABOVE_LINES: case PROP_PIXELS_ABOVE_LINES:
text_tag->pixels_above_lines_set = TRUE; text_tag->pixels_above_lines_set = TRUE;
text_tag->values->pixels_above_lines = g_value_get_int (value); text_tag->values->pixels_above_lines = g_value_get_int (value);
g_object_notify (G_OBJECT (text_tag), "pixels_above_lines_set");
size_changed = TRUE; size_changed = TRUE;
break; break;
case PROP_PIXELS_BELOW_LINES: case PROP_PIXELS_BELOW_LINES:
text_tag->pixels_below_lines_set = TRUE; text_tag->pixels_below_lines_set = TRUE;
text_tag->values->pixels_below_lines = g_value_get_int (value); text_tag->values->pixels_below_lines = g_value_get_int (value);
g_object_notify (G_OBJECT (text_tag), "pixels_below_lines_set");
size_changed = TRUE; size_changed = TRUE;
break; break;
case PROP_PIXELS_INSIDE_WRAP: case PROP_PIXELS_INSIDE_WRAP:
text_tag->pixels_inside_wrap_set = TRUE; text_tag->pixels_inside_wrap_set = TRUE;
text_tag->values->pixels_inside_wrap = g_value_get_int (value); text_tag->values->pixels_inside_wrap = g_value_get_int (value);
g_object_notify (G_OBJECT (text_tag), "pixels_inside_wrap_set");
size_changed = TRUE; size_changed = TRUE;
break; break;
case PROP_EDITABLE: case PROP_EDITABLE:
text_tag->editable_set = TRUE; text_tag->editable_set = TRUE;
text_tag->values->editable = g_value_get_boolean (value); text_tag->values->editable = g_value_get_boolean (value);
g_object_notify (G_OBJECT (text_tag), "editable_set");
break; break;
case PROP_WRAP_MODE: case PROP_WRAP_MODE:
text_tag->wrap_mode_set = TRUE; text_tag->wrap_mode_set = TRUE;
text_tag->values->wrap_mode = g_value_get_enum (value); text_tag->values->wrap_mode = g_value_get_enum (value);
g_object_notify (G_OBJECT (text_tag), "wrap_mode_set");
size_changed = TRUE; size_changed = TRUE;
break; break;
case PROP_JUSTIFY: case PROP_JUSTIFY:
text_tag->justify_set = TRUE; text_tag->justify_set = TRUE;
text_tag->values->justify = g_value_get_enum (value); text_tag->values->justify = g_value_get_enum (value);
g_object_notify (G_OBJECT (text_tag), "justify_set");
size_changed = TRUE; size_changed = TRUE;
break; break;
@ -956,45 +1012,53 @@ gtk_text_tag_set_property (GObject *object,
case PROP_LEFT_MARGIN: case PROP_LEFT_MARGIN:
text_tag->left_margin_set = TRUE; text_tag->left_margin_set = TRUE;
text_tag->values->left_margin = g_value_get_int (value); text_tag->values->left_margin = g_value_get_int (value);
g_object_notify (G_OBJECT (text_tag), "left_margin_set");
size_changed = TRUE; size_changed = TRUE;
break; break;
case PROP_INDENT: case PROP_INDENT:
text_tag->indent_set = TRUE; text_tag->indent_set = TRUE;
text_tag->values->indent = g_value_get_int (value); text_tag->values->indent = g_value_get_int (value);
g_object_notify (G_OBJECT (text_tag), "indent_set");
size_changed = TRUE; size_changed = TRUE;
break; break;
case PROP_STRIKETHROUGH: case PROP_STRIKETHROUGH:
text_tag->strikethrough_set = TRUE; text_tag->strikethrough_set = TRUE;
text_tag->values->appearance.strikethrough = g_value_get_boolean (value); text_tag->values->appearance.strikethrough = g_value_get_boolean (value);
g_object_notify (G_OBJECT (text_tag), "strikethrough_set");
break; break;
case PROP_RIGHT_MARGIN: case PROP_RIGHT_MARGIN:
text_tag->right_margin_set = TRUE; text_tag->right_margin_set = TRUE;
text_tag->values->right_margin = g_value_get_int (value); text_tag->values->right_margin = g_value_get_int (value);
g_object_notify (G_OBJECT (text_tag), "right_margin_set");
size_changed = TRUE; size_changed = TRUE;
break; break;
case PROP_UNDERLINE: case PROP_UNDERLINE:
text_tag->underline_set = TRUE; text_tag->underline_set = TRUE;
text_tag->values->appearance.underline = g_value_get_enum (value); text_tag->values->appearance.underline = g_value_get_enum (value);
g_object_notify (G_OBJECT (text_tag), "underline_set");
break; break;
case PROP_RISE: case PROP_RISE:
text_tag->rise_set = TRUE; text_tag->rise_set = TRUE;
text_tag->values->appearance.rise = g_value_get_int (value); text_tag->values->appearance.rise = g_value_get_int (value);
g_object_notify (G_OBJECT (text_tag), "rise_set");
size_changed = TRUE; size_changed = TRUE;
break; break;
case PROP_BG_FULL_HEIGHT: case PROP_BG_FULL_HEIGHT:
text_tag->bg_full_height_set = TRUE; text_tag->bg_full_height_set = TRUE;
text_tag->values->bg_full_height = g_value_get_boolean (value); text_tag->values->bg_full_height = g_value_get_boolean (value);
g_object_notify (G_OBJECT (text_tag), "bg_full_height_set");
break; break;
case PROP_LANGUAGE: case PROP_LANGUAGE:
text_tag->language_set = TRUE; text_tag->language_set = TRUE;
text_tag->values->language = g_strdup (g_value_get_string (value)); text_tag->values->language = g_strdup (g_value_get_string (value));
g_object_notify (G_OBJECT (text_tag), "language_set");
break; break;
case PROP_TABS: case PROP_TABS:
@ -1007,12 +1071,15 @@ gtk_text_tag_set_property (GObject *object,
text_tag->values->tabs = text_tag->values->tabs =
pango_tab_array_copy (g_value_get_as_pointer (value)); pango_tab_array_copy (g_value_get_as_pointer (value));
g_object_notify (G_OBJECT (text_tag), "tabs_set");
size_changed = TRUE; size_changed = TRUE;
break; break;
case PROP_INVISIBLE: case PROP_INVISIBLE:
text_tag->invisible_set = TRUE; text_tag->invisible_set = TRUE;
text_tag->values->invisible = g_value_get_boolean (value); text_tag->values->invisible = g_value_get_boolean (value);
g_object_notify (G_OBJECT (text_tag), "invisible_set");
size_changed = TRUE; size_changed = TRUE;
break; break;
@ -1300,6 +1367,10 @@ gtk_text_tag_get_property (GObject *object,
g_value_set_enum (value, tag->values->justify); g_value_set_enum (value, tag->values->justify);
break; break;
case PROP_DIRECTION:
g_value_set_enum (value, tag->values->direction);
break;
case PROP_LEFT_MARGIN: case PROP_LEFT_MARGIN:
g_value_set_int (value, tag->values->left_margin); g_value_set_int (value, tag->values->left_margin);
break; break;

View File

@ -3317,7 +3317,7 @@ gtk_text_view_move_cursor (GtkTextView *text_view,
case GTK_MOVEMENT_PARAGRAPH_ENDS: case GTK_MOVEMENT_PARAGRAPH_ENDS:
if (count > 0) if (count > 0)
gtk_text_iter_forward_to_delimiters (&newplace); gtk_text_iter_forward_to_line_end (&newplace);
else if (count < 0) else if (count < 0)
gtk_text_iter_set_line_offset (&newplace, 0); gtk_text_iter_set_line_offset (&newplace, 0);
break; break;
@ -3521,7 +3521,7 @@ gtk_text_view_delete_from_cursor (GtkTextView *text_view,
while (count > 0) while (count > 0)
{ {
if (!gtk_text_iter_forward_to_delimiters (&end)) if (!gtk_text_iter_forward_to_line_end (&end))
break; break;
--count; --count;
@ -3535,12 +3535,12 @@ gtk_text_view_delete_from_cursor (GtkTextView *text_view,
if (count > 0) if (count > 0)
{ {
gtk_text_iter_set_line_offset (&start, 0); gtk_text_iter_set_line_offset (&start, 0);
gtk_text_iter_forward_to_delimiters (&end); gtk_text_iter_forward_to_line_end (&end);
/* Do the lines beyond the first. */ /* Do the lines beyond the first. */
while (count > 1) while (count > 1)
{ {
gtk_text_iter_forward_to_delimiters (&end); gtk_text_iter_forward_to_line_end (&end);
--count; --count;
} }

View File

@ -451,7 +451,7 @@ gtk_tree_model_simple_changed (GtkTreeModelSimple *simple,
GtkTreeIter *iter) GtkTreeIter *iter)
{ {
g_return_if_fail (simple != NULL); g_return_if_fail (simple != NULL);
g_return_if_fail (GTK_IS_MODEL_SIMPLE (simple)); g_return_if_fail (GTK_IS_TREE_MODEL_SIMPLE (simple));
g_return_if_fail (path != NULL); g_return_if_fail (path != NULL);
gtk_signal_emit_by_name (GTK_OBJECT (simple), "changed", path, iter); gtk_signal_emit_by_name (GTK_OBJECT (simple), "changed", path, iter);
@ -463,7 +463,7 @@ gtk_tree_model_simple_inserted (GtkTreeModelSimple *simple,
GtkTreeIter *iter) GtkTreeIter *iter)
{ {
g_return_if_fail (simple != NULL); g_return_if_fail (simple != NULL);
g_return_if_fail (GTK_IS_MODEL_SIMPLE (simple)); g_return_if_fail (GTK_IS_TREE_MODEL_SIMPLE (simple));
g_return_if_fail (path != NULL); g_return_if_fail (path != NULL);
gtk_signal_emit_by_name (GTK_OBJECT (simple), "inserted", path, iter); gtk_signal_emit_by_name (GTK_OBJECT (simple), "inserted", path, iter);
@ -475,7 +475,7 @@ gtk_tree_model_simple_child_toggled (GtkTreeModelSimple *simple,
GtkTreeIter *iter) GtkTreeIter *iter)
{ {
g_return_if_fail (simple != NULL); g_return_if_fail (simple != NULL);
g_return_if_fail (GTK_IS_MODEL_SIMPLE (simple)); g_return_if_fail (GTK_IS_TREE_MODEL_SIMPLE (simple));
g_return_if_fail (path != NULL); g_return_if_fail (path != NULL);
gtk_signal_emit_by_name (GTK_OBJECT (simple), "child_toggled", path, iter); gtk_signal_emit_by_name (GTK_OBJECT (simple), "child_toggled", path, iter);
@ -487,7 +487,7 @@ gtk_tree_model_simple_iter_deleted (GtkTreeModelSimple *simple,
GtkTreeIter *iter) GtkTreeIter *iter)
{ {
g_return_if_fail (simple != NULL); g_return_if_fail (simple != NULL);
g_return_if_fail (GTK_IS_MODEL_SIMPLE (simple)); g_return_if_fail (GTK_IS_TREE_MODEL_SIMPLE (simple));
g_return_if_fail (path != NULL); g_return_if_fail (path != NULL);
gtk_signal_emit_by_name (GTK_OBJECT (simple), "iter_deleted", path, iter); gtk_signal_emit_by_name (GTK_OBJECT (simple), "iter_deleted", path, iter);

View File

@ -30,8 +30,8 @@ extern "C" {
#define GTK_TYPE_MODEL_SIMPLE (gtk_tree_model_simple_get_type ()) #define GTK_TYPE_MODEL_SIMPLE (gtk_tree_model_simple_get_type ())
#define GTK_TREE_MODEL_SIMPLE(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_MODEL_SIMPLE, GtkTreeModelSimple)) #define GTK_TREE_MODEL_SIMPLE(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_MODEL_SIMPLE, GtkTreeModelSimple))
#define GTK_TREE_MODEL_SIMPLE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_MODEL_SIMPLE, GtkTreeModelSimpleClass)) #define GTK_TREE_MODEL_SIMPLE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_MODEL_SIMPLE, GtkTreeModelSimpleClass))
#define GTK_IS_MODEL_SIMPLE(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_MODEL_SIMPLE)) #define GTK_IS_TREE_MODEL_SIMPLE(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_MODEL_SIMPLE))
#define GTK_IS_MODEL_SIMPLE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), GTK_TYPE_MODEL_SIMPLE)) #define GTK_IS_TREE_MODEL_SIMPLE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), GTK_TYPE_MODEL_SIMPLE))
typedef struct _GtkTreeModelSimple GtkTreeModelSimple; typedef struct _GtkTreeModelSimple GtkTreeModelSimple;
typedef struct _GtkTreeModelSimpleClass GtkTreeModelSimpleClass; typedef struct _GtkTreeModelSimpleClass GtkTreeModelSimpleClass;

View File

@ -3273,15 +3273,15 @@ gtk_tree_view_columns_autosize (GtkTreeView *tree_view)
* "active" is confusing since it also is a widget state * "active" is confusing since it also is a widget state
*/ */
/** /**
* gtk_tree_view_set_headers_active: * gtk_tree_view_set_headers_clickable:
* @tree_view: A #GtkTreeView. * @tree_view: A #GtkTreeView.
* @active: TRUE if the columns are active. * @setting: TRUE if the columns are clickable.
* *
* Sets the headers active (eg. keyboard navigable) or inactive. * Allow the column title buttons to be clicked.
**/ **/
void void
gtk_tree_view_set_headers_active (GtkTreeView *tree_view, gtk_tree_view_set_headers_clickable (GtkTreeView *tree_view,
gboolean active) gboolean setting)
{ {
GList *list; GList *list;
@ -3290,7 +3290,7 @@ gtk_tree_view_set_headers_active (GtkTreeView *tree_view,
g_return_if_fail (tree_view->priv->model != NULL); g_return_if_fail (tree_view->priv->model != NULL);
for (list = tree_view->priv->columns; list; list = list->next) for (list = tree_view->priv->columns; list; list = list->next)
gtk_tree_view_column_set_header_clickable (GTK_TREE_VIEW_COLUMN (list->data), active); gtk_tree_view_column_set_header_clickable (GTK_TREE_VIEW_COLUMN (list->data), setting);
} }
/** /**

View File

@ -77,7 +77,7 @@ gboolean gtk_tree_view_get_headers_visible (GtkTreeView *tr
void gtk_tree_view_set_headers_visible (GtkTreeView *tree_view, void gtk_tree_view_set_headers_visible (GtkTreeView *tree_view,
gboolean headers_visible); gboolean headers_visible);
void gtk_tree_view_columns_autosize (GtkTreeView *tree_view); void gtk_tree_view_columns_autosize (GtkTreeView *tree_view);
void gtk_tree_view_set_headers_active (GtkTreeView *tree_view, void gtk_tree_view_set_headers_clickable (GtkTreeView *tree_view,
gboolean active); gboolean active);
gint gtk_tree_view_append_column (GtkTreeView *tree_view, gint gtk_tree_view_append_column (GtkTreeView *tree_view,
GtkTreeViewColumn *column); GtkTreeViewColumn *column);

View File

@ -0,0 +1,4 @@
This document is a laundry list of stuff to check if you want to
verify that GtkTreeView and associated objects are working properly.

View File

@ -2,6 +2,627 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <string.h> #include <string.h>
static GtkWidget* create_prop_editor (GObject *object);
/* This custom model is to test custom model use. */
#define GTK_TYPE_MODEL_TYPES (gtk_tree_model_types_get_type ())
#define GTK_TREE_MODEL_TYPES(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_MODEL_TYPES, GtkTreeModelTypes))
#define GTK_TREE_MODEL_TYPES_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_MODEL_TYPES, GtkTreeModelTypesClass))
#define GTK_IS_TREE_MODEL_TYPES(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_MODEL_TYPES))
#define GTK_IS_TREE_MODEL_TYPES_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), GTK_TYPE_MODEL_TYPES))
typedef struct _GtkTreeModelTypes GtkTreeModelTypes;
typedef struct _GtkTreeModelTypesClass GtkTreeModelTypesClass;
struct _GtkTreeModelTypes
{
GtkObject parent;
gint stamp;
};
struct _GtkTreeModelTypesClass
{
GtkObjectClass parent_class;
guint (* get_flags) (GtkTreeModel *tree_model);
gint (* get_n_columns) (GtkTreeModel *tree_model);
GType (* get_column_type) (GtkTreeModel *tree_model,
gint index);
gboolean (* get_iter) (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreePath *path);
GtkTreePath *(* get_path) (GtkTreeModel *tree_model,
GtkTreeIter *iter);
void (* get_value) (GtkTreeModel *tree_model,
GtkTreeIter *iter,
gint column,
GValue *value);
gboolean (* iter_next) (GtkTreeModel *tree_model,
GtkTreeIter *iter);
gboolean (* iter_children) (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *parent);
gboolean (* iter_has_child) (GtkTreeModel *tree_model,
GtkTreeIter *iter);
gint (* iter_n_children) (GtkTreeModel *tree_model,
GtkTreeIter *iter);
gboolean (* iter_nth_child) (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *parent,
gint n);
gboolean (* iter_parent) (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *child);
void (* ref_iter) (GtkTreeModel *tree_model,
GtkTreeIter *iter);
void (* unref_iter) (GtkTreeModel *tree_model,
GtkTreeIter *iter);
/* These will be moved into the GtkTreeModelIface eventually */
void (* changed) (GtkTreeModel *tree_model,
GtkTreePath *path,
GtkTreeIter *iter);
void (* inserted) (GtkTreeModel *tree_model,
GtkTreePath *path,
GtkTreeIter *iter);
void (* child_toggled) (GtkTreeModel *tree_model,
GtkTreePath *path,
GtkTreeIter *iter);
void (* deleted) (GtkTreeModel *tree_model,
GtkTreePath *path);
};
GtkType gtk_tree_model_types_get_type (void);
GtkTreeModelTypes *gtk_tree_model_types_new (void);
typedef enum
{
MODEL_TYPES,
MODEL_LAST
} ModelType;
static GtkTreeModel *models[MODEL_LAST];
int
main (int argc,
char **argv)
{
GtkWidget *window;
GtkWidget *sw;
GtkWidget *tv;
GtkTreeViewColumn *col;
GtkCellRenderer *rend;
gint i;
gtk_init (&argc, &argv);
models[MODEL_TYPES] = GTK_TREE_MODEL (gtk_tree_model_types_new ());
i = 0;
while (i < MODEL_LAST)
{
window = create_prop_editor (G_OBJECT (models[i]));
gtk_window_set_title (GTK_WINDOW (window), g_type_name (G_TYPE_FROM_INSTANCE (models[i])));
++i;
}
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 400, 400);
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (window), sw);
tv = gtk_tree_view_new_with_model (models[0]);
gtk_container_add (GTK_CONTAINER (sw), tv);
rend = gtk_cell_renderer_text_new ();
col = gtk_tree_view_column_new_with_attributes ("Type ID",
rend,
"text", 0,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (tv), col);
g_object_unref (G_OBJECT (rend));
g_object_unref (G_OBJECT (col));
rend = gtk_cell_renderer_text_new ();
col = gtk_tree_view_column_new_with_attributes ("Name",
rend,
"text", 1,
NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (tv), col);
g_object_unref (G_OBJECT (rend));
g_object_unref (G_OBJECT (col));
gtk_widget_show_all (window);
gtk_main ();
return 0;
}
/*
* GtkTreeModelTypes
*/
enum {
CHANGED,
INSERTED,
CHILD_TOGGLED,
DELETED,
LAST_SIGNAL
};
static void gtk_tree_model_types_init (GtkTreeModelTypes *model_types);
static void gtk_tree_model_types_class_init (GtkTreeModelTypesClass *class);
static void gtk_tree_model_types_tree_model_init (GtkTreeModelIface *iface);
static gint gtk_real_model_types_get_n_columns (GtkTreeModel *tree_model);
static GType gtk_real_model_types_get_column_type (GtkTreeModel *tree_model,
gint index);
static GtkTreePath *gtk_real_model_types_get_path (GtkTreeModel *tree_model,
GtkTreeIter *iter);
static void gtk_real_model_types_get_value (GtkTreeModel *tree_model,
GtkTreeIter *iter,
gint column,
GValue *value);
static gboolean gtk_real_model_types_iter_next (GtkTreeModel *tree_model,
GtkTreeIter *iter);
static gboolean gtk_real_model_types_iter_children (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *parent);
static gboolean gtk_real_model_types_iter_has_child (GtkTreeModel *tree_model,
GtkTreeIter *iter);
static gint gtk_real_model_types_iter_n_children (GtkTreeModel *tree_model,
GtkTreeIter *iter);
static gboolean gtk_real_model_types_iter_nth_child (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *parent,
gint n);
static gboolean gtk_real_model_types_iter_parent (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *child);
static guint model_types_signals[LAST_SIGNAL] = { 0 };
GtkType
gtk_tree_model_types_get_type (void)
{
static GtkType model_types_type = 0;
if (!model_types_type)
{
static const GTypeInfo model_types_info =
{
sizeof (GtkTreeModelTypesClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) gtk_tree_model_types_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (GtkTreeModelTypes),
0,
(GInstanceInitFunc) gtk_tree_model_types_init
};
static const GInterfaceInfo tree_model_info =
{
(GInterfaceInitFunc) gtk_tree_model_types_tree_model_init,
NULL,
NULL
};
model_types_type = g_type_register_static (GTK_TYPE_OBJECT, "GtkTreeModelTypes", &model_types_info, 0);
g_type_add_interface_static (model_types_type,
GTK_TYPE_TREE_MODEL,
&tree_model_info);
}
return model_types_type;
}
GtkTreeModelTypes *
gtk_tree_model_types_new (void)
{
GtkTreeModelTypes *retval;
retval = GTK_TREE_MODEL_TYPES (g_object_new (GTK_TYPE_MODEL_TYPES, NULL));
return retval;
}
static void
gtk_tree_model_types_class_init (GtkTreeModelTypesClass *class)
{
GObjectClass *object_class;
object_class = (GObjectClass*) class;
model_types_signals[CHANGED] =
g_signal_newc ("changed",
GTK_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
GTK_SIGNAL_OFFSET (GtkTreeModelTypesClass, changed),
NULL,
gtk_marshal_VOID__BOXED_BOXED,
G_TYPE_NONE, 2,
G_TYPE_POINTER,
G_TYPE_POINTER);
model_types_signals[INSERTED] =
g_signal_newc ("inserted",
GTK_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
GTK_SIGNAL_OFFSET (GtkTreeModelTypesClass, inserted),
NULL,
gtk_marshal_VOID__BOXED_BOXED,
G_TYPE_NONE, 2,
G_TYPE_POINTER,
G_TYPE_POINTER);
model_types_signals[CHILD_TOGGLED] =
g_signal_newc ("child_toggled",
GTK_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
GTK_SIGNAL_OFFSET (GtkTreeModelTypesClass, child_toggled),
NULL,
gtk_marshal_VOID__BOXED_BOXED,
G_TYPE_NONE, 2,
G_TYPE_POINTER,
G_TYPE_POINTER);
model_types_signals[DELETED] =
g_signal_newc ("deleted",
GTK_CLASS_TYPE (object_class),
G_SIGNAL_RUN_FIRST,
GTK_SIGNAL_OFFSET (GtkTreeModelTypesClass, deleted),
NULL,
gtk_marshal_VOID__BOXED,
G_TYPE_NONE, 1,
G_TYPE_POINTER);
}
static void
gtk_tree_model_types_tree_model_init (GtkTreeModelIface *iface)
{
iface->get_n_columns = gtk_real_model_types_get_n_columns;
iface->get_column_type = gtk_real_model_types_get_column_type;
iface->get_path = gtk_real_model_types_get_path;
iface->get_value = gtk_real_model_types_get_value;
iface->iter_next = gtk_real_model_types_iter_next;
iface->iter_children = gtk_real_model_types_iter_children;
iface->iter_has_child = gtk_real_model_types_iter_has_child;
iface->iter_n_children = gtk_real_model_types_iter_n_children;
iface->iter_nth_child = gtk_real_model_types_iter_nth_child;
iface->iter_parent = gtk_real_model_types_iter_parent;
}
static void
gtk_tree_model_types_init (GtkTreeModelTypes *model_types)
{
model_types->stamp = g_random_int ();
}
static GType column_types[] = {
G_TYPE_STRING, /* GType */
G_TYPE_STRING /* type name */
};
static gint
gtk_real_model_types_get_n_columns (GtkTreeModel *tree_model)
{
return G_N_ELEMENTS (column_types);
}
static GType
gtk_real_model_types_get_column_type (GtkTreeModel *tree_model,
gint index)
{
g_return_val_if_fail (index < G_N_ELEMENTS (column_types), G_TYPE_INVALID);
return column_types[index];
}
#if 0
/* Use default implementation of this */
static gboolean
gtk_real_model_types_get_iter (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreePath *path)
{
}
#endif
/* The toplevel nodes of the tree are the reserved types, G_TYPE_NONE through
* G_TYPE_RESERVED_FUNDAMENTAL.
*/
static GtkTreePath *
gtk_real_model_types_get_path (GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
GtkTreePath *retval;
GType type;
GType parent;
g_return_val_if_fail (GTK_IS_TREE_MODEL_TYPES (tree_model), NULL);
g_return_val_if_fail (iter != NULL, NULL);
type = GPOINTER_TO_INT (iter->user_data);
retval = gtk_tree_path_new ();
parent = g_type_parent (type);
while (parent != G_TYPE_INVALID)
{
GType* children = g_type_children (parent, NULL);
gint i = 0;
if (!children || children[0] == G_TYPE_INVALID)
{
g_warning ("bad iterator?");
return NULL;
}
while (children[i] != type)
++i;
gtk_tree_path_prepend_index (retval, i);
g_free (children);
type = parent;
parent = g_type_parent (parent);
}
/* The fundamental type itself is the index on the toplevel */
gtk_tree_path_prepend_index (retval, type);
return retval;
}
static void
gtk_real_model_types_get_value (GtkTreeModel *tree_model,
GtkTreeIter *iter,
gint column,
GValue *value)
{
GType type;
type = GPOINTER_TO_INT (iter->user_data);
switch (column)
{
case 0:
{
gchar *str;
g_value_init (value, G_TYPE_STRING);
str = g_strdup_printf ("%d", type);
g_value_set_string (value, str);
g_free (str);
}
break;
case 1:
g_value_init (value, G_TYPE_STRING);
g_value_set_string (value, g_type_name (type));
break;
default:
g_warning ("Bad column %d requested", column);
}
}
static gboolean
gtk_real_model_types_iter_next (GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
GType parent;
GType type;
type = GPOINTER_TO_INT (iter->user_data);
parent = g_type_parent (type);
if (parent == G_TYPE_INVALID)
{
/* fundamental type, add 1 */
if ((type + 1) < G_TYPE_LAST_RESERVED_FUNDAMENTAL)
{
iter->user_data = GINT_TO_POINTER (type + 1);
return TRUE;
}
else
return FALSE;
}
else
{
GType* children = g_type_children (parent, NULL);
gint i = 0;
g_assert (children != NULL);
while (children[i] != type)
++i;
++i;
if (children[i] != G_TYPE_INVALID)
{
g_free (children);
iter->user_data = GINT_TO_POINTER (children[i]);
return TRUE;
}
else
{
g_free (children);
return FALSE;
}
}
}
static gboolean
gtk_real_model_types_iter_children (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *parent)
{
GType type;
GType* children;
type = GPOINTER_TO_INT (parent->user_data);
children = g_type_children (type, NULL);
if (!children || children[0] == G_TYPE_INVALID)
{
g_free (children);
return FALSE;
}
else
{
iter->user_data = GINT_TO_POINTER (children[0]);
g_free (children);
return TRUE;
}
}
static gboolean
gtk_real_model_types_iter_has_child (GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
GType type;
GType* children;
type = GPOINTER_TO_INT (iter->user_data);
children = g_type_children (type, NULL);
if (!children || children[0] == G_TYPE_INVALID)
{
g_free (children);
return FALSE;
}
else
{
g_free (children);
return TRUE;
}
}
static gint
gtk_real_model_types_iter_n_children (GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
if (iter == NULL)
{
return G_TYPE_LAST_RESERVED_FUNDAMENTAL - 1;
}
else
{
GType type;
GType* children;
guint n_children = 0;
type = GPOINTER_TO_INT (iter->user_data);
children = g_type_children (type, &n_children);
g_free (children);
return n_children;
}
}
static gboolean
gtk_real_model_types_iter_nth_child (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *parent,
gint n)
{
if (parent == NULL)
{
/* fundamental type */
if (n < G_TYPE_LAST_RESERVED_FUNDAMENTAL)
{
iter->user_data = GINT_TO_POINTER (n);
return TRUE;
}
else
return FALSE;
}
else
{
GType type = GPOINTER_TO_INT (parent->user_data);
guint n_children = 0;
GType* children = g_type_children (type, &n_children);
if (n_children == 0)
{
g_free (children);
return FALSE;
}
else if (n >= n_children)
{
g_free (children);
return FALSE;
}
else
{
iter->user_data = GINT_TO_POINTER (children[n]);
g_free (children);
return TRUE;
}
}
}
static gboolean
gtk_real_model_types_iter_parent (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *child)
{
GType type;
GType parent;
type = GPOINTER_TO_INT (child->user_data);
parent = g_type_parent (type);
if (parent == G_TYPE_INVALID)
{
if (type >= G_TYPE_LAST_RESERVED_FUNDAMENTAL)
g_warning ("no parent for %d %s\n", type, g_type_name (type));
return FALSE;
}
else
{
iter->user_data = GINT_TO_POINTER (parent);
return TRUE;
}
}
/*
* Property editor thingy
*/
static void static void
get_param_specs (GObject *object, get_param_specs (GObject *object,
@ -55,7 +676,7 @@ connect_controller (GObject *controller,
p->prop = g_strdup (prop_name); p->prop = g_strdup (prop_name);
g_signal_connect_data (controller, signal, func, p, g_signal_connect_data (controller, signal, func, p,
(GDestroyNotify)free_object_property, (GClosureNotify)free_object_property,
FALSE, FALSE); FALSE, FALSE);
} }
@ -142,6 +763,52 @@ bool_changed (GObject *object, GParamSpec *pspec, gpointer data)
g_value_unset (&val); g_value_unset (&val);
} }
static void
enum_modified (GtkOptionMenu *om, gpointer data)
{
ObjectProperty *p = data;
gint i;
GParamSpec *spec;
GEnumClass *eclass;
spec = g_object_class_find_property (G_OBJECT_GET_CLASS (p->obj),
p->prop);
eclass = G_ENUM_CLASS (g_type_class_peek (spec->value_type));
i = gtk_option_menu_get_history (om);
g_object_set (p->obj, p->prop, eclass->values[i].value, NULL);
}
static void
enum_changed (GObject *object, GParamSpec *pspec, gpointer data)
{
GtkOptionMenu *om = GTK_OPTION_MENU (data);
GValue val = { 0, };
GEnumClass *eclass;
gint i;
eclass = G_ENUM_CLASS (g_type_class_peek (pspec->value_type));
g_value_init (&val, pspec->value_type);
g_object_get_property (object, pspec->name, &val);
i = 0;
while (i < eclass->n_values)
{
if (eclass->values[i].value == g_value_get_enum (&val))
break;
++i;
}
if (gtk_option_menu_get_history (om) != i)
gtk_option_menu_set_history (om, i);
g_value_unset (&val);
}
static GtkWidget* static GtkWidget*
create_prop_editor (GObject *object) create_prop_editor (GObject *object)
{ {
@ -262,6 +929,52 @@ create_prop_editor (GObject *object)
break; break;
default: default:
if (g_type_is_a (spec->value_type, G_TYPE_ENUM))
{
GtkWidget *menu;
GEnumClass *eclass;
gint i;
hbox = gtk_hbox_new (FALSE, 10);
label = gtk_label_new (spec->nick);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
prop_edit = gtk_option_menu_new ();
menu = gtk_menu_new ();
eclass = G_ENUM_CLASS (g_type_class_peek (spec->value_type));
i = 0;
while (i < eclass->n_values)
{
GtkWidget *mi;
mi = gtk_menu_item_new_with_label (eclass->values[i].value_name);
gtk_widget_show (mi);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
++i;
}
gtk_option_menu_set_menu (GTK_OPTION_MENU (prop_edit), menu);
gtk_box_pack_end (GTK_BOX (hbox), prop_edit, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
g_object_connect_property (object, spec->name,
GTK_SIGNAL_FUNC (enum_changed),
prop_edit);
if (can_modify)
connect_controller (G_OBJECT (prop_edit), "changed",
object, spec->name, (GtkSignalFunc) enum_modified);
}
else
{ {
gchar *msg = g_strdup_printf ("%s: don't know how to edit type %s", gchar *msg = g_strdup_printf ("%s: don't know how to edit type %s",
spec->nick, g_type_name (spec->value_type)); spec->nick, g_type_name (spec->value_type));
@ -294,20 +1007,3 @@ create_prop_editor (GObject *object)
return win; return win;
} }
int
main (int argc,
char **argv)
{
GtkWidget *window;
gtk_init (&argc, &argv);
/* I didn't write the tree test yet, just the property editor to use
* inside the tree test ;-)
*/
window = create_prop_editor (G_OBJECT (gtk_text_tag_new ("foo")));
gtk_main ();
return 0;
}