Added menubar items corresponding to almost all context menu items.
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 21 Jul 2004 15:05:56 +0000 (15:05 +0000)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 21 Jul 2004 15:05:56 +0000 (15:05 +0000)
12 files changed:
src/gkofoto/albums.py
src/gkofoto/categories.py
src/gkofoto/glade/gkofoto.glade
src/gkofoto/icons/about-icon.png [new file with mode: 0644]
src/gkofoto/icons/rotateleft.png [new file with mode: 0644]
src/gkofoto/icons/rotateright.png [new file with mode: 0644]
src/gkofoto/mainwindow.py
src/gkofoto/menuhandler.py
src/gkofoto/objectcollection.py
src/gkofoto/objectcollectionview.py
src/gkofoto/singleobjectview.py
src/gkofoto/tableview.py

index 0e136e6..8e4fbac 100644 (file)
@@ -28,17 +28,20 @@ class Albums:
         self.__mainWindow = mainWindow
         self.__albumView = env.widgets["albumView"]
         self.__albumView.set_model(self.__albumModel)
+        self.__albumView.connect("focus-in-event", self._treeViewFocusInEvent)
+        self.__albumView.connect("focus-out-event", self._treeViewFocusOutEvent)
         renderer = gtk.CellRendererText()
         column = gtk.TreeViewColumn("Albums", renderer, text=self.__COLUMN_TEXT)
         column.set_clickable(True)
         self.__albumView.append_column(column)
         albumSelection = self.__albumView.get_selection()
-        albumSelection.connect('changed', self._albumSelectionUpdated)
+        albumSelection.connect("changed", self._albumSelectionUpdated)
         albumSelection.set_select_function(self._isSelectable, self.__albumModel)
         self.__contextMenu = self.__createContextMenu()
         self._albumSelectionUpdated()
         self.__albumView.connect("button_press_event", self._button_pressed)
         self.loadAlbumTree()
+        self._connectedOids = []
 
     def loadAlbumTree(self):
         env.shelf.flushObjectCache()
@@ -53,7 +56,7 @@ class Albums:
     def _isSelectable(self, path, model):
         return model[path][self.__COLUMN_SELECTABLE]
 
-    def _albumSelectionUpdated(self, selection=None):
+    def _albumSelectionUpdated(self, selection=None, load=True):
         if not selection:
             selection = self.__albumView.get_selection()
         albumModel, iterator =  self.__albumView.get_selection().get_selected()
@@ -63,13 +66,18 @@ class Albums:
         editMenuItem = self.__menuGroup[self.__editAlbumLabel]
         if iterator:
             albumTag = albumModel.get_value(iterator, self.__COLUMN_TAG)
-            self.__mainWindow.loadQuery("/" + albumTag.decode("utf-8"))
+            if load:
+                self.__mainWindow.loadQuery("/" + albumTag.decode("utf-8"))
             album = env.shelf.getAlbum(
                 albumModel.get_value(iterator, self.__COLUMN_ALBUM_ID))
             createMenuItem.set_sensitive(album.isMutable())
+            env.widgets["menubarCreateAlbumChild"].set_sensitive(album.isMutable())
             registerMenuItem.set_sensitive(album.isMutable())
+            env.widgets["menubarRegisterAndAddImages"].set_sensitive(album.isMutable())
             destroyMenuItem.set_sensitive(album != env.shelf.getRootAlbum())
+            env.widgets["menubarDestroy"].set_sensitive(album != env.shelf.getRootAlbum())
             editMenuItem.set_sensitive(True)
+            env.widgets["menubarProperties"].set_sensitive(True)
         else:
             createMenuItem.set_sensitive(False)
             registerMenuItem.set_sensitive(False)
@@ -145,6 +153,36 @@ class Albums:
         else:
             return False
 
+    def _treeViewFocusInEvent(self, widget, event):
+        self._albumSelectionUpdated(None, load=False)
+        for widgetName, function in [
+                ("menubarCreateAlbumChild", self._createChildAlbum),
+                ("menubarRegisterAndAddImages", self._registerImages),
+                ("menubarProperties", self._editAlbum),
+                ]:
+            oid = env.widgets[widgetName].connect("activate", function, None)
+            self._connectedOids.append((env.widgets[widgetName], oid))
+        for widgetName, function in [
+                ("menubarCreateAlbumChild", self._createChildAlbum),
+                ("menubarRegisterAndAddImages", self._registerImages),
+                ("menubarProperties", self._editAlbum),
+                ("menubarDestroy", self._destroyAlbum),
+                ]:
+            w = env.widgets[widgetName]
+            oid = w.connect("activate", function, None)
+            self._connectedOids.append((w, oid))
+
+    def _treeViewFocusOutEvent(self, widget, event):
+        for (widget, oid) in self._connectedOids:
+            widget.disconnect(oid)
+        self._connectedOids = []
+        for widgetName in [
+                "menubarCreateAlbumChild",
+                "menubarRegisterAndAddImages",
+                "menubarProperties",
+                ]:
+            env.widgets[widgetName].set_sensitive(False)
+
 ###############################################################################
 ### Private
 
@@ -178,12 +216,14 @@ class Albums:
 
     def __createContextMenu(self):
         self.__menuGroup = MenuGroup()
-        self.__menuGroup.addMenuItem(self.__createAlbumLabel,
-                                     self._createChildAlbum)
-        self.__menuGroup.addMenuItem(self.__registerImagesLabel,
-                                     self._registerImages)
-        self.__menuGroup.addMenuItem(self.__destroyAlbumLabel,
-                                     self._destroyAlbum)
-        self.__menuGroup.addMenuItem(self.__editAlbumLabel,
-                                     self._editAlbum)
+        self.__menuGroup.addMenuItem(
+            self.__createAlbumLabel, self._createChildAlbum)
+        self.__menuGroup.addMenuItem(
+            self.__registerImagesLabel, self._registerImages)
+        self.__menuGroup.addMenuItem(
+            self.__destroyAlbumLabel, self._destroyAlbum)
+        self.__menuGroup.addStockImageMenuItem(
+            self.__editAlbumLabel,
+            gtk.STOCK_PROPERTIES,
+            self._editAlbum)
         return self.__menuGroup.createGroupMenu()
index a8ca362..027a9f8 100644 (file)
@@ -4,6 +4,7 @@ import string
 
 from environment import env
 from categorydialog import CategoryDialog
+from menuhandler import *
 from kofoto.search import *
 from kofoto.shelf import *
 
@@ -24,6 +25,8 @@ class Categories:
         self.__categoryView = env.widgets["categoryView"]
         self.__categoryView.realize()
         self.__categoryView.set_model(self.__categoryModel)
+        self.__categoryView.connect("focus-in-event", self._categoryViewFocusInEvent)
+        self.__categoryView.connect("focus-out-event", self._categoryViewFocusOutEvent)
         self.__mainWindow = mainWindow
 
         # Create toggle column
@@ -46,45 +49,47 @@ class Categories:
         #      If not, create some helper functions to construct the menu...
         self._contextMenu = gtk.Menu()
 
-        self._cutItem = gtk.MenuItem("Cut")
-        self._cutItem.show()
-        self._cutItem.connect("activate", self._cutCategory, None)
-        self._contextMenu.append(self._cutItem)
-
-        self._copyItem = gtk.MenuItem("Copy")
-        self._copyItem.show()
-        self._copyItem.connect("activate", self._copyCategory, None)
-        self._contextMenu.append(self._copyItem)
-
-        self._pasteItem = gtk.MenuItem("Paste as child(ren)")
-        self._pasteItem.show()
-        self._pasteItem.connect("activate", self._pasteCategory, None)
-        self._contextMenu.append(self._pasteItem)
-
-        self._deleteItem = gtk.MenuItem("Destroy...")
-        self._deleteItem.show()
-        self._deleteItem.connect("activate", self._deleteCategories, None)
-        self._contextMenu.append(self._deleteItem)
-
-        self._disconnectItem = gtk.MenuItem("Disconnect from parent")
-        self._disconnectItem.show()
-        self._disconnectItem.connect("activate", self._disconnectCategory, None)
-        self._contextMenu.append(self._disconnectItem)
-
-        self._createChildItem = gtk.MenuItem("Create child")
-        self._createChildItem.show()
-        self._createChildItem.connect("activate", self._createChildCategory, None)
-        self._contextMenu.append(self._createChildItem)
-
-        self._createRootItem = gtk.MenuItem("Create root")
-        self._createRootItem.show()
-        self._createRootItem.connect("activate", self._createRootCategory, None)
-        self._contextMenu.append(self._createRootItem)
-
-        self._propertiesItem = gtk.MenuItem("Properties")
-        self._propertiesItem.show()
-        self._propertiesItem.connect("activate", self._editProperties, None)
-        self._contextMenu.append(self._propertiesItem)
+        self._contextMenuGroup = MenuGroup()
+        self._contextMenuGroup.addStockImageMenuItem(
+            self.__cutCategoryLabel,
+            gtk.STOCK_CUT,
+            self._cutCategory)
+        self._contextMenuGroup.addStockImageMenuItem(
+            self.__copyCategoryLabel,
+            gtk.STOCK_COPY,
+            self._copyCategory)
+        self._contextMenuGroup.addStockImageMenuItem(
+            self.__pasteCategoryLabel,
+            gtk.STOCK_PASTE,
+            self._pasteCategory)
+        self._contextMenuGroup.addStockImageMenuItem(
+            self.__destroyCategoryLabel,
+            gtk.STOCK_DELETE,
+            self._deleteCategories)
+        self._contextMenuGroup.addMenuItem(
+            self.__disconnectCategoryLabel,
+            self._disconnectCategory)
+        self._contextMenuGroup.addMenuItem(
+            self.__createChildCategoryLabel,
+            self._createChildCategory)
+        self._contextMenuGroup.addMenuItem(
+            self.__createRootCategoryLabel,
+            self._createRootCategory)
+        self._contextMenuGroup.addStockImageMenuItem(
+            self.__propertiesLabel,
+            gtk.STOCK_PROPERTIES,
+            self._editProperties)
+
+        for item in self._contextMenuGroup:
+            self._contextMenu.append(item)
+
+        # Init menubar items.
+        env.widgets["menubarDisconnectFromParent"].connect(
+            "activate", self._disconnectCategory, None)
+        env.widgets["menubarCreateChild"].connect(
+            "activate", self._createChildCategory, None)
+        env.widgets["menubarCreateRoot"].connect(
+            "activate", self._createRootCategory, None)
 
         # Init selection functions
         categorySelection = self.__categoryView.get_selection()
@@ -131,6 +136,26 @@ class Categories:
         if query:
             self.__mainWindow.loadQuery(query)
 
+    def _categoryViewFocusInEvent(self, widget, event):
+        self._menubarOids = []
+        for widgetName, function in [
+                ("menubarCut", lambda *x: self._cutCategory(None, None)),
+                ("menubarCopy", lambda *x: self._copyCategory(None, None)),
+                ("menubarPaste", lambda *x: self._pasteCategory(None, None)),
+                ("menubarDestroy", lambda *x: self._deleteCategories(None, None)),
+                ("menubarClear", lambda *x: widget.get_selection().unselect_all()),
+                ("menubarSelectAll", lambda *x: widget.get_selection().select_all()),
+                ("menubarProperties", lambda *x: self._editProperties(None, None)),
+                ]:
+            w = env.widgets[widgetName]
+            oid = w.connect("activate", function)
+            self._menubarOids.append((w, oid))
+        self.__updateContextMenu()
+
+    def _categoryViewFocusOutEvent(self, widget, event):
+        for (widget, oid) in self._menubarOids:
+            widget.disconnect(oid)
+
     def _categorySelectionChanged(self, selection):
         selectedCategoryRows = []
         selection = self.__categoryView.get_selection()
@@ -301,6 +326,15 @@ class Categories:
 ######################################################################
 ### Private
 
+    __cutCategoryLabel = "Cut"
+    __copyCategoryLabel = "Copy"
+    __pasteCategoryLabel = "Paste as child(ren)"
+    __destroyCategoryLabel = "Destroy..."
+    __disconnectCategoryLabel = "Disconnect from parent"
+    __createChildCategoryLabel = "Create child"
+    __createRootCategoryLabel = "Create root"
+    __propertiesLabel = "Properties"
+
     __COLUMN_CATEGORY_ID  = 0
     __COLUMN_DESCRIPTION  = 1
     __COLUMN_CONNECTED    = 2
@@ -326,27 +360,35 @@ class Categories:
 
     def __updateContextMenu(self):
         # TODO Create helper functions to use from this method
+        menubarWidgetNames = [
+                "menubarCut",
+                "menubarCopy",
+                "menubarPaste",
+                "menubarDestroy",
+                "menubarProperties",
+                "menubarDisconnectFromParent",
+                "menubarCreateChild",
+                "menubarCreateRoot",
+                ]
         if len(self.__selectedCategoriesIds) == 0:
-            self._deleteItem.set_sensitive(False)
-            self._createChildItem.set_sensitive(False)
-            self._copyItem.set_sensitive(False)
-            self._cutItem.set_sensitive(False)
-            self._pasteItem.set_sensitive(False)
-            self._disconnectItem.set_sensitive(False)
-        else:
-            self._deleteItem.set_sensitive(True)
-            self._createChildItem.set_sensitive(True)
-            self._copyItem.set_sensitive(True)
-            self._cutItem.set_sensitive(True)
-            if env.clipboard.hasCategories():
-                self._pasteItem.set_sensitive(True)
-            else:
-                self._pasteItem.set_sensitive(False)
-            self._disconnectItem.set_sensitive(True)
-        if len(self.__selectedCategoriesIds) == 1:
-            self._propertiesItem.set_sensitive(True)
+            self._contextMenuGroup.disable()
+            for widgetName in menubarWidgetNames:
+                env.widgets[widgetName].set_sensitive(False)
+            self._contextMenuGroup[
+                self.__createRootCategoryLabel].set_sensitive(True)
+            env.widgets["menubarCreateRoot"].set_sensitive(True)
         else:
-            self._propertiesItem.set_sensitive(False)
+            self._contextMenuGroup.enable()
+            for widgetName in menubarWidgetNames:
+                env.widgets[widgetName].set_sensitive(True)
+            if not env.clipboard.hasCategories():
+                self._contextMenuGroup[
+                    self.__pasteCategoryLabel].set_sensitive(False)
+                env.widgets["menubarPaste"].set_sensitive(False)
+        propertiesItem = self._contextMenuGroup[self.__propertiesLabel]
+        propertiesItemSensitive = len(self.__selectedCategoriesIds) == 1
+        propertiesItem.set_sensitive(propertiesItemSensitive)
+        env.widgets["menubarProperties"].set_sensitive(propertiesItemSensitive)
 
     def __updateToggleColumn(self):
         # find out which categories are connected, not connected or
index 5d8e957..231f442 100644 (file)
                <widget class="GtkMenu" id="file1_menu">
 
                  <child>
-                   <widget class="GtkImageMenuItem" id="save">
+                   <widget class="GtkImageMenuItem" id="menubarSave">
                      <property name="visible">True</property>
                      <property name="label" translatable="yes">_Save</property>
                      <property name="use_underline">True</property>
                      <accelerator key="s" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 
                      <child internal-child="image">
-                       <widget class="GtkImage" id="image14">
+                       <widget class="GtkImage" id="image204">
                          <property name="visible">True</property>
                          <property name="stock">gtk-save</property>
                          <property name="icon_size">1</property>
                  </child>
 
                  <child>
-                   <widget class="GtkImageMenuItem" id="revert">
+                   <widget class="GtkImageMenuItem" id="menubarRevert">
                      <property name="visible">True</property>
                      <property name="label" translatable="yes">_Revert</property>
                      <property name="use_underline">True</property>
                      <signal name="activate" handler="on_revert_activate" last_modification_time="Sat, 17 May 2003 15:02:14 GMT"/>
 
                      <child internal-child="image">
-                       <widget class="GtkImage" id="image15">
+                       <widget class="GtkImage" id="image205">
                          <property name="visible">True</property>
                          <property name="stock">gtk-revert-to-saved</property>
                          <property name="icon_size">1</property>
                  </child>
 
                  <child>
-                   <widget class="GtkImageMenuItem" id="quit">
+                   <widget class="GtkImageMenuItem" id="menubarQuit">
                      <property name="visible">True</property>
                      <property name="label" translatable="yes">_Quit</property>
                      <property name="use_underline">True</property>
                      <accelerator key="q" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 
                      <child internal-child="image">
-                       <widget class="GtkImage" id="image17">
+                       <widget class="GtkImage" id="image206">
                          <property name="visible">True</property>
                          <property name="stock">gtk-quit</property>
                          <property name="icon_size">1</property>
              </child>
            </widget>
          </child>
+
+         <child>
+           <widget class="GtkMenuItem" id="edit">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">_Edit</property>
+             <property name="use_underline">True</property>
+             <signal name="activate" handler="on_edit_activate" last_modification_time="Sun, 11 Jul 2004 19:26:27 GMT"/>
+
+             <child>
+               <widget class="GtkMenu" id="edit_menu">
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="menubarCut">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">Cu_t</property>
+                     <property name="use_underline">True</property>
+                     <signal name="activate" handler="on_menubarCut_activate" last_modification_time="Sun, 11 Jul 2004 19:26:27 GMT"/>
+                     <accelerator key="x" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+
+                     <child internal-child="image">
+                       <widget class="GtkImage" id="image207">
+                         <property name="visible">True</property>
+                         <property name="stock">gtk-cut</property>
+                         <property name="icon_size">1</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="menubarCopy">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">_Copy</property>
+                     <property name="use_underline">True</property>
+                     <signal name="activate" handler="on_menubarCopy_activate" last_modification_time="Sun, 11 Jul 2004 19:26:27 GMT"/>
+                     <accelerator key="c" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+
+                     <child internal-child="image">
+                       <widget class="GtkImage" id="image208">
+                         <property name="visible">True</property>
+                         <property name="stock">gtk-copy</property>
+                         <property name="icon_size">1</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="menubarPaste">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">_Paste</property>
+                     <property name="use_underline">True</property>
+                     <signal name="activate" handler="on_menubarPaste_activate" last_modification_time="Sun, 11 Jul 2004 19:26:27 GMT"/>
+                     <accelerator key="v" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+
+                     <child internal-child="image">
+                       <widget class="GtkImage" id="image209">
+                         <property name="visible">True</property>
+                         <property name="stock">gtk-paste</property>
+                         <property name="icon_size">1</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="menubarDelete">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-delete</property>
+                     <property name="use_stock">True</property>
+                     <signal name="activate" handler="on_delete_activate" last_modification_time="Sun, 11 Jul 2004 19:26:27 GMT"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="menubarDestroy">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">Destroy...</property>
+                     <property name="use_underline">True</property>
+                     <signal name="activate" handler="on_destroy_activate" last_modification_time="Sun, 11 Jul 2004 19:26:27 GMT"/>
+
+                     <child internal-child="image">
+                       <widget class="GtkImage" id="image210">
+                         <property name="visible">True</property>
+                         <property name="stock">gtk-delete</property>
+                         <property name="icon_size">1</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkSeparatorMenuItem" id="separator1">
+                     <property name="visible">True</property>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="menubarClear">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">C_lear</property>
+                     <property name="use_underline">True</property>
+                     <signal name="activate" handler="on_clear_activate" last_modification_time="Sun, 11 Jul 2004 20:06:16 GMT"/>
+
+                     <child internal-child="image">
+                       <widget class="GtkImage" id="image211">
+                         <property name="visible">True</property>
+                         <property name="stock">gtk-clear</property>
+                         <property name="icon_size">1</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkMenuItem" id="menubarSelectAll">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">Select _all</property>
+                     <property name="use_underline">True</property>
+                     <signal name="activate" handler="on_select_all_activate" last_modification_time="Sun, 11 Jul 2004 19:26:27 GMT"/>
+                     <accelerator key="a" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkSeparatorMenuItem" id="separator3">
+                     <property name="visible">True</property>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="menubarProperties">
+                     <property name="visible">True</property>
+                     <property name="label">gtk-properties</property>
+                     <property name="use_stock">True</property>
+                     <signal name="activate" handler="on_menubarProperties_activate" last_modification_time="Wed, 14 Jul 2004 10:12:21 GMT"/>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkMenuItem" id="menubarView">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">_View</property>
+             <property name="use_underline">True</property>
+
+             <child>
+               <widget class="GtkMenu" id="menubarView_menu">
+
+                 <child>
+                   <widget class="GtkRadioMenuItem" id="menubarThumbnailsView">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">I_cons</property>
+                     <property name="use_underline">True</property>
+                     <property name="active">False</property>
+                     <signal name="activate" handler="on_icons_view_activate" last_modification_time="Sun, 11 Jul 2004 19:28:48 GMT"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkRadioMenuItem" id="menubarObjectView">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">_Image</property>
+                     <property name="use_underline">True</property>
+                     <property name="active">False</property>
+                     <property name="group">menubarThumbnailsView</property>
+                     <signal name="activate" handler="on_image_view_activate" last_modification_time="Sun, 11 Jul 2004 19:28:48 GMT"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkRadioMenuItem" id="menubarTableView">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">_Table</property>
+                     <property name="use_underline">True</property>
+                     <property name="active">True</property>
+                     <property name="group">menubarThumbnailsView</property>
+                     <signal name="activate" handler="on_table_view_activate" last_modification_time="Sun, 11 Jul 2004 19:28:48 GMT"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkSeparatorMenuItem" id="separator2">
+                     <property name="visible">True</property>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkMenuItem" id="menubarSortBy">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">Sort by</property>
+                     <property name="use_underline">True</property>
+                     <signal name="activate" handler="on_sort_by_activate" last_modification_time="Sun, 11 Jul 2004 19:58:39 GMT"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkSeparatorMenuItem" id="separator6">
+                     <property name="visible">True</property>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="menubarNextImage">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">_Next image</property>
+                     <property name="use_underline">True</property>
+                     <signal name="activate" handler="on_menubarNextImage_activate" last_modification_time="Wed, 21 Jul 2004 14:33:49 GMT"/>
+
+                     <child internal-child="image">
+                       <widget class="GtkImage" id="image212">
+                         <property name="visible">True</property>
+                         <property name="stock">gtk-go-forward</property>
+                         <property name="icon_size">1</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="menubarPreviousImage">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">_Previous image</property>
+                     <property name="use_underline">True</property>
+                     <signal name="activate" handler="on_menubarPreviousImage_activate" last_modification_time="Wed, 21 Jul 2004 14:33:49 GMT"/>
+
+                     <child internal-child="image">
+                       <widget class="GtkImage" id="image213">
+                         <property name="visible">True</property>
+                         <property name="stock">gtk-go-back</property>
+                         <property name="icon_size">1</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkMenuItem" id="menubarZoom">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">Zoom</property>
+                     <property name="use_underline">True</property>
+                     <signal name="activate" handler="on_menubarZoom_activate" last_modification_time="Wed, 21 Jul 2004 14:33:49 GMT"/>
+
+                     <child>
+                       <widget class="GtkMenu" id="menubarZoom_menu">
+
+                         <child>
+                           <widget class="GtkMenuItem" id="menubarActualSize">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">_Actual size</property>
+                             <property name="use_underline">True</property>
+                             <signal name="activate" handler="on_menubarActualSize_activate" last_modification_time="Wed, 21 Jul 2004 14:33:49 GMT"/>
+                           </widget>
+                         </child>
+
+                         <child>
+                           <widget class="GtkMenuItem" id="menubarZoomToFit">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">Zoom to _fit</property>
+                             <property name="use_underline">True</property>
+                             <signal name="activate" handler="on_menubarZoomToFit_activate" last_modification_time="Wed, 21 Jul 2004 14:33:49 GMT"/>
+                           </widget>
+                         </child>
+
+                         <child>
+                           <widget class="GtkMenuItem" id="menubarZoomIn">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">Zoom _in</property>
+                             <property name="use_underline">True</property>
+                             <signal name="activate" handler="on_menubarZoomIn_activate" last_modification_time="Wed, 21 Jul 2004 14:33:49 GMT"/>
+                           </widget>
+                         </child>
+
+                         <child>
+                           <widget class="GtkMenuItem" id="menubarZoomOut">
+                             <property name="visible">True</property>
+                             <property name="label" translatable="yes">Zoom _out</property>
+                             <property name="use_underline">True</property>
+                             <signal name="activate" handler="on_menubarZoomOut_activate" last_modification_time="Wed, 21 Jul 2004 14:33:49 GMT"/>
+                           </widget>
+                         </child>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkMenuItem" id="menubarAlbum">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">_Album</property>
+             <property name="use_underline">True</property>
+
+             <child>
+               <widget class="GtkMenu" id="menubarAlbum_menu">
+
+                 <child>
+                   <widget class="GtkMenuItem" id="menubarCreateAlbumChild">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">_Create album child...</property>
+                     <property name="use_underline">True</property>
+                     <signal name="activate" handler="on_create_album_child_activate" last_modification_time="Sun, 11 Jul 2004 19:57:53 GMT"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkMenuItem" id="menubarRegisterAndAddImages">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">_Register and add images...</property>
+                     <property name="use_underline">True</property>
+                     <signal name="activate" handler="on_register_and_add_images1_activate" last_modification_time="Sun, 11 Jul 2004 19:57:53 GMT"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkMenuItem" id="menubarRegisterImages">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">Register images...</property>
+                     <property name="use_underline">True</property>
+                     <signal name="activate" handler="on_register_images1_activate" last_modification_time="Sun, 11 Jul 2004 19:57:53 GMT"/>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkMenuItem" id="menubarImage">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">_Image</property>
+             <property name="use_underline">True</property>
+
+             <child>
+               <widget class="GtkMenu" id="menubarImage_menu">
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="menubarOpenImage">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">_Open in external program...</property>
+                     <property name="use_underline">True</property>
+                     <signal name="activate" handler="on_open_image_activate" last_modification_time="Sun, 11 Jul 2004 19:52:02 GMT"/>
+
+                     <child internal-child="image">
+                       <widget class="GtkImage" id="image214">
+                         <property name="visible">True</property>
+                         <property name="stock">gtk-open</property>
+                         <property name="icon_size">1</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="menubarRotateLeft">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">Rotate _left</property>
+                     <property name="use_underline">True</property>
+                     <signal name="activate" handler="on_rotate_left_activate" last_modification_time="Sun, 11 Jul 2004 19:52:02 GMT"/>
+                     <accelerator key="L" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+
+                     <child internal-child="image">
+                       <widget class="GtkImage" id="image215">
+                         <property name="visible">True</property>
+                         <property name="stock">gtk-add</property>
+                         <property name="icon_size">1</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="menubarRotateRight">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">Rotate _right</property>
+                     <property name="use_underline">True</property>
+                     <signal name="activate" handler="on_rotate_right_activate" last_modification_time="Sun, 11 Jul 2004 19:52:02 GMT"/>
+                     <accelerator key="R" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+
+                     <child internal-child="image">
+                       <widget class="GtkImage" id="image216">
+                         <property name="visible">True</property>
+                         <property name="stock">gtk-add</property>
+                         <property name="icon_size">1</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkMenuItem" id="menubarCategory">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">_Category</property>
+             <property name="use_underline">True</property>
+             <signal name="activate" handler="on_menubarCategory_activate" last_modification_time="Wed, 14 Jul 2004 10:12:21 GMT"/>
+
+             <child>
+               <widget class="GtkMenu" id="menubarCategory_menu">
+
+                 <child>
+                   <widget class="GtkMenuItem" id="menubarDisconnectFromParent">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">Disconnect from parent</property>
+                     <property name="use_underline">True</property>
+                     <signal name="activate" handler="on_menubarDisconnectFromParent_activate" last_modification_time="Wed, 14 Jul 2004 10:12:21 GMT"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkMenuItem" id="menubarCreateChild">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">Create child...</property>
+                     <property name="use_underline">True</property>
+                     <signal name="activate" handler="on_menubarCreateChild_activate" last_modification_time="Wed, 14 Jul 2004 10:12:21 GMT"/>
+                   </widget>
+                 </child>
+
+                 <child>
+                   <widget class="GtkMenuItem" id="menubarCreateRoot">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">Create root...</property>
+                     <property name="use_underline">True</property>
+                     <signal name="activate" handler="on_menubarCreateRoot_activate" last_modification_time="Wed, 14 Jul 2004 10:12:21 GMT"/>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
+
+         <child>
+           <widget class="GtkMenuItem" id="menubarHelp">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">_Help</property>
+             <property name="use_underline">True</property>
+             <signal name="activate" handler="on_help_activate" last_modification_time="Sun, 11 Jul 2004 20:05:01 GMT"/>
+
+             <child>
+               <widget class="GtkMenu" id="menubarHelp_menu">
+
+                 <child>
+                   <widget class="GtkImageMenuItem" id="menubarAbout">
+                     <property name="visible">True</property>
+                     <property name="label" translatable="yes">_About Kofoto...</property>
+                     <property name="use_underline">True</property>
+                     <signal name="activate" handler="on_about_activate" last_modification_time="Sun, 11 Jul 2004 20:05:01 GMT"/>
+
+                     <child internal-child="image">
+                       <widget class="GtkImage" id="image217">
+                         <property name="visible">True</property>
+                         <property name="stock">gtk-add</property>
+                         <property name="icon_size">1</property>
+                         <property name="xalign">0.5</property>
+                         <property name="yalign">0.5</property>
+                         <property name="xpad">0</property>
+                         <property name="ypad">0</property>
+                       </widget>
+                     </child>
+                   </widget>
+                 </child>
+               </widget>
+             </child>
+           </widget>
+         </child>
        </widget>
        <packing>
          <property name="padding">0</property>
diff --git a/src/gkofoto/icons/about-icon.png b/src/gkofoto/icons/about-icon.png
new file mode 100644 (file)
index 0000000..d66bfd7
Binary files /dev/null and b/src/gkofoto/icons/about-icon.png differ
diff --git a/src/gkofoto/icons/rotateleft.png b/src/gkofoto/icons/rotateleft.png
new file mode 100644 (file)
index 0000000..bfb0fdd
Binary files /dev/null and b/src/gkofoto/icons/rotateleft.png differ
diff --git a/src/gkofoto/icons/rotateright.png b/src/gkofoto/icons/rotateright.png
new file mode 100644 (file)
index 0000000..e19929c
Binary files /dev/null and b/src/gkofoto/icons/rotateright.png differ
index 5e43519..be2e9b4 100644 (file)
@@ -10,6 +10,7 @@ from gkofoto.thumbnailview import *
 from gkofoto.singleobjectview import *
 from gkofoto.objectcollectionfactory import *
 from gkofoto.objectcollection import *
+from gkofoto.registerimagesdialog import RegisterImagesDialog
 
 class MainWindow(gtk.Window):
     def __init__(self):
@@ -25,19 +26,38 @@ class MainWindow(gtk.Window):
         env.widgets["thumbnailsViewToggleButton"].get_child().add(self.getIconImage("thumbnailsview.png"))
         env.widgets["objectViewToggleButton"].connect("clicked", self._toggleObjectView)
         env.widgets["objectViewToggleButton"].get_child().add(self.getIconImage("objectview.png"))
+        env.widgets["menubarObjectView"].connect("activate", self._toggleObjectView)
         env.widgets["tableViewToggleButton"].connect("clicked", self._toggleTableView)
         env.widgets["tableViewToggleButton"].get_child().add(self.getIconImage("tableview.png"))
-        env.widgets["save"].connect("activate", env.controller.save)
-        env.widgets["revert"].connect("activate", env.controller.revert)
-        env.widgets["quit"].connect("activate", env.controller.quit)
-        env.widgets["save"].set_sensitive(False)
-        env.widgets["revert"].set_sensitive(False)
+        env.widgets["menubarTableView"].connect("activate", self._toggleTableView)
         env.widgets["previousButton"].set_sensitive(False)
         env.widgets["nextButton"].set_sensitive(False)
         env.widgets["zoom100"].set_sensitive(False)
         env.widgets["zoomToFit"].set_sensitive(False)
         env.widgets["zoomIn"].set_sensitive(False)
         env.widgets["zoomOut"].set_sensitive(False)
+
+        env.widgets["menubarSave"].connect("activate", env.controller.save)
+        env.widgets["menubarSave"].set_sensitive(False)
+        env.widgets["menubarRevert"].connect("activate", env.controller.revert)
+        env.widgets["menubarRevert"].set_sensitive(False)
+        env.widgets["menubarQuit"].connect("activate", env.controller.quit)
+
+        env.widgets["menubarThumbnailsView"].set_sensitive(False)
+
+        env.widgets["menubarNextImage"].set_sensitive(False)
+        env.widgets["menubarPreviousImage"].set_sensitive(False)
+        env.widgets["menubarZoom"].set_sensitive(False)
+
+        env.widgets["menubarRegisterImages"].connect("activate", self.registerImages, None)
+
+        env.widgets["menubarRotateLeft"].get_children()[1].set_from_pixbuf(
+            gtk.gdk.pixbuf_new_from_file(os.path.join(env.iconDir, "rotateleft.png")))
+        env.widgets["menubarRotateRight"].get_children()[1].set_from_pixbuf(
+            gtk.gdk.pixbuf_new_from_file(os.path.join(env.iconDir, "rotateright.png")))
+        env.widgets["menubarAbout"].get_children()[1].set_from_pixbuf(
+            gtk.gdk.pixbuf_new_from_file(os.path.join(env.iconDir, "about-icon.png")))
+
         self.__sourceEntry.connect("activate", self._sourceEntryActivated)
 
         env.shelf.registerModificationCallback(self._shelfModificationChangedCallback)
@@ -72,6 +92,10 @@ class MainWindow(gtk.Window):
     def reloadAlbumTree(self):
         self.__albums.loadAlbumTree()
 
+    def registerImages(self, widget, data):
+        dialog = RegisterImagesDialog()
+        dialog.run()
+
     def getIconImage(self, name):
         pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.join(env.iconDir, name))
         image = gtk.Image()
@@ -109,8 +133,12 @@ class MainWindow(gtk.Window):
         if not self._toggleLock:
             self._toggleLock = True
             button.set_active(True)
+            env.widgets["thumbnailsViewToggleButton"].set_active(True)
             env.widgets["objectViewToggleButton"].set_active(False)
             env.widgets["tableViewToggleButton"].set_active(False)
+            env.widgets["menubarThumbnailsView"].set_active(True)
+            env.widgets["menubarObjectView"].set_active(False)
+            env.widgets["menubarTableView"].set_active(False)
             self.__showThumbnailView()
             self._toggleLock = False
 
@@ -118,8 +146,12 @@ class MainWindow(gtk.Window):
         if not self._toggleLock:
             self._toggleLock = True
             button.set_active(True)
-            env.widgets["tableViewToggleButton"].set_active(False)
             env.widgets["thumbnailsViewToggleButton"].set_active(False)
+            env.widgets["objectViewToggleButton"].set_active(True)
+            env.widgets["tableViewToggleButton"].set_active(False)
+            env.widgets["menubarThumbnailsView"].set_active(False)
+            env.widgets["menubarObjectView"].set_active(True)
+            env.widgets["menubarTableView"].set_active(False)
             self.__showSingleObjectView()
             self._toggleLock = False
 
@@ -129,12 +161,16 @@ class MainWindow(gtk.Window):
             button.set_active(True)
             env.widgets["thumbnailsViewToggleButton"].set_active(False)
             env.widgets["objectViewToggleButton"].set_active(False)
+            env.widgets["tableViewToggleButton"].set_active(True)
+            env.widgets["menubarThumbnailsView"].set_active(False)
+            env.widgets["menubarObjectView"].set_active(False)
+            env.widgets["menubarTableView"].set_active(True)
             self.__showTableView()
             self._toggleLock = False
 
     def _shelfModificationChangedCallback(self, modified):
-        env.widgets["revert"].set_sensitive(modified)
-        env.widgets["save"].set_sensitive(modified)
+        env.widgets["menubarRevert"].set_sensitive(modified)
+        env.widgets["menubarSave"].set_sensitive(modified)
 
     def __setObjectCollection(self, objectCollection):
         if self.__currentObjectCollection != objectCollection:
index a2768e3..b471d3a 100644 (file)
@@ -11,6 +11,22 @@ class MenuGroup:
         item = gtk.MenuItem(label)
         self.__addItem(item, label, callback, callbackData)
 
+    def addStockImageMenuItem(self, label, stockId, callback,
+                              callbackData=None):
+        item = gtk.ImageMenuItem(label)
+        image = gtk.Image()
+        image.set_from_stock(stockId, gtk.ICON_SIZE_MENU)
+        item.set_image(image)
+        self.__addItem(item, label, callback, callbackData)
+
+    def addImageMenuItem(self, label, imageFilename, callback,
+                         callbackData=None):
+        item = gtk.ImageMenuItem(label)
+        image = gtk.Image()
+        image.set_from_file(imageFilename)
+        item.set_image(image)
+        self.__addItem(item, label, callback, callbackData)
+
     def addCheckedMenuItem(self, label, callback, callbackData=None):
         item = gtk.CheckMenuItem(label)
         self.__addItem(item, label, callback, callbackData)
index 4276f39..029bd24 100644 (file)
@@ -312,7 +312,7 @@ class ObjectCollection(object):
             # TODO Show dialog error box?
             print "Not allowed to set album tag on image"
 
-    def createAlbumChild(self, widget, data):
+    def createAlbumChild(self, *unused):
         dialog = AlbumDialog("Create album")
         dialog.run(self._createAlbumChildHelper)
 
index 97a40d6..21c2c46 100644 (file)
@@ -22,9 +22,37 @@ class ObjectCollectionView:
             self.__hidden = False
             self.__connectObjectCollection(objectCollection)
             self._showHelper()
+            self._connectMenubarImageItems()
+            self._updateMenubarSortMenu()
         else:
             self.setObjectCollection(objectCollection)
 
+    def _connectMenubarImageItems(self):
+        self._connect(
+            env.widgets["menubarOpenImage"],
+            "activate",
+            self._objectCollection.openImage)
+        self._connect(
+            env.widgets["menubarRotateLeft"],
+            "activate",
+            self._objectCollection.rotateImage,
+            270)
+        self._connect(
+            env.widgets["menubarRotateRight"],
+            "activate",
+            self._objectCollection.rotateImage,
+            90)
+
+    def _updateMenubarSortMenu(self):
+        sortMenuGroup = self.__createSortMenuGroup(self._objectCollection)
+        sortByItem = env.widgets["menubarSortBy"]
+        if self._objectCollection.isSortable():
+            sortByItem.set_sensitive(True)
+            sortByItem.set_submenu(sortMenuGroup.createGroupMenu())
+        else:
+            sortByItem.remove_submenu()
+            sortByItem.set_sensitive(False)
+
     def hide(self):
         if not self.__hidden:
             self.__hidden = True
@@ -72,10 +100,14 @@ class ObjectCollectionView:
 ##############################################################################
 ### Methods used by and overloaded by subbclasses
 
-    def _connect(self, obj, signal, function):
-        oid = obj.connect(signal, function)
+    def _connect(self, obj, signal, function, data=None):
+        oid = obj.connect(signal, function, data)
         self.__connections.append((obj, oid))
 
+    def _disconnect(self, obj, oid):
+        obj.disconnect(oid)
+        self.__connections.remove((obj, oid))
+
     def _clearAllConnections(self):
         for (obj, oid) in self.__connections:
             obj.disconnect(oid)
@@ -102,17 +134,23 @@ class ObjectCollectionView:
     def _clearContextMenu(self):
         env.debug("Clearing view context menu")
         self._contextMenu = None
-        self.__sortMenuGroup = None
         self.__clipboardMenuGroup = None
+        self.__objectMenuGroup = None
+        self.__albumMenuGroup = None
+        self.__imageMenuGroup = None
+        self.__sortMenuGroup = None
 
     def _updateContextMenu(self, *foo):
         env.debug("Updating context menu")
         self.__objectMenuGroup[self._objectCollection.getDestroyLabel()].set_sensitive(False)
+        env.widgets["menubarDestroy"].set_sensitive(False)
         mutable = self._objectCollection.isMutable()
         if env.clipboard.hasObjects():
             self.__clipboardMenuGroup[self._objectCollection.getPasteLabel()].set_sensitive(mutable)
+            env.widgets["menubarPaste"].set_sensitive(mutable)
         else:
             self.__clipboardMenuGroup[self._objectCollection.getPasteLabel()].set_sensitive(False)
+            env.widgets["menubarPaste"].set_sensitive(False)
         objectSelection = self._objectCollection.getObjectSelection()
         if objectSelection:
             model = self._objectCollection.getModel()
@@ -134,30 +172,63 @@ class ObjectCollectionView:
                     imagesSelected += 1
 
             self.__clipboardMenuGroup[self._objectCollection.getCutLabel()].set_sensitive(mutable)
+            env.widgets["menubarCut"].set_sensitive(mutable)
             self.__clipboardMenuGroup[self._objectCollection.getCopyLabel()].set_sensitive(True)
+            env.widgets["menubarCopy"].set_sensitive(True)
             self.__clipboardMenuGroup[self._objectCollection.getDeleteLabel()].set_sensitive(mutable)
-            self.__objectMenuGroup[self._objectCollection.getDestroyLabel()].set_sensitive(
-                (imagesSelected == 0) ^ (albumsSelected == 0) and not rootAlbumSelected)
+            env.widgets["menubarDelete"].set_sensitive(mutable)
+            destroyActive = (imagesSelected == 0) ^ (albumsSelected == 0) and not rootAlbumSelected
+            self.__objectMenuGroup[self._objectCollection.getDestroyLabel()].set_sensitive(destroyActive)
+            env.widgets["menubarDestroy"].set_sensitive(destroyActive)
             if albumsSelected == 1 and imagesSelected == 0:
                 selectedAlbumId = model.get_value(
                     iterator, self._objectCollection.COLUMN_OBJECT_ID)
                 selectedAlbum = env.shelf.getAlbum(selectedAlbumId)
                 if selectedAlbum.isMutable():
                     self.__albumMenuGroup.enable()
+                    env.widgets["menubarCreateAlbumChild"].set_sensitive(True)
+                    env.widgets["menubarRegisterAndAddImages"].set_sensitive(True)
+                    env.widgets["menubarProperties"].set_sensitive(True)
                 else:
                     self.__albumMenuGroup.disable()
                     self.__albumMenuGroup[self._objectCollection.getAlbumPropertiesLabel()].set_sensitive(True)
+                    env.widgets["menubarCreateAlbumChild"].set_sensitive(False)
+                    env.widgets["menubarRegisterAndAddImages"].set_sensitive(False)
+                    env.widgets["menubarProperties"].set_sensitive(True)
             else:
                 self.__albumMenuGroup.disable()
+                env.widgets["menubarCreateAlbumChild"].set_sensitive(False)
+                env.widgets["menubarRegisterAndAddImages"].set_sensitive(False)
+                env.widgets["menubarProperties"].set_sensitive(False)
             if albumsSelected == 0 and imagesSelected > 0:
                 self.__imageMenuGroup.enable()
+                env.widgets["menubarOpenImage"].set_sensitive(True)
+                env.widgets["menubarRotateLeft"].set_sensitive(True)
+                env.widgets["menubarRotateRight"].set_sensitive(True)
             else:
                 self.__imageMenuGroup.disable()
+                env.widgets["menubarOpenImage"].set_sensitive(False)
+                env.widgets["menubarRotateLeft"].set_sensitive(False)
+                env.widgets["menubarRotateRight"].set_sensitive(False)
         else:
             self.__clipboardMenuGroup.disable()
+            env.widgets["menubarCut"].set_sensitive(False)
+            env.widgets["menubarCopy"].set_sensitive(False)
+            env.widgets["menubarPaste"].set_sensitive(False)
+            env.widgets["menubarDelete"].set_sensitive(False)
+
             self.__objectMenuGroup.disable()
+            env.widgets["menubarDestroy"].set_sensitive(False)
+
             self.__albumMenuGroup.disable()
+            env.widgets["menubarCreateAlbumChild"].set_sensitive(False)
+            env.widgets["menubarRegisterAndAddImages"].set_sensitive(False)
+            env.widgets["menubarProperties"].set_sensitive(False)
+
             self.__imageMenuGroup.disable()
+            env.widgets["menubarOpenImage"].set_sensitive(False)
+            env.widgets["menubarRotateLeft"].set_sensitive(False)
+            env.widgets["menubarRotateRight"].set_sensitive(False)
 
 ###############################################################################
 ### Private
@@ -203,16 +274,21 @@ class ObjectCollectionView:
     def __createClipboardMenuGroup(self, oc):
         menuGroup = MenuGroup()
         env.debug("Creating clipboard menu")
-        menuGroup.addMenuItem(oc.getCutLabel(), oc.cut)
-        menuGroup.addMenuItem(oc.getCopyLabel(), oc.copy)
-        menuGroup.addMenuItem(oc.getPasteLabel(), oc.paste)
-        menuGroup.addMenuItem(oc.getDeleteLabel(), oc.delete)
+        menuGroup.addStockImageMenuItem(
+            oc.getCutLabel(), gtk.STOCK_CUT, oc.cut)
+        menuGroup.addStockImageMenuItem(
+            oc.getCopyLabel(), gtk.STOCK_COPY, oc.copy)
+        menuGroup.addStockImageMenuItem(
+            oc.getPasteLabel(), gtk.STOCK_PASTE, oc.paste)
+        menuGroup.addStockImageMenuItem(
+            oc.getDeleteLabel(), gtk.STOCK_DELETE, oc.delete)
         menuGroup.addSeparator()
         return menuGroup
 
     def __createObjectMenuGroup(self, oc):
         menuGroup = MenuGroup()
-        menuGroup.addMenuItem(oc.getDestroyLabel(), oc.destroy)
+        menuGroup.addStockImageMenuItem(
+            oc.getDestroyLabel(), gtk.STOCK_DELETE, oc.destroy)
         menuGroup.addSeparator()
         return menuGroup
 
@@ -222,17 +298,23 @@ class ObjectCollectionView:
             oc.getCreateAlbumChildLabel(), oc.createAlbumChild)
         menuGroup.addMenuItem(
             oc.getRegisterImagesLabel(), oc.registerAndAddImages)
-        menuGroup.addMenuItem(
-            oc.getAlbumPropertiesLabel(), oc.albumProperties)
+        menuGroup.addStockImageMenuItem(
+            oc.getAlbumPropertiesLabel(),
+            gtk.STOCK_PROPERTIES,
+            oc.albumProperties)
         menuGroup.addSeparator()
         return menuGroup
 
     def __createImageMenuGroup(self, oc):
         menuGroup = MenuGroup()
         menuGroup.addMenuItem(oc.getOpenImageLabel(), oc.openImage)
-        menuGroup.addMenuItem(
-            oc.getRotateImageLeftLabel(), oc.rotateImage, 270)
-        menuGroup.addMenuItem(
-            oc.getRotateImageRightLabel(), oc.rotateImage, 90)
+        menuGroup.addImageMenuItem(
+            oc.getRotateImageLeftLabel(),
+            os.path.join(env.iconDir, "rotateleft.png"),
+            oc.rotateImage, 270)
+        menuGroup.addImageMenuItem(
+            oc.getRotateImageRightLabel(),
+            os.path.join(env.iconDir, "rotateright.png"),
+            oc.rotateImage, 90)
         menuGroup.addSeparator()
         return menuGroup
index 1b90076..1162035 100644 (file)
@@ -16,11 +16,17 @@ class SingleObjectView(ObjectCollectionView, ImageView):
         self._viewWidget.add(self)
         self.show_all()
         env.widgets["nextButton"].connect("clicked", self._goto, 1)
+        env.widgets["menubarNextImage"].connect("activate", self._goto, 1)
         env.widgets["previousButton"].connect("clicked", self._goto, -1)
+        env.widgets["menubarPreviousImage"].connect("activate", self._goto, -1)
         env.widgets["zoomToFit"].connect("clicked", self.fitToWindow)
+        env.widgets["menubarZoomToFit"].connect("activate", self.fitToWindow)
         env.widgets["zoom100"].connect("clicked", self.zoom100)
+        env.widgets["menubarActualSize"].connect("activate", self.zoom100)
         env.widgets["zoomIn"].connect("clicked", self.zoomIn)
+        env.widgets["menubarZoomIn"].connect("activate", self.zoomIn)
         env.widgets["zoomOut"].connect("clicked", self.zoomOut)
+        env.widgets["menubarZoomOut"].connect("activate", self.zoomOut)
         self.connect("button_press_event", self._mouse_button_pressed)
         self.__selectionLocked = False
 
@@ -50,36 +56,57 @@ class SingleObjectView(ObjectCollectionView, ImageView):
                     self.loadFile(env.albumIconFileName, False)
                 else:
                     self.loadFile(selectedObject.getLocation(), False)
-            if self.__selectedRowNr <= 0:
-                env.widgets["previousButton"].set_sensitive(False)
-            else:
-                env.widgets["previousButton"].set_sensitive(True)
-            if (self.__selectedRowNr == -1 or self.__selectedRowNr >= len(model) - 1):
-                env.widgets["nextButton"].set_sensitive(False)
-            else:
-                env.widgets["nextButton"].set_sensitive(True)
+            enablePreviousButton = (self.__selectedRowNr > 0)
+            env.widgets["previousButton"].set_sensitive(enablePreviousButton)
+            env.widgets["menubarPreviousImage"].set_sensitive(enablePreviousButton)
+            enableNextButton = (self.__selectedRowNr != -1 and
+                                self.__selectedRowNr < len(model) - 1)
+            env.widgets["nextButton"].set_sensitive(enableNextButton)
+            env.widgets["menubarNextImage"].set_sensitive(enableNextButton)
             self.__selectionLocked = False
         self._updateContextMenu()
 
+        # Override sensitiveness set in _updateContextMenu.
+        for widgetName in [
+                "menubarCut",
+                "menubarCopy",
+                "menubarDelete",
+                "menubarDestroy",
+                "menubarProperties",
+                "menubarCreateAlbumChild",
+                "menubarRegisterAndAddImages",
+                ]:
+            env.widgets[widgetName].set_sensitive(False)
+
     def _showHelper(self):
         env.enter("SingleObjectView.showHelper()")
         env.widgets["objectView"].show()
         env.widgets["objectView"].grab_focus()
-        env.widgets["zoom100"].set_sensitive(True)
-        env.widgets["zoomToFit"].set_sensitive(True)
-        env.widgets["zoomIn"].set_sensitive(True)
-        env.widgets["zoomOut"].set_sensitive(True)
+        for widgetName in [
+                "zoom100",
+                "zoomToFit",
+                "zoomIn",
+                "zoomOut",
+                "menubarZoom",
+                ]:
+            env.widgets[widgetName].set_sensitive(True)
         env.exit("SingleObjectView.showHelper()")
 
     def _hideHelper(self):
         env.enter("SingleObjectView.hideHelper()")
         env.widgets["objectView"].hide()
-        env.widgets["previousButton"].set_sensitive(False)
-        env.widgets["nextButton"].set_sensitive(False)
-        env.widgets["zoom100"].set_sensitive(False)
-        env.widgets["zoomToFit"].set_sensitive(False)
-        env.widgets["zoomIn"].set_sensitive(False)
-        env.widgets["zoomOut"].set_sensitive(False)
+        for widgetName in [
+                "previousButton",
+                "nextButton",
+                "menubarPreviousImage",
+                "menubarNextImage",
+                "zoom100",
+                "zoomToFit",
+                "zoomIn",
+                "zoomOut",
+                "menubarZoom",
+                ]:
+            env.widgets[widgetName].set_sensitive(False)
         env.exit("SingleObjectView.hideHelper()")
 
     def _connectObjectCollectionHelper(self):
@@ -123,3 +150,11 @@ class SingleObjectView(ObjectCollectionView, ImageView):
     def _goto(self, button, direction):
         objectSelection = self._objectCollection.getObjectSelection()
         objectSelection.setSelection([self.__selectedRowNr + direction])
+
+    def _viewWidgetFocusInEvent(self, widget, event):
+        ObjectCollectionView._viewWidgetFocusInEvent(self, widget, event)
+        for widgetName in [
+                "menubarClear",
+                "menubarSelectAll",
+                ]:
+            env.widgets[widgetName].set_sensitive(False)
index a649c46..0d3fb23 100644 (file)
@@ -5,6 +5,7 @@ from gkofoto.objectcollectionview import *
 from sets import Set
 from objectcollection import *
 from menuhandler import *
+
 class TableView(ObjectCollectionView):
 
 ###############################################################################
@@ -21,6 +22,7 @@ class TableView(ObjectCollectionView):
         self.__userChoosenColumns = {}
         self.__createdColumns = {}
         self.__editedCallbacks = {}
+        self._connectedOids = []
         # Import the users setting in the configuration file for
         # which columns that shall be shown.
         columnLocation = 0
@@ -46,6 +48,7 @@ class TableView(ObjectCollectionView):
                 self._viewWidget.scroll_to_cell(rowNr, None, False, 0, 0)
             self.__selectionLocked = False
         self._updateContextMenu()
+        self._updateMenubarSortMenu()
 
     def fieldsDisabled(self, fields):
         env.debug("Table view disable fields: " + str(fields))
@@ -117,19 +120,26 @@ class TableView(ObjectCollectionView):
     def _thawHelper(self):
         env.enter("TableView.thawHelper()")
         self._initDragAndDrop()
-        self._connect(self._viewWidget.get_selection(), 'changed', self._widgetSelectionChanged)
+        self._connect(self._viewWidget, "focus-in-event", self._treeViewFocusInEvent)
+        self._connect(self._viewWidget, "focus-out-event", self._treeViewFocusOutEvent)
+        self._connect(self._viewWidget.get_selection(), "changed", self._widgetSelectionChanged)
         env.exit("TableView.thawHelper()")
 
     def _createContextMenu(self, objectCollection):
         ObjectCollectionView._createContextMenu(self, objectCollection)
-        columnNames = list(objectCollection.getObjectMetadataMap().keys())
+        self.__viewGroup = self.__createTableColumnsMenuGroup(objectCollection)
+        self._contextMenu.add(self.__viewGroup.createGroupMenuItem())
+
+    def __createTableColumnsMenuGroup(self, objectCollection):
+        menuGroup = MenuGroup("View columns")
+        columnNames = objectCollection.getObjectMetadataMap().keys()
         columnNames.sort()
-        self.__viewGroup = MenuGroup("View columns")
         for columnName in columnNames:
-            self.__viewGroup.addCheckedMenuItem(columnName,
-                                                self._viewColumnToggled,
-                                                columnName)
-        self._contextMenu.add(self.__viewGroup.createGroupMenuItem())
+            menuGroup.addCheckedMenuItem(
+                columnName,
+                self._viewColumnToggled,
+                columnName)
+        return menuGroup
 
     def _clearContextMenu(self):
         ObjectCollectionView._clearContextMenu(self)
@@ -138,7 +148,49 @@ class TableView(ObjectCollectionView):
 ###############################################################################
 ### Callback functions registered by this class but invoked from other classes.
 
-    def _widgetSelectionChanged(self, selection):
+    def _treeViewFocusInEvent(self, widget, event, data):
+        oc = self._objectCollection
+        for widgetName, function in [
+                ("menubarCut", self._objectCollection.cut),
+                ("menubarCopy", self._objectCollection.copy),
+                ("menubarPaste", self._objectCollection.paste),
+                ("menubarDestroy", oc.destroy),
+                ("menubarClear", lambda x: widget.get_selection().unselect_all()),
+                ("menubarSelectAll", lambda x: widget.get_selection().select_all()),
+                ("menubarCreateAlbumChild", oc.createAlbumChild),
+                ("menubarRegisterAndAddImages", oc.registerAndAddImages),
+                ("menubarProperties", oc.albumProperties),
+                ]:
+            w = env.widgets[widgetName]
+            oid = w.connect("activate", function)
+            self._connectedOids.append((w, oid))
+
+        self._updateContextMenu()
+
+        for widgetName in [
+                "menubarClear",
+                "menubarSelectAll"
+                ]:
+            env.widgets[widgetName].set_sensitive(True)
+
+    def _treeViewFocusOutEvent(self, widget, event, data):
+        for (widget, oid) in self._connectedOids:
+            widget.disconnect(oid)
+        self._connectedOids = []
+        for widgetName in [
+                "menubarCut",
+                "menubarCopy",
+                "menubarPaste",
+                "menubarDestroy",
+                "menubarClear",
+                "menubarSelectAll",
+                "menubarCreateAlbumChild",
+                "menubarRegisterAndAddImages",
+                "menubarProperties",
+                ]:
+            env.widgets[widgetName].set_sensitive(False)
+
+    def _widgetSelectionChanged(self, selection, data):
         if not self.__selectionLocked:
             env.enter("TableView selection changed")
             self.__selectionLocked = True