📄 interface.c
字号:
/* * GTelnet * by: Kenth Andersson <d99kan@du.se> (Initial development v1.0) * Prana <pranalukas@gmx.de> (v1.1, v1.2, v2.0, v2.1, v2.2, v2.3, v2.4, 2.5) * * Developed partially with Glade <http://glade.pn.org> */#include "interface.h"#define default_background_location "/usr/share/pixmaps/gtelnet/gtelnet_bg_black.jpg"gushort red[] ={ 0x0000,0xaaaa,0x0000, 0xaaaa,0x0000,0xaaaa, 0x0000,0x5fbb,0x5555, 0xffff,0x5555,0xffff, 0x5555,0xffff,0x5555, 0xffff,0x0000,0x0000 };gushort green[] ={ 0x0000,0x0000,0xaaaa, 0x5555,0x0000,0x0000, 0xaaaa,0xee8b,0x5555, 0x5555,0xffff,0xffff, 0x5555,0x5555,0xffff, 0xffff,0xea60,0x0000};gushort blue[] ={ 0x0000,0x0000,0x0000, 0x0000,0xaaaa,0xaaaa, 0xaaaa,0x2fc9,0x5555, 0x5555,0x5555,0x5555, 0xffff,0xffff,0xffff, 0xffff,0x0000,0x0000 };char *the_terminal_types[] = { "ansi", // 1 "ansi-bbs", "ansi-cis", "aixterm", "arm100", // 5 "att700", "bsdos-pc", "crt", "hpansi", "hpterm", // 10 "iris-ansi", "iris-color", "linux", "mach", "mgr", // 15 "ncsa", "pckermit", "ncsa", "qnx", "rcons", "rcons-color",// 20 "rxvt", "rxvt-color", "scoansi", "sun", "vt52", // 25 "vt100", "vt102", "vt131", "vt220", "vt320", // 30 "vt340", "vt400", "vt420", "vt525", "wyse30", // 35 "wyse50", "wyse60", "wy100", "xterm", "xterm-debian" "xterm-color" // 40 };char *the_encryption_types[] = { "none", "des", "3des", "blowfish", "idea", "arcfour", "twofish", "any", "anystd", "anycipher", "anystdcipher" };struct opt_widget telnet_checkbox[] = {{ NULL, "tlnt_chk1", N_("8-bit data path (both output and input)")},{ NULL, "tlnt_chk2", N_("8-bit data path on output")}, { NULL, "tlnt_chk3", N_("Stop any character from being recognized as an escape character")},{ NULL, "tlnt_chk4", N_("Forward a forwardable copy of the local credentials to the remote system (if Kerberos V5 is used)")},{ NULL, "tlnt_chk5", N_("Attempt automatic login")}, { NULL, "tlnt_chk6", N_("Specify a user interface similar to rlogin")},{ NULL, "tlnt_chk7", N_("Turn on encryption of the data stream")},{ NULL, "tlnt_chk8", N_("Set the initial value of the debug flag to TRUE")},{ NULL, "tlnt_chk9", N_("Set the initial telnet escape character to:")},{ NULL, "tlnt_chk10", N_("Set the IP type-of-service (TOS) option to the value:")},{ NULL, "tlnt_chk11", N_("Disable the type of authentication: ")},{ NULL, "tlnt_chk12", N_("Request Kerberos tickets for the remote host in the realm:")},{ NULL, "tlnt_chk13", N_("Trace file :")}};struct opt_widget ssh_checkbox[] = {{ NULL, "ssh_chk1", N_("Redirect input from /dev/null")},{ NULL, "ssh_chk2", N_("Enable authentication agent forwarding")},{ NULL, "ssh_chk3", N_("Enable X11 connection forwarding")},{ NULL, "ssh_chk4", N_("Allocate a tty even if command is given")},{ NULL, "ssh_chk5", N_("Display verbose debugging messages")},{ NULL, "ssh_chk6", N_("Don't allocate a privileged port")},{ NULL, "ssh_chk7", N_("Don't display any warning messages")},{ NULL, "ssh_chk8", N_("Fork into background after authentication")},{ NULL, "ssh_chk9", N_("Enable compression")},{ NULL, "ssh_chk10", N_("Allow remote hosts to connect to local forwarded ports")},{ NULL, "ssh_chk11", N_("Don't request a session")},{ NULL, "ssh_chk12", N_("Set SSH2 debug level to:")},{ NULL, "ssh_chk13", N_("Identity file for public key authentication to:")},{ NULL, "ssh_chk14", N_("Set escape character to:")},{ NULL, "ssh_chk15", N_("Select encryption algorithm (For OpenSSH: only '3des' and 'blowfish' are supported)")},};struct opt_widget rlogin_checkbox[] = {{ NULL, "rlogin_chk1", N_("Allows an eight-bit input data path at all times")},{ NULL, "rlogin_chk2", N_("Stops any character from being recognized as an escape character")},{ NULL, "rlogin_chk3", N_("Turns off all Kerberos authentication")},{ NULL, "rlogin_chk4", N_("Allows the rlogin session to be run in \"litout\" mode")},{ NULL, "rlogin_chk5", N_("Turns on socket debugging")},{ NULL, "rlogin_chk6", N_("Turns on DES encryption for all data passed via the rlogin session")},{ NULL, "rlogin_chk7", N_("Set the initial telnet escape character to:")},{ NULL, "rlogin_chk8", N_("Request Kerberos tickets for the remote host in the realm:")}};struct opt_widget display_option_labels[] = {{ NULL, "display_lbl1", N_("Background Color")},{ NULL, "display_lbl2", N_("Foreground Color")},{ NULL, "display_lbl3", N_("Executable Files Color")},{ NULL, "display_lbl4", N_("Directories Color")},{ NULL, "display_lbl5", N_("Display Font")},{ NULL, "display_lbl6", N_("Background Image")},};static void selectconnection (GtkWidget *item, int num) {/* Select 0: telnet 1: ssh 2: rlogin*/ connection_type = num; }static void select_ssh_encrypt_type (GtkWidget *item, int num) {/* Select the ssh encryption type.. Note: for OpenSSH, only "3des" and "blowfish" will work right now... but for SSH2, "idea", etc will work ;)*/ gnome_property_box_changed(GNOME_PROPERTY_BOX(property_box)); ssh_encrypt_type = num;}static void add_menu_item (void *callback, char *label, GtkWidget *menu, void *parameters) {/* Add menu item*/ GtkWidget *item; item = gtk_menu_item_new_with_label (label); gtk_menu_append (GTK_MENU (menu), item); gtk_signal_connect (GTK_OBJECT (item), "activate", GTK_SIGNAL_FUNC (callback), parameters); gtk_widget_show (item);}static void destroy_win(GtkWidget *widget, gpointer data) {/* Kill application - cropped directly from GTelnet*/ gtk_main_quit();}static void changed(GtkWidget *widget, gint page_num, gpointer data) {/* Indicates that there has been a settings that's changed in Property Box dialog - cropped directly from old GTelnet v1.0*/ gnome_property_box_changed(GNOME_PROPERTY_BOX(property_box));}static GtkWidget *new_toolbar_button(GtkWidget *parent, GtkWidget *a_toolbar,char *icon, char *namez, gchar *title, gchar *tooltips) { GtkWidget *tmp_toolbar_icon; GtkWidget *tool_button; tmp_toolbar_icon = gnome_stock_pixmap_widget (parent, icon); tool_button = gtk_toolbar_append_element (GTK_TOOLBAR (a_toolbar), GTK_TOOLBAR_CHILD_BUTTON,NULL, title, tooltips, NULL, tmp_toolbar_icon, NULL, NULL); gtk_widget_ref (tool_button); gtk_object_set_data_full (GTK_OBJECT (parent), namez, tool_button, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (tool_button); return tool_button;}static GtkWidget *new_label(GtkWidget *parent,gchar *namez, gchar *title)/* New label*/{ GtkWidget *label; label = gtk_label_new (title); gtk_widget_ref (label); gtk_object_set_data_full (GTK_OBJECT (parent), namez, label, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (label); return label;}static GtkWidget *new_checkbox(GtkWidget *parent, char *namez, gchar *label) {/* Just for code cleanup*/ GtkWidget *checkbox; checkbox = gtk_check_button_new_with_label (label); gtk_widget_ref (checkbox); gtk_object_set_data_full (GTK_OBJECT (parent), namez, checkbox, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (checkbox); return checkbox;}static GtkWidget *new_box(GtkWidget *parent, char *namez, int box_direction)// make a box with{ GtkWidget *a_box; if (box_direction==vertbox) a_box = gtk_vbox_new (FALSE, 0); else a_box = gtk_hbox_new (FALSE, 0); gtk_widget_ref (a_box); gtk_object_set_data_full (GTK_OBJECT (parent), namez, a_box, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (a_box); return a_box;}static GtkWidget *new_entry(GtkWidget *parent, char *namez)// make new option menu{ GtkWidget *entry; entry = gtk_entry_new (); gtk_widget_ref (entry); gtk_object_set_data_full (GTK_OBJECT (parent), namez, entry, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (entry); return entry;}GtkWidget* create_main_window (int x_count, char *x_choice, char *x_hostname, char *x_port){/* Main Window*/ GtkWidget *main_window; GtkWidget *dock1; GtkWidget *toolbar; GtkWidget *connect_via_menu; GtkWidget *host_label; GtkWidget *port_label; GtkWidget *vbox8; GtkWidget *entry6; GtkWidget *hbox4; GtkWidget *vscrollbar1; GtkWidget *connect_button, *disconnect_button, *preferences_button, *about_button; main_window = gnome_app_new ("gnome-telnet", _("GTelnet")); gtk_object_set_data (GTK_OBJECT (main_window), "main_window", main_window); gtk_window_set_position (GTK_WINDOW (main_window), GTK_WIN_POS_CENTER); gtk_window_set_policy (GTK_WINDOW (main_window), TRUE, TRUE, TRUE); gtk_widget_realize(main_window); dock1 = GNOME_APP (main_window)->dock; gtk_widget_ref (dock1); gtk_object_set_data_full (GTK_OBJECT (main_window), "dock1", dock1, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (dock1); toolbar = gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_BOTH); gtk_widget_ref (toolbar); gtk_object_set_data_full (GTK_OBJECT (main_window), "toolbar", toolbar, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (toolbar); gnome_app_add_toolbar (GNOME_APP (main_window), GTK_TOOLBAR (toolbar), "toolbar", GNOME_DOCK_ITEM_BEH_EXCLUSIVE, GNOME_DOCK_TOP, 0, 0, 0); gtk_container_set_border_width (GTK_CONTAINER (toolbar), 1); gtk_toolbar_set_space_size (GTK_TOOLBAR (toolbar), 16); gtk_toolbar_set_space_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_SPACE_LINE); gtk_toolbar_set_button_relief (GTK_TOOLBAR (toolbar), GTK_RELIEF_NONE); connect_via = gtk_option_menu_new (); gtk_widget_ref (connect_via); gtk_object_set_data_full (GTK_OBJECT (main_window), "connect_via", connect_via, (GtkDestroyNotify) gtk_widget_unref); gtk_widget_show (connect_via); gtk_toolbar_append_widget (GTK_TOOLBAR (toolbar), connect_via, _("Select one of the options"), NULL);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -