def show(options, filenames=[]): import gtk from gazpacho.catalog import load_catalogs load_catalogs() from gazpacho.loader.loader import ObjectBuilder if not filenames: raise SystemExit('--show needs at least one filename') windows = [] def window_close_cb(window, event): windows.remove(window) if not windows: gtk.main_quit() for filename in filenames: builder = ObjectBuilder(filename) for widget in builder.get_widgets(): if not isinstance(widget, gtk.Window): continue elif isinstance(widget, gtk.Action): if widget.get_property('stock-id') == gtk.STOCK_QUIT: widget.connect('activate', gtk.main_quit) widget.connect('delete-event', window_close_cb) widget.show_all() windows.append(widget) if not windows: raise SystemExit("none of the specified files has any windows") gtk.main()
def __init__(self, argv, base=None): """ All operation that Buxon need to run """ try: global widgets global callbacks global buxon if (base == None): path = __file__.split('/') base = '/'.join(path[:-1]) + '/' widgets = ObjectBuilder(base + 'includes/ui/graphical/buxon.glade') callbacks = Callbacks() widgets.signal_autoconnect(Callbacks.__dict__) buxon = Buxon(base) if ('-h' in argv or '--help' in argv): buxon.usage() if (len(argv) > 0): buxon.main(argv[0]) else: buxon.main() except KeyboardInterrupt: print 'Received Ctrl+C or another break signal. Exiting...' sys.exit()
def __init__(self, argv, base=None): """ All operation that Buxon need to run """ try: global widgets global callbacks global buxon if (base == None): path = __file__.split('/') base = '/'.join(path[:-1]) + '/' widgets = ObjectBuilder(base + 'includes/ui/graphical/buxon.glade') callbacks = Callbacks() widgets.signal_autoconnect(Callbacks.__dict__) buxon = Buxon(base) if ('-h' in argv or '--help' in argv): buxon.usage() if (len(argv)>0): buxon.main(argv[0]) else: buxon.main() except KeyboardInterrupt: print 'Received Ctrl+C or another break signal. Exiting...' sys.exit()
def __init__(self, **kwargs): self._app = kwargs.pop('app', None) kwargs['placeholder'] = self.create_placeholder kwargs['custom'] = Custom # We want to ignore the domain, otherwise we will end up # with a /translated/ interface inside gazpacho itself. kwargs['ignore_domain'] = True ObjectBuilder.__init__(self, **kwargs)
def _preview_cb(self, action): project = self.get_current_project() if not project.selection: return xml = project.serialize() builder = ObjectBuilder(buffer=xml) toplevel = project.selection[0].get_toplevel() widget = builder.get_widget(toplevel.get_name()) widget.show_all()
def __init__(self, argv, base='./'): """ All operation that Buxon need to run """ #configure buxon logger self.logger = logging.getLogger('buxon') self.logger.setLevel(logging.DEBUG) _hdlr = logging.StreamHandler() _hdlr.setFormatter( logging.Formatter( '%(asctime)s %(name)s %(levelname)s: %(message)s')) self.logger.addHandler(_hdlr) self.logger.info('Starting up Buxon') sys.path.append(base + 'src') sys.path.append(base + 'lib') from buxon.ui.buxonwindow import BuxonWindow try: global widgets global callbacks global buxon widgets = ObjectBuilder(base + 'includes/ui/graphical/buxon.glade') callbacks = Callbacks() widgets.signal_autoconnect(Callbacks.__dict__) self.logger.debug('GUI loaded') buxon = BuxonWindow(widgets, base) if ('-h' in argv or '--help' in argv): buxon.usage() if (len(argv) > 0): buxon.main(argv[0]) else: buxon.main() except KeyboardInterrupt: self.logger.info( 'Received Ctrl+C or another break signal. Exiting...') sys.exit()
def __init__(self, argv, base='./'): """ All operation that Buxon need to run """ #configure buxon logger self.logger = logging.getLogger('buxon') self.logger.setLevel(logging.DEBUG) _hdlr = logging.StreamHandler() _hdlr.setFormatter(logging.Formatter('%(asctime)s %(name)s %(levelname)s: %(message)s')) self.logger.addHandler(_hdlr) self.logger.info('Starting up Buxon') sys.path.append(base + 'src') sys.path.append(base + 'lib') from buxon.ui.buxonwindow import BuxonWindow try: global widgets global callbacks global buxon widgets = ObjectBuilder(base + 'includes/ui/graphical/buxon.glade') callbacks = Callbacks() widgets.signal_autoconnect(Callbacks.__dict__) self.logger.debug('GUI loaded') buxon = BuxonWindow(widgets, base) if ('-h' in argv or '--help' in argv): buxon.usage() if (len(argv)>0): buxon.main(argv[0]) else: buxon.main() except KeyboardInterrupt: self.logger.info('Received Ctrl+C or another break signal. Exiting...') sys.exit()
def __init__(self): self.app = get_utility(IGazpachoApp) self.plugin_manager = get_utility(IPluginManager) ui_file = environ.find_resource('glade', 'preferences.glade') app_window = self.app.get_window() self.ob = ObjectBuilder(ui_file) self.dialog = self.ob.get_widget('dialog') # dialog setup self.dialog.set_modal(True) self.dialog.set_transient_for(app_window) # this should go into the glade file as soon as we get support for it close = self.ob.get_widget('close') close.connect('clicked', self.on_close__clicked) # setup each tab self._setup_plugins_tab()
Report bugs to: <http://swaml.berlios.de/bugs> """ sys.exit() if ('-h' in sys.argv or '--help' in sys.argv): usage() widgets = None callbacks = None buxon = None if __name__ == '__main__': try: widgets = ObjectBuilder('includes/buxon.glade') callbacks = Callbacks() widgets.signal_autoconnect(Callbacks.__dict__) buxon = Buxon() if (len(sys.argv)>1): buxon.main(sys.argv[1]) else: buxon.main() except KeyboardInterrupt: print 'Received Ctrl+C or another break signal. Exiting...' sys.exit()
pygtk.require('2.0') import gtk import gobject import gettext import pango from sys import argv from gconfWrapper import GConf, GConfWrapper import os.path import srtLoader from saveconfirm import SaveConfirmationAlert from dialogProject import NewProjectDialog from gazpacho.loader.loader import ObjectBuilder wt = ObjectBuilder('ui-v1.xml') gconf = GConf('sutil') wrapper = GConfWrapper(gconf) class Controller: def __init__(self): self.counter = 1 self.movie = srtLoader.Movie() wt.get_widget('spinCurrentLine').set_value(0) wt.get_widget('hbox2').set_sensitive(False) wt.get_widget('tvOriginal2').get_buffer().create_tag("bold", weight=pango.WEIGHT_BOLD) wt.get_widget('tvTranslation2').get_buffer().create_tag("bold", weight=pango.WEIGHT_BOLD) wt.get_widget('tvTranslation2').set_overwrite(False)
Report bugs to: <http://swaml.berlios.de/bugs> """ sys.exit() if ('-h' in sys.argv or '--help' in sys.argv): usage() widgets = None callbacks = None buxon = None if __name__ == '__main__': try: widgets = ObjectBuilder('includes/buxon.glade') callbacks = Callbacks() widgets.signal_autoconnect(Callbacks.__dict__) buxon = Buxon() if (len(sys.argv) > 1): buxon.main(sys.argv[1]) else: buxon.main() except KeyboardInterrupt: print 'Received Ctrl+C or another break signal. Exiting...' sys.exit()
def __init__(self, gladefile=None, gladestream=None, root=None): self._wt = ObjectBuilder(filename=gladefile, buffer=gladestream, root=root) self._signal_magicconnect()
class Proxy(object): def __init__(self, gladefile=None, gladestream=None, root=None): self._wt = ObjectBuilder(filename=gladefile, buffer=gladestream, root=root) self._signal_magicconnect() def signal_autoconnect(self, dic): self._wt.signal_autoconnect(dic) def _signal_magicconnect(self): """Look for our methods to see if we need to connect any signal. This is copied from Kiwi.""" actions = [] if self._uimanager is not None: for a in [ag.list_actions() for ag in \ self._uimanager.get_action_groups()]: actions.extend(a) self._connect_methods('on_', actions) self._connect_methods('after_', actions) def _connect_methods(self, method_prefix, actions): methods = [m for m in getmembers(self) \ if ismethod(m[1]) and m[0].find(method_prefix) == 0] for name, method in methods: index = name.rfind('__') widget_name = name[len(method_prefix):index] signal_name = name[index+2:] try: # First we look in the widgets widget = self._wt.get_widget(widget_name) if not widget: raise AttributeError if method_prefix == 'on_': widget.connect(signal_name, method) elif method_prefix == 'after_': widget.connect_after(signal_name, method) except AttributeError: # Now we try to find it in the actions for action in actions: if widget_name == action.get_name(): if method_prefix == 'on_': action.connect(signal_name, method) elif method_prefix == 'after_': action.connect_after(signal_name, method) break else: print ('Warning: the widget %s is not on my widget tree ' 'neither in the action list') % widget_name def __getattr__(self, name): """Easy way to access the widgets by their name.""" return self._wt.get_widget(name) def get_widgets(self): """Returns an iterator to loop through the widgets.""" return self._wt.widgets widgets = property(get_widgets)
class PreferencesDialog: def __init__(self): self.app = get_utility(IGazpachoApp) self.plugin_manager = get_utility(IPluginManager) ui_file = environ.find_resource('glade', 'preferences.glade') app_window = self.app.get_window() self.ob = ObjectBuilder(ui_file) self.dialog = self.ob.get_widget('dialog') # dialog setup self.dialog.set_modal(True) self.dialog.set_transient_for(app_window) # this should go into the glade file as soon as we get support for it close = self.ob.get_widget('close') close.connect('clicked', self.on_close__clicked) # setup each tab self._setup_plugins_tab() def on_close__clicked(self, button): self.dialog.response(gtk.RESPONSE_CLOSE) def run(self): self.dialog.show() self.dialog.run() self.dialog.destroy() def _setup_plugins_tab(self): plugin_list = self.ob.get_widget('plugins_list') model = gtk.ListStore(bool, str, object) # fill the model for plugin_info in self.plugin_manager.get_plugins(): activated = self.plugin_manager.is_activated(plugin_info.name) model.append((activated, plugin_info.title, plugin_info)) plugin_list.set_model(model) # make the cells editable toggle = self.ob.get_widget('treeviewcolumn1-renderer1') toggle.set_property('activatable', True) toggle.connect('toggled', self.on_plugin__activated, model) # disable buttons plugin_about = self.ob.get_widget('plugin_about') plugin_about.set_sensitive(False) plugin_about.connect('clicked', self.on_plugin_about__clicked) plugin_preferences = self.ob.get_widget('plugin_preferences') plugin_preferences.set_sensitive(False) plugin_preferences.connect('clicked', self.on_plugin_prefs__clicked) selection = plugin_list.get_selection() selection.connect('changed', self.on_plugin_selection__changed) def on_plugin__activated(self, cell, path, model): row = model[path] new_value = not row[COL_ACTIVATED] row[COL_ACTIVATED] = new_value plugin = row[COL_PLUGININFO] if new_value: self.plugin_manager.activate_plugin(plugin.name, self.app) else: self.plugin_manager.deactivate_plugin(plugin.name) plugin_preferences = self.ob.get_widget('plugin_preferences') plugin_preferences.set_sensitive(new_value) config.set_plugin(plugin.name, new_value) def on_plugin_selection__changed(self, selection): model, model_iter = selection.get_selected() plugin_about = self.ob.get_widget('plugin_about') plugin_preferences = self.ob.get_widget('plugin_preferences') if model_iter: plugin_about.set_sensitive(True) activated = model.get_value(model_iter, COL_ACTIVATED) plugin_preferences.set_sensitive(activated) else: plugin_about.set_sensitive(False) plugin_preferences.set_sensitive(False) def on_plugin_about__clicked(self, button): plugin_info = self._get_selected_plugin() if plugin_info: dialog = gtk.AboutDialog() dialog.set_name(plugin_info.title) dialog.set_version(plugin_info.version) dialog.set_comments(plugin_info.description) dialog.set_authors([plugin_info.author]) dialog.set_transient_for(self.dialog) dialog.run() dialog.destroy() def on_plugin_prefs__clicked(self, button): plugin_info = self._get_selected_plugin() if plugin_info: self.plugin_manager.show_plugin_preferences(plugin_info.name, self.dialog) def _get_selected_plugin(self): plugin_list = self.ob.get_widget('plugins_list') selection = plugin_list.get_selection() model, model_iter = selection.get_selected() if model_iter: return model.get_value(model_iter, COL_PLUGININFO)
self.statusbar = widgets.get_widget('gsrStatusbar') self.messageBar('ready') #main window self.window = widgets.get_widget('gsr') self.window.set_icon_from_file('rdf.ico') self.window.show() #RDFlib namespaces RDF = Namespace(u'http://www.w3.org/1999/02/22-rdf-syntax-ns#') SIOC = Namespace(u'http://rdfs.org/sioc/ns#') DC = Namespace(u'http://purl.org/dc/elements/1.1/') DCTERMS = Namespace(u'http://purl.org/dc/terms/') #and all necessary for PyGTK widgets = ObjectBuilder('gsr.glade') callbacks = Callbacks() widgets.signal_autoconnect(Callbacks.__dict__) gsr = GSR() if __name__ == '__main__': try: if (len(sys.argv) > 1): gsr.main(sys.argv[1]) else: gsr.main() except KeyboardInterrupt: print 'Received Ctrl+C or another break signal. Exiting...' sys.exit()