~ubuntu-branches/ubuntu/trusty/pitivi/trusty

« back to all changes in this revision

Viewing changes to pitivi/ui/screencast_managerdialog.py

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2011-07-07 13:43:47 UTC
  • mto: (6.1.9 sid) (1.2.12)
  • mto: This revision was merged to the branch mainline in revision 32.
  • Revision ID: james.westby@ubuntu.com-20110707134347-cari9kxjiakzej9z
Tags: upstream-0.14.1
ImportĀ upstreamĀ versionĀ 0.14.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# PiTiVi , Non-linear video editor
2
 
#
3
 
#       pitivi/ui/screencast_managerdialog.py
4
 
#
5
 
# Copyright (c) 2008, Sarath Lakshman <sarathlakshman@slynux.org>
6
 
#
7
 
# This program is free software; you can redistribute it and/or
8
 
# modify it under the terms of the GNU Lesser General Public
9
 
# License as published by the Free Software Foundation; either
10
 
# version 2.1 of the License, or (at your option) any later version.
11
 
#
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 GNU
15
 
# Lesser General Public License for more details.
16
 
#
17
 
# You should have received a copy of the GNU Lesser General Public
18
 
# License along with this program; if not, write to the
19
 
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20
 
# Boston, MA 02111-1307, USA.
21
 
 
22
 
import gtk
23
 
import os
24
 
import gtk.glade
25
 
import gst
26
 
import dbus
27
 
import dbus.service
28
 
import dbus.glib
29
 
import thread
30
 
import time
31
 
 
32
 
from pitivi.configure import LIBDIR
33
 
 
34
 
class ScreencastManagerDialog(object):
35
 
 
36
 
    def __init__(self, instance):
37
 
        gst.log("Creating new ScreencastManager Dialog")
38
 
        self.app = instance
39
 
 
40
 
        # Create gtk widget using glade model
41
 
        if 'pitivi.exe' in __file__.lower():
42
 
            glade_dir = LIBDIR + '\\pitivi.exe'
43
 
        else:
44
 
            glade_dir = os.path.dirname(os.path.abspath(__file__))
45
 
        pool_ui = gtk.glade.XML(os.path.join(glade_dir, "screencast_manager.glade"))
46
 
 
47
 
        self.window = pool_ui.get_widget("screencast_window")
48
 
        self.close_btn = pool_ui.get_widget("btn_close")
49
 
        self.ok_btn = pool_ui.get_widget("btn_ok")
50
 
        self.screencast_btn = pool_ui.get_widget("btn_screencast")
51
 
        self.istanbul_btn = pool_ui.get_widget("btn_istanbul")
52
 
 
53
 
        self.close_btn.connect("clicked",self.close)
54
 
        self.ok_btn.connect("clicked",self.ok)
55
 
        self.istanbul_btn.connect("clicked",self.start_istanbul)
56
 
        self.screencast_btn.set_active(self.app.screencast)
57
 
 
58
 
 
59
 
        self.dbus_connect()
60
 
 
61
 
 
62
 
 
63
 
    def dbus_connect(self):
64
 
        # Connect to istanbul dbus service
65
 
        try:
66
 
            bus = dbus.SessionBus()
67
 
            remote_object = bus.get_object("org.gnome.istanbul", "/state")
68
 
            self.iface = dbus.Interface(remote_object, "org.gnome.istanbul")
69
 
            self.istanbul_btn.hide()
70
 
            self.screencast_btn.set_sensitive(True)
71
 
            self.ok_btn.set_sensitive(True)
72
 
 
73
 
        except:
74
 
            self.screencast_btn.set_sensitive(False)
75
 
            self.ok_btn.set_sensitive(False)
76
 
 
77
 
    def close(self,w):
78
 
        self.window.destroy()
79
 
 
80
 
    def ok(self,w):
81
 
        self.screencast(None)
82
 
        self.close(None)
83
 
 
84
 
 
85
 
    def start_thread_istanbul(self):
86
 
        os.system("istanbul")
87
 
 
88
 
 
89
 
    # Start istanbul using thread module
90
 
    def start_istanbul(self,w):
91
 
        thread.start_new_thread(self.start_thread_istanbul,())
92
 
        time.sleep(2)
93
 
        self.dbus_connect()
94
 
 
95
 
    def screencast(self,w):
96
 
        if self.screencast_btn.get_active():
97
 
            self.iface.savemode(True)
98
 
            self.app.screencast = True
99
 
        else:
100
 
            self.iface.savemode(False)
101
 
            self.app.screencast = False