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;
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)};
220static int cmp(
const void *key,
const void *candidate) {
221 const attr_t *
const a = candidate;
222 return strncasecmp(key, a->
name, strlen(key));
241 res = strncasecmp(
prefix, (*attrp)->name, strlen(
prefix));
244 if (strncasecmp(
prefix, (*attrp)->name, strlen(
prefix)) != 0) {
248 for (
int res = 0; res == 0; ) {
249 res = strncasecmp(
prefix, (*attrp)->name, strlen(
prefix));
250 if (res == 0 && (*attrp)->objType[objKind] == 1)
277 gtk_widget_show(glade_xml_get_widget(
xml,
"txtValue"));
278 gtk_widget_show(glade_xml_get_widget(
xml,
"txtDefValue"));
280 gtk_entry_set_text((GtkEntry *)
281 glade_xml_get_widget(
xml,
"txtDefValue"),
"");
282 gtk_entry_set_text((GtkEntry *) glade_xml_get_widget(
xml,
"txtValue"),
284 gtk_widget_set_sensitive(glade_xml_get_widget(
xml,
"txtDefValue"), 1);
285 gtk_widget_show(glade_xml_get_widget(
xml,
"attrAddBtn"));
286 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrApplyBtn"));
287 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrApplyAllBtn"));
288 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrSearchBtn"));
289 gtk_toggle_button_set_active((GtkToggleButton *)
290 glade_xml_get_widget(
xml,
"attrProg"), 0);
292 if (strlen(
prefix) == 0) {
293 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrAddBtn"));
294 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrApplyBtn"));
295 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrApplyAllBtn"));
296 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrSearchBtn"));
297 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrAddBtn"));
298 gtk_widget_hide(glade_xml_get_widget(
xml,
"txtValue"));
299 gtk_widget_hide(glade_xml_get_widget(
xml,
"txtDefValue"));
309 gtk_entry_set_text((GtkEntry *)
310 glade_xml_get_widget(
xml,
314 gtk_entry_set_text((GtkEntry *)
315 glade_xml_get_widget(
xml,
319 gtk_entry_set_text((GtkEntry *)
320 glade_xml_get_widget(
xml,
323 gtk_widget_set_sensitive(glade_xml_get_widget
324 (
xml,
"txtDefValue"), 0);
325 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrAddBtn"));
326 gtk_widget_show(glade_xml_get_widget(
xml,
"attrApplyBtn"));
327 gtk_widget_show(glade_xml_get_widget(
xml,
"attrApplyAllBtn"));
328 gtk_widget_show(glade_xml_get_widget(
xml,
"attrSearchBtn"));
329 gtk_toggle_button_set_active((GtkToggleButton *)
330 glade_xml_get_widget(
xml,
343 gtk_widget_set_sensitive(glade_xml_get_widget(
xml,
"attrApplyBtn"),
367 (
char *) gtk_entry_get_text((GtkEntry *)
368 glade_xml_get_widget(
xml,
"txtAttr"));
369 const char *def_val = gtk_entry_get_text((GtkEntry *)
370 glade_xml_get_widget(
xml,
372 const char *value = gtk_entry_get_text((GtkEntry *)
373 glade_xml_get_widget(
xml,
"txtValue"));
375 gtk_toggle_button_get_active((GtkToggleButton *)
376 glade_xml_get_widget(
xml,
388 agset(g, attr_name, value);
390 else if (objKind ==
AGNODE) {
397 else if (objKind ==
AGEDGE) {
406 "on_attrApplyBtn_clicked: unknown object kind %d\n",
448 (
char *) gtk_entry_get_text((GtkEntry *)
449 glade_xml_get_widget(
xml,
"txtAttr"));
450 const char *defValue = gtk_entry_get_text((GtkEntry *)
451 glade_xml_get_widget(
xml,
473 else if (objKind ==
AGNODE) {
477 }
else if (objKind ==
AGEDGE) {
482 fprintf(stderr,
"on_attrAddBtn_clicked: unknown object kind %d\n",
493 static char *smyrna_attrs;
500 file = fopen(smyrna_attrs,
"r");
502 for (
size_t i = 0; fgets(buffer,
sizeof(buffer), file) !=
NULL; ++i) {
504 a = strtok(buffer,
",");
506 for (
int idx = 0; (a = strtok(
NULL,
",")); ++idx) {
581 snprintf(buf,
sizeof(buf),
"%d Nodes and %d edges selected", nodeCnt,
583 gtk_label_set_text((GtkLabel *) glade_xml_get_widget(
xml,
"label124"),
585 gtk_entry_set_text((GtkEntry *) glade_xml_get_widget(
xml,
"txtAttr"),
592 void *
const dlg = gtk_message_dialog_new(
NULL, GTK_DIALOG_MODAL,
593 GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK,
595 (void)gtk_dialog_run(dlg);
596 gtk_widget_destroy(dlg);
600 gtk_widget_hide(glade_xml_get_widget(
xml,
"dlgSettings"));
601 gtk_widget_show(glade_xml_get_widget(
xml,
"dlgSettings"));
602 gtk_notebook_set_current_page((GtkNotebook *)
603 glade_xml_get_widget(
xml,
"notebook3"),
609static void gvpr_select(
const char *attrname,
const char *regex_str,
614 agxbprint(&sf,
"N[%s==\"%s\"]{selected = \"1\"}", attrname, regex_str);
615 else if (objType ==
AGEDGE)
616 agxbprint(&sf,
"E[%s==\"%s\"]{selected = \"1\"}", attrname, regex_str);
621 char *argv[argc + 1] = {
"smyrna", bf2};
632 const char *attrname = gtk_entry_get_text((GtkEntry *)
633 glade_xml_get_widget(
xml,
"txtAttr"));
634 const char *regex_str = gtk_entry_get_text((GtkEntry *)
635 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