summaryrefslogtreecommitdiff
path: root/openbox
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2007-07-10 23:24:14 +0000
committerDana Jansens <danakj@orodu.net>2007-07-10 23:24:14 +0000
commitd519deeb2e24ba27664a231c6579bee1e02b4ebb (patch)
treeb677224d51caaa77f2a2063f23ec17d600c0683f /openbox
parent5dba9562258c6bc40ced0eb7c7ae32e8cad6905c (diff)
let you specify shortcuts in your menus. change & to be _ for shortcut selection
Diffstat (limited to 'openbox')
-rw-r--r--openbox/client_list_combined_menu.c4
-rw-r--r--openbox/client_list_menu.c4
-rw-r--r--openbox/client_menu.c26
-rw-r--r--openbox/menu.c22
-rw-r--r--openbox/menu.h2
5 files changed, 31 insertions, 27 deletions
diff --git a/openbox/client_list_combined_menu.c b/openbox/client_list_combined_menu.c
index c979253f..556245df 100644
--- a/openbox/client_list_combined_menu.c
+++ b/openbox/client_list_combined_menu.c
@@ -96,8 +96,8 @@ static gboolean self_update(ObMenuFrame *frame, gpointer data)
}
menu_add_separator(menu, CLIENT, _("Manage desktops"));
- menu_add_normal(menu, ADD_DESKTOP, _("&Add new desktop"), NULL, TRUE);
- menu_add_normal(menu, REMOVE_DESKTOP, _("&Remove last desktop"),
+ menu_add_normal(menu, ADD_DESKTOP, _("_Add new desktop"), NULL, TRUE);
+ menu_add_normal(menu, REMOVE_DESKTOP, _("_Remove last desktop"),
NULL, TRUE);
return TRUE; /* always show the menu */
diff --git a/openbox/client_list_menu.c b/openbox/client_list_menu.c
index 56b9a569..62558ef4 100644
--- a/openbox/client_list_menu.c
+++ b/openbox/client_list_menu.c
@@ -149,8 +149,8 @@ static gboolean self_update(ObMenuFrame *frame, gpointer data)
}
menu_add_separator(menu, CLIENT, NULL);
- menu_add_normal(menu, ADD_DESKTOP, _("&Add new desktop"), NULL, TRUE);
- menu_add_normal(menu, REMOVE_DESKTOP, _("&Remove last desktop"),
+ menu_add_normal(menu, ADD_DESKTOP, _("_Add new desktop"), NULL, TRUE);
+ menu_add_normal(menu, REMOVE_DESKTOP, _("_Remove last desktop"),
NULL, TRUE);
return TRUE; /* always show */
diff --git a/openbox/client_menu.c b/openbox/client_menu.c
index e92a772c..fbca23d1 100644
--- a/openbox/client_menu.c
+++ b/openbox/client_menu.c
@@ -357,17 +357,17 @@ void client_menu_startup()
ObMenu *menu;
ObMenuEntry *e;
- menu = menu_new(LAYER_MENU_NAME, _("&Layer"), TRUE, NULL);
+ menu = menu_new(LAYER_MENU_NAME, _("_Layer"), TRUE, NULL);
menu_show_all_shortcuts(menu, TRUE);
menu_set_update_func(menu, layer_menu_update);
menu_set_execute_func(menu, layer_menu_execute);
- menu_add_normal(menu, LAYER_TOP, _("Always on &top"), NULL, TRUE);
- menu_add_normal(menu, LAYER_NORMAL, _("&Normal"), NULL, TRUE);
- menu_add_normal(menu, LAYER_BOTTOM, _("Always on &bottom"),NULL, TRUE);
+ menu_add_normal(menu, LAYER_TOP, _("Always on _top"), NULL, TRUE);
+ menu_add_normal(menu, LAYER_NORMAL, _("_Normal"), NULL, TRUE);
+ menu_add_normal(menu, LAYER_BOTTOM, _("Always on _bottom"),NULL, TRUE);
- menu = menu_new(SEND_TO_MENU_NAME, _("&Send to desktop"), TRUE, NULL);
+ menu = menu_new(SEND_TO_MENU_NAME, _("_Send to desktop"), TRUE, NULL);
menu_set_update_func(menu, send_to_menu_update);
menu_set_execute_func(menu, send_to_menu_execute);
@@ -377,7 +377,7 @@ void client_menu_startup()
menu_set_place_func(menu, client_menu_place);
menu_set_execute_func(menu, client_menu_execute);
- e = menu_add_normal(menu, CLIENT_RESTORE, _("R&estore"), NULL, TRUE);
+ e = menu_add_normal(menu, CLIENT_RESTORE, _("R_estore"), NULL, TRUE);
e->data.normal.mask = ob_rr_theme->max_toggled_mask;
e->data.normal.mask_normal_color = ob_rr_theme->menu_color;
e->data.normal.mask_selected_color = ob_rr_theme->menu_selected_color;
@@ -385,11 +385,11 @@ void client_menu_startup()
e->data.normal.mask_disabled_selected_color =
ob_rr_theme->menu_disabled_selected_color;
- menu_add_normal(menu, CLIENT_MOVE, _("&Move"), NULL, TRUE);
+ menu_add_normal(menu, CLIENT_MOVE, _("_Move"), NULL, TRUE);
- menu_add_normal(menu, CLIENT_RESIZE, _("Resi&ze"), NULL, TRUE);
+ menu_add_normal(menu, CLIENT_RESIZE, _("Resi_ze"), NULL, TRUE);
- e = menu_add_normal(menu, CLIENT_ICONIFY, _("Ico&nify"), NULL, TRUE);
+ e = menu_add_normal(menu, CLIENT_ICONIFY, _("Ico_nify"), NULL, 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_selected_color = ob_rr_theme->menu_selected_color;
@@ -397,7 +397,7 @@ void client_menu_startup()
e->data.normal.mask_disabled_selected_color =
ob_rr_theme->menu_disabled_selected_color;
- e = menu_add_normal(menu, CLIENT_MAXIMIZE, _("Ma&ximize"), NULL, TRUE);
+ e = menu_add_normal(menu, CLIENT_MAXIMIZE, _("Ma_ximize"), NULL, 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_selected_color = ob_rr_theme->menu_selected_color;
@@ -405,9 +405,9 @@ void client_menu_startup()
e->data.normal.mask_disabled_selected_color =
ob_rr_theme->menu_disabled_selected_color;
- menu_add_normal(menu, CLIENT_SHADE, _("&Roll up/down"), NULL, TRUE);
+ menu_add_normal(menu, CLIENT_SHADE, _("_Roll up/down"), NULL, TRUE);
- menu_add_normal(menu, CLIENT_DECORATE, _("Un/&Decorate"), NULL, TRUE);
+ menu_add_normal(menu, CLIENT_DECORATE, _("Un/_Decorate"), NULL, TRUE);
menu_add_separator(menu, -1, NULL);
@@ -417,7 +417,7 @@ void client_menu_startup()
menu_add_separator(menu, -1, NULL);
- e = menu_add_normal(menu, CLIENT_CLOSE, _("&Close"), NULL, TRUE);
+ e = menu_add_normal(menu, CLIENT_CLOSE, _("_Close"), NULL, 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_selected_color = ob_rr_theme->menu_selected_color;
diff --git a/openbox/menu.c b/openbox/menu.c
index 5d9ea796..b49177ba 100644
--- a/openbox/menu.c
+++ b/openbox/menu.c
@@ -222,28 +222,34 @@ static gunichar parse_shortcut(const gchar *label, gboolean allow_shortcut,
*strippedlabel = g_strdup(label);
- /* if allow_shortcut is false, then you can't use the &, instead you
+ /* if allow_shortcut is false, then you can't use the '_', instead you
have to just use the first valid character
*/
- i = strchr(*strippedlabel, '&');
+ i = strchr(*strippedlabel, '_');
if (allow_shortcut && i != NULL) {
- /* there is an ampersand in the string */
+ /* there is an underscore in the string */
/* you have to use a printable ascii character for shortcuts
- don't allow space either, so you can have like "a & b"
+ don't allow space either, so you can have like "a _ b"
*/
if (VALID_SHORTCUT(*(i+1))) {
shortcut = g_unichar_tolower(g_utf8_get_char(i+1));
*position = i - *strippedlabel;
*always_show = TRUE;
- /* remove the & from the string */
+ /* remove the '_' from the string */
for (; *i != '\0'; ++i)
*i = *(i+1);
+ } else if (*(i+1) == '\0') {
+ /* no default shortcut if the '_' is the last character
+ (eg. "Exit_") for menu entries that you don't want
+ to be executed by mistake
+ */
+ *i = '\0';
}
} else {
- /* there is no ampersand, so find the first valid character to use
+ /* there is no underscore, so find the first valid character to use
instead */
for (i = *strippedlabel; *i != '\0'; ++i)
@@ -273,7 +279,7 @@ static void parse_menu_item(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
if (a)
acts = g_slist_append(acts, a);
}
- menu_add_normal(state->parent, -1, label, acts, FALSE);
+ menu_add_normal(state->parent, -1, label, acts, TRUE);
g_free(label);
}
}
@@ -310,7 +316,7 @@ static void parse_menu(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
if (!parse_attr_string("label", node, &title))
goto parse_menu_fail;
- if ((menu = menu_new(name, title, FALSE, NULL))) {
+ if ((menu = menu_new(name, title, TRUE, NULL))) {
menu->pipe_creator = state->pipe_creator;
if (parse_attr_string("execute", node, &script)) {
menu->execute = parse_expand_tilde(script);
diff --git a/openbox/menu.h b/openbox/menu.h
index 09938fcd..8832a124 100644
--- a/openbox/menu.h
+++ b/openbox/menu.h
@@ -164,8 +164,6 @@ void menu_shutdown(gboolean reconfig);
void menu_entry_ref(ObMenuEntry *self);
void menu_entry_unref(ObMenuEntry *self);
-/*! @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_selection, gpointer data);
void menu_free(ObMenu *menu);