summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorOwen Taylor <owt1@cornell.edu>1998-03-31 02:36:51 +0000
committerOwen Taylor <otaylor@src.gnome.org>1998-03-31 02:36:51 +0000
commitf59f2039c00f4fc2788cbb483ac1133710959dcf (patch)
treedfe687fdeaa7da59af8bb1037e23bb61e19f85aa /gtk
parenta20f83d9a981cab18162bd52c6faabeeb61331cb (diff)
downloadgtk+-f59f2039c00f4fc2788cbb483ac1133710959dcf.tar.gz
Add a "style_set" callback, so the font can be changed at run time.
Mon Mar 30 21:29:43 1998 Owen Taylor <owt1@cornell.edu> * gtk/gtkentry.c: Add a "style_set" callback, so the font can be changed at run time. (needed for GIMP text tool)
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkentry.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index f5fe852a13..866456e2a0 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -65,6 +65,8 @@ static void gtk_entry_draw_cursor (GtkEntry *entry);
static void gtk_entry_draw_cursor_on_drawable
(GtkEntry *entry,
GdkDrawable *drawable);
+static void gtk_entry_style_set (GtkWidget *widget,
+ GtkStyle *previous_style);
static void gtk_entry_queue_draw (GtkEntry *entry);
static gint gtk_entry_timer (gpointer data);
static gint gtk_entry_position (GtkEntry *entry,
@@ -229,6 +231,7 @@ gtk_entry_class_init (GtkEntryClass *class)
widget_class->key_press_event = gtk_entry_key_press;
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;
editable_class->insert_text = gtk_entry_insert_text;
editable_class->delete_text = gtk_entry_delete_text;
@@ -2073,3 +2076,23 @@ gtk_entry_set_max_length (GtkEntry *entry,
gtk_editable_delete_text(GTK_EDITABLE(entry), max, -1);
entry->text_max_length = max;
}
+
+static void
+gtk_entry_style_set (GtkWidget *widget,
+ GtkStyle *previous_style)
+{
+ GtkEntry *entry;
+ gint scroll_char;
+
+ g_return_if_fail (widget != NULL);
+ g_return_if_fail (GTK_IS_ENTRY (widget));
+
+ if (previous_style && GTK_WIDGET_REALIZED (widget))
+ {
+ entry = GTK_ENTRY (widget);
+
+ scroll_char = gtk_entry_find_position (entry, entry->scroll_offset);
+ gtk_entry_recompute_offsets (GTK_ENTRY (widget));
+ entry->scroll_offset = entry->char_offset[scroll_char];
+ }
+}