aboutsummaryrefslogtreecommitdiffstats
path: root/gg_map/gg_map.c
diff options
context:
space:
mode:
authorLaurent Ghigonis <laurent@p1sec.com>2012-12-13 18:01:44 +0100
committerLaurent Ghigonis <laurent@p1sec.com>2012-12-13 18:01:44 +0100
commit0aea74313157abf679cd6c1449257bd9a6cc2ba3 (patch)
tree18582301cbf893ea6cd0759f038e66a8b892f135 /gg_map/gg_map.c
parentattach and detach node groups to "inactive tree" or to current active node (diff)
downloadglouglou-0aea74313157abf679cd6c1449257bd9a6cc2ba3.tar.xz
glouglou-0aea74313157abf679cd6c1449257bd9a6cc2ba3.zip
improve gg_map UI, by using copying from egraph demoapp
Diffstat (limited to 'gg_map/gg_map.c')
-rw-r--r--gg_map/gg_map.c224
1 files changed, 207 insertions, 17 deletions
diff --git a/gg_map/gg_map.c b/gg_map/gg_map.c
index 2d710de..11d19f7 100644
--- a/gg_map/gg_map.c
+++ b/gg_map/gg_map.c
@@ -9,7 +9,7 @@
int _debug = 0;
Evas_Object *_mainwin;
-Evas_Object *_egraph;
+Evas_Object *_egraph = NULL;
struct ggnet *_ggnet;
struct event_base *_ev_base;
@@ -252,6 +252,100 @@ _cb_packet(struct gg_client *cli, struct gg_packet *pkt)
return 0;
}
+/* static void
+_cb_del_edges(void *data, Evas_Object *obj, void *event_info)
+{
+ if (!_egraph)
+ return;
+
+ // XXX ggnet_clear(_ggnet);
+ egraph_clear(_egraph);
+} */
+
+static void
+_cb_show_nodes(void *data, Evas_Object *obj, void *event_info)
+{
+ egraph_display_vertices_set(_egraph, elm_check_state_get(obj));
+}
+
+static void
+_cb_show_labels(void *data, Evas_Object *obj, void *event_info)
+{
+ if (!_egraph)
+ return;
+
+ egraph_display_names_set(_egraph, elm_check_state_get(obj));
+}
+
+static void
+_cb_show_edges(void *data, Evas_Object *obj, void *event_info)
+{
+ if (!_egraph)
+ return;
+
+ egraph_display_edges_set(_egraph, elm_check_state_get(obj));
+}
+
+static void
+_cb_use_animations(void *data, Evas_Object *obj, void *event_info)
+{
+ if (!_egraph)
+ return;
+
+ egraph_use_animations_set(_egraph, elm_check_state_get(obj));
+}
+
+static void
+_cb_do_improvements(void *data, Evas_Object *obj, void *event_info)
+{
+ if (!_egraph)
+ return;
+
+ egraph_do_improvements_set(_egraph, elm_check_state_get(obj));
+}
+
+static void
+_cb_use_theme_v(void *data, Evas_Object *obj, void *event_info)
+{
+ if (!_egraph)
+ return;
+
+ egraph_theme_vertices_set(_egraph, elm_check_state_get(obj));
+}
+
+static void
+_cb_use_theme_e(void *data, Evas_Object *obj, void *event_info)
+{
+ if (!_egraph)
+ return;
+
+ egraph_theme_edges_set(_egraph, elm_check_state_get(obj));
+}
+
+static void
+_cb_layout_changed(void *data, Evas_Object *obj, void *event_info)
+{
+ Elm_Object_Item *it;
+ char *selected;
+ int layout;
+
+ if (!_egraph)
+ return;
+
+ it = event_info;
+ selected = elm_object_item_text_get(it);
+ layout = EGRAPH_LAYOUT_DEFAULT;
+ if (!strcmp(selected, "Kamada K."))
+ layout = EGRAPH_LAYOUT_KAMADAKAWAI;
+ else if (!strcmp(selected, "GraphOpt"))
+ layout = EGRAPH_LAYOUT_GRAPHOPT;
+ else if (!strcmp(selected, "Fruchterman R."))
+ layout = EGRAPH_LAYOUT_FRUCHTERMANREINGOLD;
+
+ egraph_layout_set(_egraph, layout);
+}
+
+
static void
_cb_on_done(void *data, Evas_Object *obj, void *event_info)
{
@@ -261,14 +355,15 @@ _cb_on_done(void *data, Evas_Object *obj, void *event_info)
EAPI_MAIN int
elm_main(int argc, char **argv)
{
- Evas_Object *win, *bg, *panes, *bt, *egraph;
+ Evas_Object *win, *bg, *egraph, *panes;
+ Evas_Object *bx, *tb, *tb_it, *ck, *sc, *seg_it, *lb;
Evas *evas;
struct gg_client *ggcli;
int retval = -1;
win = elm_win_add(NULL, "panes", ELM_WIN_BASIC);
evas = evas_object_evas_get(win);
- elm_win_title_set(win, "Glouglou Network Mapper");
+ elm_win_title_set(win, "Glouglou Network Map");
evas_object_smart_callback_add(win, "delete,request", _cb_on_done, NULL);
bg = elm_bg_add(win);
@@ -277,33 +372,128 @@ elm_main(int argc, char **argv)
evas_object_color_set(bg, 0, 0, 0, 255);
evas_object_show(bg);
+ bx = elm_box_add(win);
+ elm_box_horizontal_set(bx, EINA_TRUE);
+ evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ elm_win_resize_object_add(win, bx);
+ evas_object_show(bx);
+
+ tb = elm_toolbar_add(win);
+ elm_toolbar_homogeneous_set(tb, EINA_FALSE);
+ elm_toolbar_horizontal_set(tb, EINA_FALSE);
+ elm_toolbar_shrink_mode_set(tb, ELM_TOOLBAR_SHRINK_EXPAND);
+ elm_toolbar_select_mode_set(tb, ELM_OBJECT_SELECT_MODE_ALWAYS);
+ elm_toolbar_transverse_expanded_set(tb, EINA_TRUE);
+ elm_object_style_set(tb, "item_centered");
+ evas_object_size_hint_weight_set(tb, 0.0, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_box_pack_end(bx, tb);
+ evas_object_show(tb);
+ //elm_toolbar_item_append(tb, "edit-delete", "Delete all",
+ // _cb_del_edges, NULL);
+ elm_toolbar_item_separator_set(elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL), EINA_FALSE);
+ lb = elm_label_add(win);
+ elm_object_text_set(lb, "<b>Layout</b>");
+ evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+ evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL);
+ elm_object_item_part_content_set(tb_it, "object", lb);
+ sc = elm_segment_control_add(win);
+ //evas_object_size_hint_weight_set(sc, em->weight.w, em->weight.h);
+ //evas_object_size_hint_align_set(sc, em->align.x, em->align.y);
+ seg_it = elm_segment_control_item_add(sc, NULL, "GraphOpt");
+ elm_segment_control_item_selected_set(seg_it, EINA_TRUE);
+ seg_it = elm_segment_control_item_add(sc, NULL, "Kamada K.");
+ elm_segment_control_item_selected_set(seg_it, EINA_FALSE);
+ seg_it = elm_segment_control_item_add(sc, NULL, "Fruchterman R.");
+ elm_segment_control_item_selected_set(seg_it, EINA_FALSE);
+ evas_object_smart_callback_add(sc, "changed", _cb_layout_changed, NULL);
+ evas_object_show(sc);
+ tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL);
+ elm_object_item_part_content_set(tb_it, "object", sc);
+ elm_toolbar_item_separator_set(elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL), EINA_FALSE);
+ ck = elm_check_add(win);
+ elm_object_text_set(ck, "Show Node");
+ elm_check_state_set(ck, EINA_TRUE);
+ evas_object_show(ck);
+ evas_object_smart_callback_add(ck, "changed", _cb_show_nodes, NULL);
+ tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL);
+ elm_object_item_part_content_set(tb_it, "object", ck);
+ ck = elm_check_add(win);
+ elm_object_text_set(ck, "Show Label");
+ elm_check_state_set(ck, EINA_TRUE);
+ evas_object_show(ck);
+ evas_object_smart_callback_add(ck, "changed", _cb_show_labels, NULL);
+ tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL);
+ elm_object_item_part_content_set(tb_it, "object", ck);
+ ck = elm_check_add(win);
+ elm_object_text_set(ck, "Show Edges");
+ elm_check_state_set(ck, EINA_TRUE);
+ evas_object_show(ck);
+ evas_object_smart_callback_add(ck, "changed", _cb_show_edges, NULL);
+ tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL);
+ elm_object_item_part_content_set(tb_it, "object", ck);
+ ck = elm_check_add(win);
+ elm_object_text_set(ck, "Use animations");
+ elm_check_state_set(ck, EINA_TRUE);
+ evas_object_show(ck);
+ evas_object_smart_callback_add(ck, "changed", _cb_use_animations, NULL);
+ tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL);
+ elm_object_item_part_content_set(tb_it, "object", ck);
+ ck = elm_check_add(win);
+ elm_object_text_set(ck, "Do improvements");
+ elm_check_state_set(ck, EINA_TRUE);
+ evas_object_show(ck);
+ evas_object_smart_callback_add(ck, "changed", _cb_do_improvements, NULL);
+ tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL);
+ elm_object_item_part_content_set(tb_it, "object", ck);
+ ck = elm_check_add(win);
+ elm_object_text_set(ck, "Use theme for vertices");
+ elm_check_state_set(ck, EINA_TRUE);
+ evas_object_show(ck);
+ evas_object_smart_callback_add(ck, "changed", _cb_use_theme_v, NULL);
+ tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL);
+ elm_object_item_part_content_set(tb_it, "object", ck);
+ ck = elm_check_add(win);
+ elm_object_text_set(ck, "Use theme for edges");
+ elm_check_state_set(ck, EINA_TRUE);
+ evas_object_show(ck);
+ evas_object_smart_callback_add(ck, "changed", _cb_use_theme_e, NULL);
+ tb_it = elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL);
+ elm_object_item_part_content_set(tb_it, "object", ck);
+ //elm_toolbar_item_separator_set(elm_toolbar_item_append(tb, NULL, NULL, NULL, NULL), EINA_FALSE);
+ elm_toolbar_item_append(tb, "exit", "Quit",
+ _cb_on_done, NULL);
+
panes = elm_panes_add(win);
- elm_win_resize_object_add(win, panes);
evas_object_size_hint_weight_set(panes, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(panes, EVAS_HINT_FILL, EVAS_HINT_FILL);
+ elm_panes_content_right_size_set(panes, 0.0);
+ elm_box_pack_end(bx, panes);
evas_object_show(panes);
- bt = elm_button_add(win);
- elm_object_text_set(bt, "Quit");
- //evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- //evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
- evas_object_smart_callback_add(bt, "clicked", _cb_on_done, bt);
- evas_object_show(bt);
- elm_object_part_content_set(panes, "left", bt);
-
egraph = egraph_new(evas, 1);
if (!egraph)
goto quit;
- egraph_layout_set(egraph, EGRAPH_LAYOUT_FRUCHTERMANREINGOLD); // XXX
evas_object_size_hint_weight_set(egraph, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(egraph, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(egraph);
- elm_object_part_content_set(panes, "right", egraph);
-
- evas_object_resize(win, 320, 400);
+ elm_object_part_content_set(panes, "left", egraph);
+
+ lb = elm_label_add(win);
+ elm_object_style_set(lb, "marker");
+ evas_object_color_set(lb, 255, 255, 255, 255);
+ elm_object_text_set(lb,
+ "Glouglou Network Mapper<br/>"
+ "<br/>"
+ "Enjoy !<br/>");
+ evas_object_show(lb);
+ elm_object_part_content_set(panes, "right", lb);
+
+ evas_object_resize(win, 150, 150); // XXX workaround elm sizing issue
evas_object_show(win);
+ evas_object_resize(win, 950, 715);
evas_object_show(win);
-
_egraph = egraph;
_mainwin = win;