16#include <glade/glade.h>
17#include <gdk/gdkkeysyms.h>
44 if (gtk_toggle_button_get_active
45 ((GtkToggleButton *) glade_xml_get_widget(
xml,
"attrRB0")))
47 if (gtk_toggle_button_get_active
48 ((GtkToggleButton *) glade_xml_get_widget(
xml,
"attrRB1")))
50 if (gtk_toggle_button_get_active
51 ((GtkToggleButton *) glade_xml_get_widget(
xml,
"attrRB2")))
99 gtk_label_set_text(l->
fLabels[
id],
"");
115 l->
fLabels[
id] = (GtkLabel *) gtk_label_new(
"");
117 gtk_widget_add_events((GtkWidget *) l->
fLabels[
id],
118 GDK_BUTTON_MOTION_MASK |
119 GDK_POINTER_MOTION_MASK |
120 GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS |
121 GDK_BUTTON_RELEASE_MASK |
122 GDK_SCROLL | GDK_VISIBILITY_NOTIFY_MASK);
124 gtk_widget_show((GtkWidget *) l->
fLabels[
id]);
126 gtk_fixed_put((GtkFixed *) glade_xml_get_widget(
xml,
"fixed6"),
127 (GtkWidget *) l->
fLabels[
id], 10, 110 +
id * 13);
135 const attr_t *
const *c = candidate;
136 return strcasecmp(k, (*c)->name);
149 for (
size_t id = 0;
id < attrs_size(&l->
attributes); ++
id)
194 const char *start = a.
data + a.
size;
198 start += strlen(
" or ");
199 const char *end = strstr(start,
" or ");
203 a = (
strview_t){.
data = start, .size = (size_t)(end - start)};
223 while (high !=
SIZE_MAX && low <= high) {
224 size_t middle = (low + high) / 2;
225 int res = strncasecmp(searchKey, attrs_get(&l->
attributes, middle)->name, strlen(searchKey));
253 while (at->
index > 0 && res == 0) {
261 if (res == 0 && at->
objType[objKind] == 1)
275 for (
size_t ind = 0; ind < attrs_size(&fl->
attributes); ++ind) {
284 gtk_widget_show(glade_xml_get_widget(
xml,
"txtValue"));
285 gtk_widget_show(glade_xml_get_widget(
xml,
"txtDefValue"));
287 gtk_entry_set_text((GtkEntry *)
288 glade_xml_get_widget(
xml,
"txtDefValue"),
"");
289 gtk_entry_set_text((GtkEntry *) glade_xml_get_widget(
xml,
"txtValue"),
291 gtk_widget_set_sensitive(glade_xml_get_widget(
xml,
"txtDefValue"), 1);
292 gtk_widget_show(glade_xml_get_widget(
xml,
"attrAddBtn"));
293 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrApplyBtn"));
294 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrApplyAllBtn"));
295 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrSearchBtn"));
296 gtk_toggle_button_set_active((GtkToggleButton *)
297 glade_xml_get_widget(
xml,
"attrProg"), 0);
299 if (strlen(
prefix) == 0) {
300 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrAddBtn"));
301 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrApplyBtn"));
302 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrApplyAllBtn"));
303 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrSearchBtn"));
304 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrAddBtn"));
305 gtk_widget_hide(glade_xml_get_widget(
xml,
"txtValue"));
306 gtk_widget_hide(glade_xml_get_widget(
xml,
"txtDefValue"));
310 for (
size_t ind = 0; ind < attrs_size(&fl->
attributes); ++ind) {
316 gtk_entry_set_text((GtkEntry *)
317 glade_xml_get_widget(
xml,
321 gtk_entry_set_text((GtkEntry *)
322 glade_xml_get_widget(
xml,
326 gtk_entry_set_text((GtkEntry *)
327 glade_xml_get_widget(
xml,
330 gtk_widget_set_sensitive(glade_xml_get_widget
331 (
xml,
"txtDefValue"), 0);
332 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrAddBtn"));
333 gtk_widget_show(glade_xml_get_widget(
xml,
"attrApplyBtn"));
334 gtk_widget_show(glade_xml_get_widget(
xml,
"attrApplyAllBtn"));
335 gtk_widget_show(glade_xml_get_widget(
xml,
"attrSearchBtn"));
336 gtk_toggle_button_set_active((GtkToggleButton *)
337 glade_xml_get_widget(
xml,
347 gtk_widget_set_sensitive(glade_xml_get_widget(
xml,
"attrApplyBtn"),
361 if (strcasecmp(name,
"pos") == 0)
363 if (strcasecmp(name,
"color") == 0)
365 if (strcasecmp(name,
"selected") == 0)
382 (
char *) gtk_entry_get_text((GtkEntry *)
383 glade_xml_get_widget(
xml,
"txtAttr"));
384 const char *def_val = gtk_entry_get_text((GtkEntry *)
385 glade_xml_get_widget(
xml,
387 const char *value = gtk_entry_get_text((GtkEntry *)
388 glade_xml_get_widget(
xml,
"txtValue"));
390 gtk_toggle_button_get_active((GtkToggleButton *)
391 glade_xml_get_widget(
xml,
400 sym =
agattr(g, objKind, attr_name, def_val);
403 agset(g, attr_name, value);
405 else if (objKind ==
AGNODE) {
412 else if (objKind ==
AGEDGE) {
421 "on_attrApplyBtn_clicked: unknown object kind %d\n",
468 (
char *) gtk_entry_get_text((GtkEntry *)
469 glade_xml_get_widget(
xml,
"txtAttr"));
470 const char *defValue = gtk_entry_get_text((GtkEntry *)
471 glade_xml_get_widget(
xml,
495 else if (objKind ==
AGNODE) {
499 }
else if (objKind ==
AGEDGE) {
504 fprintf(stderr,
"on_attrAddBtn_clicked: unknown object kind %d\n",
515 static char *smyrna_attrs;
522 file = fopen(smyrna_attrs,
"r");
524 for (
size_t i = 0; fgets(buffer,
sizeof(buffer), file) !=
NULL; ++i) {
526 a = strtok(buffer,
",");
529 for (
int idx = 0; (a = strtok(
NULL,
",")); ++idx) {
607 snprintf(buf,
sizeof(buf),
"%d Nodes and %d edges selected", nodeCnt,
609 gtk_label_set_text((GtkLabel *) glade_xml_get_widget(
xml,
"label124"),
611 gtk_entry_set_text((GtkEntry *) glade_xml_get_widget(
xml,
"txtAttr"),
617 gtk_widget_hide(glade_xml_get_widget(
xml,
"dlgSettings"));
618 gtk_widget_show(glade_xml_get_widget(
xml,
"dlgSettings"));
619 gtk_notebook_set_current_page((GtkNotebook *)
620 glade_xml_get_widget(
xml,
"notebook3"),
626static void gvpr_select(
const char *attrname,
const char *regex_str,
635 agxbprint(&sf,
"N[%s==\"%s\"]{selected = \"1\"}", attrname, regex_str);
636 else if (objType ==
AGEDGE)
637 agxbprint(&sf,
"E[%s==\"%s\"]{selected = \"1\"}", attrname, regex_str);
646 argv[j++] =
"smyrna";
650 for (i = 1; i < argc; i++)
660 const char *attrname = gtk_entry_get_text((GtkEntry *)
661 glade_xml_get_widget(
xml,
"txtAttr"));
662 const char *regex_str = gtk_entry_get_text((GtkEntry *)
663 glade_xml_get_widget(
xml,
"txtValue"));
static int agxbprint(agxbuf *xb, const char *fmt,...)
Printf-style output to an agxbuf.
static char * agxbdisown(agxbuf *xb)
Memory allocation wrappers that exit on failure.
static char * gv_strdup(const char *original)
static void * gv_alloc(size_t size)
_BB void on_attrProg_toggled(GtkWidget *widget, gpointer user_data)
static void set_attr_object_type(const char *str, int *t)
static void object_type_helper(strview_t a, int *t)
_BB void on_attrAddBtn_clicked(GtkWidget *widget, gpointer user_data)
static char * safestrdup(const char *src)
static attr_list * attr_list_new(bool with_widgets)
static int attr_compare(const attr_t **a, const attr_t **b)
_BB void on_attrApplyBtn_clicked(GtkWidget *widget, gpointer user_data)
static attr_t * binarySearch(attr_list *l, const char *searchKey)
static void create_filtered_list(const char *prefix, attr_list *sl, attr_list *tl)
static void attr_list_add(attr_list *l, attr_t *a)
static attr_t * new_attr_with_ref(Agsym_t *sym)
static attr_t * new_attr(void)
_BB void on_attrRB0_clicked(GtkWidget *widget, gpointer user_data)
_BB void on_txtAttr_changed(GtkWidget *widget, gpointer user_data)
static attr_t * new_attr_ref(attr_t *refAttr)
static void reset_attr_list_widgets(attr_list *l)
void showAttrsWidget(void)
static void doApply(void)
static void set_header_text(void)
static void set_refresh_filters(ViewInfo *v, char *name)
static attr_data_type get_attr_data_type(char c)
static void gvpr_select(const char *attrname, const char *regex_str, int objType)
static int attr_compare_core(const void *key, const void *candidate)
static attr_t * pBinarySearch(attr_list *l, const char *searchKey)
static int get_object_type(void)
_BB void on_attrSearchBtn_clicked(GtkWidget *widget, gpointer user_data)
static void filter_attributes(const char *prefix, topview *t)
attr_list * load_attr_list(Agraph_t *g)
#define ATTR_NOTEBOOK_IDX
require define api prefix
Agsym_t * agattr(Agraph_t *g, int kind, char *name, const char *value)
creates or looks up attributes of a graph
int agset(void *obj, char *name, const char *value)
Agsym_t * agnxtattr(Agraph_t *g, int kind, Agsym_t *attr)
permits traversing the list of attributes of a given type
int agxset(void *obj, Agsym_t *sym, const char *value)
Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Agnode_t * agfstnode(Agraph_t *g)
void Color_Widget_bg(char *colorstring, GtkWidget *widget)
int run_gvpr(Agraph_t *srcGraph, size_t argc, char *argv[])
char * smyrnaPath(char *suffix)
#define MAX_FILTERED_ATTR_COUNT
static bool startswith(const char *s, const char *prefix)
does the string s begin with the string prefix?
platform abstraction for case-insensitive string functions
GtkLabel * fLabels[MAX_FILTERED_ATTR_COUNT]
a non-owning string reference
const char * data
start of the pointed to string
size_t size
extent of the string in bytes
Non-owning string references.
static bool strview_str_eq(strview_t a, const char *b)
compare a string reference to a string for equality
static strview_t strview(const char *referent, char terminator)
create a string reference