summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2001-04-02 20:15:18 +0000
committerOwen Taylor <otaylor@src.gnome.org>2001-04-02 20:15:18 +0000
commit3961437baba035ba969e83c5bb15edce6ebc4e05 (patch)
treef5a99bb62eeb856fbd7eef304b955debf90d7902
parent096fdfb79706a5caa5cd7610401808325aee8c31 (diff)
downloadgtk+-3961437baba035ba969e83c5bb15edce6ebc4e05.tar.gz
Avoid chaining up to parent impl, since we have a INPUT_ONLY window.
Mon Apr 2 16:13:58 2001 Owen Taylor <otaylor@redhat.com> * gtk/gtkinvisible.c (gtk_invisible_style_set): Avoid chaining up to parent impl, since we have a INPUT_ONLY window. * gtk/gtkentry.[ch]: Add a cursor_color property to set the foreground color for the cursor.
-rw-r--r--gtk/gtkentry.c46
-rw-r--r--gtk/gtkentry.h2
-rw-r--r--gtk/gtkinvisible.c24
3 files changed, 61 insertions, 11 deletions
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 1d1a36e4cb..d620f389df 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -425,7 +425,14 @@ gtk_entry_class_init (GtkEntryClass *class)
-1,
G_PARAM_READABLE | G_PARAM_WRITABLE));
-
+
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_boxed ("cursor_color",
+ _("Cursor color"),
+ _("Color with which to draw insertion cursor"),
+ GTK_TYPE_GDK_COLOR,
+ G_PARAM_READABLE));
+
signals[INSERT_TEXT] =
gtk_signal_new ("insert_text",
GTK_RUN_LAST,
@@ -825,6 +832,24 @@ gtk_entry_finalize (GObject *object)
}
static void
+gtk_entry_realize_cursor_gc (GtkEntry *entry)
+{
+ GdkColor *cursor_color;
+
+ if (entry->cursor_gc)
+ gdk_gc_unref (entry->cursor_gc);
+
+ gtk_widget_style_get (GTK_WIDGET (entry), "cursor_color", &cursor_color, NULL);
+ if (cursor_color)
+ {
+ entry->cursor_gc = gdk_gc_new (entry->text_area);
+ gdk_gc_set_rgb_fg_color (entry->cursor_gc, cursor_color);
+ }
+ else
+ entry->cursor_gc = gdk_gc_ref (GTK_WIDGET (entry)->style->bg_gc[GTK_STATE_SELECTED]);
+}
+
+static void
gtk_entry_realize (GtkWidget *widget)
{
GtkEntry *entry;
@@ -883,9 +908,11 @@ gtk_entry_realize (GtkWidget *widget)
gdk_window_set_user_data (entry->text_area, entry);
gdk_cursor_destroy (attributes.cursor);
-
+
widget->style = gtk_style_attach (widget->style, widget->window);
+ gtk_entry_realize_cursor_gc (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)]);
@@ -915,8 +942,17 @@ gtk_entry_unrealize (GtkWidget *widget)
entry->text_area = NULL;
}
+ if (entry->cursor_gc)
+ {
+ gdk_gc_unref (entry->cursor_gc);
+ entry->cursor_gc = NULL;
+ }
+
if (entry->popup_menu)
- gtk_widget_destroy (entry->popup_menu);
+ {
+ gtk_widget_destroy (entry->popup_menu);
+ entry->popup_menu = NULL;
+ }
if (GTK_WIDGET_CLASS (parent_class)->unrealize)
(* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
@@ -1653,6 +1689,8 @@ gtk_entry_style_set (GtkWidget *widget,
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)]);
+
+ gtk_entry_realize_cursor_gc (entry);
}
}
@@ -2373,7 +2411,7 @@ gtk_entry_draw_cursor (GtkEntry *entry,
gtk_entry_get_cursor_locations (entry, type, &strong_x, &weak_x);
- gdk_draw_line (entry->text_area, widget->style->bg_gc[GTK_STATE_SELECTED],
+ gdk_draw_line (entry->text_area, entry->cursor_gc,
xoffset + strong_x, INNER_BORDER,
xoffset + strong_x, text_area_height - INNER_BORDER);
diff --git a/gtk/gtkentry.h b/gtk/gtkentry.h
index f94072b98e..a35e2be3cd 100644
--- a/gtk/gtkentry.h
+++ b/gtk/gtkentry.h
@@ -102,6 +102,8 @@ struct _GtkEntry
gunichar invisible_char;
gint width_chars;
+
+ GdkGC *cursor_gc;
};
struct _GtkEntryClass
diff --git a/gtk/gtkinvisible.c b/gtk/gtkinvisible.c
index 2594c3b7d4..8757fe42a4 100644
--- a/gtk/gtkinvisible.c
+++ b/gtk/gtkinvisible.c
@@ -28,13 +28,15 @@
#include "gtksignal.h"
#include "gtkinvisible.h"
-static void gtk_invisible_class_init (GtkInvisibleClass *klass);
-static void gtk_invisible_init (GtkInvisible *invisible);
-static void gtk_invisible_destroy (GtkObject *object);
-static void gtk_invisible_realize (GtkWidget *widget);
-static void gtk_invisible_show (GtkWidget *widget);
-static void gtk_invisible_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
+static void gtk_invisible_class_init (GtkInvisibleClass *klass);
+static void gtk_invisible_init (GtkInvisible *invisible);
+static void gtk_invisible_destroy (GtkObject *object);
+static void gtk_invisible_realize (GtkWidget *widget);
+static void gtk_invisible_style_set (GtkWidget *widget,
+ GtkStyle *previous_style);
+static void gtk_invisible_show (GtkWidget *widget);
+static void gtk_invisible_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation);
GtkType
gtk_invisible_get_type (void)
@@ -71,6 +73,7 @@ gtk_invisible_class_init (GtkInvisibleClass *class)
object_class = (GtkObjectClass*) class;
widget_class->realize = gtk_invisible_realize;
+ widget_class->style_set = gtk_invisible_style_set;
widget_class->show = gtk_invisible_show;
widget_class->size_allocate = gtk_invisible_size_allocate;
@@ -139,6 +142,13 @@ gtk_invisible_realize (GtkWidget *widget)
}
static void
+gtk_invisible_style_set (GtkWidget *widget,
+ GtkStyle *previous_style)
+{
+ /* Don't chain up to parent implementation */
+}
+
+static void
gtk_invisible_show (GtkWidget *widget)
{
g_return_if_fail (widget != NULL);