//------------------------------------------------------------------------------ void DbMySQLTableEditor::refresh_table_page() { Gtk::Entry *entry(0); xml()->get_widget("table_name", entry); if (_be->get_name() != entry->get_text()) { entry->set_text(_be->get_name()); _signal_title_changed.emit(_be->get_title()); } Gtk::TextView *tview; xml()->get_widget("table_comments", tview); if (_be->get_comment() != tview->get_buffer()->get_text()) tview->get_buffer()->set_text(_be->get_comment()); Gtk::ComboBox *combo = 0; xml()->get_widget("engine_combo", combo); set_selected_combo_item(combo, _be->get_table_option_by_name("ENGINE")); xml()->get_widget("collation_combo", combo); std::string collation = _be->get_table_option_by_name("CHARACTER SET - COLLATE"); if (collation == " - " || collation.empty()) set_selected_combo_item(combo, "*Default*"); else set_selected_combo_item(combo, collation); }
virtual void do_refresh_form_data() { Gtk::Entry *entry; xml()->get_widget("name_entry", entry); Gtk::TextView *tview; xml()->get_widget("text_view", tview); Gtk::ComboBox *combo; xml()->get_widget("collation_combo", combo); Gtk::Button *btn; xml()->get_widget("refactor_btn", btn); if (_be) { set_selected_combo_item(combo, _be->get_schema_option_by_name("CHARACTER SET - COLLATE")); _old_name = _be->get_name(); entry->set_text(_old_name); tview->get_buffer()->set_text(_be->get_comment()); bool is_editing_live_obj= is_editing_live_object(); tview->set_sensitive(!is_editing_live_obj); Gtk::Label *tlabel; xml()->get_widget("label5", tlabel); tlabel->set_sensitive(!is_editing_live_obj); btn->set_sensitive(_be->refactor_possible()); } }
void GscHelpWindow::set_topic(const Glib::ustring& topic) { this->selection_callback_enabled = false; // temporarily disable it // scroll to it Gtk::TextView* content = this->lookup_widget<Gtk::TextView*>("content_textview"); if (content) { Glib::RefPtr<Gtk::TextBuffer> buffer = content->get_buffer(); Glib::RefPtr<Gtk::TextMark> mark = buffer->get_mark(topic); if (mark) content->scroll_to(mark, 0., 0., 0.); } // select it in tree view Gtk::TreeView* treeview = this->lookup_widget<Gtk::TreeView*>("topics_treeview"); if (treeview && !list_store->children().empty()) { for (Gtk::TreeIter iter = list_store->children().begin(); iter != list_store->children().end(); ++iter) { if (iter->get_value(col_topic) == topic) { selection->select(*iter); treeview->scroll_to_cell(list_store->get_path(iter), *(treeview->get_column(0)), 0.3, 0.); // about 30% from top break; } } } this->selection_callback_enabled = true; // enable it back }
void FontSubstitution::show(Glib::ustring out, GSList *l) { Gtk::MessageDialog warning(_("\nSome fonts are not available and have been substituted."), false, Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK, true); warning.set_resizable(true); warning.set_title(_("Font substitution")); GtkWidget *dlg = GTK_WIDGET(warning.gobj()); sp_transientize(dlg); Gtk::TextView * textview = new Gtk::TextView(); textview->set_editable(false); textview->set_wrap_mode(Gtk::WRAP_WORD); textview->show(); textview->get_buffer()->set_text(_(out.c_str())); Gtk::ScrolledWindow * scrollwindow = new Gtk::ScrolledWindow(); scrollwindow->add(*textview); scrollwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); scrollwindow->set_shadow_type(Gtk::SHADOW_IN); scrollwindow->set_size_request(0, 100); scrollwindow->show(); Gtk::CheckButton *cbSelect = new Gtk::CheckButton(); cbSelect->set_label(_("Select all the affected items")); cbSelect->set_active(true); cbSelect->show(); Gtk::CheckButton *cbWarning = new Gtk::CheckButton(); cbWarning->set_label(_("Don't show this warning again")); cbWarning->show(); #if GTK_CHECK_VERSION(3,0,0) Gtk::Box * box = warning.get_content_area(); #else Gtk::Box * box = warning.get_vbox(); #endif box->set_spacing(2); box->pack_start(*scrollwindow, true, true, 4); box->pack_start(*cbSelect, false, false, 0); box->pack_start(*cbWarning, false, false, 0); warning.run(); if (cbWarning->get_active()) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); prefs->setInt("/options/font/substitutedlg", 0); } if (cbSelect->get_active()) { SPDesktop *desktop = SP_ACTIVE_DESKTOP; Inkscape::Selection *selection = sp_desktop_selection (desktop); selection->clear(); selection->setList(l); } }
void DebugDialogImpl::message(char const *msg) { Glib::RefPtr<Gtk::TextBuffer> buffer = messageText.get_buffer(); Glib::ustring uMsg = msg; if (uMsg[uMsg.length()-1] != '\n') uMsg += '\n'; buffer->insert (buffer->end(), uMsg); }
virtual void do_refresh_form_data() { Gtk::Entry *entry; _xml->get_widget("name_entry", entry); Gtk::TextView *tview; _xml->get_widget("text_view", tview); entry->set_text(_be.get_name()); tview->get_buffer()->set_text(_be.get_text()); }
//------------------------------------------------------------------------------ void DbMySQLRoutineGroupEditor::do_refresh_form_data() { Gtk::Entry* entry(0); xml()->get_widget("rg_name", entry); if (entry->get_text() != _be->get_name()) { entry->set_text(_be->get_name()); _signal_title_changed.emit(_be->get_title()); } Gtk::TextView* tv; xml()->get_widget("rg_comment", tv); tv->get_buffer()->set_text(_be->get_comment()); _be->load_routines_sql(); recreate_model_from_string_list(_routines_model, _be->get_routines_names()); }
void TextBoxImpl::append_text(::mforms::TextBox *self, const std::string &text, bool scroll_to_end) { TextBoxImpl* cb = self->get_data<TextBoxImpl>(); if ( cb ) { Gtk::TextView *tv = cb->_text; if (tv) { Glib::RefPtr<Gtk::TextBuffer> buf = tv->get_buffer(); buf->insert(buf->end(), text); if (scroll_to_end) { Gtk::TextIter it = buf->end(); tv->scroll_to(it, 0.3); } } } }
int common___::proc__(std::deque<Glib::ustring>* p,char*buf,long siz,char**addr_ret,void*shangji,void*ce) { const Glib::ustring& p0=(*p)[0]; if(p0=="剪贴板"){ if(siz==-1)return 1; Glib::RefPtr<Gtk::Clipboard> cb = Gtk::Clipboard::get(); if(p->size()>1) cb->set_text((*p)[1].c_str()); else *addr_ret=dup__(cb->wait_for_text().c_str()); return 1; } if(p0=="全屏"){ if(siz==-1)return 1; Gtk::Window* w=w__(p,1); if(!w) return 1; w->fullscreen(); return 1; } if(p0=="取消全屏"){ if(siz==-1)return 1; Gtk::Window* w=w__(p,1); if(!w) return 1; w->unfullscreen(); return 1; } if(p0=="置顶"){ if(siz==-1)return 1; Gtk::Window* w=w__(p,1); if(!w) return 1; w->set_keep_above(true); return 1; } if(p0=="取消置顶"){ if(siz==-1)return 1; Gtk::Window* w=w__(p,1); if(!w) return 1; w->set_keep_above(false); return 1; } if(p0=="无边框"){ if(siz==-1)return 1; Gtk::Window* w=w__(p,1); if(!w) return 1; w->set_decorated(false); return 1; } if(p0=="跳过任务栏"){ if(siz==-1)return 1; Gtk::Window* w=w__(p,1); if(!w) return 1; w->set_skip_taskbar_hint(true); return 1; } if(p0=="窗口活动"){ if(siz==-1)return 1; Gtk::Window* w=w__(p,1); if(!w) return 1; cpy__(buf,w->property_is_active(),siz); return 1; } if(p0=="图标"){ if(siz==-1)return 1; Gtk::Window* w=w__(p,2); if(!w) return 1; if(p->size()>1){ const Glib::ustring& p1=(*p)[1]; w->set_icon_name(p1); Glib::RefPtr<Gdk::Pixbuf> pb=Gdk::Pixbuf::create_from_file(p1); if(pb) w->set_icon(pb); }else cpy__(buf,w->get_icon_name().c_str(),siz); return 1; } if(p->size()<2){ return 0; } const Glib::ustring& p1=(*p)[1]; Gtk::Entry* e; Gtk::Label* l; Gtk::Button* b; Gtk::ToolButton* tb; Gtk::TextView* tv; Gtk::Notebook* n; Gtk::Bin* bI; Gtk::Widget* w; Gtk::Statusbar* sB; Gtk::FileChooserButton* fcb; Gtk::ToggleButton* tOb;//CheckButton RadioButton Gtk::ToggleToolButton*ttb; //Gtk::RadioButtonGroup* rbg; Gtk::MenuItem* mi; Gtk::CheckMenuItem* cmi; Gtk::SpinButton* sb; if(p0=="窗口标题"){ if(siz==-1)return 1; Gtk::Window* w1; if(p1=="") w1=sh_->main_win_; else{ sh_->builder_->get_widget(p1, w); if(!w){ d_(sh_,err_show_wufa_,2,p,1); return 1; } w1=(Gtk::Window*)w; } if(p->size()<3){ cpy__(buf,w1->get_title().c_str(),siz); }else{ w1->set_title((*p)[2]); } return 1; } if(p0=="内容"){ if(siz==-1)return 1; Glib::ustring text; bool read=false; int start=2; if(p->size()>2&&(*p)[2]=="读取"){ read=true; start=3; } for(size_t i=start;i<p->size();i++){ if((*p)[i]=="源码") text+=sh_->src_; else{ if(read){ string name=sh_->ui_file_; size_t i1=name.rfind('/'); if(i1==string::npos) i1=name.rfind('\\'); if(i1!=string::npos) name=name.substr(0,i1+1); name+=(*p)[i]; file_get__(name.c_str(),text); }else text+=(*p)[i]; } } if(p1=="源码"){ if(p->size()>2) sh_->src_=text; else *addr_ret=dup__(sh_->src_.c_str()); return 1; }else{ sh_->builder_->get_widget(p1, sb); if(sb){ if(p->size()>2){ float f=0; sscanf(text.c_str(),"%f",&f); sb->set_value(f); return 1; } } sh_->builder_->get_widget(p1, e); if(e){ if(p->size()<3){ *addr_ret=dup__(e->get_text().c_str()); }else{ e->set_text(text); } return 1; } sh_->builder_->get_widget(p1, l); if(l){ if(p->size()<3){ *addr_ret=dup__(l->get_text().c_str()); }else{ l->set_markup(text); } return 1; } sh_->builder_->get_widget(p1, tv); if(tv){ if(p->size()<3){ *addr_ret=dup__(tv->get_buffer()->get_text().c_str()); }else{ tv->get_buffer()->set_text(text); } return 1; } sh_->builder_->get_widget(p1, fcb); if(fcb){ if(p->size()<3){ *addr_ret=dup__(fcb->get_filename().c_str()); }else{ fcb->set_filename(text); /*GtkFileChooser *chooser=(GtkFileChooser *)fcb->gobj(); const gchar *filename=text.c_str(); gtk_file_chooser_unselect_all (chooser); //gtk_file_chooser_select_filename (chooser, filename); GFile *file; gboolean result; file = g_file_new_for_path (filename); result = gtk_file_chooser_select_file (chooser, file, NULL); //#define GTK_FILE_CHOOSER_GET_IFACE(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GTK_TYPE_FILE_CHOOSER, GtkFileChooserIface)) //result = GTK_FILE_CHOOSER_GET_IFACE (chooser)->select_file (chooser, file, NULL); g_object_unref (file);*/ } return 1; } sh_->builder_->get_widget(p1, tOb); if(tOb){ if(p->size()<3){ cpy__(buf,tOb->get_label().c_str(),siz); }else{ tOb->set_label(text); } return 1; } sh_->builder_->get_widget(p1, sB); if(sB){ if(p->size()<3){ }else{ sB->push(text,sB->get_context_id(text)); return 1; } } sh_->builder_->get_widget(p1, n); if(n){ if(p->size()<3){ cpy__(buf,n->get_current_page()+1,siz); }else{ n->set_current_page(s2i__(text,1)-1); } return 1; } } d_(sh_,err_show_wufa_,2,p,1); return 1; } if(p0=="勾选"){ if(siz==-1)return 1; if(p->size()>2){ bool b=d_(sh_,bool_,(*p)[p->size()-1].c_str()); for(size_t i=1;i<p->size()-1;i++){ sh_->builder_->get_widget((*p)[i], tOb); if(tOb){ tOb->set_active(b); continue; } sh_->builder_->get_widget((*p)[i], ttb); if(ttb){ ttb->set_active(b); continue; } sh_->builder_->get_widget((*p)[i], cmi); if(cmi){ cmi->set_active(b); continue; } d_(sh_,err_show_wufa_,2,p,i); return 1; } }else{ sh_->builder_->get_widget(p1, tOb); if(tOb){ cpy__(buf,tOb->get_active(),siz); return 1; } sh_->builder_->get_widget(p1, ttb); if(ttb){ cpy__(buf,ttb->get_active(),siz); return 1; } sh_->builder_->get_widget(p1, cmi); if(cmi){ cpy__(buf,cmi->get_active(),siz); return 1; } d_(sh_,err_show_wufa_,2,p,1); } return 1; } if(p0=="提示文字"){ if(siz==-1)return 1; sh_->builder_->get_widget(p1, w); if(w){ if(p->size()<3){ cpy__(buf,w->get_tooltip_markup().c_str(),siz); }else{ w->set_tooltip_markup((*p)[2]); } return 1; } d_(sh_,err_show_wufa_,2,p,1); return 1; } if(p0=="焦点"){ if(siz==-1)return 1; sh_->builder_->get_widget(p1, w); if(w){ w->grab_focus(); return 1; } d_(sh_,err_show_wufa_,2,p,1); return 1; } if(p0=="侦听"){ if(siz==-1)return 1; if(p->size()>2){ if(p1=="点击"){ Glib::ustring code; size_t size=p->size(); if(size>=4) code=(*p)[--size]; for(size_t i=2;i<size;i++){ if((*p)[i].length()==0) continue; Glib::SignalProxy0< void >* sp0=NULL; Glib::SignalProxy1< bool, GdkEventButton* >* sp1=NULL; Glib::ustring dong; bI=NULL; w=NULL; for(;;){ sh_->builder_->get_widget((*p)[i], b); if(b){ bI=b; w=b; dong=b->get_label(); sp0=&b->signal_clicked(); break; } sh_->builder_->get_widget((*p)[i], tb); if(tb){ bI=tb; w=tb; dong=tb->get_label(); sp0=&tb->signal_clicked(); break; } sh_->builder_->get_widget((*p)[i], mi); if(mi){ bI=mi; w=mi; sp1=&mi->signal_button_press_event(); break; } sh_->builder_->get_widget((*p)[i], w); if(w){ sp1=&w->signal_button_press_event(); break; } d_(sh_,err_show_wufa_,3,p,i,0); return 1; } if(w){ const char*arg4; if(dong.empty()){ dong=(*p)[i]; arg4=NULL; }else arg4=(*p)[i].c_str(); control___* c; const char*zhao; const char*arg3; //不buf会乱指 Glib::ustring buf3; if(w==mi){ zhao="菜单"; buf3=mi->get_label(); }else{ zhao=bI!=NULL?"按钮":p1.c_str(); buf3=w->get_tooltip_text(); } arg3=buf3.c_str(); if(!arg4) c=new control___(zhao,dong.c_str(),sh_,d_,code.c_str(),arg3); else c=new control___(zhao,dong.c_str(),sh_,d_,code.c_str(),arg3,arg4); if(sp0) sp0->connect(sigc::mem_fun(*c, &control___::on__)); else if(sp1) sp1->connect(sigc::mem_fun(*c, &control___::on1__)); w->set_data("ctl",c); if(p->size()==4) break; } } return 1; } d_(sh_,err_show_wufa_,2,p,1); return 1; } d_(sh_,err_show_buzu_,p); return 1; } if(p0=="点击"){ if(siz==-1)return 1; for(size_t i=1;i<p->size();i++){ w=NULL; for(;;){ sh_->builder_->get_widget((*p)[i], b); if(b){ w=b; break; } sh_->builder_->get_widget((*p)[i], tb); if(tb){ w=tb; break; } sh_->builder_->get_widget((*p)[i], mi); if(mi){ w=mi; break; } sh_->builder_->get_widget((*p)[i], w); if(w){ break; } d_(sh_,err_show_wufa_,3,p,i,0); return 1; } control___* c=(control___*)w->get_data("ctl"); if(!c){ d_(sh_,err_show_wufa_,3,p,i,0); return 1; } c->on__(); } return 1; } if(p0=="可见"){ if(siz==-1)return 1; sh_->builder_->get_widget(p1, w); if(w){ if(p->size()>2){ bool b=d_(sh_,bool_,(*p)[p->size()-1].c_str()); for(size_t i=1;i<p->size()-1;i++){ sh_->builder_->get_widget((*p)[i], w); if(w) w->set_visible(b); else d_(sh_,err_show_wufa_,2,p,i); } }else cpy__(buf,w->get_visible(),siz); return 1; } d_(sh_,err_show_wufa_,2,p,1); return 1; } if(p0=="可见状态"){ if(siz==-1)return 1; sh_->builder_->get_widget(p1, e); if(e){ bool b; if(p->size()>2) b=d_(sh_,bool_,(*p)[2].c_str()); else b=!e->get_visibility(); e->set_visibility(b); return 1; } d_(sh_,err_show_wufa_,2,p,1); return 1; } if(p0=="敏感"){ if(siz==-1)return 1; sh_->builder_->get_widget(p1, w); if(w){ if(p->size()>2){ bool b=d_(sh_,bool_,(*p)[p->size()-1].c_str()); for(size_t i=1;i<p->size()-1;i++){ sh_->builder_->get_widget((*p)[i], w); if(w) w->set_sensitive(b); else d_(sh_,err_show_wufa_,2,p,i); } }else cpy__(buf,w->get_sensitive(),siz); return 1; } d_(sh_,err_show_wufa_,2,p,1); return 1; } if(p0=="区域信息"){ if(siz==-1)return 1; sh_->builder_->get_widget(p1, w); if(w){ Gtk::Allocation a=w->get_allocation(); sprintf(buf,"%d,%d,%d,%d,",a.get_x(),a.get_y(),a.get_width(),a.get_height()); return 1; } d_(sh_,err_show_wufa_,2,p,1); return 1; } if(p0=="鼠标"){ if(siz==-1)return 1; sh_->builder_->get_widget(p1, w); if(w){ gint x,y; /*Glib::RefPtr<Gdk::Window> w2=w->get_window(); w2->get_pointer(x,y,);*/ w->get_pointer(x,y); sprintf(buf,"%d,%d,",x,y); return 1; } d_(sh_,err_show_wufa_,2,p,1); return 1; } if(p0=="数目"){ if(siz==-1)return 1; sh_->builder_->get_widget(p1, n); if(n){ sprintf(buf,"%d",n->get_n_pages()); return 1; } d_(sh_,err_show_wufa_,2,p,1); return 1; } if(p0=="遍历"){ if(siz==-1)return 1; const Glib::ustring& code=(*p)[p->size()-1]; bool exe=true; char s1[16]; const char*argv[]={s1}; int err; for(size_t i=1;i<p->size()-1&&exe;i++){ sh_->builder_->get_widget((*p)[i], n); if(n){ for(int pn=0;pn<n->get_n_pages();pn++){ w=n->get_nth_page(pn); sprintf(s1,"%d",pn+1); d_(sh_,call4_1_,code.c_str(),shangji,NULL,NULL,NULL,1,argv,0,ce,&err); if(err){ if(err==jieshiqi_go_+keyword_break_) break; if(err==jieshiqi_go_+keyword_continue_) continue; if(err==jieshiqi_go_+keyword_exit_){ exe=false; break; } d_(sh_,call4_2_,err); return 1; } } continue; } d_(sh_,err_show_wufa_,2,p,i); } return 1; } return 0; }
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()); }
// This is horribly inefficient right now, but I have other things I'd rather focus on. void VizTab::updateSelectionText() { string info = ""; if (mCurrSelection.size() == 1) { int gid = mCurrSelection.back(); graph::VertexData* data = pGraph->vertexData(gid); for (auto prop = data->properties.begin(); prop != data->properties.end(); ++prop) info += prop->first + ": " + prop->second + "\n"; TheBuilder::get<Gtk::Button>("viz_compare_button")->hide(); } else if (mCurrSelection.size() > 1) { TheBuilder::get<Gtk::Button>("viz_compare_button")->show(); info = "You have selected " + to_string(mCurrSelection.size()) + " items."; } else TheBuilder::get<Gtk::Button>("viz_compare_button")->hide(); Gtk::TextView* infoBox = TheBuilder::get<Gtk::TextView>("viz_sel_info_box"); infoBox->get_buffer()->set_text(info); map<string, vector<string>> selectedProperties; for (int i = 0; i < mCurrSelection.size(); ++i) { graph::VertexData* data = pGraph->vertexData(mCurrSelection[i]); for (auto prop = data->properties.begin(); prop != data->properties.end(); ++prop) selectedProperties[prop->first]; } Gtk::TreeModel::ColumnRecord colRec; vector<Gtk::TreeModelColumn<Glib::ustring>*> cols; for (int i = 0; i < selectedProperties.size(); ++i) { cols.push_back(new Gtk::TreeModelColumn<Glib::ustring>); colRec.add(*cols.back()); } auto listStore = Gtk::ListStore::create(colRec); for (int i = 0; i < mCurrSelection.size(); ++i) { auto row = listStore->append(); int j = 0; for (auto prop = selectedProperties.begin(); prop != selectedProperties.end(); ++prop) { string val; graph::VertexData* data = pGraph->vertexData(mCurrSelection[i]); if (data->properties.find(prop->first) != data->properties.end()) val = data->properties[prop->first]; row->set_value(j++, val); } } Gtk::TreeView* tv = TheBuilder::get<Gtk::TreeView>("compare_treeview"); tv->set_model(listStore); int i = 0; for (auto prop = selectedProperties.begin(); prop != selectedProperties.end(); ++prop) { tv->append_column(prop->first, *(cols[i])); tv->get_column(i++)->set_reorderable(); } }
aboutDialog::aboutDialog() { Gtk::Dialog *ad = this; Gtk::Button *okbutton = Gtk::manage(new class Gtk::Button("ok")); Gtk::Label *aboutLabel = Gtk::manage(new class Gtk::Label( "About " + GPD->sGUI_CLIENT() + " " + GPD->sVERSION() + ", build " + GPD->sBUILD() )); Gtk::TextView *textview = Gtk::manage(new class Gtk::TextView()); Gtk::ScrolledWindow *scrolledwindow = Gtk::manage(new class Gtk::ScrolledWindow()); Gtk::VBox *vbox = Gtk::manage(new class Gtk::VBox(false, 0)); okbutton->set_flags(Gtk::CAN_FOCUS); okbutton->set_relief(Gtk::RELIEF_NORMAL); ad->get_action_area()->property_layout_style().set_value(Gtk::BUTTONBOX_END); ad->set_default_size(300, 200); aboutLabel->set_alignment(0.5,0.5); aboutLabel->set_padding(0,0); aboutLabel->set_justify(Gtk::JUSTIFY_LEFT); aboutLabel->set_line_wrap(false); aboutLabel->set_use_markup(false); aboutLabel->set_selectable(false); textview->set_flags(Gtk::CAN_FOCUS); textview->set_editable(true); textview->set_cursor_visible(true); textview->set_pixels_above_lines(0); textview->set_pixels_below_lines(0); textview->set_pixels_inside_wrap(0); textview->set_left_margin(0); textview->set_right_margin(0); textview->set_indent(0); textview->set_wrap_mode(Gtk::WRAP_NONE); textview->set_justification(Gtk::JUSTIFY_LEFT); using namespace std; string text; text += "btg Copyright (C) 2005 Michael Wojciechowski."; text += GPD->sNEWLINE(); text += "This program is free software; you can redistribute it and/or modify"; text += GPD->sNEWLINE(); text += "it under the terms of the GNU General Public License as published by "; text += GPD->sNEWLINE(); text += "the Free Software Foundation; either version 2 of the License, or "; text += GPD->sNEWLINE(); text += "(at your option) any later version."; text += GPD->sNEWLINE(); text += "This program is distributed in the hope that it will be useful, "; text += GPD->sNEWLINE(); text += "but WITHOUT ANY WARRANTY; without even the implied warranty of "; text += GPD->sNEWLINE(); text += "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "; text += GPD->sNEWLINE(); text += "GNU General Public License for more details."; text += GPD->sNEWLINE(); text += "You should have received a copy of the GNU General Public License "; text += GPD->sNEWLINE(); text += "along with this program; if not, write to the Free Software "; text += GPD->sNEWLINE(); text += "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA"; text += GPD->sNEWLINE(); textview->get_buffer()->set_text(text); scrolledwindow->set_flags(Gtk::CAN_FOCUS); scrolledwindow->set_shadow_type(Gtk::SHADOW_IN); scrolledwindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); scrolledwindow->property_window_placement().set_value(Gtk::CORNER_TOP_LEFT); scrolledwindow->add(*textview); vbox->pack_start(*aboutLabel, Gtk::PACK_SHRINK, 0); vbox->pack_start(*scrolledwindow); ad->get_vbox()->set_homogeneous(false); ad->get_vbox()->set_spacing(0); ad->get_vbox()->pack_start(*vbox); //ad->set_title( "About " + GPD->sGUI_CLIENT() + " " + GPD->sVERSION() ); ad->set_title( GPD->sGUI_CLIENT() + " " + GPD->sVERSION() + " / About" ); ad->set_modal(true); ad->property_window_position().set_value(Gtk::WIN_POS_CENTER); ad->set_resizable(true); ad->property_destroy_with_parent().set_value(false); ad->set_has_separator(true); ad->add_action_widget(*okbutton, -5); okbutton->show(); aboutLabel->show(); textview->show(); scrolledwindow->show(); vbox->show(); okbutton->signal_clicked().connect(sigc::mem_fun(*this, &aboutDialog::on_ok_clicked)); // ad->show(); }