X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=pdf%2Fxpdf%2Fgpdf.cc;h=8a8860f4448e95442cfba4afa68ea15290a62b1a;hb=b0f6e6f4e92ce461fa48d5d95ba7a863fc35966b;hp=33e3dda8ff0f79fd46217ca5d7f20d8b53f1128f;hpb=8db6ea908fea5d48ff174580a3398b67ee265717;p=evince.git diff --git a/pdf/xpdf/gpdf.cc b/pdf/xpdf/gpdf.cc index 33e3dda8..8a8860f4 100644 --- a/pdf/xpdf/gpdf.cc +++ b/pdf/xpdf/gpdf.cc @@ -3,8 +3,8 @@ // gpdf.cc // // Copyright 1996 Derek B. Noonburg -// Copyright 1999 Miguel de Icaza // Copyright 1999 Michael Meeks. +// Copyright 1999 Miguel de Icaza // //======================================================================== @@ -41,6 +41,27 @@ GBool printCommands = gFalse; gint gpdf_debug; poptContext ctx; +struct DOC_ROOT { + GString *title; + PDFDoc *pdf; + GtkWidget *toplevel; + GtkWidget *table; + GnomeAppBar *appbar; + GtkDrawingArea *area; + GdkVisual *visual; + GdkPixmap *pixmap; + OutputDev *out; + GdkColor paper; +}; + + +static void +crummy_cmd (GtkWidget *widget, DOC_ROOT *tmp) +{ + printf ("Crummy\n"); +} + + const struct poptOption gpdf_popt_options [] = { { "debug", '\0', POPT_ARG_INT, &gpdf_debug, 0, N_("Enables some debugging functions"), N_("LEVEL") }, @@ -48,69 +69,108 @@ const struct poptOption gpdf_popt_options [] = { }; +static GnomeUIInfo dummy_menu [] = { + { GNOME_APP_UI_ITEM, N_("_dummy"), + N_("What a dummy!"), crummy_cmd }, + GNOMEUIINFO_END +}; + +static GnomeUIInfo main_menu [] = { + { GNOME_APP_UI_SUBTREE, N_("_Dummy"), NULL, dummy_menu }, + GNOMEUIINFO_END +}; + //------------------------------------------------------------------------ // loadFile / displayPage //------------------------------------------------------------------------ -static GBool loadFile(GString *fileName) { - GString *title; - PDFDoc *newDoc; +static gint +doc_config_event (GtkWidget *widget, DOC_ROOT *doc) +{ + if (!doc) + return TRUE; + + if (doc->pixmap) + gdk_pixmap_unref(doc->pixmap); + + doc->pixmap = gdk_pixmap_new(widget->window, + widget->allocation.width, + widget->allocation.height, + -1); + gdk_draw_rectangle (doc->pixmap, + widget->style->white_gc, + TRUE, + 0, 0, + widget->allocation.width, + widget->allocation.height); + return TRUE; +} + +static gint +doc_redraw_event (GtkWidget *widget, DOC_ROOT *doc) +{ +/* Redraw the screen from the backing pixmap */ + + gdk_color_white (gtk_widget_get_default_colormap(), &doc->paper); + doc->out = new GOutputDev (doc->pixmap, doc->paper); + + doc->pdf->displayPage(doc->out, 1, 1, 0, gTrue); + +/* gdk_draw_pixmap(widget->window, + widget->style->fg_gc[GTK_WIDGET_STATE (widget)], + doc->pixmap, + event->area.x, event->area.y, + event->area.x, event->area.y, + event->area.width, event->area.height);*/ + + return FALSE; +} + +static GBool +loadFile(GString *fileName) +{ + DOC_ROOT *doc = new DOC_ROOT(); char s[20]; char *p; - // busy cursor - if (win) - win->setBusyCursor(gTrue); - // open PDF file - newDoc = new PDFDoc(fileName); - if (!newDoc->isOk()) { - delete newDoc; - if (win) - win->setBusyCursor(gFalse); + doc->pdf = new PDFDoc(fileName); + if (!doc->pdf->isOk()) { + delete doc->pdf; + delete doc; return gFalse; } - // replace old document - if (doc) - delete doc; - doc = newDoc; - - // nothing displayed yet - page = -99; + doc->toplevel = gnome_app_new ("gpdf", "gpdf"); + gtk_window_set_policy(GTK_WINDOW(doc->toplevel), 1, 1, 0); + gtk_window_set_default_size (GTK_WINDOW(doc->toplevel), 600, 400); + doc->table = GTK_WIDGET (gtk_table_new (0, 0, 0)); + doc->appbar = GNOME_APPBAR (gnome_appbar_new (FALSE, TRUE, + GNOME_PREFERENCES_USER)); + gnome_app_set_statusbar (GNOME_APP (doc->toplevel), + GTK_WIDGET (doc->appbar)); + gnome_app_set_contents (GNOME_APP (doc->toplevel), doc->table); + gnome_app_create_menus_with_data (GNOME_APP (doc->toplevel), main_menu, doc); + gnome_app_install_menu_hints(GNOME_APP (doc->toplevel), main_menu); + + doc->pixmap = NULL; + doc->area = GTK_DRAWING_AREA (gtk_drawing_area_new ()); + gtk_signal_connect (GTK_OBJECT (doc->area), "expose_event", + (GtkSignalFunc) doc_redraw_event, NULL); + gtk_signal_connect (GTK_OBJECT(doc->area),"configure_event", + (GtkSignalFunc) doc_config_event, NULL); + + gtk_table_attach (GTK_TABLE (doc->table), GTK_WIDGET (doc->area), + 0, 1, 1, 2, + GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_EXPAND, + 0, 0); + + gtk_widget_show_all (doc->toplevel); - // init PostScript output params - if (psFileName) - delete psFileName; - if (defPSFileName) { - psFileName = defPSFileName->copy(); - } else { - p = fileName->getCString() + fileName->getLength() - 4; - if (!strcmp(p, ".pdf") || !strcmp(p, ".PDF")) - psFileName = new GString(fileName->getCString(), - fileName->getLength() - 4); - else - psFileName = fileName->copy(); - psFileName->append(".ps"); - } - psFirstPage = 1; - psLastPage = doc->getNumPages(); - - // set up title, number-of-pages display; back to normal cursor - if (win) { - title = new GString("xpdf: "); - title->append(fileName); - win->setTitle(title); - sprintf(s, "of %d", doc->getNumPages()); - numPagesLabel->setText(s); - win->setBusyCursor(gFalse); - } - - // done return gTrue; } -static void displayPage(int page1, int zoom1, int rotate1) { +/*static void displayPage(int page1, int zoom1, int rotate1) { char s[20]; // check for document @@ -144,7 +204,7 @@ static void displayPage(int page1, int zoom1, int rotate1) { // back to regular cursor win->setBusyCursor(gFalse); -} + }*/ int main (int argc, char *argv []) @@ -156,6 +216,8 @@ main (int argc, char *argv []) "gpdf", "0.1", argc, argv, gpdf_popt_options, 0, &ctx); + initParams (xpdfConfigFile); /* Init font path */ + view_files = poptGetArgs (ctx); /* Load files */ if (view_files) { @@ -171,6 +233,8 @@ main (int argc, char *argv []) poptFreeContext (ctx); + freeParams(); + gtk_main (); /* Destroy files */