SHARE
TWEET

Untitled

reiton Sep 30th, 2011 210 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/perl
  2.  
  3. use Gtk2 ('-init');
  4. use threads ('yield', 'stack_size', 262144, 'exit', 'threads_only', 'stringify');
  5.  
  6. $icon = 'Gtk2::StatusIcon'->new;
  7. $icon->set_from_stock('gtk-home');
  8. $icon->set_visible(1);
  9. $icon->signal_connect('button-release-event', sub {
  10.     show_icon_menu();
  11. });
  12. $icon->set_tooltip('Click for menu...');
  13.  
  14. sub show_icon_menu {
  15.     $menu = 'Gtk2::Menu'->new;
  16.  
  17.     $item15 = 'Gtk2::ImageMenuItem'->new(q[File Manager]);
  18.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/icons/Tango-Original/16x16/apps/file-manager.png], 16, 16);
  19.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  20.     $item15->show;
  21.     $item15->signal_connect('activate', sub {
  22.         'threads'->create(sub {
  23.             system q[pcmanfm];
  24.         });}
  25.     );
  26.     $item15->set_image($img);
  27.     $menu->append($item15);
  28.     $item16 = 'Gtk2::ImageMenuItem'->new(q[Terminal]);
  29.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/icons/Tango-Original/16x16/apps/terminal.png], 16, 16);
  30.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  31.     $item16->show;
  32.     $item16->signal_connect('activate', sub {
  33.         'threads'->create(sub {
  34.             system q[lxterminal];
  35.         });}
  36.     );
  37.     $item16->set_image($img);
  38.     $menu->append($item16);
  39.     $item17 = 'Gtk2::ImageMenuItem'->new(q[Web Browser]);
  40.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/icons/Tango-Original/16x16/apps/web-browser.png], 16, 16);
  41.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  42.     $item17->show;
  43.     $item17->signal_connect('activate', sub {
  44.         'threads'->create(sub {
  45.             system q[firefox];
  46.         });}
  47.     );
  48.     $item17->set_image($img);
  49.     $menu->append($item17);
  50.     $item18 = 'Gtk2::ImageMenuItem'->new(q[Text Editor]);
  51.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/icons/Tango-Original/16x16/apps/text-editor.png], 16, 16);
  52.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  53.     $item18->show;
  54.     $item18->signal_connect('activate', sub {
  55.         'threads'->create(sub {
  56.             system q[lxterminal -e vi];
  57.         });}
  58.     );
  59.     $item18->set_image($img);
  60.     $menu->append($item18);
  61.     $separator = Gtk2::SeparatorMenuItem->new;
  62.     $menu->append($separator);
  63.  
  64.                                 # # # # # # # # # # # # # # # # # # # # Accessories # # # # # # # # # # # # # # # # # # # #
  65.  
  66.     $all_apps = 'Gtk2::Menu'->new->new;
  67.     $category0 = 'Gtk2::ImageMenuItem'->new(q[Accessories]);
  68.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/icons/Tango-Original/16x16/categories/applications-accessories.png], 16, 16);
  69.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  70.     $category0->set_image($img);
  71.     $725 = 'Gtk2::ImageMenuItem'->new(q[7-Zip FM]);
  72.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/icons/hicolor/32x32/apps/p7zip.png], 16, 16);
  73.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  74.     $725->show;
  75.     $725->signal_connect('activate', sub {
  76.         'threads'->create(sub {
  77.             system q[7zFM];
  78.         });}
  79.     );
  80.     $725->set_image($img);
  81.     $all_apps->append($725);
  82.     $file22 = 'Gtk2::ImageMenuItem'->new(q[File Manager]);
  83.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/icons/Tango-Original/16x16/apps/system-file-manager.png], 16, 16);
  84.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  85.     $file22->show;
  86.     $file22->signal_connect('activate', sub {
  87.         'threads'->create(sub {
  88.             system q[pcmanfm];
  89.         });}
  90.     );
  91.     $file22->set_image($img);
  92.     $all_apps->append($file22);
  93.     $lxterminal24 = 'Gtk2::ImageMenuItem'->new(q[LXTerminal]);
  94.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/pixmaps/lxterminal.png], 16, 16);
  95.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  96.     $lxterminal24->show;
  97.     $lxterminal24->signal_connect('activate', sub {
  98.         'threads'->create(sub {
  99.             system q[lxterminal];
  100.         });}
  101.     );
  102.     $lxterminal24->set_image($img);
  103.     $all_apps->append($lxterminal24);
  104.     $xarchiver23 = 'Gtk2::ImageMenuItem'->new(q[Xarchiver]);
  105.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/icons/hicolor/16x16/apps/xarchiver.png], 16, 16);
  106.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  107.     $xarchiver23->show;
  108.     $xarchiver23->signal_connect('activate', sub {
  109.         'threads'->create(sub {
  110.             system q[xarchiver];
  111.         });}
  112.     );
  113.     $xarchiver23->set_image($img);
  114.     $all_apps->append($xarchiver23);
  115.     $category0->set_submenu($all_apps);
  116.     $menu->append($category0);
  117.  
  118.                                 # # # # # # # # # # # # # # # # # # # # Network # # # # # # # # # # # # # # # # # # # #
  119.  
  120.     $all_apps = 'Gtk2::Menu'->new->new;
  121.     $category6 = 'Gtk2::ImageMenuItem'->new(q[Network]);
  122.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/icons/Tango/16x16/categories/applications-internet.png], 16, 16);
  123.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  124.     $category6->set_image($img);
  125.     $avahi33 = 'Gtk2::ImageMenuItem'->new(q[Avahi VNC Server Browser]);
  126.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/icons/Tango-Original/16x16/devices/network-wired.png], 16, 16);
  127.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  128.     $avahi33->show;
  129.     $avahi33->signal_connect('activate', sub {
  130.         'threads'->create(sub {
  131.             system q[/usr/bin/bvnc];
  132.         });}
  133.     );
  134.     $avahi33->set_image($img);
  135.     $all_apps->append($avahi33);
  136.     $avahi34 = 'Gtk2::ImageMenuItem'->new(q[Avahi SSH Server Browser]);
  137.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/icons/Tango-Original/16x16/devices/network-wired.png], 16, 16);
  138.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  139.     $avahi34->show;
  140.     $avahi34->signal_connect('activate', sub {
  141.         'threads'->create(sub {
  142.             system q[/usr/bin/bssh];
  143.         });}
  144.     );
  145.     $avahi34->set_image($img);
  146.     $all_apps->append($avahi34);
  147.     $firefox35 = 'Gtk2::ImageMenuItem'->new(q[Firefox]);
  148.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/icons/hicolor/16x16/apps/firefox.png], 16, 16);
  149.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  150.     $firefox35->show;
  151.     $firefox35->signal_connect('activate', sub {
  152.         'threads'->create(sub {
  153.             system q[firefox];
  154.         });}
  155.     );
  156.     $firefox35->set_image($img);
  157.     $all_apps->append($firefox35);
  158.     $pidgin36 = 'Gtk2::ImageMenuItem'->new(q[Pidgin Internet Messenger]);
  159.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/icons/hicolor/16x16/apps/pidgin.png], 16, 16);
  160.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  161.     $pidgin36->show;
  162.     $pidgin36->signal_connect('activate', sub {
  163.         'threads'->create(sub {
  164.             system q[pidgin];
  165.         });}
  166.     );
  167.     $pidgin36->set_image($img);
  168.     $all_apps->append($pidgin36);
  169.     $category6->set_submenu($all_apps);
  170.     $menu->append($category6);
  171.  
  172.                                 # # # # # # # # # # # # # # # # # # # # Others # # # # # # # # # # # # # # # # # # # #
  173.  
  174.     $all_apps = 'Gtk2::Menu'->new->new;
  175.     $category8 = 'Gtk2::ImageMenuItem'->new(q[Others]);
  176.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/icons/Tango/16x16/categories/applications-other.png], 16, 16);
  177.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  178.     $category8->set_image($img);
  179.     $openbox40 = 'Gtk2::ImageMenuItem'->new(q[Openbox]);
  180.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/pixmaps/openbox.png], 16, 16);
  181.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  182.     $openbox40->show;
  183.     $openbox40->signal_connect('activate', sub {
  184.         'threads'->create(sub {
  185.             system q[openbox];
  186.         });}
  187.     );
  188.     $openbox40->set_image($img);
  189.     $all_apps->append($openbox40);
  190.     $category8->set_submenu($all_apps);
  191.     $menu->append($category8);
  192.  
  193.                                 # # # # # # # # # # # # # # # # # # # # Settings # # # # # # # # # # # # # # # # # # # #
  194.  
  195.     $all_apps = 'Gtk2::Menu'->new->new;
  196.     $category9 = 'Gtk2::ImageMenuItem'->new(q[Settings]);
  197.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/pixmaps/openbox.png], 16, 16);
  198.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  199.     $category9->set_image($img);
  200.     $adobe44 = 'Gtk2::ImageMenuItem'->new(q[Adobe Flash Player]);
  201.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/icons/hicolor/16x16/apps/flash-player-properties.png], 16, 16);
  202.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  203.     $adobe44->show;
  204.     $adobe44->signal_connect('activate', sub {
  205.         'threads'->create(sub {
  206.             system q[flash-player-properties];
  207.         });}
  208.     );
  209.     $adobe44->set_image($img);
  210.     $all_apps->append($adobe44);
  211.     $disk47 = 'Gtk2::ImageMenuItem'->new(q[Disk Utility]);
  212.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/icons/hicolor/16x16/apps/palimpsest.png], 16, 16);
  213.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  214.     $disk47->show;
  215.     $disk47->signal_connect('activate', sub {
  216.         'threads'->create(sub {
  217.             system q[palimpsest];
  218.         });}
  219.     );
  220.     $disk47->set_image($img);
  221.     $all_apps->append($disk47);
  222.     $obtheme48 = 'Gtk2::ImageMenuItem'->new(q[ObTheme]);
  223.     $img = 'Gtk2::Image'->new_from_stock('gtk-missing-image', 'menu');
  224.     $obtheme48->show;
  225.     $obtheme48->signal_connect('activate', sub {
  226.         'threads'->create(sub {
  227.             system q[obtheme];
  228.         });}
  229.     );
  230.     $obtheme48->set_image($img);
  231.     $all_apps->append($obtheme48);
  232.     $openbox43 = 'Gtk2::ImageMenuItem'->new(q[Openbox Configuration Manager]);
  233.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/pixmaps/obconf.png], 16, 16);
  234.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  235.     $openbox43->show;
  236.     $openbox43->signal_connect('activate', sub {
  237.         'threads'->create(sub {
  238.             system q[obconf];
  239.         });}
  240.     );
  241.     $openbox43->set_image($img);
  242.     $all_apps->append($openbox43);
  243.     $panel46 = 'Gtk2::ImageMenuItem'->new(q[Panel tint2]);
  244.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/pixmaps/tint2conf.png], 16, 16);
  245.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  246.     $panel46->show;
  247.     $panel46->signal_connect('activate', sub {
  248.         'threads'->create(sub {
  249.             system q[tint2conf];
  250.         });}
  251.     );
  252.     $panel46->set_image($img);
  253.     $all_apps->append($panel46);
  254.     $preferred45 = 'Gtk2::ImageMenuItem'->new(q[Preferred Applications]);
  255.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/icons/Tango-Original/16x16/categories/preferences-desktop.png], 16, 16);
  256.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  257.     $preferred45->show;
  258.     $preferred45->signal_connect('activate', sub {
  259.         'threads'->create(sub {
  260.             system q[libfm-pref-apps];
  261.         });}
  262.     );
  263.     $preferred45->set_image($img);
  264.     $all_apps->append($preferred45);
  265.     $category9->set_submenu($all_apps);
  266.     $menu->append($category9);
  267.  
  268.                                 # # # # # # # # # # # # # # # # # # # # System # # # # # # # # # # # # # # # # # # # #
  269.  
  270.     $all_apps = 'Gtk2::Menu'->new->new;
  271.     $category10 = 'Gtk2::ImageMenuItem'->new(q[System]);
  272.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/icons/Tango/16x16/categories/applications-system.png], 16, 16);
  273.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  274.     $category10->set_image($img);
  275.     $avahi51 = 'Gtk2::ImageMenuItem'->new(q[Avahi Zeroconf Browser]);
  276.     $pixbuf = 'Gtk2::Gdk::Pixbuf'->new_from_file_at_size( q[/usr/share/icons/Tango-Original/16x16/devices/network-wired.png], 16, 16);
  277.     $img = 'Gtk2::Image'->new_from_pixbuf($pixbuf);
  278.     $avahi51->show;
  279.     $avahi51->signal_connect('activate', sub {
  280.         'threads'->create(sub {
  281.             system q[/usr/bin/avahi-discover];
  282.         });}
  283.     );
  284.     $avahi51->set_image($img);
  285.     $all_apps->append($avahi51);
  286.     $category10->set_submenu($all_apps);
  287.     $menu->append($category10);
  288.  
  289.                                 # # # # # # # # # # # # # # # # # # # # Menutray # # # # # # # # # # # # # # # # # # # #
  290.  
  291.     $all_apps = 'Gtk2::Menu'->new->new;
  292.     $category11 = 'Gtk2::MenuItem'->new(q[Menutray]);
  293.     $edit54 = 'Gtk2::ImageMenuItem'->new(q[Edit menutray menu]);
  294.     $img = 'Gtk2::Image'->new_from_stock('gtk-missing-image', 'menu');
  295.     $edit54->show;
  296.     $edit54->signal_connect('activate', sub {
  297.         'threads'->create(sub {
  298.             system q[lxterminal -e vi /root/.config/menutray/menutray.pl];
  299.         });}
  300.     );
  301.     $edit54->set_image($img);
  302.     $all_apps->append($edit54);
  303.     $edit55 = 'Gtk2::ImageMenuItem'->new(q[Edit menutray schema]);
  304.     $img = 'Gtk2::Image'->new_from_stock('gtk-missing-image', 'menu');
  305.     $edit55->show;
  306.     $edit55->signal_connect('activate', sub {
  307.         'threads'->create(sub {
  308.             system q[lxterminal -e vi /root/.config/menutray/menutray.schema];
  309.         });}
  310.     );
  311.     $edit55->set_image($img);
  312.     $all_apps->append($edit55);
  313.     $edit56 = 'Gtk2::ImageMenuItem'->new(q[Edit menutray configuration]);
  314.     $img = 'Gtk2::Image'->new_from_stock('gtk-missing-image', 'menu');
  315.     $edit56->show;
  316.     $edit56->signal_connect('activate', sub {
  317.         'threads'->create(sub {
  318.             system q[lxterminal -e vi /root/.config/menutray/menutray.conf];
  319.         });}
  320.     );
  321.     $edit56->set_image($img);
  322.     $all_apps->append($edit56);
  323.     $category11->set_submenu($all_apps);
  324.     $menu->append($category11);
  325.     $separator = Gtk2::SeparatorMenuItem->new;
  326.     $menu->append($separator);
  327.     $item59 = 'Gtk2::ImageMenuItem'->new(q[Regenerate]);
  328.     $img = 'Gtk2::Image'->new_from_stock('gtk-refresh', 'menu');
  329.     $item59->show;
  330.     $item59->signal_connect('activate', sub { `menutray -i`;
  331.         'threads'->exit;
  332.     });
  333.     $item59->set_image($img);
  334.     $menu->append($item59);
  335.     $quit = 'Gtk2::ImageMenuItem'->new('Quit');
  336.     $img = 'Gtk2::Image'->new_from_stock('gtk-quit', 'menu');
  337.     $quit->show;
  338.     $quit->signal_connect('activate', sub { 'threads'->exit; exit; });
  339.     $quit->set_image($img);
  340.     $menu->append($quit);
  341.     $menu->show_all;
  342.     $menu->popup(undef, undef, sub {
  343.         return Gtk2::StatusIcon::position_menu($menu, 0, 0, $icon);
  344.     }
  345.     , [1, 1], 0, 0);
  346. }
  347. 'Gtk2'->main;
  348.  
  349.  
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top