From 288e26ab518b03512bb2889c2b466d592c2eec3e Mon Sep 17 00:00:00 2001 From: iovar Date: Sat, 23 Sep 2006 07:09:36 +0000 Subject: new interface git-svn-id: https://recordmydesktop.svn.sourceforge.net/svnroot/recordmydesktop/trunk@63 f606c939-3180-4ac9-a4b8-4b8779d57d0a --- gtk-recordmydesktop/gtk-recordMyDesktop | 4 +- gtk-recordmydesktop/rmdPrefsWidget.py | 112 ++++++------- gtk-recordmydesktop/rmdSelect.py | 18 +-- gtk-recordmydesktop/rmdSelectThumb.py | 185 +++++++++++++++++++++ gtk-recordmydesktop/rmdSimple.py | 277 ++++++++++++++++++++++++++++++++ gtk-recordmydesktop/rmdTrayIcon.py | 105 +++++++----- gtk-recordmydesktop/rmdTrayPopup.py | 14 +- 7 files changed, 590 insertions(+), 125 deletions(-) create mode 100755 gtk-recordmydesktop/rmdSelectThumb.py create mode 100644 gtk-recordmydesktop/rmdSimple.py diff --git a/gtk-recordmydesktop/gtk-recordMyDesktop b/gtk-recordmydesktop/gtk-recordMyDesktop index 61afcf1..69e309f 100755 --- a/gtk-recordmydesktop/gtk-recordMyDesktop +++ b/gtk-recordmydesktop/gtk-recordMyDesktop @@ -27,10 +27,10 @@ #* For further information contact me at johnvarouhakis@gmail.com * #**********************************************************************************/ -import rmdTrayIcon +import rmdSimple def main(): - tr=rmdTrayIcon.trayIcon() + tr=rmdSimple.simpleWidget() main() diff --git a/gtk-recordmydesktop/rmdPrefsWidget.py b/gtk-recordmydesktop/rmdPrefsWidget.py index 6ca4b3f..772d952 100644 --- a/gtk-recordmydesktop/rmdPrefsWidget.py +++ b/gtk-recordmydesktop/rmdPrefsWidget.py @@ -36,27 +36,27 @@ import os class prefsWidget(object): - labelStrings=[_('Frames Per Second'),_('Sound Recording'),_('Startup Delay(secs)'), + labelStrings=[_('Frames Per Second'),_(''),_('Startup Delay(secs)'), _('Channels'),_('Frequency'),_('Device'),_('Video Quality'),_('Sound Quality'), _('Display'),_('Mouse Cursor'),_('Full shots at every frame'),_('MIT-Shm extension'), _('Drop Frames(encoder)'),_('Shared Threshold'),_('Quick Subsampling')] mouseStrings=[_('Normal'),_('White'),_('Black'),_('None')] stateStrings=[_('Enabled'),_('Disabled')] - tabStrings=[_('Basic'),_('Sound'),_('Encoding'),_('Advanced')] + tabStrings=[_('Basic'),_('Sound'),_('Advanced')] def destroy(self,Event=None): self.values[0]=self.fpsSpinButton.get_value_as_int() self.values[1]=self.mouseComboBox.get_active() - self.values[2]=self.soundComboBox.get_active() + #self.values[2]=self.soundComboBox.get_active() self.values[3]=self.fullComboBox.get_active() - self.values[4]=self.pathEntry.get_text() + #self.values[4]=self.pathEntry.get_text() #self.values[5]=self.are self.values[6]=self.delaySpinButton.get_value_as_int() self.values[7]=self.channelsSpinButton.get_value_as_int() self.values[8]=self.freqSpinButton.get_value_as_int() self.values[9]=self.deviceEntry.get_text().replace(' ','') - self.values[10]=self.vidqSpinButton.get_value_as_int() - self.values[11]=self.soundqSpinButton.get_value_as_int() + #self.values[10]=self.vidqSpinButton.get_value_as_int() + #self.values[11]=self.soundqSpinButton.get_value_as_int() self.values[12]=self.displayEntry.get_text().replace(' ','') self.values[13]=self.sharedComboBox.get_active() self.values[14]=self.frdropComboBox.get_active() @@ -72,25 +72,14 @@ class prefsWidget(object): self.optionsOpen[0]=0 self.window.destroy() - def __fileSelQuit__(self,Event=None): - self.fileSel.destroy() - - def __fileSelOk__(self,Event=None): - self.pathEntry.set_text(self.fileSel.get_filename()) - self.fileSel.destroy() - def __fileSelect__(self,Event=None): - self.fileSel = gtk.FileSelection(title=None) - self.fileSel.ok_button.connect("clicked", self.__fileSelOk__) - self.fileSel.cancel_button.connect("clicked", self.__fileSelQuit__) - self.fileSel.set_filename(self.values[4]) - self.fileSel.show() def __subWidgets__(self): self.labels={} self.boxes={} self.labelbox={} - for i in range(4): + #self.labelbox[0]=gtk.VBox(homogeneous=False, spacing=20) + for i in range(3): self.labelbox[i]=gtk.VBox(homogeneous=False, spacing=20) self.notebook = gtk.Notebook() @@ -99,21 +88,21 @@ class prefsWidget(object): self.fpsSpinButton= gtk.SpinButton(self.fpsAdjustment, climb_rate=0.5, digits=0) - 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.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.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.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.okButton=gtk.Button(None,gtk.STOCK_CLOSE) - for i in range(3): + for i in xrange(0,3,2): 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) @@ -123,26 +112,27 @@ class prefsWidget(object): self.boxes[3]=gtk.HBox(homogeneous=False, spacing=20) self.labelbox[0].pack_start(self.boxes[3],expand=False,fill=False) - placeholder2=gtk.Label("") + placeholder2=gtk.Label("\n\n\n\n\n\n") placeholder2.show() - self.labelbox[0].pack_start(placeholder2) + self.labelbox[0].pack_start(placeholder2,True,True) 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.soundComboBox.show() - self.boxes[1].pack_end(self.soundComboBox,expand=False,fill=False) + #self.soundComboBox.show() + #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[3].pack_start(self.pathEntry,expand=False,fill=False) - self.pathButton.show() - self.boxes[3].pack_end(self.pathButton,expand=False,fill=False) + #self.pathEntry.show() + #self.boxes[3].pack_start(self.pathEntry,expand=False,fill=False) + #self.pathButton.show() + #self.boxes[3].pack_end(self.pathButton,expand=False,fill=False) self.okButton.show() - self.boxes[4].pack_start(self.okButton,expand=True,fill=True) + self.boxes[4].pack_end(self.okButton,expand=False,fill=False) for i in range(5): - self.boxes[i].show() + if i!=1: + self.boxes[i].show() #sound page for i in xrange(3,6): self.labels[i]=gtk.Label(self.labelStrings[i]) @@ -172,24 +162,24 @@ class prefsWidget(object): #encoding page - for i in xrange(6,8): - self.labels[i]=gtk.Label(self.labelStrings[i]) - self.labels[i].set_justify(gtk.JUSTIFY_LEFT) - self.boxes[i+5]=gtk.HBox(homogeneous=False, spacing=0) - self.boxes[i+5].pack_start(self.labels[i],expand=False,fill=False) - self.labels[i].show() - #self.boxes[i+5].show() - self.labelbox[2].pack_start(self.boxes[i+5],expand=False,fill=False) - self.vidqAdjustment=gtk.Adjustment(value=self.values[10], lower=0,upper=63, step_incr=1, page_incr=1, page_size=1) - self.vidqSpinButton= gtk.SpinButton(self.vidqAdjustment, climb_rate=0.5, digits=0) - self.boxes[11].pack_end(self.vidqSpinButton,expand=False,fill=False) - self.vidqSpinButton.show() - self.boxes[11].show() - self.soundqAdjustment=gtk.Adjustment(value=self.values[11], lower=-1,upper=10, step_incr=1, page_incr=1, page_size=1) - self.soundqSpinButton= gtk.SpinButton(self.soundqAdjustment, climb_rate=0.5, digits=0) - self.boxes[12].pack_end(self.soundqSpinButton,expand=False,fill=False) - self.soundqSpinButton.show() - self.boxes[12].show() + #for i in xrange(6,8): + #self.labels[i]=gtk.Label(self.labelStrings[i]) + #self.labels[i].set_justify(gtk.JUSTIFY_LEFT) + #self.boxes[i+5]=gtk.HBox(homogeneous=False, spacing=0) + #self.boxes[i+5].pack_start(self.labels[i],expand=False,fill=False) + #self.labels[i].show() + ##self.boxes[i+5].show() + #self.labelbox[2].pack_start(self.boxes[i+5],expand=False,fill=False) + #self.vidqAdjustment=gtk.Adjustment(value=self.values[10], lower=0,upper=63, step_incr=1, page_incr=1, page_size=1) + #self.vidqSpinButton= gtk.SpinButton(self.vidqAdjustment, climb_rate=0.5, digits=0) + #self.boxes[11].pack_end(self.vidqSpinButton,expand=False,fill=False) + #self.vidqSpinButton.show() + #self.boxes[11].show() + #self.soundqAdjustment=gtk.Adjustment(value=self.values[11], lower=-1,upper=10, step_incr=1, page_incr=1, page_size=1) + #self.soundqSpinButton= gtk.SpinButton(self.soundqAdjustment, climb_rate=0.5, digits=0) + #self.boxes[12].pack_end(self.soundqSpinButton,expand=False,fill=False) + #self.soundqSpinButton.show() + #self.boxes[12].show() #misc page for i in xrange(8,15): @@ -199,7 +189,7 @@ class prefsWidget(object): self.boxes[i+5].pack_start(self.labels[i],expand=False,fill=False) self.labels[i].show() #self.boxes[i+5].show() - self.labelbox[3].pack_start(self.boxes[i+5],expand=False,fill=False) + self.labelbox[2].pack_start(self.boxes[i+5],expand=False,fill=False) self.displayEntry= gtk.Entry(max=0) self.displayEntry.set_text(self.values[12]) self.boxes[13].pack_end(self.displayEntry,expand=False,fill=False) @@ -254,15 +244,15 @@ class prefsWidget(object): self.boxes[19].show() #append and show - for i in range(4): + for i in range(3): self.notebook.append_page(self.labelbox[i],gtk.Label(self.tabStrings[i])) self.window.add(self.notebook) - for i in range(4): + for i in range(3): self.labelbox[i].show() self.notebook.show() def __makeCons__(self): - self.pathButton.connect("clicked",self.__fileSelect__) + #self.pathButton.connect("clicked",self.__fileSelect__) self.okButton.connect("clicked",self.destroy) def __init__(self,values,optionsOpen): @@ -276,7 +266,7 @@ class prefsWidget(object): self.__makeCons__() - self.window.set_size_request(288,384) + self.window.set_size_request(350,-1) self.window.show() def main(self): diff --git a/gtk-recordmydesktop/rmdSelect.py b/gtk-recordmydesktop/rmdSelect.py index 45dfb2f..cf03403 100644 --- a/gtk-recordmydesktop/rmdSelect.py +++ b/gtk-recordmydesktop/rmdSelect.py @@ -106,21 +106,7 @@ class GtkAreaSelector(gtk.Window): self.area_return[1]=min(int(self.y1),int(self.y2)) self.area_return[2]=max(int(self.x1),int(self.x2)) self.area_return[3]=max(int(self.y1),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.hide() self.destroy() return True @@ -142,7 +128,7 @@ class GtkAreaSelector(gtk.Window): self.queue_draw() return True - def delete_cb(self, widget): + def delete_cb(self, widget,Event=None): pass if __name__ == "__main__": diff --git a/gtk-recordmydesktop/rmdSelectThumb.py b/gtk-recordmydesktop/rmdSelectThumb.py new file mode 100755 index 0000000..74c2186 --- /dev/null +++ b/gtk-recordmydesktop/rmdSelectThumb.py @@ -0,0 +1,185 @@ + +import gtk +import gtk.gdk +#from rmdSelect import * +import gobject +import gc + +class GtkThumbSelector(gtk.DrawingArea): + def __init__(self,area_return,hidden,update_interval=2000): + self.hidden=hidden + self.area_return=area_return + self.selecting=0 + gtk.DrawingArea.__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() + self.wroot = gtk.gdk.get_default_root_window() + (self.wwidth, self.wheight) = self.wroot.get_size() + ############################################################### + + self.factor=1; + twidth=self.wwidth + while twidth>320 or self.factor<4: + twidth/=2 + self.factor*=2 + self.root=gtk.gdk.Image(gtk.gdk.IMAGE_NORMAL,self.wroot.get_visual(),self.wwidth/self.factor,self.wheight/self.factor) + #(width, height) = root.get_size() + sroot = self.wroot.get_image(0, 0, self.wwidth, self.wheight) + self.__subsample__(sroot,self.wwidth,self.wheight,self.root,self.factor) + #self.root = root.get_image(0, 0, width, height) + self.x1 = self.y1 = -1 + self.x2 = self.y2 = -1 + self.set_size_request(self.wwidth/self.factor,self.wheight/self.factor) + self.timed_id=gobject.timeout_add(update_interval,self.update_image) + + def __subsample__(self,im1,w,h,im2,stride,x=0,y=0): + for i in xrange(y,h,stride): + for k in xrange(x,w,stride): + im2.put_pixel(k/stride,i/stride,im1.get_pixel(k,i)) + def button_release_cb(self, widget, event): + if event.button == 1 and self.x1 >= 0 and widget==self: + self.selecting=0 + self.x2 = event.x + 1 + self.y2 = event.y + 1 + # stop + if self.x1 <0: self.x1=0 + if self.x2 <0: self.x2=0 + if self.y1 <0: self.y1=0 + if self.y2 <0: self.y2=0 + if self.x1 >self.wwidth/self.factor: self.x1=self.wwidth/self.factor + if self.x2 >self.wwidth/self.factor: self.x2=self.wwidth/self.factor + if self.y1 >self.wheight/self.factor: self.y1=self.wheight/self.factor + if self.y2 >self.wheight/self.factor: self.y2=self.wheight/self.factor + + + self.area_return[0]=min(int(self.x1),int(self.x2))*self.factor + self.area_return[1]=min(int(self.y1),int(self.y2))*self.factor + self.area_return[2]=max(int(self.x1),int(self.x2))*self.factor + self.area_return[3]=max(int(self.y1),int(self.y2))*self.factor + self.x1=self.y1=self.x2=self.y2=-1 + #print self.area_return + self.update_image() + + def button_press_cb(self, widget, event): + if widget==self: + if event.button == 1: + self.selecting=1 + self.update_image() + self.x1 = event.x + self.y1 = event.y + else: + self.x1 = self.y1=self.x2=self.y2=-1 + self.area_return[0]=self.area_return[1]=0 + self.area_return[2]=self.wwidth + self.area_return[3]=self.wheight + self.update_image() + + def realize_cb(self, widget): + if widget == self: + 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): + if widget==self: + 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): + if widget ==self: + 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 update_image(self): + #self.root.destroy() + self.queue_draw() + if self.hidden[0]==0 : + gc.collect() + sroot = self.wroot.get_image(0,0,self.wwidth,self.wheight) + self.__subsample__(sroot,self.wwidth,self.wheight,self.root,self.factor) + vals=[0,0, self.wwidth, self.wheight] + if self.area_return[0]>=0: + vals[0]=self.area_return[0] + if self.area_return[1]>=0: + vals[1]=self.area_return[1] + if self.area_return[2]>=0: + vals[2]=self.area_return[2]-self.area_return[0] + if self.area_return[3]>=0: + vals[3]=self.area_return[3]-self.area_return[1] + if vals[0] >0 or vals[1] >0 or vals[2]