dia r3923 - in trunk: . app lib plug-ins/cairo



Author: hans
Date: Sat Apr  5 12:08:07 2008
New Revision: 3923
URL: http://svn.gnome.org/viewvc/dia?rev=3923&view=rev

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

	* app/menus.c(ensure_menu_path) : allow plug-ins to create a menu 
	path again. Does not yet work fopr the integrated ui, see bug #526146
	(_ui_manager_connect_proxy) : resurrection of menuitem tooltips,
	especially for recent file menu. They were lost in trnaslation to
	the GtkAction framework: bug #340352
	
	* app/load_save.c : disable remaining g_access() for win32, otherwise we
	can not save to a preexisting file

	* app/app_procs.c(app_exit) : don't g_free() const strings, 
	dia_open_diagrams() returns a GList, not a GSList
	Also evaluate the return value of diagram_save() and don't simply 
	assume saving can't fail. Related to bug #501703
	(process_opts) : by accident I had removed the gtk options which broke
	also --help
	
	* app/display.c : removed "Key input ..." debug spew
	
	* app/interface.c app/sheets : enforce Dia's toolbox icon size by cropping
	icons which are too huge
	
	* lib/makefile.msc : cosmetic change
	
	* plug-ins/cairo/diacairo-print.c : with_alpha does not make sense in 
	conjunction with printing



Modified:
   trunk/ChangeLog
   trunk/app/app_procs.c
   trunk/app/disp_callbacks.c
   trunk/app/interface.c
   trunk/app/load_save.c
   trunk/app/menus.c
   trunk/app/sheets.c
   trunk/lib/makefile.msc
   trunk/plug-ins/cairo/diacairo-print.c

Modified: trunk/app/app_procs.c
==============================================================================
--- trunk/app/app_procs.c	(original)
+++ trunk/app/app_procs.c	Sat Apr  5 12:08:07 2008
@@ -975,10 +975,9 @@
           const gchar * name = diagram_get_name (diagram);
           const gchar * path = diagram->filename;
           exit_dialog_add_item (dialog, name, path, diagram);
-          g_free (name);
         }
 
-        list = g_slist_next (list);
+        list = g_list_next (list);
       }
 
       result = exit_dialog_run (dialog, &items);
@@ -999,7 +998,10 @@
           diagram  = items->array[i].data;
           filename = g_filename_from_utf8 (diagram->filename, -1, NULL, NULL, NULL);
           diagram_update_extents (diagram);
-          diagram_save (diagram, filename);
+          if (!diagram_save (diagram, filename)) {
+            exit_dialog_free_items (items);
+            return FALSE;
+	      }
           g_free (filename);
         }
         exit_dialog_free_items (items);
@@ -1162,6 +1164,7 @@
       
       context = g_option_context_new(_("[FILE...]"));
       g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
+      g_option_context_add_group (context, gtk_get_option_group (FALSE));
 
       if (!g_option_context_parse (context, argc, &argv, &error)) {
         if (error) { /* IMO !error here is a bug upstream, triggered with --gdk-debug=updates */

Modified: trunk/app/disp_callbacks.c
==============================================================================
--- trunk/app/disp_callbacks.c	(original)
+++ trunk/app/disp_callbacks.c	Sat Apr  5 12:08:07 2008
@@ -681,9 +681,9 @@
         state = kevent->state;
         key_handled = FALSE;
         im_context_used = FALSE;
-
+#if 0
 	printf("Key input %d in state %d\n", kevent->keyval, textedit_mode(ddisp));
-
+#endif
         focus = get_active_focus((DiagramData *) ddisp->diagram);
         if (focus != NULL) {
 	  /* Keys goes to the active focus. */

Modified: trunk/app/interface.c
==============================================================================
--- trunk/app/interface.c	(original)
+++ trunk/app/interface.c	Sat Apr  5 12:08:07 2008
@@ -1269,6 +1269,17 @@
       
       pixbuf = gdk_pixbuf_new_from_file(sheet_obj->pixmap_file, &gerror);
       if (pixbuf != NULL) {
+          int width = gdk_pixbuf_get_width (pixbuf);
+          int height = gdk_pixbuf_get_height (pixbuf);
+          if (width > 22) {
+	    GdkPixbuf *cropped;
+	    g_warning ("Shape icon '%s' size wrong, cropped.", sheet_obj->pixmap_file);
+	    cropped = gdk_pixbuf_new_subpixbuf (pixbuf, 
+	                                       (width - 22) / 2, height > 22 ? (height - 22) / 2 : 0, 
+					       22, height > 22 ? 22 : height);
+	    g_object_unref (pixbuf);
+	    pixbuf = cropped;
+	  }
           gdk_pixbuf_render_pixmap_and_mask_for_colormap(pixbuf, gtk_widget_get_colormap(sheet_wbox), &pixmap, &mask, 1.0);
           gdk_pixbuf_unref(pixbuf);
       } else {

Modified: trunk/app/load_save.c
==============================================================================
--- trunk/app/load_save.c	(original)
+++ trunk/app/load_save.c	Sat Apr  5 12:08:07 2008
@@ -267,7 +267,9 @@
   while ((list != NULL) && (obj_node != NULL)) {
     DiaObject *obj = (DiaObject *) list->data;
 
-    while (obj_node && xmlIsBlankNode(obj_node)) obj_node = obj_node->next;
+    /* the obj and there node must stay in sync to properly setup connections */
+    while (obj_node && (xmlIsBlankNode(obj_node) || XML_COMMENT_NODE == obj_node->type)) 
+      obj_node = obj_node->next;
     if (!obj_node) break;
     
     if IS_GROUP(obj) {
@@ -938,13 +940,11 @@
   int ret;
 
   /* Once we depend on GTK 2.8+, we can use these tests. */
-#if GLIB_CHECK_VERSION(2,8,0)
+#if GLIB_CHECK_VERSION(2,8,0) && !defined G_OS_WIN32
   /* Check that we're allowed to write to the target file at all. */
+  /* not going to work with 'My Docments' - read-only but still useable, see bug #504469 */
   if (   g_file_test(filename, G_FILE_TEST_EXISTS)
-#  if !defined G_OS_WIN32 /* not going to work with 'My Docments' - read-only but still useable, see bug #504469 */
-      && g_access(filename, W_OK) != 0
-#  endif
-     ) {
+      && g_access(filename, W_OK) != 0) {
     message_error(_("Not allowed to write to output file %s\n"), 
 		  dia_message_filename(filename));
     return FALSE;
@@ -966,10 +966,7 @@
 #if GLIB_CHECK_VERSION(2,8,0) && !defined G_OS_WIN32
   /* Check that we can create the other files */
   if (   g_file_test(dirname, G_FILE_TEST_EXISTS) 
-#  if !defined G_OS_WIN32
-      && g_access(dirname, W_OK) != 0
-#  endif
-     ) {
+      && g_access(dirname, W_OK) != 0) {
     message_error(_("Not allowed to write temporary files in %s\n"), 
 		  dia_message_filename(dirname));
     return FALSE;

Modified: trunk/app/menus.c
==============================================================================
--- trunk/app/menus.c	(original)
+++ trunk/app/menus.c	Sat Apr  5 12:08:07 2008
@@ -492,6 +492,43 @@
     }
 }
 
+static guint
+ensure_menu_path (GtkUIManager *ui_manager, GtkActionGroup *actions, const gchar *path, gboolean end)
+{
+  guint id = gtk_ui_manager_new_merge_id (ui_manager);
+
+  if (!gtk_ui_manager_get_widget (ui_manager, path)) {
+    gchar *subpath = g_strdup (path);
+
+    if (strrchr (subpath, '/')) {
+      const gchar *action_name;
+      gchar *sep;
+
+      GtkAction *action;
+
+      sep = strrchr (subpath, '/');
+      *sep = '\0'; /* cut subpath */
+      action_name = sep + 1;
+
+
+      ensure_menu_path (ui_manager, actions, subpath, FALSE);
+
+      action = gtk_action_new (action_name, sep + 1, NULL, NULL);
+      gtk_action_group_add_action (actions, action);
+      g_object_unref (G_OBJECT (action));
+
+      gtk_ui_manager_add_ui (ui_manager, id, subpath, 
+	                     action_name, action_name,
+			     end ? GTK_UI_MANAGER_SEPARATOR : GTK_UI_MANAGER_MENU,
+			     FALSE); /* FALSE=add-to-end */
+    } else {
+      g_warning ("ensure_menu_path() invalid menu path: %s.", subpath ? subpath : "NULL");
+    }
+    g_free (subpath);
+  }
+  return id;
+}
+
 /**
  * Create the toolbar for the integrated UI
  * @return Main toolbar (GtkToolbar*) for the integrated UI main window
@@ -662,7 +699,7 @@
       continue;
     }
 
-    if (0 == strncmp (cbf->menupath, TOOLBOX_MENU, strlen (TOOLBOX_MENU))) {
+    if (strncmp (cbf->menupath, DISPLAY_MENU, strlen (DISPLAY_MENU)) != 0) {
       /* hook for toolbox, skip */
       continue;
     }
@@ -674,7 +711,7 @@
     gtk_action_group_add_action (actions, action);
     g_object_unref (G_OBJECT (action));
 
-    id = gtk_ui_manager_new_merge_id (ui_manager);
+    id = ensure_menu_path (ui_manager, actions, cbf->menupath, TRUE);
     gtk_ui_manager_add_ui (ui_manager, id, 
 			   cbf->menupath, 
 			   cbf->description, 
@@ -738,6 +775,29 @@
   return uifile;
 }
 
+/*!
+ * 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.
+ */
+static void
+_ui_manager_connect_proxy (GtkUIManager *manager,
+                           GtkAction    *action,
+                           GtkWidget    *proxy)
+{
+  if (GTK_IS_MENU_ITEM (proxy))
+    {
+      gchar *tooltip;
+
+      g_object_get (action, "tooltip", &tooltip, NULL);
+
+      if (tooltip)
+        {
+	  gtk_tooltips_set_tip (tool_tips, proxy, tooltip, NULL);
+	}
+    }
+}
+
 static void
 menus_init(void)
 {
@@ -765,6 +825,10 @@
                 NULL);
 
   toolbox_ui_manager = gtk_ui_manager_new ();
+  g_signal_connect (G_OBJECT (toolbox_ui_manager), 
+                    "connect_proxy",
+		    _ui_manager_connect_proxy,
+		    NULL);
   gtk_ui_manager_set_add_tearoffs (toolbox_ui_manager, DIA_SHOW_TEAROFFS);
   gtk_ui_manager_insert_action_group (toolbox_ui_manager, toolbox_actions, 0);
   uifile = build_ui_filename ("ui/toolbox-ui.xml");
@@ -867,6 +931,11 @@
       continue;
     }
 
+    if (strncmp (cbf->menupath, TOOLBOX_MENU, strlen (TOOLBOX_MENU)) != 0) {
+      /* no hook for display, skip */
+      continue;
+    }
+
     action = gtk_action_new (cbf->action, cbf->description, 
                              NULL, NULL);
     g_signal_connect (G_OBJECT (action), "activate", 
@@ -876,7 +945,7 @@
     gtk_action_group_add_action (plugin_actions, action);
     g_object_unref (G_OBJECT (action));
 
-    id = gtk_ui_manager_new_merge_id (toolbox_ui_manager);
+    id = ensure_menu_path (ui_manager, plugin_actions, cbf->menupath, TRUE);
     gtk_ui_manager_add_ui (ui_manager, id, 
                            cbf->menupath, 
                            cbf->description, 

Modified: trunk/app/sheets.c
==============================================================================
--- trunk/app/sheets.c	(original)
+++ trunk/app/sheets.c	Sat Apr  5 12:08:07 2008
@@ -337,6 +337,18 @@
       pixbuf = gdk_pixbuf_new_from_file(so->pixmap_file, &error);
       if (pixbuf != NULL)
       {
+        int width = gdk_pixbuf_get_width (pixbuf);
+        int height = gdk_pixbuf_get_height (pixbuf);
+        if (width > 22) 
+	{
+	  GdkPixbuf *cropped;
+	  g_warning ("Shape icon '%s' size wrong, cropped.", so->pixmap_file);
+	  cropped = gdk_pixbuf_new_subpixbuf (pixbuf, 
+	                                      (width - 22) / 2, height > 22 ? (height - 22) / 2 : 0, 
+					      22, height > 22 ? 22 : height);
+	  g_object_unref (pixbuf);
+	  pixbuf = cropped;
+	}
         gdk_pixbuf_render_pixmap_and_mask(pixbuf, pixmap, mask, 1.0);
         gdk_pixbuf_unref(pixbuf);
       } else {

Modified: trunk/lib/makefile.msc
==============================================================================
--- trunk/lib/makefile.msc	(original)
+++ trunk/lib/makefile.msc	Sat Apr  5 12:08:07 2008
@@ -153,7 +153,8 @@
 	lib /out:$(PACKAGE).lib $(OBJECTS)
 
 $(PACKAGE).dll : $(OBJECTS) $(PACKAGE).def
-	$(CC) $(CFLAGS) -LD -Fe$(PACKAGE).dll $(OBJECTS) $(PKG_LINK) user32.lib advapi32.lib wsock32.lib $(LDFLAGS) /def:$(PACKAGE).def
+	$(CC) $(CFLAGS) -LD -Fe$(PACKAGE).dll $(OBJECTS) \
+	$(PKG_LINK) user32.lib advapi32.lib wsock32.lib $(LDFLAGS) /def:$(PACKAGE).def
 
 $(PRJ_TOP)\config.h: $(PRJ_TOP)\config.h.win32
 	copy $(PRJ_TOP)\config.h.win32 $(PRJ_TOP)\config.h

Modified: trunk/plug-ins/cairo/diacairo-print.c
==============================================================================
--- trunk/plug-ins/cairo/diacairo-print.c	(original)
+++ trunk/plug-ins/cairo/diacairo-print.c	Sat Apr  5 12:08:07 2008
@@ -75,6 +75,9 @@
   g_return_if_fail (cairo_renderer->cr == NULL);
 
   /* the renderer wants it's own reference */
+#if 0 /* no alpha with printers */
+  cairo_renderer->with_alpha = TRUE;
+#endif
   cairo_renderer->cr = cairo_reference (gtk_print_context_get_cairo_context (context));
   cairo_renderer->dia = print_data->data;
 #if 0 /* needs some text size scaling ... */



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