dia r4229 - in trunk: . app po
- From: hans svn gnome org
- To: svn-commits-list gnome org
- Subject: dia r4229 - in trunk: . app po
- Date: Sun, 25 Jan 2009 20:52:50 +0000 (UTC)
Author: hans
Date: Sun Jan 25 20:52:50 2009
New Revision: 4229
URL: http://svn.gnome.org/viewvc/dia?rev=4229&view=rev
Log:
* app/confirm.[ch] : new function confirm_export_size() which let's the
user confirm an unusal diagram size
* app/Makefile.am app/makefile.msc po/POTFILES.in : add new files
* app/commands.c app/filedlg.c : use it before export and print to avoid
possibly unintended numbers of pages printed or memory used for export.
(Bug #540477, Martin Wegner)
app/preferences.[ch] : removed obsolete print preference
Added:
trunk/app/confirm.c (contents, props changed)
trunk/app/confirm.h (contents, props changed)
Modified:
trunk/ChangeLog
trunk/app/Makefile.am
trunk/app/app_procs.c
trunk/app/commands.c
trunk/app/filedlg.c
trunk/app/makefile.msc
trunk/app/preferences.c
trunk/app/preferences.h
trunk/po/POTFILES.in
Modified: trunk/app/Makefile.am
==============================================================================
--- trunk/app/Makefile.am (original)
+++ trunk/app/Makefile.am Sun Jan 25 20:52:50 2009
@@ -83,122 +83,124 @@
oafinfo_DATA = $(dia_oafinfo)
dia_core_files = \
- exit_dialog.h \
- exit_dialog.c \
- diagram.c \
- diagram.h \
- preferences.c \
- preferences.h \
- load_save.c \
- load_save.h \
- properties-dialog.c \
- properties-dialog.h \
- defaults.c \
- defaults.h \
- undo.c \
- undo.h \
- object_ops.c \
- object_ops.h \
- layer_dialog.c \
- layer_dialog.h \
- commands.c \
- commands.h \
- app_procs.c \
- app_procs.h \
- connectionpoint_ops.h \
- connectionpoint_ops.c \
- disp_callbacks.c \
- disp_callbacks.h \
- display.c \
- display.h \
- select.c \
- select.h \
- color_area.c \
- color_area.h \
- linewidth_area.c \
- linewidth_area.h \
- grid.c \
- grid.h \
- handle_ops.c \
- handle_ops.h \
- interface.c \
- interface.h \
- dia-app-icons.h \
- modify_tool.c \
- modify_tool.h \
- scroll_tool.c \
- scroll_tool.h \
- create_object.c \
- create_object.h \
- magnify.c \
- magnify.h \
- menus.c \
- menus.h \
- cut_n_paste.c \
- cut_n_paste.h \
- render_gdk.c \
- render_gdk.h \
- tool.c \
- tool.h \
- pixmaps.h \
- diapagelayout.c \
- diapagelayout.h \
- pagesetup.c \
- pagesetup.h \
- filedlg.c \
- filedlg.h \
- find-and-replace.c \
- find-and-replace.h \
- plugin-manager.c \
- plugin-manager.h \
- dia-props.c \
- dia-props.h \
- gtkwrapbox.h \
- gtkwrapbox.c \
- gtkhwrapbox.h \
- gtkhwrapbox.c \
- gtkvwrapbox.h \
- gtkvwrapbox.c \
- cursor.c \
- cursor.h \
- splash.c \
- dia-app-icons.h \
- recent_files.h \
- recent_files.c \
- diagram_tree.h \
- diagram_tree.c \
- diagram_tree_window.h \
- diagram_tree_window.c \
- diagram_tree_menu.h \
- diagram_tree_menu.c \
- diagram_tree_menu_callbacks.h \
- diagram_tree_menu_callbacks.c \
- sheets.c \
- sheets.h \
- sheets_dialog.c \
- sheets_dialog.h \
- sheets_dialog_callbacks.c \
- sheets_dialog_callbacks.h \
- autosave.c \
- autosave.h \
- authors.h \
- dynamic_refresh.h \
- dynamic_refresh.c \
- navigation.h \
- navigation.c \
- diacanvas.c \
- diacanvas.h \
- highlight.c \
- highlight.h \
- textedit.c \
- textedit.h \
- textedit_tool.c \
- textedit_tool.h \
- diagrid.h
+ confirm.h \
+ confirm.c \
+ exit_dialog.h \
+ exit_dialog.c \
+ diagram.c \
+ diagram.h \
+ preferences.c \
+ preferences.h \
+ load_save.c \
+ load_save.h \
+ properties-dialog.c \
+ properties-dialog.h \
+ defaults.c \
+ defaults.h \
+ undo.c \
+ undo.h \
+ object_ops.c \
+ object_ops.h \
+ layer_dialog.c \
+ layer_dialog.h \
+ commands.c \
+ commands.h \
+ app_procs.c \
+ app_procs.h \
+ connectionpoint_ops.h \
+ connectionpoint_ops.c \
+ disp_callbacks.c \
+ disp_callbacks.h \
+ display.c \
+ display.h \
+ select.c \
+ select.h \
+ color_area.c \
+ color_area.h \
+ linewidth_area.c \
+ linewidth_area.h \
+ grid.c \
+ grid.h \
+ handle_ops.c \
+ handle_ops.h \
+ interface.c \
+ interface.h \
+ dia-app-icons.h \
+ modify_tool.c \
+ modify_tool.h \
+ scroll_tool.c \
+ scroll_tool.h \
+ create_object.c \
+ create_object.h \
+ magnify.c \
+ magnify.h \
+ menus.c \
+ menus.h \
+ cut_n_paste.c \
+ cut_n_paste.h \
+ render_gdk.c \
+ render_gdk.h \
+ tool.c \
+ tool.h \
+ pixmaps.h \
+ diapagelayout.c \
+ diapagelayout.h \
+ pagesetup.c \
+ pagesetup.h \
+ filedlg.c \
+ filedlg.h \
+ find-and-replace.c \
+ find-and-replace.h \
+ plugin-manager.c \
+ plugin-manager.h \
+ dia-props.c \
+ dia-props.h \
+ gtkwrapbox.h \
+ gtkwrapbox.c \
+ gtkhwrapbox.h \
+ gtkhwrapbox.c \
+ gtkvwrapbox.h \
+ gtkvwrapbox.c \
+ cursor.c \
+ cursor.h \
+ splash.c \
+ dia-app-icons.h \
+ recent_files.h \
+ recent_files.c \
+ diagram_tree.h \
+ diagram_tree.c \
+ diagram_tree_window.h \
+ diagram_tree_window.c \
+ diagram_tree_menu.h \
+ diagram_tree_menu.c \
+ diagram_tree_menu_callbacks.h \
+ diagram_tree_menu_callbacks.c \
+ sheets.c \
+ sheets.h \
+ sheets_dialog.c \
+ sheets_dialog.h \
+ sheets_dialog_callbacks.c \
+ sheets_dialog_callbacks.h \
+ autosave.c \
+ autosave.h \
+ authors.h \
+ dynamic_refresh.h \
+ dynamic_refresh.c \
+ navigation.h \
+ navigation.c \
+ diacanvas.c \
+ diacanvas.h \
+ highlight.c \
+ highlight.h \
+ textedit.c \
+ textedit.h \
+ textedit_tool.c \
+ textedit_tool.h \
+ diagrid.h
dia_SOURCES = \
- $(dia_core_files) \
- main.c
+ $(dia_core_files) \
+ main.c
EFENCE =
@@ -210,8 +212,8 @@
## Especially the configure/make parts.
dia_embedd_SOURCES = \
- $(dia_core_files) \
- dia_embedd.c
+ $(dia_core_files) \
+ dia_embedd.c
dia_embedd_LDADD = ../lib/libdia.la \
$(EFENCE) \
Modified: trunk/app/app_procs.c
==============================================================================
--- trunk/app/app_procs.c (original)
+++ trunk/app/app_procs.c Sun Jan 25 20:52:50 2009
@@ -781,7 +781,8 @@
log_to_stderr = TRUE;
libdia_init ( (dia_is_interactive ? DIA_INTERACTIVE : 0)
- || (log_to_stderr ? DIA_MESSAGE_STDERR : 0));
+ | (log_to_stderr ? DIA_MESSAGE_STDERR : 0)
+ | (verbose ? DIA_VERBOSE : 0) );
print_credits(credits);
@@ -801,6 +802,7 @@
load_all_sheets(); /* new mechanism */
+ dia_log_message ("object defaults");
dia_object_defaults_load (NULL, TRUE /* prefs.object_defaults_create_lazy */);
debug_break();
@@ -823,6 +825,7 @@
/* further initialization *before* reading files */
active_tool = create_modify_tool();
+ dia_log_message ("ui creation");
if (prefs.use_integrated_ui) {
create_integrated_ui();
} else {
@@ -849,6 +852,7 @@
}
+ dia_log_message ("diagrams");
made_conversions = handle_all_diagrams(files, export_file_name,
export_file_format, size, show_layers,
input_directory, output_directory);
@@ -886,6 +890,7 @@
if (made_conversions) exit(0);
dynobj_refresh_init();
+ dia_log_message ("initialized");
}
#if 0
Modified: trunk/app/commands.c
==============================================================================
--- trunk/app/commands.c (original)
+++ trunk/app/commands.c Sun Jan 25 20:52:50 2009
@@ -37,7 +37,7 @@
#include <textedit.h>
#include <focus.h>
-
+#include "confirm.h"
/** Functions called on menu selects.
* Note that GTK (at least up to 2.12) doesn't disable the keyboard shortcuts
@@ -109,30 +109,26 @@
file_print_callback (GtkAction *_action)
{
Diagram *dia;
+ DDisplay *ddisp;
GtkAction *action;
dia = ddisplay_active_diagram();
if (!dia) return;
+ ddisp = ddisplay_active();
+ if (!ddisp) return;
action = menus_get_action ("FilePrintGTK");
if (!action)
action = menus_get_action ("FilePrintGDI");
if (!action)
action = menus_get_action ("FilePrintPS");
-#if 1
- if (action)
- gtk_action_activate (action);
- else
+
+ if (action) {
+ if (confirm_export_size (dia, GTK_WINDOW(ddisp->shell), CONFIRM_PRINT|CONFIRM_PAGES))
+ gtk_action_activate (action);
+ } else {
message_error (_("No print plug-in found!"));
-#else
-#ifdef G_OS_WIN32
- /* This option could be used with Gnome too. Does it make sense there ? */
- if (!prefs.prefer_psprint)
- diagram_print_gdi(dia);
- else
-#endif
- diagram_print_ps(dia);
-#endif
+ }
}
void
Added: trunk/app/confirm.c
==============================================================================
--- (empty file)
+++ trunk/app/confirm.c Sun Jan 25 20:52:50 2009
@@ -0,0 +1,90 @@
+/* Dia -- an diagram creation/manipulation program
+ * Copyright (C) 1998 Alexander Larsson
+ *
+ * confirm.c - a dialog usually not to be shown
+ *
+ * Copyright (C) 2009 Hans Breuer
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+
+#include "confirm.h"
+#include "intl.h"
+
+static gint
+confirm_respond (GtkWidget *widget, gint response_id, gpointer data)
+{
+ /* just close it in any case */
+ gtk_widget_hide (widget);
+ return 0;
+}
+
+/*!
+ * \brief Check and - if huge - let the user confirm the diagram size before export
+ */
+gboolean
+confirm_export_size (Diagram *dia, GtkWindow *parent, guint flags)
+{
+ GtkWidget *dialog;
+ int pages = 0;
+ gint64 bytes = 0;
+ gchar *size, *msg;
+ gboolean ret;
+
+ pages = ceil((dia->data->extents.right - dia->data->extents.left) / dia->data->paper.width)
+ * ceil((dia->data->extents.bottom - dia->data->extents.top) / dia->data->paper.height);
+ /* three guesses: 4 bytes per pixel, 20 pixels per cm; using * dia->data->paper.scaling */
+ bytes = (gint64)4
+ * ceil((dia->data->extents.right - dia->data->extents.left) * dia->data->paper.scaling * 20)
+ * ceil((dia->data->extents.bottom - dia->data->extents.top) * dia->data->paper.scaling * 20);
+
+ if ((flags & CONFIRM_PRINT) && (pages < 10)) /* hardcoded limits for the dialog to show */
+ return TRUE;
+ else if ((flags & CONFIRM_MEMORY) && (bytes < (G_GINT64_CONSTANT(100)<<16)))
+ return TRUE; /* smaller than 100MB */
+ else if ((flags & CONFIRM_PAGES) && (pages < 50))
+ return TRUE;
+
+ /* message and limits depend on the flags give */
+ size = g_format_size_for_display (bytes);
+ if (flags & CONFIRM_PRINT)
+ msg = g_strdup_printf (_("You are about to print a diagram with %d pages."), pages);
+ else if ((flags & ~CONFIRM_PAGES) == 0)
+ msg = g_strdup_printf (_("You are about to export a diagram with %d pages."), pages);
+ else
+ msg = g_strdup_printf (_("You are about to export a diagram "
+ "which may require %s of memory.(%d pages)."), size, pages);
+ dialog = gtk_message_dialog_new (parent, /* diagrams display 'shell' */
+ GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_WARNING,
+ GTK_BUTTONS_OK_CANCEL,
+ msg);
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ _("You can adjust the size of the diagram by changing "
+ "the 'Scaling' in the 'Page Setup' dialog.\n"
+ "Alternatively use 'Select All' and 'Best Fit' "
+ "to move objects/handles into the intended bounds."), NULL);
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Confirm Diagram Size"));
+ g_free (size);
+
+ g_signal_connect(G_OBJECT (dialog), "response",
+ G_CALLBACK(confirm_respond), NULL);
+
+ ret = (GTK_RESPONSE_OK == gtk_dialog_run (GTK_DIALOG (dialog)));
+ gtk_widget_destroy(dialog);
+ return ret;
+}
Added: trunk/app/confirm.h
==============================================================================
--- (empty file)
+++ trunk/app/confirm.h Sun Jan 25 20:52:50 2009
@@ -0,0 +1,10 @@
+#include <gtk/gtk.h>
+#include "diagram.h"
+
+typedef enum {
+ CONFIRM_PAGES = (1<<0),
+ CONFIRM_MEMORY = (1<<1),
+ CONFIRM_PRINT = (1<<2)
+} ConfirmationKind;
+
+gboolean confirm_export_size (Diagram *dia, GtkWindow *parent, guint flags);
Modified: trunk/app/filedlg.c
==============================================================================
--- trunk/app/filedlg.c (original)
+++ trunk/app/filedlg.c Sun Jan 25 20:52:50 2009
@@ -43,6 +43,7 @@
#include "preferences.h"
#include "interface.h"
#include "recent_files.h"
+#include "confirm.h"
#include "filedlg.h"
@@ -697,6 +698,9 @@
if (!ddisp) return;
dia = ddisp->diagram;
+ if (!confirm_export_size (dia, GTK_WINDOW(ddisp->shell), CONFIRM_MEMORY|CONFIRM_PAGES))
+ return;
+
if (!exportdlg) {
persistence_register_integer ("export-filter", 0);
exportdlg = gtk_file_chooser_dialog_new_with_backend(_("Export Diagram"),
Modified: trunk/app/makefile.msc
==============================================================================
--- trunk/app/makefile.msc (original)
+++ trunk/app/makefile.msc Sun Jan 25 20:52:50 2009
@@ -24,6 +24,7 @@
app_procs.obj \
color_area.obj \
commands.obj \
+ confirm.obj \
connectionpoint_ops.obj \
create_object.obj \
cursor.obj \
Modified: trunk/app/preferences.c
==============================================================================
--- trunk/app/preferences.c (original)
+++ trunk/app/preferences.c Sun Jan 25 20:52:50 2009
@@ -256,9 +256,6 @@
&default_true,0,"pretty formated xml",NULL, TRUE},
*/
- { "prefer_psprint", PREF_BOOLEAN,PREF_OFFSET(prefer_psprint),
- &default_false,0,"prefer psprint", NULL, TRUE},
-
{ NULL, PREF_NONE, 0, NULL, TREE_TAB, N_("Diagram tree window:") },
{ "diagram_tree_save_hidden", PREF_BOOLEAN, PREF_OFFSET(dia_tree.save_hidden),
&default_false, TREE_TAB, N_("Save hidden object types")},
Modified: trunk/app/preferences.h
==============================================================================
--- trunk/app/preferences.h (original)
+++ trunk/app/preferences.h Sun Jan 25 20:52:50 2009
@@ -65,7 +65,6 @@
} pagebreak;
int render_bounding_boxes;
- int prefer_psprint;
int toolbox_on_top;
Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in (original)
+++ trunk/po/POTFILES.in Sun Jan 25 20:52:50 2009
@@ -4,6 +4,7 @@
app/autosave.c
app/color_area.c
app/commands.c
+app/confirm.c
app/create_object.c
app/defaults.c
app/dia-props.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]