65
65
#include "st-clipboard.h"
66
66
#include "st-private.h"
68
#include <clutter/x11/clutter-x11.h>
70
#include <X11/cursorfont.h>
68
72
#include "st-widget-accessible.h"
70
74
#define HAS_FOCUS(actor) (clutter_actor_get_stage (actor) && clutter_stage_get_key_focus ((ClutterStage *) clutter_actor_get_stage (actor)) == actor)
131
138
st_entry_set_text (entry, g_value_get_string (value));
141
case PROP_INPUT_PURPOSE:
142
st_entry_set_input_purpose (entry, g_value_get_enum (value));
145
case PROP_INPUT_HINTS:
146
st_entry_set_input_hints (entry, g_value_get_flags (value));
135
150
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
159
174
g_value_set_string (value, clutter_text_get_text (CLUTTER_TEXT (priv->entry)));
177
case PROP_INPUT_PURPOSE:
178
g_value_set_enum (value, st_im_text_get_input_purpose (ST_IM_TEXT (priv->entry)));
181
case PROP_INPUT_HINTS:
182
g_value_set_flags (value, st_im_text_get_input_hints (ST_IM_TEXT (priv->entry)));
163
186
G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
564
clutter_text_button_press_event (ClutterActor *actor,
565
ClutterButtonEvent *event,
568
GtkSettings *settings = gtk_settings_get_default ();
569
gboolean primary_paste_enabled;
571
g_object_get (settings,
572
"gtk-enable-primary-paste", &primary_paste_enabled,
575
if (primary_paste_enabled && event->button == 2)
577
StClipboard *clipboard;
579
clipboard = st_clipboard_get_default ();
581
/* By the time the clipboard callback is called,
582
* the rest of the signal handlers will have
583
* run, making the text cursor to be in the correct
586
st_clipboard_get_text (clipboard,
587
ST_CLIPBOARD_TYPE_PRIMARY,
588
st_entry_clipboard_callback,
541
596
st_entry_key_press_event (ClutterActor *actor,
542
597
ClutterKeyEvent *event)
556
611
clipboard = st_clipboard_get_default ();
558
st_clipboard_get_text (clipboard, st_entry_clipboard_callback, actor);
613
st_clipboard_get_text (clipboard,
614
ST_CLIPBOARD_TYPE_CLIPBOARD,
615
st_entry_clipboard_callback,
564
622
if ((event->modifier_state & CLUTTER_CONTROL_MASK)
565
&& event->keyval == CLUTTER_c)
623
&& event->keyval == CLUTTER_c &&
624
clutter_text_get_password_char ((ClutterText*) priv->entry) == 0)
567
626
StClipboard *clipboard;
572
631
text = clutter_text_get_selection ((ClutterText*) priv->entry);
574
633
if (text && strlen (text))
575
st_clipboard_set_text (clipboard, text);
634
st_clipboard_set_text (clipboard,
635
ST_CLIPBOARD_TYPE_CLIPBOARD,
592
654
if (text && strlen (text))
594
st_clipboard_set_text (clipboard, text);
656
st_clipboard_set_text (clipboard,
657
ST_CLIPBOARD_TYPE_CLIPBOARD,
596
660
/* now delete the text */
597
661
clutter_text_delete_selection ((ClutterText *) priv->entry);
681
st_entry_set_cursor (StEntry *entry,
685
ClutterActor *stage, *actor = CLUTTER_ACTOR (entry);
687
static Cursor ibeam = None;
689
dpy = clutter_x11_get_default_display ();
690
stage = clutter_actor_get_stage (actor);
694
g_warn_if_fail (!entry->priv->has_ibeam);
698
wid = clutter_x11_get_stage_window (CLUTTER_STAGE (stage));
701
ibeam = XCreateFontCursor (dpy, XC_xterm);
704
XDefineCursor (dpy, wid, ibeam);
706
XUndefineCursor (dpy, wid);
708
entry->priv->has_ibeam = use_ibeam;
712
st_entry_crossing_event (ClutterActor *actor,
713
ClutterCrossingEvent *event)
715
if (event->source == ST_ENTRY (actor)->priv->entry && event->related != NULL)
716
st_entry_set_cursor (ST_ENTRY (actor), (event->type == CLUTTER_ENTER));
722
st_entry_unmap (ClutterActor *actor)
724
if (ST_ENTRY (actor)->priv->has_ibeam)
725
st_entry_set_cursor (ST_ENTRY (actor), FALSE);
727
CLUTTER_ACTOR_CLASS (st_entry_parent_class)->unmap (actor);
617
731
st_entry_class_init (StEntryClass *klass)
619
733
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
631
745
actor_class->get_preferred_width = st_entry_get_preferred_width;
632
746
actor_class->get_preferred_height = st_entry_get_preferred_height;
633
747
actor_class->allocate = st_entry_allocate;
748
actor_class->unmap = st_entry_unmap;
635
750
actor_class->key_press_event = st_entry_key_press_event;
636
751
actor_class->key_focus_in = st_entry_key_focus_in;
753
actor_class->enter_event = st_entry_crossing_event;
754
actor_class->leave_event = st_entry_crossing_event;
638
756
widget_class->style_changed = st_entry_style_changed;
639
757
widget_class->navigate_focus = st_entry_navigate_focus;
640
758
widget_class->get_accessible_type = st_entry_accessible_get_type;
659
777
NULL, G_PARAM_READWRITE);
660
778
g_object_class_install_property (gobject_class, PROP_TEXT, pspec);
780
pspec = g_param_spec_enum ("input-purpose",
782
"Purpose of the text field",
783
GTK_TYPE_INPUT_PURPOSE,
784
GTK_INPUT_PURPOSE_FREE_FORM,
785
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
786
g_object_class_install_property (gobject_class,
790
pspec = g_param_spec_flags ("input-hints",
792
"Hints for the text field behaviour",
793
GTK_TYPE_INPUT_HINTS,
795
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
796
g_object_class_install_property (gobject_class,
664
802
* StEntry::primary-icon-clicked:
709
847
g_signal_connect (priv->entry, "notify::password-char",
710
848
G_CALLBACK (clutter_text_password_char_cb), entry);
850
g_signal_connect (priv->entry, "button-press-event",
851
G_CALLBACK (clutter_text_button_press_event), entry);
712
853
priv->spacing = 6.0f;
714
855
clutter_actor_add_child (CLUTTER_ACTOR (entry), priv->entry);
863
1004
return entry->priv->hint;
1008
* st_entry_set_input_purpose:
1009
* @entry: a #StEntry
1010
* @purpose: the purpose
1012
* Sets the #StEntry:input-purpose property which
1013
* can be used by on-screen keyboards and other input
1014
* methods to adjust their behaviour.
1017
st_entry_set_input_purpose (StEntry *entry,
1018
GtkInputPurpose purpose)
1022
g_return_if_fail (ST_IS_ENTRY (entry));
1024
imtext = ST_IM_TEXT (entry->priv->entry);
1026
if (st_im_text_get_input_purpose (imtext) != purpose)
1028
st_im_text_set_input_purpose (imtext, purpose);
1030
g_object_notify (G_OBJECT (entry), "input-purpose");
1035
* st_entry_get_input_purpose:
1036
* @entry: a #StEntry
1038
* Gets the value of the #StEntry:input-purpose property.
1041
st_entry_get_input_purpose (StEntry *entry)
1043
g_return_val_if_fail (ST_IS_ENTRY (entry), GTK_INPUT_PURPOSE_FREE_FORM);
1045
return st_im_text_get_input_purpose (ST_IM_TEXT (entry->priv->entry));
1049
* st_entry_set_input_hints:
1050
* @entry: a #StEntry
1053
* Sets the #StEntry:input-hints property, which
1054
* allows input methods to fine-tune their behaviour.
1057
st_entry_set_input_hints (StEntry *entry,
1058
GtkInputHints hints)
1062
g_return_if_fail (ST_IS_ENTRY (entry));
1064
imtext = ST_IM_TEXT (entry->priv->entry);
1066
if (st_im_text_get_input_hints (imtext) != hints)
1068
st_im_text_set_input_hints (imtext, hints);
1070
g_object_notify (G_OBJECT (entry), "input-hints");
1075
* st_entry_get_input_hints:
1076
* @entry: a #StEntry
1078
* Gets the value of the #StEntry:input-hints property.
1081
st_entry_get_input_hints (StEntry *entry)
1083
g_return_val_if_fail (ST_IS_ENTRY (entry), GTK_INPUT_HINT_NONE);
1085
return st_im_text_get_input_hints (ST_IM_TEXT (entry->priv->entry));
867
1089
_st_entry_icon_press_cb (ClutterActor *actor,
868
1090
ClutterButtonEvent *event,