[gnome-builder/wip/minimap2: 7/13] minimap: keep the cursor as arrow over map area, doublearrow over scrubber



commit cc6039121cb90776a70a17717bae078b564a3e1b
Author: Christian Hergert <christian hergert me>
Date:   Tue Apr 21 13:59:17 2015 -0700

    minimap: keep the cursor as arrow over map area, doublearrow over scrubber

 libide/ide-source-map.c |  103 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 101 insertions(+), 2 deletions(-)
---
diff --git a/libide/ide-source-map.c b/libide/ide-source-map.c
index f3bce19..5bc5c27 100644
--- a/libide/ide-source-map.c
+++ b/libide/ide-source-map.c
@@ -376,8 +376,9 @@ ide_source_map__child_view_button_press_event (IdeSourceMap   *self,
 }
 
 static void
-ide_source_map__child_view_realize_after (GtkWidget *widget,
-                                          GtkWidget *child_view)
+ide_source_map__child_view_state_flags_changed (GtkWidget     *widget,
+                                                GtkStateFlags  flags,
+                                                GtkWidget     *child_view)
 {
   IdeSourceMap *self = (IdeSourceMap *)widget;
   GdkWindow *window;
@@ -390,6 +391,79 @@ ide_source_map__child_view_realize_after (GtkWidget *widget,
 }
 
 static void
+ide_source_map__child_view_realize_after (GtkWidget *widget,
+                                          GtkWidget *child_view)
+{
+  IdeSourceMap *self = (IdeSourceMap *)widget;
+
+  g_assert (IDE_IS_SOURCE_MAP (self));
+  g_assert (GTK_SOURCE_IS_VIEW (child_view));
+
+  ide_source_map__child_view_state_flags_changed (widget, 0, child_view);
+}
+
+static void
+ide_source_map__overlay_box_realize_after (IdeSourceMap *self,
+                                           GtkEventBox  *overlay_box)
+{
+  GdkCursor *cursor;
+  GdkDisplay *display;
+  GdkWindow *window;
+
+  g_assert (IDE_IS_SOURCE_MAP (self));
+  g_assert (GTK_IS_EVENT_BOX (overlay_box));
+
+  window = gtk_widget_get_window (GTK_WIDGET (overlay_box));
+  g_assert (window != NULL);
+
+  display = gdk_window_get_display (window);
+  g_assert (display != NULL);
+
+  cursor = gdk_cursor_new_for_display (display, GDK_DOUBLE_ARROW);
+  g_assert (cursor != NULL);
+
+  gdk_window_set_cursor (window, cursor);
+
+  g_clear_object (&cursor);
+}
+
+static gboolean
+ide_source_map__overlay_box_button_press_event (IdeSourceMap   *self,
+                                                GdkEventButton *event,
+                                                GtkEventBox    *overlay_box)
+{
+  g_assert (IDE_IS_SOURCE_MAP (self));
+  g_assert (event != NULL);
+  g_assert (GTK_IS_EVENT_BOX (overlay_box));
+
+  return GDK_EVENT_PROPAGATE;
+}
+
+static gboolean
+ide_source_map__overlay_box_button_release_event (IdeSourceMap   *self,
+                                                  GdkEventButton *event,
+                                                  GtkEventBox    *overlay_box)
+{
+  g_assert (IDE_IS_SOURCE_MAP (self));
+  g_assert (event != NULL);
+  g_assert (GTK_IS_EVENT_BOX (overlay_box));
+
+  return GDK_EVENT_PROPAGATE;
+}
+
+static gboolean
+ide_source_map__overlay_box_motion_notify_event (IdeSourceMap   *self,
+                                                 GdkEventMotion *event,
+                                                 GtkEventBox    *overlay_box)
+{
+  g_assert (IDE_IS_SOURCE_MAP (self));
+  g_assert (event != NULL);
+  g_assert (GTK_IS_EVENT_BOX (overlay_box));
+
+  return GDK_EVENT_PROPAGATE;
+}
+
+static void
 ide_source_map_finalize (GObject *object)
 {
   IdeSourceMap *self = (IdeSourceMap *)object;
@@ -486,6 +560,11 @@ ide_source_map_init (IdeSourceMap *self)
                            self,
                            G_CONNECT_SWAPPED);
   g_signal_connect_object (self->child_view,
+                           "state-flags-changed",
+                           G_CALLBACK (ide_source_map__child_view_state_flags_changed),
+                           self,
+                           G_CONNECT_SWAPPED | G_CONNECT_AFTER);
+  g_signal_connect_object (self->child_view,
                            "realize",
                            G_CALLBACK (ide_source_map__child_view_realize_after),
                            self,
@@ -498,6 +577,26 @@ ide_source_map_init (IdeSourceMap *self)
                                     "height-request", 10,
                                     "width-request", 100,
                                     NULL);
+  g_signal_connect_object (self->overlay_box,
+                           "realize",
+                           G_CALLBACK (ide_source_map__overlay_box_realize_after),
+                           self,
+                           G_CONNECT_SWAPPED | G_CONNECT_AFTER);
+  g_signal_connect_object (self->overlay_box,
+                           "button-press-event",
+                           G_CALLBACK (ide_source_map__overlay_box_button_press_event),
+                           self,
+                           G_CONNECT_SWAPPED);
+  g_signal_connect_object (self->overlay_box,
+                           "button-release-event",
+                           G_CALLBACK (ide_source_map__overlay_box_button_release_event),
+                           self,
+                           G_CONNECT_SWAPPED);
+  g_signal_connect_object (self->overlay_box,
+                           "motion-notify-event",
+                           G_CALLBACK (ide_source_map__overlay_box_motion_notify_event),
+                           self,
+                           G_CONNECT_SWAPPED);
 
   G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
   {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]