I need to get the GtkWindow or toplevel widget from my G_DEFINE_TYPE:
MyAppWindow.c:
#include "MyAppWindow.h"
struct _MyAppWindow
{
GtkApplicationWindow parent;
};
G_DEFINE_TYPE (MyAppWindow, my_app_window, GTK_TYPE_APPLICATION_WINDOW);
void my_app_window_init (MyAppWindow *app)
{
}
void my_app_window_class_init (MyAppWindowClass *class)
{
}
MyAppWindow * my_app_window_new (MyApp *app)
{
return g_object_new (MY_APP_WINDOW_TYPE, "application", app, NULL);
}
MyAppWindow.h:
#ifndef _MY_APP_WINDOW_H_INCLUDED
#define _MY_APP_WINDOW_H_INCLUDED
#include "MyApp.h"
#define MY_APP_WINDOW_TYPE (my_app_window_get_type ())
G_DECLARE_FINAL_TYPE (MyAppWindow, my_app_window, MY, APP_WINDOW, GtkApplicationWindow)
MyAppWindow * my_app_window_new (MyApp *);
#endif
In my activate prototype:
void my_app_activate (GApplication *app)
{
MyAppWindow *win = my_app_window_new (MY_APP (app));
// .. more code
g_action_map_add_action_entries (G_ACTION_MAP (app), entries, G_N_ELEMENTS (entries), app);
}
In some callback:
void cb_showmsg (GSimpleAction *action, GVariant *parameter, gpointer user_data)
{
// user_data: need here to access both GApplication and MyAppWindow
}
I need MyAppWindow to show or hide the toplevel window, any ideas?