]>
Dogcows Code - chaz/openbox/blob - plugins/menu/client_list_menu.c
1 #include "kernel/openbox.h"
2 #include "kernel/menu.h"
3 #include "kernel/menuframe.h"
4 #include "kernel/action.h"
5 #include "kernel/screen.h"
6 #include "kernel/client.h"
7 #include "kernel/focus.h"
10 #include "render/theme.h"
14 #define MENU_NAME "client-list-menu"
17 /* how many desktop menus we've made */
25 void plugin_setup_config() { }
27 static void desk_menu_update(ObMenuFrame
*frame
, gpointer data
)
29 ObMenu
*menu
= frame
->menu
;
30 DesktopData
*d
= data
;
34 menu_clear_entries(menu
->name
);
36 for (it
= focus_order
[d
->desktop
], i
= 0; it
; it
= g_list_next(it
), ++i
) {
37 ObClient
*c
= it
->data
;
38 if (client_normal(c
)) {
44 act
= action_from_string("activate");
45 act
->data
.activate
.c
= c
;
46 acts
= g_slist_prepend(NULL
, act
);
47 menu_add_normal(menu
->name
, i
,
48 (c
->iconic
? c
->icon_title
: c
->title
), acts
);
50 if ((icon
= client_icon(c
, 32, 32))) {
51 e
= menu_find_entry_id(menu
, i
);
52 e
->data
.normal
.icon_width
= icon
->width
;
53 e
->data
.normal
.icon_height
= icon
->height
;
54 e
->data
.normal
.icon_data
= icon
->data
;
61 /* executes it without changing the client in the actions, since we set that
62 when we make the actions! */
63 static void desk_menu_execute(ObMenuEntryFrame
*self
, gpointer data
)
67 for (it
= self
->entry
->data
.normal
.actions
; it
; it
= g_slist_next(it
))
69 ObAction
*act
= it
->data
;
70 act
->func(&act
->data
);
74 static void desk_menu_destroy(ObMenu
*menu
, gpointer data
)
76 DesktopData
*d
= data
;
81 static void self_update(ObMenuFrame
*frame
, gpointer data
)
86 menu_clear_entries(MENU_NAME
);
88 for (i
= 0; i
< screen_num_desktops
; ++i
) {
89 gchar
*name
= g_strdup_printf("%s-%u", MENU_NAME
, i
);
90 DesktopData
*data
= g_new(DesktopData
, 1);
93 menu_new(name
, screen_desktop_names
[i
], data
);
94 menu_set_update_func(name
, desk_menu_update
);
95 menu_set_execute_func(name
, desk_menu_execute
);
96 menu_set_destroy_func(name
, desk_menu_destroy
);
98 menu_add_submenu(MENU_NAME
, 0, name
);
103 d
->desktops
= MAX(d
->desktops
, screen_num_desktops
);
106 static void self_destroy(ObMenu
*menu
, gpointer data
)
111 for (i
= 0; i
< d
->desktops
; ++i
) {
112 gchar
*name
= g_strdup_printf("%s-%u", MENU_NAME
, i
);
119 void plugin_startup()
123 data
= g_new(MenuData
, 1);
125 menu_new(MENU_NAME
, _("Desktops"), data
);
126 menu_set_update_func(MENU_NAME
, self_update
);
127 menu_set_destroy_func(MENU_NAME
, self_destroy
);
130 void plugin_shutdown()
132 menu_free(MENU_NAME
);
This page took 0.037584 seconds and 4 git commands to generate.