Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/QuinterApp/Quinter into main
Browse files Browse the repository at this point in the history
  • Loading branch information
masonasons committed Aug 2, 2021
2 parents cb198a5 + 1c56c0f commit 8f55a76
Show file tree
Hide file tree
Showing 18 changed files with 132 additions and 110 deletions.
38 changes: 19 additions & 19 deletions GUI/invisible.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
def register_key(key,name,reg=True):
if hasattr(main.window,name):
try:
if reg==True:
if reg:
main.window.handler.register_key(key,getattr(main.window,name))
else:
main.window.handler.unregister_key(key,getattr(main.window,name))
Expand All @@ -15,7 +15,7 @@ def register_key(key,name,reg=True):
return False
if hasattr(main.window,"on"+name):
try:
if reg==True:
if reg:
main.window.handler.register_key(key,getattr(main.window,"on"+name))
else:
main.window.handler.unregister_key(key,getattr(main.window,"on"+name))
Expand All @@ -24,7 +24,7 @@ def register_key(key,name,reg=True):
return False
if hasattr(main.window,"On"+name):
try:
if reg==True:
if reg:
main.window.handler.register_key(key,getattr(main.window,"On"+name))
else:
main.window.handler.unregister_key(key,getattr(main.window,"On"+name))
Expand All @@ -33,7 +33,7 @@ def register_key(key,name,reg=True):
return False
if hasattr(inv,name):
try:
if reg==True:
if reg:
main.window.handler.register_key(key,getattr(inv,name))
else:
main.window.handler.unregister_key(key,getattr(inv,name))
Expand All @@ -44,29 +44,29 @@ def register_key(key,name,reg=True):
class invisible_interface(object):
def focus_tl(self,sync=False):
globals.currentAccount.currentTimeline=globals.currentAccount.list_timelines()[globals.currentAccount.currentIndex]
if sync==False and globals.prefs.invisible_sync==True or sync==True:
if not sync and globals.prefs.invisible_sync or sync:
main.window.list.SetSelection(globals.currentAccount.currentIndex)
main.window.on_list_change(None)
extratext=""
if globals.prefs.position==True:
if globals.prefs.position:
if len(globals.currentAccount.currentTimeline.statuses)==0:
extratext+="Empty"
else:
extratext+=str(globals.currentAccount.currentTimeline.index+1)+" of "+str(len(globals.currentAccount.currentTimeline.statuses))
if globals.currentAccount.currentTimeline.read==True:
if globals.currentAccount.currentTimeline.read:
extratext+=", Autoread"
if globals.currentAccount.currentTimeline.mute==True:
if globals.currentAccount.currentTimeline.mute:
extratext+=", muted"
speak.speak(globals.currentAccount.currentTimeline.name+". "+extratext,True)
if globals.prefs.invisible_sync==False and sync==False:
if not globals.prefs.invisible_sync and not sync:
main.window.play_earcon()

def focus_tl_item(self):
if globals.prefs.invisible_sync==True:
if globals.prefs.invisible_sync:
main.window.list2.SetSelection(globals.currentAccount.currentTimeline.index)
main.window.on_list2_change(None)
else:
if globals.prefs.earcon_audio==True and len(sound.get_media_urls(utils.find_urls_in_tweet(globals.currentAccount.currentTimeline.statuses[globals.currentAccount.currentTimeline.index])))>0:
if globals.prefs.earcon_audio and len(sound.get_media_urls(utils.find_urls_in_tweet(globals.currentAccount.currentTimeline.statuses[globals.currentAccount.currentTimeline.index]))) > 0:
sound.play(globals.currentAccount,"media")
self.speak_item()

Expand All @@ -91,19 +91,19 @@ def next_tl(self,sync=False):
def prev_item(self):
if globals.currentAccount.currentTimeline.index==0 or len(globals.currentAccount.currentTimeline.statuses)==0:
sound.play(globals.currentAccount,"boundary")
if globals.prefs.repeat==True:
if globals.prefs.repeat:
self.speak_item()
return
globals.currentAccount.currentTimeline.index-=1
self.focus_tl_item()

def prev_item_jump(self):
if globals.currentAccount.currentTimeline.index<20:
if globals.currentAccount.currentTimeline.index < globals.prefs.move_amount:
sound.play(globals.currentAccount,"boundary")
if globals.prefs.repeat==True:
if globals.prefs.repeat:
self.speak_item()
return
globals.currentAccount.currentTimeline.index-=20
globals.currentAccount.currentTimeline.index -= globals.prefs.move_amount
self.focus_tl_item()

def top_item(self):
Expand All @@ -113,19 +113,19 @@ def top_item(self):
def next_item(self):
if globals.currentAccount.currentTimeline.index==len(globals.currentAccount.currentTimeline.statuses)-1 or len(globals.currentAccount.currentTimeline.statuses)==0:
sound.play(globals.currentAccount,"boundary")
if globals.prefs.repeat==True:
if globals.prefs.repeat:
self.speak_item()
return
globals.currentAccount.currentTimeline.index+=1
self.focus_tl_item()

def next_item_jump(self):
if globals.currentAccount.currentTimeline.index>=len(globals.currentAccount.currentTimeline.statuses)-20:
if globals.currentAccount.currentTimeline.index >= len(globals.currentAccount.currentTimeline.statuses) - globals.prefs.move_amount:
sound.play(globals.currentAccount,"boundary")
if globals.prefs.repeat==True:
if globals.prefs.repeat:
self.speak_item()
return
globals.currentAccount.currentTimeline.index+=20
globals.currentAccount.currentTimeline.index += globals.prefs.move_amount
self.focus_tl_item()

def bottom_item(self):
Expand Down
4 changes: 2 additions & 2 deletions GUI/lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self,account,user=None,add=True):
self.list.Bind(wx.EVT_LISTBOX, self.on_list_change)
self.add_items()
if self.user!=None:
if self.add==True:
if self.add:
self.load = wx.Button(self.panel, wx.ID_DEFAULT, "&Add")
else:
self.load = wx.Button(self.panel, wx.ID_DEFAULT, "&Remove")
Expand Down Expand Up @@ -120,7 +120,7 @@ def Load(self, event):
if self.user==None:
misc.list_timeline(self.account,self.lists[self.list.GetSelection()].name, self.lists[self.list.GetSelection()].id)
else:
if self.add==True:
if self.add:
self.account.api.add_list_member(user_id=self.user.id, list_id=self.lists[self.list.GetSelection()].id)
else:
self.account.api.remove_list_member(user_id=self.user.id, list_id=self.lists[self.list.GetSelection()].id)
Expand Down
20 changes: 10 additions & 10 deletions GUI/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,14 +272,14 @@ def unregister_keys(self):
success=invisible.register_key(key[0],key[1],False)

def ToggleWindow(self):
if self.IsShown()==True:
if self.IsShown():
self.Show(False)
globals.prefs.window_shown=False
else:
self.Show(True)
self.Raise()
globals.prefs.window_shown=True
if globals.prefs.invisible_sync==False:
if not globals.prefs.invisible_sync:
self.list.SetSelection(globals.currentAccount.currentIndex)
self.on_list_change(None)
self.list2.SetSelection(globals.currentAccount.currentTimeline.index)
Expand Down Expand Up @@ -339,13 +339,13 @@ def OnHide(self,event=None):
globals.currentAccount.currentTimeline.hide_tl()

def OnNextInThread(self,event=None):
if globals.prefs.reversed==False:
if not globals.prefs.reversed:
misc.next_in_thread(globals.currentAccount)
else:
misc.previous_in_thread(globals.currentAccount)

def OnPreviousInThread(self,event=None):
if globals.prefs.reversed==False:
if not globals.prefs.reversed:
misc.previous_in_thread(globals.currentAccount)
else:
misc.next_in_thread(globals.currentAccount)
Expand Down Expand Up @@ -395,7 +395,7 @@ def refreshTimelines(self):
def on_list_change(self, event):
globals.currentAccount.currentTimeline=globals.currentAccount.list_timelines()[self.list.GetSelection()]
globals.currentAccount.currentIndex=self.list.GetSelection()
if globals.currentAccount.currentTimeline.removable==True:
if globals.currentAccount.currentTimeline.removable:
self.m_close_timeline.Enable(True)
else:
self.m_close_timeline.Enable(False)
Expand All @@ -404,7 +404,7 @@ def on_list_change(self, event):
self.refreshList()

def play_earcon(self):
if globals.prefs.earcon_top==True and (globals.prefs.reversed==False and globals.currentAccount.currentTimeline.index>0 or globals.prefs.reversed==True and globals.currentAccount.currentTimeline.index<len(globals.currentAccount.currentTimeline.statuses)-1):
if globals.prefs.earcon_top and (not globals.prefs.reversed and globals.currentAccount.currentTimeline.index > 0 or globals.prefs.reversed and globals.currentAccount.currentTimeline.index < len(globals.currentAccount.currentTimeline.statuses) - 1):
sound.play(globals.currentAccount,"new")

def OnFollowers(self,event=None):
Expand Down Expand Up @@ -447,7 +447,7 @@ def OnCleanUserDb(self, event=None):

def on_list2_change(self, event):
globals.currentAccount.currentTimeline.index=self.list2.GetSelection()
if globals.prefs.earcon_audio==True and len(sound.get_media_urls(utils.find_urls_in_tweet(globals.currentAccount.currentTimeline.statuses[globals.currentAccount.currentTimeline.index])))>0:
if globals.prefs.earcon_audio and len(sound.get_media_urls(utils.find_urls_in_tweet(globals.currentAccount.currentTimeline.statuses[globals.currentAccount.currentTimeline.index]))) > 0:
sound.play(globals.currentAccount,"media")

def onRefresh(self,event=None):
Expand Down Expand Up @@ -558,12 +558,12 @@ def OnUnmuteUser(self, event=None):

def OnCloseTimeline(self, event=None):
tl=globals.currentAccount.currentTimeline
if tl.removable==True:
if globals.prefs.ask_dismiss==True:
if tl.removable:
if globals.prefs.ask_dismiss:
dlg=wx.MessageDialog(None,"Are you sure you wish to close "+tl.name+"?","Warning",wx.YES_NO | wx.ICON_QUESTION)
result=dlg.ShowModal()
dlg.Destroy()
if globals.prefs.ask_dismiss==False or globals.prefs.ask_dismiss==True and result== wx.ID_YES:
if not globals.prefs.ask_dismiss or globals.prefs.ask_dismiss and result== wx.ID_YES:
if tl.type=="user" and tl.data in globals.currentAccount.prefs.user_timelines:
globals.currentAccount.prefs.user_timelines.remove(tl.data)
if tl.type=="list" and tl.data in globals.currentAccount.prefs.list_timelines:
Expand Down
18 changes: 9 additions & 9 deletions GUI/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,36 +193,36 @@ def havent_tweeted(account):
flw.Show()

def user_timeline_user(account,username,focus=True):
if username in account.prefs.user_timelines and focus==True:
if username in account.prefs.user_timelines and focus:
utils.alert("You already have a timeline for this user open.","Error")
return False
if len(account.prefs.user_timelines)>=8:
utils.alert("You cannot have this many user timelines open! Please consider using a list instead.","Error")
return False
user=utils.lookup_user_name(account,username)
if user!=-1:
if focus==False:
if not focus:
account.timelines.append(timeline.timeline(account,name=username+"'s Timeline",type="user",data=username,user=user,silent=True))
else:
account.timelines.append(timeline.timeline(account,name=username+"'s Timeline",type="user",data=username,user=user))
if username not in account.prefs.user_timelines:
account.prefs.user_timelines.append(username)
main.window.refreshTimelines()
if focus==True:
if focus:
account.currentIndex=len(account.timelines)-1
main.window.list.SetSelection(len(account.timelines)-1)
main.window.on_list_change(None)
return True

def search(account,q,focus=True):
if focus==False:
if not focus:
account.timelines.append(timeline.timeline(account,name=q+" Search",type="search",data=q,silent=True))
else:
account.timelines.append(timeline.timeline(account,name=q+" Search",type="search",data=q))
if q not in account.prefs.search_timelines:
account.prefs.search_timelines.append(q)
main.window.refreshTimelines()
if focus==True:
if focus:
account.currentIndex=len(account.timelines)-1
main.window.list.SetSelection(len(account.timelines)-1)
main.window.on_list_change(None)
Expand All @@ -233,20 +233,20 @@ def user_search(account,q):
u.Show()

def list_timeline(account,n, q,focus=True):
if q in account.prefs.list_timelines and focus==True:
if q in account.prefs.list_timelines and focus:
utils.alert("You already have a timeline for this list open!","Error")
return
if len(account.prefs.list_timelines)>=8:
utils.alert("You cannot have this many list timelines open!","Error")
return
if focus==False:
if not focus:
account.timelines.append(timeline.timeline(account,name=n+" List",type="list",data=q,silent=True))
else:
account.timelines.append(timeline.timeline(account,name=n+" List",type="list",data=q))
if q not in account.prefs.list_timelines:
account.prefs.list_timelines.append(q)
main.window.refreshTimelines()
if focus==True:
if focus:
account.currentIndex=len(account.timelines)-1
main.window.list.SetSelection(len(account.timelines)-1)
main.window.on_list_change(None)
Expand Down Expand Up @@ -324,7 +324,7 @@ def load_conversation(account,status):
main.window.on_list_change(None)

def play(status):
if sound.player!=None and sound.player.is_playing==True:
if sound.player != None and sound.player.is_playing:
speak.speak("Stopped")
sound.stop()
return
Expand Down
17 changes: 13 additions & 4 deletions GUI/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ def __init__(self, parent):
self.wrap=wx.CheckBox(self, -1, "Word wrap in text fields")
self.main_box.Add(self.wrap, 0, wx.ALL, 10)
self.wrap.SetValue(globals.prefs.wrap)
self.move_amount_label = wx.StaticText(self, -1, "Number of tweets to move when using control+windows+page up/down")
self.move_amount = wx.TextCtrl(self, -1, "")
self.main_box.Add(self.move_amount, 0, wx.ALL, 10)
self.move_amount.AppendText(str(globals.prefs.move_amount))
self.autoOpenSingleURL=wx.CheckBox(self, -1, "when getting URLs from a tweet, automatically open the first URL if it is the only one")
self.main_box.Add(self.autoOpenSingleURL, 0, wx.ALL, 10)
self.autoOpenSingleURL.SetValue(globals.prefs.autoOpenSingleURL)
Expand Down Expand Up @@ -138,9 +142,9 @@ def OnOK(self, event):
globals.prefs.invisible_sync=self.advanced.invisible_sync.GetValue()
globals.prefs.repeat=self.advanced.repeat.GetValue()
globals.prefs.invisible_sync=self.advanced.invisible_sync.GetValue()
if globals.prefs.invisible==True and main.window.invisible==False:
if globals.prefs.invisible and not main.window.invisible:
main.window.register_keys()
if globals.prefs.invisible==False and main.window.invisible==True:
if not globals.prefs.invisible and main.window.invisible:
main.window.unregister_keys()
# globals.prefs.streaming=self.advanced.streaming.GetValue()
globals.prefs.position=self.advanced.position.GetValue()
Expand All @@ -151,6 +155,11 @@ def OnOK(self, event):
globals.prefs.update_time=int(self.advanced.update_time.GetValue())
if globals.prefs.update_time<1:
globals.prefs.update_time=1
globals.prefs.move_amount = int(self.general.move_amount.GetValue())
if globals.prefs.move_amount < 5:
globals.prefs.move_amount = 5
if globals.prefs.move_amount > 50:
globals.prefs.move_amount = 50
globals.prefs.user_limit=int(self.advanced.user_limit.GetValue())
if globals.prefs.user_limit<1:
globals.prefs.user_limit=1
Expand All @@ -176,9 +185,9 @@ def OnOK(self, event):
globals.prefs.userTemplate=self.templates.userTemplate.GetValue()
globals.prefs.autoOpenSingleURL=self.general.autoOpenSingleURL.GetValue()
self.Destroy()
if reverse==True:
if reverse:
timeline.reverse()
if refresh==True:
if refresh:
main.window.refreshList()

def OnClose(self, event):
Expand Down
4 changes: 2 additions & 2 deletions GUI/tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, frame):
def CreatePopupMenu(self):
menu = wx.Menu()
create_menu_item(menu, 'New tweet', self.frame.OnTweet)
if self.frame.IsShown()==True:
if self.frame.IsShown():
create_menu_item(menu, 'Hide window', self.OnShowHide)
else:
create_menu_item(menu, 'Show window', self.OnShowHide)
Expand All @@ -35,7 +35,7 @@ def OnShowHide(self, event):

def on_exit(self, event, blah=True):
self.Destroy()
if blah==True:
if blah:
self.frame.OnClose(event)

def set_icon(self, path):
Expand Down
6 changes: 3 additions & 3 deletions GUI/tweet.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def onKeyPress(self,event):
mods = event.HasAnyModifiers()
keycode = event.GetKeyCode()
if keycode == wx.WXK_RETURN:
if mods==False:
if not mods:
self.Tweet(None)
event.Skip()

Expand Down Expand Up @@ -180,7 +180,7 @@ def Tweet(self, event):
index=0
if hasattr(self,"list"):
for i in self.users:
if self.list.IsChecked(index)==False:
if not self.list.IsChecked(index):
self.ids.append(str(i.id))
index+=1
status=self.account.tweet(self.text.GetValue(),self.status.id,auto_populate_reply_metadata=True,exclude_reply_user_ids=",".join(self.ids))
Expand Down Expand Up @@ -211,7 +211,7 @@ def Tweet(self, event):
snd="send_message"
if status!=False:
sound.play(self.account,snd)
if hasattr(self,"thread")==True and self.thread.GetValue()==False or hasattr(self,"thread")==False:
if hasattr(self,"thread") and not self.thread.GetValue() or not hasattr(self, "thread"):
self.Destroy()
else:
self.status=status
Expand Down
Loading

0 comments on commit 8f55a76

Please sign in to comment.