Пример #1
0
	def new_timeline(self, *args, **kwargs):
		b = self.get_current_buffer()
		if not hasattr(b, "get_users"):
			b = self.search("home_timeline")
		d = []
		for i in self.session.db["users"]:
			d.append((i, self.session.get_user_name(i, "nom")))
		for i in self.session.db["groups"]:
			d.append((-i, self.session.get_user_name(-i)))
		a = timeline.timelineDialog([i[1] for i in d])
		if a.get_response() == widgetUtils.OK:
			user = a.get_user()
			buffertype = a.get_buffer_type()
			user_id = ""
			for i in d:
				if i[1] == user:
					user_id = i[0]
			if user_id == None:
				commonMessages.no_user_exist()
				return
			print user_id
			if buffertype == "audio":
				buffer = buffers.audioBuffer(parent=self.window.tb, name="{0}_audio".format(user_id,), composefunc="compose_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"], owner_id=user_id)
				# Translators: {0} will be replaced with an user.
				name_ = _(u"{0}'s audios").format(self.session.get_user_name(user_id, "gen"),)
			elif buffertype == "wall":
				buffer = buffers.feedBuffer(parent=self.window.tb, name="{0}_feed".format(user_id,), composefunc="compose_status", session=self.session, endpoint="get", parent_endpoint="wall", extended=1, count=self.session.settings["buffers"]["count_for_wall_buffers"],  owner_id=user_id)
				# Translators: {0} will be replaced with an user.
				name_ = _(u"{0}'s wall posts").format(self.session.get_user_name(user_id, "gen"),)
			elif buffertype == "friends":
				buffer = buffers.peopleBuffer(parent=self.window.tb, name="friends_{0}".format(user_id,), composefunc="compose_person", session=self.session, endpoint="get", parent_endpoint="friends", count=5000, fields="uid, first_name, last_name, last_seen", user_id=user_id)
				# Translators: {0} will be replaced with an user.
				name_ = _(u"{0}'s friends").format(self.session.get_user_name(user_id, "friends"),)
			self.buffers.append(buffer)
			call_threaded(self.complete_buffer_creation, buffer=buffer, name_=name_, position=self.window.search("timelines"))
Пример #2
0
	def search_audios(self, *args, **kwargs):
		dlg = searchDialogs.searchAudioDialog()
		if dlg.get_response() == widgetUtils.OK:
			q = dlg.get("term").encode("utf-8")
			count = 300
			auto_complete = dlg.get_checkable("auto_complete")
			lyrics = dlg.get_checkable("lyrics")
			performer_only = dlg.get_checkable("artist_only")
			sort = dlg.get_sort_order()
			newbuff = buffers.audioBuffer(parent=self.window.tb, name=u"{0}_audiosearch".format(q.decode("utf-8"),), session=self.session, composefunc="compose_audio", parent_endpoint="audio", endpoint="search", q=q, count=count, auto_complete=auto_complete, lyrics=lyrics, performer_only=performer_only, sort=sort)
			self.buffers.append(newbuff)
			call_threaded(newbuff.get_items)
			# Translators: {0} will be replaced with the search term.
			self.window.insert_buffer(newbuff.tab, _(u"Search for {0}").format(q.decode("utf-8"),), self.window.search("audios"))
Пример #3
0
	def create_controls(self):
		log.debug("Creating controls for the window...")
		posts_ = buffers.empty(parent=self.window.tb, name="posts")
		self.buffers.append(posts_)
		# Translators: Name for the posts tab in the tree view.
		self.window.add_buffer(posts_.tab, _(u"Posts"))
		home = buffers.baseBuffer(parent=self.window.tb, name="home_timeline", session=self.session, composefunc="compose_new", endpoint="newsfeed", count=self.session.settings["buffers"]["count_for_wall_buffers"])
		self.buffers.append(home)
		# Translators: Newsfeed's name in the tree view.
		self.window.insert_buffer(home.tab, _(u"Home"), self.window.search("posts"))
		self.repeatedUpdate = RepeatingTimer(180, self.update_all_buffers)
		self.repeatedUpdate.start()

		self.readMarker = RepeatingTimer(120, self.mark_as_read)
		self.readMarker.start()

		feed = buffers.feedBuffer(parent=self.window.tb, name="me_feed", composefunc="compose_status", session=self.session, endpoint="get", parent_endpoint="wall", extended=1, count=self.session.settings["buffers"]["count_for_wall_buffers"])
		self.buffers.append(feed)
		# Translators: Own user's wall name in the tree view.
		self.window.insert_buffer(feed.tab, _(u"My wall"), self.window.search("posts"))
		audios = buffers.empty(parent=self.window.tb, name="audios")
		self.buffers.append(audios)
		# Translators: name for the music category in the tree view.
		self.window.add_buffer(audios.tab, _(u"Music"))

		audio = buffers.audioBuffer(parent=self.window.tb, name="me_audio", composefunc="compose_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"])
		self.buffers.append(audio)
		self.window.insert_buffer(audio.tab, _(u"My audios"), self.window.search("audios"))
		p_audio = buffers.audioBuffer(parent=self.window.tb, name="popular_audio", composefunc="compose_audio", session=self.session, endpoint="getPopular", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"])
		self.buffers.append(p_audio)
		self.window.insert_buffer(p_audio.tab, _(u"Populars"), self.window.search("audios"))
		r_audio = buffers.audioBuffer(parent=self.window.tb, name="recommended_audio", composefunc="compose_audio", session=self.session, endpoint="getRecommendations", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"])
		self.buffers.append(r_audio)
		self.window.insert_buffer(r_audio.tab, _(u"Recommendations"), self.window.search("audios"))
		albums = buffers.empty(parent=self.window.tb, name="albums")
		self.buffers.append(albums)
		self.window.insert_buffer(albums.tab, _(u"Albums"), self.window.search("audios"))

		videos = buffers.empty(parent=self.window.tb, name="videos")
		self.buffers.append(videos)
		# Translators: name for the videos category in the tree view.
		self.window.add_buffer(videos.tab, _(u"Video"))
		my_videos = buffers.videoBuffer(parent=self.window.tb, name="me_video", composefunc="compose_video", session=self.session, endpoint="get", parent_endpoint="video", count=self.session.settings["buffers"]["count_for_video_buffers"])
		self.buffers.append(my_videos)
		self.window.insert_buffer(my_videos.tab, _(u"My videos"), self.window.search("videos"))
		video_albums = buffers.empty(parent=self.window.tb, name="video_albums")
		self.buffers.append(video_albums)
		self.window.insert_buffer(video_albums.tab, _(u"Albums"), self.window.search("videos"))

		people = buffers.empty(parent=self.window.tb, name="people")
		self.buffers.append(people)
		self.window.add_buffer(people.tab, _(u"People"))
		friends = buffers.peopleBuffer(parent=self.window.tb, name="friends_", composefunc="compose_person", session=self.session, endpoint="get", parent_endpoint="friends", count=5000, fields="uid, first_name, last_name, last_seen")
		self.buffers.append(friends)
		self.window.insert_buffer(friends.tab, _(u"Friends"), self.window.search("people"))

		requests_ = buffers.empty(parent=self.window.tb, name="requests")
		self.buffers.append(requests_)
		self.window.insert_buffer(requests_.tab, _(u"Friendship requests"), self.window.search("people"))
		incoming_requests = buffers.requestsBuffer(parent=self.window.tb, name="friend_requests", composefunc="compose_person", session=self.session, count=1000)
		self.buffers.append(incoming_requests)
		self.window.insert_buffer(incoming_requests.tab, _(u"Followers"), self.window.search("requests"))
		outgoing_requests = buffers.requestsBuffer(parent=self.window.tb, name="friend_requests_sent", composefunc="compose_person", session=self.session, count=1000, out=1)
		self.buffers.append(outgoing_requests)
		self.window.insert_buffer(outgoing_requests.tab, _(u"I follow"), self.window.search("requests"))

		chats = buffers.empty(parent=self.window.tb, name="chats")
		self.buffers.append(chats)
		self.window.add_buffer(chats.tab, _(u"Chats"))
		timelines = buffers.empty(parent=self.window.tb, name="timelines")
		self.buffers.append(timelines)
		self.window.add_buffer(timelines.tab, _(u"Timelines"))
		self.window.realize()