From e2cf25fc0a51de7f1305fe6a22329d0c945977b1 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 18 May 2019 09:48:22 -0700 Subject: [PATCH] add menuitem to copy relayid to gtk clipboard (I'm tired of typing it manually.) --- xwords4/linux/gtkmain.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/xwords4/linux/gtkmain.c b/xwords4/linux/gtkmain.c index 4f5a5b8b2..f44912bd7 100644 --- a/xwords4/linux/gtkmain.c +++ b/xwords4/linux/gtkmain.c @@ -519,6 +519,17 @@ handle_movescheck( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* apg ) relaycon_checkMsgs( params ); } +static void +handle_relayid_to_clip( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* apg ) +{ + LaunchParams* params = apg->params; + XP_U32 relayID = linux_getDevIDRelay( params ); + gchar str[32]; + snprintf( &str[0], VSIZE(str), "%d", relayID ); + GtkClipboard *clipboard = gtk_clipboard_get( GDK_SELECTION_CLIPBOARD ); + gtk_clipboard_set_text( clipboard, str, strlen(str) ); +} + static void makeGamesWindow( GtkAppGlobals* apg ) { @@ -550,6 +561,8 @@ makeGamesWindow( GtkAppGlobals* apg ) (void)createAddItem( netMenu, "Check for moves", (GCallback)handle_movescheck, apg ); } + (void)createAddItem( netMenu, "copy relayid", + (GCallback)handle_relayid_to_clip, apg ); gtk_widget_show( menubar ); gtk_box_pack_start( GTK_BOX(vbox), menubar, FALSE, TRUE, 0 );