move 'check moves' menu to main window

This commit is contained in:
Eric House 2017-10-24 19:14:23 -07:00
parent 342d229be1
commit 6ff13e6e23
3 changed files with 25 additions and 12 deletions

View file

@ -1178,11 +1178,6 @@ handle_memstats( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
} /* handle_memstats */
static void
handle_movescheck( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
{
checkForMsgsNow( globals->cGlobals.params );
}
#endif
#ifdef XWFEATURE_ACTIVERECT
@ -1207,15 +1202,15 @@ frame_active( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals )
}
#endif
static GtkWidget*
GtkWidget*
createAddItem( GtkWidget* parent, gchar* label,
GCallback handlerFunc, GtkGameGlobals* globals )
GCallback handlerFunc, gpointer closure )
{
GtkWidget* item = gtk_menu_item_new_with_label( label );
if ( handlerFunc != NULL ) {
g_signal_connect( item, "activate", G_CALLBACK(handlerFunc),
globals );
closure );
}
gtk_menu_shell_append( GTK_MENU_SHELL(parent), item );
@ -1289,10 +1284,6 @@ makeMenus( GtkGameGlobals* globals )
#ifdef MEM_DEBUG
(void)createAddItem( fileMenu, "Mem stats",
(GCallback)handle_memstats, globals );
if ( globals->cGlobals.params->useHTTP ) {
(void)createAddItem( fileMenu, "Check for moves",
(GCallback)handle_movescheck, globals );
}
#endif
#ifdef XWFEATURE_ACTIVERECT

View file

@ -187,6 +187,10 @@ XP_Bool loadGameNoDraw( GtkGameGlobals* globals, LaunchParams* params,
sqlite3_int64 rowid );
void destroy_board_window( GtkWidget* widget, GtkGameGlobals* globals );
GtkWidget* makeAddSubmenu( GtkWidget* menubar, gchar* label );
GtkWidget* createAddItem( GtkWidget* parent, gchar* label,
GCallback handlerFunc, gpointer closure );
#endif /* PLATFORM_GTK */
#endif

View file

@ -509,6 +509,13 @@ trySetWinConfig( GtkAppGlobals* apg )
gtk_window_move (GTK_WINDOW(apg->window), xx, yy );
}
static void
handle_movescheck( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* apg )
{
LaunchParams* params = apg->params;
checkForMsgsNow( params );
}
static void
makeGamesWindow( GtkAppGlobals* apg )
{
@ -532,6 +539,17 @@ makeGamesWindow( GtkAppGlobals* apg )
GtkWidget* vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add( GTK_CONTAINER(swin), vbox );
gtk_widget_show( vbox );
// add menubar here
GtkWidget* menubar = gtk_menu_bar_new();
GtkWidget* netMenu = makeAddSubmenu( menubar, "Network" );
if ( params->useHTTP ) {
(void)createAddItem( netMenu, "Check for moves",
(GCallback)handle_movescheck, apg );
}
gtk_widget_show( menubar );
gtk_box_pack_start( GTK_BOX(vbox), menubar, FALSE, TRUE, 0 );
GtkWidget* list = init_games_list( apg );
gtk_container_add( GTK_CONTAINER(vbox), list );