aboutsummaryrefslogtreecommitdiffstats
path: root/menu/xdg_menu
diff options
context:
space:
mode:
authorFrederic Crozat <fcrozat@mandriva.com>2009-03-16 16:23:05 +0000
committerFrederic Crozat <fcrozat@mandriva.com>2009-03-16 16:23:05 +0000
commit8c53d3283f0ae75de4c61bf869e7eca35638c0b6 (patch)
treea8a7f7934c4eb2a95ee49ca660db99ec1ba8468f /menu/xdg_menu
parentca9ba01ff2735a3560e203230e5d7507940b1c97 (diff)
downloadcommon-data-8c53d3283f0ae75de4c61bf869e7eca35638c0b6.tar
common-data-8c53d3283f0ae75de4c61bf869e7eca35638c0b6.tar.gz
common-data-8c53d3283f0ae75de4c61bf869e7eca35638c0b6.tar.bz2
common-data-8c53d3283f0ae75de4c61bf869e7eca35638c0b6.tar.xz
common-data-8c53d3283f0ae75de4c61bf869e7eca35638c0b6.zip
- Icon support for fluxbot (patch from Jorge Van Hemelryck)
Diffstat (limited to 'menu/xdg_menu')
-rwxr-xr-xmenu/xdg_menu87
1 files changed, 85 insertions, 2 deletions
diff --git a/menu/xdg_menu b/menu/xdg_menu
index 0ac1768..931b373 100755
--- a/menu/xdg_menu
+++ b/menu/xdg_menu
@@ -56,6 +56,85 @@ sub check_file ($)
}
}
+sub findicon
+{
+
+# my $theme = "hicolor";
+
+ my $iconname = shift;
+
+
+ my $home = $ENV{"HOME"};
+ my $xdg_data_dirs = $ENV{"XDG_DATA_DIRS"};
+
+ my (@xdg_data_dirs);
+ @xdg_data_dirs = split(":",$xdg_data_dirs);
+
+ my (@icon_search_path);
+
+ my (@categorylist);
+ @categorylist = ("apps", "places", "devices", "actions", "animations", "categories", "emblems", "emotes", "filesystems", "intl", "mimetypes", "status", "stock");
+
+ my (@sizelist);
+ @sizelist = (16, 22, 24, 26, 32, 36, 48, 64, 72, 128, 192, 256);
+
+ my $thisdir = $home."/.icons";
+ ( -d $thisdir ) && push @icon_search_path, $thisdir;
+
+
+
+ foreach my $dir (@xdg_data_dirs)
+ {
+ my $theme = "hicolor";
+ my $size;
+ my $category;
+ foreach $size (@sizelist)
+ {
+ foreach $category (@categorylist)
+ {
+ $thisdir = $dir."/icons/".$theme."/".$size."x".$size."/".$category;
+ ( -d $thisdir ) && push @icon_search_path, $thisdir;
+ }
+ }
+ $thisdir = $dir."/icons/mini";
+ ( -d $thisdir ) && push @icon_search_path, $thisdir;
+ $thisdir = $dir."/icons";
+ ( -d $thisdir ) && push @icon_search_path, $thisdir;
+ $thisdir = $dir."/icons/large";
+ ( -d $thisdir ) && push @icon_search_path, $thisdir;
+ $theme = "gnome";
+ foreach $size (@sizelist)
+ {
+ foreach $category (@categorylist)
+ {
+ $thisdir = $dir."/icons/".$theme."/".$size."x".$size."/".$category;
+ ( -d $thisdir ) && push @icon_search_path, $thisdir;
+ }
+ }
+ }
+
+ push @icon_search_path, "/usr/share/pixmaps";
+
+ my $filename;
+
+ if ( -f $iconname )
+ {
+ return $iconname;
+ }
+ else
+ {
+
+ foreach my $dir (@icon_search_path)
+ {
+ foreach my $ext ('','.png','.xpm')
+ {
+ $filename = $dir."/".$iconname.$ext;
+ ( -f $filename ) && return $filename;
+ }
+ }
+ }
+}
+
sub add_png_extension_if_needed ($)
{
my ($f) = @_;
@@ -1535,19 +1614,23 @@ sub output_blackbox_inner_menu ($;$)
$indent = 0 unless defined $indent;
my $menu_name = $menu->{'PrepName'};
+ $menu_name =~ s/\)/\\\)/g;
+ my $menu_icon = findicon($menu->{'PrepIcon'} || "folder");
$output .= ' ' x $indent;
- $output .= "[submenu] ($menu_name)\n";
+ $output .= "[submenu] ($menu_name) <$menu_icon>\n";
foreach my $entry (@{$menu->{'entries'}}) {
if ($entry->{type} eq 'desktop') {
my $desktop = $entry->{desktop};
my $name = $desktop->{'PrepName'};
+ $name =~ s/\)/\\\)/g;
my $exec = $desktop->{'PrepExec'};
+ my $icon = findicon($desktop->{'Icon'});
$output .= ' ' x $indent;
- $output .= " [exec] ($name) {$exec}\n";
+ $output .= " [exec] ($name) {$exec} <$icon>\n";
}
elsif ($entry->{type} eq 'menu') {
$output .= output_blackbox_inner_menu ($entry->{'menu'}, $indent + 1);