3 * Sven Verdoolaege. All rights reserved.
5 * See the LICENSE file for redistribution information.
10 #include <sys/types.h>
11 #include <sys/queue.h>
12 #include <bitstring.h>
15 #include <sys/types.h>
18 #include "../common/common.h"
19 #include "../ipc/ip.h"
23 #include "gtkviwindow.h"
24 #include "gtkviscreen.h"
25 #include "../gtk/extern.h"
27 static void vi_destroyed
__P((GtkWidget
*,GtkWidget
*));
28 static void vi_rename
__P((GtkWidget
*,gchar
*,GtkWidget
*));
29 static void vi_quit
__P((GtkViWindow
*, int));
31 static void win_toplevel(GtkViWindow
*win
);
32 static void create_toplevel(GtkVi
*vi
);
34 static GtkItemFactoryEntry menu_items
[] = {
35 { "/_File", NULL
, NULL
, 0, "<Branch>" },
36 { "/File/E_xit", NULL
, vi_quit
, 1, NULL
},
37 { "/File/_Quit", NULL
, vi_quit
, 0, NULL
},
38 { "/_Window", NULL
, NULL
, 0, "<Branch>" },
39 { "/Window/New Window", NULL
, win_toplevel
, 0, NULL
},
40 #if 0 /*wrong argument anyway*/
41 { "/Window/Show Terminal", NULL
, gtk_vi_show_term
, 1, NULL
},
42 { "/Window/Show Vi", NULL
, gtk_vi_show_term
, 0, NULL
},
46 static int n_toplevel
= 0;
49 main(int argc
, char **argv
)
55 gtk_init (&argc
, &argv
);
57 gtk_vi_init(&vi
, argc
, argv
);
67 void win_toplevel(GtkViWindow
*win
)
69 create_toplevel(win
->vi
);
73 void create_toplevel(GtkVi
*vi
)
76 GtkWidget
*box
, *menubar
;
78 gint nmenu_items
= sizeof (menu_items
) / sizeof (menu_items
[0]);
79 GtkItemFactory
*factory
;
82 window
= gtk_window_new(GTK_WINDOW_TOPLEVEL
);
85 box
= gtk_vbox_new(FALSE
, 0);
86 gtk_container_add(GTK_CONTAINER(window
), box
);
89 vi_window
= gtk_vi_window_new(vi
);
91 accel
= gtk_accel_group_new();
92 factory
= gtk_item_factory_new (GTK_TYPE_MENU_BAR
, "<main>", accel
);
93 gtk_item_factory_create_items (factory
, nmenu_items
, menu_items
, (gpointer
)vi_window
);
94 gtk_accel_group_attach(accel
, GTK_OBJECT(window
));
95 menubar
= gtk_item_factory_get_widget (factory
, "<main>");
96 gtk_widget_show(menubar
);
97 gtk_box_pack_start(GTK_BOX(box
), menubar
, FALSE
, FALSE
, 0);
99 gtk_accel_group_attach(accel
, GTK_OBJECT(vi_window
));
100 gtk_widget_show(vi_window
);
102 gtk_signal_connect(GTK_OBJECT(vi_window
), "rename",
103 GTK_SIGNAL_FUNC(vi_rename
),
105 gtk_signal_connect(GTK_OBJECT(GTK_VI_WINDOW(vi_window
)->vi_screen
), "destroy",
106 GTK_SIGNAL_FUNC(vi_destroyed
),
108 gtk_box_pack_start(GTK_BOX(box
), vi_window
, TRUE
, TRUE
, 0);
111 gtk_widget_grab_focus(GTK_WIDGET(vi->vi));
114 gtk_widget_show(window
);
118 vi_quit(GtkViWindow
*vi
, gint write
)
120 gtk_vi_quit(vi
, write
);
124 vi_destroyed(GtkWidget
*vi
, GtkWidget
*window
)
126 gtk_widget_destroy(window
);
132 vi_rename(GtkWidget
*vi
, gchar
*name
, GtkWidget
*window
)
134 gtk_window_set_title(GTK_WINDOW(window
), name
);