forked from AuroraMiddleware/gtk
Merge branch 'wip/carlosg/text-handle-natives' into 'master'
Make text handles use native surfaces See merge request GNOME/gtk!1487
This commit is contained in:
commit
fa4be719d8
@ -1227,54 +1227,6 @@ rewrite_event_for_grabs (GdkEvent *event)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget *
|
|
||||||
widget_get_popover_ancestor (GtkWidget *widget,
|
|
||||||
GtkWindow *window)
|
|
||||||
{
|
|
||||||
GtkWidget *parent = gtk_widget_get_parent (widget);
|
|
||||||
|
|
||||||
while (parent && parent != GTK_WIDGET (window))
|
|
||||||
{
|
|
||||||
widget = parent;
|
|
||||||
parent = gtk_widget_get_parent (widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!parent || parent != GTK_WIDGET (window))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (_gtk_window_is_popover_widget (GTK_WINDOW (window), widget))
|
|
||||||
return widget;
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
check_event_in_child_popover (GtkWidget *event_widget,
|
|
||||||
GtkWidget *grab_widget)
|
|
||||||
{
|
|
||||||
GtkWidget *window, *popover = NULL, *popover_parent = NULL;
|
|
||||||
|
|
||||||
if (grab_widget == event_widget)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
window = gtk_widget_get_ancestor (event_widget, GTK_TYPE_WINDOW);
|
|
||||||
|
|
||||||
if (!window)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
popover = widget_get_popover_ancestor (event_widget, GTK_WINDOW (window));
|
|
||||||
|
|
||||||
if (!popover)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
popover_parent = _gtk_window_get_popover_parent (GTK_WINDOW (window), popover);
|
|
||||||
|
|
||||||
if (!popover_parent)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return (popover_parent == grab_widget || gtk_widget_is_ancestor (popover_parent, grab_widget));
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
translate_event_coordinates (GdkEvent *event,
|
translate_event_coordinates (GdkEvent *event,
|
||||||
double *x,
|
double *x,
|
||||||
@ -1733,14 +1685,6 @@ gtk_main_do_event (GdkEvent *event)
|
|||||||
gtk_widget_is_ancestor (target_widget, grab_widget)))
|
gtk_widget_is_ancestor (target_widget, grab_widget)))
|
||||||
grab_widget = target_widget;
|
grab_widget = target_widget;
|
||||||
|
|
||||||
/* popovers are not really a "child" of their "parent" in the widget/window
|
|
||||||
* hierarchy sense, we however want to interact with popovers spawn by widgets
|
|
||||||
* within grab_widget. If this is the case, we let the event go through
|
|
||||||
* unaffected by the grab.
|
|
||||||
*/
|
|
||||||
if (check_event_in_child_popover (target_widget, grab_widget))
|
|
||||||
grab_widget = target_widget;
|
|
||||||
|
|
||||||
/* Not all events get sent to the grabbing widget.
|
/* Not all events get sent to the grabbing widget.
|
||||||
* The delete, destroy, expose, focus change and resize
|
* The delete, destroy, expose, focus change and resize
|
||||||
* events still get sent to the event widget because
|
* events still get sent to the event widget because
|
||||||
|
@ -1650,11 +1650,16 @@ gtk_popover_set_pointing_to (GtkPopover *popover,
|
|||||||
{
|
{
|
||||||
priv->pointing_to = *rect;
|
priv->pointing_to = *rect;
|
||||||
priv->has_pointing_to = TRUE;
|
priv->has_pointing_to = TRUE;
|
||||||
|
priv->pointing_to.width = MAX (priv->pointing_to.width, 1);
|
||||||
|
priv->pointing_to.height = MAX (priv->pointing_to.height, 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
priv->has_pointing_to = FALSE;
|
priv->has_pointing_to = FALSE;
|
||||||
|
|
||||||
g_object_notify_by_pspec (G_OBJECT (popover), properties[PROP_POINTING_TO]);
|
g_object_notify_by_pspec (G_OBJECT (popover), properties[PROP_POINTING_TO]);
|
||||||
|
|
||||||
|
if (gtk_widget_is_visible (GTK_WIDGET (popover)))
|
||||||
|
present_popup (popover);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1724,6 +1729,9 @@ gtk_popover_set_position (GtkPopover *popover,
|
|||||||
priv->final_position = position;
|
priv->final_position = position;
|
||||||
|
|
||||||
g_object_notify_by_pspec (G_OBJECT (popover), properties[PROP_POSITION]);
|
g_object_notify_by_pspec (G_OBJECT (popover), properties[PROP_POSITION]);
|
||||||
|
|
||||||
|
if (gtk_widget_is_visible (GTK_WIDGET (popover)))
|
||||||
|
present_popup (popover);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
321
gtk/gtktext.c
321
gtk/gtktext.c
@ -140,6 +140,13 @@
|
|||||||
|
|
||||||
static GQuark quark_password_hint = 0;
|
static GQuark quark_password_hint = 0;
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
TEXT_HANDLE_CURSOR,
|
||||||
|
TEXT_HANDLE_SELECTION_BOUND,
|
||||||
|
TEXT_HANDLE_N_HANDLES
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct _GtkTextPasswordHint GtkTextPasswordHint;
|
typedef struct _GtkTextPasswordHint GtkTextPasswordHint;
|
||||||
|
|
||||||
typedef struct _GtkTextPrivate GtkTextPrivate;
|
typedef struct _GtkTextPrivate GtkTextPrivate;
|
||||||
@ -159,7 +166,7 @@ struct _GtkTextPrivate
|
|||||||
char *im_module;
|
char *im_module;
|
||||||
|
|
||||||
GtkWidget *emoji_completion;
|
GtkWidget *emoji_completion;
|
||||||
GtkTextHandle *text_handle;
|
GtkTextHandle *text_handles[TEXT_HANDLE_N_HANDLES];
|
||||||
GtkWidget *selection_bubble;
|
GtkWidget *selection_bubble;
|
||||||
guint selection_bubble_timeout_id;
|
guint selection_bubble_timeout_id;
|
||||||
|
|
||||||
@ -229,6 +236,7 @@ struct _GtkTextPrivate
|
|||||||
guint selection_handle_dragged : 1;
|
guint selection_handle_dragged : 1;
|
||||||
guint populate_all : 1;
|
guint populate_all : 1;
|
||||||
guint propagate_text_width : 1;
|
guint propagate_text_width : 1;
|
||||||
|
guint text_handles_enabled : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GtkTextPasswordHint
|
struct _GtkTextPasswordHint
|
||||||
@ -464,15 +472,12 @@ static gboolean gtk_text_key_controller_key_pressed (GtkEventControllerKey *c
|
|||||||
|
|
||||||
/* GtkTextHandle handlers */
|
/* GtkTextHandle handlers */
|
||||||
static void gtk_text_handle_drag_started (GtkTextHandle *handle,
|
static void gtk_text_handle_drag_started (GtkTextHandle *handle,
|
||||||
GtkTextHandlePosition pos,
|
|
||||||
GtkText *self);
|
GtkText *self);
|
||||||
static void gtk_text_handle_dragged (GtkTextHandle *handle,
|
static void gtk_text_handle_dragged (GtkTextHandle *handle,
|
||||||
GtkTextHandlePosition pos,
|
|
||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
GtkText *self);
|
GtkText *self);
|
||||||
static void gtk_text_handle_drag_finished (GtkTextHandle *handle,
|
static void gtk_text_handle_drag_finished (GtkTextHandle *handle,
|
||||||
GtkTextHandlePosition pos,
|
|
||||||
GtkText *self);
|
GtkText *self);
|
||||||
|
|
||||||
/* Internal routines
|
/* Internal routines
|
||||||
@ -539,6 +544,7 @@ static void emit_changed (GtkText *self);
|
|||||||
|
|
||||||
static void gtk_text_update_clipboard_actions (GtkText *self);
|
static void gtk_text_update_clipboard_actions (GtkText *self);
|
||||||
static void gtk_text_update_emoji_action (GtkText *self);
|
static void gtk_text_update_emoji_action (GtkText *self);
|
||||||
|
static void gtk_text_update_handles (GtkText *self);
|
||||||
|
|
||||||
static void gtk_text_activate_clipboard_cut (GtkWidget *widget,
|
static void gtk_text_activate_clipboard_cut (GtkWidget *widget,
|
||||||
const char *action_name,
|
const char *action_name,
|
||||||
@ -1701,6 +1707,26 @@ gtk_text_get_property (GObject *object,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gtk_text_ensure_text_handles (GtkText *self)
|
||||||
|
{
|
||||||
|
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < TEXT_HANDLE_N_HANDLES; i++)
|
||||||
|
{
|
||||||
|
if (priv->text_handles[i])
|
||||||
|
continue;
|
||||||
|
priv->text_handles[i] = gtk_text_handle_new (GTK_WIDGET (self));
|
||||||
|
g_signal_connect (priv->text_handles[i], "drag-started",
|
||||||
|
G_CALLBACK (gtk_text_handle_drag_started), self);
|
||||||
|
g_signal_connect (priv->text_handles[i], "handle-dragged",
|
||||||
|
G_CALLBACK (gtk_text_handle_dragged), self);
|
||||||
|
g_signal_connect (priv->text_handles[i], "drag-finished",
|
||||||
|
G_CALLBACK (gtk_text_handle_drag_finished), self);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_text_init (GtkText *self)
|
gtk_text_init (GtkText *self)
|
||||||
{
|
{
|
||||||
@ -1852,6 +1878,8 @@ gtk_text_dispose (GObject *object)
|
|||||||
|
|
||||||
g_clear_pointer (&priv->selection_bubble, gtk_widget_unparent);
|
g_clear_pointer (&priv->selection_bubble, gtk_widget_unparent);
|
||||||
g_clear_pointer (&priv->popup_menu, gtk_widget_unparent);
|
g_clear_pointer (&priv->popup_menu, gtk_widget_unparent);
|
||||||
|
g_clear_pointer ((GtkWidget **) &priv->text_handles[TEXT_HANDLE_CURSOR], gtk_widget_unparent);
|
||||||
|
g_clear_pointer ((GtkWidget **) &priv->text_handles[TEXT_HANDLE_SELECTION_BOUND], gtk_widget_unparent);
|
||||||
g_clear_object (&priv->extra_menu);
|
g_clear_object (&priv->extra_menu);
|
||||||
|
|
||||||
G_OBJECT_CLASS (gtk_text_parent_class)->dispose (object);
|
G_OBJECT_CLASS (gtk_text_parent_class)->dispose (object);
|
||||||
@ -1869,7 +1897,6 @@ gtk_text_finalize (GObject *object)
|
|||||||
g_clear_object (&priv->cached_layout);
|
g_clear_object (&priv->cached_layout);
|
||||||
g_clear_object (&priv->im_context);
|
g_clear_object (&priv->im_context);
|
||||||
g_clear_pointer (&priv->magnifier_popover, gtk_widget_destroy);
|
g_clear_pointer (&priv->magnifier_popover, gtk_widget_destroy);
|
||||||
g_clear_object (&priv->text_handle);
|
|
||||||
g_free (priv->im_module);
|
g_free (priv->im_module);
|
||||||
|
|
||||||
g_clear_pointer (&priv->placeholder, gtk_widget_unparent);
|
g_clear_pointer (&priv->placeholder, gtk_widget_unparent);
|
||||||
@ -1896,6 +1923,7 @@ gtk_text_ensure_magnifier (GtkText *self)
|
|||||||
gtk_widget_set_size_request (priv->magnifier, 100, 60);
|
gtk_widget_set_size_request (priv->magnifier, 100, 60);
|
||||||
_gtk_magnifier_set_magnification (GTK_MAGNIFIER (priv->magnifier), 2.0);
|
_gtk_magnifier_set_magnification (GTK_MAGNIFIER (priv->magnifier), 2.0);
|
||||||
priv->magnifier_popover = gtk_popover_new ();
|
priv->magnifier_popover = gtk_popover_new ();
|
||||||
|
gtk_popover_set_position (GTK_POPOVER (priv->magnifier_popover), GTK_POS_TOP);
|
||||||
gtk_widget_set_parent (priv->magnifier_popover, GTK_WIDGET (self));
|
gtk_widget_set_parent (priv->magnifier_popover, GTK_WIDGET (self));
|
||||||
gtk_widget_add_css_class (priv->magnifier_popover, "magnifier");
|
gtk_widget_add_css_class (priv->magnifier_popover, "magnifier");
|
||||||
gtk_popover_set_autohide (GTK_POPOVER (priv->magnifier_popover), FALSE);
|
gtk_popover_set_autohide (GTK_POPOVER (priv->magnifier_popover), FALSE);
|
||||||
@ -1904,23 +1932,6 @@ gtk_text_ensure_magnifier (GtkText *self)
|
|||||||
gtk_widget_show (priv->magnifier);
|
gtk_widget_show (priv->magnifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gtk_text_ensure_text_handles (GtkText *self)
|
|
||||||
{
|
|
||||||
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
|
||||||
|
|
||||||
if (priv->text_handle)
|
|
||||||
return;
|
|
||||||
|
|
||||||
priv->text_handle = _gtk_text_handle_new (GTK_WIDGET (self));
|
|
||||||
g_signal_connect (priv->text_handle, "drag-started",
|
|
||||||
G_CALLBACK (gtk_text_handle_drag_started), self);
|
|
||||||
g_signal_connect (priv->text_handle, "handle-dragged",
|
|
||||||
G_CALLBACK (gtk_text_handle_dragged), self);
|
|
||||||
g_signal_connect (priv->text_handle, "drag-finished",
|
|
||||||
G_CALLBACK (gtk_text_handle_drag_finished), self);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
begin_change (GtkText *self)
|
begin_change (GtkText *self)
|
||||||
{
|
{
|
||||||
@ -2051,10 +2062,8 @@ gtk_text_unmap (GtkWidget *widget)
|
|||||||
GtkText *self = GTK_TEXT (widget);
|
GtkText *self = GTK_TEXT (widget);
|
||||||
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
||||||
|
|
||||||
if (priv->text_handle)
|
priv->text_handles_enabled = FALSE;
|
||||||
_gtk_text_handle_set_mode (priv->text_handle,
|
gtk_text_update_handles (self);
|
||||||
GTK_TEXT_HANDLE_MODE_NONE);
|
|
||||||
|
|
||||||
priv->cursor_alpha = 1.0;
|
priv->cursor_alpha = 1.0;
|
||||||
|
|
||||||
GTK_WIDGET_CLASS (gtk_text_parent_class)->unmap (widget);
|
GTK_WIDGET_CLASS (gtk_text_parent_class)->unmap (widget);
|
||||||
@ -2119,20 +2128,20 @@ update_im_cursor_location (GtkText *self)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_text_move_handle (GtkText *self,
|
gtk_text_move_handle (GtkText *self,
|
||||||
GtkTextHandlePosition pos,
|
GtkTextHandle *handle,
|
||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
int height)
|
int height)
|
||||||
{
|
{
|
||||||
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
||||||
|
|
||||||
if (!_gtk_text_handle_get_is_dragged (priv->text_handle, pos) &&
|
if (!gtk_text_handle_get_is_dragged (handle) &&
|
||||||
(x < 0 || x > gtk_widget_get_width (GTK_WIDGET (self))))
|
(x < 0 || x > gtk_widget_get_width (GTK_WIDGET (self))))
|
||||||
{
|
{
|
||||||
/* Hide the handle if it's not being manipulated
|
/* Hide the handle if it's not being manipulated
|
||||||
* and fell outside of the visible text area.
|
* and fell outside of the visible text area.
|
||||||
*/
|
*/
|
||||||
_gtk_text_handle_set_visible (priv->text_handle, pos, FALSE);
|
gtk_widget_hide (GTK_WIDGET (handle));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2143,9 +2152,9 @@ gtk_text_move_handle (GtkText *self,
|
|||||||
rect.width = 1;
|
rect.width = 1;
|
||||||
rect.height = height;
|
rect.height = height;
|
||||||
|
|
||||||
_gtk_text_handle_set_visible (priv->text_handle, pos, TRUE);
|
gtk_text_handle_set_position (handle, &rect);
|
||||||
_gtk_text_handle_set_position (priv->text_handle, pos, &rect);
|
gtk_widget_set_direction (GTK_WIDGET (handle), priv->resolved_dir);
|
||||||
_gtk_text_handle_set_direction (priv->text_handle, pos, priv->resolved_dir);
|
gtk_widget_show (GTK_WIDGET (handle));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2173,20 +2182,27 @@ gtk_text_get_selection_bound_location (GtkText *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_text_update_handles (GtkText *self,
|
gtk_text_update_handles (GtkText *self)
|
||||||
GtkTextHandleMode mode)
|
|
||||||
{
|
{
|
||||||
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
||||||
const int text_height = gtk_widget_get_height (GTK_WIDGET (self));
|
const int text_height = gtk_widget_get_height (GTK_WIDGET (self));
|
||||||
int strong_x;
|
int strong_x;
|
||||||
int cursor, bound;
|
int cursor, bound;
|
||||||
|
|
||||||
_gtk_text_handle_set_mode (priv->text_handle, mode);
|
if (!priv->text_handles_enabled)
|
||||||
|
{
|
||||||
|
if (priv->text_handles[TEXT_HANDLE_CURSOR])
|
||||||
|
gtk_widget_hide (GTK_WIDGET (priv->text_handles[TEXT_HANDLE_CURSOR]));
|
||||||
|
if (priv->text_handles[TEXT_HANDLE_SELECTION_BOUND])
|
||||||
|
gtk_widget_hide (GTK_WIDGET (priv->text_handles[TEXT_HANDLE_SELECTION_BOUND]));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gtk_text_ensure_text_handles (self);
|
||||||
gtk_text_get_cursor_locations (self, &strong_x, NULL);
|
gtk_text_get_cursor_locations (self, &strong_x, NULL);
|
||||||
cursor = strong_x - priv->scroll_offset;
|
cursor = strong_x - priv->scroll_offset;
|
||||||
|
|
||||||
if (mode == GTK_TEXT_HANDLE_MODE_SELECTION)
|
if (priv->selection_bound != priv->current_pos)
|
||||||
{
|
{
|
||||||
int start, end;
|
int start, end;
|
||||||
|
|
||||||
@ -2204,15 +2220,28 @@ gtk_text_update_handles (GtkText *self,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Update start selection bound */
|
/* Update start selection bound */
|
||||||
gtk_text_move_handle (self, GTK_TEXT_HANDLE_POSITION_SELECTION_START,
|
gtk_text_handle_set_role (priv->text_handles[TEXT_HANDLE_SELECTION_BOUND],
|
||||||
start, 0, text_height);
|
GTK_TEXT_HANDLE_ROLE_SELECTION_END);
|
||||||
gtk_text_move_handle (self, GTK_TEXT_HANDLE_POSITION_SELECTION_END,
|
gtk_text_move_handle (self,
|
||||||
|
priv->text_handles[TEXT_HANDLE_SELECTION_BOUND],
|
||||||
end, 0, text_height);
|
end, 0, text_height);
|
||||||
|
gtk_text_handle_set_role (priv->text_handles[TEXT_HANDLE_CURSOR],
|
||||||
|
GTK_TEXT_HANDLE_ROLE_SELECTION_START);
|
||||||
|
gtk_text_move_handle (self,
|
||||||
|
priv->text_handles[TEXT_HANDLE_CURSOR],
|
||||||
|
start, 0, text_height);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
gtk_text_move_handle (self, GTK_TEXT_HANDLE_POSITION_CURSOR,
|
{
|
||||||
|
gtk_widget_hide (GTK_WIDGET (priv->text_handles[TEXT_HANDLE_SELECTION_BOUND]));
|
||||||
|
gtk_text_handle_set_role (priv->text_handles[TEXT_HANDLE_CURSOR],
|
||||||
|
GTK_TEXT_HANDLE_ROLE_CURSOR);
|
||||||
|
gtk_text_move_handle (self,
|
||||||
|
priv->text_handles[TEXT_HANDLE_CURSOR],
|
||||||
cursor, 0, text_height);
|
cursor, 0, text_height);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_text_measure (GtkWidget *widget,
|
gtk_text_measure (GtkWidget *widget,
|
||||||
@ -2342,13 +2371,7 @@ gtk_text_size_allocate (GtkWidget *widget,
|
|||||||
if (chooser)
|
if (chooser)
|
||||||
gtk_native_check_resize (GTK_NATIVE (chooser));
|
gtk_native_check_resize (GTK_NATIVE (chooser));
|
||||||
|
|
||||||
if (priv->text_handle)
|
gtk_text_update_handles (self);
|
||||||
{
|
|
||||||
GtkTextHandleMode handle_mode = _gtk_text_handle_get_mode (priv->text_handle);
|
|
||||||
|
|
||||||
if (handle_mode != GTK_TEXT_HANDLE_MODE_NONE)
|
|
||||||
gtk_text_update_handles (self, handle_mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (priv->emoji_completion)
|
if (priv->emoji_completion)
|
||||||
gtk_native_check_resize (GTK_NATIVE (priv->emoji_completion));
|
gtk_native_check_resize (GTK_NATIVE (priv->emoji_completion));
|
||||||
@ -2361,6 +2384,12 @@ gtk_text_size_allocate (GtkWidget *widget,
|
|||||||
|
|
||||||
if (priv->selection_bubble)
|
if (priv->selection_bubble)
|
||||||
gtk_native_check_resize (GTK_NATIVE (priv->selection_bubble));
|
gtk_native_check_resize (GTK_NATIVE (priv->selection_bubble));
|
||||||
|
|
||||||
|
if (priv->text_handles[TEXT_HANDLE_CURSOR])
|
||||||
|
gtk_native_check_resize (GTK_NATIVE (priv->text_handles[TEXT_HANDLE_CURSOR]));
|
||||||
|
|
||||||
|
if (priv->text_handles[TEXT_HANDLE_SELECTION_BOUND])
|
||||||
|
gtk_native_check_resize (GTK_NATIVE (priv->text_handles[TEXT_HANDLE_SELECTION_BOUND]));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2599,7 +2628,6 @@ gtk_text_click_gesture_pressed (GtkGestureClick *gesture,
|
|||||||
else if (button == GDK_BUTTON_PRIMARY)
|
else if (button == GDK_BUTTON_PRIMARY)
|
||||||
{
|
{
|
||||||
gboolean have_selection;
|
gboolean have_selection;
|
||||||
GtkTextHandleMode mode;
|
|
||||||
gboolean is_touchscreen, extend_selection;
|
gboolean is_touchscreen, extend_selection;
|
||||||
GdkDevice *source;
|
GdkDevice *source;
|
||||||
guint state;
|
guint state;
|
||||||
@ -2612,15 +2640,7 @@ gtk_text_click_gesture_pressed (GtkGestureClick *gesture,
|
|||||||
is_touchscreen = gtk_simulate_touchscreen () ||
|
is_touchscreen = gtk_simulate_touchscreen () ||
|
||||||
gdk_device_get_source (source) == GDK_SOURCE_TOUCHSCREEN;
|
gdk_device_get_source (source) == GDK_SOURCE_TOUCHSCREEN;
|
||||||
|
|
||||||
if (!is_touchscreen)
|
priv->text_handles_enabled = is_touchscreen;
|
||||||
mode = GTK_TEXT_HANDLE_MODE_NONE;
|
|
||||||
else if (have_selection)
|
|
||||||
mode = GTK_TEXT_HANDLE_MODE_SELECTION;
|
|
||||||
else
|
|
||||||
mode = GTK_TEXT_HANDLE_MODE_CURSOR;
|
|
||||||
|
|
||||||
if (is_touchscreen)
|
|
||||||
gtk_text_ensure_text_handles (self);
|
|
||||||
|
|
||||||
priv->in_drag = FALSE;
|
priv->in_drag = FALSE;
|
||||||
priv->select_words = FALSE;
|
priv->select_words = FALSE;
|
||||||
@ -2693,15 +2713,11 @@ gtk_text_click_gesture_pressed (GtkGestureClick *gesture,
|
|||||||
case 2:
|
case 2:
|
||||||
priv->select_words = TRUE;
|
priv->select_words = TRUE;
|
||||||
gtk_text_select_word (self);
|
gtk_text_select_word (self);
|
||||||
if (is_touchscreen)
|
|
||||||
mode = GTK_TEXT_HANDLE_MODE_SELECTION;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
priv->select_lines = TRUE;
|
priv->select_lines = TRUE;
|
||||||
gtk_text_select_line (self);
|
gtk_text_select_line (self);
|
||||||
if (is_touchscreen)
|
|
||||||
mode = GTK_TEXT_HANDLE_MODE_SELECTION;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -2733,8 +2749,7 @@ gtk_text_click_gesture_pressed (GtkGestureClick *gesture,
|
|||||||
gtk_gesture_set_state (priv->drag_gesture,
|
gtk_gesture_set_state (priv->drag_gesture,
|
||||||
GTK_EVENT_SEQUENCE_CLAIMED);
|
GTK_EVENT_SEQUENCE_CLAIMED);
|
||||||
|
|
||||||
if (priv->text_handle)
|
gtk_text_update_handles (self);
|
||||||
gtk_text_update_handles (self, mode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n_press >= 3)
|
if (n_press >= 3)
|
||||||
@ -2950,11 +2965,8 @@ gtk_text_drag_gesture_update (GtkGestureDrag *gesture,
|
|||||||
if (gtk_simulate_touchscreen () ||
|
if (gtk_simulate_touchscreen () ||
|
||||||
input_source == GDK_SOURCE_TOUCHSCREEN)
|
input_source == GDK_SOURCE_TOUCHSCREEN)
|
||||||
{
|
{
|
||||||
gtk_text_ensure_text_handles (self);
|
priv->text_handles_enabled = TRUE;
|
||||||
gtk_text_update_handles (self,
|
gtk_text_update_handles (self);
|
||||||
(priv->current_pos == priv->selection_bound) ?
|
|
||||||
GTK_TEXT_HANDLE_MODE_CURSOR :
|
|
||||||
GTK_TEXT_HANDLE_MODE_SELECTION);
|
|
||||||
gtk_text_show_magnifier (self, x - priv->scroll_offset, y);
|
gtk_text_show_magnifier (self, x - priv->scroll_offset, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2967,10 +2979,8 @@ gtk_text_drag_gesture_end (GtkGestureDrag *gesture,
|
|||||||
GtkText *self)
|
GtkText *self)
|
||||||
{
|
{
|
||||||
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
||||||
gboolean in_drag, is_touchscreen;
|
gboolean in_drag;
|
||||||
GdkEventSequence *sequence;
|
GdkEventSequence *sequence;
|
||||||
GdkEvent *event;
|
|
||||||
GdkDevice *source;
|
|
||||||
|
|
||||||
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
|
sequence = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
|
||||||
in_drag = priv->in_drag;
|
in_drag = priv->in_drag;
|
||||||
@ -2983,11 +2993,6 @@ gtk_text_drag_gesture_end (GtkGestureDrag *gesture,
|
|||||||
if (!gtk_gesture_handles_sequence (GTK_GESTURE (gesture), sequence))
|
if (!gtk_gesture_handles_sequence (GTK_GESTURE (gesture), sequence))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), sequence);
|
|
||||||
source = gdk_event_get_source_device (event);
|
|
||||||
is_touchscreen = gtk_simulate_touchscreen () ||
|
|
||||||
gdk_device_get_source (source) == GDK_SOURCE_TOUCHSCREEN;
|
|
||||||
|
|
||||||
if (in_drag)
|
if (in_drag)
|
||||||
{
|
{
|
||||||
int tmp_pos = gtk_text_find_position (self, priv->drag_start_x);
|
int tmp_pos = gtk_text_find_position (self, priv->drag_start_x);
|
||||||
@ -2995,8 +3000,7 @@ gtk_text_drag_gesture_end (GtkGestureDrag *gesture,
|
|||||||
gtk_text_set_selection_bounds (self, tmp_pos, tmp_pos);
|
gtk_text_set_selection_bounds (self, tmp_pos, tmp_pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_touchscreen && priv->selection_bound != priv->current_pos)
|
gtk_text_update_handles (self);
|
||||||
gtk_text_update_handles (self, GTK_TEXT_HANDLE_MODE_CURSOR);
|
|
||||||
|
|
||||||
gtk_text_update_primary_selection (self);
|
gtk_text_update_primary_selection (self);
|
||||||
}
|
}
|
||||||
@ -3029,9 +3033,8 @@ gtk_text_key_controller_key_pressed (GtkEventControllerKey *controller,
|
|||||||
|
|
||||||
gtk_text_selection_bubble_popup_unset (self);
|
gtk_text_selection_bubble_popup_unset (self);
|
||||||
|
|
||||||
if (priv->text_handle)
|
priv->text_handles_enabled = FALSE;
|
||||||
_gtk_text_handle_set_mode (priv->text_handle,
|
gtk_text_update_handles (self);
|
||||||
GTK_TEXT_HANDLE_MODE_NONE);
|
|
||||||
|
|
||||||
if (keyval == GDK_KEY_Return ||
|
if (keyval == GDK_KEY_Return ||
|
||||||
keyval == GDK_KEY_KP_Enter ||
|
keyval == GDK_KEY_KP_Enter ||
|
||||||
@ -3082,9 +3085,8 @@ gtk_text_focus_out (GtkWidget *widget)
|
|||||||
|
|
||||||
gtk_text_selection_bubble_popup_unset (self);
|
gtk_text_selection_bubble_popup_unset (self);
|
||||||
|
|
||||||
if (priv->text_handle)
|
priv->text_handles_enabled = FALSE;
|
||||||
_gtk_text_handle_set_mode (priv->text_handle,
|
gtk_text_update_handles (self);
|
||||||
GTK_TEXT_HANDLE_MODE_NONE);
|
|
||||||
|
|
||||||
gtk_widget_queue_draw (widget);
|
gtk_widget_queue_draw (widget);
|
||||||
|
|
||||||
@ -3957,15 +3959,7 @@ gtk_text_cut_clipboard (GtkText *self)
|
|||||||
|
|
||||||
gtk_text_selection_bubble_popup_unset (self);
|
gtk_text_selection_bubble_popup_unset (self);
|
||||||
|
|
||||||
if (priv->text_handle)
|
gtk_text_update_handles (self);
|
||||||
{
|
|
||||||
GtkTextHandleMode handle_mode;
|
|
||||||
|
|
||||||
handle_mode = _gtk_text_handle_get_mode (priv->text_handle);
|
|
||||||
|
|
||||||
if (handle_mode != GTK_TEXT_HANDLE_MODE_NONE)
|
|
||||||
gtk_text_update_handles (self, GTK_TEXT_HANDLE_MODE_CURSOR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -3978,15 +3972,7 @@ gtk_text_paste_clipboard (GtkText *self)
|
|||||||
else
|
else
|
||||||
gtk_widget_error_bell (GTK_WIDGET (self));
|
gtk_widget_error_bell (GTK_WIDGET (self));
|
||||||
|
|
||||||
if (priv->text_handle)
|
gtk_text_update_handles (self);
|
||||||
{
|
|
||||||
GtkTextHandleMode handle_mode;
|
|
||||||
|
|
||||||
handle_mode = _gtk_text_handle_get_mode (priv->text_handle);
|
|
||||||
|
|
||||||
if (handle_mode != GTK_TEXT_HANDLE_MODE_NONE)
|
|
||||||
gtk_text_update_handles (self, GTK_TEXT_HANDLE_MODE_CURSOR);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -4243,9 +4229,6 @@ gtk_text_reset_layout (GtkText *self)
|
|||||||
static void
|
static void
|
||||||
gtk_text_recompute (GtkText *self)
|
gtk_text_recompute (GtkText *self)
|
||||||
{
|
{
|
||||||
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
|
||||||
GtkTextHandleMode handle_mode;
|
|
||||||
|
|
||||||
gtk_text_reset_layout (self);
|
gtk_text_reset_layout (self);
|
||||||
gtk_text_check_cursor_blink (self);
|
gtk_text_check_cursor_blink (self);
|
||||||
|
|
||||||
@ -4253,13 +4236,7 @@ gtk_text_recompute (GtkText *self)
|
|||||||
|
|
||||||
update_im_cursor_location (self);
|
update_im_cursor_location (self);
|
||||||
|
|
||||||
if (priv->text_handle)
|
gtk_text_update_handles (self);
|
||||||
{
|
|
||||||
handle_mode = _gtk_text_handle_get_mode (priv->text_handle);
|
|
||||||
|
|
||||||
if (handle_mode != GTK_TEXT_HANDLE_MODE_NONE)
|
|
||||||
gtk_text_update_handles (self, handle_mode);
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_widget_queue_draw (GTK_WIDGET (self));
|
gtk_widget_queue_draw (GTK_WIDGET (self));
|
||||||
}
|
}
|
||||||
@ -4543,74 +4520,58 @@ gtk_text_draw_cursor (GtkText *self,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_text_handle_dragged (GtkTextHandle *handle,
|
gtk_text_handle_dragged (GtkTextHandle *handle,
|
||||||
GtkTextHandlePosition pos,
|
|
||||||
int x,
|
int x,
|
||||||
int y,
|
int y,
|
||||||
GtkText *self)
|
GtkText *self)
|
||||||
{
|
{
|
||||||
int cursor_pos, selection_bound_pos, tmp_pos;
|
int cursor_pos, selection_bound_pos, tmp_pos, *old_pos;
|
||||||
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
||||||
GtkTextHandleMode mode;
|
|
||||||
int *min, *max;
|
|
||||||
|
|
||||||
gtk_text_selection_bubble_popup_unset (self);
|
gtk_text_selection_bubble_popup_unset (self);
|
||||||
|
|
||||||
cursor_pos = priv->current_pos;
|
cursor_pos = priv->current_pos;
|
||||||
selection_bound_pos = priv->selection_bound;
|
selection_bound_pos = priv->selection_bound;
|
||||||
mode = _gtk_text_handle_get_mode (handle);
|
|
||||||
|
|
||||||
tmp_pos = gtk_text_find_position (self, x + priv->scroll_offset);
|
tmp_pos = gtk_text_find_position (self, x + priv->scroll_offset);
|
||||||
|
|
||||||
if (mode == GTK_TEXT_HANDLE_MODE_CURSOR ||
|
if (handle == priv->text_handles[TEXT_HANDLE_CURSOR])
|
||||||
cursor_pos >= selection_bound_pos)
|
|
||||||
{
|
{
|
||||||
max = &cursor_pos;
|
/* Avoid running past the other handle in selection mode */
|
||||||
min = &selection_bound_pos;
|
if (tmp_pos >= selection_bound_pos &&
|
||||||
|
gtk_widget_is_visible (GTK_WIDGET (priv->text_handles[TEXT_HANDLE_SELECTION_BOUND])))
|
||||||
|
{
|
||||||
|
tmp_pos = selection_bound_pos - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
old_pos = &cursor_pos;
|
||||||
|
}
|
||||||
|
else if (handle == priv->text_handles[TEXT_HANDLE_SELECTION_BOUND])
|
||||||
|
{
|
||||||
|
/* Avoid running past the other handle */
|
||||||
|
if (tmp_pos <= cursor_pos)
|
||||||
|
tmp_pos = cursor_pos + 1;
|
||||||
|
|
||||||
|
old_pos = &selection_bound_pos;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
g_assert_not_reached ();
|
||||||
max = &selection_bound_pos;
|
|
||||||
min = &cursor_pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pos == GTK_TEXT_HANDLE_POSITION_SELECTION_END)
|
if (tmp_pos != *old_pos)
|
||||||
{
|
{
|
||||||
if (mode == GTK_TEXT_HANDLE_MODE_SELECTION)
|
*old_pos = tmp_pos;
|
||||||
{
|
|
||||||
int min_pos;
|
|
||||||
|
|
||||||
min_pos = MAX (*min + 1, 0);
|
if (handle == priv->text_handles[TEXT_HANDLE_CURSOR] &&
|
||||||
tmp_pos = MAX (tmp_pos, min_pos);
|
!gtk_widget_is_visible (GTK_WIDGET (priv->text_handles[TEXT_HANDLE_SELECTION_BOUND])))
|
||||||
}
|
|
||||||
|
|
||||||
*max = tmp_pos;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (mode == GTK_TEXT_HANDLE_MODE_SELECTION)
|
|
||||||
{
|
|
||||||
int max_pos;
|
|
||||||
|
|
||||||
max_pos = *max - 1;
|
|
||||||
*min = MIN (tmp_pos, max_pos);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cursor_pos != priv->current_pos ||
|
|
||||||
selection_bound_pos != priv->selection_bound)
|
|
||||||
{
|
|
||||||
if (mode == GTK_TEXT_HANDLE_MODE_CURSOR)
|
|
||||||
{
|
|
||||||
priv->cursor_handle_dragged = TRUE;
|
|
||||||
gtk_text_set_positions (self, cursor_pos, cursor_pos);
|
gtk_text_set_positions (self, cursor_pos, cursor_pos);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
priv->selection_handle_dragged = TRUE;
|
|
||||||
gtk_text_set_positions (self, cursor_pos, selection_bound_pos);
|
gtk_text_set_positions (self, cursor_pos, selection_bound_pos);
|
||||||
}
|
|
||||||
|
|
||||||
gtk_text_update_handles (self, mode);
|
if (handle == priv->text_handles[TEXT_HANDLE_CURSOR])
|
||||||
|
priv->cursor_handle_dragged = TRUE;
|
||||||
|
else if (handle == priv->text_handles[TEXT_HANDLE_SELECTION_BOUND])
|
||||||
|
priv->selection_handle_dragged = TRUE;
|
||||||
|
|
||||||
|
gtk_text_update_handles (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_text_show_magnifier (self, x, y);
|
gtk_text_show_magnifier (self, x, y);
|
||||||
@ -4618,7 +4579,6 @@ gtk_text_handle_dragged (GtkTextHandle *handle,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_text_handle_drag_started (GtkTextHandle *handle,
|
gtk_text_handle_drag_started (GtkTextHandle *handle,
|
||||||
GtkTextHandlePosition pos,
|
|
||||||
GtkText *self)
|
GtkText *self)
|
||||||
{
|
{
|
||||||
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
||||||
@ -4629,7 +4589,6 @@ gtk_text_handle_drag_started (GtkTextHandle *handle,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_text_handle_drag_finished (GtkTextHandle *handle,
|
gtk_text_handle_drag_finished (GtkTextHandle *handle,
|
||||||
GtkTextHandlePosition pos,
|
|
||||||
GtkText *self)
|
GtkText *self)
|
||||||
{
|
{
|
||||||
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
||||||
@ -4644,7 +4603,7 @@ gtk_text_handle_drag_finished (GtkTextHandle *handle,
|
|||||||
if (g_get_monotonic_time() - priv->handle_place_time < double_click_time * 1000)
|
if (g_get_monotonic_time() - priv->handle_place_time < double_click_time * 1000)
|
||||||
{
|
{
|
||||||
gtk_text_select_word (self);
|
gtk_text_select_word (self);
|
||||||
gtk_text_update_handles (self, GTK_TEXT_HANDLE_MODE_SELECTION);
|
gtk_text_update_handles (self);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
gtk_text_selection_bubble_popup_set (self);
|
gtk_text_selection_bubble_popup_set (self);
|
||||||
@ -4755,20 +4714,14 @@ static gboolean
|
|||||||
gtk_text_get_is_selection_handle_dragged (GtkText *self)
|
gtk_text_get_is_selection_handle_dragged (GtkText *self)
|
||||||
{
|
{
|
||||||
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
||||||
GtkTextHandlePosition pos;
|
GtkTextHandle *handle;
|
||||||
|
|
||||||
if (!priv->text_handle)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (_gtk_text_handle_get_mode (priv->text_handle) != GTK_TEXT_HANDLE_MODE_SELECTION)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (priv->current_pos >= priv->selection_bound)
|
if (priv->current_pos >= priv->selection_bound)
|
||||||
pos = GTK_TEXT_HANDLE_POSITION_SELECTION_START;
|
handle = priv->text_handles[TEXT_HANDLE_CURSOR];
|
||||||
else
|
else
|
||||||
pos = GTK_TEXT_HANDLE_POSITION_SELECTION_END;
|
handle = priv->text_handles[TEXT_HANDLE_SELECTION_BOUND];
|
||||||
|
|
||||||
return _gtk_text_handle_get_is_dragged (priv->text_handle, pos);
|
return handle && gtk_text_handle_get_is_dragged (handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -4818,7 +4771,6 @@ gtk_text_adjust_scroll (GtkText *self)
|
|||||||
int min_offset, max_offset;
|
int min_offset, max_offset;
|
||||||
int strong_x, weak_x;
|
int strong_x, weak_x;
|
||||||
int strong_xoffset, weak_xoffset;
|
int strong_xoffset, weak_xoffset;
|
||||||
GtkTextHandleMode handle_mode;
|
|
||||||
|
|
||||||
if (!gtk_widget_get_realized (GTK_WIDGET (self)))
|
if (!gtk_widget_get_realized (GTK_WIDGET (self)))
|
||||||
return;
|
return;
|
||||||
@ -4881,13 +4833,7 @@ gtk_text_adjust_scroll (GtkText *self)
|
|||||||
|
|
||||||
g_object_notify_by_pspec (G_OBJECT (self), text_props[PROP_SCROLL_OFFSET]);
|
g_object_notify_by_pspec (G_OBJECT (self), text_props[PROP_SCROLL_OFFSET]);
|
||||||
|
|
||||||
if (priv->text_handle)
|
gtk_text_update_handles (self);
|
||||||
{
|
|
||||||
handle_mode = _gtk_text_handle_get_mode (priv->text_handle);
|
|
||||||
|
|
||||||
if (handle_mode != GTK_TEXT_HANDLE_MODE_NONE)
|
|
||||||
gtk_text_update_handles (self, handle_mode);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -5926,23 +5872,10 @@ show_or_hide_handles (GtkWidget *popover,
|
|||||||
{
|
{
|
||||||
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
|
||||||
gboolean visible;
|
gboolean visible;
|
||||||
GtkTextHandle *handle;
|
|
||||||
GtkTextHandleMode mode;
|
|
||||||
|
|
||||||
visible = gtk_widget_get_visible (popover);
|
visible = gtk_widget_get_visible (popover);
|
||||||
|
priv->text_handles_enabled = !visible;
|
||||||
handle = priv->text_handle;
|
gtk_text_update_handles (self);
|
||||||
mode = _gtk_text_handle_get_mode (handle);
|
|
||||||
|
|
||||||
if (mode == GTK_TEXT_HANDLE_MODE_CURSOR)
|
|
||||||
{
|
|
||||||
_gtk_text_handle_set_visible (handle, GTK_TEXT_HANDLE_POSITION_CURSOR, !visible);
|
|
||||||
}
|
|
||||||
else if (mode == GTK_TEXT_HANDLE_MODE_SELECTION)
|
|
||||||
{
|
|
||||||
_gtk_text_handle_set_visible (handle, GTK_TEXT_HANDLE_POSITION_SELECTION_START, !visible);
|
|
||||||
_gtk_text_handle_set_visible (handle, GTK_TEXT_HANDLE_POSITION_SELECTION_END, !visible);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
1021
gtk/gtktexthandle.c
1021
gtk/gtktexthandle.c
File diff suppressed because it is too large
Load Diff
@ -22,68 +22,27 @@
|
|||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GTK_TYPE_TEXT_HANDLE (_gtk_text_handle_get_type ())
|
#define GTK_TYPE_TEXT_HANDLE (gtk_text_handle_get_type ())
|
||||||
#define GTK_TEXT_HANDLE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GTK_TYPE_TEXT_HANDLE, GtkTextHandle))
|
G_DECLARE_FINAL_TYPE (GtkTextHandle, gtk_text_handle,
|
||||||
#define GTK_TEXT_HANDLE_CLASS(c) (G_TYPE_CHECK_CLASS_CAST ((c), GTK_TYPE_TEXT_HANDLE, GtkTextHandleClass))
|
GTK, TEXT_HANDLE, GtkWidget)
|
||||||
#define GTK_IS_TEXT_HANDLE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GTK_TYPE_TEXT_HANDLE))
|
|
||||||
#define GTK_IS_TEXT_HANDLE_CLASS(o) (G_TYPE_CHECK_CLASS_TYPE ((o), GTK_TYPE_TEXT_HANDLE))
|
|
||||||
#define GTK_TEXT_HANDLE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GTK_TYPE_TEXT_HANDLE, GtkTextHandleClass))
|
|
||||||
|
|
||||||
typedef struct _GtkTextHandle GtkTextHandle;
|
|
||||||
typedef struct _GtkTextHandleClass GtkTextHandleClass;
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
GTK_TEXT_HANDLE_POSITION_CURSOR,
|
GTK_TEXT_HANDLE_ROLE_CURSOR,
|
||||||
GTK_TEXT_HANDLE_POSITION_SELECTION_START,
|
GTK_TEXT_HANDLE_ROLE_SELECTION_START,
|
||||||
GTK_TEXT_HANDLE_POSITION_SELECTION_END = GTK_TEXT_HANDLE_POSITION_CURSOR
|
GTK_TEXT_HANDLE_ROLE_SELECTION_END,
|
||||||
} GtkTextHandlePosition;
|
} GtkTextHandleRole;
|
||||||
|
|
||||||
typedef enum
|
GtkTextHandle * gtk_text_handle_new (GtkWidget *parent);
|
||||||
{
|
|
||||||
GTK_TEXT_HANDLE_MODE_NONE,
|
|
||||||
GTK_TEXT_HANDLE_MODE_CURSOR,
|
|
||||||
GTK_TEXT_HANDLE_MODE_SELECTION
|
|
||||||
} GtkTextHandleMode;
|
|
||||||
|
|
||||||
struct _GtkTextHandle
|
void gtk_text_handle_set_role (GtkTextHandle *handle,
|
||||||
{
|
GtkTextHandleRole role);
|
||||||
GObject parent_instance;
|
GtkTextHandleRole gtk_text_handle_get_role (GtkTextHandle *handle);
|
||||||
gpointer priv;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _GtkTextHandleClass
|
void gtk_text_handle_set_position (GtkTextHandle *handle,
|
||||||
{
|
const GdkRectangle *rect);
|
||||||
GObjectClass parent_class;
|
|
||||||
|
|
||||||
void (* handle_dragged) (GtkTextHandle *handle,
|
gboolean gtk_text_handle_get_is_dragged (GtkTextHandle *handle);
|
||||||
GtkTextHandlePosition pos,
|
|
||||||
gint x,
|
|
||||||
gint y);
|
|
||||||
void (* drag_finished) (GtkTextHandle *handle,
|
|
||||||
GtkTextHandlePosition pos);
|
|
||||||
};
|
|
||||||
|
|
||||||
GType _gtk_text_handle_get_type (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
GtkTextHandle * _gtk_text_handle_new (GtkWidget *parent);
|
|
||||||
|
|
||||||
void _gtk_text_handle_set_mode (GtkTextHandle *handle,
|
|
||||||
GtkTextHandleMode mode);
|
|
||||||
GtkTextHandleMode
|
|
||||||
_gtk_text_handle_get_mode (GtkTextHandle *handle);
|
|
||||||
void _gtk_text_handle_set_position (GtkTextHandle *handle,
|
|
||||||
GtkTextHandlePosition pos,
|
|
||||||
GdkRectangle *rect);
|
|
||||||
void _gtk_text_handle_set_visible (GtkTextHandle *handle,
|
|
||||||
GtkTextHandlePosition pos,
|
|
||||||
gboolean visible);
|
|
||||||
|
|
||||||
gboolean _gtk_text_handle_get_is_dragged (GtkTextHandle *handle,
|
|
||||||
GtkTextHandlePosition pos);
|
|
||||||
void _gtk_text_handle_set_direction (GtkTextHandle *handle,
|
|
||||||
GtkTextHandlePosition pos,
|
|
||||||
GtkTextDirection dir);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -149,6 +149,13 @@
|
|||||||
typedef struct _GtkTextWindow GtkTextWindow;
|
typedef struct _GtkTextWindow GtkTextWindow;
|
||||||
typedef struct _GtkTextPendingScroll GtkTextPendingScroll;
|
typedef struct _GtkTextPendingScroll GtkTextPendingScroll;
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
TEXT_HANDLE_CURSOR,
|
||||||
|
TEXT_HANDLE_SELECTION_BOUND,
|
||||||
|
TEXT_HANDLE_N_HANDLES
|
||||||
|
};
|
||||||
|
|
||||||
struct _GtkTextViewPrivate
|
struct _GtkTextViewPrivate
|
||||||
{
|
{
|
||||||
GtkTextLayout *layout;
|
GtkTextLayout *layout;
|
||||||
@ -161,7 +168,7 @@ struct _GtkTextViewPrivate
|
|||||||
gint dnd_x;
|
gint dnd_x;
|
||||||
gint dnd_y;
|
gint dnd_y;
|
||||||
|
|
||||||
GtkTextHandle *text_handle;
|
GtkTextHandle *text_handles[TEXT_HANDLE_N_HANDLES];
|
||||||
GtkWidget *selection_bubble;
|
GtkWidget *selection_bubble;
|
||||||
guint selection_bubble_timeout_id;
|
guint selection_bubble_timeout_id;
|
||||||
|
|
||||||
@ -273,6 +280,8 @@ struct _GtkTextViewPrivate
|
|||||||
|
|
||||||
guint scroll_after_paste : 1;
|
guint scroll_after_paste : 1;
|
||||||
|
|
||||||
|
guint text_handles_enabled : 1;
|
||||||
|
|
||||||
/* GtkScrollablePolicy needs to be checked when
|
/* GtkScrollablePolicy needs to be checked when
|
||||||
* driving the scrollable adjustment values */
|
* driving the scrollable adjustment values */
|
||||||
guint hscroll_policy : 1;
|
guint hscroll_policy : 1;
|
||||||
@ -565,18 +574,14 @@ static void update_node_ordering (GtkWidget *widget);
|
|||||||
|
|
||||||
/* GtkTextHandle handlers */
|
/* GtkTextHandle handlers */
|
||||||
static void gtk_text_view_handle_drag_started (GtkTextHandle *handle,
|
static void gtk_text_view_handle_drag_started (GtkTextHandle *handle,
|
||||||
GtkTextHandlePosition pos,
|
|
||||||
GtkTextView *text_view);
|
GtkTextView *text_view);
|
||||||
static void gtk_text_view_handle_dragged (GtkTextHandle *handle,
|
static void gtk_text_view_handle_dragged (GtkTextHandle *handle,
|
||||||
GtkTextHandlePosition pos,
|
|
||||||
gint x,
|
gint x,
|
||||||
gint y,
|
gint y,
|
||||||
GtkTextView *text_view);
|
GtkTextView *text_view);
|
||||||
static void gtk_text_view_handle_drag_finished (GtkTextHandle *handle,
|
static void gtk_text_view_handle_drag_finished (GtkTextHandle *handle,
|
||||||
GtkTextHandlePosition pos,
|
|
||||||
GtkTextView *text_view);
|
GtkTextView *text_view);
|
||||||
static void gtk_text_view_update_handles (GtkTextView *text_view,
|
static void gtk_text_view_update_handles (GtkTextView *text_view);
|
||||||
GtkTextHandleMode mode);
|
|
||||||
|
|
||||||
static void gtk_text_view_selection_bubble_popup_unset (GtkTextView *text_view);
|
static void gtk_text_view_selection_bubble_popup_unset (GtkTextView *text_view);
|
||||||
static void gtk_text_view_selection_bubble_popup_set (GtkTextView *text_view);
|
static void gtk_text_view_selection_bubble_popup_set (GtkTextView *text_view);
|
||||||
@ -1719,6 +1724,26 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
|
|||||||
gtk_text_view_activate_misc_insert_emoji);
|
gtk_text_view_activate_misc_insert_emoji);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_gtk_text_view_ensure_text_handles (GtkTextView *text_view)
|
||||||
|
{
|
||||||
|
GtkTextViewPrivate *priv = text_view->priv;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < TEXT_HANDLE_N_HANDLES; i++)
|
||||||
|
{
|
||||||
|
if (priv->text_handles[i])
|
||||||
|
continue;
|
||||||
|
priv->text_handles[i] = gtk_text_handle_new (GTK_WIDGET (text_view));
|
||||||
|
g_signal_connect (priv->text_handles[i], "drag-started",
|
||||||
|
G_CALLBACK (gtk_text_view_handle_drag_started), text_view);
|
||||||
|
g_signal_connect (priv->text_handles[i], "handle-dragged",
|
||||||
|
G_CALLBACK (gtk_text_view_handle_dragged), text_view);
|
||||||
|
g_signal_connect (priv->text_handles[i], "drag-finished",
|
||||||
|
G_CALLBACK (gtk_text_view_handle_drag_finished), text_view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_text_view_init (GtkTextView *text_view)
|
gtk_text_view_init (GtkTextView *text_view)
|
||||||
{
|
{
|
||||||
@ -1848,23 +1873,6 @@ gtk_text_view_get_selection_node (GtkTextView *text_view)
|
|||||||
return text_view->priv->selection_node;
|
return text_view->priv->selection_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
_gtk_text_view_ensure_text_handles (GtkTextView *text_view)
|
|
||||||
{
|
|
||||||
GtkTextViewPrivate *priv = text_view->priv;
|
|
||||||
|
|
||||||
if (priv->text_handle)
|
|
||||||
return;
|
|
||||||
|
|
||||||
priv->text_handle = _gtk_text_handle_new (GTK_WIDGET (text_view));
|
|
||||||
g_signal_connect (priv->text_handle, "drag-started",
|
|
||||||
G_CALLBACK (gtk_text_view_handle_drag_started), text_view);
|
|
||||||
g_signal_connect (priv->text_handle, "handle-dragged",
|
|
||||||
G_CALLBACK (gtk_text_view_handle_dragged), text_view);
|
|
||||||
g_signal_connect (priv->text_handle, "drag-finished",
|
|
||||||
G_CALLBACK (gtk_text_view_handle_drag_finished), text_view);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_gtk_text_view_ensure_magnifier (GtkTextView *text_view)
|
_gtk_text_view_ensure_magnifier (GtkTextView *text_view)
|
||||||
{
|
{
|
||||||
@ -1876,6 +1884,7 @@ _gtk_text_view_ensure_magnifier (GtkTextView *text_view)
|
|||||||
priv->magnifier = _gtk_magnifier_new (GTK_WIDGET (text_view));
|
priv->magnifier = _gtk_magnifier_new (GTK_WIDGET (text_view));
|
||||||
_gtk_magnifier_set_magnification (GTK_MAGNIFIER (priv->magnifier), 2.0);
|
_gtk_magnifier_set_magnification (GTK_MAGNIFIER (priv->magnifier), 2.0);
|
||||||
priv->magnifier_popover = gtk_popover_new ();
|
priv->magnifier_popover = gtk_popover_new ();
|
||||||
|
gtk_popover_set_position (GTK_POPOVER (priv->magnifier_popover), GTK_POS_TOP);
|
||||||
gtk_widget_set_parent (priv->magnifier_popover, GTK_WIDGET (text_view));
|
gtk_widget_set_parent (priv->magnifier_popover, GTK_WIDGET (text_view));
|
||||||
gtk_widget_add_css_class (priv->magnifier_popover, "magnifier");
|
gtk_widget_add_css_class (priv->magnifier_popover, "magnifier");
|
||||||
gtk_popover_set_autohide (GTK_POPOVER (priv->magnifier_popover), FALSE);
|
gtk_popover_set_autohide (GTK_POPOVER (priv->magnifier_popover), FALSE);
|
||||||
@ -2043,8 +2052,7 @@ gtk_text_view_set_buffer (GtkTextView *text_view,
|
|||||||
gtk_text_buffer_add_selection_clipboard (priv->buffer, clipboard);
|
gtk_text_buffer_add_selection_clipboard (priv->buffer, clipboard);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->text_handle)
|
gtk_text_view_update_handles (text_view);
|
||||||
gtk_text_view_update_handles (text_view, GTK_TEXT_HANDLE_MODE_NONE);
|
|
||||||
|
|
||||||
gtk_widget_action_set_enabled (GTK_WIDGET (text_view), "text.undo", can_undo);
|
gtk_widget_action_set_enabled (GTK_WIDGET (text_view), "text.undo", can_undo);
|
||||||
gtk_widget_action_set_enabled (GTK_WIDGET (text_view), "text.redo", can_redo);
|
gtk_widget_action_set_enabled (GTK_WIDGET (text_view), "text.redo", can_redo);
|
||||||
@ -2655,9 +2663,7 @@ gtk_text_view_flush_scroll (GtkTextView *text_view)
|
|||||||
scroll->yalign,
|
scroll->yalign,
|
||||||
TRUE);
|
TRUE);
|
||||||
|
|
||||||
if (text_view->priv->text_handle)
|
gtk_text_view_update_handles (text_view);
|
||||||
gtk_text_view_update_handles (text_view,
|
|
||||||
_gtk_text_handle_get_mode (text_view->priv->text_handle));
|
|
||||||
|
|
||||||
free_pending_scroll (scroll);
|
free_pending_scroll (scroll);
|
||||||
|
|
||||||
@ -3695,6 +3701,9 @@ gtk_text_view_destroy (GtkWidget *widget)
|
|||||||
if (priv->magnifier)
|
if (priv->magnifier)
|
||||||
_gtk_magnifier_set_inspected (GTK_MAGNIFIER (priv->magnifier), NULL);
|
_gtk_magnifier_set_inspected (GTK_MAGNIFIER (priv->magnifier), NULL);
|
||||||
|
|
||||||
|
g_clear_pointer ((GtkWidget **) &priv->text_handles[TEXT_HANDLE_CURSOR], gtk_widget_unparent);
|
||||||
|
g_clear_pointer ((GtkWidget **) &priv->text_handles[TEXT_HANDLE_SELECTION_BOUND], gtk_widget_unparent);
|
||||||
|
|
||||||
GTK_WIDGET_CLASS (gtk_text_view_parent_class)->destroy (widget);
|
GTK_WIDGET_CLASS (gtk_text_view_parent_class)->destroy (widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3737,8 +3746,6 @@ gtk_text_view_finalize (GObject *object)
|
|||||||
|
|
||||||
if (priv->magnifier_popover)
|
if (priv->magnifier_popover)
|
||||||
gtk_widget_destroy (priv->magnifier_popover);
|
gtk_widget_destroy (priv->magnifier_popover);
|
||||||
if (priv->text_handle)
|
|
||||||
g_object_unref (priv->text_handle);
|
|
||||||
g_object_unref (priv->im_context);
|
g_object_unref (priv->im_context);
|
||||||
|
|
||||||
g_free (priv->im_module);
|
g_free (priv->im_module);
|
||||||
@ -4428,6 +4435,12 @@ gtk_text_view_size_allocate (GtkWidget *widget,
|
|||||||
|
|
||||||
if (priv->popup_menu)
|
if (priv->popup_menu)
|
||||||
gtk_native_check_resize (GTK_NATIVE (priv->popup_menu));
|
gtk_native_check_resize (GTK_NATIVE (priv->popup_menu));
|
||||||
|
|
||||||
|
if (priv->text_handles[TEXT_HANDLE_CURSOR])
|
||||||
|
gtk_native_check_resize (GTK_NATIVE (priv->text_handles[TEXT_HANDLE_CURSOR]));
|
||||||
|
|
||||||
|
if (priv->text_handles[TEXT_HANDLE_SELECTION_BOUND])
|
||||||
|
gtk_native_check_resize (GTK_NATIVE (priv->text_handles[TEXT_HANDLE_SELECTION_BOUND]));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -4861,8 +4874,8 @@ _widget_to_text_surface_coords (GtkTextView *text_view,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_text_view_set_handle_position (GtkTextView *text_view,
|
gtk_text_view_set_handle_position (GtkTextView *text_view,
|
||||||
GtkTextIter *iter,
|
GtkTextHandle *handle,
|
||||||
GtkTextHandlePosition pos)
|
GtkTextIter *iter)
|
||||||
{
|
{
|
||||||
GtkTextViewPrivate *priv;
|
GtkTextViewPrivate *priv;
|
||||||
GdkRectangle rect;
|
GdkRectangle rect;
|
||||||
@ -4874,32 +4887,32 @@ gtk_text_view_set_handle_position (GtkTextView *text_view,
|
|||||||
x = rect.x - priv->xoffset;
|
x = rect.x - priv->xoffset;
|
||||||
y = rect.y - priv->yoffset;
|
y = rect.y - priv->yoffset;
|
||||||
|
|
||||||
if (!_gtk_text_handle_get_is_dragged (priv->text_handle, pos) &&
|
if (!gtk_text_handle_get_is_dragged (handle) &&
|
||||||
(x < 0 || x > SCREEN_WIDTH (text_view) ||
|
(x < 0 || x > SCREEN_WIDTH (text_view) ||
|
||||||
y < 0 || y > SCREEN_HEIGHT (text_view)))
|
y < 0 || y > SCREEN_HEIGHT (text_view)))
|
||||||
{
|
{
|
||||||
/* Hide the handle if it's not being manipulated
|
/* Hide the handle if it's not being manipulated
|
||||||
* and fell outside of the visible text area.
|
* and fell outside of the visible text area.
|
||||||
*/
|
*/
|
||||||
_gtk_text_handle_set_visible (priv->text_handle, pos, FALSE);
|
gtk_widget_hide (GTK_WIDGET (handle));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GtkTextDirection dir = GTK_TEXT_DIR_LTR;
|
GtkTextDirection dir = GTK_TEXT_DIR_LTR;
|
||||||
GtkTextAttributes attributes = { 0 };
|
GtkTextAttributes attributes = { 0 };
|
||||||
|
|
||||||
_gtk_text_handle_set_visible (priv->text_handle, pos, TRUE);
|
gtk_widget_show (GTK_WIDGET (handle));
|
||||||
|
|
||||||
rect.x = CLAMP (x, 0, SCREEN_WIDTH (text_view));
|
rect.x = CLAMP (x, 0, SCREEN_WIDTH (text_view));
|
||||||
rect.y = CLAMP (y, 0, SCREEN_HEIGHT (text_view));
|
rect.y = CLAMP (y, 0, SCREEN_HEIGHT (text_view));
|
||||||
_text_window_to_widget_coords (text_view, &rect.x, &rect.y);
|
_text_window_to_widget_coords (text_view, &rect.x, &rect.y);
|
||||||
|
|
||||||
_gtk_text_handle_set_position (priv->text_handle, pos, &rect);
|
gtk_text_handle_set_position (handle, &rect);
|
||||||
|
|
||||||
if (gtk_text_iter_get_attributes (iter, &attributes))
|
if (gtk_text_iter_get_attributes (iter, &attributes))
|
||||||
dir = attributes.direction;
|
dir = attributes.direction;
|
||||||
|
|
||||||
_gtk_text_handle_set_direction (priv->text_handle, pos, dir);
|
gtk_widget_set_direction (GTK_WIDGET (handle), dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4949,22 +4962,16 @@ gtk_text_view_show_magnifier (GtkTextView *text_view,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_text_view_handle_dragged (GtkTextHandle *handle,
|
gtk_text_view_handle_dragged (GtkTextHandle *handle,
|
||||||
GtkTextHandlePosition pos,
|
|
||||||
gint x,
|
gint x,
|
||||||
gint y,
|
gint y,
|
||||||
GtkTextView *text_view)
|
GtkTextView *text_view)
|
||||||
{
|
{
|
||||||
GtkTextViewPrivate *priv;
|
GtkTextViewPrivate *priv;
|
||||||
GtkTextIter old_cursor, old_bound;
|
GtkTextIter cursor, bound, iter, *old_iter;
|
||||||
GtkTextIter cursor, bound, iter;
|
|
||||||
GtkTextIter *min, *max;
|
|
||||||
GtkTextHandleMode mode;
|
|
||||||
GtkTextBuffer *buffer;
|
GtkTextBuffer *buffer;
|
||||||
GtkTextHandlePosition cursor_pos;
|
|
||||||
|
|
||||||
priv = text_view->priv;
|
priv = text_view->priv;
|
||||||
buffer = get_buffer (text_view);
|
buffer = get_buffer (text_view);
|
||||||
mode = _gtk_text_handle_get_mode (handle);
|
|
||||||
|
|
||||||
_widget_to_text_surface_coords (text_view, &x, &y);
|
_widget_to_text_surface_coords (text_view, &x, &y);
|
||||||
|
|
||||||
@ -4972,83 +4979,72 @@ gtk_text_view_handle_dragged (GtkTextHandle *handle,
|
|||||||
gtk_text_layout_get_iter_at_pixel (priv->layout, &iter,
|
gtk_text_layout_get_iter_at_pixel (priv->layout, &iter,
|
||||||
x + priv->xoffset,
|
x + priv->xoffset,
|
||||||
y + priv->yoffset);
|
y + priv->yoffset);
|
||||||
gtk_text_buffer_get_iter_at_mark (buffer, &old_cursor,
|
|
||||||
|
gtk_text_buffer_get_iter_at_mark (buffer, &cursor,
|
||||||
gtk_text_buffer_get_insert (buffer));
|
gtk_text_buffer_get_insert (buffer));
|
||||||
gtk_text_buffer_get_iter_at_mark (buffer, &old_bound,
|
gtk_text_buffer_get_iter_at_mark (buffer, &bound,
|
||||||
gtk_text_buffer_get_selection_bound (buffer));
|
gtk_text_buffer_get_selection_bound (buffer));
|
||||||
cursor = old_cursor;
|
|
||||||
bound = old_bound;
|
|
||||||
|
|
||||||
if (mode == GTK_TEXT_HANDLE_MODE_CURSOR ||
|
|
||||||
gtk_text_iter_compare (&cursor, &bound) >= 0)
|
|
||||||
{
|
|
||||||
cursor_pos = GTK_TEXT_HANDLE_POSITION_CURSOR;
|
|
||||||
max = &cursor;
|
|
||||||
min = &bound;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cursor_pos = GTK_TEXT_HANDLE_POSITION_SELECTION_START;
|
|
||||||
max = &bound;
|
|
||||||
min = &cursor;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pos == GTK_TEXT_HANDLE_POSITION_SELECTION_END)
|
if (handle == priv->text_handles[TEXT_HANDLE_CURSOR])
|
||||||
{
|
{
|
||||||
if (mode == GTK_TEXT_HANDLE_MODE_SELECTION &&
|
/* Avoid running past the other handle in selection mode */
|
||||||
gtk_text_iter_compare (&iter, min) <= 0)
|
if (gtk_text_iter_compare (&iter, &bound) >= 0 &&
|
||||||
|
gtk_widget_is_visible (GTK_WIDGET (priv->text_handles[TEXT_HANDLE_SELECTION_BOUND])))
|
||||||
{
|
{
|
||||||
iter = *min;
|
iter = bound;
|
||||||
gtk_text_iter_forward_char (&iter);
|
|
||||||
}
|
|
||||||
|
|
||||||
*max = iter;
|
|
||||||
gtk_text_view_set_handle_position (text_view, &iter, pos);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (mode == GTK_TEXT_HANDLE_MODE_SELECTION &&
|
|
||||||
gtk_text_iter_compare (&iter, max) >= 0)
|
|
||||||
{
|
|
||||||
iter = *max;
|
|
||||||
gtk_text_iter_backward_char (&iter);
|
gtk_text_iter_backward_char (&iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
*min = iter;
|
old_iter = &cursor;
|
||||||
gtk_text_view_set_handle_position (text_view, &iter, pos);
|
gtk_text_view_set_handle_position (text_view, handle, &iter);
|
||||||
|
}
|
||||||
|
else if (handle == priv->text_handles[TEXT_HANDLE_SELECTION_BOUND])
|
||||||
|
{
|
||||||
|
/* Avoid running past the other handle */
|
||||||
|
if (gtk_text_iter_compare (&iter, &cursor) <= 0)
|
||||||
|
{
|
||||||
|
iter = cursor;
|
||||||
|
gtk_text_iter_forward_char (&iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gtk_text_iter_compare (&old_cursor, &cursor) != 0 ||
|
old_iter = &bound;
|
||||||
gtk_text_iter_compare (&old_bound, &bound) != 0)
|
gtk_text_view_set_handle_position (text_view, handle, &iter);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
g_assert_not_reached ();
|
||||||
|
|
||||||
|
if (gtk_text_iter_compare (&iter, old_iter) != 0)
|
||||||
{
|
{
|
||||||
if (mode == GTK_TEXT_HANDLE_MODE_CURSOR)
|
*old_iter = iter;
|
||||||
|
|
||||||
|
if (handle == priv->text_handles[TEXT_HANDLE_CURSOR] &&
|
||||||
|
!gtk_widget_is_visible (GTK_WIDGET (priv->text_handles[TEXT_HANDLE_SELECTION_BOUND])))
|
||||||
gtk_text_buffer_place_cursor (buffer, &cursor);
|
gtk_text_buffer_place_cursor (buffer, &cursor);
|
||||||
else
|
else
|
||||||
gtk_text_buffer_select_range (buffer, &cursor, &bound);
|
gtk_text_buffer_select_range (buffer, &cursor, &bound);
|
||||||
|
|
||||||
if (_gtk_text_handle_get_is_dragged (priv->text_handle, cursor_pos))
|
if (handle == priv->text_handles[TEXT_HANDLE_CURSOR])
|
||||||
{
|
{
|
||||||
text_view->priv->cursor_handle_dragged = TRUE;
|
text_view->priv->cursor_handle_dragged = TRUE;
|
||||||
gtk_text_view_scroll_mark_onscreen (text_view,
|
gtk_text_view_scroll_mark_onscreen (text_view,
|
||||||
gtk_text_buffer_get_insert (buffer));
|
gtk_text_buffer_get_insert (buffer));
|
||||||
}
|
}
|
||||||
else
|
else if (handle == priv->text_handles[TEXT_HANDLE_SELECTION_BOUND])
|
||||||
{
|
{
|
||||||
text_view->priv->selection_handle_dragged = TRUE;
|
text_view->priv->selection_handle_dragged = TRUE;
|
||||||
gtk_text_view_scroll_mark_onscreen (text_view,
|
gtk_text_view_scroll_mark_onscreen (text_view,
|
||||||
gtk_text_buffer_get_selection_bound (buffer));
|
gtk_text_buffer_get_selection_bound (buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gtk_text_view_update_handles (text_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_gtk_text_handle_get_is_dragged (priv->text_handle, cursor_pos))
|
gtk_text_view_show_magnifier (text_view, &iter, x, y);
|
||||||
gtk_text_view_show_magnifier (text_view, &cursor, x, y);
|
|
||||||
else
|
|
||||||
gtk_text_view_show_magnifier (text_view, &bound, x, y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_text_view_handle_drag_started (GtkTextHandle *handle,
|
gtk_text_view_handle_drag_started (GtkTextHandle *handle,
|
||||||
GtkTextHandlePosition pos,
|
|
||||||
GtkTextView *text_view)
|
GtkTextView *text_view)
|
||||||
{
|
{
|
||||||
text_view->priv->cursor_handle_dragged = FALSE;
|
text_view->priv->cursor_handle_dragged = FALSE;
|
||||||
@ -5057,7 +5053,6 @@ gtk_text_view_handle_drag_started (GtkTextHandle *handle,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_text_view_handle_drag_finished (GtkTextHandle *handle,
|
gtk_text_view_handle_drag_finished (GtkTextHandle *handle,
|
||||||
GtkTextHandlePosition pos,
|
|
||||||
GtkTextView *text_view)
|
GtkTextView *text_view)
|
||||||
{
|
{
|
||||||
GtkTextViewPrivate *priv = text_view->priv;
|
GtkTextViewPrivate *priv = text_view->priv;
|
||||||
@ -5079,7 +5074,7 @@ gtk_text_view_handle_drag_finished (GtkTextHandle *handle,
|
|||||||
extend_selection (text_view, SELECT_WORDS, &cursor, &start, &end);
|
extend_selection (text_view, SELECT_WORDS, &cursor, &start, &end);
|
||||||
gtk_text_buffer_select_range (buffer, &start, &end);
|
gtk_text_buffer_select_range (buffer, &start, &end);
|
||||||
|
|
||||||
gtk_text_view_update_handles (text_view, GTK_TEXT_HANDLE_MODE_SELECTION);
|
gtk_text_view_update_handles (text_view);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
gtk_text_view_selection_bubble_popup_set (text_view);
|
gtk_text_view_selection_bubble_popup_set (text_view);
|
||||||
@ -5092,13 +5087,22 @@ gtk_text_view_handle_drag_finished (GtkTextHandle *handle,
|
|||||||
static gboolean cursor_visible (GtkTextView *text_view);
|
static gboolean cursor_visible (GtkTextView *text_view);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_text_view_update_handles (GtkTextView *text_view,
|
gtk_text_view_update_handles (GtkTextView *text_view)
|
||||||
GtkTextHandleMode mode)
|
|
||||||
{
|
{
|
||||||
GtkTextViewPrivate *priv = text_view->priv;
|
GtkTextViewPrivate *priv = text_view->priv;
|
||||||
GtkTextIter cursor, bound, min, max;
|
GtkTextIter cursor, bound;
|
||||||
GtkTextBuffer *buffer;
|
GtkTextBuffer *buffer;
|
||||||
|
|
||||||
|
if (!priv->text_handles_enabled)
|
||||||
|
{
|
||||||
|
if (priv->text_handles[TEXT_HANDLE_CURSOR])
|
||||||
|
gtk_widget_hide (GTK_WIDGET (priv->text_handles[TEXT_HANDLE_CURSOR]));
|
||||||
|
if (priv->text_handles[TEXT_HANDLE_SELECTION_BOUND])
|
||||||
|
gtk_widget_hide (GTK_WIDGET (priv->text_handles[TEXT_HANDLE_SELECTION_BOUND]));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_gtk_text_view_ensure_text_handles (text_view);
|
||||||
buffer = get_buffer (text_view);
|
buffer = get_buffer (text_view);
|
||||||
|
|
||||||
gtk_text_buffer_get_iter_at_mark (buffer, &cursor,
|
gtk_text_buffer_get_iter_at_mark (buffer, &cursor,
|
||||||
@ -5106,38 +5110,41 @@ gtk_text_view_update_handles (GtkTextView *text_view,
|
|||||||
gtk_text_buffer_get_iter_at_mark (buffer, &bound,
|
gtk_text_buffer_get_iter_at_mark (buffer, &bound,
|
||||||
gtk_text_buffer_get_selection_bound (buffer));
|
gtk_text_buffer_get_selection_bound (buffer));
|
||||||
|
|
||||||
if (mode == GTK_TEXT_HANDLE_MODE_SELECTION &&
|
if (gtk_text_iter_compare (&cursor, &bound) == 0 && priv->editable)
|
||||||
gtk_text_iter_compare (&cursor, &bound) == 0)
|
|
||||||
{
|
{
|
||||||
mode = GTK_TEXT_HANDLE_MODE_CURSOR;
|
/* Cursor mode */
|
||||||
|
gtk_widget_hide (GTK_WIDGET (priv->text_handles[TEXT_HANDLE_SELECTION_BOUND]));
|
||||||
|
|
||||||
|
gtk_text_view_set_handle_position (text_view,
|
||||||
|
priv->text_handles[TEXT_HANDLE_CURSOR],
|
||||||
|
&cursor);
|
||||||
|
gtk_text_handle_set_role (priv->text_handles[TEXT_HANDLE_CURSOR],
|
||||||
|
GTK_TEXT_HANDLE_ROLE_CURSOR);
|
||||||
|
gtk_widget_show (GTK_WIDGET (priv->text_handles[TEXT_HANDLE_CURSOR]));
|
||||||
}
|
}
|
||||||
|
else if (gtk_text_iter_compare (&cursor, &bound) != 0)
|
||||||
if (mode == GTK_TEXT_HANDLE_MODE_CURSOR &&
|
|
||||||
(!gtk_widget_is_sensitive (GTK_WIDGET (text_view)) || !cursor_visible (text_view)))
|
|
||||||
{
|
{
|
||||||
mode = GTK_TEXT_HANDLE_MODE_NONE;
|
/* Selection mode */
|
||||||
}
|
gtk_text_view_set_handle_position (text_view,
|
||||||
|
priv->text_handles[TEXT_HANDLE_CURSOR],
|
||||||
|
&cursor);
|
||||||
|
gtk_text_handle_set_role (priv->text_handles[TEXT_HANDLE_CURSOR],
|
||||||
|
GTK_TEXT_HANDLE_ROLE_SELECTION_START);
|
||||||
|
gtk_widget_show (GTK_WIDGET (priv->text_handles[TEXT_HANDLE_CURSOR]));
|
||||||
|
|
||||||
_gtk_text_handle_set_mode (priv->text_handle, mode);
|
gtk_text_view_set_handle_position (text_view,
|
||||||
|
priv->text_handles[TEXT_HANDLE_SELECTION_BOUND],
|
||||||
if (gtk_text_iter_compare (&cursor, &bound) >= 0)
|
&bound);
|
||||||
{
|
gtk_text_handle_set_role (priv->text_handles[TEXT_HANDLE_SELECTION_BOUND],
|
||||||
min = bound;
|
GTK_TEXT_HANDLE_ROLE_SELECTION_END);
|
||||||
max = cursor;
|
gtk_widget_show (GTK_WIDGET (priv->text_handles[TEXT_HANDLE_SELECTION_BOUND]));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
min = cursor;
|
gtk_widget_hide (GTK_WIDGET (priv->text_handles[TEXT_HANDLE_CURSOR]));
|
||||||
max = bound;
|
gtk_widget_hide (GTK_WIDGET (priv->text_handles[TEXT_HANDLE_SELECTION_BOUND]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode != GTK_TEXT_HANDLE_MODE_NONE)
|
|
||||||
gtk_text_view_set_handle_position (text_view, &max,
|
|
||||||
GTK_TEXT_HANDLE_POSITION_SELECTION_END);
|
|
||||||
|
|
||||||
if (mode == GTK_TEXT_HANDLE_MODE_SELECTION)
|
|
||||||
gtk_text_view_set_handle_position (text_view, &min,
|
|
||||||
GTK_TEXT_HANDLE_POSITION_SELECTION_START);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -5199,9 +5206,8 @@ gtk_text_view_key_controller_key_pressed (GtkEventControllerKey *controller,
|
|||||||
gtk_text_view_reset_blink_time (text_view);
|
gtk_text_view_reset_blink_time (text_view);
|
||||||
gtk_text_view_pend_cursor_blink (text_view);
|
gtk_text_view_pend_cursor_blink (text_view);
|
||||||
|
|
||||||
if (priv->text_handle)
|
text_view->priv->text_handles_enabled = FALSE;
|
||||||
_gtk_text_handle_set_mode (priv->text_handle,
|
gtk_text_view_update_handles (text_view);
|
||||||
GTK_TEXT_HANDLE_MODE_NONE);
|
|
||||||
|
|
||||||
gtk_text_view_selection_bubble_popup_unset (text_view);
|
gtk_text_view_selection_bubble_popup_unset (text_view);
|
||||||
|
|
||||||
@ -5312,7 +5318,6 @@ gtk_text_view_click_gesture_pressed (GtkGestureClick *gesture,
|
|||||||
}
|
}
|
||||||
else if (button == GDK_BUTTON_PRIMARY)
|
else if (button == GDK_BUTTON_PRIMARY)
|
||||||
{
|
{
|
||||||
GtkTextHandleMode handle_mode = GTK_TEXT_HANDLE_MODE_NONE;
|
|
||||||
gboolean extends = FALSE;
|
gboolean extends = FALSE;
|
||||||
GdkModifierType state;
|
GdkModifierType state;
|
||||||
|
|
||||||
@ -5332,8 +5337,7 @@ gtk_text_view_click_gesture_pressed (GtkGestureClick *gesture,
|
|||||||
*/
|
*/
|
||||||
GtkTextIter start, end;
|
GtkTextIter start, end;
|
||||||
|
|
||||||
if (is_touchscreen)
|
priv->text_handles_enabled = is_touchscreen;
|
||||||
handle_mode = GTK_TEXT_HANDLE_MODE_CURSOR;
|
|
||||||
|
|
||||||
get_iter_from_gesture (text_view, GTK_GESTURE (gesture),
|
get_iter_from_gesture (text_view, GTK_GESTURE (gesture),
|
||||||
&iter, NULL, NULL);
|
&iter, NULL, NULL);
|
||||||
@ -5348,12 +5352,11 @@ gtk_text_view_click_gesture_pressed (GtkGestureClick *gesture,
|
|||||||
!gtk_widget_get_visible (priv->selection_bubble))
|
!gtk_widget_get_visible (priv->selection_bubble))
|
||||||
{
|
{
|
||||||
gtk_text_view_selection_bubble_popup_set (text_view);
|
gtk_text_view_selection_bubble_popup_set (text_view);
|
||||||
handle_mode = GTK_TEXT_HANDLE_MODE_NONE;
|
priv->text_handles_enabled = FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gtk_text_view_selection_bubble_popup_unset (text_view);
|
gtk_text_view_selection_bubble_popup_unset (text_view);
|
||||||
handle_mode = GTK_TEXT_HANDLE_MODE_SELECTION;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -5383,11 +5386,6 @@ gtk_text_view_click_gesture_pressed (GtkGestureClick *gesture,
|
|||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
if (is_touchscreen)
|
|
||||||
{
|
|
||||||
handle_mode = GTK_TEXT_HANDLE_MODE_SELECTION;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
gtk_text_view_end_selection_drag (text_view);
|
gtk_text_view_end_selection_drag (text_view);
|
||||||
|
|
||||||
get_iter_from_gesture (text_view, GTK_GESTURE (gesture),
|
get_iter_from_gesture (text_view, GTK_GESTURE (gesture),
|
||||||
@ -5400,8 +5398,7 @@ gtk_text_view_click_gesture_pressed (GtkGestureClick *gesture,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_gtk_text_view_ensure_text_handles (text_view);
|
gtk_text_view_update_handles (text_view);
|
||||||
gtk_text_view_update_handles (text_view, handle_mode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n_press >= 3)
|
if (n_press >= 3)
|
||||||
@ -5468,9 +5465,8 @@ gtk_text_view_focus_out (GtkWidget *widget)
|
|||||||
text_view);
|
text_view);
|
||||||
gtk_text_view_selection_bubble_popup_unset (text_view);
|
gtk_text_view_selection_bubble_popup_unset (text_view);
|
||||||
|
|
||||||
if (priv->text_handle)
|
text_view->priv->text_handles_enabled = FALSE;
|
||||||
_gtk_text_handle_set_mode (priv->text_handle,
|
gtk_text_view_update_handles (text_view);
|
||||||
GTK_TEXT_HANDLE_MODE_NONE);
|
|
||||||
|
|
||||||
if (priv->editable)
|
if (priv->editable)
|
||||||
{
|
{
|
||||||
@ -6840,11 +6836,8 @@ gtk_text_view_buffer_changed_handler (GtkTextBuffer *buffer,
|
|||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GtkTextView *text_view = data;
|
GtkTextView *text_view = data;
|
||||||
GtkTextViewPrivate *priv = text_view->priv;
|
|
||||||
|
|
||||||
if (priv->text_handle)
|
gtk_text_view_update_handles (text_view);
|
||||||
gtk_text_view_update_handles (text_view,
|
|
||||||
_gtk_text_handle_get_mode (priv->text_handle));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -7288,8 +7281,8 @@ gtk_text_view_drag_gesture_update (GtkGestureDrag *gesture,
|
|||||||
|
|
||||||
if (is_touchscreen)
|
if (is_touchscreen)
|
||||||
{
|
{
|
||||||
_gtk_text_view_ensure_text_handles (text_view);
|
text_view->priv->text_handles_enabled = TRUE;
|
||||||
gtk_text_view_update_handles (text_view, GTK_TEXT_HANDLE_MODE_SELECTION);
|
gtk_text_view_update_handles (text_view);
|
||||||
gtk_text_view_show_magnifier (text_view, &cursor, x, y);
|
gtk_text_view_show_magnifier (text_view, &cursor, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7338,7 +7331,6 @@ gtk_text_view_drag_gesture_end (GtkGestureDrag *gesture,
|
|||||||
if (!is_touchscreen && clicked_in_selection &&
|
if (!is_touchscreen && clicked_in_selection &&
|
||||||
!gtk_drag_check_threshold (GTK_WIDGET (text_view), start_x, start_y, x, y))
|
!gtk_drag_check_threshold (GTK_WIDGET (text_view), start_x, start_y, x, y))
|
||||||
{
|
{
|
||||||
GtkTextHandleMode mode = GTK_TEXT_HANDLE_MODE_NONE;
|
|
||||||
GtkTextIter iter;
|
GtkTextIter iter;
|
||||||
|
|
||||||
/* Unselect everything; we clicked inside selection, but
|
/* Unselect everything; we clicked inside selection, but
|
||||||
@ -7351,13 +7343,7 @@ gtk_text_view_drag_gesture_end (GtkGestureDrag *gesture,
|
|||||||
gtk_text_buffer_place_cursor (get_buffer (text_view), &iter);
|
gtk_text_buffer_place_cursor (get_buffer (text_view), &iter);
|
||||||
gtk_text_view_check_cursor_blink (text_view);
|
gtk_text_view_check_cursor_blink (text_view);
|
||||||
|
|
||||||
if (priv->text_handle)
|
gtk_text_view_update_handles (text_view);
|
||||||
{
|
|
||||||
if (is_touchscreen)
|
|
||||||
mode = GTK_TEXT_HANDLE_MODE_CURSOR;
|
|
||||||
|
|
||||||
gtk_text_view_update_handles (text_view, mode);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8094,9 +8080,7 @@ gtk_text_view_value_changed (GtkAdjustment *adjustment,
|
|||||||
*/
|
*/
|
||||||
gtk_text_view_update_im_spot_location (text_view);
|
gtk_text_view_update_im_spot_location (text_view);
|
||||||
|
|
||||||
if (priv->text_handle)
|
gtk_text_view_update_handles (text_view);
|
||||||
gtk_text_view_update_handles (text_view,
|
|
||||||
_gtk_text_handle_get_mode (priv->text_handle));
|
|
||||||
|
|
||||||
if (priv->anchored_children.length > 0)
|
if (priv->anchored_children.length > 0)
|
||||||
gtk_widget_queue_allocate (GTK_WIDGET (text_view));
|
gtk_widget_queue_allocate (GTK_WIDGET (text_view));
|
||||||
@ -8285,9 +8269,7 @@ gtk_text_view_mark_set_handler (GtkTextBuffer *buffer,
|
|||||||
if (need_reset)
|
if (need_reset)
|
||||||
{
|
{
|
||||||
gtk_text_view_reset_im_context (text_view);
|
gtk_text_view_reset_im_context (text_view);
|
||||||
if (text_view->priv->text_handle)
|
gtk_text_view_update_handles (text_view);
|
||||||
gtk_text_view_update_handles (text_view,
|
|
||||||
_gtk_text_handle_get_mode (text_view->priv->text_handle));
|
|
||||||
|
|
||||||
has_selection = gtk_text_buffer_get_selection_bounds (get_buffer (text_view), NULL, NULL);
|
has_selection = gtk_text_buffer_get_selection_bounds (get_buffer (text_view), NULL, NULL);
|
||||||
gtk_css_node_set_visible (text_view->priv->selection_node, has_selection);
|
gtk_css_node_set_visible (text_view->priv->selection_node, has_selection);
|
||||||
@ -8697,21 +8679,10 @@ show_or_hide_handles (GtkWidget *popover,
|
|||||||
GtkTextView *text_view)
|
GtkTextView *text_view)
|
||||||
{
|
{
|
||||||
gboolean visible;
|
gboolean visible;
|
||||||
GtkTextHandle *handle;
|
|
||||||
GtkTextHandleMode mode;
|
|
||||||
|
|
||||||
visible = gtk_widget_get_visible (popover);
|
visible = gtk_widget_get_visible (popover);
|
||||||
|
text_view->priv->text_handles_enabled = !visible;
|
||||||
handle = text_view->priv->text_handle;
|
gtk_text_view_update_handles (text_view);
|
||||||
mode = _gtk_text_handle_get_mode (handle);
|
|
||||||
|
|
||||||
if (!visible)
|
|
||||||
gtk_text_view_update_handles (text_view, mode);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_gtk_text_handle_set_visible (handle, GTK_TEXT_HANDLE_POSITION_SELECTION_START, FALSE);
|
|
||||||
_gtk_text_handle_set_visible (handle, GTK_TEXT_HANDLE_POSITION_SELECTION_END, FALSE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -10335,15 +10335,6 @@ gtk_widget_pick (GtkWidget *widget,
|
|||||||
if (!gtk_widget_can_be_picked (widget, flags))
|
if (!gtk_widget_can_be_picked (widget, flags))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (GTK_IS_WINDOW (widget))
|
|
||||||
{
|
|
||||||
GtkWidget *picked;
|
|
||||||
|
|
||||||
picked = gtk_window_pick_popover (GTK_WINDOW (widget), x, y, flags);
|
|
||||||
if (picked)
|
|
||||||
return picked;
|
|
||||||
}
|
|
||||||
|
|
||||||
return gtk_widget_do_pick (widget, x, y, flags);
|
return gtk_widget_do_pick (widget, x, y, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
403
gtk/gtkwindow.c
403
gtk/gtkwindow.c
@ -170,17 +170,6 @@
|
|||||||
* instead.
|
* instead.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct _GtkWindowPopover GtkWindowPopover;
|
|
||||||
|
|
||||||
struct _GtkWindowPopover
|
|
||||||
{
|
|
||||||
GtkWidget *widget;
|
|
||||||
GtkWidget *parent;
|
|
||||||
GtkPositionType pos;
|
|
||||||
cairo_rectangle_int_t rect;
|
|
||||||
guint clamp_allocation : 1;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
GtkMnemonicHash *mnemonic_hash;
|
GtkMnemonicHash *mnemonic_hash;
|
||||||
@ -195,8 +184,6 @@ typedef struct
|
|||||||
GdkDisplay *display;
|
GdkDisplay *display;
|
||||||
GtkApplication *application;
|
GtkApplication *application;
|
||||||
|
|
||||||
GQueue popovers;
|
|
||||||
|
|
||||||
GdkModifierType mnemonic_modifier;
|
GdkModifierType mnemonic_modifier;
|
||||||
|
|
||||||
gchar *startup_id;
|
gchar *startup_id;
|
||||||
@ -722,37 +709,6 @@ gtk_window_add (GtkContainer *container,
|
|||||||
GTK_CONTAINER_CLASS (gtk_window_parent_class)->add (container, child);
|
GTK_CONTAINER_CLASS (gtk_window_parent_class)->add (container, child);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void popover_get_rect (GtkWindowPopover *popover,
|
|
||||||
GtkWindow *window,
|
|
||||||
cairo_rectangle_int_t *rect);
|
|
||||||
|
|
||||||
GtkWidget *
|
|
||||||
gtk_window_pick_popover (GtkWindow *window,
|
|
||||||
double x,
|
|
||||||
double y,
|
|
||||||
GtkPickFlags flags)
|
|
||||||
{
|
|
||||||
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
|
|
||||||
GList *popovers;
|
|
||||||
|
|
||||||
for (popovers = priv->popovers.tail; popovers; popovers = popovers->prev)
|
|
||||||
{
|
|
||||||
GtkWindowPopover *popover = popovers->data;
|
|
||||||
int dest_x, dest_y;
|
|
||||||
GtkWidget *picked;
|
|
||||||
|
|
||||||
gtk_widget_translate_coordinates (GTK_WIDGET (window), popover->widget,
|
|
||||||
x, y,
|
|
||||||
&dest_x, &dest_y);
|
|
||||||
|
|
||||||
picked = gtk_widget_pick (popover->widget, dest_x, dest_y, flags);
|
|
||||||
if (picked)
|
|
||||||
return picked;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_window_class_init (GtkWindowClass *klass)
|
gtk_window_class_init (GtkWindowClass *klass)
|
||||||
{
|
{
|
||||||
@ -1205,15 +1161,6 @@ gtk_window_close (GtkWindow *window)
|
|||||||
g_object_unref (window);
|
g_object_unref (window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
popover_destroy (GtkWindowPopover *popover)
|
|
||||||
{
|
|
||||||
if (popover->widget && _gtk_widget_get_parent (popover->widget))
|
|
||||||
gtk_widget_unparent (popover->widget);
|
|
||||||
|
|
||||||
g_free (popover);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gtk_window_titlebar_action (GtkWindow *window,
|
gtk_window_titlebar_action (GtkWindow *window,
|
||||||
GdkEvent *event,
|
GdkEvent *event,
|
||||||
@ -2892,12 +2839,6 @@ gtk_window_dispose (GObject *object)
|
|||||||
|
|
||||||
G_OBJECT_CLASS (gtk_window_parent_class)->dispose (object);
|
G_OBJECT_CLASS (gtk_window_parent_class)->dispose (object);
|
||||||
unset_titlebar (window);
|
unset_titlebar (window);
|
||||||
|
|
||||||
while (!g_queue_is_empty (&priv->popovers))
|
|
||||||
{
|
|
||||||
GtkWindowPopover *popover = g_queue_pop_head (&priv->popovers);
|
|
||||||
popover_destroy (popover);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -4813,116 +4754,6 @@ gtk_window_get_remembered_size (GtkWindow *window,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
popover_get_rect (GtkWindowPopover *popover,
|
|
||||||
GtkWindow *window,
|
|
||||||
cairo_rectangle_int_t *rect)
|
|
||||||
{
|
|
||||||
GtkAllocation win_alloc;
|
|
||||||
GtkRequisition req;
|
|
||||||
GtkBorder win_border;
|
|
||||||
gdouble min, max;
|
|
||||||
|
|
||||||
gtk_widget_get_preferred_size (popover->widget, NULL, &req);
|
|
||||||
gtk_widget_get_allocation (GTK_WIDGET (window), &win_alloc);
|
|
||||||
|
|
||||||
get_shadow_width (window, &win_border);
|
|
||||||
win_alloc.x += win_border.left;
|
|
||||||
win_alloc.y += win_border.top;
|
|
||||||
win_alloc.width -= win_border.left + win_border.right;
|
|
||||||
win_alloc.height -= win_border.top + win_border.bottom;
|
|
||||||
|
|
||||||
rect->width = req.width;
|
|
||||||
rect->height = req.height;
|
|
||||||
|
|
||||||
if (popover->pos == GTK_POS_LEFT || popover->pos == GTK_POS_RIGHT)
|
|
||||||
{
|
|
||||||
if (req.height < win_alloc.height &&
|
|
||||||
gtk_widget_get_vexpand (popover->widget))
|
|
||||||
{
|
|
||||||
rect->y = win_alloc.y;
|
|
||||||
rect->height = win_alloc.height;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
min = 0;
|
|
||||||
max = win_alloc.y + win_alloc.height + win_border.bottom - req.height;
|
|
||||||
|
|
||||||
if (popover->clamp_allocation)
|
|
||||||
{
|
|
||||||
min += win_border.top;
|
|
||||||
max -= win_border.bottom;
|
|
||||||
}
|
|
||||||
|
|
||||||
rect->y = CLAMP (popover->rect.y + (popover->rect.height / 2) -
|
|
||||||
(req.height / 2), min, max);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((popover->pos == GTK_POS_LEFT) ==
|
|
||||||
(gtk_widget_get_direction (popover->widget) == GTK_TEXT_DIR_LTR))
|
|
||||||
{
|
|
||||||
rect->x = popover->rect.x - req.width;
|
|
||||||
|
|
||||||
if (rect->x > win_alloc.x && gtk_widget_get_hexpand (popover->widget))
|
|
||||||
{
|
|
||||||
rect->x = win_alloc.x;
|
|
||||||
rect->width = popover->rect.x;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rect->x = popover->rect.x + popover->rect.width;
|
|
||||||
|
|
||||||
if (rect->x + rect->width < win_alloc.x + win_alloc.width &&
|
|
||||||
gtk_widget_get_hexpand (popover->widget))
|
|
||||||
rect->width = win_alloc.x + win_alloc.width - rect->x;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (popover->pos == GTK_POS_TOP || popover->pos == GTK_POS_BOTTOM)
|
|
||||||
{
|
|
||||||
if (req.width < win_alloc.width &&
|
|
||||||
gtk_widget_get_hexpand (popover->widget))
|
|
||||||
{
|
|
||||||
rect->x = win_alloc.x;
|
|
||||||
rect->width = win_alloc.width;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
min = 0;
|
|
||||||
max = win_alloc.x + win_alloc.width + win_border.right - req.width;
|
|
||||||
|
|
||||||
if (popover->clamp_allocation)
|
|
||||||
{
|
|
||||||
min += win_border.left;
|
|
||||||
max -= win_border.right;
|
|
||||||
}
|
|
||||||
|
|
||||||
rect->x = CLAMP (popover->rect.x + (popover->rect.width / 2) -
|
|
||||||
(req.width / 2), min, max);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (popover->pos == GTK_POS_TOP)
|
|
||||||
{
|
|
||||||
rect->y = popover->rect.y - req.height;
|
|
||||||
|
|
||||||
if (rect->y > win_alloc.y &&
|
|
||||||
gtk_widget_get_vexpand (popover->widget))
|
|
||||||
{
|
|
||||||
rect->y = win_alloc.y;
|
|
||||||
rect->height = popover->rect.y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rect->y = popover->rect.y + popover->rect.height;
|
|
||||||
|
|
||||||
if (rect->y + rect->height < win_alloc.y + win_alloc.height &&
|
|
||||||
gtk_widget_get_vexpand (popover->widget))
|
|
||||||
rect->height = win_alloc.y + win_alloc.height - rect->y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
check_scale_changed (GtkWindow *window)
|
check_scale_changed (GtkWindow *window)
|
||||||
{
|
{
|
||||||
@ -5400,24 +5231,6 @@ update_window_style_classes (GtkWindow *window)
|
|||||||
gtk_widget_remove_css_class (widget, "fullscreen");
|
gtk_widget_remove_css_class (widget, "fullscreen");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
popover_size_allocate (GtkWindowPopover *popover,
|
|
||||||
GtkWindow *window)
|
|
||||||
{
|
|
||||||
cairo_rectangle_int_t rect;
|
|
||||||
|
|
||||||
if (!gtk_widget_get_mapped (popover->widget))
|
|
||||||
return;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
if (GTK_IS_POPOVER (popover->widget))
|
|
||||||
gtk_popover_update_position (GTK_POPOVER (popover->widget));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
popover_get_rect (popover, window, &rect);
|
|
||||||
gtk_widget_size_allocate (popover->widget, &rect, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* _gtk_window_set_allocation:
|
/* _gtk_window_set_allocation:
|
||||||
* @window: a #GtkWindow
|
* @window: a #GtkWindow
|
||||||
* @allocation: the original allocation for the window
|
* @allocation: the original allocation for the window
|
||||||
@ -5447,7 +5260,6 @@ _gtk_window_set_allocation (GtkWindow *window,
|
|||||||
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
|
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
|
||||||
GtkAllocation child_allocation;
|
GtkAllocation child_allocation;
|
||||||
GtkBorder window_border = { 0 };
|
GtkBorder window_border = { 0 };
|
||||||
GList *link;
|
|
||||||
|
|
||||||
g_assert (allocation_out != NULL);
|
g_assert (allocation_out != NULL);
|
||||||
|
|
||||||
@ -5496,13 +5308,6 @@ _gtk_window_set_allocation (GtkWindow *window,
|
|||||||
}
|
}
|
||||||
|
|
||||||
*allocation_out = child_allocation;
|
*allocation_out = child_allocation;
|
||||||
|
|
||||||
for (link = priv->popovers.head; link; link = link->next)
|
|
||||||
{
|
|
||||||
GtkWindowPopover *popover = link->data;
|
|
||||||
popover_size_allocate (popover, window);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -5915,24 +5720,6 @@ gtk_window_key_released (GtkWidget *widget,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWindowPopover *
|
|
||||||
_gtk_window_has_popover (GtkWindow *window,
|
|
||||||
GtkWidget *widget)
|
|
||||||
{
|
|
||||||
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
|
|
||||||
GList *link;
|
|
||||||
|
|
||||||
for (link = priv->popovers.head; link; link = link->next)
|
|
||||||
{
|
|
||||||
GtkWindowPopover *popover = link->data;
|
|
||||||
|
|
||||||
if (popover->widget == widget)
|
|
||||||
return popover;
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_window_remove (GtkContainer *container,
|
gtk_window_remove (GtkContainer *container,
|
||||||
GtkWidget *widget)
|
GtkWidget *widget)
|
||||||
@ -5942,8 +5729,6 @@ gtk_window_remove (GtkContainer *container,
|
|||||||
|
|
||||||
if (widget == priv->title_box)
|
if (widget == priv->title_box)
|
||||||
unset_titlebar (window);
|
unset_titlebar (window);
|
||||||
else if (_gtk_window_has_popover (window, widget))
|
|
||||||
_gtk_window_remove_popover (window, widget);
|
|
||||||
else
|
else
|
||||||
GTK_CONTAINER_CLASS (gtk_window_parent_class)->remove (container, widget);
|
GTK_CONTAINER_CLASS (gtk_window_parent_class)->remove (container, widget);
|
||||||
}
|
}
|
||||||
@ -7164,7 +6949,6 @@ gtk_window_snapshot (GtkWidget *widget,
|
|||||||
GtkStyleContext *context;
|
GtkStyleContext *context;
|
||||||
GtkBorder window_border;
|
GtkBorder window_border;
|
||||||
gint title_height;
|
gint title_height;
|
||||||
GList *l;
|
|
||||||
int width, height;
|
int width, height;
|
||||||
GtkWidget *child;
|
GtkWidget *child;
|
||||||
|
|
||||||
@ -7243,12 +7027,6 @@ gtk_window_snapshot (GtkWidget *widget,
|
|||||||
if (!GTK_IS_POPOVER (child))
|
if (!GTK_IS_POPOVER (child))
|
||||||
gtk_widget_snapshot_child (widget, child, snapshot);
|
gtk_widget_snapshot_child (widget, child, snapshot);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (l = priv->popovers.head; l; l = l->next)
|
|
||||||
{
|
|
||||||
GtkWindowPopover *data = l->data;
|
|
||||||
gtk_widget_snapshot_child (widget, data->widget, snapshot);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -8292,187 +8070,6 @@ _gtk_window_get_shadow_width (GtkWindow *window,
|
|||||||
get_shadow_width (window, border);
|
get_shadow_width (window, border);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
_gtk_window_add_popover (GtkWindow *window,
|
|
||||||
GtkWidget *popover,
|
|
||||||
GtkWidget *parent,
|
|
||||||
gboolean clamp_allocation)
|
|
||||||
{
|
|
||||||
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
|
|
||||||
GtkWindowPopover *data;
|
|
||||||
AtkObject *accessible;
|
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_WINDOW (window));
|
|
||||||
g_return_if_fail (GTK_IS_WIDGET (popover));
|
|
||||||
g_return_if_fail (GTK_IS_WIDGET (parent));
|
|
||||||
g_return_if_fail (_gtk_widget_get_parent (popover) == NULL);
|
|
||||||
g_return_if_fail (gtk_widget_is_ancestor (parent, GTK_WIDGET (window)));
|
|
||||||
|
|
||||||
if (_gtk_window_has_popover (window, popover))
|
|
||||||
return;
|
|
||||||
|
|
||||||
data = g_new0 (GtkWindowPopover, 1);
|
|
||||||
data->widget = popover;
|
|
||||||
data->parent = parent;
|
|
||||||
data->clamp_allocation = !!clamp_allocation;
|
|
||||||
g_queue_push_head (&priv->popovers, data);
|
|
||||||
|
|
||||||
gtk_widget_set_parent (popover, GTK_WIDGET (window));
|
|
||||||
|
|
||||||
accessible = gtk_widget_get_accessible (GTK_WIDGET (window));
|
|
||||||
_gtk_container_accessible_add_child (GTK_CONTAINER_ACCESSIBLE (accessible),
|
|
||||||
gtk_widget_get_accessible (popover), -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
_gtk_window_remove_popover (GtkWindow *window,
|
|
||||||
GtkWidget *popover)
|
|
||||||
{
|
|
||||||
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
|
|
||||||
GtkWindowPopover *data;
|
|
||||||
AtkObject *accessible;
|
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_WINDOW (window));
|
|
||||||
g_return_if_fail (GTK_IS_WIDGET (popover));
|
|
||||||
|
|
||||||
data = _gtk_window_has_popover (window, popover);
|
|
||||||
|
|
||||||
if (!data)
|
|
||||||
return;
|
|
||||||
|
|
||||||
g_object_ref (popover);
|
|
||||||
gtk_widget_unparent (popover);
|
|
||||||
|
|
||||||
g_queue_remove (&priv->popovers, data);
|
|
||||||
|
|
||||||
accessible = gtk_widget_get_accessible (GTK_WIDGET (window));
|
|
||||||
_gtk_container_accessible_remove_child (GTK_CONTAINER_ACCESSIBLE (accessible),
|
|
||||||
gtk_widget_get_accessible (popover), -1);
|
|
||||||
popover_destroy (data);
|
|
||||||
g_object_unref (popover);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
_gtk_window_set_popover_position (GtkWindow *window,
|
|
||||||
GtkWidget *popover,
|
|
||||||
GtkPositionType pos,
|
|
||||||
const cairo_rectangle_int_t *rect)
|
|
||||||
{
|
|
||||||
GtkWindowPopover *data;
|
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_WINDOW (window));
|
|
||||||
g_return_if_fail (GTK_IS_WIDGET (popover));
|
|
||||||
|
|
||||||
data = _gtk_window_has_popover (window, popover);
|
|
||||||
|
|
||||||
if (!data)
|
|
||||||
{
|
|
||||||
g_warning ("Widget %s(%p) is not a popover of window %s(%p)",
|
|
||||||
gtk_widget_get_name (popover), popover,
|
|
||||||
gtk_widget_get_name (GTK_WIDGET (window)), window);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
data->rect = *rect;
|
|
||||||
data->pos = pos;
|
|
||||||
gtk_widget_queue_resize (popover);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
_gtk_window_get_popover_position (GtkWindow *window,
|
|
||||||
GtkWidget *popover,
|
|
||||||
GtkPositionType *pos,
|
|
||||||
cairo_rectangle_int_t *rect)
|
|
||||||
{
|
|
||||||
GtkWindowPopover *data;
|
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_WINDOW (window));
|
|
||||||
g_return_if_fail (GTK_IS_WIDGET (popover));
|
|
||||||
|
|
||||||
data = _gtk_window_has_popover (window, popover);
|
|
||||||
|
|
||||||
if (!data)
|
|
||||||
{
|
|
||||||
g_warning ("Widget %s(%p) is not a popover of window %s(%p)",
|
|
||||||
gtk_widget_get_name (popover), popover,
|
|
||||||
gtk_widget_get_name (GTK_WIDGET (window)), window);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pos)
|
|
||||||
*pos = data->pos;
|
|
||||||
|
|
||||||
if (rect)
|
|
||||||
*rect = data->rect;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*<private>
|
|
||||||
* _gtk_window_get_popover_parent:
|
|
||||||
* @window: A #GtkWindow
|
|
||||||
* @popover: A popover #GtkWidget
|
|
||||||
*
|
|
||||||
* Returns the conceptual parent of this popover, the real
|
|
||||||
* parent will always be @window.
|
|
||||||
*
|
|
||||||
* Returns: (nullable): The conceptual parent widget, or %NULL.
|
|
||||||
**/
|
|
||||||
GtkWidget *
|
|
||||||
_gtk_window_get_popover_parent (GtkWindow *window,
|
|
||||||
GtkWidget *popover)
|
|
||||||
{
|
|
||||||
GtkWindowPopover *data;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GTK_IS_WINDOW (window), NULL);
|
|
||||||
g_return_val_if_fail (GTK_IS_WIDGET (popover), NULL);
|
|
||||||
|
|
||||||
data = _gtk_window_has_popover (window, popover);
|
|
||||||
|
|
||||||
if (data && data->parent)
|
|
||||||
return data->parent;
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*<private>
|
|
||||||
* _gtk_window_is_popover_widget:
|
|
||||||
* @window: A #GtkWindow
|
|
||||||
* @possible_popover: A possible popover of @window
|
|
||||||
*
|
|
||||||
* Returns #TRUE if @possible_popover is a popover of @window.
|
|
||||||
*
|
|
||||||
* Returns: Whether the widget is a popover of @window
|
|
||||||
**/
|
|
||||||
gboolean
|
|
||||||
_gtk_window_is_popover_widget (GtkWindow *window,
|
|
||||||
GtkWidget *possible_popover)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE);
|
|
||||||
g_return_val_if_fail (GTK_IS_WIDGET (possible_popover), FALSE);
|
|
||||||
|
|
||||||
return _gtk_window_has_popover (window, possible_popover) != NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
_gtk_window_raise_popover (GtkWindow *window,
|
|
||||||
GtkWidget *widget)
|
|
||||||
{
|
|
||||||
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
|
|
||||||
GList *link;
|
|
||||||
|
|
||||||
for (link = priv->popovers.head; link; link = link->next)
|
|
||||||
{
|
|
||||||
GtkWindowPopover *popover = link->data;
|
|
||||||
|
|
||||||
if (popover->widget != widget)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
g_queue_unlink (&priv->popovers, link);
|
|
||||||
g_queue_push_tail (&priv->popovers, link->data);
|
|
||||||
g_list_free (link);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void set_warn_again (gboolean warn);
|
static void set_warn_again (gboolean warn);
|
||||||
static void gtk_window_set_debugging (GdkDisplay *display,
|
static void gtk_window_set_debugging (GdkDisplay *display,
|
||||||
gboolean enable,
|
gboolean enable,
|
||||||
|
@ -89,28 +89,6 @@ GtkWindowGroup *_gtk_window_get_window_group (GtkWindow *window);
|
|||||||
void _gtk_window_set_window_group (GtkWindow *window,
|
void _gtk_window_set_window_group (GtkWindow *window,
|
||||||
GtkWindowGroup *group);
|
GtkWindowGroup *group);
|
||||||
|
|
||||||
/* Popovers */
|
|
||||||
void _gtk_window_add_popover (GtkWindow *window,
|
|
||||||
GtkWidget *popover,
|
|
||||||
GtkWidget *popover_parent,
|
|
||||||
gboolean clamp_allocation);
|
|
||||||
void _gtk_window_remove_popover (GtkWindow *window,
|
|
||||||
GtkWidget *popover);
|
|
||||||
void _gtk_window_set_popover_position (GtkWindow *window,
|
|
||||||
GtkWidget *popover,
|
|
||||||
GtkPositionType pos,
|
|
||||||
const cairo_rectangle_int_t *rect);
|
|
||||||
void _gtk_window_get_popover_position (GtkWindow *window,
|
|
||||||
GtkWidget *popover,
|
|
||||||
GtkPositionType *pos,
|
|
||||||
cairo_rectangle_int_t *rect);
|
|
||||||
void _gtk_window_raise_popover (GtkWindow *window,
|
|
||||||
GtkWidget *popover);
|
|
||||||
|
|
||||||
GtkWidget * _gtk_window_get_popover_parent (GtkWindow *window,
|
|
||||||
GtkWidget *popover);
|
|
||||||
gboolean _gtk_window_is_popover_widget (GtkWindow *window,
|
|
||||||
GtkWidget *popover);
|
|
||||||
|
|
||||||
GdkPaintable * gtk_window_get_icon_for_size (GtkWindow *window,
|
GdkPaintable * gtk_window_get_icon_for_size (GtkWindow *window,
|
||||||
int size);
|
int size);
|
||||||
|
Loading…
Reference in New Issue
Block a user