if (c->iconic) {
gchar *title = g_strdup_printf("(%s)", c->icon_title);
- e = menu_add_normal(menu, i, title, acts);
+ e = menu_add_normal(menu, i, title, acts, FALSE);
g_free(title);
} else
- e = menu_add_normal(menu, i, c->title, acts);
+ e = menu_add_normal(menu, i, c->title, acts, FALSE);
if (config_menu_client_list_icons
&& (icon = client_icon(c, 32, 32))) {
act = action_from_string("Desktop", OB_USER_ACTION_MENU_SELECTION);
act->data.desktop.desk = desktop;
acts = g_slist_append(acts, act);
- e = menu_add_normal(menu, 0, _("Go there..."), acts);
+ e = menu_add_normal(menu, 0, _("Go there..."), acts, TRUE);
if (desktop == screen_desktop)
e->data.normal.enabled = FALSE;
}
if (!reconfig)
client_add_destructor(client_dest, NULL);
- combined_menu = menu_new(MENU_NAME, _("Windows"), NULL);
+ combined_menu = menu_new(MENU_NAME, _("Windows"), TRUE, NULL);
menu_set_update_func(combined_menu, self_update);
menu_set_execute_func(combined_menu, menu_execute);
}
act->data.desktop.desk = d->desktop;
acts = g_slist_append(acts, act);
e = menu_add_normal(menu, i,
- (c->iconic ? c->icon_title : c->title), acts);
+ (c->iconic ? c->icon_title : c->title),
+ acts, FALSE);
if (config_menu_client_list_icons
&& (icon = client_icon(c, 32, 32))) {
act = action_from_string("Desktop", OB_USER_ACTION_MENU_SELECTION);
act->data.desktop.desk = d->desktop;
acts = g_slist_append(acts, act);
- e = menu_add_normal(menu, 0, _("Go there..."), acts);
+ e = menu_add_normal(menu, 0, _("Go there..."), acts, TRUE);
if (d->desktop == screen_desktop)
e->data.normal.enabled = FALSE;
}
DesktopData *data = g_new(DesktopData, 1);
data->desktop = i;
- submenu = menu_new(name, screen_desktop_names[i], data);
+ submenu = menu_new(name, screen_desktop_names[i], FALSE, data);
menu_set_update_func(submenu, desk_menu_update);
menu_set_execute_func(submenu, desk_menu_execute);
menu_set_destroy_func(submenu, desk_menu_destroy);
if (!reconfig)
client_add_destructor(client_dest, NULL);
- menu = menu_new(MENU_NAME, _("Desktops"), NULL);
+ menu = menu_new(MENU_NAME, _("Desktops"), TRUE, NULL);
menu_set_update_func(menu, self_update);
}
e = menu_find_entry_id(menu, CLIENT_MAXIMIZE);
menu_entry_set_label(e,
(frame->client->max_vert || frame->client->max_horz ?
- _("Restor&e") : _("Maximiz&e")));
+ _("Restor&e") : _("Maximiz&e")), TRUE);
e->data.normal.enabled =frame->client->functions & OB_CLIENT_FUNC_MAXIMIZE;
e = menu_find_entry_id(menu, CLIENT_SHADE);
menu_entry_set_label(e, (frame->client->shaded ?
- _("&Roll down") : _("&Roll up")));
+ _("&Roll down") : _("&Roll up")), TRUE);
e->data.normal.enabled = frame->client->functions & OB_CLIENT_FUNC_SHADE;
e = menu_find_entry_id(menu, CLIENT_MOVE);
act->data.sendto.desk = desk;
act->data.sendto.follow = FALSE;
acts = g_slist_prepend(NULL, act);
- e = menu_add_normal(menu, desk, name, acts);
+ e = menu_add_normal(menu, desk, name, acts, FALSE);
if (frame->client->desktop == desk)
e->data.normal.enabled = FALSE;
ObMenu *menu;
ObMenuEntry *e;
- menu = menu_new(LAYER_MENU_NAME, _("&Layer"), NULL);
+ menu = menu_new(LAYER_MENU_NAME, _("&Layer"), TRUE, NULL);
menu_show_all_shortcuts(menu, TRUE);
menu_set_update_func(menu, layer_update);
acts = g_slist_prepend(NULL, action_from_string
("SendToTopLayer", OB_USER_ACTION_MENU_SELECTION));
- menu_add_normal(menu, LAYER_TOP, _("Always on &top"), acts);
+ menu_add_normal(menu, LAYER_TOP, _("Always on &top"), acts, TRUE);
acts = g_slist_prepend(NULL, action_from_string
("SendToNormalLayer",
OB_USER_ACTION_MENU_SELECTION));
- menu_add_normal(menu, LAYER_NORMAL, _("&Normal"), acts);
+ menu_add_normal(menu, LAYER_NORMAL, _("&Normal"), acts, TRUE);
acts = g_slist_prepend(NULL, action_from_string
("SendToBottomLayer",
OB_USER_ACTION_MENU_SELECTION));
- menu_add_normal(menu, LAYER_BOTTOM, _("Always on &bottom"),acts);
+ menu_add_normal(menu, LAYER_BOTTOM, _("Always on &bottom"),acts, TRUE);
- menu = menu_new(SEND_TO_MENU_NAME, _("&Send to desktop"), NULL);
- menu_show_all_shortcuts(menu, TRUE);
+ menu = menu_new(SEND_TO_MENU_NAME, _("&Send to desktop"), TRUE, NULL);
menu_set_update_func(menu, send_to_update);
- menu = menu_new(CLIENT_MENU_NAME, _("Client menu"), NULL);
+ menu = menu_new(CLIENT_MENU_NAME, _("Client menu"), TRUE, NULL);
menu_show_all_shortcuts(menu, TRUE);
menu_set_update_func(menu, client_update);
acts = g_slist_prepend(NULL, action_from_string
("Iconify", OB_USER_ACTION_MENU_SELECTION));
- e = menu_add_normal(menu, CLIENT_ICONIFY, _("Ico&nify"), acts);
+ e = menu_add_normal(menu, CLIENT_ICONIFY, _("Ico&nify"), acts, TRUE);
e->data.normal.mask = ob_rr_theme->iconify_mask;
e->data.normal.mask_normal_color = ob_rr_theme->menu_color;
e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color;
acts = g_slist_prepend(NULL, action_from_string
("ToggleMaximizeFull",
OB_USER_ACTION_MENU_SELECTION));
- e = menu_add_normal(menu, CLIENT_MAXIMIZE, "MAXIMIZE", acts);
+ e = menu_add_normal(menu, CLIENT_MAXIMIZE, "MAXIMIZE", acts, TRUE);
e->data.normal.mask = ob_rr_theme->max_mask;
e->data.normal.mask_normal_color = ob_rr_theme->menu_color;
e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color;
acts = g_slist_prepend(NULL, action_from_string
("Raise", OB_USER_ACTION_MENU_SELECTION));
- menu_add_normal(menu, CLIENT_RAISE, _("Raise to &top"), acts);
+ menu_add_normal(menu, CLIENT_RAISE, _("Raise to &top"), acts, TRUE);
acts = g_slist_prepend(NULL, action_from_string
("Lower", OB_USER_ACTION_MENU_SELECTION));
- menu_add_normal(menu, CLIENT_LOWER, _("Lower to &bottom"),acts);
+ menu_add_normal(menu, CLIENT_LOWER, _("Lower to &bottom"),acts, TRUE);
acts = g_slist_prepend(NULL, action_from_string
("ToggleShade", OB_USER_ACTION_MENU_SELECTION));
- e = menu_add_normal(menu, CLIENT_SHADE, "SHADE", acts);
+ e = menu_add_normal(menu, CLIENT_SHADE, "SHADE", acts, TRUE);
e->data.normal.mask = ob_rr_theme->shade_mask;
e->data.normal.mask_normal_color = ob_rr_theme->menu_color;
e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color;
acts = g_slist_prepend(NULL, action_from_string
("ToggleDecorations",
OB_USER_ACTION_MENU_SELECTION));
- menu_add_normal(menu, CLIENT_DECORATE, _("&Decorate"), acts);
+ menu_add_normal(menu, CLIENT_DECORATE, _("&Decorate"), acts, TRUE);
menu_add_separator(menu, -1, NULL);
acts = g_slist_prepend(NULL, action_from_string
("Move", OB_USER_ACTION_MENU_SELECTION));
- menu_add_normal(menu, CLIENT_MOVE, _("&Move"), acts);
+ menu_add_normal(menu, CLIENT_MOVE, _("&Move"), acts, TRUE);
acts = g_slist_prepend(NULL, action_from_string
("Resize", OB_USER_ACTION_MENU_SELECTION));
- menu_add_normal(menu, CLIENT_RESIZE, _("Resi&ze"), acts);
+ menu_add_normal(menu, CLIENT_RESIZE, _("Resi&ze"), acts, TRUE);
menu_add_separator(menu, -1, NULL);
acts = g_slist_prepend(NULL, action_from_string
("Close", OB_USER_ACTION_MENU_SELECTION));
- e = menu_add_normal(menu, CLIENT_CLOSE, _("&Close"), acts);
+ e = menu_add_normal(menu, CLIENT_CLOSE, _("&Close"), acts, TRUE);
e->data.normal.mask = ob_rr_theme->close_mask;
e->data.normal.mask_normal_color = ob_rr_theme->menu_color;
e->data.normal.mask_disabled_color = ob_rr_theme->menu_disabled_color;
#ifdef HAVE_SIGNAL_H
# include <signal.h>
#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h> /* for usleep() */
+#endif
#ifdef XKB
# include <X11/XKBlib.h>
#endif
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:
void menu_startup(gboolean reconfig);
void menu_shutdown(gboolean reconfig);
-ObMenu* menu_new(const gchar *name, const gchar *title, gpointer data);
+/*! @param allow_shortcut this should be false when the label is coming from
+ outside data like window or desktop titles */
+ObMenu* menu_new(const gchar *name, const gchar *title,
+ gboolean allow_shortcut, gpointer data);
void menu_free(ObMenu *menu);
/* Repopulate a pipe-menu by running its command */
void menu_set_destroy_func(ObMenu *menu, ObMenuDestroyFunc func);
/* functions for building menus */
+/*! @param allow_shortcut this should be false when the label is coming from
+ outside data like window or desktop titles */
ObMenuEntry* menu_add_normal(ObMenu *menu, gint id, const gchar *label,
- GSList *actions);
+ GSList *actions, gboolean allow_shortcut);
ObMenuEntry* menu_add_submenu(ObMenu *menu, gint id, const gchar *submenu);
ObMenuEntry* menu_add_separator(ObMenu *menu, gint id, const gchar *label);
void menu_clear_entries(ObMenu *menu);
void menu_entry_remove(ObMenuEntry *self);
-void menu_entry_set_label(ObMenuEntry *self, const gchar *label);
+void menu_entry_set_label(ObMenuEntry *self, const gchar *label,
+ gboolean allow_shortcut);
ObMenuEntry* menu_find_entry_id(ObMenu *self, gint id);