void Gobby::EncodingSelector::remove_text(const Glib::ustring& text)
{
	Glib::RefPtr<Gtk::ListStore> list =
		Glib::RefPtr<Gtk::ListStore>::cast_dynamic(get_model());

	if(!list)
	{
		throw std::logic_error(
			"Gobby::EncodingSelector::remove_text:\n"
			"Underlaying TreeModel is not a liststore"
		);
	}

	Gtk::TreeNodeChildren children = list->children();

	Gtk::TreeIter next_iter;
	for(Gtk::TreeIter iter = children.begin();
	    iter != children.end();
	    iter = next_iter)
	{
		next_iter = iter;
		++ next_iter;

		if( (*iter)[m_text_columns.m_column] == text)
			iter = list->erase(iter);
	}
}
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;
}
Example #3
0
void KeysStoreDialog::onBtnRemoveClick() {
	bool changed = false;

	Glib::RefPtr<Gtk::TreeModel> model = treeView->get_model();
	Glib::RefPtr<Gtk::ListStore> listStore = Glib::RefPtr<Gtk::ListStore>::cast_static(model);

	Glib::RefPtr<Gtk::TreeSelection> sel = treeView->get_selection();
	std::vector<Gtk::TreeModel::Path> pathlist = sel->get_selected_rows();

	for(int i = pathlist.size() - 1; i >= 0 ; i--) {
		Gtk::TreeModel::iterator iter = treeView->get_model()->get_iter(pathlist[i]);
		Gtk::TreeModel::Row row = *iter;

		listStore->erase(iter);
		changed = true;
	}

	// Emit signal if any change appear
	if(changed)
		signal_changed(prepareModel());
}
Example #4
0
void ukwd_wiring_dialog::on_delete_clicked()
{
    Glib::RefPtr<Gtk::ListStore> m;
    Gtk::TreeView *t = NULL;
    ref_xml->get_widget("stecker_treeview" + name_post_fix, t);
    Glib::RefPtr<Gtk::TreeSelection> selection = t->get_selection();
    
    if (selection->count_selected_rows() != 0)
    {
        // A connection is selected
        m = m.cast_dynamic(t->get_model());
        Gtk::TreeModel::iterator iter = selection->get_selected();
  
        // Test is fixed connection is selected for removal  
        if ( (((*iter)[plugboard_cols.first]) != "J") and  (((*iter)[plugboard_cols.second]) != "Y") )
        {
            // No! -> delete the selected connection
            remove_plug((*iter)[plugboard_cols.first], (*iter)[plugboard_cols.second]);
            num_plugs--;
            update_plug_counter();
            m->erase(iter);
        }
        else
        {
            // Yes! -> error message
            Gtk::MessageDialog msg(*dialog, "The connection J, Y is fixed and cannot be removed.", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
            msg.set_title("Enigma");
            msg.run();                
        }
    }
    else
    {
        // No connection is selected    
        Gtk::MessageDialog msg(*dialog, "Nothing selected to delete.", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
        msg.set_title("Enigma");
        msg.run();        
    }
}
Example #5
0
/**
 * 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());
}
Example #6
0
void DebugDialogImpl::clear()
{
    Glib::RefPtr<Gtk::TextBuffer> buffer = messageText.get_buffer();
    buffer->erase(buffer->begin(), buffer->end());
}