dia r3950 - in trunk: . app lib objects/Istar objects/Jackson objects/SADT objects/standard



Author: hans
Date: Sat Apr 19 14:12:06 2008
New Revision: 3950
URL: http://svn.gnome.org/viewvc/dia?rev=3950&view=rev

Log:
2008-04-19  Hans Breuer  <hans breuer org>

	* app/diagram.c : put the modification mark ('*') in the window title
	like other programs do, ...
	* app/display : ... remove "Diagram modified" from the statusbar ...
	* app/create_object.c app/modify_tool.c : ... and clean out temporary 
	positions in button_release
	* app/interface.[ch] : removed specialized handling of modification for 
	integrated ui, it is not needed anymore
	
	* app/tool.h : remove unused struct _ToolInfo
	
	* lib/textline.c : an empyt text created bogus ascent/descent, it used 
	to mean the fonts ascent/descent. Fixes e.g. the positioning of 
	'UML - LargePackage' label

	* objects/standard/textobj.c(textobj_load) : intialize TextObj::attrs 
	from TextObj::text (bug #528903, Leon Stringer)
	* objects/Istar/goal.c objects/Istar/other.c objects/Jackson/domain.c
	  objects/SADT/box.c : had a similar problem leaving attrs 
	 uninitialized in their create method



Modified:
   trunk/ChangeLog
   trunk/app/create_object.c
   trunk/app/diagram.c
   trunk/app/display.c
   trunk/app/interface.c
   trunk/app/interface.h
   trunk/app/menus.c
   trunk/app/modify_tool.c
   trunk/app/tool.h
   trunk/lib/textline.c
   trunk/objects/Istar/goal.c
   trunk/objects/Istar/other.c
   trunk/objects/Jackson/domain.c
   trunk/objects/SADT/box.c
   trunk/objects/standard/textobj.c

Modified: trunk/app/create_object.c
==============================================================================
--- trunk/app/create_object.c	(original)
+++ trunk/app/create_object.c	Sat Apr 19 14:12:06 2008
@@ -171,7 +171,14 @@
     }
     tool->moving = FALSE;
     tool->handle = NULL;
-    tool->obj = NULL;
+    tool->obj = NULL;    
+  }
+  
+  {
+    /* remove position from status bar */
+    GtkStatusbar *statusbar = GTK_STATUSBAR (ddisp->modified_status);
+    guint context_id = gtk_statusbar_get_context_id (statusbar, "ObjectPos");
+    gtk_statusbar_pop (statusbar, context_id);
   }
   
   highlight_reset_all(ddisp->diagram);

Modified: trunk/app/diagram.c
==============================================================================
--- trunk/app/diagram.c	(original)
+++ trunk/app/diagram.c	Sat Apr 19 14:12:06 2008
@@ -364,10 +364,14 @@
 diagram_modified(Diagram *dia)
 {
   GSList *displays;
+  gchar *title = g_strdup_printf ("%s%s", diagram_is_modified(dia) ? "*" : "", diagram_get_name(dia));
+
   displays = dia->displays;
-  while (displays != NULL) {
-    DDisplay *display = (DDisplay*) displays->data;
-    ddisplay_update_statusbar(display);
+  while (displays!=NULL) {
+    DDisplay *ddisp = (DDisplay *) displays->data;
+
+    ddisplay_set_title(ddisp, title);
+    
     displays = g_slist_next(displays);
   }
   if (diagram_is_modified(dia)) {
@@ -375,6 +379,7 @@
     dia->is_default = FALSE;
   }
   /*  diagram_set_modified(dia, TRUE);*/
+  g_free (title);
 }
 
 /** Set this diagram explicitly modified.  This should not be called

Modified: trunk/app/display.c
==============================================================================
--- trunk/app/display.c	(original)
+++ trunk/app/display.c	Sat Apr 19 14:12:06 2008
@@ -91,35 +91,6 @@
 }
 
 static void
-update_modified_status(DDisplay *ddisp)
-{
-  GtkStatusbar *statusbar;
-  guint context_id;
-
-  if (is_integrated_ui ())
-  {
-     integrated_ui_show_diagram_modified_status (ddisp);
-     return;
-  }
-
-  if (diagram_is_modified(ddisp->diagram))
-  {
-    statusbar = GTK_STATUSBAR (ddisp->modified_status);
-    context_id = gtk_statusbar_get_context_id (statusbar, "Changed");
-  
-    gtk_statusbar_pop (statusbar, context_id); 
-    gtk_statusbar_push (statusbar, context_id, _("Diagram modified!"));
-  }
-  else
-  {
-    statusbar = GTK_STATUSBAR (ddisp->modified_status);
-    context_id = gtk_statusbar_get_context_id (statusbar, "Changed");
-  
-    gtk_statusbar_pop (statusbar, context_id); 
-  }
-}
-
-static void
 selection_changed (Diagram* dia, int n, DDisplay* ddisp)
 {
   GtkStatusbar *statusbar;
@@ -1446,7 +1417,6 @@
   update_zoom_status (ddisp);
   update_snap_grid_status (ddisp);
   update_mainpoint_status (ddisp);
-  update_modified_status (ddisp);
 }
 
 void

Modified: trunk/app/interface.c
==============================================================================
--- trunk/app/interface.c	(original)
+++ trunk/app/interface.c	Sat Apr 19 14:12:06 2008
@@ -479,33 +479,6 @@
 }
 
 /**
- * Change diagram notebook label to show that the diagram has
- * been modified (or that it hasn't been modified).
- *
- * @param ddisp The display which needs the label updated.
- */
-void integrated_ui_show_diagram_modified_status (DDisplay *ddisp)
-{
-   GtkLabel * label = g_object_get_data (G_OBJECT (ddisp->container), "tab-label");
-   gchar * name;
-   
-   name = diagram_get_name (ddisp->diagram);
-
-   if (diagram_is_modified (ddisp->diagram))
-   {
-     gchar * text = g_strdup_printf ("*%s",name);
-     gtk_label_set_text (label, text);  
-     g_free (text);
-   }
-   else
-   {
-     gtk_label_set_text (label,name);  
-   }
-
-   g_free (name);
-}
-
-/**
  * @param ddisp The diagram display object that a window is created for
  * @param title
  */

Modified: trunk/app/interface.h
==============================================================================
--- trunk/app/interface.h	(original)
+++ trunk/app/interface.h	Sat Apr 19 14:12:06 2008
@@ -55,8 +55,6 @@
 
 int is_integrated_ui (void);
 
-void integrated_ui_show_diagram_modified_status (DDisplay *ddisp);
-
 void create_display_shell(DDisplay *ddisp,
 			  int width, int height,
 			  char *title, int use_mbar, int top_level_window);

Modified: trunk/app/menus.c
==============================================================================
--- trunk/app/menus.c	(original)
+++ trunk/app/menus.c	Sat Apr 19 14:12:06 2008
@@ -778,7 +778,7 @@
 /*!
  * Not sure why this service is not provided by GTK+. 
  * We are passing tooltips into the actions (especially recent file menu).
- * But they were not shown without explicit seeting on connect.
+ * But they were not shown without explicit setting on connect.
  */
 static void
 _ui_manager_connect_proxy (GtkUIManager *manager,
@@ -864,6 +864,10 @@
   display_tool_actions = create_tool_actions ();
 
   display_ui_manager = gtk_ui_manager_new ();
+  g_signal_connect (G_OBJECT (display_ui_manager), 
+                    "connect_proxy",
+		    _ui_manager_connect_proxy,
+		    NULL);
   gtk_ui_manager_set_add_tearoffs (display_ui_manager, DIA_SHOW_TEAROFFS);
   gtk_ui_manager_insert_action_group (display_ui_manager, display_actions, 0);
   gtk_ui_manager_insert_action_group (display_ui_manager, display_tool_actions, 0);

Modified: trunk/app/modify_tool.c
==============================================================================
--- trunk/app/modify_tool.c	(original)
+++ trunk/app/modify_tool.c	Sat Apr 19 14:12:06 2008
@@ -386,9 +386,6 @@
   gboolean auto_scroll, vertical = FALSE;
   ConnectionPoint *connectionpoint = NULL;
   ObjectChange *objchange;
-  gchar *postext;
-  GtkStatusbar *statusbar;
-  guint context_id;
 
   if (tool->state==STATE_NONE)
     return; /* Fast path... */
@@ -454,19 +451,22 @@
     object_add_updates(tool->object, ddisp->diagram);
 
     /* Put current mouse position in status bar */
-    statusbar = GTK_STATUSBAR (ddisp->modified_status);
-    context_id = gtk_statusbar_get_context_id (statusbar, "ObjectPos");
-    
-    postext = g_strdup_printf("%.3f, %.3f - %.3f, %.3f",
-			      tool->object->bounding_box.left,
-			      tool->object->bounding_box.top,
-			      tool->object->bounding_box.right,
-			      tool->object->bounding_box.bottom);
+    {
+      gchar *postext;
+      GtkStatusbar *statusbar = GTK_STATUSBAR (ddisp->modified_status);
+      guint context_id = gtk_statusbar_get_context_id (statusbar, "ObjectPos");
+      gtk_statusbar_pop (statusbar, context_id); 
+      postext = g_strdup_printf("%.3f, %.3f - %.3f, %.3f",
+			        tool->object->bounding_box.left,
+			        tool->object->bounding_box.top,
+			        tool->object->bounding_box.right,
+			        tool->object->bounding_box.bottom);
 			       
-    gtk_statusbar_pop (statusbar, context_id); 
-    gtk_statusbar_push (statusbar, context_id, postext);
-
-    g_free(postext);
+      gtk_statusbar_pop (statusbar, context_id); 
+      gtk_statusbar_push (statusbar, context_id, postext);
+      
+      g_free(postext);
+    }
 
     diagram_update_connections_selection(ddisp->diagram);
     diagram_flush(ddisp->diagram);
@@ -535,16 +535,19 @@
     }
 
     /* Put current mouse position in status bar */
-    statusbar = GTK_STATUSBAR (ddisp->modified_status);
-    context_id = gtk_statusbar_get_context_id (statusbar, "CursorPos");
+    {
+      gchar *postext;
+      GtkStatusbar *statusbar = GTK_STATUSBAR (ddisp->modified_status);
+      guint context_id = gtk_statusbar_get_context_id (statusbar, "ObjectPos");
     
-    postext = g_strdup_printf("%.3f, %.3f", to.x, to.y);
+      postext = g_strdup_printf("%.3f, %.3f", to.x, to.y);
 			       
-    gtk_statusbar_pop (statusbar, context_id); 
-    gtk_statusbar_push (statusbar, context_id, postext);
-
-    g_free(postext);
+      gtk_statusbar_pop (statusbar, context_id); 
+      gtk_statusbar_push (statusbar, context_id, postext);
 
+      g_free(postext);
+    }
+    
     object_add_updates(tool->object, ddisp->diagram);
 
     /* Handle undo */
@@ -629,6 +632,12 @@
   tool->break_connections = FALSE;
   ddisplay_set_all_cursor(default_cursor);
 
+  /* remove position from status bar */
+  {
+    GtkStatusbar *statusbar = GTK_STATUSBAR (ddisp->modified_status);
+    guint context_id = gtk_statusbar_get_context_id (statusbar, "ObjectPos");
+    gtk_statusbar_pop (statusbar, context_id);
+  }
   switch (tool->state) {
   case STATE_MOVE_OBJECT:
     /* Return to normal state */

Modified: trunk/app/tool.h
==============================================================================
--- trunk/app/tool.h	(original)
+++ trunk/app/tool.h	Sat Apr 19 14:12:06 2008
@@ -21,7 +21,6 @@
 #include <gdk/gdk.h>
 
 typedef struct _Tool Tool;
-typedef struct _ToolInfo ToolInfo;
 typedef struct _ToolState ToolState;
 
 typedef enum _ToolType ToolType;
@@ -51,11 +50,6 @@
   DoubleClickFunc    double_click_func;
 };
 
-struct _ToolInfo {
-  ToolType type;
-  char *tooltip;
-};
-
 struct _ToolState {
   ToolType type;
   gpointer extra_data;

Modified: trunk/lib/textline.c
==============================================================================
--- trunk/lib/textline.c	(original)
+++ trunk/lib/textline.c	Sat Apr 19 14:12:06 2008
@@ -259,6 +259,24 @@
 }
 
 static void
+clear_layout_offset (TextLine *text_line)
+{
+  if (text_line->layout_offsets != NULL) {
+    GSList *runs = text_line->layout_offsets->runs;
+
+    for (; runs != NULL; runs = g_slist_next(runs)) {
+      PangoGlyphItem *run = (PangoGlyphItem *) runs->data;
+	  
+      g_free(run->glyphs->glyphs);
+      g_free(run->glyphs);
+    }
+    g_slist_free(runs);
+    g_free(text_line->layout_offsets);
+    text_line->layout_offsets = NULL;
+  }
+}
+
+static void
 text_line_cache_values(TextLine *text_line)
 {
   if (!text_line->clean ||
@@ -275,26 +293,19 @@
       (*text_line->renderer_cache->free_func)(text_line->renderer_cache);
       text_line->renderer_cache = NULL;
     }
-    if (text_line->layout_offsets != NULL) {
-        GSList *runs = text_line->layout_offsets->runs;
-
-	for (; runs != NULL; runs = g_slist_next(runs)) {
-	  PangoGlyphItem *run = (PangoGlyphItem *) runs->data;
-	  
-	  g_free(run->glyphs->glyphs);
-	  g_free(run->glyphs);
-	}
-	g_slist_free(runs);
-	g_free(text_line->layout_offsets);
-	text_line->layout_offsets = NULL;
-    }
+    clear_layout_offset (text_line);
 
     if (text_line->chars == NULL ||
 	text_line->chars[0] == '\0') {
-      text_line->offsets = g_new(real, 0);
-      text_line->layout_offsets = NULL;
-      text_line->ascent = text_line->height * .5;
-      text_line->descent = text_line->height * .5;
+      /* caclculate reasonable ascent/decent even for empty string */
+      text_line->offsets = 
+        dia_font_get_sizes("XjgM149", text_line->font, text_line->height,
+			   &text_line->width, &text_line->ascent, 
+			   &text_line->descent, &n_offsets,
+			   &text_line->layout_offsets);
+      clear_layout_offset (text_line);
+      g_free (text_line->offsets);
+      text_line->offsets = g_new (real,0); /* another way to assign NULL;) */
       text_line->width = 0;
     } else {
       text_line->offsets = 

Modified: trunk/objects/Istar/goal.c
==============================================================================
--- trunk/objects/Istar/goal.c	(original)
+++ trunk/objects/Istar/goal.c	Sat Apr 19 14:12:06 2008
@@ -526,6 +526,7 @@
                        &color_black,
                        ALIGN_CENTER);
   dia_font_unref(font);
+  text_get_attributes(goal->text,&goal->attrs);
 
   element_init(elem, 8, NUM_CONNECTIONS);
 

Modified: trunk/objects/Istar/other.c
==============================================================================
--- trunk/objects/Istar/other.c	(original)
+++ trunk/objects/Istar/other.c	Sat Apr 19 14:12:06 2008
@@ -530,6 +530,7 @@
                        &color_black,
                        ALIGN_CENTER);
   dia_font_unref(font);
+  text_get_attributes(other->text,&other->attrs);
 
   element_init(elem, 8, 0);
 

Modified: trunk/objects/Jackson/domain.c
==============================================================================
--- trunk/objects/Jackson/domain.c	(original)
+++ trunk/objects/Jackson/domain.c	Sat Apr 19 14:12:06 2008
@@ -592,6 +592,7 @@
                        &color_black,
                        ALIGN_CENTER);
   dia_font_unref(font);
+  text_get_attributes(box->text,&box->attrs);
 
   element_init(elem, 8, 0);
 

Modified: trunk/objects/SADT/box.c
==============================================================================
--- trunk/objects/SADT/box.c	(original)
+++ trunk/objects/SADT/box.c	Sat Apr 19 14:12:06 2008
@@ -508,6 +508,7 @@
                        &color_black,
                        ALIGN_CENTER);
   dia_font_unref(font);
+  text_get_attributes(box->text,&box->attrs);
   
   box->id = g_strdup("A0"); /* should be made better. 
                                Automatic counting ? */

Modified: trunk/objects/standard/textobj.c
==============================================================================
--- trunk/objects/standard/textobj.c	(original)
+++ trunk/objects/standard/textobj.c	Sat Apr 19 14:12:06 2008
@@ -365,6 +365,8 @@
 			     &startpoint, &color_black, ALIGN_CENTER);
     dia_font_unref(font);
   }
+  /* initialize attrs from text */
+  text_get_attributes(textobj->text,&textobj->attrs);
 
   attr = object_find_attribute(obj_node, "valign");
   if (attr != NULL)



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