def new_folder_chooser (self, menuitem, window): dialog = self.newProjectDialogUI.get_object ("dialog-window") response = dialog.run () if (response == Gtk.ResponseType.OK): filechooser = self.newProjectDialogUI.get_object ("filechooser-button") projectNameEntry = self.newProjectDialogUI.get_object ("project-name") self.listStore.clear () projectName = projectNameEntry.get_text () self.projectDir = filechooser.get_filename ()+"/"+projectName GLib.mkdir_with_parents (self.projectDir, 0755) self.projectConfig = isrProject.isrProject (self.projectDir+"/"+projectName+".isr", projectName) self.projectLabel.set_text (_("Project: ")+projectName) self.enable_buttons (True) dialog.hide ()
def new_folder_chooser(self, menuitem, window): dialog = self.newProjectDialogUI.get_object("dialog-window") response = dialog.run() if (response == Gtk.ResponseType.OK): filechooser = self.newProjectDialogUI.get_object( "filechooser-button") projectNameEntry = self.newProjectDialogUI.get_object( "project-name") self.listStore.clear() projectName = projectNameEntry.get_text() self.projectDir = filechooser.get_filename() + "/" + projectName GLib.mkdir_with_parents(self.projectDir, 0755) self.projectConfig = isrProject.isrProject( self.projectDir + "/" + projectName + ".isr", projectName) self.projectLabel.set_text(_("Project: ") + projectName) self.enable_buttons(True) dialog.hide()
def open_file_chooser(self, menuitem, window): dialog = Gtk.FileChooserDialog( _("Open Project"), window, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) fileFilter = Gtk.FileFilter() fileFilter.set_name(_("Insight recorder projects")) #old project file extension fileFilter.add_pattern("*.dut") fileFilter.add_pattern("*.isr") response = dialog.run() if (response == Gtk.ResponseType.OK): projectFile = dialog.get_filename() self.projectDir = GLib.path_get_dirname(projectFile) self.listStore.clear() self.projectConfig = isrProject.isrProject(projectFile, None) self.projectConfig.populate(self, m) dialog.destroy()
def new_folder_chooser (self, menuitem, window): dialog = Gtk.FileChooserDialog (_("New project"), None, Gtk.FileChooserAction.CREATE_FOLDER, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_SAVE, Gtk.ResponseType.OK)) dialog.set_do_overwrite_confirmation (True) response = dialog.run () if response == Gtk.ResponseType.OK: self.listStore.clear () self.projectDir = dialog.get_filename () projectName = GLib.filename_display_basename (self.projectDir) self.projectConfig = isrProject.isrProject (self.projectDir+"/"+projectName+".isr", projectName) self.projectLabel.set_text (_("Project: ")+projectName) self.enable_buttons (True) dialog.destroy()
def open_file_chooser (self, menuitem, window): dialog = Gtk.FileChooserDialog (_("Open Project"), window, Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) fileFilter = Gtk.FileFilter () fileFilter.set_name (_("Insight recorder projects")) #old project file extension fileFilter.add_pattern ("*.dut") fileFilter.add_pattern ("*.isr") response = dialog.run () if (response == Gtk.ResponseType.OK): projectFile = dialog.get_filename () self.projectDir = GLib.path_get_dirname (projectFile) self.listStore.clear () self.projectConfig = isrProject.isrProject (projectFile, None) self.projectConfig.populate (self, m) dialog.destroy()
def __init__(self): self.primary = None self.secondary = None self.mux = None self.projectDir = None self.projectLabel = None self.listStore = None self.buttonBox = None self.screen = None self.projectConfig = None self.recordButton = None self.mainWindow = None self.updateTimer = None self.listItr = None self.currentRecording = None self.isRecording = False self.stopRecordButton = None self.recordingText = _("Recording in progress") Gst.init (None) self.check_gst_elements_available () signal.signal(signal.SIGINT, self.close) # UI declaration self.icon = Gtk.StatusIcon (visible=False) self.icon.set_from_stock (Gtk.STOCK_MEDIA_RECORD) self.icon.connect ("activate", self.stop_record) self.mainWindow = Gtk.Window(title="Insight recorder", resizable=False, icon_name=Gtk.STOCK_MEDIA_RECORD) self.mainWindow.connect("destroy", self.on_mainWindow_destroy) self.indicator = isrIndicator.Indicator (self) outterBoxLayout = Gtk.VBox (homogeneous=False) menu = Gtk.Toolbar () menu.get_style_context ().add_class (Gtk.STYLE_CLASS_PRIMARY_TOOLBAR) fileNew = Gtk.ToolButton.new_from_stock ("gtk-new") fileNew.set_label (_("New project")) fileNew.set_tooltip_text (_("Create a new project")) fileNew.connect ("clicked", self.new_folder_chooser, self.mainWindow) fileOpen = Gtk.ToolButton.new_from_stock ("gtk-open") fileOpen.set_label (_("Open project")) fileOpen.connect ("clicked", self.open_file_chooser, self.mainWindow) fileOpen.set_tooltip_text (_("Open an existing project")) menu.insert (fileNew, 0) menu.insert (fileOpen, 1) #InfoBar self.recordingInfoBar = Gtk.InfoBar () self.stopRecordButton = self.recordingInfoBar.add_button (_("Stop recording"), Gtk.ResponseType.OK) self.recordingInfoBar.set_message_type (Gtk.MessageType.INFO) self.recordingInfoBar.connect ("response", self.stop_record) recordingInfoBarArea = self.recordingInfoBar.get_content_area () self.infoBarLabel = Gtk.Label (); self.infoBarLabel.set_text (self.recordingText) recordingInfoBarArea.pack_start (self.infoBarLabel, False, False, 3) self.eosSpinner = Gtk.Spinner () self.recordingInfoBar.get_action_area ().pack_start (self.eosSpinner, False, False, 3) self.eosSpinner.hide () self.projectLabel = Gtk.Label (halign=Gtk.Align.START) self.projectLabel.set_markup ("<span style='italic'>"+_("No project open")+"</span>") self.recordButton = Gtk.Button (label=_("Create recording"), tooltip_text=_("Create a new recording"), sensitive=False) self.recordButton.connect("clicked", self.new_record_button_clicked_cb) self.recordingDeleteButton = Gtk.Button (label=_("Delete"), tooltip_text=_("Delete selected sessions"), sensitive=False) self.recordingDeleteButton.connect("clicked", self.delete_button_clicked_cb) self.listStore = Gtk.ListStore (str, str, int, bool) recordingsView = Gtk.TreeView (model=self.listStore) recordingsView.connect ("row-activated", self.row_activated) # Column Recording Name recordingTitle = Gtk.CellRendererText (xalign=0) col1 = Gtk.TreeViewColumn (_("Recording name"), recordingTitle, text=m.TITLE) recordingsView.append_column (col1) # Column Date recordingDate = Gtk.CellRendererText () col2 = Gtk.TreeViewColumn (_("Date"), recordingDate, text=m.DATE) recordingsView.append_column (col2) # Column Duration recordingDuration = Gtk.CellRendererText (xalign=0) col3 = Gtk.TreeViewColumn (_("Duration"), recordingDuration, text=m.DURATION) recordingsView.append_column (col3) col3.set_cell_data_func(recordingDuration, lambda column, cell, model, iter, data: cell.set_property('text', str(timedelta (seconds=model.get_value (iter, m.DURATION)))) ) # Column for delete recordingDelete = Gtk.CellRendererToggle (xalign=0.5) recordingDelete.connect ("toggled", self.delete_toggled) col5 = Gtk.TreeViewColumn ("Delete", recordingDelete, active=m.DELETE) recordingsView.append_column (col5) col5.connect ("notify::x-offset", self.buttons_x_offset) # Box for new recording, and delete buttons self.buttonBox = Gtk.HBox (spacing=5, homogeneous=False) self.buttonBox.pack_start (self.recordButton, False, False, 3) self.buttonBox.pack_start (self.recordingDeleteButton, False, False, 3) # Box for rest of the UI which doesn't span the whole window innerVbox = Gtk.VBox (spacing=5, homogeneous=False, margin_left=5, margin_right=5) innerVbox.pack_start (self.projectLabel, False, False, 3) innerVbox.pack_start (recordingsView, False, False, 3) innerVbox.pack_start (self.buttonBox, False, False, 3) # Main container in window outterBoxLayout.pack_start (menu, False, False, 0) outterBoxLayout.pack_start (self.recordingInfoBar, False, False, 0) outterBoxLayout.pack_start (innerVbox, False, False, 0) self.mainWindow.add(outterBoxLayout) self.mainWindow.show_all() self.recordingInfoBar.hide () self.currentRecording = isrNewRecording.NewRecording (self.mainWindow) print self.mainWindow self.currentRecording.set_transient_for(self.mainWindow) self.currentRecording.startRecordButton.connect ("clicked", self.new_record_setup_done) # New Project dialog self.newProjectDialogUI = Gtk.Builder () ui_file = os.path.join(os.path.dirname(__file__), "isrnewprojectdialog.ui"); self.newProjectDialogUI.add_from_file (ui_file) dialog = self.newProjectDialogUI.get_object ("dialog-window") dialog.set_transient_for (self.mainWindow) fileChooseButton = self.newProjectDialogUI.get_object ("filechooser-button") fileChooseButton.set_current_folder (GLib.get_user_special_dir (GLib.UserDirectory.DIRECTORY_VIDEOS)) chooserEntry = self.newProjectDialogUI.get_object ("project-name") chooserEntry.connect ("activate", lambda entry: dialog.response (Gtk.ResponseType.OK)) #argv always contains at least the execuratable as the first item if (len (sys.argv) > 1): #Rudimentary check to see if this is a file we want to open if (sys.argv[1].find (".isr") > 0 or sys.argv[1].find (".dut") > 0): self.projectConfig = isrProject.isrProject (sys.argv[1], None) self.projectConfig.populate (self, m) else: print ("Warning: "+sys.argv[1]+" is not a valid project file (.isr)")
def __init__(self): self.primary = None self.secondary = None self.mux = None self.projectDir = None self.projectLabel = None self.listStore = None self.buttonBox = None self.screen = None self.projectConfig = None self.recordButton = None self.mainWindow = None self.updateTimer = None self.listItr = None self.currentRecording = None self.isRecording = False self.stopRecordButton = None self.recordingText = _("Recording in progress") Gst.init(None) self.check_gst_elements_available() signal.signal(signal.SIGINT, self.close) # UI declaration self.icon = Gtk.StatusIcon(visible=False) self.icon.set_from_stock(Gtk.STOCK_MEDIA_RECORD) self.icon.connect("activate", self.stop_record) self.mainWindow = Gtk.Window(title="Insight recorder", resizable=False, icon_name=Gtk.STOCK_MEDIA_RECORD) self.mainWindow.connect("destroy", self.on_mainWindow_destroy) self.indicator = isrIndicator.Indicator(self) outterBoxLayout = Gtk.VBox(homogeneous=False) menu = Gtk.Toolbar() menu.get_style_context().add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR) fileNew = Gtk.ToolButton.new_from_stock("gtk-new") fileNew.set_label(_("New project")) fileNew.set_tooltip_text(_("Create a new project")) fileNew.connect("clicked", self.new_folder_chooser, self.mainWindow) fileOpen = Gtk.ToolButton.new_from_stock("gtk-open") fileOpen.set_label(_("Open project")) fileOpen.connect("clicked", self.open_file_chooser, self.mainWindow) fileOpen.set_tooltip_text(_("Open an existing project")) menu.insert(fileNew, 0) menu.insert(fileOpen, 1) #InfoBar self.recordingInfoBar = Gtk.InfoBar() self.stopRecordButton = self.recordingInfoBar.add_button( _("Stop recording"), Gtk.ResponseType.OK) self.recordingInfoBar.set_message_type(Gtk.MessageType.INFO) self.recordingInfoBar.connect("response", self.stop_record) recordingInfoBarArea = self.recordingInfoBar.get_content_area() self.infoBarLabel = Gtk.Label() self.infoBarLabel.set_text(self.recordingText) recordingInfoBarArea.pack_start(self.infoBarLabel, False, False, 3) self.eosSpinner = Gtk.Spinner() self.recordingInfoBar.get_action_area().pack_start( self.eosSpinner, False, False, 3) self.eosSpinner.hide() self.projectLabel = Gtk.Label(halign=Gtk.Align.START) self.projectLabel.set_markup("<span style='italic'>" + _("No project open") + "</span>") self.recordButton = Gtk.Button( label=_("Create recording"), tooltip_text=_("Create a new recording"), sensitive=False) self.recordButton.connect("clicked", self.new_record_button_clicked_cb) self.recordingDeleteButton = Gtk.Button( label=_("Delete"), tooltip_text=_("Delete selected sessions"), sensitive=False) self.recordingDeleteButton.connect("clicked", self.delete_button_clicked_cb) self.listStore = Gtk.ListStore(str, str, int, bool) recordingsView = Gtk.TreeView(model=self.listStore) recordingsView.connect("row-activated", self.row_activated) # Column Recording Name recordingTitle = Gtk.CellRendererText(xalign=0) col1 = Gtk.TreeViewColumn(_("Recording name"), recordingTitle, text=m.TITLE) recordingsView.append_column(col1) # Column Date recordingDate = Gtk.CellRendererText() col2 = Gtk.TreeViewColumn(_("Date"), recordingDate, text=m.DATE) recordingsView.append_column(col2) # Column Duration recordingDuration = Gtk.CellRendererText(xalign=0) col3 = Gtk.TreeViewColumn(_("Duration"), recordingDuration, text=m.DURATION) recordingsView.append_column(col3) col3.set_cell_data_func( recordingDuration, lambda column, cell, model, iter, data: cell.set_property( 'text', str(timedelta(seconds=model.get_value(iter, m.DURATION))))) # Column for delete recordingDelete = Gtk.CellRendererToggle(xalign=0.5) recordingDelete.connect("toggled", self.delete_toggled) col5 = Gtk.TreeViewColumn("Delete", recordingDelete, active=m.DELETE) recordingsView.append_column(col5) col5.connect("notify::x-offset", self.buttons_x_offset) # Box for new recording, and delete buttons self.buttonBox = Gtk.HBox(spacing=5, homogeneous=False) self.buttonBox.pack_start(self.recordButton, False, False, 3) self.buttonBox.pack_start(self.recordingDeleteButton, False, False, 3) # Box for rest of the UI which doesn't span the whole window innerVbox = Gtk.VBox(spacing=5, homogeneous=False, margin_left=5, margin_right=5) innerVbox.pack_start(self.projectLabel, False, False, 3) innerVbox.pack_start(recordingsView, False, False, 3) innerVbox.pack_start(self.buttonBox, False, False, 3) # Main container in window outterBoxLayout.pack_start(menu, False, False, 0) outterBoxLayout.pack_start(self.recordingInfoBar, False, False, 0) outterBoxLayout.pack_start(innerVbox, False, False, 0) self.mainWindow.add(outterBoxLayout) self.mainWindow.show_all() self.recordingInfoBar.hide() self.currentRecording = isrNewRecording.NewRecording(self.mainWindow) print self.mainWindow self.currentRecording.set_transient_for(self.mainWindow) self.currentRecording.startRecordButton.connect( "clicked", self.new_record_setup_done) # New Project dialog self.newProjectDialogUI = Gtk.Builder() ui_file = os.path.join(os.path.dirname(__file__), "isrnewprojectdialog.ui") self.newProjectDialogUI.add_from_file(ui_file) dialog = self.newProjectDialogUI.get_object("dialog-window") dialog.set_transient_for(self.mainWindow) fileChooseButton = self.newProjectDialogUI.get_object( "filechooser-button") fileChooseButton.set_current_folder( GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_VIDEOS)) chooserEntry = self.newProjectDialogUI.get_object("project-name") chooserEntry.connect( "activate", lambda entry: dialog.response(Gtk.ResponseType.OK)) #argv always contains at least the execuratable as the first item if (len(sys.argv) > 1): #Rudimentary check to see if this is a file we want to open if (sys.argv[1].find(".isr") > 0 or sys.argv[1].find(".dut") > 0): self.projectConfig = isrProject.isrProject(sys.argv[1], None) self.projectConfig.populate(self, m) else: print("Warning: " + sys.argv[1] + " is not a valid project file (.isr)")