From c34d2ea09a1e1429cada98d8f2baa267ad837f92 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Sun, 22 Aug 1999 21:20:25 +0000 Subject: [PATCH] untested changes for Mig. --- pdf/xpdf/ChangeLog | 4 ++ pdf/xpdf/bonobo-image-x-pdf.cc | 25 +++++++- pdf/xpdf/gpdf.cc | 111 ++++++++++++++++++++++++++++----- 3 files changed, 122 insertions(+), 18 deletions(-) diff --git a/pdf/xpdf/ChangeLog b/pdf/xpdf/ChangeLog index bc9f82c4..a3b727d4 100644 --- a/pdf/xpdf/ChangeLog +++ b/pdf/xpdf/ChangeLog @@ -1,3 +1,7 @@ +1999-08-22 Michael Meeks + + * bonobo-image-x-pdf.cc: Add zoom. + 1999-08-19 Michael Meeks * PDFDoc.cc: Altered to read / write lines. diff --git a/pdf/xpdf/bonobo-image-x-pdf.cc b/pdf/xpdf/bonobo-image-x-pdf.cc index 5c452ee6..678a7242 100644 --- a/pdf/xpdf/bonobo-image-x-pdf.cc +++ b/pdf/xpdf/bonobo-image-x-pdf.cc @@ -40,6 +40,7 @@ extern "C" { #include "BonoboStream.h" #define PDF_DEBUG 0 +#define UNTESTED 0 GBool printCommands = gFalse; @@ -450,7 +451,12 @@ view_create_menus (view_data_t *view_data) N_("Last"), N_("View the last page"), -1, GNOME_UI_HANDLER_PIXMAP_NONE, NULL, 0, (GdkModifierType)0, page_last_cb, (gpointer)view_data); - +#if UNTESTED > 0 + gnome_ui_handler_toolbar_new_item (uih, "/First", GNOME_UI_HANDLER_MENU_ITEM, + N_("First"), N_("View the first page"), -1, + GNOME_UI_HANDLER_PIXMAP_STOCK, GNOME_STOCK_PIXMAP_FIRST, + 0, (GdkModifierType)0, page_first_cb, (gpointer)view_data); +#endif } @@ -519,10 +525,24 @@ extern "C" { { view_data_t *view_data = (view_data_t *) data; + g_return_if_fail (view_data != NULL); + *desired_width = view_data->w; *desired_height = view_data->h; } + static void + view_zoom_query (GnomeView *view, gdouble new_zoom, gpointer data) + { + view_data_t *view_data = (view_data_t *) data; + + g_return_if_fail (view_data != NULL); + + view_data->zoom = new_zoom; + + redraw_view_all (view_data); + } + static void realize_drawing_areas (bed_t *bed) { @@ -618,6 +638,9 @@ view_factory (GnomeEmbeddable *embeddable, gtk_signal_connect (GTK_OBJECT (view), "size_query", GTK_SIGNAL_FUNC (view_size_query), view_data); + gtk_signal_connect (GTK_OBJECT (view), "set_zoom_factor", + GTK_SIGNAL_FUNC (view_zoom_query), view_data); + bed->views = g_list_prepend (bed->views, view_data); /* Verb handling */ diff --git a/pdf/xpdf/gpdf.cc b/pdf/xpdf/gpdf.cc index 37112ae7..8dcdd6a5 100644 --- a/pdf/xpdf/gpdf.cc +++ b/pdf/xpdf/gpdf.cc @@ -41,6 +41,8 @@ extern "C" { #include "Error.h" #include "config.h" +#define UNTESTED 0 + poptContext ctx; gint gpdf_debug=0; @@ -50,25 +52,29 @@ const struct poptOption gpdf_popt_options [] = { { NULL, '\0', 0, NULL, 0 } }; +typedef struct _Component Component; +typedef struct _Container Container; /* NB. there is a 1 to 1 Container -> Component mapping, this is due to how much MDI sucks; unutterably */ -typedef struct { - GnomeContainer *container; - GnomeUIHandler *uih; - - GnomeViewFrame *active_view_frame; - - GtkWidget *app; - GtkWidget *view_widget; -} Container; +struct _Container { + GnomeContainer *container; + GnomeUIHandler *uih; + + GnomeViewFrame *active_view_frame; + + GtkWidget *app; + GtkWidget *view_widget; + Component *component; + gdouble zoom; +}; -typedef struct { +struct _Component { Container *container; GnomeClientSite *client_site; GnomeViewFrame *view_frame; GnomeObjectClient *server; -} Component; +}; GList *containers = NULL; /* @@ -81,6 +87,9 @@ extern "C" { static void container_close_cmd (GtkWidget *widget, Container *container); static void container_exit_cmd (void); static Component *container_activate_component (Container *container, char *component_goad_id); + static void zoom_in_cmd (GtkWidget *widget, Container *container); + static void zoom_out_cmd (GtkWidget *widget, Container *container); + static void zoom_set (Container *container); } /* @@ -95,8 +104,28 @@ static GnomeUIInfo container_file_menu [] = { GNOMEUIINFO_END }; +static GnomeUIInfo container_menu_zoom [] = { + { GNOME_APP_UI_ITEM, N_("_Zoom in"), + N_("Increase the size of objects in the PDF"), + NULL, zoom_in_cmd }, + { GNOME_APP_UI_ITEM, N_("_Zoom out"), + N_("Decrease the size of objects in the PDF"), + zoom_out_cmd }, + GNOMEUIINFO_END +}; + static GnomeUIInfo container_main_menu [] = { GNOMEUIINFO_MENU_FILE_TREE (container_file_menu), + { GNOME_APP_UI_SUBTREE, N_("_Zoom"), NULL, container_menu_zoom }, + GNOMEUIINFO_END +}; + +static GnomeUIInfo container_toolbar [] = { + GNOMEUIINFO_ITEM_STOCK ( + N_("Open"), N_("Opens an existing workbook"), + container_open_cmd, GNOME_STOCK_PIXMAP_OPEN), + + GNOMEUIINFO_SEPARATOR, GNOMEUIINFO_END }; @@ -141,6 +170,8 @@ extern "C" { GNOME_PersistStream_load (persist, (GNOME_Stream) gnome_object_corba_objref (GNOME_OBJECT (stream)), &ev); + + GNOME_Unknown_unref (persist, &ev); CORBA_Object_release (persist, &ev); @@ -239,6 +270,35 @@ extern "C" { container_destroy ((Container *)containers->data); } + /* + * Enforces the containers zoom factor. + */ + static void + zoom_set (Container *container) + { + g_return_if_fail (container != NULL); + g_return_if_fail (container->component != NULL); + + gnome_view_frame_set_zoom_factor (container->component->view_frame, + container->zoom); + } + + static void + zoom_in_cmd (GtkWidget *widget, Container *container) + { + g_return_if_fail (container != NULL); + container->zoom *= 1.4; + zoom_set (container); + } + + static void + zoom_out_cmd (GtkWidget *widget, Container *container) + { + g_return_if_fail (container != NULL); + container->zoom /= 1.4; + zoom_set (container); + } + static void component_user_activate_request_cb (GnomeViewFrame *view_frame, gpointer data) { @@ -380,6 +440,7 @@ container_set_view (Container *container, Component *component) */ view_widget = gnome_view_frame_get_wrapper (view_frame); container->view_widget = view_widget; + container->component = component; /* gtk_box_pack_start (GTK_BOX (container->app), view_widget, FALSE, FALSE, 5);*/ gnome_app_set_contents (GNOME_APP (container->app), view_widget); @@ -547,6 +608,23 @@ container_create_menus (Container *container) gnome_ui_handler_menu_free_list (menu_list); } +static void +container_create_toolbar (Container *container) +{ + GnomeUIHandlerMenuItem *toolbar; + +#if UNTESTED > 0 + gnome_ui_handler_create_menubar (container->uih); + + /* + * Create the basic menus out of UIInfo structures. + */ + toolbar = gnome_ui_handler_toolbar_parse_uiinfo_list_with_data (container_toolbar, container); + gnome_ui_handler_toolbar_add_list (container->uih, "/", menu_list); + gnome_ui_handler_toolbar_free_list (menu_list); +#endif +} + static Container * container_new (const char *fname) { @@ -554,8 +632,9 @@ container_new (const char *fname) container = g_new0 (Container, 1); - container->app = gnome_app_new ("pdf-viewer", - "GNOME PDF viewer"); + container->app = gnome_app_new ("pdf-viewer", + "GNOME PDF viewer"); + container->zoom = 43.0; gtk_window_set_default_size (GTK_WINDOW (container->app), 400, 400); gtk_window_set_policy (GTK_WINDOW (container->app), TRUE, TRUE, FALSE); @@ -572,10 +651,8 @@ container_new (const char *fname) container->uih = gnome_ui_handler_new (); gnome_ui_handler_set_app (container->uih, GNOME_APP (container->app)); - /* - * Create the menus. - */ - container_create_menus (container); + container_create_menus (container); + container_create_toolbar (container); gtk_widget_show_all (container->app); -- 2.43.5