void mQuitSlot(GtkWidget * widget, gpointer user_data)
{
- //1 check all graphs 1 by 1 to see any unsaved
- int respond;
- int gIndex;
-#ifdef UNUSED
- int active_graph = view->activeGraph; //stores the active graph in case quit aborted
-#endif
- for (gIndex = 0; gIndex < view->graphCount; gIndex++) {
- view->activeGraph = gIndex;
- if (view->Topview->Graphdata.Modified)
- {
- sprintf(buf,
- "graph %s has been modified \n , would you like to save it before quitting the the program?",
- view->Topview->Graphdata.GraphFileName);
- Dlg =
- (GtkMessageDialog *) gtk_message_dialog_new(NULL,
- GTK_DIALOG_MODAL,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE,
- buf);
- gtk_dialog_add_button((GtkDialog *) Dlg, "YES", 100);
- gtk_dialog_add_button((GtkDialog *) Dlg, "NO", 101);
- gtk_dialog_add_button((GtkDialog *) Dlg, "Cancel", 102);
-
- respond = gtk_dialog_run((GtkDialog *) Dlg);
- if (respond == 100) //save and continue
- {
- if (!save_graph())
- break;
- }
- if (respond == 102) //save and continue
- {
- break;
- }
- }
- }
- gtk_main_quit();
+ if (close_graph(view,view->activeGraph));
+ gtk_main_quit();
}
+int show_close_nosavedlg(void)
+{
+ GtkWidget *dialog;
+ char buf[512];
+ int rv; /*return value*/
+ sprintf(buf,"%s has been modified. Do you want to save it before closing?",view->Topview->Graphdata.GraphFileName);
+ dialog = gtk_message_dialog_new(NULL,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE,
+ buf);
+
+ gtk_window_set_title(GTK_WINDOW(dialog), "Smyrna Warning");
+ gtk_dialog_add_button(dialog,"Yes",0);
+ gtk_dialog_add_button(dialog,"No",1);
+ gtk_dialog_add_button(dialog,"Cancel",2);
+ rv=gtk_dialog_run(GTK_DIALOG(dialog));
+ gtk_widget_destroy(dialog);
+ return rv;
+}
+
+
//edit
void mCutSlot(GtkWidget * widget, gpointer user_data)
}
-static Agraph_t* test_cgraph(Agraph_t* g,char* filename)
-{
-
- Agnode_t *v;
- Agedge_t *e;
- FILE *input_file;
- char buf[512];
- if (g)
- close_cgraph(g);
-
- if (!(input_file = fopen(filename, "r")))
- {
- g_print("Cannot open %s\n", filename);
- return 0;
- }
- if (!(g = agread(input_file, NIL(Agdisc_t *))))
- {
- g_print("Cannot read graph in %s\n", filename);
- fclose (input_file);
- return 0;
- }
-
- for (v = agfstnode(g); v; v = agnxtnode(g, v))
- {
- agbindrec(v, "temp_node_record", sizeof(temp_node_record), TRUE);//graph custom data
- }
- for (v = agfstnode(g); v; v = agnxtnode(g, v))
- {
- for (e = agfstout(g, v); e; e = agnxtout(g, e))
- {
- strcpy(buf, agget(aghead(e), "pos"));
- }
- }
-
- return g;
-}
-static void test_md5()
-{
- char buf[512];
- BYTE digest[16];
- md5_state_t pms;
- int ind=0;
-
- strcpy(buf,"sdfsdfsdfasdf asdfas dasdf asdf asdfas fsd asd fasdf asd fasdf sda fsdf asdf sda fasfsdf sdf sdf");
- /* Initialize the algorithm. */
- md5_init(&pms);
- for (ind =0 ; ind < 1500000 ; ind ++)
- {
- md5_append(&pms,buf,32);
- }
- md5_finish(&pms,digest);
- for (ind=0;ind < 16;ind ++)
- {
- printf ("%x ",digest[ind]);
- }
-}
GdkGLConfig *glconfig;
char* initFileName;
Agraph_t* g=NULL;
- Agraph_t* testg=NULL;
-
-// testg=test_cgraph(testg,"c:/4elt.gv");
-// agclose(testg);
-// test_cgraph(testg,"c:/4elt.gv");
- test_md5();
-
-
-
smyrnaDir = getenv ("SMYRNA_PATH");
#ifndef _WIN32
if (!smyrnaDir)
#include "glcompset.h"
#include "hier.h"
+typedef unsigned char BYTE;
+
#define IS_TEST_MODE_ON 0
#define DEFAULT_MAGNIFIER_WIDTH 300
#define DEFAULT_MAGNIFIER_HEIGHT 225
/*free topview if there is one */
if (view->activeGraph >= 0)
cleartopview(view->Topview);
- if (view->graphCount) {
- /*all cgraph graphs should be freed */
- for (ind = 0; ind < view->graphCount; ind++) {
- agclose(view->g[ind]);
- }
- /*frees itself */
- }
- free(view);
+ if (view->graphCount)
+ agclose(view->g[view->activeGraph]);
+ init_viewport(view);
}
static void* get_glut_font(int ind)
{
}
}
-static fill_key(BYTE* b,BYTE* data)
+static void fill_key(BYTE* b,BYTE* data)
{
int ind=0;
for (ind=0;ind < 16;ind ++)
}
}
+static int compare_keys(BYTE* b1,BYTE* b2)
+{
+ /*1 keys are equal*/
+ /*0 not equal*/
+
+ int ind=0;
+ int eq=1;
+ for (ind=0;ind < 16;ind ++)
+ {
+ if (b1[ind] != b2[ind])
+ {
+ eq=0;
+ }
+ }
+ return eq;
+}
-void close_graph(ViewInfo * view,int graphid)
+int close_graph(ViewInfo * view,int graphid)
{
int ind=0;
int modified=0;
- /*check if graph has been modified*/
+ if (view->activeGraph < 0)
+ return 1;
fill_key(view->final_key,get_md5_key(view->g[graphid]));
- printf ("graph original identification:");
- for (ind=0;ind < 16;ind ++)
- {
- printf ("%x ",view->orig_key[ind]);
- }
- printf ("graph final identification:");
- for (ind=0;ind < 16;ind ++)
+ if (!compare_keys(view->final_key,view->orig_key))
+ view->Topview->Graphdata.Modified=1;
+ if (view->Topview->Graphdata.Modified)
{
- printf ("%x ",view->final_key[ind]);
- }
+ switch (show_close_nosavedlg())
+ {
+ case 0: /*save and close*/
+ save_graph();
+ clear_viewport(view);
+ return 1;
+ break;
+ case 1:/*dont save but close*/
+ clear_viewport(view);
+ return 1;
+ break;
+ case 2:/*cancel do nothing*/
+ return 0;
+ break;
+ default:
+ break;
+ }
+ }
+ clear_viewport(view);
+ return 1;
- if (graphid >= 0)
- cleartopview(view->Topview);
- agclose(view->g[0]);
- view->graphCount = view->graphCount -1;
- view->activeGraph=-1;
}
char *get_attribute_value(char *attr, ViewInfo * view, Agraph_t * g)
expose_event(view->drawing_area, NULL, NULL);
}
int gl_main_expose(void) {
- if(view->Topview->animate==1)
- expose_event(view->drawing_area, NULL, NULL);
- return 1;
+ if (view->activeGraph >= 0)
+ {
+ if(view->Topview->animate==1)
+ expose_event(view->drawing_area, NULL, NULL);
+ return 1;
+ }
}
gtk_widget_hide(glade_xml_get_widget(xml, "frmWait"));
}
+
+
void set_viewport_settings_from_template(ViewInfo * view, Agraph_t *);
void clear_viewport(ViewInfo * view);
int add_graph_to_viewport_from_file(char *fileName);
-void close_graph(ViewInfo * view,int graphid);
+int close_graph(ViewInfo * view,int graphid);
int save_graph(void);
int save_graph_with_file_name(Agraph_t * graph, char *fileName);
int save_as_graph(void);