Git Product home page Git Product logo

tray's Introduction

Cross-platform Linux/Windows/MacOS Tray

Cross-platform, single header, super tiny C99 implementation of a system tray icon with a popup menu.

Works well on:

  • Linux/Gtk (libappindicator)
  • Windows XP or newer (shellapi.h)
  • MacOS (Cocoa/AppKit)

The code is C++ friendly and will compile fine in C++98 and up.

This fork is intended to bring together the original work of Serge Zaitsev and the most interesting forks and PRs of respectable contributors:

Building

mkdir build
cd build
cmake ..
  • On Linux/MacOS run the resulting Makefile with make
  • On Windows build the resulting Visual Studio solution

Demo

Execute the tray_example application:

./tray_example

API

Tray structure defines an icon and a menu. Menu is a NULL-terminated array of items. Menu item defines menu text, menu checked and disabled (grayed) flags and a callback with some optional context pointer.

struct tray {
  char *icon;
  struct tray_menu *menu;
};

struct tray_menu {
  char *text;
  int disabled;
  int checked;

  void (*cb)(struct tray_menu *);
  void *context;

  struct tray_menu *submenu;
};
  • int tray_init(struct tray *) - creates tray icon. Returns -1 if tray icon/menu can't be created.
  • void tray_update(struct tray *) - updates tray icon and menu.
  • int tray_loop(int blocking) - runs one iteration of the UI loop. Returns -1 if tray_exit() has been called.
  • void tray_exit() - terminates UI loop.

All functions are meant to be called from the UI thread only.

Menu arrays must be terminated with a NULL item, e.g. the last item in the array must have text field set to NULL.

License

This software is distributed under MIT license, so feel free to integrate it in your commercial products.

tray's People

Contributors

zserge avatar madera avatar angelskieglazki avatar jesselawson avatar longhronshen avatar s-h-a-d-o-w avatar jslegendre avatar dmikushin avatar nburrus avatar spacepluk avatar intika avatar usm916 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.