def __init__(self, main, parent): ## Shows the preferences dialogue. # Sets some variables for easier access. self.main = main # Create the dialogue and connect signals using gtk-builder. windowname = 'PreferencesDlg' self.wTree = gtk.Builder() self.wTree.add_from_file(useful.getBuilderFile('preferences')) dic = { "on_PreferencesDlg_delete_event" : self.closeWindow, "on_checkbox_toggled" : self.checkboxToggle, "on_scrollbar_changed" : self.adjustmentChanged, "on_spinbutton_changed" : self.adjustmentChanged, "on_cmbOnExtNewFile_changed" : self.extNewFileChanged, "on_entry_changed" : self.entryChanged, "on_btnVideoDefaults_clicked" : self.resetVideoDefaults, "on_btnClose_clicked" : self.closeWindow } self.wTree.connect_signals(dic) # Create a dictionary for checkboxes and their associated settings. self.chkDic = { self.wTree.get_object('chkInstantSeek') : {CFGS : "gui/instantseek"}, self.wTree.get_object('chkDisableScreensaver') : {CFGS : "misc/disablescreensaver"}, self.wTree.get_object('chkShowTimeRemaining') : {CFGS : "gui/showtimeremaining"}, self.wTree.get_object('chkEnableVisualisation') : {CFGS : "gui/enablevisualisation", CLBKS : self.toggleEnableVis}, self.wTree.get_object('chkFileAsTitle') : {CFGS : "gui/fileastitle"}, self.wTree.get_object('chkForceAspect') : {CFGS : "video/force-aspect-ratio", CLBKS : self.toggleForceAspect} } # And one for the scrollbars. clrCbk = self.scrollbarColourScroll self.adjDic = { self.wTree.get_object('spnMouseTimeout') : {CFGS : "gui/mousehidetimeout"}, self.wTree.get_object('hscBrightness') : {CFGS : "video/brightness", CLBKS : clrCbk}, self.wTree.get_object('hscContrast') : {CFGS : "video/contrast", CLBKS : clrCbk}, self.wTree.get_object('hscHue') : {CFGS : "video/hue", CLBKS : clrCbk}, self.wTree.get_object('hscSaturation') : {CFGS : "video/saturation", CLBKS : clrCbk} } # And entries. self.entDic = {self.wTree.get_object('entTagSyntax') : {CFGS : "gui/tagsyntax"}} # More easy access. self.window = self.wTree.get_object(windowname) # Set the parent window to the widget passed (hopefully the main window.) self.window.set_transient_for(parent) self.prepareAudioDevCmb() # Load the preferences. self.loadPreferences() # Run the dialogue. self.window.run()
def __init__(self): # Set the last folder to the directory from which the program was called. useful.lastFolder = useful.origDir # Set the application's name (for about dialogue etc). gobject.set_application_name(str(useful.lName)) # Create & prepare the player for playing. self.preparePlayer() # Connect up the sigterm signal. signal.signal(signal.SIGTERM, self.sigterm) if msgBus.avail: self.dbus = msgBus.IntObject(self) # Set up the gtk-builder and interface. self.wTree = gtk.Builder() windowname = "main" self.wTree.add_from_file(useful.getBuilderFile('main')) dic = { "on_main_delete_event" : self.quit, "on_mnuiQuit_activate" : self.quit, "on_mnuiOpen_activate" : self.showOpenDialogue, "on_mnuiOpenURI_activate" : self.showOpenURIDialogue, "on_btnPlayToggle_clicked" : self.togglePlayPause, "on_btnStop_clicked" : self.stopPlayer, "on_btnNext_clicked" : self._cb_on_btnNext_clicked, "on_btnRestart_clicked" : self.restartTrack, "on_pbarProgress_button_press_event" : self.progressBarClick, "on_pbarProgress_button_release_event" : self.seekEnd, "on_pbarProgress_motion_notify_event" : self.progressBarMotion, "on_btnVolume_value_changed" : self.changeVolume, "on_mnuiFS_activate" : self.toggleFullscreen, "on_btnLeaveFullscreen_clicked" : self.toggleFullscreen, "on_videoWindow_expose_event" : self.videoWindowExpose, "on_videoWindow_configure_event" : self.videoWindowConfigure, "on_main_key_press_event" : self.windowKeyPressed, "on_videoWindow_button_press_event" : self.videoWindowClicked, "on_videoWindow_scroll_event" : self.videoWindowScroll, "on_mnuiAbout_activate" : self.showAboutDialogue, "on_main_drag_data_received" : self.openDroppedFiles, "on_videoWindow_motion_notify_event" : self.videoWindowMotion, "on_videoWindow_leave_notify_event" : self.videoWindowLeave, "on_videoWindow_enter_notify_event" : self.videoWindowEnter, "on_mnuiPreferences_activate" : self.showPreferencesDialogue, "on_mnuiPlayDVD_activate" : self.showPlayDVDDialogue, "on_mnuiDVDMenu_activate" : self.gotoDVDMenu, "on_mnuiAudioTrack_activate" : self.showAudioTracksDialogue, "on_mnuiSubtitleManager_activate" : self.openSubtitleManager, "on_mnuiReportBug_activate" : self.openBugReporter, "on_main_window_state_event" : self.onMainStateEvent, "on_mnuiQueue_toggled" : self.toggleQueueWindow, "on_eventNumQueued_button_release_event" : self.toggleQueueWindow, "on_mnuiAdvCtrls_toggled" : self.toggleAdvControls, "on_mnuiSupFeatures_activate" : self.openSupFeaturesDlg, "on_spnPlaySpeed_value_changed" : self.onPlaySpeedChange } self.wTree.connect_signals(dic) # Add the queue to the queue box. self.wTree.get_object("queueBox").pack_start(queue.qwin) # Get several items for access later. useful.mainWin = self.mainWindow = self.wTree.get_object(windowname) self.progressBar = self.wTree.get_object("pbarProgress") self.videoWindow = self.wTree.get_object("videoWindow") self.nowPlyLbl = self.wTree.get_object("lblNowPlaying") self.volAdj = self.wTree.get_object("btnVolume").get_adjustment() self.hboxVideo = self.wTree.get_object("hboxVideo") queue.mnuiWidget = self.wTree.get_object("mnuiQueue") # Set gapless flag self.isvideo = None # Set the icon. self.mainWindow.set_icon_from_file(os.path.join(useful.dataDir, 'images', 'whaawmp48.png')) # Set the window to allow drops self.mainWindow.drag_dest_set(gtk.DEST_DEFAULT_ALL, [("text/uri-list", 0, 0)], gtk.gdk.ACTION_COPY) # If we drop stuff on the queue label we want it queued (bottom right) self.wTree.get_object('lblNumQueued').drag_dest_set(gtk.DEST_DEFAULT_ALL, [("text/uri-list", 0, 0)], gtk.gdk.ACTION_COPY) self.wTree.get_object('lblNumQueued').connect('drag-data-received', queue.enqueueDropped) # Update the progress bar. self.progressUpdate() # Get the volume from the configuration. volVal = cfg.getFloat("audio/volume") if (cfg.cl.volume == None) else float(cfg.cl.volume) self.volAdj.value = useful.toRange(volVal, 0, 1) # Set the quit on stop checkbox. self.wTree.get_object("mnuiQuitOnStop").set_active(cfg.cl.quitOnEnd) # Set up the default flags. self.controlsShown = True self.seeking = False # Call the function to change the play/pause image. self.playPauseChange(False) # Show the next button & restart track button if enabled. if (cfg.getBool("gui/shownextbutton")): self.wTree.get_object("btnNext").show() if (cfg.getBool("gui/showrestartbutton")): self.wTree.get_object("btnRestart").show() # Setup the signals. signals.connect('toggle-play-pause', self.togglePlayPause) signals.connect('toggle-fullscreen', self.toggleFullscreen) signals.connect('play-next', self.playNext, False) signals.connect('restart-track', self.restartTrack) signals.connect('toggle-queue', queue.toggle) signals.connect('toggle-advanced-controls', self.toggleAdvancedControls) signals.connect('queue-changed', self.numQueuedChanged) # Show the window. self.mainWindow.show() # Save the windows ID so we can use it to inhibit screensaver. useful.winID = self.mainWindow.get_window().xid # Set the queue play command, so it can play tracks. queue.playCommand = self.playFile # Play a file (if it was specified on the command line). if (len(cfg.args) > 0): # Append all tracks to the queue. queue.appendMany(cfg.args) # Then play the next track. gobject.idle_add(self.playNext, False) if (cfg.cl.fullscreen): # If the fullscreen option was passed, start fullscreen. self.activateFullscreen() # Connect the hooks. self.connectLinkHooks() # Enter the GTK main loop. gtk.main()