Re: [gtk-vnc-devel] [patch] debug messages revisited
- From: Jonh Wendell <jwendell gnome org>
- To: Anthony Liguori <anthony codemonkey ws>
- Cc: gtk-vnc-devel List <gtk-vnc-devel lists sourceforge net>
- Subject: Re: [gtk-vnc-devel] [patch] debug messages revisited
- Date: Sat, 29 Mar 2008 10:16:42 -0300
Em Sex, 2008-03-28 às 22:53 -0500, Anthony Liguori escreveu:
> Looks good to me!
>
> Could just add add the necessary plumbing to examples/gvncviewer.c?
> That's what I tend to use for debugging so it would be very helpful.
>
> Regards,
>
> Anthony Liguori
Ok, here is another patch. The only difference between this one and the
prior is the gvncviewer.c, which is using GLib's GOption framework to
deal with command-line arguments.
Okay to commit?
--
Jonh Wendell
www.bani.com.br
diff -r 15d01d93a5fe configure.ac
--- a/configure.ac Tue Mar 25 17:09:36 2008 -0300
+++ b/configure.ac Sat Mar 29 10:06:00 2008 -0300
@@ -196,15 +196,6 @@ if test "$WITH_PYTHON" = "yes"; then
fi
fi
-dnl --enable-debug=(yes|no)
-AC_ARG_ENABLE(debug, [ --enable-debug=[no/yes] turn on debugging [default=no]],,enable_debug=no)
-if test "$enable_debug" = "yes"; then
- DEBUG_CFLAGS="-DENABLE_DEBUG"
-else
- DEBUG_CFLAGS=""
-fi
-AC_SUBST(DEBUG_CFLAGS)
-
dnl --enable-plugin to enable the browser plugin.
AC_ARG_ENABLE(plugin,
[ --enable-plugin=[no/yes] enable browser plugin [default=no]],,
@@ -251,6 +242,5 @@ Configure summary:
Python biding ..............: ${WITH_PYTHON}
Install example programs ...: ${WITH_EXAMPLES}
Browser plugin .............: ${enable_plugin}
- DEBUG messages..............: ${enable_debug}
Scaling support.............: ${with_scaling}
"
diff -r 15d01d93a5fe examples/gvncviewer.c
--- a/examples/gvncviewer.c Tue Mar 25 17:09:36 2008 -0300
+++ b/examples/gvncviewer.c Sat Mar 29 10:06:00 2008 -0300
@@ -3,12 +3,24 @@
#include <gdk/gdkkeysyms.h>
#include <stdlib.h>
#include <string.h>
+#include <glib.h>
#include "config.h"
#if WITH_LIBVIEW
#include <libview/autoDrawer.h>
#endif
+
+static gchar **args = NULL;
+static const GOptionEntry options [] =
+{
+ {
+ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_STRING_ARRAY, &args,
+ NULL, "hostname[:display]" },
+
+ { NULL }
+};
+
static GtkWidget *vnc;
@@ -258,6 +270,8 @@ static gboolean window_state_event(GtkWi
int main(int argc, char **argv)
{
+ GOptionContext *context;
+ GError *error = NULL;
char port[1024], hostname[1024];
char *display;
GtkWidget *window;
@@ -271,16 +285,28 @@ int main(int argc, char **argv)
GtkWidget *cab;
GtkWidget *fullscreen;
GtkWidget *scaling;
+ const char *help_msg = "Run 'gvncviewer --help' to see a full list of available command line options";
- if (argc != 2 && argc != 3) {
- fprintf(stderr, "Usage: %s hostname[:display] [password]\n",
- argv[0]);
+ /* Setup command line options */
+ context = g_option_context_new ("- Simple VNC Client");
+ g_option_context_add_main_entries (context, options, NULL);
+ g_option_context_add_group (context, gtk_get_option_group (TRUE));
+ g_option_context_add_group (context, vnc_display_get_option_group ());
+ g_option_context_parse (context, &argc, &argv, &error);
+ if (error) {
+ g_print ("%s\n%s\n",
+ error->message,
+ help_msg);
+ g_error_free (error);
+ return 1;
+ }
+ if (!args || (g_strv_length(args) != 1)) {
+ fprintf(stderr, "Usage: gvncviewer hostname[:display]\n%s\n", help_msg);
return 1;
}
- gtk_init(&argc, &argv);
+ vnc = vnc_display_new();
- vnc = vnc_display_new();
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
#if WITH_LIBVIEW
layout = ViewAutoDrawer_New();
@@ -332,10 +358,7 @@ int main(int argc, char **argv)
gtk_container_add(GTK_CONTAINER(window), layout);
gtk_widget_realize(vnc);
- if (argc == 3)
- vnc_display_set_credential(VNC_DISPLAY(vnc), VNC_DISPLAY_CREDENTIAL_PASSWORD, argv[2]);
-
- snprintf(hostname, sizeof(hostname), "%s", argv[1]);
+ snprintf(hostname, sizeof(hostname), "%s", args[0]);
display = strchr(hostname, ':');
if (display) {
@@ -347,7 +370,6 @@ int main(int argc, char **argv)
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);
- //vnc_display_set_pointer_local(VNC_DISPLAY(vnc), TRUE);
gtk_signal_connect(GTK_OBJECT(window), "delete-event",
GTK_SIGNAL_FUNC(gtk_main_quit), NULL);
diff -r 15d01d93a5fe src/Makefile.am
--- a/src/Makefile.am Tue Mar 25 17:09:36 2008 -0300
+++ b/src/Makefile.am Sat Mar 29 10:06:00 2008 -0300
@@ -8,7 +8,7 @@ libgtk_vnc_1_0_la_CFLAGS = @GTK_CFLAGS@
libgtk_vnc_1_0_la_CFLAGS = @GTK_CFLAGS@ @GTKGLEXT_CFLAGS@ @GNUTLS_CFLAGS@ \
@GTHREAD_CFLAGS@ @WARNING_CFLAGS@ \
-DSYSCONFDIR=\""$(sysconfdir)"\" \
- @DEBUG_CFLAGS@
+ -DG_LOG_DOMAIN=\"gtk-vnc\"
libgtk_vnc_1_0_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libgtk-vnc_sym.version \
-version-info 0:1:0
@@ -49,7 +49,7 @@ gtkvnc_la_LIBADD = libgtk-vnc-1.0.la @PY
# Auto-generated C code for Python binding is full of compiler warnings :-(
#gtkvnc_la_CFLAGS = @GTK_CFLAGS@ @WARNING_CFLAGS@ @PYTHON_INCLUDES@ @PYGTK_CFLAGS@
gtkvnc_la_CFLAGS = @GTK_CFLAGS@ @GTKGLEXT_CFLAGS@ @PYTHON_INCLUDES@ \
- @PYGTK_CFLAGS@ @DEBUG_CFLAGS@
+ @PYGTK_CFLAGS@
gtkvnc_la_LDFLAGS = -module -avoid-version -fPIC
gtkvnc_la_SOURCES = vncmodule.c vncmodule.defs.c
diff -r 15d01d93a5fe src/libgtk-vnc_sym.version
--- a/src/libgtk-vnc_sym.version Tue Mar 25 17:09:36 2008 -0300
+++ b/src/libgtk-vnc_sym.version Sat Mar 29 10:06:00 2008 -0300
@@ -45,6 +45,8 @@
vnc_display_force_grab;
vnc_display_is_pointer_absolute;
+ vnc_display_get_option_group;
+
local:
*;
};
diff -r 15d01d93a5fe src/utils.h
--- a/src/utils.h Tue Mar 25 17:09:36 2008 -0300
+++ b/src/utils.h Sat Mar 29 10:06:00 2008 -0300
@@ -11,10 +11,10 @@
#ifndef _UTILS_H
#define _UTILS_H
-#ifdef ENABLE_DEBUG
-#define GVNC_DEBUG(fmt, ...) do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
-#else
-#define GVNC_DEBUG(fmt, ...) do { } while (0)
-#endif
+#include <glib.h>
+
+extern gboolean debug_enabled;
+
+#define GVNC_DEBUG(fmt, ...) do { if (G_UNLIKELY(debug_enabled)) g_debug(fmt, ## __VA_ARGS__); } while (0)
#endif
diff -r 15d01d93a5fe src/vncdisplay.c
--- a/src/vncdisplay.c Tue Mar 25 17:09:36 2008 -0300
+++ b/src/vncdisplay.c Sat Mar 29 10:06:00 2008 -0300
@@ -150,6 +150,14 @@ static guint signals[LAST_SIGNAL] = { 0,
0, 0, 0, 0,
0, 0, 0, 0, 0,};
static GParamSpec *signalCredParam;
+gboolean debug_enabled = FALSE;
+
+static const GOptionEntry gtk_vnc_args[] =
+{
+ { "gtk-vnc-debug", 0, 0, G_OPTION_ARG_NONE, &debug_enabled, "Enables debug output", 0 },
+ { NULL }
+};
+
static void
vnc_display_get_property (GObject *object,
@@ -2354,6 +2362,18 @@ gboolean vnc_display_is_pointer_absolute
return obj->priv->absolute;
}
+GOptionGroup *
+vnc_display_get_option_group (void)
+{
+ GOptionGroup *group;
+
+ group = g_option_group_new ("gtk-vnc", "GTK-VNC Options", "Show GTK-VNC Options", NULL, NULL);
+
+ g_option_group_add_entries (group, gtk_vnc_args);
+
+ return group;
+}
+
/*
* Local variables:
* c-indent-level: 8
diff -r 15d01d93a5fe src/vncdisplay.h
--- a/src/vncdisplay.h Tue Mar 25 17:09:36 2008 -0300
+++ b/src/vncdisplay.h Sat Mar 29 10:06:00 2008 -0300
@@ -120,6 +120,8 @@ void vnc_display_force_grab(VncDisplay
gboolean vnc_display_is_pointer_absolute(VncDisplay *obj);
+GOptionGroup * vnc_display_get_option_group(void);
+
G_END_DECLS
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]