Selaa lähdekoodia

Add option to send hostname.

Signed-off-by: Bradley Smith <[email protected]>
Bradley Smith 15 vuotta sitten
vanhempi
säilyke
979dbe0b11
2 muutettua tiedostoa jossa 27 lisäystä ja 0 poistoa
  1. 26 0
      src/mssh-window.c
  2. 1 0
      src/mssh-window.h

+ 26 - 0
src/mssh-window.c

@@ -7,6 +7,26 @@
 
 G_DEFINE_TYPE(MSSHWindow, mssh_window, GTK_TYPE_WINDOW)
 
+static void mssh_window_sendhost(GtkWidget *widget, gpointer data)
+{
+	int i;
+
+	MSSHWindow *window = MSSH_WINDOW(data);
+
+	for(i = 0; i < window->num_servers; i++)
+	{
+		if(window->terms[i] != NULL)
+		{
+			if(gtk_check_menu_item_get_active(
+				GTK_CHECK_MENU_ITEM(window->items[i])))
+			{
+				vte_terminal_feed_child(VTE_TERMINAL(window->terms[i]),
+					window->servers[i], strlen(window->servers[i]));
+			}
+		}
+	}
+}
+
 static void mssh_window_destroy(GtkWidget *widget, gpointer data)
 {
 	gtk_main_quit();
@@ -72,14 +92,20 @@ static void mssh_window_init(MSSHWindow* window)
 	window->file_item = gtk_menu_item_new_with_label("File");
 	window->file_quit = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT,
 		NULL);
+	window->file_sendhost = gtk_image_menu_item_new_with_label(
+		"Send hostname");
 
 	gtk_menu_item_set_submenu(GTK_MENU_ITEM(window->file_item),
 		window->file_menu);
 	gtk_menu_item_set_submenu(GTK_MENU_ITEM(window->server_item),
 		window->server_menu);
 
+	gtk_menu_shell_append(GTK_MENU_SHELL(window->file_menu),
+		window->file_sendhost);
 	gtk_menu_shell_append(GTK_MENU_SHELL(window->file_menu),
 		window->file_quit);
+	g_signal_connect(G_OBJECT(window->file_sendhost), "activate",
+		G_CALLBACK(mssh_window_sendhost), window);
 	g_signal_connect(G_OBJECT(window->file_quit), "activate",
 		G_CALLBACK(mssh_window_destroy), NULL);
 	gtk_widget_add_accelerator(window->file_quit, "activate", accel_group,

+ 1 - 0
src/mssh-window.h

@@ -27,6 +27,7 @@ typedef struct
 	GtkWidget *file_menu;
 	GtkWidget *server_item;
 	GtkWidget *file_item;
+	GtkWidget *file_sendhost;
 	GtkWidget *file_quit;
 	char **env;
 	char **servers;