Merge with trunk done.
authordanigm <dani@danigm.net>
Wed, 8 Jul 2009 15:07:32 +0000 (17:07 +0200)
committerdanigm <dani@danigm.net>
Wed, 8 Jul 2009 15:07:32 +0000 (17:07 +0200)
Sweetter public timeline added.
Sweetter messages fixed.

1  2 
gwibber/gwui.py
gwibber/microblog/__init__.py
gwibber/microblog/support/__init__.py
gwibber/microblog/sweetter.py
ui/preferences.glade

diff --cc gwibber/gwui.py
Simple merge
@@@ -1,9 -1,9 +1,9 @@@
  
  import operator, traceback 
  from . import can
- from . import twitter, jaiku, identica, laconica, pownce, friendfeed, sweetter
+ from . import twitter, jaiku, identica, laconica, pownce, friendfeed
  from . import digg, flickr, brightkite, rss, pingfm, facebook
- from . import greader
 -from . import greader, qaiku
++from . import greader, qaiku, sweetter
  
  # i18n magic
  import gettext
@@@ -24,7 -24,7 +24,8 @@@ PROTOCOLS = 
    "pingfm": pingfm,
    "greader": greader,
    "brightkite": brightkite,
+   "qaiku": qaiku,
 +  "sweetter": sweetter,
  }
  
  def supports(a, feature):
Simple merge
index 7dbf0c4,0000000..2ab40de
mode 100644,000000..100644
--- /dev/null
@@@ -1,111 -1,0 +1,122 @@@
-     return self.sweetter.get_last_comments("index")
 +
 +"""
 +
 +Sweetterinterface for Gwibber
 +J. Felix Ontanon - 11/06/2009
 +
 +"""
 +
 +from . import can, support
 +import time, re, mx.DateTime
 +
 +PROTOCOL_INFO = {
 +  "name": "Sweetter",
 +  "version": 0.1,
 +  
 +  "config": [
 +    "private:password",
 +    "username",
 +    "message_color",
 +    "receive_enabled",
 +    "send_enabled",
 +    "receive_count",
++    "public_enabled",
 +  ],
 +
 +  "features": [
 +    can.SEND,
 +    can.RECEIVE,
 +    can.REPLY,
 +    can.RESPONSES,
 +    can.RETWEET,
 +    can.USER_MESSAGES,
++    can.PUBLIC,
 +  ],
 +}
 +
 +NICK_PARSE = re.compile("\B@([A-Za-z0-9_]+|@[A-Za-z0-9_]$)")
 +HASH_PARSE = re.compile("\B#([A-Za-z0-9_\-]+|@[A-Za-z0-9_\-]$)")
 +
 +class Message:
 +  def __init__(self, client, data):
 +   def local_to_utc(localdate):
 +     utcdate = time.gmtime(time.mktime(localdate.timetuple()))
 +     return mx.DateTime.DateTime(utcdate.tm_year, utcdate.tm_mon, 
 +                   utcdate.tm_mday, utcdate.tm_hour, utcdate.tm_min,
 +                   utcdate.tm_sec)
 +   try:
 +    self.client = client
 +    self.account = client.account
 +    self.protocol = client.account["protocol"]
 +    self.username = client.account["username"]
 +    self.bgcolor = "message_color"
 +    self.time = local_to_utc(data.created)
 +
 +    self.sender = data.user
 +    self.sender_nick = data.user
 +    self.image = data.avatar
 +    self.url = "http://sweetter.net/" + data.user
 +    self.profile_url = "gwibber:user/%s/%s" % (self.account.id, data.user)
 +    self.external_profile_url = self.url 
 +    self.text = data.sweet
 +    self.html_string = '<span class="text">%s</span>' % \
 +        HASH_PARSE.sub('#<a class="inlinehash" href="gwibber:tag/\\1">\\1</a>', 
 +          NICK_PARSE.sub('@<a class="inlinenick" href="gwibber:user/'+self.account.id+'/\\1">\\1</a>', 
 +          support.linkify(self.text)))
 +    self.is_reply = re.compile("@%s[\W]+|@%s$" % (self.username, self.username)).search(self.text)
 +    self.reply_nick = ''
 +    self.reply_url = ''
 +   except Exception:
 +    from traceback import format_exc
 +    print(format_exc())
 +
 +class Client:
 +  def __init__(self, acct):
 +    self.account = acct
 +    self.sweetter = support.pysweetter.Sweetter(apikey=self.account['private:password'])
 +
 +  def send_enabled(self):
 +    return self.account["send_enabled"] and \
 +      self.account["username"] != None and \
 +      self.account["private:password"] != None
 +
 +  def receive_enabled(self):
 +    return self.account["receive_enabled"] and \
 +      self.account["username"] != None and \
 +      self.account["private:password"] != None
 +
 +  def connect(self, url, data = None):
 +    self.sweetter.autenticate(self.account['private:password'])
 +
 +  def get_messages(self):
++    return self.sweetter.get_last_followings(self.account['username'])
 +
 +  def get_user_messages(self, screen_name):
 +    return self.sweetter.get_last_comments(screen_name)
 +
 +  def get_replies(self):
 +    return self.sweetter.get_replies(self.account["username"])
 +
 +  def responses(self):
 +    for data in self.get_replies():
 +      yield Message(self, data)
 +
 +  def receive(self):
 +    for data in self.get_messages():
 +      yield Message(self, data)
 +
 +  def user_messages(self, screen_name):
 +    for data in self.get_user_messages(screen_name):
 +      yield Message(self, data)
 +
 +  def send(self, message):
 +    self.sweetter.post(message)
++
++  def public_enabled(self):
++    return self.account["public_enabled"] and \
++      self.account["username"] != None and \
++      self.account["private:password"] != None
++
++  def public_timeline(self):
++      for data in self.sweetter.get_last_comments("index"):
++          yield Message(self, data) 
@@@ -4340,266 -4379,285 +4379,548 @@@ a Gwibber login code from Facebook.</pr
        </widget>
      </child>
    </widget>
+   <widget class="GtkDialog" id="dialog_qaiku">
+     <property name="border_width">5</property>
+     <property name="window_position">center-on-parent</property>
+     <property name="type_hint">dialog</property>
+     <child internal-child="vbox">
+       <widget class="GtkVBox" id="dialog-vbox20">
+         <property name="visible">True</property>
+         <property name="orientation">vertical</property>
+         <property name="spacing">2</property>
+         <child>
+           <widget class="GtkVBox" id="vbox10">
+             <property name="visible">True</property>
+             <property name="orientation">vertical</property>
+             <property name="spacing">10</property>
+             <child>
+               <widget class="GtkFrame" id="frameAccount3">
+                 <property name="visible">True</property>
+                 <property name="label_xalign">0</property>
+                 <property name="shadow_type">none</property>
+                 <child>
+                   <widget class="GtkAlignment" id="alignment14">
+                     <property name="visible">True</property>
+                     <property name="top_padding">10</property>
+                     <property name="left_padding">12</property>
+                     <child>
+                       <widget class="GtkTable" id="table5">
+                         <property name="visible">True</property>
+                         <property name="n_rows">2</property>
+                         <property name="n_columns">2</property>
+                         <property name="column_spacing">5</property>
+                         <property name="row_spacing">5</property>
+                         <child>
+                           <widget class="GtkEntry" id="qaiku_password">
+                             <property name="visible">True</property>
+                             <property name="can_focus">True</property>
+                             <property name="visibility">False</property>
+                             <property name="invisible_char">&#x2022;</property>
+                           </widget>
+                           <packing>
+                             <property name="left_attach">1</property>
+                             <property name="right_attach">2</property>
+                             <property name="top_attach">1</property>
+                             <property name="bottom_attach">2</property>
+                           </packing>
+                         </child>
+                         <child>
+                           <widget class="GtkEntry" id="qaiku_username">
+                             <property name="visible">True</property>
+                             <property name="can_focus">True</property>
+                             <property name="invisible_char">&#x2022;</property>
+                           </widget>
+                           <packing>
+                             <property name="left_attach">1</property>
+                             <property name="right_attach">2</property>
+                           </packing>
+                         </child>
+                         <child>
+                           <widget class="GtkLabel" id="label25">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">Password:</property>
+                           </widget>
+                           <packing>
+                             <property name="top_attach">1</property>
+                             <property name="bottom_attach">2</property>
+                           </packing>
+                         </child>
+                         <child>
+                           <widget class="GtkLabel" id="label26">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">Username:</property>
+                           </widget>
+                         </child>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
+                 <child>
+                   <widget class="GtkLabel" id="label28">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">&lt;b&gt;Account Information&lt;/b&gt;</property>
+                     <property name="use_markup">True</property>
+                   </widget>
+                   <packing>
+                     <property name="type">label_item</property>
+                   </packing>
+                 </child>
+               </widget>
+               <packing>
+                 <property name="expand">False</property>
+                 <property name="position">0</property>
+               </packing>
+             </child>
+             <child>
+               <placeholder/>
+             </child>
+             <child>
+               <placeholder/>
+             </child>
+             <child>
+               <widget class="GtkFrame" id="frameStatus3">
+                 <property name="visible">True</property>
+                 <property name="label_xalign">0</property>
+                 <property name="shadow_type">none</property>
+                 <child>
+                   <widget class="GtkAlignment" id="alignment15">
+                     <property name="visible">True</property>
+                     <property name="top_padding">10</property>
+                     <property name="left_padding">12</property>
+                     <child>
+                       <widget class="GtkVBox" id="vbox11">
+                         <property name="visible">True</property>
+                         <property name="orientation">vertical</property>
+                         <child>
+                           <widget class="GtkCheckButton" id="qaiku_receive_enabled">
+                             <property name="label" translatable="yes">_Receive Messages</property>
+                             <property name="visible">True</property>
+                             <property name="can_focus">True</property>
+                             <property name="receives_default">False</property>
+                             <property name="use_underline">True</property>
+                             <property name="draw_indicator">True</property>
+                           </widget>
+                           <packing>
+                             <property name="position">0</property>
+                           </packing>
+                         </child>
+                         <child>
+                           <widget class="GtkCheckButton" id="qaiku_send_enabled">
+                             <property name="label" translatable="yes">_Send Messages</property>
+                             <property name="visible">True</property>
+                             <property name="can_focus">True</property>
+                             <property name="receives_default">False</property>
+                             <property name="use_underline">True</property>
+                             <property name="draw_indicator">True</property>
+                           </widget>
+                           <packing>
+                             <property name="position">1</property>
+                           </packing>
+                         </child>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
+                 <child>
+                   <widget class="GtkLabel" id="label29">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">&lt;b&gt;Account Status&lt;/b&gt;</property>
+                     <property name="use_markup">True</property>
+                   </widget>
+                   <packing>
+                     <property name="type">label_item</property>
+                   </packing>
+                 </child>
+               </widget>
+               <packing>
+                 <property name="expand">False</property>
+                 <property name="position">3</property>
+               </packing>
+             </child>
+             <child>
+               <widget class="GtkFrame" id="frameAppearance3">
+                 <property name="visible">True</property>
+                 <property name="label_xalign">0</property>
+                 <property name="shadow_type">none</property>
+                 <child>
+                   <widget class="GtkAlignment" id="alignment16">
+                     <property name="visible">True</property>
+                     <property name="top_padding">10</property>
+                     <property name="left_padding">12</property>
+                     <child>
+                       <widget class="GtkTable" id="table13">
+                         <property name="visible">True</property>
+                         <property name="n_rows">2</property>
+                         <property name="n_columns">2</property>
+                         <child>
+                           <widget class="GtkLabel" id="label30">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">Message Color:</property>
+                           </widget>
+                         </child>
+                         <child>
+                           <widget class="GtkLabel" id="label62">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">Comment Color:</property>
+                           </widget>
+                           <packing>
+                             <property name="top_attach">1</property>
+                             <property name="bottom_attach">2</property>
+                           </packing>
+                         </child>
+                         <child>
+                           <widget class="GtkColorButton" id="qaiku_message_color">
+                             <property name="visible">True</property>
+                             <property name="can_focus">True</property>
+                             <property name="receives_default">True</property>
+                             <property name="color">#000000000000</property>
+                           </widget>
+                           <packing>
+                             <property name="left_attach">1</property>
+                             <property name="right_attach">2</property>
+                           </packing>
+                         </child>
+                         <child>
+                           <widget class="GtkColorButton" id="qaiku_comment_color">
+                             <property name="visible">True</property>
+                             <property name="can_focus">True</property>
+                             <property name="receives_default">True</property>
+                             <property name="color">#000000000000</property>
+                           </widget>
+                           <packing>
+                             <property name="left_attach">1</property>
+                             <property name="right_attach">2</property>
+                             <property name="top_attach">1</property>
+                             <property name="bottom_attach">2</property>
+                           </packing>
+                         </child>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
+                 <child>
+                   <widget class="GtkLabel" id="label31">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">&lt;b&gt;Appearance&lt;/b&gt;</property>
+                     <property name="use_markup">True</property>
+                   </widget>
+                   <packing>
+                     <property name="type">label_item</property>
+                   </packing>
+                 </child>
+               </widget>
+               <packing>
+                 <property name="expand">False</property>
+                 <property name="position">4</property>
+               </packing>
+             </child>
+           </widget>
+           <packing>
+             <property name="position">1</property>
+           </packing>
+         </child>
+         <child internal-child="action_area">
+           <widget class="GtkHButtonBox" id="dialog-action_area20">
+             <property name="visible">True</property>
+             <child>
+               <widget class="GtkButton" id="qaiku_btndelete">
+                 <property name="label">gtk-delete</property>
+                 <property name="visible">True</property>
+                 <property name="can_focus">True</property>
+                 <property name="receives_default">True</property>
+                 <property name="use_stock">True</property>
+               </widget>
+               <packing>
+                 <property name="expand">False</property>
+                 <property name="fill">False</property>
+                 <property name="position">0</property>
+               </packing>
+             </child>
+             <child>
+               <widget class="GtkButton" id="qaiku_btnclose">
+                 <property name="label">gtk-close</property>
+                 <property name="visible">True</property>
+                 <property name="can_focus">True</property>
+                 <property name="receives_default">True</property>
+                 <property name="use_stock">True</property>
+               </widget>
+               <packing>
+                 <property name="expand">False</property>
+                 <property name="fill">False</property>
+                 <property name="position">1</property>
+               </packing>
+             </child>
+           </widget>
+           <packing>
+             <property name="expand">False</property>
+             <property name="pack_type">end</property>
+             <property name="position">0</property>
+           </packing>
+         </child>
+       </widget>
+     </child>
+   </widget>
++
 +  <widget class="GtkDialog" id="dialog_sweetter">
 +    <property name="border_width">5</property>
 +    <property name="window_position">center-on-parent</property>
 +    <property name="type_hint">dialog</property>
 +    <child internal-child="vbox">
 +      <widget class="GtkVBox" id="dialog-vbox18">
 +        <property name="visible">True</property>
 +        <property name="spacing">2</property>
 +        <child>
 +          <widget class="GtkVBox" id="vbox10">
 +            <property name="visible">True</property>
 +            <property name="orientation">vertical</property>
 +            <property name="spacing">10</property>
 +            <child>
 +              <widget class="GtkFrame" id="frameAccount3">
 +                <property name="visible">True</property>
 +                <property name="label_xalign">0</property>
 +                <property name="shadow_type">none</property>
 +                <child>
 +                  <widget class="GtkAlignment" id="alignment14">
 +                    <property name="visible">True</property>
 +                    <property name="top_padding">10</property>
 +                    <property name="left_padding">12</property>
 +                    <child>
 +                      <widget class="GtkTable" id="table5">
 +                        <property name="visible">True</property>
 +                        <property name="n_rows">2</property>
 +                        <property name="n_columns">2</property>
 +                        <property name="column_spacing">5</property>
 +                        <property name="row_spacing">5</property>
 +                        <child>
 +                          <widget class="GtkEntry" id="sweetter_password">
 +                            <property name="visible">True</property>
 +                            <property name="can_focus">True</property>
 +                            <property name="visibility">False</property>
 +                            <property name="invisible_char">&#x25CF;</property>
 +                          </widget>
 +                          <packing>
 +                            <property name="left_attach">1</property>
 +                            <property name="right_attach">2</property>
 +                            <property name="top_attach">1</property>
 +                            <property name="bottom_attach">2</property>
 +                          </packing>
 +                        </child>
 +                        <child>
 +                          <widget class="GtkEntry" id="sweetter_username">
 +                            <property name="visible">True</property>
 +                            <property name="can_focus">True</property>
 +                            <property name="invisible_char">&#x25CF;</property>
 +                          </widget>
 +                          <packing>
 +                            <property name="left_attach">1</property>
 +                            <property name="right_attach">2</property>
 +                          </packing>
 +                        </child>
 +                        <child>
 +                          <widget class="GtkLabel" id="label25">
 +                            <property name="visible">True</property>
 +                            <property name="label" translatable="yes">API key:</property>
 +                          </widget>
 +                          <packing>
 +                            <property name="top_attach">1</property>
 +                            <property name="bottom_attach">2</property>
 +                          </packing>
 +                        </child>
 +                        <child>
 +                          <widget class="GtkLabel" id="label26">
 +                            <property name="visible">True</property>
 +                            <property name="label" translatable="yes">Username:</property>
 +                          </widget>
 +                        </child>
 +                      </widget>
 +                    </child>
 +                  </widget>
 +                </child>
 +                <child>
 +                  <widget class="GtkLabel" id="label28">
 +                    <property name="visible">True</property>
 +                    <property name="label" translatable="yes">&lt;b&gt;Account Information&lt;/b&gt;</property>
 +                    <property name="use_markup">True</property>
 +                  </widget>
 +                  <packing>
 +                    <property name="type">label_item</property>
 +                  </packing>
 +                </child>
 +              </widget>
 +              <packing>
 +                <property name="expand">False</property>
 +                <property name="position">0</property>
 +              </packing>
 +            </child>
 +            <child>
 +              <widget class="GtkLinkButton" id="sweetter_linkbutton">
 +                <property name="label" translatable="yes">Get Sweetter API key</property>
 +                <property name="visible">True</property>
 +                <property name="can_focus">True</property>
 +                <property name="receives_default">True</property>
 +                <property name="relief">none</property>
 +                <property name="uri">http://sweetter.net/edit_profile</property>
 +              </widget>
 +              <packing>
 +                <property name="position">1</property>
 +              </packing>
 +            </child>
 +            <child>
 +              <widget class="GtkFrame" id="frameStatus3">
 +                <property name="visible">True</property>
 +                <property name="label_xalign">0</property>
 +                <property name="shadow_type">none</property>
 +                <child>
 +                  <widget class="GtkAlignment" id="alignment15">
 +                    <property name="visible">True</property>
 +                    <property name="top_padding">10</property>
 +                    <property name="left_padding">12</property>
 +                    <child>
 +                      <widget class="GtkVBox" id="vbox11">
 +                        <property name="visible">True</property>
 +                        <property name="orientation">vertical</property>
 +                        <child>
 +                          <widget class="GtkCheckButton" id="sweetter_receive_enabled">
 +                            <property name="label" translatable="yes">_Receive Messages</property>
 +                            <property name="visible">True</property>
 +                            <property name="can_focus">True</property>
 +                            <property name="receives_default">False</property>
 +                            <property name="use_underline">True</property>
 +                            <property name="draw_indicator">True</property>
 +                          </widget>
 +                          <packing>
 +                            <property name="position">0</property>
 +                          </packing>
 +                        </child>
 +                        <child>
 +                          <widget class="GtkCheckButton" id="sweetter_send_enabled">
 +                            <property name="label" translatable="yes">_Send Messages</property>
 +                            <property name="visible">True</property>
 +                            <property name="can_focus">True</property>
 +                            <property name="receives_default">False</property>
 +                            <property name="use_underline">True</property>
 +                            <property name="draw_indicator">True</property>
 +                          </widget>
 +                          <packing>
 +                            <property name="position">1</property>
 +                          </packing>
 +                        </child>
 +                      </widget>
 +                    </child>
 +                  </widget>
 +                </child>
 +                <child>
 +                  <widget class="GtkLabel" id="label29">
 +                    <property name="visible">True</property>
 +                    <property name="label" translatable="yes">&lt;b&gt;Account Status&lt;/b&gt;</property>
 +                    <property name="use_markup">True</property>
 +                  </widget>
 +                  <packing>
 +                    <property name="type">label_item</property>
 +                  </packing>
 +                </child>
 +              </widget>
 +              <packing>
 +                <property name="expand">False</property>
 +                <property name="position">2</property>
 +              </packing>
 +            </child>
 +            <child>
 +              <widget class="GtkFrame" id="frameAppearance3">
 +                <property name="visible">True</property>
 +                <property name="label_xalign">0</property>
 +                <property name="shadow_type">none</property>
 +                <child>
 +                  <widget class="GtkAlignment" id="alignment16">
 +                    <property name="visible">True</property>
 +                    <property name="top_padding">10</property>
 +                    <property name="left_padding">12</property>
 +                    <child>
 +                      <widget class="GtkTable" id="table13">
 +                        <property name="visible">True</property>
 +                        <property name="n_columns">2</property>
 +                        <child>
 +                          <widget class="GtkLabel" id="label30">
 +                            <property name="visible">True</property>
 +                            <property name="label" translatable="yes">Message Color:</property>
 +                          </widget>
 +                        </child>
 +                        <child>
 +                          <widget class="GtkColorButton" id="sweetter_message_color">
 +                            <property name="visible">True</property>
 +                            <property name="can_focus">True</property>
 +                            <property name="receives_default">True</property>
 +                            <property name="color">#000000000000</property>
 +                          </widget>
 +                          <packing>
 +                            <property name="left_attach">1</property>
 +                            <property name="right_attach">2</property>
 +                          </packing>
 +                        </child>
 +                      </widget>
 +                    </child>
 +                  </widget>
 +                </child>
 +                <child>
 +                  <widget class="GtkLabel" id="label31">
 +                    <property name="visible">True</property>
 +                    <property name="label" translatable="yes">&lt;b&gt;Appearance&lt;/b&gt;</property>
 +                    <property name="use_markup">True</property>
 +                  </widget>
 +                  <packing>
 +                    <property name="type">label_item</property>
 +                  </packing>
 +                </child>
 +              </widget>
 +              <packing>
 +                <property name="expand">False</property>
 +                <property name="position">3</property>
 +              </packing>
 +            </child>
 +          </widget>
 +          <packing>
 +            <property name="position">1</property>
 +          </packing>
 +        </child>
 +        <child internal-child="action_area">
 +          <widget class="GtkHButtonBox" id="dialog-action_area18">
 +            <property name="visible">True</property>
 +            <child>
 +              <widget class="GtkButton" id="sweetter_btndelete">
 +                <property name="label">gtk-delete</property>
 +                <property name="visible">True</property>
 +                <property name="can_focus">True</property>
 +                <property name="receives_default">True</property>
 +                <property name="use_stock">True</property>
 +              </widget>
 +              <packing>
 +                <property name="expand">False</property>
 +                <property name="fill">False</property>
 +                <property name="position">0</property>
 +              </packing>
 +            </child>
 +            <child>
 +              <widget class="GtkButton" id="sweetter_btnclose">
 +                <property name="label">gtk-close</property>
 +                <property name="visible">True</property>
 +                <property name="can_focus">True</property>
 +                <property name="receives_default">True</property>
 +                <property name="use_stock">True</property>
 +              </widget>
 +              <packing>
 +                <property name="expand">False</property>
 +                <property name="fill">False</property>
 +                <property name="position">1</property>
 +              </packing>
 +            </child>
 +          </widget>
 +          <packing>
 +            <property name="expand">False</property>
 +            <property name="pack_type">end</property>
 +            <property name="position">0</property>
 +          </packing>
 +        </child>
 +      </widget>
 +    </child>
 +  </widget>
  </glade-interface>