Exemplo n.º 1
0
static gboolean desk_menu_update(ObMenuFrame *frame, gpointer data)
{
    ObMenu *menu = frame->menu;
    DesktopData *d = data;
    GList *it;
    gboolean empty = TRUE;
    gboolean onlyiconic = TRUE;

    menu_clear_entries(menu);

    for (it = focus_order; it; it = g_list_next(it)) {
        ObClient *c = it->data;
        if (focus_valid_target(c, d->desktop,
                               TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE)) {
            ObMenuEntry *e;

            empty = FALSE;

            if (c->iconic) {
                gchar *title = g_strdup_printf("(%s)", c->icon_title);
                e = menu_add_normal(menu, d->desktop, title, NULL, FALSE);
                g_free(title);
            } else {
                onlyiconic = FALSE;
                e = menu_add_normal(menu, d->desktop, c->title, NULL, FALSE);
            }

            if (config_menu_show_icons) {
                e->data.normal.icon = client_icon(c);
                RrImageRef(e->data.normal.icon);
                e->data.normal.icon_alpha = c->iconic ? OB_ICONIC_ALPHA : 0xff;
            }

            e->data.normal.data = c;
        }
    }

    if (empty || onlyiconic) {
        ObMenuEntry *e;

        /* no entries or only iconified windows, so add a
         * way to go to this desktop without uniconifying a window */
        if (!empty)
            menu_add_separator(menu, SEPARATOR, NULL);

        e = menu_add_normal(menu, d->desktop, _("Go there..."), NULL, TRUE);
        if (d->desktop == screen_desktop)
            e->data.normal.enabled = FALSE;
    }

    return TRUE; /* always show */
}
Exemplo n.º 2
0
static gboolean self_update(ObMenuFrame *frame, gpointer data)
{
    ObMenu *menu = frame->menu;
    guint i;

    menu_clear_entries(menu);

    while (desktop_menus) {
        menu_free(desktop_menus->data);
        desktop_menus = g_slist_delete_link(desktop_menus, desktop_menus);
    }

    for (i = 0; i < screen_num_desktops; ++i) {
        ObMenu *submenu;
        gchar *name = g_strdup_printf("%s-%u", MENU_NAME, i);
        DesktopData *ddata = g_slice_new(DesktopData);

        ddata->desktop = i;
        submenu = menu_new(name, screen_desktop_names[i], FALSE, ddata);
        menu_set_update_func(submenu, desk_menu_update);
        menu_set_execute_func(submenu, desk_menu_execute);
        menu_set_destroy_func(submenu, desk_menu_destroy);

        menu_add_submenu(menu, i, name);

        g_free(name);

        desktop_menus = g_slist_append(desktop_menus, submenu);
    }

    if (config_menu_manage_desktops) {
        menu_add_separator(menu, SEPARATOR, NULL);
        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 */
}
Exemplo n.º 3
0
static void parse_menu_item(xmlNodePtr node,  gpointer data)
{
    ObMenuParseState *state = data;
    gchar *label;
    gchar *icon;
    ObMenuEntry *e;

    if (state->parent) {
        /* Don't try to extract "icon" attribute if icons in user-defined
           menus are not enabled. */

        if (obt_xml_attr_string(node, "label", &label)) {
            xmlNodePtr c;
            GSList *acts = NULL;

            c = obt_xml_find_node(node->children, "action");
            while (c) {
                ObActionsAct *action = actions_parse(c);
                if (action)
                    acts = g_slist_append(acts, action);
                c = obt_xml_find_node(node->next, "action");
            }
            e = menu_add_normal(state->parent, -1, label, acts, TRUE);
            
            if (config_menu_show_icons &&
                obt_xml_attr_string(node, "icon", &icon))
            {
                RrImage *ic;

                ic = RrImageCacheFindName(ob_rr_icons, icon);
                if (ic)
                    RrImageRef(ic);
                else {
                    ic = RrImageNew(ob_rr_icons);
                    if (!RrImageAddPictureName(ic, icon)) {
                        RrImageUnref(ic); /* no need to keep it around */
                        ic = NULL;
                    }
                }
                e->data.normal.icon = ic;

                if (e->data.normal.icon)
                    e->data.normal.icon_alpha = 0xff;

                g_free(icon);
            }
            g_free(label);
        }
    }
}
Exemplo n.º 4
0
static gboolean self_update(ObMenuFrame *frame, gpointer data)
{
    ObMenu *menu = frame->menu;
    ObMenuEntry *e;
    GList *it;
    guint desktop;

    menu_clear_entries(menu);

    for (desktop = 0; desktop < screen_num_desktops; desktop++) {
        gboolean empty = TRUE;
        gboolean onlyiconic = TRUE;

        menu_add_separator(menu, SEPARATOR, screen_desktop_names[desktop]);
        for (it = client_list; it; it = g_list_next(it)) {
            ObClient *c = it->data;
            if (focus_valid_target(c, desktop,
                                   TRUE, TRUE,
                                   FALSE, TRUE, FALSE, FALSE, FALSE))
            {
                empty = FALSE;

                if (c->iconic) {
                    gchar *title = g_strdup_printf("(%s)", c->icon_title);
                    e = menu_add_normal(menu, desktop, title, NULL, FALSE);
                    g_free(title);
                } else {
                    onlyiconic = FALSE;
                    e = menu_add_normal(menu, desktop, c->title, NULL, FALSE);
                    e->data.normal.indent = get_order(c, desktop);
                }

                if (config_menu_show_icons) {
                    e->data.normal.icon = client_icon(c);
                    RrImageRef(e->data.normal.icon);
                    e->data.normal.icon_alpha =
                        c->iconic ? OB_ICONIC_ALPHA : 0xff;
                }

                e->data.normal.data = c;
            }
        }

        if (empty || onlyiconic) {
            /* no entries or only iconified windows, so add a
             * way to go to this desktop without uniconifying a window */
            if (!empty)
                menu_add_separator(menu, SEPARATOR, NULL);

            e = menu_add_normal(menu, desktop, _("Go there..."), NULL, TRUE);
            if (desktop == screen_desktop)
                e->data.normal.enabled = FALSE;
        }
    }

    if (config_menu_manage_desktops) {
        menu_add_separator(menu, SEPARATOR, _("Manage desktops"));
        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 */
}