Commit b02ebc65 authored by Owen Taylor's avatar Owen Taylor Committed by Owen Taylor

Call gtk_widget_size_request() on reparented child, if one. Otherwise,

Sun Jul  2 14:37:58 2000  Owen Taylor  <otaylor@redhat.com>

	* gtk/gtkoptionmenu.c (gtk_option_menu_size_request): Call
	gtk_widget_size_request() on reparented child, if one. Otherwise,
	queue_resize() on the child never results in it getting size-requested
	at all.

	* gtk/testgtk.c (build_option_menu): Remove silly radio-menu-items
	in option menus, so that (with luck) people won't copy it into
	their apps in the future.

	* gtk/gtkoptionmenu.c: Connect ::size_request on the menu
	to gtk_option_menu_calc_size. This isn't perfect, but should fix
	a lot of problems with changing the size of the menu's menu
	items after adding it to the option menu.

	* gtk/gtktexttag.c: Include gtkmain.h for gtk_get_default_language().

	* gtk/gtkwidget.[ch]: Add a ::direction_changed that triggers when
	the text direction for a widget changes.

	* gtk/gtk{entry.c,label.[ch],textview.[ch]} gtk/testgtk.c: Use
	::direction_changed to get rid of various hacks.
parent d2058c28
Sun Jul 2 14:37:58 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_size_request): Call
gtk_widget_size_request() on reparented child, if one. Otherwise,
queue_resize() on the child never results in it getting size-requested
at all.
* gtk/testgtk.c (build_option_menu): Remove silly radio-menu-items
in option menus, so that (with luck) people won't copy it into
their apps in the future.
* gtk/gtkoptionmenu.c: Connect ::size_request on the menu
to gtk_option_menu_calc_size. This isn't perfect, but should fix
a lot of problems with changing the size of the menu's menu
items after adding it to the option menu.
* gtk/gtktexttag.c: Include gtkmain.h for gtk_get_default_language().
* gtk/gtkwidget.[ch]: Add a ::direction_changed that triggers when
the text direction for a widget changes.
* gtk/gtk{entry.c,label.[ch],textview.[ch]} gtk/testgtk.c: Use
::direction_changed to get rid of various hacks.
Sun Jul 2 13:19:12 2000 Owen Taylor <otaylor@redhat.com>
* docs/Changes-2.0.txt: Move Changes-1.4.txt to the appropriate
......
Sun Jul 2 14:37:58 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_size_request): Call
gtk_widget_size_request() on reparented child, if one. Otherwise,
queue_resize() on the child never results in it getting size-requested
at all.
* gtk/testgtk.c (build_option_menu): Remove silly radio-menu-items
in option menus, so that (with luck) people won't copy it into
their apps in the future.
* gtk/gtkoptionmenu.c: Connect ::size_request on the menu
to gtk_option_menu_calc_size. This isn't perfect, but should fix
a lot of problems with changing the size of the menu's menu
items after adding it to the option menu.
* gtk/gtktexttag.c: Include gtkmain.h for gtk_get_default_language().
* gtk/gtkwidget.[ch]: Add a ::direction_changed that triggers when
the text direction for a widget changes.
* gtk/gtk{entry.c,label.[ch],textview.[ch]} gtk/testgtk.c: Use
::direction_changed to get rid of various hacks.
Sun Jul 2 13:19:12 2000 Owen Taylor <otaylor@redhat.com>
* docs/Changes-2.0.txt: Move Changes-1.4.txt to the appropriate
......
Sun Jul 2 14:37:58 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_size_request): Call
gtk_widget_size_request() on reparented child, if one. Otherwise,
queue_resize() on the child never results in it getting size-requested
at all.
* gtk/testgtk.c (build_option_menu): Remove silly radio-menu-items
in option menus, so that (with luck) people won't copy it into
their apps in the future.
* gtk/gtkoptionmenu.c: Connect ::size_request on the menu
to gtk_option_menu_calc_size. This isn't perfect, but should fix
a lot of problems with changing the size of the menu's menu
items after adding it to the option menu.
* gtk/gtktexttag.c: Include gtkmain.h for gtk_get_default_language().
* gtk/gtkwidget.[ch]: Add a ::direction_changed that triggers when
the text direction for a widget changes.
* gtk/gtk{entry.c,label.[ch],textview.[ch]} gtk/testgtk.c: Use
::direction_changed to get rid of various hacks.
Sun Jul 2 13:19:12 2000 Owen Taylor <otaylor@redhat.com>
* docs/Changes-2.0.txt: Move Changes-1.4.txt to the appropriate
......
Sun Jul 2 14:37:58 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_size_request): Call
gtk_widget_size_request() on reparented child, if one. Otherwise,
queue_resize() on the child never results in it getting size-requested
at all.
* gtk/testgtk.c (build_option_menu): Remove silly radio-menu-items
in option menus, so that (with luck) people won't copy it into
their apps in the future.
* gtk/gtkoptionmenu.c: Connect ::size_request on the menu
to gtk_option_menu_calc_size. This isn't perfect, but should fix
a lot of problems with changing the size of the menu's menu
items after adding it to the option menu.
* gtk/gtktexttag.c: Include gtkmain.h for gtk_get_default_language().
* gtk/gtkwidget.[ch]: Add a ::direction_changed that triggers when
the text direction for a widget changes.
* gtk/gtk{entry.c,label.[ch],textview.[ch]} gtk/testgtk.c: Use
::direction_changed to get rid of various hacks.
Sun Jul 2 13:19:12 2000 Owen Taylor <otaylor@redhat.com>
* docs/Changes-2.0.txt: Move Changes-1.4.txt to the appropriate
......
Sun Jul 2 14:37:58 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_size_request): Call
gtk_widget_size_request() on reparented child, if one. Otherwise,
queue_resize() on the child never results in it getting size-requested
at all.
* gtk/testgtk.c (build_option_menu): Remove silly radio-menu-items
in option menus, so that (with luck) people won't copy it into
their apps in the future.
* gtk/gtkoptionmenu.c: Connect ::size_request on the menu
to gtk_option_menu_calc_size. This isn't perfect, but should fix
a lot of problems with changing the size of the menu's menu
items after adding it to the option menu.
* gtk/gtktexttag.c: Include gtkmain.h for gtk_get_default_language().
* gtk/gtkwidget.[ch]: Add a ::direction_changed that triggers when
the text direction for a widget changes.
* gtk/gtk{entry.c,label.[ch],textview.[ch]} gtk/testgtk.c: Use
::direction_changed to get rid of various hacks.
Sun Jul 2 13:19:12 2000 Owen Taylor <otaylor@redhat.com>
* docs/Changes-2.0.txt: Move Changes-1.4.txt to the appropriate
......
Sun Jul 2 14:37:58 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_size_request): Call
gtk_widget_size_request() on reparented child, if one. Otherwise,
queue_resize() on the child never results in it getting size-requested
at all.
* gtk/testgtk.c (build_option_menu): Remove silly radio-menu-items
in option menus, so that (with luck) people won't copy it into
their apps in the future.
* gtk/gtkoptionmenu.c: Connect ::size_request on the menu
to gtk_option_menu_calc_size. This isn't perfect, but should fix
a lot of problems with changing the size of the menu's menu
items after adding it to the option menu.
* gtk/gtktexttag.c: Include gtkmain.h for gtk_get_default_language().
* gtk/gtkwidget.[ch]: Add a ::direction_changed that triggers when
the text direction for a widget changes.
* gtk/gtk{entry.c,label.[ch],textview.[ch]} gtk/testgtk.c: Use
::direction_changed to get rid of various hacks.
Sun Jul 2 13:19:12 2000 Owen Taylor <otaylor@redhat.com>
* docs/Changes-2.0.txt: Move Changes-1.4.txt to the appropriate
......
Sun Jul 2 14:37:58 2000 Owen Taylor <otaylor@redhat.com>
* gtk/gtkoptionmenu.c (gtk_option_menu_size_request): Call
gtk_widget_size_request() on reparented child, if one. Otherwise,
queue_resize() on the child never results in it getting size-requested
at all.
* gtk/testgtk.c (build_option_menu): Remove silly radio-menu-items
in option menus, so that (with luck) people won't copy it into
their apps in the future.
* gtk/gtkoptionmenu.c: Connect ::size_request on the menu
to gtk_option_menu_calc_size. This isn't perfect, but should fix
a lot of problems with changing the size of the menu's menu
items after adding it to the option menu.
* gtk/gtktexttag.c: Include gtkmain.h for gtk_get_default_language().
* gtk/gtkwidget.[ch]: Add a ::direction_changed that triggers when
the text direction for a widget changes.
* gtk/gtk{entry.c,label.[ch],textview.[ch]} gtk/testgtk.c: Use
::direction_changed to get rid of various hacks.
Sun Jul 2 13:19:12 2000 Owen Taylor <otaylor@redhat.com>
* docs/Changes-2.0.txt: Move Changes-1.4.txt to the appropriate
......
......@@ -55,68 +55,67 @@ enum {
};
static void gtk_entry_class_init (GtkEntryClass *klass);
static void gtk_entry_init (GtkEntry *entry);
static void gtk_entry_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_entry_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_entry_finalize (GObject *object);
static void gtk_entry_realize (GtkWidget *widget);
static void gtk_entry_unrealize (GtkWidget *widget);
static void gtk_entry_draw_focus (GtkWidget *widget);
static void gtk_entry_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_entry_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_entry_draw (GtkWidget *widget,
GdkRectangle *area);
static gint gtk_entry_expose (GtkWidget *widget,
GdkEventExpose *event);
static gint gtk_entry_button_press (GtkWidget *widget,
GdkEventButton *event);
static gint gtk_entry_button_release (GtkWidget *widget,
GdkEventButton *event);
static gint gtk_entry_motion_notify (GtkWidget *widget,
GdkEventMotion *event);
static gint gtk_entry_key_press (GtkWidget *widget,
GdkEventKey *event);
static gint gtk_entry_focus_in (GtkWidget *widget,
GdkEventFocus *event);
static gint gtk_entry_focus_out (GtkWidget *widget,
GdkEventFocus *event);
static void gtk_entry_draw_text (GtkEntry *entry);
static void gtk_entry_ensure_layout (GtkEntry *entry);
static void gtk_entry_draw_cursor (GtkEntry *entry);
static void gtk_entry_style_set (GtkWidget *widget,
GtkStyle *previous_style);
static void gtk_entry_state_changed (GtkWidget *widget,
GtkStateType previous_state);
static void gtk_entry_queue_draw (GtkEntry *entry);
static gint gtk_entry_find_position (GtkEntry *entry,
gint x);
static void gtk_entry_get_cursor_locations (GtkEntry *entry,
gint *strong_x,
gint *weak_x);
static void entry_adjust_scroll (GtkEntry *entry);
static void gtk_entry_insert_text (GtkEditable *editable,
const gchar *new_text,
gint new_text_length,
gint *position);
static void gtk_entry_delete_text (GtkEditable *editable,
gint start_pos,
gint end_pos);
static void gtk_entry_update_text (GtkEditable *editable,
gint start_pos,
gint end_pos);
static gchar * gtk_entry_get_chars (GtkEditable *editable,
gint start_pos,
gint end_pos);
static void gtk_entry_class_init (GtkEntryClass *klass);
static void gtk_entry_init (GtkEntry *entry);
static void gtk_entry_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_entry_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_entry_finalize (GObject *object);
static void gtk_entry_realize (GtkWidget *widget);
static void gtk_entry_unrealize (GtkWidget *widget);
static void gtk_entry_draw_focus (GtkWidget *widget);
static void gtk_entry_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_entry_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_entry_draw (GtkWidget *widget,
GdkRectangle *area);
static gint gtk_entry_expose (GtkWidget *widget,
GdkEventExpose *event);
static gint gtk_entry_button_press (GtkWidget *widget,
GdkEventButton *event);
static gint gtk_entry_button_release (GtkWidget *widget,
GdkEventButton *event);
static gint gtk_entry_motion_notify (GtkWidget *widget,
GdkEventMotion *event);
static gint gtk_entry_key_press (GtkWidget *widget,
GdkEventKey *event);
static gint gtk_entry_focus_in (GtkWidget *widget,
GdkEventFocus *event);
static gint gtk_entry_focus_out (GtkWidget *widget,
GdkEventFocus *event);
static void gtk_entry_draw_text (GtkEntry *entry);
static void gtk_entry_ensure_layout (GtkEntry *entry);
static void gtk_entry_draw_cursor (GtkEntry *entry);
static void gtk_entry_style_set (GtkWidget *widget,
GtkStyle *previous_style);
static void gtk_entry_direction_changed (GtkWidget *widget,
GtkTextDirection previous_dir);
static void gtk_entry_state_changed (GtkWidget *widget,
GtkStateType previous_state);
static void gtk_entry_queue_draw (GtkEntry *entry);
static gint gtk_entry_find_position (GtkEntry *entry,
gint x);
static void gtk_entry_get_cursor_locations (GtkEntry *entry,
gint *strong_x,
gint *weak_x);
static void entry_adjust_scroll (GtkEntry *entry);
static void gtk_entry_insert_text (GtkEditable *editable,
const gchar *new_text,
gint new_text_length,
gint *position);
static void gtk_entry_delete_text (GtkEditable *editable,
gint start_pos,
gint end_pos);
static void gtk_entry_update_text (GtkEditable *editable,
gint start_pos,
gint end_pos);
static gchar *gtk_entry_get_chars (GtkEditable *editable,
gint start_pos,
gint end_pos);
/* Binding actions */
static void gtk_entry_move_cursor (GtkEditable *editable,
......@@ -288,6 +287,7 @@ gtk_entry_class_init (GtkEntryClass *class)
widget_class->focus_in_event = gtk_entry_focus_in;
widget_class->focus_out_event = gtk_entry_focus_out;
widget_class->style_set = gtk_entry_style_set;
widget_class->direction_changed = gtk_entry_direction_changed;
widget_class->state_changed = gtk_entry_state_changed;
editable_class->insert_text = gtk_entry_insert_text;
......@@ -668,14 +668,6 @@ gtk_entry_size_request (GtkWidget *widget,
entry = GTK_ENTRY (widget);
/* We do this to deal with direction changes - should that be a signal?
*/
if (entry->layout)
{
g_object_unref (G_OBJECT (entry->layout));
entry->layout = NULL;
}
gtk_entry_ensure_layout (entry);
/* hackish for now, get metrics
......@@ -1972,20 +1964,36 @@ static void
gtk_entry_style_set (GtkWidget *widget,
GtkStyle *previous_style)
{
GtkEntry *entry;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_ENTRY (widget));
GtkEntry *entry = GTK_ENTRY (widget);
if (previous_style && GTK_WIDGET_REALIZED (widget))
{
entry = GTK_ENTRY (widget);
entry_adjust_scroll (entry);
gdk_window_set_background (widget->window, &widget->style->base[GTK_WIDGET_STATE (widget)]);
gdk_window_set_background (entry->text_area, &widget->style->base[GTK_WIDGET_STATE (widget)]);
}
if (entry->layout)
{
g_object_unref (G_OBJECT (entry->layout));
entry->layout = NULL;
}
}
static void
gtk_entry_direction_changed (GtkWidget *widget,
GtkTextDirection previous_dir)
{
GtkEntry *entry = GTK_ENTRY (widget);
if (entry->layout)
{
g_object_unref (G_OBJECT (entry->layout));
entry->layout = NULL;
}
GTK_WIDGET_CLASS (parent_class)->direction_changed (widget, previous_dir);
}
static void
......
......@@ -39,22 +39,23 @@ enum {
ARG_WRAP
};
static void gtk_label_class_init (GtkLabelClass *klass);
static void gtk_label_init (GtkLabel *label);
static void gtk_label_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_label_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_label_finalize (GObject *object);
static void gtk_label_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_label_style_set (GtkWidget *widget,
GtkStyle *previous_style);
static gint gtk_label_expose (GtkWidget *widget,
GdkEventExpose *event);
static void gtk_label_class_init (GtkLabelClass *klass);
static void gtk_label_init (GtkLabel *label);
static void gtk_label_set_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_label_get_arg (GtkObject *object,
GtkArg *arg,
guint arg_id);
static void gtk_label_finalize (GObject *object);
static void gtk_label_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_label_style_set (GtkWidget *widget,
GtkStyle *previous_style);
static void gtk_label_direction_changed (GtkWidget *widget,
GtkTextDirection previous_dir);
static gint gtk_label_expose (GtkWidget *widget,
GdkEventExpose *event);
static GtkMiscClass *parent_class = NULL;
......@@ -108,6 +109,7 @@ gtk_label_class_init (GtkLabelClass *class)
widget_class->size_request = gtk_label_size_request;
widget_class->style_set = gtk_label_style_set;
widget_class->direction_changed = gtk_label_direction_changed;
widget_class->expose_event = gtk_label_expose;
}
......@@ -180,7 +182,6 @@ gtk_label_init (GtkLabel *label)
label->wrap = FALSE;
label->layout = NULL;
label->rtl = (gtk_widget_get_direction (GTK_WIDGET (label)) == GTK_TEXT_DIR_RTL);
gtk_label_set_text (label, "");
}
......@@ -394,16 +395,6 @@ gtk_label_size_request (GtkWidget *widget,
requisition->width = label->misc.xpad;
requisition->height = label->misc.ypad;
/* Detect direction changes. FIXME: make this a signal
*/
if (label->rtl != (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) &&
label->layout)
{
label->rtl = !label->rtl;
g_object_unref (G_OBJECT (label->layout));
label->layout = NULL;
}
if (!label->layout)
{
PangoAlignment align = PANGO_ALIGN_LEFT; /* Quiet gcc */
......@@ -550,6 +541,21 @@ gtk_label_style_set (GtkWidget *widget,
}
}
static void
gtk_label_direction_changed (GtkWidget *widget,
GtkTextDirection previous_dir)
{
GtkLabel *label = GTK_LABEL (widget);
if (label->layout)
{
g_object_unref (G_OBJECT (label->layout));
label->layout = NULL;
}
GTK_WIDGET_CLASS (parent_class)->direction_changed (widget, previous_dir);
}
#if 0
static void
gtk_label_paint_word (GtkLabel *label,
......
......@@ -60,7 +60,6 @@ struct _GtkLabel
gboolean wrap : 1;
/*< private >*/
gint rtl : 2; /* Base dir, cached to detect changes */
PangoLayout *layout;
};
......
......@@ -204,6 +204,9 @@ gtk_option_menu_set_menu (GtkOptionMenu *option_menu,
gtk_signal_connect (GTK_OBJECT (option_menu->menu), "deactivate",
(GtkSignalFunc) gtk_option_menu_deactivate,
option_menu);
gtk_signal_connect_object (GTK_OBJECT (option_menu->menu), "size_request",
(GtkSignalFunc) gtk_option_menu_calc_size,
GTK_OBJECT (option_menu));
if (GTK_WIDGET (option_menu)->parent)
gtk_widget_queue_resize (GTK_WIDGET (option_menu));
......@@ -288,6 +291,8 @@ gtk_option_menu_size_request (GtkWidget *widget,
{
GtkOptionMenu *option_menu;
gint tmp;
GtkRequisition child_requisition = { 0, 0 };
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_OPTION_MENU (widget));
......@@ -295,15 +300,23 @@ gtk_option_menu_size_request (GtkWidget *widget,
option_menu = GTK_OPTION_MENU (widget);
if (GTK_BIN (option_menu)->child && GTK_WIDGET_VISIBLE (GTK_BIN (option_menu)->child))
{
gtk_widget_size_request (GTK_BIN (option_menu)->child, &child_requisition);
requisition->width += child_requisition.width;
requisition->height += child_requisition.height;
}
requisition->width = ((GTK_CONTAINER (widget)->border_width +
GTK_WIDGET (widget)->style->xthickness) * 2 +
option_menu->width +
MAX (child_requisition.width, option_menu->width) +
OPTION_INDICATOR_WIDTH +
OPTION_INDICATOR_SPACING * 5 +
CHILD_LEFT_SPACING + CHILD_RIGHT_SPACING + 2);
requisition->height = ((GTK_CONTAINER (widget)->border_width +
GTK_WIDGET (widget)->style->ythickness) * 2 +
option_menu->height +
MAX (child_requisition.height, option_menu->height) +
CHILD_TOP_SPACING + CHILD_BOTTOM_SPACING + 2);
tmp = (requisition->height - option_menu->height +
......@@ -602,6 +615,8 @@ gtk_option_menu_calc_size (GtkOptionMenu *option_menu)
GtkWidget *child;
GList *children;
GtkRequisition child_requisition;
gint old_width = option_menu->width;
gint old_height = option_menu->height;
g_return_if_fail (option_menu != NULL);
g_return_if_fail (GTK_IS_OPTION_MENU (option_menu));
......@@ -626,6 +641,9 @@ gtk_option_menu_calc_size (GtkOptionMenu *option_menu)
}
}
}
if (old_width != option_menu->width || old_height != option_menu->height)
gtk_widget_queue_resize (GTK_WIDGET (option_menu));
}
static void
......
......@@ -47,6 +47,7 @@
*
*/
#include "gtkmain.h"
#include "gtktexttag.h"
#include "gtktexttypes.h"
#include "gtktexttagtable.h"
......
......@@ -101,6 +101,8 @@ static void gtk_text_view_realize (GtkWidget *widget);
static void gtk_text_view_unrealize (GtkWidget *widget);
static void gtk_text_view_style_set (GtkWidget *widget,
GtkStyle *previous_style);
static void gtk_text_view_direction_changed (GtkWidget *widget,
GtkTextDirection previous_direction);
static gint gtk_text_view_event (GtkWidget *widget,
GdkEvent *event);
static gint gtk_text_view_key_press_event (GtkWidget *widget,
......@@ -537,6 +539,7 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
widget_class->realize = gtk_text_view_realize;
widget_class->unrealize = gtk_text_view_unrealize;
widget_class->style_set = gtk_text_view_style_set;
widget_class->direction_changed = gtk_text_view_direction_changed;
widget_class->size_request = gtk_text_view_size_request;
widget_class->size_allocate = gtk_text_view_size_allocate;
widget_class->event = gtk_text_view_event;
......@@ -651,8 +654,6 @@ gtk_text_view_set_buffer (GtkTextView *text_view,
if (buffer != NULL)
{
char *mark_name;
GtkTextIter start;
gtk_object_ref (GTK_OBJECT (buffer));
......@@ -1056,23 +1057,9 @@ static void
gtk_text_view_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GtkTextView *text_view = GTK_TEXT_VIEW (widget);
/* Hrm */
requisition->width = 1;
requisition->height = 1;
/* Check to see if the widget direction has changed */
if (text_view->layout)
{
GtkTextDirection direction = gtk_widget_get_direction (widget);
if (direction != text_view->layout->default_style->direction)
{
text_view->layout->default_style->direction = direction;
gtk_text_layout_default_style_changed (text_view->layout);
}
}
}
static void
......@@ -1357,6 +1344,19 @@ gtk_text_view_style_set (GtkWidget *widget,
}
}
static void
gtk_text_view_direction_changed (GtkWidget *widget,
GtkTextDirection previous_direction)
{
GtkTextView *text_view = GTK_TEXT_VIEW (widget);
if (text_view->layout)
{
text_view->layout->default_style->direction = gtk_widget_get_direction (widget);
gtk_text_layout_default_style_changed (text_view->layout);
}
}
/*
* Events
*/
......
......@@ -59,6 +59,7 @@ enum {
STATE_CHANGED,
PARENT_SET,
STYLE_SET,
DIRECTION_CHANGED,
ADD_ACCELERATOR,
REMOVE_ACCELERATOR,
GRAB_FOCUS,
......@@ -163,10 +164,11 @@ static gint gtk_widget_real_key_release_event (GtkWidget *widget,
GdkEventKey *event);
static void gtk_widget_style_set (GtkWidget *widget,
GtkStyle *previous_style);
static void gtk_widget_direction_changed (GtkWidget *widget,
GtkTextDirection previous_direction);
static void gtk_widget_real_grab_focus (GtkWidget *focus_widget);
static GdkColormap* gtk_widget_peek_colormap (void);
static GdkVisual* gtk_widget_peek_visual (void);
static GtkStyle* gtk_widget_peek_style (void);
static void gtk_widget_reparent_container_child (GtkWidget *widget,
......@@ -292,6 +294,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
klass->state_changed = NULL;
klass->parent_set = NULL;
klass->style_set = gtk_widget_style_set;
klass->direction_changed = gtk_widget_direction_changed;
klass->add_accelerator = (void*) gtk_accel_group_handle_add;
klass->remove_accelerator = (void*) gtk_accel_group_handle_remove;
klass->grab_focus = gtk_widget_real_grab_focus;
......@@ -453,6 +456,14 @@ gtk_widget_class_init (GtkWidgetClass *klass)
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
GTK_TYPE_STYLE);
widget_signals[DIRECTION_CHANGED] =
gtk_signal_new ("direction_changed",
GTK_RUN_FIRST,
GTK_CLASS_TYPE (object_class),
GTK_SIGNAL_OFFSET (GtkWidgetClass, direction_changed),
gtk_marshal_NONE__UINT,
GTK_TYPE_NONE, 1,
GTK_TYPE_TEXT_DIRECTION);
widget_signals[ADD_ACCELERATOR] =
gtk_accel_group_create_add (GTK_CLASS_TYPE (object_class), GTK_RUN_LAST,
GTK_SIGNAL_OFFSET (GtkWidgetClass, add_accelerator));
......@@ -3050,6 +3061,13 @@ gtk_widget_style_set (GtkWidget *widget,
gtk_style_set_background (widget->style, widget->window, widget->state);
}
static void
gtk_widget_direction_changed (GtkWidget *widget,
GtkTextDirection previous_direction)
{
gtk_widget_queue_resize (widget);
}
static void
gtk_widget_set_style_internal (GtkWidget *widget,
GtkStyle *style,
......@@ -3874,10 +3892,14 @@ void
gtk_widget_set_direction (GtkWidget *widget,
GtkTextDirection dir)
{
GtkTextDirection old_dir;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (dir >= GTK_TEXT_DIR_NONE && dir <= GTK_TEXT_DIR_RTL);
old_dir = gtk_widget_get_direction (widget);
if (dir == GTK_TEXT_DIR_NONE)
GTK_PRIVATE_UNSET_FLAG (widget, GTK_DIRECTION_SET);
else
......@@ -3888,6 +3910,9 @@ gtk_widget_set_direction (GtkWidget *widget,
else
GTK_PRIVATE_UNSET_FLAG (widget, GTK_DIRECTION_LTR);
}
if (old_dir != gtk_widget_get_direction (widget))
gtk_signal_emit (GTK_OBJECT (widget), widget_signals[DIRECTION_CHANGED], old_dir);
}
/**
......@@ -3911,6 +3936,24 @@ gtk_widget_get_direction (GtkWidget *widget)
return gtk_default_direction;
}
static void
gtk_widget_set_default_direction_recurse (GtkWidget *widget, gpointer data)
{
GtkTextDirection old_dir = GPOINTER_TO_UINT (data);
g_object_ref (G_OBJECT (widget));
if (!GTK_WIDGET_DIRECTION_SET (widget))
gtk_signal_emit (GTK_OBJECT (widget), widget_signals[DIRECTION_CHANGED], old_dir);
if (GTK_IS_CONTAINER (widget))
gtk_container_forall (GTK_CONTAINER (widget),
gtk_widget_set_default_direction_recurse,
data);
g_object_unref (G_OBJECT (widget));
}
/**
* gtk_widget_set_default_direction:
* @dir: the new default direction. This cannot be
......@@ -3924,7 +3967,25 @@ gtk_widget_set_default_direction (GtkTextDirection dir)
{
g_return_if_fail (dir == GTK_TEXT_DIR_RTL || dir == GTK_TEXT_DIR_LTR);
gtk_default_direction = dir;
if (dir != gtk_default_direction)
{
GList *toplevels, *tmp_list;
GtkTextDirection old_dir = gtk_default_direction;
gtk_default_direction = dir;