Exemplo n.º 1
0
function setup_menu($vbox, $menus)
{
    // note 1
    $menubar = new GtkMenuBar();
    $vbox->pack_start($menubar, 0, 0);
    foreach ($menus as $toplevel => $sublevels) {
        $menubar->append($top_menu = new GtkMenuItem($toplevel));
        $menu = new GtkMenu();
        $top_menu->set_submenu($menu);
        foreach ($sublevels as $submenu) {
            if (is_array($submenu)) {
                // set up radio menus
                $i = 0;
                $radio[0] = null;
                foreach ($submenu as $radio_item) {
                    // note 3
                    $radio[$i] = new GtkRadioMenuItem($radio[0], $radio_item);
                    $radio[$i]->connect('toggled', "on_toggle");
                    $menu->append($radio[$i]);
                    ++$i;
                }
                $radio[0]->set_active(1);
                // select the first item
            } else {
                if ($submenu == '<hr>') {
                    $menu->append(new GtkSeparatorMenuItem());
                } else {
                    $menu->append($menu_item = new GtkMenuItem($submenu));
                    $menu_item->connect('activate', 'on_menu_select');
                }
            }
        }
    }
}
Exemplo n.º 2
0
		private function GenerateMenus($menu, $menus){
			foreach($menus AS $key => $value){
				$newmenu = new GtkMenuItem($key);
				
				if (is_array($value)){
					$submenu = new GtkMenu();
					$submenu->set_size_request(135, -1);
					$this->GenerateMenus($submenu, $value);
					
					$newmenu->set_submenu($submenu);
				}else{
					$newmenu->connect("activate", array($this, "MenuClicked"), $value);
				}
				
				$menu->append($newmenu);
			}
		}
Exemplo n.º 3
0
 /**
  * Create the menu.
  *
  * The menu is very simple. It an exit menu item, which exits
  * the application, and an about menu item, which shows some
  * basic information about the application itself.
  *
  * @access private
  * @param  none
  * @return &object The GtkMenuBar
  */
 function &_createMenu()
 {
     // Create the menu bar.
     $menuBar = new GtkMenuBar();
     // Create the main (only) menu item.
     $phpHeader = new GtkMenuItem('PHPUnit');
     // Add the menu item to the menu bar.
     $menuBar->append($phpHeader);
     // Create the PHPUnit menu.
     $phpMenu = new GtkMenu();
     // Add the menu items
     $about = new GtkMenuItem('About...');
     $about->connect('activate', array(&$this, 'about'));
     $phpMenu->append($about);
     $exit = new GtkMenuItem('Exit');
     $exit->connect_object('activate', array('gtk', 'main_quit'));
     $phpMenu->append($exit);
     // Complete the menu.
     $phpHeader->set_submenu($phpMenu);
     return $menuBar;
 }