[caribou: 2/6] Project files are reorganized and have consts separated on a new file



commit 4b9ebd473e7a9dc6fbb3983fcda314da582f8bca
Author: Daniel Baeyens <dbaeyens warp es>
Date:   Wed Jun 16 01:38:41 2010 +0200

    Project files are reorganized and have consts separated on a new file
    
    New organization:
    caribou.common has files not related to the UI
    caribou.ui has files related to the UI
    
    Makefiles.am files have been modified to successfully build the package
    .gitignore is updated to ignore moved built files

 .gitignore                    |    2 +-
 bin/caribou.in                |   12 +++++++-----
 caribou/Makefile.am           |   12 ++++--------
 caribou/common/Makefile.am    |    8 ++++++++
 caribou/common/__init__.py    |    1 +
 caribou/{ => common}/const.py |    8 +++++---
 caribou/ui/Makefile.am        |   15 +++++++++++++++
 caribou/ui/__init__.py        |    1 +
 caribou/{ => ui}/animation.py |    0
 caribou/{ => ui}/i18n.py.in   |    0
 caribou/{ => ui}/keyboard.py  |   40 ++++++++++------------------------------
 caribou/{ => ui}/main.py      |    2 +-
 caribou/{ => ui}/opacity.py   |    0
 caribou/{ => ui}/window.py    |    2 +-
 configure.ac                  |    4 +++-
 15 files changed, 57 insertions(+), 50 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index ca461e1..5ef5d2b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,7 +14,7 @@ bin/caribou
 install-sh
 missing
 py-compile
-caribou/i18n.py
+caribou/ui/i18n.py
 mkinstalldirs
 po/Makefile.in.in
 po/POTFILES
diff --git a/bin/caribou.in b/bin/caribou.in
index c9a8189..9e8e0ae 100644
--- a/bin/caribou.in
+++ b/bin/caribou.in
@@ -43,14 +43,16 @@ _dirname = os.path.dirname(__file__)
 if os.path.dirname(__file__) != "@prefix@/bin":
     srcdir = os.path.normpath(os.path.join(_dirname, '..'))
     sys.path.insert(1, srcdir)
-    import caribou
+    import caribou.common
+    import caribou.ui
 else:
-    import caribou
+    import caribou.common
+    import caribou.ui
     caribou.data_path = os.path.join("@prefix@", "share", "caribou")
 
-import caribou.window as window
-import caribou.keyboard as keyboard
-import caribou.main as main
+import caribou.ui.window as window
+import caribou.ui.keyboard as keyboard
+import caribou.ui.main as main
 
 _ = gettext.gettext
 
diff --git a/caribou/Makefile.am b/caribou/Makefile.am
index 9095ab9..962a2b4 100644
--- a/caribou/Makefile.am
+++ b/caribou/Makefile.am
@@ -1,15 +1,11 @@
 cariboudir = $(pkgpythondir)/
 
 caribou_PYTHON = \
-	animation.py \
-	__init__.py \
-	keyboard.py \
-	main.py \
-	opacity.py \
-	window.py \
-	i18n.py
+	__init__.py 
 
-DISTCLEANFILES = i18n.py
+SUBDIRS = \
+        common/ \
+        ui/
 
 clean-local:
 	rm -rf *.pyc *.pyo
diff --git a/caribou/common/Makefile.am b/caribou/common/Makefile.am
new file mode 100644
index 0000000..fade772
--- /dev/null
+++ b/caribou/common/Makefile.am
@@ -0,0 +1,8 @@
+caribou_commondir = $(pkgpythondir)/common/
+
+caribou_common_PYTHON = \
+	__init__.py \
+	const.py 
+
+clean-local:
+	rm -rf *.pyc *.pyo
diff --git a/caribou/common/__init__.py b/caribou/common/__init__.py
new file mode 100644
index 0000000..8d1c8b6
--- /dev/null
+++ b/caribou/common/__init__.py
@@ -0,0 +1 @@
+ 
diff --git a/caribou/const.py b/caribou/common/const.py
similarity index 94%
rename from caribou/const.py
rename to caribou/common/const.py
index 919fc80..bb0aa7c 100644
--- a/caribou/const.py
+++ b/caribou/common/const.py
@@ -22,13 +22,15 @@
 from os.path import join
 from os.path import dirname
 
+import gtk
+
 # Application name
 APP_NAME = 'Caribou'
 APP_SLUG_NAME = 'caribou'
 
-# paths
-DATA_DIR = join('/usr', 'share', '%s' APP_SLUG_NAME)
-RESOURES_DIR = join(DATA_DIR, 'resources')
+# Paths
+DATA_DIR = join('/usr', 'share', '%s' % APP_SLUG_NAME)
+RESOURCES_DIR = join(DATA_DIR, 'resources')
 KEYBOARDS_DIR = join(RESOURCES_DIR, 'keyboards')
 CONFIG_DIR = join(RESOURCES_DIR, 'config')
 DATABASES_DIR = join(RESOURCES_DIR, 'databases')
diff --git a/caribou/ui/Makefile.am b/caribou/ui/Makefile.am
new file mode 100644
index 0000000..f4a352d
--- /dev/null
+++ b/caribou/ui/Makefile.am
@@ -0,0 +1,15 @@
+caribou_uidir = $(pkgpythondir)/ui/
+
+caribou_ui_PYTHON = \
+	__init__.py \
+	animation.py \
+        i18n.py \
+	keyboard.py \
+	main.py \
+	opacity.py \
+	window.py 
+
+DISTCLEANFILES = i18n.py
+
+clean-local:
+	rm -rf *.pyc *.pyo
diff --git a/caribou/ui/__init__.py b/caribou/ui/__init__.py
new file mode 100644
index 0000000..8d1c8b6
--- /dev/null
+++ b/caribou/ui/__init__.py
@@ -0,0 +1 @@
+ 
diff --git a/caribou/animation.py b/caribou/ui/animation.py
similarity index 100%
rename from caribou/animation.py
rename to caribou/ui/animation.py
diff --git a/caribou/i18n.py.in b/caribou/ui/i18n.py.in
similarity index 100%
rename from caribou/i18n.py.in
rename to caribou/ui/i18n.py.in
diff --git a/caribou/keyboard.py b/caribou/ui/keyboard.py
similarity index 90%
rename from caribou/keyboard.py
rename to caribou/ui/keyboard.py
index db5f5f7..6ac17fd 100644
--- a/caribou/keyboard.py
+++ b/caribou/ui/keyboard.py
@@ -22,6 +22,7 @@
 # along with this program; if not, write to the Free Software Foundation,
 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
+import caribou.common.const as const
 import gconf
 import gobject
 import gtk
@@ -37,28 +38,7 @@ else:
 import xml.etree.ElementTree as ET
 from xml.dom import minidom
 
-from . import data_path
-
-NORMAL_KEY_TYPE = 'normal'
-LAYOUT_SWITCHER_KEY_TYPE = 'layout_switcher'
-PREFERENCES_KEY_TYPE = 'preferences'
-DUMMY_KEY_TYPE = 'dummy'
-MASK_KEY_TYPE = 'mask'
-
-KEY_MASKS = {'shift': gtk.gdk.SHIFT_MASK,
-             'lock': gtk.gdk.LOCK_MASK,
-             'control': gtk.gdk.CONTROL_MASK,
-             'mod1': gtk.gdk.MOD1_MASK,
-             'mod2': gtk.gdk.MOD2_MASK,
-             'mod3': gtk.gdk.MOD3_MASK,
-             'mod4': gtk.gdk.MOD4_MASK,
-             'mod5': gtk.gdk.MOD5_MASK,
-             'button1': gtk.gdk.BUTTON1_MASK,
-             'button2': gtk.gdk.BUTTON2_MASK,
-             'button3': gtk.gdk.BUTTON3_MASK,
-             'button4': gtk.gdk.BUTTON4_MASK,
-             'button5': gtk.gdk.BUTTON5_MASK}
-
+from caribou import data_path
 
 class KeyboardPreferences:
     __gtype_name__ = "KeyboardPreferences"
@@ -128,10 +108,10 @@ class Key(gtk.Button):
         self.width = float(width)
         self.fill = False
         self.label = label or value
-        if self.key_type == DUMMY_KEY_TYPE:
+        if self.key_type == const.DUMMY_KEY_TYPE:
             self.set_relief(gtk.RELIEF_NONE)
             self.set_sensitive(False)
-        elif self.key_type == PREFERENCES_KEY_TYPE:
+        elif self.key_type == const.PREFERENCES_KEY_TYPE:
             image = gtk.Image()
             image.set_from_stock(gtk.STOCK_PREFERENCES,
                                  gtk.ICON_SIZE_BUTTON)
@@ -151,7 +131,7 @@ class Key(gtk.Button):
         return self._value
 
     def _set_value(self, value):
-        if self.key_type == NORMAL_KEY_TYPE:
+        if self.key_type == const.NORMAL_KEY_TYPE:
             if type(value) == str or type(value) == unicode:
                 value = value.decode('utf-8')
                 if len(value) == 1:
@@ -160,9 +140,9 @@ class Key(gtk.Button):
                     key_value = gtk.gdk.keyval_from_name(value)
                     if key_value:
                         self._value = key_value
-        elif self.key_type == MASK_KEY_TYPE:
+        elif self.key_type == const.MASK_KEY_TYPE:
             if type(value) == str or type(value) == unicode:
-                for key, mask in KEY_MASKS.items():
+                for key, mask in const.KEY_MASKS.items():
                     if value == key:
                         self._value = mask
         else:
@@ -307,13 +287,13 @@ class CaribouKeyboard(gtk.Notebook):
             self.append_page(layout)
             for row in layout.rows:
                 for key in row:
-                    if key.key_type == LAYOUT_SWITCHER_KEY_TYPE:
+                    if key.key_type == const.LAYOUT_SWITCHER_KEY_TYPE:
                         key.connect('clicked',
                                     self._pressed_layout_switcher_key)
-                    elif key.key_type == MASK_KEY_TYPE:
+                    elif key.key_type == const.MASK_KEY_TYPE:
                         key.connect('clicked',
                                     self._pressed_mask_key)
-                    elif key.key_type == PREFERENCES_KEY_TYPE:
+                    elif key.key_type == const.PREFERENCES_KEY_TYPE:
                         key.connect('clicked',
                                     self._pressed_preferences_key)
                     else:
diff --git a/caribou/main.py b/caribou/ui/main.py
similarity index 99%
rename from caribou/main.py
rename to caribou/ui/main.py
index 6c978de..2230243 100644
--- a/caribou/main.py
+++ b/caribou/ui/main.py
@@ -3,7 +3,7 @@ import pyatspi
 import gconf
 from window import CaribouWindowEntry
 from keyboard import CaribouKeyboard
-from i18n import _
+from caribou.ui.i18n import _
 
 debug = False
 
diff --git a/caribou/opacity.py b/caribou/ui/opacity.py
similarity index 100%
rename from caribou/opacity.py
rename to caribou/ui/opacity.py
diff --git a/caribou/window.py b/caribou/ui/window.py
similarity index 99%
rename from caribou/window.py
rename to caribou/ui/window.py
index 6d55c98..14f21ce 100644
--- a/caribou/window.py
+++ b/caribou/ui/window.py
@@ -19,7 +19,7 @@
 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
 import animation
-from . import data_path
+from caribou import data_path
 import gconf
 import gtk
 import gtk.gdk as gdk
diff --git a/configure.ac b/configure.ac
index b2bd70d..2bf96f4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -46,7 +46,9 @@ AC_OUTPUT([
 Makefile
 po/Makefile.in
 caribou/Makefile
-caribou/i18n.py
+caribou/common/Makefile
+caribou/ui/i18n.py
+caribou/ui/Makefile
 bin/Makefile
 bin/caribou
 data/Makefile



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]