~ubuntu-branches/ubuntu/trusty/autokey/trusty-proposed

« back to all changes in this revision

Viewing changes to src/lib/gtkui/notifier.py

  • Committer: Package Import Robot
  • Author(s): Andrew Starr-Bochicchio, Jakub Wilk, Andrew Starr-Bochicchio
  • Date: 2014-01-28 22:10:47 UTC
  • mfrom: (1.4.5)
  • Revision ID: package-import@ubuntu.com-20140128221047-4ag02iz2c6ge1ns4
Tags: 0.90.4-1
* Team upload.

[ Jakub Wilk ]
* Use canonical URIs for Vcs-* fields.

[ Andrew Starr-Bochicchio ]
* New upstream release (Closes: #717948).
* Acknowledge my own NMU.
* Fix debian/watch file to find new versions. 
* Fix chmod call in debian/rules for new path.
* Bump Standards-Version to 3.9.5, no changes needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
# along with this program.  If not, see <http://www.gnu.org/licenses/>..
17
17
 
18
18
#import pynotify, gtk, gettext
19
 
from gi.repository import Gtk, Notify
 
19
from gi.repository import Gtk, Gdk, Notify
20
20
import gettext
21
21
 
22
22
import popupmenu
24
24
from autokey import common
25
25
 
26
26
HAVE_APPINDICATOR = False
27
 
#try:
28
 
#    import appindicator
29
 
#    HAVE_APPINDICATOR = True
30
 
#except ImportError:
31
 
#    pass
 
27
try:
 
28
    from gi.repository import AppIndicator3
 
29
    HAVE_APPINDICATOR = True
 
30
except ImportError:
 
31
    pass
32
32
 
33
33
gettext.install("autokey")
34
34
 
154
154
        
155
155
    def show_notify(self, message, iconName):
156
156
        Gdk.threads_enter()
157
 
        n = Notify.Notification("AutoKey", message, iconName)
158
 
        n.set_urgency(Notify.URGENCY_LOW)
 
157
        n = Notify.Notification.new("AutoKey", message, iconName)
 
158
        n.set_urgency(Notify.Urgency.LOW)
159
159
        if ConfigManager.SETTINGS[SHOW_TRAY_ICON]:
160
160
            n.attach_to_status_icon(self.icon)
161
161
        n.show()
170
170
        self.app = autokeyApp
171
171
        self.configManager = autokeyApp.service.configManager
172
172
 
173
 
        self.indicator = appindicator.Indicator("AutoKey", ConfigManager.SETTINGS[NOTIFICATION_ICON],
174
 
                                                appindicator.CATEGORY_APPLICATION_STATUS)
 
173
        self.indicator = AppIndicator3.Indicator.new("AutoKey", ConfigManager.SETTINGS[NOTIFICATION_ICON],
 
174
                                                AppIndicator3.IndicatorCategory.APPLICATION_STATUS)
175
175
                                                
176
 
        
177
176
        self.indicator.set_attention_icon(common.ICON_FILE_NOTIFICATION_ERROR)
178
177
        self.update_visible_status()           
179
178
        self.rebuild_menu()
180
179
        
181
180
    def update_visible_status(self):
182
181
        if ConfigManager.SETTINGS[SHOW_TRAY_ICON]:
183
 
            self.indicator.set_status(appindicator.STATUS_ACTIVE)
 
182
            self.indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE)
184
183
        else:
185
 
            self.indicator.set_status(appindicator.STATUS_PASSIVE)   
 
184
            self.indicator.set_status(AppIndicator3.IndicatorStatus.PASSIVE)   
186
185
            
187
186
    def hide_icon(self):     
188
 
        self.indicator.set_status(appindicator.STATUS_PASSIVE)
 
187
        self.indicator.set_status(AppIndicator3.IndicatorStatus.PASSIVE)
189
188
        
190
189
    def rebuild_menu(self):
191
190
        # Main Menu items
203
202
        removeMenuItem = Gtk.ImageMenuItem(_("Remove icon"))
204
203
        removeMenuItem.set_image(Gtk.Image.new_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.MENU))
205
204
        
206
 
        quitMenuItem = Gtk.ImageMenuItem(Gtk.STOCK_QUIT)
 
205
        quitMenuItem = Gtk.ImageMenuItem.new_from_stock(Gtk.STOCK_QUIT, None)
207
206
                
208
207
        # Menu signals
209
208
        enableMenuItem.connect("toggled", self.on_enable_toggled)
240
239
    def notify_error(self, message):
241
240
        self.show_notify(message, Gtk.STOCK_DIALOG_ERROR)
242
241
        self.errorItem.show()
243
 
        self.indicator.set_status(appindicator.STATUS_ATTENTION)
 
242
        self.indicator.set_status(AppIndicator3.IndicatorStatus.ATTENTION)
244
243
        
245
244
    def show_notify(self, message, iconName):
246
245
        Gdk.threads_enter()
247
 
        n = Notify.Notification("AutoKey", message, iconName)
248
 
        n.set_urgency(Notify.URGENCY_LOW)
 
246
        n = Notify.Notification.new("AutoKey", message, iconName)
 
247
        n.set_urgency(Notify.Urgency.LOW)
249
248
        n.show()
250
249
        Gdk.threads_leave()
251
250
        
267
266
        self.app.show_configure()
268
267
 
269
268
    def on_remove_icon(self, widget, data=None):
270
 
        self.indicator.set_status(appindicator.STATUS_PASSIVE)
 
269
        self.indicator.set_status(AppIndicator3.IndicatorStatus.PASSIVE)
271
270
        ConfigManager.SETTINGS[SHOW_TRAY_ICON] = False
272
271
                
273
272
    def on_destroy_and_exit(self, widget, data=None):