Trying some app_menu stuff

This commit is contained in:
Markus Koch 2017-02-16 22:21:00 +01:00
parent b8e7169608
commit 844813709b
2 changed files with 25 additions and 1 deletions

View File

@ -10,17 +10,31 @@ int main(int argc, char *argv[])
struct mainWindow *mainWindow; struct mainWindow *mainWindow;
struct mdiary_settings *settings; struct mdiary_settings *settings;
gchar *settings_path; gchar *settings_path;
GtkApplication *app;
gtk_init(&argc, &argv); gtk_init(&argc, &argv);
mainWindow = mainWindow_new(); mainWindow = mainWindow_new();
app = gtk_application_new(0, G_APPLICATION_FLAGS_NONE);
g_application_register(app, NULL, NULL);
gtk_application_add_window(app, mainWindow->mainWindow);
GMenu *app_menu = g_menu_new();
GMenu *p1 = g_menu_new();
GMenu *p2 = g_menu_new();
g_menu_append(p1, "Settings", "win.settings");
g_menu_append(p2, "Quit", "win.quit");
g_menu_append_section(app_menu, NULL, p1);
g_menu_append_section(app_menu, NULL, p2);
gtk_application_set_app_menu(app, G_MENU_MODEL(app_menu));
settings_path = g_strdup_printf("%s/.mdiary.conf", g_get_home_dir()); settings_path = g_strdup_printf("%s/.mdiary.conf", g_get_home_dir());
settings = mdiary_settings_new(mainWindow); settings = mdiary_settings_new(mainWindow);
mdiary_load_settings(settings_path, settings); mdiary_load_settings(settings_path, settings);
gtk_widget_show(mainWindow->mainWindow); gtk_widget_show(mainWindow->mainWindow);
gtk_main(); /* gtk_main(); */
g_application_run(G_APPLICATION(app), argc, argv);
mdiary_save_settings(settings_path, settings); mdiary_save_settings(settings_path, settings);
mdiary_settings_free(settings); mdiary_settings_free(settings);

View File

@ -451,6 +451,15 @@ void mainWindow_webkit_set_enabled(struct mainWindow *mainWindow, gboolean state
} }
} }
static void mainWindow_configure_menu(struct mainWindow *mainWindow)
{
GMenu *menu;
menu = g_menu_new();
g_menu_append (menu, "Copy", "win.copy");
}
/** /**
* @brief mainWindow_new creates a new mainWindow. * @brief mainWindow_new creates a new mainWindow.
* @return Returns struct mainWindow * * @return Returns struct mainWindow *
@ -504,6 +513,7 @@ struct mainWindow *mainWindow_new()
g_object_unref(G_OBJECT(builder)); g_object_unref(G_OBJECT(builder));
mainWindow_configure_menu(mainWindow);
mainWindow_configure_treeView(mainWindow); mainWindow_configure_treeView(mainWindow);
mainWindow->webkitView = NULL; mainWindow->webkitView = NULL;
mainWindow->webkitScrollArea = NULL; mainWindow->webkitScrollArea = NULL;