Use standard cursor names

This changes GTK+ to use gdk_cursor_new_from_name() with the
'standard' css names, instead of GdkCursorType.

https://bugzilla.gnome.org/show_bug.cgi?id=652085
This commit is contained in:
Matthias Clasen 2015-05-09 22:50:02 -04:00
parent b3fb1aefd8
commit 5c2759af3c
15 changed files with 44 additions and 64 deletions

View File

@ -123,7 +123,7 @@ query_for_toplevel (GdkScreen *screen,
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_widget_show_all (popup);
cursor = gdk_cursor_new_for_display (display, GDK_CROSSHAIR);
cursor = gdk_cursor_new_from_name (display, "crosshair");
if (gdk_device_grab (gtk_get_current_event_device (),
gtk_widget_get_window (popup),

View File

@ -253,9 +253,11 @@ do_hypertext (GtkWidget *do_widget)
GtkWidget *view;
GtkWidget *sw;
GtkTextBuffer *buffer;
GdkDisplay *display;
hand_cursor = gdk_cursor_new_for_display (gtk_widget_get_display (do_widget), GDK_HAND2);
regular_cursor = gdk_cursor_new_for_display (gtk_widget_get_display (do_widget), GDK_XTERM);
display = gtk_widget_get_display (do_widget);
hand_cursor = gdk_cursor_new_from_name (display, "pointer");
regular_cursor = gdk_cursor_new_from_name (display, "text");
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_title (GTK_WINDOW (window), "Hypertext");

View File

@ -804,8 +804,8 @@ gtk_about_dialog_realize (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_about_dialog_parent_class)->realize (widget);
display = gtk_widget_get_display (widget);
priv->hand_cursor = gdk_cursor_new_for_display (display, GDK_HAND2);
priv->regular_cursor = gdk_cursor_new_for_display (display, GDK_XTERM);
priv->hand_cursor = gdk_cursor_new_from_name (display, "pointer");
priv->regular_cursor = gdk_cursor_new_from_name (display, "text");
}
static void

View File

@ -196,8 +196,7 @@ set_cross_cursor (GtkWidget *widget,
return;
if (enabled)
cursor = gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (widget)),
GDK_CROSSHAIR);
cursor = gdk_cursor_new_from_name (gtk_widget_get_display (GTK_WIDGET (widget)), "crosshair");
gdk_window_set_device_cursor (window, device, cursor);

View File

@ -3170,7 +3170,7 @@ update_cursors (GtkWidget *widget)
(icon_info->nonactivatable && icon_info->target_list == NULL)))
{
display = gtk_widget_get_display (widget);
cursor = gdk_cursor_new_for_display (display, GDK_XTERM);
cursor = gdk_cursor_new_from_name (display, "text");
gdk_window_set_cursor (icon_info->window, cursor);
g_object_unref (cursor);
}

View File

@ -4229,11 +4229,7 @@ set_busy_cursor (GtkFileChooserWidget *impl,
display = gtk_widget_get_display (widget);
if (busy)
{
cursor = gdk_cursor_new_from_name (display, "left_ptr_watch");
if (cursor == NULL)
cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
}
cursor = gdk_cursor_new_from_name (display, "progress");
else
cursor = NULL;

View File

@ -4080,9 +4080,9 @@ gtk_label_update_cursor (GtkLabel *label)
display = gtk_widget_get_display (widget);
if (priv->select_info->active_link)
cursor = gdk_cursor_new_for_display (display, GDK_HAND2);
cursor = gdk_cursor_new_from_name (display, "pointer");
else if (priv->select_info->selectable)
cursor = gdk_cursor_new_for_display (display, GDK_XTERM);
cursor = gdk_cursor_new_from_name (display, "text");
else
cursor = NULL;
}

View File

@ -298,7 +298,7 @@ set_hand_cursor (GtkWidget *widget,
cursor = NULL;
if (show_hand)
cursor = gdk_cursor_new_for_display (display, GDK_HAND2);
cursor = gdk_cursor_new_from_name (display, "pointer");
gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
gdk_display_flush (display);

View File

@ -109,7 +109,6 @@ struct _GtkPanedPrivate
GtkWidget *saved_focus;
GtkOrientation orientation;
GdkCursorType cursor_type;
GdkRectangle handle_pos;
GdkWindow *handle;
@ -787,7 +786,6 @@ gtk_paned_init (GtkPaned *paned)
priv = paned->priv;
priv->orientation = GTK_ORIENTATION_HORIZONTAL;
priv->cursor_type = GDK_SB_H_DOUBLE_ARROW;
priv->child1 = NULL;
priv->child2 = NULL;
@ -841,17 +839,11 @@ gtk_paned_set_property (GObject *object,
_gtk_orientable_set_style_classes (GTK_ORIENTABLE (paned));
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
{
priv->cursor_type = GDK_SB_H_DOUBLE_ARROW;
gtk_gesture_pan_set_orientation (GTK_GESTURE_PAN (priv->pan_gesture),
GTK_ORIENTATION_HORIZONTAL);
}
gtk_gesture_pan_set_orientation (GTK_GESTURE_PAN (priv->pan_gesture),
GTK_ORIENTATION_HORIZONTAL);
else
{
priv->cursor_type = GDK_SB_V_DOUBLE_ARROW;
gtk_gesture_pan_set_orientation (GTK_GESTURE_PAN (priv->pan_gesture),
GTK_ORIENTATION_VERTICAL);
}
gtk_gesture_pan_set_orientation (GTK_GESTURE_PAN (priv->pan_gesture),
GTK_ORIENTATION_VERTICAL);
/* state_flags_changed updates the cursor */
gtk_paned_state_flags_changed (GTK_WIDGET (paned), 0);
@ -1609,8 +1601,9 @@ gtk_paned_realize (GtkWidget *widget)
attributes_mask = GDK_WA_X | GDK_WA_Y;
if (gtk_widget_is_sensitive (widget))
{
attributes.cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
priv->cursor_type);
attributes.cursor = gdk_cursor_new_from_name (gtk_widget_get_display (widget),
priv->orientation == GTK_ORIENTATION_HORIZONTAL
? "col-resize" : "row-resize");
attributes_mask |= GDK_WA_CURSOR;
}
@ -1884,8 +1877,9 @@ gtk_paned_state_flags_changed (GtkWidget *widget,
if (gtk_widget_get_realized (widget))
{
if (gtk_widget_is_sensitive (widget))
cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget),
priv->cursor_type);
cursor = gdk_cursor_new_from_name (gtk_widget_get_display (widget),
priv->orientation == GTK_ORIENTATION_HORIZONTAL
? "col-resize" : "row-resize");
else
cursor = NULL;

View File

@ -584,11 +584,7 @@ set_busy_cursor (GtkPrintUnixDialog *dialog,
display = gtk_widget_get_display (widget);
if (busy)
{
cursor = gdk_cursor_new_from_name (display, "left_ptr_watch");
if (cursor == NULL)
cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
}
cursor = gdk_cursor_new_from_name (display, "progress");
else
cursor = NULL;

View File

@ -697,11 +697,7 @@ set_busy_cursor (GtkRecentChooserDefault *impl,
display = gtk_widget_get_display (GTK_WIDGET (toplevel));
if (busy)
{
cursor = gdk_cursor_new_from_name (display, "left_ptr_watch");
if (cursor == NULL)
cursor = gdk_cursor_new_for_display (display, GDK_WATCH);
}
cursor = gdk_cursor_new_from_name (display, "progress");
else
cursor = NULL;

View File

@ -4488,7 +4488,7 @@ gtk_text_view_state_flags_changed (GtkWidget *widget,
if (gtk_widget_get_realized (widget))
{
if (gtk_widget_is_sensitive (widget))
cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), GDK_XTERM);
cursor = gdk_cursor_new_from_name (gtk_widget_get_display (widget), "text");
else
cursor = NULL;
@ -4516,7 +4516,7 @@ set_invisible_cursor (GdkWindow *window)
GdkCursor *cursor;
display = gdk_window_get_display (window);
cursor = gdk_cursor_new_for_display (display, GDK_BLANK_CURSOR);
cursor = gdk_cursor_new_from_name (display, "none");
gdk_window_set_cursor (window, cursor);
@ -4539,10 +4539,11 @@ gtk_text_view_unobscure_mouse_cursor (GtkTextView *text_view)
{
if (text_view->priv->mouse_cursor_obscured)
{
GdkDisplay *display;
GdkCursor *cursor;
cursor = gdk_cursor_new_for_display (gtk_widget_get_display (GTK_WIDGET (text_view)),
GDK_XTERM);
display = gtk_widget_get_display (GTK_WIDGET (text_view));
cursor = gdk_cursor_new_from_name (display, "text");
gdk_window_set_cursor (text_view->priv->text_window->bin_window, cursor);
g_object_unref (cursor);
text_view->priv->mouse_cursor_obscured = FALSE;
@ -9433,6 +9434,7 @@ text_window_realize (GtkTextWindow *win,
GdkWindow *window;
GdkWindowAttr attributes;
gint attributes_mask;
GdkDisplay *display;
GdkCursor *cursor;
attributes.window_type = GDK_WINDOW_CHILD;
@ -9485,12 +9487,11 @@ text_window_realize (GtkTextWindow *win,
case GTK_TEXT_WINDOW_TEXT:
if (gtk_widget_is_sensitive (widget))
{
/* I-beam cursor */
cursor = gdk_cursor_new_for_display (gdk_window_get_display (window),
GDK_XTERM);
display = gdk_window_get_display (window);
cursor = gdk_cursor_new_from_name (display, "text");
gdk_window_set_cursor (win->bin_window, cursor);
g_object_unref (cursor);
}
}
gtk_im_context_set_client_window (GTK_TEXT_VIEW (widget)->priv->im_context,
win->window);

View File

@ -1342,6 +1342,7 @@ _gtk_tree_view_column_realize_button (GtkTreeViewColumn *column)
GdkWindowAttr attr;
guint attributes_mask;
gboolean rtl;
GdkDisplay *display;
tree_view = (GtkTreeView *)priv->tree_view;
rtl = (gtk_widget_get_direction (priv->tree_view) == GTK_TEXT_DIR_RTL);
@ -1362,8 +1363,8 @@ _gtk_tree_view_column_realize_button (GtkTreeViewColumn *column)
GDK_POINTER_MOTION_MASK |
GDK_KEY_PRESS_MASK);
attributes_mask = GDK_WA_CURSOR | GDK_WA_X | GDK_WA_Y;
attr.cursor = gdk_cursor_new_for_display
(gdk_window_get_display (_gtk_tree_view_get_header_window (tree_view)), GDK_SB_H_DOUBLE_ARROW);
display = gdk_window_get_display (_gtk_tree_view_get_header_window (tree_view));
attr.cursor = gdk_cursor_new_from_name (display, "col-resize");
attr.y = 0;
attr.width = TREE_VIEW_DRAG_WIDTH;
attr.height = _gtk_tree_view_get_header_height (tree_view);

View File

@ -7172,15 +7172,10 @@ gtk_window_realize (GtkWidget *widget)
if (priv->client_decorated && priv->type == GTK_WINDOW_TOPLEVEL)
{
GdkCursorType cursor_type[8] = {
GDK_TOP_LEFT_CORNER,
GDK_TOP_SIDE,
GDK_TOP_RIGHT_CORNER,
GDK_LEFT_SIDE,
GDK_RIGHT_SIDE,
GDK_BOTTOM_LEFT_CORNER,
GDK_BOTTOM_SIDE,
GDK_BOTTOM_RIGHT_CORNER
const gchar *cursor[8] = {
"nw-resize", "n-resize", "ne-resize",
"w-resize", "e-resize",
"sw-resize", "s-resize", "se-resize"
};
attributes.wclass = GDK_INPUT_ONLY;
@ -7191,7 +7186,7 @@ gtk_window_realize (GtkWidget *widget)
for (i = 0; i < 8; i++)
{
attributes.cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), cursor_type[i]);
attributes.cursor = gdk_cursor_new_from_name (gtk_widget_get_display (widget), cursor[i]);
priv->border_window[i] = gdk_window_new (gdk_window, &attributes, attributes_mask);
g_object_unref (attributes.cursor);

View File

@ -376,7 +376,7 @@ gtk_inspector_on_inspect (GtkWidget *button,
}
display = gdk_display_get_default ();
cursor = gdk_cursor_new_for_display (display, GDK_CROSSHAIR);
cursor = gdk_cursor_new_from_name (display, "crosshair");
device = gdk_device_manager_get_client_pointer (gdk_display_get_device_manager (display));
status = gdk_device_grab (device,
gtk_widget_get_window (iw->invisible),