xmlNodePtr tree_get_node(const gchar *path, const gchar *def) { xmlNodePtr n, c; gchar **nodes; gchar **it, **next; n = obt_xml_root(parse_i); nodes = g_strsplit(path, "/", 0); for (it = nodes; *it; it = next) { gchar **attrs; gboolean ok = FALSE; attrs = g_strsplit(*it, ":", 0); next = it + 1; /* match attributes */ c = obt_xml_find_node(n->children, attrs[0]); while (c && !ok) { gint i; ok = TRUE; for (i = 1; attrs[i]; ++i) { gchar **eq = g_strsplit(attrs[i], "=", 2); if (eq[1] && !obt_xml_attr_contains(c, eq[0], eq[1])) ok = FALSE; g_strfreev(eq); } if (!ok) c = obt_xml_find_node(c->next, attrs[0]); } if (!c) { gint i; c = xmlNewTextChild(n, NULL, (xmlChar*)attrs[0], (xmlChar*)(*next ? NULL : def)); for (i = 1; attrs[i]; ++i) { gchar **eq = g_strsplit(attrs[i], "=", 2); if (eq[1]) xmlNewProp(c, (xmlChar*)eq[0], (xmlChar*)eq[1]); g_strfreev(eq); } } n = c; g_strfreev(attrs); } g_strfreev(nodes); return n; }
static gpointer setup_func(xmlNodePtr node) { xmlNodePtr n; Options *o; o = g_slice_new0(Options); if ((n = obt_xml_find_node(node, "command")) || (n = obt_xml_find_node(node, "execute"))) { gchar *s = obt_xml_node_string(n); o->cmd = obt_paths_expand_tilde(s); g_free(s); } if ((n = obt_xml_find_node(node, "prompt"))) o->prompt = obt_xml_node_string(n); if ((n = obt_xml_find_node(node, "startupnotify"))) { xmlNodePtr m; if ((m = obt_xml_find_node(n->children, "enabled"))) o->sn = obt_xml_node_bool(m); if ((m = obt_xml_find_node(n->children, "name"))) o->sn_name = obt_xml_node_string(m); if ((m = obt_xml_find_node(n->children, "icon"))) o->sn_icon = obt_xml_node_string(m); if ((m = obt_xml_find_node(n->children, "wmclass"))) o->sn_wmclass = obt_xml_node_string(m); } return o; }
static void parse_menu_item(xmlNodePtr node, gpointer data) { ObMenuParseState *state = data; gchar *label; gchar *icon; ObMenuEntry *e; if (state->parent) { /* Don't try to extract "icon" attribute if icons in user-defined menus are not enabled. */ if (obt_xml_attr_string(node, "label", &label)) { xmlNodePtr c; GSList *acts = NULL; c = obt_xml_find_node(node->children, "action"); while (c) { ObActionsAct *action = actions_parse(c); if (action) acts = g_slist_append(acts, action); c = obt_xml_find_node(node->next, "action"); } e = menu_add_normal(state->parent, -1, label, acts, TRUE); if (config_menu_show_icons && obt_xml_attr_string(node, "icon", &icon)) { RrImage *ic; ic = RrImageCacheFindName(ob_rr_icons, icon); if (ic) RrImageRef(ic); else { ic = RrImageNew(ob_rr_icons); if (!RrImageAddPictureName(ic, icon)) { RrImageUnref(ic); /* no need to keep it around */ ic = NULL; } } e->data.normal.icon = ic; if (e->data.normal.icon) e->data.normal.icon_alpha = 0xff; g_free(icon); } g_free(label); } } }
static gpointer setup_func(xmlNodePtr node) { xmlNodePtr n; Options *o; o = g_slice_new0(Options); o->stop_int = TRUE; if ((n = obt_xml_find_node(node, "here"))) o->here = obt_xml_node_bool(n); if ((n = obt_xml_find_node(node, "stopInteractive"))) o->stop_int = obt_xml_node_bool(n); return o; }
static gpointer setup_func(xmlNodePtr node) { xmlNodePtr n; Options *o; o = g_slice_new0(Options); o->x.pos = G_MININT; o->y.pos = G_MININT; o->w = G_MININT; o->h = G_MININT; o->monitor = CURRENT_MONITOR; if ((n = obt_xml_find_node(node, "x"))) config_parse_gravity_coord(n, &o->x); if ((n = obt_xml_find_node(node, "y"))) config_parse_gravity_coord(n, &o->y); if ((n = obt_xml_find_node(node, "width"))) { gchar *s = obt_xml_node_string(n); if (g_ascii_strcasecmp(s, "current") != 0) config_parse_relative_number(s, &o->w, &o->w_denom); g_free(s); } if ((n = obt_xml_find_node(node, "height"))) { gchar *s = obt_xml_node_string(n); if (g_ascii_strcasecmp(s, "current") != 0) config_parse_relative_number(s, &o->h, &o->h_denom); g_free(s); } if ((n = obt_xml_find_node(node, "monitor"))) { gchar *s = obt_xml_node_string(n); if (g_ascii_strcasecmp(s, "current") != 0) { if (!g_ascii_strcasecmp(s, "all")) o->monitor = ALL_MONITORS; else if(!g_ascii_strcasecmp(s, "next")) o->monitor = NEXT_MONITOR; else if(!g_ascii_strcasecmp(s, "prev")) o->monitor = PREV_MONITOR; else o->monitor = obt_xml_node_int(n) - 1; } g_free(s); } return o; }
static gpointer setup_func(xmlNodePtr node) { xmlNodePtr n, c; Options *o; gboolean x_pos_given = FALSE; o = g_slice_new0(Options); o->monitor = -1; if ((n = obt_xml_find_node(node, "menu"))) o->name = obt_xml_node_string(n); if ((n = obt_xml_find_node(node, "position"))) { if ((c = obt_xml_find_node(n->children, "x"))) { if (!obt_xml_node_contains(c, "default")) { config_parse_gravity_coord(c, &o->position.x); x_pos_given = TRUE; } } if (x_pos_given && (c = obt_xml_find_node(n->children, "y"))) { if (!obt_xml_node_contains(c, "default")) { config_parse_gravity_coord(c, &o->position.y); o->use_position = TRUE; } } /* unlike client placement, x/y is needed to specify a monitor, * either it's under the mouse or it's in an exact actual position */ if (o->use_position && (c = obt_xml_find_node(n->children, "monitor"))) { if (!obt_xml_node_contains(c, "default")) { gchar *s = obt_xml_node_string(c); if (!g_ascii_strcasecmp(s, "mouse")) o->monitor_type = OB_PLACE_MONITOR_MOUSE; else if (!g_ascii_strcasecmp(s, "active")) o->monitor_type = OB_PLACE_MONITOR_ACTIVE; else if (!g_ascii_strcasecmp(s, "primary")) o->monitor_type = OB_PLACE_MONITOR_PRIMARY; else if (!g_ascii_strcasecmp(s, "all")) o->monitor_type = OB_PLACE_MONITOR_ALL; else o->monitor = obt_xml_node_int(c) - 1; g_free(s); } } } return o; }
static gpointer setup_func(xmlNodePtr node) { xmlNodePtr n; Options *o; o = g_slice_new0(Options); if ((n = obt_xml_find_node(node, "edge"))) { gchar *s = obt_xml_node_string(n); o->corner_specified = TRUE; if (!g_ascii_strcasecmp(s, "top")) o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOP); else if (!g_ascii_strcasecmp(s, "bottom")) o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOM); else if (!g_ascii_strcasecmp(s, "left")) o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_LEFT); else if (!g_ascii_strcasecmp(s, "right")) o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_RIGHT); else if (!g_ascii_strcasecmp(s, "topleft")) o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPLEFT); else if (!g_ascii_strcasecmp(s, "topright")) o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_TOPRIGHT); else if (!g_ascii_strcasecmp(s, "bottomleft")) o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT); else if (!g_ascii_strcasecmp(s, "bottomright")) o->corner = OBT_PROP_ATOM(NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT); else o->corner_specified = FALSE; g_free(s); } return o; }
static gpointer setup_func(xmlNodePtr node) { xmlNodePtr n; Options *o; o = g_slice_new0(Options); o->dir = OB_DIRECTION_NORTH; if ((n = obt_xml_find_node(node, "direction"))) { gchar *s = obt_xml_node_string(n); if (!g_ascii_strcasecmp(s, "north") || !g_ascii_strcasecmp(s, "up")) o->dir = OB_DIRECTION_NORTH; else if (!g_ascii_strcasecmp(s, "south") || !g_ascii_strcasecmp(s, "down")) o->dir = OB_DIRECTION_SOUTH; else if (!g_ascii_strcasecmp(s, "west") || !g_ascii_strcasecmp(s, "left")) o->dir = OB_DIRECTION_WEST; else if (!g_ascii_strcasecmp(s, "east") || !g_ascii_strcasecmp(s, "right")) o->dir = OB_DIRECTION_EAST; g_free(s); } return o; }
static gpointer setup_func(xmlNodePtr node) { xmlNodePtr n; Options *o; o = g_slice_new0(Options); if ((n = obt_xml_find_node(node, "string"))) o->str = obt_xml_node_string(n); return o; }
static gpointer setup_func(xmlNodePtr node) { xmlNodePtr n; Options *o; o = g_slice_new0(Options); if ((n = obt_xml_find_node(node, "left"))) xml_node_relative(n, &o->left, &o->left_denom); if ((n = obt_xml_find_node(node, "right"))) xml_node_relative(n, &o->right, &o->right_denom); if ((n = obt_xml_find_node(node, "top")) || (n = obt_xml_find_node(node, "up"))) xml_node_relative(n, &o->top, &o->top_denom); if ((n = obt_xml_find_node(node, "bottom")) || (n = obt_xml_find_node(node, "down"))) xml_node_relative(n, &o->bottom, &o->bottom_denom); return o; }