Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial import

  • Loading branch information...
commit 0c07242af30d1927f032068775305aaa6ab25c51 0 parents
@baverman authored
10 .gitignore
@@ -0,0 +1,10 @@
+/.ropeproject
+/.snaked_project
+*.pyc
+*.pyo
+/dist
+/build
+/*.egg-info
+/doc/_build
+/doc/doc.zip
+/tests/tmp
21 LICENSE
@@ -0,0 +1,21 @@
+The MIT License
+
+Copyright (c) 2010 Anton Bobrov
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
2  MANIFEST.in
@@ -0,0 +1,2 @@
+recursive-include snaked *.glade
+include LICENSE
22 setup.py
@@ -0,0 +1,22 @@
+from setuptools import setup, find_packages
+
+setup(
+ name = 'uxie',
+ version = '0.1',
+ author = 'Anton Bobrov',
+ author_email = 'bobrov@vl.ru',
+ description = 'GTK UX common functions and classes',
+ #long_description = open('README.rst').read(),
+ zip_safe = False,
+ packages = find_packages(exclude=('tests', )),
+ include_package_data = True,
+ url = 'http://github.com/baverman/uxie',
+ classifiers = [
+ "Programming Language :: Python",
+ "License :: OSI Approved :: MIT License",
+ "Development Status :: 4 - Beta",
+ "Environment :: X11 Applications :: GTK",
+ "Intended Audience :: Developers",
+ "Natural Language :: English",
+ ],
+)
0  uxie/__init__.py
No changes.
34 uxie/actions.py
@@ -0,0 +1,34 @@
+import gtk
+
+def get_accel_path(name):
+ return '<Actions>/' + name
+
+class Activator(object):
+ def __init__(self):
+ self.accel_group = gtk.AccelGroup()
+ self.actions = {}
+ self.shortcuts = {}
+
+ def attach(self, window):
+ window.add_accel_group(self.accel_group)
+
+ def map(self, name, accel):
+ key, modifier = km = gtk.accelerator_parse(accel)
+ gtk.accel_map_change_entry(get_accel_path(name), key, modifier, True)
+ self.shortcuts.setdefault(km, []).append(name)
+
+ def bind(self, name, desc, callback, *args):
+ self.actions[name] = (desc, callback, args)
+ self.accel_group.connect_by_path(get_accel_path(name), self.activate)
+
+ def bind_accel(self, name, desc, accel, callback, *args):
+ self.bind(name, desc, callback, *args)
+ self.map(name, accel)
+
+ def get_callback_and_args(self, *key):
+ return self.actions[self.shortcuts[key][0]][1:]
+
+ def activate(self, group, window, key, modifier):
+ cb, args = self.get_callback_and_args(key, modifier)
+ result = cb(*args)
+ return result is None or result
56 uxie/utils.py
@@ -0,0 +1,56 @@
+import os
+from os.path import join, dirname, exists, expanduser
+
+import gobject
+import gtk
+
+def idle_callback(callable, args):
+ args, kwargs = args
+ callable(*args, **kwargs)
+ return False
+
+def idle(callable, *args, **kwargs):
+ options = {}
+ if 'priority' in kwargs:
+ options['priority'] = kwargs['priority']
+ del kwargs['priority']
+ return gobject.idle_add(idle_callback, callable, (args, kwargs), **options)
+
+def join_to_file_dir(filename, *args):
+ return join(dirname(filename), *args)
+
+def join_to_settings_dir(*args):
+ config_dir = os.getenv('XDG_CONFIG_HOME', expanduser('~/.config'))
+ return join(config_dir, *args)
+
+def join_to_data_dir(*args):
+ config_dir = os.getenv('XDG_DATA_HOME', expanduser('~/.local/share'))
+ return join(config_dir, *args)
+
+def join_to_cache_dir(*args):
+ config_dir = os.getenv('XDG_CACHE_HOME', expanduser('~/.cache'))
+ return join(config_dir, *args)
+
+def make_missing_dirs(filename):
+ path = dirname(filename)
+ if not exists(path):
+ os.makedirs(path, mode=0755)
+
+def refresh_gui():
+ while gtk.events_pending():
+ gtk.main_iteration_do(block=False)
+
+
+class BuilderAware(object):
+ def __init__(self, glade_file):
+ self.gtk_builder = gtk.Builder()
+ self.gtk_builder.add_from_file(glade_file)
+ self.gtk_builder.connect_signals(self)
+
+ def __getattr__(self, name):
+ obj = self.gtk_builder.get_object(name)
+ if not obj:
+ raise AttributeError('Builder have no %s object' % name)
+
+ setattr(self, name, obj)
+ return obj
Please sign in to comment.
Something went wrong with that request. Please try again.