def main(): setup_pypath() import virtManager from virtManager import cli cli.setup_i18n(gettext_app, gettext_dir) # Need to do this before GTK strips args like --sync gtk_error = None origargs = " ".join(sys.argv[:]) # Urgh, pygtk merely logs a warning when failing to open # the X11 display connection, and lets everything carry # on as if all were fine. Ultimately bad stuff happens, # so lets catch it here & get the hell out... import warnings warnings.filterwarnings('error', module='gtk', append=True) try: import gobject # Set program name for gnome shell (before importing gtk, which # seems to call set_prgname on its own) if hasattr(gobject, "set_prgname"): gobject.set_prgname(appname) import gtk globals()["gtk"] = gtk except Warning, e: # ...the risk is we catch too much though # Damned if we do, damned if we dont :-)( gtk_error = str(e)
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 __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 start(self, option, logging): self.option = option self.logging = logging if (option.getSavePath() is None and option.getSetWall() is False and option.getWindow() is False and option.getDaemonize() is False): import gobject gobject.set_application_name('wallpaperoptimizer') gobject.set_prgname('wallpaperoptimizer') from WallpaperOptimizer.AppIndicator import AppIndicator AppIndicator(self.option, self.logging) gtk.main() else: self._runConsoleSide(self.option, self.logging)
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
from deluge.ui.gtkui.menubar import MenuBar from deluge.ui.gtkui.pluginmanager import PluginManager from deluge.ui.gtkui.preferences import Preferences from deluge.ui.gtkui.queuedtorrents import QueuedTorrents from deluge.ui.gtkui.sidebar import SideBar from deluge.ui.gtkui.statusbar import StatusBar from deluge.ui.gtkui.systemtray import SystemTray from deluge.ui.gtkui.toolbar import ToolBar from deluge.ui.gtkui.torrentdetails import TorrentDetails from deluge.ui.gtkui.torrentview import TorrentView from deluge.ui.hostlist import LOCALHOST from deluge.ui.sessionproxy import SessionProxy from deluge.ui.tracker_icons import TrackerIcons from deluge.ui.translations_util import set_language, setup_translations set_prgname('deluge'.encode('utf8')) log = logging.getLogger(__name__) try: from setproctitle import setproctitle, getproctitle except ImportError: def setproctitle(title): return def getproctitle(): return DEFAULT_PREFS = { 'standalone': True, 'interactive_add': True,
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)
# # In addition, as a special exception, the copyright holders give # permission to link the code of portions of this program with the OpenSSL # library. # You must obey the GNU General Public License in all respects for all of # the code used other than OpenSSL. If you modify file(s) with this # exception, you may extend this exception to your version of the file(s), # but you are not obligated to do so. If you do not wish to do so, delete # this exception statement from your version. If you delete this exception # statement from all source files in the program, then also delete it here. # # from deluge.log import LOG as log import gobject gobject.set_prgname("deluge") # Install the twisted reactor from twisted.internet import gtk2reactor reactor = gtk2reactor.install() import gettext import locale import pkg_resources import gtk, gtk.glade import sys try: from setproctitle import setproctitle, getproctitle except ImportError: setproctitle = lambda t: None
def run(Widget, pattern): window = gtk.Window() window.connect("delete-event", gtk.main_quit) window.set_default_size(800, 800) window.maximize() canvas = gtk.Table(20, 10, False) window.add(canvas) canvas.show() pattern_canvas = Widget(pattern) canvas.attach(pattern_canvas,1,10,0,19) pattern_canvas.show() btn1 = gtk.Button("Load Draft") btn1.connect("clicked", pattern_canvas.open_pattern) btn2 = gtk.Button("Load State") btn2.connect("clicked", pattern_canvas.load_state) btn3 = gtk.Button("Save State") btn3.connect("clicked", pattern_canvas.save_state) btn4 = gtk.Button("Export PDF/SVG") btn4.connect("clicked", pattern_canvas.export_chooser) btn5 = gtk.Button("Change Measures") btn5.connect("clicked", pattern_canvas.change_measures) btn_editextrapars = gtk.Button("Change Extra Parameters") btn_editextrapars.connect("clicked", pattern_canvas.change_extrapars) btn6 = gtk.Button("Reset to measures") btn6.connect("clicked", pattern_canvas.reset_measures) btn7 = gtk.Button("Reset View") btn7.connect("clicked", pattern_canvas.reset_view) btn8 = gtk.Button("Show/Hide Construction Points") btn8.connect("clicked", pattern_canvas.showshide_construction) btn_about = gtk.Button("About") btn_about.connect("clicked", about_dialogue) canvas.attach(btn1,0,1,0,1,xpadding=5) canvas.attach(btn2,0,1,1,2,xpadding=5) canvas.attach(btn3,0,1,2,3,xpadding=5) canvas.attach(btn4,0,1,3,4,xpadding=5) canvas.attach(btn5,0,1,4,5,xpadding=5) canvas.attach(btn_editextrapars,0,1,5,6,xpadding=5) canvas.attach(btn6,0,1,6,7,xpadding=5) canvas.attach(btn7,0,1,7,8,xpadding=5) canvas.attach(btn8,0,1,8,9,xpadding=5) canvas.attach(btn_about,0,1,9,10,xpadding=5) btn1.show() btn2.show() btn3.show() btn4.show() btn5.show() btn_editextrapars.show() btn6.show() btn7.show() btn8.show() btn_about.show() statusbar = gtk.Statusbar() statusbar.show() canvas.attach(statusbar,0,10,19,20) pattern_canvas.statusbar = statusbar pattern_canvas.pos_id = statusbar.get_context_id("Position") pattern_canvas.move_id = statusbar.get_context_id("Position of picked Point") accel_group = gtk.AccelGroup() accel_group.connect_group(ord('q'), gtk.gdk.CONTROL_MASK, gtk.ACCEL_LOCKED, gtk.main_quit) window.add_accel_group(accel_group) gobject.set_prgname("Pattern Drafter") # window.set_title("Pattern Draw -- " + pattern.filename+" ( "+pattern_canvas.save_name +" )") window.set_title("Pattern Drafter 0.0.1 -- "+pattern.name) window.present() gtk.main()
except Exception, details: self._error = details if self._file is not None: self._file.write(text) self._file.flush() def flush(self): if self._file is not None: self._file.flush() sys.stderr = MyStderr() # PyGTK2.10+ only throws a warning warnings.filterwarnings('error', module='gtk') try: import gobject gobject.set_prgname('gajim') import gtk except Warning, msg2: if str(msg2) == 'could not open display': print >> sys.stderr, _('Gajim needs X server to run. Quiting...') else: print >> sys.stderr, _('importing PyGTK failed: %s') % str(msg2) sys.exit() warnings.resetwarnings() if os.name == 'nt': warnings.filterwarnings(action='ignore') if gtk.widget_get_default_direction() == gtk.TEXT_DIR_RTL: i18n.direction_mark = u'\u200F'
def init_gnome(): from gobject import set_application_name, set_prgname set_prgname("Scribes") set_application_name("Scribes") return
] 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.
except Exception as e: libutempter = None sys.stderr.write('[WARN] Unable to load the library libutempter !\n') sys.stderr.write('[WARN] The <wall> command will not work in guake !\n') sys.stderr.write('[WARN] ' + str(e) + '\n') instance = None pygtk.require('2.0') gobject.threads_init() # Loading translation bindtextdomain(NAME, LOCALE_DIR) # Setting gobject program name gobject.set_prgname(NAME) class PromptQuitDialog(gtk.MessageDialog): """Prompts the user whether to quit or not if there are procs running. """ def __init__(self, parent, running_procs): super(PromptQuitDialog, self).__init__( parent, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO) self.set_keep_above(True) self.set_markup(_('Do you really want to quit Guake!?'))
SAMPLE_RATES = [8000, 11025, 22050, 32000, 44100, 48000, 96000, 192000] 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.
from deluge.ui.gtkui.menubar import MenuBar from deluge.ui.gtkui.pluginmanager import PluginManager from deluge.ui.gtkui.preferences import Preferences from deluge.ui.gtkui.queuedtorrents import QueuedTorrents from deluge.ui.gtkui.sidebar import SideBar from deluge.ui.gtkui.statusbar import StatusBar from deluge.ui.gtkui.systemtray import SystemTray from deluge.ui.gtkui.toolbar import ToolBar from deluge.ui.gtkui.torrentdetails import TorrentDetails from deluge.ui.gtkui.torrentview import TorrentView from deluge.ui.hostlist import LOCALHOST from deluge.ui.sessionproxy import SessionProxy from deluge.ui.tracker_icons import TrackerIcons from deluge.ui.translations_util import set_language, setup_translations set_prgname('deluge'.encode('utf8')) log = logging.getLogger(__name__) try: from setproctitle import setproctitle, getproctitle except ImportError: def setproctitle(title): return def getproctitle(): return DEFAULT_PREFS = { 'standalone': True,
def finish_startup(): from blaplay.blacore import blacfg, bladb # Initialize the config. blacfg.init() # Initialize the library. bla.library = bladb.init() # Create an instance of the playback device. from blaplay.blacore import blaplayer bla.player = blaplayer.init() # Initialize the GUI. from blaplay.blagui.blauimanager import BlaUIManager bla.ui_manager = BlaUIManager() from blaplay import blagui bla.window = blagui.init() from blaplay.blagui import blakeys blakeys.BlaKeys() # Set up the D-Bus interface. try: from blaplay.blautil import bladbus except ImportError: # If the DBUS module isn't available we just define a class which acts # on behalf of the module, issuing warnings whenever it's used. class bladbus: @classmethod def __warning(cls, exit): print_w("Failed to import dbus module. Install dbus-python.") if exit: raise SystemExit @classmethod def setup_bus(cls, *args): cls.__warning(False) @classmethod def query_bus(cls, *args): cls.__warning(True) bladbus.setup_bus() # Initialize MPRIS2 module. try: from blaplay.blautil import blampris except ImportError: pass else: blampris.init() # Initialize last.fm services. from blaplay.blautil import blafm blafm.init() # Initialize metadata module. from blaplay.blautil import blametadata blametadata.init() # Set process name for programs like top or gnome-system-monitor. import ctypes import ctypes.util gobject.set_prgname(blaconst.APPNAME) soname = ctypes.util.find_library("c") # 15 == PR_SET_NAME ctypes.CDLL(soname).prctl(15, blaconst.APPNAME, 0, 0, 0) # Finally, start the main loop. bla.main()