void WAttGtk::activate_cmd_input( GtkWidget *w, gpointer data) { char *text, *textutf8; WAttGtk *watt = (WAttGtk *)data; int sts; watt->wattnav->set_inputfocus(); textutf8 = gtk_editable_get_chars( GTK_EDITABLE(w), 0, -1); text = g_convert( textutf8, -1, "ISO8859-1", "UTF-8", NULL, NULL, NULL); g_free( textutf8); if ( watt->input_open) { sts = ((WAttNav *)watt->wattnav)->set_attr_value( watt->input_node, watt->input_name, text); g_object_set( w, "visible", FALSE, NULL); watt->set_prompt( ""); watt->input_open = 0; if ( watt->redraw_cb) (watt->redraw_cb)( watt); } g_free( text); g_object_set( watt->cmd_prompt, "visible", FALSE, NULL); g_object_set( watt->cmd_input, "visible", FALSE, NULL); if ( watt->pending_close) { if ( watt->close_cb) (watt->close_cb)( watt); else delete watt; } }
void WAttGtk::activate_cmd_scrolled_ok(GtkWidget* w, gpointer data) { WAttGtk* watt = (WAttGtk*)data; gchar *text, *textutf8; unsigned char* s; int sts; if (watt->input_open) { GtkTextIter start_iter, end_iter; gtk_text_buffer_get_start_iter(watt->cmd_scrolled_buffer, &start_iter); gtk_text_buffer_get_end_iter(watt->cmd_scrolled_buffer, &end_iter); textutf8 = gtk_text_buffer_get_text( watt->cmd_scrolled_buffer, &start_iter, &end_iter, FALSE); text = g_convert(textutf8, -1, "ISO8859-1", "UTF-8", NULL, NULL, NULL); g_free(textutf8); if (text) { // Replace ctrl characters with space for (s = (unsigned char*)text; *s; s++) { if (*s < ' ' && *s != 10 && *s != 13) *s = ' '; } sts = ((WAttNav*)watt->wattnav) ->set_attr_value(watt->input_node, watt->input_name, text); } g_object_set(watt->cmd_scrolledinput, "visible", FALSE, NULL); watt->set_prompt(""); watt->input_open = 0; int w, h; gdk_drawable_get_size(watt->pane->window, &w, &h); gtk_paned_set_position(GTK_PANED(watt->pane), h - 50); ((WAttNav*)watt->wattnav)->redraw(); ((WAttNav*)watt->wattnav)->set_inputfocus(); if (text) g_free(text); else watt->message('E', "Input error, invalid character"); if (watt->pending_close) { if (watt->close_cb) (watt->close_cb)(watt); else delete watt; } } }
void WAttGtk::activate_cmd_scrolled_ca( GtkWidget *w, gpointer data) { WAttGtk *watt = (WAttGtk *)data; if ( watt->input_open) { g_object_set( watt->cmd_scrolledinput, "visible", FALSE, NULL); int w, h; gdk_drawable_get_size( watt->pane->window, &w, &h); gtk_paned_set_position( GTK_PANED(watt->pane), h - 50); watt->set_prompt( ""); watt->input_open = 0; watt->wattnav->set_inputfocus(); } }
void WAttGtk::action_text_inserted( GtkTextBuffer *w, GtkTextIter *iter, gchar *str, gint len, gpointer data) { WAttGtk *watt = (WAttGtk *)data; int count = gtk_text_buffer_get_char_count( w); if ( count > watt->input_max_length) { // Remove inserted chars (note that iter now points at the end of the inserted text) GtkTextIter start_iter; int offs = gtk_text_iter_get_offset( iter); gtk_text_buffer_get_iter_at_offset( w, &start_iter, offs - len); gtk_text_buffer_delete( w, &start_iter, iter); CoWowGtk wow( watt->toplevel); wow.DisplayError( "Error message", "Attribute size exceeded"); } else watt->message( ' ', ""); }