int maskcpf(GtkWidget *widget,GdkEventKey *event,gpointer *poi){ char tt[20]; int bak; gint *j; if(event->keyval == 65288){ //g_print("erro"); bak=0;}else { j = gtk_editable_get_position(GTK_EDITABLE(widget)); if( j == 3) { sprintf(tt,"%s.",gtk_entry_get_text(GTK_ENTRY(widget))); gtk_entry_set_text(GTK_ENTRY(widget),tt); gtk_editable_set_position(GTK_EDITABLE(widget),4); } if( j == 7) { sprintf(tt,"%s.",gtk_entry_get_text(GTK_ENTRY(widget))); gtk_entry_set_text(GTK_ENTRY(widget),tt); gtk_editable_set_position(GTK_EDITABLE(widget),8); } if( j == 11) { sprintf(tt,"%s-",gtk_entry_get_text(GTK_ENTRY(widget))); gtk_entry_set_text(GTK_ENTRY(widget),tt); gtk_editable_set_position(GTK_EDITABLE(widget),12); } } return 0; }
static void gdaui_numeric_entry_assume_delete (GdauiEntry *entry, gint virt_start_pos, gint virt_end_pos, gint offset) { GdauiNumericEntry *fentry; GString *string; gchar *otext, *ntext = NULL; gint i, nlen, ndel, olen = 0; gint cursor_pos; fentry = (GdauiNumericEntry*) entry; ndel = virt_end_pos - virt_start_pos; otext = gdaui_entry_get_text (GDAUI_ENTRY (entry)); cursor_pos = gtk_editable_get_position (GTK_EDITABLE (entry)); if (otext) { if ((ndel == 1) && (otext[virt_start_pos] == fentry->priv->decimal_sep) && (fentry->priv->nb_decimals != G_MAXUINT16)) { gtk_editable_set_position (GTK_EDITABLE (entry), cursor_pos - 1); g_free (otext); return; } string = g_string_new (otext); olen = g_utf8_strlen (otext, -1); g_free (otext); g_string_erase (string, virt_start_pos, ndel); } else string = g_string_new (NULL); cursor_pos -= (virt_end_pos - virt_start_pos); /*g_print ("RAW: [%s]", string->str);*/ text_unformat (fentry, string->str, &cursor_pos); /*g_print ("SANITIZED: [%s]", string->str);*/ if (!test_text_validity (fentry, string->str)) { if ((string->str[0] == fentry->priv->decimal_sep) && string->str[1] == 0) ntext = g_strdup (""); g_string_free (string, TRUE); if (!ntext) { /*g_print ("ERROR!\n");*/ return; } } else { ntext = text_reformat (fentry, string->str, &cursor_pos, FALSE); g_string_free (string, TRUE); } /*g_print ("NEW: [%s]\n", ntext);*/ i = offset; nlen = strlen (ntext); gtk_editable_delete_text ((GtkEditable*) entry, offset, olen + offset); gtk_editable_insert_text ((GtkEditable*) entry, ntext, nlen, &i); g_free (ntext); gtk_editable_set_position (GTK_EDITABLE (entry), cursor_pos); }
/************************************************************************** Autocompletes the input line with a player or user name. Returns FALSE if there is no string to complete. **************************************************************************/ static bool chatline_autocomplete(GtkEditable *editable) { #define MAX_MATCHES 10 const char *name[MAX_MATCHES]; char buf[MAX_LEN_NAME * MAX_MATCHES]; gint pos; gchar *chars, *p, *prev; int num, i; size_t prefix_len; /* Part 1: get the string to complete. */ pos = gtk_editable_get_position(editable); chars = gtk_editable_get_chars(editable, 0, pos); p = chars + strlen(chars); while ((prev = g_utf8_find_prev_char(chars, p))) { if (!g_unichar_isalnum(g_utf8_get_char(prev))) { break; } p = prev; } /* p points to the start of the last word, or the start of the string. */ prefix_len = g_utf8_strlen(p, -1); if (0 == prefix_len) { /* Empty: nothing to complete, propagate the event. */ g_free(chars); return FALSE; } /* Part 2: compare with player and user names. */ num = check_player_or_user_name(p, name, MAX_MATCHES); if (1 == num) { gtk_editable_delete_text(editable, pos - prefix_len, pos); pos -= prefix_len; gtk_editable_insert_text(editable, name[0], strlen(name[0]), &pos); gtk_editable_set_position(editable, pos); g_free(chars); return TRUE; } else if (num > 1) { if (get_common_prefix(name, num, buf, sizeof(buf)) > prefix_len) { gtk_editable_delete_text(editable, pos - prefix_len, pos); pos -= prefix_len; gtk_editable_insert_text(editable, buf, strlen(buf), &pos); gtk_editable_set_position(editable, pos); } sz_strlcpy(buf, name[0]); for (i = 1; i < num; i++) { cat_snprintf(buf, sizeof(buf), ", %s", name[i]); } /* TRANS: comma-separated list of player/user names for completion */ output_window_printf(ftc_client, _("Suggestions: %s."), buf); } g_free(chars); return TRUE; }
void SetCursolPosition(const gchar *entry_name, const gint position) { GtkWidget *entry = NULL; entry = glade_xml_get_widget(g_cngplp_xml, entry_name); if(entry != NULL){ if(-1 == position){ const gint num = GTK_ENTRY(entry)->text_length; gtk_editable_set_position(GTK_EDITABLE(entry), num); }else{ gtk_editable_delete_text(GTK_EDITABLE(entry), position, -1); gtk_editable_set_position(GTK_EDITABLE(entry), position); } } }
void fm_path_entry_set_model(FmPathEntry *entry, FmPath* path, FmFolderModel* model) { FmPathEntryPrivate *priv = FM_PATH_ENTRY_GET_PRIVATE(entry); /* FIXME: should we use UTF-8 encoded display name here? */ gchar *path_str = fm_path_display_name(path, FALSE); if(priv->path) fm_path_unref(priv->path); priv->path = fm_path_ref(path); if( priv->model ) g_object_unref( priv->model ); if( priv->completion_model ) g_object_unref(priv->completion_model); if(model) { priv->model = g_object_ref(model); priv->completion_model = g_object_ref(model); gtk_entry_set_completion(GTK_ENTRY(entry), priv->completion); } else { priv->model = NULL; priv->completion_model = NULL; gtk_entry_set_completion(GTK_ENTRY(entry), NULL); } gtk_entry_completion_set_model( priv->completion, (GtkTreeModel*)priv->completion_model ); priv->in_change = TRUE; gtk_entry_set_text(GTK_ENTRY(entry), path_str); priv->in_change = FALSE; gtk_editable_set_position(GTK_EDITABLE(entry), -1); g_free(path_str); }
/** * Replace an incompleted address with a completed one. * \param entry Address entry field. * \param newtext New text. * \param start_pos Insertion point in entry field. */ static void replace_address_in_edit(GtkEntry *entry, const gchar *newtext, gint start_pos, gboolean is_group, GList *grp_emails) { if (!newtext) return; gtk_editable_delete_text(GTK_EDITABLE(entry), start_pos, -1); if (!is_group) { gtk_editable_insert_text(GTK_EDITABLE(entry), newtext, strlen(newtext), &start_pos); } else { gchar *addresses = NULL; GList *cur = grp_emails; for (; cur; cur = cur->next) { gchar *tmp; ItemEMail *email = (ItemEMail *)cur->data; ItemPerson *person = ( ItemPerson * ) ADDRITEM_PARENT(email); gchar *addr = get_complete_address_from_name_email( ADDRITEM_NAME(person), email->address); if (addresses) tmp = g_strdup_printf("%s, %s", addresses, addr); else tmp = g_strdup_printf("%s", addr); g_free(addr); g_free(addresses); addresses = tmp; } gtk_editable_insert_text(GTK_EDITABLE(entry), addresses, strlen(addresses), &start_pos); g_free(addresses); } gtk_editable_set_position(GTK_EDITABLE(entry), -1); }
void XttFileviewGtk::list_cursor_changed_cb( GtkTreeView *tree_view, gpointer data) { XttFileviewGtk *fileview = (XttFileviewGtk *) data; if ( fileview->type == fileview_eType_Save) { char *text; static char selected_text[80]; GtkTreeIter iter; GtkTreeModel *store; g_object_get( fileview->list, "model", &store, NULL); GtkTreeSelection *selection = gtk_tree_view_get_selection( GTK_TREE_VIEW(fileview->list)); if ( gtk_tree_selection_get_selected( selection, NULL, &iter)) { gtk_tree_model_get( GTK_TREE_MODEL( store), &iter, 0, &text, -1); strcpy( selected_text, text); } gint pos = 0; gtk_editable_delete_text( GTK_EDITABLE(fileview->input_text), 0, -1); gtk_editable_insert_text( GTK_EDITABLE(fileview->input_text), selected_text, strlen(selected_text), &pos); // Select the text gtk_editable_set_position( GTK_EDITABLE(fileview->input_text), -1); gtk_editable_select_region( GTK_EDITABLE(fileview->input_text), 0, -1); } }
static void layout_path_entry_tab_cb(const gchar *path, gpointer data) { LayoutWindow *lw = data; gchar *buf; gchar *base; buf = g_strdup(path); parse_out_relatives(buf); base = remove_level_from_path(buf); if (isdir(buf)) { if ((!lw->path || strcmp(lw->path, buf) != 0) && layout_set_path(lw, buf)) { gint pos = -1; /* put the '/' back, if we are in tab completion for a dir and result was path change */ gtk_editable_insert_text(GTK_EDITABLE(lw->path_entry), "/", -1, &pos); gtk_editable_set_position(GTK_EDITABLE(lw->path_entry), strlen(gtk_entry_get_text(GTK_ENTRY(lw->path_entry)))); } } else if (lw->path && strcmp(lw->path, base) == 0) { layout_list_scroll_to_subpart(lw, filename_from_path(buf)); } g_free(base); g_free(buf); }
void gtkurl_check_all(GtkText *gtktext) { guint origpos; guint pos = 0; guint len; float adj_value; len = gtk_text_get_length(gtktext); adj_value = gtktext->vadj->value; gtk_text_freeze(gtktext); origpos = gtk_editable_get_position(GTK_EDITABLE(gtktext)); while (pos < len) { while (pos < len && iswordsep(GTK_TEXT_INDEX(gtktext, pos))) pos++; while (pos < len && !iswordsep(GTK_TEXT_INDEX(gtktext, pos))) pos++; if (pos > 0) check_at(gtktext, pos-1); } gtk_text_thaw(gtktext); gtk_editable_set_position(GTK_EDITABLE(gtktext), origpos); }
static gboolean thunar_location_entry_accept_focus (ThunarLocationBar *location_bar, const gchar *initial_text) { ThunarLocationEntry *location_entry = THUNAR_LOCATION_ENTRY (location_bar); /* give the keyboard focus to the path entry */ gtk_widget_grab_focus (location_entry->path_entry); /* check if we have an initial text for the location bar */ if (G_LIKELY (initial_text != NULL)) { /* setup the new text */ gtk_entry_set_text (GTK_ENTRY (location_entry->path_entry), initial_text); /* move the cursor to the end of the text */ gtk_editable_set_position (GTK_EDITABLE (location_entry->path_entry), -1); } else { /* select the whole path in the path entry */ gtk_editable_select_region (GTK_EDITABLE (location_entry->path_entry), 0, -1); } return TRUE; }
void XttGeGtk::ge_change_value_cb(void* ge_ctx, void* value_object, char* text) { XttGeGtk* ge = (XttGeGtk*)ge_ctx; if (ge->value_input_open) { g_object_set(ge->value_dialog, "visible", FALSE, NULL); ge->value_input_open = 0; return; } g_object_set(ge->value_dialog, "visible", TRUE, NULL); ge->message(' ', ""); gtk_widget_grab_focus(ge->value_input); gint pos = 0; gtk_editable_delete_text(GTK_EDITABLE(ge->value_input), 0, -1); gtk_editable_insert_text( GTK_EDITABLE(ge->value_input), text, strlen(text), &pos); gtk_editable_set_position(GTK_EDITABLE(ge->value_input), -1); gtk_editable_select_region(GTK_EDITABLE(ge->value_input), 0, -1); ge->value_input_open = 1; ge->current_value_object = value_object; }
static gboolean presence_chooser_entry_focus_out_cb (EmpathyPresenceChooser *chooser, GdkEventFocus *event, GtkEntry *entry) { EmpathyPresenceChooserPriv *priv = GET_PRIV (chooser); if (priv->editing_status) { /* this seems a bit evil and maybe it will be fragile, * someone should think of a better way to do it. * * The entry has focused out, but we don't know where the focus * has gone. If it goes to the combo box, we don't want to * do anything. If it's gone anywhere else, we want to commit * the result. * * Thus we install this idle handler and store its source. * If the source is scheduled when the popup handler runs, * it will remove it, else the callback will commit the result. */ priv->focus_out_idle_source = g_idle_add ( presence_chooser_entry_focus_out_idle_cb, chooser); } gtk_editable_set_position (GTK_EDITABLE (entry), 0); return FALSE; }
static void fm_path_entry_paste_and_go(GtkMenuItem *menuitem, GtkEntry *entry) { GtkClipboard* clipboard = gtk_clipboard_get_for_display( gtk_widget_get_display (GTK_WIDGET (menuitem)),GDK_SELECTION_CLIPBOARD); gchar* full_path = gtk_clipboard_wait_for_text(clipboard); if (full_path) { FmPathEntryPrivate *priv = FM_PATH_ENTRY_GET_PRIVATE(entry); if(priv->path) fm_path_unref(priv->path); /* special handling for home dir */ if(full_path[0] == '~' && full_path[1] == G_DIR_SEPARATOR) priv->path = fm_path_new_relative(fm_path_get_home(), full_path + 2); else if(full_path[0] == '~' && full_path[1] == 0) priv->path = fm_path_ref(fm_path_get_home()); else priv->path = fm_path_new_for_str(full_path); gchar * disp_name = fm_path_display_name(priv->path, FALSE); gtk_entry_set_text(entry, disp_name); g_free(disp_name); gtk_editable_set_position(GTK_EDITABLE(entry), -1); g_free(full_path); fm_path_entry_activate(FM_PATH_ENTRY(entry)); } }
static void fm_path_entry_on_activate(GtkEntry *entry, gpointer user_data) { FmPathEntryPrivate *priv = FM_PATH_ENTRY_GET_PRIVATE(entry); const char* full_path; char* disp_name; /* convert current path string to FmPath here */ full_path = gtk_entry_get_text(entry); if(priv->path) fm_path_unref(priv->path); /* special handling for home dir */ if(full_path[0] == '~' && full_path[1] == G_DIR_SEPARATOR) priv->path = fm_path_new_relative(fm_path_get_home(), full_path + 2); else if(full_path[0] == '~' && full_path[1] == 0) priv->path = fm_path_ref(fm_path_get_home()); else priv->path = fm_path_new_for_str(full_path); disp_name = fm_path_display_name(priv->path, FALSE); gtk_entry_set_text(entry, disp_name); g_free(disp_name); gtk_editable_set_position(GTK_EDITABLE(entry), -1); }
static gboolean fm_path_entry_match_selected(GtkEntryCompletion *widget, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data) { GtkWidget *entry = gtk_entry_completion_get_entry(widget); gchar new_text[PATH_MAX]; FmPathEntryPrivate *priv = FM_PATH_ENTRY_GET_PRIVATE( FM_PATH_ENTRY(entry) ); gchar *model_file_name; gchar *new_path; gtk_tree_model_get(GTK_TREE_MODEL(model), iter, COL_FILE_NAME, &model_file_name, -1); /* FIXME: should we use UTF-8 encoded display name here? */ new_path = fm_path_to_str(priv->completion_model->dir->dir_path); g_sprintf(new_text, "%s/%s", /* prevent leading double slash */ g_str_equal(new_path, "/") ? "" : new_path, model_file_name); g_free(new_path); priv->completion_len = 0; gtk_entry_set_text(GTK_ENTRY(entry), new_text); /* move the cursor to the end of entry */ gtk_editable_set_position(GTK_EDITABLE(entry), -1); return TRUE; }
static void ide_editor_spell_widget__row_selected_cb (IdeEditorSpellWidget *self, GtkListBoxRow *row, GtkListBox *listbox) { const gchar *word; GtkLabel *label; g_assert (IDE_IS_EDITOR_SPELL_WIDGET (self)); g_assert (GTK_IS_LIST_BOX_ROW (row) || row == NULL); g_assert (GTK_IS_LIST_BOX (listbox)); if (row != NULL) { label = GTK_LABEL (gtk_bin_get_child (GTK_BIN (row))); word = gtk_label_get_text (label); g_signal_handlers_block_by_func (self->word_entry, ide_editor_spell_widget__word_entry_changed_cb, self); gtk_entry_set_text (self->word_entry, word); gtk_editable_set_position (GTK_EDITABLE (self->word_entry), -1); update_change_ignore_sensibility (self); g_signal_handlers_unblock_by_func (self->word_entry, ide_editor_spell_widget__word_entry_changed_cb, self); } }
/** * gimp_color_hex_entry_set_color: * @entry: a #GimpColorHexEntry widget * @color: pointer to a #GimpRGB * * Sets the color displayed by a #GimpColorHexEntry. If the new color * is different to the previously set color, the "color-changed" * signal is emitted. * * Since: GIMP 2.2 **/ void gimp_color_hex_entry_set_color (GimpColorHexEntry *entry, const GimpRGB *color) { g_return_if_fail (GIMP_IS_COLOR_HEX_ENTRY (entry)); g_return_if_fail (color != NULL); if (gimp_rgb_distance (&entry->color, color) > 0.0) { gchar buffer[8]; guchar r, g, b; gimp_rgb_set (&entry->color, color->r, color->g, color->b); gimp_rgb_clamp (&entry->color); gimp_rgb_get_uchar (&entry->color, &r, &g, &b); g_snprintf (buffer, sizeof (buffer), "%.2x%.2x%.2x", r, g, b); gtk_entry_set_text (GTK_ENTRY (entry), buffer); /* move cursor to the end */ gtk_editable_set_position (GTK_EDITABLE (entry), -1); g_signal_emit (entry, entry_signals[COLOR_CHANGED], 0); } }
static void gimp_path_editor_new_clicked (GtkWidget *widget, GimpPathEditor *editor) { if (editor->sel_path) { g_signal_handlers_block_by_func (editor->sel, gimp_path_editor_selection_changed, editor); gtk_tree_selection_unselect_path (editor->sel, editor->sel_path); g_signal_handlers_unblock_by_func (editor->sel, gimp_path_editor_selection_changed, editor); gtk_tree_path_free (editor->sel_path); editor->sel_path = NULL; } gtk_widget_set_sensitive (editor->delete_button, FALSE); gtk_widget_set_sensitive (editor->up_button, FALSE); gtk_widget_set_sensitive (editor->down_button, FALSE); gtk_widget_set_sensitive (editor->file_entry, TRUE); gtk_editable_set_position (GTK_EDITABLE (GIMP_FILE_ENTRY (editor->file_entry)->entry), -1); gtk_widget_grab_focus (GTK_WIDGET (GIMP_FILE_ENTRY (editor->file_entry)->entry)); }
void sc_focus_inputbar(Browser *b, const Arg *arg) { char *data, *clipboard_text; if (arg->data) { if (arg->n == APPEND_URL) { asprintf(&data, "%s%s", arg->data, webkit_web_view_get_uri(b->UI.view)); } else { data = strdup(arg->data); } browser_notify(b, DEFAULT, data); free(data); /* save primary selection - will be overwritten on grab_focus */ clipboard_text = gtk_clipboard_wait_for_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY)); gtk_widget_grab_focus(GTK_WIDGET(b->UI.inputbar)); gtk_editable_set_position(GTK_EDITABLE(b->UI.inputbar), -1); if (clipboard_text) { /* restore primary selection */ gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), clipboard_text, -1); free(clipboard_text); } } else if (!gtk_widget_is_focus(GTK_WIDGET(b->UI.inputbar))) { gtk_widget_grab_focus(GTK_WIDGET(b->UI.inputbar)); } if (!gtk_widget_get_visible(GTK_WIDGET(b->UI.inputbar))) { gtk_widget_show(GTK_WIDGET(b->UI.inputbar)); } }
static GtkWidget * ekiga_window_uri_entry_new (EkigaWindow *mw) { GtkWidget *entry = NULL; GtkEntryCompletion *completion = NULL; g_return_val_if_fail (EKIGA_IS_WINDOW (mw), NULL); /* URI Entry */ entry = gm_entry_new (BASIC_URI_REGEX); gm_entry_set_activate_icon (GM_ENTRY (entry), "call-start"); mw->priv->completion = gtk_list_store_new (1, G_TYPE_STRING); completion = gtk_entry_completion_new (); gtk_entry_completion_set_model (GTK_ENTRY_COMPLETION (completion), GTK_TREE_MODEL (mw->priv->completion)); gtk_entry_completion_set_text_column (GTK_ENTRY_COMPLETION (completion), 0); gtk_entry_set_completion (GTK_ENTRY (entry), completion); gtk_entry_set_text (GTK_ENTRY (entry), "sip:"); gtk_entry_completion_set_inline_completion (GTK_ENTRY_COMPLETION (completion), true); gtk_entry_completion_set_popup_completion (GTK_ENTRY_COMPLETION (completion), true); gtk_widget_add_accelerator (entry, "grab-focus", mw->priv->accel, GDK_KEY_L, (GdkModifierType) GDK_CONTROL_MASK, (GtkAccelFlags) 0); gtk_editable_set_position (GTK_EDITABLE (entry), -1); g_signal_connect (entry, "changed", G_CALLBACK (url_changed_cb), mw); g_signal_connect (entry, "activated", G_CALLBACK (place_call_cb), mw); return entry; }
gboolean on_match_selected( GtkEntryCompletion *completion, GtkTreeModel *model, GtkTreeIter *iter, GtkWidget *entry ) { char* path = NULL; gtk_tree_model_get( model, iter, COL_PATH, &path, -1 ); if ( path && path[0] && !g_str_has_suffix( path, "/" ) ) { g_signal_handlers_block_matched( G_OBJECT( entry ), G_SIGNAL_MATCH_FUNC, 0, 0, NULL, on_changed, NULL ); char* new_path = g_strdup_printf( "%s/", path ); gtk_entry_set_text( GTK_ENTRY( entry ), new_path ); g_free( new_path ); g_free( path ); gtk_editable_set_position( (GtkEditable*)entry, -1 ); g_signal_handlers_unblock_matched( G_OBJECT( entry ), G_SIGNAL_MATCH_FUNC, 0, 0, NULL, on_changed, NULL ); on_changed( GTK_ENTRY( entry ), NULL ); return TRUE; } return FALSE; }
static void menu_join(GtkWidget *wid, gpointer none) { GtkWidget *hbox, *dialog, *entry, *label; dialog = gtk_dialog_new_with_buttons(_("Join Channel"), GTK_WINDOW(parent_window), 0, _("Retrieve channel list..."), GTK_RESPONSE_HELP, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL); gtk_box_set_homogeneous(GTK_BOX(GTK_DIALOG(dialog)->vbox), TRUE); gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_MOUSE); hbox = gtk_hbox_new(TRUE, 0); entry = gtk_entry_new(); GTK_ENTRY(entry)->editable = 0; /* avoid auto-selection */ gtk_entry_set_text(GTK_ENTRY(entry), "#"); g_signal_connect(G_OBJECT(entry), "activate", G_CALLBACK(menu_join_entry_cb), dialog); gtk_box_pack_end(GTK_BOX(hbox), entry, 0, 0, 0); label = gtk_label_new(_("Enter Channel to Join:")); gtk_box_pack_end(GTK_BOX(hbox), label, 0, 0, 0); g_signal_connect(G_OBJECT(dialog), "response", G_CALLBACK(menu_join_cb), entry); gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), hbox); gtk_widget_show_all(dialog); gtk_editable_set_editable(GTK_EDITABLE(entry), TRUE); gtk_editable_set_position(GTK_EDITABLE(entry), 1); }
gboolean vol_set_filename_text(gpointer data) { volume_t * vol = (volume_t *)data; AQUALUNG_MUTEX_LOCK(vol->wait_mutex); if (vol->slot) { char * utf8; AQUALUNG_MUTEX_LOCK(vol->thread_mutex); utf8 = g_filename_display_name(vol->item->file); AQUALUNG_MUTEX_UNLOCK(vol->thread_mutex); gtk_entry_set_text(GTK_ENTRY(vol->file_entry), utf8); gtk_editable_set_position(GTK_EDITABLE(vol->file_entry), -1); g_free(utf8); } AQUALUNG_COND_SIGNAL(vol->thread_wait); AQUALUNG_MUTEX_UNLOCK(vol->wait_mutex); return FALSE; }
static gboolean tab_completion_popup_key_press(GtkWidget *widget, GdkEventKey *event, gpointer data) { TabCompData *td = data; if (event->keyval == GDK_KEY_Tab || event->keyval == GDK_KEY_BackSpace || (event->keyval >= 0x20 && event->keyval <= 0xFF) ) { if (event->keyval >= 0x20 && event->keyval <= 0xFF) { gchar buf[2]; gint p = -1; buf[0] = event->keyval; buf[1] = '\0'; gtk_editable_insert_text(GTK_EDITABLE(td->entry), buf, 1, &p); gtk_editable_set_position(GTK_EDITABLE(td->entry), -1); /* Reduce the number of entries in the menu */ td->choices = 0; gtk_container_foreach(GTK_CONTAINER(widget), tab_completion_iter_menu_items, (gpointer) td); if (td->choices > 1) return TRUE; /* multiple choices */ if (td->choices > 0) tab_completion_do(td); /* one choice */ } /* close the menu */ gtk_menu_popdown(GTK_MENU(widget)); /* doing this does not emit the "selection done" signal, unref it ourselves */ g_object_unref(widget); return TRUE; } return FALSE; }
static void midorator_entry_perform_completion(MidoratorEntry* e) { char *str = g_strdup(gtk_entry_get_text(GTK_ENTRY(e))); int prelen = 0; if (str[0]) { prelen = g_utf8_offset_to_pointer(str, gtk_editable_get_position(GTK_EDITABLE(e))) - str; str[prelen] = 0; } GList *list = midorator_entry_get_comp_list(e, str); g_free(str); if (!list) return; str = g_strdup(list->data); GList *i; bool crop = false; for (i = list->next; i; i = i->next) { const char *s = i->data; int j; for (j = 0; s[j] && s[j] == str[j]; j++); if (str[j]) { crop = true; str[j] = 0; } } int pos = gtk_editable_get_position(GTK_EDITABLE(e)); gtk_editable_insert_text(GTK_EDITABLE(e), str + prelen, -1, &pos); if (!crop) gtk_editable_insert_text(GTK_EDITABLE(e), " ", -1, &pos); gtk_editable_set_position(GTK_EDITABLE(e), pos); g_free(str); }
/* entry_insert_text(const char *) {{{*/ void entry_insert_text(const char *text) { int position = gtk_editable_get_position(GTK_EDITABLE(dwb.gui.entry)); gtk_editable_insert_text(GTK_EDITABLE(dwb.gui.entry), text, -1, &position); gtk_editable_set_position(GTK_EDITABLE(dwb.gui.entry), position); }/*}}}*/
/* Starts the selection state in the icon text item */ static void iti_start_selecting (MateIconTextItem *iti, int idx, guint32 event_time) { MateIconTextItemPrivate *priv; GtkEditable *e; GdkCursor *ibeam; priv = iti->_priv; e = GTK_EDITABLE (priv->entry); gtk_editable_select_region (e, idx, idx); gtk_editable_set_position (e, idx); ibeam = gdk_cursor_new (GDK_XTERM); mate_canvas_item_grab (MATE_CANVAS_ITEM (iti), GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK, ibeam, event_time); gdk_cursor_unref (ibeam); gtk_editable_select_region (e, idx, idx); priv->selecting = TRUE; priv->selection_start = idx; mate_canvas_item_request_update (MATE_CANVAS_ITEM (iti)); g_signal_emit (iti, iti_signals[SELECTION_STARTED], 0); }
static void autocomplete_protocol_string(GtkWidget *filter_te, gchar *selected_str) { int pos; gchar *filter_str; gchar *pch; /* Get the current filter string */ pos = gtk_editable_get_position(GTK_EDITABLE(filter_te)); filter_str = gtk_editable_get_chars(GTK_EDITABLE(filter_te), 0, pos); /* Start from the end */ pch = filter_str + strlen(filter_str); /* Walk back through string to find last non-punctuation */ while(pch != filter_str) { pch--; if(!g_ascii_isalnum(*pch) && (*pch) != '.' && (*pch) != '_' && (*pch) != '-') { pch++; break; } } if(strncmp(pch, selected_str, pos-(pch-filter_str))) { gtk_editable_delete_text(GTK_EDITABLE(filter_te), (gint) (pch-filter_str), pos); pos = (int) (pch-filter_str); pch = selected_str; } else { pch = (selected_str + strlen(pch)); } gtk_editable_insert_text(GTK_EDITABLE(filter_te), pch, (gint) strlen(pch), &pos); gtk_editable_set_position(GTK_EDITABLE(filter_te), pos); g_free (filter_str); }
void wxTextEntry::WriteText(const wxString& value) { GtkEditable * const edit = GetEditable(); // remove the selection if there is one and suppress the text change event // generated by this: we only want to generate one event for this change, // not two { EventsSuppressor noevents(this); gtk_editable_delete_selection(edit); } // insert new text at the cursor position gint len = gtk_editable_get_position(edit); gtk_editable_insert_text ( edit, wxGTK_CONV_FONT(value, GetEditableWindow()->GetFont()), -1, // text: length: compute it using strlen() &len // will be updated to position after the text end ); // and move cursor to the end of new text gtk_editable_set_position(edit, len); }
static void on_menuitem_select_all_activate(void) { GtkEditable *widget = GTK_EDITABLE(gtk_window_get_focus(gui.window)); gtk_editable_set_position(widget, -1); gtk_editable_select_region(widget, 0, -1); }