void Settings::restore_settings() { char buffer[10]; m_local_aet->set_text(m_configuration.get_local_aet()); g_snprintf(buffer, sizeof(buffer), "%i", m_configuration.get_local_port()); m_local_port->set_text(buffer); Glib::ustring charset = ImagePool::get_encoding(); m_characterset->set_active_text(charset); Gtk::TreeModel::Children::iterator i = m_refTreeModel->children().begin(); for(; i != m_refTreeModel->children().end();) { i = m_refTreeModel->erase(i); } Glib::RefPtr<ImagePool::ServerList> list = ImagePool::ServerList::get(); for(ImagePool::ServerList::iterator i = list->begin(); i != list->end(); i++) { Gtk::TreeModel::Row row = *(m_refTreeModel->append()); row[m_Columns.m_aet] = i->second.m_aet; row[m_Columns.m_port] = i->second.m_port; row[m_Columns.m_hostname] = i->second.m_hostname; row[m_Columns.m_name] = i->second.m_name; row[m_Columns.m_group] = i->second.m_group; row[m_Columns.m_lossy] = i->second.m_lossy; row[m_Columns.m_relational] = i->second.m_relational; } reload_windowlevel_preset(m_windowlevels_modality); }
GCodeIter::GCodeIter (Glib::RefPtr<Gtk::TextBuffer> buffer) : m_buffer (buffer), m_it (buffer->begin()), m_line_count (buffer->get_line_count()), m_cur_line (1) { }
int textview___::insert__(std::deque<Glib::ustring>* p,size_t start){ Gtk::TextView* tv=tv__(p,1+start); if(!tv){ return 1; } int i=0; size_t i_ctl=3+start; if(p->size()>i_ctl){ if((*p)[i_ctl]=="头") i=1; else if((*p)[i_ctl]=="尾") i=2; else{ d_(sh_,err_show_buzhichi_,2,p,i_ctl); return 1; } } Glib::RefPtr < Gtk::TextBuffer > tb = tv->get_buffer(); Gtk::TextBuffer::iterator i1,i2; switch(i){ case 1: i1=tb->begin(); break; case 2: i1=tb->end(); break; default: tb->get_selection_bounds(i1,i2); if(i2>i1){ i1=tb->erase(i1,i2); } break; } Gdk::Rectangle rect; tv->get_visible_rect(rect); int y = -1; int height = -1; tv->get_line_yrange(i1, y, height); tb->place_cursor(tb->insert(i1, (*p)[2+start])); if (y < rect.get_y() + rect.get_height() + 16) tv->scroll_to_mark(tb->get_insert(), 0); return 1; }
void GscExecutorLogWindow::on_tree_selection_changed() { this->clear_view_widgets(); if (selection->count_selected_rows()) { Gtk::TreeIter iter = selection->get_selected(); Gtk::TreeRow row = *iter; CmdexSyncCommandInfoRefPtr entry = row[col_entry]; Gtk::TextView* output_textview = this->lookup_widget<Gtk::TextView*>("output_textview"); if (output_textview) { Glib::RefPtr<Gtk::TextBuffer> buffer = output_textview->get_buffer(); if (buffer) { buffer->set_text(app_output_make_valid(entry->std_output)); Glib::RefPtr<Gtk::TextTag> tag; Glib::RefPtr<Gtk::TextTagTable> table = buffer->get_tag_table(); if (table) tag = table->lookup("font"); if (!tag) tag = buffer->create_tag("font"); tag->property_family() = "Monospace"; buffer->apply_tag(tag, buffer->begin(), buffer->end()); } } Gtk::Entry* command_entry = this->lookup_widget<Gtk::Entry*>("command_entry"); if (command_entry) { std::string cmd_text = entry->command + " " + entry->parameters; command_entry->set_text(app_output_make_valid(cmd_text)); } Gtk::Button* window_save_current_button = this->lookup_widget<Gtk::Button*>("window_save_current_button"); if (window_save_current_button) window_save_current_button->set_sensitive(true); } }
void SendMsgDlgTab::on_send_button_clicked() { m_bold_button.set_active(false); m_italic_button.set_active(false); m_underline_button.set_active(false); m_bigfont_button.set_active(false); m_normalfont_button.set_active(false); m_smallfont_button.set_active(false); m_selectfont_button.set_active(false); m_fgcolor_button.set_active(false); m_bgcolor_button.set_active(false); m_smilies_button.set_active(false); Glib::RefPtr<Gtk::TextBuffer> buffer; buffer = m_input_textview.get_buffer(); if (buffer->size() != 0) { Glib::ustring text = buffer->get_text(false); linqMain->getUDPSession()->sendMessage(MSG_TEXT, name.c_str(), text.c_str()); m_input_textview.get_buffer()->erase(buffer->begin(), buffer->end()); time_t when; when = time(NULL); char mdate[64]; strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&when)); std::string str; str = "<FONT SIZE=\"2\">("; str += mdate; str += ") </FONT><B>"; str += linqMain->myInfo.name; str += ": "; str += text; str += "</B><BR>"; gtk_imhtml_append_text(GTK_IMHTML(imhtml), str.c_str(), str.length(), (GtkIMHtmlOptions)0); } m_input_textview.grab_focus(); }
static void deserialize(const Glib::RefPtr<Gtk::TextBuffer> &buffer, const std::string & content) { deserialize(buffer, buffer->begin(), content); }
/** * Also a public method. Remove all text from the dialog */ void Messages::clear() { Glib::RefPtr<Gtk::TextBuffer> buffer = messageText.get_buffer(); buffer->erase(buffer->begin(), buffer->end()); }
GscHelpWindow::GscHelpWindow(BaseObjectType* gtkcobj, const app_ui_res_ref_t& ref_ui) : AppUIResWidget<GscHelpWindow, false>(gtkcobj, ref_ui), selection_callback_enabled(true) { // Connect callbacks APP_GTKMM_CONNECT_VIRTUAL(delete_event); // make sure the event handler is called Gtk::Button* window_close_button = 0; APP_UI_RES_AUTO_CONNECT(window_close_button, clicked); // Accelerators Glib::RefPtr<Gtk::AccelGroup> accel_group = this->get_accel_group(); if (window_close_button) { window_close_button->add_accelerator("clicked", accel_group, GDK_Escape, Gdk::ModifierType(0), Gtk::AccelFlags(0)); } // --------------- Make a treeview Gtk::TreeView* treeview = this->lookup_widget<Gtk::TreeView*>("topics_treeview"); if (treeview) { Gtk::TreeModelColumnRecord model_columns; int num_tree_cols = 0; // Topic model_columns.add(col_topic); num_tree_cols = app_gtkmm_create_tree_view_column(col_topic, *treeview, "Topic", "Topic"); // create a TreeModel (ListStore) list_store = Gtk::ListStore::create(model_columns); treeview->set_model(list_store); selection = treeview->get_selection(); selection->signal_changed().connect(sigc::mem_fun(*this, &self_type::on_tree_selection_changed) ); } // --------------- Parse help text /* README.txt File Format The whole text is converted to unix newline format before parsing. Sections are separated by 3 newlines (two empty lines). The first line of the section is its header. When splitting the file to sections and headers, any leading or trailing whitespace is removed. If there is a single newline inside a section, it is converted to space to enable correct wrapping. If there are two consequent newlines, they are left as they are, essentially making a paragraph break. */ std::string readme = hz::string_any_to_unix_copy(ReadmeTextResData().get_string()); // split by double-newlines std::vector<std::string> topics; hz::string_split(readme, "\n\n\n", topics, true); // skip empty // add to treeview and textview Gtk::TextView* content = this->lookup_widget<Gtk::TextView*>("content_textview"); if (treeview && content) { Glib::RefPtr<Gtk::TextBuffer> buffer = content->get_buffer(); buffer->create_mark("Begin", buffer->begin(), true); for (unsigned int i = 0; i < topics.size(); ++i) { std::string topic = hz::string_trim_copy(topics[i]); // The first line of topic is its title std::vector<std::string> topic_split; hz::string_split(topic, "\n\n", topic_split, true, 2); // skip empty, get 2 elements only if (topic_split.size() < 2) { debug_out_warn("app", DBG_FUNC_MSG << "Cannot extract topic title in topic " << i << "\n"); continue; } std::string topic_title = hz::string_trim_copy(topic_split[0]); std::string topic_body = hz::string_trim_copy(topic_split[1]); buffer->create_mark(topic_title, buffer->end(), true); // set topic mark to the end of what's there // add the title and make it bold buffer->insert(buffer->end(), "\n" + topic_title); Gtk::TextIter first = buffer->end(), last = first; first.backward_lines(1); Glib::RefPtr<Gtk::TextTag> tag = buffer->create_tag(); tag->property_weight() = Pango::WEIGHT_BOLD; tag->property_size_points() = 14; buffer->apply_tag(tag, first, last); // add the rest // single newlines to spaces, to allow proper wrapping. app_pcre_replace("/([^\\n])\\n([^\\n])/", "\\1 \\2", topic_body); buffer->insert(buffer->end(), "\n\n" + topic_body + "\n\n"); // Add to treeview Gtk::TreeRow row = *(list_store->append()); row[col_topic] = topic_title; } } // --------------- // show(); }
int textview___::proc__(std::deque<Glib::ustring>* p,char*buf,long siz,char**addr_ret,void*shangji) { char sdz=0; if((*p)[0]=="插入"){ if(siz==-1)return 1; sdz='i'; }else if((*p)[0]==name__()){ if(siz==-1)return 1; sdz='t'; }else return 0; if(p->size()<=2){ d_(sh_,err_show_buzu_,p); return 1; } switch(sdz){ case'i': return insert__(p,0); case't': { Gtk::TextView* tv; char sdz1=0; const Glib::ustring& p1=(*p)[1]; if(p1=="剪切") sdz1='x'; else if(p1=="复制") sdz1='c'; else if(p1=="粘贴") sdz1='v'; else if(p1=="已修改") sdz1='m'; else if(p1=="内容") sdz1=' '; else if(p1=="焦点") sdz1='.'; else if(p1=="不可编辑") sdz1='e'; else if(p1=="光标位置") sdz1='p'; else if(p1=="光标行列") sdz1='l'; else if(p1=="选择") sdz1='S'; else if(p1=="插入") return insert__(p,1); else{ switch(sdz){ case't': d_(sh_,err_show_buzhichi_,2,p,1); return 1; } } tv=tv__(p,2); if(!tv) return 1; Glib::RefPtr < Gtk::TextBuffer > tb = tv->get_buffer(); switch(sdz1){ case'x': case'c': case'v': { Glib::RefPtr<Gtk::Clipboard> cb = Gtk::Clipboard::get(); switch(sdz1){ case'x': tb->cut_clipboard(cb); break; case'c': tb->copy_clipboard(cb); break; case'v': tb->paste_clipboard(cb); break; } break; } case'm': if(p->size()>3){ const Glib::ustring&s=(*p)[3]; if(s=="侦听"){ control___* ctl=Gtk::manage(new control___(sh_,d_,(*p)[0],(*p)[2],p1)); if(p->size()>4) ctl->code__((*p)[4]); tb->signal_modified_changed().connect(sigc::mem_fun(*ctl,&control___::modified_changed__),false); }else tb->set_modified(d_(sh_,bool_,s.c_str())); }else l2s__(tb->get_modified(),buf); break; case' ': if(p->size()>3) tb->set_text((*p)[3]); else *addr_ret=dup__(tb->get_text().c_str()); break; case'.': tv->grab_focus(); break; case'e': if(p->size()>3) tv->set_editable(d_(sh_,bool_,(*p)[3].c_str())); else tv->set_editable(false); break; case'p': case'l': { Gtk::TextIter ti=tb->get_iter_at_mark(tb->get_mark("insert")); if(sdz1=='l'){ if(p->size()<=3) sprintf(buf,"%d,%d,",ti.get_line (),ti.get_line_offset ()); else{ int line_offset=ti.get_line_offset (); if(p->size()>3) ti.set_line (s2i_plus__((*p)[3],ti.get_line ())); if(p->size()>4) ti.set_line_offset (s2i_plus__((*p)[4],line_offset)); tb->place_cursor(ti); } }else{ if(p->size()>3){ ti.set_offset (s2i_plus__((*p)[3],ti.get_offset ())); tb->place_cursor(ti); }else l2s__(ti.get_offset (),buf); } break; } case'S': if(p->size()>4){ Gtk::TextIter ti1=tb->begin(),ti2=tb->begin(); ti1.set_offset(s2i__((*p)[3])); ti2.set_offset(s2i__((*p)[4])); tb->select_range(ti1,ti2); } break; } break; } } return 1; }
void DebugDialogImpl::clear() { Glib::RefPtr<Gtk::TextBuffer> buffer = messageText.get_buffer(); buffer->erase(buffer->begin(), buffer->end()); }