Ejemplo n.º 1
0
static void
aw_login_dialog_init (AwLoginDialog *dialog)
{
  GtkWidget  *table, *widget, *content;
  char       *username, *password;
  gboolean    store_credentials;

  dialog->priv = G_TYPE_INSTANCE_GET_PRIVATE (dialog, AW_TYPE_LOGIN_DIALOG,
                                              AwLoginDialogPrivate);

  g_object_get (aw_settings_get_singleton (),
                "username", &username, "password", &password,
                "store-credentials", &store_credentials, NULL);

  gtk_dialog_add_button (GTK_DIALOG (dialog), _("Login"), GTK_RESPONSE_OK);

  table = gtk_table_new (3, 2, FALSE);
  gtk_table_set_col_spacings (GTK_TABLE (table), HILDON_MARGIN_DOUBLE);
  content = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
  gtk_container_add (GTK_CONTAINER (content), table);

  widget = gtk_label_new (_("Username"));
  gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
  gtk_table_attach (GTK_TABLE (table), widget, 0, 1, 0, 1, GTK_FILL, GTK_FILL | GTK_EXPAND, 0, 0);

  widget = hildon_entry_new (HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT);
  gtk_entry_set_text (GTK_ENTRY (widget), username ? username : "");
  gtk_table_attach_defaults (GTK_TABLE (table), widget, 1, 2, 0, 1);
  dialog->priv->username = widget;

  widget = gtk_label_new (_("Password"));
  gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5);
  gtk_table_attach (GTK_TABLE (table), widget, 0, 1, 1, 2, GTK_FILL, GTK_FILL | GTK_EXPAND, 0, 0);

  widget = hildon_entry_new (HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT);
  gtk_entry_set_text (GTK_ENTRY (widget), password ? password : "");
  gtk_entry_set_visibility (GTK_ENTRY (widget), FALSE);
  gtk_table_attach_defaults (GTK_TABLE (table), widget, 1, 2, 1, 2);
  dialog->priv->password = widget;

  widget = hildon_check_button_new (HILDON_SIZE_AUTO_WIDTH | HILDON_SIZE_FINGER_HEIGHT);
  hildon_check_button_set_active (HILDON_CHECK_BUTTON (widget), store_credentials);
  gtk_button_set_label (GTK_BUTTON (widget), _("Remember login credentials"));
  gtk_table_attach_defaults (GTK_TABLE (table), widget, 1, 2, 2, 3);
  dialog->priv->store_credentials = widget;

  gtk_widget_show_all (table);

  g_free (username);
  g_free (password);
}
Ejemplo n.º 2
0
GtkWidget* 
et_dialog_new ( GtkWindow *parent, Token *token )
{
  GtkWidget *et_dialog;
  EtDialog *self;
  const gchar *description;
  GtkDialog *dialog;
  GtkWidget *box;


  et_dialog = g_object_new ( TYPE_ET_DIALOG, NULL );
  self = ET_DIALOG(et_dialog);
  dialog = GTK_DIALOG (self);
  
  self->token = token;

  /* title */
  gtk_window_set_title ( GTK_WINDOW (self), token->name );
  
  /* description */
  description = g_strjoin ( " ", algorithm_labels[token->algorithm],
			    counter_type_labels[token->counter_t],
			    "token", NULL );
  gtk_label_set_text ( GTK_LABEL ( self->description ), description );
  
  /* key */
  gtk_entry_set_text ( GTK_ENTRY( self->key ), token_get_key_as_str ( token ) );

  /* Algorithm specific parameters */
  switch ( self->token->algorithm )
    {
    case HOTP:
      switch ( self->token->counter_t )
	{
	case EVENT: 
	  LABELED_ENTRY ( "Counter value", self->counter );  
	  gtk_entry_set_text ( GTK_ENTRY ( self->counter ), 
			       g_strdup_printf("%lu", (gulong)token->counter ) );
	  hildon_gtk_entry_set_input_mode ( GTK_ENTRY ( self->counter ), 
					    HILDON_GTK_INPUT_MODE_NUMERIC );
	  break;
	  
	case TIME:  
	  LABELED_ENTRY ( "Interval (seconds) ", self->interval);
	  gtk_entry_set_text ( GTK_ENTRY ( self->interval ), 
			       g_strdup_printf("%u", token->interval ) );
	  hildon_gtk_entry_set_input_mode ( GTK_ENTRY ( self->interval ),
					    HILDON_GTK_INPUT_MODE_NUMERIC );
	  break;

	default:;
	}
      /* disp hex */
      self->disp_hex = hildon_check_button_new ( HILDON_SIZE_FINGER_HEIGHT );
      gtk_button_set_label ( GTK_BUTTON ( self->disp_hex ), "Display Hexadecimal" );
      hildon_check_button_set_active ( HILDON_CHECK_BUTTON(self->disp_hex), token->disp_hex );
      APPEND ( self->disp_hex );
      /* Digits */
      self->digits = integer_selector_new ( MIN_DIGITS, MAX_DIGITS );
      hildon_button_set_title ( HILDON_BUTTON(self->digits), "Digits" );
      hildon_touch_selector_set_active ( hildon_picker_button_get_selector ( HILDON_PICKER_BUTTON(self->digits) ),
					 0, (token->digits - MIN_DIGITS) );
      APPEND ( self->digits );  
      break;
      
    case MOTP:
      if ( self->token->counter_t == EVENT ){
	LABELED_ENTRY ( "Counter", self->counter );
	gtk_entry_set_text ( GTK_ENTRY ( self->counter ), 
			     g_strdup_printf("%lu", (gulong)token->counter ) );
      }
      self->pin_size = integer_selector_new ( MIN_PIN_SIZE, MAX_PIN_SIZE );
      hildon_button_set_title ( HILDON_BUTTON(self->pin_size), "PIN length" );
      hildon_touch_selector_set_active ( hildon_picker_button_get_selector ( HILDON_PICKER_BUTTON(self->pin_size) ),
					 0, (token->pin_size - MIN_PIN_SIZE) );
      APPEND ( self->pin_size );
      break;

    default:;
    }

  return et_dialog;
}