gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r3317 - in GNUnet/src/setup: gtk ncurses


From: grothoff
Subject: [GNUnet-SVN] r3317 - in GNUnet/src/setup: gtk ncurses
Date: Fri, 25 Aug 2006 21:17:18 -0700 (PDT)

Author: grothoff
Date: 2006-08-25 21:17:14 -0700 (Fri, 25 Aug 2006)
New Revision: 3317

Modified:
   GNUnet/src/setup/gtk/gconf.c
   GNUnet/src/setup/gtk/gconf.h
   GNUnet/src/setup/gtk/glade_support.c
   GNUnet/src/setup/gtk/glade_support.h
   GNUnet/src/setup/ncurses/mconf.c
   GNUnet/src/setup/ncurses/mconf.h
   GNUnet/src/setup/ncurses/mconf_util.c
Log:
minor adjustments towards ncurses and gtk plugins -- far from complete

Modified: GNUnet/src/setup/gtk/gconf.c
===================================================================
--- GNUnet/src/setup/gtk/gconf.c        2006-08-26 04:01:40 UTC (rev 3316)
+++ GNUnet/src/setup/gtk/gconf.c        2006-08-26 04:17:14 UTC (rev 3317)
@@ -25,22 +25,19 @@
 
 /**
  * @brief GNUnet Setup
- * @file conf/gconf.c
+ * @file setup/gtk/gconf.c
  * @author Roman Zippel
  * @author Nils Durner
  * @author Christian Grothoff
  */
 
+#include "gnunet_setup_lib.h"
 #include "platform.h"
 
-#define LKC_DIRECT_LINK
 #define ENABLE_NLS 1
 
 #define BUG916 NO
 
-#include "lkc.h"
-#include "confdata.h"
-
 #define USE_XPM_SINGLE_VIEW 1
 #define USE_XPM_SPLIT_VIEW 1
 #define USE_XPM_TREE_VIEW 1
@@ -1610,7 +1607,7 @@
 }
 
 
-void gconf_main_post_init(void * lib) {
+void gconf_main_post_init(struct PluginHandle * lib) {
   char * filename;
 
   setLibrary(lib);
@@ -1648,10 +1645,15 @@
 
 /* Main */
 int gconf_main(int argc, 
-              char **argv, 
-              void * lib) {
+              const char ** argv, 
+              struct PluginHandle * self,
+              struct GE_Context * ectx,
+              struct GC_Configuration * cfg,
+              struct GNS_Context * gns,
+              const char * filename,
+              int is_daemon) {
   g_thread_init(NULL);
-  gtk_init(&argc, &argv);
+  gtk_init(&argc, (char***) &argv);
 #if ENABLE_NLS
   bind_textdomain_codeset(PACKAGE, "UTF-8"); /* for gtk */
 #endif
@@ -1661,6 +1663,6 @@
 
   /* add_pixmap_directory (PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps"); */
   /* add_pixmap_directory (PACKAGE_SOURCE_DIR "/pixmaps"); */
-  gconf_main_post_init(lib);
+  gconf_main_post_init(self);
   return 0;
 }

Modified: GNUnet/src/setup/gtk/gconf.h
===================================================================
--- GNUnet/src/setup/gtk/gconf.h        2006-08-26 04:01:40 UTC (rev 3316)
+++ GNUnet/src/setup/gtk/gconf.h        2006-08-26 04:17:14 UTC (rev 3317)
@@ -29,9 +29,14 @@
 #define GNUNET_SETUP_GCONF_H
 
 int gconf_main(int argc, 
-              char **argv, 
-              void * lib);
+              const char ** argv, 
+              struct PluginHandle * self,
+              struct GE_Context * ectx,
+              struct GC_Configuration * cfg,
+              struct GNS_Context * gns,
+              const char * filename,
+              int is_daemon);
 
-void gconf_main_post_init(void * lib);
+void gconf_main_post_init(struct PluginHandle * lib);
  
 #endif

Modified: GNUnet/src/setup/gtk/glade_support.c
===================================================================
--- GNUnet/src/setup/gtk/glade_support.c        2006-08-26 04:01:40 UTC (rev 
3316)
+++ GNUnet/src/setup/gtk/glade_support.c        2006-08-26 04:17:14 UTC (rev 
3317)
@@ -25,7 +25,7 @@
 /**
  * Handle to the dynamic library (which contains this code)
  */
-static void * library;
+static struct PluginHandler * library;
 
 /**
  * Current glade handle.
@@ -67,15 +67,11 @@
   void * method;
 
   GE_ASSERT(ectx, xml != NULL);
-  method = trybindDynamicMethod(library,
-                               "",
-                               handler_name);
-  if (method == NULL) {
-    GE_LOG(ectx, GE_DEBUG | GE_REQUEST | GE_USER,
-       _("Failed to find handler for `%s'\n"),
-       handler_name);
-    return;
-  }
+  method = os_plugin_resolve_function(library,
+                                     handler_name,
+                                     YES);
+  if (method == NULL) 
+    return; 
   glade_xml_signal_connect(xml,
                           handler_name,
                           (GCallback) method);
@@ -131,7 +127,7 @@
   g_object_unref(myXML);
 }
 
-void setLibrary(void * lib) {
+void setLibrary(struct PluginHandle * lib) {
   library = lib;
 }
 

Modified: GNUnet/src/setup/gtk/glade_support.h
===================================================================
--- GNUnet/src/setup/gtk/glade_support.h        2006-08-26 04:01:40 UTC (rev 
3316)
+++ GNUnet/src/setup/gtk/glade_support.h        2006-08-26 04:17:14 UTC (rev 
3317)
@@ -31,7 +31,7 @@
 
 void destroyMainXML(void);
 
-void setLibrary(void * lib);
+void setLibrary(struct PluginHandle * lib);
 
 GtkWidget * get_xml(const char * dialog_name);
  

Modified: GNUnet/src/setup/ncurses/mconf.c
===================================================================
--- GNUnet/src/setup/ncurses/mconf.c    2006-08-26 04:01:40 UTC (rev 3316)
+++ GNUnet/src/setup/ncurses/mconf.c    2006-08-26 04:17:14 UTC (rev 3317)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     (C) 2005 Christian Grothoff (and other contributing authors)
+     (C) 2005, 2006 Christian Grothoff (and other contributing authors)
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -770,28 +770,27 @@
        }
 }
 
-static void conf_cleanup(void)
-{
+static void conf_cleanup() {
 #ifndef MINGW
-       tcsetattr(1, TCSAFLUSH, &ios_org);
+  tcsetattr(1, TCSAFLUSH, &ios_org);
 #endif
-       UNLINK(".help.tmp");
-       UNLINK("lxdialog.scrltmp");
+  UNLINK(".help.tmp");
+  UNLINK("lxdialog.scrltmp");
 }
 
-int mconf_main(int argc, char **argv)
-{
-       char *mode;
-       int stat;
-  char * filename;
 
-  filename = getConfigurationString("GNUNET-SETUP",
-                                   "FILENAME");
-  conf_read(filename);
+int main_setup_ncurses(int argc,
+                      const char **argv,
+                      struct PluginHandle * self,
+                      struct GE_Context * ectx,
+                      struct GC_Configuration * cfg,
+                      struct GNS_Context * gns,
+                      const char * filename,
+                      int is_daemon) {
+  char *mode;
+  int stat;
 
-  backtitle = malloc(128);
-  strcpy(backtitle, "GNUnet Configuration");
-
+  backtitle = _("GNUnet Configuration");
   mode = getenv("MENUCONFIG_MODE");
   if (mode) {
     if (!strcasecmp(mode, "single_menu"))
@@ -806,33 +805,35 @@
     sa.sa_flags = SA_RESTART;
     sigaction(SIGWINCH, &sa, NULL);
   }
-
   tcgetattr(1, &ios_org);
 #endif
   atexit(conf_cleanup);
   init_dialog();
-
   init_wsize();
   conf(&rootmenu);
 
+
+  if ( (0 == GC_test_dirty(cfg)) &&
+       (0 == ACCESS(filename, R_OK)) ) {
+    printf(_("Configuration unchanged, no need to save.\n"));    
+    end_dialog();
+    return 0;
+  }  
   do {
     stat = dialog_yesno(NULL,
-                       "Do you wish to save your new configuration?",
+                       _("Do you wish to save your new configuration?"),
                        5, 60);
   } while (stat < 0);
   end_dialog();
-
+  printf("\n\n");
   if (stat == 0) {
-    conf_write(filename);
-    printf("\n\n"
-          "*** End of configuration.\n"
-          "\n\n");
+    if (0 != GC_write_configuration(cfg,
+                                   filename)) {
+      return 1;
+    }
+    printf(_("End of configuration.\n"));
   } else {
-    printf("\n\n"
-          "Your configuration changes were NOT saved."
-          "\n\n");
+    printf(_("Your configuration changes were NOT saved.\n"));
   }
-  FREE(filename);
-
   return 0;
 }

Modified: GNUnet/src/setup/ncurses/mconf.h
===================================================================
--- GNUnet/src/setup/ncurses/mconf.h    2006-08-26 04:01:40 UTC (rev 3316)
+++ GNUnet/src/setup/ncurses/mconf.h    2006-08-26 04:17:14 UTC (rev 3317)
@@ -28,6 +28,13 @@
 #ifndef MCONF_H
 #define MCONF_H
 
-int mconf_main(int argc, char **argv);
+int main_setup_ncurses(int argc,
+                      const char **argv,
+                      struct PluginHandle * self,
+                      struct GE_Context * ectx,
+                      struct GC_Configuration * cfg,
+                      struct GNS_Context * gns,
+                      const char * filename,
+                      int is_daemon);
 
 #endif

Modified: GNUnet/src/setup/ncurses/mconf_util.c
===================================================================
--- GNUnet/src/setup/ncurses/mconf_util.c       2006-08-26 04:01:40 UTC (rev 
3316)
+++ GNUnet/src/setup/ncurses/mconf_util.c       2006-08-26 04:17:14 UTC (rev 
3317)
@@ -32,7 +32,7 @@
 /* use colors by default? */
 bool use_colors = 1;
 
-char *backtitle = NULL;
+const char * backtitle = NULL;
 
 const char *dialog_result;
 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]