Skip to content

Commit

Permalink
snap
Browse files Browse the repository at this point in the history
  • Loading branch information
Code7R committed Feb 4, 2024
1 parent 12731c8 commit 439cdfa
Show file tree
Hide file tree
Showing 4 changed files with 1,050 additions and 419 deletions.
119 changes: 119 additions & 0 deletions contrib/Additional_Categories.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
Building,Development
Debugger,Development
IDE,Development
GUIDesigner,Development
Profiling,Development
RevisionControl,Development
Translation,Development
Calendar,Office
ContactManagement,Office
Database,Office or Development or Audio or Video
Dictionary,Office or TextTools
Chart,Office
Email,Office or Network
Finance,Office
FlowChart,Office
PDA,Office
ProjectManagement,Office or Development
Presentation,Office
Spreadsheet,Office
WordProcessor,Office
2DGraphics,Graphics
VectorGraphics,Graphics;2DGraphics
RasterGraphics,Graphics;2DGraphics
3DGraphics,Graphics
Scanning,Graphics
OCR,Graphics;Scanning
Photography,Graphics or Office
Publishing,Graphics or Office
Viewer,Graphics or Office
TextTools,Utility
DesktopSettings,Settings
HardwareSettings,Settings
Printing,Settings;HardwareSettings
PackageManager,Settings
Dialup,Network
InstantMessaging,Network
Chat,Network
IRCClient,Network
Feed,Network
FileTransfer,Network
HamRadio,Network or Audio
News,Network
P2P,Network
RemoteAccess,Network
Telephony,Network
TelephonyTools,Utility
VideoConference,Network
WebBrowser,Network
WebDevelopment,Network or Development
Midi,Audio or Video;Audio
Mixer,Audio or Video;Audio
Sequencer,Audio or Video;Audio
Tuner,Audio or Video;Audio
TV,Audio or Video;Video
AudioVideoEditing,Audio or Video
Player,Audio or Video
Recorder,Audio or Video
DiscBurning,Audio or Video
ActionGame,Game
AdventureGame,Game
ArcadeGame,Game
BoardGame,Game
BlocksGame,Game
CardGame,Game
KidsGame,Game
LogicGame,Game
RolePlaying,Game
Shooter,Game
Simulation,Game
SportsGame,Game
StrategyGame,Game
Art,Education or Science
Construction,Education or Science
Music,Audio or Video or Education
Languages,Education or Science
ArtificialIntelligence,Education or Science
Astronomy,Education or Science
Biology,Education or Science
Chemistry,Education or Science
ComputerScience,Education or Science
DataVisualization,Education or Science
Economy,Education or Science
Electricity,Education or Science
Geography,Education or Science
Geology,Education or Science
Geoscience,Education or Science
History,Education or Science
Humanities,Education or Science
ImageProcessing,Education or Science
Literature,Education or Science
Maps,Education or Science or Utility
Math,Education or Science
NumericalAnalysis,Education;Math or Science;Math
MedicalSoftware,Education or Science
Physics,Education or Science
Robotics,Education or Science
Spirituality,Education or Science or Utility
Sports,Education or Science
ParallelComputing,Education;ComputerScience or Science;ComputerScience
Amusement,
Archiving,Utility
Compression,Utility or Archiving
Electronics,
Emulator,System or Game
Engineering,
FileTools,Utility or System
FileManager,System;FileTools
TerminalEmulator,System
Filesystem,System
Monitor,System or Network
Security,Settings or System
Accessibility,Settings or Utility
Calculator,Utility
Clock,Utility
TextEditor,Utility
Documentation,
Adult,
Core,
ConsoleOnly,
160 changes: 116 additions & 44 deletions contrib/conv_cat.pl
Original file line number Diff line number Diff line change
@@ -1,45 +1,8 @@
#!/usr/bin/perl

print "// WARNING: this is an autogenerated file. Any change might be overwritten!\n";
use strict;
my %grps, my %secs, my %hints;
$grps{"ANY"} = '';

for(<>)
{
chomp;
(my $sec, my $pred) = split(/,/);
next if $sec eq "GTK" or $sec eq "Qt" or $sec eq "GNOME" or $sec eq "KDE" or $sec eq "XFCE" or $sec eq "Java" or $sec eq "ConsoleOnly";
# key is sanitized name of the filter set or ANY for no filters
my $key = $pred;
$key=~ s/\W//g;
$key = "ANY" if(!$key);
$secs{$sec}=$key;
$hints{$sec}=$pred;
if($key && !defined($grps{$key}))
{
$pred=~s/ or /", "|", "/g;
$pred=~s/;/", "/g;
$grps{$key}=$pred;
}

}

# start of the list, the end of the list are
print "
#include \"intl.h\"
namespace spec {
";
use Data::Dumper;

print "const char* $_\[\] = { \"$grps{$_}\", \"|\", nullptr };\n" for(sort keys %grps);

print "
// statically presorted list of categories. See fdomenu.cc for details.
const tStaticMenuDescription menuinfo[] =
{
";

my @cats = sort(keys %secs,
my @cats = sort(
"Accessibility",
"Settings",
"Screensavers",
Expand All @@ -61,12 +24,121 @@
"Utility",
"Other"
);
for(@cats)



print "// WARNING: this is an autogenerated file. Any change might be overwritten!\n";
use strict;
#my %grps, my %secs, my %hints;
#$grps{"ANY"} = '';

my %mapping;
my @stable;
my @scats;

sub uniq {
my %seen;
grep !$seen{$_}++, @_;
}

for(<>)
{
chomp;
my @toks = split(/\s*,\s*|\s*;\s*|\s+or\s+/);
# trim them
@toks = map { $_=~s/^\s*//; $_=~s/\s*$//; $_ } @toks;
#print Dumper(@toks);
push(@stable, \@toks);
push(@scats, $toks[0]);
#next if $sec eq "GTK" or $sec eq "Qt" or $sec eq "GNOME" or $sec eq "KDE" or $sec eq "XFCE" or $sec eq "Java" or $sec eq "ConsoleOnly";
# key is sanitized name of the filter set or ANY for no filters
#my $subcat = shift(@toks);
# expand to all categories
#@toks = @cats unless @toks;
#push(@toks, "-") unless length(join("", @toks));
##$mapping{$key} = @toks;
#for my $maincat (uniq(@toks)) {
# next if ! length($maincat);
# if ($mapping{$subcat}) {
# push(@{$mapping{$subcat}}, $maincat);
# }
# else {
# $mapping{$subcat} = [$maincat] ;
# }
# }
}

# start of the list, the end of the list are
print "
#include \"intl.h\"
#include <tuple>
namespace spec {
using mstring = const char*;
using mapping = std::tuple<mstring, mstring, mstring>;
namespace mcat {
".join("\n\t", map { "
// TRANSLATORS: This is a menu category name from https://specifications.freedesktop.org/menu-spec/menu-spec-1.0.html#category-registry . Please add spaces as needed but no double-quotes.
const auto x$_ = N_(\"$_\");" } @cats)."
const mstring sall[] = {
".join(",\n\t\t", map { "x$_" } @cats)."
};
}
namespace scat {
".join("\n\t", map { "
// TRANSLATORS: This is a menu category name from https://specifications.freedesktop.org/menu-spec/menu-spec-1.0.html#category-registry . Please add spaces as needed but no double-quotes.
const auto x$_ = N_(\"$_\");" } @scats)."
}
static mapping subcat_to_maincat[] = {
";

#print "const char* $_\[\] = { \"$grps{$_}\", \"|\", nullptr };\n" for(sort keys %grps);

print "
// statically presorted list of sub category mapping. See fdomenu.cc for details.
";

for my $x ( sort { ${$a}[0] cmp ${$b}[0]} (@stable)) {
my @l = @{$x};
my $scat = shift(@l);
if (@l) {
for my $y (uniq( sort { $a cmp $b } (@l))) {
if ( grep { $_ eq $y } @cats) {
print "\t{ scat::x$scat, mcat::x$y, nullptr },\n"
}
else {
print "\t{ scat::x$scat, nullptr, scat::x$y },\n"
}
}
}
else {
print "\t{ scat::x$scat, nullptr, nullptr },\n"
}
}
print "
};
}
";


exit(0);


for my $subcatkey (sort(keys %mapping))
{
my $ptr = $secs{$_} ? "&$secs{$_}" : "nullptr";
print "// TRANSLATORS: This is a menu category name from https://specifications.freedesktop.org/menu-spec/menu-spec-1.0.html#category-registry . Please add spaces as needed but no double-quotes.".($hints{$_} ? " Context: $hints{$_}\n" : "\n");
print " { N_(\"$_\"), \"folder\", (const char**) $ptr}";
print $_ eq $cats[-1] ? "\n" : ",\n";
for my $mcatref (@{$mapping{$subcatkey}}) {
print "\t// TRANSLATORS: This is a menu category name from https://specifications.freedesktop.org/menu-spec/menu-spec-1.0.html#category-registry . Please add spaces as needed but no double-quotes.\n";
print "\t{ \"$subcatkey\", \"$mcatref\" },\n";
}

# my $ptr = $secs{$_} ? "&$secs{$_}" : "nullptr";
# print "// TRANSLATORS: This is a menu category name from https://specifications.freedesktop.org/menu-spec/menu-spec-1.0.html#category-registry . Please add spaces as needed but no double-quotes.".($hints{$_} ? " Context: $hints{$_}\n" : "\n");
# print " { N_(\"$_\"), \"folder\", (const char**) $ptr}";
# print $_ eq $cats[-1] ? "\n" : ",\n";
}
print "};
}
Expand Down
Loading

0 comments on commit 439cdfa

Please sign in to comment.