This repository has been archived on 2025-08-18. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
Bungloo/Linux/TentiaWindows.py
Jeena Paradies 12f86ecc20 added pyQt4
2012-11-10 15:46:05 +01:00

113 lines
2.9 KiB
Python

from PyQt4 import QtCore, QtGui, QtWebKit
class Preferences:
def __init__(self, app):
self.app = app
self.window = gtk.Window()
self.window.set_title("Preferences")
self.window.set_position(gtk.WIN_POS_CENTER)
self.window.connect("delete-event", self.quit)
hbox1 = gtk.HBox()
self.window.add(hbox1)
icon = gtk.Image()
pixbuffer = gtk.gdk.pixbuf_new_from_file(self.app.resources_path() + "Icon.png")
scaled_buffer = pixbuffer.scale_simple(150, 150, gtk.gdk.INTERP_BILINEAR)
icon.set_from_pixbuf(scaled_buffer)
hbox1.pack_start(icon, False, False, 20)
fix = gtk.Fixed()
hbox1.pack_start(fix, False, False, 20)
label = gtk.Label("Please enter your entity:")
fix.put(label, 0, 30)
self.entity_entry = gtk.Entry()
self.entity_entry.set_width_chars(36)
fix.put(self.entity_entry, 0, 52)
self.login_button = gtk.Button(label="Login")
self.login_button.connect("clicked", self.on_login_button_clicked)
fix.put(self.login_button, 248, 82)
self.window.show_all()
self.window.hide()
def quit(self, wiget, foo):
self.window.hide()
self.app.quit(self)
def on_login_button_clicked(self, widget):
self.app.login_with_entity(self.entity_entry.get_text())
def show(self):
self.window.show()
def hide(self):
self.window.hide()
class Timeline:
def __init__(self, app, action="home_timeline", title="Tentia"):
self.app = app
self.action = action
self.title = title
self.window = gtk.Window()
self.window.connect("delete-event", self.quit)
self.window.set_title(self.title)
self.window.set_position(gtk.WIN_POS_CENTER)
self.window.set_size_request(390, 650)
scroller = gtk.ScrolledWindow()
self.window.add(scroller)
self.web_view = webkit.WebView()
scroller.add(self.web_view)
def quit(self, widget, foo):
self.window.hide()
self.app.quit(self)
def show(self):
self.window.show()
def hide(self):
self.window.hide()
def init_web_view(self):
self.web_view.connect("load-finished", self.load_finished)
self.web_view.open(self.app.resources_path() + "index.html")
def load_finished(self, widget):
delay = 1
if self.action == "mentions":
delay = 1000
script = "setTimeout(\
function() {\
tentia_instance = new Core('" + self.action + "');\
document.getElementsByTagName('body')[0].appendChild(tentia_instance.body);\
setTimeout(function(){ loadPlugin(controller.pluginURL()) }, 1); }, " + delay + "\
);"
self.web_view.execute_script(script)
class OauthImplementation:
def __init__(self, app):
self.app = app
self.web_view = gtk.WebView()
self.init_web_view()
def init_web_view(self):
self.web_view.connect("load-finished", self.load_finished)
self.web_view.open(self.app.resources_path() + "index_oauth.html")
def load_finished(self, widget):
script = "setTimeout( function() { tentia_oauth = new OauthImplementation(); }, 2);"
self.web_view.execute_script(stript)