summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@gtk.org>1998-05-22 07:07:11 +0000
committerOwen Taylor <otaylor@src.gnome.org>1998-05-22 07:07:11 +0000
commit579856439b9d4a088717d15caaa1bc6cc7d10242 (patch)
tree830d51f7895280d656fbc411db4dacaeef14dd57 /gtk
parentbf874e967e1627a21bb8f25e5db13e3f68a2f083 (diff)
downloadgtk+-579856439b9d4a088717d15caaa1bc6cc7d10242.tar.gz
Added style_set handler.
Fri May 22 03:02:40 1998 Owen Taylor <otaylor@gtk.org> * gtk/gtkhandlebox.c: Added style_set handler. Fri May 22 02:55:57 1998 Owen Taylor <otaylor@gtk.org> [ From: Chris Lahey <clahey@umich.edu> ] * gtk/gtkeditable.c, gtk/gtkeditable.h, gtk/gtktext.c, gtk/gtkentry.c: Added get_position, and set_position functions to get and set the cursor position. * gtk/gtkeditable.c: Restored "insert_text" and "delete_text" to signal status. Make GtkText do user-controlled insertion and deletion through the Editable widget so that these signals are properly emitted. * gtk/gtkentry.c: Changed gtk_entry_set_visibility to display asterisks instead of empty space when visible = FALSE)
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkeditable.c100
-rw-r--r--gtk/gtkeditable.h5
-rw-r--r--gtk/gtkentry.c99
-rw-r--r--gtk/gtkhandlebox.c26
-rw-r--r--gtk/gtktext.c69
-rw-r--r--gtk/testgtk.c15
6 files changed, 252 insertions, 62 deletions
diff --git a/gtk/gtkeditable.c b/gtk/gtkeditable.c
index b4e45b5aa6..d5803634c3 100644
--- a/gtk/gtkeditable.c
+++ b/gtk/gtkeditable.c
@@ -35,6 +35,8 @@
enum {
ACTIVATE,
CHANGED,
+ INSERT_TEXT,
+ DELETE_TEXT,
LAST_SIGNAL
};
@@ -53,12 +55,32 @@ static void gtk_editable_set_selection (GtkEditable *editable,
gint start,
gint end);
+static void gtk_editable_marshal_signal_1 (GtkObject * object,
+ GtkSignalFunc func,
+ gpointer func_data,
+ GtkArg * args);
+static void gtk_editable_marshal_signal_2 (GtkObject * object,
+ GtkSignalFunc func,
+ gpointer func_data,
+ GtkArg * args);
+
static GtkWidgetClass *parent_class = NULL;
static guint editable_signals[LAST_SIGNAL] = { 0 };
static GdkAtom ctext_atom = GDK_NONE;
static GdkAtom text_atom = GDK_NONE;
static GdkAtom clipboard_atom = GDK_NONE;
+typedef void (*GtkTextSignal1) (GtkObject * object,
+ gchar *arg1,
+ gint arg2,
+ gint *arg3,
+ gpointer data);
+
+typedef void (*GtkTextSignal2) (GtkObject * object,
+ gint arg1,
+ gint arg2,
+ gpointer data);
+
guint
gtk_editable_get_type (void)
{
@@ -110,6 +132,29 @@ gtk_editable_class_init (GtkEditableClass *class)
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
+ editable_signals[INSERT_TEXT] =
+ gtk_signal_new ("insert_text",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (GtkEditableClass, insert_text),
+ gtk_editable_marshal_signal_1,
+ GTK_TYPE_NONE,
+ 3,
+ GTK_TYPE_STRING,
+ GTK_TYPE_INT,
+ GTK_TYPE_POINTER);
+
+ editable_signals[DELETE_TEXT] =
+ gtk_signal_new ("delete_text",
+ GTK_RUN_LAST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (GtkEditableClass, delete_text),
+ gtk_editable_marshal_signal_2,
+ GTK_TYPE_NONE,
+ 2,
+ GTK_TYPE_INT,
+ GTK_TYPE_INT);
+
gtk_object_class_add_signals (object_class, editable_signals, LAST_SIGNAL);
object_class->finalize = gtk_editable_finalize;
@@ -219,7 +264,7 @@ gtk_editable_insert_text (GtkEditable *editable,
strncpy (text, new_text, new_text_length);
- klass->insert_text (editable, text, new_text_length, position);
+ gtk_signal_emit (GTK_OBJECT (editable), editable_signals[INSERT_TEXT], text, new_text_length, position);
gtk_signal_emit (GTK_OBJECT (editable), editable_signals[CHANGED]);
if (new_text_length > 64)
@@ -238,7 +283,7 @@ gtk_editable_delete_text (GtkEditable *editable,
klass = GTK_EDITABLE_CLASS (GTK_OBJECT (editable)->klass);
- klass->delete_text (editable, start_pos, end_pos);
+ gtk_signal_emit (GTK_OBJECT (editable), editable_signals[DELETE_TEXT], start_pos, end_pos);
gtk_signal_emit (GTK_OBJECT (editable), editable_signals[CHANGED]);
}
@@ -287,6 +332,26 @@ gtk_editable_set_selection (GtkEditable *editable,
klass->set_selection (editable, start_pos, end_pos);
}
+void
+gtk_editable_set_position (GtkEditable *editable,
+ gint position)
+{
+ GtkEditableClass *klass;
+
+ g_return_if_fail (editable != NULL);
+ g_return_if_fail (GTK_IS_EDITABLE (editable));
+
+ klass = GTK_EDITABLE_CLASS (GTK_OBJECT (editable)->klass);
+
+ return klass->set_position (editable, position);
+}
+
+gint
+gtk_editable_get_position (GtkEditable *editable)
+{
+ return editable->current_pos;
+}
+
static gint
gtk_editable_selection_clear (GtkWidget *widget,
GdkEventSelection *event)
@@ -573,3 +638,34 @@ gtk_editable_changed (GtkEditable *editable)
{
gtk_signal_emit (GTK_OBJECT (editable), editable_signals[CHANGED]);
}
+
+static void
+gtk_editable_marshal_signal_1 (GtkObject * object,
+ GtkSignalFunc func,
+ gpointer func_data,
+ GtkArg * args)
+{
+ GtkTextSignal1 rfunc;
+
+ rfunc = (GtkTextSignal1) func;
+
+ (*rfunc) (object, GTK_VALUE_STRING (args[0]),
+ GTK_VALUE_INT (args[1]),
+ GTK_VALUE_POINTER (args[2]),
+ func_data);
+}
+
+static void
+gtk_editable_marshal_signal_2 (GtkObject * object,
+ GtkSignalFunc func,
+ gpointer func_data,
+ GtkArg * args)
+{
+ GtkTextSignal2 rfunc;
+
+ rfunc = (GtkTextSignal2) func;
+
+ (*rfunc) (object, GTK_VALUE_INT (args[0]),
+ GTK_VALUE_INT (args[1]),
+ func_data);
+}
diff --git a/gtk/gtkeditable.h b/gtk/gtkeditable.h
index 577957c7f5..2c4d3bab97 100644
--- a/gtk/gtkeditable.h
+++ b/gtk/gtkeditable.h
@@ -76,6 +76,8 @@ struct _GtkEditableClass
gint end_pos);
void (* activate) (GtkEditable *editable);
void (* changed) (GtkEditable *editable);
+ void (* set_position) (GtkEditable *editable,
+ gint position);
};
guint gtk_editable_get_type (void);
@@ -104,6 +106,9 @@ void gtk_editable_claim_selection (GtkEditable *editable,
void gtk_editable_delete_selection (GtkEditable *editable);
void gtk_editable_changed (GtkEditable *editable);
+void gtk_editable_set_position (GtkEditable *editable,
+ gint position);
+gint gtk_editable_get_position (GtkEditable *editable);
#ifdef __cplusplus
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 93cf32e577..7b258ffd85 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -115,6 +115,8 @@ static gint gtk_entry_find_char (GtkEntry *entry,
gint position);
static gint gtk_entry_find_position (GtkEntry *entry,
gint position);
+static void gtk_entry_set_position_from_editable (GtkEditable *editable,
+ gint position);
static GtkWidgetClass *parent_class = NULL;
static GdkAtom ctext_atom = GDK_NONE;
@@ -241,6 +243,7 @@ gtk_entry_class_init (GtkEntryClass *class)
editable_class->set_selection = gtk_entry_set_selection;
editable_class->changed = (void (*)(GtkEditable *)) gtk_entry_adjust_scroll;
editable_class->activate = NULL;
+ editable_class->set_position = gtk_entry_set_position_from_editable;
}
static void
@@ -351,6 +354,13 @@ gtk_entry_set_position (GtkEntry *entry,
GTK_EDITABLE(entry)->current_pos = position;
}
+static void
+gtk_entry_set_position_from_editable (GtkEditable *editable,
+ gint position)
+{
+ gtk_entry_set_position (GTK_ENTRY (editable), position);
+}
+
void
gtk_entry_set_visibility (GtkEntry *entry,
gboolean visible)
@@ -359,6 +369,8 @@ gtk_entry_set_visibility (GtkEntry *entry,
g_return_if_fail (GTK_IS_ENTRY (entry));
entry->visible = visible;
+ gtk_entry_recompute_offsets (entry);
+ gtk_widget_queue_draw (GTK_WIDGET (entry));
}
void
@@ -1142,7 +1154,10 @@ gtk_entry_draw_text (GtkEntry *entry)
gint start_char;
gint start_pos;
gint end_pos;
+ gint end_char;
gint start_xoffset;
+ gint selection_start_char;
+ gint selection_end_char;
gint selection_start_pos;
gint selection_end_pos;
gint selection_start_xoffset;
@@ -1151,6 +1166,8 @@ gtk_entry_draw_text (GtkEntry *entry)
gint y;
GdkDrawable *drawable;
gint use_backing_pixmap;
+ gchar *stars;
+ gchar *toprint;
g_return_if_fail (entry != NULL);
g_return_if_fail (GTK_IS_ENTRY (entry));
@@ -1161,12 +1178,6 @@ gtk_entry_draw_text (GtkEntry *entry)
entry->timer = 0;
}
- if (!entry->visible)
- {
- gtk_entry_draw_cursor (entry);
- return;
- }
-
if (GTK_WIDGET_DRAWABLE (entry))
{
widget = GTK_WIDGET (entry);
@@ -1212,32 +1223,55 @@ gtk_entry_draw_text (GtkEntry *entry)
start_pos = entry->char_pos[start_char];
start_xoffset = entry->char_offset[start_char] - entry->scroll_offset;
- end_pos = gtk_entry_position (entry, entry->scroll_offset + width);
+ end_char = gtk_entry_find_position (entry, entry->scroll_offset + width);
+ end_pos = entry->char_pos[end_char];
if (end_pos < entry->text_length)
end_pos += 1;
selected_state = GTK_STATE_SELECTED;
if (!editable->has_selection)
selected_state = GTK_STATE_ACTIVE;
-
+
selection_start_pos = MIN (editable->selection_start_pos, editable->selection_end_pos);
selection_end_pos = MAX (editable->selection_start_pos, editable->selection_end_pos);
selection_start_pos = CLAMP (selection_start_pos, start_pos, end_pos);
selection_end_pos = CLAMP (selection_end_pos, start_pos, end_pos);
+ selection_start_char = gtk_entry_find_char(entry,selection_start_pos);
+ selection_end_char = gtk_entry_find_char(entry,selection_end_pos);
+
selection_start_xoffset =
- entry->char_offset[gtk_entry_find_char(entry,selection_start_pos)] -
- entry->scroll_offset;
+ entry->char_offset[selection_start_char] - entry->scroll_offset;
selection_end_xoffset =
- entry->char_offset[gtk_entry_find_char(entry,selection_end_pos)] -
- entry->scroll_offset;
+ entry->char_offset[selection_end_char] -entry->scroll_offset;
+ /* if entry->visible, print a bunch of stars. If not, print the standard text. */
+ if (entry->visible)
+ {
+ toprint = entry->text + start_pos;
+ }
+ else
+ {
+ gint i;
+
+ stars = g_malloc (end_char - start_char);
+ for (i = 0; i < end_char - start_char; i++)
+ stars[i] = '*';
+ toprint = stars;
+
+ /* Since '*' is always one byte, work in bytes */
+ start_pos = start_char;
+ selection_start_pos = selection_start_char;
+ selection_end_pos = selection_end_char;
+ end_pos = end_char;
+ }
+
if (selection_start_pos > start_pos)
gdk_draw_text (drawable, widget->style->font,
widget->style->fg_gc[GTK_STATE_NORMAL],
start_xoffset, y,
- entry->text + start_pos,
+ toprint,
selection_start_pos - start_pos);
if ((selection_end_pos >= start_pos) &&
@@ -1255,7 +1289,7 @@ gtk_entry_draw_text (GtkEntry *entry)
gdk_draw_text (drawable, widget->style->font,
widget->style->fg_gc[selected_state],
selection_start_xoffset, y,
- entry->text + selection_start_pos,
+ toprint + selection_start_pos - start_pos,
selection_end_pos - selection_start_pos);
}
@@ -1263,9 +1297,13 @@ gtk_entry_draw_text (GtkEntry *entry)
gdk_draw_text (drawable, widget->style->font,
widget->style->fg_gc[GTK_STATE_NORMAL],
selection_end_xoffset, y,
- entry->text + selection_end_pos,
+ toprint + selection_end_pos - start_pos,
end_pos - selection_end_pos);
+ /* free the space allocated for the stars if it's neccessary. */
+ if (!entry->visible)
+ g_free (toprint);
+
if (editable->editable)
gtk_entry_draw_cursor_on_drawable (entry, drawable);
@@ -1303,10 +1341,7 @@ gtk_entry_draw_cursor_on_drawable (GtkEntry *entry, GdkDrawable *drawable)
widget = GTK_WIDGET (entry);
editable = GTK_EDITABLE (entry);
- if (entry->visible)
- xoffset = entry->char_offset[gtk_entry_find_char (entry, editable->current_pos)];
- else
- xoffset = 0;
+ xoffset = entry->char_offset[gtk_entry_find_char (entry, editable->current_pos)];
xoffset -= entry->scroll_offset;
if (GTK_WIDGET_HAS_FOCUS (widget) &&
@@ -1576,9 +1611,16 @@ gtk_entry_insert_text (GtkEditable *editable,
for (i=start_char; i<end_char; i++)
{
entry->char_offset[i] = entry->char_offset[start_char] + offset;
- offset += gdk_text_width (GTK_WIDGET (entry)->style->font,
- entry->text + entry->char_pos[i],
- entry->char_pos[i+1] - entry->char_pos[i]);
+ if (entry->visible)
+ {
+ offset += gdk_text_width (GTK_WIDGET (entry)->style->font,
+ entry->text + entry->char_pos[i],
+ entry->char_pos[i+1] - entry->char_pos[i]);
+ }
+ else
+ {
+ offset += gdk_text_width (GTK_WIDGET (entry)->style->font, "*", 1);
+ }
}
for (i = end_char ; i <= last_char ; i++)
entry->char_offset[i] += offset;
@@ -1601,9 +1643,16 @@ gtk_entry_recompute_offsets (GtkEntry *entry)
for (i=0; i<entry->nchars; i++)
{
entry->char_offset[i] = offset;
- offset += gdk_text_width (GTK_WIDGET (entry)->style->font,
- entry->text + entry->char_pos[i],
- entry->char_pos[i+1] - entry->char_pos[i]);
+ if (entry->visible)
+ {
+ offset += gdk_text_width (GTK_WIDGET (entry)->style->font,
+ entry->text + entry->char_pos[i],
+ entry->char_pos[i+1] - entry->char_pos[i]);
+ }
+ else
+ {
+ offset += gdk_text_width (GTK_WIDGET (entry)->style->font, "*", 1);
+ }
}
entry->char_offset[i] = offset;
diff --git a/gtk/gtkhandlebox.c b/gtk/gtkhandlebox.c
index f723807b72..a59f643ea1 100644
--- a/gtk/gtkhandlebox.c
+++ b/gtk/gtkhandlebox.c
@@ -49,6 +49,8 @@ static void gtk_handle_box_map (GtkWidget *widget);
static void gtk_handle_box_unmap (GtkWidget *widget);
static void gtk_handle_box_realize (GtkWidget *widget);
static void gtk_handle_box_unrealize (GtkWidget *widget);
+static void gtk_handle_box_style_set (GtkWidget *widget,
+ GtkStyle *previous_style);
static void gtk_handle_box_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void gtk_handle_box_size_allocate (GtkWidget *widget,
@@ -151,6 +153,7 @@ gtk_handle_box_class_init (GtkHandleBoxClass *class)
widget_class->unmap = gtk_handle_box_unmap;
widget_class->realize = gtk_handle_box_realize;
widget_class->unrealize = gtk_handle_box_unrealize;
+ widget_class->style_set = gtk_handle_box_style_set;
widget_class->size_request = gtk_handle_box_size_request;
widget_class->size_allocate = gtk_handle_box_size_allocate;
widget_class->draw = gtk_handle_box_draw;
@@ -350,6 +353,29 @@ gtk_handle_box_unrealize (GtkWidget *widget)
}
static void
+gtk_handle_box_style_set (GtkWidget *widget,
+ GtkStyle *previous_style)
+{
+ GtkHandleBox *hb;
+
+ g_return_if_fail (widget != NULL);
+ g_return_if_fail (GTK_IS_HANDLE_BOX (widget));
+
+ hb = GTK_HANDLE_BOX (widget);
+
+ if (GTK_WIDGET_REALIZED (widget) &&
+ !GTK_WIDGET_NO_WINDOW (widget))
+ {
+ gtk_style_set_background (widget->style, widget->window,
+widget->state);
+ gtk_style_set_background (widget->style, hb->bin_window, widget->state);
+ gtk_style_set_background (widget->style, hb->float_window, widget->state);
+ if (GTK_WIDGET_DRAWABLE (widget))
+ gdk_window_clear (widget->window);
+ }
+}
+
+static void
gtk_handle_box_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 69b533c29a..448f913aa7 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -302,6 +302,9 @@ static void gtk_text_select_word (GtkText *text,
static void gtk_text_select_line (GtkText *text,
guint32 time);
+static void gtk_text_set_position (GtkEditable *editable,
+ gint position);
+
/* #define DEBUG_GTK_TEXT */
#if defined(DEBUG_GTK_TEXT) && defined(__GNUC__)
@@ -478,6 +481,7 @@ gtk_text_class_init (GtkTextClass *class)
editable_class->update_text = gtk_text_update_text;
editable_class->get_chars = gtk_text_get_chars;
editable_class->set_selection = gtk_text_set_selection;
+ editable_class->set_position = gtk_text_set_position;
}
static void
@@ -834,6 +838,20 @@ gtk_text_forward_delete (GtkText *text,
return TRUE;
}
+
+static void
+gtk_text_set_position (GtkEditable *editable,
+ gint position)
+{
+ GtkText *text = (GtkText *) editable;
+
+ undraw_cursor( text, FALSE );
+ text->has_cursor = 1;
+ text->cursor_mark = find_mark( text, position );
+ find_cursor( text, TRUE );
+ draw_cursor( text, FALSE );
+ gtk_editable_select_region (editable, 0, 0);
+}
static gchar *
gtk_text_get_chars (GtkEditable *editable,
@@ -1584,16 +1602,6 @@ gtk_text_motion_notify (GtkWidget *widget,
return FALSE;
}
-static void
-gtk_text_insert_1_at_point (GtkText* text, gchar key)
-{
- gtk_text_insert (text,
- MARK_CURRENT_FONT (&text->point),
- MARK_CURRENT_FORE (&text->point),
- MARK_CURRENT_BACK (&text->point),
- &key, 1);
-}
-
static void
gtk_text_insert_text (GtkEditable *editable,
const gchar *new_text,
@@ -1635,6 +1643,7 @@ gtk_text_key_press (GtkWidget *widget,
GtkEditable *editable;
gchar key;
gint return_val;
+ gint position;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_TEXT (widget), FALSE);
@@ -1765,16 +1774,16 @@ gtk_text_key_press (GtkWidget *widget,
gtk_text_delete_forward_character (text);
break;
case GDK_Tab:
- gtk_text_insert_1_at_point (text, '\t');
- gtk_editable_changed (editable);
+ position = text->point.index;
+ gtk_editable_insert_text (editable, "\t", 1, &position);
break;
case GDK_Return:
if (event->state & GDK_CONTROL_MASK)
gtk_signal_emit_by_name (GTK_OBJECT (text), "activate");
else
{
- gtk_text_insert_1_at_point (text, '\n');
- gtk_editable_changed (editable);
+ position = text->point.index;
+ gtk_editable_insert_text (editable, "\n", 1, &position);
}
break;
case GDK_Escape:
@@ -1818,8 +1827,8 @@ gtk_text_key_press (GtkWidget *widget,
if (event->length == 1)
{
gtk_editable_delete_selection (editable);
- gtk_text_insert_1_at_point (text, event->string[0]);
- gtk_editable_changed (editable);
+ position = text->point.index;
+ gtk_editable_insert_text (editable, &(event->string[0]), 1, &position);
}
return_val = TRUE;
@@ -3488,8 +3497,7 @@ gtk_text_delete_forward_character (GtkText *text)
gtk_editable_delete_selection (editable);
else
{
- gtk_text_forward_delete (text, 1);
- gtk_editable_changed (editable);
+ gtk_editable_delete_text (editable, text->point.index, text->point.index + 1);
}
}
@@ -3503,8 +3511,7 @@ gtk_text_delete_backward_character (GtkText *text)
gtk_editable_delete_selection (editable);
else
{
- gtk_text_backward_delete (text, 1);
- gtk_editable_changed (editable);
+ gtk_editable_delete_text (editable, text->point.index - 1, text->point.index);
}
}
@@ -3522,9 +3529,7 @@ gtk_text_delete_forward_word (GtkText *text)
{
old_pos = text->cursor_mark.index;
gtk_text_move_forward_word (text);
- gtk_text_set_point (text, text->cursor_mark.index);
- gtk_text_backward_delete (text, text->cursor_mark.index - old_pos);
- gtk_editable_changed (editable);
+ gtk_editable_delete_text (editable, old_pos, text->cursor_mark.index);
}
}
@@ -3540,11 +3545,9 @@ gtk_text_delete_backward_word (GtkText *text)
gtk_editable_delete_selection (editable);
else
{
- old_pos = text->point.index;
+ old_pos = text->cursor_mark.index;
gtk_text_move_backward_word (text);
- gtk_text_set_point (text, text->cursor_mark.index);
- gtk_text_forward_delete (text, old_pos - text->cursor_mark.index);
- gtk_editable_changed (editable);
+ gtk_editable_delete_text (editable, text->cursor_mark.index, old_pos);
}
}
@@ -3553,6 +3556,7 @@ gtk_text_delete_line (GtkText *text)
{
gint start_pos;
gint end_pos;
+ GtkEditable *editable = GTK_EDITABLE (text);
gtk_text_move_beginning_of_line (text);
start_pos = text->cursor_mark.index;
@@ -3561,10 +3565,7 @@ gtk_text_delete_line (GtkText *text)
gtk_text_move_forward_character (text);
end_pos = text->cursor_mark.index;
- gtk_text_set_point (text, start_pos);
- gtk_text_forward_delete (text, end_pos - start_pos);
-
- gtk_editable_changed (GTK_EDITABLE (text));
+ gtk_editable_delete_text (editable, start_pos, end_pos);
}
static void
@@ -3572,6 +3573,7 @@ gtk_text_delete_to_line_end (GtkText *text)
{
gint start_pos;
gint end_pos;
+ GtkEditable *editable = GTK_EDITABLE (text);
start_pos = text->cursor_mark.index;
@@ -3581,10 +3583,7 @@ gtk_text_delete_to_line_end (GtkText *text)
gtk_text_move_forward_character (text);
end_pos = text->cursor_mark.index;
- gtk_text_set_point (text, start_pos);
- gtk_text_forward_delete (text, end_pos - start_pos);
-
- gtk_editable_changed (GTK_EDITABLE (text));
+ gtk_editable_delete_text (editable, start_pos, end_pos);
}
static void
diff --git a/gtk/testgtk.c b/gtk/testgtk.c
index b2a4ca8a71..586966cfed 100644
--- a/gtk/testgtk.c
+++ b/gtk/testgtk.c
@@ -2265,6 +2265,14 @@ entry_toggle_editable (GtkWidget *checkbutton,
}
static void
+entry_toggle_visibility (GtkWidget *checkbutton,
+ GtkWidget *entry)
+{
+ gtk_entry_set_visibility(GTK_ENTRY(entry),
+ GTK_TOGGLE_BUTTON(checkbutton)->active);
+}
+
+static void
create_entry (void)
{
static GtkWidget *window = NULL;
@@ -2330,6 +2338,13 @@ create_entry (void)
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(editable_check), TRUE);
gtk_widget_show (editable_check);
+ editable_check = gtk_check_button_new_with_label("Visible");
+ gtk_box_pack_start (GTK_BOX (box2), editable_check, FALSE, TRUE, 0);
+ gtk_signal_connect (GTK_OBJECT(editable_check), "toggled",
+ GTK_SIGNAL_FUNC(entry_toggle_visibility), entry);
+ gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(editable_check), TRUE);
+ gtk_widget_show (editable_check);
+
separator = gtk_hseparator_new ();
gtk_box_pack_start (GTK_BOX (box1), separator, FALSE, TRUE, 0);
gtk_widget_show (separator);