X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=pdf%2Fxpdf%2Fgpdf.cc;h=05bdad905876f017db24918243fe1aad24710722;hb=e4328aef245464741c6d742bfc5aef4ee579ef23;hp=5fc249eb23d4c104fa1dc0602c57166a2c282aa8;hpb=9ba1814ab3299570c586ff83dfa4d2dee44eb9ae;p=evince.git diff --git a/pdf/xpdf/gpdf.cc b/pdf/xpdf/gpdf.cc index 5fc249eb..05bdad90 100644 --- a/pdf/xpdf/gpdf.cc +++ b/pdf/xpdf/gpdf.cc @@ -41,8 +41,6 @@ extern "C" { #include "Error.h" #include "config.h" -#define UNTESTED 0 - poptContext ctx; gint gpdf_debug=0; @@ -57,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; }; @@ -171,8 +170,8 @@ extern "C" { GNOME_PersistStream_load (persist, (GNOME_Stream) gnome_object_corba_objref (GNOME_OBJECT (stream)), &ev); - - + zoom_set (container); + GNOME_Unknown_unref (persist, &ev); CORBA_Object_release (persist, &ev); CORBA_exception_free (&ev); @@ -287,131 +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 - component_view_activated_cb (GnomeViewFrame *view_frame, gboolean activated, gpointer data) - { - Component *component = (Component *) data; - Container *container = component->container; - - if (activated) { - /* - * If the View is requesting to be activated, then we - * check whether or not there is already an active - * View. - */ - if (container->active_view_frame != NULL) { - g_warning ("View requested to be activated but there is already " - "an active View!\n"); - return; - } - - /* - * Otherwise, uncover it so that it can receive - * events, and set it as the active View. - */ - gnome_view_frame_set_covered (view_frame, FALSE); - container->active_view_frame = view_frame; - } else { - /* - * If the View is asking to be deactivated, always - * oblige. We may have already deactivated it (see - * user_activation_request_cb), but there's no harm in - * doing it again. There is always the possibility - * that a View will ask to be deactivated when we have - * not told it to deactivate itself, and that is - * why we cover the view here. - */ - gnome_view_frame_set_covered (view_frame, TRUE); - - if (view_frame == container->active_view_frame) - container->active_view_frame = NULL; - } - } - - static void - component_user_context_cb (GnomeViewFrame *view_frame, gpointer data) - { - Component *component = (Component *) data; - char *executed_verb; - GList *l; - - /* - * See if the remote GnomeEmbeddable supports any verbs at - * all. - */ - l = gnome_client_site_get_verbs (component->client_site); - if (l == NULL) - return; - gnome_client_site_free_verbs (l); - - /* - * Popup the verb popup and execute the chosen verb. This - * function saves us the work of creating the menu, connecting - * the callback, and executing the verb on the remove - * GnomeView. We could implement all this functionality - * ourselves if we wanted. - */ - executed_verb = gnome_view_frame_popup_verbs (view_frame); - - g_free (executed_verb); } } @@ -441,46 +329,18 @@ 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. - * After the user double clicks on the component, our signal - * callback (compoennt_user_activate_request_cb()) asks the - * component to activate itself (see - * gnome_view_frame_view_activate()). The component can then - * choose to either accept or refuse activation. When an - * embedded component notifies us of its decision to change - * its activation state, the "view_activated" signal is - * emitted from the view frame. It is at that point that we - * actually remove the cover so that events can get through. + * Show the component. */ - gtk_signal_connect (GTK_OBJECT (view_frame), "view_activated", - GTK_SIGNAL_FUNC (component_view_activated_cb), component); + gtk_scrolled_window_add_with_viewport (container->scroll, view_widget); /* - * The "user_context" signal is emitted when the user right - * clicks on the wrapper. We use it to pop up a verb menu. + * Activate it ( get it to merge menus etc. ) */ - gtk_signal_connect (GTK_OBJECT (view_frame), "user_context", - GTK_SIGNAL_FUNC (component_user_context_cb), component); + gnome_view_frame_view_activate (view_frame); - /* - * Show the component. - */ - gtk_widget_show_all (view_widget); + gtk_widget_show_all (GTK_WIDGET (container->scroll)); } static GnomeObjectClient * @@ -494,7 +354,7 @@ container_launch_component (GnomeClientSite *client_site, * Launch the component. */ object_server = gnome_object_activate_with_goad_id ( - NULL, component_goad_id, 0, NULL); + NULL, component_goad_id, GOAD_ACTIVATE_SHLIB, NULL); if (object_server == NULL) return NULL; @@ -591,6 +451,35 @@ extern "C" { return component; } + + static void + filenames_dropped (GtkWidget * widget, + GdkDragContext *context, + gint x, + gint y, + GtkSelectionData *selection_data, + guint info, + guint time, + Container *container) + { + GList *names, *tmp_list; + + names = gnome_uri_list_extract_filenames ((char *)selection_data->data); + tmp_list = names; + + while (tmp_list) { + const char *fname = (const char *)tmp_list->data; + + if (fname) { + if (container->view_widget) + container = container_new (fname); + else + open_pdf (container, fname); + } + + tmp_list = g_list_next (tmp_list); + } + } } static void @@ -611,36 +500,48 @@ container_create_menus (Container *container) static void container_create_toolbar (Container *container) { - GnomeUIHandlerMenuItem *toolbar; - -#if UNTESTED > 0 - gnome_ui_handler_create_menubar (container->uih); + GnomeUIHandlerToolbarItem *toolbar; - /* - * Create the basic menus out of UIInfo structures. - */ + gnome_ui_handler_create_toolbar (container->uih, "pdf"); 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 + gnome_ui_handler_toolbar_add_list (container->uih, "/", toolbar); + gnome_ui_handler_toolbar_free_list (toolbar); } static Container * container_new (const char *fname) { Container *container; - + static GtkTargetEntry drag_types[] = + { + { "text/uri-list", 0, 0 }, + }; + static gint n_drag_types = sizeof (drag_types) / sizeof (drag_types [0]); + container = g_new0 (Container, 1); container->app = gnome_app_new ("pdf-viewer", "GNOME PDF viewer"); - container->zoom = 43.0; + container->zoom = 86.0; + + gtk_drag_dest_set (container->app, + GTK_DEST_DEFAULT_ALL, + drag_types, n_drag_types, + GDK_ACTION_COPY); - gtk_window_set_default_size (GTK_WINDOW (container->app), 400, 400); + gtk_signal_connect (GTK_OBJECT(container->app), + "drag_data_received", + GTK_SIGNAL_FUNC(filenames_dropped), (gpointer)container); + + gtk_window_set_default_size (GTK_WINDOW (container->app), 600, 600); 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 @@ -709,4 +610,3 @@ main (int argc, char **argv) return 0; } -