]> www.fi.muni.cz Git - evince.git/commitdiff
Close / Exit, About box,
authorMichael Meeks <mmeeks@src.gnome.org>
Tue, 3 Aug 1999 20:15:45 +0000 (20:15 +0000)
committerMichael Meeks <mmeeks@src.gnome.org>
Tue, 3 Aug 1999 20:15:45 +0000 (20:15 +0000)
Close / Exit,
About box,

pdf/xpdf/ChangeLog
pdf/xpdf/Makefile.in
pdf/xpdf/about.glade [new file with mode: 0644]
pdf/xpdf/gpdf.cc
pdf/xpdf/gpdf.glade

index e564419bf77c16c050c5c292fa5855ffb52e31a1..7684ac15c88ff708db6b1a48f8c4cb42ef8208c4 100644 (file)
@@ -1,6 +1,7 @@
 1999-08-03  Michael Meeks  <michael@imaginator.com>
 
-       * gpdf.cc: Lots of updates.
+       * gpdf.cc: Lots of updates, gives up on logging changes
+       ( for a bit. )
 
 1999-08-02  Michael Meeks  <michael@edenproject.org>
 
index 7ba540bc25b2cf3ffb1b3fde6a6f630a19f51ff5..f15f26ea7a3d543a45f83f1ed728c3f89a425f25 100644 (file)
@@ -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 (file)
index 0000000..51a07d1
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<GTK-Interface>
+
+<project>
+  <name>about</name>
+  <program_name>about</program_name>
+  <directory></directory>
+  <source_directory>src</source_directory>
+  <pixmaps_directory>pixmaps</pixmaps_directory>
+  <language>C</language>
+  <gnome_support>True</gnome_support>
+  <gettext_support>True</gettext_support>
+  <use_widget_names>False</use_widget_names>
+  <output_main_file>True</output_main_file>
+  <output_support_files>True</output_support_files>
+  <output_build_files>True</output_build_files>
+  <backup_source_files>True</backup_source_files>
+  <main_source_file>interface.c</main_source_file>
+  <main_header_file>interface.h</main_header_file>
+  <handler_source_file>callbacks.c</handler_source_file>
+  <handler_header_file>callbacks.h</handler_header_file>
+  <support_source_file>support.c</support_source_file>
+  <support_header_file>support.h</support_header_file>
+  <translatable_strings_file></translatable_strings_file>
+</project>
+
+<widget>
+  <class>GnomeAbout</class>
+  <name>about</name>
+  <copyright></copyright>
+  <authors>Derek B. Noonburg,
+Michael Meeks,
+Miguel de Icaza
+</authors>
+  <comments>This software is available subject to the terms of the GPL.</comments>
+</widget>
+
+</GTK-Interface>
index 7da47d58497c5b47c57b04fc6cea098dfc0844d7..bba767ee7a5d857924d7c157637ea73298b1061d 100644 (file)
@@ -8,7 +8,6 @@
 //
 //========================================================================
 
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <stddef.h>
@@ -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 {
index 1d71de570ef5e6412f8e7d38e8228021b331e5a3..1ce942a371731db4198b17400bcace2dbf85bffa 100644 (file)
 
        <widget>
          <class>GtkMenuItem</class>
-         <name>file1</name>
+         <name>file_menu</name>
          <stock_item>GNOMEUIINFO_MENU_FILE_TREE</stock_item>
 
          <widget>
            <class>GtkMenu</class>
-           <name>file1_menu</name>
+           <name>file_menu_menu</name>
 
            <widget>
              <class>GtkPixmapMenuItem</class>
-             <name>open1</name>
-             <signal>
-               <name>activate</name>
-               <handler>on_open1_activate</handler>
-               <last_modification_time>Sun, 01 Aug 1999 03:04:00 GMT</last_modification_time>
-             </signal>
+             <name>open_menu</name>
              <stock_item>GNOMEUIINFO_MENU_OPEN_ITEM</stock_item>
            </widget>
 
            <widget>
              <class>GtkPixmapMenuItem</class>
-             <name>close</name>
-             <signal>
-               <name>activate</name>
-               <handler>on_close_activate</handler>
-               <last_modification_time>Sun, 01 Aug 1999 23:33:35 GMT</last_modification_time>
-             </signal>
+             <name>close_menu</name>
              <stock_item>GNOMEUIINFO_MENU_CLOSE_ITEM</stock_item>
            </widget>
 
 
            <widget>
              <class>GtkPixmapMenuItem</class>
-             <name>print1</name>
-             <signal>
-               <name>activate</name>
-               <handler>on_print1_activate</handler>
-               <last_modification_time>Sun, 01 Aug 1999 03:04:00 GMT</last_modification_time>
-             </signal>
+             <name>print_menu</name>
              <stock_item>GNOMEUIINFO_MENU_PRINT_ITEM</stock_item>
            </widget>
 
            <widget>
              <class>GtkPixmapMenuItem</class>
-             <name>print_setup1</name>
-             <signal>
-               <name>activate</name>
-               <handler>on_print_setup1_activate</handler>
-               <last_modification_time>Sun, 01 Aug 1999 03:04:00 GMT</last_modification_time>
-             </signal>
+             <name>print_setup_menu</name>
              <stock_item>GNOMEUIINFO_MENU_PRINT_SETUP_ITEM</stock_item>
            </widget>
 
 
            <widget>
              <class>GtkPixmapMenuItem</class>
-             <name>exit1</name>
-             <signal>
-               <name>activate</name>
-               <handler>on_exit1_activate</handler>
-               <last_modification_time>Sun, 01 Aug 1999 03:04:00 GMT</last_modification_time>
-             </signal>
+             <name>exit_menu</name>
              <stock_item>GNOMEUIINFO_MENU_EXIT_ITEM</stock_item>
            </widget>
          </widget>
 
        <widget>
          <class>GtkMenuItem</class>
-         <name>edit1</name>
+         <name>edit_menu</name>
          <stock_item>GNOMEUIINFO_MENU_EDIT_TREE</stock_item>
 
          <widget>
            <class>GtkMenu</class>
-           <name>edit1_menu</name>
+           <name>edit_menu_menu</name>
 
            <widget>
              <class>GtkPixmapMenuItem</class>
-             <name>replace1</name>
-             <signal>
-               <name>activate</name>
-               <handler>on_replace1_activate</handler>
-               <last_modification_time>Sun, 01 Aug 1999 03:04:00 GMT</last_modification_time>
-             </signal>
+             <name>replace_menu</name>
              <stock_item>GNOMEUIINFO_MENU_FIND_ITEM</stock_item>
            </widget>
 
            <widget>
              <class>GtkPixmapMenuItem</class>
-             <name>find_again1</name>
-             <signal>
-               <name>activate</name>
-               <handler>on_find_again1_activate</handler>
-               <last_modification_time>Sun, 01 Aug 1999 03:04:00 GMT</last_modification_time>
-             </signal>
+             <name>find_again_menu</name>
              <stock_item>GNOMEUIINFO_MENU_FIND_AGAIN_ITEM</stock_item>
            </widget>
 
 
            <widget>
              <class>GtkPixmapMenuItem</class>
-             <name>properties1</name>
-             <signal>
-               <name>activate</name>
-               <handler>on_properties1_activate</handler>
-               <last_modification_time>Sun, 01 Aug 1999 03:04:00 GMT</last_modification_time>
-             </signal>
+             <name>properties_menu</name>
              <stock_item>GNOMEUIINFO_MENU_PROPERTIES_ITEM</stock_item>
            </widget>
          </widget>
 
        <widget>
          <class>GtkMenuItem</class>
-         <name>view1</name>
+         <name>view_menu</name>
          <stock_item>GNOMEUIINFO_MENU_VIEW_TREE</stock_item>
 
          <widget>
            <class>GtkMenu</class>
-           <name>view1_menu</name>
+           <name>view_menu_menu</name>
 
            <widget>
              <class>GtkMenuItem</class>
-             <name>larger1</name>
-             <signal>
-               <name>activate</name>
-               <handler>on_larger1_activate</handler>
-               <last_modification_time>Sun, 01 Aug 1999 03:20:39 GMT</last_modification_time>
-             </signal>
+             <name>larger_menu</name>
              <label>Larger</label>
              <right_justify>False</right_justify>
            </widget>
 
            <widget>
              <class>GtkMenuItem</class>
-             <name>smaller1</name>
-             <signal>
-               <name>activate</name>
-               <handler>on_smaller1_activate</handler>
-               <last_modification_time>Sun, 01 Aug 1999 03:21:07 GMT</last_modification_time>
-             </signal>
+             <name>smaller_menu</name>
              <label>smaller</label>
              <right_justify>False</right_justify>
            </widget>
 
        <widget>
          <class>GtkMenuItem</class>
-         <name>settings1</name>
+         <name>settings_menu</name>
          <stock_item>GNOMEUIINFO_MENU_SETTINGS_TREE</stock_item>
 
          <widget>
            <class>GtkMenu</class>
-           <name>settings1_menu</name>
+           <name>settings_menu_menu</name>
 
            <widget>
              <class>GtkPixmapMenuItem</class>
-             <name>preferences1</name>
-             <signal>
-               <name>activate</name>
-               <handler>on_preferences1_activate</handler>
-               <last_modification_time>Sun, 01 Aug 1999 03:04:00 GMT</last_modification_time>
-             </signal>
+             <name>preferences_menu</name>
              <stock_item>GNOMEUIINFO_MENU_PREFERENCES_ITEM</stock_item>
            </widget>
          </widget>
 
        <widget>
          <class>GtkMenuItem</class>
-         <name>help1</name>
+         <name>help_menu</name>
          <stock_item>GNOMEUIINFO_MENU_HELP_TREE</stock_item>
 
          <widget>
            <class>GtkMenu</class>
-           <name>help1_menu</name>
+           <name>help_menu_menu</name>
 
            <widget>
              <class>GtkPixmapMenuItem</class>
-             <name>about1</name>
-             <signal>
-               <name>activate</name>
-               <handler>on_about1_activate</handler>
-               <last_modification_time>Sun, 01 Aug 1999 03:04:00 GMT</last_modification_time>
-             </signal>
+             <name>about_menu</name>
              <stock_item>GNOMEUIINFO_MENU_ABOUT_ITEM</stock_item>
            </widget>
          </widget>