Example #1
0
 def __load_previous_file(self, scroll_to_end=True):
     if self._sub_file_number > 0:
         self.__load_file(self._sub_file_number - 1)
         if scroll_to_end is True:
             GObject.timeout_add(100, self.__scroll_to_end_of_loaded_file)
         else:
             self._previous_file_loaded = True
    def set_blinking(self, blinking):
        self.blinking = blinking

        if blinking and self.tick_id == 0:
            GObject.idle_add(self._blink_idle)
        elif self.tick_id > 0:
            self.stop_blinking = True
Example #3
0
File: hotot.py Project: sarim/Hotot
def main():
    for opt in sys.argv[1:]:
        if opt in ('-h', '--help'):
            usage()
            sys.exit()
        elif opt in ('-d', '--dev'):
            config.ENABLE_INSPECTOR = True
        else:
            print "hotot: unrecognized option '%s'" % opt
            usage()
            sys.exit(1)

    try:
        import i18n
    except:
        from gettext import gettext as _

    try:
        import prctl
        prctl.set_name('hotot')
    except:
        pass

    GObject.threads_init()
    config.loads();

    agent.init_notify()
    app = Hotot()
    agent.app = app

    Gdk.threads_enter()
    Gtk.main()
    Gdk.threads_leave()
Example #4
0
	def on_autorefresh_toggled(self, autorefresh):
		if self.autorefresh_id != 0:
			GObject.source_remove(self.autorefresh_id)
			self.autorefresh_id = 0
			
		if autorefresh.get_active():
			self.autorefresh_id = GObject.timeout_add(AUTOREFRESH_TIMEOUT, self.on_refresh_chart, True)
Example #5
0
 def testAdd(self):
     self.hook = True
     e = E()
     e.connect('signal', self._callback)
     GObject.add_emission_hook(E, "signal", self._emission_hook)
     e.emit('signal')
     self.assertEqual(e.status, 3)
Example #6
0
    def run(self):

        GObject.timeout_add(100, self._idle, priority=GObject.PRIORITY_HIGH)

        while True:
            Gtk.main_iteration()
            gevent.sleep(.001)
 def find_books(self, search_text):
     if _NEW_TOOLBAR_SUPPORT:
         self.enable_button(False)
     else:
         self._books_toolbar.enable_button(False)
     self.clear_downloaded_bytes()
     textbuffer = self.textview.get_buffer()
     textbuffer.set_text(_('Performing lookup, please wait') + '...')
     self.book_selected = False
     self.ls.clear()
     search_tuple = search_text.lower().split()
     if len(search_tuple) == 0:
         self._alert(_('Error'), _('You must enter at least one search word.'))
         if _NEW_TOOLBAR_SUPPORT:
             self.search_entry.grab_focus()
         else:
             self._books_toolbar.search_entry.grab_focus()
         return
     FL = urllib.quote('fl[]')
     SORT = urllib.quote('sort[]')
     self.search_url = 'http://www.archive.org/advancedsearch.php?q=' +  \
         urllib.quote('(title:(' + search_text.lower() + ') OR creator:(' + search_text.lower() +')) AND format:(DJVU)')
     self.search_url += '&' + FL + '=creator&' + FL + '=description&' + FL + '=format&' + FL + '=identifier&'  \
         + FL + '=language'
     self.search_url += '&' + FL +  '=publisher&' + FL + '=subject&' + FL + '=title&' + FL + '=volume'
     self.search_url += '&' + SORT + '=title&' + SORT + '&' + SORT + '=&rows=500&save=yes&fmt=csv&xmlsearch=Search'
     GObject.idle_add(self.download_csv,  self.search_url)
Example #8
0
    def __init__(self, pipeline_string='videotestsrc pattern=18 ! tee name=t ! queue ! autovideosink t. ! queue ! videoconvert ! videorate ! video/x-raw,width=(int)320,height=(int)240,format=(string)RGB16,framerate=(fraction)30/1 ! appsink name=sink'):
        self.data = None# this will contain the data passed between
        self.source_id = None
        self.lock = Lock()

        self.isWhite = True
        self.isStream = True
        self.timestamp = 0

        self.pipeline = Gst.parse_launch(pipeline_string)

        self.appsink = self.pipeline.get_by_name('sink')

        assert self.appsink, 'appsink element named \'sink\' not found'

        self.appsink.connect('new-sample', self.on_new_buffer)
        self.appsink.set_property('emit-signals', True)

        self.pipeline.set_state(Gst.State.PLAYING)

        # OUTPUT pipeline
        self.pipeline_out = Gst.parse_launch('appsrc name=source ! videoconvert ! autovideosink')

        self.appsrc = self.pipeline_out.get_by_name('source')

        assert self.appsrc, 'appsrc element named \'source\' not found'

        self.appsrc.set_property('caps', Gst.Caps.from_string('video/x-raw,format=(string)RGB16,width=(int)320,height=(int)240,framerate=(fraction)30/1'))

        self.appsrc.connect('need-data', self.on_need_data)
        self.appsrc.connect('enough-data', self.on_enough_data)

        self.pipeline_out.set_state(Gst.State.PLAYING)

        GObject.timeout_add_seconds(2, self._switch_data_type)
Example #9
0
    def _move(self, up=False):
        text = self._search_entry.get_text()
        if not text:
            return

        if up and self.__selected_search_result == 1:
            return False

        model = self._treeview.get_model()
        selection = self._treeview.get_selection()
        # disable flush timeout while searching
        if self._entry_flush_timeout:
            GObject.source_remove(self._entry_flush_timeout)
            self._entry_flush_timeout = 0
        # search
        start_count = self.__selected_search_result + (-1 if up else 1)
        start_iter = model.get_iter_first()
        found_iter = self.search_iter(selection, start_iter, text, 0,
                                      start_count)
        if found_iter:
            self.__selected_search_result += (-1 if up else 1)
            return True
        else:
            # Return to old iter
            self.search_iter(selection, start_iter, text, 0,
                             self.__selected_search_result)
            return False
        # renew flush timeout
        self._renew_flush_timeout()
        return
def run():
    # Protobuf
    #c = ControllerProtobuf()

    # Directly connected to the vision server
    c = VisionManager()
    
    if not c.is_connected():
        print("Vision server is not accessible.")
        return

    server = Server()
    server.start("127.0.0.1", 5030)

    # add observer output for "server"
    c.add_filter_output_observer(server.send)

    from gi.repository import Gtk, GObject
    import CapraVision.client.gtk.main
    GObject.threads_init()

    w = CapraVision.client.gtk.main.WinFilterChain(c)

    w.window.show_all()
    Gtk.main()

    # Close connection
    server.stop()
    c.close_server()
Example #11
0
	def __init__(self):
		#self.radio = tea5767()
		self.player = player()
		self.load = False
		self.defaullt = "/data/media/Music"
		self.config = configparser.ConfigParser()
		self.config.read('config.ini')
		interface = gtk.Builder()
		interface.add_from_file('./interface/interface.glade')
		self.volume = interface.get_object("volume")
		self.progression = interface.get_object("progression")
		self.music = interface.get_object("music")
		self.artiste = interface.get_object("artiste")
		self.cover = interface.get_object("pochette")
		self.mode = interface.get_object("mode")
		self.freq = interface.get_object("scale1")
		self.deroul = interface.get_object("liststore1") 
		self.folder = interface.get_object("filechooserbutton1")
		self.tab = interface.get_object('notebook1')
		self.on_notebook1_switch_page(self.tab, None,self.tab.get_current_page())
		self.fullScreen = interface.get_object("main")
		interface.connect_signals(self)
		gobject.idle_add(self.test)
		if True:#(self.config["player"]["last"] != self.defaullt)
			time.sleep(2)
			self.player.new_folder(self.defaullt)
			self.config["player"]["last"] = self.defaullt
			with open("./config.ini", 'w') as configfile:    # save
				self.config.write(configfile)
Example #12
0
	def unfullscreen(self):
		""" Unfullscreens the window """
		
		if self.is_fullscreen:
			GObject.idle_add(self.main.set_resizable, False)
			GObject.idle_add(self.main.unfullscreen)
			self.is_fullscreen = False
Example #13
0
	def fullscreen(self):
		""" Makes the window fullscreen. """
		
		if not self.is_fullscreen:
			GObject.idle_add(self.main.set_resizable, True)
			GObject.idle_add(self.main.fullscreen)
			self.is_fullscreen = True
Example #14
0
    def go_to_bookmark(self, subfilenumber, identifier):
        if self._sub_file_number != subfilenumber:
            self.__load_file(subfilenumber, timeout=100)

        GObject.timeout_add(100,
                            self.__scroll_to_bookmark_position_in_file,
                            identifier)
Example #15
0
 def checkFiles( self ):
     for monitored in self.monitoredFiles:
         if monitored.hasChanged():
             if monitored.args:
                 GObject.idle_add( monitored.callback, monitored.args )
             else:
                 GObject.idle_add( monitored.callback )
Example #16
0
    def __init__(self):
        GObject.GObject.__init__(self)
        self.connected = False
        
        
        # check is ONECONF_NET_CONNECTED is in the environment variables
        # if so force the network status to be connected or disconnected
        if "ONECONF_NET_CONNECTED" in os.environ:
            if os.environ["ONECONF_NET_CONNECTED"].lower() == 'true':
                GObject.idle_add(self._on_connection_state_changed, self.NM_STATE_CONNECTED_LOCAL)
                LOG.warn('forced netstate into connected mode...')
            else:
                GObject.idle_add(self._on_connection_state_changed, self.NM_STATE_DISCONNECTED)
                LOG.warn('forced netstate into disconnected mode...')
            return
        try:
            bus = dbus.SystemBus()
            nm = bus.get_object('org.freedesktop.NetworkManager',
                                '/org/freedesktop/NetworkManager')
            nm.connect_to_signal("StateChanged", self._on_connection_state_changed)
            network_state = nm.state(dbus_interface='org.freedesktop.NetworkManager')
            self._on_connection_state_changed(network_state)

        except Exception as e:
            LOG.warn("failed to init network state watcher '%s'" % e)
            self._on_connection_state_changed(self.NM_STATE_UNKNOWN)
    def _create_activity(self):
        if self._handle.activity_id is None:
            self._handle.activity_id = create_activity_id()

        self._shell.NotifyLaunch(
            self._service_name, self._handle.activity_id,
            reply_handler=self._no_reply_handler,
            error_handler=self._notify_launch_error_handler)

        environ = get_environment(self._bundle)
        (log_path, log_file) = open_log_file(self._bundle)
        command = get_command(self._bundle, self._handle.activity_id,
                              self._handle.object_id, self._handle.uri,
                              self._handle.invited)

        dev_null = file('/dev/null', 'r')
        child = subprocess.Popen([str(s) for s in command],
                                 env=environ,
                                 cwd=str(self._bundle.get_path()),
                                 close_fds=True,
                                 stdin=dev_null.fileno(),
                                 stdout=log_file.fileno(),
                                 stderr=log_file.fileno())

        GObject.child_watch_add(child.pid,
                                _child_watch_cb,
                                (log_file,
                                 self._handle.activity_id))
Example #18
0
    def calculateDiffs(self, menuItem, showNotification=True):
        self.setMenuEnabled(False)
        self.packageTitle.set_label('Calculating file diffs...')
        while Gtk.events_pending():
            Gtk.main_iteration()
        selected = self.getSelectedPackages()

        totalDiff = 0

        for package in selected:
            diff = self.bkup.getFileSizeDiff(package)
            totalDiff += diff
            print(self.bkup.humanPrint(diff))
            humanDiff = self.bkup.humanPrint(diff)
            newLabel = package + ' (' + humanDiff + ' change)'
            print(self.packages[package].set_label(newLabel))

        self.setMenuEnabled(True)
        self.packageTitle.set_label('Packages from bkup.yaml:')
        self.removeDiffLabelTime = time.time() + 60 * 5
        GObject.timeout_add(60 * 1000, self.checkDiffLabelRemovalTime)

        if showNotification:
            msg = Notify.Notification.new('Calculated file diffs', 'Bkup')
            msg.show()

        return totalDiff
Example #19
0
 def add_log_message(self, client_program_name, q_domain, domain_filter,
                     action):
     """Add log message to the logs window"""
     self._logs_window.add_log_line(client_program_name, q_domain,
                                    domain_filter, action)
     color = ACTION_COLOR_MAP.get(action, ACTION_COLOR_MAP['default'])
     GObject.timeout_add(1000, self.set_blinker, color)
Example #20
0
 def run(self, argv):
     GObject.threads_init()
     GObject.timeout_add(10, self.on_timer)
     self.connect("startup", self.on_startup)
     self.connect("activate", self.on_activate)
     self.connect("shutdown", self.on_shutdown)
     return super(Gtk3Example, self).run(argv)
Example #21
0
    def __key_release_event_cb(self, window, event):
        if self.__is_alt(event) and self._alt_timeout_sid:
            self._home_box.set_resume_mode(True)
            GObject.source_remove(self._alt_timeout_sid)
            self._alt_timeout_sid = None

        return False
Example #22
0
File: main.py Project: z411/trackma
def main():
    debug = False

    print("Trackma-gtk v{}".format(utils.VERSION))

    if '-h' in sys.argv:
        print("Usage: trackma-qt [options]")
        print()
        print('Options:')
        print(' -d  Shows debugging information')
        print(' -h  Shows this help')
        return
    if '-d' in sys.argv:
        debug = True

    app = TrackmaWindow(debug)
    try:
        GObject.threads_init()
        Gdk.threads_init()
        Gdk.threads_enter()
        app.main()
        Gtk.main()
    except utils.TrackmaFatal as e:
        md = Gtk.MessageDialog(None,
                               Gtk.DialogFlags.DESTROY_WITH_PARENT,
                               Gtk.MessageType.ERROR,
                               Gtk.ButtonsType.CLOSE, str(e))
        md.run()
        md.destroy()
    finally:
        Gdk.threads_leave()
Example #23
0
    def _button_clicked_cb(self, widget):
        self.set_enabled()

        if self.activity.player.is_playing():
            self.activity.player.pause()
            self.set_button_play()
            GObject.source_remove(self._scale_update_id)
            self._scale_update_id = -1
        else:
            if self.activity.player.error:
                self.set_disabled()
            else:
                if self.activity.player.player.props.current_uri is None:
                    # There is no stream selected to be played
                    # yet. Select the first one
                    available = self.activity.playlist_widget.\
                        _items[0]['available']
                    if available:
                        path = self.activity.playlist_widget._items[0]['path']
                        self.activity.playlist_widget.emit(
                            'play-index', 0, path)
                        self.activity.playlist_widget.set_current_playing(0)
                else:
                    self.activity.player.play()
                    self.activity._switch_canvas(True)
                    self._scale_update_id = GObject.timeout_add(
                        self.SCALE_UPDATE_INTERVAL, self.__update_scale_cb)
Example #24
0
    def __init__(self, window):
        Gtk.Dialog.__init__(self, _('Edit archive'), window, Gtk.DialogFlags.MODAL,
            (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL))
        self.kill = False # Dialog is killed.
        self.file_handler = window.file_handler
        self._window = window
        self._save_button = self.add_button(Gtk.STOCK_SAVE_AS, Gtk.ResponseType.OK)
        # There is no stock response for "import", but by using
        # RESPONSE_HELP we automatically get the button placed at the left.
        self._import_button = self.add_button(_('Import'), Gtk.ResponseType.HELP)
        self._import_button.set_image(Gtk.Image.new_from_stock(Gtk.STOCK_ADD,
            Gtk.IconSize.BUTTON))
        self.set_border_width(4)
        self.resize(min(Gdk.Screen.get_default().get_width() - 50, 750),
            min(Gdk.Screen.get_default().get_height() - 50, 600))
        self.connect('response', self._response)
        
        self._image_area = _ImageArea(self)
        self._other_area = _OtherArea(self)

        notebook = Gtk.Notebook()
        notebook.set_border_width(6)
        notebook.append_page(self._image_area, Gtk.Label(label=_('Images')))
        notebook.append_page(self._other_area, Gtk.Label(label=_('Other files')))
        self.vbox.pack_start(notebook, True, True, 0)
        self.show_all()
        GObject.idle_add(self._load_original_files)
    def on_realized(self, widget, data=None):
        if self.blinking and self.tick_id == 0:
            GObject.idle_add(self._blink_idle)

        trackers.con_tracker_get().disconnect(self,
                                              "realize",
                                              self.on_realized)
Example #26
0
 def test_searchentry(self):
     from softwarecenter.ui.gtk3.widgets.searchentry import get_test_searchentry_window
     win = get_test_searchentry_window()
     s = "foo"
     win.entry.insert_text(s, len(s))
     GObject.timeout_add(TIMEOUT, lambda: win.destroy())
     Gtk.main()
Example #27
0
def clear_token_from_ubuntu_sso_sync(appname):
    """ send a dbus signal to the com.ubuntu.sso service to clear
        the credentials for the given appname, e.g. _("Ubuntu Software Center")
        and wait for it to finish (or 2s)
    """
    from ubuntu_sso import (
        DBUS_BUS_NAME,
        DBUS_CREDENTIALS_IFACE,
        DBUS_CREDENTIALS_PATH,
        )
    # clean
    loop = GObject.MainLoop()
    bus = dbus.SessionBus()
    obj = bus.get_object(bus_name=DBUS_BUS_NAME,
                         object_path=DBUS_CREDENTIALS_PATH,
                         follow_name_owner_changes=True)
    proxy = dbus.Interface(object=obj,
                           dbus_interface=DBUS_CREDENTIALS_IFACE)
    proxy.connect_to_signal("CredentialsCleared", loop.quit)
    proxy.connect_to_signal("CredentialsNotFound", loop.quit)
    proxy.connect_to_signal("CredentialsError", loop.quit)
    proxy.clear_credentials(appname, {})
    # ensure we don't hang forever here
    GObject.timeout_add_seconds(2, loop.quit)
    # run the mainloop until the credentials are clear
    loop.run()
Example #28
0
    def _import_gst(self):
        """Import the necessary GObject-related modules and assign `Gst`
        and `GObject` fields on this object.
        """

        try:
            import gi
        except ImportError:
            raise FatalReplayGainError(
                "Failed to load GStreamer: python-gi not found"
            )

        try:
            gi.require_version('Gst', '1.0')
        except ValueError as e:
            raise FatalReplayGainError(
                "Failed to load GStreamer 1.0: {0}".format(e)
            )

        from gi.repository import GObject, Gst, GLib
        # Calling GObject.threads_init() is not needed for
        # PyGObject 3.10.2+
        with warnings.catch_warnings():
            warnings.simplefilter("ignore")
            GObject.threads_init()
        Gst.init([sys.argv[0]])

        self.GObject = GObject
        self.GLib = GLib
        self.Gst = Gst
Example #29
0
 def arm (self, manager):
   self.manager = manager
   props = dict(obj=self.remote.path, name=self.remote.item.name, expected=self.when.isoformat( ), **self.remote.item.fields)
   self.props = props
   new_path = PATH + '/Scheduler/Armed/' + self.hashed
   delay_ms = (self.when - datetime.datetime.now( )).total_seconds( ) * 1000
   self.remote.bus.add_signal_receiver(self.cleanup, "Remove", dbus_interface=Trigger.OWN_IFACE, bus_name=BUS, path=new_path)
   # manager.bus.add_signal_receiver(self.attrs, ack=self.on_success, error=self.on_error)
   trigger = None
   try:
     trigger = Trigger(new_path, manager, props, self)
     if trigger:
       trigger.Armed( )
       self.manager.Trigger("Arming", trigger.path)
       self.trigger = trigger
       print "DELAYING", delay_ms
       gobject.timeout_add(delay_ms, trigger.Fire)
       manager.InterfacesAdded(trigger.path, { Trigger.OWN_IFACE: props })
       self.manager.Trigger("Armed", trigger.path)
   except:
     print "already exited?"
     raise
   finally:
     pass
   return trigger
Example #30
0
  def _iterAction(self):
    '''
    Iterate to the next sequence step.
    '''
    if len(self.steps) <= self._current_step:
      if self._loop is not None:
        self._loop.quit()
      return
    action = self.steps[self._current_step]
    if self._verbose:
      print _('SEQUENCE: %s') % action

    try:
      next_action = self.steps[self._current_step + 1]
    except IndexError:
      next_action = None

    pyatspi.Registry.deregisterEventListener(self._onAnticipatedEvent,
                                             *self._anticipated_event_types)
    if isinstance(next_action, WaitAction):
      self._anticipated_event_types = next_action.wait_for
    else:
      self._anticipated_event_types = []
    pyatspi.Registry.registerEventListener(self._onAnticipatedEvent,
                                           *self._anticipated_event_types)
    self._current_handler = action.connect('done', self._onStepDone)

    GObject.timeout_add(action.delta_time, self._doAction, action)