[dia] Focus::user_data was just duplicating Focus::text



commit 9f97aa8bac1cdfb2b63546808c53e3db321466df
Author: Hans Breuer <hans breuer org>
Date:   Tue Jul 7 22:52:11 2009 +0200

    Focus::user_data was just duplicating Focus::text

 app/commands.c |    4 +---
 app/textedit.c |    4 ++--
 lib/focus.h    |    1 -
 lib/text.c     |    6 ++----
 4 files changed, 5 insertions(+), 10 deletions(-)
---
diff --git a/app/commands.c b/app/commands.c
index 46e2d79..93a88d7 100644
--- a/app/commands.c
+++ b/app/commands.c
@@ -504,7 +504,6 @@ edit_cut_text_callback (GtkAction *action)
   Focus *focus;
   DDisplay *ddisp;
   DiaObject *obj;
-  Text *text;
   GPtrArray *textprops;
   TextProperty *prop;
   ObjectChange *change;
@@ -516,7 +515,6 @@ edit_cut_text_callback (GtkAction *action)
   if ((focus == NULL) || (!focus->has_focus)) return;
 
   obj = focus_get_object(focus);
-  text = (Text*)focus->user_data;
 
   if (obj->ops->get_props == NULL) 
     return;
@@ -538,7 +536,7 @@ edit_cut_text_callback (GtkAction *action)
 
   prop_list_free(textprops);
 
-  if (text_delete_all(text, &change)) { 
+  if (text_delete_all(focus->text, &change)) { 
     object_add_updates(obj, ddisp->diagram);
     undo_object_change(ddisp->diagram, obj, change);
     undo_set_transactionpoint(ddisp->diagram->undo);
diff --git a/app/textedit.c b/app/textedit.c
index 5de4832..64ac322 100644
--- a/app/textedit.c
+++ b/app/textedit.c
@@ -204,7 +204,7 @@ textedit_activate_focus(DDisplay *ddisp, Focus *focus, Point *clicked)
     textedit_end_edit(ddisp, old_focus);
   }
   if (clicked) {
-      text_set_cursor((Text*)focus->user_data, clicked, ddisp->renderer);
+      text_set_cursor(focus->text, clicked, ddisp->renderer);
   }
   textedit_begin_edit(ddisp, focus);
   give_focus(focus);
@@ -230,7 +230,7 @@ textedit_activate_object(DDisplay *ddisp, DiaObject *obj, Point *clicked)
     }
     give_focus(new_focus); 
     if (clicked) {
-      text_set_cursor((Text*)new_focus->user_data, clicked, ddisp->renderer);
+      text_set_cursor(new_focus->text, clicked, ddisp->renderer);
     }
     textedit_begin_edit(ddisp, new_focus);
     diagram_flush(ddisp->diagram);
diff --git a/lib/focus.h b/lib/focus.h
index 59fb140..4dc1258 100644
--- a/lib/focus.h
+++ b/lib/focus.h
@@ -24,7 +24,6 @@ struct _Focus {
   DiaObject *obj;
   Text *text;
   int has_focus;
-  void *user_data; /* To be used by the object using this focus (eg. Text) */
 
   /* return TRUE if modified object.
      Set change if object is changed. */
diff --git a/lib/text.c b/lib/text.c
index b9bb8db..93c4989 100644
--- a/lib/text.c
+++ b/lib/text.c
@@ -291,7 +291,6 @@ new_text(const char *string, DiaFont *font, real height,
   
   text->focus.obj = NULL;
   text->focus.has_focus = FALSE;
-  text->focus.user_data = (void *)text;
   text->focus.key_event = text_key_event;
   text->focus.text = text;
   
@@ -329,7 +328,6 @@ text_copy(Text *text)
   copy->cursor_row = 0;
   copy->focus.obj = NULL;
   copy->focus.has_focus = FALSE;
-  copy->focus.user_data = (void *)copy;
   copy->focus.key_event = text_key_event;
   copy->focus.text = copy;
   
@@ -852,7 +850,7 @@ text_delete_key_handler(Focus *focus, ObjectChange ** change)
   const char *utf;
   gunichar c;
 
-  text = (Text *)focus->user_data;
+  text = focus->text;
   row = text->cursor_row;
   if (text->cursor_pos >= text_get_line_strlen(text, row)) {
     if (row+1 < text->numlines) {
@@ -887,7 +885,7 @@ text_key_event(Focus *focus,
 
   *change = NULL;
   
-  text = (Text *)focus->user_data;
+  text = focus->text;
 
   switch(keyval) {
       case GDK_Up:



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