From fc4b8c849ea8b97265b69db502e1ef543c82d015 Mon Sep 17 00:00:00 2001 From: erg Date: Mon, 22 Jun 2009 20:53:47 +0000 Subject: [PATCH] Combine shared code; reformat --- cmd/smyrna/viewport.c | 45 ++++++++++--------------------------------- 1 file changed, 10 insertions(+), 35 deletions(-) diff --git a/cmd/smyrna/viewport.c b/cmd/smyrna/viewport.c index a347e87c6..59482bd43 100755 --- a/cmd/smyrna/viewport.c +++ b/cmd/smyrna/viewport.c @@ -582,37 +582,15 @@ static void refresh_borders(Agraph_t* g) /* add_graph_to_viewport_from_file: - * returns 1 if successfull else 0 + * returns 1 if successful else 0 */ int add_graph_to_viewport_from_file(char *fileName) { - //returns 1 if successfull else 0 - Agraph_t *graph; - - graph = loadGraph(fileName); - if (graph) { - view->graphCount = view->graphCount + 1; - view->g = - (Agraph_t **) realloc(view->g, - sizeof(Agraph_t *) * view->graphCount); - view->g[view->graphCount - 1] = graph; - view->activeGraph = view->graphCount - 1; - load_settings_from_graph(view->g[view->activeGraph]); - update_graph_from_settings(view->g[view->activeGraph]); - set_viewport_settings_from_template(view, view->g[view->activeGraph]); - update_topview(graph, view->Topview,1); - fill_key(view->orig_key,get_md5_key(graph)); - expose_event(view->drawing_area, NULL, NULL); - - - return 1; - } else - { - return 0; - - } + Agraph_t *graph = loadGraph(fileName); + return add_graph_to_viewport (graph); } + int add_graph_to_viewport(Agraph_t* graph) { if (graph) { @@ -624,18 +602,15 @@ int add_graph_to_viewport(Agraph_t* graph) view->activeGraph = view->graphCount - 1; load_settings_from_graph(view->g[view->activeGraph]); update_graph_from_settings(view->g[view->activeGraph]); - set_viewport_settings_from_template(view, view->g[view->activeGraph]); + set_viewport_settings_from_template(view, view->g[view->activeGraph]); update_topview(graph, view->Topview,1); fill_key(view->orig_key,get_md5_key(graph)); - expose_event(view->drawing_area, NULL, NULL); - - + expose_event(view->drawing_area, NULL, NULL); return 1; - } else - { - return 0; - - } + } + else { + return 0; + } } -- 2.50.1