~gnome15-team/gnome15/trunk

« back to all changes in this revision

Viewing changes to gnome15/src/main/python/gnome15/g15service.py

  • Committer: tanktarta
  • Date: 2012-11-24 10:27:36 UTC
  • Revision ID: tanktarta-20121124102736-0drhasy3jdn862wx
0.9.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
334
334
        
335
335
    def action_performed(self, binding):
336
336
        if binding.action == g15actions.CANCEL_MACRO:
337
 
            self.cancel_running_macro()
 
337
            self.cancel()
338
338
            return True 
339
339
        
340
340
    def _do_handle_key(self, keys, state_id, post):
577
577
        if not no_trap:
578
578
            signal.signal(signal.SIGINT, self.sigint_handler)
579
579
            signal.signal(signal.SIGTERM, self.sigterm_handler)
 
580
            signal.signal(signal.SIGUSR1, self.sigusr1_handler)
580
581
            
581
582
        g15desktop.G15AbstractService.__init__(self)
582
583
        self.name = "DesktopService"
588
589
            self.shutdown(True)
589
590
            logger.error("Failed to start service. %s" % str(e))
590
591
    
 
592
    def sigusr1_handler(self, signum, frame):
 
593
        logger.info("Got SIGUSR1 signal from %s, restarting" % str(frame))
 
594
        self.restart()
 
595
    
591
596
    def sigint_handler(self, signum, frame):
592
597
        logger.info("Got SIGINT signal from %s, shutting down" % str(frame))
593
598
        self.shutdown(True)
633
638
        else:
634
639
            logger.warn("Ignoring stop request, already stopped.")
635
640
            
636
 
        
 
641
    def restart(self):        
 
642
        g15util.run_script("g15-desktop-service", ["restart"], background = True)
 
643
            
637
644
    def shutdown(self, quickly = False):
638
645
        logger.info("Shutting down")
639
646
        self.shutting_down = True
660
667
    def _active_window_changed(self, old, object_name):
661
668
        if object_name != "":
662
669
            app = self.session_bus.get_object("org.ayatana.bamf", object_name)
663
 
            view = dbus.Interface(app, 'org.ayatana.bamf.view')
664
 
            self.active_application_name = view.Name()
665
 
            screens = list(self.screens)
666
 
            for s in list(screens):
667
 
                if self._check_active_application(s, app, view):
668
 
                    screens.remove(s)
 
670
            view = None
 
671
            try:
 
672
                view = dbus.Interface(app, 'org.ayatana.bamf.view')
 
673
                self.active_application_name = view.Name()
 
674
            except dbus.DBusException:
 
675
                self.active_application_name = None
 
676
                
 
677
            if view is not None:
 
678
                screens = list(self.screens)
 
679
                for s in list(screens):
 
680
                    if self._check_active_application(s, app, view):
 
681
                        screens.remove(s)
669
682
                    
670
683
            window = dbus.Interface(app, 'org.ayatana.bamf.window')
671
684
            self.active_window_title = self._get_x_prop(window, '_NET_WM_VISIBLE_NAME')
703
716
        
704
717
    def _check_active_application(self, screen, app, view):
705
718
        try :
706
 
            if view.IsActive() == 1:
 
719
            if view is not None and view.IsActive() == 1:
707
720
                vn = view.Name()
708
721
                if screen.set_active_application_name(vn):
709
722
                    return True