Ejemplo n.º 1
0
/**
* Sets up the block bar.
*/
GtkBlockBar::GtkBlockBar() :
	//The GType name will actually be gtkmm__CustomObject_BlockBar
	Glib::ObjectBase("BlockBar"),
	Gtk::Widget()
{
	set_has_window(true);
}
Ejemplo n.º 2
0
GrBx::Area::Area (Gtk::Adjustment &_hadjustment, Gtk::Adjustment &_vadjustment)
    : hadjustment (_hadjustment),
      vadjustment (_vadjustment),
      sx (1),
      sy (1)
{
    set_has_window (false);
    hadjustment.signal_value_changed ().connect (sigc::mem_fun (*this, &GrBx::Area::on_adjustment_value_changed));
    vadjustment.signal_value_changed ().connect (sigc::mem_fun (*this, &GrBx::Area::on_adjustment_value_changed));
}
Ejemplo n.º 3
0
	Image::Image(const Glib::RefPtr<Post> &post_,
	             const std::shared_ptr<ImageFetcher>& image_fetcher,
	             sigc::slot<void, const ImageState&> state_change_callback) :
		Gtk::Bin(),
		post(post_),
		event_box(Gtk::manage(new Gtk::EventBox())),
		image(Gtk::manage(new Gtk::Image())),
		image_state(NONE),
		is_changing_state(false),
		scaled_width(-1),
		scaled_height(-1),
		is_scaled(false),
		am_fetching_thumb(false),
		am_fetching_image(false),
		canceller(std::make_shared<Canceller>()),
		ifetcher(image_fetcher)
	{
		set_has_window(false);
		set_redraw_on_allocate(false);
		set_name("imagewindow");
		event_box->set_events(Gdk::BUTTON_PRESS_MASK);
		event_box->set_visible_window(false);
		event_box->signal_button_press_event().connect( sigc::mem_fun(*this, &Image::on_image_click) );
		image->set_name("image");
		image->set_halign(Gtk::ALIGN_START);
		image->set_valign(Gtk::ALIGN_START);
		event_box->add(*image);
		add(*event_box);

		state_changed_dispatcher.connect(sigc::mem_fun(*this,
		                                               &Image::run_state_changed_callbacks));
		signal_state_changed.connect(state_change_callback);

		if (post->has_image()) {
			std::string ext = post->get_image_ext();
			if (ext.compare(".gif") == 0) {
				fetch_image();
			} else {
				fetch_thumbnail();
			}
		} else {
			g_error("Horizon::Image created for post %" G_GINT64_FORMAT
			        " that has no image.",
			        post->get_id()); 
		}

		image->signal_unmap()    .connect(sigc::mem_fun(*this, &Image::on_image_unmap));
		image->signal_unrealize().connect(sigc::mem_fun(*this, &Image::on_image_unrealize));
		image->signal_draw()     .connect(sigc::mem_fun(*this, &Image::on_image_draw), false);
	}
MyWidget::MyWidget() :
  //The GType name will actually be gtkmm__CustomObject_mywidget
  Glib::ObjectBase("mywidget"),
  Gtk::Widget(),
  m_scale(1000)
{
  set_has_window(true);

  //This shows the GType name, which must be used in the CSS file.
  std::cout << "GType name: " << G_OBJECT_TYPE_NAME(gobj()) << std::endl;

  //This shows that the GType still derives from GtkWidget:
  //std::cout << "Gtype is a GtkWidget?:" << GTK_IS_WIDGET(gobj()) << std::endl;

  //Install a style so that an aspect of this widget may be themed via a CSS
  //style sheet file:
  gtk_widget_class_install_style_property(GTK_WIDGET_CLASS(
              G_OBJECT_GET_CLASS(gobj())),
      g_param_spec_int("example_scale",
        "Scale of Example Drawing",
        "The scale to use when drawing. This is just a silly example.",
        G_MININT,
        G_MAXINT,
        500,
        G_PARAM_READABLE) );

  m_refStyleProvider = Gtk::CssProvider::create();
  Glib::RefPtr<Gtk::StyleContext> refStyleContext = get_style_context();
  refStyleContext->add_provider(m_refStyleProvider,
    GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);

  try
  {
    m_refStyleProvider->load_from_path("custom_gtk.css");
  }
  catch(const Glib::Error& ex)
  {
    std::cerr << "Gtk::CssProvider::load_from_path() failed: " << ex.what() << std::endl;
  }
}
Ejemplo n.º 5
0
 ButtonBar::ButtonBar()
 {
   set_orientation (Gtk::ORIENTATION_HORIZONTAL);
   set_has_window (false);
 }