RrAppearanceFree(self->a_item);
RrAppearanceFree(self->a_disabled);
RrAppearanceFree(self->a_hilite);
+ RrAppearanceFree(self->a_submenu);
XDestroyWindow(ob_display, self->item);
-
+ XDestroyWindow(ob_display, self->submenu_pic);
g_free(self);
}
attrib.event_mask = ENTRY_EVENTMASK;
entry->item = createWindow(menu->items, CWEventMask, &attrib);
+ entry->submenu_pic = createWindow(menu->items, CWEventMask, &attrib);
XMapWindow(ob_display, entry->item);
+ XMapWindow(ob_display, entry->submenu_pic);
- entry->a_item = entry->a_disabled = entry->a_hilite = NULL;
+ entry->a_item = entry->a_disabled = entry->a_hilite = entry->a_submenu
+ = NULL;
menu->invalid = TRUE;
g_hash_table_insert(window_map, &entry->item, menu);
+ g_hash_table_insert(window_map, &entry->submenu_pic, menu);
}
void menu_show(char *name, int x, int y, ObClient *client)
a = screen_physical_area_monitor(self->parent->xin_area);
- if (self->submenu->size.width + x >= a->x + a->width)
- x = self->parent->location.x - self->submenu->size.width -
- ob_rr_theme->bwidth + ob_rr_theme->menu_overlap;
+ if (self->submenu->size.width + x >= a->x + a->width) {
+ int newparentx = a->x + a->width
+ - self->submenu->size.width
+ - self->parent->size.width
+ - ob_rr_theme->bwidth
+ - ob_rr_theme->menu_overlap;
+
+ x = a->x + a->width - self->submenu->size.width
+ - ob_rr_theme->menu_overlap;
+ XWarpPointer(ob_display, None, None, 0, 0, 0, 0,
+ newparentx - self->parent->location.x, 0);
+
+ menu_show_full(self->parent, newparentx,
+ self->parent->location.y, self->parent->client);
+ }
menu_show_full(self->submenu, x,
self->parent->location.y + self->y,
/* render stuff */
Window item;
+ Window submenu_pic;
+
RrAppearance *a_item;
RrAppearance *a_disabled;
RrAppearance *a_hilite;
+ RrAppearance *a_submenu;
gint y;
gint min_w;
} MenuEntry;
e->a_item = RrAppearanceCopy(ob_rr_theme->a_menu_item);
e->a_disabled = RrAppearanceCopy(ob_rr_theme->a_menu_disabled);
e->a_hilite = RrAppearanceCopy(ob_rr_theme->a_menu_hilite);
+ e->a_submenu = RrAppearanceCopy(ob_rr_theme->a_menu_bullet);
}
-
+
e->a_item->texture[0].data.text.string = e->label;
RrMinsize(e->a_item, &e->min_w, &self->item_h);
self->size.width = MAX(self->size.width, e->min_w);
void menu_entry_render(ObMenuEntry *self)
{
ObMenu *menu = self->parent;
- RrAppearance *a;
+ RrAppearance *a, *s = NULL;
switch (self->render_type) {
case OB_MENU_ENTRY_RENDER_TYPE_SUBMENU:
- /* TODO: submenu mask */
+ a = self->enabled ? (self->hilite ? self->a_hilite : self->a_item)
+ : self->a_disabled;
+ s = self->a_submenu;
+ break;
case OB_MENU_ENTRY_RENDER_TYPE_BOOLEAN:
/* TODO: boolean check */
a = self->enabled ? (self->hilite ? self->a_hilite : self->a_item)
g_assert_not_reached(); /* unhandled rendering type */
break;
}
- ob_debug("%s %d\n", self->label, self->hilite);
XMoveResizeWindow(ob_display, self->item, 0, self->y,
menu->size.width, menu->item_h);
-
+ XMoveResizeWindow(ob_display, self->submenu_pic, menu->size.width - ob_rr_theme->bevel - 1, self->y,
+ 8, 8);
a->surface.parent = menu->a_items;
a->surface.parentx = 0;
a->surface.parenty = self->y;
+ if (s) {
+ s->surface.parent = a;
+ s->surface.parentx = menu->size.width - 8;
+ s->surface.parenty = 0;
+ }
+
RrPaint(a, self->item, menu->size.width, menu->item_h);
+
+ if (s)
+ RrPaint(s, self->submenu_pic, 8, 8);
}
+/*
+ * $Header$
+ *
+ * FFIO menu plugin
+ * Provides a menu from a FIFO located in ~/.openbox/fifo_menu/id
+ * Example:
+ * rc3:
+ * <menu id="fonk" label="fonk" plugin="fifo_menu"></menu>
+ * Menu format
+ * <fifo_menu>
+ * <item label="GLOVE.png">
+ * <action name="execute">
+ * <execute>
+ * bsetbg "/home/woodblock/.openbox/backgrounds/GLOVE.png"
+ * </execute>
+ * </action>
+ * </item>
+ * </fifo_menu>
+ *
+ * If the attribute pid="true" is in the <menu>
+ */
+
#include <glib.h>
#include <sys/types.h>
#include <sys/stat.h>
if (node &&
!xmlStrcasecmp(node->name, (const xmlChar*) "fifo_menu")) {
- if ((node = parse_find_node("item", node->xmlChildrenNode)))
- parse_menu_full(doc, node, menu, FALSE);
+ parse_menu_full(doc, node, menu, FALSE);
}
fifo_menu_clean_up(menu);
+/*
+ * $Header$
+ *
+ * Timed menu plugin
+ * Provides a menu from either a periodically executing process or by
+ * periodically checking the timestamp of a file and loading if it has changed.
+ *
+ * Examples:
+ * Piped timed menu:
+ * rc3:
+ * <menu id="name" label="Piped menu" plugin="timed_menu" timeout="120"
+ * command="obcommand.py -c bsetbg -d ~/.openbox/backgrounds/" />
+ * timeout is in seconds
+ *
+ * Output of command:
+ * <timed_menu>
+ * <item label="GLOVE.png">
+ * <action name="execute">
+ * <execute>
+ * bsetbg "/home/woodblock/.openbox/backgrounds/GLOVE.png"
+ * </execute>
+ * </action>
+ * </item>
+ * </fifo_menu>
+ *
+ * stat() menu:
+ * <menu id="name" label="Stat menu" plugin="timed_menu" type="stat"
+ * timeout="120" file="~/.openbox/stat_menu" />
+ * stat_menu contents: same as timed menu
+ *
+ */
+
#include <glib.h>
#include <stdlib.h>
#include <unistd.h>
typedef struct {
Timed_Menu_Type type;
ObTimer *timer;
- char *command; /* for the PIPE */
+ char *command; /* command to run or file to stat() */
char *buf; /* buffer to hold partially read menu */
unsigned long buflen; /* how many bytes are in the buffer */
int fd; /* file descriptor to read menu from */
void timed_menu_clean_up(ObMenu *m) {
if (TIMED_MENU_DATA(m)->buf != NULL) {
- fprintf(stderr, "%s", TIMED_MENU_DATA(m)->buf);
g_free(TIMED_MENU_DATA(m)->buf);
TIMED_MENU_DATA(m)->buf = NULL;
}
waitpid(TIMED_MENU_DATA(m)->pid, NULL, 0);
TIMED_MENU_DATA(m)->pid = -1;
}
-
- TIMED_MENU_DATA(m)->mtime = 0;
}
void timed_menu_read_pipe(int fd, void *d)
node = xmlDocGetRootElement(doc);
- if (!xmlStrcasecmp(node->name, (const xmlChar*) "timed_menu")) {
- if ((node = parse_find_node("item", node->xmlChildrenNode)))
- parse_menu_full(doc, node, menu, FALSE);
+ if (node &&
+ !xmlStrcasecmp(node->name, (const xmlChar*) "timed_menu")) {
+ parse_menu_full(doc, node, menu, FALSE);
}
timed_menu_clean_up(menu);
}
if (stat_buf.st_mtime > TIMED_MENU_DATA(data)->mtime) {
+ xmlDocPtr doc;
+ xmlNodePtr node;
+
g_warning("file changed");
TIMED_MENU_DATA(data)->mtime = stat_buf.st_mtime;
- /* TODO: parse */
+
+ data->invalid = TRUE;
+ menu_clear(data);
+
+ doc = xmlParseFile(TIMED_MENU_DATA(data)->command);
+
+ node = xmlDocGetRootElement(doc);
+
+ if (node &&
+ !xmlStrcasecmp(node->name, (const xmlChar*) "timed_menu")) {
+ parse_menu_full(doc, node, data, FALSE);
+ }
+
+ timed_menu_clean_up(data);
}
}
}
char *id;
char *label;
char *timeout;
+ char *type;
+
Timed_Menu_Data *d;
ObMenu *m;
(label != NULL ? label : ""),
m));
- if (!parse_attr_string("command", data->node, &d->command)) {
- d->command = g_strdup("");
- }
+ d->type = TIMED_MENU_PIPE;
+
+ if (parse_attr_string("type", data->node, &type) &&
+ !g_strcasecmp(type, "stat")) {
+ d->type = TIMED_MENU_STAT;
+
+ if (!parse_attr_string("file", data->node, &d->command)) {
+ d->command = g_strdup("");
+ }
+ } else
+ if (!parse_attr_string("command", data->node, &d->command)) {
+ d->command = g_strdup("");
+ }
if (parse_attr_string("timeout", data->node, &timeout)) {
char *endptr;
} else
d->timer = timer_start(600 * 1000000, &timed_menu_timeout_handler, m);
- d->type = TIMED_MENU_PIPE;
d->buf = NULL;
d->buflen = 0;
d->fd = -1;
theme->a_menu_item = RrAppearanceNew(inst, 1);
theme->a_menu_disabled = RrAppearanceNew(inst, 1);
theme->a_menu_hilite = RrAppearanceNew(inst, 1);
+ theme->a_menu_bullet = RrAppearanceNew(inst, 1);
theme->a_clear = RrAppearanceNew(inst, 0);
theme->app_hilite_bg = RrAppearanceNew(inst, 0);
if (!read_color(db, inst,
"menu.frame.textColor", &theme->menu_color))
theme->menu_color = RrColorNew(inst, 0xff, 0xff, 0xff);
+ if (!read_color(db, inst,
+ "menu.bullet.picColor", &theme->menu_color))
+ theme->menu_bullet_color = RrColorNew(inst, 0x00, 0x00, 0x00);
if (!read_color(db, inst,
"menu.frame.disableColor", &theme->menu_disabled_color))
theme->menu_disabled_color = RrColorNew(inst, 0, 0, 0);
"menu.hilite.textColor", &theme->menu_hilite_color))
theme->menu_hilite_color = RrColorNew(inst, 0, 0, 0);
+
if (read_mask(inst, "max.xbm", theme, &theme->max_mask)) {
if (!read_mask(inst, "max_pressed.xbm", theme,
&theme->max_pressed_mask)) {
theme->close_pressed_mask = RrPixmapMaskCopy(theme->close_mask);
theme->close_disabled_mask = RrPixmapMaskCopy(theme->close_mask);
theme->close_hover_mask = RrPixmapMaskCopy(theme->close_mask);
- }
+ }
+
+ if (!read_mask(inst, "bullet.xbm", theme, &theme->menu_bullet_mask)) {
+ unsigned char data[] =
+ { 0x18, 0x30, 0x60, 0xfe, 0xfe, 0x60, 0x30, 0x18 };
+ theme->menu_bullet_mask = RrPixmapMaskNew(inst, 8, 8,
+ (gchar *)data);
+ }
/* read the decoration textures */
if (!read_appearance(db, inst,
theme->a_menu_item->surface.grad =
theme->a_menu_disabled->surface.grad =
+ theme->a_menu_bullet->surface.grad =
theme->app_icon->surface.grad = RR_SURFACE_PARENTREL;
theme->a_menu_item->texture[0].type =
theme->menu_disabled_color;
theme->a_menu_hilite->texture[0].data.text.color =
theme->menu_hilite_color;
+ theme->a_menu_bullet->texture[0].data.mask.color =
+ theme->menu_bullet_color;
theme->a_disabled_focused_max->texture[0].type =
theme->a_disabled_unfocused_max->texture[0].type =
theme->a_focused_unpressed_iconify->texture[0].type =
theme->a_focused_pressed_iconify->texture[0].type =
theme->a_unfocused_unpressed_iconify->texture[0].type =
- theme->a_unfocused_pressed_iconify->texture[0].type = RR_TEXTURE_MASK;
+ theme->a_unfocused_pressed_iconify->texture[0].type =
+ theme->a_menu_bullet->texture[0].type = RR_TEXTURE_MASK;
+
theme->a_disabled_focused_max->texture[0].data.mask.mask =
theme->a_disabled_unfocused_max->texture[0].data.mask.mask =
theme->max_disabled_mask;
RrPixmapMaskFree(theme->close_disabled_mask);
RrPixmapMaskFree(theme->close_hover_mask);
RrPixmapMaskFree(theme->close_pressed_mask);
+ RrPixmapMaskFree(theme->menu_bullet_mask);
RrFontClose(theme->winfont);
RrFontClose(theme->mtitlefont);
RrColor *titlebut_unfocused_unpressed_color;
RrColor *menu_title_color;
RrColor *menu_color;
+ RrColor *menu_bullet_color;
RrColor *menu_disabled_color;
RrColor *menu_hilite_color;
RrPixmapMask *close_disabled_mask;
RrPixmapMask *close_pressed_mask;
+ RrPixmapMask *menu_bullet_mask; /* submenu pointer */
+ RrPixmapMask *menu_toggle_mask; /* menu boolean */
+
/* global appearances */
RrAppearance *a_disabled_focused_max;
RrAppearance *a_disabled_unfocused_max;
RrAppearance *a_menu_item;
RrAppearance *a_menu_disabled;
RrAppearance *a_menu_hilite;
+ RrAppearance *a_menu_bullet;
RrAppearance *a_clear;
RrAppearance *app_hilite_bg;
RrAppearance *app_hilite_label;
RrAppearance *app_unhilite_label;
RrAppearance *app_icon;
+
};
RrTheme *RrThemeNew(const RrInstance *inst, gchar *theme);