]> granicus.if.org Git - graphviz/commitdiff
Add support for environment variable SMYRNA_PATH to root directory
authorerg <devnull@localhost>
Tue, 25 Mar 2008 19:51:06 +0000 (19:51 +0000)
committererg <devnull@localhost>
Tue, 25 Mar 2008 19:51:06 +0000 (19:51 +0000)
of smyrna data directories gui, icons, etc.

cmd/smyrna/Makefile.am
cmd/smyrna/gltemplate.c
cmd/smyrna/gui/gui.c
cmd/smyrna/main.c
cmd/smyrna/smyrnadefs.h
cmd/smyrna/topview.c
cmd/smyrna/topview.h

index 30a4e8125936f9597bf85800b2cc6ea9a7061d49..5b93f5dc89937cbf5dd52cc31f3b0bfd18518f46 100644 (file)
@@ -2,6 +2,7 @@ guidir = $(pkgdatadir)/gui
 icondir = $(pkgdatadir)/icons
 
 AM_CPPFLAGS = \
+       -DSMYRNA_PATH=\""$(pkgdatadir)"\" \
        -DSMYRNA_GLADE=\""$(guidir)/smyrna.glade"\" \
        -DSMYRNA_ATTRS=\""$(guidir)/attrs.txt"\" \
        -DSMYRNA_FONT=\""$(guidir)/arial.tga"\" \
index 268480467cd89f380d14815afe052133e7343e88..bb82bcaedb4b694b96e4a6cc10bac38962684bb0 100755 (executable)
@@ -126,6 +126,7 @@ static void realize(GtkWidget * widget, gpointer data)
     GLfloat lmodel_ambient[] = { 0.2f, 0.2f, 0.2f, 1.0f };
     GLfloat local_view[] = { 0.0 };
 
+    char* smyrna_font;
 
 #ifdef WIN32
 #define SMYRNA_FONT "c:/arial.tga"
@@ -133,7 +134,11 @@ static void realize(GtkWidget * widget, gpointer data)
 // using -DSMYRNA_FONT from Makefile.am and configure.ac
 #endif
 
-    g_print("loading font....%i\n", fontLoad(SMYRNA_FONT));
+    if ((smyrna_font = smyrnaPath ("gui/arial.tga"))) {
+       g_print("loading font....%i\n", fontLoad(smyrna_font));
+       free (smyrna_font);
+    }
+    else g_print("loading font....%i\n", fontLoad(SMYRNA_FONT));
 
   /*** OpenGL BEGIN ***/
     if (!gdk_gl_drawable_gl_begin(gldrawable, glcontext))
index 300201b03d367a6d0ef9db0afc2a184d12f06638..095146495c61ea5518d43b13681f55745bba1b1f 100755 (executable)
@@ -69,7 +69,7 @@ void create_object_properties()
 #endif
     GladeXML *xml;
     GtkWidget *widget;
-    xml = glade_xml_new(SMYRNA_GLADE, NULL, NULL);
+    xml = glade_xml_new(smyrnaGlade, NULL, NULL);
 
     widget = glade_xml_get_widget(xml, "listPoints");
     gtk_clist_set_column_title((GtkCList *) widget, 0, "Def");
@@ -109,7 +109,7 @@ void graph_properties_init(int newgraph)    //initialize little open graph dialog
 
 
     gint result = 0;
-    xml = glade_xml_new(SMYRNA_GLADE, NULL, NULL);
+    xml = glade_xml_new(smyrnaGlade, NULL, NULL);
     gladewidget = glade_xml_get_widget(xml, "entryGraphFileName");
 
     //signals
@@ -663,8 +663,15 @@ void load_attributes()
     char *pch;
     int ind = 0;
     int attrcount = 0;
+    static char* smyrna_attrs;
+
+    if (!smyrna_attrs) {
+       if (!(smyrna_attrs = smyrnaPath ("gui/attrs.txt")))
+           smyrna_attrs = SMYRNA_ATTRS;
+    }
+
     //loads attributes from a text file
-    file = fopen(SMYRNA_ATTRS, "r");
+    file = fopen(smyrna_attrs, "r");
     if (file != NULL) {
        while (fgets(line, sizeof line, file) != NULL) {
            pch = strtok(line, ",");
index 4dacea8d1ebceee0d463272df10dca6b42cf9ffb..0ac9d60f3143a8c659c04130e3cd7db51a24173b 100755 (executable)
 #include "viewport.h"
 #include "menucallbacks.h"
 #include "gltemplate.h"
+#include "memory.h"
 #ifdef ENABLE_NLS
 #include "libintl.h"
 #endif
 
+#ifdef G_OS_WIN32
 gchar *package_prefix;
 gchar *package_data_dir;
+#endif
 gchar *package_locale_dir;
+static char* smyrnaDir;
+char* smyrnaGlade;
+
+char*
+smyrnaPath (char* suffix)
+{
+    char* buf;
+    if (!smyrnaDir) return NULL;
+    buf = N_NEW(strlen(smyrnaDir)+strlen(suffix)+2,char);
+    sprintf (buf, "%s/%s", smyrnaDir, suffix);
+    return buf;
+}
 
 int main(int argc, char *argv[])
 {
     GdkGLConfig *glconfig;
+    char* smyrnaDir;
     load_attributes();
 
+    smyrnaDir = getenv ("SMYRNA_PATH");
+
 #ifdef G_OS_WIN32
     package_prefix =
        g_win32_get_package_installation_directory(NULL, NULL);
     package_data_dir = g_build_filename(package_prefix, "share", NULL);
     package_locale_dir =
        g_build_filename(package_prefix, "share", "locale", NULL);
+#else
+    if (smyrnaDir)
+       package_locale_dir = g_build_filename(smyrnaDir, "locale", NULL);
+    else
+       package_locale_dir = g_build_filename(SMYRNA_PATH, "locale", NULL);
 #endif /* # */
 #ifdef ENABLE_NLS
     bindtextdomain(GETTEXT_PACKAGE, package_locale_dir);
@@ -65,7 +88,10 @@ int main(int argc, char *argv[])
 #ifdef _WIN32
 #define GTKTOPVIEW_ICONSDIR "C:\\Projects\\ATT\\GTK\\GTKTest2\\GUI\\images\\"
 #endif
-    xml = glade_xml_new(SMYRNA_GLADE, NULL, NULL);
+    if (!(smyrnaGlade = smyrnaPath ("gui/smyrna.glade"))) {
+       smyrnaGlade = SMYRNA_GLADE;
+    }
+    xml = glade_xml_new(smyrnaGlade, NULL, NULL);
     gladewidget = glade_xml_get_widget(xml, "frmMain");
     gtk_widget_show(gladewidget);
     g_signal_connect((gpointer) gladewidget, "destroy",
@@ -85,8 +111,8 @@ int main(int argc, char *argv[])
 #ifdef G_OS_WIN32
     g_free(package_prefix);
     g_free(package_data_dir);
-    g_free(package_locale_dir);
 #endif
+    g_free(package_locale_dir);
     clear_viewport(view);
     return 0;
 }
index 1b21ef053fc489b67e7fd4e24ebf4106810eb01d..1719118a5ae9204437ed05d5bde406df80136c2f 100644 (file)
@@ -351,6 +351,8 @@ typedef struct _ViewInfo {
 extern ViewInfo *view;
 extern GtkMessageDialog *Dlg;
 extern int respond;
+extern char* smyrnaPath (char* suffix);
+extern char* smyrnaGlade;
 
 extern void glexpose();
 
index 59a807f0453f8dc66746e593200a7e330ea7e5dd..67ebe0b09599bbddedfde0bc7714a83cb64599ad 100755 (executable)
@@ -954,6 +954,13 @@ void menu_click_alpha_plus(void *p)
 #define SMYRNA_ICON_FISHEYE "c:/fisheye.raw"
 #endif
 
+static char* smyrna_icon_pan;
+static char* smyrna_icon_zoom;
+static char* smyrna_icon_zoomplus;
+static char* smyrna_icon_zoomminus;
+static char* smyrna_icon_fisheye;
+
+#define SET_PATH(var,sfx,dflt) if (!(var=smyrnaPath(sfx))) var = dflt
 
 glCompSet *glcreate_gl_topview_menu()
 {
@@ -961,6 +968,15 @@ glCompSet *glcreate_gl_topview_menu()
     glCompPanel *p;
     glCompButton *b;
     glCompLabel *l;
+
+    if (!smyrna_icon_pan) {
+       SET_PATH(smyrna_icon_pan,"icons/pan.raw",SMYRNA_ICON_PAN);
+       SET_PATH(smyrna_icon_zoom,"icons/zoom.raw",SMYRNA_ICON_ZOOM);
+       SET_PATH(smyrna_icon_zoomplus,"icons/zoomplus.raw",SMYRNA_ICON_ZOOMPLUS);
+       SET_PATH(smyrna_icon_zoomminus,"icons/zoomminus.raw",SMYRNA_ICON_ZOOMMINUS);
+       SET_PATH(smyrna_icon_fisheye,"icons/fisheye.raw",SMYRNA_ICON_FISHEYE);
+    }
+
     s->panelcount = 0;
     s->panels = '\0';
     s->buttoncount = 0;
index 33a87b6d2b0dce803d6f9bb799bc6d377641debc..ee0fe05afd88a7820ac8b6b3d5743e72a34b3eed 100755 (executable)
@@ -42,8 +42,8 @@ int move_TVnodes();
 void local_zoom(topview * t);
 void originate_distorded_coordinates(topview * t);
 _BB void on_host_alpha_change(GtkWidget * widget, gpointer user_data);
-double dist(double x1, double y1, double x2, double y2);
-double G(double x);
+/* double dist(double x1, double y1, double x2, double y2); */
+/* double G(double x); */
 glCompSet *glcreate_gl_topview_menu();
 void fisheye_polar(double x_focus, double y_focus, topview * t);
 void prepare_topological_fisheye(topview * t);