Added version property (taken from kofoto.version, if available) to
authorJoel Rosdahl <joel@rosdahl.net>
Thu, 22 Jul 2004 12:31:12 +0000 (12:31 +0000)
committerJoel Rosdahl <joel@rosdahl.net>
Thu, 22 Jul 2004 12:31:12 +0000 (12:31 +0000)
kofoto.clientversion.ClientEnvironment.

Read version from ClientEnvironment in commandline client.

Added option parsing to gkofoto.

Added about box to gkofoto.

src/cmdline/kofoto
src/gkofoto/environment.py
src/gkofoto/glade/gkofoto.glade
src/gkofoto/main.py
src/gkofoto/mainwindow.py
src/lib/kofoto/clientenvironment.py

index d10d504..1596abf 100755 (executable)
@@ -729,7 +729,7 @@ def main(argv):
         elif opt in ("-v", "--verbose"):
             env.verbose = True
         elif opt in ("-V", "--version"):
-            sys.stdout.write("crowbar\n")
+            sys.stdout.write("%s\n" % env.version)
             sys.exit(0)
         elif opt == "--no-act":
             sys.stdout.write("no-act: No changes will be commited to the shelf!\n")
index acddf48..c804fd2 100644 (file)
@@ -29,14 +29,15 @@ class Environment(ClientEnvironment):
         ClientEnvironment.__init__(self)
         self.startupNotices = []
 
-    def setup(self, bindir):
+    def setup(self, bindir, isDebug=False, configFileLocation=None,
+              shelfLocation=None):
         try:
-            ClientEnvironment.setup(self)
+            ClientEnvironment.setup(self, configFileLocation, shelfLocation)
         except ClientEnvironmentError, e:
             self.startupNotices += [e[0]]
             return False
 
-        # TODO: Make it possible for the user to specify configuration file on the command line.
+        self.isDebug = isDebug
         self.thumbnailSize = self.config.getcoordlist(
             "gkofoto", "thumbnail_size_limit")[0]
         self.defaultTableViewColumns = re.findall(
@@ -66,7 +67,6 @@ class Environment(ClientEnvironment):
 
         self.widgets = WidgetsWrapper()
 
-        self.isDebug = False # TODO get as a command line parameter
         return True
 
     def _writeInfo(self, infoString):
index dba23e1..abc789a 100644 (file)
@@ -1954,4 +1954,130 @@ The categories' children will not be destroyed, nor will the images associated w
   </child>
 </widget>
 
+<widget class="GtkDialog" id="aboutDialog">
+  <property name="visible">True</property>
+  <property name="title" translatable="yes">About Kofoto</property>
+  <property name="type">GTK_WINDOW_TOPLEVEL</property>
+  <property name="window_position">GTK_WIN_POS_NONE</property>
+  <property name="modal">False</property>
+  <property name="resizable">True</property>
+  <property name="destroy_with_parent">False</property>
+  <property name="decorated">True</property>
+  <property name="skip_taskbar_hint">False</property>
+  <property name="skip_pager_hint">False</property>
+  <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+  <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
+  <property name="has_separator">True</property>
+
+  <child internal-child="vbox">
+    <widget class="GtkVBox" id="dialog-vbox5">
+      <property name="visible">True</property>
+      <property name="homogeneous">False</property>
+      <property name="spacing">0</property>
+
+      <child internal-child="action_area">
+       <widget class="GtkHButtonBox" id="dialog-action_area5">
+         <property name="visible">True</property>
+         <property name="layout_style">GTK_BUTTONBOX_END</property>
+
+         <child>
+           <widget class="GtkButton" id="okbutton3">
+             <property name="visible">True</property>
+             <property name="can_default">True</property>
+             <property name="can_focus">True</property>
+             <property name="label">gtk-ok</property>
+             <property name="use_stock">True</property>
+             <property name="relief">GTK_RELIEF_NORMAL</property>
+             <property name="focus_on_click">True</property>
+             <property name="response_id">-5</property>
+           </widget>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">False</property>
+         <property name="fill">True</property>
+         <property name="pack_type">GTK_PACK_END</property>
+       </packing>
+      </child>
+
+      <child>
+       <widget class="GtkVBox" id="vbox13">
+         <property name="visible">True</property>
+         <property name="homogeneous">False</property>
+         <property name="spacing">0</property>
+
+         <child>
+           <widget class="GtkLabel" id="nameAndVersionLabel">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">&lt;span size=&quot;xx-large&quot;&gt;Kofoto development version&lt;/span&gt;</property>
+             <property name="use_underline">False</property>
+             <property name="use_markup">True</property>
+             <property name="justify">GTK_JUSTIFY_LEFT</property>
+             <property name="wrap">False</property>
+             <property name="selectable">False</property>
+             <property name="xalign">0.5</property>
+             <property name="yalign">0.5</property>
+             <property name="xpad">0</property>
+             <property name="ypad">10</property>
+           </widget>
+           <packing>
+             <property name="padding">0</property>
+             <property name="expand">False</property>
+             <property name="fill">False</property>
+           </packing>
+         </child>
+
+         <child>
+           <widget class="GtkLabel" id="label37">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">An image categorization tool.</property>
+             <property name="use_underline">False</property>
+             <property name="use_markup">True</property>
+             <property name="justify">GTK_JUSTIFY_LEFT</property>
+             <property name="wrap">False</property>
+             <property name="selectable">False</property>
+             <property name="xalign">0.5</property>
+             <property name="yalign">0.46</property>
+             <property name="xpad">0</property>
+             <property name="ypad">5</property>
+           </widget>
+           <packing>
+             <property name="padding">0</property>
+             <property name="expand">False</property>
+             <property name="fill">False</property>
+           </packing>
+         </child>
+
+         <child>
+           <widget class="GtkLabel" id="label38">
+             <property name="visible">True</property>
+             <property name="label" translatable="yes">&lt;span size=&quot;small&quot;&gt;Copyright © 2002-2004 Joel Rosdahl and Ulrik Svensson&lt;/span&gt;</property>
+             <property name="use_underline">False</property>
+             <property name="use_markup">True</property>
+             <property name="justify">GTK_JUSTIFY_LEFT</property>
+             <property name="wrap">False</property>
+             <property name="selectable">False</property>
+             <property name="xalign">0.5</property>
+             <property name="yalign">0.5</property>
+             <property name="xpad">0</property>
+             <property name="ypad">0</property>
+           </widget>
+           <packing>
+             <property name="padding">0</property>
+             <property name="expand">False</property>
+             <property name="fill">False</property>
+           </packing>
+         </child>
+       </widget>
+       <packing>
+         <property name="padding">0</property>
+         <property name="expand">True</property>
+         <property name="fill">True</property>
+       </packing>
+      </child>
+    </widget>
+  </child>
+</widget>
+
 </glade-interface>
index 5ce01a0..dbd492a 100644 (file)
@@ -1,8 +1,35 @@
 import sys
+from kofoto.clientenvironment import DEFAULT_CONFIGFILE_LOCATION
 from gkofoto.environment import env
 from gkofoto.controller import Controller
+from optparse import OptionParser
 
 def main(bindir, argv):
-    setupOk = env.setup(bindir)
+    parser = OptionParser(version=env.version)
+    parser.add_option(
+        "--configfile",
+        type="string",
+        dest="configfile",
+        help="use configuration file CONFIGFILE instead of the default (%s)" % (
+            DEFAULT_CONFIGFILE_LOCATION),
+        default=None)
+    parser.add_option(
+        "--debug",
+        action="store_true",
+        help="print debug messages to stdout",
+        default=False)
+    parser.add_option(
+        "--shelf",
+        type="string",
+        dest="shelf",
+        help="use shelf SHELF instead of the default (specified in the configuration file)",
+        default=None)
+    options, args = parser.parse_args(argv[1:])
+
+    if len(args) != 0:
+        parser.error("incorrect number of arguments")
+
+    setupOk = env.setup(
+        bindir, options.debug, options.configfile, options.shelf)
     env.controller = Controller()
     env.controller.start(setupOk)
index 5058e63..25f826f 100644 (file)
@@ -61,6 +61,8 @@ class MainWindow(gtk.Window):
         env.widgets["menubarAbout"].get_children()[1].set_from_pixbuf(
             gtk.gdk.pixbuf_new_from_file(os.path.join(env.iconDir, "about-icon.png")))
 
+        env.widgets["menubarAbout"].connect("activate", self.showAboutBox)
+
         self.__sourceEntry.connect("activate", self._sourceEntryActivated)
 
         env.shelf.registerModificationCallback(self._shelfModificationChangedCallback)
@@ -105,6 +107,14 @@ class MainWindow(gtk.Window):
         dialog.run()
         dialog.destroy()
 
+    def showAboutBox(self, *unused):
+        widgets = gtk.glade.XML(env.gladeFile, "aboutDialog")
+        aboutDialog = widgets.get_widget("aboutDialog")
+        nameAndVersionLabel = widgets.get_widget("nameAndVersionLabel")
+        nameAndVersionLabel.set_text("Kofoto %s" % env.version)
+        aboutDialog.run()
+        aboutDialog.destroy()
+
     def getIconImage(self, name):
         pixbuf = gtk.gdk.pixbuf_new_from_file(os.path.join(env.iconDir, name))
         image = gtk.Image()
index a4ee217..39c43a0 100644 (file)
@@ -15,6 +15,10 @@ import sys
 from kofoto.config import *
 from kofoto.shelf import Shelf, FailedWritingError
 from kofoto.imagecache import ImageCache
+try:
+    from kofoto.version import version as kofotoVersion
+except ImportError:
+    kofotoVersion = "development version"
 
 ######################################################################
 # Public classes.
@@ -165,6 +169,10 @@ class ClientEnvironment(object):
         return self.__imageCache
     imageCache = property(getImageCache)
 
+    def getVersion(self):
+        return kofotoVersion
+    version = property(getVersion)
+
     def unicodeToLocalizedString(self, unicodeString):
         """If unicodeString is a Unicode string, convert it to a
         localized string. Otherwise, unicodeString is returned without