|
|
|
@ -252,13 +252,16 @@ class Interface(object):
|
|
|
|
|
self._statusbar = self._create_statusbar() |
|
|
|
|
|
|
|
|
|
self._main_tabs = gtk.Notebook() |
|
|
|
|
self._grids = [] |
|
|
|
|
|
|
|
|
|
(grid_widget, self._grid) = self._create_grid('_new_message_count') |
|
|
|
|
self._main_tabs.insert_page(grid_widget, gtk.Label('Messages')) |
|
|
|
|
self._grids.append((self._grid, '_new_messages_count')) |
|
|
|
|
|
|
|
|
|
(replies_widget, self._replies) = self._create_grid( |
|
|
|
|
'_new_replies_count') |
|
|
|
|
self._main_tabs.insert_page(replies_widget, gtk.Label('Replies')) |
|
|
|
|
self._grids.append((self._replies, '_new_replies_count')) |
|
|
|
|
|
|
|
|
|
update_box = gtk.VPaned() |
|
|
|
|
update_box.pack1(self._main_tabs, resize=True, shrink=False) |
|
|
|
@ -788,39 +791,6 @@ class Interface(object):
|
|
|
|
|
store.sort_column_changed() |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
def _update_word_wrap(self, widget): |
|
|
|
|
"""Update the word wrap for the widget.""" |
|
|
|
|
model = widget.get_model() |
|
|
|
|
if len(model) == 0: |
|
|
|
|
# don't try to update if there are no data to be updated |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
(win_width, win_height) = self._main_window.get_size() |
|
|
|
|
column = widget.get_column(1) |
|
|
|
|
iter = model.get_iter_first() |
|
|
|
|
path = model.get_path(iter) |
|
|
|
|
|
|
|
|
|
width = win_width - 70 # 48 = icon size |
|
|
|
|
# TODO: Find out where those 12 pixels came from and/or if they |
|
|
|
|
# are platform specific. |
|
|
|
|
|
|
|
|
|
for renderer in column.get_cell_renderers(): |
|
|
|
|
renderer.set_property('wrap-width', width) |
|
|
|
|
|
|
|
|
|
while iter: |
|
|
|
|
path = model.get_path(iter) |
|
|
|
|
model.row_changed(path, iter) |
|
|
|
|
iter = model.iter_next(iter) |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
def _get_current_grid(self): |
|
|
|
|
"""Return the grid of the current selected tab.""" |
|
|
|
|
page = self._main_tabs.get_current_page() |
|
|
|
|
if page == 0: |
|
|
|
|
return self._grid |
|
|
|
|
elif page == 1: |
|
|
|
|
return self._replies |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# ------------------------------------------------------------ |
|
|
|
|
# Widget callback functions |
|
|
|
@ -904,9 +874,29 @@ class Interface(object):
|
|
|
|
|
def _grid_resize(self, widget, requisition, data=None): |
|
|
|
|
"""Called when the window is resized. We use it to set the proper |
|
|
|
|
word-wrapping in the message column.""" |
|
|
|
|
for grid in self._grids: |
|
|
|
|
(grid, counter) = grid |
|
|
|
|
model = grid.get_model() |
|
|
|
|
if len(model) == 0: |
|
|
|
|
# don't try to update if there are no data to be updated |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
(win_width, win_height) = self._main_window.get_size() |
|
|
|
|
column = grid.get_column(1) |
|
|
|
|
iter = model.get_iter_first() |
|
|
|
|
path = model.get_path(iter) |
|
|
|
|
|
|
|
|
|
self._update_word_wrap(self._grid) |
|
|
|
|
self._update_word_wrap(self._replies) |
|
|
|
|
width = win_width - 70 # 48 = icon size |
|
|
|
|
# TODO: Find out where those 12 pixels came from and/or if they |
|
|
|
|
# are platform specific. |
|
|
|
|
|
|
|
|
|
for renderer in column.get_cell_renderers(): |
|
|
|
|
renderer.set_property('wrap-width', width) |
|
|
|
|
|
|
|
|
|
while iter: |
|
|
|
|
path = model.get_path(iter) |
|
|
|
|
model.row_changed(path, iter) |
|
|
|
|
iter = model.iter_next(iter) |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
def _order_datetime(self, model, iter1, iter2, user_data=None): |
|
|
|
@ -951,21 +941,16 @@ class Interface(object):
|
|
|
|
|
def _clear_posts(self, widget, user_data=None): |
|
|
|
|
"""Clear the list of posts from the grid.""" |
|
|
|
|
page = self._main_tabs.get_current_page() |
|
|
|
|
# we can't use self._get_current_grid() 'cause we actually need to |
|
|
|
|
# know the current grid to clear the counts |
|
|
|
|
if page == 0: |
|
|
|
|
# messages |
|
|
|
|
self._grid.get_model().clear() |
|
|
|
|
self._new_message_count = 0 |
|
|
|
|
elif page == 1: |
|
|
|
|
self._replies.get_model().clear() |
|
|
|
|
self._new_replies_count = 0 |
|
|
|
|
(grid, counter) = self._grids[page] |
|
|
|
|
grid.get_model().clear() |
|
|
|
|
set_attr(self, counter, 0) |
|
|
|
|
self._message_count_updated() |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
def _mark_all_read(self, widget, user_data=None): |
|
|
|
|
"""Mark all messages as read.""" |
|
|
|
|
grid = self._get_current_grid() |
|
|
|
|
page = self._main_tabs.get_current_page() |
|
|
|
|
(grid, counter) = self._grids[page] |
|
|
|
|
model = grid.get_model() |
|
|
|
|
if len(model) == 0: |
|
|
|
|
# no messages, so we don't worry (if I recall correctly, |
|
|
|
@ -979,18 +964,14 @@ class Interface(object):
|
|
|
|
|
iter = model.iter_next(iter) |
|
|
|
|
|
|
|
|
|
# update the counters |
|
|
|
|
page = self._main_tabs.get_current_page() |
|
|
|
|
if page == 0: |
|
|
|
|
self._new_message_count = 0 |
|
|
|
|
else: |
|
|
|
|
self._new_replies_count = 0 |
|
|
|
|
set(attr, self, counter, 0) |
|
|
|
|
self._message_count_updated() |
|
|
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
def _delete_message(self, widget, user_data=None): |
|
|
|
|
"""Delete a message.""" |
|
|
|
|
grid = self._get_current_grid() |
|
|
|
|
(grid, counter) = self._grids[self._main_tabs.get_current_page()] |
|
|
|
|
(model, iter) = grid.get_selection().get_selected() |
|
|
|
|
message = model.get_value(iter, 0) |
|
|
|
|
|
|
|
|
@ -1017,7 +998,7 @@ class Interface(object):
|
|
|
|
|
|
|
|
|
|
def _reply_message(self, widget, user_data=None): |
|
|
|
|
"""Reply to someone else's message.""" |
|
|
|
|
grid = self._get_current_grid() |
|
|
|
|
(grid, _) = self._grids[self._main_tabs.get_current_page()] |
|
|
|
|
(model, iter) = grid.get_selection().get_selected() |
|
|
|
|
message = model.get_value(iter, 0) |
|
|
|
|
self._update_text.get_buffer().set_text( |
|
|
|
@ -1029,7 +1010,7 @@ class Interface(object):
|
|
|
|
|
|
|
|
|
|
def _repost_message(self, widget, user_data=None): |
|
|
|
|
"""Repost someone else's message on your timeline.""" |
|
|
|
|
grid = self._get_current_grid() |
|
|
|
|
(grid, counter) = self._grids[self._main_tabs.get_current_page()] |
|
|
|
|
(model, iter) = grid.get_selection().get_selected() |
|
|
|
|
message = model.get_value(iter, 0) |
|
|
|
|
self._update_statusbar(_('Reposting %s message...') % |
|
|
|
@ -1042,7 +1023,7 @@ class Interface(object):
|
|
|
|
|
|
|
|
|
|
def _favourite_message(self, widget, user_data=None): |
|
|
|
|
"""Toggle the favourite status of a message.""" |
|
|
|
|
grid = self._get_current_grid() |
|
|
|
|
(grid, counter) = self._grids[self._main_tabs.get_current_page()] |
|
|
|
|
(model, iter) = grid.get_selection().get_selected() |
|
|
|
|
message = model.get_value(iter, 0) |
|
|
|
|
|
|
|
|
@ -1252,9 +1233,10 @@ class Interface(object):
|
|
|
|
|
retrieved.""" |
|
|
|
|
_log.debug('%d new tweets', len(results)) |
|
|
|
|
|
|
|
|
|
store = self._grid.get_model() |
|
|
|
|
(grid, counter) = self._grids[0] |
|
|
|
|
store = grid.get_model() |
|
|
|
|
self._fill_store(store, results) |
|
|
|
|
self._grid.queue_draw() |
|
|
|
|
grid.queue_draw() |
|
|
|
|
|
|
|
|
|
self._new_message_count += len(results) |
|
|
|
|
self._message_count_updated() |
|
|
|
@ -1288,9 +1270,10 @@ class Interface(object):
|
|
|
|
|
"""Called after we retrieve the replies.""" |
|
|
|
|
_log.debug("%d new replies", len(results)) |
|
|
|
|
|
|
|
|
|
store = self._replies.get_model() |
|
|
|
|
(grid, counter) = self._grids[1] |
|
|
|
|
store = grid.get_model() |
|
|
|
|
self._fill_store(store, results) |
|
|
|
|
self._replies.queue_draw() |
|
|
|
|
grid.queue_draw() |
|
|
|
|
|
|
|
|
|
self._new_replies_count += len(results) |
|
|
|
|
self._message_count_updated() |
|
|
|
@ -1336,7 +1319,8 @@ class Interface(object):
|
|
|
|
|
user_pic = user_pic.scale_simple(48, 48, gtk.gdk.INTERP_BILINEAR) |
|
|
|
|
self._avatars[url] = user_pic |
|
|
|
|
|
|
|
|
|
self._grid.queue_draw() |
|
|
|
|
(grid, _) = self._grids[0] |
|
|
|
|
grid.queue_draw() |
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
def _exception_download_pic(self, widget, exception): |
|
|
|
@ -1475,8 +1459,8 @@ class Interface(object):
|
|
|
|
|
self._delete_info = None |
|
|
|
|
self._reply_message_id = None |
|
|
|
|
self._favourite_info = None |
|
|
|
|
self._new_message_count = 0 |
|
|
|
|
self._new_replies_count = 0 |
|
|
|
|
self._new_message_count = 0 # TODO: Turn this into a @property |
|
|
|
|
self._new_replies_count = 0 # TODO: Turn this into a @property |
|
|
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|