port-to-gtk3: Use draw signal in the partition visualizer (#7)
In Gtk2 widgets draw themselves in response to the expose event signal. In Gtk3 widgets draw themselves in response to the GtkWidget::draw signal, and the signal handler gets a Cairo context as an argument. Convert Gtk::DrawingArea rendering code to respond to the GtkWidget::draw signal. This commit is specific to the drawing area contained in the main application window (also called the DrawingAreaVisualDisk). Reference: [1] Migrating from GTK+ 2.x to GTK+ 3 - "The GtkWidget::draw signal": https://developer.gnome.org/gtk3/stable/ch26s02.html#id-1.6.3.4.11 Closes #7 - Port to Gtk3
This commit is contained in:
parent
4c1fe3bf7a
commit
93b1425549
|
@ -65,7 +65,7 @@ private:
|
|||
int spreadout_leftover_px( std::vector<visual_partition> & visual_partitions, int pixels ) ;
|
||||
|
||||
//overridden signalhandlers
|
||||
bool on_expose_event( GdkEventExpose * event ) ;
|
||||
bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
|
||||
bool on_button_press_event( GdkEventButton * event ) ;
|
||||
void on_size_allocate( Gtk::Allocation & allocation ) ;
|
||||
|
||||
|
|
|
@ -314,21 +314,9 @@ void DrawingAreaVisualDisk::set_selected( const std::vector<visual_partition> &
|
|||
}
|
||||
|
||||
|
||||
bool DrawingAreaVisualDisk::on_expose_event( GdkEventExpose * event )
|
||||
bool DrawingAreaVisualDisk::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
|
||||
{
|
||||
bool ret_val = Gtk::DrawingArea::on_expose_event( event ) ;
|
||||
|
||||
Glib::RefPtr<Gdk::Window> window = get_window();
|
||||
if (!window)
|
||||
return true;
|
||||
|
||||
Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
|
||||
|
||||
// Clip to the area indicated by the expose event so that we only redraw
|
||||
// the portion of the window that needs to be redrawn.
|
||||
cr->rectangle(event->area.x, event->area.y,
|
||||
event->area.width, event->area.height);
|
||||
cr->clip();
|
||||
bool ret_val = Gtk::DrawingArea::on_draw(cr);
|
||||
|
||||
cr->set_line_width(2.0);
|
||||
cr->set_line_join(Cairo::LINE_JOIN_MITER); // default
|
||||
|
|
Loading…
Reference in New Issue