void e_pixmaps_update (BonoboUIComponent *uic, EPixmap *pixcache) { static int done_init = 0; int i; if (!done_init) { g_atexit (free_pixmaps); done_init = 1; } if (g_slist_find (inited_arrays, pixcache) == NULL) inited_arrays = g_slist_prepend (inited_arrays, pixcache); for (i = 0; pixcache [i].path; i++) { if (!pixcache [i].pixbuf) { GdkPixbuf *pixbuf; pixbuf = e_icon_factory_get_icon (pixcache [i].name, pixcache [i].size); pixcache [i].pixbuf = bonobo_ui_util_pixbuf_to_xml (pixbuf); g_object_unref (pixbuf); bonobo_ui_component_set_prop (uic, pixcache [i].path, "pixname", pixcache [i].pixbuf, NULL); } else { bonobo_ui_component_set_prop (uic, pixcache [i].path, "pixname", pixcache [i].pixbuf, NULL); } } }
static void cb_do_hide_toolbar (GtkWindow *window, BonoboWindow *win) { const char path [] = "/Toolbar"; char *val; val = bonobo_ui_component_get_prop (global_component, path, "hidden", NULL); if (val && atoi (val)) bonobo_ui_component_set_prop (global_component, path, "hidden", "0", NULL); else bonobo_ui_component_set_prop (global_component, path, "hidden", "1", NULL); g_free (val); }
static void update_offline_menu_item (EShellWindow *shell_window, EShellLineStatus line_status) { BonoboUIComponent *ui_component; ui_component = e_shell_window_peek_bonobo_ui_component (shell_window); switch (line_status) { case E_SHELL_LINE_STATUS_OFFLINE: case E_SHELL_LINE_STATUS_FORCED_OFFLINE: bonobo_ui_component_set_prop (ui_component, "/menu/File/ToggleOffline", "label", _("_Work Online"), NULL); bonobo_ui_component_set_prop (ui_component, "/menu/File/ToggleOffline", "verb", "WorkOnline", NULL); bonobo_ui_component_set_prop (ui_component, "/commands/ToggleOffline", "sensitive", "1", NULL); e_pixmaps_update (ui_component, online_pixmaps); break; case E_SHELL_LINE_STATUS_ONLINE: bonobo_ui_component_set_prop (ui_component, "/menu/File/ToggleOffline", "label", _("_Work Offline"), NULL); bonobo_ui_component_set_prop (ui_component, "/menu/File/ToggleOffline", "verb", "WorkOffline", NULL); bonobo_ui_component_set_prop (ui_component, "/commands/ToggleOffline", "sensitive", "1", NULL); e_pixmaps_update (ui_component, offline_pixmaps); break; case E_SHELL_LINE_STATUS_GOING_OFFLINE: bonobo_ui_component_set_prop (ui_component, "/menu/File/ToggleOffline", "label", _("Work Offline"), NULL); bonobo_ui_component_set_prop (ui_component, "/menu/File/ToggleOffline", "verb", "WorkOffline", NULL); bonobo_ui_component_set_prop (ui_component, "/commands/ToggleOffline", "sensitive", "0", NULL); e_pixmaps_update (ui_component, offline_pixmaps); break; default: g_return_if_reached(); } }
static gboolean workrave_applet_set_menu_status(WorkraveApplet *applet, const char *name, gboolean status, GError **err) { BonoboUIComponent *ui = NULL; gboolean set = FALSE; if (applet != NULL && applet->applet != NULL) { ui = panel_applet_get_popup_component(PANEL_APPLET(applet->applet)); } if (ui != NULL) { const char *s = bonobo_ui_component_get_prop(ui, name, "state", NULL); set = (s != NULL && atoi(s) != 0); if ((status && !set) || (!status && set)) { bonobo_ui_component_set_prop(ui, name, "state", status ? "1" : "0", NULL); } } return TRUE; }
static void cb_set_state (GtkEntry *state_entry, GtkEntry *path_entry) { const char *path, *state; char *txt, *str; path = gtk_entry_get_text (path_entry); state = gtk_entry_get_text (state_entry); g_warning ("Set state on '%s' to '%s'", path, state); bonobo_ui_component_set_prop ( global_component, path, "state", state, NULL); txt = bonobo_ui_component_get_prop ( global_component, path, "state", NULL); g_warning ("Re-fetched state was '%s'", txt); str = g_strdup_printf ("The state is now '%s'", txt); bonobo_ui_component_set_status (global_component, str, NULL); g_free (str); g_free (txt); }
static void emmb_activate (EMFolderView *emfv, BonoboUIComponent *uic, gint state) { EMFolderViewClass *folder_view_class; folder_view_class = EM_FOLDER_VIEW_CLASS (parent_class); if (state) { /* Chain up to parent's activate() method. */ folder_view_class->activate (emfv, uic, state); bonobo_ui_component_add_verb_list_with_data ( uic, emmb_verbs, emfv); bonobo_ui_component_set_prop( uic, "/commands/EditPaste", "sensitive", "0", NULL); } else { const BonoboUIVerb *verb; for (verb = &emmb_verbs[0]; verb->cname; verb++) bonobo_ui_component_remove_verb (uic, verb->cname); /* Chain up to parent's activate() method. */ folder_view_class->activate (emfv, uic, state); } }
static GtkWidget * wireless_applet_new (WirelessApplet *applet) { panel_applet_set_flags (PANEL_APPLET (applet), PANEL_APPLET_EXPAND_MINOR); applet->skfd = iw_sockets_open (); /* this ensures that properties are loaded */ wireless_applet_load_properties (applet); wireless_applet_load_theme (applet); setup_widgets (applet); applet->tips = gtk_tooltips_new (); g_object_ref (applet->tips); gtk_object_sink (GTK_OBJECT (applet->tips)); applet->prefs = NULL; g_signal_connect (applet,"destroy", G_CALLBACK (wireless_applet_destroy),NULL); g_signal_connect (applet->button, "button_press_event", G_CALLBACK (do_not_eat_button_press), NULL); /* Setup the menus */ panel_applet_setup_menu_from_file (PANEL_APPLET (applet), NULL, "GNOME_WirelessApplet.xml", NULL, wireless_menu_verbs, applet); if (panel_applet_get_locked_down (PANEL_APPLET (applet))) { BonoboUIComponent *popup_component; popup_component = panel_applet_get_popup_component (PANEL_APPLET (applet)); bonobo_ui_component_set_prop (popup_component, "/commands/WirelessProperties", "hidden", "1", NULL); } check_wireless (applet); wireless_applet_timeout_handler (applet); wireless_applet_start_timeout (applet); g_signal_connect (G_OBJECT (applet), "change_size", G_CALLBACK (change_size_cb), applet); g_signal_connect (G_OBJECT (applet), "change_orient", G_CALLBACK (change_orient_cb), applet); return GTK_WIDGET (applet); }
static void view_toolbar_item_toggled_handler (BonoboUIComponent *ui_component, const char *path, Bonobo_UIComponent_EventType type, const char *state, EShellWindow *shell_window) { gboolean is_visible; is_visible = state[0] == '1'; bonobo_ui_component_set_prop (ui_component, "/Toolbar", "hidden", is_visible ? "0" : "1", NULL); }
static void sensitize_items(BonoboUIComponent *uic, struct _sensitize_item *items, guint32 mask) { while (items->command) { char command[32]; if (strlen(items->command)>=21) { g_warning ("items->command >= 21: %s\n", items->command); continue; } sprintf(command, "/commands/%s", items->command); bonobo_ui_component_set_prop (uic, command, "sensitive", (items->enable & mask) == 0 ? "1" : "0", NULL); items++; } }
static void workrave_applet_set_hidden(gchar *name, gboolean hidden) { BonoboUIComponent *ui = NULL; gboolean set = FALSE; if (g_applet != NULL && g_applet->applet != NULL) { ui = panel_applet_get_popup_component(PANEL_APPLET(g_applet->applet)); } if (ui != NULL) { const char *s = bonobo_ui_component_get_prop(ui, name, "hidden", NULL); set = (s != NULL && atoi(s) != 0); if ((hidden && !set) || (!hidden && set)) { bonobo_ui_component_set_prop(ui, name, "hidden", hidden ? "1" : "0", NULL); } } }
static void macmenu_construct(AppletType* applet) { MacMenu *mmb = g_slice_new0(MacMenu); mmb->applet = applet; mmb->screen = wnck_screen_get(gdk_screen_get_number( gtk_widget_get_screen(GTK_WIDGET(applet)) )); mmb->mbars_scks = g_hash_table_new(NULL, NULL); mmb->title_subs = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); mmb->ts_mtime = 0; mmb->basebox = GTK_BOX(gtk_hbox_new(FALSE, 0)); gtk_container_set_border_width(GTK_CONTAINER(mmb->basebox), 0); gtk_container_add(GTK_CONTAINER(applet), GTK_WIDGET(mmb->basebox)); mmb->label = GTK_LABEL(gtk_label_new(MAIN_LABEL_TEXT)); PangoAttrList *pattr = pango_attr_list_new(); PangoAttribute *pa = pango_attr_weight_new(PANGO_WEIGHT_BOLD); pa->start_index = 0; pa->end_index = 1024; pango_attr_list_insert(pattr, pa); gtk_label_set_attributes(mmb->label, pattr); pango_attr_list_unref(pattr); gtk_label_set_ellipsize(mmb->label, PANGO_ELLIPSIZE_END); gtk_label_set_max_width_chars(mmb->label, MAX_LABEL_WIDTH_N_CHARS * 10); gtk_label_set_single_line_mode(mmb->label, TRUE); gtk_box_pack_start(mmb->basebox, GTK_WIDGET(mmb->label), FALSE, FALSE, 0); mmb->label_space = gtk_event_box_new(); gtk_widget_set_size_request(mmb->label_space, 8, 1); gtk_box_pack_start(mmb->basebox, mmb->label_space, FALSE, FALSE, 0); mmb->notebook = GTK_NOTEBOOK(gtk_notebook_new()); gtk_notebook_set_show_tabs(mmb->notebook, FALSE); gtk_notebook_set_show_border(mmb->notebook, FALSE); gtk_box_pack_start(mmb->basebox, GTK_WIDGET(mmb->notebook), TRUE, TRUE, 0); mmb->dummysck = gtk_hbox_new(FALSE, 0); gtk_notebook_append_page(mmb->notebook, mmb->dummysck, NULL); mmb->mainsck = gtk_hbox_new(FALSE, SHORTCUT_SPACING); gtk_notebook_append_page(mmb->notebook, mmb->mainsck, NULL); //initialize_mainsck(mmb); mmb->button = GTK_BUTTON(gtk_button_new()); gtk_button_set_relief(mmb->button, GTK_RELIEF_NONE); gtk_button_set_focus_on_click(GTK_BUTTON(mmb->button), FALSE); gtk_box_pack_start(mmb->basebox, GTK_WIDGET(mmb->button), FALSE, FALSE, 0); g_signal_connect(mmb->screen, "active-window-changed", G_CALLBACK(desktop_active_window_changed), mmb); g_signal_connect(mmb->screen, "window-opened", G_CALLBACK(desktop_window_opened), mmb); #ifdef FOR_XFCE g_signal_connect(applet, "free-data", G_CALLBACK(macmenu_free_data), mmb); g_signal_connect(applet, "size-changed", G_CALLBACK(macmenu_set_size), mmb); // setup panel applet gtk_widget_show_all(GTK_WIDGET(mmb->basebox)); xfce_panel_plugin_add_action_widget (applet, GTK_WIDGET(mmb->button)); xfce_panel_plugin_set_expand(applet, TRUE); macmenu_set_size(applet, xfce_panel_plugin_get_size(applet), mmb); // load config, set popup macmenu_load_from_rc(mmb); GtkWidget* label_toggle = gtk_check_menu_item_new_with_label("Hide Label"); g_signal_connect(label_toggle, "toggled", G_CALLBACK(on_label_toggled), mmb); gtk_widget_show(label_toggle); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(label_toggle), mmb->hide_label); gtk_check_menu_item_toggled(GTK_CHECK_MENU_ITEM(label_toggle)); xfce_panel_plugin_menu_insert_item(mmb->applet, GTK_MENU_ITEM(label_toggle)); #elif FOR_GNOME g_signal_connect(applet, "destroy", G_CALLBACK(macmenu_free_data), mmb); // setup panel applet gtk_widget_show_all(GTK_WIDGET(applet)); g_signal_connect(GTK_WIDGET(mmb->button), "pressed", G_CALLBACK(on_button_pressed), mmb); panel_applet_set_flags (applet, PANEL_APPLET_EXPAND_MAJOR); macmenu_set_size(applet, panel_applet_get_size(applet), mmb); // load config, set popup mmb->gconf = gconf_client_get_default(); macmenu_load_from_gconf(mmb); macmenu_write_gconf(mmb); static const char toggle_menu_xml [] = "<popup name=\"button3\">\n" " <menuitem name=\"hide_label\" " " verb=\"hide_label\" " " _label=\"_Hide Label\"\n" " type=\"toggle\"/>\n" "</popup>\n"; static const BonoboUIVerb toggle_menu_verbs[] = { BONOBO_UI_VERB_END }; panel_applet_setup_menu(mmb->applet, toggle_menu_xml, toggle_menu_verbs, mmb); BonoboUIComponent* popup_component = panel_applet_get_popup_component(mmb->applet); bonobo_ui_component_set_prop(popup_component, "/commands/hide_label", "state", mmb->hide_label ? "1": "0", NULL); bonobo_ui_component_add_listener(panel_applet_get_popup_component(mmb->applet), "hide_label", (BonoboUIListenerFn) on_label_toggled, mmb); on_label_toggled(NULL, NULL, 0, NULL, mmb); #endif // FOR_XFCE/FOR_GNOME add_all(mmb); XSetErrorHandler(handle_x_error); }
gboolean workspace_switcher_applet_fill (PanelApplet *applet) { PagerData *pager; GError *error; gboolean display_names; BonoboUIComponent* popup_component; panel_applet_add_preferences (applet, "/schemas/apps/workspace_switcher_applet/prefs", NULL); pager = g_new0 (PagerData, 1); pager->applet = GTK_WIDGET (applet); panel_applet_set_flags (PANEL_APPLET (pager->applet), PANEL_APPLET_EXPAND_MINOR); setup_gconf (pager); error = NULL; pager->n_rows = panel_applet_gconf_get_int (applet, "num_rows", &error); if (error) { g_printerr (_("Error loading num_rows value for Workspace Switcher: %s\n"), error->message); g_error_free (error); /* leave current value */ } pager->n_rows = CLAMP (pager->n_rows, 1, MAX_REASONABLE_ROWS); error = NULL; display_names = panel_applet_gconf_get_bool (applet, "display_workspace_names", &error); if (error) { g_printerr (_("Error loading display_workspace_names value for Workspace Switcher: %s\n"), error->message); g_error_free (error); /* leave current value */ } if (display_names) { pager->display_mode = WNCK_PAGER_DISPLAY_NAME; } else { pager->display_mode = WNCK_PAGER_DISPLAY_CONTENT; } error = NULL; pager->display_all = panel_applet_gconf_get_bool (applet, "display_all_workspaces", &error); if (error) { g_printerr (_("Error loading display_all_workspaces value for Workspace Switcher: %s\n"), error->message); g_error_free (error); /* leave current value */ } switch (panel_applet_get_orient (applet)) { case PANEL_APPLET_ORIENT_LEFT: case PANEL_APPLET_ORIENT_RIGHT: pager->orientation = GTK_ORIENTATION_VERTICAL; break; case PANEL_APPLET_ORIENT_UP: case PANEL_APPLET_ORIENT_DOWN: default: pager->orientation = GTK_ORIENTATION_HORIZONTAL; break; } pager->screen = wncklet_get_screen (pager->applet); /* because the pager doesn't respond to signals at the moment */ wnck_screen_force_update (pager->screen); pager->pager = wnck_pager_new (pager->screen); wnck_pager_set_shadow_type (WNCK_PAGER (pager->pager), GTK_SHADOW_IN); g_signal_connect (G_OBJECT (pager->pager), "destroy", G_CALLBACK (destroy_pager), pager); pager_update (pager); gtk_container_add (GTK_CONTAINER (pager->applet), pager->pager); gtk_widget_show (pager->pager); gtk_widget_show (pager->applet); g_signal_connect (G_OBJECT (pager->applet), "realize", G_CALLBACK (applet_realized), pager); g_signal_connect (G_OBJECT (pager->applet), "change_orient", G_CALLBACK (applet_change_orient), pager); g_signal_connect (G_OBJECT (pager->applet), "scroll-event", G_CALLBACK (applet_scroll), pager); g_signal_connect (G_OBJECT (pager->applet), "change_background", G_CALLBACK (applet_change_background), pager); panel_applet_set_background_widget (PANEL_APPLET (pager->applet), GTK_WIDGET (pager->applet)); panel_applet_setup_menu_from_file (PANEL_APPLET (pager->applet), NULL, "GNOME_WorkspaceSwitcherApplet.xml", NULL, pager_menu_verbs, pager); if (panel_applet_get_locked_down (PANEL_APPLET (pager->applet))) { BonoboUIComponent *popup_component; popup_component = panel_applet_get_popup_component (PANEL_APPLET (pager->applet)); bonobo_ui_component_set_prop (popup_component, "/commands/PagerPreferences", "hidden", "1", NULL); } popup_component = panel_applet_get_popup_component (PANEL_APPLET (pager->applet)); launchpad_integration_add_bonobo_ui(popup_component, "/popups/button3/LaunchpadItems"); return TRUE; }
gboolean window_list_applet_fill (PanelApplet *applet) { TasklistData *tasklist; GError *error; GConfValue *value; gint sizepref; tasklist = g_new0 (TasklistData, 1); tasklist->applet = GTK_WIDGET (applet); panel_applet_set_flags (PANEL_APPLET (tasklist->applet), PANEL_APPLET_EXPAND_MAJOR | PANEL_APPLET_EXPAND_MINOR | PANEL_APPLET_HAS_HANDLE); panel_applet_add_preferences (applet, "/schemas/apps/window_list_applet/prefs", NULL); setup_gconf (tasklist); error = NULL; tasklist->include_all_workspaces = panel_applet_gconf_get_bool (applet, "display_all_workspaces", &error); if (error) { g_error_free (error); tasklist->include_all_workspaces = FALSE; /* Default value */ } error = NULL; tasklist->grouping = -1; value = panel_applet_gconf_get_value (applet, "group_windows", &error); if (error) { g_error_free (error); } else if (value) { tasklist->grouping = get_grouping_type (value); gconf_value_free (value); } if (tasklist->grouping < 0) tasklist->grouping = WNCK_TASKLIST_AUTO_GROUP; /* Default value */ error = NULL; tasklist->move_unminimized_windows = panel_applet_gconf_get_bool (applet, "move_unminimized_windows", &error); if (error) { g_error_free (error); tasklist->move_unminimized_windows = TRUE; /* Default value */ } tasklist->size = panel_applet_get_size (applet); switch (panel_applet_get_orient (applet)) { case PANEL_APPLET_ORIENT_LEFT: case PANEL_APPLET_ORIENT_RIGHT: tasklist->orientation = GTK_ORIENTATION_VERTICAL; break; case PANEL_APPLET_ORIENT_UP: case PANEL_APPLET_ORIENT_DOWN: default: tasklist->orientation = GTK_ORIENTATION_HORIZONTAL; break; } tasklist->screen = wncklet_get_screen (tasklist->applet); /* because the tasklist doesn't respond to signals at the moment */ wnck_screen_force_update (tasklist->screen); tasklist->tasklist = wnck_tasklist_new (tasklist->screen); wnck_tasklist_set_icon_loader (WNCK_TASKLIST (tasklist->tasklist), icon_loader_func, tasklist, NULL); /* get size preferences */ error = NULL; sizepref = panel_applet_gconf_get_int (applet, "minimum_size", &error); if (error) { sizepref = 50; /* Default value */ g_error_free (error); } if (tasklist->orientation == GTK_ORIENTATION_HORIZONTAL) wnck_tasklist_set_minimum_width (WNCK_TASKLIST (tasklist->tasklist), sizepref); else wnck_tasklist_set_minimum_height (WNCK_TASKLIST (tasklist->tasklist), sizepref); error = NULL; sizepref = panel_applet_gconf_get_int (applet, "maximum_size", &error); if (error) { sizepref = 4096; /* Default value */ g_error_free (error); } tasklist->maximum_size = sizepref; g_signal_connect (G_OBJECT (tasklist->tasklist), "destroy", G_CALLBACK (destroy_tasklist), tasklist); g_signal_connect (G_OBJECT (tasklist->applet), "size_request", G_CALLBACK (applet_size_request), tasklist); tasklist_update (tasklist); gtk_widget_show (tasklist->tasklist); gtk_container_add (GTK_CONTAINER (tasklist->applet), tasklist->tasklist); g_signal_connect (G_OBJECT (tasklist->applet), "realize", G_CALLBACK (applet_realized), tasklist); g_signal_connect (G_OBJECT (tasklist->applet), "change_orient", G_CALLBACK (applet_change_orient), tasklist); g_signal_connect (G_OBJECT (tasklist->applet), "change_size", G_CALLBACK (applet_change_pixel_size), tasklist); g_signal_connect (G_OBJECT (tasklist->applet), "change_background", G_CALLBACK (applet_change_background), tasklist); panel_applet_set_background_widget (PANEL_APPLET (tasklist->applet), GTK_WIDGET (tasklist->applet)); panel_applet_setup_menu_from_file (PANEL_APPLET (tasklist->applet), NULL, "GNOME_WindowListApplet.xml", NULL, tasklist_menu_verbs, tasklist); if (panel_applet_get_locked_down (PANEL_APPLET (tasklist->applet))) { BonoboUIComponent *popup_component; popup_component = panel_applet_get_popup_component (PANEL_APPLET (tasklist->applet)); bonobo_ui_component_set_prop (popup_component, "/commands/TasklistPreferences", "hidden", "1", NULL); } gtk_widget_show (tasklist->applet); return TRUE; }
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 (); }