/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to olive/frontend/gtk/__init__.py

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2006-08-08 18:32:32 UTC
  • mto: (0.14.1 main) (93.1.1 win32.bialix)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060808183232-e27b1b45f7487da8
Implemented bookmarking.

2006-08-08  Szilveszter Farkas <Szilveszter.Farkas@gmail.com>
    * olive/frontend/gtk/menu.py: Added left context menu + Bookmark option
    * olive/frontend/gtk/__init__.py: load bookmarks into the left panel
    * olive/frontend/gtk/handler.py: implemented signal handlers for left panel
    * olive.glade: added signals for the bookmark TreeView
    * cmenu.ui: added description for bookmark context menu

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
 
17
import ConfigParser
17
18
import os
18
19
import os.path
19
20
import sys
78
79
                "on_toolbutton_pull_clicked": handler.not_implemented,
79
80
                "on_toolbutton_push_clicked": handler.on_menuitem_branch_push_activate,
80
81
                "on_treeview_right_button_press_event": handler.on_treeview_right_button_press_event,
81
 
                "on_treeview_right_row_activated": handler.on_treeview_right_row_activated }
 
82
                "on_treeview_right_row_activated": handler.on_treeview_right_row_activated,
 
83
                "on_treeview_left_button_press_event": handler.on_treeview_left_button_press_event,
 
84
                "on_treeview_left_row_activated": handler.on_treeview_left_row_activated }
82
85
        
83
86
        # Connect the signals to the handlers
84
87
        self.toplevel.signal_autoconnect(dic)
91
94
        
92
95
    def _load_left(self):
93
96
        """ Load data into the left panel. (Bookmarks) """
94
 
        pass
 
97
        # set cursor to busy
 
98
        self.comm.set_busy(self.treeview_left)
 
99
        
 
100
        # Create TreeStore
 
101
        treestore = gtk.TreeStore(str)
 
102
        
 
103
        # Get bookmarks
 
104
        bookmarks = self.comm.pref.get_bookmarks()
 
105
        
 
106
        # Add them to the TreeStore
 
107
        titer = treestore.append(None, ['Bookmarks'])
 
108
        for item in bookmarks:
 
109
            treestore.append(titer, [item])
 
110
        
 
111
        # Create the column and add it to the TreeView
 
112
        self.treeview_left.set_model(treestore)
 
113
        tvcolumn_bookmark = gtk.TreeViewColumn('Bookmark')
 
114
        self.treeview_left.append_column(tvcolumn_bookmark)
 
115
        
 
116
        # Set up the cells
 
117
        cell = gtk.CellRendererText()
 
118
        tvcolumn_bookmark.pack_start(cell, True)
 
119
        tvcolumn_bookmark.add_attribute(cell, 'text', 0)
 
120
        
 
121
        # Expand the tree
 
122
        self.treeview_left.expand_all()
 
123
        
 
124
        self.comm.set_busy(self.treeview_left, False)
95
125
        
96
126
    def _load_right(self):
97
127
        """ Load data into the right panel. (Filelist) """
185
215
            return None
186
216
        else:
187
217
            return model.get_value(iter, 1)
 
218
    
 
219
    def get_selected_left(self):
 
220
        """ Get the selected bookmark. """
 
221
        treeselection = self.treeview_left.get_selection()
 
222
        (model, iter) = treeselection.get_selected()
 
223
        
 
224
        if iter is None:
 
225
            return None
 
226
        else:
 
227
            return model.get_value(iter, 0)
188
228
 
189
229
    def set_statusbar(self, message):
190
230
        """ Set the statusbar message. """
194
234
        """ Clean the last message from the statusbar. """
195
235
        self.statusbar.pop(self.context_id)
196
236
    
 
237
    def refresh_left(self):
 
238
        """ Refresh the bookmark list. """
 
239
        # set cursor to busy
 
240
        self.set_busy(self.treeview_left)
 
241
        
 
242
        # Get TreeStore and clear it
 
243
        treestore = self.treeview_left.get_model()
 
244
        treestore.clear()
 
245
        
 
246
        # Get bookmarks
 
247
        bookmarks = self.pref.get_bookmarks()
 
248
        
 
249
        # Add them to the TreeStore
 
250
        titer = treestore.append(None, ['Bookmarks'])
 
251
        for item in bookmarks:
 
252
            treestore.append(titer, [item])
 
253
        
 
254
        # Add the TreeStore to the TreeView
 
255
        self.treeview_left.set_model(treestore)
 
256
        
 
257
        # Expand the tree
 
258
        self.treeview_left.expand_all()
 
259
        
 
260
        self.set_busy(self.treeview_left, False)
 
261
    
197
262
    def refresh_right(self, path=None):
198
263
        """ Refresh the file list. """
199
264
        import olive.backend.fileops as fileops
247
312
    """ A class which handles Olive's preferences. """
248
313
    def __init__(self):
249
314
        """ Initialize the Preferences class. """
250
 
        import ConfigParser
251
 
        
252
315
        # Some default options
253
316
        self.defaults = { 'strict_commit': False,
254
317
                          'dotted_files' : False }
336
399
        """ Add bookmark. """
337
400
        try:
338
401
            self.config.add_section(path)
339
 
        except DuplicateSectionError:
 
402
        except ConfigParser.DuplicateSectionError:
340
403
            return False
341
404
        else:
342
405
            return True
343
406
 
344
 
    def del_bookmark(self, path):
 
407
    def remove_bookmark(self, path):
345
408
        """ Remove bookmark. """
346
409
        return self.config.remove_section(path)