Sophie

Sophie

distrib > Fedora > 13 > i386 > media > updates-src > by-pkgid > 4fe0eac35e20eb2d09b83f78a19ab835 > files > 5

gwibber-3.0.0.1-2.fc13.src.rpm

diff -up gwibber-2.91.92/gwibber/gwui.py.minimize gwibber-2.91.92/gwibber/gwui.py
--- gwibber-2.91.92/gwibber/gwui.py.minimize	2011-03-24 16:17:30.569113002 -0400
+++ gwibber-2.91.92/gwibber/gwui.py	2011-03-24 16:18:32.829112921 -0400
@@ -1,4 +1,5 @@
-
+# -*- coding: utf-8 -*-
+#
 import os, json, urlparse, util
 import subprocess
 import gtk, gobject, pango, webkit, time, gconf
@@ -1053,6 +1054,14 @@ class InputTextView(gtk.TextView):
       except:
         pass
 
+    # Replace these characters with shorter ones
+    # First field: search for string if this character was entered
+    # Second field: string to search for
+    # Third field: replace with this string
+    self.replacements = [(".", "...", "…"), ("-", "--", "—")]
+    # Keep replacements from triggering themselves
+    self.__replace_lock = False
+
   def get_text(self):
     buf = self.get_buffer()
     return buf.get_text(*buf.get_bounds()).strip()
@@ -1061,8 +1070,11 @@ class InputTextView(gtk.TextView):
     return len(unicode(self.get_text(), "utf-8"))
 
   def on_add_text(self, buf, iter, text, tlen):
+    if not text:
+      return
+
     if self.model.settings["shorten_urls"]:
-      if text and text.startswith("http") and not " " in text \
+      if text.startswith("http") and not " " in text \
           and len(text) > 30:
 
         buf = self.get_buffer()
@@ -1090,6 +1102,26 @@ class InputTextView(gtk.TextView):
         self.shortener.Shorten(text,
             reply_handler=add_shortened,
             error_handler=error_shortened)
+    if self.model.settings["minimize_chars"] and not self.__replace_lock:
+      for entry in self.replacements:
+        if entry[0] in text:
+          buf = self.get_buffer()
+          buf.stop_emission("insert-text")
+          try:
+            self.__replace_lock = True
+            buf.insert(iter, text)
+          finally:
+            self.__replace_lock = False
+
+          # Search the whole buffer in case someone pastes something with the
+          # replacement string as a subset
+          search_iter = buf.get_start_iter()
+          match = search_iter.forward_search(entry[1], 0)
+          while match:
+            buf.delete(match[0], match[1])
+            buf.insert(match[0], entry[2])
+            search_iter = buf.get_start_iter()
+            match = search_iter.forward_search(entry[1], 0)
 
   def set_overlay_text(self, text):
     if not hasattr(self, 'pango_overlay'):
diff -up gwibber-2.91.92/gwibber/microblog/util/const.py.minimize gwibber-2.91.92/gwibber/microblog/util/const.py
--- gwibber-2.91.92/gwibber/microblog/util/const.py.minimize	2011-03-22 12:15:23.000000000 -0400
+++ gwibber-2.91.92/gwibber/microblog/util/const.py	2011-03-24 16:17:30.586113002 -0400
@@ -38,6 +38,7 @@ DEFAULT_SETTINGS = {
   "presence_check": True,
   "show_fullname": True,
   "shorten_urls": True,
+  "minimize_chars": False,
   "urlshorter": "is.gd",
   "reply_append_colon": True,
   "retweet_style": "recycle",
diff -up gwibber-2.91.92/gwibber/preferences.py.minimize gwibber-2.91.92/gwibber/preferences.py
--- gwibber-2.91.92/gwibber/preferences.py.minimize	2011-03-13 11:09:42.000000000 -0400
+++ gwibber-2.91.92/gwibber/preferences.py	2011-03-24 16:17:30.587113002 -0400
@@ -69,6 +69,7 @@ class GwibberPreferences(object):
       "no_notifications",
       "show_fullname",
       "shorten_urls",
+      "minimize_chars",
       "reply_append_colon",
       "global_retweet",
       "interval",
diff -up gwibber-2.91.92/ui/gwibber-preferences-dialog.ui.minimize gwibber-2.91.92/ui/gwibber-preferences-dialog.ui
--- gwibber-2.91.92/ui/gwibber-preferences-dialog.ui.minimize	2011-03-13 11:09:42.000000000 -0400
+++ gwibber-2.91.92/ui/gwibber-preferences-dialog.ui	2011-03-24 16:17:30.587113002 -0400
@@ -396,6 +396,20 @@
                             <property name="n_rows">3</property>
                             <property name="homogeneous">True</property>
                             <child>
+                              <object class="GtkCheckButton" id="minimize_chars">
+                                <property name="label" translatable="yes">Automatically replace common strings with unicode equivalents to minimize characters (e.g. ... replaced with …)</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="top_attach">3</property>
+                                <property name="bottom_attach">4</property>
+                              </packing>
+       	       	       	    </child>
+                            <child>
                               <object class="GtkCheckButton" id="reply_append_colon">
                                 <property name="label" translatable="yes">Append colon to username when replying</property>
                                 <property name="visible">True</property>