mirror of
https://github.com/gryf/wmaker.git
synced 2026-02-11 19:25:49 +01:00
added WINDOWS_MENU to rootmenu
This commit is contained in:
@@ -3,6 +3,8 @@ Changes since version 0.64.0:
|
|||||||
- fix with gnome hints stuff, related to tasklist/bar
|
- fix with gnome hints stuff, related to tasklist/bar
|
||||||
- ripped off single appicon stuff
|
- ripped off single appicon stuff
|
||||||
- added better appicon handling of apps of the same type
|
- added better appicon handling of apps of the same type
|
||||||
|
- applied patch for wkdemenu (Malcolm Cowe <malk@bruhaha.co.uk>)
|
||||||
|
- added WINDOWS_MENU submenu type for root menu (Bastien Nocera <hadess@hadess.net>)
|
||||||
|
|
||||||
Changes since version 0.63.1:
|
Changes since version 0.63.1:
|
||||||
.............................
|
.............................
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ void clickedTable(WMWidget *w, void *self)
|
|||||||
|
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
Display *dpy = XOpenDisplay("");
|
|
||||||
WMScreen *scr;
|
WMScreen *scr;
|
||||||
WMWindow *win;
|
WMWindow *win;
|
||||||
WMTableView *table;
|
WMTableView *table;
|
||||||
@@ -81,14 +80,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
WMInitializeApplication("test", &argc, argv);
|
WMInitializeApplication("test", &argc, argv);
|
||||||
|
|
||||||
|
scr = WMOpenScreen();
|
||||||
|
|
||||||
dpy = XOpenDisplay("");
|
|
||||||
if (!dpy) {
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
scr = WMCreateScreen(dpy, DefaultScreen(dpy));
|
|
||||||
|
|
||||||
|
|
||||||
win = WMCreateWindow(scr, "eweq");
|
win = WMCreateWindow(scr, "eweq");
|
||||||
|
|||||||
@@ -1279,6 +1279,7 @@ main(int argc, char **argv)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
testScrollView(scr);
|
||||||
testTabView(scr);
|
testTabView(scr);
|
||||||
#if 0
|
#if 0
|
||||||
testBox(scr);
|
testBox(scr);
|
||||||
@@ -1295,7 +1296,6 @@ main(int argc, char **argv)
|
|||||||
testDragAndDrop(scr);
|
testDragAndDrop(scr);
|
||||||
testFontPanel(scr);
|
testFontPanel(scr);
|
||||||
|
|
||||||
testScrollView(scr);
|
|
||||||
testButton(scr);
|
testButton(scr);
|
||||||
|
|
||||||
testFrame(scr);
|
testFrame(scr);
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ WMCreateAlertPanel(WMScreen *scrPtr, WMWindow *owner,
|
|||||||
|
|
||||||
|
|
||||||
if (msg) {
|
if (msg) {
|
||||||
panel->mLbl = WMCreateLabel(panel->win);
|
panel->mLbl = WMCreateLabel(panel->vbox);
|
||||||
WMSetLabelWraps(panel->mLbl, True);
|
WMSetLabelWraps(panel->mLbl, True);
|
||||||
WMMapWidget(panel->mLbl);
|
WMMapWidget(panel->mLbl);
|
||||||
WMAddBoxSubview(panel->vbox, WMWidgetView(panel->mLbl), True, True,
|
WMAddBoxSubview(panel->vbox, WMWidgetView(panel->mLbl), True, True,
|
||||||
|
|||||||
@@ -195,7 +195,7 @@ WMSetScrollerParameters(WMScroller *sPtr, float floatValue,
|
|||||||
if (sPtr->view->flags.realized)
|
if (sPtr->view->flags.realized)
|
||||||
paintScroller(sPtr);
|
paintScroller(sPtr);
|
||||||
|
|
||||||
WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, NULL);
|
/* WMPostNotificationName(WMScrollerDidScrollNotification, sPtr, NULL);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ typedef struct W_ScrollView {
|
|||||||
|
|
||||||
WMScroller *vScroller;
|
WMScroller *vScroller;
|
||||||
WMScroller *hScroller;
|
WMScroller *hScroller;
|
||||||
|
|
||||||
short lineScroll;
|
short lineScroll;
|
||||||
short pageScroll;
|
short pageScroll;
|
||||||
|
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ typedef enum {
|
|||||||
PipeInfo,
|
PipeInfo,
|
||||||
DirectoryInfo,
|
DirectoryInfo,
|
||||||
WSMenuInfo,
|
WSMenuInfo,
|
||||||
|
WWindowListInfo,
|
||||||
LastInfo
|
LastInfo
|
||||||
} InfoType;
|
} InfoType;
|
||||||
|
|
||||||
@@ -461,6 +462,7 @@ createPanel(_Panel *p)
|
|||||||
panel->markerPix[PipeInfo] = pixm;
|
panel->markerPix[PipeInfo] = pixm;
|
||||||
panel->markerPix[DirectoryInfo] = pixm;
|
panel->markerPix[DirectoryInfo] = pixm;
|
||||||
panel->markerPix[WSMenuInfo] = pixm;
|
panel->markerPix[WSMenuInfo] = pixm;
|
||||||
|
panel->markerPix[WWindowListInfo] = pixm;
|
||||||
|
|
||||||
XFreeGC(dpy, gc);
|
XFreeGC(dpy, gc);
|
||||||
}
|
}
|
||||||
@@ -495,6 +497,7 @@ createPanel(_Panel *p)
|
|||||||
data = putNewItem(panel, pad, PipeInfo, _("Generated Submenu"));
|
data = putNewItem(panel, pad, PipeInfo, _("Generated Submenu"));
|
||||||
data = putNewItem(panel, pad, DirectoryInfo, _("Directory Contents"));
|
data = putNewItem(panel, pad, DirectoryInfo, _("Directory Contents"));
|
||||||
data = putNewItem(panel, pad, WSMenuInfo, _("Workspace Menu"));
|
data = putNewItem(panel, pad, WSMenuInfo, _("Workspace Menu"));
|
||||||
|
data = putNewItem(panel, pad, WWindowListInfo, _("Window List Menu"));
|
||||||
|
|
||||||
panel->itemPad[0] = pad;
|
panel->itemPad[0] = pad;
|
||||||
}
|
}
|
||||||
@@ -1029,6 +1032,8 @@ parseCommand(proplist_t item)
|
|||||||
}
|
}
|
||||||
} else if (strcmp(command, "WORKSPACE_MENU") == 0) {
|
} else if (strcmp(command, "WORKSPACE_MENU") == 0) {
|
||||||
data->type = WSMenuInfo;
|
data->type = WSMenuInfo;
|
||||||
|
} else if (strcmp(command, "WINDOWS_MENU") == 0) {
|
||||||
|
data->type = WWindowListInfo;
|
||||||
} else {
|
} else {
|
||||||
int cmd;
|
int cmd;
|
||||||
|
|
||||||
@@ -1114,6 +1119,10 @@ updateFrameTitle(_Panel *panel, char *title, InfoType type)
|
|||||||
tmp = wstrconcat(title, _(": Open Workspaces Submenu"));
|
tmp = wstrconcat(title, _(": Open Workspaces Submenu"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WWindowListInfo:
|
||||||
|
tmp = wstrconcat(title, _(": Open Window List Submenu"));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
tmp = NULL;
|
tmp = NULL;
|
||||||
break;
|
break;
|
||||||
@@ -1704,6 +1713,10 @@ processData(char *title, ItemData *data)
|
|||||||
PLAppendArrayElement(item, PLMakeString("WORKSPACE_MENU"));
|
PLAppendArrayElement(item, PLMakeString("WORKSPACE_MENU"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case WWindowListInfo:
|
||||||
|
PLAppendArrayElement(item, PLMakeString("WINDOWS_MENU"));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -770,6 +770,32 @@ addWorkspaceMenu(WScreen *scr, WMenu *menu, char *title)
|
|||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static WMenuEntry*
|
||||||
|
addWindowsMenu(WScreen *scr, WMenu *menu, char *title)
|
||||||
|
{
|
||||||
|
WMenu *wwmenu;
|
||||||
|
WWindow *wwin;
|
||||||
|
WMenuEntry *entry;
|
||||||
|
|
||||||
|
if (scr->flags.added_windows_menu) {
|
||||||
|
wwarning(_("There are more than one WINDOWS_MENU commands in the applications menu. Only one is allowed."));
|
||||||
|
return NULL;
|
||||||
|
} else {
|
||||||
|
scr->flags.added_windows_menu = 1;
|
||||||
|
|
||||||
|
wwmenu = wMenuCreate(scr, _("Window List"), False);
|
||||||
|
scr->switch_menu = wwmenu;
|
||||||
|
wwin = scr->focused_window;
|
||||||
|
while (wwin) {
|
||||||
|
UpdateSwitchMenu(scr, wwin, ACTION_ADD);
|
||||||
|
|
||||||
|
wwin = wwin->prev;
|
||||||
|
}
|
||||||
|
entry = wMenuAddCallback(menu, title, NULL, NULL);
|
||||||
|
wMenuEntrySetCascade(menu, entry, wwmenu);
|
||||||
|
}
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
static WMenuEntry*
|
static WMenuEntry*
|
||||||
addMenuEntry(WMenu *menu, char *title, char *shortcut, char *command,
|
addMenuEntry(WMenu *menu, char *title, char *shortcut, char *command,
|
||||||
@@ -844,6 +870,10 @@ addMenuEntry(WMenu *menu, char *title, char *shortcut, char *command,
|
|||||||
} else if (strcmp(command, "WORKSPACE_MENU")==0) {
|
} else if (strcmp(command, "WORKSPACE_MENU")==0) {
|
||||||
entry = addWorkspaceMenu(scr, menu, title);
|
entry = addWorkspaceMenu(scr, menu, title);
|
||||||
|
|
||||||
|
shortcutOk = True;
|
||||||
|
} else if (strcmp(command, "WINDOWS_MENU")==0) {
|
||||||
|
entry = addWindowsMenu(scr, menu, title);
|
||||||
|
|
||||||
shortcutOk = True;
|
shortcutOk = True;
|
||||||
} else if (strcmp(command, "ARRANGE_ICONS")==0) {
|
} else if (strcmp(command, "ARRANGE_ICONS")==0) {
|
||||||
entry = wMenuAddCallback(menu, title, arrangeIconsCommand, NULL);
|
entry = wMenuAddCallback(menu, title, arrangeIconsCommand, NULL);
|
||||||
|
|||||||
@@ -310,6 +310,7 @@ typedef struct _WScreen {
|
|||||||
unsigned int dnd_data_convertion_status:1;
|
unsigned int dnd_data_convertion_status:1;
|
||||||
unsigned int root_menu_changed_shortcuts:1;
|
unsigned int root_menu_changed_shortcuts:1;
|
||||||
unsigned int added_workspace_menu:1;
|
unsigned int added_workspace_menu:1;
|
||||||
|
unsigned int added_windows_menu:1;
|
||||||
unsigned int startup2:1; /* startup phase 2 */
|
unsigned int startup2:1; /* startup phase 2 */
|
||||||
unsigned int supports_tiff:1;
|
unsigned int supports_tiff:1;
|
||||||
unsigned int clip_balloon_mapped:1;
|
unsigned int clip_balloon_mapped:1;
|
||||||
|
|||||||
311
util/wkdemenu.pl
311
util/wkdemenu.pl
@@ -54,9 +54,32 @@
|
|||||||
#
|
#
|
||||||
#---------------------------------------------------------------------
|
#---------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# 21st January 2001.
|
# v1.2.0 -- 14th February 2001.
|
||||||
#
|
#
|
||||||
# This script has been competely re-written to allow recursion of the
|
# Added alphabetic sorting of the menus.
|
||||||
|
#
|
||||||
|
# Directories are now displayed before files in the menu.
|
||||||
|
#
|
||||||
|
#---------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# v1.1.5 -- 3rd February 2001. (No public release)
|
||||||
|
#
|
||||||
|
# Unsupported applnk files have a fallback entry in the menu tree so
|
||||||
|
# that users can report menu entries that do not work. So far,
|
||||||
|
# wkdemenu.pl assumes that there is an Exec= line in the application
|
||||||
|
# definition, which is not always the case.
|
||||||
|
#
|
||||||
|
# --------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# v1.1.0 -- 29th January 2001.
|
||||||
|
#
|
||||||
|
# Code cleanup and bug fixes.
|
||||||
|
#
|
||||||
|
# --------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# v1.0.0 -- 21st January 2001.
|
||||||
|
#
|
||||||
|
# This script has been completely re-written to allow recursion of the
|
||||||
# KDE menu directories to an arbitrary depth, fixing a major
|
# KDE menu directories to an arbitrary depth, fixing a major
|
||||||
# functional limitation in the original script. To do this, I have
|
# functional limitation in the original script. To do this, I have
|
||||||
# rewritten the code to traverse directories recursively, introducing
|
# rewritten the code to traverse directories recursively, introducing
|
||||||
@@ -92,6 +115,9 @@
|
|||||||
# use. This still defaults to xterm, but could be used to specify
|
# use. This still defaults to xterm, but could be used to specify
|
||||||
# aterm, etc.
|
# aterm, etc.
|
||||||
#
|
#
|
||||||
|
# Malcolm Cowe, malk@271m.net.
|
||||||
|
#
|
||||||
|
# --------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# To Do
|
# To Do
|
||||||
# -----
|
# -----
|
||||||
@@ -99,9 +125,6 @@
|
|||||||
# Programmatically determine the system location for the KDE menu
|
# Programmatically determine the system location for the KDE menu
|
||||||
# directory.
|
# directory.
|
||||||
#
|
#
|
||||||
# Organise the output alphabetically, with directories appearing
|
|
||||||
# before files.
|
|
||||||
#
|
|
||||||
# Find a better way to parse the Exec= lines. In the short term,
|
# Find a better way to parse the Exec= lines. In the short term,
|
||||||
# provide a user mechanism for generating exceptions to the curtailing
|
# provide a user mechanism for generating exceptions to the curtailing
|
||||||
# of command line options. In the longer term, emulate what KDE does
|
# of command line options. In the longer term, emulate what KDE does
|
||||||
@@ -110,46 +133,51 @@
|
|||||||
# Optimise the code. This is my first proper PERL script, and I'm sure
|
# Optimise the code. This is my first proper PERL script, and I'm sure
|
||||||
# there's a better way. =)
|
# there's a better way. =)
|
||||||
#
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Variables
|
||||||
#
|
#
|
||||||
# Malcolm Cowe, malk@271m.net.
|
|
||||||
|
|
||||||
###
|
# The External Menu file, this should NEVER point to the root menu file
|
||||||
### Variables
|
|
||||||
###
|
|
||||||
|
|
||||||
### The External Menu file, this should NEVER point to the root menu file
|
|
||||||
$menufile = "$ENV{'HOME'}/.kde2wmaker.menu";
|
$menufile = "$ENV{'HOME'}/.kde2wmaker.menu";
|
||||||
|
|
||||||
### Base directory, location of all the KDE AppName.kdelnk files +
|
# Base directory, location of all the KDE AppName.kdelnk files.
|
||||||
### Malcolm Cowe, 21/01/2001.
|
|
||||||
### Change the base directory default to point at the system files,
|
# Change the base directory default to point at the system files,
|
||||||
### not the user files. Need to find a way of determining the prefix
|
# not the user files. Need to find a way of determining the prefix
|
||||||
### programmatically.
|
# programmatically.
|
||||||
$prefix="/usr";
|
$prefix="/usr";
|
||||||
$basedir = $prefix."/share/applnk";
|
$basedir = $prefix."/share/applnk";
|
||||||
### - Malcolm Cowe, 21/01/2001.
|
|
||||||
|
|
||||||
### Terminal to use. May be specified on the command line with the -t
|
# Terminal to use. May be specified on the command line with the -t
|
||||||
### switch.
|
# switch.
|
||||||
$term = "xterm";
|
$term = "xterm";
|
||||||
|
|
||||||
### Print to STDOUT, default is YES, a filename is specified
|
# Xmessage command line to invoke (can vary platform to platform)
|
||||||
|
$ostype = `uname -s`;
|
||||||
|
if ($ostype =~ /^HP-UX$/) {
|
||||||
|
$xmsg = "xmessage -geometry 400x100 -f -";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$xmsg = "xmessage -geometry 400x100 -file - -default \"okay\"";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Print to STDOUT, default is YES, a filename is specified
|
||||||
$stdout = 1;
|
$stdout = 1;
|
||||||
|
|
||||||
### + Malcolm Cowe, 21/01/2001.
|
# KDE Locale Support
|
||||||
### KDE Locale Support
|
|
||||||
|
|
||||||
### Support for KDE internationalisation so that menu entries appear
|
# Support for KDE internationalisation so that menu entries appear
|
||||||
### in the language chosen by the user. Also gets around some problems
|
# in the language chosen by the user. Also gets around some problems
|
||||||
### with the KDE applnk file format.
|
# with the KDE applnk file format.
|
||||||
|
|
||||||
### The Locale is stored in one of two places, depending on the
|
# The Locale is stored in one of two places, depending on the
|
||||||
### version of KDE that is running.
|
# version of KDE that is running.
|
||||||
$kde2cf="$ENV{'HOME'}/.kde/share/config/kdeglobals";
|
$kde2cf="$ENV{'HOME'}/.kde/share/config/kdeglobals";
|
||||||
$kde1cf="$ENV{'HOME'}/.kderc";
|
$kde1cf="$ENV{'HOME'}/.kderc";
|
||||||
$kdeLanguage = "";
|
$kdeLanguage = "";
|
||||||
|
|
||||||
### Open the file, if it exists, otherwise provide a default language.
|
# Open the file, if it exists, otherwise provide a default language.
|
||||||
unless(open KDERC, $kde2cf) {
|
unless(open KDERC, $kde2cf) {
|
||||||
unless(open KDERC, $kde1cf) {
|
unless(open KDERC, $kde1cf) {
|
||||||
$kdeLanguage = "C";
|
$kdeLanguage = "C";
|
||||||
@@ -158,10 +186,10 @@ unless(open KDERC, $kde2cf) {
|
|||||||
|
|
||||||
if ( $kdeLanguage == ""){
|
if ( $kdeLanguage == ""){
|
||||||
$kdeLanguage = "C";
|
$kdeLanguage = "C";
|
||||||
### Search through the contents of the file
|
# Search through the contents of the file
|
||||||
while($line = <KDERC>) {
|
while($line = <KDERC>) {
|
||||||
chomp($line);
|
chomp($line);
|
||||||
### Grab the Language
|
# Grab the Language
|
||||||
if($line =~ /^Language=/) {
|
if($line =~ /^Language=/) {
|
||||||
$kdeLanguage = $line;
|
$kdeLanguage = $line;
|
||||||
$kdeLanguage =~ s/Language=//;
|
$kdeLanguage =~ s/Language=//;
|
||||||
@@ -172,14 +200,12 @@ if ( $kdeLanguage == ""){
|
|||||||
close(KDERC);
|
close(KDERC);
|
||||||
}
|
}
|
||||||
|
|
||||||
### - Malcolm Cowe, 21/01/2001.
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Begin Main Iteration.
|
||||||
|
#
|
||||||
|
|
||||||
###
|
# Process command line arguments
|
||||||
### Begin Main Iteration.
|
|
||||||
###
|
|
||||||
|
|
||||||
### Process command line arguments
|
|
||||||
foreach $arg(@ARGV) {
|
foreach $arg(@ARGV) {
|
||||||
if($last) {
|
if($last) {
|
||||||
if($last eq "-d") {
|
if($last eq "-d") {
|
||||||
@@ -189,14 +215,11 @@ foreach $arg(@ARGV) {
|
|||||||
$menufile = $arg;
|
$menufile = $arg;
|
||||||
$stdout = 0;
|
$stdout = 0;
|
||||||
}
|
}
|
||||||
### + Malcolm Cowe, 21/01/2001.
|
|
||||||
elsif($last eq "-t") {
|
elsif($last eq "-t") {
|
||||||
$term = $arg;
|
$term = $arg;
|
||||||
}
|
}
|
||||||
### - Malcolm Cowe, 21/01/2001.
|
|
||||||
undef($last);
|
undef($last);
|
||||||
} elsif($arg =~ /^-/) {
|
} elsif($arg =~ /^-/) {
|
||||||
### + Malcolm Cowe, 21/01/2001.
|
|
||||||
if($arg =~ /^-[dfst]$/) {
|
if($arg =~ /^-[dfst]$/) {
|
||||||
$last = $arg;
|
$last = $arg;
|
||||||
} else {
|
} else {
|
||||||
@@ -205,16 +228,14 @@ foreach $arg(@ARGV) {
|
|||||||
"\t\t-d <KDE App.kdelnk dir>\n".
|
"\t\t-d <KDE App.kdelnk dir>\n".
|
||||||
"\t\t-f <output menufile>\n".
|
"\t\t-f <output menufile>\n".
|
||||||
"\t\t-t <X terminal application>\n");
|
"\t\t-t <X terminal application>\n");
|
||||||
### - Malcolm Cowe, 21/01/2001.
|
|
||||||
&Usage;
|
&Usage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
### Make sure the KDE Menu's Top Level Directory exists.
|
# Make sure the KDE Menu's Top Level Directory exists.
|
||||||
if(-d $basedir) {
|
if(-d $basedir) {
|
||||||
|
# See if there is an old menu file. If there is, rename it
|
||||||
### See if there is an old menu file. If there is, rename it
|
|
||||||
unless($stdout) {
|
unless($stdout) {
|
||||||
if(-e $menufile) {
|
if(-e $menufile) {
|
||||||
print STDERR "\tFound $menufile, renaming\n\n";
|
print STDERR "\tFound $menufile, renaming\n\n";
|
||||||
@@ -223,9 +244,8 @@ if(-d $basedir) {
|
|||||||
open(MENUFILE,"> $menufile");
|
open(MENUFILE,"> $menufile");
|
||||||
}
|
}
|
||||||
|
|
||||||
### Start the main menu entry
|
# Start the main menu entry
|
||||||
if($stdout) {
|
if($stdout) {
|
||||||
### + Malcolm Cowe, 21/01/2001.
|
|
||||||
print STDOUT "\"KDE Applications\" MENU\n";
|
print STDOUT "\"KDE Applications\" MENU\n";
|
||||||
process_dir (STDOUT, $basedir);
|
process_dir (STDOUT, $basedir);
|
||||||
print STDOUT "\"KDE Applications\" END\n";
|
print STDOUT "\"KDE Applications\" END\n";
|
||||||
@@ -233,125 +253,156 @@ if(-d $basedir) {
|
|||||||
print MENUFILE "\"KDE Applications\" MENU\n";
|
print MENUFILE "\"KDE Applications\" MENU\n";
|
||||||
process_dir (MENUFILE, $basedir);
|
process_dir (MENUFILE, $basedir);
|
||||||
print MENUFILE "\"KDE Applications\" END\n";
|
print MENUFILE "\"KDE Applications\" END\n";
|
||||||
### - Malcolm Cowe, 21/01/2001.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
### Error out :/
|
# Error out :/
|
||||||
print STDERR "ERROR:\n\t$basedir not found\n\tTry another directory.\n";
|
print STDERR "ERROR:\n\t$basedir not found\n\tTry another directory.\n";
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
# End of Main Iteration.
|
# End of Main Iteration.
|
||||||
|
|
||||||
### + Malcolm Cowe, 21/01/2001.
|
|
||||||
|
|
||||||
### process_dir() works it's way through each file and directory in
|
|
||||||
### the tree and generates the menu output to be used by Window Maker.
|
|
||||||
|
|
||||||
|
# process_dir() works it's way through each file and directory in
|
||||||
|
# the tree and generates the menu output to be used by Window Maker.
|
||||||
sub process_dir {
|
sub process_dir {
|
||||||
|
|
||||||
my $OUT = @_[0];
|
my $OUT = @_[0];
|
||||||
my $path = @_[1];
|
my $path = @_[1];
|
||||||
my $item;
|
my $item;
|
||||||
my @tld;
|
my @tld;
|
||||||
my ($gotLang, $gotDef, $gotExec);
|
my @tlf;
|
||||||
|
my @klist;
|
||||||
|
my ($gotLang, $gotDef, $gotExec, $inTerm);
|
||||||
my $inDesktop;
|
my $inDesktop;
|
||||||
|
|
||||||
### tld == Top Level Directory.
|
# tld == Top Level Directory.
|
||||||
opendir(TLD, $path) || return;
|
opendir(TLD, $path) || return;
|
||||||
@tld = readdir(TLD);
|
# In order to display directories before files, the directory
|
||||||
|
# contents must be split. Directories are added to one array, files
|
||||||
|
# to a second. The lists are then sorted alphabetically by name and
|
||||||
|
# combined into a single list for processing by the rest of the
|
||||||
|
# subroutine.
|
||||||
|
while (defined($file = readdir(TLD))) {
|
||||||
|
next if $file =~ /^\./;
|
||||||
|
if (-d "$path/$file") {
|
||||||
|
@tld = (@tld, $file);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
@tlf = (@tlf, $file);
|
||||||
|
}
|
||||||
|
}
|
||||||
closedir(TLD);
|
closedir(TLD);
|
||||||
|
# At this stage, only sort the directories, since the application
|
||||||
|
# sorting is done later, using the "Name=" field in the applnk file.
|
||||||
|
@tld = sort (@tld);
|
||||||
|
|
||||||
|
# Print out directory names first and then process the directories.
|
||||||
foreach $item(@tld) {
|
foreach $item(@tld) {
|
||||||
|
print $OUT "\"$item\" MENU\n";
|
||||||
|
process_dir($OUT, "$path/$item");
|
||||||
|
print $OUT "\"$item\" END\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
# Process the applnk files in the current directory.
|
||||||
|
foreach $item(@tlf) {
|
||||||
$gotLang = 0;
|
$gotLang = 0;
|
||||||
$gotDef = 0;
|
$gotDef = 0;
|
||||||
$gotExec = 0;
|
$gotExec = 0;
|
||||||
|
$inTerm = 0;
|
||||||
$inDesktop = 0;
|
$inDesktop = 0;
|
||||||
|
|
||||||
### Ignore hidden files and directories.
|
# Process the contents of the applnk file to generate a menu
|
||||||
unless($item =~ /^\./) {
|
# entry for the application.
|
||||||
if (-d "$path/$item") {
|
|
||||||
print $OUT "\"$item\" MENU\n";
|
|
||||||
process_dir($OUT, "$path/$item");
|
|
||||||
print $OUT "\"$item\" END\n";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
# Process the contents of the applnk file to generate a menu
|
|
||||||
# entry for the application.
|
|
||||||
|
|
||||||
open(SUB,"$path/$item");
|
open(SUB,"$path/$item");
|
||||||
|
|
||||||
### Search through the contents of the file
|
# Set a default application warning to run in case there is no
|
||||||
while($line = <SUB>) {
|
# Exec= line in the application definition. This will be
|
||||||
chomp($line);
|
# useful for debugging exceptions.
|
||||||
### Get the application's name. This is stored in the
|
$pname="$item";
|
||||||
### [Desktop Entry] section of the applnk description.
|
$pargs="echo \"Could not extract executable information from:\\n\\n$path/$item.\"|".$xmsg;
|
||||||
###
|
|
||||||
### The application's name can have one of these forms:
|
|
||||||
### Name=
|
|
||||||
### Name[]=
|
|
||||||
### Name[language]=
|
|
||||||
###
|
|
||||||
### Get the default name anyway (one of the first two, just
|
|
||||||
### in case there is no language specific entry).
|
|
||||||
if ($inDesktop) {
|
|
||||||
# Make sure we are in fact still in the [Desktop Entry]
|
|
||||||
# section.
|
|
||||||
if ($line =~ /^\[/) {
|
|
||||||
$inDesktop = 0;
|
|
||||||
}
|
|
||||||
### Extract the Name of the Application
|
|
||||||
elsif ($line =~ /^Name=/ && (!$gotDef || !gotLang)) {
|
|
||||||
$pname = $line;
|
|
||||||
$pname =~ s/^Name=//s;
|
|
||||||
$pname =~ s/\"/\'\'/g;
|
|
||||||
$gotDef = 1;
|
|
||||||
}
|
|
||||||
elsif ($line =~ /^Name\[\]=/ && (!$gotDef || !gotLang)) {
|
|
||||||
$pname = $line;
|
|
||||||
$pname =~ s/^Name\[\]=//s;
|
|
||||||
$pname =~ s/\"/\'\'/g;
|
|
||||||
$gotDef = 1;
|
|
||||||
}
|
|
||||||
elsif ($line =~ /^Name\[$kdeLanguage\]=/ && !$gotLang) {
|
|
||||||
$pname = $line;
|
|
||||||
$pname =~ s/^Name\[$kdeLanguage\]=//s;
|
|
||||||
$pname =~ s/\"/\'\'/g;
|
|
||||||
$gotLang = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
### Grab the command
|
# Search through the contents of the file. Exit the loop at the
|
||||||
if($line =~ /^Exec=/ && !$gotExec) {
|
# EOF or if we have processed the [Desktop Entry Section] of the
|
||||||
$pargs = $line;
|
# file.
|
||||||
$pargs =~ s/^Exec=//s;
|
while($line = <SUB>) {
|
||||||
# Strip off all command line options unless the
|
chomp($line);
|
||||||
# application is "kfmclient".
|
# Get the application's name. This is stored in the
|
||||||
if ($pargs !~ /^kfmclient/
|
# [Desktop Entry] section of the applnk description.
|
||||||
&& $pargs !~ /^kcmshell/
|
#
|
||||||
&& $pargs !~ /^kdesu/){
|
# The application's name can have one of these forms:
|
||||||
($pargs) = split(/\s/, $pargs);
|
# Name=
|
||||||
}
|
# Name[]=
|
||||||
$gotExec = 1;
|
# Name[language]=
|
||||||
}
|
#
|
||||||
### If Terminal=1, then we need to execute a term
|
# Get the default name anyway (one of the first two, just
|
||||||
if($line =~ /^Terminal=1$/) {
|
# in case there is no language specific entry).
|
||||||
$pargs = "$term -T \"$pname\" -e $pargs";
|
if ($inDesktop) {
|
||||||
}
|
# Make sure we are in fact still in the [Desktop Entry]
|
||||||
}
|
# section.
|
||||||
elsif ($line =~ /^\[Desktop\ Entry\]/ ||
|
if ($line =~ /^\[/) {
|
||||||
$line =~ /^\[KDE\ Desktop\ Entry\]/) {
|
$inDesktop = 0;
|
||||||
$inDesktop = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
# Extract the Name of the Application
|
||||||
close(SUB);
|
elsif ($line =~ /^Name\[?\]?=/
|
||||||
### Begin printing menu items
|
&& (!$gotDef || !gotLang)) {
|
||||||
print $OUT "\t\"$pname\" EXEC $pargs\n";
|
$pname = $line;
|
||||||
|
$pname =~ s/^Name\[?\]?=//s;
|
||||||
|
$pname =~ s/\"/\'\'/g;
|
||||||
|
$gotDef = 1;
|
||||||
|
}
|
||||||
|
elsif ($line =~ /^Name\[$kdeLanguage\]=/ && !$gotLang) {
|
||||||
|
$pname = $line;
|
||||||
|
$pname =~ s/^Name\[$kdeLanguage\]=//s;
|
||||||
|
$pname =~ s/\"/\'\'/g;
|
||||||
|
$gotLang = 1;
|
||||||
|
}
|
||||||
|
# Grab the command
|
||||||
|
elsif($line =~ /^Exec=/ && !$gotExec) {
|
||||||
|
$pargs = $line;
|
||||||
|
$pargs =~ s/^Exec=//s;
|
||||||
|
# Strip off all command line options unless the
|
||||||
|
# application is "kfmclient", etc.
|
||||||
|
if ($pargs !~ /^kfmclient/
|
||||||
|
&& $pargs !~ /^kcm/
|
||||||
|
&& $pargs !~ /^\/bin\/bash/
|
||||||
|
&& $pargs !~ /^kdesu/){
|
||||||
|
($pargs) = split(/\s/, $pargs);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# A double check to remove any dubious characters from
|
||||||
|
# the command line of the exceptions listed in the
|
||||||
|
# above "if" statement. The only culprit so far is the
|
||||||
|
# KDE 1 kfmclient command line.
|
||||||
|
$pargs =~ s/\%[a-zA-Z]//g;
|
||||||
|
}
|
||||||
|
$gotExec = 1;
|
||||||
|
}
|
||||||
|
# If Terminal=1, then we need to execute application
|
||||||
|
# within a terminal window.
|
||||||
|
elsif($line =~ /^Terminal=(1|true)$/i) {
|
||||||
|
$inTerm=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif ($line =~ /^\[(KDE\ )?Desktop\ Entry\]/){
|
||||||
|
$inDesktop = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
close(SUB);
|
||||||
|
|
||||||
|
if ($inTerm) {
|
||||||
|
$pargs = "$term -T \"$pname\" -e $pargs";
|
||||||
|
}
|
||||||
|
@klist = (@klist, "\t\"$pname\" EXEC $pargs\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
@klist = sort(@klist);
|
||||||
|
foreach (@klist) {
|
||||||
|
print $OUT $_;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
### - Malcolm Cowe, 21/01/2001.
|
|
||||||
|
|||||||
Reference in New Issue
Block a user