bring menu handler change to gtk/win
parent
eb51fa8228
commit
56d2b8765a
|
@ -472,11 +472,11 @@ int main(int argc, char* argv[])
|
|||
/* Create the main menu bar */
|
||||
createMainMenu(app->mainWindow, app);
|
||||
|
||||
/* Initialize the context menu */
|
||||
initContext(app);
|
||||
/* Initialize the context menu handler */
|
||||
GTKContextMenuHandler *handler = new GTKContextMenuHandler(app);
|
||||
|
||||
/* Set context menu callback for the core */
|
||||
app->core->setContextMenuCallback(menuContext);
|
||||
/* Set context menu handler for the core */
|
||||
app->core->setContextMenuHandler(handler);
|
||||
|
||||
#ifdef GNOME
|
||||
/* Set window contents (GNOME) */
|
||||
|
|
|
@ -42,16 +42,18 @@ static GtkMenu* CreateAlternateSurfaceMenu(const vector<string>& surfaces);
|
|||
static AppData* app;
|
||||
|
||||
|
||||
/* Initializer. Sets the appData, since there is no way to pass it. */
|
||||
void initContext(AppData* a)
|
||||
/* Initializer. Sets the appData */
|
||||
GTKContextMenuHandler::GTKContextMenuHandler(AppData* _app) :
|
||||
CelestiaCore::ContextMenuHandler()
|
||||
{
|
||||
app = a;
|
||||
// FIXME: a workaround to have it referenced by any menu callback
|
||||
app = _app;
|
||||
}
|
||||
|
||||
|
||||
/* ENTRY: Context menu (event handled by appCore)
|
||||
* Normally, float x and y, but unused, so removed. */
|
||||
void menuContext(float, float, Selection sel)
|
||||
void GTKContextMenuHandler::requestContextMenu(float, float, Selection sel)
|
||||
{
|
||||
GtkWidget* popup = gtk_menu_new();
|
||||
string name;
|
||||
|
|
|
@ -21,11 +21,12 @@
|
|||
|
||||
#include "common.h"
|
||||
|
||||
class GTKContextMenuHandler : public CelestiaCore::ContextMenuHandler
|
||||
{
|
||||
public:
|
||||
GTKContextMenuHandler(AppData* app);
|
||||
|
||||
/* Initializer Function */
|
||||
void initContext(AppData* a);
|
||||
|
||||
/* Entry Function */
|
||||
void menuContext(float, float, Selection sel);
|
||||
void requestContextMenu(float, float, Selection sel);
|
||||
};
|
||||
|
||||
#endif /* GTK_MENU_CONTEXT_H */
|
||||
|
|
|
@ -1786,12 +1786,6 @@ void ShowWWWInfo(const Selection& sel)
|
|||
}
|
||||
|
||||
|
||||
void ContextMenu(float x, float y, Selection sel)
|
||||
{
|
||||
handlePopupMenu(mainWindow, x, y, sel);
|
||||
}
|
||||
|
||||
|
||||
bool EnableFullScreen(const DEVMODE& dm)
|
||||
{
|
||||
DEVMODE devMode;
|
||||
|
@ -2349,6 +2343,15 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class WinContextMenuHandler : public CelestiaCore::ContextMenuHandler
|
||||
{
|
||||
public:
|
||||
void requestContextMenu(float x, float y, Selection sel)
|
||||
{
|
||||
handlePopupMenu(mainWindow, x, y, sel);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static bool InitJoystick(JOYCAPS& caps)
|
||||
{
|
||||
|
@ -3524,7 +3527,7 @@ int APIENTRY WinMain(HINSTANCE hInstance,
|
|||
BuildScriptsMenu(menuBar, ScriptsDirectory);
|
||||
syncMenusWithRendererState();
|
||||
|
||||
appCore->setContextMenuCallback(ContextMenu);
|
||||
appCore->setContextMenuHandler(new WinContextMenuHandler());
|
||||
|
||||
bReady = true;
|
||||
|
||||
|
|
Loading…
Reference in New Issue