Browse Source

Catch pastes into GtkEntry.

Signed-off-by: Bradley Smith <[email protected]>
Bradley Smith 15 years ago
parent
commit
0862cbd602
3 changed files with 30 additions and 0 deletions
  1. 9 0
      src/mssh-terminal.c
  2. 1 0
      src/mssh-terminal.h
  3. 20 0
      src/mssh-window.c

+ 9 - 0
src/mssh-terminal.c

@@ -61,6 +61,15 @@ void mssh_terminal_send_host(MSSHTerminal *terminal)
 	}
 }
 
+void mssh_terminal_send_string(MSSHTerminal *terminal, gchar *string)
+{
+	if(mssh_terminal_isactive(terminal))
+	{
+		vte_terminal_feed_child(VTE_TERMINAL(terminal),	string,
+			strlen(string));
+	}
+}
+
 void mssh_terminal_send_data(MSSHTerminal *terminal, GdkEventKey *event)
 {
 	gboolean dummy;

+ 1 - 0
src/mssh-terminal.h

@@ -43,6 +43,7 @@ gboolean mssh_terminal_isactive(MSSHTerminal *terminal);
 void mssh_terminal_init_session(MSSHTerminal *terminal, char *hostname);
 void mssh_terminal_start_session(MSSHTerminal *terminal, char **env);
 void mssh_terminal_send_host(MSSHTerminal *terminal);
+void mssh_terminal_send_string(MSSHTerminal *terminal, gchar *string);
 void mssh_terminal_send_data(MSSHTerminal *terminal, GdkEventKey *event);
 
 G_END_DECLS

+ 20 - 0
src/mssh-window.c

@@ -21,6 +21,8 @@ static void mssh_window_session_closed(MSSHTerminal *terminal,
 	gpointer data);
 static void mssh_window_session_focused(MSSHTerminal *terminal,
 	gpointer data);
+static void mssh_window_insert(GtkWidget *widget, gchar *new_text,
+	gint new_text_length, gint *position, gpointer data);
 static void mssh_window_relayout(MSSHWindow *window);
 static void mssh_window_add_session(MSSHWindow *window, char *hostname);
 static void mssh_window_init(MSSHWindow* window);
@@ -100,6 +102,22 @@ static void mssh_window_pref(GtkWidget *widget, gpointer data)
 	gtk_widget_show_all(pref);
 }
 
+static void mssh_window_insert(GtkWidget *widget, gchar *new_text,
+	gint new_text_length, gint *position, gpointer data)
+{
+	int i;
+
+	MSSHWindow *window = MSSH_WINDOW(data);
+
+	for(i = 0; i < window->terminals->len; i++)
+	{
+		mssh_terminal_send_string(g_array_index(window->terminals,
+			MSSHTerminal*, i), new_text);
+	}
+
+	g_signal_stop_emission_by_name(G_OBJECT(widget), "insert-text");
+}
+
 static gboolean mssh_window_key_press(GtkWidget *widget,
 	GdkEventKey *event, gpointer data)
 {
@@ -294,6 +312,8 @@ static void mssh_window_init(MSSHWindow* window)
 
 	g_signal_connect(G_OBJECT(entry), "key-press-event",
 		G_CALLBACK(mssh_window_key_press), window);
+	g_signal_connect(G_OBJECT(entry), "insert-text",
+		G_CALLBACK(mssh_window_insert), window);
 	g_signal_connect(G_OBJECT(entry), "focus-in-event",
 		G_CALLBACK(mssh_window_entry_focused), window);