Skip to content

Commit

Permalink
Initial Commit of Twitter Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
wmbest2 committed Apr 23, 2009
1 parent 86db1b5 commit b989edf
Show file tree
Hide file tree
Showing 4 changed files with 349 additions and 4 deletions.
19 changes: 15 additions & 4 deletions ProtocolChecker/src/plugins/TwitterCheck.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,16 +6,27 @@


import twitter import twitter
import Plugin import Plugin
import TwitterCheckUI


class TwitterCheck( Plugin.Plugin ): class TwitterCheck( Plugin.Plugin ):
def twitterFeed( uid, password ): def check(self):
api = twitter.Api( username = uid, password = password ) if self.counter == self.ui.get_update():
friend_timeline = api.GetFriendsTimeline( uid ) self.counter = 0
self.update()
else:
self.counter += 15000
def update( self ):

api = twitter.Api( username = ui.get_username, password = ui.get_password )
friend_timeline = api.GetFriendsTimeline( username, None, None, None, None )


return friend_timeline return trigger_alert( friend_timeline )


def show( self ): def show( self ):
self.ui.show( )
return return


def __init__( self ): def __init__( self ):
self.ui = TwitterCheckUI.TwitterCheckUI( )
self.counter = 0
return return
247 changes: 247 additions & 0 deletions ProtocolChecker/src/plugins/TwitterCheckUI.glade
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,247 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">

<glade-interface>

<widget class="GtkDialog" id="mainWindow">
<property name="border_width">5</property>
<property name="title" translatable="yes">Gmail Checker</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="default_width">320</property>
<property name="default_height">160</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_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
<property name="urgency_hint">False</property>
<property name="has_separator">False</property>

<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>

<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>

<child>
<widget class="GtkButton" id="button1">
<property name="can_focus">True</property>
<property name="label" translatable="yes">Reset Count</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">0</property>
</widget>
</child>

<child>
<widget class="GtkButton" id="cmdLogin">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-connect</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">0</property>
<signal name="clicked" handler="on_cmdLogin_clicked"/>
</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="GtkTable" id="table1">
<property name="visible">True</property>
<property name="n_rows">3</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="GtkEntry" id="txtUsername">
<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>
</packing>
</child>

<child>
<widget class="GtkAlignment" id="alignment1">
<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">0</property>
<property name="right_padding">0</property>

<child>
<widget class="GtkEntry" id="txtPassword">
<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>
</child>
</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="GtkComboBox" id="combobox1">
<property name="height_request">30</property>
<property name="visible">True</property>
<property name="items" translatable="yes">1 Minute
5 Minutes
10 Minutes
15 Minutes
20 Minutes
25 Minutes
30 Minutes</property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options">expand</property>
</packing>
</child>

<child>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="label" translatable="yes">Time Increment: </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</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">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>

<child>
<widget class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="label" translatable="yes">Password:</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</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>
</packing>
</child>

<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="label" translatable="yes">Username:</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</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>
</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>
8 changes: 8 additions & 0 deletions ProtocolChecker/src/plugins/TwitterCheckUI.gladep
Original file line number Original file line Diff line number Diff line change
@@ -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>Plugins</name>
<program_name>plugins</program_name>
<gnome_support>FALSE</gnome_support>
</glade-project>
79 changes: 79 additions & 0 deletions ProtocolChecker/src/plugins/TwitterCheckUI.py
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,79 @@
'''
Created on Apr 17, 2009
@author: scott
'''

'''
Created on Apr 15, 2009
@author: scott
'''

import pygtk
pygtk.require( "2.0" )
import gtk
import gtk.glade

import Resources

class TwitterCheckUI:

def get_username( self ):
return self.username

def get_password( self ):
return self.password

def get_update(self):
if self.update == "1 Minute":
return 60000
elif self.update == "5 Minutes":
return 60000 * 5
elif self.update == "10 Minutes":
return 60000 * 10
elif self.update == "15 Minutes":
return 60000 * 15
elif self.update == "20 Minutes":
return 60000 * 20
elif self.update == "30 Minutes":
return 60000 * 30

def on_cmdLogin_clicked( self, widget, data = None ):
self.username = self.txtUsername.get_text( )
self.password = self.txtPassword.get_text( )
self.update = self.txtUpdate.get_active_text( )
self.window.hide( )

def delete_event( self, widget, event, data = None ):
return False

def destroy( self, widget, data = None ):
self.window.hide( )

def connect_ui( self ):

self.username = ''
self.password = ''
self.update = '5 Minutes'

glade = gtk.glade.XML( Resources.get_plugin_asset( "./TwitterCheckUI.glade" ) )
self.txtUsername = glade.get_widget( "txtUsername" )
self.txtPassword = glade.get_widget( "txtPassword" )
self.txtUpdate = glade.get_widget("txtTimeLimit")

self.txtUsername.set_text( self.username )
self.txtPassword.set_text( self.password )
#self.txtUpdate.set_active( 1 )

self.window = glade.get_widget( "mainWindow" )

glade.signal_autoconnect( self )

def show( self ):

self.window.show( )

def __init__( self ):

self.connect_ui( )

0 comments on commit b989edf

Please sign in to comment.