Add LoginDialog and move away from command line options

This commit is contained in:
R. Tyler Ballance 2009-11-17 20:55:45 -08:00
parent a232dc04e3
commit 119ba0f186
2 changed files with 257 additions and 25 deletions

View File

@ -5,7 +5,6 @@
import getpass
import logging
import os.path
import string
import time
from optparse import OptionParser
@ -98,13 +97,15 @@ class Tweep(object):
def _status_complete(self, data, **kwargs):
self.statusbar = 'Status last updated at %s' % util.readable_time()
def __init__(self, user, password, searches):
self.api = twitter.TwitterApi(user, password)
self.timelines = []
def login(self, button, **kwargs):
dialog = self.widget_tree.get_widget('LoginDialog')
login_entry = self.widget_tree.get_widget('UsernameEntry')
pass_entry = self.widget_tree.get_widget('PasswordEntry')
user, password = login_entry.get_text(), pass_entry.get_text()
self.api = twitter.TwitterApi(user, password)
self.widget_tree = gtk.glade.XML('tweepydeck.glade')
self.window = self.widget_tree.get_widget('TweepyMainWindow')
self.window.connect('destroy', self.destroy)
self.friends = timeline.Timeline(self.widget_tree.get_widget('FriendsTreeView'), self.api)
self.timelines.append(self.friends)
@ -112,42 +113,45 @@ class Tweep(object):
self.api)
self.timelines.append(self.replies)
if searches:
self.searches = timeline.SearchesTimeline(self.widget_tree.get_widget('SearchTreeView'), self.api, searches)
self.timelines.append(self.searches)
else:
self.widget_tree.get_widget('SearchScrolledWindow').destroy()
#if searches:
# self.searches = timeline.SearchesTimeline(self.widget_tree.get_widget('SearchTreeView'), self.api, searches)
# self.timelines.append(self.searches)
#else:
# self.widget_tree.get_widget('SearchScrolledWindow').destroy()
self.widget_tree.get_widget('SearchScrolledWindow').hide()
for t in self.timelines:
t.start()
dialog.destroy()
def __init__(self, *args, **kwargs):
self.timelines = []
self.widget_tree = gtk.glade.XML('tweepydeck.glade')
self.window = self.widget_tree.get_widget('TweepyMainWindow')
self.window.connect('destroy', self.destroy)
self._events = {
'on_QuitMenuItem_activate' : self.destroy,
'on_AboutMenuItem_activate' : self.show_about,
'on_StatusEntry_key_release_event' : self.status_key,
'on_StatusEntry_key_press_event' : self.status_autocomplete,
'on_LoginCancelButton_clicked' : self.destroy,
'on_LoginOkayButton_clicked' : self.login,
}
self.widget_tree.signal_autoconnect(self._events)
def main(self):
gtk.main()
def main():
op = OptionParser()
op.add_option('-u', '--user', dest='user', help='Your twitter username')
op.add_option('-s', '--searches', default=None, dest='searches',
help='Comma-separated list of searches')
opts, args = op.parse_args()
if not opts.user:
op.print_help()
quit()
password = getpass.getpass('Twitter password for %s: ' % opts.user)
searches = opts.searches and opts.searches.split(',')
Tweep(opts.user, password, searches).main()
Tweep().main()
if __name__ == "__main__":
main()
# vim: shiftwidth=4 tabstop=4 expandtab

View File

@ -300,4 +300,232 @@
<property name="translator_credits" translatable="yes" comments="TRANSLATORS: Replace this string with your names, one name per line.">translator-credits</property>
</widget>
<widget class="GtkDialog" id="LoginDialog">
<property name="visible">True</property>
<property name="title" translatable="yes">Login to TweepyDeck</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">True</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="icon_name">gtk-connect</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_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">True</property>
<property name="has_separator">True</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="LoginDialogOuterVBox">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="LoginDialogActionArea">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="LoginCancelButton">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-6</property>
<signal name="clicked" handler="on_LoginCancelButton_clicked" last_modification_time="Wed, 18 Nov 2009 04:45:50 GMT"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="LoginOkayButton">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-5</property>
<signal name="clicked" handler="on_LoginOkayButton_clicked" last_modification_time="Wed, 18 Nov 2009 04:45:56 GMT"/>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkFrame" id="LoginFrame">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="label_yalign">0.5</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<child>
<widget class="GtkAlignment" id="LoginFrameAlignment">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">12</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">0</property>
<property name="column_spacing">0</property>
<child>
<widget class="GtkLabel" id="UsernameLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Twitter Username:&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</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="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="PasswordLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Twitter Password:&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</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="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="UsernameEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">●</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="PasswordEntry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">False</property>
<property name="max_length">0</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char">●</property>
<property name="activates_default">False</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>
<property name="y_options"></property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="LoginFrameLabel">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Please login to Twitter&lt;/b&gt;</property>
<property name="use_underline">False</property>
<property name="use_markup">True</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="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>