Add basic tweepydeck script and glade files

This commit is contained in:
R. Tyler Ballance 2009-11-11 00:28:32 -08:00
parent 1bdc45ed53
commit 59d5bd0e5b
3 changed files with 180 additions and 0 deletions

66
tweepydeck Executable file
View File

@ -0,0 +1,66 @@
#!/usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk
import gtk.glade
import base64
import httplib
import string
import urllib
try:
import json
except ImportError:
import simplejson as json
class TwitterApi(object):
user = None
password = None
def __init__(self, user, password, **kwargs):
self.user = user
self.password = password
def _auth_header(self):
return 'Basic ' + string.strip(base64.encodestring(self.user + ':' + self.password))
def _fetch(self, url):
connection = httplib.HTTPSConnection('twitter.com')
connection.putrequest('GET', url)
connection.putheader('Authorization', self._auth_header())
connection.endheaders()
try:
response = connection.getresponse()
return json.loads(response.read())
finally:
connection.close()
def timeline(self, since_id=None, count=10):
args = {'count' : count}
if since_id:
args['since_id'] = since_id
return self._fetch('/statuses/friends_timeline.json?%s' % urllib.urlencode(args))
class Tweep(object):
widget_tree = None
def destroy(self, widget, data=None):
gtk.main_quit()
def __init__(self):
self.widget_tree = gtk.glade.XML('tweepydeck.glade')
self.window = self.widget_tree.get_widget('TweepMainWindow')
if self.window:
self.window.connect('destroy', self.destroy)
def main(self):
gtk.main()
if __name__ == "__main__":
Tweep().main()
# vim: shiftwidth=4 tabstop=4 expandtab

106
tweepydeck.glade Normal file
View File

@ -0,0 +1,106 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<widget class="GtkWindow" id="TweepMainWindow">
<property name="visible">True</property>
<property name="title" translatable="yes">TweepDeck</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<child>
<widget class="GtkVBox" id="OuterVBox">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="label" translatable="yes">### MENU GOES HERE ###</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="DeckHBox">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">## STATUS GOES HERE ##</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

8
tweepydeck.gladep Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd">
<glade-project>
<name>TweepyDeck</name>
<program_name>tweepydeck</program_name>
<gnome_support>FALSE</gnome_support>
</glade-project>