From 2164227e7574c89d1a03b808ec525622d42966c2 Mon Sep 17 00:00:00 2001 From: Michael Meeks Date: Mon, 23 Aug 1999 22:10:46 +0000 Subject: [PATCH] Auto activate, Scrolled panel, functioning zoom. Auto activate, Scrolled panel, functioning zoom. --- pdf/xpdf/bonobo-image-x-pdf.cc | 26 +++++---- pdf/xpdf/gpdf.cc | 99 ++++++++++------------------------ 2 files changed, 43 insertions(+), 82 deletions(-) diff --git a/pdf/xpdf/bonobo-image-x-pdf.cc b/pdf/xpdf/bonobo-image-x-pdf.cc index ca0dd664..d89d665b 100644 --- a/pdf/xpdf/bonobo-image-x-pdf.cc +++ b/pdf/xpdf/bonobo-image-x-pdf.cc @@ -132,6 +132,15 @@ redraw_view (view_data_t *view_data, GdkRectangle *rect) rect->height); } +static void +configure_size (view_data_t *view_data) +{ + gtk_widget_set_usize ( + view_data->drawing_area, + view_data->w, + view_data->h); +} + static void render_page (view_data_t *view_data) { @@ -160,15 +169,6 @@ redraw_view_all (view_data_t *view_data) gtk_widget_queue_draw (GTK_WIDGET (view_data->drawing_area)); } -static void -configure_size (view_data_t *view_data) -{ - gtk_widget_set_usize ( - view_data->drawing_area, - view_data->w, - view_data->h); -} - static void redraw_all (bed_t *bed) { @@ -177,7 +177,6 @@ redraw_all (bed_t *bed) for (l = bed->views; l; l = l->next) { GdkRectangle rect; view_data_t *view_data = (view_data_t *)l->data; - configure_size (view_data); redraw_view_all (view_data); } } @@ -342,6 +341,7 @@ extern "C" { w, h); view_data->pixmap = pixmap; + configure_size (view_data); } static gboolean @@ -568,8 +568,12 @@ extern "C" { g_return_if_fail (view_data != NULL); - view_data->zoom = new_zoom; + /* The rational behind this is that the _entire_ page is allocated + regardless of viewport size, so you _really_ don't want it too big ! */ + g_return_if_fail (new_zoom > 10.0); + g_return_if_fail (new_zoom < 180.0); + view_data->zoom = new_zoom; redraw_view_all (view_data); } diff --git a/pdf/xpdf/gpdf.cc b/pdf/xpdf/gpdf.cc index e6192944..ae4ca75f 100644 --- a/pdf/xpdf/gpdf.cc +++ b/pdf/xpdf/gpdf.cc @@ -55,14 +55,15 @@ typedef struct _Container Container; /* NB. there is a 1 to 1 Container -> Component mapping, this is due to how much MDI sucks; unutterably */ struct _Container { - GnomeContainer *container; - GnomeUIHandler *uih; + GnomeContainer *container; + GnomeUIHandler *uih; - GnomeViewFrame *active_view_frame; + GnomeViewFrame *active_view_frame; - GtkWidget *app; - GtkWidget *view_widget; - Component *component; + GtkWidget *app; + GtkScrolledWindow *scroll; + GtkWidget *view_widget; + Component *component; gdouble zoom; }; @@ -285,62 +286,20 @@ extern "C" { zoom_in_cmd (GtkWidget *widget, Container *container) { g_return_if_fail (container != NULL); - container->zoom *= 1.4; - zoom_set (container); + if (container->zoom < 180.0) { + 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) - { - Component *component = (Component *) data; - Container *container = component->container; - - /* - * If there is a - * If there is already an active View, deactivate it. - */ - if (container->active_view_frame != NULL) { - /* - * This just sends a notice to the embedded View that - * it is being deactivated. We will also forcibly - * cover it so that it does not receive any Gtk - * events. - */ - gnome_view_frame_view_deactivate (container->active_view_frame); - - /* - * Here we manually cover it if it hasn't acquiesced. - * If it has consented to be deactivated, then it will - * already have notified us that it is inactive, and - * we will have covered it and set active_view_frame - * to NULL. Which is why this check is here. - */ - if (container->active_view_frame != NULL) - gnome_view_frame_set_covered (container->active_view_frame, TRUE); - - container->active_view_frame = NULL; + if (container->zoom > 10.0) { + container->zoom /= 1.4; + zoom_set (container); } - - /* - * Activate the View which the user clicked on. This just - * sends a request to the embedded View to activate itself. - * When it agrees to be activated, it will notify its - * ViewFrame, and our view_activated_cb callback will be - * called. - * - * We do not uncover the View here, because it may not wish to - * be activated, and so we wait until it notifies us that it - * has been activated to uncover it. - */ - gnome_view_frame_view_activate (view_frame); } static void @@ -439,19 +398,6 @@ 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); - /* - * The "user_activate" signal will be emitted when the user - * double clicks on the "cover". The cover is a transparent - * window which sits on top of the component and keeps any - * events (mouse, keyboard) from reaching it. When the user - * double clicks on the cover, the container (that's us) - * can choose to activate the component. - */ - gtk_signal_connect (GTK_OBJECT (view_frame), "user_activate", - GTK_SIGNAL_FUNC (component_user_activate_request_cb), component); /* * In-place activation of a component is a two-step process. @@ -478,7 +424,14 @@ container_set_view (Container *container, Component *component) /* * Show the component. */ - gtk_widget_show_all (view_widget); + gtk_scrolled_window_add_with_viewport (container->scroll, view_widget); + + /* + * Activate it ( get it to merge menus etc. + */ + gnome_view_frame_view_activate (view_frame); + + gtk_widget_show_all (GTK_WIDGET (container->scroll)); } static GnomeObjectClient * @@ -626,13 +579,17 @@ container_new (const char *fname) container->app = gnome_app_new ("pdf-viewer", "GNOME PDF viewer"); - container->zoom = 43.0; + container->zoom = 86.0; gtk_window_set_default_size (GTK_WINDOW (container->app), 400, 400); gtk_window_set_policy (GTK_WINDOW (container->app), TRUE, TRUE, FALSE); container->container = gnome_container_new (); container->view_widget = NULL; + container->scroll = GTK_SCROLLED_WINDOW (gtk_scrolled_window_new (NULL, NULL)); + gtk_scrolled_window_set_policy (container->scroll, GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + gnome_app_set_contents (GNOME_APP (container->app), GTK_WIDGET (container->scroll)); /* * Create the GnomeUIHandler object which will be used to @@ -655,6 +612,7 @@ container_new (const char *fname) } containers = g_list_append (containers, container); + zoom_set (container); gtk_widget_show_all (container->app); @@ -701,4 +659,3 @@ main (int argc, char **argv) return 0; } - -- 2.43.5