dia r4062 - in trunk: . app lib plug-ins plug-ins/python
- From: hans svn gnome org
- To: svn-commits-list gnome org
- Subject: dia r4062 - in trunk: . app lib plug-ins plug-ins/python
- Date: Sat, 31 May 2008 16:04:48 +0000 (UTC)
Author: hans
Date: Sat May 31 16:04:47 2008
New Revision: 4062
URL: http://svn.gnome.org/viewvc/dia?rev=4062&view=rev
Log:
2008-05-31 Hans Breuer <hans breuer org>
* lib/libdia.[ch] : new files containing the initialization code ...
* app/app_procs.c : ... removed here ...
* plug-ins/python/diamodule.c : ... to be useable from here
* lib/Makefile.am lib/makefile.msc lib/libdia.def : adapted
* app/diagram.c : there is no diagram_tree to update when not
running interactively, also no display to update
[warningectomy]
* lib/diaarrowchooser.c lib/persistence.[ch] : constness
* lib/diagramdata.c : signedness
* lib/font.c : initialization
Added:
trunk/lib/libdia.c (contents, props changed)
trunk/lib/libdia.h (contents, props changed)
Modified:
trunk/ChangeLog
trunk/app/app_procs.c
trunk/app/diagram.c
trunk/lib/Makefile.am
trunk/lib/diaarrowchooser.c
trunk/lib/diagramdata.c
trunk/lib/font.c
trunk/lib/libdia.def
trunk/lib/makefile.msc
trunk/lib/persistence.c
trunk/lib/persistence.h
trunk/plug-ins/makefile.msc
trunk/plug-ins/python/diamodule.c
Modified: trunk/app/app_procs.c
==============================================================================
--- trunk/app/app_procs.c (original)
+++ trunk/app/app_procs.c Sat May 31 16:04:47 2008
@@ -53,7 +53,6 @@
#include "intl.h"
#include "app_procs.h"
#include "object.h"
-#include "color.h"
#include "commands.h"
#include "tool.h"
#include "interface.h"
@@ -71,12 +70,11 @@
#include "authors.h"
#include "autosave.h"
#include "dynamic_refresh.h"
-#include "dia_image.h"
#include "persistence.h"
#include "sheets.h"
-#include "utils.h"
#include "exit_dialog.h"
#include "newgroup.h"
+#include "libdia.h"
static void
integrated_ui_create_initial_diagrams_callback (GtkWidget *widget,
@@ -100,36 +98,7 @@
char *export_file_format, char *size, char *show_layers);
static void print_credits(gboolean credits);
-static gboolean dia_is_interactive = TRUE;
-static void
-stderr_message_internal(const char *title, enum ShowAgainStyle showAgain,
- const char *fmt, va_list *args, va_list *args2);
-
-static void
-stderr_message_internal(const char *title, enum ShowAgainStyle showAgain,
- const char *fmt, va_list *args, va_list *args2)
-{
- static gchar *buf = NULL;
- static gint alloc = 0;
- gint len;
-
- len = format_string_length_upper_bound (fmt, args);
-
- if (len >= alloc) {
- if (buf)
- g_free (buf);
-
- alloc = nearest_pow (MAX(len + 1, 1024));
-
- buf = g_new (char, alloc);
- }
-
- vsprintf (buf, fmt, *args2);
-
- fprintf(stderr,
- "%s: %s\n",
- title,buf);
-}
+static gboolean dia_is_interactive = FALSE;
#ifdef GNOME
@@ -605,22 +574,6 @@
return made_conversions;
}
-#ifdef G_OS_WIN32
-static void
-myXmlErrorReporting (void *ctx, const char* msg, ...)
-{
- va_list args;
- gchar *string;
-
- va_start(args, msg);
- string = g_strdup_vprintf (msg, args);
- g_print ("%s", string ? string : "xml error (null)?");
- va_end(args);
-
- g_free(string);
-}
-#endif
-
#ifdef HAVE_FREETYPE
/* Translators: This is an option, not to be translated */
#define EPS_PANGO "eps-pango, "
@@ -696,6 +649,9 @@
N_("Display version and exit"), NULL },
{ NULL }
};
+
+ /* for users of app_init() the default is interactive */
+ dia_is_interactive = TRUE;
options[0].arg_data = &export_file_name;
options[1].arg_data = &export_file_format;
@@ -793,44 +749,23 @@
if (!dia_is_interactive)
log_to_stderr = TRUE;
-
- if (log_to_stderr)
- set_message_func(stderr_message_internal);
- print_credits(credits);
+ libdia_init ( (dia_is_interactive ? DIA_INTERACTIVE : 0)
+ || (log_to_stderr ? DIA_MESSAGE_STDERR : 0));
- LIBXML_TEST_VERSION;
-
-#ifdef G_OS_WIN32
- xmlSetGenericErrorFunc(NULL, myXmlErrorReporting);
-#endif
-
- stdprops_init();
+ print_credits(credits);
if (dia_is_interactive) {
- dia_image_init();
-
- gdk_rgb_init();
-
- gtk_rc_parse("diagtkrc");
+ create_user_dirs();
- if (!nosplash) {
+ if (!nosplash)
app_splash_init("");
- }
- }
- if (dia_is_interactive)
- create_user_dirs();
-
- /* Init cursors: */
- if (dia_is_interactive) {
- color_init();
+ /* Init cursors: */
default_cursor = gdk_cursor_new(GDK_LEFT_PTR);
ddisplay_set_all_cursor(default_cursor);
}
- object_registry_init();
-
dia_register_plugins();
dia_register_builtin_plugin(internal_plugin_init);
Modified: trunk/app/diagram.c
==============================================================================
--- trunk/app/diagram.c (original)
+++ trunk/app/diagram.c Sat May 31 16:04:47 2008
@@ -309,12 +309,13 @@
} else {
diagram->unsaved = FALSE;
diagram_set_modified(diagram, FALSE);
- if (app_is_interactive())
+ if (app_is_interactive()) {
recent_file_history_add(filename);
- diagram_tree_add(diagram_tree(), diagram);
+ diagram_tree_add(diagram_tree(), diagram);
+ }
}
- if (diagram != NULL && was_default) {
+ if (diagram != NULL && was_default && app_is_interactive()) {
diagram_update_for_filename(diagram);
diagram->is_default = FALSE;
if ( g_slist_length(diagram->displays) == 1 )
Modified: trunk/lib/Makefile.am
==============================================================================
--- trunk/lib/Makefile.am (original)
+++ trunk/lib/Makefile.am Sat May 31 16:04:47 2008
@@ -164,6 +164,8 @@
prefs.h \
newgroup.c \
newgroup.h \
+ libdia.c \
+ libdia.h \
\
diacellrendererproperty.c \
diacellrendererproperty.h \
Modified: trunk/lib/diaarrowchooser.c
==============================================================================
--- trunk/lib/diaarrowchooser.c (original)
+++ trunk/lib/diaarrowchooser.c Sat May 31 16:04:47 2008
@@ -36,7 +36,7 @@
static gchar*
_dia_translate (const gchar* term, gpointer data)
{
- gchar* trans = term;
+ const gchar* trans = term;
if (term && *term) {
/* first try our own ... */
Modified: trunk/lib/diagramdata.c
==============================================================================
--- trunk/lib/diagramdata.c (original)
+++ trunk/lib/diagramdata.c Sat May 31 16:04:47 2008
@@ -240,7 +240,7 @@
data_raise_layer(DiagramData *data, Layer *layer)
{
guint i;
- int layer_nr = -1;
+ guint layer_nr = 0;
Layer *tmp;
for (i=0;i<data->layers->len;i++) {
@@ -248,8 +248,6 @@
layer_nr = i;
}
- g_assert(layer_nr>=0);
-
if (layer_nr < data->layers->len-1) {
tmp = g_ptr_array_index(data->layers, layer_nr+1);
g_ptr_array_index(data->layers, layer_nr+1) =
@@ -668,8 +666,6 @@
* @param obj_renderer A function that will render an object.
* @param data The diagram that the layer belongs to.
* @param active_layer Which number layer in the diagram is currently active.
- * @bug data and active_layer can be inferred from layer, though possibly
- * slowly.
*/
void
layer_render(Layer *layer, DiaRenderer *renderer, Rectangle *update,
Modified: trunk/lib/font.c
==============================================================================
--- trunk/lib/font.c (original)
+++ trunk/lib/font.c Sat May 31 16:04:47 2008
@@ -115,7 +115,7 @@
}
/* We might not need these anymore, when using FT2/Win32 fonts only */
-static GList *pango_contexts;
+static GList *pango_contexts = NULL;
void
dia_font_push_context(PangoContext *pcontext) {
Added: trunk/lib/libdia.c
==============================================================================
--- (empty file)
+++ trunk/lib/libdia.c Sat May 31 16:04:47 2008
@@ -0,0 +1,115 @@
+/* Dia -- an diagram creation/manipulation program
+ * Copyright (C) 1998 Alexander Larsson
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include <libxml/xmlerror.h>
+
+#include "libdia.h"
+#include "message.h"
+#include "utils.h"
+#include "dia_image.h"
+#include "color.h"
+#include "object.h"
+
+static void
+stderr_message_internal(const char *title, enum ShowAgainStyle showAgain,
+ const char *fmt, va_list *args, va_list *args2)
+{
+ static gchar *buf = NULL;
+ static gint alloc = 0;
+ gint len;
+
+ len = format_string_length_upper_bound (fmt, args);
+
+ if (len >= alloc) {
+ if (buf)
+ g_free (buf);
+
+ alloc = nearest_pow (MAX(len + 1, 1024));
+
+ buf = g_new (char, alloc);
+ }
+
+ vsprintf (buf, fmt, *args2);
+
+ fprintf(stderr,
+ "%s: %s\n",
+ title,buf);
+}
+
+#ifdef G_OS_WIN32
+static void
+myXmlErrorReporting (void *ctx, const char* msg, ...)
+{
+ va_list args;
+ gchar *string;
+
+ va_start(args, msg);
+ string = g_strdup_vprintf (msg, args);
+ g_print ("%s", string ? string : "xml error (null)?");
+ va_end(args);
+
+ g_free(string);
+}
+#endif
+
+/**
+ * Basic (i.e. minimal) initialization of libdia.
+ *
+ * It does not load any plug-ins but instead brings libdia to a state that plug-in loading can take place.
+ * @param flags a set of DIA_INTERACTIVE, DIA_MESSAGE_STDERR
+ */
+void
+libdia_init (guint flags)
+{
+ static gboolean initialized = FALSE;
+
+ if (initialized)
+ return;
+
+ if (flags & DIA_MESSAGE_STDERR)
+ set_message_func(stderr_message_internal);
+ LIBXML_TEST_VERSION;
+
+#ifdef G_OS_WIN32
+ xmlSetGenericErrorFunc(NULL, myXmlErrorReporting);
+#endif
+
+ stdprops_init();
+
+ if (flags & DIA_INTERACTIVE) {
+
+ dia_image_init();
+
+ gdk_rgb_init();
+
+ gtk_rc_parse("diagtkrc");
+
+ color_init();
+ }
+ initialized = TRUE;
+
+ object_registry_init();
+}
Modified: trunk/lib/libdia.def
==============================================================================
--- trunk/lib/libdia.def (original)
+++ trunk/lib/libdia.def Sat May 31 16:04:47 2008
@@ -83,7 +83,7 @@
color_convert
color_equals
- color_init
+; color_init
color_new_rgb
composite_add_attribute
@@ -248,7 +248,6 @@
dia_image_filename
dia_image_get_broken
dia_image_height
- dia_image_init
dia_image_load
dia_image_mask_data
dia_image_release
@@ -300,6 +299,7 @@
dia_plugin_unload
dia_pluginrc_write
dia_register_builtin_plugin
+ dia_register_plugin
dia_register_plugins
dia_renderer_get_type
@@ -492,7 +492,6 @@
object_prop_by_name_type
object_register_type
object_registry_foreach
- object_registry_init
object_remove_connectionpoint
object_remove_connections_to
object_remove_handle
@@ -609,7 +608,6 @@
polyshape_update_boundingbox
polyshape_update_data
- stdprops_init
make_new_prop
prefs_get_length_unit
prefs_set_fontsize_unit
@@ -697,4 +695,6 @@
dia_font_pop_context
dia_font_push_context
dia_transform_coords_double
- text_line_adjust_layout_line
\ No newline at end of file
+ text_line_adjust_layout_line
+
+ libdia_init
Added: trunk/lib/libdia.h
==============================================================================
--- (empty file)
+++ trunk/lib/libdia.h Sat May 31 16:04:47 2008
@@ -0,0 +1,8 @@
+enum DiaInitFlags
+{
+ DIA_INTERACTIVE = (1<<0),
+ DIA_MESSAGE_STDERR = (1<<1)
+};
+
+void libdia_init (guint flags);
+
Modified: trunk/lib/makefile.msc
==============================================================================
--- trunk/lib/makefile.msc (original)
+++ trunk/lib/makefile.msc Sat May 31 16:04:47 2008
@@ -62,7 +62,6 @@
diaerror.obj \
diagramdata.obj \
diagdkrenderer.obj \
- diagtkfontsel.obj \
diainteractiverenderer.obj \
diarenderer.obj \
diasvgrenderer.obj \
@@ -74,6 +73,7 @@
geometry.obj \
group.obj \
intl.obj \
+ libdia.obj \
message.obj \
newgroup.obj \
neworth_conn.obj \
Modified: trunk/lib/persistence.c
==============================================================================
--- trunk/lib/persistence.c (original)
+++ trunk/lib/persistence.c Sat May 31 16:04:47 2008
@@ -568,7 +568,7 @@
} else {
wininfo = g_new0(PersistentWindow, 1);
persistence_store_window_info(window, wininfo, FALSE);
- g_hash_table_insert(persistent_windows, name, wininfo);
+ g_hash_table_insert(persistent_windows, (gchar *)name, wininfo);
}
if (wininfo->window != NULL && wininfo->window != window) {
g_object_unref(wininfo->window);
@@ -666,7 +666,7 @@
gtk_window_get_size(window, &wininfo->width, &wininfo->height);
/* Drawable means visible & mapped, what we usually think of as open. */
wininfo->isopen = GTK_WIDGET_DRAWABLE(GTK_WIDGET(window));
- g_hash_table_insert(persistent_windows, name, wininfo);
+ g_hash_table_insert(persistent_windows, (gchar *)name, wininfo);
}
if (wininfo->window != NULL && wininfo->window != window) {
g_object_unref(wininfo->window);
@@ -802,7 +802,7 @@
list->glist = NULL;
list->sorted = FALSE;
list->max_members = G_MAXINT;
- g_hash_table_insert(persistent_lists, role, list);
+ g_hash_table_insert(persistent_lists, (gchar *)role, list);
return list;
}
@@ -830,7 +830,7 @@
}
static GList *
-persistent_list_cut_length(GList *list, gint length)
+persistent_list_cut_length(GList *list, guint length)
{
while (g_list_length(list) > length) {
GList *last = g_list_last(list);
@@ -956,7 +956,7 @@
ListenerData *listener = (ListenerData*)tmp->data;
if (listener->watch == NULL) {
/* Listener died */
- plist->listeners = g_list_remove_link(plist->listeners, listener);
+ plist->listeners = g_list_remove_link(plist->listeners, tmp->data);
g_free(listener);
} else {
/* Still listening */
@@ -1155,7 +1155,7 @@
}
void
-persistence_set_string(gchar *role, gchar *newvalue)
+persistence_set_string(gchar *role, const gchar *newvalue)
{
gchar *stringval;
if (persistent_strings == NULL) {
Modified: trunk/lib/persistence.h
==============================================================================
--- trunk/lib/persistence.h (original)
+++ trunk/lib/persistence.h Sat May 31 16:04:47 2008
@@ -87,7 +87,7 @@
gchar *persistence_register_string(gchar *role, gchar *defaultvalue);
gchar *persistence_get_string(gchar *role);
-void persistence_set_string(gchar *role, gchar *newvalue);
+void persistence_set_string(gchar *role, const gchar *newvalue);
Color *persistence_register_color(gchar *role, Color *defaultvalue);
Color *persistence_get_color(gchar *role);
Modified: trunk/plug-ins/makefile.msc
==============================================================================
--- trunk/plug-ins/makefile.msc (original)
+++ trunk/plug-ins/makefile.msc Sat May 31 16:04:47 2008
@@ -184,7 +184,7 @@
$(CC) $(CFLAGS) -c $(PKG_CFLAGS) $<
.c.obj :
- $(CC) $(CFLAGS) -GD -c $(PKG_CFLAGS) $<
+ $(CC) $(CFLAGS) -c $(PKG_CFLAGS) $<
!ENDIF
Modified: trunk/plug-ins/python/diamodule.c
==============================================================================
--- trunk/plug-ins/python/diamodule.c (original)
+++ trunk/plug-ins/python/diamodule.c Sat May 31 16:04:47 2008
@@ -39,6 +39,7 @@
#include "pydia-text.h"
#include "pydia-paperinfo.h"
+#include "lib/libdia.h"
#include "lib/object.h"
#include "lib/group.h"
#include "app/diagram.h"
@@ -47,6 +48,8 @@
#include "lib/message.h"
+#include "lib/plug-ins.h"
+
static PyObject *
PyDia_GroupCreate(PyObject *self, PyObject *args)
{
@@ -169,6 +172,19 @@
}
static PyObject *
+PyDia_RegisterPlugin(PyObject *self, PyObject *args)
+{
+ gchar *filename;
+
+ if (!PyArg_ParseTuple(args, "s:dia.register_plugin", &filename))
+ return NULL;
+ dia_register_plugin (filename);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
PyDia_RegisteredTypes(PyObject *self, PyObject *args)
{
PyObject *dict;
@@ -508,6 +524,8 @@
{ "register_action", PyDia_RegisterAction, METH_VARARGS,
"register a callback function which appears in the menu. Depending on the menu path used during registration"
"the callback gets called with the current DiaDiagramData object" },
+ { "register_plugin", PyDia_RegisterPlugin, METH_VARARGS,
+ "registers a single plug-in given its filename" },
{ NULL, NULL }
};
@@ -600,4 +618,9 @@
if (PyErr_Occurred())
Py_FatalError("can't initialise module dia");
+ else {
+ /* should all be no-ops when used embedded */
+ g_type_init ();
+ libdia_init (DIA_MESSAGE_STDERR);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]