mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-29 10:26:36 +01:00
start on a gtk dialog displaying/editing knowns
This commit is contained in:
parent
21483cf861
commit
6c5d1b082f
4 changed files with 133 additions and 2 deletions
|
@ -208,7 +208,9 @@ GTK_OBJS = \
|
|||
$(BUILD_PLAT_DIR)/gtkutils.o \
|
||||
$(BUILD_PLAT_DIR)/gtkntilesask.o \
|
||||
$(BUILD_PLAT_DIR)/gtkaskdict.o \
|
||||
$(BUILD_PLAT_DIR)/gtkchat.o
|
||||
$(BUILD_PLAT_DIR)/gtkchat.o \
|
||||
$(BUILD_PLAT_DIR)/gtkkpdlg.o \
|
||||
|
||||
endif
|
||||
ifdef DO_CURSES
|
||||
CURSES_OBJS = \
|
||||
|
|
90
xwords4/linux/gtkkpdlg.c
Normal file
90
xwords4/linux/gtkkpdlg.c
Normal file
|
@ -0,0 +1,90 @@
|
|||
/* -*- compile-command: "make MEMDEBUG=TRUE -j5"; -*- */
|
||||
/*
|
||||
* Copyright 2001-2014 by Eric House (xwords@eehouse.org). All rights
|
||||
* reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifdef PLATFORM_GTK
|
||||
|
||||
#include "gtkkpdlg.h"
|
||||
#include "knownplyr.h"
|
||||
#include "strutils.h"
|
||||
|
||||
static GtkWidget*
|
||||
makeForPlayer( XW_DUtilCtxt* dutil, const gchar* name )
|
||||
{
|
||||
GtkWidget* vbox = NULL;
|
||||
|
||||
CommsAddrRec addr;
|
||||
if ( kplr_getAddr( dutil, NULL_XWE, name, &addr ) ) {
|
||||
vbox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 );
|
||||
|
||||
GtkWidget* label = gtk_label_new( name );
|
||||
gtk_box_pack_start( GTK_BOX(vbox), label, FALSE, TRUE, 0 );
|
||||
|
||||
if ( addr_hasType( &addr, COMMS_CONN_MQTT ) ) {
|
||||
XP_UCHAR buf[32];
|
||||
formatMQTTDevID( &addr.u.mqtt.devID, buf, VSIZE(buf) );
|
||||
label = gtk_label_new( buf );
|
||||
gtk_box_pack_start( GTK_BOX(vbox), label, FALSE, TRUE, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
return vbox;
|
||||
}
|
||||
|
||||
static void
|
||||
showDialog( XW_DUtilCtxt* dutil, const XP_UCHAR* players[], int nFound )
|
||||
{
|
||||
GtkWidget* vbox = gtk_box_new( GTK_ORIENTATION_VERTICAL, 0 );
|
||||
|
||||
for ( int ii = 0; ii < nFound; ++ii ) {
|
||||
GtkWidget* one = makeForPlayer( dutil, players[ii] );
|
||||
if ( !!one ) {
|
||||
gtk_box_pack_start( GTK_BOX(vbox), one, FALSE, TRUE, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
GtkWidget* dialog = gtk_dialog_new();
|
||||
gtk_window_set_modal( GTK_WINDOW( dialog ), TRUE );
|
||||
gtk_container_add( GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
|
||||
vbox );
|
||||
|
||||
gtk_widget_show_all( dialog );
|
||||
gtk_main();
|
||||
gtk_widget_destroy( dialog );
|
||||
}
|
||||
|
||||
void
|
||||
gtkkp_show( GtkAppGlobals* apg )
|
||||
{
|
||||
XW_DUtilCtxt* dutil = apg->cag.params->dutil;
|
||||
|
||||
XP_U16 nFound = 0;
|
||||
kplr_getNames( dutil, NULL_XWE, NULL, &nFound );
|
||||
const XP_UCHAR* players[nFound];
|
||||
kplr_getNames( dutil, NULL_XWE, players, &nFound );
|
||||
|
||||
for ( int ii = 0; ii < nFound; ++ii ) {
|
||||
XP_LOGFF( "got one: %s", players[ii] );
|
||||
}
|
||||
|
||||
if ( 0 < nFound ) {
|
||||
showDialog( dutil, players, nFound );
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
30
xwords4/linux/gtkkpdlg.h
Normal file
30
xwords4/linux/gtkkpdlg.h
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* -*- compile-command: "make MEMDEBUG=TRUE -j5"; -*- */
|
||||
/*
|
||||
* Copyright 2020 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef _GTKKPDLG_H_
|
||||
#define _GTKKPDLG_H_
|
||||
|
||||
# ifdef PLATFORM_GTK
|
||||
|
||||
#include "main.h"
|
||||
|
||||
void gtkkp_show( GtkAppGlobals* apg );
|
||||
|
||||
|
||||
# endif
|
||||
#endif
|
|
@ -33,6 +33,7 @@
|
|||
#include "linuxsms.h"
|
||||
#include "gtkask.h"
|
||||
#include "device.h"
|
||||
#include "gtkkpdlg.h"
|
||||
|
||||
static void onNewData( GtkAppGlobals* apg, sqlite3_int64 rowid,
|
||||
XP_Bool isNew );
|
||||
|
@ -550,6 +551,12 @@ handle_movescheck( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* apg )
|
|||
relaycon_checkMsgs( params );
|
||||
}
|
||||
|
||||
static void
|
||||
handle_known_players( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* apg )
|
||||
{
|
||||
gtkkp_show( apg );
|
||||
}
|
||||
|
||||
static void
|
||||
handle_relayid_to_clip( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* apg )
|
||||
{
|
||||
|
@ -596,7 +603,9 @@ makeGamesWindow( GtkAppGlobals* apg )
|
|||
|
||||
// add menubar here
|
||||
GtkWidget* menubar = gtk_menu_bar_new();
|
||||
GtkWidget* netMenu = makeAddSubmenu( menubar, "Network" );
|
||||
GtkWidget* netMenu = makeAddSubmenu( menubar, "Menu" );
|
||||
(void)createAddItem( netMenu, "Known Players",
|
||||
(GCallback)handle_known_players, apg );
|
||||
if ( params->useHTTP ) {
|
||||
(void)createAddItem( netMenu, "Check for moves",
|
||||
(GCallback)handle_movescheck, apg );
|
||||
|
|
Loading…
Reference in a new issue