Gnome UI is now optional.
authorshort <>
Fri, 21 May 2004 19:14:46 +0000 (19:14 +0000)
committershort <>
Fri, 21 May 2004 19:14:46 +0000 (19:14 +0000)
src/Makefile.am
src/main.c

index 59e0d8f..2ca3bad 100644 (file)
@@ -29,6 +29,13 @@ GLADE_OUT= \
                ui-gnome-support.c \
                ui-gnome-support.h
 
+if HAVE_GNOME
+GNOME_SRCS= \
+               ui-gnome.c \
+               ui-gnome.h \
+               $(GLADE_OUT)
+endif
+
 udpgate_SOURCES= \
                main.c \
                main.h \
@@ -36,11 +43,9 @@ udpgate_SOURCES= \
                network.h \
                packet.c \
                packet.h \
-               ui-gnome.c \
-               ui-gnome.h \
                ui-line.c \
                ui-line.h \
-               $(GLADE_OUT)
+               $(GNOME_SRCS)
 
 EXTRA_DIST+= \
                $(GLADE_IN)
@@ -63,7 +68,7 @@ CLEANFILES+= \
                ui-gnome.glade.bak \
                ui-gnome.gladep.bak
 
-udpgate_LDADD+= $(POPT_LIBS) $(INTLLIBS)
+udpgate_LDADD+=$(POPT_LIBS) $(INTLLIBS)
 
 # FIXME: /usr/include/gtk-2.0/gtk/gtkitemfactory.h:51: warning: function declaration isn't a prototype
 # /* We use () here to mean unspecified arguments. This is deprecated
index f649a3e..a302c63 100644 (file)
 #include <string.h>
 #include <setjmp.h>
 #include <unistd.h>
+
+#ifdef HAVE_GNOME
 #include <libgnome/gnome-program.h>
 #include <libgnomeui/gnome-ui-init.h>
+#endif
 
 #include "main.h"      /* self */
-#include "ui-gnome.h"
 #include "ui-line.h"
 #include "network.h"
 
+#ifdef HAVE_GNOME
+#include "ui-gnome.h"
+#endif
+
 
 /* Config: */
 #define LOCAL_PORT_DEFAULT 9201
@@ -63,7 +69,12 @@ static const struct poptOption popt_table[]={
                }
 
                UDPGATE_POPT(0  ,"text"   ,POPT_ARG_NONE                          ,&optarg_text   ,0,
-                               N_("Disable Gnome UI; --text must be first argument"),NULL),
+#ifdef HAVE_GNOME
+                               N_("Disable Gnome UI; --text must be first argument")
+#else /* HAVE_GNOME */
+                               N_("(no Gnome UI compiled - stub only); --text must be first argument")
+#endif /* HAVE_GNOME */
+                               ,NULL),
                UDPGATE_POPT('v',"verbose",POPT_ARG_NONE                          ,&optarg_verbose,0,
                                N_("Display additional debug information"),NULL),
                UDPGATE_POPT('p',"port"   ,POPT_ARG_INT |POPT_ARGFLAG_SHOW_DEFAULT,&optarg_port   ,0,
@@ -86,6 +97,7 @@ static const struct poptOption popt_table_autohelp[]={
                };
 
 
+#ifdef HAVE_GNOME
 static jmp_buf gnome_init_atexit_jmpbuf;
 static gboolean gnome_init_atexit_disable;
 
@@ -105,13 +117,16 @@ static void gnome_init_g_log_handler(const gchar *log_domain,GLogLevelFlags log_
        gnome_init_g_log_handler_hit=TRUE;
        g_log_default_handler(log_domain,log_level,message,user_data);
 }
+#endif /* HAVE_GNOME */
 
 int main(int argc,char **argv)
 {
 poptContext context;
 int errint;
 gboolean is_interactive;
+#ifdef HAVE_GNOME
 gboolean no_gnome;
+#endif /* HAVE_GNOME */
 
 #if 0
        g_log_set_always_fatal(~(0
@@ -129,9 +144,12 @@ gboolean no_gnome;
        if (argv[1] && !strcmp(argv[1],"--text"))
                optarg_text=1;
 
+#ifdef HAVE_GNOME
        no_gnome=(optarg_text || !getenv("DISPLAY") || !*getenv("DISPLAY"));
 
-       if (no_gnome) {
+       if (no_gnome)
+#endif /* HAVE_GNOME */
+       {
                context=poptGetContext(
                                PACKAGE,        /* name */
                                argc,(/*en-const*/const char **)argv,   /* argc,argv */
@@ -148,15 +166,12 @@ gboolean no_gnome;
                        return EXIT_FAILURE;
                        }
                errint=poptGetNextOpt(context);
-               if (errint!=-1) {
-                       g_assert_not_reached(); /* some non-callbacked argument reached */
-                       return EXIT_FAILURE;
-                       }
-               if (poptPeekArg(context)) {
+               if (errint!=-1)
+                       g_error(_("Specified option not expected"));
+               if (poptPeekArg(context))
                        g_error(_("No arguments expected"));
-                       return EXIT_FAILURE;
-                       }
                }
+#ifdef HAVE_GNOME
        else {
 GnomeProgram *gnome_program;
 guint handler_id;
@@ -187,6 +202,7 @@ guint handler_id;
                                "Gtk",  /* log_domain */
                                handler_id);    /* handler_id */
                }
+#endif /* HAVE_GNOME */
 
        is_interactive=(1
                        && !optarg_start
@@ -194,7 +210,9 @@ guint handler_id;
 
        /* Initialize UI here to catch all GLog errors below. */
        if (is_interactive
+#ifdef HAVE_GNOME
                        && (no_gnome || !ui_gnome_init())
+#endif /* HAVE_GNOME */
                        && !ui_line_init())
                g_error(_("No UI interface could be initialized"));