[gnumeric] don't overwrite text when pasting names



commit 72276d6fa5964a3f036c65adcf75c513bb752cea
Author: Andreas J Guelzow <aguelzow pyrshep ca>
Date:   Thu Jun 3 12:32:50 2010 -0600

    don't overwrite text when pasting names
    
    2010-06-03 Andreas J. Guelzow <aguelzow pyrshep ca>
    
    	dialog-define-names.c (name_guru_paste): don't overwrite text

 src/dialogs/ChangeLog             |    4 +++
 src/dialogs/dialog-define-names.c |   45 ++++++++++++++++++-------------------
 2 files changed, 26 insertions(+), 23 deletions(-)
---
diff --git a/src/dialogs/ChangeLog b/src/dialogs/ChangeLog
index 5643a8f..9ba3289 100644
--- a/src/dialogs/ChangeLog
+++ b/src/dialogs/ChangeLog
@@ -1,5 +1,9 @@
 2010-06-03 Andreas J. Guelzow <aguelzow pyrshep ca>
 
+	dialog-define-names.c (name_guru_paste): don't overwrite text
+	
+2010-06-03 Andreas J. Guelzow <aguelzow pyrshep ca>
+
 	* paste-names.glade: deleted
 	* dialog-paste-names.c: deleted
 	* Makefile.am: remove the two above
diff --git a/src/dialogs/dialog-define-names.c b/src/dialogs/dialog-define-names.c
index dd7bbff..a44f157 100644
--- a/src/dialogs/dialog-define-names.c
+++ b/src/dialogs/dialog-define-names.c
@@ -334,9 +334,8 @@ name_guru_populate_list (NameGuruState *state)
 static gboolean
 name_guru_paste (NameGuruState *state, GtkTreeIter *iter) 
 {
-        char *name, *txt;
+        char *name;
 	gboolean is_pastable;
-	WorkbookControl *wbc = WORKBOOK_CONTROL (state->wbcg);
 
 	gtk_tree_model_get (GTK_TREE_MODEL (state->model), 
 			    iter,
@@ -347,23 +346,27 @@ name_guru_paste (NameGuruState *state, GtkTreeIter *iter)
 	if (!is_pastable)
 		return FALSE;
 
-	txt = g_strconcat ("=", name, NULL);
-
-	g_free (name);
-	state->has_pasted = TRUE;
-
 	if (wbcg_edit_start (state->wbcg, FALSE, FALSE)) {
-		WorkbookControl *wbc = WORKBOOK_CONTROL (state->wbcg);
-		SheetView *sv = wb_control_cur_sheet_view (wbc);
-		Sheet *sheet = sv_sheet (sv);
-		GnmCell const *cell = sheet_cell_fetch (sheet,
-							sv->edit_pos.col,
-							sv->edit_pos.row);
-		wb_control_edit_line_set (wbc, txt);
-
+		GtkEntry *entry;
+		gint position;
+		entry = wbcg_get_entry (state->wbcg);
+
+		position = gtk_entry_get_text_length (entry);
+		if (position == 0)
+			gtk_editable_insert_text (GTK_EDITABLE (entry), "=",
+					  -1, &position);
+		if (state->has_pasted) {
+			char sep = go_locale_get_arg_sep ();
+			gtk_editable_insert_text (GTK_EDITABLE (entry), &sep,
+					  1, &position);
+		}
+		gtk_editable_insert_text (GTK_EDITABLE (entry), name,
+					  -1, &position);
 	}
-	g_free (txt);
 
+	g_free (name);
+
+	state->has_pasted = TRUE;
 	return TRUE;
 }
 
@@ -417,22 +420,18 @@ cb_name_guru_destroy (NameGuruState *state)
 		state->gui = NULL;
 	}
 
-	wbcg_edit_finish (state->wbcg,
-			  state->has_pasted ?
-			  WBC_EDIT_ACCEPT : WBC_EDIT_REJECT,
-			  NULL);
-
-	state->dialog = NULL;
-
 	if (state->is_paste_dialog)
 		g_object_unref (G_OBJECT (state->image_paste));
 	else {
+		wbcg_edit_finish (state->wbcg, WBC_EDIT_REJECT, NULL);
 		g_object_unref (G_OBJECT (state->image_add));
 		g_object_unref (G_OBJECT (state->image_delete));
 		g_object_unref (G_OBJECT (state->image_lock));
 		g_object_unref (G_OBJECT (state->image_up));
 		g_object_unref (G_OBJECT (state->image_down));
 	}
+
+	state->dialog = NULL;
 	g_free (state);
 }
 



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