X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=sidebyside;f=pdf%2Fxpdf%2Fgpdf.cc;h=aa44c4eb83c86a32794b101fcd38331f256a05e9;hb=11c2610a62f60a0394c0eea0fede081d9fd678bd;hp=a78a37e176c227526ff4b0fc8aa5199daf696af9;hpb=9c4aa5453d1eaaa13eacb1d44e36c013be9cf3f9;p=evince.git diff --git a/pdf/xpdf/gpdf.cc b/pdf/xpdf/gpdf.cc index a78a37e1..aa44c4eb 100644 --- a/pdf/xpdf/gpdf.cc +++ b/pdf/xpdf/gpdf.cc @@ -3,7 +3,6 @@ * * Author: * Michael Meeks - * */ #include #include @@ -13,11 +12,7 @@ extern "C" { #define GString G_String #include -#if USING_OAF #include -#else -#include -#endif #include #include @@ -41,13 +36,13 @@ 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 { - BonoboContainer *container; - BonoboUIHandler *uih; + BonoboItemContainer *container; + BonoboUIComponent *ui_component; - GtkWidget *app; - GtkWidget *slot; - GtkWidget *view_widget; - Component *component; + GtkWidget *app; + GtkWidget *slot; + GtkWidget *view_widget; + Component *component; }; struct _Component { @@ -69,41 +64,26 @@ extern "C" { static void container_close_cmd (GtkWidget *widget, Container *container); static void container_exit_cmd (void); static void container_about_cmd (GtkWidget *widget, Container *container); + static void container_dump_cmd (GtkWidget *widget, Container *container); static Component *container_activate_component (Container *container, char *component_goad_id); } /* * The menus. */ -static GnomeUIInfo container_file_menu [] = { - GNOMEUIINFO_MENU_OPEN_ITEM (container_open_cmd, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_CLOSE_ITEM(container_close_cmd, NULL), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_EXIT_ITEM (container_exit_cmd, NULL), - GNOMEUIINFO_END -}; +BonoboUIVerb verbs [] = { + BONOBO_UI_UNSAFE_VERB ("FileOpen", container_open_cmd), + BONOBO_UI_UNSAFE_VERB ("FileClose", container_close_cmd), + BONOBO_UI_UNSAFE_VERB ("FileExit", container_exit_cmd), -static GnomeUIInfo container_help_menu [] = { - GNOMEUIINFO_MENU_ABOUT_ITEM(container_about_cmd, NULL), - GNOMEUIINFO_END -}; + BONOBO_UI_UNSAFE_VERB ("HelpAbout", container_about_cmd), -static GnomeUIInfo container_main_menu [] = { - GNOMEUIINFO_MENU_FILE_TREE (container_file_menu), - GNOMEUIINFO_MENU_HELP_TREE (container_help_menu), - GNOMEUIINFO_END -}; + BONOBO_UI_UNSAFE_VERB ("DebugDumpXml", container_dump_cmd), -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 + BONOBO_UI_VERB_END }; + extern "C" { static gboolean open_pdf (Container *container, const char *name) @@ -117,19 +97,16 @@ extern "C" { g_return_val_if_fail (container != NULL, FALSE); g_return_val_if_fail (container->view_widget == NULL, FALSE); -#if USING_OAF - comp = container_activate_component (container, "OAFIID:gpdf_componet:892f2727-e2ec-423c-91ad-6f7b75fec6c8"); + comp = container_activate_component ( + container, "OAFIID:GNOME_XPDF_Embeddable"); -#else - comp = container_activate_component (container, "bonobo-object:application-x-pdf"); -#endif if (!comp || !(object = comp->server)) { gnome_error_dialog (_("Could not launch bonobo object.")); return FALSE; } CORBA_exception_init (&ev); - persist = Bonobo_Unknown_query_interface ( + persist = Bonobo_Unknown_queryInterface ( bonobo_object_corba_objref (BONOBO_OBJECT (object)), "IDL:Bonobo/PersistStream:1.0", &ev); @@ -139,7 +116,7 @@ extern "C" { return FALSE; } - stream = bonobo_stream_fs_open (name, Bonobo_Storage_READ); + stream = bonobo_stream_open (BONOBO_IO_DRIVER_FS, name, Bonobo_Storage_READ, 0); if (stream == NULL) { char *err = g_strconcat (_("Could not open "), name, NULL); @@ -149,7 +126,9 @@ extern "C" { } Bonobo_PersistStream_load (persist, - (Bonobo_Stream) bonobo_object_corba_objref (BONOBO_OBJECT (stream)), &ev); + (Bonobo_Stream) bonobo_object_corba_objref (BONOBO_OBJECT (stream)), + "application/pdf", + &ev); Bonobo_Unknown_unref (persist, &ev); CORBA_Object_release (persist, &ev); @@ -308,6 +287,12 @@ extern "C" { container_destroy ((Container *)containers->data); } +static void +container_dump_cmd (GtkWidget *widget, Container *container) +{ + bonobo_window_dump (BONOBO_WINDOW(container->app), "on demand"); +} + static void container_about_cmd (GtkWidget *widget, Container *container) { @@ -347,9 +332,10 @@ container_set_view (Container *container, Component *component) /* * Create the remote view and the local ViewFrame. */ - view_frame = bonobo_client_site_new_view (component->client_site, - bonobo_object_corba_objref (BONOBO_OBJECT ( - container->uih))); + view_frame = bonobo_client_site_new_view ( + component->client_site, + bonobo_ui_component_get_container (container->ui_component)); + component->view_frame = view_frame; /* @@ -372,9 +358,9 @@ container_set_view (Container *container, Component *component) } static BonoboObjectClient * -container_launch_component (BonoboClientSite *client_site, - BonoboContainer *container, - char *component_goad_id) +container_launch_component (BonoboClientSite *client_site, + BonoboItemContainer *container, + char *component_goad_id) { BonoboObjectClient *object_server; @@ -397,13 +383,6 @@ container_launch_component (BonoboClientSite *client_site, return NULL; } - /* - * The BonoboContainer object maintains a list of the - * ClientSites which it manages. Here we add the new - * ClientSite to that list. - */ - bonobo_container_add (container, BONOBO_OBJECT (client_site)); - return object_server; } @@ -480,33 +459,6 @@ extern "C" { tmp_list = g_list_next (tmp_list); } } - -} - -static void -container_create_menus (Container *container) -{ - BonoboUIHandlerMenuItem *menu_list; - - bonobo_ui_handler_create_menubar (container->uih); - - /* - * Create the basic menus out of UIInfo structures. - */ - menu_list = bonobo_ui_handler_menu_parse_uiinfo_list_with_data (container_main_menu, container); - bonobo_ui_handler_menu_add_list (container->uih, "/", menu_list); - bonobo_ui_handler_menu_free_list (menu_list); -} - -static void -container_create_toolbar (Container *container) -{ - BonoboUIHandlerToolbarItem *toolbar; - - bonobo_ui_handler_create_toolbar (container->uih, "pdf"); - toolbar = bonobo_ui_handler_toolbar_parse_uiinfo_list_with_data (container_toolbar, container); - bonobo_ui_handler_toolbar_add_list (container->uih, "/pdf/", toolbar); - bonobo_ui_handler_toolbar_free_list (toolbar); } static Container * @@ -518,11 +470,12 @@ container_new (const char *fname) { "text/uri-list", 0, 0 }, }; static gint n_drag_types = sizeof (drag_types) / sizeof (drag_types [0]); + BonoboUIContainer *ui_container; container = g_new0 (Container, 1); - container->app = gnome_app_new ("pdf-viewer", - "GNOME PDF viewer"); + container->app = bonobo_window_new ("pdf-viewer", + "GNOME PDF viewer"); gtk_drag_dest_set (container->app, GTK_DEST_DEFAULT_ALL, @@ -537,30 +490,33 @@ container_new (const char *fname) gtk_window_set_default_size (GTK_WINDOW (container->app), 600, 600); gtk_window_set_policy (GTK_WINDOW (container->app), TRUE, TRUE, FALSE); - container->container = bonobo_container_new (); + container->container = bonobo_item_container_new (); container->view_widget = NULL; container->slot = gtk_event_box_new (); gtk_widget_show (container->slot); - gnome_app_set_contents (GNOME_APP (container->app), GTK_WIDGET (container->slot)); + bonobo_window_set_contents (BONOBO_WINDOW(container->app), + GTK_WIDGET (container->slot)); + gtk_widget_show_all (container->slot); gtk_object_set_data (GTK_OBJECT (container->app), "container_data", container); gtk_signal_connect (GTK_OBJECT (container->app), "delete_event", GTK_SIGNAL_FUNC (container_destroy_cb), container); - /* - * Create the BonoboUIHandler object which will be used to - * create the container's menus and toolbars. The UIHandler - * also creates a CORBA server which embedded components use - * to do menu/toolbar merging. - */ - container->uih = bonobo_ui_handler_new (); - bonobo_ui_handler_set_app (container->uih, GNOME_APP (container->app)); + ui_container = bonobo_ui_container_new (); + bonobo_ui_container_set_win (ui_container, BONOBO_WINDOW(container->app)); - container_create_menus (container); - container_create_toolbar (container); + container->ui_component = bonobo_ui_component_new ("gpdf"); + bonobo_ui_component_set_container ( + container->ui_component, + bonobo_object_corba_objref (BONOBO_OBJECT (ui_container))); - gtk_widget_show_all (container->app); + bonobo_ui_component_add_verb_list_with_data ( + container->ui_component, verbs, container); + + bonobo_ui_util_set_ui (container->ui_component, DATADIR, "gpdf-ui.xml", "gpdf"); + + gtk_widget_show (container->app); containers = g_list_append (containers, container); @@ -570,7 +526,7 @@ container_new (const char *fname) return NULL; } - gtk_widget_show_all (container->app); + gtk_widget_show (container->app); return container; } @@ -587,20 +543,11 @@ main (int argc, char **argv) CORBA_exception_init (&ev); -#if USING_OAF gnomelib_register_popt_table (oaf_popt_options, "OAF"); gnome_init_with_popt_table("PDFViewer", "0.0.1", argc, argv, gpdf_popt_options, 0, &ctx); orb = oaf_init (argc, argv); -#else - gnome_CORBA_init_with_popt_table ("PDFViewer", "0.0.1", - &argc, argv, - gpdf_popt_options, 0, &ctx, - GNORBA_INIT_SERVER_FUNC, &ev); - - orb = gnome_CORBA_ORB (); -#endif CORBA_exception_free (&ev);