port-to-gtk3: Use draw signal in the partition info dialog (#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 in the Partition Info dialog. 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
e3f77966c9
commit
4c1fe3bf7a
|
@ -46,7 +46,7 @@ private:
|
|||
void Display_Info();
|
||||
|
||||
// Signal handler
|
||||
bool drawingarea_on_expose( GdkEventExpose *ev );
|
||||
bool drawingarea_on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
|
||||
|
||||
const Partition & partition; // (Alias to element in Win_GParted::display_partitions[] vector).
|
||||
|
||||
|
|
|
@ -118,19 +118,8 @@ Dialog_Partition_Info::Dialog_Partition_Info( const Partition & partition ) : pa
|
|||
}
|
||||
|
||||
|
||||
bool Dialog_Partition_Info::drawingarea_on_expose( GdkEventExpose *ev )
|
||||
bool Dialog_Partition_Info::drawingarea_on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
|
||||
{
|
||||
Glib::RefPtr<Gdk::Window> window = drawingarea.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(ev->area.x, ev->area.y, ev->area.width, ev->area.height);
|
||||
cr->clip();
|
||||
|
||||
Gdk::Cairo::set_source_color(cr, color_partition);
|
||||
cr->rectangle(0, 0, 400, 60);
|
||||
cr->fill();
|
||||
|
@ -173,8 +162,8 @@ bool Dialog_Partition_Info::drawingarea_on_expose( GdkEventExpose *ev )
|
|||
void Dialog_Partition_Info::init_drawingarea()
|
||||
{
|
||||
drawingarea .set_size_request( 400, 60 ) ;
|
||||
drawingarea .signal_expose_event().connect( sigc::mem_fun(*this, &Dialog_Partition_Info::drawingarea_on_expose) ) ;
|
||||
|
||||
drawingarea.signal_draw().connect(sigc::mem_fun(*this, &Dialog_Partition_Info::drawingarea_on_draw));
|
||||
|
||||
frame = manage( new Gtk::Frame() ) ;
|
||||
frame ->add( drawingarea ) ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue