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],
"");
116 gtk_widget_add_events(l->
fLabels[
id],
117 GDK_BUTTON_MOTION_MASK |
118 GDK_POINTER_MOTION_MASK |
119 GDK_BUTTON_PRESS_MASK | GDK_KEY_PRESS |
120 GDK_BUTTON_RELEASE_MASK |
121 GDK_SCROLL | GDK_VISIBILITY_NOTIFY_MASK);
123 gtk_widget_show(l->
fLabels[
id]);
125 gtk_fixed_put((GtkFixed *) glade_xml_get_widget(
xml,
"fixed6"),
126 l->
fLabels[
id], 10, 110 +
id * 13);
134 const attr_t *
const *c = candidate;
135 return strcasecmp(k, (*c)->name);
139 const attr_t *
const *a = x;
140 const attr_t *
const *b = y;
192 const char *start = a.
data + a.
size;
196 start += strlen(
" or ");
197 const char *end = strstr(start,
" or ");
201 a = (
strview_t){.
data = start, .size = (size_t)(end - start)};
218static int cmp(
const void *key,
const void *candidate) {
219 const attr_t *
const a = candidate;
220 return strncasecmp(key, a->
name, strlen(key));
239 res = strncasecmp(
prefix, (*attrp)->name, strlen(
prefix));
242 if (strncasecmp(
prefix, (*attrp)->name, strlen(
prefix)) != 0) {
246 for (
int res = 0; res == 0; ) {
247 res = strncasecmp(
prefix, (*attrp)->name, strlen(
prefix));
248 if (res == 0 && (*attrp)->objType[objKind] == 1)
275 gtk_widget_show(glade_xml_get_widget(
xml,
"txtValue"));
276 gtk_widget_show(glade_xml_get_widget(
xml,
"txtDefValue"));
278 gtk_entry_set_text((GtkEntry *)
279 glade_xml_get_widget(
xml,
"txtDefValue"),
"");
280 gtk_entry_set_text((GtkEntry *) glade_xml_get_widget(
xml,
"txtValue"),
282 gtk_widget_set_sensitive(glade_xml_get_widget(
xml,
"txtDefValue"), 1);
283 gtk_widget_show(glade_xml_get_widget(
xml,
"attrAddBtn"));
284 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrApplyBtn"));
285 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrApplyAllBtn"));
286 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrSearchBtn"));
287 gtk_toggle_button_set_active((GtkToggleButton *)
288 glade_xml_get_widget(
xml,
"attrProg"), 0);
290 if (strlen(
prefix) == 0) {
291 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrAddBtn"));
292 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrApplyBtn"));
293 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrApplyAllBtn"));
294 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrSearchBtn"));
295 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrAddBtn"));
296 gtk_widget_hide(glade_xml_get_widget(
xml,
"txtValue"));
297 gtk_widget_hide(glade_xml_get_widget(
xml,
"txtDefValue"));
307 gtk_entry_set_text((GtkEntry *)
308 glade_xml_get_widget(
xml,
312 gtk_entry_set_text((GtkEntry *)
313 glade_xml_get_widget(
xml,
317 gtk_entry_set_text((GtkEntry *)
318 glade_xml_get_widget(
xml,
321 gtk_widget_set_sensitive(glade_xml_get_widget
322 (
xml,
"txtDefValue"), 0);
323 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrAddBtn"));
324 gtk_widget_show(glade_xml_get_widget(
xml,
"attrApplyBtn"));
325 gtk_widget_show(glade_xml_get_widget(
xml,
"attrApplyAllBtn"));
326 gtk_widget_show(glade_xml_get_widget(
xml,
"attrSearchBtn"));
327 gtk_toggle_button_set_active((GtkToggleButton *)
328 glade_xml_get_widget(
xml,
341 gtk_widget_set_sensitive(glade_xml_get_widget(
xml,
"attrApplyBtn"),
365 (
char *) gtk_entry_get_text((GtkEntry *)
366 glade_xml_get_widget(
xml,
"txtAttr"));
367 const char *def_val = gtk_entry_get_text((GtkEntry *)
368 glade_xml_get_widget(
xml,
370 const char *value = gtk_entry_get_text((GtkEntry *)
371 glade_xml_get_widget(
xml,
"txtValue"));
373 gtk_toggle_button_get_active((GtkToggleButton *)
374 glade_xml_get_widget(
xml,
386 agset(g, attr_name, value);
388 else if (objKind ==
AGNODE) {
395 else if (objKind ==
AGEDGE) {
404 "on_attrApplyBtn_clicked: unknown object kind %d\n",
446 (
char *) gtk_entry_get_text((GtkEntry *)
447 glade_xml_get_widget(
xml,
"txtAttr"));
448 const char *defValue = gtk_entry_get_text((GtkEntry *)
449 glade_xml_get_widget(
xml,
471 else if (objKind ==
AGNODE) {
475 }
else if (objKind ==
AGEDGE) {
480 fprintf(stderr,
"on_attrAddBtn_clicked: unknown object kind %d\n",
491 static char *smyrna_attrs;
498 file = fopen(smyrna_attrs,
"r");
500 for (
size_t i = 0; fgets(buffer,
sizeof(buffer), file) !=
NULL; ++i) {
502 a = strtok(buffer,
",");
504 for (
int idx = 0; (a = strtok(
NULL,
",")); ++idx) {
579 snprintf(buf,
sizeof(buf),
"%d Nodes and %d edges selected", nodeCnt,
581 gtk_label_set_text((GtkLabel *) glade_xml_get_widget(
xml,
"label124"),
583 gtk_entry_set_text((GtkEntry *) glade_xml_get_widget(
xml,
"txtAttr"),
590 void *
const dlg = gtk_message_dialog_new(
NULL, GTK_DIALOG_MODAL,
591 GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK,
593 (void)gtk_dialog_run(dlg);
594 gtk_widget_destroy(dlg);
598 gtk_widget_hide(glade_xml_get_widget(
xml,
"dlgSettings"));
599 gtk_widget_show(glade_xml_get_widget(
xml,
"dlgSettings"));
600 gtk_notebook_set_current_page((GtkNotebook *)
601 glade_xml_get_widget(
xml,
"notebook3"),
607static void gvpr_select(
const char *attrname,
const char *regex_str,
612 agxbprint(&sf,
"N[%s==\"%s\"]{selected = \"1\"}", attrname, regex_str);
613 else if (objType ==
AGEDGE)
614 agxbprint(&sf,
"E[%s==\"%s\"]{selected = \"1\"}", attrname, regex_str);
619 char *argv[argc + 1] = {
"smyrna", bf2};
630 const char *attrname = gtk_entry_get_text((GtkEntry *)
631 glade_xml_get_widget(
xml,
"txtAttr"));
632 const char *regex_str = gtk_entry_get_text((GtkEntry *)
633 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, item)
#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