Changeset 326
- Timestamp:
- 06/23/06 19:40:28 (3 years ago)
- Files:
-
- trunk/src/main_window.py (modified) (8 diffs)
- trunk/src/mesk_gui.glade (modified) (4 diffs)
- trunk/src/playlist_control.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main_window.py
r325 r326 74 74 self._audio_control) 75 75 76 self._active_playlist = None 76 # The active control is the one that has ownership of the AudioControl 77 self._active_control = None 78 77 79 # Load playlists 78 80 playlists = mesk.config.getlist(mesk.CONFIG_MAIN, 'playlists') … … 98 100 99 101 self.add_notebook_control(pl_ctrl) 100 if not self._active_ playlist:101 self.set_ control_active(pl_ctrl)102 if not self._active_control: 103 self.set_active_control(pl_ctrl) 102 104 103 105 self._pref_window = None … … 107 109 108 110 def _on_playlist_ctrl_changed(self, ctrl): 109 if ctrl == self._active_ playlist:111 if ctrl == self._active_control: 110 112 if not len(ctrl.get_playlist()): 111 113 self._album_cover_control.clear() … … 113 115 def _on_control_request_active(self, ctrl): 114 116 # A control is requesting the AudioControl. Grant it. 115 self.set_ control_active(ctrl)116 117 def set_ control_active(self, ctrl):118 if ctrl == self._active_ playlist:117 self.set_active_control(ctrl) 118 119 def set_active_control(self, ctrl): 120 if ctrl == self._active_control: 119 121 return 120 122 self._audio_control.stop() 121 if self._active_ playlist:122 self._active_ playlist.set_active(False, None)123 124 self._active_ playlist= ctrl125 pl = self._active_ playlist.get_playlist()123 if self._active_control: 124 self._active_control.set_active(False, None) 125 126 self._active_control = ctrl 127 pl = self._active_control.get_playlist() 126 128 self._audio_control.set_playlist(pl) 127 self._active_ playlist.set_active(True, self._audio_control)129 self._active_control.set_active(True, self._audio_control) 128 130 129 131 def add_notebook_control(self, ctrl): … … 134 136 if self._notebook.get_n_pages() > 1: 135 137 self._notebook.set_show_tabs(True) 138 # This list order does not necessarily correspond to the tab order 136 139 self._controls.append(ctrl) 137 140 138 141 def remove_notebook_control(self, ctrl): 139 # FIXME: Transition active tab if necessary 140 page = self._notebook.page_num(ctrl.widget) 142 if self._notebook.get_n_pages() == 1: 143 raise RuntimeError('Notebook MUST have at least one page') 144 145 page_num = self._notebook.page_num(ctrl.widget) 146 new_active = False 147 148 # Transition active tab if necessary 149 if ctrl == self._active_control: 150 new_active = True 151 ctrl.set_active(False) 152 153 # Remove 141 154 self._controls.remove(ctrl) 142 self._notebook.remove_page(page )155 self._notebook.remove_page(page_num) 143 156 if self._notebook.get_n_pages() == 1: 144 157 self._notebook.set_show_tabs(False) 145 158 159 # Set the new active control 160 if new_active: 161 page = self._notebook.get_current_page() 162 page = self._notebook.get_nth_page(page) 163 ctrl = self._get_control_from_widget(page) 164 self.set_active_control(ctrl) 165 166 def _get_control_from_widget(self, widget): 167 for ctrl in self._controls: 168 if ctrl.widget == widget: 169 return ctrl 170 return None 171 172 def get_focused_control(self): 173 curr = self._notebook.get_current_page() 174 page_widget = self._notebook.get_nth_page(curr) 175 return self._get_control_from_widget(page_widget) 176 146 177 def _on_window_focus_in_event(self, window, event): 147 active_control = self.get_showing_control() 148 if active_control: 149 active_control.set_focused() 178 active_control = self.get_focused_control() 179 active_control.set_focused() 150 180 151 181 def _on_notebook_switch_page(self, notebook, page, page_num): … … 157 187 def _on_tab_close_button_clicked(self, widget, ctrl): 158 188 self.remove_notebook_control(ctrl) 159 160 def get_showing_control(self):161 curr = self._notebook.get_current_page()162 page_widget = self._notebook.get_nth_page(curr)163 return self._get_control_from_widget(page_widget)164 165 def _get_control_from_widget(self, widget):166 for ctrl in self._controls:167 if ctrl.widget == widget:168 return ctrl169 return None170 189 171 190 def show(self): … … 283 302 if (event.keyval == gtk.keysyms.w and 284 303 self._notebook.get_n_pages() > 1): 285 self.remove_notebook_control(self.get_ showing_control())304 self.remove_notebook_control(self.get_focused_control()) 286 305 return True 287 306 return False … … 319 338 _('Volume %d%%') % (vol * 100)) 320 339 340 trunk/src/mesk_gui.glade
r325 r326 45 45 46 46 <child> 47 <widget class="GtkMenuItem" id="open_playlist"> 48 <property name="visible">True</property> 49 <property name="label" translatable="yes">Open Playlist</property> 47 <widget class="GtkImageMenuItem" id="new_playlist"> 48 <property name="visible">True</property> 49 <property name="label" translatable="yes">New</property> 50 <property name="use_underline">True</property> 51 <signal name="activate" handler="on_new_playlist_activate" last_modification_time="Fri, 23 Jun 2006 03:17:11 GMT"/> 52 53 <child internal-child="image"> 54 <widget class="GtkImage" id="image91"> 55 <property name="visible">True</property> 56 <property name="stock">gtk-new</property> 57 <property name="icon_size">1</property> 58 <property name="xalign">0.5</property> 59 <property name="yalign">0.5</property> 60 <property name="xpad">0</property> 61 <property name="ypad">0</property> 62 </widget> 63 </child> 64 </widget> 65 </child> 66 67 <child> 68 <widget class="GtkImageMenuItem" id="open_playlist"> 69 <property name="visible">True</property> 70 <property name="label" translatable="yes">Open...</property> 50 71 <property name="use_underline">True</property> 51 72 <signal name="activate" handler="on_open_playlist_activate" last_modification_time="Fri, 23 Jun 2006 03:17:11 GMT"/> 52 </widget> 53 </child> 54 55 <child> 56 <widget class="GtkMenuItem" id="new_playlist"> 57 <property name="visible">True</property> 58 <property name="label" translatable="yes">New Playlist</property> 59 <property name="use_underline">True</property> 60 <signal name="activate" handler="on_new_playlist_activate" last_modification_time="Fri, 23 Jun 2006 03:17:11 GMT"/> 73 74 <child internal-child="image"> 75 <widget class="GtkImage" id="image92"> 76 <property name="visible">True</property> 77 <property name="stock">gtk-open</property> 78 <property name="icon_size">1</property> 79 <property name="xalign">0.5</property> 80 <property name="yalign">0.5</property> 81 <property name="xpad">0</property> 82 <property name="ypad">0</property> 83 </widget> 84 </child> 61 85 </widget> 62 86 </child> … … 99 123 100 124 <child internal-child="image"> 101 <widget class="GtkImage" id="image 69">125 <widget class="GtkImage" id="image93"> 102 126 <property name="visible">True</property> 103 127 <property name="stock">gtk-preferences</property> … … 158 182 159 183 <child internal-child="image"> 160 <widget class="GtkImage" id="image 70">184 <widget class="GtkImage" id="image94"> 161 185 <property name="visible">True</property> 162 186 <property name="stock">gtk-help</property> … … 179 203 180 204 <child internal-child="image"> 181 <widget class="GtkImage" id="image 71">205 <widget class="GtkImage" id="image95"> 182 206 <property name="visible">True</property> 183 207 <property name="stock">gtk-about</property> trunk/src/playlist_control.py
r318 r326 239 239 240 240 def set_active(self, active = True, audio_ctrl = None): 241 241 242 if not active: 243 if self._audio_control: 244 self._audio_control.stop() 242 245 self._audio_control = None 243 246 else:
