Ejemplo n.º 1
0
void WarningListDialog::add_warning(const Glib::ustring& warning)
{
  Gtk::HBox* hb = Gtk::manage(new Gtk::HBox);
  Gtk::Label* l = Gtk::manage(new Gtk::Label);
  hb->show();
  hb->set_spacing(LENGTH_BORDER_WIDTH*2);

  if(warning_icon)
  {
    Gtk::Image* img = Gtk::manage(new Gtk::Image(warning_icon));
    hb->pack_start(*img, false, false);
  }
  l->set_markup(warning);
  l->set_alignment(0., 0.5);
  l->set_line_wrap(true);
  hb->pack_start(*l);

  if(warnings.get_children().size())
  {
    Gtk::HSeparator* s = Gtk::manage(new Gtk::HSeparator);
    s->show();
    warnings.pack_start(*s, false, false, LENGTH_SMALLSPACE);
  }

  hb->show_all_children();
  warnings.pack_start(*hb, false, false);
}
Ejemplo n.º 2
0
/** \brief  Creates a new preference dialog for extension preferences
    \param  name  Name of the Extension whose dialog this is
    \param  help  The help string for the extension (NULL if none)
    \param  controls  The extension specific widgets in the dialog

    This function initializes the dialog with the name of the extension
    in the title.  It adds a few buttons and sets up handlers for
    them.  It also places the passed-in widgets into the dialog.
*/
PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * controls, Effect * effect) :
#if WITH_GTKMM_3_0
    Gtk::Dialog::Dialog(_(name.c_str()), true),
#else
    Gtk::Dialog::Dialog(_(name.c_str()), true, true),
#endif
    _help(help),
    _name(name),
    _button_ok(NULL),
    _button_cancel(NULL),
    _button_preview(NULL),
    _param_preview(NULL),
    _effect(effect),
    _exEnv(NULL)
{
    Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox());
    if (controls == NULL) {
        if (_effect == NULL) {
            std::cout << "AH!!!  No controls and no effect!!!" << std::endl;
            return;
        }
        controls = _effect->get_imp()->prefs_effect(_effect, SP_ACTIVE_DESKTOP, &_signal_param_change, NULL);
        _signal_param_change.connect(sigc::mem_fun(this, &PrefDialog::param_change));
    }

    hbox->pack_start(*controls, true, true, 6);
    hbox->show();
    this->get_vbox()->pack_start(*hbox, true, true, 6);

    /*
    Gtk::Button * help_button = add_button(Gtk::Stock::HELP, Gtk::RESPONSE_HELP);
    if (_help == NULL)
        help_button->set_sensitive(false);
    */
    _button_cancel = add_button(_effect == NULL ? Gtk::Stock::CANCEL : Gtk::Stock::CLOSE, Gtk::RESPONSE_CANCEL);
    _button_cancel->set_use_stock(true);

    _button_ok = add_button(_effect == NULL ? Gtk::Stock::OK : Gtk::Stock::APPLY, Gtk::RESPONSE_OK);
    _button_ok->set_use_stock(true);
    set_default_response(Gtk::RESPONSE_OK);
    _button_ok->grab_focus();

    if (_effect != NULL && !_effect->no_live_preview) {
        if (_param_preview == NULL) {
            XML::Document * doc = sp_repr_read_mem(live_param_xml, strlen(live_param_xml), NULL);
            _param_preview = Parameter::make(doc->root(), _effect);
        }

        Gtk::HSeparator * sep = Gtk::manage(new Gtk::HSeparator());
        sep->show();
        this->get_vbox()->pack_start(*sep, true, true, 4);

        hbox = Gtk::manage(new Gtk::HBox());
        _button_preview = _param_preview->get_widget(NULL, NULL, &_signal_preview);
        _button_preview->show();
        hbox->pack_start(*_button_preview, true, true,6);
        hbox->show();
        this->get_vbox()->pack_start(*hbox, true, true, 6);

        Gtk::Box * hbox = dynamic_cast<Gtk::Box *>(_button_preview);
        if (hbox != NULL) {
#if WITH_GTKMM_3_0
            _checkbox_preview = dynamic_cast<Gtk::CheckButton *>(hbox->get_children().front());
#else
            _checkbox_preview = dynamic_cast<Gtk::CheckButton *>(hbox->children().back().get_widget());
#endif
        }

        preview_toggle();
        _signal_preview.connect(sigc::mem_fun(this, &PrefDialog::preview_toggle));
    }

    // Set window modality for effects that don't use live preview
    if (_effect != NULL && _effect->no_live_preview) {
        set_modal(false);
    }

    GtkWidget *dlg = GTK_WIDGET(gobj());
    sp_transientize(dlg);

    return;
}
Ejemplo n.º 3
0
  void 
  RSphericalParticles::initGTK()
  {
    _optList.reset(new Gtk::VBox);//The Vbox of options
    _colorMap.reset(new magnet::gtk::ColorMapSelector);

    _singleColorMode.reset(new Gtk::RadioButton("Single Color"));
    _colorByIDMode.reset(new Gtk::RadioButton("Color by ID"));
    
    _RFixed.reset(new Gtk::SpinButton);
    _GFixed.reset(new Gtk::SpinButton);
    _BFixed.reset(new Gtk::SpinButton);
    _AFixed.reset(new Gtk::SpinButton);
    
    {
      _optList->add(*_colorMap); _colorMap->show();
      //Horizontal seperator
      Gtk::HSeparator* line = manage(new Gtk::HSeparator);
      line->show();
      _optList->add(*line);
    }
   
    {//Single color and RGBA boxes
      Gtk::HBox* box = manage(new Gtk::HBox);
      
      box->pack_start(*_singleColorMode, true, true);_singleColorMode->show();
      if (_mode == SINGLE_COLOR) _singleColorMode->set_active();
      
      Gtk::Label* label = manage(new Gtk::Label("RGBA"));
      box->pack_start(*label, false, false); label->show();
      
      _RFixed->set_increments(1.0, 1.0);
      _RFixed->set_range(0.0, 255.0);
      _RFixed->set_value(_colorFixed.s[0]);
      
      _GFixed->set_increments(1.0, 1.0);
      _GFixed->set_range(0.0, 255.0);
      _GFixed->set_value(_colorFixed.s[1]);
      
      _BFixed->set_increments(1.0, 1.0);
      _BFixed->set_range(0.0, 255.0);
      _BFixed->set_value(_colorFixed.s[2]);
      
      _AFixed->set_increments(1.0, 1.0);
      _AFixed->set_range(0.0, 255.0);
      _AFixed->set_value(_colorFixed.s[3]);      
      
      box->pack_start(*_RFixed, false, false); _RFixed->show();
      box->pack_start(*_GFixed, false, false); _GFixed->show();
      box->pack_start(*_BFixed, false, false); _BFixed->show();
      box->pack_start(*_AFixed, false, false); _AFixed->show();
      
      _optList->add(*box);
      box->show();
      
      //Horizontal seperator
      Gtk::HSeparator* line = manage(new Gtk::HSeparator);
      line->show();
      _optList->add(*line);
    }
    
    Gtk::RadioButton::Group group = _singleColorMode->get_group();
    
    {//Color by ID
      _colorByIDMode->set_group(group);
      _colorByIDMode->show();
      if (_mode == COLOR_BY_ID) _colorByIDMode->set_active();
      
      _optList->add(*_colorByIDMode);
      
      //Horizontal seperator
      Gtk::HSeparator* line = manage(new Gtk::HSeparator);
      line->show();
      _optList->add(*line);
    }
    
    _optList->show();
    
    _singleColorMode->signal_toggled()
      .connect(sigc::mem_fun(*this, &RSphericalParticles::guiUpdate));
    _colorMap->signal_changed()
      .connect(sigc::mem_fun(*this, &RSphericalParticles::guiUpdate));
    _RFixed->signal_value_changed()
      .connect(sigc::mem_fun(*this, &RSphericalParticles::guiUpdate));
    _GFixed->signal_value_changed()
      .connect(sigc::mem_fun(*this, &RSphericalParticles::guiUpdate));
    _BFixed->signal_value_changed()
      .connect(sigc::mem_fun(*this, &RSphericalParticles::guiUpdate));
    _AFixed->signal_value_changed()
      .connect(sigc::mem_fun(*this, &RSphericalParticles::guiUpdate));
    
    _colorByIDMode->signal_toggled()
      .connect(sigc::mem_fun(*this, &RSphericalParticles::guiUpdate));

    guiUpdate();
  }
Ejemplo n.º 4
0
void dv_selector_widget::set_source_count(unsigned count)
{
    if (count > thumbnails_.size())
    {
	resize(count, 1);
	mixer::source_id first_new_source_id = thumbnails_.size();

	try
	{
	    thumbnails_.resize(count);

	    for (mixer::source_id i = first_new_source_id; i != count; ++i)
	    {
		unsigned column = 1;
		unsigned row = i * row_multiplier;

		if (0)//(i != 0 && i != count - 1)
		{
		    Gtk::HSeparator * sep = manage(new Gtk::HSeparator);
		    sep->show();
		    attach(*sep,
			   column - 1, column,
			   row, row + row_multiplier,
			   Gtk::FILL, Gtk::FILL,
			   0, 0);
		}

		dv_thumb_display_widget * thumb =
		    manage(new dv_thumb_display_widget);
		thumb->show();
		attach(*thumb,
		       column + column_display, column + column_display + 1,
		       row, row + row_multiplier,
		       Gtk::FILL, Gtk::FILL,
		       0, 0);
		thumbnails_[i] = thumb;

		char label_text[4];
		snprintf(label_text, sizeof(label_text),
			 (i < 9) ? "_%u" : "%u", unsigned(1 + i));
		Gtk::Label * label =
		    manage(new Gtk::Label(label_text, true));
		label->show();
		attach(*label,
		       column + column_labels, column + column_labels + 1,
		       row + row_text_label, row + row_text_label + 1,
		       Gtk::FILL, Gtk::FILL,
		       0, 0);

		Gtk::RadioButton * pri_video_button =
		    create_radio_button(pri_video_button_group_,
					pri_video_source_pixbuf_);
		pri_video_button->signal_pressed().connect(
		    sigc::bind(
			sigc::mem_fun(*this,
				      &dv_selector_widget::on_pri_video_selected),
			i));
		pri_video_button->show();
		attach(*pri_video_button,
		       column + column_labels, column + column_labels + 1,
		       row + row_pri_video_button,
		       row + row_pri_video_button + 1,
		       Gtk::FILL, Gtk::FILL,
		       0, 0);

		Gtk::RadioButton * audio_button =
		    create_radio_button(audio_button_group_,
					audio_source_pixbuf_);
		audio_button_list_.push_back(audio_button);
		// disable by default, if not in expert mode
		audio_button->set_sensitive(expert_mode ? true : false);
		audio_button->signal_pressed().connect(
				sigc::bind(
					sigc::mem_fun(*this,
						&dv_selector_widget::on_audio_selected),
					i));
		audio_button->show();
		attach(*audio_button,
		       column + column_labels, column + column_labels + 1,
		       row + row_audio_button, row + row_audio_button + 1,
		       Gtk::FILL, Gtk::FILL,
		       0, 0);

		if (i < 9)
		{
		    // Make the mnemonic on the label work.  Also make
		    // the numeric keypad and Alt-keys work.
		    label->set_mnemonic_widget(*pri_video_button);
		    pri_video_button->add_accelerator("activate",
						  accel_group_,
						  GDK_KP_1 + i,
						  Gdk::ModifierType(0),
						  Gtk::AccelFlags(0));
		    pri_video_button->signal_activate().connect(
			sigc::bind(
			    sigc::mem_fun(
				*this,
				&dv_selector_widget::on_pri_video_selected),
			    i));
		    audio_button->add_accelerator("activate",
						  accel_group_,
						  '1' + i,
						  Gdk::MOD1_MASK,
						  Gtk::AccelFlags(0));
		    audio_button->add_accelerator("activate",
						  accel_group_,
						  GDK_KP_1 + i,
						  Gdk::MOD1_MASK,
						  Gtk::AccelFlags(0));
		    audio_button->signal_activate().connect(
			sigc::bind(
			    sigc::mem_fun(
				*this,
				&dv_selector_widget::on_audio_selected),
			    i));
		}
	    }
	}
	catch (std::exception & e)
	{
	    // Roll back size changes
	    thumbnails_.resize(first_new_source_id);
	    std::cerr << "ERROR: Failed to add source display: " << e.what()
		      << "\n";
	}
    }
}