Esempio n. 1
0
static void
scan_start (unsigned int timestamp)
{
  ScanState *state = scan_state();
  switch (state->timer_state)
    {
    case SCAN_IDLE:
      state->timer_state = SCAN_LINES;
      state->scan_column = 0;
      state->scan_row = 0;
      g_timeout_add_full (G_PRIORITY_HIGH_IDLE, 600, increment_scan, state, NULL);
      select_line (state->scan_row);
      break;
    case SCAN_LINES_DONE:
      state->timer_state = SCAN_KEYS;
      g_timeout_add_full (G_PRIORITY_HIGH_IDLE, 600, increment_scan, state, NULL);
      deselect_line (state->scan_row);
      select_key (state->scan_row, state->scan_column);
      break;
    case SCAN_KEYS_DONE:
      gtk_button_clicked (buttons[state->scan_row][state->scan_column]);
      deselect_key (state->scan_row, state->scan_column);
      state->timer_state = SCAN_IDLE;
      break;
    default:
      g_print("unexpected state for 'scan start'\n");
    }
}
Esempio n. 2
0
static gboolean
increment_scan (gpointer data)
{
  ScanState *state = (ScanState *) data;
  int max_columns;
  switch (state->timer_state)
    {  
      case SCAN_IDLE: 
/* happens if switch-break occurs before the timer fires, after SCAN_KEYS_DONE*/
          return FALSE;
      case SCAN_LINES:
          deselect_line (state->scan_row);
          state->scan_row = (++state->scan_row < MAX_ROWS) ? state->scan_row : 0;
          select_line (state->scan_row);
          g_print ("line %d\n", state->scan_row);
	  break;
      case SCAN_KEYS:
          deselect_key (state->scan_row, state->scan_column);
	  if (state->scan_row == MAX_ROWS-1) max_columns = 2;
	  else max_columns = MAX_COLUMNS; /* last row has only two keys */
          state->scan_column = (++state->scan_column < max_columns) ? state->scan_column : 0;
          select_key (state->scan_row, state->scan_column);
          g_print ("row %d\n", state->scan_column);
	  break;
      case SCAN_LINES_DONE:
      case SCAN_KEYS_DONE:
	  return FALSE;
    }
  return TRUE;
}
Esempio n. 3
0
void
select_line (gint lineno)
{
  int i;
  int max_columns = MAX_COLUMNS;
  if (lineno == MAX_ROWS-1) max_columns = 2;
  for (i=0; i<max_columns; ++i)
	  select_key (lineno, i);
}
Esempio n. 4
0
static int select_key_default(const char *fingerprint, const char *shortname,
			      const char *key,
			      int invalid,
			      struct gpg_list_info *gli)
{
	struct listinfo *li=(struct listinfo *)gli->voidarg;

	return (select_key(fingerprint, shortname, key, gli,
			   li->default_key && strcmp(li->default_key,
						     fingerprint)
			   == 0));
}
Esempio n. 5
0
static int encrypt_key_default(const char *fingerprint, const char *shortname,
			       const char *key,
			       int invalid,
			       struct gpg_list_info *gli)
{
	struct listinfo *li=(struct listinfo *)gli->voidarg;

	if (invalid)
		return (0);

	return (select_key(fingerprint, shortname, key, gli,
			   knownkey(shortname, li->default_key)));
}