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)
{
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)
{
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);
}
}
w, h);
view_data->pixmap = pixmap;
+ configure_size (view_data);
}
static gboolean
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);
}
/* 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;
};
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
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.
/*
* 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 *
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
}
containers = g_list_append (containers, container);
+ zoom_set (container);
gtk_widget_show_all (container->app);
return 0;
}
-