5 * Sven Verdoolaege. All rights reserved.
7 * See the LICENSE file for redistribution information.
12 #include <sys/types.h>
13 #include <sys/queue.h>
14 #include <bitstring.h>
17 #include <sys/types.h>
20 #include "../common/common.h"
21 #include "../ipc/ip.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
},
48 static int n_toplevel
= 0;
51 main(int argc
, char **argv
)
57 gtk_init (&argc
, &argv
);
59 gtk_vi_init(&vi
, argc
, argv
);
69 void win_toplevel(GtkViWindow
*win
)
71 create_toplevel(win
->vi
);
75 void create_toplevel(GtkVi
*vi
)
78 GtkWidget
*box
, *menubar
;
80 gint nmenu_items
= sizeof (menu_items
) / sizeof (menu_items
[0]);
81 GtkItemFactory
*factory
;
84 window
= gtk_window_new(GTK_WINDOW_TOPLEVEL
);
87 box
= gtk_vbox_new(FALSE
, 0);
88 gtk_container_add(GTK_CONTAINER(window
), 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
),
107 gtk_signal_connect(GTK_OBJECT(GTK_VI_WINDOW(vi_window
)->vi_screen
), "destroy",
108 GTK_SIGNAL_FUNC(vi_destroyed
),
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
);
120 vi_quit(GtkViWindow
*vi
, gint write
)
122 gtk_vi_quit(vi
, write
);
126 vi_destroyed(GtkWidget
*vi
, GtkWidget
*window
)
128 gtk_widget_destroy(window
);
134 vi_rename(GtkWidget
*vi
, gchar
*name
, GtkWidget
*window
)
136 gtk_window_set_title(GTK_WINDOW(window
), name
);