gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r1274 - in gnunet-gtk/src: common core include plugins/abou


From: grothoff
Subject: [GNUnet-SVN] r1274 - in gnunet-gtk/src: common core include plugins/about plugins/daemon plugins/fs
Date: Tue, 5 Jul 2005 13:57:35 -0700 (PDT)

Author: grothoff
Date: 2005-07-05 13:57:20 -0700 (Tue, 05 Jul 2005)
New Revision: 1274

Added:
   gnunet-gtk/src/include/gnunetgtk_common.h
Removed:
   gnunet-gtk/src/include/helper.h
Modified:
   gnunet-gtk/src/common/helper.c
   gnunet-gtk/src/core/main.c
   gnunet-gtk/src/include/Makefile.am
   gnunet-gtk/src/include/platform.h
   gnunet-gtk/src/plugins/about/about.c
   gnunet-gtk/src/plugins/daemon/daemon.c
   gnunet-gtk/src/plugins/fs/download.c
   gnunet-gtk/src/plugins/fs/download.h
   gnunet-gtk/src/plugins/fs/fs.c
   gnunet-gtk/src/plugins/fs/fs.h
   gnunet-gtk/src/plugins/fs/search.c
   gnunet-gtk/src/plugins/fs/search.h
   gnunet-gtk/src/plugins/fs/upload.c
   gnunet-gtk/src/plugins/fs/upload.h
Log:
code cleanup

Modified: gnunet-gtk/src/common/helper.c
===================================================================
--- gnunet-gtk/src/common/helper.c      2005-07-05 19:49:49 UTC (rev 1273)
+++ gnunet-gtk/src/common/helper.c      2005-07-05 20:57:20 UTC (rev 1274)
@@ -17,65 +17,85 @@
      Boston, MA 02111-1307, USA.
 */
 /**
- * @file src/applications/afs/gtkui/helper.c
+ * @file src/common/helper.c
  * @brief This file contains some GUI helper functions
  * @author Igor Wronsky
+ * @author Christian Grothoff
  */
 
 #include "platform.h"
-#include "helper.h"
+#include "gnunetgtk_common.h"
 
 #define HELPER_DEBUG NO
 
 static GladeXML * mainXML;
 
-static char *gladeFile = NULL;
+static char * gladeFile;
 
-static GtkWidget * infoWindow = NULL;
+static GtkWidget * infoWindow;
 
-static GtkWidget * infoText = NULL;
+static GtkWidget * infoText;
 
-/* the main thread */
+/**
+ * the main thread 
+ */
 static PTHREAD_T mainThread;
 
+typedef struct {
+  Semaphore * sem;
+  void * args;
+  SimpleCallback func;
+} SaveCall;
+
 static SaveCall ** psc;
+
 static unsigned int pscCount;
+
 static Mutex sclock;
 
 static int saveCallsUp;
 
-static GtkNotebook * notebook = NULL;
+static gboolean saveCallWrapper(gpointer data) {
+  SaveCall * call = data;
 
+  call->func(call->args);
+  if (call->sem != NULL)
+    SEMAPHORE_UP(call->sem);
+  return FALSE;
+}
 
 /**
  * Call a callback function from the mainloop/main thread ("SaveCall").
  * Since GTK doesn't work with multi-threaded applications under Windows,
  * all GTK operations have to be done in the main thread
  */
-void gtkSaveCall(GtkFunction func, void *args) {
+void gtkSaveCall(SimpleCallback func, 
+                void * args) {
   SaveCall call;
   int i;
 
-  call.args = args;
-  call.func = func;
   MUTEX_LOCK(&sclock);
   if ( (saveCallsUp == NO) ||
        (! PTHREAD_SELF_TEST(&mainThread)) ) {
-    call.sem = SEMAPHORE_NEW(0);
+    call.args = args;
+    call.func = func;
+    call.sem  = SEMAPHORE_NEW(0);
     GROW(psc,
         pscCount,
         pscCount+1);
     psc[pscCount-1] = &call;
     MUTEX_UNLOCK(&sclock);
-    gtk_idle_add(func, &call);
+    gtk_idle_add(&saveCallWrapper, 
+                &call);
     SEMAPHORE_DOWN(call.sem);
     /* remove from psc list */
     MUTEX_LOCK(&sclock);
-    for (i=0;i<pscCount;i++)
+    for (i=0;i<pscCount;i++) {
       if (psc[i] == &call) {
        psc[i] = psc[pscCount-1];
        break;
       }
+    }
     GNUNET_ASSERT(i != pscCount);
     GROW(psc,
         pscCount,
@@ -84,20 +104,10 @@
     SEMAPHORE_FREE(call.sem);
   } else {
     MUTEX_UNLOCK(&sclock);
-    call.sem = NULL;
-    func(&call);
+    func(args);
   }
 }
 
-/**
- * Initialize "SaveCalls"
- */
-void gtkInitSaveCalls() {
-  MUTEX_CREATE_RECURSIVE(&sclock);
-  PTHREAD_GET_SELF(&mainThread);
-  saveCallsUp = YES;
-}
-
 int gtkRunSomeSaveCalls() {
   int i;
 
@@ -124,80 +134,32 @@
   return YES;
 }
 
-void gtkDoneSaveCalls() {
-  int i;
-
-  saveCallsUp = NO;
-  PTHREAD_REL_SELF(&mainThread);
-  MUTEX_LOCK(&sclock);
-  for (i=0;i<pscCount;i++) 
-    psc[i]->func(psc[i]);
-  i = pscCount;
-  MUTEX_UNLOCK(&sclock);  
-  /* wait until all PSC-jobs have left
-     the gtkSaveCall method before destroying
-     the mutex! */
-  while (i != 0) {
-    gnunet_util_sleep(50 * cronMILLIS);    
-    MUTEX_LOCK(&sclock);
-    i = pscCount;
-    MUTEX_UNLOCK(&sclock);
-  }
-  MUTEX_DESTROY(&sclock);
-}
-
-
 /**
- * Called from a "SaveCall"-function to indicate that it is done
- */
-void gtkSaveCallDone(Semaphore *sem) {
-  if (sem)
-    SEMAPHORE_UP(sem);
-}
-
-/**
- * Destroy a widget. Called from threads other than the main thread
- */
-gint doDestroyWidget(SaveCall *call) {
-  gtk_widget_destroy((GtkWidget *) call->args);
-
-  gtkSaveCallDone(call->sem);
-
-  return FALSE;
-}
-
-/**
  * Callback for handling "delete_event": close the window 
  */
-gint deleteEvent(GtkWidget * widget,
-                GdkEvent * event,
-                gpointer data) {
-#if DEBUG_HELPER
-  LOG(LOG_DEBUG, 
-      "In '%s'.\n",
-      __FUNCTION__);
-#endif
+static gint 
+deleteEvent(GtkWidget * widget,
+           GdkEvent * event,
+           gpointer data) {
   return FALSE;
 }
 
 /**
  * A callback to destroy any widget given as second argument
  */
-void destroyWidget(GtkWidget * dummy, 
-                  GtkWidget * widget) {
-#if DEBUG_HELPER
-  LOG(LOG_DEBUG, 
-      "In '%s' of %p.\n", 
-      __FUNCTION__,
-      widget);
-#endif
+static void 
+destroyWidget(GtkWidget * dummy, 
+             GtkWidget * widget) {
   gtk_widget_destroy(widget);
 }
 
 /**
  * Callback function for guiMessage()
+ *
+ * FIXME: use GLADE (or direct GTK functionality) here!
  */
-gint doGuiMessage(SaveCall *call) {
+static void doGuiMessage(void * args) {
+  const gchar * msg = args;
   GtkWidget * window;
   GtkWidget * label;
   GtkWidget * box;
@@ -216,8 +178,7 @@
   gtk_container_add(GTK_CONTAINER(window), 
                    box);
 
-  label = gtk_label_new((gchar *) call->args);
-  free((gchar *) call->args); /* allocated in g_strdup_vprintf */
+  label = gtk_label_new(msg);
   gtk_box_pack_start(GTK_BOX(box),
                     label,
                     FALSE,
@@ -226,49 +187,60 @@
   
   button = gtk_button_new_with_label(_("Ok"));
   gtk_signal_connect(GTK_OBJECT (button),
-                     "clicked",
-                     GTK_SIGNAL_FUNC(destroyWidget),
+                    "clicked",
+                    GTK_SIGNAL_FUNC(destroyWidget),
                     window);
-  gtk_box_pack_start(GTK_BOX(box),button,FALSE,FALSE,0);
-  
+  gtk_box_pack_start(GTK_BOX(box),
+                    button,
+                    FALSE,
+                    FALSE,
+                    0);  
   gtk_window_set_position(GTK_WINDOW(window),
                          GTK_WIN_POS_MOUSE);
   gtk_widget_show_all(window);
   gtk_widget_grab_focus(button);
-  
-  gtkSaveCallDone(call->sem);
-
-  return FALSE;
 }
 
 /** 
  * Displays an informative message to the user in a fresh window 
  */
-void guiMessage(const char * format, ...) {
+void guiMessage(const char * format,
+               ...) {
   va_list args;
   gchar *note;
 
   va_start(args, format);
   note = g_strdup_vprintf(format, args);
-  va_end(args);
-  
-  gtkSaveCall((GtkFunction) doGuiMessage, note);
+  va_end(args);  
+  gtkSaveCall(&doGuiMessage, note);
+  free(note);
 }
 
 static void hideWindow(GtkWidget * widget,
                       gpointer data) {
-  if(widget)
+  if (widget != NULL)
     gtk_widget_hide(widget);
 }
 
 /**
+ * Closure for doInfoMessage.
+ */
+typedef struct {
+  int doPopup;
+  char * note;
+} InfoMessage;
+
+/**
  * Callback for infoMessage()
+ *
+ * FIXME: use GLADE (or direct GTK functionality) here!
  */
-gint doInfoMessage(SaveCall *call) {
+static void doInfoMessage(void * args) {
+  const InfoMessage * info = args;
   GtkTextIter iter;
   GtkTextBuffer * buffer;
 
-  if(!infoWindow) {
+  if (! infoWindow) {
     GtkWidget * box1;
     GtkWidget * button;
     GtkWidget * scrolled_window;
@@ -306,7 +278,7 @@
     infoText = gtk_text_view_new();
     
     gtk_text_view_set_editable(GTK_TEXT_VIEW (infoText),
-                          FALSE);
+                              FALSE);
     gtk_container_add(GTK_CONTAINER(scrolled_window),
                      infoText);
     gtk_widget_show(infoText);
@@ -333,29 +305,26 @@
                               GTK_OBJECT(infoWindow));
     gtk_widget_show(button);
   }
-  if(((InfoMessage *) call->args)->doPopup==YES)
+  if (info->doPopup==YES)
     gtk_widget_show(infoWindow);
 
   /* append the text */
-  buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW (infoText));
+  buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(infoText));
   gtk_text_buffer_get_iter_at_offset(buffer, &iter, -1);
   gtk_text_buffer_insert(buffer,
                         &iter,
-                        ((InfoMessage *) call->args)->note, 
+                        info->note, 
                         -1);
-
-  gtkSaveCallDone(call->sem);
-
-  return FALSE;
 }
 
 /** 
  * Appends a message to the info window
  *
  * @param doPopup do we open the window, YES or NO
- *
  */
-void infoMessage(int doPopup, const char * format, ...) {
+void infoMessage(int doPopup,
+                const char * format,
+                ...) {
   va_list args;
   InfoMessage info;
 
@@ -363,11 +332,12 @@
   info.note = g_strdup_vprintf(format, args);
   va_end(args);
   info.doPopup = doPopup;
-  gtkSaveCall((GtkFunction) doInfoMessage, &info);
+  gtkSaveCall(&doInfoMessage, 
+             &info);
   g_free(info.note);
 }
 
-static gint saveAddLogEntry(SaveCall * call) {
+static void saveAddLogEntry(void * args) {
   static GtkWidget * s = NULL;
   static int once = 1;
   static guint id;
@@ -383,9 +353,7 @@
                      id);
   gtk_statusbar_push(GTK_STATUSBAR(s),
                     id,
-                    (const char*) call->args);
-  gtkSaveCallDone(call->sem);
-  return FALSE;
+                    (const char*) args);
 }
 
 /** 
@@ -394,121 +362,31 @@
  * @param txt the log entry
  *
  */
-void addLogEntry(const char *txt) {
+void addLogEntry(const char * txt) {
   infoMessage(NO, txt);
-  gtkSaveCall((GtkFunction)saveAddLogEntry,
+  gtkSaveCall(&saveAddLogEntry,
              (void*) txt);
 }
 
-gint doAddToNotebook(SaveCall *call) {
-  GtkWidget * label = gtk_label_new(((AddNotebook *) call->args)->labelName);
-  gtk_notebook_append_page(notebook, 
-                          ((AddNotebook *) call->args)->frame, 
-                          label);
-  gtk_widget_show(((AddNotebook *) call->args)->frame);  
-  
-  gtkSaveCallDone(call->sem);
-  
-  return FALSE;
-}
-
-void addToNotebook(const char * labelName,
-                  GtkWidget * frame) {
-  AddNotebook note;
-  
-  note.labelName = labelName;
-  note.frame = frame;
-  /* add a new notebook for the search results */
-  gtkSaveCall((GtkFunction) doAddToNotebook, &note);
-}
-
 /**
- * A function for numeric comparisons of strings
+ * Simple accessor method.
  */
-gint numericComp(GtkCList *clist,
-                 gconstpointer ptr1,
-                 gconstpointer ptr2) {
-  double value1;
-  double value2;
-  GtkCListRow * row1 = (GtkCListRow *) ptr1;
-  GtkCListRow * row2 = (GtkCListRow *) ptr2;
-
-  value1 = atof(GTK_CELL_TEXT(row1->cell[clist->sort_column])->text);
-  value2 = atof(GTK_CELL_TEXT(row2->cell[clist->sort_column])->text);
-
-  if(value1>value2)
-    return(-1);
-  else if(value1==value2)
-    return(0);
-  else
-    return(1);
+const char * getGladeFileName() {
+  return gladeFile;
 }
 
 /**
- * A function for case-insensitive text comparisons
+ * Simple accessor method.
  */
-gint alphaComp(GtkCList *clist,
-               gconstpointer ptr1,
-               gconstpointer ptr2) {
-  char * text1;
-  char * text2;
-  GtkCListRow * row1 = (GtkCListRow *) ptr1;
-  GtkCListRow * row2 = (GtkCListRow *) ptr2;
-
-  text1 = GTK_CELL_TEXT(row1->cell[clist->sort_column])->text;
-  text2 = GTK_CELL_TEXT(row2->cell[clist->sort_column])->text;
-
-  return (strcasecmp(text1,text2));
+GladeXML * getMainXML() {
+  return mainXML;
 }
 
-/**
- * A function for percentage comparisons 
- */
-gint percentComp(GtkCList *clist,
-                 gconstpointer ptr1,
-                 gconstpointer ptr2) {
-  char * tmp1;
-  char * tmp2;
-  double value1;
-  double value2;
-  GtkCListRow * row1 = (GtkCListRow *) ptr1;
-  GtkCListRow * row2 = (GtkCListRow *) ptr2;
+void initGNUnetGTKCommon() {
+  MUTEX_CREATE_RECURSIVE(&sclock);
+  PTHREAD_GET_SELF(&mainThread);
+  saveCallsUp = YES;
 
-  tmp1 = GTK_CELL_TEXT(row1->cell[clist->sort_column])->text;
-  tmp2 = GTK_CELL_TEXT(row2->cell[clist->sort_column])->text;
-
-  /* Hack for DONE strings :) */
-  if(strstr(tmp1,"%") == 0) {
-    if(strstr(tmp2,"%") == 0)
-      return 0;        /* Both "DONE" */
-    else
-      return -1; /* A done, B not */
-  }
-  if(strstr(tmp2,"%")==0) 
-    return 1; /* B done, A not */
-
-  /* Both have %, must remove */
-  tmp1 = STRDUP(GTK_CELL_TEXT(row1->cell[clist->sort_column])->text);
-  tmp2 = STRDUP(GTK_CELL_TEXT(row2->cell[clist->sort_column])->text);
- 
-  tmp1[strlen(tmp1)-1]=0;
-  tmp2[strlen(tmp2)-1]=0;
-  
-  value1 = atof(tmp1);
-  value2 = atof(tmp2);
-
-  FREE(tmp1);
-  FREE(tmp2);
-
-  if(value1>value2)
-    return(-1);
-  else if(value1==value2)
-    return(0);
-  else
-    return(1);
-}
-
-void initGlade() {
   /* load the interface */
 #ifdef MINGW
   gladeFile = MALLOC(_MAX_PATH + 1);
@@ -522,21 +400,32 @@
                          NULL);
 }
 
-void doneGlade() {
+void doneGNUnetGTKCommon() {
+  int i;
+
   UNREF(mainXML);
   mainXML = NULL;
   FREE(gladeFile);
   gladeFile = NULL;
-}
 
-const char * getGladeFileName() {
-  return gladeFile;
-}
+  saveCallsUp = NO;
+  PTHREAD_REL_SELF(&mainThread);
+  MUTEX_LOCK(&sclock);
+  for (i=0;i<pscCount;i++) 
+    psc[i]->func(psc[i]);
+  i = pscCount;
+  MUTEX_UNLOCK(&sclock);  
+  /* wait until all PSC-jobs have left
+     the gtkSaveCall method before destroying
+     the mutex! */
+  while (i != 0) {
+    gnunet_util_sleep(50 * cronMILLIS);    
+    MUTEX_LOCK(&sclock);
+    i = pscCount;
+    MUTEX_UNLOCK(&sclock);
+  }
+  MUTEX_DESTROY(&sclock);
 
-GladeXML * getMainXML() {
-  return mainXML;
 }
 
-
-
 /* end of helper.c */

Modified: gnunet-gtk/src/core/main.c
===================================================================
--- gnunet-gtk/src/core/main.c  2005-07-05 19:49:49 UTC (rev 1273)
+++ gnunet-gtk/src/core/main.c  2005-07-05 20:57:20 UTC (rev 1274)
@@ -19,17 +19,14 @@
 */
 
 /**
- * @file src/main.c
+ * @file src/core/main.c
  * @brief Main function of gnunet-gtk
  * @author Christian Grothoff
  */
 
-#include "config.h"
-#include "gettext.h"
+#include "platform.h"
+#include "gnunetgtk_common.h"
 
-#include <GNUnet/gnunet_util.h>
-#include "helper.h"
-
 /**
  * Prints the usage information for this command if the user errs.
  */
@@ -200,9 +197,7 @@
                         &parseOptions))
     return 0;
   startCron();
-  gtkInitSaveCalls();
-
-  initGlade();
+  initGNUnetGTKCommon();
   root
     = glade_xml_get_widget(getMainXML(),
                           "mainWindow");
@@ -237,9 +232,8 @@
     unloadPlugin(plugin);
     plugin = next;
   }
-  
-  gtkDoneSaveCalls();
-  doneGlade();
+ 
+  doneGNUnetGTKCommon();
   doneUtil();
   
   return 0;

Modified: gnunet-gtk/src/include/Makefile.am
===================================================================
--- gnunet-gtk/src/include/Makefile.am  2005-07-05 19:49:49 UTC (rev 1273)
+++ gnunet-gtk/src/include/Makefile.am  2005-07-05 20:57:20 UTC (rev 1274)
@@ -1,5 +1,9 @@
+gnunetincludedir = $(includedir)/GNUnet
+
+gnunetinclude_HEADERS = \
+  gnunetgtk_common.h
+
 EXTRA_DIST = \
-  helper.h \
   gettext.h \
   plibc.h \
   platform.h

Copied: gnunet-gtk/src/include/gnunetgtk_common.h (from rev 1273, 
gnunet-gtk/src/include/helper.h)
===================================================================
--- gnunet-gtk/src/include/helper.h     2005-07-05 19:49:49 UTC (rev 1273)
+++ gnunet-gtk/src/include/gnunetgtk_common.h   2005-07-05 20:57:20 UTC (rev 
1274)
@@ -0,0 +1,88 @@
+/*
+     This file is part of GNUnet
+     (C) 2005 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
+     by the Free Software Foundation; either version 2, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/include/gnunetgtk_common.h
+ * @author Igor Wronsky 
+ * @author Christian Grothoff
+ */
+
+#ifndef GTKUI_HELPER_H
+#define GTKUI_HELPER_H
+
+void initGNUnetGTKCommon(void);
+
+void doneGNUnetGTKCommon(void);
+
+/**
+ * Get the name of the main glade file for gnunet-gtk.
+ */
+const char * getGladeFileName(void);
+
+/**
+ * Get the GladeXML for the main window of gnunet-gtk.
+ */
+GladeXML * getMainXML(void);
+
+/**
+ * Displays an informative message to the user
+ * in a new popup window.
+ */
+void guiMessage(const char * format,
+               ...);
+
+/**
+ * Appends a message to the info window 
+ * @param doPopup if YES, the info window will
+ *   be opened
+ */
+void infoMessage(int doPopup, 
+                const char * format, ...);
+
+/** 
+ * Appends a log entry to the info window
+ * and update the statusbar to show this
+ * message (until the next call).
+ *
+ * @param txt the log entry
+ */
+void addLogEntry(const char * txt);
+              
+/**
+ * Simple callback function.
+ */
+typedef void (*SimpleCallback)(void *);
+
+/**
+ * Call a callback function from the mainloop/main thread ("SaveCall").
+ * Since GTK doesn't work with multi-threaded applications under Windows,
+ * all GTK operations have to be done in the main thread
+ */
+void gtkSaveCall(SimpleCallback func, 
+                void * arg);
+
+/**
+ * Use this method when blocking the
+ * GTK event thread and save calls should
+ * still continue.
+ */
+int gtkRunSomeSaveCalls();
+ 
+#endif

Deleted: gnunet-gtk/src/include/helper.h
===================================================================
--- gnunet-gtk/src/include/helper.h     2005-07-05 19:49:49 UTC (rev 1273)
+++ gnunet-gtk/src/include/helper.h     2005-07-05 20:57:20 UTC (rev 1274)
@@ -1,148 +0,0 @@
-/*
-     This file is part of GNUnet
-
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
-     option) any later version.
-
-     GNUnet is distributed in the hope that it will be useful, but
-     WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
-
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
-*/
-
-/**
- * @file src/helper.h
- * @author Igor Wronsky 
- */
-
-#ifndef GTKUI_HELPER_H
-#define GTKUI_HELPER_H
-
-#include "platform.h"
-#include <GNUnet/gnunet_util.h>
-
-/* for GTK 2 */
-#define GTK_ENABLE_BROKEN
-
-#include <gtk/gtk.h>
-#include <gtk/gtktext.h>
-#include <glade/glade.h>
-
-const char * getGladeFileName(void);
-
-GladeXML * getMainXML(void);
-
-void initGlade(void);
-
-void doneGlade(void);
-
-typedef struct {
-  Semaphore *sem;
-  void *args;
-  GtkFunction func;
-} SaveCall;
-
-typedef struct {
-  int doPopup;
-  gchar *note;
-} InfoMessage;      
-
-typedef struct {
-  const char *labelName;
-  GtkWidget *frame;
-} AddNotebook;
-
-
-/* callback: window close: close the window */
-gint deleteEvent(GtkWidget * widget,
-                GdkEvent * event,
-                gpointer data);
-
-/**
- * A callback to destroy any widget given as second argument
- *
- */
-void destroyWidget(GtkWidget * dummy, GtkWidget * widget);
-
-/**
- * Displays an informative message to the user
- */
-void guiMessage(const char * format, ...);
-
-/**
- * Appends a message to the info window 
- */
-void infoMessage(int doPopup, const char * format, ...);
-
-/** 
- * Appends a log entry to the info window
- *
- * @param txt the log entry
- *
- */
-void addLogEntry(const char *txt);
-
-/**
- * A function for numeric comparisons of strings
- */
-gint numericComp(GtkCList *clist,
-                 gconstpointer ptr1,
-                 gconstpointer ptr2);
-
-/**
- * A function for case-insensitive text comparisons
- */
-gint alphaComp(GtkCList *clist,
-               gconstpointer ptr1,
-               gconstpointer ptr2);
-
-/**
- * A function for comparisons of percentages
- */
-gint percentComp(GtkCList *clist,
-                 gconstpointer ptr1,
-                 gconstpointer ptr2);
-
-/**
- * A general right-button popup menu callback
- */
-gboolean popupCallback(GtkWidget *widget,
-                       GdkEvent *event,
-                      GtkWidget *menu );
-                      
-/**
- * Call a callback function from the mainloop/main thread ("SaveCall").
- * Since GTK doesn't work with multi-threaded applications under Windows,
- * all GTK operations have to be done in the main thread
- */
-void gtkSaveCall(GtkFunction func, void *args);
-
-/**
- * Initialize "SaveCalls"
- */
-void gtkInitSaveCalls();
-
-void gtkDoneSaveCalls();
-
-int gtkRunSomeSaveCalls();
- 
-/**
- * Called from a "SaveCall"-function to indicate that it is done
- */
-void gtkSaveCallDone(Semaphore *sem);
-
-/**
- * Destroy a widget. Called from threads other than the main thread
- */
-gint doDestroyWidget(SaveCall *call);
-
-extern GtkWidget * infoWindow;
-
-#endif

Modified: gnunet-gtk/src/include/platform.h
===================================================================
--- gnunet-gtk/src/include/platform.h   2005-07-05 19:49:49 UTC (rev 1273)
+++ gnunet-gtk/src/include/platform.h   2005-07-05 20:57:20 UTC (rev 1274)
@@ -174,4 +174,15 @@
        #include "langinfo.h"
 #endif
 
+#include <GNUnet/gnunet_util.h>
+
+/* for GTK 2 */
+#define GTK_ENABLE_BROKEN
+
+#include <gtk/gtk.h>
+#include <gtk/gtktext.h>
+#include <glade/glade.h>
+
+
+
 #endif

Modified: gnunet-gtk/src/plugins/about/about.c
===================================================================
--- gnunet-gtk/src/plugins/about/about.c        2005-07-05 19:49:49 UTC (rev 
1273)
+++ gnunet-gtk/src/plugins/about/about.c        2005-07-05 20:57:20 UTC (rev 
1274)
@@ -25,8 +25,8 @@
  * This file contains the about dialog.
  */
 
-#include "config.h"
-#include "helper.h"
+#include "platform.h"
+#include "gnunetgtk_common.h"
 
 /**
  * This displays an about window

Modified: gnunet-gtk/src/plugins/daemon/daemon.c
===================================================================
--- gnunet-gtk/src/plugins/daemon/daemon.c      2005-07-05 19:49:49 UTC (rev 
1273)
+++ gnunet-gtk/src/plugins/daemon/daemon.c      2005-07-05 20:57:20 UTC (rev 
1274)
@@ -25,10 +25,11 @@
  */
 
 #include "platform.h"
-#include "helper.h"
-#include <GNUnet/gnunet_util.h>
+#include "gnunetgtk_common.h"
 
-static gint doUpdateMenus(SaveCall * call) {
+
+static void doUpdateMenus(void * arg) {
+  int ret = *(int*) arg;
   static GtkWidget * killEntry = NULL;
   static GtkWidget * launchEntry = NULL;
   static GtkWidget * statsEntryYes = NULL;
@@ -36,9 +37,7 @@
   static int once = 1;
   static int isLocal;
   char * host;
-  int ret;
 
-  ret = * (int*) call->args;
   if (once) {
     once = 0;
     killEntry
@@ -73,8 +72,6 @@
     gtk_widget_set_sensitive(killEntry, TRUE);
     gtk_widget_set_sensitive(launchEntry, FALSE);
   }    
-  gtkSaveCallDone(call->sem);
-  return FALSE;
 }
 
 static void cronCheckDaemon(void * dummy) {
@@ -84,7 +81,7 @@
   ret = checkGNUnetDaemonRunning();
   if (ret != last) {
     last = ret;    
-    gtkSaveCall((GtkFunction) doUpdateMenus, &ret);
+    gtkSaveCall(&doUpdateMenus, &ret);
   }      
 }
 

Modified: gnunet-gtk/src/plugins/fs/download.c
===================================================================
--- gnunet-gtk/src/plugins/fs/download.c        2005-07-05 19:49:49 UTC (rev 
1273)
+++ gnunet-gtk/src/plugins/fs/download.c        2005-07-05 20:57:20 UTC (rev 
1274)
@@ -25,9 +25,10 @@
  */
 
 #include "platform.h"
+#include "gnunetgtk_common.h"
 #include "download.h"
 #include "search.h"
-#include "helper.h"
+#include "fs.h"
 #include <extractor.h>
 
 typedef struct DL {

Modified: gnunet-gtk/src/plugins/fs/download.h
===================================================================
--- gnunet-gtk/src/plugins/fs/download.h        2005-07-05 19:49:49 UTC (rev 
1273)
+++ gnunet-gtk/src/plugins/fs/download.h        2005-07-05 20:57:20 UTC (rev 
1274)
@@ -19,7 +19,7 @@
 */
 
 /**
- * @file src/download.h
+ * @file src/plugins/fs/download.h
  * @brief code for downloading with gnunet-gtk
  * @author Christian Grothoff
  */
@@ -27,10 +27,8 @@
 #ifndef GTK_DOWNLOAD_H
 #define GTK_DOWNLOAD_H
 
-#include "helper.h"
-#include "fs.h"
+#include <GNUnet/gnunet_ecrs_lib.h>
 
-
 /**
  */
 void displayDownloadUpdate(const struct ECRS_URI * uri,
@@ -47,5 +45,4 @@
 
 void fs_download_stop(void);
 
-
 #endif

Modified: gnunet-gtk/src/plugins/fs/fs.c
===================================================================
--- gnunet-gtk/src/plugins/fs/fs.c      2005-07-05 19:49:49 UTC (rev 1273)
+++ gnunet-gtk/src/plugins/fs/fs.c      2005-07-05 20:57:20 UTC (rev 1274)
@@ -24,8 +24,9 @@
  * @author Christian Grothoff
  */
 
+#include "platform.h"
+#include "gnunetgtk_common.h"
 #include "fs.h"
-#include "helper.h"
 #include "download.h"
 #include "search.h"
 #include "upload.h"
@@ -33,10 +34,9 @@
 
 struct FSUI_Context * ctx;
 
-static gint saveEventProcessor(SaveCall * call) {
-  const FSUI_Event * event;
+static void saveEventProcessor(void * arg) {
+  const FSUI_Event * event = arg;
 
-  event = (const FSUI_Event *) call->args;
   switch (event->type) {
   case FSUI_search_result:
     displaySearchResult(&event->data.SearchResult.fi,
@@ -106,9 +106,6 @@
        event->type);
     break;
   }
-
-  gtkSaveCallDone(call->sem);
-  return FALSE;
 }
 
 /**
@@ -116,7 +113,7 @@
  */
 static void eventProcessor(void * cls,
                           const FSUI_Event * event) {
-  gtkSaveCall((GtkFunction) &saveEventProcessor,
+  gtkSaveCall(&saveEventProcessor,
              (void*) event);
 }
 

Modified: gnunet-gtk/src/plugins/fs/fs.h
===================================================================
--- gnunet-gtk/src/plugins/fs/fs.h      2005-07-05 19:49:49 UTC (rev 1273)
+++ gnunet-gtk/src/plugins/fs/fs.h      2005-07-05 20:57:20 UTC (rev 1274)
@@ -19,7 +19,7 @@
 */
 
 /**
- * @file src/fs.h
+ * @file src/plugins/fs/fs.h
  * @brief file-sharing globals of gnunet-gtk
  * @author Christian Grothoff
  */
@@ -27,7 +27,6 @@
 #ifndef GTK_FS_H
 #define GTK_FS_H
 
-#include <GNUnet/gnunet_util.h>
 #include <GNUnet/gnunet_ecrs_lib.h>
 #include <GNUnet/gnunet_fsui_lib.h>
 
@@ -80,11 +79,6 @@
   KTYPE_NUM,
 };
 
-
 extern struct FSUI_Context * ctx;
 
-void gtk_fs_init(void);
-
-void gtk_fs_done(void);
-
 #endif

Modified: gnunet-gtk/src/plugins/fs/search.c
===================================================================
--- gnunet-gtk/src/plugins/fs/search.c  2005-07-05 19:49:49 UTC (rev 1273)
+++ gnunet-gtk/src/plugins/fs/search.c  2005-07-05 20:57:20 UTC (rev 1274)
@@ -25,8 +25,9 @@
  */
 
 #include "platform.h"
+#include "gnunetgtk_common.h"
 #include "search.h"
-#include "helper.h"
+#include "fs.h"
 #include <extractor.h>
 
 /**
@@ -617,7 +618,7 @@
  * cron job that periodically updates the model for the
  * namespace selection in the search vbox.
  */
-static gint updateNCBModelSafe(SaveCall * call) {
+static void updateNCBModelSafe(void * unused) {
   GtkWidget * searchNamespaceCB;
   GtkListStore * model;
   GtkTreeIter iter;
@@ -644,12 +645,10 @@
   if (-1 == gtk_combo_box_get_active(GTK_COMBO_BOX(searchNamespaceCB)))
     gtk_combo_box_set_active(GTK_COMBO_BOX(searchNamespaceCB),
                             0);
-  gtkSaveCallDone(call->sem);
-  return FALSE;
 }
 
-static void updateNCBModel(void * call) {
-  gtkSaveCall((GtkFunction) updateNCBModelSafe, NULL);
+static void updateNCBModel(void * dummy) {
+  gtkSaveCall(&updateNCBModelSafe, NULL);
 }
 
 /**

Modified: gnunet-gtk/src/plugins/fs/search.h
===================================================================
--- gnunet-gtk/src/plugins/fs/search.h  2005-07-05 19:49:49 UTC (rev 1273)
+++ gnunet-gtk/src/plugins/fs/search.h  2005-07-05 20:57:20 UTC (rev 1274)
@@ -19,7 +19,7 @@
 */
 
 /**
- * @file src/search.h
+ * @file src/plugins/fs/search.h
  * @brief code for searching with gnunet-gtk
  * @author Christian Grothoff
  */
@@ -27,8 +27,7 @@
 #ifndef GTK_SEARCH_H
 #define GTK_SEARCH_H
 
-#include "helper.h"
-#include "fs.h"
+#include <GNUnet/gnunet_ecrs_lib.h>
 
 /**
  * Add an entry to the search tree.

Modified: gnunet-gtk/src/plugins/fs/upload.c
===================================================================
--- gnunet-gtk/src/plugins/fs/upload.c  2005-07-05 19:49:49 UTC (rev 1273)
+++ gnunet-gtk/src/plugins/fs/upload.c  2005-07-05 20:57:20 UTC (rev 1274)
@@ -19,22 +19,24 @@
 */
 
 /**
- * @file src/upload.c
+ * @file src/plugins/fs/upload.c
  * @brief code for uploading with gnunet-gtk
  * @author Christian Grothoff
  */
 
 #include "platform.h"
+#include "gnunetgtk_common.h"
 #include "search.h"
 #include "upload.h"
+#include "fs.h"
 #include <extractor.h>
 
 #ifdef MINGW
-       #include <shlobj.h>
-       #ifndef BIF_NONEWFOLDERBUTTON
-               #define BIF_NONEWFOLDERBUTTON 0x200
-       #endif
+#include <shlobj.h>
+#ifndef BIF_NONEWFOLDERBUTTON
+#define BIF_NONEWFOLDERBUTTON 0x200
 #endif
+#endif
 
 
 static GtkTreeStore * summary;

Modified: gnunet-gtk/src/plugins/fs/upload.h
===================================================================
--- gnunet-gtk/src/plugins/fs/upload.h  2005-07-05 19:49:49 UTC (rev 1273)
+++ gnunet-gtk/src/plugins/fs/upload.h  2005-07-05 20:57:20 UTC (rev 1274)
@@ -19,7 +19,7 @@
 */
 
 /**
- * @file src/upload.h
+ * @file src/plugins/fs/upload.h
  * @brief code for uploading with gnunet-gtk
  * @author Christian Grothoff
  */
@@ -27,9 +27,6 @@
 #ifndef GTK_UPLOAD_H
 #define GTK_UPLOAD_H
 
-#include "helper.h"
-#include "fs.h"
-
 /**
  */
 void displayUploadUpdate(const char * mainName,
@@ -57,7 +54,6 @@
                         const struct ECRS_URI * uri,
                         GtkTreeRowReference * row);
 
-
 void fs_upload_start(void);
 
 void fs_upload_stop(void);





reply via email to

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