changeset 76256088742d in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=76256088742d description: More doc-string refactoring
diffstat:
src/groupchat_control.py | 212 +++++++++++++++++++++++++++++++++++----------------- 1 files changed, 142 insertions(+), 70 deletions(-)
diffs (truncated from 496 to 300 lines):
diff -r d49c1c384960 -r 76256088742d src/groupchat_control.py --- a/src/groupchat_control.py Wed Nov 25 15:01:40 2009 +0200 +++ b/src/groupchat_control.py Wed Nov 25 15:24:48 2009 +0200 @@ -64,7 +64,9 @@ ) = range(5)
def set_renderer_color(treeview, renderer, set_background=True): - '''set style for group row, using PRELIGHT system color''' + """ + Set style for group row, using PRELIGHT system color + """ if set_background: bgcolor = treeview.style.bg[gtk.STATE_PRELIGHT] renderer.set_property('cell-background-gdk', bgcolor) @@ -141,7 +143,9 @@ self.TYPE_ID = 'pm'
def send_message(self, message, xhtml=None, process_commands=True): - '''call this function to send our message''' + """ + Call this method to send the message + """ if not message: return
@@ -383,7 +387,9 @@ self.widget.show_all()
def tree_compare_iters(self, model, iter1, iter2): - '''Compare two iters to sort them''' + """ + Compare two iters to sort them + """ type1 = model[iter1][C_TYPE] type2 = model[iter2][C_TYPE] if not type1 or not type2: @@ -422,8 +428,10 @@ return locale.strcoll(name1.lower(), name2.lower())
def on_msg_textview_populate_popup(self, textview, menu): - '''we override the default context menu and we prepend Clear - and the ability to insert a nick''' + """ + Override the default context menu and we prepend Clear + and the ability to insert a nick + """ ChatControlBase.on_msg_textview_populate_popup(self, textview, menu) item = gtk.SeparatorMenuItem() menu.prepend(item) @@ -452,7 +460,9 @@ gobject.idle_add(reset_flag)
def on_treeview_size_allocate(self, widget, allocation): - '''The MUC treeview has resized. Move the hpaned in all tabs to match''' + """ + The MUC treeview has resized. Move the hpaned in all tabs to match + """ if self.resize_from_another_muc: # Don't send the event to other MUC return @@ -467,7 +477,9 @@ ctrl.resize_occupant_treeview(hpaned_position)
def iter_contact_rows(self): - '''iterate over all contact rows in the tree model''' + """ + Iterate over all contact rows in the tree model + """ model = self.list_treeview.get_model() role_iter = model.get_iter_root() while role_iter: @@ -478,7 +490,9 @@ role_iter = model.iter_next(role_iter)
def on_list_treeview_style_set(self, treeview, style): - '''When style (theme) changes, redraw all contacts''' + """ + When style (theme) changes, redraw all contacts + """ # Get the room_jid from treeview for contact in self.iter_contact_rows(): nick = contact[C_NICK].decode('utf-8') @@ -500,10 +514,11 @@ self.draw_contact(nick, selected=True, focus=True)
def get_tab_label(self, chatstate): - '''Markup the label if necessary. Returns a tuple such as: - (new_label_str, color) - either of which can be None - if chatstate is given that means we have HE SENT US a chatstate''' + """ + Markup the label if necessary. Returns a tuple such as: (new_label_str, + color) either of which can be None if chatstate is given that means we + have HE SENT US a chatstate + """
has_focus = self.parent_win.window.get_property('has-toplevel-focus') current_tab = self.parent_win.get_active_control() == self @@ -588,10 +603,10 @@ banner_status_img.set_from_pixbuf(scaled_pix)
def get_continued_conversation_name(self): - '''Get the name of a continued conversation. - Will return Continued Conversation if there isn't any other - contact in the room - ''' + """ + Get the name of a continued conversation. Will return Continued + Conversation if there isn't any other contact in the room + """ nicks = [] for nick in gajim.contacts.get_nick_list(self.account, self.room_jid): @@ -605,9 +620,10 @@ return title
def draw_banner_text(self): - '''Draw the text in the fat line at the top of the window that - houses the room jid, subject. - ''' + """ + Draw the text in the fat line at the top of the window that houses the + room jid, subject + """ self.name_label.set_ellipsize(pango.ELLIPSIZE_END) self.banner_status_label.set_ellipsize(pango.ELLIPSIZE_END) font_attrs, font_attrs_small = self.get_font_attrs() @@ -641,7 +657,9 @@ self.banner_status_label.set_markup(subject_text)
def prepare_context_menu(self, hide_buttonbar_items=False): - '''sets sensitivity state for configure_room''' + """ + Set sensitivity state for configure_room + """ xml = gtkgui_helpers.get_glade('gc_control_popup_menu.glade') menu = xml.get_widget('gc_control_popup_menu')
@@ -745,7 +763,7 @@ return menu
def destroy_menu(self, menu, change_nick_menuitem, change_subject_menuitem, - bookmark_room_menuitem, history_menuitem): + bookmark_room_menuitem, history_menuitem): # destroy accelerators ag = gtk.accel_groups_from_object(self.parent_win.window)[0] change_nick_menuitem.remove_accelerator(ag, gtk.keysyms.n, @@ -760,7 +778,7 @@ menu.destroy()
def on_message(self, nick, msg, tim, has_timestamp=False, xhtml=None, - status_code=[]): + status_code=[]): if '100' in status_code: # Room is not anonymous self.is_anonymous = False @@ -776,8 +794,8 @@ else: self.print_conversation(msg, nick, tim, xhtml)
- def on_private_message(self, nick, msg, tim, xhtml, session, - msg_id=None, encrypted=False): + def on_private_message(self, nick, msg, tim, xhtml, session, msg_id=None, + encrypted=False): # Do we have a queue? fjid = self.room_jid + '/' + nick no_queue = len(gajim.events.get_events(self.account, fjid)) == 0 @@ -835,8 +853,7 @@ fin = True return None
- def print_old_conversation(self, text, contact='', tim=None, - xhtml = None): + def print_old_conversation(self, text, contact='', tim=None, xhtml = None): if isinstance(text, str): text = unicode(text, 'utf-8') if contact: @@ -855,11 +872,14 @@ small_attr + ['restored_message'], count_as_new=False, xhtml=xhtml)
def print_conversation(self, text, contact='', tim=None, xhtml=None, - graphics=True): - '''Print a line in the conversation: - if contact is set: it's a message from someone or an info message (contact - = 'info' in such a case) - if contact is not set: it's a message from the server or help''' + graphics=True): + """ + Print a line in the conversation + + If contact is set: it's a message from someone or an info message + (contact = 'info' in such a case). + If contact is not set: it's a message from the server or help. + """ if isinstance(text, str): text = unicode(text, 'utf-8') other_tags_for_name = [] @@ -938,8 +958,10 @@ return nb
def highlighting_for_message(self, text, tim): - '''Returns a 2-Tuple. The first says whether or not to highlight the - text, the second, what sound to play.''' + """ + Returns a 2-Tuple. The first says whether or not to highlight the text, + the second, what sound to play + """ highlight, sound = (None, None)
# Are any of the defined highlighting words in the text? @@ -961,10 +983,11 @@ return (highlight, sound)
def check_and_possibly_add_focus_out_line(self): - '''checks and possibly adds focus out line for room_jid if it needs it - and does not already have it as last event. If it goes to add this line - it removes previous line first''' - + """ + Check and possibly add focus out line for room_jid if it needs it and + does not already have it as last event. If it goes to add this line + - remove previous line first + """ win = gajim.interface.msg_win_mgr.get_window(self.room_jid, self.account) if win and self.room_jid == win.get_active_jid() and\ win.window.get_property('has-toplevel-focus') and\ @@ -976,9 +999,10 @@ self.conv_textview.show_focus_out_line()
def needs_visual_notification(self, text): - '''checks text to see whether any of the words in (muc_highlight_words - and nick) appear.''' - + """ + Check text to see whether any of the words in (muc_highlight_words and + nick) appear + """ special_words = gajim.config.get('muc_highlight_words').split(';') special_words.append(self.nick) # Strip empties: ''.split(';') == [''] and would highlight everything. @@ -1072,9 +1096,11 @@ self.list_treeview.columns_autosize()
def on_send_pm(self, widget=None, model=None, iter_=None, nick=None, - msg=None): - '''opens a chat window and if msg is not None sends private message to a - contact in a room''' + msg=None): + """ + Open a chat window and if msg is not None - send private message to a + contact in a room + """ if nick is None: nick = model[iter_][C_NICK].decode('utf-8')
@@ -1083,7 +1109,9 @@ ctrl.send_message(msg)
def on_send_file(self, widget, gc_contact): - '''sends a file to a contact in the room''' + """ + Send a file to a contact in the room + """ self._on_send_file(gc_contact)
def draw_contact(self, nick, selected=False, focus=False): @@ -1168,8 +1196,10 @@ self.draw_role(role)
def chg_contact_status(self, nick, show, status, role, affiliation, jid, - reason, actor, statusCode, new_nick, avatar_sha, tim=None): - '''When an occupant changes his or her status''' + reason, actor, statusCode, new_nick, avatar_sha, tim=None): + """ + When an occupant changes his or her status + """ if show == 'invisible': return
@@ -1448,7 +1478,7 @@ self.print_conversation(st, tim=tim, graphics=False)
def add_contact_to_roster(self, nick, show, role, affiliation, status, - jid=''): + jid=''): model = self.list_treeview.get_model() role_name = helpers.get_uf_role(role, plural=True)
@@ -1514,7 +1544,9 @@ return None
def remove_contact(self, nick): - '''Remove a user from the contacts_list''' + """ + Remove a user from the contacts_list + """ model = self.list_treeview.get_model() iter_ = self.get_contact_iter(nick) if not iter_: @@ -1529,7 +1561,9 @@