Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37509096
en ru br
Репозитории ALT
S:2.1.41-alt23
5.1: 2.1.41-alt9
4.1: 2.1.41-alt3.M41.1
4.0: 2.1.35-alt5
3.0: 2.1.25-alt3
+backports:2.1.29-alt4.0.M30
www.altlinux.org/Changes

Группа :: Система/Основа
Пакет: menu

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: menu-2.1.35-alt-locate_icon-function.patch
Скачать


diff -u'Nrpk~' menu-2.1.35~/install-menu/functions.cc menu-2.1.35/install-menu/functions.cc
--- menu-2.1.35/install-menu/functions.cc~	2007-10-10 14:33:44 +0400
+++ menu-2.1.35/install-menu/functions.cc	2007-10-10 14:42:57 +0400
@@ -597,4 +597,72 @@ ostream &substr::output(ostream &o, vect
   return o << s.substr( ps, sz );
 }
 
+ostream &locate_icon::output(ostream &o, vector<cat_str *> &args,
+    map<string, string> &menuentry)
+{
+  string path;
+  string str_sz = args[0]->soutput(menuentry);
+  string icon_name = args[1]->soutput(menuentry);
+  std::list<string> paths;
+  std::list<string> exts;
+  int icon_name_sz = icon_name.size();
+
+  if( str_sz.size() <= 0 )
+  {
+    str_sz = "16";
+  }
+
+  if( icon_name_sz <= 0 )
+  {
+    icon_name_sz = 15;
+    icon_name = "default_section";
+  }
+  else if( icon_name.substr(0,1) == "/" )
+  {
+    return o << icon_name;
+  }
+
+  if( icon_name.substr(icon_name_sz-4,1) == "." )
+  {
+    icon_name_sz = icon_name_sz-4;
+    icon_name = icon_name.substr(0, icon_name_sz);
+  }
+
+  exts.push_back(".png");
+  exts.push_back(".xpm");
+
+  paths.push_back(string("/usr/share/icons/Tango/") + str_sz +"x" + str_sz + "/apps/");
+  paths.push_back(string("/usr/share/icons/TangoKDE/") + str_sz +"x" + str_sz + "/apps/");
+  paths.push_back(string("/usr/share/icons/hicolor/") + str_sz +"x" + str_sz + "/apps/");
+  paths.push_back(string("/usr/share/icons/default.kde/") + str_sz +"x" + str_sz + "/apps/");
+  paths.push_back(string("/usr/share/icons/default.gnome/") + str_sz +"x" + str_sz + "/apps/");
+  if( str_sz == "48" )
+    paths.push_back("/usr/share/icons/large/");
+  else if( str_sz == "32" )
+    paths.push_back("/usr/share/icons/");
+  else if( str_sz == "16" )
+    paths.push_back("/usr/share/icons/mini/");
+  paths.push_back("/usr/share/pixmaps/");
+
+  std::list<string>::iterator it_ext;
+  for(it_ext = exts.begin(); it_ext != exts.end(); it_ext++)
+  {
+    std::list<string>::iterator it_path;
+    for(it_path = paths.begin(); it_path != paths.end(); it_path++)
+    {
+	string xpath(*it_path + icon_name + *it_ext);
+	if( ::access(xpath.c_str(), F_OK) == 0 )
+	{
+	    path = xpath;
+	    break;
+	}
+    }
+  }
+
+  if( path.size() <= 0 )
+    path = string("/usr/share/icons/hicolor/") + str_sz +"x" + str_sz + "/apps/default_section.png";
+
+  return o << path;
+}
+
 }
diff -u'Nrpk~' menu-2.1.35~/install-menu/functions.h menu-2.1.35/install-menu/functions.h
--- menu-2.1.35~/install-menu/functions.h	2007-10-09 18:33:14 +0400
+++ menu-2.1.35/install-menu/functions.h	2007-10-09 17:17:44 +0400
@@ -314,6 +314,10 @@ namespace functions {
     const char * getName() const {return "substr";}
   };
 
+  struct locate_icon : public funcN<2> {
+    std::ostream &output(std::ostream &o, std::vector<cat_str *> &, std::map<std::string, std::string> &);
+    const char * getName() const { return "locate_icon"; }
+  };
 }
 
 #endif
diff -u'Nrpk~' menu-2.1.35~/install-menu/install-menu.cc menu-2.1.35/install-menu/install-menu.cc
--- menu-2.1.35~/install-menu/install-menu.cc	2007-10-09 18:33:14 +0400
+++ menu-2.1.35/install-menu/install-menu.cc	2007-10-09 17:04:39 +0400
@@ -189,6 +189,7 @@ void add_functions()
   store_func(new functions::encode_translate);
   store_func(new functions::encode);
   store_func(new functions::substr);
+  store_func(new functions::locate_icon);
 }
 
 cat_str *get_eq_cat_str(parsestream &i)
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin