From: Carlos Garcia Campos Date: Sun, 27 Apr 2008 15:52:51 +0000 (+0000) Subject: Merge branch 'ev-debug' into work X-Git-Tag: EVINCE_2_23_4~25 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=ae482b5ca216978f0fdc1e5b89e9709c3ff8b06b;p=evince.git Merge branch 'ev-debug' into work svn path=/trunk/; revision=3025 --- diff --git a/ChangeLog b/ChangeLog index 9db436e9..e4d89dab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2008-04-27 Carlos Garcia Campos + + * configure.ac: + * libdocument/Makefile.am: + * libdocument/ev-debug.[ch]: + * libdocument/ev-document.c: + * shell/ev-jobs.c: (ev_job_links_dispose), + (ev_job_render_dispose), (ev_job_thumbnail_dispose), + (ev_job_print_dispose), (ev_job_finished), (ev_job_links_new), + (ev_job_links_run), (ev_job_render_new), (notify_page_ready), + (ev_job_render_page_ready), (ev_job_render_run), + (ev_job_thumbnail_new), (ev_job_thumbnail_run), + (ev_job_fonts_new), (ev_job_fonts_run), (ev_job_load_dispose), + (ev_job_load_new), (ev_job_load_set_uri), (ev_job_load_run), + (ev_job_save_dispose), (ev_job_save_new), (ev_job_save_run), + (ev_job_print_new), (ev_job_print_run): + * shell/main.c: (main): + + Add debug mode based on gedit code. Add debug messages in + ev-jobs. + 2008-04-24 Carlos Garcia Campos * libdocument/ev-document-factory.c: (get_document_from_uri): diff --git a/configure.ac b/configure.ac index 4b0dd846..53ec974a 100644 --- a/configure.ac +++ b/configure.ac @@ -27,7 +27,6 @@ GNOME_DOC_INIT GNOME_MAINTAINER_MODE_DEFINES GNOME_COMPILE_WARNINGS GNOME_CXX_WARNINGS -GNOME_DEBUG_CHECK GTK_DOC_CHECK(1.0) @@ -129,28 +128,39 @@ fi AC_SUBST([DBUS_CFLAGS]) AC_SUBST([DBUS_LIBS]) -LIB_CFLAGS="$LIB_CFLAGS $GNOME_CFLAGS" +AM_CONDITIONAL([ENABLE_DBUS], [test "x$enable_dbus" = "xyes"]) +AM_CONDITIONAL([DBUS_TOOL_NO_PREFIX], [test "x$DBUS_VERSION" = "x33"]) + +dnl Debug mode +AC_ARG_ENABLE([debug], + AC_HELP_STRING([--enable-debug], + [Turn on evince debug mode]),, + [enable_debug=no]) + +if test "x$enable_debug" = "xyes"; then + DEBUG_FLAGS="-DEV_ENABLE_DEBUG" +fi + + +LIB_CFLAGS="$LIB_CFLAGS $GNOME_CFLAGS $DEBUG_FLAGS" LIB_LIBS="$LIB_LIBS $GNOME_LIBS" AC_SUBST(LIB_CFLAGS) AC_SUBST(LIB_LIBS) -BACKEND_CFLAGS="$BACKEND_CFLAGS -DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE" +BACKEND_CFLAGS="$BACKEND_CFLAGS -DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE $DEBUG_FLAGS" AC_SUBST(BACKEND_CFLAGS) AC_SUBST(BACKEND_LIBS) -SHELL_CFLAGS="$SHELL_CORE_CFLAGS $DBUS_CFLAGS $GNOMEUI_CFLAGS $KEYRING_CFLAGS -DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE" +SHELL_CFLAGS="$SHELL_CORE_CFLAGS $DBUS_CFLAGS $GNOMEUI_CFLAGS $KEYRING_CFLAGS -DGDK_MULTIHEAD_SAFE -DGTK_MULTIHEAD_SAFE $DEBUG_FLAGS" SHELL_LIBS="$SHELL_CORE_LIBS $DBUS_LIBS $GNOMEUI_LIBS $KEYRING_LIBS -lz" AC_SUBST(SHELL_CFLAGS) AC_SUBST(SHELL_LIBS) -FRONTEND_CFLAGS="$FRONTEND_CORE_CFLAGS $GNOME_CFLAGS" +FRONTEND_CFLAGS="$FRONTEND_CORE_CFLAGS $GNOME_CFLAGS $DEBUG_FLAGS" FRONTEND_LIBS="$FRONTEND_CORE_LIBS $GNOME_LIBS -lz" AC_SUBST(FRONTEND_CFLAGS) AC_SUBST(FRONTEND_LIBS) -AM_CONDITIONAL([ENABLE_DBUS], [test "x$enable_dbus" = "xyes"]) -AM_CONDITIONAL([DBUS_TOOL_NO_PREFIX], [test "x$DBUS_VERSION" = "x33"]) - dnl Check for Nautilus property page build AC_ARG_ENABLE(nautilus, AC_HELP_STRING([--enable-nautilus],[compile the nautilus plugin]), @@ -466,6 +476,7 @@ Configure summary: Nautilus Plugin....: $HAVE_NAUTILUS Thumbnailer........: $ENABLE_THUMBNAILER Gtk-Doc Support....: $enable_gtk_doc + Debug mode.........: $enable_debug PDF Backend........: $enable_pdf PostScript Backend.: $enable_ps diff --git a/libdocument/Makefile.am b/libdocument/Makefile.am index 577c1c52..b225caa1 100644 --- a/libdocument/Makefile.am +++ b/libdocument/Makefile.am @@ -14,6 +14,7 @@ libevbackend_la_LIBADD = $(LIB_LIBS) NOINST_H_FILES = \ ev-backend-marshalers.h \ ev-backends-manager.h \ + ev_debug.h \ ev-document-factory.h \ ev-module.h @@ -66,6 +67,7 @@ libevbackend_la_SOURCES= \ ev-document-transition.c \ ev-document-forms.c \ ev-form-field.c \ + ev-debug.c \ ev-file-exporter.c \ ev-file-helpers.c \ ev-module.c \ diff --git a/libdocument/ev-debug.c b/libdocument/ev-debug.c new file mode 100644 index 00000000..3806fd45 --- /dev/null +++ b/libdocument/ev-debug.c @@ -0,0 +1,85 @@ +/* + * ev-debug.c + * This file is part of Evince + * + * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence + * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi + * Copyright (C) 2002 - 2005 Paolo Maggi + * + * 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. + */ + +/* + * Modified by the gedit Team, 1998-2005. See the AUTHORS file for a + * list of people on the gedit Team. + * See the ChangeLog files for a list of changes. + * + * $Id: gedit-debug.c 4809 2006-04-08 14:46:31Z pborelli $ + */ + +/* Modified by Evince Team */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "ev-debug.h" + +#ifdef EV_ENABLE_DEBUG +static EvDebugSection ev_debug = EV_NO_DEBUG; + +void +ev_debug_init () +{ + if (g_getenv ("EV_DEBUG") != NULL) { + /* enable all debugging */ + ev_debug = ~EV_NO_DEBUG; + return; + } + + if (g_getenv ("EV_DEBUG_JOBS") != NULL) + ev_debug |= EV_DEBUG_JOBS; +} + +void +ev_debug_message (EvDebugSection section, + const gchar *file, + gint line, + const gchar *function, + const gchar *format, ...) +{ + if (G_UNLIKELY (ev_debug & section)) { + gchar *msg = NULL; + + if (format) { + va_list args; + + va_start (args, format); + msg = g_strdup_vprintf (format, args); + va_end (args); + } + + g_print ("%s:%d (%s) %s\n", file, line, function, msg ? msg : ""); + + fflush (stdout); + + g_free (msg); + } +} + +#endif /* EV_ENABLE_DEBUG */ diff --git a/libdocument/ev-debug.h b/libdocument/ev-debug.h new file mode 100644 index 00000000..b025597a --- /dev/null +++ b/libdocument/ev-debug.h @@ -0,0 +1,72 @@ +/* + * ev-debug.h + * This file is part of Evince + * + * Copyright (C) 1998, 1999 Alex Roberts, Evan Lawrence + * Copyright (C) 2000, 2001 Chema Celorio, Paolo Maggi + * Copyright (C) 2002 - 2005 Paolo Maggi + * + * 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. + */ + +/* + * Modified by the gedit Team, 1998-2005. See the AUTHORS file for a + * list of people on the gedit Team. + * See the ChangeLog files for a list of changes. + * + * $Id: gedit-debug.h 4809 2006-04-08 14:46:31Z pborelli $ + */ + +/* Modified by Evince Team */ + +#ifndef __EV_DEBUG_H__ +#define __EV_DEBUG_H__ + +#include + +#ifndef EV_ENABLE_DEBUG +#define ev_debug_init() +#define ev_debug_message(...) +#else + +G_BEGIN_DECLS + +/* + * Set an environmental var of the same name to turn on + * debugging output. Setting EV_DEBUG will turn on all + * sections. + */ +typedef enum { + EV_NO_DEBUG = 0, + EV_DEBUG_JOBS = 1 << 0 +} EvDebugSection; + + +#define DEBUG_JOBS EV_DEBUG_JOBS, __FILE__, __LINE__, G_STRFUNC + +void ev_debug_init (void); + +void ev_debug_message (EvDebugSection section, + const gchar *file, + gint line, + const gchar *function, + const gchar *format, ...) G_GNUC_PRINTF(5, 6); + + +G_END_DECLS + +#endif /* EV_ENABLE_DEBUG */ +#endif /* __EV_DEBUG_H__ */ diff --git a/libdocument/ev-document.c b/libdocument/ev-document.c index 5e582d0a..7bb86be9 100644 --- a/libdocument/ev-document.c +++ b/libdocument/ev-document.c @@ -30,7 +30,6 @@ static void ev_document_class_init (gpointer g_class); GMutex *ev_doc_mutex = NULL; GMutex *ev_fc_mutex = NULL; -#define LOG(x) GType ev_document_get_type (void) { @@ -118,7 +117,7 @@ ev_document_load (EvDocument *document, { EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document); gboolean retval; - LOG ("ev_document_load"); + retval = iface->load (document, uri, error); return retval; @@ -132,7 +131,6 @@ ev_document_save (EvDocument *document, EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document); gboolean retval; - LOG ("ev_document_save"); retval = iface->save (document, uri, error); return retval; @@ -144,7 +142,6 @@ ev_document_get_n_pages (EvDocument *document) EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document); gint retval; - LOG ("ev_document_get_n_pages"); retval = iface->get_n_pages (document); return retval; @@ -173,7 +170,6 @@ ev_document_get_page_size (EvDocument *document, { EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document); - LOG ("ev_document_get_page_size"); iface->get_page_size (document, page, width, height); } @@ -183,7 +179,6 @@ ev_document_get_page_label (EvDocument *document, { EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document); - LOG ("ev_document_get_page_label"); if (iface->get_page_label == NULL) return NULL; @@ -215,7 +210,6 @@ ev_document_get_attachments (EvDocument *document) EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document); GList *retval; - LOG ("ev_document_get_attachments"); if (iface->get_attachments == NULL) return NULL; retval = iface->get_attachments (document); @@ -230,7 +224,6 @@ ev_document_render (EvDocument *document, EvDocumentIface *iface = EV_DOCUMENT_GET_IFACE (document); cairo_surface_t *retval; - LOG ("ev_document_render_pixbuf"); g_assert (iface->render); retval = iface->render (document, rc); diff --git a/shell/ev-jobs.c b/shell/ev-jobs.c index 8c0472a1..5e572c74 100644 --- a/shell/ev-jobs.c +++ b/shell/ev-jobs.c @@ -11,6 +11,7 @@ #include "ev-file-helpers.h" #include "ev-document-fonts.h" #include "ev-async-renderer.h" +#include "ev-debug.h" #include #include @@ -98,6 +99,8 @@ ev_job_links_dispose (GObject *object) { EvJobLinks *job; + ev_debug_message (DEBUG_JOBS, NULL); + job = EV_JOB_LINKS (object); if (job->model) { @@ -128,6 +131,8 @@ ev_job_render_dispose (GObject *object) job = EV_JOB_RENDER (object); + ev_debug_message (DEBUG_JOBS, "page: %d", job->ev_page->index); + if (job->ev_page) { g_object_unref (job->ev_page); job->ev_page = NULL; @@ -179,6 +184,8 @@ ev_job_thumbnail_dispose (GObject *object) job = EV_JOB_THUMBNAIL (object); + ev_debug_message (DEBUG_JOBS, "%d", job->page); + if (job->thumbnail) { g_object_unref (job->thumbnail); job->thumbnail = NULL; @@ -206,6 +213,8 @@ ev_job_print_dispose (GObject *object) job = EV_JOB_PRINT (object); + ev_debug_message (DEBUG_JOBS, NULL); + if (job->temp_file) { g_unlink (job->temp_file); g_free (job->temp_file); @@ -240,6 +249,8 @@ ev_job_print_class_init (EvJobPrintClass *class) void ev_job_finished (EvJob *job) { + ev_debug_message (DEBUG_JOBS, NULL); + g_return_if_fail (EV_IS_JOB (job)); g_signal_emit (job, job_signals[FINISHED], 0); @@ -250,6 +261,8 @@ ev_job_links_new (EvDocument *document) { EvJob *job; + ev_debug_message (DEBUG_JOBS, NULL); + job = g_object_new (EV_TYPE_JOB_LINKS, NULL); job->document = g_object_ref (document); @@ -259,6 +272,8 @@ ev_job_links_new (EvDocument *document) void ev_job_links_run (EvJobLinks *job) { + ev_debug_message (DEBUG_JOBS, NULL); + g_return_if_fail (EV_IS_JOB_LINKS (job)); ev_document_doc_mutex_lock (); @@ -278,6 +293,8 @@ ev_job_render_new (EvDocument *document, { EvJobRender *job; + ev_debug_message (DEBUG_JOBS, "page: %d", page); + job = g_object_new (EV_TYPE_JOB_RENDER, NULL); EV_JOB (job)->document = g_object_ref (document); @@ -328,6 +345,8 @@ render_finished_cb (EvDocument *document, static gboolean notify_page_ready (EvJobRender *job) { + ev_debug_message (DEBUG_JOBS, "%d", job->ev_page->index); + g_signal_emit (job, job_render_signals[PAGE_READY], 0); return FALSE; @@ -336,6 +355,8 @@ notify_page_ready (EvJobRender *job) static void ev_job_render_page_ready (EvJobRender *job) { + ev_debug_message (DEBUG_JOBS, "%d", job->ev_page->index); + job->page_ready = TRUE; g_idle_add_full (G_PRIORITY_HIGH_IDLE, (GSourceFunc)notify_page_ready, @@ -348,6 +369,8 @@ ev_job_render_run (EvJobRender *job) { g_return_if_fail (EV_IS_JOB_RENDER (job)); + ev_debug_message (DEBUG_JOBS, "page: %d", job->page); + ev_document_doc_mutex_lock (); if (EV_JOB (job)->async) { @@ -415,6 +438,8 @@ ev_job_thumbnail_new (EvDocument *document, { EvJobThumbnail *job; + ev_debug_message (DEBUG_JOBS, "%d", page); + job = g_object_new (EV_TYPE_JOB_THUMBNAIL, NULL); EV_JOB (job)->document = g_object_ref (document); @@ -430,6 +455,8 @@ ev_job_thumbnail_run (EvJobThumbnail *job) { EvRenderContext *rc; EvPage *page; + + ev_debug_message (DEBUG_JOBS, "%d", job->page); g_return_if_fail (EV_IS_JOB_THUMBNAIL (job)); @@ -457,6 +484,8 @@ ev_job_fonts_new (EvDocument *document) { EvJobFonts *job; + ev_debug_message (DEBUG_JOBS, NULL); + job = g_object_new (EV_TYPE_JOB_FONTS, NULL); EV_JOB (job)->document = g_object_ref (document); @@ -469,6 +498,8 @@ ev_job_fonts_run (EvJobFonts *job) { EvDocumentFonts *fonts; + ev_debug_message (DEBUG_JOBS, NULL); + g_return_if_fail (EV_IS_JOB_FONTS (job)); ev_document_doc_mutex_lock (); @@ -490,6 +521,8 @@ ev_job_load_dispose (GObject *object) { EvJobLoad *job = EV_JOB_LOAD (object); + ev_debug_message (DEBUG_JOBS, "%s", job->uri); + if (job->uri) { g_free (job->uri); job->uri = NULL; @@ -532,6 +565,8 @@ ev_job_load_new (const gchar *uri, { EvJobLoad *job; + ev_debug_message (DEBUG_JOBS, "%s", uri); + job = g_object_new (EV_TYPE_JOB_LOAD, NULL); job->uri = g_strdup (uri); @@ -548,6 +583,8 @@ ev_job_load_new (const gchar *uri, void ev_job_load_set_uri (EvJobLoad *job, const gchar *uri) { + ev_debug_message (DEBUG_JOBS, "%s", uri); + if (job->uri) g_free (job->uri); job->uri = g_strdup (uri); @@ -557,6 +594,8 @@ void ev_job_load_run (EvJobLoad *job) { g_return_if_fail (EV_IS_JOB_LOAD (job)); + + ev_debug_message (DEBUG_JOBS, "%s", job->uri); if (job->error) { g_error_free (job->error); @@ -589,6 +628,8 @@ ev_job_save_dispose (GObject *object) { EvJobSave *job = EV_JOB_SAVE (object); + ev_debug_message (DEBUG_JOBS, "%s", job->uri); + if (job->uri) { g_free (job->uri); job->uri = NULL; @@ -624,6 +665,8 @@ ev_job_save_new (EvDocument *document, { EvJobSave *job; + ev_debug_message (DEBUG_JOBS, "uri: %s, document_uri: %s", uri, document_uri); + job = g_object_new (EV_TYPE_JOB_SAVE, NULL); EV_JOB (job)->document = g_object_ref (document); @@ -641,6 +684,8 @@ ev_job_save_run (EvJobSave *job) gchar *filename; gchar *tmp_filename; gchar *local_uri; + + ev_debug_message (DEBUG_JOBS, "uri: %s, document_uri: %s", job->uri, job->document_uri); filename = ev_tmp_filename ("saveacopy"); tmp_filename = g_strdup_printf ("%s.XXXXXX", filename); @@ -734,6 +779,12 @@ ev_job_print_new (EvDocument *document, { EvJobPrint *job; + ev_debug_message (DEBUG_JOBS, "format: %s, width: %f, height:%f," + "n_ranges: %d, pages_per_sheet: %d, copies: %d," + "collate: %s, reverse: %s", + format, width, height, n_ranges, pages_per_sheet, copies, + collate ? "True" : "False", reverse ? "True" : "False"); + job = g_object_new (EV_TYPE_JOB_PRINT, NULL); EV_JOB (job)->document = g_object_ref (document); @@ -889,6 +940,8 @@ ev_job_print_run (EvJobPrint *job) g_return_if_fail (EV_IS_JOB_PRINT (job)); + ev_debug_message (DEBUG_JOBS, NULL); + if (job->temp_file) g_free (job->temp_file); job->temp_file = NULL; diff --git a/shell/main.c b/shell/main.c index e0fc9933..a552a328 100644 --- a/shell/main.c +++ b/shell/main.c @@ -21,6 +21,7 @@ #include "ev-application.h" #include "ev-metadata-manager.h" +#include "ev-debug.h" #include #include @@ -378,6 +379,8 @@ main (int argc, char *argv[]) } #endif + ev_debug_init (); + #if WITH_GNOME gnome_authentication_manager_init (); #endif