From a5156c1efea5f8d06bcb088db7890db7a9a7c5f9 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Sun, 1 Aug 1999 21:47:54 +0000 Subject: [PATCH] Begginings of glade GUI, more cleans. --- pdf/xpdf/ChangeLog | 11 ++ pdf/xpdf/Makefile.in | 2 +- pdf/xpdf/gpdf.cc | 114 ++++++------- pdf/xpdf/gpdf.glade | 385 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 447 insertions(+), 65 deletions(-) create mode 100644 pdf/xpdf/gpdf.glade diff --git a/pdf/xpdf/ChangeLog b/pdf/xpdf/ChangeLog index 96cf7323..8dc28958 100644 --- a/pdf/xpdf/ChangeLog +++ b/pdf/xpdf/ChangeLog @@ -1,3 +1,14 @@ +1999-08-01 Michael Meeks + + * Makefile.in: Added -lglade, -lglade-gnome & Added -Wall + + * gpdf.glade: Added. + + * gpdf.cc (loadFile): Add typecast. + Remove all DOC_ROOT's magic numbers. + Add glade GUI, + Lots of other bits ... + 1999-07-29 Michael Meeks * GOutputDev.cc: Hahaaa... the bug ! :-) diff --git a/pdf/xpdf/Makefile.in b/pdf/xpdf/Makefile.in index e7934a60..7ba540bc 100644 --- a/pdf/xpdf/Makefile.in +++ b/pdf/xpdf/Makefile.in @@ -15,7 +15,7 @@ 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) -g `gnome-config --cflags gnomeui` -I$(srcdir) @Xpm_CFLAGS@ @X_CFLAGS@ +CXXFLAGS = @CXXFLAGS@ @DEFS@ @OPTIONS@ -I$(GOOSRCDIR) -I$(LTKSRCDIR) -Wall -g `gnome-config --cflags gnomeui` -lglade -lglade-gnome -I$(srcdir) @Xpm_CFLAGS@ @X_CFLAGS@ XLIBS = @Xpm_LIBS@ @X_PRE_LIBS@ @X_LIBS@ -lX11 @X_EXTRA_LIBS@ OTHERLIBS = @LIBS@ diff --git a/pdf/xpdf/gpdf.cc b/pdf/xpdf/gpdf.cc index adcdc933..6b1485a0 100644 --- a/pdf/xpdf/gpdf.cc +++ b/pdf/xpdf/gpdf.cc @@ -15,6 +15,7 @@ #include #define GString G_String #include +#include #undef GString #include "gtypes.h" #include "GString.h" @@ -37,51 +38,31 @@ #include "Error.h" #include "config.h" +#define GPDF_GLADE_DIR "/opt/gnome/src/xpdf/xpdf" + GBool printCommands = gFalse; gint gpdf_debug=1; poptContext ctx; #define DOC_KEY "xpdf_doc_key" -#define DOC_ROOT_MAGIC 0xad3f556d struct DOC_ROOT { - guint32 magic; GString *title; PDFDoc *pdf; - GtkWidget *toplevel; - GtkWidget *table; - GnomeAppBar *appbar; GtkDrawingArea *area; GdkPixmap *pixmap; OutputDev *out; GdkColor paper; GtkScrolledWindow *scroll; + GtkWidget *mainframe; + GladeXML *gui; }; -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") }, { NULL, '\0', 0, NULL, 0 } }; - -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 //------------------------------------------------------------------------ @@ -94,7 +75,6 @@ doc_config_event (GtkWidget *widget, void *ugly) doc = (DOC_ROOT *)gtk_object_get_data (GTK_OBJECT (widget), DOC_KEY); g_return_val_if_fail (doc, FALSE); - g_return_val_if_fail (doc->magic == DOC_ROOT_MAGIC, FALSE); if (doc->pixmap) gdk_pixmap_unref(doc->pixmap); @@ -133,8 +113,6 @@ doc_config_event (GtkWidget *widget, void *ugly) return TRUE; } -GdkGC *magic_black; - static gint doc_redraw_event (GtkWidget *widget, GdkEventExpose *event) { @@ -145,14 +123,10 @@ doc_redraw_event (GtkWidget *widget, GdkEventExpose *event) doc = (DOC_ROOT *)gtk_object_get_data (GTK_OBJECT (widget), DOC_KEY); g_return_val_if_fail (doc != NULL, FALSE); - g_return_val_if_fail (doc->magic == DOC_ROOT_MAGIC, FALSE); if (doc->out && doc->pdf) { - GtkStyle *style = gtk_widget_get_default_style(); printf ("There are %d pages\n", doc->pdf->getNumPages()); - magic_black = widget->style->black_gc; - doc->pdf->displayPage(doc->out, 1, 86, 0, gTrue); gdk_draw_pixmap(widget->window, widget->style->fg_gc[GTK_WIDGET_STATE (widget)], @@ -166,51 +140,60 @@ doc_redraw_event (GtkWidget *widget, GdkEventExpose *event) return FALSE; } +static PDFDoc * +getPDF (GString *fname) +{ + PDFDoc *pdf; + pdf = new PDFDoc(fname); + if (!pdf->isOk()) { + delete pdf; + return NULL; + } + g_return_val_if_fail (pdf->getCatalog(), NULL); + return pdf; +} + + static GBool -loadFile(GString *fileName) +loadPDF(GString *fileName) { DOC_ROOT *doc = new DOC_ROOT(); - char s[20]; - char *p; + GtkVBox *pane; + GtkAdjustment *hadj, *vadj; - doc->magic = DOC_ROOT_MAGIC; // open PDF file - doc->pdf = new PDFDoc(fileName); - if (!doc->pdf->isOk()) { - delete doc->pdf; + doc->pdf = getPDF (fileName); + if (!doc->pdf) { delete doc; return gFalse; } - g_assert (doc->pdf->getCatalog()); - - 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->gui = glade_xml_new (GPDF_GLADE_DIR "/gpdf.glade", NULL); + if (!doc->gui || + !(doc->mainframe = glade_xml_get_widget (doc->gui, "gpdf")) || + !(pane = GTK_VBOX (glade_xml_get_widget (doc->gui, "pane")))) { + printf ("Couldn't find " GPDF_GLADE_DIR "/gpdf.glade\n"); + delete doc->pdf; + delete doc; + return gFalse; + } + doc->pixmap = NULL; doc->area = GTK_DRAWING_AREA (gtk_drawing_area_new ()); + gtk_object_set_data (GTK_OBJECT (doc->area), DOC_KEY, doc); gtk_signal_connect (GTK_OBJECT (doc->area),"configure_event", (GtkSignalFunc) doc_config_event, doc); gtk_signal_connect (GTK_OBJECT (doc->area), "expose_event", (GtkSignalFunc) doc_redraw_event, doc); - 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); + hadj = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, 1, 0.01, 0.1, 2)); + vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0, 0, 1, 0.01, 0.1, 2)); + doc->scroll = GTK_SCROLLED_WINDOW (gtk_scrolled_window_new (hadj, vadj)); + gtk_scrolled_window_add_with_viewport (doc->scroll, GTK_WIDGET (doc->area)); + gtk_box_pack_start (GTK_BOX (pane), GTK_WIDGET (doc->scroll), TRUE, TRUE, 0); + gtk_widget_show_all (doc->mainframe); return gTrue; } @@ -250,12 +233,13 @@ loadFile(GString *fileName) win->setBusyCursor(gFalse); }*/ + int main (int argc, char *argv []) { char **view_files = NULL; - int lp; - + int i; + gnome_init_with_popt_table ( "gpdf", "0.1", argc, argv, gpdf_popt_options, 0, &ctx); @@ -264,13 +248,15 @@ main (int argc, char *argv []) initParams (xpdfConfigFile); /* Init font path */ + glade_gnome_init (); + view_files = poptGetArgs (ctx); /* Load files */ if (view_files) { - for (lp=0;view_files[lp];lp++) { - GString *name = new GString (view_files[lp]); - if (!name || !loadFile(name)) - printf ("Error loading '%s'\n", view_files[lp]); + for (i = 0; view_files[i]; i++) { + GString *name = new GString (view_files[i]); + if (!name || !loadPDF (name)) + printf ("Error loading '%s'\n", view_files[i]); } } else { printf ("Need filenames...\n"); diff --git a/pdf/xpdf/gpdf.glade b/pdf/xpdf/gpdf.glade new file mode 100644 index 00000000..91b67d7a --- /dev/null +++ b/pdf/xpdf/gpdf.glade @@ -0,0 +1,385 @@ + + + + + gpdf + gpdf + + src + pixmaps + C + True + True + False + True + True + True + True + interface.c + interface.h + callbacks.c + callbacks.h + support.c + support.h + + + + + GnomeApp + gpdf + 600 + 400 + GNOME PDF viewer + True + False + True + False + + + GnomeDock + GnomeApp:dock + dock1 + + 0 + True + True + + True + + + GnomeDockItem + dockitem1 + 2 + GNOME_DOCK_TOP + 0 + 0 + 0 + False + True + False + True + False + GTK_SHADOW_OUT + + + GtkMenuBar + menubar1 + + + GtkMenuItem + file1 + GNOMEUIINFO_MENU_FILE_TREE + + + GtkMenu + file1_menu + + + GtkPixmapMenuItem + open1 + + activate + on_open1_activate + Sun, 01 Aug 1999 03:04:00 GMT + + GNOMEUIINFO_MENU_OPEN_ITEM + + + + GtkPixmapMenuItem + close1 + + activate + on_close1_activate + Sun, 01 Aug 1999 03:04:00 GMT + + GNOMEUIINFO_MENU_CLOSE_ITEM + + + + GtkMenuItem + separator1 + False + + + + GtkPixmapMenuItem + print1 + + activate + on_print1_activate + Sun, 01 Aug 1999 03:04:00 GMT + + GNOMEUIINFO_MENU_PRINT_ITEM + + + + GtkPixmapMenuItem + print_setup1 + + activate + on_print_setup1_activate + Sun, 01 Aug 1999 03:04:00 GMT + + GNOMEUIINFO_MENU_PRINT_SETUP_ITEM + + + + GtkMenuItem + separator2 + False + + + + GtkPixmapMenuItem + exit1 + + activate + on_exit1_activate + Sun, 01 Aug 1999 03:04:00 GMT + + GNOMEUIINFO_MENU_EXIT_ITEM + + + + + + GtkMenuItem + edit1 + GNOMEUIINFO_MENU_EDIT_TREE + + + GtkMenu + edit1_menu + + + GtkPixmapMenuItem + replace1 + + activate + on_replace1_activate + Sun, 01 Aug 1999 03:04:00 GMT + + GNOMEUIINFO_MENU_FIND_ITEM + + + + GtkPixmapMenuItem + find_again1 + + activate + on_find_again1_activate + Sun, 01 Aug 1999 03:04:00 GMT + + GNOMEUIINFO_MENU_FIND_AGAIN_ITEM + + + + GtkMenuItem + separator5 + False + + + + GtkPixmapMenuItem + properties1 + + activate + on_properties1_activate + Sun, 01 Aug 1999 03:04:00 GMT + + GNOMEUIINFO_MENU_PROPERTIES_ITEM + + + + + + GtkMenuItem + view1 + GNOMEUIINFO_MENU_VIEW_TREE + + + GtkMenu + view1_menu + + + GtkMenuItem + larger1 + + activate + on_larger1_activate + Sun, 01 Aug 1999 03:20:39 GMT + + + False + + + + GtkMenuItem + smaller1 + + activate + on_smaller1_activate + Sun, 01 Aug 1999 03:21:07 GMT + + + False + + + + + + GtkMenuItem + settings1 + GNOMEUIINFO_MENU_SETTINGS_TREE + + + GtkMenu + settings1_menu + + + GtkPixmapMenuItem + preferences1 + + activate + on_preferences1_activate + Sun, 01 Aug 1999 03:04:00 GMT + + GNOMEUIINFO_MENU_PREFERENCES_ITEM + + + + + + GtkMenuItem + help1 + GNOMEUIINFO_MENU_HELP_TREE + + + GtkMenu + help1_menu + + + GtkPixmapMenuItem + about1 + + activate + on_about1_activate + Sun, 01 Aug 1999 03:04:00 GMT + + GNOMEUIINFO_MENU_ABOUT_ITEM + + + + + + + + GnomeDockItem + dockitem2 + 1 + GNOME_DOCK_TOP + 1 + 0 + 0 + False + True + False + False + False + GTK_SHADOW_OUT + + + GtkToolbar + toolbar1 + 1 + GTK_ORIENTATION_HORIZONTAL + GTK_TOOLBAR_BOTH + 16 + GTK_TOOLBAR_SPACE_LINE + GTK_RELIEF_NONE + True + + + GtkButton + Toolbar:button + button2 + Open File + + GNOME_STOCK_PIXMAP_OPEN + + + + GtkButton + Toolbar:button + first + + GNOME_STOCK_PIXMAP_FIRST + + + + GtkButton + Toolbar:button + back + + GNOME_STOCK_PIXMAP_BACK + + + + GtkButton + Toolbar:button + forward + + GNOME_STOCK_PIXMAP_FORWARD + + + + GtkButton + Toolbar:button + last + + GNOME_STOCK_PIXMAP_LAST + + + + GtkButton + Toolbar:button + larger + + GNOME_STOCK_PIXMAP_UP + + + + GtkButton + Toolbar:button + smaller + + GNOME_STOCK_PIXMAP_DOWN + + + + + + GtkVBox + GnomeDock:contents + pane + False + 0 + + + + + GnomeAppBar + GnomeApp:appbar + appbar1 + + 0 + True + True + + True + True + + + + -- 2.43.5