[gnome-control-center/display-capplet-ui-cleanup: 2/4] Set the mouse cursor to a hand when an output is draggable
- From: Federico Mena Quintero <federico src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-control-center/display-capplet-ui-cleanup: 2/4] Set the mouse cursor to a hand when an output is draggable
- Date: Fri, 12 Feb 2010 20:19:02 +0000 (UTC)
commit d43cb0cd8ccb1705ef29d33e67d930d406a9d818
Author: Federico Mena Quintero <federico novell com>
Date: Fri Feb 12 13:28:39 2010 -0600
Set the mouse cursor to a hand when an output is draggable
This should make it more obvious that outputs are in fact draggable
in the FooScrollArea, and it will let us remove the ugly label
with instructions for how to drag the monitors.
Signed-off-by: Federico Mena Quintero <federico novell com>
capplets/display/xrandr-capplet.c | 50 ++++++++++++++++++++++++++----------
1 files changed, 36 insertions(+), 14 deletions(-)
---
diff --git a/capplets/display/xrandr-capplet.c b/capplets/display/xrandr-capplet.c
index 4d39b02..b1d6bea 100644
--- a/capplets/display/xrandr-capplet.c
+++ b/capplets/display/xrandr-capplet.c
@@ -1464,6 +1464,30 @@ compare_snaps (gconstpointer v1, gconstpointer v2)
}
}
+/* Sets a mouse cursor for a widget's window. As a hack, you can pass
+ * GDK_BLANK_CURSOR to mean "set the cursor to NULL" (i.e. reset the widget's
+ * window's cursor to its default).
+ */
+static void
+set_cursor (GtkWidget *widget, GdkCursorType type)
+{
+ GdkCursor *cursor;
+ GdkWindow *window;
+
+ if (type == GDK_BLANK_CURSOR)
+ cursor = NULL;
+ else
+ cursor = gdk_cursor_new_for_display (gtk_widget_get_display (widget), type);
+
+ window = gtk_widget_get_window (widget);
+
+ if (window)
+ gdk_window_set_cursor (window, cursor);
+
+ if (cursor)
+ gdk_cursor_unref (cursor);
+}
+
static void
on_output_event (FooScrollArea *area,
FooScrollAreaEvent *event,
@@ -1472,6 +1496,13 @@ on_output_event (FooScrollArea *area,
GnomeOutputInfo *output = data;
App *app = g_object_get_data (G_OBJECT (area), "app");
+ /* If the mouse is inside the outputs, set the cursor to a hand. See
+ * on_canvas_event() for where we reset the cursor to the default if it
+ * exits the outputs' area.
+ */
+ if (!app->current_configuration->clone && get_n_connected (app) > 1)
+ set_cursor (GTK_WIDGET (area), GDK_HAND1);
+
if (event->type == FOO_BUTTON_PRESS)
{
GrabInfo *info;
@@ -1570,24 +1601,17 @@ on_output_event (FooScrollArea *area,
}
}
-#if 0
static void
on_canvas_event (FooScrollArea *area,
FooScrollAreaEvent *event,
gpointer data)
{
- App *app = g_object_get_data (G_OBJECT (area), "app");
-
- if (event->type == FOO_BUTTON_PRESS)
- {
- app->current_output = NULL;
-
- rebuild_gui (app);
-
- foo_scroll_area_invalidate (area);
- }
+ /* If the mouse exits the outputs, reset the cursor to the default. See
+ * on_output_event() for where we set the cursor to a hand if it is over one
+ * of the outputs.
+ */
+ set_cursor (GTK_WIDGET (area), GDK_BLANK_CURSOR);
}
-#endif
static PangoLayout *
get_display_name (App *app,
@@ -1631,9 +1655,7 @@ paint_background (FooScrollArea *area,
cairo_fill_preserve (cr);
-#if 0
foo_scroll_area_add_input_from_fill (area, cr, on_canvas_event, NULL);
-#endif
cairo_set_source_rgb (cr,
widget->style->dark[GTK_STATE_SELECTED].red / 65535.0,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]