#include <glib.h>
#include <gtk/gtk.h>
+#include <gdk/gdkkeysyms.h>
#include <vncdisplay.h>
#ifdef HAVE_NETDB_H
// would require a CA by default (self-signed wont work)
// (don't set to true, change var/flag to no_check_cert)
+/* The WUI thread has updated the vm list. Here in the main thread
+* we keep our own copy of the vmlist.
+*/
+static GSList *vmlist = NULL;
+
/* Private functions. */
static void start_ui (void);
static GtkWidget *menu_item_new (int which_menu);
static void refresh_menu_vm_list (GtkWidget *, gpointer);
static void connect_to_wui_on_enter (GtkWidget *, gpointer);
static void connect_to_wui (GtkWidget *, gpointer);
+static void send_key_to_vm (GtkWidget *widget, gpointer _keyComboDef);
static void login_to_wui_on_enter (GtkWidget *, gpointer);
static void login_to_wui (GtkWidget *, gpointer);
static gboolean delete_event (GtkWidget *widget, GdkEvent *event, gpointer data);
static void viewer_disconnected (GtkWidget *vnc);
static void viewer_credential (GtkWidget *vnc, GValueArray *credList);
static int viewer_open_vnc_socket (const char *vnchost, int vncport);
+static void add_vm_to_connectmenu (gpointer _vm, gpointer data);
/* For any widgets accessed from multiple functions. */
static GtkWidget *window;
{ HELP_MENU, NULL, "_Help", "Help" }
};
+#define MAX_KEY_COMBO 3
+ struct keyComboDef {
+ guint keys[MAX_KEY_COMBO];
+ guint nkeys;
+ const char *label;
+ };
+
+#define NUM_KEY_COMBOS 17
+static struct keyComboDef keyCombos[] = {
+ { { GDK_Control_L, GDK_Alt_L, GDK_Delete }, 3, "Ctrl+Alt+Del"},
+ { { GDK_Control_L, GDK_Alt_L, GDK_BackSpace }, 3, "Ctrl+Alt+Backspace"},
+ { {}, 0, "" },
+ { { GDK_Control_L, GDK_Alt_L, GDK_F1 }, 3, "Ctrl+Alt+F1"},
+ { { GDK_Control_L, GDK_Alt_L, GDK_F2 }, 3, "Ctrl+Alt+F2"},
+ { { GDK_Control_L, GDK_Alt_L, GDK_F3 }, 3, "Ctrl+Alt+F3"},
+ { { GDK_Control_L, GDK_Alt_L, GDK_F4 }, 3, "Ctrl+Alt+F4"},
+ { { GDK_Control_L, GDK_Alt_L, GDK_F5 }, 3, "Ctrl+Alt+F5"},
+ { { GDK_Control_L, GDK_Alt_L, GDK_F6 }, 3, "Ctrl+Alt+F6"},
+ { { GDK_Control_L, GDK_Alt_L, GDK_F7 }, 3, "Ctrl+Alt+F7"},
+ { { GDK_Control_L, GDK_Alt_L, GDK_F8 }, 3, "Ctrl+Alt+F8"},
+ { { GDK_Control_L, GDK_Alt_L, GDK_F5 }, 3, "Ctrl+Alt+F9"},
+ { { GDK_Control_L, GDK_Alt_L, GDK_F6 }, 3, "Ctrl+Alt+F10"},
+ { { GDK_Control_L, GDK_Alt_L, GDK_F7 }, 3, "Ctrl+Alt+F11"},
+ { { GDK_Control_L, GDK_Alt_L, GDK_F8 }, 3, "Ctrl+Alt+F12"},
+ { {}, 0, "" },
+ { { GDK_Print }, 1, "PrintScreen"},
+};
+
/* Window title. */
static const char *title = "oVirt Viewer";
static void
start_ui (void)
{
+ int i;
GtkWidget *vbox;
GtkWidget *menubar;
GtkWidget *view;
GtkWidget *viewmenu;
GtkWidget *sendkey;
GtkWidget *sendkeymenu;
+ GtkWidget *sendkeymenuitem;
GtkWidget *wind;
GtkWidget *windmenu;
GtkWidget *help;
sendkeymenu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (sendkey), sendkeymenu);
+ for(i = 0; i < NUM_KEY_COMBOS; ++i){
+ sendkeymenuitem = gtk_menu_item_new_with_label (keyCombos[i].label);
+ gtk_menu_append (GTK_MENU (sendkeymenu), sendkeymenuitem);
+ g_signal_connect (G_OBJECT (sendkeymenuitem), "activate",
+ G_CALLBACK (send_key_to_vm), &(keyCombos[i]));
+ }
+
wind = menu_item_new (WINDOW_MENU);
windmenu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (wind), windmenu);
DEBUG ("finished creating new tab");
}
+/* Send key to a virtual machine. This callback is called from the
+ * send key menu. If finds vm in focus, and sends specified key to it
+ */
+static void
+send_key_to_vm (GtkWidget *widget, gpointer _keyComboDef)
+{
+ GtkWidget* viewer;
+ struct keyComboDef* key_combo = (struct keyComboDef*) _keyComboDef;
+ int c = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
+
+ if(c < 0){
+ return;
+ }
+
+ viewer = gtk_notebook_get_nth_page(GTK_NOTEBOOK (notebook), c);
+ if(viewer != NULL){
+ DEBUG ("sending keys to vm");
+ vnc_display_send_keys(VNC_DISPLAY(viewer),
+ key_combo->keys,
+ key_combo->nkeys);
+ }
+}
+
+
/*
static void viewer_grab(GtkWidget *vnc, GtkWidget *window)
{
return FALSE;
}
-/* The WUI thread has updated the vm list. Here in the main thread
- * we keep our own copy of the vmlist.
- */
-static GSList *vmlist = NULL;
-
-static void add_vm_to_connectmenu (gpointer _vm, gpointer data);
-
gboolean
main_vmlist_updated (gpointer data)
{