[gparted] port-to-gtk3: Use Gdk::Cursor via Glib::RefPtr<> (#7)
- From: Mike Fleetwood <mfleetwo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gparted] port-to-gtk3: Use Gdk::Cursor via Glib::RefPtr<> (#7)
- Date: Mon, 11 Feb 2019 09:19:25 +0000 (UTC)
commit 5fb58f8877464511716d128702d58d9f1c566a99
Author: Luca Bacci <luca bacci982 gmail com>
Date: Fri Aug 3 18:50:40 2018 +0200
port-to-gtk3: Use Gdk::Cursor via Glib::RefPtr<> (#7)
Starting from Gtkmm3 Gdk::Cursor objects cannot be constructed directly,
but instead you have to get a smart pointer to an instance by calling
the static member function Gdk::Cursor::create().
Gdk::Cursor::create() returns a Glib::RefPtr<Gdk::Cursor> object.
Gtkmm3 always uses Glib::RefPtr<Gdk::Cursor> in its interface and never
plain Gdk::Cursor.
Reference:
[1] Programming with gtkmm3, Changes in gtkmm3:
https://developer.gnome.org/gtkmm-tutorial/3.24/changes-gtkmm3.html.en
"... Gdk::Cursor are now used via Glib::RefPtr."
Closes #7 - Port to Gtk3
include/Frame_Resizer_Base.h | 3 ++-
src/DialogManageFlags.cc | 2 +-
src/Frame_Resizer_Base.cc | 12 +++++-------
src/Frame_Resizer_Extended.cc | 4 ++--
src/Win_GParted.cc | 2 +-
5 files changed, 11 insertions(+), 12 deletions(-)
---
diff --git a/include/Frame_Resizer_Base.h b/include/Frame_Resizer_Base.h
index 28ff6381..7a52275d 100644
--- a/include/Frame_Resizer_Base.h
+++ b/include/Frame_Resizer_Base.h
@@ -82,7 +82,8 @@ protected:
std::vector<Gdk::Point> arrow_points;
- Gdk::Cursor *cursor_resize, *cursor_move;
+ Glib::RefPtr<Gdk::Cursor> cursor_resize;
+ Glib::RefPtr<Gdk::Cursor> cursor_move;
int temp_x, temp_y ;
bool fixed_start; //a fixed start disables moving the start and thereby the whole move functionality..
diff --git a/src/DialogManageFlags.cc b/src/DialogManageFlags.cc
index edb502cf..1057d7e9 100644
--- a/src/DialogManageFlags.cc
+++ b/src/DialogManageFlags.cc
@@ -74,7 +74,7 @@ void DialogManageFlags::load_treeview()
void DialogManageFlags::on_flag_toggled( const Glib::ustring & path )
{
- get_window() ->set_cursor( Gdk::Cursor( Gdk::WATCH ) ) ;
+ get_window()->set_cursor(Gdk::Cursor::create(Gdk::WATCH));
set_sensitive( false ) ;
while ( Gtk::Main::events_pending() )
Gtk::Main::iteration() ;
diff --git a/src/Frame_Resizer_Base.cc b/src/Frame_Resizer_Base.cc
index 7649ec36..86a737d7 100644
--- a/src/Frame_Resizer_Base.cc
+++ b/src/Frame_Resizer_Base.cc
@@ -59,8 +59,8 @@ void Frame_Resizer_Base::init()
color_background.set("darkgrey");
color_arrow_rectangle.set("lightgrey");
- cursor_resize = new Gdk::Cursor( Gdk::SB_H_DOUBLE_ARROW ) ;
- cursor_move = new Gdk::Cursor( Gdk::FLEUR ) ;
+ cursor_resize = Gdk::Cursor::create(Gdk::SB_H_DOUBLE_ARROW);
+ cursor_move = Gdk::Cursor::create(Gdk::FLEUR);
GRIP_MOVE = GRIP_LEFT = GRIP_RIGHT = false;
X_END = 0;
@@ -306,18 +306,18 @@ bool Frame_Resizer_Base::drawingarea_on_mouse_motion( GdkEventMotion * ev )
ev ->x <= X_START &&
ev ->y >= 5 &&
ev ->y <= 45 )
- drawingarea .get_parent_window() ->set_cursor( *cursor_resize ) ;
+ drawingarea.get_parent_window()->set_cursor(cursor_resize);
//right grip
else if ( ev ->x >= X_END &&
ev ->x <= X_END + GRIPPER &&
ev ->y >= 5 &&
ev ->y <= 45 )
- drawingarea .get_parent_window() ->set_cursor( *cursor_resize ) ;
+ drawingarea.get_parent_window()->set_cursor(cursor_resize);
//move grip
else if ( ! fixed_start &&
ev ->x >= X_START &&
ev ->x <= X_END )
- drawingarea .get_parent_window() ->set_cursor( *cursor_move ) ;
+ drawingarea.get_parent_window()->set_cursor(cursor_move);
//normal pointer
else
drawingarea .get_parent_window() ->set_cursor() ;
@@ -451,8 +451,6 @@ void Frame_Resizer_Base::redraw()
Frame_Resizer_Base::~Frame_Resizer_Base()
{
- delete cursor_resize;
- delete cursor_move;
}
diff --git a/src/Frame_Resizer_Extended.cc b/src/Frame_Resizer_Extended.cc
index c1e80d9d..284c4c94 100644
--- a/src/Frame_Resizer_Extended.cc
+++ b/src/Frame_Resizer_Extended.cc
@@ -143,13 +143,13 @@ bool Frame_Resizer_Extended::drawingarea_on_mouse_motion( GdkEventMotion * ev )
ev ->x <= X_START &&
ev ->y >= 5 &&
ev ->y <= 45 )
- drawingarea .get_parent_window() ->set_cursor( *cursor_resize ) ;
+ drawingarea.get_parent_window()->set_cursor(cursor_resize);
//right grip
else if ( ev ->x >= X_END &&
ev ->x <= X_END + GRIPPER &&
ev ->y >= 5 &&
ev ->y <= 45 )
- drawingarea .get_parent_window() ->set_cursor( *cursor_resize ) ;
+ drawingarea.get_parent_window()->set_cursor(cursor_resize);
//normal pointer
else
drawingarea .get_parent_window() ->set_cursor() ;
diff --git a/src/Win_GParted.cc b/src/Win_GParted.cc
index aacdc888..10dcbb17 100644
--- a/src/Win_GParted.cc
+++ b/src/Win_GParted.cc
@@ -3095,7 +3095,7 @@ void Win_GParted::activate_manage_flags()
g_assert( selected_partition_ptr != NULL ); // Bug: Partition callback without a selected partition
g_assert( valid_display_partition_ptr( selected_partition_ptr ) ); // Bug: Not pointing at a valid
display partition object
- get_window() ->set_cursor( Gdk::Cursor( Gdk::WATCH ) ) ;
+ get_window()->set_cursor(Gdk::Cursor::create(Gdk::WATCH));
while ( Gtk::Main::events_pending() )
Gtk::Main::iteration() ;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]