[gparted] port-to-gtk3: Use draw signal in the partition resizer (#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 resizer (#7)
- Date: Mon, 11 Feb 2019 09:19:45 +0000 (UTC)
commit 21d8ad218e4df91373203bbd9e350134e27dc5e3
Author: Luca Bacci <luca bacci982 gmail com>
Date: Fri Aug 3 19:33:54 2018 +0200
port-to-gtk3: Use draw signal in the partition resizer (#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 Create new Partition
dialog and the Resize/Move 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/Frame_Resizer_Base.h | 2 +-
src/Frame_Resizer_Base.cc | 18 +++---------------
2 files changed, 4 insertions(+), 16 deletions(-)
---
diff --git a/include/Frame_Resizer_Base.h b/include/Frame_Resizer_Base.h
index 7a52275d..e671b566 100644
--- a/include/Frame_Resizer_Base.h
+++ b/include/Frame_Resizer_Base.h
@@ -68,7 +68,7 @@ protected:
//signal handlers
void drawingarea_on_realize();
- bool drawingarea_on_expose( GdkEventExpose * ev );
+ bool drawingarea_on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
virtual bool drawingarea_on_mouse_motion( GdkEventMotion * ev ) ;
bool drawingarea_on_button_press_event( GdkEventButton * ev ) ;
bool drawingarea_on_button_release_event( GdkEventButton * ev ) ;
diff --git a/src/Frame_Resizer_Base.cc b/src/Frame_Resizer_Base.cc
index 86a737d7..77608a33 100644
--- a/src/Frame_Resizer_Base.cc
+++ b/src/Frame_Resizer_Base.cc
@@ -40,8 +40,8 @@ void Frame_Resizer_Base::init()
drawingarea .signal_realize() .connect(
sigc::mem_fun(*this, &Frame_Resizer_Base::drawingarea_on_realize) ) ;
- drawingarea .signal_expose_event() .connect(
- sigc::mem_fun(*this, &Frame_Resizer_Base::drawingarea_on_expose) ) ;
+ drawingarea.signal_draw().connect(
+ sigc::mem_fun(*this, &Frame_Resizer_Base::drawingarea_on_draw));
drawingarea .signal_motion_notify_event() .connect(
sigc::mem_fun(*this, &Frame_Resizer_Base::drawingarea_on_mouse_motion) ) ;
drawingarea .signal_button_press_event() .connect(
@@ -138,20 +138,8 @@ void Frame_Resizer_Base::drawingarea_on_realize()
drawingarea .add_events( Gdk::LEAVE_NOTIFY_MASK );
}
-bool Frame_Resizer_Base::drawingarea_on_expose( GdkEventExpose * ev )
+bool Frame_Resizer_Base::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();
-
cr->set_line_cap(Cairo::LINE_CAP_SQUARE);
cr->set_line_width(1.0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]