diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2017-10-09 18:53:29 +0100 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2017-10-09 18:53:29 +0100 |
commit | 4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch) | |
tree | ba5f07bf3f9d22d82e54a462313f5d244036c768 /sci-electronics/gresistor |
reinit the tree, so we can have metadata
Diffstat (limited to 'sci-electronics/gresistor')
-rw-r--r-- | sci-electronics/gresistor/Manifest | 6 | ||||
-rw-r--r-- | sci-electronics/gresistor/files/SimpleGladeApp.py | 341 | ||||
-rw-r--r-- | sci-electronics/gresistor/gresistor-0.0.2.ebuild | 35 | ||||
-rw-r--r-- | sci-electronics/gresistor/metadata.xml | 11 |
4 files changed, 393 insertions, 0 deletions
diff --git a/sci-electronics/gresistor/Manifest b/sci-electronics/gresistor/Manifest new file mode 100644 index 000000000000..dc81470296de --- /dev/null +++ b/sci-electronics/gresistor/Manifest @@ -0,0 +1,6 @@ +AUX SimpleGladeApp.py 11794 SHA256 aa62b8dcb0285b14a17479c2531b92126db60f52243b291fe7166087ef0f5de3 SHA512 d6eb78b2e138d5b0813b993177106bc3713172ca65a7561584eea314053bc49e27fa784465ca87fa678d65382252bffda733a4c3e846f6161bd4dffa01e83d36 WHIRLPOOL bed6b33bce18cd5feb8c53044b754bcc78e8038920df5fe477b98ceb107c13228085c9a97b1f455abef30cf00ad00740aa41f364c3eb14215df40e462c281eec +DIST gresistor-0.0.2.tar.gz 10240 SHA256 6e9032d501b53adddc869eb32478a3e2052de1a90ca27409cd9c1102da4e5e96 SHA512 263483f5712a48f2095bddf620520233e2843c64c1a03a7924cecb856de8fdcac601100cda4dc9f1943ff7753ffaaab04e25032416dd9438fe3f17d7d6681072 WHIRLPOOL 680ea863910a0b0771b36ba84e694ded608badc445346cd292256b2f8d6d1cdd1e71a62d4000d05d9902963443b43dd76f83a0c0a71c6d01f3287cfea7baf0ae +EBUILD gresistor-0.0.2.ebuild 798 SHA256 b6ecc02c029e03c300b0f5fdda42b518703f13bac83abc27da50a6c8281bfd2d SHA512 efddc7d7db534f820c5cf193c976652dd5ae01707877908d730356a0f0dceca690ad45263e946c37bc52e3d611529d203b03e5e47cf4954cca75a17a28d8e66c WHIRLPOOL 7645afd612f36dd6b07b641a913655680ad472dcc2d5fcaba97657db6251965dbb0ef79398fd1ecd5818583fa822a2aefb5cffa3989265a9a2e8df8a1edf8c29 +MISC ChangeLog 2901 SHA256 febde5089f77eb6f776c9bc1ea28c3ab7144946fd4b2a8ed53aa99668427643b SHA512 85d88058df833e7e0f54464c77f866d5df3c0e93bd3ccbe5b027d553b04751426c05845f9f9b47e19b25d680d448845053a554f895dd420f4694ac63c4f9c5df WHIRLPOOL 5ae11a1cc1278e20689e491f355c740dd2d21941d59d28e3c208a30301c242c81add4969c8bfa6283d130bc876a371fb0be8f5dc46da67717a3968985946bb20 +MISC ChangeLog-2015 1522 SHA256 33ad5fe8e856fbd279fc1974aae901327cd61e3d755b10de30ce3d5fc5fe9427 SHA512 3880c991df9590fc33ef3414e10ae1a9a01917e48a54aa71c3c4cf0bba11f723ecae74339286d167aa72a4488022815c1fc538d996b79e2848143b546ca81f21 WHIRLPOOL 5d6b0ecc2a3dda215b0173e917c028ef2aa1b9b197cfda24e9b86873aa1bbff0d9b88b07cc293ab5d8eb2bd10c0fa3886afd0bab5bf27df0ca01ec8d7df58488 +MISC metadata.xml 329 SHA256 8d6fdbe3fa063c0b2526453b98c76647325eb9f126873cedeffdefe38a582dba SHA512 77eb3320109727b2c65e077b45bb8969218c9912d0f37e866d72f941555984d7974a711b549b485c9874dd88a65256aba7549a43bf93f168b7acada6999b99c7 WHIRLPOOL 302b521145d63697fb2323de961a291c237187913cfde43bfdf7b4bd5ab8e39db42e8be0bda455f9bef51702d5ecf9dd596b93796927b4f9192ab541481d6609 diff --git a/sci-electronics/gresistor/files/SimpleGladeApp.py b/sci-electronics/gresistor/files/SimpleGladeApp.py new file mode 100644 index 000000000000..90c598cc4fff --- /dev/null +++ b/sci-electronics/gresistor/files/SimpleGladeApp.py @@ -0,0 +1,341 @@ +""" + SimpleGladeApp.py + Module that provides an object oriented abstraction to pygtk and libglade. + Copyright (C) 2004 Sandino Flores Moreno +""" + +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA + +import os +import sys +import re + +import tokenize +import gtk +import gtk.glade +import weakref +import inspect + +__version__ = "1.0" +__author__ = 'Sandino "tigrux" Flores-Moreno' + +def bindtextdomain(app_name, locale_dir=None): + """ + Bind the domain represented by app_name to the locale directory locale_dir. + It has the effect of loading translations, enabling applications for different + languages. + + app_name: + a domain to look for translations, tipically the name of an application. + + locale_dir: + a directory with locales like locale_dir/lang_isocode/LC_MESSAGES/app_name.mo + If omitted or None, then the current binding for app_name is used. + """ + try: + import locale + import gettext + locale.setlocale(locale.LC_ALL, "") + gtk.glade.bindtextdomain(app_name, locale_dir) + gettext.install(app_name, locale_dir, unicode=1) + except (IOError,locale.Error), e: + print "Warning", app_name, e + __builtins__.__dict__["_"] = lambda x : x + + +class SimpleGladeApp: + + def __init__(self, path, root=None, domain=None, **kwargs): + """ + Load a glade file specified by glade_filename, using root as + root widget and domain as the domain for translations. + + If it receives extra named arguments (argname=value), then they are used + as attributes of the instance. + + path: + path to a glade filename. + If glade_filename cannot be found, then it will be searched in the + same directory of the program (sys.argv[0]) + + root: + the name of the widget that is the root of the user interface, + usually a window or dialog (a top level widget). + If None or ommited, the full user interface is loaded. + + domain: + A domain to use for loading translations. + If None or ommited, no translation is loaded. + + **kwargs: + a dictionary representing the named extra arguments. + It is useful to set attributes of new instances, for example: + glade_app = SimpleGladeApp("ui.glade", foo="some value", bar="another value") + sets two attributes (foo and bar) to glade_app. + """ + if os.path.isfile(path): + self.glade_path = path + else: + glade_dir = os.path.dirname( sys.argv[0] ) + self.glade_path = os.path.join(glade_dir, path) + for key, value in kwargs.items(): + try: + setattr(self, key, weakref.proxy(value) ) + except TypeError: + setattr(self, key, value) + self.glade = None + self.install_custom_handler(self.custom_handler) + self.glade = self.create_glade(self.glade_path, root, domain) + if root: + self.main_widget = self.get_widget(root) + else: + self.main_widget = None + self.normalize_names() + self.add_callbacks(self) + self.new() + + def __repr__(self): + class_name = self.__class__.__name__ + if self.main_widget: + root = gtk.Widget.get_name(self.main_widget) + repr = '%s(path="%s", root="%s")' % (class_name, self.glade_path, root) + else: + repr = '%s(path="%s")' % (class_name, self.glade_path) + return repr + + def new(self): + """ + Method called when the user interface is loaded and ready to be used. + At this moment, the widgets are loaded and can be refered as self.widget_name + """ + pass + + def add_callbacks(self, callbacks_proxy): + """ + It uses the methods of callbacks_proxy as callbacks. + The callbacks are specified by using: + Properties window -> Signals tab + in glade-2 (or any other gui designer like gazpacho). + + Methods of classes inheriting from SimpleGladeApp are used as + callbacks automatically. + + callbacks_proxy: + an instance with methods as code of callbacks. + It means it has methods like on_button1_clicked, on_entry1_activate, etc. + """ + self.glade.signal_autoconnect(callbacks_proxy) + + def normalize_names(self): + """ + It is internally used to normalize the name of the widgets. + It means a widget named foo:vbox-dialog in glade + is refered self.vbox_dialog in the code. + + It also sets a data "prefixes" with the list of + prefixes a widget has for each widget. + """ + for widget in self.get_widgets(): + widget_name = gtk.Widget.get_name(widget) + prefixes_name_l = widget_name.split(":") + prefixes = prefixes_name_l[ : -1] + widget_api_name = prefixes_name_l[-1] + widget_api_name = "_".join( re.findall(tokenize.Name, widget_api_name) ) + gtk.Widget.set_name(widget, widget_api_name) + if hasattr(self, widget_api_name): + raise AttributeError("instance %s already has an attribute %s" % (self,widget_api_name)) + else: + setattr(self, widget_api_name, widget) + if prefixes: + gtk.Widget.set_data(widget, "prefixes", prefixes) + + def add_prefix_actions(self, prefix_actions_proxy): + """ + By using a gui designer (glade-2, gazpacho, etc) + widgets can have a prefix in theirs names + like foo:entry1 or foo:label3 + It means entry1 and label3 has a prefix action named foo. + + Then, prefix_actions_proxy must have a method named prefix_foo which + is called everytime a widget with prefix foo is found, using the found widget + as argument. + + prefix_actions_proxy: + An instance with methods as prefix actions. + It means it has methods like prefix_foo, prefix_bar, etc. + """ + prefix_s = "prefix_" + prefix_pos = len(prefix_s) + + is_method = lambda t : callable( t[1] ) + is_prefix_action = lambda t : t[0].startswith(prefix_s) + drop_prefix = lambda (k,w): (k[prefix_pos:],w) + + members_t = inspect.getmembers(prefix_actions_proxy) + methods_t = filter(is_method, members_t) + prefix_actions_t = filter(is_prefix_action, methods_t) + prefix_actions_d = dict( map(drop_prefix, prefix_actions_t) ) + + for widget in self.get_widgets(): + prefixes = gtk.Widget.get_data(widget, "prefixes") + if prefixes: + for prefix in prefixes: + if prefix in prefix_actions_d: + prefix_action = prefix_actions_d[prefix] + prefix_action(widget) + + def custom_handler(self, + glade, function_name, widget_name, + str1, str2, int1, int2): + """ + Generic handler for creating custom widgets, internally used to + enable custom widgets (custom widgets of glade). + + The custom widgets have a creation function specified in design time. + Those creation functions are always called with str1,str2,int1,int2 as + arguments, that are values specified in design time. + + Methods of classes inheriting from SimpleGladeApp are used as + creation functions automatically. + + If a custom widget has create_foo as creation function, then the + method named create_foo is called with str1,str2,int1,int2 as arguments. + """ + try: + handler = getattr(self, function_name) + return handler(str1, str2, int1, int2) + except AttributeError: + return None + + def gtk_widget_show(self, widget, *args): + """ + Predefined callback. + The widget is showed. + Equivalent to widget.show() + """ + widget.show() + + def gtk_widget_hide(self, widget, *args): + """ + Predefined callback. + The widget is hidden. + Equivalent to widget.hide() + """ + widget.hide() + + def gtk_widget_grab_focus(self, widget, *args): + """ + Predefined callback. + The widget grabs the focus. + Equivalent to widget.grab_focus() + """ + widget.grab_focus() + + def gtk_widget_destroy(self, widget, *args): + """ + Predefined callback. + The widget is destroyed. + Equivalent to widget.destroy() + """ + widget.destroy() + + def gtk_window_activate_default(self, window, *args): + """ + Predefined callback. + The default widget of the window is activated. + Equivalent to window.activate_default() + """ + widget.activate_default() + + def gtk_true(self, *args): + """ + Predefined callback. + Equivalent to return True in a callback. + Useful for stopping propagation of signals. + """ + return True + + def gtk_false(self, *args): + """ + Predefined callback. + Equivalent to return False in a callback. + """ + return False + + def gtk_main_quit(self, *args): + """ + Predefined callback. + Equivalent to self.quit() + """ + self.quit() + + def main(self): + """ + Starts the main loop of processing events. + The default implementation calls gtk.main() + + Useful for applications that needs a non gtk main loop. + For example, applications based on gstreamer needs to override + this method with gst.main() + + Do not directly call this method in your programs. + Use the method run() instead. + """ + gtk.main() + + def quit(self): + """ + Quit processing events. + The default implementation calls gtk.main_quit() + + Useful for applications that needs a non gtk main loop. + For example, applications based on gstreamer needs to override + this method with gst.main_quit() + """ + gtk.main_quit() + + def run(self): + """ + Starts the main loop of processing events checking for Control-C. + + The default implementation checks wheter a Control-C is pressed, + then calls on_keyboard_interrupt(). + + Use this method for starting programs. + """ + try: + self.main() + except KeyboardInterrupt: + self.on_keyboard_interrupt() + + def on_keyboard_interrupt(self): + """ + This method is called by the default implementation of run() + after a program is finished by pressing Control-C. + """ + pass + + def install_custom_handler(self, custom_handler): + gtk.glade.set_custom_handler(custom_handler) + + def create_glade(self, glade_path, root, domain): + return gtk.glade.XML(self.glade_path, root, domain) + + def get_widget(self, widget_name): + return self.glade.get_widget(widget_name) + + def get_widgets(self): + return self.glade.get_widget_prefix("") diff --git a/sci-electronics/gresistor/gresistor-0.0.2.ebuild b/sci-electronics/gresistor/gresistor-0.0.2.ebuild new file mode 100644 index 000000000000..fa0b5112d491 --- /dev/null +++ b/sci-electronics/gresistor/gresistor-0.0.2.ebuild @@ -0,0 +1,35 @@ +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +EAPI=6 + +PYTHON_COMPAT=( python2_7 ) +DISTUTILS_SINGLE_IMPL=1 + +inherit distutils-r1 eutils + +DESCRIPTION="Translate a resistor color codes into a readable value" +HOMEPAGE="https://sourceforge.net/projects/gresistor/" +SRC_URI="mirror://sourceforge/gresistor/${P}.tar.gz" + +LICENSE="|| ( GPL-3 LGPL-3 )" +SLOT="0" +KEYWORDS="amd64 x86" +IUSE="" + +DEPEND=" + dev-python/pygtk:2[${PYTHON_USEDEP}] + x11-libs/gtk+:2 + gnome-base/libglade:2.0[${PYTHON_USEDEP}]" +RDEPEND="${DEPEND}" + +src_prepare() { + sed -i -e 's/Version=0.0.2/Version=1.0/g' ${PN}.desktop || die + distutils-r1_src_prepare +} + +src_install() { + distutils-r1_src_install + python_domodule "${FILESDIR}/SimpleGladeApp.py" + domenu ${PN}.desktop +} diff --git a/sci-electronics/gresistor/metadata.xml b/sci-electronics/gresistor/metadata.xml new file mode 100644 index 000000000000..987b979d3fc8 --- /dev/null +++ b/sci-electronics/gresistor/metadata.xml @@ -0,0 +1,11 @@ +<?xml version='1.0' encoding='UTF-8'?> +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> +<pkgmetadata> + <maintainer type="person"> + <email>hwoarang@gentoo.org</email> + <name>Markos Chandras</name> + </maintainer> + <upstream> + <remote-id type="sourceforge">gresistor</remote-id> + </upstream> +</pkgmetadata> |