mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
add checkbox to tab label when selected
This commit is contained in:
parent
71fbae622a
commit
f853aad904
1 changed files with 14 additions and 7 deletions
|
@ -27,7 +27,8 @@
|
||||||
typedef struct _PageData {
|
typedef struct _PageData {
|
||||||
CommsConnType pageType;
|
CommsConnType pageType;
|
||||||
gboolean doUse;
|
gboolean doUse;
|
||||||
const char* label;
|
const char* labelText;
|
||||||
|
GtkWidget* label;
|
||||||
} PageData;
|
} PageData;
|
||||||
|
|
||||||
typedef struct _GtkConnsState {
|
typedef struct _GtkConnsState {
|
||||||
|
@ -169,6 +170,11 @@ useCheckToggled( GtkWidget* item, PageData* data )
|
||||||
{
|
{
|
||||||
gboolean checked = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(item) );
|
gboolean checked = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(item) );
|
||||||
data->doUse = checked;
|
data->doUse = checked;
|
||||||
|
|
||||||
|
gchar buf[64];
|
||||||
|
gchar* fmt = checked ? "✓ %s" : "%s";
|
||||||
|
snprintf( buf, sizeof(buf), fmt, data->labelText );
|
||||||
|
gtk_label_set_text( GTK_LABEL(data->label), buf );
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget*
|
static GtkWidget*
|
||||||
|
@ -180,7 +186,7 @@ boxWithUseCheck( GtkConnsState* state, PageData* data )
|
||||||
GtkWidget* vbox = gtk_vbox_new( FALSE, 0 );
|
GtkWidget* vbox = gtk_vbox_new( FALSE, 0 );
|
||||||
|
|
||||||
gchar buf[32];
|
gchar buf[32];
|
||||||
snprintf( buf, sizeof(buf), "Connect via %s", data->label );
|
snprintf( buf, sizeof(buf), "Connect via %s", data->labelText );
|
||||||
GtkWidget* check = gtk_check_button_new_with_label( buf );
|
GtkWidget* check = gtk_check_button_new_with_label( buf );
|
||||||
g_signal_connect( GTK_OBJECT(check),
|
g_signal_connect( GTK_OBJECT(check),
|
||||||
"toggled", G_CALLBACK(useCheckToggled), data );
|
"toggled", G_CALLBACK(useCheckToggled), data );
|
||||||
|
@ -323,7 +329,8 @@ getNextData( GtkConnsState* state, CommsConnType typ, gchar* label )
|
||||||
{
|
{
|
||||||
PageData* result = &state->pageData[state->nTypes++];
|
PageData* result = &state->pageData[state->nTypes++];
|
||||||
result->pageType = typ;
|
result->pageType = typ;
|
||||||
result->label = label;
|
result->label = gtk_label_new( label );
|
||||||
|
result->labelText = label;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,25 +357,25 @@ gtkConnsDlg( GtkGameGlobals* globals, CommsAddrRec* addr, DeviceRole role,
|
||||||
data = getNextData( &state, COMMS_CONN_RELAY, "Relay" );
|
data = getNextData( &state, COMMS_CONN_RELAY, "Relay" );
|
||||||
(void)gtk_notebook_append_page( GTK_NOTEBOOK(state.notebook),
|
(void)gtk_notebook_append_page( GTK_NOTEBOOK(state.notebook),
|
||||||
makeRelayPage( &state, data ),
|
makeRelayPage( &state, data ),
|
||||||
gtk_label_new( data->label ) );
|
data->label );
|
||||||
#endif
|
#endif
|
||||||
#ifdef XWFEATURE_BLUETOOTH
|
#ifdef XWFEATURE_BLUETOOTH
|
||||||
data = getNextData( &state, COMMS_CONN_BT, "Bluetooth" );
|
data = getNextData( &state, COMMS_CONN_BT, "Bluetooth" );
|
||||||
(void)gtk_notebook_append_page( GTK_NOTEBOOK(state.notebook),
|
(void)gtk_notebook_append_page( GTK_NOTEBOOK(state.notebook),
|
||||||
makeBTPage( &state, data ),
|
makeBTPage( &state, data ),
|
||||||
gtk_label_new( data->label ) );
|
data->label );
|
||||||
#endif
|
#endif
|
||||||
#ifdef XWFEATURE_DIRECTIP
|
#ifdef XWFEATURE_DIRECTIP
|
||||||
data = getNextData( &state, COMMS_CONN_IP_DIRECT, "Direct" );
|
data = getNextData( &state, COMMS_CONN_IP_DIRECT, "Direct" );
|
||||||
(void)gtk_notebook_append_page( GTK_NOTEBOOK(state.notebook),
|
(void)gtk_notebook_append_page( GTK_NOTEBOOK(state.notebook),
|
||||||
makeIPDirPage(&state, data),
|
makeIPDirPage(&state, data),
|
||||||
gtk_label_new( data->label ) );
|
data->label );
|
||||||
#endif
|
#endif
|
||||||
#ifdef XWFEATURE_SMS
|
#ifdef XWFEATURE_SMS
|
||||||
data = getNextData( &state, COMMS_CONN_SMS, "SMS" );
|
data = getNextData( &state, COMMS_CONN_SMS, "SMS" );
|
||||||
(void)gtk_notebook_append_page( GTK_NOTEBOOK(state.notebook),
|
(void)gtk_notebook_append_page( GTK_NOTEBOOK(state.notebook),
|
||||||
makeSMSPage( &state, data ),
|
makeSMSPage( &state, data ),
|
||||||
gtk_label_new( data->label ) );
|
data->label );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
vbox = gtk_vbox_new( FALSE, 0 );
|
vbox = gtk_vbox_new( FALSE, 0 );
|
||||||
|
|
Loading…
Reference in a new issue