// Allocates a binding (bound to the last menu entry) OptionBinding* allocate_binding(MenuData *m) { OptionBinding *binds = (OptionBinding*)m->context, *bind; binds = realloc(binds, m->ecount * sizeof(OptionBinding)); bind = &(binds[m->ecount - 1]); initialize_binding(bind); m->context = (void*)binds; return bind; }
static void initialize(expression * e) { switch (e->type) { case expr_type_constant: initialize_constant(e); break; case expr_type_variable: initialize_variable(e); break; case expr_type_map: initialize_map(e); break; case expr_type_function: initialize_function(e); break; case expr_type_binding: initialize_binding(e); break; default: G_fatal_error(_("Unknown type: %d"), e->type); } }
/* * Initialize bindings with configuration retrieved from dbus */ void shortcuts_initialize_bindings(SFLPhoneClient *client) { gchar* action, *maskAndKey, *token1, *token2 = NULL; guint mask, key = 0; g_debug("Shortcuts: Initialize bindings"); // get shortcuts stored in config through dbus shortcutsMap = dbus_get_shortcuts(); // initialize list of keys initialize_accelerators_list(client); // iterate through keys to initialize bindings GList *shortcutsKeys = g_hash_table_get_keys(shortcutsMap); for (GList *elem = shortcutsKeys; elem; elem = elem->next) { action = elem->data; maskAndKey = g_hash_table_lookup(shortcutsMap, action); token1 = strtok(maskAndKey, "x"); token2 = strtok(NULL, "x"); mask = 0; key = 0; // Value not setted if (token1 && token2) { g_debug("Shortcuts: token1 %s, token2 %s", token1, token2); mask = atoi(token1); key = atoi(token2); } if (key != 0) initialize_binding(action, key, mask); } }