Ticket #1165: openmoko-terminal2-patch-g-option-simple.diff

File openmoko-terminal2-patch-g-option-simple.diff, 1.4 KB (added by haakeyar-mailinglists@…, 11 years ago)

Sorry, attached to the wrong bug.

  • src/mainwindow.vala

     
    3636    private ToolButton btn_zoom_out; 
    3737    private ToolButton btn_paste; 
    3838 
     39    private static string cmdln_parsed_initial_command; 
    3940    private string initial_command; 
    4041 
    4142    public MainWindow() 
     
    205206        Gtk.main(); 
    206207    } 
    207208 
     209    const OptionEntry[] options = { 
     210        { "command", 'e', 0, OptionArg.STRING, out cmdln_parsed_initial_command, "Execute COMMAND inside the terminal.", "COMMAND"}, 
     211        { null } 
     212    }; 
     213 
    208214    static int main (string[] args) { 
    209         if ( args.length == 2 || args.length > 3 ) 
     215        try { 
     216            Gtk.init_with_args(ref args.length, ref args, " - a lightweight terminal for the OpenMoko environment", options, null); 
     217        } catch (Error e) 
    210218        { 
    211             stdout.printf( "Usage: %s [ -e <initial command> ]\n", args[0] ); 
    212             return 0; 
     219            stderr.printf("Error: %s\n", e.message); 
     220            return 1;  
    213221        } 
    214  
    215         Gtk.init(ref args); 
     222         
    216223        var window = new MainWindow(); 
    217         if ( args.length == 3 && args[1] == "-e" ) 
    218             window.setup_command( args[2] ); 
     224        if ( cmdln_parsed_initial_command != null ) 
     225        { 
     226            window.setup_command( cmdln_parsed_initial_command ); 
     227        } 
    219228        window.run(); 
    220229 
    221230        return 0;