#include "config.h" #include #include #include #include #include "container-menu.h" #include "container.h" #include "container-filesel.h" #include "document.h" static void verb_AddComponent_cb (BonoboUIComponent *uic, gpointer user_data, const char *cname) { SampleApp *inst = user_data; char *required_interfaces [2] = { "IDL:Bonobo/CanvasComponentFactory:1.0", NULL }; char *obj_id; /* Ask the user to select a component. */ obj_id = bonobo_selector_select_id ( "Select an embeddable Bonobo component to add", (const gchar **) required_interfaces); if (!obj_id) return; sample_doc_add_component (inst->doc, obj_id); g_free (obj_id); } static void load_response_cb (GtkWidget *caller, gint response, SampleApp *app) { GtkWidget *fs = app->fileselection; gchar *filename; if (response == GTK_RESPONSE_OK) { filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fs)); if (filename) sample_doc_load (app->doc, filename); g_free (filename); } gtk_widget_destroy (fs); } static void save_response_cb (GtkWidget *caller, gint response, SampleApp *app) { GtkWidget *fs = app->fileselection; gchar *filename; if (response == GTK_RESPONSE_OK) { filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fs)); if (filename) sample_doc_save (app->doc, filename); g_free (filename); } gtk_widget_destroy (fs); } static void verb_FileSaveAs_cb (BonoboUIComponent *uic, gpointer user_data, const char *cname) { SampleApp *app = user_data; container_request_file (app, TRUE, G_CALLBACK (save_response_cb), app); } static void verb_FileLoad_cb (BonoboUIComponent *uic, gpointer user_data, const char *cname) { SampleApp *app = user_data; container_request_file (app, FALSE, G_CALLBACK (load_response_cb), app); } static void verb_PrintPreview_cb (BonoboUIComponent *uic, gpointer user_data, const char *cname) { #if 0 SampleApp *app = user_data; sample_app_print_preview (app); #else g_warning ("Print Preview not implemented yet."); #endif } static void verb_HelpAbout_cb (BonoboUIComponent *uic, gpointer user_data, const char *cname) { #if 0 /* gnome_about would require a libgnomeui dependency */ static const gchar *authors[] = { "ÉRDI Gergõ ", "Mike Kestner ", NULL }; GtkWidget *about = gnome_about_new ("sample-container-2", VERSION, "(C) 2000-2001 ÉRDI Gergõ, Mike Kestner, and Ximian, Inc", authors, "Bonobo sample container", NULL); gtk_widget_show (about); #endif } static void verb_FileExit_cb (BonoboUIComponent *uic, gpointer user_data, const char *cname) { SampleApp *app = user_data; sample_app_exit (app); } /* * The menus. */ static char ui_commands [] = "\n" " \n" " \n" " \n" " \n" " \n" " \n" ""; static char ui_data [] = "\n" " \n" " \n" " " " \n" "\n" " \n" "\n" " \n" "\n" " \n" " \n" " \n" " \n" " \n" "\n" " \n" " \n" " \n" ""; static BonoboUIVerb sample_app_verbs[] = { BONOBO_UI_VERB ("AddEmbeddable", verb_AddComponent_cb), BONOBO_UI_VERB ("FileOpen", verb_FileLoad_cb), BONOBO_UI_VERB ("FileSaveAs", verb_FileSaveAs_cb), BONOBO_UI_VERB ("PrintPreview", verb_PrintPreview_cb), BONOBO_UI_VERB ("FileExit", verb_FileExit_cb), BONOBO_UI_VERB ("HelpAbout", verb_HelpAbout_cb), BONOBO_UI_VERB_END }; void sample_app_fill_menu (SampleApp *app) { Bonobo_UIContainer corba_uic; BonoboUIComponent *uic; uic = bonobo_ui_component_new ("sample"); corba_uic = BONOBO_OBJREF (bonobo_window_get_ui_container ( BONOBO_WINDOW (app->win))); bonobo_ui_component_set_container (uic, corba_uic, NULL); bonobo_ui_component_set_translate (uic, "/", ui_commands, NULL); bonobo_ui_component_set_translate (uic, "/", ui_data, NULL); bonobo_ui_component_add_verb_list_with_data (uic, sample_app_verbs, app); }