예제 #1
0
파일: gtkentrybuffer.c 프로젝트: Pfiver/gtk
/**
 * gtk_entry_buffer_set_text:
 * @buffer: a #GtkEntryBuffer
 * @chars: the new text
 * @n_chars: the number of characters in @text, or -1
 *
 * Sets the text in the buffer.
 *
 * This is roughly equivalent to calling gtk_entry_buffer_delete_text()
 * and gtk_entry_buffer_insert_text().
 *
 * Note that @n_chars is in characters, not in bytes.
 *
 * Since: 2.18
 **/
void
gtk_entry_buffer_set_text (GtkEntryBuffer *buffer,
                           const gchar    *chars,
                           gint            n_chars)
{
  g_return_if_fail (GTK_IS_ENTRY_BUFFER (buffer));
  g_return_if_fail (chars != NULL);

  g_object_freeze_notify (G_OBJECT (buffer));
  gtk_entry_buffer_delete_text (buffer, 0, -1);
  gtk_entry_buffer_insert_text (buffer, 0, chars, n_chars);
  g_object_thaw_notify (G_OBJECT (buffer));
}
예제 #2
0
파일: gtkentrybuffer.c 프로젝트: Pfiver/gtk
/**
 * gtk_entry_buffer_set_max_length:
 * @buffer: a #GtkEntryBuffer
 * @max_length: the maximum length of the entry buffer, or 0 for no maximum.
 *   (other than the maximum length of entries.) The value passed in will
 *   be clamped to the range 0-65536.
 *
 * Sets the maximum allowed length of the contents of the buffer. If
 * the current contents are longer than the given length, then they
 * will be truncated to fit.
 *
 * Since: 2.18
 **/
void
gtk_entry_buffer_set_max_length (GtkEntryBuffer *buffer,
                                 gint            max_length)
{
  g_return_if_fail (GTK_IS_ENTRY_BUFFER (buffer));

  max_length = CLAMP (max_length, 0, GTK_ENTRY_BUFFER_MAX_SIZE);

  if (max_length > 0 && gtk_entry_buffer_get_length (buffer) > max_length)
    gtk_entry_buffer_delete_text (buffer, max_length, -1);

  buffer->priv->max_length = max_length;
  g_object_notify (G_OBJECT (buffer), "max-length");
}
예제 #3
0
static void port_icons_callback(GtkEntry *entry,GtkEntryIconPosition icon_pos,GdkEvent *event,gpointer data)
{
	FacqPlugDialog *dialog = FACQ_PLUG_DIALOG(data);
	GtkEntryBuffer *buf = NULL;

	switch(icon_pos){
	case GTK_ENTRY_ICON_PRIMARY:
		buf = gtk_entry_get_buffer(entry);
		gtk_entry_buffer_delete_text(buf,0,-1);
	break;
	case GTK_ENTRY_ICON_SECONDARY:
		gtk_spin_button_set_value(GTK_SPIN_BUTTON(dialog->priv->spin_button),dialog->priv->port);
	break;
	default:
		return;
	}
}