Made some changes to the api threads and related callback so that we can save the members in each list into a data structure. This will help when building out some more List API functionality
This commit is contained in:
parent
5a675ee8d9
commit
48cce6a353
2 changed files with 18 additions and 9 deletions
14
hrafn.py
14
hrafn.py
|
@ -81,6 +81,8 @@ class Hrafn():
|
|||
|
||||
self.reply_id = None
|
||||
|
||||
self.lists = {}
|
||||
|
||||
# Load up all the programmatic GUI stuff
|
||||
self.init_widgets()
|
||||
|
||||
|
@ -489,20 +491,28 @@ class Hrafn():
|
|||
apithreads.GetFollowing(api=self.api, pane=pane, user=user).start()
|
||||
|
||||
|
||||
def on_lists_ready(self, widget, username, list_names):
|
||||
def on_lists_ready(self, widget, username, list_data):
|
||||
''' This callback takes information from a child thread that grabs list info from the API, and stores that info for later use '''
|
||||
|
||||
# Setup the new sub-menu
|
||||
outer_menu_item = gtk.MenuItem(username, False)
|
||||
self.view_menu.append(outer_menu_item)
|
||||
new_menu = gtk.Menu()
|
||||
outer_menu_item.set_submenu(new_menu)
|
||||
|
||||
# Save the member info in a data structure for later usage
|
||||
self.lists[username] = list_data
|
||||
|
||||
list_names = list_data.keys()
|
||||
list_names.sort()
|
||||
|
||||
# Insert the default list items
|
||||
list_names.insert(0, 'Home')
|
||||
list_names.insert(1, '@' + username)
|
||||
list_names.insert(2, 'Direct Messages')
|
||||
|
||||
# Add the items to the submenu, connect handler
|
||||
for l in list_names:
|
||||
# Add the item to the submenu, connect handler
|
||||
menu_item = gtk.MenuItem(l, False)
|
||||
new_menu.append(menu_item)
|
||||
menu_item.connect('activate', self.on_view_selected, username, l)
|
||||
|
|
Reference in a new issue