mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Add 'Quit' menu item, and fix invisible "File" on gtk2
I didn't even notice that the "File" part of the file menu no longer
showed up, since the keyboard accelerator for ^S worked fine.. But
apparently there's no default label associated with GTK_STOCK_FILE in
gtk2, so the "File" text went away with the conversion to GtkUIManager
in commit 4d62478e14
("Use the newer GtkUIManager for menu creation.")
The addition of a Quit menu entry with the associated keyboard
accelerator also makes ^Q "just work".
Of course, if we actually tracked dirty state etc, we could perhaps ask
the user whether they wanted to save or something. But I'm not exactly
famous for my GUI chops, so ..
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
c938679726
commit
a6b9eaee0a
1 changed files with 11 additions and 4 deletions
15
main.c
15
main.c
|
@ -128,10 +128,16 @@ static void file_save(GtkWidget *w, gpointer data)
|
||||||
gtk_widget_destroy(dialog);
|
gtk_widget_destroy(dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void quit(GtkWidget *w, gpointer data)
|
||||||
|
{
|
||||||
|
gtk_main_quit();
|
||||||
|
}
|
||||||
|
|
||||||
static GtkActionEntry menu_items[] = {
|
static GtkActionEntry menu_items[] = {
|
||||||
{ "FileMenuAction", GTK_STOCK_FILE, NULL, NULL, NULL, NULL},
|
{ "FileMenuAction", GTK_STOCK_FILE, "File", NULL, NULL, NULL},
|
||||||
{ "OpenFile", GTK_STOCK_OPEN, NULL, "<control>O", NULL, G_CALLBACK(file_open) },
|
{ "OpenFile", GTK_STOCK_OPEN, NULL, "<control>O", NULL, G_CALLBACK(file_open) },
|
||||||
{ "SaveFile", GTK_STOCK_SAVE, NULL, "<control>S", NULL, G_CALLBACK(file_save) },
|
{ "SaveFile", GTK_STOCK_SAVE, NULL, "<control>S", NULL, G_CALLBACK(file_save) },
|
||||||
|
{ "Quit", GTK_STOCK_QUIT, NULL, "<control>Q", NULL, G_CALLBACK(quit) },
|
||||||
};
|
};
|
||||||
static gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
|
static gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
|
||||||
|
|
||||||
|
@ -141,6 +147,7 @@ static const gchar* ui_string = " \
|
||||||
<menu name=\"FileMenu\" action=\"FileMenuAction\"> \
|
<menu name=\"FileMenu\" action=\"FileMenuAction\"> \
|
||||||
<menuitem name=\"Open\" action=\"OpenFile\" /> \
|
<menuitem name=\"Open\" action=\"OpenFile\" /> \
|
||||||
<menuitem name=\"Save\" action=\"SaveFile\" /> \
|
<menuitem name=\"Save\" action=\"SaveFile\" /> \
|
||||||
|
<menuitem name=\"Quit\" action=\"Quit\" /> \
|
||||||
</menu> \
|
</menu> \
|
||||||
</menubar> \
|
</menubar> \
|
||||||
</ui> \
|
</ui> \
|
||||||
|
@ -190,7 +197,7 @@ int main(int argc, char **argv)
|
||||||
report_dives();
|
report_dives();
|
||||||
|
|
||||||
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||||
g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(on_destroy), NULL);
|
g_signal_connect(G_OBJECT(win), "destroy", G_CALLBACK(on_destroy), NULL);
|
||||||
main_window = win;
|
main_window = win;
|
||||||
|
|
||||||
vbox = gtk_vbox_new(FALSE, 0);
|
vbox = gtk_vbox_new(FALSE, 0);
|
||||||
|
|
Loading…
Reference in a new issue