int main (int argc, char *argv []) { g_thread_init (NULL); free (malloc (8)); if (!bonobo_init (NULL, NULL)) g_error ("Can not bonobo_init"); bonobo_activate (); check_string ("a:", "\\\\", "\\"); check_string ("a:", "\\#", "#"); check_string ("prefix:", "\\!", "!"); check_string ("a:", "1\\!\\#\\!\\!\\#\\\\", "1!#!!#\\"); check_parse_name ("#b:", "b:", 0); check_parse_name ("a:#b:", "b:", 2); check_parse_name ("a:!b:", "!b:", 2); check_parse_name ("a:3456789#b:", "b:", 9); check_parse_name ("a:\\##b:", "b:", 4); check_parse_name ("a:\\#c:", "a:\\#c:", 0); check_parse_name ("a:\\\\##c:", "c:", 5); check_parse_name ("a:\\\\#b:#c:", "c:", 7); check_parse_name ("a:\\\\#b:\\#c:", "b:\\#c:", 4); check_parse_name ("a:\\\\\\#b:\\#c:", "a:\\\\\\#b:\\#c:", 0); test_real_monikers (); return bonobo_debug_shutdown (); }
int main (int argc, char *argv []) { Bonobo_Sample_Echo echo_server; CORBA_Environment ev; /* * Initialize bonobo. */ if (!bonobo_init (&argc, argv)) g_error (_("I could not initialize Bonobo")); /* * Enable CORBA/Bonobo to start processing requests */ bonobo_activate (); echo_server = bonobo_get_object ("OAFIID:Bonobo_Sample_Echo", "Bonobo/Sample/Echo", NULL); if (echo_server == CORBA_OBJECT_NIL) { g_warning (_("Could not create an instance of the sample echo component")); return bonobo_debug_shutdown (); } /* Send a message */ CORBA_exception_init (&ev); Bonobo_Sample_Echo_echo (echo_server, "This is the message from the client\n", &ev); /* Check for exceptions */ if (BONOBO_EX (&ev)) { char *err = bonobo_exception_get_text (&ev); g_warning (_("An exception occurred '%s'"), err); g_free (err); } CORBA_exception_free (&ev); bonobo_object_release_unref (echo_server, NULL); return bonobo_debug_shutdown (); }
int main (int argc, char *argv[]) { GnomeProgram *program; free (malloc (8)); textdomain (GETTEXT_PACKAGE); program = gnome_program_init ("test-filesel", VERSION, LIBBONOBOUI_MODULE, argc, argv, NULL); bonobo_activate (); g_idle_add (get_files, NULL); bonobo_main (); g_object_unref (program); return 0; }
int main (int argc, char *argv []) { BonoboObject *object; Bonobo_Unknown ref; CORBA_Environment *ev, real_ev; g_thread_init (NULL); free (malloc (8)); if (bonobo_init (&argc, argv) == FALSE) g_error ("Can not bonobo_init"); bonobo_activate (); ev = &real_ev; CORBA_exception_init (ev); fprintf (stderr, "Local lifecycle\n"); { object = BONOBO_OBJECT (g_object_new ( bonobo_moniker_get_type (), NULL)); g_assert (bonobo_object_ref (object) == object); g_assert (bonobo_object_unref (BONOBO_OBJECT (object)) == NULL); bonobo_object_unref (BONOBO_OBJECT (object)); } fprintf (stderr, "In-proc lifecycle\n"); { object = BONOBO_OBJECT (g_object_new ( bonobo_moniker_get_type (), NULL)); ref = CORBA_Object_duplicate (BONOBO_OBJREF (object), NULL); bonobo_object_release_unref (ref, NULL); } fprintf (stderr, "Query interface\n"); { BonoboObject *a, *b; a = BONOBO_OBJECT (g_object_new ( bonobo_moniker_get_type (), NULL)); b = BONOBO_OBJECT (g_object_new ( bonobo_stream_mem_get_type (), NULL)); bonobo_object_add_interface (a, b); fprintf (stderr, " invalid interface\n"); object = bonobo_object_query_local_interface ( a, "IDL:This/Is/Not/There:1.0"); g_assert (object == CORBA_OBJECT_NIL); fprintf (stderr, " symmetry\n"); object = bonobo_object_query_local_interface ( a, "IDL:Bonobo/Stream:1.0"); g_assert (object == b); bonobo_object_unref (object); object = bonobo_object_query_local_interface ( b, "IDL:Bonobo/Stream:1.0"); g_assert (object == b); bonobo_object_unref (object); object = bonobo_object_query_local_interface ( a, "IDL:Bonobo/Moniker:1.0"); g_assert (object == a); bonobo_object_unref (object); object = bonobo_object_query_local_interface ( b, "IDL:Bonobo/Moniker:1.0"); g_assert (object == a); bonobo_object_unref (object); fprintf (stderr, " remote\n"); ref = Bonobo_Unknown_queryInterface ( BONOBO_OBJREF (a), "IDL:Broken/1.0", ev); g_assert (!BONOBO_EX (ev)); g_assert (ref == CORBA_OBJECT_NIL); ref = Bonobo_Unknown_queryInterface ( BONOBO_OBJREF (a), "IDL:Bonobo/Stream:1.0", ev); g_assert (!BONOBO_EX (ev)); g_assert (ref == BONOBO_OBJREF (b)); bonobo_object_release_unref (ref, ev); g_assert (!BONOBO_EX (ev)); bonobo_object_unref (a); } fprintf (stderr, "Environment exception checks\n"); { object = BONOBO_OBJECT (g_object_new ( bonobo_moniker_get_type (), NULL)); g_signal_connect (G_OBJECT (object), "system_exception", G_CALLBACK (system_exception_cb), object); CORBA_exception_set_system ( ev, ex_CORBA_COMM_FAILURE, CORBA_COMPLETED_MAYBE); g_assert (BONOBO_EX (ev)); signal_emitted = 0; BONOBO_OBJECT_CHECK ( object, BONOBO_OBJREF (object), ev); g_assert (signal_emitted); CORBA_exception_free (ev); bonobo_object_unref (object); } fprintf (stderr, "Servant mapping...\n"); { PortableServer_Servant servant; object = BONOBO_OBJECT (g_object_new ( bonobo_moniker_get_type (), NULL)); servant = (PortableServer_Servant) &object->servant; g_assert (bonobo_object (object) == object); g_assert (bonobo_object (&object->servant) == object); g_assert (bonobo_object_get_servant (object) == servant); g_assert (bonobo_object_from_servant (servant) == object); g_assert (bonobo_object_fast (object) == object); g_assert (bonobo_object_fast (servant) == object); bonobo_object_unref (object); } fprintf (stderr, "Ret-ex tests...\n"); { g_assert (!ret_ex_test (ev)); ex_test (ev); CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_Bonobo_PropertyBag_NotFound, NULL); g_assert (ret_ex_test (ev)); CORBA_exception_free (ev); } fprintf (stderr, "General error tests...\n"); { bonobo_exception_general_error_set ( ev, NULL, "a%s exception occurred", "n exceptional"); g_assert (BONOBO_EX (ev)); g_assert (!strcmp (BONOBO_EX_REPOID (ev), ex_Bonobo_GeneralError)); g_assert (!strcmp (bonobo_exception_get_text (ev), "an exceptional exception occurred")); } fprintf (stderr, "All tests passed\n"); return bonobo_debug_shutdown (); }
int main (int argc, char **argv) { BonoboWindow *win; BonoboUIComponent *componenta; BonoboUIComponent *componentb; BonoboUIComponent *componentc; BonoboUIContainer *container; Bonobo_UIContainer corba_container; CORBA_Environment real_ev, *ev; GnomeProgram *program; char *txt, *fname; int i; char simplea [] = "<menu>\n" " <submenu name=\"File\" _label=\"_Ga'\">\n" " <menuitem name=\"open\" pos=\"bottom\" _label=\"_Open\" verb=\"FileOpen\" pixtype=\"stock\" pixname=\"Open\" _tip=\"Wibble\"/>\n" " <control name=\"MyControl\"/>\n" " <control name=\"MyControl2\"/>\n" " <control name=\"ThisIsEmpty\"/>\n" " <menuitem name=\"close\" noplace=\"1\" verb=\"FileExit\" _label=\"_CloseA\" _tip=\"hi\"" " pixtype=\"stock\" pixname=\"Close\" accel=\"*Control*q\"/>\n" " </submenu>\n" "</menu>"; char keysa [] = "<keybindings>\n" " <accel name=\"*Control*3\" id=\"MyFoo\"/>\n" "</keybindings>\n"; char simpleb [] = "<submenu name=\"File\" _label=\"_File\">\n" " <menuitem name=\"open\" _label=\"_OpenB\" pixtype=\"stock\" pixname=\"Open\" _tip=\"Open you fool\"/>\n" " <separator/>\n" " <menuitem name=\"toggle\" type=\"toggle\" id=\"MyFoo\" _label=\"_ToggleMe\" _tip=\"a\" accel=\"*Control*t\"/>\n" " <placeholder name=\"Nice\" delimit=\"top\"/>\n" " <menuitem name=\"close\" noplace=\"1\" verb=\"FileExit\" _label=\"_CloseB\" _tip=\"hi\"" " pixtype=\"stock\" pixname=\"Close\" accel=\"*Control*q\"/>\n" "</submenu>\n"; char simplec [] = "<submenu name=\"File\" _label=\"_FileC\" _tip=\"what!\">\n" " <placeholder name=\"Nice\" delimit=\"top\" hidden=\"0\">\n" " <menuitem name=\"fooa\" _label=\"_FooA\" type=\"radio\" group=\"foogroup\" _tip=\"Radio1\"/>\n" " <menuitem name=\"foob\" _label=\"_FooB\" type=\"radio\" group=\"foogroup\" _tip=\"kippers\"/>\n" " <menuitem name=\"wibble\" verb=\"ThisForcesAnError\" _label=\"_Baa\"" " pixtype=\"stock\" pixname=\"Open\" sensitive=\"0\" _tip=\"fish\"/>\n" " <separator/>\n" " </placeholder>\n" "</submenu>\n"; char simpled [] = "<menuitem name=\"save\" _label=\"_SaveD\" pixtype=\"stock\" pixname=\"Save\" _tip=\"tip1\"/>\n"; char simplee [] = "<menuitem name=\"fish\" _label=\"_Inplace\" pixtype=\"stock\" pixname=\"Save\" _tip=\"tip2\"/>\n"; char toola [] = "<dockitem name=\"Toolbar\" homogeneous=\"0\" vlook=\"icon\">\n" " <toolitem type=\"toggle\" name=\"foo2\" id=\"MyFoo\" pixtype=\"stock\" pixname=\"Save\"" " _label=\"TogSave\" _tip=\"My tooltip\" priority=\"1\"/>\n" " <separator/>\n" " <toolitem name=\"baa\" pixtype=\"stock\" pixname=\"Open\" _label=\"baa\" _tip=\"My 2nd tooltip\" verb=\"testme\"/>\n" " <control name=\"AControl\" _tip=\"a tip on a control\" hidden=\"0\" vdisplay=\"button\"\n" " pixtype=\"stock\" pixname=\"gtk-italic\" _label=\"EntryControl\" verb=\"OpenEntry\"/>\n" " <control name=\"BControl\" _tip=\"another tip on a control\" hidden=\"0\"\n" " pixtype=\"stock\" pixname=\"gtk-stop\"/>\n" "</dockitem>"; char toolb [] = "<dockitem name=\"Toolbar\" look=\"icon\" relief=\"none\">\n" " <toolitem name=\"foo1\" _label=\"Insensitive\" sensitive=\"0\" hidden=\"0\" priority=\"1\"/>\n" " <toolitem type=\"toggle\" name=\"foo5\" id=\"MyFoo\" pixtype=\"stock\" pixname=\"Close\"" " _label=\"TogSame\" _tip=\"My tooltip\"/>\n" "</dockitem>"; /* char statusa [] = "<item name=\"main\">Kippers</item>\n";*/ char statusb [] = "<status>\n" " <item name=\"main\"/>\n" " <control name=\"Progress\"/>\n" "</status>"; ev = &real_ev; CORBA_exception_init (ev); free (malloc (8)); program = gnome_program_init ("test-ui", VERSION, LIBBONOBOUI_MODULE, argc, argv, NULL); textdomain (GETTEXT_PACKAGE); bonobo_activate (); dump_prefs (); win = BONOBO_WINDOW (bonobo_window_new ("Win", "My Test Application")); container = bonobo_window_get_ui_container (win); bonobo_ui_engine_config_set_path (bonobo_window_get_ui_engine (win), "/test-ui/UIConfig/kvps"); corba_container = BONOBO_OBJREF (container); { GtkWidget *box = gtk_vbox_new (FALSE, 0); GtkWidget *button; GtkWidget *path_entry, *state_entry; button = gtk_button_new_with_label ("Press me to test!"); g_signal_connect (GTK_OBJECT (button), "clicked", (GtkSignalFunc) cb_do_quit, NULL); gtk_widget_show (GTK_WIDGET (button)); gtk_box_pack_start_defaults (GTK_BOX (box), button); button = gtk_button_new_with_label ("Dump Xml tree"); g_signal_connect (GTK_OBJECT (button), "clicked", (GtkSignalFunc) cb_do_dump, win); gtk_widget_show (GTK_WIDGET (button)); gtk_box_pack_start_defaults (GTK_BOX (box), button); button = gtk_button_new_with_label ("Popup"); g_signal_connect (GTK_OBJECT (button), "clicked", (GtkSignalFunc) cb_do_popup, win); gtk_widget_show (GTK_WIDGET (button)); gtk_box_pack_start_defaults (GTK_BOX (box), button); button = gtk_button_new_with_label ("Hide toolbar"); g_signal_connect (GTK_OBJECT (button), "clicked", (GtkSignalFunc) cb_do_hide_toolbar, win); gtk_widget_show (GTK_WIDGET (button)); gtk_box_pack_start_defaults (GTK_BOX (box), button); path_entry = gtk_entry_new (); gtk_entry_set_text (GTK_ENTRY (path_entry), "/commands/MyFoo"); gtk_widget_show (GTK_WIDGET (path_entry)); gtk_box_pack_start_defaults (GTK_BOX (box), path_entry); state_entry = gtk_entry_new (); gtk_entry_set_text (GTK_ENTRY (state_entry), "1"); g_signal_connect (GTK_OBJECT (state_entry), "changed", (GtkSignalFunc) cb_set_state, path_entry); gtk_widget_show (GTK_WIDGET (state_entry)); gtk_box_pack_start_defaults (GTK_BOX (box), state_entry); gtk_widget_show (GTK_WIDGET (box)); bonobo_window_set_contents (win, box); } g_signal_connect (GTK_OBJECT (win), "size_request", G_CALLBACK (slow_size_request), NULL); componenta = bonobo_ui_component_new ("A"); bonobo_object_unref (BONOBO_OBJECT (componenta)); componenta = bonobo_ui_component_new ("A"); componentb = bonobo_ui_component_new ("B"); componentc = bonobo_ui_component_new ("C"); bonobo_ui_component_set_container (componenta, corba_container, NULL); bonobo_ui_component_set_container (componentb, corba_container, NULL); bonobo_ui_component_set_container (componentc, corba_container, NULL); global_component = componenta; fname = bonobo_ui_util_get_ui_fname (NULL, "../doc/std-ui.xml"); if (fname && g_file_test (fname, G_FILE_TEST_EXISTS)) { fprintf (stderr, "\n\n--- Add std-ui.xml ---\n\n\n"); bonobo_ui_util_set_ui (componenta, NULL, "../doc/std-ui.xml", "gdm", NULL); /* bonobo_ui_component_set_prop ( componenta, "/menu/Preferences", "pixname", "/demo/a.xpm", NULL);*/ gtk_widget_show (GTK_WIDGET (win)); bonobo_main (); } else { g_warning ("Can't find ../doc/std-ui.xml"); gtk_widget_show (GTK_WIDGET (win)); } g_free (fname); bonobo_ui_component_freeze (componenta, NULL); fprintf (stderr, "\n\n--- Remove A ---\n\n\n"); bonobo_ui_component_rm (componenta, "/", ev); g_assert (!BONOBO_EX (ev)); /* bonobo_ui_component_set_translate (componentb, "/status", statusa, ev); g_assert (!BONOBO_EX (ev));*/ bonobo_ui_component_set_translate (componenta, "/", simplea, ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_set_translate (componentb, "/", "<popups> <popup name=\"MyStuff\"/> </popups>", ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_set_translate (componenta, "/popups/MyStuff", simpleb, ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_set_translate (componenta, "/", keysa, ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_set_translate (componentb, "/", toola, ev); g_assert (!BONOBO_EX (ev)); { GtkWidget *widget = gtk_button_new_with_label ("My Label"); BonoboControl *control = bonobo_control_new (widget); BonoboUIComponent *componentp; g_signal_connect (GTK_OBJECT (widget), "button_press_event", G_CALLBACK (do_sane_popup), control); componentp = bonobo_control_get_popup_ui_component (control); #if 1 bonobo_ui_component_set (componentp, "/", "<popups>" "<popup name=\"button3\"/></popups>", ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_set_translate ( componentp, "/popups/button3", simpleb, ev); g_assert (!BONOBO_EX (ev)); #endif gtk_widget_show (widget); bonobo_ui_component_object_set (componenta, "/menu/File/MyControl", BONOBO_OBJREF (control), ev); bonobo_object_unref (BONOBO_OBJECT (control)); g_assert (!BONOBO_EX (ev)); widget = gtk_menu_item_new_with_mnemonic ("_Foo item"); gtk_widget_show (widget); bonobo_ui_component_widget_set (componenta, "/menu/File/MyControl2", widget, ev); } { GtkWidget *widget = gtk_entry_new (); gtk_entry_set_text (GTK_ENTRY (widget), "Example text"); gtk_widget_show (widget); bonobo_ui_component_widget_set (componenta, "/Toolbar/AControl", widget, ev); g_assert (!BONOBO_EX (ev)); } { GtkWidget *widget; GdkPixbuf *pixbuf = gdk_pixbuf_new_from_xpm_data (tame_xpm); widget = bonobo_ui_toolbar_button_item_new (pixbuf, "Test Control"); gtk_widget_show (widget); bonobo_ui_component_widget_set (componenta, "/Toolbar/BControl", widget, ev); g_assert (!BONOBO_EX (ev)); } bonobo_ui_component_add_listener (componentb, "MyFoo", toggled_cb, ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_set_translate (componentb, "/", statusb, ev); g_assert (!BONOBO_EX (ev)); /* Duplicate set */ bonobo_ui_component_set_translate (componenta, "/", simplea, ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_add_verb_list_with_data ( componenta, verbs, GUINT_TO_POINTER (15)); bonobo_ui_component_thaw (componenta, ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_set_status (componenta, "WhatA1", ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_set_status (componenta, "WhatA1", ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_set_status (componentb, "WhatB2", ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_set_status (componenta, "WhatA3", ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_rm (componenta, "/status", ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_set_status (componentb, "WhatB4", ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_set_status (componenta, "WhatA5", ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_set_status (componenta, "WhatA6>", ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_set_status (componentb, "WhatB7", ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_set_status (componentb, "", ev); g_assert (!BONOBO_EX (ev)); g_assert (bonobo_ui_component_get_prop ( componentb, "/status/main", "non-existant", ev) == NULL); g_assert (!strcmp (BONOBO_EX_REPOID (ev), ex_Bonobo_UIContainer_NonExistentAttr)); CORBA_exception_free (ev); { const char *good = "<item name=\"main\">WhatA6></item>\n"; txt = bonobo_ui_component_get (componenta, "/status/main", TRUE, NULL); if (!txt || strcmp (txt, good)) { g_warning ("Broken merging code '%s' should be '%s'", txt, good); bonobo_window_dump (win, "on fatal error"); g_assert_not_reached (); } CORBA_free (txt); } bonobo_main (); bonobo_ui_component_freeze (componenta, ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_set_translate (componentb, "/menu", simpleb, ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_set_translate (componenta, "/", toolb, ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_set_prop (componenta, "/menu/File", "label", "_Goo-wan>", ev); g_assert (!BONOBO_EX (ev)); /* A 'transparent' node merge */ txt = bonobo_ui_component_get_prop (componenta, "/Toolbar", "look", ev); g_assert (!BONOBO_EX (ev)); printf ("Before merge look '%s'\n", txt); bonobo_ui_component_set_translate (componenta, "/", "<dockitem name=\"Toolbar\"/>", ev); g_assert (!BONOBO_EX (ev)); g_free (txt); txt = bonobo_ui_component_get_prop (componenta, "/Toolbar", "look", ev); g_assert (!BONOBO_EX (ev)); printf ("After merge look '%s'\n", txt); if (txt == NULL || strcmp (txt, "icon")) g_warning ("Serious transparency regression"); g_free (txt); bonobo_ui_component_set_translate (componenta, "/menu/File/Nice", simplee, ev); g_assert (!BONOBO_EX (ev)); { GtkWidget *widget = gtk_progress_bar_new (); BonoboControl *control = bonobo_control_new (widget); guint id; gtk_widget_show (widget); bonobo_ui_component_object_set (componenta, "/status/Progress", BONOBO_OBJREF (control), NULL); id = gtk_timeout_add (100, (GSourceFunc) update_progress, widget); g_signal_connect (GTK_OBJECT (widget), "destroy", G_CALLBACK (disconnect_progress), GUINT_TO_POINTER (id)); bonobo_object_unref (BONOBO_OBJECT (control)); } bonobo_ui_component_set_status (componenta, "This is a very long status message " "that should cause the window to be resized if " "there is in fact a bug in it", ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_thaw (componenta, ev); g_assert (!BONOBO_EX (ev)); bonobo_main (); g_warning ("Begginning stress test, this may take some time ..."); for (i = 0; i < 100; i++) { bonobo_ui_component_freeze (componentc, ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_set_translate (componentc, "/commands", "<cmd name=\"MyFoo\" sensitive=\"0\"/>", ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_set_translate (componentc, "/menu", simplec, ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_set_translate (componentc, "/menu/File", simpled, ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_thaw (componentc, ev); g_assert (!BONOBO_EX (ev)); } g_warning ("Done stress test"); bonobo_main (); bonobo_ui_component_freeze (componenta, ev); g_assert (!BONOBO_EX (ev)); fprintf (stderr, "\n\n--- Remove 2 ---\n\n\n"); bonobo_ui_component_rm (componentb, "/", ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_set_prop (componentc, "/menu/File/save", "label", "SaveC", ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_thaw (componenta, ev); g_assert (!BONOBO_EX (ev)); bonobo_main (); bonobo_ui_component_freeze (componenta, ev); g_assert (!BONOBO_EX (ev)); fprintf (stderr, "\n\n--- Remove 3 ---\n\n\n"); bonobo_ui_component_rm (componentc, "/", ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_thaw (componenta, ev); g_assert (!BONOBO_EX (ev)); bonobo_main (); bonobo_ui_component_freeze (componenta, ev); g_assert (!BONOBO_EX (ev)); fprintf (stderr, "\n\n--- Remove 1 ---\n\n\n"); bonobo_ui_component_rm (componenta, "/", ev); g_assert (!BONOBO_EX (ev)); bonobo_ui_component_thaw (componenta, ev); g_assert (!BONOBO_EX (ev)); bonobo_main (); bonobo_object_unref (BONOBO_OBJECT (componenta)); bonobo_object_unref (BONOBO_OBJECT (componentb)); bonobo_object_unref (BONOBO_OBJECT (componentc)); gtk_widget_destroy (GTK_WIDGET (win)); CORBA_exception_free (ev); g_object_unref (program); return bonobo_ui_debug_shutdown (); }
int main(int argc, char **argv) { CORBA_Environment ev; CORBA_Object oclient; char *obj_id; CORBA_long i; CORBA_short n_desktops; CORBA_long j; CORBA_long n_apps; CORBA_string s; Accessibility_Desktop desktop; Accessibility_Application app; Accessibility_Registry registry; SpiListener *listener; CORBA_exception_init(&ev); if (!bonobo_init (&argc, argv)) { g_error ("Could not initialize Bonobo"); } obj_id = "OAFIID:Accessibility_Registry:1.0"; oclient = bonobo_activation_activate_from_id (obj_id, 0, NULL, &ev); if (ev._major != CORBA_NO_EXCEPTION) { fprintf(stderr, ("Accessibility app error: exception during registry activation from id: %s\n"), CORBA_exception_id(&ev)); CORBA_exception_free(&ev); exit(-1); } if (CORBA_Object_is_nil (oclient, &ev)) { g_error ("Could not locate registry"); } bonobo_activate (); listener = spi_listener_new (); registry = (Accessibility_Registry) oclient; Accessibility_Registry_registerGlobalEventListener (registry, (Accessibility_EventListener) bonobo_object_corba_objref (bonobo_object (listener)), "focus:", &ev); check_ev (&ev, "register:focus"); Accessibility_Registry_registerGlobalEventListener (registry, (Accessibility_EventListener) bonobo_object_corba_objref (bonobo_object (listener)), "Gtk:GtkWidget:button-press-event", &ev); check_ev (&ev, "register:button_press"); fprintf (stderr, "AT callback registered.\n"); n_desktops = Accessibility_Registry_getDesktopCount (registry, &ev); for (i=0; i<n_desktops; ++i) { desktop = Accessibility_Registry_getDesktop (registry, i, &ev); s = Accessibility_Desktop__get_name (desktop, &ev); fprintf (stderr, "desktop %d name: %s\n", i, s); CORBA_free (s); check_ev (&ev, "desktop:name"); n_apps = Accessibility_Desktop__get_childCount (desktop, &ev); check_ev (&ev, "desktop:childCount"); fprintf (stderr, "desktop has %d apps:\n", n_apps); for (j=0; j<n_apps; ++j) { app = (Accessibility_Application) Accessibility_Desktop_getChildAtIndex (desktop, j, &ev); check_ev (&ev, "desktop:getChildAtIndex"); s = Accessibility_Application__get_name (app, &ev); fprintf (stderr, "app %d name: %s\n", j, s); CORBA_free (s); check_ev (&ev, "app:getName"); } } fprintf (stderr, "finished querying desktop(s).\n"); bonobo_main (); /* needed by at because it is a server ? */ exit(0); }
int main (int argc, char *argv[]) { gboolean kill_shell; gboolean restart_shell; gboolean no_default_window; gboolean browser_window; gboolean no_desktop; const char *startup_id; char *startup_id_copy; char *session_to_load; gchar *geometry; const gchar **remaining; gboolean perform_self_check; GOptionContext *context; NautilusApplication *application; char **argv_copy; GnomeProgram *program; const GOptionEntry options[] = { #ifndef NAUTILUS_OMIT_SELF_CHECK { "check", 'c', 0, G_OPTION_ARG_NONE, &perform_self_check, N_("Perform a quick set of self-check tests."), NULL }, #endif { "geometry", 'g', 0, G_OPTION_ARG_STRING, &geometry, N_("Create the initial window with the given geometry."), N_("GEOMETRY") }, { "no-default-window", 'n', 0, G_OPTION_ARG_NONE, &no_default_window, N_("Only create windows for explicitly specified URIs."), NULL }, { "no-desktop", '\0', 0, G_OPTION_ARG_NONE, &no_desktop, N_("Do not manage the desktop (ignore the preference set in the preferences dialog)."), NULL }, { "browser", '\0', 0, G_OPTION_ARG_NONE, &browser_window, N_("open a browser window."), NULL }, { "quit", 'q', 0, G_OPTION_ARG_NONE, &kill_shell, N_("Quit Nautilus."), NULL }, { "restart", '\0', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &restart_shell, N_("Restart Nautilus."), NULL }, { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining, NULL, N_("[URI...]") }, { "load-session", 'l', 0, G_OPTION_ARG_STRING, &session_to_load, /* Translators: --no-default-window is a nautilus command line parameter, don't modify it. */ N_("Load a saved session from the specified file. Implies \"--no-default-window\"."), N_("FILENAME") }, { NULL } }; g_thread_init (NULL); setlocale (LC_ALL, ""); /* This will be done by gtk+ later, but for now, force it to GNOME */ g_desktop_app_info_set_desktop_env ("GNOME"); if (g_getenv ("NAUTILUS_DEBUG") != NULL) { eel_make_warnings_and_criticals_stop_in_debugger (); } /* Initialize gettext support */ bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); startup_id = g_getenv ("DESKTOP_STARTUP_ID"); startup_id_copy = NULL; if (startup_id != NULL && *startup_id != '\0') { /* Clear the DESKTOP_STARTUP_ID, but make sure to copy it first */ startup_id_copy = g_strdup (startup_id); g_unsetenv ("DESKTOP_STARTUP_ID"); } /* we'll do it ourselves due to complicated factory setup */ gtk_window_set_auto_startup_notification (FALSE); /* Get parameters. */ remaining = NULL; geometry = NULL; session_to_load = NULL; kill_shell = FALSE; no_default_window = FALSE; no_desktop = FALSE; perform_self_check = FALSE; restart_shell = FALSE; browser_window = FALSE; g_set_application_name (_("File Manager")); context = g_option_context_new (_("\n\nBrowse the file system with the file manager")); g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); #ifdef HAVE_EXEMPI xmp_init(); #endif program = gnome_program_init ("nautilus", VERSION, LIBGNOMEUI_MODULE, argc, argv, GNOME_PROGRAM_STANDARD_PROPERTIES, GNOME_PARAM_GOPTION_CONTEXT, context, GNOME_PARAM_HUMAN_READABLE_NAME, _("Nautilus"), NULL); /* We do this after gnome_program_init(), since that function sets up * its own handler for SIGSEGV and others --- we want to chain to those * handlers. */ setup_debug_log (); if (session_to_load != NULL) { no_default_window = TRUE; } /* Do this here so that gdk_display is initialized */ if (startup_id_copy == NULL) { /* Create a fake one containing a timestamp that we can use */ Time timestamp; timestamp = slowly_and_stupidly_obtain_timestamp (gdk_display); startup_id_copy = g_strdup_printf ("_TIME%lu", timestamp); } /* Set default icon for all nautilus windows */ gtk_window_set_default_icon_name (NAUTILUS_ICON_FOLDER); /* Need to set this to the canonical DISPLAY value, since thats where we're registering per-display components */ bonobo_activation_set_activation_env_value ("DISPLAY", gdk_display_get_name (gdk_display_get_default())); if (perform_self_check && remaining != NULL) { /* translators: %s is an option (e.g. --check) */ fprintf (stderr, _("nautilus: %s cannot be used with URIs.\n"), "--check"); return EXIT_FAILURE; } if (perform_self_check && (kill_shell || restart_shell)) { fprintf (stderr, _("nautilus: --check cannot be used with other options.\n")); return EXIT_FAILURE; } if (kill_shell && remaining != NULL) { fprintf (stderr, _("nautilus: %s cannot be used with URIs.\n"), "--quit"); return EXIT_FAILURE; } if (restart_shell && remaining != NULL) { fprintf (stderr, _("nautilus: %s cannot be used with URIs.\n"), "--restart"); return EXIT_FAILURE; } if (geometry != NULL && remaining != NULL && remaining[0] != NULL && remaining[1] != NULL) { fprintf (stderr, _("nautilus: --geometry cannot be used with more than one URI.\n")); return EXIT_FAILURE; } /* Initialize the services that we use. */ LIBXML_TEST_VERSION /* Initialize preferences. This is needed so that proper * defaults are available before any preference peeking * happens. */ nautilus_global_preferences_init (); if (no_desktop) { eel_preferences_set_is_invisible (NAUTILUS_PREFERENCES_SHOW_DESKTOP, TRUE); eel_preferences_set_is_invisible (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR, TRUE); } bonobo_activate (); /* do now since we need it before main loop */ application = NULL; /* Do either the self-check or the real work. */ if (perform_self_check) { #ifndef NAUTILUS_OMIT_SELF_CHECK /* Run the checks (each twice) for nautilus and libnautilus-private. */ nautilus_run_self_checks (); nautilus_run_lib_self_checks (); eel_exit_if_self_checks_failed (); nautilus_run_self_checks (); nautilus_run_lib_self_checks (); eel_exit_if_self_checks_failed (); #endif } else { /* Run the nautilus application. */ application = nautilus_application_new (); nautilus_application_startup (application, kill_shell, restart_shell, no_default_window, no_desktop, !(kill_shell || restart_shell), browser_window, startup_id_copy, geometry, session_to_load, remaining); g_free (startup_id_copy); /* The application startup does things in an idle, so we need to check whether the main loop is needed in an idle */ g_idle_add (initial_event_loop_needed, NULL); gtk_main (); } nautilus_icon_info_clear_caches (); if (application != NULL) { bonobo_object_unref (application); } eel_debug_shut_down (); /* If told to restart, exec() myself again. This is used when * the program is told to restart with CORBA, for example when * an update takes place. */ if (g_getenv ("_NAUTILUS_RESTART") != NULL) { g_unsetenv ("_NAUTILUS_RESTART"); /* Might eventually want to copy all the parameters * from argv into the new exec. For now, though, that * would just interfere with the re-creation of * windows based on the window info stored in gconf, * including whether the desktop was started. */ argv_copy = g_new0 (char *, 2); argv_copy[0] = argv[0]; execvp (argv[0], argv_copy); }