Exemplo n.º 1
0
bool KeysStoreDialog::onInputValidation(const Glib::ustring key, Glib::ustring& message) {
	const static boost::regex e("([\\da-fA-F][\\da-fA-F]:){5}[\\da-fA-F][\\da-fA-F]");

	if(key == "") {
		message = "Input field is empty.";
		return false;
	}

	if(!boost::regex_match(key.raw(), e)) {
		message = "Input text do not match to the key pattern.";
		return false;
	}

	// Check if key is already in listStore
	Glib::RefPtr<Gtk::TreeModel> model = treeView->get_model();
	Glib::RefPtr<Gtk::ListStore> listStore = Glib::RefPtr<Gtk::ListStore>::cast_static(model);

	for(Gtk::TreeModel::iterator iter = model->children().begin(); iter != model->children().end(); iter++) {
		Gtk::TreeModel::Row row = *iter;

		Glib::ustring text;
		row.get_value<Glib::ustring>(0, text);

		if(text == key) {
			message = "Key is already on the list.";
			return false;
		}
	}

	return true;
}
Exemplo n.º 2
0
  void NotebookNoteAddin::get_notebook_menu_items(std::list<NotebookMenuItem*>& items)
  {
    Glib::RefPtr<Gtk::TreeModel> model = NotebookManager::obj().get_notebooks();
    Gtk::TreeIter iter;

    items.clear();

    iter = model->children().begin();
    for(iter = model->children().begin(); iter != model->children().end(); ++iter) {
      Notebook::Ptr notebook;
      iter->get_value(0, notebook);
      NotebookMenuItem *item = manage(new NotebookMenuItem (m_radio_group, 
                                                            get_note(), notebook));
      items.push_back (item);
    }
  }
Exemplo n.º 3
0
SelectJackControlPgm::SelectJackControlPgm(BaseObjectType* cobject, Glib::RefPtr<GxBuilder> bld, gx_engine::GxMachineBase& m)
    : Gtk::Window(cobject),
      description(),
      customstarter(),
      startercombo(),
      dontask(),
      machine(m),
      close() {
    signal_delete_event().connect(sigc::mem_fun(*this, &SelectJackControlPgm::on_delete_event));
    bld->find_widget("description", description);
    bld->find_widget("customstarter", customstarter);
    customstarter->set_text(machine.get_parameter_value<string>("ui.jack_starter"));
    bld->find_widget("startercombo", startercombo);
    const char *v_id = machine.get_parameter("ui.jack_starter_idx").getValueNames()[machine.get_parameter_value<int>("ui.jack_starter_idx")].value_id;
    int n = 0;
    Glib::RefPtr<Gtk::TreeModel> model = startercombo->get_model();
    for (Gtk::TreeIter i = model->children().begin(); i; ++i, ++n) {
	Glib::ustring s;
	i->get_value(1, s);
	if (s == v_id) {
	    startercombo->set_active(n);
	}
    }
    startercombo->signal_changed().connect(sigc::mem_fun(*this, &SelectJackControlPgm::on_starter_changed));
    bld->find_widget("dontask", dontask);
    dontask->set_active(!machine.get_parameter_value<bool>("ui.ask_for_jack_starter"));
    Gtk::Button *button;
    bld->find_widget("ok_button", button);
    button->signal_clicked().connect(
	sigc::mem_fun(*this, &SelectJackControlPgm::on_ok_button));
    bld->find_widget("cancel_button", button);
    button->signal_clicked().connect(
	sigc::mem_fun(*this, &SelectJackControlPgm::on_cancel_button));
    on_starter_changed();
}
Exemplo n.º 4
0
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);
	}
}
Exemplo n.º 5
0
std::vector<std::string> KeysStoreDialog::prepareModel() {
	this->model.clear();

	// Check if key is already in listStore
	Glib::RefPtr<Gtk::TreeModel> model = treeView->get_model();
	Glib::RefPtr<Gtk::ListStore> listStore = Glib::RefPtr<Gtk::ListStore>::cast_static(model);

	for(Gtk::TreeModel::iterator iter = model->children().begin(); iter != model->children().end(); iter++) {
		Gtk::TreeModel::Row row = *iter;

		Glib::ustring text;
		row.get_value<Glib::ustring>(0, text);

		this->model.push_back(text.raw());
	}

	return this->model;
}
Exemplo n.º 6
0
    void NotebookApplicationAddin::add_menu_items(Gtk::Menu * menu,   
                                                  std::list<Gtk::MenuItem*> & menu_items)
    {
      remove_menu_items (menu, menu_items);      

      NotebookNewNoteMenuItem *item;

      Glib::RefPtr<Gtk::TreeModel> model = NotebookManager::obj().get_notebooks();
      Gtk::TreeIter iter;
      
      // Add in the "New Notebook..." menu item
      Gtk::ImageMenuItem *newNotebookMenuItem =
        manage(new Gtk::ImageMenuItem (_("New Note_book..."), true));
      newNotebookMenuItem->set_image(*manage(new Gtk::Image(
          IconManager::obj().get_icon(IconManager::NOTEBOOK_NEW, 16))));
      newNotebookMenuItem->signal_activate()
        .connect(sigc::mem_fun(*this, &NotebookApplicationAddin::on_new_notebook_menu_item));
      newNotebookMenuItem->show_all ();
      menu->append (*newNotebookMenuItem);
      menu_items.push_back(newNotebookMenuItem);

      
      if (model->children().size() > 0) {
        Gtk::SeparatorMenuItem *separator = manage(new Gtk::SeparatorMenuItem ());
        separator->show_all ();
        menu->append (*separator);
        menu_items.push_back(separator);
        
        iter = model->children().begin();
        while (iter) {
          Notebook::Ptr notebook;
          iter->get_value(0, notebook);
          item = manage(new NotebookNewNoteMenuItem (notebook));
          item->show_all ();
          menu->append (*item);
          menu_items.push_back(item);
          ++iter;
        }
      }
    }
//------------------------------------------------------------------------------
void QueryOutputView::refresh()
{
  const int mode = _mode.get_active_row_number();
  switch (mode)
  {

    case 2: // History output
    {
      const Glib::RefPtr<Gtk::TreeModel> entry_model = _entries_grid.get_model();
      const Gtk::TreeModel::Children children = entry_model->children();
      const int size = children.size();
      if (size > 0)
      {
        const Gtk::TreeIter iter = (--children.end());
        const Gtk::TreePath path = entry_model->get_path(iter);
        _entries_grid.set_cursor(path);
      }

      _details_grid.scroll_to(1);
    }
    case 0: // Action Output - always need refresh even if it's not visible
    case 1: //Text output
    {
      _action_output.refresh(false);

      const int log_row_count = _action_output.row_count();
      if (log_row_count > 0)
      {
        Gtk::TreePath path;
        path.push_back(log_row_count-1);
        _action_output.scroll_to_row(path);
        _action_output.set_cursor(path);
      }
      break;
    }
  }
}
Exemplo n.º 8
0
int ukwd_wiring_dialog::run()
{
    int result = 42, res_temp;
    Glib::RefPtr<Gtk::ListStore> m;
    set<pair<char, char> > plugs;
    vector<pair<char, char> > steckers_temp;
    Gtk::TreeModel::Children::iterator iter;    
    Glib::ustring first_help, second_help;     
    Gtk::TreeView *t = NULL;
    ref_xml->get_widget("stecker_treeview" + name_post_fix, t);
    
    do
    {
        res_temp = dialog->run();

        // OK clicked?        
        if (res_temp == 0)
        {
            // Yes!
            steckers_temp.clear();
            m = m.cast_dynamic(t->get_model());
            Gtk::TreeModel::Children children = m->children();
            
            // Iterate over all connections in TreeView
            for (iter = children.begin(); iter != children.end(); ++iter)
            {
                pair<char, char> help;
                first_help = (*iter)[plugboard_cols.first];
                second_help = (*iter)[plugboard_cols.second];
                
                help.first = tolower((char)(first_help[0]));
                help.second = tolower((char)(second_help[0]));
                
                steckers_temp.push_back(help);                
            }        
        
            // Check if user selected exactly 13 connections
            if (steckers_temp.size() == 13)
            {
                // Yes! -> set result variables
                current_steckers = steckers_temp;                
                result = res_temp;
            }
            else
            {
                // No! -> error message
                Gtk::MessageDialog msg(*dialog, "There have to be exactly 13 connections.", false, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, true);
                msg.set_title("Enigma");
                msg.run();                            
            }            
        }
        else
        {
            // No!
            result = res_temp;
        }
    
    } while(result == 42); 
       
    dialog->hide();
    
    return result;
}
Exemplo n.º 9
0
//------------------------------------------------------------------------------
void mforms::gtk::ToolBarImpl::set_item_text(mforms::ToolBarItem *item, const std::string &label) {
  const mforms::ToolBarItemType type = item->get_type();

  switch (type) {
    case mforms::TextActionItem:
    case mforms::ActionItem:
    case mforms::SegmentedToggleItem:
    case mforms::ToggleItem:
    case mforms::SwitcherItem: {
      Gtk::Button *btn = cast<Gtk::Button *>(item->get_data_ptr());
      if (type == mforms::SwitcherItem) {
        btn->set_label(label);
        btn->get_style_context()->add_class("SwitcherItem");
      } else
        btn->add_label(label);
      btn->set_name(label);
      break;
    }
    case mforms::TitleItem:
    case mforms::LabelItem: {
      Gtk::Label *lbl = cast<Gtk::Label *>(item->get_data_ptr());
      if (lbl) {
        lbl->set_markup("<small>" + label + "</small>");
        lbl->set_name(label);
      }
      break;
    }
    case mforms::FlatSelectorItem:
    case mforms::SelectorItem: {
      Gtk::ComboBoxText *ct = cast<Gtk::ComboBoxText *>(item->get_data_ptr());
      if (ct)
        ct->set_active_text(label);
      break;
    }
    case mforms::ColorSelectorItem: {
      Gtk::ComboBox *combo = cast<Gtk::ComboBox *>(item->get_data_ptr());
      if (combo) {
        Glib::RefPtr<Gtk::TreeModel> model = combo->get_model();
        if (model) {
          const Gtk::TreeModel::Children children = model->children();
          const Gtk::TreeIter last = children.end();
          Gtk::TreeRow row;

          for (Gtk::TreeIter it = children.begin(); it != last; ++it) {
            row = *it;
            if (row.get_value(color_combo_columns->color) == label) {
              combo->set_active(it);
              break;
            }
          }
        }
      }
      break;
    }
    case mforms::SearchFieldItem:
    case mforms::TextEntryItem: {
      Gtk::Entry *e = cast<Gtk::Entry *>(item->get_data_ptr());
      if (e)
        e->set_text(label);
      break;
    }
    case mforms::SeparatorItem:
    case mforms::ExpanderItem:
    case mforms::ImageBoxItem:
      break;
  }
}
Exemplo n.º 10
0
void setComboboxLastActive(string n) { // TODO: google how to get N rows!
    Gtk::ComboBox* cb;
    VRGuiBuilder()->get_widget(n, cb);
    Glib::RefPtr<Gtk::TreeModel> model = cb->get_model();
    cb->set_active(model->children().size() - 1);
}