From: Michael Meeks Date: Tue, 3 Aug 1999 20:15:45 +0000 (+0000) Subject: Close / Exit, About box, X-Git-Tag: ChangeLog~38 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=c03586d1782165b360ef34d0879e2ebfaba7fbed;p=evince.git Close / Exit, About box, Close / Exit, About box, --- diff --git a/pdf/xpdf/ChangeLog b/pdf/xpdf/ChangeLog index e564419b..7684ac15 100644 --- a/pdf/xpdf/ChangeLog +++ b/pdf/xpdf/ChangeLog @@ -1,6 +1,7 @@ 1999-08-03 Michael Meeks - * gpdf.cc: Lots of updates. + * gpdf.cc: Lots of updates, gives up on logging changes + ( for a bit. ) 1999-08-02 Michael Meeks diff --git a/pdf/xpdf/Makefile.in b/pdf/xpdf/Makefile.in index 7ba540bc..f15f26ea 100644 --- a/pdf/xpdf/Makefile.in +++ b/pdf/xpdf/Makefile.in @@ -15,10 +15,10 @@ LTKSRCDIR = $(srcdir)/../ltk LTKLIBDIR = ../ltk #CXXFLAGS = @CXXFLAGS@ @DEFS@ @OPTIONS@ -I$(GOOSRCDIR) -I$(LTKSRCDIR) -I$(srcdir) @X_CFLAGS@ @Xpm_CFLAGS@ -CXXFLAGS = @CXXFLAGS@ @DEFS@ @OPTIONS@ -I$(GOOSRCDIR) -I$(LTKSRCDIR) -Wall -g `gnome-config --cflags gnomeui` -lglade -lglade-gnome -I$(srcdir) @Xpm_CFLAGS@ @X_CFLAGS@ +CXXFLAGS = @CXXFLAGS@ @DEFS@ @OPTIONS@ -I$(GOOSRCDIR) -I$(LTKSRCDIR) -Wall -g `gnome-config --cflags gnomeui` -I$(srcdir) @Xpm_CFLAGS@ @X_CFLAGS@ XLIBS = @Xpm_LIBS@ @X_PRE_LIBS@ @X_LIBS@ -lX11 @X_EXTRA_LIBS@ -OTHERLIBS = @LIBS@ +OTHERLIBS = @LIBS@ -lglade -lglade-gnome CXX = @CXX@ STRIP = @STRIP@ diff --git a/pdf/xpdf/about.glade b/pdf/xpdf/about.glade new file mode 100644 index 00000000..51a07d1a --- /dev/null +++ b/pdf/xpdf/about.glade @@ -0,0 +1,38 @@ + + + + + about + about + + src + pixmaps + C + True + True + False + True + True + True + True + interface.c + interface.h + callbacks.c + callbacks.h + support.c + support.h + + + + + GnomeAbout + about + + Derek B. Noonburg, +Michael Meeks, +Miguel de Icaza + + This software is available subject to the terms of the GPL. + + + diff --git a/pdf/xpdf/gpdf.cc b/pdf/xpdf/gpdf.cc index 7da47d58..bba767ee 100644 --- a/pdf/xpdf/gpdf.cc +++ b/pdf/xpdf/gpdf.cc @@ -8,7 +8,6 @@ // //======================================================================== - #include #include #include @@ -49,10 +48,11 @@ poptContext ctx; double zoom = 86.0; gint page = 2; -#define DOC_KEY "xpdf_doc_key" +#define DOC_ROOT_TAG "xpdf_doc_root" struct DOC_ROOT { GString *title; PDFDoc *pdf; + Catalog *cat; GtkDrawingArea *area; GtkPixmap *pixmap; OutputDev *out; @@ -62,33 +62,23 @@ struct DOC_ROOT { GladeXML *gui; }; +GList *documents = NULL; + const struct poptOption gpdf_popt_options [] = { { "debug", '\0', POPT_ARG_INT, &gpdf_debug, 0, N_("Enables some debugging functions"), N_("LEVEL") }, { NULL, '\0', 0, NULL, 0 } }; +extern "C" { + static void connect_signals (DOC_ROOT *doc); +} + //------------------------------------------------------------------------ // loadFile / displayPage //------------------------------------------------------------------------ -static void -get_page_geom (int *w, int *h, Page *p) -{ - double pw = p->getWidth(); - double ph = p->getHeight(); - - *w = 612; - *h = 792; - - if (!p) - return; - - *w = (int)((pw * zoom)/72.0 + 28.0); - *h = (int)((ph * zoom)/72.0 + 56.0); -} - -static GdkPixmap * +static GtkPixmap * setup_pixmap (DOC_ROOT *doc, GdkWindow *window) { GdkGCValues gcValues; @@ -97,16 +87,11 @@ setup_pixmap (DOC_ROOT *doc, GdkWindow *window) int w, h; GdkPixmap *pixmap = NULL; - if (pixmap) - gdk_pixmap_unref(pixmap); - - Catalog *cat = pdf->getCatalog(); - get_page_geom (&w, &h, cat->getPage (page)); + w = (int)((pdf->getPageWidth (page) * zoom) / 72.0); + h = (int)((pdf->getPageHeight (page) * zoom) / 72.0); pixmap = gdk_pixmap_new (window, w, h, -1); - gtk_widget_set_usize (GTK_WIDGET (doc->scroll), w, h); - printf ("Creating pixmap of size %d %d\n", w, h); gdk_color_white (gtk_widget_get_default_colormap(), &doc->paper); doc->out = new GOutputDev (pixmap, doc->paper, window); @@ -121,49 +106,51 @@ setup_pixmap (DOC_ROOT *doc, GdkWindow *window) gdk_draw_rectangle (pixmap, strokeGC, TRUE, 0, 0, w, h); - return pixmap; + + return GTK_PIXMAP (gtk_pixmap_new (pixmap, NULL)); } -/*static gint -doc_config_event (GtkWidget *widget, void *ugly) +static void +show_page (DOC_ROOT *doc, gint page) { - DOC_ROOT *doc; + doc->pdf->displayPage(doc->out, page, zoom, 0, gTrue); +} - doc = (DOC_ROOT *)gtk_object_get_data (GTK_OBJECT (widget), DOC_KEY); - - g_return_val_if_fail (doc, FALSE); +/*static void displayPage(int page1, int zoom1, int rotate1) { + char s[20]; - return TRUE; -} + // check for document + if (!doc) + return; -static gint -doc_redraw_event (GtkWidget *widget, GdkEventExpose *event) -{ - DOC_ROOT *doc; - - g_return_val_if_fail (widget != NULL, FALSE); - - doc = (DOC_ROOT *)gtk_object_get_data (GTK_OBJECT (widget), DOC_KEY); - - g_return_val_if_fail (doc != NULL, FALSE); - - if (doc->out && doc->pdf) { -#if DEV_DEBUG > 0 - printf ("There are %d pages\n", doc->pdf->getNumPages()); -#endif - - doc->pdf->displayPage(doc->out, 1, 86, 0, gTrue); - gdk_draw_pixmap(widget->window, - widget->style->fg_gc[GTK_WIDGET_STATE (widget)], - doc->pixmap, - 0, 0, - event->area.x, event->area.y, - event->area.width, event->area.height); - } else - printf ("Null pointer error %p %p\n", doc->out, doc->pdf); - - return FALSE; -}*/ + // busy cursor + if (win) + win->setBusyCursor(gTrue); + + // new page/zoom/rotate values + page = page1; + zoom = zoom1; + rotate = rotate1; + + // initialize mouse-related stuff + linkAction = NULL; + win->setDefaultCursor(); + linkLabel->setText(NULL); + selectXMin = selectXMax = 0; + selectYMin = selectYMax = 0; + lastDragLeft = lastDragTop = gTrue; + + // draw the page + doc->displayPage(out, page, zoomDPI[zoom - minZoom], rotate, gTrue); + layoutCbk(win); + + // update page number display + sprintf(s, "%d", page); + pageNumText->setText(s); + + // back to regular cursor + win->setBusyCursor(gFalse); + }*/ static PDFDoc * getPDF (GString *fname) @@ -178,20 +165,17 @@ getPDF (GString *fname) return pdf; } - -static GBool -loadPDF(GString *fileName) +static DOC_ROOT * +doc_root_new (GString *fileName) { DOC_ROOT *doc = new DOC_ROOT(); GtkVBox *pane; - GtkAdjustment *hadj, *vadj; - GdkPixmap *pix; // open PDF file doc->pdf = getPDF (fileName); if (!doc->pdf) { delete doc; - return gFalse; + return NULL; } doc->gui = glade_xml_new (GPDF_GLADE_DIR "/gpdf.glade", NULL); @@ -201,67 +185,86 @@ loadPDF(GString *fileName) printf ("Couldn't find " GPDF_GLADE_DIR "/gpdf.glade\n"); delete doc->pdf; delete doc; - return gFalse; + return NULL; } -/* glade_xml_signal_autoconnect (doc->gui);*/ - - pix = setup_pixmap (doc, gtk_widget_get_parent_window (GTK_WIDGET (pane))); - doc->pixmap = GTK_PIXMAP (gtk_pixmap_new (pix, NULL)); + + connect_signals (doc); + + gtk_object_set_data (GTK_OBJECT (doc->mainframe), DOC_ROOT_TAG, doc); + + doc->pixmap = setup_pixmap (doc, gtk_widget_get_parent_window (GTK_WIDGET (pane))); doc->scroll = GTK_SCROLLED_WINDOW (gtk_scrolled_window_new (NULL, NULL)); gtk_scrolled_window_set_policy (doc->scroll, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - doc->pdf->displayPage(doc->out, page, zoom, 0, gTrue); + show_page (doc, page); gtk_scrolled_window_add_with_viewport (doc->scroll, GTK_WIDGET (doc->pixmap)); gtk_box_pack_start (GTK_BOX (pane), GTK_WIDGET (doc->scroll), TRUE, TRUE, 0); gtk_widget_show_all (doc->mainframe); - return gTrue; -} -/*static void displayPage(int page1, int zoom1, int rotate1) { - char s[20]; + documents = g_list_append (documents, doc); - // check for document - if (!doc) - return; - - // busy cursor - if (win) - win->setBusyCursor(gTrue); + return doc; +} - // new page/zoom/rotate values - page = page1; - zoom = zoom1; - rotate = rotate1; +static void +doc_root_destroy (DOC_ROOT *doc) +{ + gtk_widget_destroy (doc->mainframe); + gtk_object_destroy (GTK_OBJECT (doc->gui)); + + documents = g_list_remove (documents, doc); + if (g_list_length (documents) == 0) + gtk_main_quit (); + delete (doc); +} - // initialize mouse-related stuff - linkAction = NULL; - win->setDefaultCursor(); - linkLabel->setText(NULL); - selectXMin = selectXMax = 0; - selectYMin = selectYMax = 0; - lastDragLeft = lastDragTop = gTrue; +//------------------------------------------------------------------------ +// Signal handlers +//------------------------------------------------------------------------ - // draw the page - doc->displayPage(out, page, zoomDPI[zoom - minZoom], rotate, gTrue); - layoutCbk(win); +extern "C" { + void + do_close (GtkWidget *menuitem, DOC_ROOT *doc) + { + doc_root_destroy (doc); + } - // update page number display - sprintf(s, "%d", page); - pageNumText->setText(s); + void + do_exit (GtkWidget *menuitem, DOC_ROOT *doc) + { + GList *l; + while ((l=documents)) + doc_root_destroy ((DOC_ROOT *)l->data); + } - // back to regular cursor - win->setBusyCursor(gFalse); - }*/ + static void + do_about_box (GtkWidget *w, DOC_ROOT *doc) + { + GladeXML *gui = glade_xml_new (GPDF_GLADE_DIR "/about.glade", NULL); + g_return_if_fail (gui); + GtkWidget *wi = glade_xml_get_widget (gui, "about_box"); + g_return_if_fail (wi); + gtk_widget_show (wi); + gtk_object_destroy (GTK_OBJECT (gui)); + } -extern "C" { - void - on_close_activate (GtkWidget *window, void *data) + static void + simple_connect (DOC_ROOT *doc, const char *name, GtkSignalFunc func) { - printf ("Bye..."); - gtk_widget_destroy (window); + GtkWidget *w; + w = glade_xml_get_widget (doc->gui, name); + gtk_signal_connect (GTK_OBJECT (w), "activate", func, doc); } + + static void + connect_signals (DOC_ROOT *doc) + { + simple_connect (doc, "about_menu", GTK_SIGNAL_FUNC (do_about_box)); + simple_connect (doc, "close_menu", GTK_SIGNAL_FUNC (do_close)); + simple_connect (doc, "exit_menu", GTK_SIGNAL_FUNC (do_exit)); + } } int @@ -285,7 +288,7 @@ main (int argc, char *argv []) if (view_files) { for (i = 0; view_files[i]; i++) { GString *name = new GString (view_files[i]); - if (!name || !loadPDF (name)) + if (!name || !doc_root_new (name)) printf ("Error loading '%s'\n", view_files[i]); } } else { diff --git a/pdf/xpdf/gpdf.glade b/pdf/xpdf/gpdf.glade index 1d71de57..1ce942a3 100644 --- a/pdf/xpdf/gpdf.glade +++ b/pdf/xpdf/gpdf.glade @@ -67,32 +67,22 @@ GtkMenuItem - file1 + file_menu GNOMEUIINFO_MENU_FILE_TREE GtkMenu - file1_menu + file_menu_menu GtkPixmapMenuItem - open1 - - activate - on_open1_activate - Sun, 01 Aug 1999 03:04:00 GMT - + open_menu GNOMEUIINFO_MENU_OPEN_ITEM GtkPixmapMenuItem - close - - activate - on_close_activate - Sun, 01 Aug 1999 23:33:35 GMT - + close_menu GNOMEUIINFO_MENU_CLOSE_ITEM @@ -104,23 +94,13 @@ GtkPixmapMenuItem - print1 - - activate - on_print1_activate - Sun, 01 Aug 1999 03:04:00 GMT - + print_menu GNOMEUIINFO_MENU_PRINT_ITEM GtkPixmapMenuItem - print_setup1 - - activate - on_print_setup1_activate - Sun, 01 Aug 1999 03:04:00 GMT - + print_setup_menu GNOMEUIINFO_MENU_PRINT_SETUP_ITEM @@ -132,12 +112,7 @@ GtkPixmapMenuItem - exit1 - - activate - on_exit1_activate - Sun, 01 Aug 1999 03:04:00 GMT - + exit_menu GNOMEUIINFO_MENU_EXIT_ITEM @@ -145,32 +120,22 @@ GtkMenuItem - edit1 + edit_menu GNOMEUIINFO_MENU_EDIT_TREE GtkMenu - edit1_menu + edit_menu_menu GtkPixmapMenuItem - replace1 - - activate - on_replace1_activate - Sun, 01 Aug 1999 03:04:00 GMT - + replace_menu GNOMEUIINFO_MENU_FIND_ITEM GtkPixmapMenuItem - find_again1 - - activate - on_find_again1_activate - Sun, 01 Aug 1999 03:04:00 GMT - + find_again_menu GNOMEUIINFO_MENU_FIND_AGAIN_ITEM @@ -182,12 +147,7 @@ GtkPixmapMenuItem - properties1 - - activate - on_properties1_activate - Sun, 01 Aug 1999 03:04:00 GMT - + properties_menu GNOMEUIINFO_MENU_PROPERTIES_ITEM @@ -195,33 +155,23 @@ GtkMenuItem - view1 + view_menu GNOMEUIINFO_MENU_VIEW_TREE GtkMenu - view1_menu + view_menu_menu GtkMenuItem - larger1 - - activate - on_larger1_activate - Sun, 01 Aug 1999 03:20:39 GMT - + larger_menu False GtkMenuItem - smaller1 - - activate - on_smaller1_activate - Sun, 01 Aug 1999 03:21:07 GMT - + smaller_menu False @@ -230,21 +180,16 @@ GtkMenuItem - settings1 + settings_menu GNOMEUIINFO_MENU_SETTINGS_TREE GtkMenu - settings1_menu + settings_menu_menu GtkPixmapMenuItem - preferences1 - - activate - on_preferences1_activate - Sun, 01 Aug 1999 03:04:00 GMT - + preferences_menu GNOMEUIINFO_MENU_PREFERENCES_ITEM @@ -252,21 +197,16 @@ GtkMenuItem - help1 + help_menu GNOMEUIINFO_MENU_HELP_TREE GtkMenu - help1_menu + help_menu_menu GtkPixmapMenuItem - about1 - - activate - on_about1_activate - Sun, 01 Aug 1999 03:04:00 GMT - + about_menu GNOMEUIINFO_MENU_ABOUT_ITEM