static void hildon_find_toolbar_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { HildonFindToolbarPrivate *priv = HILDON_FIND_TOOLBAR_GET_PRIVATE (object); g_assert (priv); const gchar *string; gint c_n, max_len; switch (prop_id) { case PROP_LABEL: string = gtk_label_get_text (GTK_LABEL (priv->label)); g_value_set_string (value, string); break; case PROP_PREFIX: string = gtk_entry_get_text (hildon_find_toolbar_get_entry(priv)); g_value_set_string (value, string); break; case PROP_LIST: g_value_set_object (value, hildon_find_toolbar_get_list_model(priv)); break; case PROP_COLUMN: c_n = gtk_combo_box_entry_get_text_column (priv->entry_combo_box); g_value_set_int (value, c_n); break; case PROP_MAX: max_len = gtk_entry_get_max_length (hildon_find_toolbar_get_entry(priv)); g_value_set_int (value, max_len); break; case PROP_HISTORY_LIMIT: g_value_set_int (value, priv->history_limit); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static void text_inserted (GtkEditable *editable, gchar *new_text, gint new_text_length, gint *position, gpointer user_data) { GtkEntryBuffer *buffer; gchar* new_label; gint i; gint current_length, max_length; gboolean valid; valid = TRUE; buffer = gtk_entry_get_buffer (GTK_ENTRY (editable)); current_length = gtk_entry_buffer_get_length (buffer); max_length = gtk_entry_get_max_length (GTK_ENTRY (editable)); /* honor max length property */ if (current_length + new_text_length > max_length) return; /* stop the default implementation */ g_signal_stop_emission (editable, g_signal_lookup ("insert-text", GTK_TYPE_ENTRY), 0); for (i = 0; i < new_text_length; i++) { gchar c; c = *(new_text + i); /* trying to insert a non-numeric char */ if (c < '0' || c > '9') { valid = FALSE; break; } } if (!valid) return; new_label = g_strdup_printf ("%s%s", gtk_entry_buffer_get_text (buffer), new_text); gtk_entry_buffer_set_text (buffer, new_label, current_length + new_text_length); *position = *position + new_text_length; g_free (new_label); }
// If max characters reached, jump to next field static void ygtk_field_entry_insert_text (GtkEditable *editable, const gchar *new_text, gint new_text_length, gint *position, YGtkFieldEntry *fields) { if (*position == gtk_entry_get_max_length (GTK_ENTRY (editable))) { GtkEntry *next_entry = ygtk_field_entry_focus_next_entry (fields, GTK_ENTRY (editable), 1); if (next_entry) { gint pos = 0; gtk_editable_insert_text (GTK_EDITABLE (next_entry), new_text, new_text_length, &pos); gtk_editable_set_position (GTK_EDITABLE (next_entry), pos); // it would not insert the text anyway, but to avoid the beep g_signal_stop_emission_by_name (editable, "insert_text"); } } }
static gboolean _admin_focus_out_resv(GtkEntry *entry, GdkEventFocus *event, resv_desc_msg_t *resv_msg) { if (global_entry_changed) { const char *col_name = NULL; int type = gtk_entry_get_max_length(entry); const char *name = gtk_entry_get_text(entry); type -= DEFAULT_ENTRY_LENGTH; col_name = _set_resv_msg(resv_msg, name, type); if (global_edit_error && !global_edit_error_msg) { global_edit_error_msg = g_strdup_printf( "Reservation %s %s can't be set to %s", resv_msg->name, col_name, name); } global_entry_changed = 0; } return false; }
static gboolean _admin_focus_out_defaults(GtkEntry *entry, GdkEventFocus *event, sview_config_t *sview_config) { if (global_entry_changed) { const char *col_name = NULL; int type = gtk_entry_get_max_length(entry); const char *name = gtk_entry_get_text(entry); type -= DEFAULT_ENTRY_LENGTH; col_name = _set_sview_config(sview_config, name, type); if (global_edit_error) { if (global_edit_error_msg) g_free(global_edit_error_msg); global_edit_error_msg = g_strdup_printf( "Default for %s can't be set to %s", col_name, name); } global_entry_changed = 0; } return false; }
static void hildon_get_password_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { HildonGetPasswordDialog *dialog = HILDON_GET_PASSWORD_DIALOG (object); HildonGetPasswordDialogPrivate *priv; const gchar *string; gint max_length; #ifdef MAEMO_GTK gint input_mode; #endif priv = HILDON_GET_PASSWORD_DIALOG_GET_PRIVATE (dialog); g_assert (priv); switch (prop_id) { case PROP_MESSAGE: string = gtk_label_get_text (priv->message_label); g_value_set_string (value, string); break; case PROP_PASSWORD: string = gtk_entry_get_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->password_entry)))); g_value_set_string (value, string); break; case PROP_NUMBERS_ONLY: #ifdef MAEMO_GTK /* This property is set if and only if the input mode of the password entry has been set to numeric only */ g_object_get (G_OBJECT (gtk_bin_get_child (GTK_BIN (priv->password_entry))), "hildon-input-mode", &input_mode, NULL); g_value_set_boolean (value, (input_mode == HILDON_GTK_INPUT_MODE_NUMERIC)); #else g_value_set_boolean (value, FALSE); #endif break; case PROP_CAPTION_LABEL: string = hildon_caption_get_label (priv->password_entry); g_value_set_string (value, string); break; case PROP_MAX_CHARS: max_length = gtk_entry_get_max_length (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (priv->password_entry)))); g_value_set_int (value, max_length); break; case PROP_GET_OLD: g_value_set_boolean (value, priv->get_old); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }