Skip to content
Permalink
Browse files

st-entry: Implement middle click paste

  • Loading branch information
magcius committed Nov 9, 2011
1 parent 0616261 commit eaf184b5852825d49c85c683bd7bde96df02baf2
Showing with 35 additions and 0 deletions.
  1. +35 −0 src/st/st-entry.c
@@ -541,6 +541,38 @@ st_entry_clipboard_callback (StClipboard *clipboard,
clutter_text_insert_text (ctext, text, cursor_pos);
}

static gboolean
clutter_text_button_press_event (ClutterActor *actor,
ClutterButtonEvent *event,
gpointer user_data)
{
GtkSettings *settings = gtk_settings_get_default ();
gboolean primary_paste_enabled;

g_object_get (settings,
"gtk-enable-primary-paste", &primary_paste_enabled,
NULL);

if (primary_paste_enabled && event->button == 2)
{
StClipboard *clipboard;

clipboard = st_clipboard_get_default ();

/* By the time the clipboard callback is called,
* the rest of the signal handlers will have
* run, making the text cursor to be in the correct
* place.
*/
st_clipboard_get_text (clipboard,
ST_CLIPBOARD_TYPE_PRIMARY,
st_entry_clipboard_callback,
user_data);
}

return FALSE;
}

static gboolean
st_entry_key_press_event (ClutterActor *actor,
ClutterKeyEvent *event)
@@ -755,6 +787,9 @@ st_entry_init (StEntry *entry)
g_signal_connect (priv->entry, "notify::password-char",
G_CALLBACK (clutter_text_password_char_cb), entry);

g_signal_connect (priv->entry, "button-press-event",
G_CALLBACK (clutter_text_button_press_event), entry);

priv->spacing = 6.0f;

clutter_actor_add_child (CLUTTER_ACTOR (entry), priv->entry);

0 comments on commit eaf184b

Please sign in to comment.
You can’t perform that action at this time.