Compare commits
3 Commits
6c462332be
...
128a205b29
Author | SHA1 | Date | |
---|---|---|---|
128a205b29 | |||
faa06072f3 | |||
2c4f0c273a |
68
src/main.c
68
src/main.c
@ -5,40 +5,68 @@
|
|||||||
#include "mdiary.h"
|
#include "mdiary.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
static void quit_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
|
||||||
|
{
|
||||||
|
g_print("TODO\n");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void settings_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
|
||||||
|
{
|
||||||
|
g_print("nTODO\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
const GActionEntry app_actions[] = {
|
||||||
|
{ "quit", quit_cb },
|
||||||
|
{ "settings", settings_cb }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void activate(GApplication *app, gpointer user_data)
|
||||||
{
|
{
|
||||||
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);
|
|
||||||
|
|
||||||
mainWindow = mainWindow_new();
|
mainWindow = mainWindow_new();
|
||||||
app = gtk_application_new(0, G_APPLICATION_FLAGS_NONE);
|
gtk_application_add_window(GTK_APPLICATION(app), GTK_WINDOW(mainWindow->mainWindow));
|
||||||
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(); */
|
|
||||||
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);
|
||||||
g_free(settings_path);
|
g_free(settings_path);
|
||||||
|
}
|
||||||
return 0;
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
GtkApplication *app;
|
||||||
|
GMenu *app_menu;
|
||||||
|
GMenu *p1;
|
||||||
|
GMenu *p2;
|
||||||
|
int status;
|
||||||
|
|
||||||
|
app = gtk_application_new("net.notsyncing.mdiary", G_APPLICATION_FLAGS_NONE);
|
||||||
|
g_application_register(GTK_APPLICATION(app), NULL, NULL);
|
||||||
|
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
|
||||||
|
|
||||||
|
app_menu = g_menu_new();
|
||||||
|
p1 = g_menu_new();
|
||||||
|
p2 = g_menu_new();
|
||||||
|
g_menu_append(p1, "Settings", "app.settings");
|
||||||
|
g_menu_append(p2, "Quit", "app.quit");
|
||||||
|
g_menu_append_section(app_menu, NULL, G_MENU_MODEL(p1));
|
||||||
|
g_menu_append_section(app_menu, NULL, G_MENU_MODEL(p2));
|
||||||
|
gtk_application_set_app_menu(app, G_MENU_MODEL(app_menu));
|
||||||
|
g_action_map_add_action_entries(G_ACTION_MAP(app), app_actions, G_N_ELEMENTS(app_actions), app);
|
||||||
|
gtk_application_set_app_menu(GTK_APPLICATION(app), G_MENU_MODEL(app_menu));
|
||||||
|
g_object_unref(p1);
|
||||||
|
g_object_unref(p2);
|
||||||
|
g_object_unref(app_menu);
|
||||||
|
|
||||||
|
status = g_application_run(G_APPLICATION(app), argc, argv);
|
||||||
|
g_object_unref(app);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user