18#include <glade/glade.h>
19#include <gdk/gdkkeysyms.h>
46 if (gtk_toggle_button_get_active
47 ((GtkToggleButton *) glade_xml_get_widget(
xml,
"attrRB0")))
49 if (gtk_toggle_button_get_active
50 ((GtkToggleButton *) glade_xml_get_widget(
xml,
"attrRB1")))
52 if (gtk_toggle_button_get_active
53 ((GtkToggleButton *) glade_xml_get_widget(
xml,
"attrRB2")))
101 gtk_label_set_text(l->
fLabels[
id],
"");
118 gtk_widget_add_events(l->
fLabels[
id],
119 GDK_BUTTON_MOTION_MASK |
120 GDK_POINTER_MOTION_MASK |
121 GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS |
122 GDK_BUTTON_RELEASE_MASK |
123 GDK_SCROLL | GDK_VISIBILITY_NOTIFY_MASK);
125 gtk_widget_show(l->
fLabels[
id]);
127 gtk_fixed_put((GtkFixed *) glade_xml_get_widget(
xml,
"fixed6"),
128 l->
fLabels[
id], 10, 110 +
id * 13);
136 const attr_t *
const *c = candidate;
137 return strcasecmp(k, (*c)->name);
141 const attr_t *
const *a = x;
142 const attr_t *
const *b = y;
190 const char *start = a.
data + a.
size;
194 start += strlen(
" or ");
195 const char *end = strstr(start,
" or ");
199 a = (
strview_t){.
data = start, .size = (size_t)(end - start)};
216static int cmp(
const void *key,
const void *candidate) {
217 const attr_t *
const a = candidate;
218 return strncasecmp(key, a->
name, strlen(key));
237 res = strncasecmp(
prefix, (*attrp)->name, strlen(
prefix));
240 if (strncasecmp(
prefix, (*attrp)->name, strlen(
prefix)) != 0) {
244 for (
int res = 0; res == 0; ) {
245 res = strncasecmp(
prefix, (*attrp)->name, strlen(
prefix));
246 if (res == 0 && (*attrp)->objType[objKind] == 1)
273 gtk_widget_show(glade_xml_get_widget(
xml,
"txtValue"));
274 gtk_widget_show(glade_xml_get_widget(
xml,
"txtDefValue"));
276 gtk_entry_set_text((GtkEntry *)
277 glade_xml_get_widget(
xml,
"txtDefValue"),
"");
278 gtk_entry_set_text((GtkEntry *) glade_xml_get_widget(
xml,
"txtValue"),
280 gtk_widget_set_sensitive(glade_xml_get_widget(
xml,
"txtDefValue"), 1);
281 gtk_widget_show(glade_xml_get_widget(
xml,
"attrAddBtn"));
282 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrApplyBtn"));
283 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrApplyAllBtn"));
284 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrSearchBtn"));
285 gtk_toggle_button_set_active((GtkToggleButton *)
286 glade_xml_get_widget(
xml,
"attrProg"), 0);
288 if (strlen(
prefix) == 0) {
289 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrAddBtn"));
290 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrApplyBtn"));
291 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrApplyAllBtn"));
292 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrSearchBtn"));
293 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrAddBtn"));
294 gtk_widget_hide(glade_xml_get_widget(
xml,
"txtValue"));
295 gtk_widget_hide(glade_xml_get_widget(
xml,
"txtDefValue"));
305 gtk_entry_set_text((GtkEntry *)
306 glade_xml_get_widget(
xml,
310 gtk_entry_set_text((GtkEntry *)
311 glade_xml_get_widget(
xml,
315 gtk_entry_set_text((GtkEntry *)
316 glade_xml_get_widget(
xml,
319 gtk_widget_set_sensitive(glade_xml_get_widget
320 (
xml,
"txtDefValue"), 0);
321 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrAddBtn"));
322 gtk_widget_show(glade_xml_get_widget(
xml,
"attrApplyBtn"));
323 gtk_widget_show(glade_xml_get_widget(
xml,
"attrApplyAllBtn"));
324 gtk_widget_show(glade_xml_get_widget(
xml,
"attrSearchBtn"));
325 gtk_toggle_button_set_active((GtkToggleButton *)
326 glade_xml_get_widget(
xml,
339 gtk_widget_set_sensitive(glade_xml_get_widget(
xml,
"attrApplyBtn"),
363 (
char *) gtk_entry_get_text((GtkEntry *)
364 glade_xml_get_widget(
xml,
"txtAttr"));
365 const char *def_val = gtk_entry_get_text((GtkEntry *)
366 glade_xml_get_widget(
xml,
368 const char *value = gtk_entry_get_text((GtkEntry *)
369 glade_xml_get_widget(
xml,
"txtValue"));
371 gtk_toggle_button_get_active((GtkToggleButton *)
372 glade_xml_get_widget(
xml,
384 agset(g, attr_name, value);
386 else if (objKind ==
AGNODE) {
393 else if (objKind ==
AGEDGE) {
402 "on_attrApplyBtn_clicked: unknown object kind %d\n",
444 (
char *) gtk_entry_get_text((GtkEntry *)
445 glade_xml_get_widget(
xml,
"txtAttr"));
446 const char *defValue = gtk_entry_get_text((GtkEntry *)
447 glade_xml_get_widget(
xml,
469 else if (objKind ==
AGNODE) {
473 }
else if (objKind ==
AGEDGE) {
478 fprintf(stderr,
"on_attrAddBtn_clicked: unknown object kind %d\n",
489 static char *smyrna_attrs;
496 file = fopen(smyrna_attrs,
"r");
498 while (fgets(buffer,
sizeof(buffer), file) !=
NULL) {
500 a = strtok(buffer,
",");
502 for (
int idx = 0; (a = strtok(
NULL,
",")); ++idx) {
577 snprintf(buf,
sizeof(buf),
"%d Nodes and %d edges selected", nodeCnt,
579 gtk_label_set_text((GtkLabel *) glade_xml_get_widget(
xml,
"label124"),
581 gtk_entry_set_text((GtkEntry *) glade_xml_get_widget(
xml,
"txtAttr"),
588 void *
const dlg = gtk_message_dialog_new(
NULL, GTK_DIALOG_MODAL,
589 GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK,
591 (void)gtk_dialog_run(dlg);
592 gtk_widget_destroy(dlg);
596 gtk_widget_hide(glade_xml_get_widget(
xml,
"dlgSettings"));
597 gtk_widget_show(glade_xml_get_widget(
xml,
"dlgSettings"));
598 gtk_notebook_set_current_page((GtkNotebook *)
599 glade_xml_get_widget(
xml,
"notebook3"),
605static void gvpr_select(
const char *attrname,
const char *regex_str,
610 agxbprint(&sf,
"N[%s==\"%s\"]{selected = \"1\"}", attrname, regex_str);
611 else if (objType ==
AGEDGE)
612 agxbprint(&sf,
"E[%s==\"%s\"]{selected = \"1\"}", attrname, regex_str);
617 char *argv[argc + 1] = {
"smyrna", bf2};
628 const char *attrname = gtk_entry_get_text((GtkEntry *)
629 glade_xml_get_widget(
xml,
"txtAttr"));
630 const char *regex_str = gtk_entry_get_text((GtkEntry *)
631 glade_xml_get_widget(
xml,
"txtValue"));
Dynamically expanding string buffers.
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)
static void set_attr_object_type(const char *str, int *t)
static void object_type_helper(strview_t a, int *t)
static char * safestrdup(const char *src)
static attr_list * attr_list_new(bool with_widgets)
_BB void on_attrApplyBtn_clicked(GtkWidget *widget, void *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 int cmp(const void *key, const void *candidate)
static attr_t * new_attr_with_ref(Agsym_t *sym)
static attr_t * new_attr(void)
_BB void on_attrSearchBtn_clicked(GtkWidget *widget, void *user_data)
static attr_t * new_attr_ref(attr_t *refAttr)
static void reset_attr_list_widgets(attr_list *l)
_BB void on_attrProg_toggled(GtkWidget *widget, void *user_data)
void showAttrsWidget(void)
static void doApply(void)
static void set_header_text(void)
static int attr_compare(const void *x, const void *y)
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 int get_object_type(void)
_BB void on_txtAttr_changed(GtkWidget *widget, void *user_data)
static void filter_attributes(const char *prefix, topview *t)
_BB void on_attrAddBtn_clicked(GtkWidget *widget, void *user_data)
_BB void on_attrRB0_clicked(GtkWidget *widget, void *user_data)
attr_list * load_attr_list(Agraph_t *g)
#define ATTR_NOTEBOOK_IDX
require define api prefix
Agsym_t * agattr_text(Agraph_t *g, int kind, char *name, const char *value)
creates or looks up text 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[])
textitem scanner parser str
#define LIST_APPEND(list,...)
#define LIST_SORT(list, cmp)
#define LIST_IS_EMPTY(list)
#define LIST_GET(list, index)
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
void * 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