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],
"");
114 l->
fLabels[
id] = (GtkLabel *) gtk_label_new(
"");
116 gtk_widget_add_events((GtkWidget *) 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((GtkWidget *) l->
fLabels[
id]);
125 gtk_fixed_put((GtkFixed *) glade_xml_get_widget(
xml,
"fixed6"),
126 (GtkWidget *) l->
fLabels[
id], 10, 110 +
id * 13);
134 const attr_t *
const *c = candidate;
135 return strcasecmp(k, (*c)->name);
148 for (
size_t id = 0;
id < attrs_size(&l->
attributes); ++
id)
193 const char *start = a.
data + a.
size;
197 start += strlen(
" or ");
198 const char *end = strstr(start,
" or ");
202 a = (
strview_t){.
data = start, .size = (size_t)(end - start)};
219static int cmp(
const void *key,
const void *candidate) {
220 const attr_t *
const a = candidate;
221 return strncasecmp(key, a->
name, strlen(key));
238 for (
int res = 0; at->
index > 0 && res == 0; ) {
242 for (
int res = 0; at->
index < attrs_size(&sl->
attributes) && res == 0; ) {
245 if (res == 0 && at->
objType[objKind] == 1)
259 for (
size_t ind = 0; ind < attrs_size(&fl->
attributes); ++ind) {
268 gtk_widget_show(glade_xml_get_widget(
xml,
"txtValue"));
269 gtk_widget_show(glade_xml_get_widget(
xml,
"txtDefValue"));
271 gtk_entry_set_text((GtkEntry *)
272 glade_xml_get_widget(
xml,
"txtDefValue"),
"");
273 gtk_entry_set_text((GtkEntry *) glade_xml_get_widget(
xml,
"txtValue"),
275 gtk_widget_set_sensitive(glade_xml_get_widget(
xml,
"txtDefValue"), 1);
276 gtk_widget_show(glade_xml_get_widget(
xml,
"attrAddBtn"));
277 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrApplyBtn"));
278 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrApplyAllBtn"));
279 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrSearchBtn"));
280 gtk_toggle_button_set_active((GtkToggleButton *)
281 glade_xml_get_widget(
xml,
"attrProg"), 0);
283 if (strlen(
prefix) == 0) {
284 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrAddBtn"));
285 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrApplyBtn"));
286 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrApplyAllBtn"));
287 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrSearchBtn"));
288 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrAddBtn"));
289 gtk_widget_hide(glade_xml_get_widget(
xml,
"txtValue"));
290 gtk_widget_hide(glade_xml_get_widget(
xml,
"txtDefValue"));
294 for (
size_t ind = 0; ind < attrs_size(&fl->
attributes); ++ind) {
300 gtk_entry_set_text((GtkEntry *)
301 glade_xml_get_widget(
xml,
305 gtk_entry_set_text((GtkEntry *)
306 glade_xml_get_widget(
xml,
310 gtk_entry_set_text((GtkEntry *)
311 glade_xml_get_widget(
xml,
314 gtk_widget_set_sensitive(glade_xml_get_widget
315 (
xml,
"txtDefValue"), 0);
316 gtk_widget_hide(glade_xml_get_widget(
xml,
"attrAddBtn"));
317 gtk_widget_show(glade_xml_get_widget(
xml,
"attrApplyBtn"));
318 gtk_widget_show(glade_xml_get_widget(
xml,
"attrApplyAllBtn"));
319 gtk_widget_show(glade_xml_get_widget(
xml,
"attrSearchBtn"));
320 gtk_toggle_button_set_active((GtkToggleButton *)
321 glade_xml_get_widget(
xml,
331 gtk_widget_set_sensitive(glade_xml_get_widget(
xml,
"attrApplyBtn"),
355 (
char *) gtk_entry_get_text((GtkEntry *)
356 glade_xml_get_widget(
xml,
"txtAttr"));
357 const char *def_val = gtk_entry_get_text((GtkEntry *)
358 glade_xml_get_widget(
xml,
360 const char *value = gtk_entry_get_text((GtkEntry *)
361 glade_xml_get_widget(
xml,
"txtValue"));
363 gtk_toggle_button_get_active((GtkToggleButton *)
364 glade_xml_get_widget(
xml,
373 sym =
agattr(g, objKind, attr_name, def_val);
376 agset(g, attr_name, value);
378 else if (objKind ==
AGNODE) {
385 else if (objKind ==
AGEDGE) {
394 "on_attrApplyBtn_clicked: unknown object kind %d\n",
436 (
char *) gtk_entry_get_text((GtkEntry *)
437 glade_xml_get_widget(
xml,
"txtAttr"));
438 const char *defValue = gtk_entry_get_text((GtkEntry *)
439 glade_xml_get_widget(
xml,
463 else if (objKind ==
AGNODE) {
467 }
else if (objKind ==
AGEDGE) {
472 fprintf(stderr,
"on_attrAddBtn_clicked: unknown object kind %d\n",
483 static char *smyrna_attrs;
490 file = fopen(smyrna_attrs,
"r");
492 for (
size_t i = 0; fgets(buffer,
sizeof(buffer), file) !=
NULL; ++i) {
494 a = strtok(buffer,
",");
497 for (
int idx = 0; (a = strtok(
NULL,
",")); ++idx) {
575 snprintf(buf,
sizeof(buf),
"%d Nodes and %d edges selected", nodeCnt,
577 gtk_label_set_text((GtkLabel *) glade_xml_get_widget(
xml,
"label124"),
579 gtk_entry_set_text((GtkEntry *) glade_xml_get_widget(
xml,
"txtAttr"),
585 gtk_widget_hide(glade_xml_get_widget(
xml,
"dlgSettings"));
586 gtk_widget_show(glade_xml_get_widget(
xml,
"dlgSettings"));
587 gtk_notebook_set_current_page((GtkNotebook *)
588 glade_xml_get_widget(
xml,
"notebook3"),
594static void gvpr_select(
const char *attrname,
const char *regex_str,
603 agxbprint(&sf,
"N[%s==\"%s\"]{selected = \"1\"}", attrname, regex_str);
604 else if (objType ==
AGEDGE)
605 agxbprint(&sf,
"E[%s==\"%s\"]{selected = \"1\"}", attrname, regex_str);
614 argv[j++] =
"smyrna";
618 for (i = 1; i < argc; i++)
627 const char *attrname = gtk_entry_get_text((GtkEntry *)
628 glade_xml_get_widget(
xml,
"txtAttr"));
629 const char *regex_str = gtk_entry_get_text((GtkEntry *)
630 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)
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 int attr_compare(const attr_t **a, const attr_t **b)
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 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(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[])
textitem scanner parser str
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