Signals that do not get emitted



At one time we had the GtkPrintOperation widget working, sending
begin_print and draw_page signals; now it no longer works - the callback
is never reached - and I wonder if anyone has some idea as to why that
should be.
It is not the specific bit of code that creates/launches the widget, but
something more generic (like disabling a class of signals, if such a
thing is possible). I say this because I only came across it when I
installed a widget from libevince which uses the GtkPrintOperation and
that fails to get the callbacks.
I have built the evince widget as a standalone program (see below) and
it works. But the same piece of code called from within our (large)
program does not.

This has been seen in Gtk 2.30.2 and also in Gtk-3 (not sure which
version).

Any ideas how this can happen? (the project is Denemo, www.denemo.org,
and the file concerned is print.c).

Below is the Evince widget demo code which I wrote to test out.

Richard Shann

#include <stdio.h>
#include <gtk/gtk.h>
#include <evince-view.h>


evince_print() {
        GError *err = NULL;
  GFile       *file;
  gchar *filename = "test.pdf";
  file = g_file_new_for_commandline_arg (filename);
  gchar *uri = g_file_get_uri (file);
  g_object_unref (file);
  EvDocument *doc = ev_document_factory_get_document (uri, &err);
  if(err) {
    g_warning ("Trying to read the pdf file %s gave an error: %s", uri,
err->message);
    if(err)
                        g_error_free (err);
    err = NULL;
  } else {
    EvPrintOperation *printop = ev_print_operation_new (doc);      
    ev_print_operation_run (printop, NULL);
  }
}

int main(int argc, char **argv)
{

  GtkWidget *main_vbox, *top;
  gtk_init(&argc, &argv);
  ev_init();
  GtkWidget *printarea;    
  top = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title(GTK_WINDOW(top), "Evince Print Test");
 

  printarea = gtk_button_new_with_label("click me to print the file
test.pdf");  
  gtk_container_add (GTK_CONTAINER(top), (GtkWidget*)printarea);

  g_signal_connect (G_OBJECT (printarea), "clicked",
                      G_CALLBACK (evince_print), NULL);  
  gtk_widget_show_all(top);  
        gtk_main();
        return 0;
}

//////////////// end of source code
To build use something like

gcc testevince.c -o test -I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 
-I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 
-I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include      
-I/usr/include/libxml2   -pthread -I/usr/include/gtksourceview-2.0 -I/usr/include/libxml2 
-I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo 
-I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/pixman-1 -I/usr/include/freetype2 
-I/usr/include/libpng12 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -pthread 
-I/usr/include/librsvg-2 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/gtk-2.0 
-I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12     
-I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include   -I/usr/include/evince/2.30 -levview -levdocument

(a lot of that could be omitted I'm sure :)




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