12 #define CLIENT_MENU_NAME "client-menu"
13 #define SEND_TO_MENU_NAME "client-send-to-menu"
14 #define LAYER_MENU_NAME "client-layer-menu"
36 static void client_update(ObMenuFrame
*frame
, gpointer data
)
38 ObMenu
*menu
= frame
->menu
;
42 frame
->show_title
= FALSE
;
44 for (it
= menu
->entries
; it
; it
= g_list_next(it
)) {
46 if (e
->type
== OB_MENU_ENTRY_TYPE_NORMAL
)
47 e
->data
.normal
.enabled
= !!frame
->client
;
53 e
= menu_find_entry_id(menu
, CLIENT_ICONIFY
);
54 e
->data
.normal
.enabled
= frame
->client
->functions
& OB_CLIENT_FUNC_ICONIFY
;
56 e
= menu_find_entry_id(menu
, CLIENT_MAXIMIZE
);
57 e
->data
.normal
.enabled
=frame
->client
->functions
& OB_CLIENT_FUNC_MAXIMIZE
;
59 e
= menu_find_entry_id(menu
, CLIENT_SHADE
);
60 e
->data
.normal
.enabled
= frame
->client
->functions
& OB_CLIENT_FUNC_SHADE
;
62 e
= menu_find_entry_id(menu
, CLIENT_MOVE
);
63 e
->data
.normal
.enabled
= frame
->client
->functions
& OB_CLIENT_FUNC_MOVE
;
65 e
= menu_find_entry_id(menu
, CLIENT_RESIZE
);
66 e
->data
.normal
.enabled
= frame
->client
->functions
& OB_CLIENT_FUNC_RESIZE
;
68 e
= menu_find_entry_id(menu
, CLIENT_CLOSE
);
69 e
->data
.normal
.enabled
= frame
->client
->functions
& OB_CLIENT_FUNC_CLOSE
;
72 static void layer_update(ObMenuFrame
*frame
, gpointer data
)
74 ObMenu
*menu
= frame
->menu
;
78 for (it
= menu
->entries
; it
; it
= g_list_next(it
)) {
80 if (e
->type
== OB_MENU_ENTRY_TYPE_NORMAL
)
81 e
->data
.normal
.enabled
= !!frame
->client
;
87 e
= menu_find_entry_id(menu
, LAYER_TOP
);
88 e
->data
.normal
.enabled
= !frame
->client
->above
;
90 e
= menu_find_entry_id(menu
, LAYER_NORMAL
);
91 e
->data
.normal
.enabled
= (frame
->client
->above
|| frame
->client
->below
);
93 e
= menu_find_entry_id(menu
, LAYER_BOTTOM
);
94 e
->data
.normal
.enabled
= !frame
->client
->below
;
97 static void send_to_update(ObMenuFrame
*frame
, gpointer data
)
99 ObMenu
*menu
= frame
->menu
;
104 menu_clear_entries(menu
);
109 for (i
= 0; i
<= screen_num_desktops
; ++i
) {
113 if (i
>= screen_num_desktops
) {
114 menu_add_separator(menu
, -1);
117 name
= _("All desktops");
120 name
= screen_desktop_names
[i
];
123 act
= action_from_string("SendToDesktop",
124 OB_USER_ACTION_MENU_SELECTION
);
125 act
->data
.sendto
.desk
= desk
;
126 act
->data
.sendto
.follow
= FALSE
;
127 acts
= g_slist_prepend(NULL
, act
);
128 menu_add_normal(menu
, desk
, name
, acts
);
130 if (frame
->client
->desktop
== desk
) {
131 ObMenuEntry
*e
= menu_find_entry_id(menu
, desk
);
133 e
->data
.normal
.enabled
= FALSE
;
138 void client_menu_startup()
144 menu
= menu_new(LAYER_MENU_NAME
, _("Layer"), NULL
);
145 menu_set_update_func(menu
, layer_update
);
147 acts
= g_slist_prepend(NULL
, action_from_string
148 ("SendToTopLayer", OB_USER_ACTION_MENU_SELECTION
));
149 menu_add_normal(menu
, LAYER_TOP
, _("Always on top"), acts
);
151 acts
= g_slist_prepend(NULL
, action_from_string
152 ("SendToNormalLayer",
153 OB_USER_ACTION_MENU_SELECTION
));
154 menu_add_normal(menu
, LAYER_NORMAL
, _("Normal"), acts
);
156 acts
= g_slist_prepend(NULL
, action_from_string
157 ("SendToBottomLayer",
158 OB_USER_ACTION_MENU_SELECTION
));
159 menu_add_normal(menu
, LAYER_BOTTOM
, _("Always on bottom"),acts
);
162 menu
= menu_new(SEND_TO_MENU_NAME
, _("Send to desktop"), NULL
);
163 menu_set_update_func(menu
, send_to_update
);
166 menu
= menu_new(CLIENT_MENU_NAME
, _("Client menu"), NULL
);
167 menu_set_update_func(menu
, client_update
);
169 e
= menu_add_submenu(menu
, CLIENT_SEND_TO
, SEND_TO_MENU_NAME
);
170 e
->data
.normal
.mask
= ob_rr_theme
->desk_mask
;
171 e
->data
.normal
.mask_normal_color
= ob_rr_theme
->menu_color
;
172 e
->data
.normal
.mask_disabled_color
= ob_rr_theme
->menu_disabled_color
;
173 e
->data
.normal
.mask_selected_color
= ob_rr_theme
->menu_selected_color
;
175 menu_add_submenu(menu
, CLIENT_LAYER
, LAYER_MENU_NAME
);
177 acts
= g_slist_prepend(NULL
, action_from_string
178 ("Iconify", OB_USER_ACTION_MENU_SELECTION
));
179 e
= menu_add_normal(menu
, CLIENT_ICONIFY
, _("Iconify"), acts
);
180 e
->data
.normal
.mask
= ob_rr_theme
->iconify_mask
;
181 e
->data
.normal
.mask_normal_color
= ob_rr_theme
->menu_color
;
182 e
->data
.normal
.mask_disabled_color
= ob_rr_theme
->menu_disabled_color
;
183 e
->data
.normal
.mask_selected_color
= ob_rr_theme
->menu_selected_color
;
185 acts
= g_slist_prepend(NULL
, action_from_string
186 ("ToggleMaximizeFull",
187 OB_USER_ACTION_MENU_SELECTION
));
188 e
= menu_add_normal(menu
, CLIENT_MAXIMIZE
, _("Maximize"), acts
);
189 e
->data
.normal
.mask
= ob_rr_theme
->max_mask
;
190 e
->data
.normal
.mask_normal_color
= ob_rr_theme
->menu_color
;
191 e
->data
.normal
.mask_disabled_color
= ob_rr_theme
->menu_disabled_color
;
192 e
->data
.normal
.mask_selected_color
= ob_rr_theme
->menu_selected_color
;
194 acts
= g_slist_prepend(NULL
, action_from_string
195 ("Raise", OB_USER_ACTION_MENU_SELECTION
));
196 menu_add_normal(menu
, CLIENT_RAISE
, _("Raise to top"), acts
);
198 acts
= g_slist_prepend(NULL
, action_from_string
199 ("Lower", OB_USER_ACTION_MENU_SELECTION
));
200 menu_add_normal(menu
, CLIENT_LOWER
, _("Lower to bottom"),acts
);
202 acts
= g_slist_prepend(NULL
, action_from_string
203 ("ToggleShade", OB_USER_ACTION_MENU_SELECTION
));
204 e
= menu_add_normal(menu
, CLIENT_SHADE
, _("Roll up/down"), acts
);
205 e
->data
.normal
.mask
= ob_rr_theme
->shade_mask
;
206 e
->data
.normal
.mask_normal_color
= ob_rr_theme
->menu_color
;
207 e
->data
.normal
.mask_disabled_color
= ob_rr_theme
->menu_disabled_color
;
208 e
->data
.normal
.mask_selected_color
= ob_rr_theme
->menu_selected_color
;
210 acts
= g_slist_prepend(NULL
, action_from_string
211 ("ToggleDecorations",
212 OB_USER_ACTION_MENU_SELECTION
));
213 menu_add_normal(menu
, CLIENT_DECORATE
, _("Decorate"), acts
);
215 menu_add_separator(menu
, -1);
217 acts
= g_slist_prepend(NULL
, action_from_string
218 ("Move", OB_USER_ACTION_MENU_SELECTION
));
219 menu_add_normal(menu
, CLIENT_MOVE
, _("Move"), acts
);
221 acts
= g_slist_prepend(NULL
, action_from_string
222 ("Resize", OB_USER_ACTION_MENU_SELECTION
));
223 menu_add_normal(menu
, CLIENT_RESIZE
, _("Resize"), acts
);
225 menu_add_separator(menu
, -1);
227 acts
= g_slist_prepend(NULL
, action_from_string
228 ("Close", OB_USER_ACTION_MENU_SELECTION
));
229 e
= menu_add_normal(menu
, CLIENT_CLOSE
, _("Close"), acts
);
230 e
->data
.normal
.mask
= ob_rr_theme
->close_mask
;
231 e
->data
.normal
.mask_normal_color
= ob_rr_theme
->menu_color
;
232 e
->data
.normal
.mask_disabled_color
= ob_rr_theme
->menu_disabled_color
;
233 e
->data
.normal
.mask_selected_color
= ob_rr_theme
->menu_selected_color
;