/**
* builder: GtkBuilderobject to read widgets from
* dialog: the prompt dialog
*
* Set default value depending on input_data
*
**/
static void
prepare_lock (GtkBuilder *builder, GtkDialog *dialog)
{
	GcrUnlockOptionsWidget *unlock;
	GtkWidget *area;
	gchar *option;
	guint ttl;

	unlock = GCR_UNLOCK_OPTIONS_WIDGET (gcr_unlock_options_widget_new ());
	area = GTK_WIDGET (gtk_builder_get_object (builder, "options_area"));
	g_object_set_data (G_OBJECT (dialog), "unlock-options-widget", unlock);
	gtk_container_add (GTK_CONTAINER (area), GTK_WIDGET (unlock));
	gtk_widget_show (GTK_WIDGET (unlock));

	ttl = g_key_file_get_integer (input_data, "unlock-options", "ttl", NULL);
	gcr_unlock_options_widget_set_ttl (unlock, ttl);

	option = g_key_file_get_string (input_data, "unlock-options", "choice", NULL);
	gcr_unlock_options_widget_set_choice (unlock, option ? option : GCR_UNLOCK_OPTION_SESSION);
	g_free (option);

	prepare_unlock_option (unlock, "always");
	prepare_unlock_option (unlock, "idle");
	prepare_unlock_option (unlock, "timeout");
	prepare_unlock_option (unlock, "session");
}
Exemple #2
0
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);
}