Skip to content

Commit

Permalink
machine-prefs: make read-only properties insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
dlbeswick authored and ensonic committed Mar 8, 2021
1 parent 9624cc2 commit 6928801
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/ui/edit/machine-preferences-dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,17 @@ bt_machine_preferences_dialog_init_ui (const BtMachinePreferencesDialog * self)
property = properties[i];

GST_INFO ("property %p has name '%s'", property, property->name);
tool_tip_text = (gchar *) g_param_spec_get_blurb (property);

gboolean is_readonly = (property->flags & G_PARAM_WRITABLE) == 0;
gchar *readonly_tooltip_text;

if (is_readonly) {
readonly_tooltip_text = g_strconcat("(Read-only) ", (gchar *) g_param_spec_get_blurb (property), NULL);
tool_tip_text = readonly_tooltip_text;
} else {
readonly_tooltip_text = NULL;
tool_tip_text = (gchar *) g_param_spec_get_blurb (property);
}

// get name
label = gtk_label_new (g_param_spec_get_nick (property));
Expand Down Expand Up @@ -488,17 +498,21 @@ bt_machine_preferences_dialog_init_ui (const BtMachinePreferencesDialog * self)
}
}
gtk_widget_set_tooltip_text (widget1, tool_tip_text);
gtk_widget_set_sensitive (widget1, !is_readonly);
if (!widget2) {
g_object_set (widget1, "hexpand", TRUE, "margin-left", LABEL_PADDING,
NULL);
gtk_grid_attach (GTK_GRID (table), widget1, 1, i, 2, 1);
} else {
gtk_widget_set_sensitive (widget2, !is_readonly);
gtk_widget_set_tooltip_text (widget2, tool_tip_text);
g_object_set (widget1, "hexpand", TRUE, "margin-left", LABEL_PADDING,
"margin-right", LABEL_PADDING, NULL);
gtk_grid_attach (GTK_GRID (table), widget1, 1, i, 1, 1);
gtk_grid_attach (GTK_GRID (table), widget2, 2, i, 1, 1);
}

g_free(readonly_tooltip_text);
}
// eat remaning space
#if GTK_CHECK_VERSION (3, 8, 0)
Expand Down

0 comments on commit 6928801

Please sign in to comment.