From 6df05ce439e879d3aa4ebd7339b61965d7ec6af7 Mon Sep 17 00:00:00 2001 From: iovar Date: Sun, 17 Sep 2006 15:54:13 +0000 Subject: added select and tray popup from istanbul, various changes to the interface,incorporated frugal desktop file patch git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@50 f606c939-3180-4ac9-a4b8-4b8779d57d0a --- gtk-recordmydesktop/INSTALL | 7 ++ gtk-recordmydesktop/README | 2 +- gtk-recordmydesktop/gtk-recordmydesktop.desktop | 6 +- gtk-recordmydesktop/istanbulSelect.py | 153 ++++++++++++++++++++++++ gtk-recordmydesktop/istanbulTrayPopup.py | 97 +++++++++++++++ gtk-recordmydesktop/rmdPrefsWidget.py | 104 ++++++++-------- gtk-recordmydesktop/rmdTrayIcon.py | 41 ++++--- 7 files changed, 338 insertions(+), 72 deletions(-) create mode 100644 gtk-recordmydesktop/istanbulSelect.py create mode 100644 gtk-recordmydesktop/istanbulTrayPopup.py diff --git a/gtk-recordmydesktop/INSTALL b/gtk-recordmydesktop/INSTALL index d1e4c55..8c6356c 100644 --- a/gtk-recordmydesktop/INSTALL +++ b/gtk-recordmydesktop/INSTALL @@ -2,6 +2,12 @@ NOTICE: gtk-recordMyDesktop is ONLY A FRONTEND to recordMyDesktop. You have to obtain and install that first. +DEPENDENCIES: + +PyGTK >= 2.4 +Gnome Python Extras >= 2.11.3 +recordMyDesktop 2.5 + INSTALLING recordMyDesktop(the backend): @@ -26,6 +32,7 @@ alsa (libasound) X libXext libXdamage +libXfixes libogg libvorbis libtheora diff --git a/gtk-recordmydesktop/README b/gtk-recordmydesktop/README index cbbeae6..caf8ebb 100644 --- a/gtk-recordmydesktop/README +++ b/gtk-recordmydesktop/README @@ -2,7 +2,7 @@ NOTICE: gtk-recordMyDesktop is ONLY A FRONTEND to recordMyDesktop. You have to obtain and install that first. -For installation instructions see the INSTALL file. +For installation instructions and dependencies see the INSTALL file. diff --git a/gtk-recordmydesktop/gtk-recordmydesktop.desktop b/gtk-recordmydesktop/gtk-recordmydesktop.desktop index b9a2149..3d6a4a7 100644 --- a/gtk-recordmydesktop/gtk-recordmydesktop.desktop +++ b/gtk-recordmydesktop/gtk-recordmydesktop.desktop @@ -1,10 +1,10 @@ [Desktop Entry] Encoding=UTF-8 -_Name=gtk-recordMyDesktop -_Comment=Frontend for recordMyDesktop +Name=gtk-recordMyDesktop +Comment=Frontend for recordMyDesktop Exec=gtk-recordMyDesktop Terminal=false Type=Application Icon=gtk-recordmydesktop.png -Categories=GNOME;Application;AudioVideo; +Categories=GNOME;KDE;Application;AudioVideo; StartupNotify=false diff --git a/gtk-recordmydesktop/istanbulSelect.py b/gtk-recordmydesktop/istanbulSelect.py new file mode 100644 index 0000000..a88be50 --- /dev/null +++ b/gtk-recordmydesktop/istanbulSelect.py @@ -0,0 +1,153 @@ +# -*- Mode: Python -*- +# vi:si:et:sw=4:sts=4:ts=4 +# +# Istanbul - a desktop session recorder +# Copyright (C) 2005 Zaheer Abbas Merali (zaheerabbas at merali dot org) +# All rights reserved. + +# This file may be distributed and/or modified under the terms of +# the GNU General Public License version 2 as published by +# the Free Software Foundation. +# This file is distributed without any warranty; without even the implied +# warranty of merchantability or fitness for a particular purpose. +# See "LICENSE.GPL" in the source distribution for more information. + +# Headers in this file shall remain intact. + +#This file has been modified to be used in gtk-recordMyDesktop +#by John Varouhakis +#area_return list has been added to retrieve the values +#original file name is select.py in Istanbul-0.2.1 +import gtk +import gtk.gdk + +class GtkAreaSelector(gtk.Window): + def __init__(self,area_return): + self.area_return=area_return + gtk.Window.__init__(self) + self.set_app_paintable(True) + self.fullscreen() + self.connect("expose-event", self.expose_cb) + self.connect("button-press-event", self.button_press_cb) + self.connect("button-release-event", self.button_release_cb) + self.connect("motion-notify-event", self.motion_notify_cb) + self.connect("delete-event", self.delete_cb) + self.connect("realize", self.realize_cb) + root = gtk.gdk.get_default_root_window() + (width, height) = root.get_size() + self.root = root.get_image(0, 0, width, height) + self.x1 = self.y1 = -1 + self.x2 = self.y2 = 0 + self.show_all() + + def realize_cb(self, widget): + gdkwindow = self.window + gdkwindow.set_events(gdkwindow.get_events() | + gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK | + gtk.gdk.POINTER_MOTION_MASK); + cursor = gtk.gdk.Cursor(gtk.gdk.CROSSHAIR) + gdkwindow.set_cursor(cursor) + gdkwindow.set_back_pixmap(None, False) + + def expose_cb(self, widget, event): + dashes = [ 1.0, 2.0 ] + cr = self.window.cairo_create() + cr.rectangle(event.area.x, event.area.y, event.area.width, + event.area.height) + cr.clip() + self.window.draw_image(self.style.black_gc, self.root, event.area.x, + event.area.y, event.area.x, event.area.y, event.area.width, + event.area.height) + cr.set_line_width(1.0) + cr.set_source_rgba (1.0, 0.0, 0.0, 1.0) + cr.set_dash (dashes, 0.0) + cr.move_to (self.x1 - 0.5, 0.0) + cr.line_to (self.x1 - 0.5, event.area.y + event.area.height) + cr.move_to (0.0, self.y1 - 0.5) + cr.line_to (event.area.x + event.area.width, self.y1 - 0.5) + cr.stroke () + + if self.x1 >= 0: + x = min(self.x1, self.x2) + y = min(self.y1, self.y2) + w = max(self.x1, self.x2) - x + h = max(self.y1, self.y2) - y + cr.set_dash ([], 0.0) + cr.rectangle ( x, y, w, h) + cr.fill() + cr.set_source_rgba (0.0, 0.0, 0.5, 0.5) + cr.rectangle (x + 0.5, y + 0.5, w - 1, h - 1) + cr.stroke() + + return False + + def motion_notify_cb(self, widget, event): + self.queue_draw() + + if self.x1 >= 0: + rect = gtk.gdk.Rectangle() + rect.x = min(self.x1, min(self.x2, event.x + 1)) + rect.width = max(self.x1, max(self.x2, event.x + 1)) - rect.x + rect.y = min(self.y1, min(self.y2, event.y + 1)) + rect.height = max(self.y1, max(self.y2, event.y + 1)) - rect.y + self.queue_draw_area(rect.x, rect.y, rect.width, rect.height) + + self.x2 = event.x + 1 + self.y2 = event.y + 1 + + return True + + def button_release_cb(self, widget, event): + if event.button == 1 and self.x1 >= 0: + self.x2 = event.x + 1 + self.y2 = event.y + 1 + # stop + self.area_return[0]=int(self.x1) + self.area_return[1]=int(self.y1) + self.area_return[2]=int(self.x2) + self.area_return[3]=int(self.y2) + dialog = gtk.Dialog(title=None, parent=None, flags=0, buttons=None) + label1 = gtk.Label("Recording area for the next session\n\t\t\tis set to:") + dialog.vbox.pack_start(label1, True, True, 0) + label1.show() + label2 = gtk.Label("(%d,%d) - (%d,%d)\n"%(self.area_return[0],self.area_return[1],self.area_return[2],self.area_return[3])) + dialog.vbox.pack_start(label2, True, True, 0) + label2.show() + button = gtk.Button(label=None, stock=gtk.STOCK_OK) + dialog.vbox.pack_start(button, True, True, 0) + def __destroy(button): + dialog.destroy() + button.connect("clicked", __destroy) + button.show() + dialog.set_size_request(300,128) + dialog.show() + self.destroy() + + return True + + def button_press_cb(self, widget, event): + if event.button != 1: + self.x1 = self.y1 = -1 + # stop + #print "(%d, %d) - (%d, %d)" % (self.x1, self.y1, self.x2, self.y2) + #self.area_return[0]=self.x1 + #self.area_return[1]=self.y1 + #self.area_return[2]=self.x2 + #self.area_return[3]=self.y2 + #print self.area_return + self.destroy() + return True + self.x1 = event.x + self.y1 = event.y + self.queue_draw() + return True + + def delete_cb(self, widget): + pass + +if __name__ == "__main__": + w = GtkAreaSelector() + w.show() + gtk.main() + + diff --git a/gtk-recordmydesktop/istanbulTrayPopup.py b/gtk-recordmydesktop/istanbulTrayPopup.py new file mode 100644 index 0000000..2ce7efd --- /dev/null +++ b/gtk-recordmydesktop/istanbulTrayPopup.py @@ -0,0 +1,97 @@ +# -*- Mode: Python -*- +# vi:si:et:sw=4:sts=4:ts=4 +# +# Istanbul - A desktop recorder +# Copyright (C) 2005 Zaheer Abbas Merali (zaheerabbas at merali dot org) +# Copyright (C) 2006 John N. Laliberte (allanonjl@gentoo.org) (jlaliberte@gmail.com) +# Portions Copyright (C) 2004,2005 Fluendo, S.L. (www.fluendo.com). +# All rights reserved. + + +# This file may be distributed and/or modified under the terms of +# the GNU General Public License version 2 as published by +# the Free Software Foundation. +# This file is distributed without any warranty; without even the implied +# warranty of merchantability or fitness for a particular purpose. +# See "COPYING" in the source distribution for more information. + +#gtk-recordMyDesktop - a graphical frontend for recordMyDesktop +#Copyright (C) 2006 John Varouhakis +#This file has been modified to be used in gtk-recordMyDesktop +#original file name is tray_popup.py in istanbul-0.2.1 + +import gtk +import locale, gettext +_ = gettext.gettext +import istanbulSelect as iSel +import rmdPrefsWidget as pW + +class TrayPopupMenu: + options=None + def __init__(self,values,optionsOpen): + self.optionsOpen=optionsOpen + self.values=values + self._setup_popup_menu() + self.selector = None + + def _setup_popup_menu(self): + self.popupmenu = gtk.Menu() + self._setup_about() + self._setup_prefs_widget() + self._setup_select_area() + self._setup_quit() + + def _prefs_widget(self,button): + if self.optionsOpen[0] ==0: + self.optionsOpen[0]=1 + self.options=pW.prefsWidget(self.values,self.optionsOpen) + else: + if self.options != None: + self.options.window.destroy() + self.optionsOpen[0]=0 + def _setup_prefs_widget(self): + self.popupmenu_prefs_widget = gtk.ImageMenuItem( + gtk.STOCK_PREFERENCES) + self.popupmenu_prefs_widget.connect('activate', self._prefs_widget) + self.popupmenu.add(self.popupmenu_prefs_widget) + + def _setup_about(self): + self.popupmenu_aboutitem = gtk.ImageMenuItem(gtk.STOCK_ABOUT) + self.popupmenu_aboutitem.connect('activate', self._about) + self.popupmenu.add(self.popupmenu_aboutitem) + + def _about(self, button): + aboutdialog = gtk.AboutDialog() + aboutdialog.set_name(_('gtk-recordMyDesktop')) + aboutdialog.set_version("0.2") + aboutdialog.set_comments(_('a graphical frontend for recordMyDesktop')) + aboutdialog.set_copyright(_('Copyright (C) John Varouhakis\nPortions Copyright (C) 2005-6 Zaheer Abbas Merali, John N. Laliberte\nPortions Copyright (C) Fluendo S.L.')) + aboutdialog.set_authors(['recordMyDesktop and gtk-recordMyDesktop\nis written by John Varouhakis','Portions of gtk-recordMyDesktop\nare taken from Istanbul\n(http://live.gnome.org/Istanbul)\nwritten by\nZaheer Abbas Merali and John N. Laliberte']) + aboutdialog.set_website('http://recordmydesktop.sourceforge.net') + aboutdialog.set_license('GPL-2') + aboutdialog.set_translator_credits(_('')) + aboutdialog.show_all() + + def _setup_select_area(self): + self.popupmenu_selectarea = gtk.ImageMenuItem( + _("_Select Area to Record")) + self.popupmenu.add(self.popupmenu_selectarea) + self.popupmenu_selectarea.connect("activate", self._select_area_cb) + + def _select_area_cb(self, menuitem): + self.popupmenu.hide() + self.selector = iSel.GtkAreaSelector(self.values[5]) + self.selector.show() + + def _setup_quit(self): + self.popupmenu_quititem = gtk.ImageMenuItem(gtk.STOCK_QUIT) + self.popupmenu_quititem.connect('activate', self._quit) + self.popupmenu.add(self.popupmenu_quititem) + + def _quit(self, button): + gtk.main_quit() + + def show(self): + self.popupmenu.show_all() + self.popupmenu.popup(None, None, None, 3, gtk.get_current_event_time()) + diff --git a/gtk-recordmydesktop/rmdPrefsWidget.py b/gtk-recordmydesktop/rmdPrefsWidget.py index ca5e05c..75b2a5b 100644 --- a/gtk-recordmydesktop/rmdPrefsWidget.py +++ b/gtk-recordmydesktop/rmdPrefsWidget.py @@ -26,21 +26,22 @@ import pygtk -pygtk.require('2.0') +pygtk.require('2.4') import gtk +import locale, gettext +_ = gettext.gettext import os class prefsWidget(object): - labelStrings=['Frames Per Second','Mouse Cursor','Sound Recording','Full Shots At Every Frame'] - mouseStrings=['White','Black','None'] - stateStrings=['On','Off'] - + labelStrings=[_('Frames Per Second'),_('Sound Recording'),_('Startup Delay(secs)')] + mouseStrings=[_('Normal'),_('White'),_('Black'),_('None')] + stateStrings=[_('Enabled'),_('Disabled')] + tabStrings=[_('Basic'),_('Sound'),_('Encoding'),_('Misc')] def destroy(self,Event=None): - #gtk.main_quit() self.values[0]=self.fpsSpinButton.get_value_as_int() self.values[1]=self.mouseComboBox.get_active() self.values[2]=self.soundComboBox.get_active() @@ -72,85 +73,86 @@ class prefsWidget(object): def __subWidgets__(self): self.labels={} self.boxes={} - self.labelbox=gtk.VBox(homogeneous=True, spacing=10) - + self.labelbox={} + for i in range(4): + self.labelbox[i]=gtk.VBox(homogeneous=True, spacing=10) + self.notebook = gtk.Notebook() +#basic page self.fpsAdjustment=gtk.Adjustment(value=self.values[0], lower=1, upper=50, step_incr=1, page_incr=5, page_size=0) self.fpsSpinButton= gtk.SpinButton(self.fpsAdjustment, climb_rate=0.5, digits=0) - self.mouseComboBox = gtk.combo_box_new_text() - for i in range(3): - self.mouseComboBox.append_text(self.mouseStrings[i]) - self.mouseComboBox.set_active(self.values[1]) + self.soundComboBox = gtk.combo_box_new_text() for i in range(2): self.soundComboBox.append_text(self.stateStrings[i]) self.soundComboBox.set_active(self.values[2]) - self.fullComboBox = gtk.combo_box_new_text() - for i in range(2): - self.fullComboBox.append_text(self.stateStrings[i]) - self.fullComboBox.set_active(self.values[3]) - + self.delayAdjustment=gtk.Adjustment(value=self.values[6], lower=0,upper=10000, step_incr=1, page_incr=5, page_size=0) + self.delaySpinButton= gtk.SpinButton(self.delayAdjustment, climb_rate=0.5, digits=0) self.pathEntry= gtk.Entry(max=0) self.pathEntry.set_text(self.values[4]) self.pathButton = gtk.Button(None,gtk.STOCK_SAVE_AS) self.okButton=gtk.Button(None,gtk.STOCK_OK) - self.quitButton=gtk.Button(None,gtk.STOCK_QUIT) - - for i in range(4): + for i in range(3): self.labels[i]=gtk.Label(self.labelStrings[i]) self.labels[i].set_justify(gtk.JUSTIFY_LEFT) self.boxes[i]=gtk.HBox(homogeneous=False, spacing=0) self.boxes[i].pack_start(self.labels[i],expand=False,fill=False) self.labels[i].show() - self.labelbox.pack_start(self.boxes[i]) + self.labelbox[0].pack_start(self.boxes[i]) - placeholder1=gtk.Label("") - placeholder1.show() - self.labelbox.pack_start(placeholder1) - self.boxes[4]=gtk.HBox(homogeneous=False, spacing=20) - self.labelbox.pack_start(self.boxes[4]) + self.boxes[3]=gtk.HBox(homogeneous=False, spacing=20) + self.labelbox[0].pack_start(self.boxes[3]) placeholder2=gtk.Label("") placeholder2.show() - self.labelbox.pack_start(placeholder2) - self.boxes[5]=gtk.HBox(homogeneous=False, spacing=0) - self.labelbox.pack_end(self.boxes[5]) - - + self.labelbox[0].pack_start(placeholder2) + self.boxes[4]=gtk.HBox(homogeneous=False, spacing=0) + self.labelbox[0].pack_end(self.boxes[4]) self.fpsSpinButton.show() self.boxes[0].pack_end(self.fpsSpinButton,expand=False,fill=False) - self.mouseComboBox.show() - self.boxes[1].pack_end(self.mouseComboBox,expand=False,fill=False) self.soundComboBox.show() - self.boxes[2].pack_end(self.soundComboBox,expand=False,fill=False) - self.fullComboBox.show() - self.boxes[3].pack_end(self.fullComboBox,expand=False,fill=False) + self.boxes[1].pack_end(self.soundComboBox,expand=False,fill=False) + self.delaySpinButton.show() + self.boxes[2].pack_end(self.delaySpinButton,expand=False,fill=False) self.pathEntry.show() - self.boxes[4].pack_start(self.pathEntry,expand=False,fill=False) + self.boxes[3].pack_start(self.pathEntry,expand=False,fill=False) self.pathButton.show() - self.boxes[4].pack_end(self.pathButton,expand=False,fill=False) - + self.boxes[3].pack_end(self.pathButton,expand=False,fill=False) self.okButton.show() - self.quitButton.show() - self.boxes[5].pack_start(self.okButton,expand=False,fill=False) - self.boxes[5].pack_end(self.quitButton,expand=False,fill=False) - - for i in range(6): + self.boxes[4].pack_start(self.okButton,expand=True,fill=True) + for i in range(5): self.boxes[i].show() - - self.window.add(self.labelbox) - self.labelbox.show() +#sound page +#encoding page +#misc page + self.mouseComboBox = gtk.combo_box_new_text() + for i in range(4): + self.mouseComboBox.append_text(self.mouseStrings[i]) + self.mouseComboBox.set_active(self.values[0]) + + self.fullComboBox = gtk.combo_box_new_text() + for i in range(2): + self.fullComboBox.append_text(self.stateStrings[i]) + self.fullComboBox.set_active(self.values[3]) + + +#append and show + for i in range(4): + self.notebook.append_page(self.labelbox[i],gtk.Label(self.tabStrings[i])) + self.window.add(self.notebook) + for i in range(4): + self.labelbox[i].show() + self.notebook.show() def __makeCons__(self): self.pathButton.connect("clicked",self.__fileSelect__) self.okButton.connect("clicked",self.destroy) - self.quitButton.connect("clicked",self.__exit__) def __init__(self,values,optionsOpen): self.values=values @@ -165,18 +167,12 @@ class prefsWidget(object): self.window.set_size_request(288,384) self.window.show() - #self.values=values def main(self): gtk.main() -#values=[15,0,0,1,os.path.join(os.getenv('HOME'),'out.ogg')] -#ps=prefsWidget(values) -#ps.main() - -#print values diff --git a/gtk-recordmydesktop/rmdTrayIcon.py b/gtk-recordmydesktop/rmdTrayIcon.py index 69bbc3f..ed769fc 100644 --- a/gtk-recordmydesktop/rmdTrayIcon.py +++ b/gtk-recordmydesktop/rmdTrayIcon.py @@ -26,20 +26,41 @@ import pygtk -pygtk.require('2.0') +pygtk.require('2.4') import gtk -import rmdPrefsWidget as pW import egg.trayicon +import istanbulSelect as isel +import istanbulTrayPopup as iTP import os +#values struct: + +#0 fps +#1 mouse +#2 sound on/off +#3 full +#4 path +#5 area +#6 delay +#7 channels +#8 frequency +#9 device +#10 v_quality +#11 s_quality +#12 display +#13 shared memory +#14 drop-frames +#15 shared threshold +#16 quick subsampling + class trayIcon(object): - values=[15,0,0,1,os.path.join(os.getenv('HOME'),'out.ogg')] + values=[15,0,0,1,os.path.join(os.getenv('HOME'),'out.ogg'),[-1,-1,-1,-1],0] event_box = gtk.EventBox() state=0#0 stopped,1 recording,2 paused - optionsOpen=[0] rmdPid=None + optionsOpen=[0] def __buttonPress__(self,widget,event=None): if event.button==1 and self.optionsOpen[0]==0: @@ -59,15 +80,7 @@ class trayIcon(object): elif event.button == 3: if self.state == 0: - - if self.optionsOpen[0] ==0: - self.optionsOpen[0]=1 - self.options=pW.prefsWidget(self.values,self.optionsOpen) - else: - if self.options != None: - self.options.window.destroy() - self.optionsOpen[0]=0 - + self.tray_popup.show() elif self.state == 1: self.trayIcon.set_from_stock(gtk.STOCK_MEDIA_PAUSE,gtk.ICON_SIZE_SMALL_TOOLBAR) self.state=2 @@ -98,7 +111,6 @@ class trayIcon(object): execargs.append("--full-shots") execargs.append("--with-shared") - self.rmdPid=os.fork() if self.rmdPid==0: @@ -121,6 +133,7 @@ class trayIcon(object): self.event_box.add(self.trayIcon) self.tray_container = egg.trayicon.TrayIcon("recordMyDesktop") self.tray_container.add(self.event_box) + self.tray_popup=iTP.TrayPopupMenu(self.values,self.optionsOpen) self.event_box.connect("button-press-event", self.__buttonPress__) self.tray_container.show_all() gtk.main() -- cgit v1.2.3