[gparted] port-to-gtk3: Use draw signal in the partition info dialog (#7)
- From: Mike Fleetwood <mfleetwo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] port-to-gtk3: Use draw signal in the partition info dialog (#7)
- Date: Mon, 11 Feb 2019 09:19:35 +0000 (UTC)
commit 4c1fe3bf7a98d375c66dde420443c73d74c15cbf
Author: Luca Bacci <luca bacci982 gmail com>
Date: Fri Aug 3 19:25:57 2018 +0200
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
include/Dialog_Partition_Info.h | 2 +-
src/Dialog_Partition_Info.cc | 17 +++--------------
2 files changed, 4 insertions(+), 15 deletions(-)
---
diff --git a/include/Dialog_Partition_Info.h b/include/Dialog_Partition_Info.h
index 91c731b7..7a5851d8 100644
--- a/include/Dialog_Partition_Info.h
+++ b/include/Dialog_Partition_Info.h
@@ -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).
diff --git a/src/Dialog_Partition_Info.cc b/src/Dialog_Partition_Info.cc
index f899ab9a..a143458e 100644
--- a/src/Dialog_Partition_Info.cc
+++ b/src/Dialog_Partition_Info.cc
@@ -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 ) ;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]