summaryrefslogtreecommitdiff
path: root/components/shell/shell.c
blob: 0c9c5e1cf084347cf7a2bc5d4c23b76d29277dc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <errno.h>
#include <liboaf/liboaf.h>
#include <gnome.h>
#include <bonobo.h>
#include <zvt/zvtterm.h>

#include <popt.h>
extern struct poptOption oaf_popt_options[];

static BonoboObject *
shell_factory (BonoboGenericFactory *Factory, void *closure)
{
    BonoboControl	*control;
    GtkWidget		*zvtterm;
    int			pid;

    /* Create the control. */
    zvtterm = zvt_term_new_with_size (80, 24);
    gtk_widget_show (zvtterm);

    pid = zvt_term_forkpty (ZVT_TERM (zvtterm), 0);
    if (pid == 0) {
      execl ("/bin/bash", "-bash", NULL);
      fprintf (stderr, "ERROR: %s\n", strerror (errno));
      exit (1);
    }

    control = bonobo_control_new (zvtterm);

    return BONOBO_OBJECT (control);
}

void
shell_factory_init (void)
{
    static BonoboGenericFactory *xterm_factory = NULL;
    char *registration_id;

    if (xterm_factory != NULL)
	return;

    registration_id = oaf_make_registration_id (, g_getenv ("DISPLAY"));
    factory = bonobo_generic_factory_new_multi "OAFIID:shell_factory:10a7d344-c4cd-402f-9e05-bd591bbc5618", shell_factory, NULL);
    g_free (registration_id);


    if (xterm_factory == NULL)
	g_error ("I could not register a Factory.");
}

CORBA_Environment ev;
CORBA_ORB orb;

static void
init_bonobo (int argc, char **argv)
{
    /* Disable session manager connection */
    gnome_client_disable_master_connection ();

    gnomelib_register_popt_table (oaf_popt_options, oaf_get_popt_table_name ());
    orb = oaf_init (argc, argv);

    gnome_init_with_popt_table ("xterm-control-factory", "0.0",
				argc, argv);
    gdk_rgb_init ();

    if (!bonobo_init (orb, NULL, NULL))
	g_error (_("Could not initialize Bonobo"));
}

int
main (int argc, char **argv)
{
    CORBA_exception_init (&ev);

    init_bonobo (argc, argv);

    shell_factory_init ();

    bonobo_main ();

    return 0;
}