[gtk+/popovers: 25/26] texthandle: Remove relative_to API



commit d110366f84e210ba99a2a64cf60b8bda92972da1
Author: Carlos Garnacho <carlosg gnome org>
Date:   Mon Dec 23 19:15:30 2013 +0100

    texthandle: Remove relative_to API
    
    It's unused now, GtkTextHandle uses widget coordinates.

 gtk/gtkentry.c      |   15 +++++++++++----
 gtk/gtktexthandle.c |   42 +-----------------------------------------
 gtk/gtktextview.c   |    4 ----
 3 files changed, 12 insertions(+), 49 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index c35b35d..0921a29 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -3209,7 +3209,6 @@ gtk_entry_realize (GtkWidget *widget)
 
   gtk_entry_adjust_scroll (entry);
   gtk_entry_update_primary_selection (entry);
-  _gtk_text_handle_set_relative_to (priv->text_handle, priv->text_area);
 
   /* If the icon positions are already setup, create their windows.
    * Otherwise if they don't exist yet, then construct_icon_info()
@@ -3237,7 +3236,6 @@ gtk_entry_unrealize (GtkWidget *widget)
   gtk_entry_reset_layout (entry);
   
   gtk_im_context_set_client_window (priv->im_context, NULL);
-  _gtk_text_handle_set_relative_to (priv->text_handle, NULL);
 
   clipboard = gtk_widget_get_clipboard (widget, GDK_SELECTION_PRIMARY);
   if (gtk_clipboard_get_owner (clipboard) == G_OBJECT (entry))
@@ -4062,13 +4060,22 @@ gtk_entry_move_handle (GtkEntry              *entry,
     }
   else
     {
+      GtkAllocation primary, secondary;
       GdkRectangle rect;
+      gint win_x, win_y;
 
-      rect.x = CLAMP (x, 0, gdk_window_get_width (priv->text_area));
-      rect.y = y;
+      get_icon_allocations (entry, &primary, &secondary);
+      gtk_entry_get_text_area_size (entry, &win_x, &win_y, NULL, NULL);
+      rect.x = CLAMP (x, 0, gdk_window_get_width (priv->text_area)) + win_x;
+      rect.y = y + win_y;
       rect.width = 1;
       rect.height = height;
 
+      if (gtk_widget_get_direction (GTK_WIDGET (entry)) == GTK_TEXT_DIR_RTL)
+        rect.x += secondary.width;
+      else
+        rect.x += primary.width;
+
       _gtk_text_handle_set_visible (priv->text_handle, pos, TRUE);
       _gtk_text_handle_set_position (priv->text_handle, pos, &rect);
     }
diff --git a/gtk/gtktexthandle.c b/gtk/gtktexthandle.c
index decf14f..2409f39 100644
--- a/gtk/gtktexthandle.c
+++ b/gtk/gtktexthandle.c
@@ -35,8 +35,7 @@ enum {
 
 enum {
   PROP_0,
-  PROP_PARENT,
-  PROP_RELATIVE_TO
+  PROP_PARENT
 };
 
 struct _HandleWindow
@@ -55,7 +54,6 @@ struct _GtkTextHandlePrivate
 {
   HandleWindow windows[2];
   GtkWidget *parent;
-  GdkWindow *relative_to;
   guint mode : 2;
 };
 
@@ -306,9 +304,6 @@ gtk_text_handle_finalize (GObject *object)
 
   priv = GTK_TEXT_HANDLE (object)->priv;
 
-  if (priv->relative_to)
-    g_object_unref (priv->relative_to);
-
   if (priv->windows[GTK_TEXT_HANDLE_POSITION_SELECTION_START].widget)
     gtk_widget_destroy (priv->windows[GTK_TEXT_HANDLE_POSITION_SELECTION_START].widget);
 
@@ -335,10 +330,6 @@ gtk_text_handle_set_property (GObject      *object,
     case PROP_PARENT:
       priv->parent = g_value_get_object (value);
       break;
-    case PROP_RELATIVE_TO:
-      _gtk_text_handle_set_relative_to (handle,
-                                        g_value_get_object (value));
-      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -359,9 +350,6 @@ gtk_text_handle_get_property (GObject    *object,
     case PROP_PARENT:
       g_value_set_object (value, priv->parent);
       break;
-    case PROP_RELATIVE_TO:
-      g_value_set_object (value, priv->relative_to);
-      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     }
@@ -403,13 +391,6 @@ _gtk_text_handle_class_init (GtkTextHandleClass *klass)
                                                         GTK_TYPE_WIDGET,
                                                         GTK_PARAM_READWRITE |
                                                         G_PARAM_CONSTRUCT_ONLY));
-  g_object_class_install_property (object_class,
-                                   PROP_RELATIVE_TO,
-                                   g_param_spec_object ("relative-to",
-                                                        P_("Window"),
-                                                        P_("Window the coordinates are based upon"),
-                                                        GDK_TYPE_WINDOW,
-                                                        GTK_PARAM_READWRITE));
 }
 
 static void
@@ -427,27 +408,6 @@ _gtk_text_handle_new (GtkWidget *parent)
 }
 
 void
-_gtk_text_handle_set_relative_to (GtkTextHandle *handle,
-                                  GdkWindow     *window)
-{
-  GtkTextHandlePrivate *priv;
-
-  g_return_if_fail (GTK_IS_TEXT_HANDLE (handle));
-  g_return_if_fail (!window || GDK_IS_WINDOW (window));
-
-  priv = handle->priv;
-
-  if (priv->relative_to)
-    g_object_unref (priv->relative_to);
-
-  if (window)
-    g_object_ref (window);
-
-  priv->relative_to = window;
-  g_object_notify (G_OBJECT (handle), "relative-to");
-}
-
-void
 _gtk_text_handle_set_mode (GtkTextHandle     *handle,
                            GtkTextHandleMode  mode)
 {
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 7066b9c..63128d5 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -4242,8 +4242,6 @@ gtk_text_view_realize (GtkWidget *widget)
 
   /* Ensure updating the spot location. */
   gtk_text_view_update_im_spot_location (text_view);
-
-  _gtk_text_handle_set_relative_to (priv->text_handle, priv->text_window->window);
 }
 
 static void
@@ -4284,8 +4282,6 @@ gtk_text_view_unrealize (GtkWidget *widget)
   if (priv->bottom_window)
     text_window_unrealize (priv->bottom_window);
 
-  _gtk_text_handle_set_relative_to (priv->text_handle, NULL);
-
   GTK_WIDGET_CLASS (gtk_text_view_parent_class)->unrealize (widget);
 }
 


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