gvncviewer patches



Hello,

Can anybody look at these patches?

In short:

- fix error message when connection to server fails

- connect to local servers by display number only

- menu item to disable grabs - works only partially for some reason

Thanks

Michal
diff --git a/examples/gvncviewer.c b/examples/gvncviewer.c
index 04824f6..4cf573f 100644
--- a/examples/gvncviewer.c
+++ b/examples/gvncviewer.c
@@ -84,9 +84,12 @@ static void vnc_ungrab(GtkWidget *vncdisplay, GtkWidget *window)
 	set_title(VNC_DISPLAY(vncdisplay), window, FALSE);
 }
 
+static int connected = 0;
+
 static void vnc_connected(GtkWidget *vncdisplay G_GNUC_UNUSED)
 {
 	printf("Connected to server\n");
+        connected = 1;
 }
 
 static void vnc_initialized(GtkWidget *vncdisplay, GtkWidget *window)
@@ -110,7 +113,10 @@ static void vnc_desktop_resize(GtkWidget *vncdisplay G_GNUC_UNUSED,
 
 static void vnc_disconnected(GtkWidget *vncdisplay G_GNUC_UNUSED)
 {
-	printf("Disconnected from server\n");
+	if(connected)
+          printf("Disconnected from server\n");
+        else
+          printf("Failed to connect to server\n");
 	gtk_main_quit();
 }
 
diff --git a/examples/gvncviewer.c b/examples/gvncviewer.c
index 97bdef8..04824f6 100644
--- a/examples/gvncviewer.c
+++ b/examples/gvncviewer.c
@@ -36,7 +36,7 @@ static const GOptionEntry options [] =
 {
   {
     G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &args,
-    NULL, "hostname[:display]" },
+    NULL, "[hostname][:display]" },
   { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, 0 }
 };
 
@@ -323,7 +323,7 @@ int main(int argc, char **argv)
 		return 1;
 	}
 	if (!args || (g_strv_length(args) != 1)) {
-		fprintf(stderr, "Usage: gvncviewer hostname[:display]\n%s\n", help_msg);
+		fprintf(stderr, "Usage: gvncviewer [hostname][:display]\n%s\n", help_msg);
 		return 1;
 	}
 
@@ -389,6 +389,8 @@ int main(int argc, char **argv)
 	} else
 		snprintf(port, sizeof(port), "%d", 5900);
 
+        if(! *hostname) 
+          snprintf(hostname, sizeof(hostname), "%s", "127.0.0.1");
 	vnc_display_open_host(VNC_DISPLAY(vnc), hostname, port);
 	vnc_display_set_keyboard_grab(VNC_DISPLAY(vnc), TRUE);
 	vnc_display_set_pointer_grab(VNC_DISPLAY(vnc), TRUE);
diff --git a/examples/gvncviewer.c b/examples/gvncviewer.c
index 4cf573f..2d5c19e 100644
--- a/examples/gvncviewer.c
+++ b/examples/gvncviewer.c
@@ -40,6 +40,8 @@ static const GOptionEntry options [] =
   { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, 0 }
 };
 
+static int allow_grab = TRUE;
+
 
 static GtkWidget *vnc;
 
@@ -168,6 +170,23 @@ static void do_scaling(GtkWidget *menu, GtkWidget *vncdisplay)
 		vnc_display_set_scaling(VNC_DISPLAY(vncdisplay), FALSE);
 }
 
+static void set_grab(GtkWidget * vncdisplay)
+{
+	vnc_display_set_keyboard_grab(VNC_DISPLAY(vncdisplay), allow_grab);
+	vnc_display_set_pointer_grab(VNC_DISPLAY(vncdisplay), allow_grab);
+}
+
+
+static void do_allow_grab(GtkWidget *menu, GtkWidget *vncdisplay)
+{
+	if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(menu)))
+          allow_grab = TRUE;
+	else
+          allow_grab = FALSE;
+
+        set_grab(vncdisplay);
+}
+
 static void vnc_credential(GtkWidget *vncdisplay, GValueArray *credList)
 {
 	GtkWidget *dialog = NULL;
@@ -313,6 +332,7 @@ int main(int argc, char **argv)
 	GtkWidget *cab;
 	GtkWidget *fullscreen;
 	GtkWidget *scaling;
+	GtkWidget *grab;
 	const char *help_msg = "Run 'gvncviewer --help' to see a full list of available command line options";
 
 	/* Setup command line options */
@@ -375,6 +395,10 @@ int main(int argc, char **argv)
 
 	gtk_menu_item_set_submenu(GTK_MENU_ITEM(view), submenu);
 
+        grab = gtk_check_menu_item_new_with_mnemonic("Allow Input _Grab");
+        gtk_menu_bar_append(GTK_MENU_BAR(menubar), grab);
+	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(grab), allow_grab);
+
 #if WITH_LIBVIEW
 	ViewAutoDrawer_SetActive(VIEW_AUTODRAWER(layout), FALSE);
 	ViewOvBox_SetOver(VIEW_OV_BOX(layout), menubar);
@@ -398,8 +422,7 @@ int main(int argc, char **argv)
         if(! *hostname) 
           snprintf(hostname, sizeof(hostname), "%s", "127.0.0.1");
 	vnc_display_open_host(VNC_DISPLAY(vnc), hostname, port);
-	vnc_display_set_keyboard_grab(VNC_DISPLAY(vnc), TRUE);
-	vnc_display_set_pointer_grab(VNC_DISPLAY(vnc), TRUE);
+        set_grab(vnc);
 
 	if (!gtk_widget_is_composited(window)) {
 		vnc_display_set_scaling(VNC_DISPLAY(vnc), TRUE);
@@ -442,6 +465,8 @@ int main(int argc, char **argv)
 			 G_CALLBACK(do_fullscreen), window);
 	g_signal_connect(scaling, "toggled",
 			 G_CALLBACK(do_scaling), vnc);
+	g_signal_connect(grab, "toggled",
+			 G_CALLBACK(do_allow_grab), vnc);
 #if WITH_LIBVIEW
 	g_signal_connect(window, "window-state-event",
 			 G_CALLBACK(window_state_event), layout);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]