static void prepare_unlock_option (GcrUnlockOptionsWidget *unlock, const gchar *option) { GError *error = NULL; gboolean sensitive; gchar *text; text = g_key_file_get_string (input_data, option, "label", NULL); if (text) gcr_unlock_options_widget_set_label (unlock, option, text); g_free (text); sensitive = g_key_file_get_boolean (input_data, option, "sensitive", &error); if (error == NULL) { text = g_key_file_get_string (input_data, option, "reason", NULL); gcr_unlock_options_widget_set_sensitive (unlock, option, sensitive, text); g_free (text); } g_clear_error (&error); }
static void test_unlock_options (void) { GcrUnlockOptionsWidget *unlock; GtkDialog *dialog; dialog = GTK_DIALOG (gtk_dialog_new ()); g_object_ref_sink (dialog); unlock = GCR_UNLOCK_OPTIONS_WIDGET (gcr_unlock_options_widget_new ()); gtk_widget_show (GTK_WIDGET (unlock)); gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (dialog)), GTK_WIDGET (unlock)); gcr_unlock_options_widget_set_sensitive (unlock, GCR_UNLOCK_OPTION_IDLE, FALSE, "This is a test of the tooltip."); gcr_unlock_options_widget_set_sensitive (unlock, GCR_UNLOCK_OPTION_ALWAYS, TRUE, NULL); gcr_unlock_options_widget_set_label (unlock, GCR_UNLOCK_OPTION_IDLE, "Disabled label test"); gcr_unlock_options_widget_set_ttl (unlock, 80); gcr_unlock_options_widget_set_choice (unlock, GCR_UNLOCK_OPTION_ALWAYS); gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 400); gtk_dialog_run (dialog); g_printerr ("choice: %s\n", gcr_unlock_options_widget_get_choice (unlock)); g_printerr ("ttl: %u\n", gcr_unlock_options_widget_get_ttl (unlock)); g_printerr ("idle sensitive: %s\n", gcr_unlock_options_widget_get_sensitive (unlock, GCR_UNLOCK_OPTION_IDLE) ? "T" : "F"); g_printerr ("always sensitive: %s\n", gcr_unlock_options_widget_get_sensitive (unlock, GCR_UNLOCK_OPTION_ALWAYS) ? "T" : "F"); g_printerr ("label: %s\n", gcr_unlock_options_widget_get_label (unlock, GCR_UNLOCK_OPTION_ALWAYS)); g_object_unref (dialog); }