-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgit_tray.py
executable file
·76 lines (55 loc) · 1.7 KB
/
git_tray.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#* part of git-tracker project
#* git-tracker - updates local cloned git repos
#* Copyright (C) 2009 Ivan Zorin <[email protected]>
#* see README for more information
import gtk;
def state(tray, icon):
#changing tray icon;
tray.set_from_file(icon);
return 0;
def init(icon):
#initialize git tray icon;
#creating icon;
tray = gtk.StatusIcon();
#creating pop-up menu for tray icon;
menu = gtk.Menu();
#creating about menu item;
menuItem = gtk.ImageMenuItem(gtk.STOCK_ABOUT);
menuItem.connect('activate', info, icon);
menu.append(menuItem);
#creating quit menu item;
menuItem = gtk.ImageMenuItem(gtk.STOCK_QUIT);
menuItem.connect('activate', quit, tray);
menu.append(menuItem);
#setting up tray icon properties;
tray.set_from_file(icon);
tray.set_tooltip("git tracker");
tray.connect('popup-menu', popup_menu, menu);
#showing tray icon;
tray.set_visible(True);
#returning created tray icon object for using in other tray-related methods;
return tray;
def quit(widget, data = None):
#handling quit menu item;
if data:
data.set_visible(False);
gtk.main_quit();
return 0;
def popup_menu(widget, button, time, data = None):
#handling pop-up menu of tray;
if button == 3:
if data:
data.show_all();
data.popup(None, None, None, 3, time);
pass;
return 0;
def info(widget, icon, data = None):
#creating info message box about git tracker;
msgBox = gtk.MessageDialog(parent = None, buttons = gtk.BUTTONS_OK, message_format = "Simple auto updater for local cloned git repositories\nCopyright (©) 2009 Ivan Zorin");
msgBox.set_title("git tracker");
msgBox.set_icon_from_file(icon);
msgBox.run();
msgBox.destroy();
return 0;