[gnome-builder] history: add support for back/forward mouse buttons



commit e7ebd57e01d85da33d725ddd7d32c7d2b85b5aef
Author: Christian Hergert <chergert redhat com>
Date:   Thu Jan 17 22:13:57 2019 -0800

    history: add support for back/forward mouse buttons
    
    This needs testing, but a cursory check of what button number to expect
    would indicate that this should do the trick.

 .../history/gbp-history-editor-page-addin.c        | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)
---
diff --git a/src/plugins/history/gbp-history-editor-page-addin.c 
b/src/plugins/history/gbp-history-editor-page-addin.c
index 43133ac58..7c19a8e73 100644
--- a/src/plugins/history/gbp-history-editor-page-addin.c
+++ b/src/plugins/history/gbp-history-editor-page-addin.c
@@ -20,6 +20,8 @@
 
 #define G_LOG_DOMAIN "gbp-history-editor-page-addin"
 
+#include <dazzle.h>
+
 #include "gbp-history-editor-page-addin.h"
 #include "gbp-history-item.h"
 #include "gbp-history-frame-addin.h"
@@ -233,6 +235,30 @@ gbp_history_editor_page_addin_buffer_loaded (GbpHistoryEditorPageAddin *self,
     }
 }
 
+static gboolean
+gbp_history_editor_page_addin_button_press_event (GbpHistoryEditorPageAddin *self,
+                                                  GdkEventButton            *button,
+                                                  IdeSourceView             *source_view)
+{
+  g_assert (IDE_IS_MAIN_THREAD ());
+  g_assert (GBP_IS_HISTORY_EDITOR_PAGE_ADDIN (self));
+  g_assert (button != NULL);
+  g_assert (IDE_IS_SOURCE_VIEW (source_view));
+
+  if (button->button == 8)
+    {
+      dzl_gtk_widget_action (GTK_WIDGET (source_view), "history", "move-previous-edit", NULL);
+      return GDK_EVENT_STOP;
+    }
+  else if (button->button == 9)
+    {
+      dzl_gtk_widget_action (GTK_WIDGET (source_view), "history", "move-next-edit", NULL);
+      return GDK_EVENT_STOP;
+    }
+
+  return GDK_EVENT_PROPAGATE;
+}
+
 static void
 gbp_history_editor_page_addin_load (IdeEditorPageAddin *addin,
                                     IdeEditorPage      *view)
@@ -256,6 +282,11 @@ gbp_history_editor_page_addin_load (IdeEditorPageAddin *addin,
                             G_CALLBACK (gbp_history_editor_page_addin_jump),
                             addin);
 
+  g_signal_connect_swapped (source_view,
+                            "button-press-event",
+                            G_CALLBACK (gbp_history_editor_page_addin_button_press_event),
+                            addin);
+
   g_signal_connect_swapped (buffer,
                             "insert-text",
                             G_CALLBACK (gbp_history_editor_page_addin_insert_text),
@@ -292,6 +323,10 @@ gbp_history_editor_page_addin_unload (IdeEditorPageAddin *addin,
                                         G_CALLBACK (gbp_history_editor_page_addin_jump),
                                         self);
 
+  g_signal_handlers_disconnect_by_func (source_view,
+                                        G_CALLBACK (gbp_history_editor_page_addin_button_press_event),
+                                        self);
+
   g_signal_handlers_disconnect_by_func (buffer,
                                         G_CALLBACK (gbp_history_editor_page_addin_insert_text),
                                         self);


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