Re: [evolution-patches] EEntry patch to emulate GtkEntry behavior



Updated patch.  This fixes the color of the selection as well.

(I am using ->has_selection to keep track of whether we have focus; this
variable is used in the painting code but nowhere else so I am assuming
the code that updated it when getting in and out of focus got lost in
the GTK2 migration?)

BTW, why does e_text_event() have to call e_text_stop_editing()?  That
causes the primary selection to disappear when the focus is switched to
a different window.

-- Ettore
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/gal/ChangeLog,v
retrieving revision 1.764
diff -u -p -r1.764 ChangeLog
--- ChangeLog	1 May 2003 18:21:33 -0000	1.764
+++ ChangeLog	2 May 2003 19:09:10 -0000
@@ -1,3 +1,12 @@
+2003-05-02  Ettore Perazzoli  <ettore ximian com>
+
+	* gal/e-text/e-text.c (e_text_event): Set has_selection to TRUE
+	for focus in events, and to FALSE for focus out events.
+
+	* gal/e-text/e-entry.c (canvas_focus_in_event): If the
+	gtk-entry-select-on-focus GtkSetting is set, select all the text;
+	this way we behave like GtkEntry.
+
 2003-05-01  Mike Kestner  <mkestner ximian com>
 
 	* gal/e-text/e-completion-callbacks.c (e_completion_callbacks_new): 
Index: gal/e-text/e-entry.c
===================================================================
RCS file: /cvs/gnome/gal/gal/e-text/e-entry.c,v
retrieving revision 1.57
diff -u -p -r1.57 e-entry.c
--- gal/e-text/e-entry.c	3 Apr 2003 23:31:22 -0000	1.57
+++ gal/e-text/e-entry.c	2 May 2003 19:09:10 -0000
@@ -230,6 +230,16 @@ canvas_size_request (GtkWidget *widget, 
 static gint
 canvas_focus_in_event (GtkWidget *widget, GdkEventFocus *focus, EEntry *entry)
 {
+	gboolean select_on_focus;
+
+	g_object_get (G_OBJECT (gtk_widget_get_settings (widget)),
+		      "gtk-entry-select-on-focus",
+		      &select_on_focus,
+		      NULL);
+
+	if (select_on_focus)
+		e_text_select_all (E_TEXT (entry->item));
+	
 	if (entry->canvas->focused_item != GNOME_CANVAS_ITEM(entry->item))
 		gnome_canvas_item_grab_focus(GNOME_CANVAS_ITEM(entry->item));
 
Index: gal/e-text/e-text.c
===================================================================
RCS file: /cvs/gnome/gal/gal/e-text/e-text.c,v
retrieving revision 1.143
diff -u -p -r1.143 e-text.c
--- gal/e-text/e-text.c	8 Apr 2003 17:09:10 -0000	1.143
+++ gal/e-text/e-text.c	2 May 2003 19:09:10 -0000
@@ -2096,6 +2096,7 @@ e_text_event (GnomeCanvasItem *item, Gdk
 			GdkEventFocus *focus_event;
 			focus_event = (GdkEventFocus *) event;
 			if (focus_event->in) {
+				text->has_selection = TRUE;
 				if (text->im_context) {
 					if (!text->im_context_signals_registered) {
 						g_signal_connect (text->im_context, "commit",
@@ -2110,6 +2111,7 @@ e_text_event (GnomeCanvasItem *item, Gdk
 				start_editing (text);
 				text->show_cursor = FALSE; /* so we'll redraw and the cursor will be shown */
 			} else {
+				text->has_selection = FALSE;
 				if (text->im_context) {
 					g_signal_handlers_disconnect_matched (text->im_context,
 									      G_SIGNAL_MATCH_DATA,

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]