Ejemplo n.º 1
0
  TempRow(Model *model, TempType type) :
    m_model(model), m_type(type)
  {
    static const char *names[] = { "Nozzle", "Bed" };

    add(*(new Gtk::Label(names[type])));
    Gtk::ToggleButton *pOn = new Gtk::ToggleButton("Heat On");
    pOn->signal_toggled().connect
      (sigc::bind (sigc::mem_fun (*this, &TempRow::heat_toggled), pOn));
    add(*pOn);
    m_temp = new Gtk::Label();
    add (*m_temp);
    add(*(new Gtk::Label("Target Temperature (°C)")));
    m_target = new Gtk::SpinButton();
    m_target->set_increments (1, 5);
    m_target->set_range(25.0, 256.0);
    switch (type) {
    case TEMP_NOZZLE:
    default:
      m_target->set_value(200.0);
      break;
    case TEMP_BED:
      m_target->set_value(100.0);
      break;
    }
    add (*m_target);
  }
Ejemplo n.º 2
0
  TempRow(Model *model, Printer *printer, TempType type) :
    m_model(model), printer(printer), m_type(type)
  {
    static const char *names[] = { N_("Nozzle"), N_("Bed") };

    add(*(new Gtk::Label(_(names[type]))));
    Gtk::ToggleButton *pOn = new Gtk::ToggleButton(_("Heat On"));
    pOn->signal_toggled().connect
      (sigc::bind (sigc::mem_fun (*this, &TempRow::heat_toggled), pOn));
    add(*pOn);
    add(*(new Gtk::Label(_("Temp. (°C)"))));
    m_temp = new Gtk::Label(_("<unknown>"));
    add (*m_temp);

    add(*(new Gtk::Label(_("Target:"))));
    m_target = new Gtk::SpinButton();
    m_target->set_increments (1, 5);
    m_target->set_range(25.0, 256.0);
    switch (type) {
    case TEMP_NOZZLE:
    default:
      m_target->set_value(225.0);
      break;
    case TEMP_BED:
      m_target->set_value(60.0);
      break;
    }
    add (*m_target);
  }
Ejemplo n.º 3
0
void Toggle::connectWidget(Gtk::Widget* widget)
{
	if (dynamic_cast<Gtk::ToggleToolButton*>(widget) != NULL)
	{
		Gtk::ToggleToolButton* toolButton = static_cast<Gtk::ToggleToolButton*>(widget);

		toolButton->set_active(_toggled);

		// Connect the toggleToolbutton to the callback of this class
		_toggleWidgets[widget] = toolButton->signal_toggled().connect(
			sigc::mem_fun(*this, &Toggle::onToggleToolButtonClicked));
	}
	else if (dynamic_cast<Gtk::ToggleButton*>(widget) != NULL)
	{
		Gtk::ToggleButton* toggleButton = static_cast<Gtk::ToggleButton*>(widget);

		toggleButton->set_active(_toggled);

		// Connect the togglebutton to the callback of this class
		_toggleWidgets[widget] = toggleButton->signal_toggled().connect(
			sigc::mem_fun(*this, &Toggle::onToggleButtonClicked));
	}
	else if (dynamic_cast<Gtk::CheckMenuItem*>(widget) != NULL)
	{
		Gtk::CheckMenuItem* menuItem = static_cast<Gtk::CheckMenuItem*>(widget);

		menuItem->set_active(_toggled);

		// Connect the togglebutton to the callback of this class
		_toggleWidgets[widget] = menuItem->signal_toggled().connect(
			sigc::mem_fun(*this, &Toggle::onCheckMenuItemClicked));
	}
}
Ejemplo n.º 4
0
void View::connect_toggled(const char *name, const sigc::slot<void, Gtk::ToggleButton *> &slot)
{
  Gtk::ToggleButton *button = NULL;
  m_builder->get_widget (name, button);
  if (button)
    button->signal_toggled().connect (sigc::bind(slot, button));
  else {
    std::cerr << "missing toggle button " << name << "\n";
  }
}
Ejemplo n.º 5
0
//------------------------------------------------------------------------------
void mforms::gtk::ToolBarImpl::set_item_alt_icon(mforms::ToolBarItem *item, const std::string &image_path) {
  Gtk::ToggleButton *btn = cast<Gtk::ToggleButton *>(item->get_data_ptr());
  if (btn) {
    static ImageCache *images = ImageCache::get_instance();
    Gtk::Image *img = new Gtk::Image(images->image_from_path(image_path));
    if (img) {
      btn->set_data("alt_icon", img, free_icon);
      btn->signal_toggled().connect(sigc::bind(sigc::ptr_fun(swap_icons), btn));
    }
  }
}
Ejemplo n.º 6
0
void Torrents_viewport::add_info_widget(const std::string& name, Gtk::Widget& widget_container, Info_widget& widget, Gtk::ToggleButton& button)
{
	this->info_widgets.push_back(Info_widget_handle(name, button, widget));
	this->torrent_infos_notebook.append_page(widget_container);
	this->info_toggle_buttons_hbox.pack_start(button, false, false);

	button.signal_toggled().connect(
		sigc::bind<Gtk::ToggleButton*>(
			sigc::mem_fun(*this, &Torrents_viewport::on_toggle_info_callback),
			&button
		)
	);
}
Ejemplo n.º 7
0
  bool addWidgets(Gtk::Box* iBox) {
    if (mBox != NULL) return false;

    mBox = Gtk::manage(new Gtk::VBox());

    Gtk::Box* box = Gtk::manage(new Gtk::HBox());

    mToggleButton = Gtk::manage(new Gtk::ToggleButton("                    "));
    Gdk::Color color;
    color.set_rgb_p(mAttributes.mColor[0], mAttributes.mColor[1],
                    mAttributes.mColor[2]);
    mToggleButton->modify_bg(Gtk::STATE_ACTIVE, color);
    color.set_rgb_p((mAttributes.mColor[0]+1)/2, (mAttributes.mColor[1]+1)/2,
                    (mAttributes.mColor[2]+1)/2);
    mToggleButton->modify_bg(Gtk::STATE_PRELIGHT, color); 
    color.set_rgb_p(0.8, 0.8, 0.8);
    mToggleButton->modify_bg(Gtk::STATE_NORMAL, color);
    mToggleButton->signal_toggled().connect
      (sigc::mem_fun(*this, &Helper::onToggleButton));
    mToggleButton->set_active(true);
    box->pack_start(*(mToggleButton), false, false);
    Gtk::Label* label = Gtk::manage(new Gtk::Label(mAttributes.mLabel));
    box->pack_start(*label, false, false);
    if (mViewId != 1) {
      Gtk::Button* cancelButton = Gtk::manage(new Gtk::Button("X"));
      box->pack_start(*cancelButton, false, false);
      cancelButton->signal_clicked().connect
        (sigc::mem_fun(*this, &Helper::onRemoveButton));
    }
    Gtk::Button* button = Gtk::manage(new Gtk::Button("save"));
    button->signal_clicked().connect
      (sigc::mem_fun(*this, &Helper::onSaveButton));
    box->pack_start(*button, false, false);

    mBox->pack_start(*box, false, false);

    box = Gtk::manage(new Gtk::HBox());
    std::vector<int> ids;
    std::vector<std::string> labels;
    ids = { MeshRenderer::ColorModeFlat, MeshRenderer::ColorModeHeight,
            MeshRenderer::ColorModeRange, MeshRenderer::ColorModeNormal,
            MeshRenderer::ColorModeCamera };
    labels = { "Flat", "Height", "Range", "Normal", "Camera" };
    Gtk::ComboBox* combo = 
      gtkmm::RendererBase::createCombo(mAttributes.mColorMode, labels, ids);
    combo->signal_changed().connect([this]{this->mRenderer->requestDraw();});
    box->pack_start(*combo, false, false);

    ids = { MeshRenderer::MeshModePoints, MeshRenderer::MeshModeWireframe,
            MeshRenderer::MeshModeFilled };
    labels = { "Points", "Wireframe", "Filled" };
    combo =
      gtkmm::RendererBase::createCombo(mAttributes.mMeshMode, labels, ids);
    combo->signal_changed().connect([this]{this->mRenderer->requestDraw();});
    box->pack_start(*combo, false, false);
    
    Gtk::HScale* slider =
      gtkmm::RendererBase::createSlider(mAttributes.mPointSize, 0.1, 10, 0.1);
    slider->signal_value_changed().connect([this]{this->mRenderer->requestDraw();});
    box->pack_start(*slider, true, true);

    mBox->pack_start(*box, false, false);

    box = Gtk::manage(new Gtk::HBox());
    label = Gtk::manage(new Gtk::Label("Z Rng"));
    box->pack_start(*label,false,false);
    slider = gtkmm::RendererBase::createSlider(mAttributes.mMinZ, -1, 2, 0.01);
    slider->signal_value_changed().connect([this]{this->mRenderer->requestDraw();});
    box->pack_start(*slider, true, true);
    slider = gtkmm::RendererBase::createSlider(mAttributes.mMaxZ, -1, 2, 0.01);
    slider->signal_value_changed().connect([this]{this->mRenderer->requestDraw();});
    box->pack_start(*slider, true, true);

    mBox->pack_start(*box, false, false);

    mBox->pack_start(*Gtk::manage(new Gtk::HSeparator()));

    mBox->show_all();
    iBox->pack_start(*mBox, false, false);
    return true;
  }
Ejemplo n.º 8
0
//------------------------------------------------------------------------------
bool mforms::gtk::ToolBarImpl::create_tool_item(mforms::ToolBarItem *item, ToolBarItemType type) {
  Gtk::Widget *w = 0;
  switch (type) {
    case mforms::TextActionItem:
    case mforms::ActionItem:
    case mforms::SwitcherItem: {
      Gtk::Button *btn = Gtk::manage(new Gtk::Button());
      btn->set_focus_on_click(false);
      btn->set_border_width(0);
      btn->set_relief(Gtk::RELIEF_NONE);
      btn->signal_clicked().connect(sigc::bind(sigc::ptr_fun(process_ctrl_action), btn, item));
      if (type == mforms::SwitcherItem)
        btn->set_always_show_image(true);
      w = btn;
      break;
    }
    case mforms::SegmentedToggleItem:
    case mforms::ToggleItem: {
      Gtk::ToggleButton *btn = Gtk::manage(new Gtk::ToggleButton());
      btn->set_focus_on_click(false);
      btn->set_relief(Gtk::RELIEF_NONE);
      btn->signal_toggled().connect(sigc::bind(sigc::ptr_fun(process_ctrl_action), btn, item));
      btn->set_inconsistent(false);

      w = btn;
      break;
    }
    case mforms::SeparatorItem: {
      Gtk::Separator *sep = new Gtk::Separator(Gtk::ORIENTATION_VERTICAL);
      w = sep;
      break;
    }
    case mforms::SearchFieldItem: {
#if GTK_VERSION_GE(2, 16)
      Gtk::Entry *entry = Gtk::manage(new Gtk::Entry());
      w = entry;
      entry->set_icon_from_stock(Gtk::Stock::FIND);
#else
      Gtk::Box *hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 0));
      w = hbox;
      Gtk::Image *image = Gtk::manage(new Gtk::Image(Gtk::Stock::FIND, Gtk::ICON_SIZE_MENU));
      Gtk::Entry *entry = Gtk::manage(new Gtk::Entry());

      hbox->pack_start(*image, false, true);
      hbox->pack_start(*entry, true, true);
      hbox->set_data("entry", entry);
      hbox->show_all();
#endif
      entry->signal_activate().connect(sigc::bind(sigc::ptr_fun(process_ctrl_action), entry, item));
      break;
    }
    case mforms::TextEntryItem: {
      Gtk::Box *hbox = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 0));
      w = hbox;
      Gtk::Entry *entry = Gtk::manage(new Gtk::Entry());
      hbox->pack_start(*entry, true, true);
      hbox->set_data("entry", entry);
      hbox->show_all();
      entry->signal_activate().connect(sigc::bind(sigc::ptr_fun(process_ctrl_action), entry, item));
      break;
    }
    case mforms::FlatSelectorItem:
    case mforms::SelectorItem: {
      Gtk::ComboBoxText *ct = Gtk::manage(new Gtk::ComboBoxText());
      ct->signal_changed().connect(sigc::bind(sigc::ptr_fun(process_ctrl_action), ct, item));

      w = ct;
      break;
    }
    case mforms::ColorSelectorItem: {
      if (!color_combo_columns) {
        color_combo_columns = new ColorComboColumns();
      }
      Gtk::ComboBox *ct = Gtk::manage(new Gtk::ComboBox());

      ct->pack_start(color_combo_columns->image);
      ct->signal_changed().connect(sigc::bind(sigc::ptr_fun(process_ctrl_action), ct, item));

      w = ct;

      break;
    }
    case mforms::ExpanderItem:
    case mforms::LabelItem: {
      Gtk::Label *label = Gtk::manage(new Gtk::Label("", 0.0, 0.5));
      w = label;
      break;
    }
    case mforms::ImageBoxItem: {
      Gtk::Image *image = Gtk::manage(new Gtk::Image());
      w = image;
      break;
    }
    case mforms::TitleItem: {
      Gtk::Label *label = Gtk::manage(new Gtk::Label("", 0.0, 0.5));
      w = label;
      auto provider = Gtk::CssProvider::create();
      provider->load_from_data("* { color: #333; font-weight: bold; }");
      w->get_style_context()->add_provider(provider, GTK_STYLE_PROVIDER_PRIORITY_USER);
      break;
    }
  }

  if (w) {
    w->show();
  } else
    logError("create_tool_item, widget is 0 for passed type %i\n", type);

  item->set_data(w);

  return w != 0;
}
Ejemplo n.º 9
0
void
StateBrush_Context::refresh_tool_options()
{
	brush_buttons.clear();
	App::dialog_tool_options->clear();
	App::dialog_tool_options->set_local_name(_("Brush Tool"));
	App::dialog_tool_options->set_name("brush");

	// create container
	Gtk::Table *table = Gtk::manage(new Gtk::Table(1, 2, false));

	// create options
	table->attach(eraser_checkbox, 0, 1, 0, 1, Gtk::FILL, Gtk::SHRINK);

	// create brushes container widget
	int cols = 4;
	Gtk::Table *brushes_table = Gtk::manage(new Gtk::Table(1, cols));

	// load brushes
	// scan directories
	std::set<String> files;
	for(std::set<String>::const_iterator i = paths.begin(); i != paths.end(); ++i)
		scan_directory(*i, 1, files);

	// load files
	int col = 0; int row = 0;
	Gtk::ToggleButton *first_button = NULL;
	Gtk::IconSize iconsize = Gtk::ICON_SIZE_LARGE_TOOLBAR;
	for(std::set<String>::const_iterator i = files.begin(); i != files.end(); ++i)
	{
		if (!brush_buttons.count(*i) && filename_extension(*i) == ".myb")
		{
			const String &brush_file = *i;
			const String icon_file = filename_sans_extension(brush_file) + "_prev.png";
			if (files.count(icon_file))
			{
				// create button
				Gtk::ToggleButton *button = brush_buttons[*i] = Gtk::manage(new Gtk::ToggleButton());
				Glib::RefPtr<Gdk::Pixbuf> pixbuf, pixbuf_scaled;
				pixbuf = Gdk::Pixbuf::create_from_file(icon_file);
				pixbuf_scaled = pixbuf->scale_simple(48, 48, Gdk::INTERP_BILINEAR);
				button->set_image(*Gtk::manage(new Gtk::Image(pixbuf_scaled)));
				button->set_relief(Gtk::RELIEF_NONE);
				button->signal_toggled().connect(
					sigc::bind(sigc::mem_fun(*this, &StateBrush_Context::select_brush), button, brush_file) );
				if (first_button == NULL) first_button = button;

				if (col >= cols)
				{
					// add row
					col = 0;
					++row;
					brushes_table->resize(row + 1, cols);
				}

				// add button
				brushes_table->attach(*button, col, col+1, row, row+1);
				++col;
			}
		}
	}
	Gtk::ScrolledWindow *brushes_scroll = Gtk::manage(new Gtk::ScrolledWindow());
	brushes_scroll->add(*brushes_table);
	table->attach(*brushes_scroll, 0, 1, 1, 2);

	table->show_all();
	App::dialog_tool_options->add(*table);

	// select first brush
	if (first_button != NULL) first_button->set_active(true);
}