5 # Copyright (C) 2006 Joachim Breitner
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 window = gtk.Window(gtk.WINDOW_TOPLEVEL)
30 window.set_decorated(False)
31 window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"))
34 settings = gtk.settings_get_default()
36 draw = gtk.DrawingArea()
37 draw.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"))
38 draw.set_size_request(400,300)
40 pixmap = gtk.gdk.Pixmap(None, 1, 1, 1)
41 color = gtk.gdk.Color()
42 cursor = gtk.gdk.Cursor(pixmap, pixmap, color, color, 0, 0)
49 return tb.get_text(tb.get_start_iter(), tb.get_end_iter())
52 tb.set_text(" ".join(sys.argv[1:]))
56 quit = gtk.Button(stock=gtk.STOCK_QUIT)
57 quit.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"))
58 quit.connect("clicked",gtk.main_quit)
61 hbox.pack_start(tv, expand=True, fill=True)
62 hbox.pack_start(quit, expand=False,fill=False)
65 vbox.pack_start(draw, expand=True, fill=True)
66 vbox.pack_start(hbox, expand=False, fill=False)
69 font = pango.FontDescription()
70 font.set_family("sans-serif")
71 font.set_size(60*pango.SCALE)
72 layout = draw.create_pango_layout(get_text())
73 layout.set_font_description(font)
74 layout.set_alignment(pango.ALIGN_CENTER)
77 accel = gtk.AccelGroup()
78 key, mod = gtk.accelerator_parse("<Ctrl>Q")
79 accel.connect_group(key, mod, 0, gtk.main_quit)
80 key, mod = gtk.accelerator_parse("Escape")
81 #accel.connect_group(key, mod, 0, gtk.main_quit)
82 #key, mod = gtk.accelerator_parse("<Ctrl>C")
83 accel.connect_group(key, mod, 0, (lambda x,y,z,v: tb.set_text("")))
84 window.add_accel_group(accel)
91 def resize(w=None,rect=None):
93 draw.window.set_cursor(cursor)
94 (w1,h1) = layout.get_pixel_size()
96 (x,y,w2,h2) = draw.get_allocation()
98 s = min ( int (s*w2/w1), int (s*h2/h1) )
100 layout.set_font_description(font)
105 def redraw(w=None,e=None):
106 global need_resize, need_quick
107 if layout.get_text(): # Fails for empty lines :-(
108 gc = draw.get_style().fg_gc[gtk.STATE_NORMAL]
109 (w1,h1) = layout.get_pixel_size()
111 (x,y,w2,h2) = draw.get_allocation()
112 draw.window.draw_layout(gc,(w2-w1)/2,(h2-h1)/2,layout)
116 def hq(q,force=False):
120 settings.set_long_property("gtk-xft-antialias",1,"Hier halt")
122 settings.set_long_property("gtk-xft-antialias",0,"Hier halt")
132 layout.set_text(get_text())
136 draw.connect("configure-event", resize)
137 draw.connect("expose-event", redraw)
138 tb.connect("changed", newtext)