From 2818036da3f1b3b28f097d77ef427a0e80f170f4 Mon Sep 17 00:00:00 2001 From: erg Date: Tue, 12 May 2009 19:21:23 +0000 Subject: [PATCH] Clean up warning messages; fix various errors; use single function for smyrna data directory --- cmd/smyrna/gltemplate.c | 5 +-- cmd/smyrna/gui/topviewsettings.c | 1 + cmd/smyrna/main.c | 54 ++++++++++++++++++++------------ cmd/smyrna/viewport.c | 47 +++++++++------------------ cmd/smyrna/viewport.h | 1 + 5 files changed, 54 insertions(+), 54 deletions(-) diff --git a/cmd/smyrna/gltemplate.c b/cmd/smyrna/gltemplate.c index 344e6e566..8cf81889c 100755 --- a/cmd/smyrna/gltemplate.c +++ b/cmd/smyrna/gltemplate.c @@ -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; } /* diff --git a/cmd/smyrna/gui/topviewsettings.c b/cmd/smyrna/gui/topviewsettings.c index ce5e7b7cd..4e2f00b63 100644 --- a/cmd/smyrna/gui/topviewsettings.c +++ b/cmd/smyrna/gui/topviewsettings.c @@ -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) diff --git a/cmd/smyrna/main.c b/cmd/smyrna/main.c index af1fb23c8..4f3f68940 100755 --- a/cmd/smyrna/main.c +++ b/cmd/smyrna/main.c @@ -36,6 +36,7 @@ #ifdef ENABLE_NLS #include "libintl.h" #endif +#include #ifdef HAVE_GETOPT_H #include @@ -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] \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(); diff --git a/cmd/smyrna/viewport.c b/cmd/smyrna/viewport.c index c25031126..67edfcbc2 100755 --- a/cmd/smyrna/viewport.c +++ b/cmd/smyrna/viewport.c @@ -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]; diff --git a/cmd/smyrna/viewport.h b/cmd/smyrna/viewport.h index 3161de1ac..ada2c3c74 100755 --- a/cmd/smyrna/viewport.h +++ b/cmd/smyrna/viewport.h @@ -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 -- 2.40.0