merged other changes.
authormicroft <microft@joker>
Sat, 20 Jun 2009 11:31:03 +0000 (12:31 +0100)
committermicroft <microft@joker>
Sat, 20 Jun 2009 11:31:03 +0000 (12:31 +0100)
gwibber/client.py
gwibber/microblog/__init__.py
gwibber/microblog/pingfm.py
gwibber/microblog/twitter.py

index 25423e1..38923dc 100644 (file)
@@ -203,7 +203,7 @@ class GwibberClient(gtk.Window):
     self.input.connect("populate-popup", self.on_input_context_menu)
     self.input.connect("activate", self.on_input_activate)
     self.input.connect("changed", self.on_input_change)
     self.input.connect("populate-popup", self.on_input_context_menu)
     self.input.connect("activate", self.on_input_activate)
     self.input.connect("changed", self.on_input_change)
-    #self.input.set_max_length(MAX_MESSAGE_LENGTH)
+    self.input.set_max_length(MAX_MESSAGE_LENGTH)
 
     self.cancel_button = gtk.Button(_("Cancel"))
     self.cancel_button.connect("clicked", self.on_cancel_reply)
 
     self.cancel_button = gtk.Button(_("Cancel"))
     self.cancel_button.connect("clicked", self.on_cancel_reply)
@@ -480,7 +480,6 @@ class GwibberClient(gtk.Window):
     self.message_target = None
     self._reply_acct = None
     self.input.set_text("")
     self.message_target = None
     self._reply_acct = None
     self.input.set_text("")
-    self.retweet_target_acct = None
 
   def on_toggle_window_visibility(self, w):
     if self.get_property("visible"):
 
   def on_toggle_window_visibility(self, w):
     if self.get_property("visible"):
@@ -608,22 +607,6 @@ class GwibberClient(gtk.Window):
           query, True, gtk.STOCK_INFO, True)
         self.update([view.get_parent()])
         return True
           query, True, gtk.STOCK_INFO, True)
         self.update([view.get_parent()])
         return True
-      elif uri.startswith("gwibber:retweet"):
-        self.retweet(view.message_store[int(uri.split("/")[-1])])
-        return True
-      elif uri.startswith("gwibber:forward"):
-        self.forward(view.message_store[int(uri.split("/")[-1])])
-        return True
-      elif uri.startswith("gwibber:follow"):
-        id = uri.split("/")[-1]
-        account_id = uri.split("/")[-2]
-        self.client.follow(id, account_id)
-        return True
-      elif uri.startswith("gwibber:unfollow"):
-        account_id = uri.split("/")[-2]
-        user_id = uri.split("/")[-1]
-        self.client.unfollow(user_id, account_id)
-        return True
       elif uri.startswith("gwibber:read"):
         msg = view.message_store[int(uri.split("/")[-1])]
         acct = msg.account
       elif uri.startswith("gwibber:read"):
         msg = view.message_store[int(uri.split("/")[-1])]
         acct = msg.account
@@ -663,7 +646,7 @@ class GwibberClient(gtk.Window):
         if self.input.get_max_length() > MAX_MESSAGE_LENGTH:
           self.input.set_max_length(MAX_MESSAGE_LENGTH)
         self.statusbar.push(1, _("Characters remaining: %s") % (
         if self.input.get_max_length() > MAX_MESSAGE_LENGTH:
           self.input.set_max_length(MAX_MESSAGE_LENGTH)
         self.statusbar.push(1, _("Characters remaining: %s") % (
-        MAX_MESSAGE_LENGTH - i_textlen))
+        self.input.get_max_length() - i_textlen))
 
   def on_theme_change(self, *args):
     for tab in self.tabs:
 
   def on_theme_change(self, *args):
     for tab in self.tabs:
@@ -994,19 +977,14 @@ class GwibberClient(gtk.Window):
         account = self.message_target.account
         if account:
           # temporarily send_enable the account to allow reply to be posted
         account = self.message_target.account
         if account:
           # temporarily send_enable the account to allow reply to be posted
-          old_send_enabled_value = account["send_enabled"] 
+          is_send_enabled = account["send_enabled"]
           account["send_enabled"] = True
           if account.supports(microblog.can.THREAD_REPLY) and hasattr(self.message_target, "id"):
             result = self.client.send_thread(text, self.message_target, [account["protocol"]])
           else:
             result = self.client.reply(text, [account["protocol"]])
           account["send_enabled"] = True
           if account.supports(microblog.can.THREAD_REPLY) and hasattr(self.message_target, "id"):
             result = self.client.send_thread(text, self.message_target, [account["protocol"]])
           else:
             result = self.client.reply(text, [account["protocol"]])
-          account["send_enabled"] = old_send_enabled_value
-      elif self.retweet_target_acct:
-          account = self.retweet_target_acct
-          old_send_enabled_value = account["send_enabled"] 
-          account["send_enabled"] = True
-          result = self.client.send(text, [account["protocol"],] )
-          account["send_enabled"] = old_send_enabled_value
+          # restore send_enabled choice after replying
+          account["send_enabled"] = is_send_enabled
       # else standard post
       else:
         result = self.client.send(text, list(microblog.PROTOCOLS.keys()))
       # else standard post
       else:
         result = self.client.send(text, list(microblog.PROTOCOLS.keys()))
index bf88b40..2fedb5a 100644 (file)
@@ -142,10 +142,3 @@ class Client:
       # Translators: this message appears in the Errors dialog
       # Indicates with wich action the error happened       
       lambda c: c.group(query.lower().replace("!", "")), _("perform group query"), filter)
       # Translators: this message appears in the Errors dialog
       # Indicates with wich action the error happened       
       lambda c: c.group(query.lower().replace("!", "")), _("perform group query"), filter)
-
-  def unfollow(self, id, account_id, filter=list(PROTOCOLS.keys())):
-    return list(self.get_data(
-      lambda a: a.id == account_id,
-      lambda c: c.unfollow(id), "unfollow %s" % (id,) , filter, False))
-
-
index 0b51abb..e05b06f 100644 (file)
@@ -33,7 +33,7 @@ class Client:
 
   def connect(self, url, data = None):
     data.update({"api_key": API_KEY, "user_app_key": self.account["private:app_key"]})
 
   def connect(self, url, data = None):
     data.update({"api_key": API_KEY, "user_app_key": self.account["private:app_key"]})
-    return urllib2.urlopen(urllib2.Request(url, urllib.urlencode(data))).read() 
+    urllib2.urlopen(urllib2.Request(url, urllib.urlencode(data))).read()
 
   def send(self, message):
     return self.connect("http://api.ping.fm/v1/user.post",
 
   def send(self, message):
     return self.connect("http://api.ping.fm/v1/user.post",
index 64f6404..dce3175 100644 (file)
@@ -58,12 +58,6 @@ class Message:
     self.time = support.parse_time(data["created_at"])
     self.is_private  = False
 
     self.time = support.parse_time(data["created_at"])
     self.is_private  = False
 
-    self.can_retweet = True
-
-    try:
-      self.source = data["source"]
-    except: pass
-
     if "user" in data:
       user = data["user"]
       self.reply_nick = data["in_reply_to_screen_name"]
     if "user" in data:
       user = data["user"]
       self.reply_nick = data["in_reply_to_screen_name"]
@@ -130,7 +124,6 @@ class SearchResult:
     self.url = "https://twitter.com/%s/statuses/%s" % (data["from_user"], data["id"])
     self.profile_url = "gwibber:user/%s/%s" % (self.account.id, data["from_user"])
     self.external_profile_url = "https://twitter.com/%s" % data["from_user"]
     self.url = "https://twitter.com/%s/statuses/%s" % (data["from_user"], data["id"])
     self.profile_url = "gwibber:user/%s/%s" % (self.account.id, data["from_user"])
     self.external_profile_url = "https://twitter.com/%s" % data["from_user"]
-    self.can_retweet = True
 
     if query: html = support.highlight_search_results(self.text, query)
     else: html = self.text
 
     if query: html = support.highlight_search_results(self.text, query)
     else: html = self.text
@@ -167,13 +160,13 @@ class Client:
   def get_messages(self):
     return simplejson.loads(self.connect(
       "https://twitter.com/statuses/friends_timeline.json" +'?'+
   def get_messages(self):
     return simplejson.loads(self.connect(
       "https://twitter.com/statuses/friends_timeline.json" +'?'+
-      urllib.urlencode({"count": self.account["receive_count"] or "20"})))
+      urllib.urlencode({"count": self.account["receive_count"] or "50"})))
 
   def get_user_messages(self, screen_name):
     try:
       return simplejson.loads(self.connect(
         "https://twitter.com/statuses/user_timeline/"+ screen_name + ".json" +'?'+
 
   def get_user_messages(self, screen_name):
     try:
       return simplejson.loads(self.connect(
         "https://twitter.com/statuses/user_timeline/"+ screen_name + ".json" +'?'+
-          urllib.urlencode({"count": self.account["receive_count"] or "20"})))
+          urllib.urlencode({"count": self.account["receive_count"] or "50"})))
     except Exception:
       profile = [simplejson.loads(self.connect(
         "https://twitter.com/users/show/"+ screen_name +".json"))]
     except Exception:
       profile = [simplejson.loads(self.connect(
         "https://twitter.com/users/show/"+ screen_name +".json"))]
@@ -182,7 +175,7 @@ class Client:
   def get_replies(self):
     return simplejson.loads(self.connect(
       "https://twitter.com/statuses/replies.json" +'?'+
   def get_replies(self):
     return simplejson.loads(self.connect(
       "https://twitter.com/statuses/replies.json" +'?'+
-        urllib.urlencode({"count": self.account["receive_count"] or "20"})))
+        urllib.urlencode({"count": self.account["receive_count"] or "50"})))
 
   def get_direct_messages(self):
     return simplejson.loads(self.connect(
 
   def get_direct_messages(self):
     return simplejson.loads(self.connect(
@@ -245,22 +238,3 @@ class Client:
           "in_reply_to_status_id":target.id, "source": "gwibbernet"})))
     return Message(self, data)
 
           "in_reply_to_status_id":target.id, "source": "gwibbernet"})))
     return Message(self, data)
 
-  #def amfollowing(self, id):
-  #  data = simplejson.loads(self.connect(
-  #      "https://twitter.com/friendships/exists.json",
-  #      urllib.urlencode( { "id" : id ,} )))
-
-  def follow(self, id):
-    data = simplejson.loads(self.connect(
-        "https://twitter.com/friendships/create/%s.json" % id,
-        urllib.urlencode( { } )))
-    return True
-
-  def unfollow(self, id):
-    data = simplejson.loads(self.connect(
-        "https://twitter.com/friendships/destroy/%s.json" % id,
-        urllib.urlencode( { } )))
-    return True
-
-
-