GTK3: replace reprecatated gdk_cursor functions

- Gtk+-3.16: gdk_cursor_new --> gdk_cursor_new_for_display
- GTK3: gdk_cursor_unref --> g_object_unref
This commit is contained in:
Wolfgang Ulbrich 2015-11-20 01:46:26 +01:00
parent e357519c94
commit cf7db5e02e
3 changed files with 58 additions and 4 deletions

View File

@ -114,7 +114,11 @@ pluma_file_browser_view_finalize (GObject * object)
PlumaFileBrowserView *obj = PLUMA_FILE_BROWSER_VIEW(object); PlumaFileBrowserView *obj = PLUMA_FILE_BROWSER_VIEW(object);
if (obj->priv->hand_cursor) if (obj->priv->hand_cursor)
gdk_cursor_unref(obj->priv->hand_cursor); #if GTK_CHECK_VERSION (3, 0, 0)
g_object_unref (obj->priv->hand_cursor);
#else
gdk_cursor_unref (obj->priv->hand_cursor)
#endif
if (obj->priv->hover_path) if (obj->priv->hover_path)
gtk_tree_path_free (obj->priv->hover_path); gtk_tree_path_free (obj->priv->hover_path);
@ -125,7 +129,11 @@ pluma_file_browser_view_finalize (GObject * object)
obj->priv->expand_state = NULL; obj->priv->expand_state = NULL;
} }
#if GTK_CHECK_VERSION (3, 0, 0)
g_object_unref (obj->priv->busy_cursor);
#else
gdk_cursor_unref (obj->priv->busy_cursor); gdk_cursor_unref (obj->priv->busy_cursor);
#endif
G_OBJECT_CLASS (pluma_file_browser_view_parent_class)-> G_OBJECT_CLASS (pluma_file_browser_view_parent_class)->
finalize (object); finalize (object);
@ -308,7 +316,12 @@ set_click_policy_property (PlumaFileBrowserView *obj,
if (click_policy == PLUMA_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE) { if (click_policy == PLUMA_FILE_BROWSER_VIEW_CLICK_POLICY_SINGLE) {
if (obj->priv->hand_cursor == NULL) if (obj->priv->hand_cursor == NULL)
#if GTK_CHECK_VERSION (3, 16, 0)
display = gtk_widget_get_display (GTK_WIDGET (obj));
obj->priv->hand_cursor = gdk_cursor_new_for_display (display, GDK_HAND2);
#else
obj->priv->hand_cursor = gdk_cursor_new(GDK_HAND2); obj->priv->hand_cursor = gdk_cursor_new(GDK_HAND2);
#endif
} else if (click_policy == PLUMA_FILE_BROWSER_VIEW_CLICK_POLICY_DOUBLE) { } else if (click_policy == PLUMA_FILE_BROWSER_VIEW_CLICK_POLICY_DOUBLE) {
if (obj->priv->hover_path != NULL) { if (obj->priv->hover_path != NULL) {
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (obj->priv->model), if (gtk_tree_model_get_iter (GTK_TREE_MODEL (obj->priv->model),
@ -331,7 +344,11 @@ set_click_policy_property (PlumaFileBrowserView *obj,
} }
if (obj->priv->hand_cursor) { if (obj->priv->hand_cursor) {
#if GTK_CHECK_VERSION (3, 0, 0)
g_object_unref (obj->priv->hand_cursor);
#else
gdk_cursor_unref (obj->priv->hand_cursor); gdk_cursor_unref (obj->priv->hand_cursor);
#endif
obj->priv->hand_cursor = NULL; obj->priv->hand_cursor = NULL;
} }
} }
@ -945,6 +962,9 @@ cell_data_cb (GtkTreeViewColumn * tree_column, GtkCellRenderer * cell,
static void static void
pluma_file_browser_view_init (PlumaFileBrowserView * obj) pluma_file_browser_view_init (PlumaFileBrowserView * obj)
{ {
#if GTK_CHECK_VERSION (3, 16, 0)
GdkDisplay *display;
#endif
obj->priv = PLUMA_FILE_BROWSER_VIEW_GET_PRIVATE (obj); obj->priv = PLUMA_FILE_BROWSER_VIEW_GET_PRIVATE (obj);
obj->priv->column = gtk_tree_view_column_new (); obj->priv->column = gtk_tree_view_column_new ();
@ -979,7 +999,12 @@ pluma_file_browser_view_init (PlumaFileBrowserView * obj)
G_N_ELEMENTS (drag_source_targets), G_N_ELEMENTS (drag_source_targets),
GDK_ACTION_COPY); GDK_ACTION_COPY);
#if GTK_CHECK_VERSION (3, 16, 0)
display = gtk_widget_get_display (GTK_WIDGET (obj));
obj->priv->busy_cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
#else
obj->priv->busy_cursor = gdk_cursor_new (GDK_WATCH); obj->priv->busy_cursor = gdk_cursor_new (GDK_WATCH);
#endif
} }
static gboolean static gboolean

View File

@ -359,8 +359,12 @@ pluma_file_browser_widget_finalize (GObject * object)
g_hash_table_destroy (obj->priv->bookmarks_hash); g_hash_table_destroy (obj->priv->bookmarks_hash);
cancel_async_operation (obj); cancel_async_operation (obj);
#if GTK_CHECK_VERSION (3, 0, 0)
g_object_unref (obj->priv->busy_cursor);
#else
gdk_cursor_unref (obj->priv->busy_cursor); gdk_cursor_unref (obj->priv->busy_cursor);
#endif
G_OBJECT_CLASS (pluma_file_browser_widget_parent_class)->finalize (object); G_OBJECT_CLASS (pluma_file_browser_widget_parent_class)->finalize (object);
} }
@ -1248,6 +1252,9 @@ create_filter (PlumaFileBrowserWidget * obj)
static void static void
pluma_file_browser_widget_init (PlumaFileBrowserWidget * obj) pluma_file_browser_widget_init (PlumaFileBrowserWidget * obj)
{ {
#if GTK_CHECK_VERSION (3, 16, 0)
GdkDisplay *display;
#endif
obj->priv = PLUMA_FILE_BROWSER_WIDGET_GET_PRIVATE (obj); obj->priv = PLUMA_FILE_BROWSER_WIDGET_GET_PRIVATE (obj);
obj->priv->bookmarks_hash = g_hash_table_new_full (g_file_hash, obj->priv->bookmarks_hash = g_hash_table_new_full (g_file_hash,
@ -1256,8 +1263,13 @@ pluma_file_browser_widget_init (PlumaFileBrowserWidget * obj)
free_name_icon); free_name_icon);
gtk_box_set_spacing (GTK_BOX (obj), 3); gtk_box_set_spacing (GTK_BOX (obj), 3);
#if GTK_CHECK_VERSION (3, 16, 0)
display = gtk_widget_get_display (GTK_WIDGET (obj));
obj->priv->busy_cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
#else
obj->priv->busy_cursor = gdk_cursor_new (GDK_WATCH); obj->priv->busy_cursor = gdk_cursor_new (GDK_WATCH);
#endif
} }
/* Private */ /* Private */
@ -2088,7 +2100,6 @@ async_free (AsyncData *async)
static void static void
set_busy (PlumaFileBrowserWidget *obj, gboolean busy) set_busy (PlumaFileBrowserWidget *obj, gboolean busy)
{ {
GdkCursor *cursor;
GdkWindow *window; GdkWindow *window;
window = gtk_widget_get_window (GTK_WIDGET (obj->priv->treeview)); window = gtk_widget_get_window (GTK_WIDGET (obj->priv->treeview));
@ -2098,9 +2109,23 @@ set_busy (PlumaFileBrowserWidget *obj, gboolean busy)
if (busy) if (busy)
{ {
#if GTK_CHECK_VERSION (3, 16, 0)
GdkDisplay *display;
GdkCursor *cursor;
display = gtk_widget_get_display (GTK_WIDGET (obj));
cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
#else
GdkCursor *cursor;
cursor = gdk_cursor_new (GDK_WATCH); cursor = gdk_cursor_new (GDK_WATCH);
#endif
gdk_window_set_cursor (window, cursor); gdk_window_set_cursor (window, cursor);
#if GTK_CHECK_VERSION (3, 0, 0)
g_object_unref (obj->priv->busy_cursor);
#else
gdk_cursor_unref (cursor); gdk_cursor_unref (cursor);
#endif
} }
else else
{ {

View File

@ -49,6 +49,10 @@
#define PLUMA_TAB_KEY "PLUMA_TAB_KEY" #define PLUMA_TAB_KEY "PLUMA_TAB_KEY"
#if GTK_CHECK_VERSION (3, 0, 0)
#define gdk_cursor_unref(cursor) g_object_unref (cursor)
#endif
struct _PlumaTabPrivate struct _PlumaTabPrivate
{ {
PlumaTabState state; PlumaTabState state;