Exemplo n.º 1
0
/* Clear a string element from the UI */
static void stringclear(const char* l) {
	GtkLabel* label = GTK_LABEL(gtk_builder_get_object(builder, l));
	/* Should only appear in the hash table if we successfully found it
	   earlier... */
	assert(label != NULL);
	g_object_set_threaded(G_OBJECT(label), "label", "-", NULL);
	g_object_set_threaded(G_OBJECT(label), "sensitive", FALSE, NULL);
}
Exemplo n.º 2
0
/* Clear the photo element on the identity tab */
static void clearphoto(char* label) {
	GtkWidget* image = GTK_WIDGET(gtk_builder_get_object(builder, "photo"));
	g_object_set_threaded(G_OBJECT(image), "stock", "gtk-file", NULL);
	g_object_set_threaded(G_OBJECT(image), "sensitive", (void*)FALSE, NULL);
	if(pi.raw)
		free(pi.raw);
	if(pi.hash)
		free(pi.hash);
	memset(&pi, 0, sizeof(pi));
}
Exemplo n.º 3
0
Arquivo: main.c Projeto: Fedict/eid-mw
/* Handle the "new source" event from the state machine */
static void newsrc(enum eid_vwr_source src) {
	clear_certdata();
	g_hash_table_foreach(touched_labels, cleardata, NULL);
	if(src == EID_VWR_SRC_CARD) {
		g_object_set_threaded(G_OBJECT(gtk_builder_get_object(builder, "mainwin")), "urgency-hint", (void*)TRUE, NULL);
	}
	// TODO: update display so we see which source we're using
}
Exemplo n.º 4
0
/* Add a new string to the UI */
static void newstringdata(const char* l, const char* data) {
	GtkLabel* label = GTK_LABEL(gtk_builder_get_object(builder, l));
	if(!label) {
		char* msg = g_strdup_printf(_("Could not display label '%s', data '%s': no GtkLabel found for data"), l, data);
		uilog(EID_VWR_LOG_DETAIL, msg);
		g_free(msg);
		return;
	}
	if(!data || strlen(data) == 0) {
		stringclear(l);
		return;
	}
	/* Remember which elements we've touched, so we can clear them
	 * again later on */
	g_hash_table_insert(touched_labels, g_strdup(l), stringclear);
	g_object_set_threaded(G_OBJECT(label), "label", g_strdup(data), g_free);
	g_object_set_threaded(G_OBJECT(label), "sensitive", (void*)TRUE, NULL);
}
Exemplo n.º 5
0
/* Handle "state changed" elements */
static void newstate(enum eid_vwr_states s) {
	GObject *open, *savexml, *savecsv, *print, *close, *pintest, *pinchg, *validate;
#define want_verify (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtk_builder_get_object(builder, "validate_always"))))
	open = gtk_builder_get_object(builder, "mi_file_open");
	savexml = gtk_builder_get_object(builder, "mi_file_saveas_xml");
	savecsv = gtk_builder_get_object(builder, "mi_file_saveas_csv");
	print = gtk_builder_get_object(builder, "mi_file_print");
	close = gtk_builder_get_object(builder, "mi_file_close");
	pintest = gtk_builder_get_object(builder, "pintestbut");
	pinchg = gtk_builder_get_object(builder, "pinchangebut");
	validate = gtk_builder_get_object(builder, "validate_now");

	g_object_set_threaded(open, "sensitive", (void*)FALSE, NULL);
	g_object_set_threaded(close, "sensitive", (void*)FALSE, NULL);
	g_object_set_threaded(print, "sensitive", (void*)FALSE, NULL);
	g_object_set_threaded(savexml, "sensitive", (void*)FALSE, NULL);
	g_object_set_threaded(savecsv, "sensitive", (void*)FALSE, NULL);
	g_object_set_threaded(pintest, "sensitive", (void*)FALSE, NULL);
	g_object_set_threaded(pinchg, "sensitive", (void*)FALSE, NULL);
	g_object_set_threaded(validate, "sensitive", (void*)FALSE, NULL);
	g_object_set_data_threaded(validate, "want_active", (void*)FALSE, NULL);
	switch(s) {
		case STATE_LIBOPEN:
		case STATE_CALLBACKS:
			uistatus(TRUE, _("Initializing"));
			return;
		case STATE_READY:
			uistatus(FALSE, _("Ready to read identity card."));
			g_object_set_threaded(open, "sensitive", (void*)TRUE, NULL);
			disable_dnd();
			return;
		case STATE_NO_READER:
			uistatus(FALSE, _("No cardreader found."));
			return;
		case STATE_TOKEN:
			uistatus(TRUE, _("Card available"));
			return;
		case STATE_TOKEN_WAIT:
			uistatus(FALSE, "");
			g_object_set_threaded(print, "sensitive", (void*)TRUE, NULL);
			g_object_set_threaded(savexml, "sensitive", (void*)TRUE, NULL);
			g_object_set_threaded(savecsv, "sensitive", (void*)TRUE, NULL);
			g_object_set_threaded(pintest, "sensitive", (void*)TRUE, NULL);
			g_object_set_threaded(pinchg, "sensitive", (void*)TRUE, NULL);
			if(!data_verifies()) {
				uilog(EID_VWR_LOG_COARSE, "Cannot load card: data signature invalid!");
				eid_vwr_be_set_invalid();
			}
			g_object_set_data_threaded(validate, "want_active", (void*)TRUE, NULL);
			if(want_verify) {
				validate_all(NULL, NULL);
			} else {
				g_object_set_threaded(validate, "sensitive", (void*)TRUE, NULL);
			}
			setup_dnd();
			return;
		case STATE_TOKEN_ID:
			uistatus(TRUE, _("Reading identity."));
			return;
		case STATE_TOKEN_CERTS:
			uistatus(TRUE, _("Reading certificates from card"));
			return;
		case STATE_TOKEN_ERROR:
			uistatus(FALSE, _("Failed to read identity data."));
			return;
		case STATE_TOKEN_PINOP:
			uistatus(TRUE, _("Performing a PIN operation"));
			return;
		case STATE_FILE:
			uistatus(FALSE, "");
			g_object_set_threaded(print, "sensitive", (void*)TRUE, NULL);
			g_object_set_threaded(close, "sensitive", (void*)TRUE, NULL);
			g_object_set_data_threaded(validate, "want_active", (void*)TRUE, NULL);
			if(want_verify) {
				validate_all(NULL, NULL);
			} else {
				g_object_set_threaded(validate, "sensitive", (void*)TRUE, NULL);
			}
			setup_dnd();
		default:
			return;
	}
}