diff options
author | Owen Taylor <otaylor@redhat.com> | 1999-02-10 00:39:49 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 1999-02-10 00:39:49 +0000 |
commit | c3a4205cfaf1cbe1b299a3dc49bb2e1907d580de (patch) | |
tree | e76b008a3ef88ebe04c4deabaa33357483a467f3 /gtk/gtkeditable.c | |
parent | 72d584389835b1f7de3dafd6b0fb0497c63646e3 (diff) | |
download | gdk-pixbuf-c3a4205cfaf1cbe1b299a3dc49bb2e1907d580de.tar.gz |
Moved entry->visible into editable class. (Leave it behind deprecated for
Tue Feb 9 19:39:32 1999 Owen Taylor <otaylor@redhat.com>
* gtk/gtkentry.[ch] gtk/gtkeditable.h: Moved
entry->visible into editable class. (Leave it
behind deprecated for compatibility)
* gtk/gtkeditable.c: If not editable->visible,
return *'s for clipboard and selection.
Diffstat (limited to 'gtk/gtkeditable.c')
-rw-r--r-- | gtk/gtkeditable.c | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/gtk/gtkeditable.c b/gtk/gtkeditable.c index d85743f87..178b5ca99 100644 --- a/gtk/gtkeditable.c +++ b/gtk/gtkeditable.c @@ -75,6 +75,9 @@ static void gtk_editable_set_arg (GtkObject *object, static void gtk_editable_get_arg (GtkObject *object, GtkArg *arg, guint arg_id); +static void *gtk_editable_get_public_chars (GtkEditable *editable, + gint start, + gint end); static gint gtk_editable_selection_clear (GtkWidget *widget, GdkEventSelection *event); static void gtk_editable_selection_get (GtkWidget *widget, @@ -382,6 +385,7 @@ gtk_editable_init (GtkEditable *editable) editable->selection_end_pos = 0; editable->has_selection = FALSE; editable->editable = 1; + editable->visible = 1; editable->clipboard_text = NULL; #ifdef USE_XIM @@ -473,6 +477,35 @@ gtk_editable_get_chars (GtkEditable *editable, return klass->get_chars (editable, start, end); } +/* + * Like gtk_editable_get_chars, but if the editable is not + * visible, return asterisks + */ +static void * +gtk_editable_get_public_chars (GtkEditable *editable, + gint start, + gint end) +{ + if (editable->visible) + return gtk_editable_get_chars (editable, start, end); + else + { + gint i; + gint nchars = end - start; + gchar *str; + + if (nchars < 0) + nchars = -nchars; + + str = g_new (gchar, nchars + 1); + for (i = 0; i<nchars; i++) + str[i] = '*'; + str[i] = '\0'; + + return str; + } +} + static void gtk_editable_set_selection (GtkEditable *editable, gint start_pos, @@ -568,9 +601,9 @@ gtk_editable_selection_get (GtkWidget *widget, { selection_start_pos = MIN (editable->selection_start_pos, editable->selection_end_pos); selection_end_pos = MAX (editable->selection_start_pos, editable->selection_end_pos); - str = gtk_editable_get_chars(editable, - selection_start_pos, - selection_end_pos); + str = gtk_editable_get_public_chars(editable, + selection_start_pos, + selection_end_pos); if (!str) return; /* Refuse */ length = strlen (str); @@ -890,9 +923,9 @@ gtk_editable_real_copy_clipboard (GtkEditable *editable) if (gtk_selection_owner_set (GTK_WIDGET (editable), clipboard_atom, time)) - editable->clipboard_text = gtk_editable_get_chars (editable, - selection_start_pos, - selection_end_pos); + editable->clipboard_text = gtk_editable_get_public_chars (editable, + selection_start_pos, + selection_end_pos); } } |