def __init__(self, gyotoytop): gobject.set_application_name("Gyotoy") gobject.set_prgname("Gyotoy") self.gyotoytop = gyotoytop self._pyk_blocked = 0 self.length_unit = "geometrical" # read GUI definition self.glade = gtk.glade.XML(os.path.join(self.gyotoytop, "gyotoy.glade")) # handle destroy event (so that we can kill the window through window bar) self.window = self.glade.get_widget("window1") if self.window: self.window.connect("destroy", self.destroy) # autoconnect to callback functions # this will automatically connect the event handler "on_something_event" # to the here-defined function of the same name. This avoid defining a # long dictionary that serves the same purpose self.glade.signal_autoconnect(self) # set stdin non blocking, this will prevent readline to block # stdin is coming from yorick (yorick spawned this python process) fd = sys.stdin.fileno() flags = fcntl.fcntl(fd, fcntl.F_GETFL) fcntl.fcntl(fd, fcntl.F_SETFL, flags | os.O_NONBLOCK) # ... and add stdin to the event loop (yorick input pipe by spawn) gobject.io_add_watch(sys.stdin, gobject.IO_IN | gobject.IO_HUP, self.yo2py, None) # run: realize the interface, start event management gtk.main()
def run(self): gobject.set_application_name(app.config.get(prefs.SHORT_APP_NAME)) os.environ["PULSE_PROP_media.role"] = "video" gtk.gdk.threads_init() self._setup_webkit() self.startup() logging.info("Linux version: %s %s %s", platform.system(), platform.release(), platform.machine()) logging.info("Python version: %s", sys.version) logging.info("Gtk+ version: %s", gtk.gtk_version) logging.info("PyGObject version: %s", gtk.ver) logging.info("PyGtk version: %s", gtk.pygtk_version) langs = ("LANGUAGE", "LC_ALL", "LC_MESSAGES", "LANG") langs = [(l, os.environ.get(l)) for l in langs if os.environ.get(l)] logging.info("Language: %s", langs) try: import libtorrent logging.info("libtorrent: %s", libtorrent.version) except AttributeError: logging.info("libtorrent: unknown version") except ImportError: logging.exception("libtorrent won't load") try: import pycurl logging.info("pycurl: %s", pycurl.version) except ImportError: logging.exception("pycurl won't load") renderers.init_renderer() gtk.main() app.controller.on_shutdown()
def run(self): self.log_initial_info() gobject.set_application_name(app.config.get(prefs.SHORT_APP_NAME)) os.environ["PULSE_PROP_media.role"] = "video" gobject.threads_init() self._setup_webkit() associate_protocols(self._get_command()) gtkdirectorywatch.GTKDirectoryWatcher.install() self.menubar = gtkmenus.MainWindowMenuBar() renderers.init_renderer() self.startup() langs = ("LANGUAGE", "LC_ALL", "LC_MESSAGES", "LANG") langs = [(l, os.environ.get(l)) for l in langs if os.environ.get(l)] logging.info("Language: %s", langs) try: import libtorrent logging.info("libtorrent: %s", libtorrent.version) except AttributeError: logging.info("libtorrent: unknown version") except ImportError: logging.exception("libtorrent won't load") try: import pycurl logging.info("pycurl: %s", pycurl.version) except ImportError: logging.exception("pycurl won't load") try: gtk.main() except (KeyboardInterrupt, SystemExit): self.do_quit() app.controller.on_shutdown()
def set_application_name(app_name): """Set the name of the application.""" if has_gi: from gi.repository import GObject GObject.set_application_name(app_name) else: import gobject gobject.set_application_name(app_name)
def __init__(self, name, server, protocol, setName=False): if setName: import gobject gobject.set_application_name (name) self._name = name self._server = server self._protocol = protocol self._keyring = gkey.get_default_keyring_sync()
def __init__(self): CredentialStore.__init__(self) # Older versions of gobject don't provide get_application_name so we # can't always check. get_app_name = getattr(gobject, 'get_application_name', None) if get_app_name is None or get_app_name() is None: # External applications that load bzrlib may already have set the # application name so we don't contradict them (when we can # determine it that is). gobject.set_application_name("bzr")
def init_ui(self): gobject.set_application_name("Pithos") gtk.window_set_default_icon_name('pithos') os.environ['PULSE_PROP_media.role'] = 'music' self.playpause_button = self.builder.get_object('playpause_button') self.volume = self.builder.get_object('volume') self.volume.set_property("value", math.pow(float(self.preferences['volume']), 1.0/3.0)) self.statusbar = self.builder.get_object('statusbar1') self.song_menu = self.builder.get_object('song_menu') self.song_menu_love = self.builder.get_object('menuitem_love') self.song_menu_unlove = self.builder.get_object('menuitem_unlove') self.song_menu_ban = self.builder.get_object('menuitem_ban') self.song_menu_unban = self.builder.get_object('menuitem_unban') self.songs_treeview = self.builder.get_object('songs_treeview') self.songs_treeview.set_model(self.songs_model) title_col = gtk.TreeViewColumn() def bgcolor_data_func(column, cell, model, iter): if model.get_value(iter, 0) is self.current_song: bgcolor = column.get_tree_view().get_style().mid[gtk.STATE_NORMAL] else: bgcolor = column.get_tree_view().get_style().base[gtk.STATE_NORMAL] cell.set_property("cell-background-gdk", bgcolor) render_icon = CellRendererAlbumArt() title_col.pack_start(render_icon, expand=False) title_col.add_attribute(render_icon, "icon", 2) title_col.add_attribute(render_icon, "pixbuf", 3) title_col.set_cell_data_func(render_icon, bgcolor_data_func) render_text = gtk.CellRendererText() render_text.props.ellipsize = pango.ELLIPSIZE_END title_col.pack_start(render_text, expand=True) title_col.add_attribute(render_text, "markup", 1) title_col.set_cell_data_func(render_text, bgcolor_data_func) self.songs_treeview.append_column(title_col) self.songs_treeview.connect('button_press_event', self.on_treeview_button_press_event) self.stations_combo = self.builder.get_object('stations') self.stations_combo.set_model(self.stations_model) render_text = gtk.CellRendererText() self.stations_combo.pack_start(render_text, expand=True) self.stations_combo.add_attribute(render_text, "text", 1) self.stations_combo.set_row_separator_func(lambda model, iter: model.get_value(iter, 0) is None) buttonMenu(self.builder.get_object("toolbutton_options"), self.builder.get_object("menu_options"))
def __init__(self): gobject.GObject.__init__(self) gobject.set_application_name("Meld") gtk.window_set_default_icon_name("meld") self.version = version self.prefs = preferences.MeldPreferences() self.prefs.notify_add(self.on_preference_changed) self.file_filters = self._parse_filters(self.prefs.filters, FilterEntry.SHELL) self.text_filters = self._parse_filters(self.prefs.regexes, FilterEntry.REGEX)
def __init__(self): gobject.set_prgname(CONFIGURATION.get("name")) gobject.set_application_name("Internet Enabler") pynotify.init(CONFIGURATION.get("name")) self.notifications_show_actions = 'actions' in pynotify.get_server_caps() self.online = False self._create_gui() self.nm = NetworkListener() self.nm.connect("online", lambda x: self.authenticate("Enable")) if self.nm.online: delay_ms = int(CONFIGURATION.get("delay_ms")) if delay_ms >= 0: gobject.timeout_add(delay_ms,self.authenticate,"Enable")
def main(argv, reactor=None): """Run the client GUI. Typical use: >>> sys.exit(main(sys.argv)) @param argv: The arguments to run it with, e.g. sys.argv. @param reactor: The reactor to use. Must be compatible with gtk as this module uses gtk API"s. @return exitcode: The exit code it returned, as per sys.exit. """ if reactor is None: from twisted.internet import gtk2reactor gtk2reactor.install() from twisted.internet import reactor try: AWSStatusIcon(reactor) gobject.set_application_name("aws-status") reactor.run() except ValueError: # In this case, the user cancelled, and the exception bubbled to here. pass
def run(args, datadir): ''' Executes the properties dialog. ''' import logging # Support full tracing when --debug switch is passed: if '--debug' in args or '-d' in args: logging.getLogger().setLevel(logging.NOTSET) # Integrate DBus with GLib main loop from dbus.mainloop.glib import DBusGMainLoop DBusGMainLoop(set_as_default=True) # Initialize user interface import pygtk pygtk.require('2.0') from gettext import gettext as _ from gnome_lirc_properties import ui import gobject, gtk, gtk.gdk, os.path # Setup defaut properties: gobject.threads_init() gobject.set_application_name(_('Infrared Remote Control Properties')) gtk.window_set_default_icon_name('gnome-lirc-properties') # Enable thread support: gtk.gdk.threads_init() # Load the user interface: ui_filename = os.path.join(datadir, 'gnome-lirc-properties.ui') builder = gtk.Builder() builder.add_from_file(ui_filename) return ui.RemoteControlProperties(builder, datadir).run()
def init(library=None, icon=None, title=None, name=None): print_d("Entering quodlibet.init") _gtk_init(icon) _dbus_init() import gobject if title: gobject.set_prgname(title) set_process_title(title) # Issue 736 - set after main loop has started (gtk seems to reset it) gobject.idle_add(set_process_title, title) if name: gobject.set_application_name(name) # We already imported this, but Python is dumb and thinks we're rebinding # a local when we import it later. import quodlibet.util quodlibet.util.mkdir(quodlibet.const.USERDIR) if library: print_d("Initializing main library (%s)" % ( quodlibet.util.unexpand(library))) import quodlibet.library library = quodlibet.library.init(library) print_d("Initializing debugging extensions") import quodlibet.debug quodlibet.debug.init() print_d("Finished initialization.") return library
def __init__(self): gladefile = paths.ui_dir("meldapp.glade") gtk.window_set_default_icon_name("icon") if getattr(gobject, "pygobject_version", ()) >= (2, 16, 0): gobject.set_application_name("Meld") gnomeglade.Component.__init__(self, gladefile, "meldapp") self.prefs = MeldPreferences() actions = ( ("FileMenu", None, _("_File")), ("New", gtk.STOCK_NEW, _("_New..."), "<control>N", _("Start a new comparison"), self.on_menu_file_new_activate), ("Save", gtk.STOCK_SAVE, None, None, _("Save the current file"), self.on_menu_save_activate), ("SaveAs", gtk.STOCK_SAVE_AS, None, "<control><shift>S", "Save the current file with a different name", self.on_menu_save_as_activate), ("Close", gtk.STOCK_CLOSE, None, None, _("Close the current file"), self.on_menu_close_activate), ("Quit", gtk.STOCK_QUIT, None, None, _("Quit the program"), self.on_menu_quit_activate), ("EditMenu", None, _("_Edit")), ("Undo", gtk.STOCK_UNDO, None, "<control>Z", _("Undo the last action"), self.on_menu_undo_activate), ("Redo", gtk.STOCK_REDO, None, "<control><shift>Z", _("Redo the last undone action"), self.on_menu_redo_activate), ("Cut", gtk.STOCK_CUT, None, None, _("Cut the selection"), self.on_menu_cut_activate), ("Copy", gtk.STOCK_COPY, None, None, _("Copy the selection"), self.on_menu_copy_activate), ("Paste", gtk.STOCK_PASTE, None, None, _("Paste the clipboard"), self.on_menu_paste_activate), ("Find", gtk.STOCK_FIND, None, None, _("Search for text"), self.on_menu_find_activate), ("FindNext", None, _("Find Ne_xt"), "<control>G", _("Search forwards for the same text"), self.on_menu_find_next_activate), ("Replace", gtk.STOCK_FIND_AND_REPLACE, _("_Replace"), "<control>H", _("Find and replace text"), self.on_menu_replace_activate), ("Down", gtk.STOCK_GO_DOWN, None, "<control>D", _("Go to the next difference"), self.on_menu_edit_down_activate), ("Up", gtk.STOCK_GO_UP, None, "<control>E", _("Go to the previous difference"), self.on_menu_edit_up_activate), ("Preferences", gtk.STOCK_PREFERENCES, _("Prefere_nces"), None, _("Configure the application"), self.on_menu_preferences_activate), ("ViewMenu", None, _("_View")), ("FileStatus", None, _("File status")), ("VcStatus", None, _("Version status")), ("FileFilters", None, _("File filters")), ("Stop", gtk.STOCK_STOP, None, "Escape", _("Stop the current action"), self.on_toolbar_stop_clicked), ("Refresh", gtk.STOCK_REFRESH, None, "<control>R", _("Refresh the view"), self.on_menu_refresh_activate), ("Reload", gtk.STOCK_REFRESH, _("Reload"), "<control><shift>R", _("Reload the comparison"), self.on_menu_reload_activate), ("HelpMenu", None, _("_Help")), ("Help", gtk.STOCK_HELP, _("_Contents"), "F1", _("Open the Meld manual"), self.on_menu_help_activate), ("BugReport", gtk.STOCK_DIALOG_WARNING, _("Report _Bug"), None, _("Report a bug in Meld"), self.on_menu_help_bug_activate), ("About", gtk.STOCK_ABOUT, None, None, _("About this program"), self.on_menu_about_activate), ) toggleactions = ( ("Fullscreen", None, _("Full Screen"), "F11", _("View the comparison in full screen"), self.on_action_fullscreen_toggled, False), ("ToolbarVisible", None, _("_Toolbar"), None, _("Show or hide the toolbar"), self.on_menu_toolbar_toggled, self.prefs.toolbar_visible), ("StatusbarVisible", None, _("_Statusbar"), None, _("Show or hide the statusbar"), self.on_menu_statusbar_toggled, self.prefs.statusbar_visible) ) ui_file = paths.ui_dir("meldapp-ui.xml") self.actiongroup = gtk.ActionGroup('MainActions') self.actiongroup.set_translation_domain("meld") self.actiongroup.add_actions(actions) self.actiongroup.add_toggle_actions(toggleactions) self.ui = gtk.UIManager() self.ui.insert_action_group(self.actiongroup, 0) self.ui.add_ui_from_file(ui_file) self.ui.connect("connect-proxy", self._on_uimanager_connect_proxy) self.ui.connect("disconnect-proxy", self._on_uimanager_disconnect_proxy) for menuitem in ("Save", "Undo"): self.actiongroup.get_action(menuitem).props.is_important = True self.widget.add_accel_group(self.ui.get_accel_group()) self.menubar = self.ui.get_widget('/Menubar') self.toolbar = self.ui.get_widget('/Toolbar') self.appvbox.pack_start(self.menubar, expand=False) self.appvbox.pack_start(self.toolbar, expand=False) # TODO: should possibly use something other than doc_status self._menu_context = self.doc_status.get_context_id("Tooltips") self.statusbar = MeldStatusBar(self.task_progress, self.task_status, self.doc_status) self.widget.drag_dest_set( gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP, [ ('text/uri-list', 0, 0) ], gtk.gdk.ACTION_COPY) if gnomevfs_available: self.widget.connect('drag_data_received', self.on_widget_drag_data_received) self.toolbar.set_style( self.prefs.get_toolbar_style() ) self.toolbar.props.visible = self.prefs.toolbar_visible self.status_box.props.visible = self.prefs.statusbar_visible self.prefs.notify_add(self.on_preference_changed) self.idle_hooked = 0 self.scheduler = task.LifoScheduler() self.scheduler.connect("runnable", self.on_scheduler_runnable ) self.widget.set_default_size(self.prefs.window_size_x, self.prefs.window_size_y) self.ui.ensure_update() self.widget.show() self.widget.connect('focus_in_event', self.on_focus_change) self.widget.connect('focus_out_event', self.on_focus_change)
signal_name="SubjectsAdded", dbus_interface="org.freedesktop.Tracker1.Resources.Class", path="/org/freedesktop/Tracker1/Resources/Classes/mfo/FeedMessage") bus.add_signal_receiver (notification_removal, signal_name="SubjectsRemoved", dbus_interface="org.freedesktop.Tracker1.Resources.Class", path="/org/freedesktop/Tracker1/Resources/Classes/mfo/FeedMessage") bus.add_signal_receiver (notification_update, signal_name="SubjectsChanged", dbus_interface="org.freedesktop.Tracker1.Resources.Class", path="/org/freedesktop/Tracker1/Resources/Classes/mfo/FeedMessage") window = ui.get_object ("main_window") gobject.set_application_name ("Rss/tracker") create_posts_tree_view () ui.get_object("posts_treeview").set_model (posts_model) channels_treeview = create_channels_tree_view () channels_treeview.set_model (channels_model) dialog = gtk.Dialog ("Sources", window, gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) dialog.vbox.add (channels_treeview) ui.get_object ("button_toggle").connect ("clicked", clicked_toggle_cb) ui.get_object ("notebook1").connect ("switch-page", change_tab_cb)
# set imap_user = "******" # source "~/bin/mutt-gnome-keyring-password.py yourusername your.imap.server imap"| # # Note the trailing | character in the last line! # # This script was inspired by a similar hack for offlineimap by Ross Burton: # http://burtonini.com/blog/computers/offlineimap-2008-11-04-20-00 # import sys import gobject import gnomekeyring try: user, server, protocol = sys.argv[1:] except ValueError as e: print 'Error parsing arguments: %s' % (e,) print 'Usage: %s USERNAME SERVERNAME PROTOCOL' % (sys.argv[0],) sys.exit(1) gobject.set_application_name('Mutt') try: q = dict(user=user, server=server, protocol=protocol) keys = gnomekeyring.find_network_password_sync(**q) password = keys[0]["password"].replace('"', r'\"') print 'set imap_pass = "******"' % (password,) except (gnomekeyring.NoMatchError, gnomekeyring.IOError), e: pass
from urllib2 import AbstractHTTPHandler, build_opener, proxy_bypass, HTTPSHandler from . import OscConfigParser from osc import oscerr from .oscsslexcp import NoSecureSSLError GENERIC_KEYRING = False GNOME_KEYRING = False try: import keyring GENERIC_KEYRING = True except: try: import gobject gobject.set_application_name('osc') import gnomekeyring if os.environ['GNOME_DESKTOP_SESSION_ID']: # otherwise gnome keyring bindings spit out errors, when you have # it installed, but you are not under gnome # (even though hundreds of gnome-keyring daemons got started in parallel) # another option would be to support kwallet here GNOME_KEYRING = gnomekeyring.is_available() except: pass def _get_processors(): """ get number of processors (online) based on SC_NPROCESSORS_ONLN (returns 1 if config name does not exist).
def __init__(self): """ Conduit application class Parses command line arguments. Sets up the views and models; restores application settings, shows the splash screen and the UI Notes: 1) If conduit is launched without --console switch then the gui and the console interfaces are started 2) If launched with --console and then later via the gui then set up the gui and connect all the appropriate signal handlers """ self.splash = None self.gui = None self.statusIcon = None self.guiSyncSet = None self.uiLib = None gobject.set_application_name("Conduit") self.settingsFile = os.path.join(conduit.USER_DIR, "settings.xml") self.dbFile = os.path.join(conduit.USER_DIR, "mapping.db") #initialize application settings conduit.GLOBALS.settings = Settings() #command line parsing parser = optparse.OptionParser( prog="conduit", version="%%prog %s" % conduit.VERSION, description=_("Conduit is a synchronization application.")) parser.add_option( "-c", "--console", dest="build_gui", action="store_false", default=True, help=_("Launch without GUI. [default: %default]")) parser.add_option( "-f", "--config-file", metavar="FILE", default=self.settingsFile, help=_("Save dataprovider configuration to FILE. [default: %default]")) parser.add_option( "-i", "--iconify", action="store_true", default=False, help=_("Iconify on startup. [default: %default]")) parser.add_option( "-u", "--ui", metavar="NAME", default="gtk", help=_("Run with the specified UI. [default: %default]")) parser.add_option( "-w", "--with-modules", metavar="mod1,mod2", help=_("Only load modules in the named files. [default: load all modules]")) parser.add_option( "-x", "--without-modules", metavar="mod1,mod2", help=_("Do not load modules in the named files. [default: load all modules]")) parser.add_option( "-e", "--settings", metavar="key=val,key=val", help=_("Explicitly set internal Conduit settings (keys) to the given values for this session. [default: do not set]")) parser.add_option( "-U", "--enable-unsupported", action="store_true", default=False, help=_("Enable loading of unfinished or unsupported dataproviders. [default: %default]")) parser.add_option( "-d", "--debug", action="store_true", default=False, help=_("Generate more debugging information. [default: %default]")) parser.add_option( "-q", "--quiet", action="store_true", default=False, help=_("Generate less debugging information. [default: %default]")) parser.add_option( "-s", "--silent", action="store_true", default=False, help=_("Generate no debugging information. [default: %default]")) options, args = parser.parse_args() whitelist = None blacklist = None settings = {} if options.settings: for i in options.settings.split(','): k,v = i.split('=') settings[k] = v if options.with_modules: whitelist = options.with_modules.split(",") if options.without_modules: blacklist = options.without_modules.split(",") self.ui = options.ui self.settingsFile = os.path.abspath(options.config_file) if options.debug or not conduit.IS_INSTALLED: Logging.enable_debugging() if options.quiet: Logging.disable_debugging() if options.silent: Logging.disable_logging() log.info("Conduit v%s Installed: %s" % (conduit.VERSION, conduit.IS_INSTALLED)) log.info("Python: %s" % sys.version) log.info("Platform Implementations: %s,%s" % (conduit.BROWSER_IMPL, conduit.SETTINGS_IMPL)) if settings: log.info("Settings have been overridden: %s" % settings) #Make conduit single instance. If conduit is already running then #make the original process build or show the gui sessionBus = dbus.SessionBus() if Utils.dbus_service_available(APPLICATION_DBUS_IFACE, sessionBus): log.info("Conduit is already running") obj = sessionBus.get_object(APPLICATION_DBUS_IFACE, "/activate") conduitApp = dbus.Interface(obj, APPLICATION_DBUS_IFACE) if options.build_gui: if conduitApp.HasGUI(): conduitApp.ShowGUI() else: conduitApp.ImportGUI() conduitApp.ShowSplash() conduitApp.ShowStatusIcon() conduitApp.BuildGUI() conduitApp.ShowGUI() conduitApp.HideSplash() sys.exit(0) # Initialise dbus stuff here as any earlier will interfere # with Conduit already running check. bus_name = dbus.service.BusName(APPLICATION_DBUS_IFACE, bus=sessionBus) dbus.service.Object.__init__(self, bus_name, "/activate") #Throw up a splash screen ASAP. Dont show anything if launched via --console. if options.build_gui: log.info("Using UI: %s" % self.ui) self.ImportGUI() if not options.iconify: self.ShowSplash() self.ShowStatusIcon() #Dynamically load all datasources, datasinks and converters dirs_to_search = [ conduit.SHARED_MODULE_DIR, os.path.join(conduit.USER_DIR, "modules") ] if options.enable_unsupported: dirs_to_search.append(os.path.join(conduit.SHARED_MODULE_DIR, "UNSUPPORTED")) #Initialize all globals variables conduit.GLOBALS.app = self conduit.GLOBALS.moduleManager = ModuleManager(dirs_to_search) conduit.GLOBALS.moduleManager.load_all(whitelist, blacklist) conduit.GLOBALS.typeConverter = TypeConverter(conduit.GLOBALS.moduleManager) conduit.GLOBALS.syncManager = SyncManager(conduit.GLOBALS.typeConverter) conduit.GLOBALS.mappingDB = MappingDB(self.dbFile) conduit.GLOBALS.mainloop = gobject.MainLoop() #Build both syncsets and put on the bus as early as possible self.guiSyncSet = SyncSet( moduleManager=conduit.GLOBALS.moduleManager, syncManager=conduit.GLOBALS.syncManager, xmlSettingFilePath=self.settingsFile ) #Dbus view... conduit.GLOBALS.dbus = DBusInterface( conduitApplication=self, moduleManager=conduit.GLOBALS.moduleManager, typeConverter=conduit.GLOBALS.typeConverter, syncManager=conduit.GLOBALS.syncManager, guiSyncSet=self.guiSyncSet ) #Set the view models if options.build_gui: self.BuildGUI() if not options.iconify: self.ShowGUI() if self.statusIcon: dbusSyncSet = conduit.GLOBALS.dbus.get_syncset() dbusSyncSet.connect("conduit-added", self.statusIcon.on_conduit_added) dbusSyncSet.connect("conduit-removed", self.statusIcon.on_conduit_removed) #hide the splash screen self.HideSplash() try: conduit.GLOBALS.mainloop.run() except KeyboardInterrupt: self.Quit()
pynotify.init('Panucci') have_pynotify = True except: have_pynotify = False try: import hildon except: if platform.MAEMO: log = logging.getLogger('panucci.panucci') log.critical( 'Using GTK widgets, install "python2.5-hildon" ' 'for this to work properly.' ) if platform.FREMANTLE: # Workaround Maemo bug 6694 (Playback in Silent mode) gobject.set_application_name('FMRadio') gtk.icon_size_register('panucci-button', 32, 32) ################################################## # PanucciGUI ################################################## class PanucciGUI(object): """ The object that holds the entire panucci gui """ def __init__(self, settings, filename=None): self.__log = logging.getLogger('panucci.panucci.PanucciGUI') interface.register_gui(self) self.config = settings.config self.playlist = playlist.Playlist(self.config)
import magicicadaprotocol.dircontent_pb2 as dircontent_pb2 from magicicadaprotocol.dircontent_pb2 import DIRECTORY, SYMLINK from twisted.internet import reactor from magicicada.u1sync import metadata from magicicada.u1sync.client import (ConnectionError, AuthenticationError, NoSuchShareError, ForcedShutdown, Client) from magicicada.u1sync.constants import METADATA_DIR_NAME from magicicada.u1sync.genericmerge import show_tree, generic_merge from magicicada.u1sync.merge import (SyncMerge, ClobberServerMerge, ClobberLocalMerge, merge_trees) from magicicada.u1sync.scan import scan_directory from magicicada.u1sync.sync import download_tree, upload_tree from magicicada.u1sync.utils import safe_mkdir gobject.set_application_name('u1sync') DEFAULT_MERGE_ACTION = 'auto' MERGE_ACTIONS = { # action: (merge_class, should_upload, should_download) 'sync': (SyncMerge, True, True), 'clobber-server': (ClobberServerMerge, True, False), 'clobber-local': (ClobberLocalMerge, False, True), 'upload': (SyncMerge, True, False), 'download': (SyncMerge, False, True), 'auto': None # special case } NODE_TYPE_ENUM = dircontent_pb2._NODETYPE def node_type_str(node_type):
def __init__(self): """ Conduit application class Parses command line arguments. Sets up the views and models; restores application settings, shows the splash screen and the UI Notes: 1) If conduit is launched without --console switch then the gui and the console interfaces are started 2) If launched with --console and then later via the gui then set up the gui and connect all the appropriate signal handlers """ self.splash = None self.gui = None self.statusIcon = None self.dbus = None self.guiSyncSet = None self.dbusSyncSet = None self.uiLib = None gobject.set_application_name("Conduit") self.settingsFile = os.path.join(conduit.USER_DIR, "settings.xml") self.dbFile = os.path.join(conduit.USER_DIR, "mapping.db") # initialize application settings conduit.GLOBALS.settings = Settings() # command line parsing parser = optparse.OptionParser( prog="conduit", version="%%prog %s" % conduit.VERSION, description="Conduit is a synchronization application.", ) parser.add_option( "-c", "--console", dest="build_gui", action="store_false", default=True, help="Launch without GUI. [default: %default]", ) parser.add_option( "-f", "--config-file", metavar="FILE", default=self.settingsFile, help="Save dataprovider configuration to FILE. [default: %default]", ) parser.add_option( "-i", "--iconify", action="store_true", default=False, help="Iconify on startup. [default: %default]" ) parser.add_option( "-u", "--ui", metavar="NAME", default="gtk", help="Run with the specified UI. [default: %default]" ) parser.add_option( "-w", "--with-modules", metavar="mod1,mod2", help="Only load modules in the named files. [default: load all modules]", ) parser.add_option( "-x", "--without-modules", metavar="mod1,mod2", help="Do not load modules in the named files. [default: load all modules]", ) parser.add_option( "-s", "--settings", metavar="key=val,key=val", help="Explicitly set internal Conduit settings (keys) to the given values for this session. [default: do not set]", ) parser.add_option( "-U", "--enable-unsupported", action="store_true", default=False, help="Enable loading of unfinished or unsupported dataproviders. [default: %default]", ) options, args = parser.parse_args() whitelist = None blacklist = None settings = {} if options.settings: for i in options.settings.split(","): k, v = i.split("=") settings[k] = v if options.with_modules: whitelist = options.with_modules.split(",") if options.without_modules: blacklist = options.without_modules.split(",") self.ui = options.ui self.settingsFile = os.path.abspath(options.config_file) log.info("Conduit v%s Installed: %s" % (conduit.VERSION, conduit.IS_INSTALLED)) log.info("Python: %s" % sys.version) log.info( "Platform Implementations: %s,%s,%s" % (conduit.FILE_IMPL, conduit.BROWSER_IMPL, conduit.SETTINGS_IMPL) ) if settings: log.info("Settings have been overridden: %s" % settings) # Make conduit single instance. If conduit is already running then # make the original process build or show the gui sessionBus = dbus.SessionBus() if Utils.dbus_service_available(APPLICATION_DBUS_IFACE, sessionBus): log.info("Conduit is already running") obj = sessionBus.get_object(APPLICATION_DBUS_IFACE, "/activate") conduitApp = dbus.Interface(obj, APPLICATION_DBUS_IFACE) if options.build_gui: if conduitApp.HasGUI(): conduitApp.ShowGUI() else: conduitApp.ImportGUI() conduitApp.ShowSplash() conduitApp.ShowStatusIcon() conduitApp.BuildGUI() conduitApp.ShowGUI() conduitApp.HideSplash() sys.exit(0) # Initialise dbus stuff here as any earlier will interfere # with Conduit already running check. bus_name = dbus.service.BusName(APPLICATION_DBUS_IFACE, bus=sessionBus) dbus.service.Object.__init__(self, bus_name, "/activate") # Throw up a splash screen ASAP. Dont show anything if launched via --console. if options.build_gui: log.info("Using UI: %s" % self.ui) self.ImportGUI() if not options.iconify: self.ShowSplash() self.ShowStatusIcon() # Dynamically load all datasources, datasinks and converters dirs_to_search = [conduit.SHARED_MODULE_DIR, os.path.join(conduit.USER_DIR, "modules")] if options.enable_unsupported: dirs_to_search.append(os.path.join(conduit.SHARED_MODULE_DIR, "UNSUPPORTED")) # Initialize all globals variables conduit.GLOBALS.app = self conduit.GLOBALS.moduleManager = ModuleManager(dirs_to_search) conduit.GLOBALS.moduleManager.load_all(whitelist, blacklist) conduit.GLOBALS.typeConverter = TypeConverter(conduit.GLOBALS.moduleManager) conduit.GLOBALS.syncManager = SyncManager(conduit.GLOBALS.typeConverter) conduit.GLOBALS.mappingDB = MappingDB(self.dbFile) conduit.GLOBALS.mainloop = gobject.MainLoop() # Build both syncsets and put on the bus as early as possible self.guiSyncSet = SyncSet( moduleManager=conduit.GLOBALS.moduleManager, syncManager=conduit.GLOBALS.syncManager, xmlSettingFilePath=self.settingsFile, ) self.dbusSyncSet = SyncSet(moduleManager=conduit.GLOBALS.moduleManager, syncManager=conduit.GLOBALS.syncManager) # Set the view models if options.build_gui: self.BuildGUI() if not options.iconify: self.ShowGUI() # Dbus view... self.dbus = DBusInterface( conduitApplication=self, moduleManager=conduit.GLOBALS.moduleManager, typeConverter=conduit.GLOBALS.typeConverter, syncManager=conduit.GLOBALS.syncManager, guiSyncSet=self.guiSyncSet, dbusSyncSet=self.dbusSyncSet, ) if self.statusIcon: self.dbusSyncSet.connect("conduit-added", self.statusIcon.on_conduit_added) self.dbusSyncSet.connect("conduit-removed", self.statusIcon.on_conduit_removed) # hide the splash screen self.HideSplash() try: conduit.GLOBALS.mainloop.run() except KeyboardInterrupt: self.Quit()
def get_running_label(self): """ This method returns the string showing the current status when the engine is running """ return "%s insert %s clicks every %s sec." % ( self.publicname, self.msgsize, self.period) def get_random_webhistory_click(self): TEMPLATE = """<%s> a nfo:WebHistory; nie:title "This is one random title"; nie:contentCreated "%s"; nfo:domain "%s"; nfo:uri "%s". """ today = datetime.datetime.today() date = today.isoformat() + "+00:00" click_no = str(random.randint(100, 1000000)) resource = "urn:uuid:1234" + click_no uri = "http://www.maemo.org/" + click_no domain = "http://www.maemo.org" return TEMPLATE % (resource, date, domain, uri) if __name__ == "__main__": gobject.set_application_name("Web Browser saving clicks (inefficiently)") engine = WebBrowserEngine("Naughty Web Browser", options['period'], options['msgsize'], options['timeout']) mainloop()
def main(): if sys.version_info < (2, 5, 0): message = "Reinteract requires Python 2.5 or newer" print >>sys.stderr, message try: dialog = gtk.MessageDialog(buttons=gtk.BUTTONS_OK, type=gtk.MESSAGE_ERROR, message_format=message) dialog.run() finally: sys.exit(1) # When launched from the finder on OS X, the command line will have a # -psx (process serial number) argument. Strip that out. sys.argv = filter(lambda x: not x.startswith("-psn"), sys.argv) parser = OptionParser() parser.add_option("-u", "--ui", choices=("standard", "mini"), default="standard", help="the user interface mode (standard or mini)") parser.add_option("-d", "--debug", action="store_true", help="enable internal debug messages") options, args = parser.parse_args() if options.debug: logging.basicConfig(level=logging.DEBUG) global_settings.mini_mode = options.ui == "mini" user_ext_path = os.path.expanduser(os.path.join('~', '.reinteract', 'modules')) if os.path.exists(user_ext_path): sys.path[0:0] = [user_ext_path] gtk.window_set_default_icon_name("reinteract") gobject.set_application_name("Reinteract") if len(args) > 0: if options.ui == "standard": for arg in args: application.open_path(os.path.abspath(arg)) if len(application.windows) == 0: # nothing opened successfully sys.exit(1) else: # mini-mode, can specify one notebook if len(args) > 1: print >>sys.stderr, "Ignoring extra command line arguments." absolute = os.path.abspath(args[0]) # We look to see if we can find the specified notebook so that we can # produce a good error message instead of opening a worksheet window notebook_path, relative = application.find_notebook_path(absolute) if not notebook_path: if os.path.isdir(absolute): error_message = "'%s' is not a Reinteract notebook" % args[0] else: error_message = "'%s' is not inside a Reinteract notebook" % args[0] dialog = gtk.MessageDialog(buttons=gtk.BUTTONS_OK, type=gtk.MESSAGE_ERROR, message_format=error_message) dialog.run() sys.exit(1) if not application.open_path(absolute): sys.exit(1) else: recent_notebooks = application.state.get_recent_notebooks(max_count=1) if len(recent_notebooks) > 0: notebook_dir = recent_notebooks[0].path window = application.open_notebook(notebook_dir) else: notebook_dir = os.path.expanduser(os.path.join(global_settings.notebooks_dir, "Main")) if not os.path.exists(notebook_dir): window = application.create_notebook(notebook_dir, description="Notebook for scratch work.\nCreate worksheets here if they are not part of a larger project, or for quick experiments.") else: window = application.open_notebook(notebook_dir) # This really should be a more general check for "is writeable" if notebook_dir != global_settings.examples_dir: window.add_initial_worksheet() gtk.main()
BIT_RATES = [32, 64, 96, 128, 160, 192, 224] PLAYBACK_BACKENDS = [(_("Autodetect"), "autoaudiosink"), (_("Use GNOME Settings"), "gconfaudiosink"), ("ALSA", "alsasink"), ("OSS", "osssink"), ("JACK", "jackaudiosink"), ("PulseAudio", "pulsesink"), ("Direct Sound", "directsoundsink"), ("Core Audio", "osxaudiosink")] CAPTURE_BACKENDS = [(_("GNOME Settings"), "gconfaudiosrc"), ("ALSA", "alsasrc"), ("OSS", "osssrc"), ("JACK", "jackaudiosrc"), ("PulseAudio", "pulsesrc"), ("Direct Sound", "dshowaudiosrc"), ("Core Audio", "osxaudiosrc")] """ Default Instruments """ DEFAULT_INSTRUMENTS = [] """ init Settings """ settings = Settings() """ Cache Instruments """ gobject.idle_add(idleCacheInstruments) gobject.set_application_name(_("Jokosher Audio Editor")) gobject.set_prgname(LOCALE_APP) gtk.window_set_default_icon_name("jokosher") # environment variable for pulseaudio type os.environ["PULSE_PROP_media.role"] = "production" # I have decided that Globals.py is a boring source file. So, here is a little # joke. What does the tax office and a pelican have in common? They can both stick # their bills up their arses. Har har har.
# source "~/bin/mutt-gnome-keyring-password.py yourusername your.imap.server imap"| # # Note the trailing | character in the last line! # # This script was inspired by a similar hack for offlineimap by Ross Burton: # http://burtonini.com/blog/computers/offlineimap-2008-11-04-20-00 # import sys import gobject import gnomekeyring try: user, server, protocol = sys.argv[1:] except ValueError as e: print 'Error parsing arguments: %s' % (e,) print 'Usage: %s USERNAME SERVERNAME PROTOCOL' % (sys.argv[0],) sys.exit(1) gobject.set_application_name('Mutt') try: q = dict(user=user, server=server, protocol=protocol) keys = gnomekeyring.find_network_password_sync(**q) password = keys[0]["password"].replace('"', r'\"') print 'set imap_pass = "******"' % (password,) print 'set smtp_pass = "******"' % (password,) except (gnomekeyring.NoMatchError, gnomekeyring.IOError), e: pass
def init_gnome(): from gobject import set_application_name, set_prgname set_prgname("Scribes") set_application_name("Scribes") return
from twisted.internet import glib2reactor glib2reactor.install() from dbus.mainloop.glib import DBusGMainLoop DBusGMainLoop(set_as_default=True) from twisted.internet import reactor, defer, ssl from twisted.python.failure import Failure from twisted.python.util import mergeFunctionMetadata try: import gobject gobject.set_application_name("cmd_client") except ImportError: pass import _pythonpath # NOQA from ubuntuone.storageprotocol.client import StorageClientFactory, StorageClient from ubuntuone.storageprotocol import request, dircontent_pb2, volumes from ubuntuone.storageprotocol.dircontent_pb2 import DirectoryContent, DIRECTORY from ubuntuone.storageprotocol.content_hash import content_hash_factory, crc32 def show_volume(volume): """Show a volume.""" if isinstance(volume, volumes.ShareVolume): print "Share %r (other: %s, access: %s, id: %s)" % (
#! /usr/bin/python import gobject import gnomekeyring as keyring from optparse import OptionParser parser = OptionParser(add_help_option=False) parser.add_option("-o", "--old", dest="old", help="The old password", metavar="PASSWORD") parser.add_option("-n", "--new", dest="new", help="The new password", metavar="PASSWORD") parser.add_option("-?", "--help", action="help", help="show this help message and exit") (options, args) = parser.parse_args() if options.old is None or options.new is None: parser.error("You must provide old and new passwords") gobject.set_application_name("keyring-utils") for item_id in keyring.list_item_ids_sync("login"): item = keyring.item_get_info_sync("login", item_id) if item.get_secret() == options.old: print item.get_display_name() item.set_secret(options.new) keyring.item_set_info_sync("login", item_id, item)
import OscConfigParser from osc import oscerr from oscsslexcp import NoSecureSSLError GENERIC_KEYRING = False GNOME_KEYRING = False try: import keyring GENERIC_KEYRING = True except: try: import gobject gobject.set_application_name("osc") import gnomekeyring if os.environ["GNOME_DESKTOP_SESSION_ID"]: # otherwise gnome keyring bindings spit out errors, when you have # it installed, but you are not under gnome # (even though hundreds of gnome-keyring daemons got started in parallel) # another option would be to support kwallet here GNOME_KEYRING = gnomekeyring.is_available() except: pass def _get_processors(): """ get number of processors (online) based on
#! /usr/bin/python import sys, gobject, gnomekeyring, getpass from optparse import OptionParser gobject.set_application_name("offlineimap") parser = OptionParser(add_help_option=False) parser.add_option("-u", "--user", dest="user", help="The user name", metavar="USER") parser.add_option("-d", "--domain", dest="domain", help="The domain", metavar="DOMAIN") parser.add_option("-s", "--server", dest="server", help="The server", metavar="SERVER") parser.add_option("-o", "--object", dest="object", help="The remote object", metavar="OBJECT") parser.add_option("-c", "--protocol", dest="protocol", help="The protocol", metavar="PROTOCOL") parser.add_option("-a", "--authtype", dest="authtype", help="The authentication type", metavar="TYPE") parser.add_option("-p", "--port", dest="port", type="int", help="The port", metavar="PORT") parser.add_option("-?", "--help", action="help", help="show this help message and exit") parser.set_defaults(user=None, domain=None, server=None, object=None, protocol=None, authtype=None, port=0)
] CAPTURE_BACKENDS = [ (_("GNOME Settings"), "gconfaudiosrc"), ("ALSA", "alsasrc"), ("OSS", "osssrc"), ("JACK", "jackaudiosrc"), ("PulseAudio", "pulsesrc"), ("Direct Sound", "dshowaudiosrc"), ("Core Audio", "osxaudiosrc") ] """ Default Instruments """ DEFAULT_INSTRUMENTS = [] """ init Settings """ settings = Settings() """ Cache Instruments """ gobject.idle_add(idleCacheInstruments) gobject.set_application_name(_("Jokosher Audio Editor")) gobject.set_prgname(LOCALE_APP) gtk.window_set_default_icon_name("jokosher") # environment variable for pulseaudio type os.environ["PULSE_PROP_media.role"] = "production" # I have decided that Globals.py is a boring source file. So, here is a little # joke. What does the tax office and a pelican have in common? They can both stick # their bills up their arses. Har har har.
signal_name="SubjectsAdded", dbus_interface="org.freedesktop.Tracker3.Resources.Class", path="/org/freedesktop/Tracker3/Resources/Classes/mfo/FeedMessage") bus.add_signal_receiver (notification_removal, signal_name="SubjectsRemoved", dbus_interface="org.freedesktop.Tracker3.Resources.Class", path="/org/freedesktop/Tracker3/Resources/Classes/mfo/FeedMessage") bus.add_signal_receiver (notification_update, signal_name="SubjectsChanged", dbus_interface="org.freedesktop.Tracker3.Resources.Class", path="/org/freedesktop/Tracker3/Resources/Classes/mfo/FeedMessage") window = ui.get_object ("main_window") gobject.set_application_name ("Rss/tracker") create_posts_tree_view () ui.get_object("posts_treeview").set_model (posts_model) channels_treeview = create_channels_tree_view () channels_treeview.set_model (channels_model) dialog = gtk.Dialog ("Sources", window, gtk.DIALOG_MODAL|gtk.DIALOG_DESTROY_WITH_PARENT, (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT)) dialog.vbox.add (channels_treeview) ui.get_object ("button_toggle").connect ("clicked", clicked_toggle_cb) ui.get_object ("notebook1").connect ("switch-page", change_tab_cb)
def __init__(self): gobject.GObject.__init__(self) self.config = tgcm.core.Config.Config(tgcm.country_support) self.is_moving = False self.__is_maximized = False self.__unmaximized_width = 0 self.__unmaximized_height = 0 # Variables related to Wi-Fi Access Point status self._wifi_aap = False self._wifi_aap_listener_id = False self.XMLConf = tgcm.core.XMLConfig.XMLConfig() self.XMLConf.import_regional_info() self.XMLTheme = tgcm.core.XMLTheme.XMLTheme() self.XMLTheme.load_theme() self.dock_layout = self.XMLTheme.get_layout('dock.layout') # FIXME: Really ugly hack to set the correct size for a dock # with ads (e.g. Latam). # TGCM/Win uses a floating window to show the advertisements, but in # TGCM/Linux we need to have only one gtk.Window for the dock. The # size of our dock does not directly appear in themes.xml, so it is # needed to do some calculations to get it is_advertising = self.config.is_ads_available() if is_advertising: ad_layout = self.XMLTheme.get_layout('dock.advertising') orig_height = self.dock_layout['size']['height'] ad_height = ad_layout['size']['height'] self.dock_layout['size']['orig_height'] = orig_height self.dock_layout['size']['height'] = orig_height + ad_height orig_minY = self.dock_layout['border']['minY'] self.dock_layout['border']['orig_minY'] = orig_minY self.dock_layout['border']['minY'] = orig_height + ad_height # Gnome 3 is an "application based" system, as opposed to "window based" (see # http://live.gnome.org/GnomeShell/ApplicationBased for more info). The interesting # thing with Gnome 3 is that it uses a different (and somewhat insane) algorithm to # look for the application name. That string is used e.g. in the title bar, alt+tab, etc. # # Currently, it seems that a .desktop file accessible world-wide (e.g. in # /usr/share/applications) is required, and the value of the X property "WM_CLASS" must # match with the name of that .desktop file. For example, if an application package # provides a file called 'xxxx.desktop', the WM_CLASS property of the application window # must be something like WM_CLASS(STRING) = "xxxx", "Xxxx". # # We have a problem with TGCM, because by default PyGTK uses the name of the main python # script to set the WM_CLASS value (in our case WM_CLASS(STRING) = "tgcm", "Tgcm"), so # Gnome 3 fails to find the appropriate .desktop file (eg. "tgcm-[es|ar|de|uy].desktop"). # Instead of showing the correct application name, it shows "Tgcm". # # The following lines are intended to correctly establish the contents of the property # WM_CLASS to something like WM_CLASS(STRING) = "tgcm-es", "Tgcm-es". It unfortunately # fails but that is the documented way to do it. prg_name = 'tgcm-%s' % tgcm.country_support app_name = 'Tgcm-%s' % tgcm.country_support gobject.set_prgname(prg_name) gobject.set_application_name(app_name) gtk.window_set_default_icon(self.XMLTheme.get_window_icon()) self.main_window = gtk.Window() self.main_window.set_name("tgcm_main_window") self.main_window.set_title(self.config.get_app_name()) # WTF: Seems that PyGTK does not properly assign the property WM_CLASS with the # functions "gobject.set_prgname()". The following function indeed it does, but in # a very hostile and probably dangerous way. Keep it in mind! self.main_window.set_wmclass(prg_name, app_name) self.main_window.set_decorated(False) self.main_window.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_NORMAL) self.main_window.connect("show", self.__on_show_window) self.main_window.connect("delete-event", self.__on_destroy_window) self.main_window.connect("check-resize", self.__on_check_resize) self.main_window.connect("configure-event", self.__on_configure_event) self.main_window.connect("motion-notify-event", self.__motion_notify_event) self.help_dialog = None self.__is_first_time = False if self.config.is_first_time(): self.__is_first_time = True self.config.done_first_time() self.vbox = gtk.VBox() self.main_window.add(self.vbox) # Hidden menu, used for Ubuntu HUD and keyboard accelerators self.menubar = tgcm.ui.widgets.dock.Menubar.Menubar() self.vbox.pack_start(self.menubar.get_menubar(), False) self.main_box = gtk.Fixed() self.main_box.connect("size-allocate", self.__on_size_allocate) self.vbox.pack_start(self.main_box, True) self.vbox.show() self.menubar.get_menubar().hide() self.main_box.show() # Add a global URI hook to gtk.LinkButton widgets. This hook check if there is an # active connection before opening the URI, and if that is not the case it initiates # the SmartConnector logic gtk.link_button_set_uri_hook(self.__linkbutton_global_uri_hook)
""" superKlass.__init__ (self, name, period, msgsize, timeout) self.run () def get_insert_sparql (self): """ This method returns an string with the sparQL we will send to tracker.SparqlUpdate method """ return "INSERT { put here your triplets }" def get_running_label (self): """ This method returns the string showing the current status when the engine is running """ return "%s sends %s items every %s sec." % (self.publicname, self.msgsize, self.period) if __name__ == "__main__": gobject.set_application_name ("Here the title of the window") engine = MockEngine ("My mock stuff", options['period'], options['msgsize'], options['timeout']) mainloop ()
self.iface.SparqlUpdate (sparql_insert) self.last_inserted = uri def clicked_remove_cb (self, widget): uri = self.uri_entry.get_text () if (not uri or (len(uri) == 0)): pass sparql_delete = DELETE_SPARQL % (uri) print sparql_delete self.iface.SparqlUpdate (sparql_delete) def gen_new_post_cb (self, widget): today = datetime.datetime.today () self.date_entry.set_text (today.isoformat ().split('.')[0] + "+00:00") post_no = str(random.randint (100, 1000000)) self.uri_entry.set_text ("http://test.maemo.org/feed/" + post_no) self.title_entry.set_text ("Title %s" % (post_no)) if barnum_available : buf = gtk.TextBuffer () buf.set_text (gen_data.create_paragraphs (2, 5, 5)) self.post_text.set_wrap_mode (gtk.WRAP_WORD) self.post_text.set_buffer (buf) if __name__ == "__main__": DBusGMainLoop(set_as_default=True) gobject.set_application_name ("Feeds engine/signals simulator") SignalerUI ()
try: from twisted.internet import gireactor gireactor.install() except ImportError: from twisted.internet import glib2reactor glib2reactor.install() from dbus.mainloop.glib import DBusGMainLoop DBusGMainLoop(set_as_default=True) from twisted.internet import reactor, defer, ssl from twisted.python.failure import Failure from twisted.python.util import mergeFunctionMetadata try: import gobject gobject.set_application_name('cmd_client') except ImportError: pass import _pythonpath # NOQA from ubuntuone.storageprotocol.client import ( StorageClientFactory, StorageClient) from ubuntuone.storageprotocol import request, dircontent_pb2, volumes from ubuntuone.storageprotocol.dircontent_pb2 import \ DirectoryContent, DIRECTORY from ubuntuone.storageprotocol.content_hash import content_hash_factory, crc32 def show_volume(volume): """Show a volume."""
'django.contrib.sites', 'django.contrib.admin', 'django.contrib.admindocs', 'django.contrib.sitemaps', 'news', 'wammu', 'downloads', 'screenshots', 'links', 'manpages', 'phonedb', ) import gobject import gnomekeyring gobject.set_application_name('Wammu-web') IDENTICA_USER = '******' IDENTICA_PASSWORD = gnomekeyring.find_network_password_sync( user = IDENTICA_USER, domain = 'identi.ca', protocol = 'https')[0]['password'] NEWS_PER_PAGE = 5 NEWS_ON_MAIN_PAGE = 5 NEWS_ON_PRODUCT_PAGE = 2 NEWS_IN_RSS = 10 SCREENSHOTS_PER_PAGE = 20 PHONES_PER_PAGE = 50 PHONES_ON_INDEX = 10 PHONES_ON_MAIN_PAGE = 5 PHONES_IN_RSS = 10
pynotify.init('Panucci') have_pynotify = True except: have_pynotify = False try: import hildon except: if platform.MAEMO: log = logging.getLogger('panucci.panucci') log.critical('Using GTK widgets, install "python2.5-hildon" ' 'for this to work properly.') if platform.FREMANTLE: # Workaround Maemo bug 6694 (Playback in Silent mode) gobject.set_application_name('FMRadio') gtk.icon_size_register('panucci-button', 32, 32) ################################################## # PanucciGUI ################################################## class PanucciGUI(object): """ The object that holds the entire panucci gui """ def __init__(self, settings, filename=None): self.__log = logging.getLogger('panucci.panucci.PanucciGUI') interface.register_gui(self) self.config = settings.config self.playlist = playlist.Playlist(self.config)
""" self.publicname self.msgsize self.period contains these values for the subclasses """ superKlass.__init__(self, name, period, msgsize, timeout) self.run() def get_insert_sparql(self): """ This method returns an string with the sparQL we will send to tracker.SparqlUpdate method """ return "INSERT { put here your triplets }" def get_running_label(self): """ This method returns the string showing the current status when the engine is running """ return "%s sends %s items every %s sec." % (self.publicname, self.msgsize, self.period) if __name__ == "__main__": gobject.set_application_name("Here the title of the window") engine = MockEngine("My mock stuff", options['period'], options['msgsize'], options['timeout']) mainloop()
def __init__(self): # Set the last folder to the directory from which the program was called. useful.lastFolder = useful.origDir # Set the application's name (for about dialogue etc). gobject.set_application_name(str(useful.lName)) # Create & prepare the player for playing. self.preparePlayer() # Connect up the sigterm signal. signal.signal(signal.SIGTERM, self.sigterm) if msgBus.avail: self.dbus = msgBus.IntObject(self) # Set up the gtk-builder and interface. self.wTree = gtk.Builder() windowname = "main" self.wTree.add_from_file(useful.getBuilderFile('main')) dic = { "on_main_delete_event" : self.quit, "on_mnuiQuit_activate" : self.quit, "on_mnuiOpen_activate" : self.showOpenDialogue, "on_mnuiOpenURI_activate" : self.showOpenURIDialogue, "on_btnPlayToggle_clicked" : self.togglePlayPause, "on_btnStop_clicked" : self.stopPlayer, "on_btnNext_clicked" : self._cb_on_btnNext_clicked, "on_btnRestart_clicked" : self.restartTrack, "on_pbarProgress_button_press_event" : self.progressBarClick, "on_pbarProgress_button_release_event" : self.seekEnd, "on_pbarProgress_motion_notify_event" : self.progressBarMotion, "on_btnVolume_value_changed" : self.changeVolume, "on_mnuiFS_activate" : self.toggleFullscreen, "on_btnLeaveFullscreen_clicked" : self.toggleFullscreen, "on_videoWindow_expose_event" : self.videoWindowExpose, "on_videoWindow_configure_event" : self.videoWindowConfigure, "on_main_key_press_event" : self.windowKeyPressed, "on_videoWindow_button_press_event" : self.videoWindowClicked, "on_videoWindow_scroll_event" : self.videoWindowScroll, "on_mnuiAbout_activate" : self.showAboutDialogue, "on_main_drag_data_received" : self.openDroppedFiles, "on_videoWindow_motion_notify_event" : self.videoWindowMotion, "on_videoWindow_leave_notify_event" : self.videoWindowLeave, "on_videoWindow_enter_notify_event" : self.videoWindowEnter, "on_mnuiPreferences_activate" : self.showPreferencesDialogue, "on_mnuiPlayDVD_activate" : self.showPlayDVDDialogue, "on_mnuiDVDMenu_activate" : self.gotoDVDMenu, "on_mnuiAudioTrack_activate" : self.showAudioTracksDialogue, "on_mnuiSubtitleManager_activate" : self.openSubtitleManager, "on_mnuiReportBug_activate" : self.openBugReporter, "on_main_window_state_event" : self.onMainStateEvent, "on_mnuiQueue_toggled" : self.toggleQueueWindow, "on_eventNumQueued_button_release_event" : self.toggleQueueWindow, "on_mnuiAdvCtrls_toggled" : self.toggleAdvControls, "on_mnuiSupFeatures_activate" : self.openSupFeaturesDlg, "on_spnPlaySpeed_value_changed" : self.onPlaySpeedChange } self.wTree.connect_signals(dic) # Add the queue to the queue box. self.wTree.get_object("queueBox").pack_start(queue.qwin) # Get several items for access later. useful.mainWin = self.mainWindow = self.wTree.get_object(windowname) self.progressBar = self.wTree.get_object("pbarProgress") self.videoWindow = self.wTree.get_object("videoWindow") self.nowPlyLbl = self.wTree.get_object("lblNowPlaying") self.volAdj = self.wTree.get_object("btnVolume").get_adjustment() self.hboxVideo = self.wTree.get_object("hboxVideo") queue.mnuiWidget = self.wTree.get_object("mnuiQueue") # Set gapless flag self.isvideo = None # Set the icon. self.mainWindow.set_icon_from_file(os.path.join(useful.dataDir, 'images', 'whaawmp48.png')) # Set the window to allow drops self.mainWindow.drag_dest_set(gtk.DEST_DEFAULT_ALL, [("text/uri-list", 0, 0)], gtk.gdk.ACTION_COPY) # If we drop stuff on the queue label we want it queued (bottom right) self.wTree.get_object('lblNumQueued').drag_dest_set(gtk.DEST_DEFAULT_ALL, [("text/uri-list", 0, 0)], gtk.gdk.ACTION_COPY) self.wTree.get_object('lblNumQueued').connect('drag-data-received', queue.enqueueDropped) # Update the progress bar. self.progressUpdate() # Get the volume from the configuration. volVal = cfg.getFloat("audio/volume") if (cfg.cl.volume == None) else float(cfg.cl.volume) self.volAdj.value = useful.toRange(volVal, 0, 1) # Set the quit on stop checkbox. self.wTree.get_object("mnuiQuitOnStop").set_active(cfg.cl.quitOnEnd) # Set up the default flags. self.controlsShown = True self.seeking = False # Call the function to change the play/pause image. self.playPauseChange(False) # Show the next button & restart track button if enabled. if (cfg.getBool("gui/shownextbutton")): self.wTree.get_object("btnNext").show() if (cfg.getBool("gui/showrestartbutton")): self.wTree.get_object("btnRestart").show() # Setup the signals. signals.connect('toggle-play-pause', self.togglePlayPause) signals.connect('toggle-fullscreen', self.toggleFullscreen) signals.connect('play-next', self.playNext, False) signals.connect('restart-track', self.restartTrack) signals.connect('toggle-queue', queue.toggle) signals.connect('toggle-advanced-controls', self.toggleAdvancedControls) signals.connect('queue-changed', self.numQueuedChanged) # Show the window. self.mainWindow.show() # Save the windows ID so we can use it to inhibit screensaver. useful.winID = self.mainWindow.get_window().xid # Set the queue play command, so it can play tracks. queue.playCommand = self.playFile # Play a file (if it was specified on the command line). if (len(cfg.args) > 0): # Append all tracks to the queue. queue.appendMany(cfg.args) # Then play the next track. gobject.idle_add(self.playNext, False) if (cfg.cl.fullscreen): # If the fullscreen option was passed, start fullscreen. self.activateFullscreen() # Connect the hooks. self.connectLinkHooks() # Enter the GTK main loop. gtk.main()
from . import OscConfigParser from osc import oscerr from osc.util.helper import raw_input from .oscsslexcp import NoSecureSSLError from osc import credentials GENERIC_KEYRING = False GNOME_KEYRING = False try: import keyring GENERIC_KEYRING = True except: try: import gobject gobject.set_application_name('osc') import gnomekeyring GNOME_KEYRING = gnomekeyring.is_available() except: pass def _get_processors(): """ get number of processors (online) based on SC_NPROCESSORS_ONLN (returns 1 if config name does not exist). """ try: return os.sysconf('SC_NPROCESSORS_ONLN') except ValueError as e: return 1
query = "INSERT {" + triplets + "}" return query def get_running_label(self): return "%s sends %s rss entries every %s sec." % ( self.publicname, self.msgsize, self.period) def gen_new_post(self): SINGLE_POST = """ <%s> a nmo:FeedMessage ; nie:contentLastModified "%s" ; nmo:communicationChannel <http://maemo.org/news/planet-maemo/atom.xml>; nie:title "%s". """ today = datetime.datetime.today() date = today.isoformat() + "+00:00" post_no = str(random.randint(100, 1000000)) uri = "http://test.maemo.org/feed/" + post_no title = "Title %s" % (post_no) return SINGLE_POST % (uri, date, title) if __name__ == "__main__": gobject.set_application_name("Feeds engine/signals simulator") engine = RSSEngine("RSS", options['period'], options['msgsize'], options['timeout']) mainloop()
def __init__(self): gladefile = paths.ui_dir("meldapp.glade") gtk.window_set_default_icon_name("icon") if getattr(gobject, "pygobject_version", ()) >= (2, 16, 0): gobject.set_application_name("Meld") gnomeglade.Component.__init__(self, gladefile, "meldapp") self.prefs = MeldPreferences() actions = ( ("FileMenu", None, _("_File")), ("New", gtk.STOCK_NEW, _("_New..."), "<control>N", _("Start a new comparison"), self.on_menu_file_new_activate), ("Save", gtk.STOCK_SAVE, None, None, _("Save the current file"), self.on_menu_save_activate), ("SaveAs", gtk.STOCK_SAVE_AS, None, "<control><shift>S", "Save the current file with a different name", self.on_menu_save_as_activate), ("Close", gtk.STOCK_CLOSE, None, None, _("Close the current file"), self.on_menu_close_activate), ("Quit", gtk.STOCK_QUIT, None, None, _("Quit the program"), self.on_menu_quit_activate), ("EditMenu", None, _("_Edit")), ("Undo", gtk.STOCK_UNDO, None, "<control>Z", _("Undo the last action"), self.on_menu_undo_activate), ("Redo", gtk.STOCK_REDO, None, "<control><shift>Z", _("Redo the last undone action"), self.on_menu_redo_activate), ("Cut", gtk.STOCK_CUT, None, None, _("Cut the selection"), self.on_menu_cut_activate), ("Copy", gtk.STOCK_COPY, None, None, _("Copy the selection"), self.on_menu_copy_activate), ("Paste", gtk.STOCK_PASTE, None, None, _("Paste the clipboard"), self.on_menu_paste_activate), ("Find", gtk.STOCK_FIND, None, None, _("Search for text"), self.on_menu_find_activate), ("FindNext", None, _("Find Ne_xt"), "<control>G", _("Search forwards for the same text"), self.on_menu_find_next_activate), ("Replace", gtk.STOCK_FIND_AND_REPLACE, _("_Replace"), "<control>H", _("Find and replace text"), self.on_menu_replace_activate), ("Down", gtk.STOCK_GO_DOWN, None, "<control>D", _("Go to the next difference"), self.on_menu_edit_down_activate), ("Up", gtk.STOCK_GO_UP, None, "<control>E", _("Go to the previous difference"), self.on_menu_edit_up_activate), ("Preferences", gtk.STOCK_PREFERENCES, _("Prefere_nces"), None, _("Configure the application"), self.on_menu_preferences_activate), ("ViewMenu", None, _("_View")), ("FileStatus", None, _("File status")), ("VcStatus", None, _("Version status")), ("FileFilters", None, _("File filters")), ("Stop", gtk.STOCK_STOP, None, "Escape", _("Stop the current action"), self.on_toolbar_stop_clicked), ("Refresh", gtk.STOCK_REFRESH, None, "<control>R", _("Refresh the view"), self.on_menu_refresh_activate), ("Reload", gtk.STOCK_REFRESH, _("Reload"), "<control><shift>R", _("Reload the comparison"), self.on_menu_reload_activate), ("HelpMenu", None, _("_Help")), ("Help", gtk.STOCK_HELP, _("_Contents"), "F1", _("Open the Meld manual"), self.on_menu_help_activate), ("BugReport", gtk.STOCK_DIALOG_WARNING, _("Report _Bug"), None, _("Report a bug in Meld"), self.on_menu_help_bug_activate), ("About", gtk.STOCK_ABOUT, None, None, _("About this program"), self.on_menu_about_activate), ) toggleactions = (("Fullscreen", None, _("Full Screen"), "F11", _("View the comparison in full screen"), self.on_action_fullscreen_toggled, False), ("ToolbarVisible", None, _("_Toolbar"), None, _("Show or hide the toolbar"), self.on_menu_toolbar_toggled, self.prefs.toolbar_visible), ("StatusbarVisible", None, _("_Statusbar"), None, _("Show or hide the statusbar"), self.on_menu_statusbar_toggled, self.prefs.statusbar_visible)) ui_file = paths.ui_dir("meldapp-ui.xml") self.actiongroup = gtk.ActionGroup('MainActions') self.actiongroup.set_translation_domain("meld") self.actiongroup.add_actions(actions) self.actiongroup.add_toggle_actions(toggleactions) self.ui = gtk.UIManager() self.ui.insert_action_group(self.actiongroup, 0) self.ui.add_ui_from_file(ui_file) self.ui.connect("connect-proxy", self._on_uimanager_connect_proxy) self.ui.connect("disconnect-proxy", self._on_uimanager_disconnect_proxy) for menuitem in ("Save", "Undo"): self.actiongroup.get_action(menuitem).props.is_important = True self.widget.add_accel_group(self.ui.get_accel_group()) self.menubar = self.ui.get_widget('/Menubar') self.toolbar = self.ui.get_widget('/Toolbar') self.appvbox.pack_start(self.menubar, expand=False) self.appvbox.pack_start(self.toolbar, expand=False) # TODO: should possibly use something other than doc_status self._menu_context = self.doc_status.get_context_id("Tooltips") self.statusbar = MeldStatusBar(self.task_progress, self.task_status, self.doc_status) self.widget.drag_dest_set( gtk.DEST_DEFAULT_MOTION | gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP, [('text/uri-list', 0, 0)], gtk.gdk.ACTION_COPY) if gnomevfs_available: self.widget.connect('drag_data_received', self.on_widget_drag_data_received) self.toolbar.set_style(self.prefs.get_toolbar_style()) self.toolbar.props.visible = self.prefs.toolbar_visible self.status_box.props.visible = self.prefs.statusbar_visible self.prefs.notify_add(self.on_preference_changed) self.idle_hooked = 0 self.scheduler = task.LifoScheduler() self.scheduler.connect("runnable", self.on_scheduler_runnable) self.widget.set_default_size(self.prefs.window_size_x, self.prefs.window_size_y) self.ui.ensure_update() self.widget.show() self.widget.connect('focus_in_event', self.on_focus_change) self.widget.connect('focus_out_event', self.on_focus_change)