diff options
author | Denis Fomin <fominde@gmail.com> | 2011-10-01 20:41:04 +0400 |
---|---|---|
committer | Denis Fomin <fominde@gmail.com> | 2011-10-01 20:41:04 +0400 |
commit | d2903b712ed351507dcfd09ba2a0cef4bcc49097 (patch) | |
tree | d77d31512f596880c0c8191a210513d9a4aae143 | |
parent | 0b240bf2ebc4f1d069fc9971d06b4c05834b7b10 (diff) |
juick. fixes #16
-rw-r--r-- | juick/config_dialog.ui | 21 | ||||
-rw-r--r-- | juick/manifest.ini | 2 | ||||
-rw-r--r-- | juick/plugin.py | 36 |
3 files changed, 47 insertions, 12 deletions
diff --git a/juick/config_dialog.ui b/juick/config_dialog.ui index 25587fa..1ad3162 100644 --- a/juick/config_dialog.ui +++ b/juick/config_dialog.ui @@ -43,6 +43,23 @@ </packing> </child> <child> + <object class="GtkCheckButton" id="only_first_avatar"> + <property name="label" translatable="yes">Show only the first avatar in the message</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="relief">none</property> + <property name="xalign">0</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="on_only_first_avatar_toggled"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + <child> <object class="GtkHBox" id="hbox1"> <property name="visible">True</property> <child> @@ -78,7 +95,7 @@ <packing> <property name="expand">False</property> <property name="fill">False</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> <child> @@ -116,7 +133,7 @@ <packing> <property name="expand">False</property> <property name="fill">False</property> - <property name="position">2</property> + <property name="position">3</property> </packing> </child> </object> diff --git a/juick/manifest.ini b/juick/manifest.ini index 4b793ff..4248fcf 100644 --- a/juick/manifest.ini +++ b/juick/manifest.ini @@ -1,7 +1,7 @@ [info] name: Juick short_name: Juick -version: 0.6 +version: 0.7 description: Clickable juick links , juick nics, preview juick picturs. The key combination alt + up in the textbox allow insert the number of last message (comment or topic). authors: Denis Fomin <fominde@gmail.com>, evgen <drujebober@gmail.com> diff --git a/juick/plugin.py b/juick/plugin.py index ed4c67a..180dfcf 100644 --- a/juick/plugin.py +++ b/juick/plugin.py @@ -43,6 +43,7 @@ class JuickPlugin(GajimPlugin): 'LINK_COLOR': ('#B8833E', 'Juick link color'), 'SHOW_TAG_BUTTON': (True, ''), 'ONLY_AUTHOR_AVATAR': (True, ''), + 'ONLY_FIRST_AVATAR': (False, ''), 'MENUITEM1': ('tune', ''), 'MENUITEM_TEXT1': ('*tune', ''), 'MENUITEM2': ('geo', ''), 'MENUITEM_TEXT2': ('*geo', ''), 'MENUITEM3': ('gajim', ''), @@ -143,10 +144,7 @@ class Base(object): self.juick_post_re = re.compile(r'#(\d+)') self.juick_post_comment_re = re.compile(r'#(\d+)/(\d+)') sharp_slash = r'#\d+(\/\d+)?' - if self.plugin.config['ONLY_AUTHOR_AVATAR']: - juick_nick = r'@[a-zA-Z0-9_@\.-]+:' - else: - juick_nick = r'@[a-zA-Z0-9_@:\.-]+' + juick_nick = r'@[a-zA-Z0-9_@:\.-]+' juick_pic = r'http://i\.juick\.com/.+/[0-9-]+\.[JPG|jpg]' interface = gajim.interface interface.sharp_slash_re = re.compile(sharp_slash) @@ -323,14 +321,30 @@ class Base(object): return if gajim.interface.juick_nick_re.match(special_text): # insert juick nick @nickname//// - if not self.plugin.config['SHOW_AVATARS']: - self.textview.plugin_modified = True - return buffer_, iter_, tag = self.get_iter_and_tag('juick_nick') mark = buffer_.create_mark(None, iter_, True) nick = special_text[1:].rstrip(':') buffer_.insert_with_tags(iter_, special_text, tag) # insert avatars + if not self.plugin.config['SHOW_AVATARS']: + self.textview.plugin_modified = True + return + b_nick = buffer_.get_text(buffer_.get_start_iter(), + buffer_.get_iter_at_mark(mark),False) + if self.plugin.config['ONLY_AUTHOR_AVATAR'] and not \ + special_text.endswith(':') and b_nick[-9:] not in ('Subscribed to ' + ): + self.textview.plugin_modified = True + return + if self.plugin.config['ONLY_FIRST_AVATAR']: + if b_nick[-9:] not in ('Reply by ', 'message from ', 'ended by ', + 'Subscribed to '): + if b_nick[-2] != gajim.config.get('after_nickname'): + self.textview.plugin_modified = True + return + elif b_nick[-1] == '\n': + self.textview.plugin_modified = True + return conn = gajim.connections[self.chat_control.account] if not conn.connected: self.textview.plugin_modified = True @@ -608,6 +622,7 @@ class JuickPluginConfigDialog(GajimPluginConfigDialog): self.xml.set_translation_domain('gajim_plugins') self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH, ['vbox1']) self.checkbutton = self.xml.get_object('checkbutton') + self.only_first_avatar = self.xml.get_object('only_first_avatar') self.avatar_size_spinbutton = self.xml.get_object('avatar_size') self.avatar_size_spinbutton.get_adjustment().set_all(20, 10, 32, 1, 10, 0) @@ -625,6 +640,8 @@ class JuickPluginConfigDialog(GajimPluginConfigDialog): def on_run(self): self.checkbutton.set_active(self.plugin.config['SHOW_AVATARS']) + self.only_first_avatar.set_active(self.plugin.config[ + 'ONLY_FIRST_AVATAR']) self.xml.get_object('only_author_avatar').set_active( self.plugin.config['ONLY_AUTHOR_AVATAR']) self.avatar_size_spinbutton.set_value(self.plugin.config['AVATAR_SIZE']) @@ -647,8 +664,9 @@ class JuickPluginConfigDialog(GajimPluginConfigDialog): def on_only_author_ava_toggled(self, checkbutton): self.plugin.config['ONLY_AUTHOR_AVATAR'] = checkbutton.get_active() - for control in self.plugin.controls: - control.create_patterns() + + def on_only_first_avatar_toggled(self, checkbutton): + self.plugin.config['ONLY_FIRST_AVATAR'] = checkbutton.get_active() def avatar_size_value_changed(self, spinbutton): self.plugin.config['AVATAR_SIZE'] = spinbutton.get_value() |