summaryrefslogtreecommitdiff
path: root/gtk-recordmydesktop/src/rmdFrame.py
blob: f5187e456bad52825e77c8924f039ae1ef391d17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#/*********************************************************************************
#*                         gtk-recordMyDesktop                                    *
#**********************************************************************************
#*                                                                                *
#*             Copyright (C) 2006  John Varouhakis                                *
#*                                                                                *
#*                                                                                *
#*    This program is free software; you can redistribute it and/or modify        *
#*    it under the terms of the GNU General Public License as published by        *
#*    the Free Software Foundation; either version 2 of the License, or           *
#*    (at your option) any later version.                                         *
#*                                                                                *
#*    This program is distributed in the hope that it will be useful,             *
#*    but WITHOUT ANY WARRANTY; without even the implied warranty of              *
#*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
#*    GNU General Public License for more details.                                *
#*                                                                                *
#*    You should have received a copy of the GNU General Public License           *
#*    along with this program; if not, write to the Free Software                 *
#*    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   *
#*                                                                                *
#*                                                                                *
#*                                                                                *
#*    For further information contact me at johnvarouhakis@gmail.com              *
#**********************************************************************************/
import pygtk
pygtk.require('2.0')
import gtk

class rmdFrame:
    borderwidth=6
    outlinewidth=1

    def __init__(self,x,y,w,h):
        self.window=gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.area=gtk.DrawingArea()
        self.x=x
        self.y=y
        self.w=w
        self.h=h

        mask = gtk.gdk.Pixmap(None,
                              self.w+self.borderwidth*2,
                              self.h+self.borderwidth*2,
                              1)
        gc = mask.new_gc()
        gc.foreground = gtk.gdk.Color(0,0,0,1)
        mask.draw_rectangle(gc,True,0,0,
                            self.w+self.borderwidth*2,
                            self.h+self.borderwidth*2)
        gc.foreground = gtk.gdk.Color(0, 0, 0, 0)
        mask.draw_rectangle(gc,True,
                            self.borderwidth,
                            self.borderwidth,
                            self.w,self.h)

        self.area.show()
        self.window.stick()
        self.window.set_keep_above(True)
        self.area.connect("expose-event", self.__expose_cb)
        self.window.shape_combine_mask(mask,0,0)
        self.window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DOCK)
        self.window.set_title("gtk-recordMyDesktop frame")
        self.window.stick()
        self.window.set_keep_above(True)
        self.window.add(self.area)
        self.window.show()

        self.window.set_size_request(self.w+self.borderwidth*2,
                                     self.h+self.borderwidth*2)
        self.window.move(self.x-self.borderwidth,
                         self.y-self.borderwidth)
        self.window.set_resizable(False)


    def __expose_cb(self, widget, event):
        if widget==self.area:
            self.area.window.draw_rectangle(self.window.style.white_gc,
                                            True,0,0,self.w+self.borderwidth*2,
                                            self.h+self.borderwidth*2)
            self.area.window.draw_rectangle(self.window.style.black_gc,
                                            True,self.outlinewidth,
                                            self.outlinewidth,
                                            self.w+(self.borderwidth-
                                                    self.outlinewidth)*2,
                                            self.h+(self.borderwidth-
                                                    self.outlinewidth)*2)
            self.area.window.draw_rectangle(self.window.style.white_gc,
                                            True,
                                            self.borderwidth-self.outlinewidth,
                                            self.borderwidth-self.outlinewidth,
                                            self.w+self.outlinewidth*2,
                                            self.h+self.outlinewidth*2)
        else:
            pass

    def destroy(self):
        self.area.destroy()
        try:
            self.window.destroy()
        except:
            pass
© All Rights Reserved