changeset d49c1c384960 in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=d49c1c384960 description: Refactored doc-strings
diffstat:
src/chat_control.py | 305 +++++++++++++++++++++++++++++++++----------------- 1 files changed, 199 insertions(+), 106 deletions(-)
diffs (truncated from 645 to 300 lines):
diff -r eed72038e5ee -r d49c1c384960 src/chat_control.py --- a/src/chat_control.py Wed Nov 25 13:29:57 2009 +0100 +++ b/src/chat_control.py Wed Nov 25 15:01:40 2009 +0200 @@ -90,8 +90,9 @@
################################################################################ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): - '''A base class containing a banner, ConversationTextview, MessageTextView - ''' + """ + A base class containing a banner, ConversationTextview, MessageTextView + """
def make_href(self, match): url_color = gajim.config.get('urlmsgcolor') @@ -99,7 +100,9 @@ url_color, match.group())
def get_font_attrs(self): - ''' get pango font attributes for banner from theme settings ''' + """ + Get pango font attributes for banner from theme settings + """ theme = gajim.config.get('roster_theme') bannerfont = gajim.config.get_per('themes', theme, 'bannerfont') bannerfontattrs = gajim.config.get_per('themes', theme, 'bannerfontattrs') @@ -133,33 +136,45 @@ type_]))
def draw_banner(self): - '''Draw the fat line at the top of the window that - houses the icon, jid, ... - ''' + """ + Draw the fat line at the top of the window that houses the icon, jid, etc + + Derived types MAY implement this. + """ self.draw_banner_text() self._update_banner_state_image() - # Derived types MAY implement this
def draw_banner_text(self): - pass # Derived types SHOULD implement this + """ + Derived types SHOULD implement this + """ + pass
def update_ui(self): + """ + Derived types SHOULD implement this + """ self.draw_banner() - # Derived types SHOULD implement this
def repaint_themed_widgets(self): + """ + Derived types MAY implement this + """ self._paint_banner() self.draw_banner() - # Derived classes MAY implement this
def _update_banner_state_image(self): - pass # Derived types MAY implement this + """ + Derived types MAY implement this + """ + pass
def handle_message_textview_mykey_press(self, widget, event_keyval, - event_keymod): - # Derived should implement this rather than connecting to the event - # itself. - + event_keymod): + """ + Derives types SHOULD implement this, rather than connection to the even + itself + """ event = gtk.gdk.Event(gtk.gdk.KEY_PRESS) event.keyval = event_keyval event.state = event_keymod @@ -212,7 +227,7 @@ helpers.launch_browser_mailer('url', url)
def __init__(self, type_id, parent_win, widget_name, contact, acct, - resource = None): + resource = None): if resource is None: # We very likely got a contact with a random resource. # This is bad, we need the highest for caps etc. @@ -386,7 +401,9 @@ dialogs.AspellDictError(lang)
def on_banner_label_populate_popup(self, label, menu): - '''We override the default context menu and add our own menutiems''' + """ + Override the default context menu and add our own menutiems + """ item = gtk.SeparatorMenuItem() menu.prepend(item)
@@ -400,8 +417,10 @@ menu.show_all()
def on_msg_textview_populate_popup(self, textview, menu): - '''we override the default context menu and we prepend an option to switch - languages''' + """ + Override the default context menu and we prepend an option to switch + languages + """ def _on_select_dictionary(widget, lang): per_type = 'contacts' if self.type_id == message_control.TYPE_GC: @@ -445,12 +464,16 @@
# moved from ChatControl def _on_banner_eventbox_button_press_event(self, widget, event): - '''If right-clicked, show popup''' + """ + If right-clicked, show popup + """ if event.button == 3: # right click self.parent_win.popup_menu(event)
def _on_send_button_clicked(self, widget): - '''When send button is pressed: send the current message''' + """ + When send button is pressed: send the current message + """ if gajim.connections[self.account].connected < 2: # we are not connected dialogs.ErrorDialog(_('A connection is not available'), _('Your message can not be sent until you are connected.')) @@ -465,7 +488,9 @@ self.send_message(message, xhtml=xhtml)
def _paint_banner(self): - '''Repaint banner with theme color''' + """ + Repaint banner with theme color + """ theme = gajim.config.get('roster_theme') bgcolor = gajim.config.get_per('themes', theme, 'bannerbgcolor') textcolor = gajim.config.get_per('themes', theme, 'bannertextcolor') @@ -512,9 +537,11 @@ self.handlers[id_] = widget
def _on_style_set_event(self, widget, style, *opts): - '''set style of widget from style class *.Frame.Eventbox + """ + Set style of widget from style class *.Frame.Eventbox opts[0] == True -> set fg color - opts[1] == True -> set bg color''' + opts[1] == True -> set bg color + """ banner_eventbox = self.xml.get_widget('banner_eventbox') self.disconnect_style_event(widget) if opts[1]: @@ -589,11 +616,11 @@ return False
def _on_message_textview_mykeypress_event(self, widget, event_keyval, - event_keymod): - '''When a key is pressed: - if enter is pressed without the shift key, message (if not empty) is sent - and printed in the conversation''' - + event_keymod): + """ + When a key is pressed: if enter is pressed without the shift key, message + (if not empty) is sent and printed in the conversation + """ # NOTE: handles mykeypress which is custom signal connected to this # CB in new_tab(). for this singal see message_textview.py message_textview = widget @@ -652,8 +679,11 @@ event_keymod)
def _on_drag_data_received(self, widget, context, x, y, selection, - target_type, timestamp): - pass # Derived classes SHOULD implement this method + target_type, timestamp): + """ + Derived types SHOULD implement this + """ + pass
def _on_drag_leave(self, widget, context, time): # FIXME: DND on non editable TextView, find a better way @@ -668,10 +698,11 @@ self.conv_textview.tv.set_editable(True)
def send_message(self, message, keyID='', type_='chat', chatstate=None, - msg_id=None, composing_xep=None, resource=None, - xhtml=None, callback=None, callback_args=[], process_commands=True): - '''Send the given message to the active tab. Doesn't return None if error - ''' + msg_id=None, composing_xep=None, resource=None, xhtml=None, + callback=None, callback_args=[], process_commands=True): + """ + Send the given message to the active tab. Doesn't return None if error + """ if not message or message == '\n': return None
@@ -711,10 +742,13 @@ self.orig_msg = None
def print_conversation_line(self, text, kind, name, tim, - other_tags_for_name=[], other_tags_for_time=[], other_tags_for_text=[], - count_as_new=True, subject=None, old_kind=None, xhtml=None, simple=False, - xep0184_id=None, graphics=True): - '''prints 'chat' type messages''' + other_tags_for_name=[], other_tags_for_time=[], + other_tags_for_text=[], count_as_new=True, subject=None, + old_kind=None, xhtml=None, simple=False, xep0184_id=None, + graphics=True): + """ + Print 'chat' type messages + """ jid = self.contact.jid full_jid = self.get_full_jid() textview = self.conv_textview @@ -789,8 +823,10 @@ self.parent_win.show_title(False, self) # Disabled Urgent hint
def toggle_emoticons(self): - '''hide show emoticons_button and make sure emoticons_menu is always there - when needed''' + """ + Hide show emoticons_button and make sure emoticons_menu is always there + when needed + """ emoticons_button = self.xml.get_widget('emoticons_button') if gajim.config.get('emoticons_theme'): emoticons_button.show() @@ -808,12 +844,16 @@ self.msg_textview.grab_focus()
def on_emoticons_button_clicked(self, widget): - '''popup emoticons menu''' + """ + Popup emoticons menu + """ gajim.interface.emoticon_menuitem_clicked = self.append_emoticon gajim.interface.popup_emoticons_under_button(widget, self.parent_win)
def on_formattings_button_clicked(self, widget): - '''popup formattings menu''' + """ + Popup formattings menu + """ menu = gtk.Menu()
menuitems = ((_('Bold'), 'bold'), @@ -875,7 +915,9 @@
def on_actions_button_clicked(self, widget): - '''popup action menu''' + """ + Popup action menu + """ menu = self.prepare_context_menu(hide_buttonbar_items=True) menu.show_all() gtkgui_helpers.popup_emoticons_under_button(menu, widget, @@ -895,7 +937,9 @@ buffer_.delete(start, end)
def _on_history_menuitem_activate(self, widget = None, jid = None): - '''When history menuitem is pressed: call history window''' + """ + When history menuitem is pressed: call history window + """ if not jid: jid = self.contact.jid
@@ -907,7 +951,9 @@ history_window.HistoryWindow(jid, self.account)
def _on_send_file(self, gc_contact=None): - '''gc_contact can be set when we are in a groupchat control''' + """ + gc_contact can be set when we are in a groupchat control + """ def _on_ok(c): gajim.interface.instances['file_transfers'].show_file_send_request( self.account, c) @@ -935,7 +981,9 @@ _on_ok(self.contact)
def on_minimize_menuitem_toggled(self, widget): - '''When a grouchat is minimized, unparent the tab, put it in roster etc''' + """ + When a grouchat is minimized, unparent the tab, put it in roster etc + """ old_value = False