diff --git a/ChangeLog b/ChangeLog index 135a76851..8e7608001 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-10-18 Alex Roitman + * src/SourceView.py: Enable popup menu on right-click. + * src/PlaceView.py: Likewise. + * src/MediaView.py: Likewise. + 2003-10-17 Don Allingham * src/RelLib.py: Add a "sortbynames" to presort keys before adding to the tables diff --git a/src/MediaView.py b/src/MediaView.py index 5346da52c..25cd8bb11 100644 --- a/src/MediaView.py +++ b/src/MediaView.py @@ -18,6 +18,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# $Id$ + #------------------------------------------------------------------------- # # standard python modules @@ -168,28 +170,51 @@ class MediaView: self.mdetails.set_text(Utils.get_detail_text(mobj,0)) def on_button_press_event(self,obj,event): - store,iter = self.selection.get_selected() - if not iter: - return - id = store.get_value(iter,1) - - object = self.db.findObjectNoMap(id) if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: - ImageSelect.GlobalMediaProperties(self.db,object,self.load_media) + self.on_edit_clicked(obj) + return 1 elif event.button == 3: - menu = gtk.Menu() - menu.set_title(_("Media Object")) + self.build_context_menu() + return 1 + return 0 + + def build_context_menu(self): + menu = gtk.Menu() + menu.set_title(_("Media Object")) + + store,iter = self.selection.get_selected() + if iter: + id = store.get_value(iter,1) + object = self.db.findObjectNoMap(id) self.obj = object Utils.add_menuitem(menu,_("View in the default viewer"),None,self.popup_view_photo) if object.getMimeType()[0:5] == "image": Utils.add_menuitem(menu,_("Edit with the GIMP"),\ None,self.popup_edit_photo) - Utils.add_menuitem(menu,_("Edit Object Properties"),None, - self.popup_change_description) if object.getLocal() == 0: Utils.add_menuitem(menu,_("Convert to local copy"),None, self.popup_convert_to_private) - menu.popup(None,None,None,0,0) + item = gtk.MenuItem() + item.show() + menu.append(item) + sel_sensitivity = 1 + else: + sel_sensitivity = 0 + + entries = [ + (gtk.STOCK_ADD, self.on_add_clicked,1), + (gtk.STOCK_REMOVE, self.on_delete_clicked,sel_sensitivity), + (_("Edit properties"), self.on_edit_clicked,sel_sensitivity), + ] + + for stock_id,callback,sensitivity in entries: + item = gtk.ImageMenuItem(stock_id) + if callback: + item.connect("activate",callback) + item.set_sensitive(sensitivity) + item.show() + menu.append(item) + menu.popup(None,None,None,0,0) def popup_view_photo(self, obj): Utils.view_photo(self.obj) diff --git a/src/PlaceView.py b/src/PlaceView.py index 70c538b35..95ffaa6eb 100644 --- a/src/PlaceView.py +++ b/src/PlaceView.py @@ -18,6 +18,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# $Id$ + """ Handles the place view for GRAMPS. """ @@ -96,15 +98,6 @@ class PlaceView: self.selection = self.list.get_selection() self.list.connect('button-press-event',self.button_press) - def button_press(self,obj,event): - if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: - store,iter = self.selection.get_selected() - id = store.get_value(iter,1) - source = self.db.getPlace(id) - EditPlace.EditPlace(self, place, self.update_display) - return 1 - return 0 - def change_db(self,db): self.db = db @@ -162,8 +155,37 @@ class PlaceView: if mlist: EditPlace.EditPlace(self,mlist[0],self.update_display) return 1 + elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: + self.build_context_menu() + return 1 return 0 + def build_context_menu(self): + """Builds the menu with editing operations on the place's list""" + + mlist = [] + self.selection.selected_foreach(self.blist,mlist) + if mlist: + sel_sensitivity = 1 + else: + sel_sensitivity = 0 + entries = [ + (gtk.STOCK_ADD, self.on_add_place_clicked,1), + (gtk.STOCK_REMOVE, self.on_delete_clicked,sel_sensitivity), + (_("Edit"), self.on_edit_clicked,sel_sensitivity), + ] + + menu = gtk.Menu() + menu.set_title(_('Source Menu')) + for stock_id,callback,sensitivity in entries: + item = gtk.ImageMenuItem(stock_id) + if callback: + item.connect("activate",callback) + item.set_sensitive(sensitivity) + item.show() + menu.append(item) + menu.popup(None,None,None,0,0) + def new_place_after_edit(self,place): #self.db.addPlace(place) self.update(0) diff --git a/src/SourceView.py b/src/SourceView.py index bc711c5c4..956884783 100644 --- a/src/SourceView.py +++ b/src/SourceView.py @@ -18,6 +18,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# $Id$ + #------------------------------------------------------------------------- # # standard python modules @@ -120,8 +122,36 @@ class SourceView: source = self.db.getSource(id) EditSource.EditSource(source,self.db,self.topWindow,self.update_display) return 1 + elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: + self.build_context_menu() + return 1 return 0 + def build_context_menu(self): + """Builds the menu with editing operations on the source's list""" + + store,iter = self.selection.get_selected() + if iter: + sel_sensitivity = 1 + else: + sel_sensitivity = 0 + entries = [ + (gtk.STOCK_ADD, self.on_add_clicked,1), + (gtk.STOCK_REMOVE, self.on_delete_clicked,sel_sensitivity), + (_("Edit"), self.on_edit_clicked,sel_sensitivity), + ] + + menu = gtk.Menu() + menu.set_title(_('Source Menu')) + for stock_id,callback,sensitivity in entries: + item = gtk.ImageMenuItem(stock_id) + if callback: + item.connect("activate",callback) + item.set_sensitive(sensitivity) + item.show() + menu.append(item) + menu.popup(None,None,None,0,0) + def on_add_clicked(self,obj): EditSource.EditSource(RelLib.Source(),self.db,self.topWindow,self.new_after_edit)