[epiphany] ephy-location-controller: Add longpress to select url text



commit b4531a7205b59334b10bfce24b803836424f7b9f
Author: Jan-Michael Brummer <jan brummer tabos org>
Date:   Wed Feb 7 18:36:02 2018 +0100

    ephy-location-controller: Add longpress to select url text
    
    Currently a touch screen user has no easy option to mark the whole url text for deleting as it is 
provided by other touch based system.
    
    Adding a long press gesture to ephy-location-controller fixes the issues and allows quick and easy page 
switching.
    
    Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=793267

 src/ephy-location-controller.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
---
diff --git a/src/ephy-location-controller.c b/src/ephy-location-controller.c
index c42e31f..f252ec5 100644
--- a/src/ephy-location-controller.c
+++ b/src/ephy-location-controller.c
@@ -51,6 +51,7 @@ struct _EphyLocationController {
 
   EphyWindow *window;
   EphyTitleWidget *title_widget;
+  GtkGesture *longpress_gesture;
   char *address;
   gboolean editable;
   gboolean sync_address_is_blocked;
@@ -364,6 +365,17 @@ search_engines_changed_cb (EphySearchEngineManager *manager,
 }
 
 static void
+longpress_gesture_cb (GtkGestureLongPress *gesture,
+                      gdouble              x,
+                      gdouble              y,
+                      gpointer             user_data)
+{
+  EphyLocationController *controller = EPHY_LOCATION_CONTROLLER (user_data);
+
+  gtk_editable_select_region (GTK_EDITABLE (controller->title_widget), 0, -1);
+}
+
+static void
 ephy_location_controller_constructed (GObject *object)
 {
   EphyLocationController *controller = EPHY_LOCATION_CONTROLLER (object);
@@ -387,6 +399,10 @@ ephy_location_controller_constructed (GObject *object)
   if (!EPHY_IS_LOCATION_ENTRY (controller->title_widget))
     return;
 
+  controller->longpress_gesture = gtk_gesture_long_press_new (widget);
+  gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (controller->longpress_gesture), TRUE);
+  g_signal_connect (controller->longpress_gesture, "pressed", G_CALLBACK(longpress_gesture_cb), controller);
+
   history_service = ephy_embed_shell_get_global_history_service (ephy_embed_shell_get_default ());
   bookmarks_manager = ephy_shell_get_bookmarks_manager (ephy_shell_get_default ());
   model = ephy_completion_model_new (history_service, bookmarks_manager);
@@ -492,6 +508,8 @@ ephy_location_controller_dispose (GObject *object)
     return;
   }
 
+  g_clear_object (&controller->longpress_gesture);
+
   if (EPHY_IS_LOCATION_ENTRY (controller->title_widget)) {
     g_signal_handlers_disconnect_matched (controller, G_SIGNAL_MATCH_DATA,
                                           0, 0, NULL, NULL, controller->title_widget);


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