gpointer data);
static void parse_menu(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
gpointer data);
-static gunichar parse_shortcut(const gchar *label, gchar **strippedlabel,
- guint *position);
+static gunichar parse_shortcut(const gchar *label, gboolean allow_shortcut,
+ gchar **strippedlabel, guint *position);
static void client_dest(ObClient *client, gpointer data)
((c) >= 'A' && (c) <= 'Z') || \
((c) >= 'a' && (c) <= 'z'))
-static gunichar parse_shortcut(const gchar *label, gchar **strippedlabel,
- guint *position)
+static gunichar parse_shortcut(const gchar *label, gboolean allow_shortcut,
+ gchar **strippedlabel, guint *position)
{
gunichar shortcut = 0;
*strippedlabel = g_strdup(label);
+ /* if allow_shortcut is false, then you can't use the &, instead you
+ have to just use the first valid character
+ */
+
i = strchr(*strippedlabel, '&');
- if (i != NULL) {
+ if (allow_shortcut && i != NULL) {
/* there is an ampersand in the string */
/* you have to use a printable ascii character for shortcuts
if (a)
acts = g_slist_append(acts, a);
}
- menu_add_normal(state->parent, -1, label, acts);
+ menu_add_normal(state->parent, -1, label, acts, FALSE);
g_free(label);
}
}
if (!parse_attr_string("label", node, &title))
goto parse_menu_fail;
- if ((menu = menu_new(name, title, NULL))) {
+ if ((menu = menu_new(name, title, FALSE, NULL))) {
menu->pipe_creator = state->pipe_creator;
if (parse_attr_string("execute", node, &script)) {
menu->execute = parse_expand_tilde(script);
g_free(script);
}
-ObMenu* menu_new(const gchar *name, const gchar *title, gpointer data)
+ObMenu* menu_new(const gchar *name, const gchar *title,
+ gboolean allow_shortcut, gpointer data)
{
ObMenu *self;
self->name = g_strdup(name);
self->data = data;
- self->shortcut = parse_shortcut(title, &self->title,
+ self->shortcut = parse_shortcut(title, allow_shortcut, &self->title,
&self->shortcut_position);
g_hash_table_replace(menu_hash, self->name, self);
}
ObMenuEntry* menu_add_normal(ObMenu *self, gint id, const gchar *label,
- GSList *actions)
+ GSList *actions, gboolean allow_shortcut)
{
ObMenuEntry *e;
e = menu_entry_new(self, OB_MENU_ENTRY_TYPE_NORMAL, id);
e->data.normal.actions = actions;
- menu_entry_set_label(e, label);
+ menu_entry_set_label(e, label, allow_shortcut);
self->entries = g_list_append(self->entries, e);
return e;
e = menu_entry_new(self, OB_MENU_ENTRY_TYPE_SEPARATOR, id);
- menu_entry_set_label(e, label);
+ menu_entry_set_label(e, label, FALSE);
self->entries = g_list_append(self->entries, e);
return e;
}
}
-void menu_entry_set_label(ObMenuEntry *self, const gchar *label)
+void menu_entry_set_label(ObMenuEntry *self, const gchar *label,
+ gboolean allow_shortcut)
{
switch (self->type) {
case OB_MENU_ENTRY_TYPE_SEPARATOR:
case OB_MENU_ENTRY_TYPE_NORMAL:
g_free(self->data.normal.label);
self->data.normal.shortcut =
- parse_shortcut(label, &self->data.normal.label,
+ parse_shortcut(label, allow_shortcut, &self->data.normal.label,
&self->data.normal.shortcut_position);
break;
default: