From 6ff13e6e23d4b0d291e5c338a97eea156fdaba90 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 24 Oct 2017 19:14:23 -0700 Subject: [PATCH] move 'check moves' menu to main window --- xwords4/linux/gtkboard.c | 15 +++------------ xwords4/linux/gtkboard.h | 4 ++++ xwords4/linux/gtkmain.c | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/xwords4/linux/gtkboard.c b/xwords4/linux/gtkboard.c index eb6c9b573..52eb7c820 100644 --- a/xwords4/linux/gtkboard.c +++ b/xwords4/linux/gtkboard.c @@ -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 diff --git a/xwords4/linux/gtkboard.h b/xwords4/linux/gtkboard.h index d46f26ba6..491be224f 100644 --- a/xwords4/linux/gtkboard.h +++ b/xwords4/linux/gtkboard.h @@ -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 diff --git a/xwords4/linux/gtkmain.c b/xwords4/linux/gtkmain.c index ad3119513..51da3f2ce 100644 --- a/xwords4/linux/gtkmain.c +++ b/xwords4/linux/gtkmain.c @@ -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 );