Explicitly request literal mode after .Xr.
[netbsd-mini2440.git] / dist / nvi / gtk / gtk_main.c
bloba37aefffc9826cd422062fd2e11556ef4a1c5181
1 /* $NetBSD$ */
3 /*-
4 * Copyright (c) 1999
5 * Sven Verdoolaege. All rights reserved.
7 * See the LICENSE file for redistribution information.
8 */
10 #include "config.h"
12 #include <sys/types.h>
13 #include <sys/queue.h>
14 #include <bitstring.h>
16 #include <sys/time.h>
17 #include <sys/types.h>
18 #include <unistd.h>
20 #include "../common/common.h"
21 #include "../ipc/ip.h"
23 #include <gtk/gtk.h>
24 #include "gtkvi.h"
25 #include "gtkviwindow.h"
26 #include "gtkviscreen.h"
27 #include "../gtk/extern.h"
29 static void vi_destroyed __P((GtkWidget*,GtkWidget*));
30 static void vi_rename __P((GtkWidget*,gchar*,GtkWidget*));
31 static void vi_quit __P((GtkViWindow*, int));
33 static void win_toplevel(GtkViWindow *win);
34 static void create_toplevel(GtkVi *vi);
36 static GtkItemFactoryEntry menu_items[] = {
37 { "/_File", NULL, NULL, 0, "<Branch>" },
38 { "/File/E_xit", NULL, vi_quit, 1, NULL },
39 { "/File/_Quit", NULL, vi_quit, 0, NULL },
40 { "/_Window", NULL, NULL, 0, "<Branch>" },
41 { "/Window/New Window", NULL, win_toplevel, 0, NULL },
42 #if 0 /*wrong argument anyway*/
43 { "/Window/Show Terminal", NULL, gtk_vi_show_term, 1, NULL },
44 { "/Window/Show Vi", NULL, gtk_vi_show_term, 0, NULL },
45 #endif
48 static int n_toplevel = 0;
50 int
51 main(int argc, char **argv)
53 GtkVi *vi;
55 gtk_set_locale ();
57 gtk_init (&argc, &argv);
59 gtk_vi_init(&vi, argc, argv);
61 create_toplevel(vi);
63 gtk_main();
65 return 0;
68 static
69 void win_toplevel(GtkViWindow *win)
71 create_toplevel(win->vi);
74 static
75 void create_toplevel(GtkVi *vi)
77 GtkWidget *window;
78 GtkWidget *box, *menubar;
79 GtkWidget *vi_window;
80 gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
81 GtkItemFactory *factory;
82 GtkAccelGroup *accel;
84 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
85 ++n_toplevel;
87 box = gtk_vbox_new(FALSE, 0);
88 gtk_container_add(GTK_CONTAINER(window), box);
89 gtk_widget_show(box);
91 vi_window = gtk_vi_window_new(vi);
93 accel = gtk_accel_group_new();
94 factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel);
95 gtk_item_factory_create_items (factory, nmenu_items, menu_items, (gpointer)vi_window);
96 gtk_accel_group_attach(accel, GTK_OBJECT(window));
97 menubar = gtk_item_factory_get_widget (factory, "<main>");
98 gtk_widget_show(menubar);
99 gtk_box_pack_start(GTK_BOX(box), menubar, FALSE, FALSE, 0);
101 gtk_accel_group_attach(accel, GTK_OBJECT(vi_window));
102 gtk_widget_show(vi_window);
104 gtk_signal_connect(GTK_OBJECT(vi_window), "rename",
105 GTK_SIGNAL_FUNC(vi_rename),
106 window);
107 gtk_signal_connect(GTK_OBJECT(GTK_VI_WINDOW(vi_window)->vi_screen), "destroy",
108 GTK_SIGNAL_FUNC(vi_destroyed),
109 window);
110 gtk_box_pack_start(GTK_BOX(box), vi_window, TRUE, TRUE, 0);
113 gtk_widget_grab_focus(GTK_WIDGET(vi->vi));
116 gtk_widget_show(window);
119 static void
120 vi_quit(GtkViWindow *vi, gint write)
122 gtk_vi_quit(vi, write);
125 static void
126 vi_destroyed(GtkWidget *vi, GtkWidget *window)
128 gtk_widget_destroy(window);
129 if (!--n_toplevel)
130 gtk_main_quit();
133 static void
134 vi_rename(GtkWidget *vi, gchar *name, GtkWidget *window)
136 gtk_window_set_title(GTK_WINDOW(window), name);