From: Pierre-Luc Beaudoin Date: Sun, 7 Sep 2008 17:01:40 +0000 (-0400) Subject: Add hand mouse cursors X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df83e4daba6758547a0b8b9790c7c7644a148375;p=libchamplain Add hand mouse cursors --- diff --git a/champlain/Makefile.am b/champlain/Makefile.am index b2d251a..e1f88d8 100644 --- a/champlain/Makefile.am +++ b/champlain/Makefile.am @@ -46,6 +46,6 @@ SOURCES = launcher.c LDADD = $(DEPS_LIBS) $(top_builddir)/champlain/libchamplain-1.0.la svgdir = $(datadir)/champlain -svg_DATA = error.svg +svg_DATA = error.svg hand_open.svg hand_closed.svg EXTRA_DIST = $(svg_DATA) $(CHAMPLAIN_MARSHAL_LIST) diff --git a/champlain/champlainview.c b/champlain/champlainview.c index df80d02..84dcee2 100644 --- a/champlain/champlainview.c +++ b/champlain/champlainview.c @@ -76,6 +76,9 @@ struct _ChamplainViewPrivate Map *map; + GdkCursor *cursor_hand_open; + GdkCursor *cursor_hand_closed; + gboolean offline; }; @@ -577,6 +580,21 @@ view_size_allocated_cb (GtkWidget *widget, GtkAllocation *allocation, ChamplainV resize_viewport(view); map_load_visible_tiles (priv->map, priv->viewport_size, priv->offline); + + // Setup mouse cursor to a hand + gdk_window_set_cursor( priv->clutter_embed->window, priv->cursor_hand_open); +} +static gboolean +mouse_button_cb (GtkWidget *widget, GdkEventButton *event, ChamplainView *view) +{ + ChamplainViewPrivate *priv = CHAMPLAIN_VIEW_GET_PRIVATE (view); + + if (event->type == GDK_BUTTON_PRESS) + gdk_window_set_cursor( priv->clutter_embed->window, priv->cursor_hand_closed); + else + gdk_window_set_cursor( priv->clutter_embed->window, priv->cursor_hand_open); + + return FALSE; } /** @@ -601,7 +619,24 @@ champlain_view_new (ChamplainViewMode mode) "size-allocate", G_CALLBACK (view_size_allocated_cb), view); - + g_signal_connect (priv->clutter_embed, + "button-press-event", + G_CALLBACK (mouse_button_cb), + view); + g_signal_connect (priv->clutter_embed, + "button-release-event", + G_CALLBACK (mouse_button_cb), + view); + // Setup cursors + priv->cursor_hand_open = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), + gdk_pixbuf_new_from_file(DATADIR "/champlain/hand_open.svg", NULL), + 20, + 20); + priv->cursor_hand_closed = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), + gdk_pixbuf_new_from_file(DATADIR "/champlain/hand_closed.svg", NULL), + 20, + 20); + // Setup stage stage = gtk_clutter_embed_get_stage (GTK_CLUTTER_EMBED (priv->clutter_embed));