envy24control: port to GTK 3

Closes: https://github.com/alsa-project/alsa-tools/pull/35
Signed-off-by: Andreas Persson <andreasp56@outlook.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Andreas Persson 2025-04-09 12:25:09 +02:00 committed by Jaroslav Kysela
parent 32495631b1
commit ddc93b66b4
12 changed files with 541 additions and 534 deletions

View file

@ -39,7 +39,14 @@ static inline int is_update_needed(void);
static int is_active(GtkWidget *widget)
{
return GTK_TOGGLE_BUTTON(widget)->active ? 1 : 0;
return gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)) ? 1 : 0;
}
static void label_set(GtkWidget* widget, const char* str)
{
const char* old = gtk_label_get_text(GTK_LABEL(widget));
if (strcmp(old, str))
gtk_label_set_text(GTK_LABEL(widget), str);
}
void master_clock_update(void)
@ -170,8 +177,8 @@ gint master_clock_status_timeout_callback(gpointer data)
snd_ctl_elem_value_set_name(sw, "Word Clock Status");
if ((err = snd_ctl_elem_read(ctl, sw)) < 0)
g_print("Unable to determine word clock status: %s\n", snd_strerror(err));
gtk_label_set_text(GTK_LABEL(hw_master_clock_status_label),
snd_ctl_elem_value_get_boolean(sw, 0) ? "No signal" : "Locked");
label_set(hw_master_clock_status_label,
snd_ctl_elem_value_get_boolean(sw, 0) ? "No signal" : "Locked");
return TRUE;
}
@ -246,7 +253,7 @@ gint internal_clock_status_timeout_callback(gpointer data)
}
}
}
gtk_label_set_text(GTK_LABEL(hw_master_clock_actual_rate_label), label);
label_set(hw_master_clock_actual_rate_label, label);
return TRUE;
}
@ -354,7 +361,7 @@ void volume_change_rate_adj(GtkAdjustment *adj, gpointer data)
{
int err;
snd_ctl_elem_value_set_integer(volume_rate, 0, adj->value);
snd_ctl_elem_value_set_integer(volume_rate, 0, gtk_adjustment_get_value(adj));
if ((err = snd_ctl_elem_write(ctl, volume_rate)) < 0)
g_print("Unable to write volume change rate: %s\n", snd_strerror(err));
}
@ -598,7 +605,7 @@ void spdif_output_toggled(GtkWidget *togglebutton, gpointer data)
page = 1;
}
spdif_output_write();
gtk_notebook_set_page(GTK_NOTEBOOK(hw_spdif_output_notebook), page);
gtk_notebook_set_current_page(GTK_NOTEBOOK(hw_spdif_output_notebook), page);
spdif_output_update();
}
}