[Nautilus-list] [PATCH] Make EelTextCaption behave properly in preferences



I just added to more funcions to eel_text_captionto make Nautilus not to
move the cursor to the end of the GtkEntry widget when a user modifies
the text in an EelTextCaption widget from the preferences.

To try just try to edit the preference for you search engine from
www.google.com to www.gbgle.com. You'll probably end with www.gogle.cob
or something like that, if you don't look to the screen.

Well, this patch just tries to make it don't happen anymore.

PD: Hope I did managed to explain myself (though I don't think so).
(IF in doubt just try the patch).
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/eel/ChangeLog,v
retrieving revision 1.95
diff -p -u -r1.95 ChangeLog
--- ChangeLog	2001/05/17 23:00:38	1.95
+++ ChangeLog	2001/05/19 15:33:21
@@ -1,3 +1,19 @@
+2001-05-19  Miguel Rodríguez Pérez  <migras atlas uvigo es>
+
+	* eel/eel-preferences-item.c 
+	(preferences_item_update_editable_string): 
+	(preferences_item_update_editable_integer): 
+	Use eel_text_caption_get_position and
+	eel_text_caption_set_position to not alter
+	thr cursor's position
+
+	* eel/eel-text-caption.h:
+	* eel/eel-text-caption.c 
+	(eel_text_caption_get_position): 
+	(eel_text_caption_set_position): 
+	New functions to get and set the cursos
+	position in an eel_text_caption.
+
 2001-05-17  Darin Adler  <darin eazel com>
 
 	* eel/eel-gtk-extensions.c:
Index: eel/eel-preferences-item.c
===================================================================
RCS file: /cvs/gnome/eel/eel/eel-preferences-item.c,v
retrieving revision 1.2
diff -p -u -r1.2 eel-preferences-item.c
--- eel/eel-preferences-item.c	2001/05/04 13:00:14	1.2
+++ eel/eel-preferences-item.c	2001/05/19 15:33:24
@@ -556,6 +556,8 @@ static void
 preferences_item_update_editable_string (EelPreferencesItem *item)
 {
 	char *current_value;
+	gint current_position;
+	gboolean same_text;
 
 	g_return_if_fail (EEL_IS_PREFERENCES_ITEM (item));
 	g_return_if_fail (item->details->item_type == EEL_PREFERENCE_ITEM_EDITABLE_STRING);
@@ -563,7 +565,13 @@ preferences_item_update_editable_string 
 	current_value = eel_preferences_get (item->details->preference_name);
 
 	g_assert (current_value != NULL);
+	current_position = eel_text_caption_get_position (EEL_TEXT_CAPTION(item->details->main_child));
+	same_text = !strcmp(eel_text_caption_get_text (EEL_TEXT_CAPTION (item->details->main_child)),
+			      current_value);
 	eel_text_caption_set_text (EEL_TEXT_CAPTION (item->details->main_child), current_value);
+	if (same_text)
+		eel_text_caption_set_position(EEL_TEXT_CAPTION (item->details->main_child),
+					      current_position);
 	g_free (current_value);
 }
 
@@ -605,6 +613,8 @@ static void
 preferences_item_update_editable_integer (EelPreferencesItem *item)
 {
 	char *current_value;
+	gint current_position;
+	gboolean same_text;
 
 	g_return_if_fail (EEL_IS_PREFERENCES_ITEM (item));
 	g_return_if_fail (item->details->item_type == EEL_PREFERENCE_ITEM_EDITABLE_INTEGER);
@@ -612,7 +622,13 @@ preferences_item_update_editable_integer
 	current_value = g_strdup_printf ("%d", eel_preferences_get_integer (item->details->preference_name));
 
 	g_assert (current_value != NULL);
+	current_position = eel_text_caption_get_position (EEL_TEXT_CAPTION(item->details->main_child));
+	same_text = !strcmp(eel_text_caption_get_text (EEL_TEXT_CAPTION (item->details->main_child)),
+			      current_value);
 	eel_text_caption_set_text (EEL_TEXT_CAPTION (item->details->main_child), current_value);
+	if (same_text)
+		eel_text_caption_set_position(EEL_TEXT_CAPTION (item->details->main_child),
+					      current_position);
 	g_free (current_value);
 }
 
Index: eel/eel-text-caption.c
===================================================================
RCS file: /cvs/gnome/eel/eel/eel-text-caption.c,v
retrieving revision 1.4
diff -p -u -r1.4 eel-text-caption.c
--- eel/eel-text-caption.c	2001/04/04 07:51:37	1.4
+++ eel/eel-text-caption.c	2001/05/19 15:33:25
@@ -241,3 +241,22 @@ eel_text_caption_set_expand_tilde (EelTe
 
 	text_caption->detail->expand_tilde = expand_tilde;
 }
+
+gint
+eel_text_caption_get_position (const EelTextCaption *text_caption)
+{
+	g_return_val_if_fail (EEL_IS_TEXT_CAPTION (text_caption), 0);
+
+	return gtk_editable_get_position (GTK_EDITABLE(text_caption->
+						       detail->text));
+}
+
+void       
+eel_text_caption_set_position     (EelTextCaption *text_caption,
+				   gint position)
+{
+	g_return_if_fail (EEL_IS_TEXT_CAPTION (text_caption));
+
+	gtk_editable_set_position (GTK_EDITABLE(text_caption->
+						detail->text), position);
+}
Index: eel/eel-text-caption.h
===================================================================
RCS file: /cvs/gnome/eel/eel/eel-text-caption.h,v
retrieving revision 1.4
diff -p -u -r1.4 eel-text-caption.h
--- eel/eel-text-caption.h	2001/04/04 07:51:37	1.4
+++ eel/eel-text-caption.h	2001/05/19 15:33:25
@@ -72,6 +72,10 @@ void       eel_text_caption_set_editable
 					      gboolean              editable);
 void       eel_text_caption_set_expand_tilde (EelTextCaption       *text_caption,
 					      gboolean              expand_tilde);
+/* Entry icon position */
+gint       eel_text_caption_get_position     (const EelTextCaption *text_caption);
+void       eel_text_caption_set_position     (EelTextCaption       *text_caption,
+					      gint                  position);
 
 END_GNOME_DECLS
 


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