Clean up warning messages; fix various errors; use single function for smyrna data...
authorerg <devnull@localhost>
Tue, 12 May 2009 19:21:23 +0000 (19:21 +0000)
committererg <devnull@localhost>
Tue, 12 May 2009 19:21:23 +0000 (19:21 +0000)
cmd/smyrna/gltemplate.c
cmd/smyrna/gui/topviewsettings.c
cmd/smyrna/main.c
cmd/smyrna/viewport.c
cmd/smyrna/viewport.h

index 344e6e5667af6ff2b6c63ded37287fe9ad683eb6..8cf81889c03b5e62722b7d59e25dfa7a683ba6ee 100755 (executable)
@@ -394,8 +394,8 @@ static gboolean button_release_event(GtkWidget * widget,
     return FALSE;
 }
 
-static scroll_event(GtkWidget * widget,
-                                   GdkEventScroll * event, gpointer data)
+static gboolean
+scroll_event(GtkWidget * widget, GdkEventScroll * event, gpointer data)
 {
        if(event->direction==0)
            view->mouse.dx = -30;
@@ -403,6 +403,7 @@ static scroll_event(GtkWidget * widget,
            view->mouse.dx = 30;
        glmotion_zoom(view);
        glexpose();
+    return TRUE;
 }
 
 /*
index ce5e7b7cd7e5cb28d36f00d31cf9785f73c263a7..4e2f00b63f449680638ad328d8dba2cecbb3cf36 100644 (file)
@@ -17,6 +17,7 @@
 #include "gui.h"
 #include "colorprocs.h"
 #include "viewport.h"
+#include "topview.h"
 #include "memory.h"
 
 void on_settingsOKBtn_clicked(GtkWidget * widget, gpointer user_data)
index af1fb23c87f2b81ff77fb9ceaaa35002cb5f20a9..4f3f689407e7420d863983c0c02544fbec3f45bb 100755 (executable)
@@ -36,6 +36,7 @@
 #ifdef ENABLE_NLS
 #include "libintl.h"
 #endif
+#include <assert.h>
 
 #ifdef HAVE_GETOPT_H
 #include <getopt.h>
@@ -48,26 +49,36 @@ gchar *package_prefix;
 gchar *package_data_dir;
 #endif
 gchar *package_locale_dir;
-static char* smyrnaDir;
+static char* smyrnaDir;    /* path to directory containin smyrna data files */
 char* smyrnaGlade;
 unsigned char SmyrnaVerbose;
 
-
-
-
-
+/* smyrnaPath:
+ * Construct pathname for smyrna data file.
+ * Base file name is given as suffix.
+ * The function resolves the directory containing the data files,
+ * and constructs a complete pathname.
+ * The returned string is malloced, so the application should free
+ * it later.
+ * Returns NULL on error.
+ */
 char*
 smyrnaPath (char* suffix)
 {
     char* buf;
-    if (!smyrnaDir) return NULL;
+    assert (smyrnaDir);
+#ifdef _WIN32
+    char* pathSep = "\\";
+#else
+    char* pathSep = "/";
+#endif
+
     buf = N_NEW(strlen(smyrnaDir)+strlen(suffix)+2,char);
-    sprintf (buf, "%s/%s", smyrnaDir, suffix);
+    sprintf (buf, "%s%s%s", smyrnaDir, pathSep, suffix);
+
     return buf;
 }
 
-
-
 static char *useString = "Usage: smyrn [-txv?] [-K<engine>] <file>\n\
   -n         - use TopView mode\n\
   -e         - use XDOT mode\n\
@@ -137,13 +148,19 @@ int main(int argc, char *argv[])
 {
     GdkGLConfig *glconfig;
     char* initFileName;
-       smyrnaDir = getenv ("SMYRNA_PATH");
-#ifndef _WIN32
-    if (!smyrnaDir)
+
+    smyrnaDir = getenv ("SMYRNA_PATH");
+    if (!smyrnaDir) {
+#ifdef _WIN32
+       int sz = GetCurrentDirectory(0, NULL);
+       smyrnaDir = N_NEW(sz, char);
+       GetCurrentDirectory (sz, smyrnaDir);
+#else
        smyrnaDir = SMYRNA_PATH;
 #endif
+    }
 
-       load_attributes();
+    load_attributes();
 
 #ifdef G_OS_WIN32
     package_prefix =
@@ -151,12 +168,9 @@ int main(int argc, char *argv[])
     package_data_dir = g_build_filename(package_prefix, "share", NULL);
     package_locale_dir =
        g_build_filename(package_prefix, "share", "locale", NULL);
-       add_pixmap_directory("C:/");
+    add_pixmap_directory("C:/");
 #else
-    if (smyrnaDir)
-       package_locale_dir = g_build_filename(smyrnaDir, "locale", NULL);
-    else
-       package_locale_dir = g_build_filename(SMYRNA_PATH, "locale", NULL);
+    package_locale_dir = g_build_filename(smyrnaDir, "locale", NULL);
 #endif /* # */
 #ifdef ENABLE_NLS
     bindtextdomain(GETTEXT_PACKAGE, package_locale_dir);
@@ -175,7 +189,7 @@ int main(int argc, char *argv[])
 #endif
     if (!(smyrnaGlade)) {
 #ifdef _WIN32
-               smyrnaGlade = view->glade_file;
+       smyrnaGlade = view->glade_file;
 #else
        smyrnaGlade = smyrnaPath ("smyrna.glade");
 #endif
@@ -198,7 +212,7 @@ int main(int argc, char *argv[])
     create_window(glconfig, gladewidget);
 
        change_cursor(GDK_TOP_LEFT_ARROW);
-       glutInit(&argc,&argv);
+       glutInit(&argc,argv);
        gtk_main();
 
 
index c2503112631a681f2b5498fb5618a7651363d6bb..67edfcbc25363fbaad03531f6d824a4b60df198c 100755 (executable)
@@ -318,34 +318,18 @@ static gboolean gl_main_expose(gpointer data) {
        return 1;
 }
 
-void get_data_dir()
+static void 
+get_data_dir()
 {
-#ifdef WIN32
-       int a=GetCurrentDirectory(0, NULL);
-#endif
-       if (view->template_file) {
-               free(view->template_file);
-               free(view->glade_file);
-               free(view->attr_file);
-       }
-#ifdef WIN32
-       view->template_file=(char*)malloc(sizeof(char)*(a+13));
-       view->glade_file=(char*)malloc(sizeof(char)*(a+13));
-       view->attr_file=(char*)malloc(sizeof(char)*(a+10));
-
-       GetCurrentDirectory(a, view->template_file);
-       GetCurrentDirectory(a, view->glade_file);
-       GetCurrentDirectory(a, view->attr_file);
+    if (view->template_file) {
+       free(view->template_file);
+       free(view->glade_file);
+       free(view->attr_file);
+    }
 
-       strcat(view->template_file,"\\template.dot");
-       strcat(view->glade_file,"\\smyrna.glade");
-       strcat(view->attr_file,"\\attrs.txt");
-#else
-       view->template_file = smyrnaPath ("template.dot");
-       view->glade_file = smyrnaPath ("smyrna.glade");
-       view->attr_file = smyrnaPath ("attrs.txt");
-#endif
-       
+    view->template_file = smyrnaPath ("template.dot");
+    view->glade_file = smyrnaPath ("smyrna.glade");
+    view->attr_file = smyrnaPath ("attrs.txt");
 }
 
 void init_viewport(ViewInfo * view)
@@ -353,9 +337,9 @@ void init_viewport(ViewInfo * view)
     FILE *input_file=NULL;
 
        
-               get_data_dir();
+    get_data_dir();
 
-       input_file = fopen(view->template_file, "rb");
+    input_file = fopen(view->template_file, "rb");
        if (!input_file) {
                fprintf (stderr, "default attributes template graph file \"%s\" not found\n", "c://graphviz-ms//bin//template");
                exit(-1);
@@ -691,7 +675,6 @@ static void refresh_borders(Agraph_t* g)
 int add_graph_to_viewport_from_file(char *fileName)
 {
     //returns 1 if successfull else 0
-       int ind=0;
        Agraph_t *graph;
 
        graph = loadGraph(fileName);
@@ -1055,7 +1038,7 @@ void please_dont_wait(void)
     gtk_widget_hide(glade_xml_get_widget(xml, "frmWait"));
 }
 
-int apply_gvpr(Agraph_t* g,char* prog)
+void apply_gvpr(Agraph_t* g,char* prog)
 {
 #ifdef WIN32   
        Agraph_t* a=exec_gvpr(prog,g);
@@ -1068,7 +1051,7 @@ float interpol(float minv,float maxv,float minc,float maxc,float x)
 void getcolorfromschema(colorschemaset* sc,float l,float maxl,RGBColor* c)
 {
        int ind;
-       float cuml=0.00;
+       /* float cuml=0.00; */
        float percl=l/maxl*100.00;
        for (ind=0;ind < sc->schemacount;ind ++)
        {
@@ -1095,7 +1078,7 @@ static void set_color_theme_color(colorschemaset* sc,char** colorstr,int colorcn
     gvcolor_t cl;
        float av_perc;
        av_perc=100.00/(float)(colorcnt-1);
-       for (ind; ind < colorcnt; ind ++)
+       for (; ind < colorcnt; ind ++)
        {
                colorxlate(colorstr[ind], &cl,RGBA_DOUBLE);
                sc->s[ind].c.R=cl.u.RGBA[0];
index 3161de1ac9315dfd025e5de81437fb9789f4a2b3..ada2c3c74695ec810f14ccb0411af79e4c9bf0a7 100755 (executable)
@@ -47,4 +47,5 @@ extern void getcolorfromschema(colorschemaset* sc,float l,float maxl,RGBColor* c
  /* helper functions */
 extern int setGdkColor(GdkColor * c, char *color);
 extern char *get_attribute_value(char *attr, ViewInfo * view, Agraph_t * g);
+extern void apply_gvpr(Agraph_t* g,char* prog);
 #endif