App menu now works properly
This commit is contained in:
parent
128a205b29
commit
cfd4531dde
@ -78,7 +78,6 @@
|
|||||||
<property name="width_request">720</property>
|
<property name="width_request">720</property>
|
||||||
<property name="height_request">405</property>
|
<property name="height_request">405</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<signal name="destroy" handler="gtk_main_quit" swapped="no"/>
|
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkPaned" id="mainPane">
|
<object class="GtkPaned" id="mainPane">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
14
src/main.c
14
src/main.c
@ -7,12 +7,15 @@
|
|||||||
|
|
||||||
static void quit_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
|
static void quit_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
|
||||||
{
|
{
|
||||||
g_print("TODO\n");
|
struct mainWindow *mainWindow = *((struct mainWindow **) user_data);
|
||||||
|
|
||||||
|
gtk_window_close(GTK_WINDOW(mainWindow->mainWindow));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void settings_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
|
static void settings_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
|
||||||
{
|
{
|
||||||
|
struct mainWindow *mainWindow = *((struct mainWindow **) user_data);
|
||||||
|
|
||||||
g_print("nTODO\n");
|
g_print("nTODO\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,7 +26,7 @@ const GActionEntry app_actions[] = {
|
|||||||
|
|
||||||
static void activate(GApplication *app, gpointer user_data)
|
static void activate(GApplication *app, gpointer user_data)
|
||||||
{
|
{
|
||||||
struct mainWindow *mainWindow;
|
struct mainWindow *mainWindow = *((struct mainWindow **) user_data);
|
||||||
struct mdiary_settings *settings;
|
struct mdiary_settings *settings;
|
||||||
gchar *settings_path;
|
gchar *settings_path;
|
||||||
|
|
||||||
@ -43,6 +46,7 @@ static void activate(GApplication *app, gpointer user_data)
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
struct mainWindow *mainWindow;
|
||||||
GtkApplication *app;
|
GtkApplication *app;
|
||||||
GMenu *app_menu;
|
GMenu *app_menu;
|
||||||
GMenu *p1;
|
GMenu *p1;
|
||||||
@ -50,8 +54,8 @@ int main(int argc, char *argv[])
|
|||||||
int status;
|
int status;
|
||||||
|
|
||||||
app = gtk_application_new("net.notsyncing.mdiary", G_APPLICATION_FLAGS_NONE);
|
app = gtk_application_new("net.notsyncing.mdiary", G_APPLICATION_FLAGS_NONE);
|
||||||
g_application_register(GTK_APPLICATION(app), NULL, NULL);
|
g_application_register(G_APPLICATION(app), NULL, NULL);
|
||||||
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
|
g_signal_connect(app, "activate", G_CALLBACK(activate), &mainWindow);
|
||||||
|
|
||||||
app_menu = g_menu_new();
|
app_menu = g_menu_new();
|
||||||
p1 = g_menu_new();
|
p1 = g_menu_new();
|
||||||
@ -61,7 +65,7 @@ int main(int argc, char *argv[])
|
|||||||
g_menu_append_section(app_menu, NULL, G_MENU_MODEL(p1));
|
g_menu_append_section(app_menu, NULL, G_MENU_MODEL(p1));
|
||||||
g_menu_append_section(app_menu, NULL, G_MENU_MODEL(p2));
|
g_menu_append_section(app_menu, NULL, G_MENU_MODEL(p2));
|
||||||
gtk_application_set_app_menu(app, G_MENU_MODEL(app_menu));
|
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);
|
g_action_map_add_action_entries(G_ACTION_MAP(app), app_actions, G_N_ELEMENTS(app_actions), &mainWindow);
|
||||||
gtk_application_set_app_menu(GTK_APPLICATION(app), G_MENU_MODEL(app_menu));
|
gtk_application_set_app_menu(GTK_APPLICATION(app), G_MENU_MODEL(app_menu));
|
||||||
g_object_unref(p1);
|
g_object_unref(p1);
|
||||||
g_object_unref(p2);
|
g_object_unref(p2);
|
||||||
|
Loading…
Reference in New Issue
Block a user