Center-align text in combo boxes
This commit is contained in:
@@ -14,8 +14,24 @@ static void combo_box_updated(struct alsa_elem *elem) {
|
|||||||
gtk_combo_box_set_active(GTK_COMBO_BOX(elem->widget), value);
|
gtk_combo_box_set_active(GTK_COMBO_BOX(elem->widget), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Center-align text in the combo box
|
||||||
|
static void combo_box_center_text(GtkComboBoxText *widget) {
|
||||||
|
GList *renderers = gtk_cell_layout_get_cells(GTK_CELL_LAYOUT(widget));
|
||||||
|
|
||||||
|
// Assuming there's only one renderer, which is the case with GtkComboBoxText
|
||||||
|
GtkCellRenderer *renderer = (GtkCellRenderer *)g_list_nth_data(renderers, 0);
|
||||||
|
|
||||||
|
// Set the "xalign" property of the renderer to center-align text
|
||||||
|
g_object_set(renderer, "xalign", (gfloat)0.5, NULL);
|
||||||
|
|
||||||
|
// Free the GList when done
|
||||||
|
g_list_free(renderers);
|
||||||
|
}
|
||||||
|
|
||||||
GtkWidget *make_combo_box_alsa_elem(struct alsa_elem *elem) {
|
GtkWidget *make_combo_box_alsa_elem(struct alsa_elem *elem) {
|
||||||
GtkWidget *combo_box = gtk_combo_box_text_new();
|
GtkWidget *combo_box = gtk_combo_box_text_new();
|
||||||
|
combo_box_center_text(GTK_COMBO_BOX_TEXT(combo_box));
|
||||||
|
|
||||||
int count = alsa_get_item_count(elem);
|
int count = alsa_get_item_count(elem);
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user