/****f* pekwm-menu/menu_application * FUNCTION * create a menu entry for an application. ****/ void menu_application (MenuCacheApp *app, OB_Menu *context) { const char *exec_name = NULL; gchar *exec_icon = NULL; gchar *exec_cmd = NULL; /* is comment (description) or name displayed ? */ if (context->comment && menu_cache_item_get_comment (MENU_CACHE_ITEM(app))) exec_name = menu_cache_item_get_comment (MENU_CACHE_ITEM(app)); else exec_name = menu_cache_item_get_name (MENU_CACHE_ITEM(app)); exec_cmd = clean_exec (app); #ifdef WITH_ICONS if (!context->no_icons) { exec_icon = get_item_icon_path (MENU_CACHE_ITEM(app)); g_string_append_printf (context->builder, "Entry = \"%s\" { Icon = \"%s\"; Actions = \"Exec ", exec_name, exec_icon); } else #endif { g_string_append_printf (context->builder, "Entry = \"%s\" { Actions = \"Exec ", exec_name); } if (menu_cache_app_get_use_terminal (app)) g_string_append_printf (context->builder, "%s %s &\" }\n", context->terminal_cmd, exec_cmd); else g_string_append_printf (context->builder, "%s &\" }\n", exec_cmd); g_free (exec_icon); g_free (exec_cmd); }
XdgCachedMenuAction::XdgCachedMenuAction(MenuCacheItem* item, QObject* parent): QAction(parent), item_(menu_cache_item_ref(item)) { QString title = QString::fromUtf8(menu_cache_item_get_name(item)); title = title.replace('&', QLatin1String("&&")); // & is reserved for mnemonics setText(title); // Only set tooltips for app items if(menu_cache_item_get_type(item) == MENU_CACHE_TYPE_APP) { QString comment = QString::fromUtf8(menu_cache_item_get_comment(item)); setToolTip(comment); } }
XdgCachedMenuAction::XdgCachedMenuAction(MenuCacheItem* item, QObject* parent): QAction(parent), item_(menu_cache_item_ref(item)) { QString title = QString::fromUtf8(menu_cache_item_get_name(item)); setText(title); // Only set tooltips for app items if(menu_cache_item_get_type(item) == MENU_CACHE_TYPE_APP) { QString comment = QString::fromUtf8(menu_cache_item_get_comment(item)); setToolTip(comment); } QIcon icon = XdgIcon::fromTheme(menu_cache_item_get_icon(item)); setIcon(icon); }
AppLinkItem::AppLinkItem(MenuCacheApp* app): CommandProviderItem() { MenuCacheItem* item = MENU_CACHE_ITEM(app); mIconName = QString::fromUtf8(menu_cache_item_get_icon(item)); mTitle = QString::fromUtf8(menu_cache_item_get_name(item)); mComment = QString::fromUtf8(menu_cache_item_get_comment(item)); mToolTip = mComment; mCommand = menu_cache_app_get_exec(app); mProgram = QFileInfo(mCommand).baseName().section(" ", 0, 0); char* path = menu_cache_item_get_file_path(MENU_CACHE_ITEM(app)); mDesktopFile = QString::fromLocal8Bit(path); g_free(path); QMetaObject::invokeMethod(this, "updateIcon", Qt::QueuedConnection); // qDebug() << "FOUND: " << mIconName << ", " << mCommand; }