Ejemplo n.º 1
0
def main():
    GLib.threads_init()
    Clutter.init(sys.argv)

    MainWindow()

    Clutter.main()
Ejemplo n.º 2
0
 def mostrar(self):
     self.show_all()
     GLib.threads_init()
     Gdk.threads_init()
     Gdk.threads_enter()
     Gtk.main()
     Gdk.threads_leave()
    def __init__(self, application, file_contents_glib_bytes):
        self.Application = application
        self.FileFlatpakRefContentsGLibBytes = file_contents_glib_bytes

        self.FlatpakInstallation = Flatpak.Installation.new_system(
            Gio.Cancellable.new())
        self.FlatpakTransaction = \
            Flatpak.Transaction.new_for_installation(
                self.FlatpakInstallation,
                Gio.Cancellable.new())
        self.FlatpakTransaction.set_disable_dependencies(False)
        self.FlatpakTransaction.set_disable_prune(False)
        self.FlatpakTransaction.set_disable_related(False)
        self.FlatpakTransaction.set_disable_static_deltas(False)
        self.FlatpakTransaction.set_no_deploy(False)
        self.FlatpakTransaction.set_no_pull(False)
        self.FlatpakTransaction.add_install_flatpakref(
            file_contents_glib_bytes)

        self.handler_id = self.FlatpakTransaction.connect(
            "new-operation", self.install_progress_callback)
        self.handler_id_2 = self.FlatpakTransaction.connect(
            "operation-done", self.install_progress_callback_disconnect)
        self.handler_id_error = self.FlatpakTransaction.connect(
            "operation-error", self.install_progress_callback_error)

        try:
            install_from_file_gui_file = "/usr/share/pardus/pardus-flatpak-gui/ui/actionwindow.glade"
            install_from_file_builder = Gtk.Builder.new_from_file(
                install_from_file_gui_file)
            install_from_file_builder.connect_signals(self)
        except GLib.GError:
            print(_("Error reading GUI file: ") + install_from_file_gui_file)
            raise

        self.InstallFromFileWindow = install_from_file_builder.get_object(
            "ActionWindow")
        self.InstallFromFileWindow.set_application(application)
        self.InstallFromFileWindow.set_title(_("Installing from file..."))
        self.InstallFromFileWindow.show()

        self.InstallFromFileProgressBar = install_from_file_builder.get_object(
            "ActionProgressBar")
        self.ProgressBarValue = int(
            self.InstallFromFileProgressBar.get_fraction() * 100)

        self.InstallFromFileLabel = install_from_file_builder.get_object(
            "ActionLabel")
        self.InstallFromFileTextBuffer = install_from_file_builder.get_object(
            "ActionTextBuffer")

        self.InstallFromFileTextBuffer.set_text("\0", -1)
        self.StatusText = _("Installing from file...")
        self.InstallFromFileLabel.set_text(self.StatusText)
        self.InstallFromFileTextBuffer.set_text(self.StatusText)

        self.InstallFromFileThread = threading.Thread(
            target=self.install_from_file, args=())
        self.InstallFromFileThread.start()
        GLib.threads_init()
Ejemplo n.º 4
0
def main():
    parser = OptionParser(version=MAINWIN_TITLE_DEFAULT + " - v%d.%d" % (APP_VERSION_MAJOR, APP_VERSION_MINOR))
    (options, args) = parser.parse_args()

    if (len(args) > 0):
        filename = args[0]
    else:
        filename = None

    print (options, args)
    #os._exit(0)

    signal.signal(signal.SIGINT, signal_handler)

    # Use threads
    GLib.threads_init()
    Gdk.threads_init()

    window = MenuExampleWindow()
    window.set_current_doc(filename)
    window.resize(1400, 500)
    window.connect("delete-event", Gtk.main_quit)
    window.show_all()

    #thread = threading.Thread(target=app.thr_main)
    #thread.start()

    Gdk.threads_init()
    Gtk.main()
    Gdk.threads_leave()
Ejemplo n.º 5
0
def main():
    GLib.threads_init()
    Gdk.threads_init()
    dbus.glib.threads_init()
    Gst.init(sys.argv)

    cleanup_temporary_files()

    _start_window_manager()

    setup_locale()
    setup_fonts()
    setup_theme()

    # this must be added early, so that it executes and unfreezes the screen
    # even when we initially get blocked on the intro screen
    GObject.idle_add(unfreeze_dcon_cb)

    GObject.idle_add(setup_cursortracker_cb)
    sound.restore()
    keyboard.setup()

    sys.path.append(config.ext_path)

    if not intro.check_profile():
        _start_intro()
    else:
        _begin_desktop_startup()

    try:
        Gtk.main()
    except KeyboardInterrupt:
        print 'Ctrl+C pressed, exiting...'

    _stop_window_manager()
Ejemplo n.º 6
0
    def __init__(self, parent_widget):
        """Initialization.

        Parameters
        ----------
        parent_widget : IconChooser
            The main widget to which this widget is tied to.
        """
        super().__init__()
        GLib.threads_init()

        self._parent_widget = parent_widget
        self._timer = None
        self._main_app = None
        self._dialog_icon_size = 32
        self._search_term = ""
        self.icon = ""
        self.dialog = None

        self._icon = Gtk.Image.new()
        self.set_image(self._icon)

        self.connect("clicked", self._show_dialog)
        self.connect("destroy", self._on_destroy)

        GLib.idle_add(self.ensure_dialog)
    def __init__(self):
        self.window = Gtk.Window()
        self.window.connect('delete-event', Gtk.main_quit)

        self.box = Gtk.Box()
        self.window.add(self.box)

        self.label = Gtk.Label('idle')
        self.box.pack_start(self.label, True, True, 0)

        self.progressbar = Gtk.ProgressBar()
        self.box.pack_start(self.progressbar, True, True, 0)

        self.button = Gtk.Button(label='Start')
        self.button.connect('clicked', self.on_button_clicked)
        self.box.pack_start(self.button, True, True, 0)

        self.window.show_all()

        gobject.threads_init()
        GLib.threads_init()
        Gdk.threads_init()
        Gdk.threads_enter()
        Gtk.main()
        Gdk.threads_leave()
Ejemplo n.º 8
0
def main():
    signal.signal(signal.SIGINT, signal.SIG_DFL)

    glib.threads_init()

    app = NetworktabletIndicator()
    gtk.main()
Ejemplo n.º 9
0
    def __init__(self, label, dep_key=None, tooltip=""):
        """Initialization.

        Parameters
        ----------
        label : str
            Widget label text.
        dep_key : None, optional
            Dependency key/s.
        tooltip : str, optional
            Widget tooltip text.
        """
        super().__init__(dep_key=dep_key)
        GLib.threads_init()
        self.dialog_width = 400
        self.dialog_height = 500
        self.app_chooser_dialog = None
        self.label = label
        self.content_widget = Gtk.Button(label=label, valign=Gtk.Align.CENTER)
        self.content_widget.set_hexpand(True)
        self.attach(self.content_widget, 0, 0, 2, 1)
        self._changed_pref_key = f'{self.pref_key}_changed'

        if self._changed_pref_key not in self.settings.settings:
            self._changed_pref_key = None

        self.set_tooltip_text(tooltip)

        self._app_store = Gtk.ListStore()
        self._app_store.set_column_types(
            [Gio.AppInfo, GObject.TYPE_STRING, Gio.Icon])

        GLib.idle_add(self.ensure_app_chooser_dialog)
Ejemplo n.º 10
0
 def __init__(self):
     GLib.threads_init()
     Gdk.threads_init()
     GtkClutter.init([])
     Endless.Application.__init__(self,
                                  application_id='com.endlessm.photos',
                                  flags=Gio.ApplicationFlags.HANDLES_OPEN)
Ejemplo n.º 11
0
    def __init__(self,
                 style=BLOCKS,
                 lemonbar_exec=LEMONBAR_EXEC,
                 lemonbar_args=LEMONBAR_ARGS):
        super().__init__()
        self._slices = []
        self.is_running = False

        if isinstance(lemonbar_args, str):
            lemonbar_args = shlex.split(lemonbar_args)
        self.__bar_cmd = [lemonbar_exec] + lemonbar_args
        self.__outstream = sys.stdout

        self.__started = False
        self.__bar_exec = None

        # HACK: LemonBar to slow
        if HACK_107:
            self.__last_draw = 0

        self.__loop = GLib.MainLoop()
        GLib.threads_init()

        # get number of active X11 outputs
        X11_DISPLAY = os.environ['DISPLAY']
        if X11_DISPLAY is None or len(X11_DISPLAY) == 0:
            raise ValueError("'DISPLAY' variable not set")

        self.__outputs = self.__get_outputs(X11_DISPLAY)
        if len(self.__outputs) == 0:
            raise RuntimeError("Cannot find any X11 outputs")
Ejemplo n.º 12
0
    def __init__(self, devicefile):
        # by default, log!
        self.do_data_logging = True
        # initially set the standard logger
        self.set_logger(logging.getLogger(__name__))
        # initially set an empty configuration
        self.set_config(configparser.ConfigParser())

        # use glib as default mailoop for dbus
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        dbus.mainloop.glib.threads_init()
        GLib.threads_init()

        self.systembus = dbus.SystemBus() # the system bus
        self.systembus.request_name(CO2MONITOR_BUSNAME) # request the bus name
        bus_name = dbus.service.BusName(CO2MONITOR_BUSNAME, self.systembus) # create bus name

        self.devicefile = devicefile

        # set up the device
        self.device = device.co2device(self.devicefile)

        # register the object on the bus name
        objectpath = "/".join([CO2MONITOR_OBJECTPATH,
            utils.devicefile2objectname(self.devicefile)])
        dbus.service.Object.__init__(self, bus_name, objectpath)
        self.update_status(_("idle"))
        threading.Thread.__init__(self)
Ejemplo n.º 13
0
Archivo: main.py Proyecto: worr/sugar
def main():
    GLib.threads_init()
    Gdk.threads_init()
    dbus.glib.threads_init()
    Gst.init(sys.argv)

    cleanup_temporary_files()

    _start_window_manager()

    setup_locale()
    setup_fonts()
    setup_theme()

    # this must be added early, so that it executes and unfreezes the screen
    # even when we initially get blocked on the intro screen
    GLib.idle_add(unfreeze_dcon_cb)

    GLib.idle_add(setup_cursortracker_cb)
    sound.restore()
    keyboard.setup()

    sys.path.append(config.ext_path)

    if not intro.check_profile():
        _start_intro()
    else:
        _begin_desktop_startup()

    try:
        Gtk.main()
    except KeyboardInterrupt:
        print 'Ctrl+C pressed, exiting...'

    _stop_window_manager()
Ejemplo n.º 14
0
 def __init__(self):
     current_run.UI = 'gtk'
     self.builder = Gtk.Builder()
     self.builder.add_from_file(gladefile)
     self.main_win = self.builder.get_object("mainWindow")
     self.gui_helper = gui_helper.GuiHelper(self)
     self.path_window = path_window.PathWindow(self, self.main_win, self.builder, self.gui_helper)
     self.run_window = run_window.RunWindow(self, self.builder, self.gui_helper)
     self.mainhandlers = {
             "on_mainWindow_delete_event": Gtk.main_quit,
             "on_browsePathBtn_clicked": self.path_window.browse_path,
             "on_nextPathBtn_clicked": self.path_window.next_window,
             "on_pathWindow_delete_event": Gtk.main_quit,
             "on_runWindow_delete_event": self.run_window.delete_event,
             "on_runWindow_destroy" : self.run_window.destroy,
             "on_prevPathBtn_clicked": self.path_window.prev_window,
             "on_debugBtn_clicked": self.run_window.debug_btn_clicked,
             "on_clipboardBtn_clicked": self.run_window.clipboard_btn_clicked,
             "on_backBtn_clicked": self.run_window.back_btn_clicked,
             "on_mainBtn_clicked": self.run_window.main_btn_clicked,
             "on_entryProjectName_changed": self.path_window.project_name_changed,
     }
     self.builder.connect_signals(self.mainhandlers)
     self.label_main_window = self.builder.get_object("sublabel")
     self.label_project_name = self.builder.get_object("labelProjectName")
     self.box4 = self.builder.get_object("box4")
     self.box4.set_spacing(12)
     self.box4.set_border_width(12)
     # Creating Notebook widget.
     self.notebook = self.gui_helper.create_notebook()
     self.notebook.set_has_tooltip(True)
     self.box4.pack_start(self.notebook, True, True, 0)
     # Devassistant creator part
     self.top_assistant = TopAssistant()
     for subas in self.top_assistant.get_subassistants():
         self.notebook.append_page(self._create_notebook_page(subas),
                                   self.gui_helper.create_label(
                                       subas.fullname,
                                       wrap=False,
                                       tooltip=self.gui_helper.get_formated_description(
                                           subas.description)))
     self.notebook.show()
     self.kwargs = dict()
     self.data = dict()
     # Used for debugging
     console_handler = logging.StreamHandler(stream=sys.stdout)
     console_formatter = logging.Formatter('%(asctime)s %(levelname)s - %(message)s')
     console_handler.setFormatter(console_formatter)
     console_handler.setLevel(logging.INFO)
     logger_gui.addHandler(console_handler)
     # End used for debugging
     self.data = dict()
     self.main_win.show_all()
     # Thread should be defined here
     # because of timeout and threads sharing.
     GLib.threads_init()
     Gdk.threads_init()
     Gdk.threads_enter()
     Gtk.main()
     Gdk.threads_leave()
Ejemplo n.º 15
0
    def __init__(self, title, url, width, height, resizable, fullscreen,
                 min_size, confirm_quit, background_color, debug, js_api,
                 webview_ready):
        BrowserView.instance = self

        self.webview_ready = webview_ready
        self.is_fullscreen = False
        self._js_result_semaphore = Semaphore(0)
        self.load_event = Event()
        self.js_bridge = None

        glib.threads_init()
        window = gtk.Window(title=title)

        if resizable:
            window.set_size_request(min_size[0], min_size[1])
            window.resize(width, height)
        else:
            window.set_size_request(width, height)

        window.set_resizable(resizable)
        window.set_position(gtk.WindowPosition.CENTER)

        # Set window background color
        style_provider = gtk.CssProvider()
        style_provider.load_from_data(
            'GtkWindow {{ background-color: {}; }}'.format(
                background_color).encode())
        gtk.StyleContext.add_provider_for_screen(
            Gdk.Screen.get_default(), style_provider,
            gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)

        scrolled_window = gtk.ScrolledWindow()
        window.add(scrolled_window)

        self.window = window

        if confirm_quit:
            self.window.connect('delete-event', self.on_destroy)
        else:
            self.window.connect('delete-event', self.close_window)

        if js_api:
            self.js_bridge = BrowserView.JSBridge(js_api)

        self.webview = webkit.WebView()
        self.webview.connect('notify::visible', self.on_webview_ready)
        self.webview.connect('document-load-finished', self.on_load_finish)
        self.webview.connect('status-bar-text-changed', self.on_status_change)
        self.webview.props.settings.props.enable_default_context_menu = False
        self.webview.props.opacity = 0.0
        scrolled_window.add(self.webview)
        window.show_all()

        if url is not None:
            self.webview.load_uri(url)

        if fullscreen:
            self.toggle_fullscreen()
Ejemplo n.º 16
0
 def run(self):
     """
     Run Steam Manager ;-)
     """
     GLib.threads_init()
     Gdk.threads_enter()
     Gtk.main()
     Gdk.threads_leave()
Ejemplo n.º 17
0
def foobnix():

    if "--debug" in sys.argv:
        LOG.with_print = True
        for param in sys.argv:
            if param.startswith("--log"):
                if "=" in param:
                    filepath = param[param.index("=")+1 : ]
                    if filepath.startswith('~'):
                        filepath = os.path.expanduser("~") + filepath[1 : ]
                else:
                    filepath = os.path.join(CONFIG_DIR, "foobnix.log")
                LOG.setup("debug", filename=filepath)
        else:
            LOG.setup("debug")
        LOG.print_platform_info()
    else:
        LOG.setup("error")

    from foobnix.gui.foobnix_core import FoobnixCore

    if "--test" in sys.argv:
        from test.all import run_all_tests
        print("""TEST MODE""")
        result = run_all_tests(ignore="test_core")
        if not result:
            raise SystemExit("Test failures are listed above.")
        exit()

    init_time = time.time()

    if "--nt" in sys.argv or os.name == 'nt':
        GLib.threads_init() #@UndefinedVariable
        core = FoobnixCore(False)
        core.run()
        analytics.begin_session()
        print("******Foobnix run in", time.time() - init_time, " seconds******")
        Gtk.main()
    else:
        init_time = time.time()
        from foobnix.gui.controls.dbus_manager import foobnix_dbus_interface
        iface = foobnix_dbus_interface()
        if "--debug" in sys.argv or not iface:
            print("start program")
            GLib.threads_init()    #@UndefinedVariable
            core = FoobnixCore(True)
            core.run()
            analytics.begin_session()
            #core.dbus.parse_arguments(sys.argv)
            analytics.begin_session()
            print("******Foobnix run in", time.time() - init_time, " seconds******")
            if sys.argv:
                Timer(1, GLib.idle_add, [core.check_for_media, sys.argv]).start()

            Gtk.main()
        else:
            print(iface.parse_arguments(sys.argv))
Ejemplo n.º 18
0
def main():
    import time
    GLib.threads_init()
    Gst.init(None)
    cm = CameraManager()
    cm.start()
    Gtk.main()
    cm.stop()
    exit(0)
Ejemplo n.º 19
0
def main():
    import time
    GLib.threads_init()
    Gst.init(None)
    cm = CameraManager()
    cm.start()
    Gtk.main()
    cm.stop()
    exit(0)
Ejemplo n.º 20
0
def run():
    args = vars(parser.parse_args())
    app = App(**args)

    GLib.threads_init()
    Gdk.threads_init()
    Gdk.threads_enter()
    Gtk.main()
    Gdk.threads_leave()
Ejemplo n.º 21
0
def run():
    args = vars(parser.parse_args())
    app = App(**args)

    GLib.threads_init()
    Gdk.threads_init()
    Gdk.threads_enter()
    Gtk.main()
    Gdk.threads_leave()
Ejemplo n.º 22
0
def foobnix():

    if "--debug" in sys.argv:
        LOG.with_print = True
        for param in sys.argv:
            if param.startswith("--log"):
                if "=" in param:
                    filepath = param[param.index("=")+1 : ]
                    if filepath.startswith('~'):
                        filepath = os.path.expanduser("~") + filepath[1 : ]
                else:
                    filepath = os.path.join(CONFIG_DIR, "foobnix.log")
                LOG.setup("debug", filename=filepath)
        else:
            LOG.setup("debug")
        LOG.print_platform_info()
    else:
        LOG.setup("error")

    from foobnix.gui.foobnix_core import FoobnixCore

    if "--test" in sys.argv:
        from test.all import run_all_tests
        print("""TEST MODE""")
        result = run_all_tests(ignore="test_core")
        if not result:
            raise SystemExit("Test failures are listed above.")
        exit()

    init_time = time.time()

    if "--nt" in sys.argv or os.name == 'nt':
        GLib.threads_init() #@UndefinedVariable
        core = FoobnixCore(False)
        core.run()
        analytics.begin_session()
        print("******Foobnix run in", time.time() - init_time, " seconds******")
        Gtk.main()
    else:
        init_time = time.time()
        from foobnix.gui.controls.dbus_manager import foobnix_dbus_interface
        iface = foobnix_dbus_interface()
        if "--debug" in sys.argv or not iface:
            print("start program")
            GLib.threads_init()    #@UndefinedVariable
            core = FoobnixCore(True)
            core.run()
            analytics.begin_session()
            #core.dbus.parse_arguments(sys.argv)
            analytics.begin_session()
            print("******Foobnix run in", time.time() - init_time, " seconds******")
            if sys.argv:
                Timer(1, GLib.idle_add, [core.check_for_media, sys.argv]).start()

            Gtk.main()
        else:
            print(iface.parse_arguments(sys.argv))
Ejemplo n.º 23
0
	def __init__(self):
		print (time.time()-start_time, "start init application")
		Gtk.Application.__init__(self, application_id = 'org.gnome.badnik', flags = Gio.ApplicationFlags.FLAGS_NONE)
		GLib.threads_init()
		Gdk.threads_init()
		
		self.simplename = "badnik"
		self.fullname = "Video games"
		
		self.datadir = os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0])))
		self.savedatadir = BaseDirectory.save_data_path(self.simplename)
		self.iconsdir = self.datadir + "/data/icons"
		self.tosecdir = self.datadir + "/data/tosec"
		self.srcdir = self.datadir + "/src"
		
		self.systems = Badnik.SystemCollection ()
		self.systems.add (Badnik.MegaDrive ())
		self.systems.add (Badnik.Desktop ())
		
		self.gamesdb = BadnikLibrary(self, self.savedatadir)
		
		self.focused_game = None
		
		self.connect("activate", self.on_activate)
		
		self.register(None)
		
		self.settings = Gio.Settings.new('org.gnome.badnik')
		
		self.builder = Gtk.Builder()
		self.builder.add_from_file(self.srcdir + "/ressources/app-menu.ui")
		self.builder.connect_signals(self)
		
		self.menumodel = self.builder.get_object("app-menu")
		self.set_app_menu(self.menumodel)
		
		self._action_entries = [ { 'name': 'quit', 'callback': self.on_quit, 'accel': '<Primary>q' },
		                         { 'name': 'about', 'callback': self.on_about },
		                         { 'name': 'help', 'callback': self.on_help, 'accel': 'F1' },
		                         { 'name': 'fullscreen', 'callback': self.on_fullscreen, 'accel': 'F11' },
		                         { 'name': 'view-as', 'callback': self.on_view_as, 'create_hook': self._view_as_create_hook,
		                           'parameter_type': 's', 'state': self.settings.get_value('view-as') },
		                         { 'name': 'add-games', 'callback': self.on_add_games },
		                         { 'name': 'download-metadata', 'callback': self.on_download_metadata, 'accel': '<Primary>m' }
		                       ]
		self._add_actions()
		
		settings = Gtk.Settings.get_default()
		settings.set_property("gtk-application-prefer-dark-theme", True)
		settings.set_property("gtk-shell-shows-app-menu", True)
		print (time.time()-start_time, "end init application")
		
		self.running_games = {}
		
		self.systems.connect("game_found", self.on_game_found)
		self.gamesdb.connect("game_added", self.on_game_added)
Ejemplo n.º 24
0
    def __init__(self, args):
        """
        init a Gps2VideoAssistant
        
        args - arguments from cmdline
        """
        self._filename = None
        self._GPX = None
        self._track = None
        self._starttime = None
        self._endttime = None
        self._plugin = None
        self._outfile = None
        self._fps = 30
        self._optimize_track = False
        self._debug = False

        if '--debug' in args:
            self._debug = True
            args.remove('--debug')

        if len(args) > 1:
            raise AttributeError('Only either no argument or' +
                                 'one gpxfile allowed as argument')
        elif len(args) == 1:
            self._filename = os.path.abspath(args[0])

        self.assistant = Gtk.Assistant()
        self.assistant.set_default_size(800, 600)
        self.assistant.set_title('Gpx 2 Video')

        self.assistant.connect('apply', self.apply, None)
        self.assistant.connect('cancel', self.cancel, None)
        self.assistant.connect("delete-event", Gtk.main_quit)
        self.assistant.connect('close', self.cancel, None)
        self.assistant.connect('prepare', self.prepare, None)

        self._pages = [
            _class(self)
            for _class in Gps2VideoAssistant._page_classes]

        for page in self._pages:
            widget = page.widget
            widget.parent_trackvisualizer_page = page
            self.assistant.append_page(widget)
            self.assistant.set_page_title(widget, page.title)
            self.assistant.set_page_type(widget, page.pagetype)

        self.assistant.show_all()

        #make sure starting threads aside GTk.main works
        GLib.threads_init()
        Gdk.threads_init()
        Gdk.threads_enter()
        Gtk.main()
        Gdk.threads_leave()
Ejemplo n.º 25
0
    def __init__(self, ble_uuid=None, context=None):
        """BLE Connection

        Parameters
        ----------
        ble_uuid : str, optional
            The UUID used by the BLE connection, if None a UUID is generated
        context : ZMQ Context, optional
            ZMQ Context, by default None
        """
        threading.Thread.__init__(self, daemon=True)

        self.connection_id = shortuuid.uuid()
        self.b_connection_id = self.connection_id.encode('utf-8')

        self.context = context or zmq.Context.instance()
        self.rx_zmq_sub = self.context.socket(zmq.SUB)
        self.rx_zmq_sub.setsockopt(zmq.SUBSCRIBE, b"ALL")
        self.rx_zmq_sub.setsockopt(zmq.SUBSCRIBE, b"ALARM")
        self.rx_zmq_sub.setsockopt_string(zmq.SUBSCRIBE, self.connection_id)
        # TODO: Need to figure out why this doesn't work
        # GLib.io_add_watch(
        #     self.rx_zmq_sub.getsockopt(zmq.FD),
        #     GLib.IO_IN | GLib.IO_ERR | GLib.IO_HUP | GLib.IO_PRI,
        #     self.zmq_callback
        # )
        GLib.timeout_add(10, self.zmq_callback, "q", "p")

        self.tx_zmq_pub = self.context.socket(zmq.PUB)
        self.tx_zmq_pub.bind(CONNECTION_PUB_URL.format(id=self.connection_id))
        dashio_service_uuid = ble_uuid or str(uuid.uuid4())

        self.ble_control = BLE(self.connection_id, dashio_service_uuid,
                               dashio_service_uuid, dashio_service_uuid)

        GLib.threads_init()
        dbus.mainloop.glib.threads_init()
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        self.mainloop = GLib.MainLoop()

        self.bus = BleTools.get_bus()
        self.path = "/"
        self.dash_service = DashIOService(0, dashio_service_uuid, self.ble_rx)

        self.response = {}

        chrc = self.dash_service.get_characteristics()
        self.response[chrc.get_path()] = chrc.get_properties()
        self.response[
            self.dash_service.get_path()] = self.dash_service.get_properties()

        dbus.service.Object.__init__(self, self.bus, self.path)
        self.register()
        self.adv = DashIOAdvertisement(0, dashio_service_uuid)
        self.start()
        time.sleep(0.5)
Ejemplo n.º 26
0
 def run():
   win = Client()
   win.connect('delete-event', Gtk.main_quit)
   win.show_all()
   GObject.threads_init()
   GLib.threads_init()
   Gdk.threads_init()
   Gdk.threads_enter()
   Gtk.main()
   Gdk.threads_leave()
Ejemplo n.º 27
0
def main():
	print("bpacman 0.1.0 \"What a Pain\" using libalpm", pyalpm.alpmversion())
	win = MainWindow("bpacman 0.1.0");
	win.connect("delete-event", Gtk.main_quit);
	win.show_all();
	GLib.threads_init()
	Gdk.threads_init()
	Gdk.threads_enter()
	Gtk.main()
	Gdk.threads_leave()
Ejemplo n.º 28
0
def spawn(title):
 global win
 win = Window(title)
 win.connect("delete-event",kill_it_all)
 win.show_all()
 

 GLib.threads_init()
 Gdk.threads_init()
 Gtk.main()
Ejemplo n.º 29
0
    def __init__(self):
        object.__init__(self)

        #####

        self.__modules_list = []
        self.__services_dict = {}

        GLib.threads_init()
        self.__main_loop = GLib.MainLoop()
Ejemplo n.º 30
0
    def __init__(self):
        GLib.threads_init()
        Gdk.threads_init()

        p = optparse.OptionParser()
        p.add_option("-l",
                     "--verbose",
                     help="Enable verbose logging",
                     action="store_true",
                     default=False)
        p.add_option("-c",
                     "--configure",
                     help="Show the configuration window on startup",
                     action="store_true",
                     default=False)
        options, args = p.parse_args()

        try:
            # Create configuration directory
            if not os.path.exists(common.CONFIG_DIR):
                os.makedirs(common.CONFIG_DIR)
            # Create data directory (for log file)
            if not os.path.exists(common.DATA_DIR):
                os.makedirs(common.DATA_DIR)
            # Create run directory (for lock file)
            if not os.path.exists(common.RUN_DIR):
                os.makedirs(common.RUN_DIR)

            # Initialise logger
            rootLogger = logging.getLogger()

            if options.verbose:
                rootLogger.setLevel(logging.DEBUG)
                handler = logging.StreamHandler(sys.stdout)
            else:
                rootLogger.setLevel(logging.INFO)
                handler = logging.handlers.RotatingFileHandler(
                    common.LOG_FILE,
                    maxBytes=common.MAX_LOG_SIZE,
                    backupCount=common.MAX_LOG_COUNT)

            handler.setFormatter(logging.Formatter(common.LOG_FORMAT))
            rootLogger.addHandler(handler)

            if self.__verifyNotRunning():
                self.__createLockFile()

            self.initialise(options.configure)

        except Exception as e:
            self.show_error_dialog(
                _("Fatal error starting AutoKey.\n") + str(e))
            logging.exception("Fatal error starting AutoKey: " + str(e))
            sys.exit(1)
Ejemplo n.º 31
0
    def enable(self):
        self.enabled = True
        self.connect("delete-event", Gtk.main_quit)
        self.show_all()

        # Enable GLib/Gdk threading so the UI won't lock main
        GLib.threads_init()
        Gdk.threads_init()
        Gdk.threads_enter()
        Gtk.main()
        Gdk.threads_leave()
Ejemplo n.º 32
0
    def __init__(self, main_window, ListDevices, BlivetUtils, Builder, kickstart_mode=False, disk=None):

        GLib.threads_init()
        Gdk.threads_init()
        Gdk.threads_enter()

        self.list_devices = ListDevices
        self.b = BlivetUtils
        self.builder = Builder

        self.kickstart_mode = kickstart_mode

        self.disk = disk
        self.main_window = main_window

        # ListStores for partitions and actions
        self.partitions_list = Gtk.TreeStore(object, str, str, str, str, str, str, object)
        self.actions_list = Gtk.ListStore(GdkPixbuf.Pixbuf, str)

        self.partitions_view = self.create_partitions_view()
        self.builder.get_object("partitions_viewport").add(self.partitions_view)

        self.actions_view = self.create_actions_view()
        self.builder.get_object("actions_viewport").add(self.actions_view)

        self.info_label = Gtk.Label()
        self.builder.get_object("pv_viewport").add(self.info_label)

        self.darea = device_canvas(blivet_utils=self.b, list_partitions=self)
        self.builder.get_object("image_window").add(self.darea)

        self.main_menu = main_menu(self.main_window, self, self.list_devices)
        self.builder.get_object("vbox").add(self.main_menu.get_main_menu)

        self.popup_menu = actions_menu(self)
        self.toolbar = actions_toolbar(self, self.main_window)
        self.builder.get_object("vbox").add(self.toolbar.get_toolbar)

        self.select = self.partitions_view.get_selection()
        self.path = self.select.select_path("1")

        self.on_partition_selection_changed(self.select)
        self.selection_signal = self.select.connect("changed", self.on_partition_selection_changed)

        self.actions = 0
        self.actions_label = self.builder.get_object("actions_page")
        self.actions_label.set_text(_("Pending actions ({0})").format(self.actions))

        self.partitions_label = self.builder.get_object("partitions_page")
        self.partitions_label.set_text(_("Partitions").format(self.actions))

        self.selected_partition = None

        self.history = actions_history(self)
Ejemplo n.º 33
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--launcher', dest='launcher', metavar='NAME', default='xdg-open', help='application launcher')
    parser.add_argument('--terminal', dest='terminal', metavar='NAME', default='xfce4-terminal', help='terminal')
    parser.add_argument('--engine', dest='engine', metavar='NAME', default='recoll', help='engine (tracker, recoll)')
    parser.add_argument('--debug', dest='debug', action="store_const", const=True, help='enable debugging ()')
    args = parser.parse_args()

    win = PyNeedle(launcher=args.launcher, terminal=args.terminal, engine=args.engine, debug=(args.debug is not None))
    win.show_all()
    GLib.threads_init()
    Gtk.main()
Ejemplo n.º 34
0
def main():
    dbus_loop = DBusGMainLoop(set_as_default=True)
    if dbus.SessionBus(mainloop=dbus_loop).request_name(
        'es.atareao.YouTubeIndicator') !=\
            dbus.bus.REQUEST_NAME_REPLY_PRIMARY_OWNER:
        print("application already running")
        exit(0)
    Notify.init('youtube-indicator')
    GLib.threads_init()
    YouTube_Indicator()
    Gtk.main()
    exit(0)
Ejemplo n.º 35
0
    def run(self):
        GLib.threads_init()
        while True:
            if self.update():
                GLib.idle_add(self.gdk_callback,
                              [v for k, v in self.logs.items()])

            ## Just stop calling the gdk_callback
            while not self.running:
                time.sleep(1)

            time.sleep(0.5)
Ejemplo n.º 36
0
 def init_dbus_link(self):
     try:
         GLib.threads_init()
         glib.init_threads()
         dbus_path = "/tmp/omxplayerdbus." + getuser()
         bus = dbus.bus.BusConnection(open(dbus_path).readlines()[0].rstrip())
         remote_object = bus.get_object("org.mpris.MediaPlayer2.omxplayer", "/org/mpris/MediaPlayer2", introspect=False)
         self.dbusif_player = dbus.Interface(remote_object, 'org.mpris.MediaPlayer2.Player')
         self.dbusif_props = dbus.Interface(remote_object, 'org.freedesktop.DBus.Properties')
     except Exception:
         return False
     return True
Ejemplo n.º 37
0
    def run(self):
        """
        Run Rigo ;-)
        """
        self._welcome_box.render()
        self._change_view_state(self._current_state)
        GLib.idle_add(self._permissions_setup)

        GLib.threads_init()
        Gdk.threads_enter()
        Gtk.main()
        Gdk.threads_leave()
        entropy.tools.kill_threads()
Ejemplo n.º 38
0
 def __init__(self):
     print (time.time()-start_time, "start init application")
     Gtk.Application.__init__(self, application_id = self.application_id, flags = Gio.ApplicationFlags.FLAGS_NONE)
     GLib.threads_init()
     Gdk.threads_init()
     
     self.datadir = os.path.dirname(os.path.dirname(os.path.realpath(sys.argv[0])))
     
     self.savedatadir = Environement.save_data_path()
     
     self.systems = Badnik.SystemCollection.full ()
     
     self.gamesdb = Badnik.Library(db_name = "games", db_dir = self.savedatadir, systems = self.systems)
     #self.gamesdb.app = self
     self.gamesdb.path = os.path.join(self.savedatadir, "games.db")
     
     self.focused_game = None
     
     self.connect("activate", self.on_activate)
     
     self.register(None)
     
     self.settings = Gio.Settings.new(self.application_id)
     
     self.builder = Gtk.Builder()
     self.builder.add_from_file(Environement.get_resource("AppMenu.ui"))
     self.builder.connect_signals(self)
     
     self.menumodel = self.builder.get_object("AppMenu")
     self.set_app_menu(self.menumodel)
     
     self._action_entries = [ { 'name': 'quit', 'callback': self.on_quit, 'accel': '<Primary>q' },
                              { 'name': 'about', 'callback': self.on_about },
                              { 'name': 'help', 'callback': self.on_help, 'accel': 'F1' },
                              #{ 'name': 'fullscreen', 'callback': self.on_fullscreen, 'accel': 'F11' },
                              #{ 'name': 'view-as', 'callback': self.on_view_as, 'create_hook': self._view_as_create_hook,
                              #  'parameter_type': 's', 'state': self.settings.get_value('view-as') },
                              { 'name': 'add-games', 'callback': self.on_add_games },
                              #{ 'name': 'download-metadata', 'callback': self.on_download_metadata, 'accel': '<Primary>m' }
                            ]
     self._add_actions()
     
     settings = Gtk.Settings.get_default()
     settings.set_property("gtk-application-prefer-dark-theme", True)
     settings.set_property("gtk-shell-shows-app-menu", True)
     print (time.time()-start_time, "end init application")
     
     self.running_games = {}
     
     self.systems.connect("game_found", self.on_game_found)
     self.gamesdb.connect("game_added", self.on_game_added)
Ejemplo n.º 39
0
def main():
    'constructor for your class instances'
    parse_options()

    GLib.threads_init()
    Gdk.threads_init()
    Gdk.threads_enter()

    # Run the application.    
    window = UrlSpanWindow.UrlSpanWindow()
    window.show()
    Gtk.main()

    Gdk.threads_leave()
Ejemplo n.º 40
0
    def run(self):
        logging.info('D-Bus process started')
        GLib.threads_init()  # allow threads in GLib
        GLib.idle_add(self._idleQueueSync)

        DBusGMainLoop(set_as_default=True)
        dbusService = SessionDBus(self.taskQueue, self.resultQueue)

        try:
            GLib.MainLoop().run()
        except KeyboardInterrupt:
            logging.debug("\nThe MainLoop will close...")
            GLib.MainLoop().quit()
        return
Ejemplo n.º 41
0
def main():
    rows = 15
    cols = 20
    button_rows = []
    running = True

    def cycle_callback():
        current_row = 0
        while running:
            for button in button_rows[current_row]:
                button.get_style_context().add_class("hilite")
            time.sleep(1.0)
            for button in button_rows[current_row]:
                button.get_style_context().remove_class("hilite")
            current_row = (current_row + 1) % rows

    style = Gtk.CssProvider()
    style.load_from_path("style.css")

    screen = Gdk.Screen.get_default()
    styleContext = Gtk.StyleContext()
    styleContext.add_provider_for_screen(screen, style,
                                         Gtk.STYLE_PROVIDER_PRIORITY_USER)

    window = Gtk.Window()
    window.connect("destroy", lambda _: Gtk.main_quit())
    window.fullscreen()

    grid = Gtk.Grid()
    grid.set_row_spacing(4)
    grid.set_column_spacing(4)
    for i in range(rows):
        button_row = []
        for j in range(cols):
            button = Gtk.Button(label="(%d, %d)" % (i, j))
            button.set_vexpand(True)
            button.set_hexpand(True)
            button_row.append(button)
            grid.attach(button, j, i, 1, 1)
        button_rows.append(button_row)

    window.add(grid)

    window.show_all()

    threading.Thread(target=cycle_callback).start()
    GLib.threads_init()
    Gtk.main()
    running = False
Ejemplo n.º 42
0
 def __init__(self):
     Thread.__init__(self)
     self.gladefile = os.path.join(__location__, "vlcd.glade")
     self.builder = Gtk.Builder()
     self.builder.add_from_file(self.gladefile)
     self.builder.connect_signals(self)
     self.window = self.builder.get_object("window")
     self.box = self.builder.get_object("box")
     self.canvas = Canvas()
     self.canvas.show()
     self.box.pack_start(self.canvas, True, True, 0)
     self.window.show()
     Gdk.threads_init()
     GLib.threads_init()
     self.start()
Ejemplo n.º 43
0
    def __init__(self):
        # Init stuff
        gi.require_version("Gst", "1.0")
        glib.threads_init()
        gobject.threads_init()
        gst.init(None)

        # Vars
        self.is_running = True
        self.current_id = -1
        self.current_url = ""
        self.current_stream = None
        self.session = Livestreamer()
        self.player = None
        self.window = None
Ejemplo n.º 44
0
def main():
    rows = 15
    cols = 20
    button_rows = []
    running = True

    def cycle_callback():
        current_row = 0
        while running:
            for button in button_rows[current_row]:
                button.get_style_context().add_class("hilite")
            time.sleep(1.0)
            for button in button_rows[current_row]:
                button.get_style_context().remove_class("hilite")
            current_row = (current_row + 1) % rows

    style = Gtk.CssProvider()
    style.load_from_path("style.css")

    screen = Gdk.Screen.get_default()
    styleContext = Gtk.StyleContext()
    styleContext.add_provider_for_screen(screen, style, Gtk.STYLE_PROVIDER_PRIORITY_USER)

    window = Gtk.Window()
    window.connect("destroy", lambda _: Gtk.main_quit())
    window.fullscreen()

    grid = Gtk.Grid()
    grid.set_row_spacing(4)
    grid.set_column_spacing(4)
    for i in range(rows):
        button_row = []
        for j in range(cols):
            button = Gtk.Button(label="(%d, %d)" % (i, j))
            button.set_vexpand(True)
            button.set_hexpand(True)
            button_row.append(button)
            grid.attach(button, j, i, 1, 1)
        button_rows.append(button_row)

    window.add(grid)

    window.show_all()

    threading.Thread(target=cycle_callback).start()
    GLib.threads_init()
    Gtk.main()
    running = False
Ejemplo n.º 45
0
    def __init__(self, label, size_group=None, dep_key=None, tooltip=""):
        """Initialization.

        Parameters
        ----------
        label : str
            The label text.
        size_group : None, optional
            A :py:class:`Gtk.SizeGroup`.
        dep_key : None, optional
            Dependency key/s.
        tooltip : str, optional
            Widget tooltip text.
        """
        super().__init__(dep_key=dep_key)
        GLib.threads_init()
        self.dialog_width = 400
        self.dialog_height = 500
        self.app_chooser_dialog = None
        self.label = SettingsLabel(label)
        self.label.set_hexpand(True)

        container = BaseGrid(orientation=Gtk.Orientation.HORIZONTAL)
        container.set_spacing(0, 0)
        # Mark for deletion on EOL. Gtk4
        # Replace Gtk.StyleContext.add_class with Gtk.Widget.add_css_class.
        container.get_style_context().add_class(Gtk.STYLE_CLASS_LINKED)

        self._clear_button = Gtk.Button(image=Gtk.Image.new_from_icon_name(
            "edit-clear-symbolic", Gtk.IconSize.BUTTON))
        self._clear_button.set_tooltip_text(_("Clear application"))
        self.content_widget = Gtk.Button()
        self.content_widget.set_always_show_image(True)

        self.attach(self.label, 0, 0, 1, 1)
        container.attach(self._clear_button, 0, 0, 1, 1)
        container.attach(self.content_widget, 1, 0, 1, 1)
        self.attach(container, 1, 0, 1, 1)

        self.set_tooltip_text(tooltip)

        if size_group:
            self.add_to_size_group(size_group)

        self._set_button_data()

        GLib.idle_add(self.ensure_app_chooser_dialog)
Ejemplo n.º 46
0
    def __init__(self, f_bottom_bar_changer: callable, f_bottom_bar_adder: callable):
        """ Constructor.

        :param f_bottom_bar_changer: change the bottom bar main text.
        :param f_bottom_bar_adder: add to the actions list in bottom bar.
        """
        self.window = None
        # A manager to handle settings
        self.settings = PluginSettings().settings
        # Using like a global function
        self.bottom_bar_text_set = f_bottom_bar_changer
        self.bottom_bar_add = f_bottom_bar_adder
        GLib.threads_init()
        self.recogniser = SpeechRecogniser(f_bottom_bar_changer, self.action_handler)
        self.threader = threading.Thread(target=self.recogniser.start_recognising)
        self.threader.daemon = True
        logger.debug("Actions INIT")
Ejemplo n.º 47
0
    def __init__(self):
        self.gladefile = "pylib/gui.glade"

        self.builder = Gtk.Builder()
        self.builder.add_from_file(self.gladefile)
        self.builder.connect_signals(self)

        self.laserviz = LaserViz(self)

        self.window = self.builder.get_object("mainWindow")
        self.window.show()

        self.ppsspinner = self.builder.get_object("spinbutton1")

        if port is not None:
            self.serial = SerialComm(port)
            if p is not None:
                self.serial.set_frame(p.get_initial_frame())
            self.serial.start()
        else:
            self.log.warning("No serial port specified. Operating in view-only mode.")
            self.serial = None

        self.player = FramePlayer(self.laserviz, p, self.serial)

        #Ctrl+C handling
        def handler(signum, frame):
            self.log.warning("INTERRUPT; shutting down...")
            self.window_destroy(None)
        signal.signal(signal.SIGTERM, handler)
        signal.signal(signal.SIGINT, handler)

        #This fairly pointless function is necessary to periodically wake up
        #the gtk main thread to detect system interrupts even when not focused
        #I believe this is due to a Gtk bug
        GLib.timeout_add(500, lambda : True)
        
        Gdk.threads_init()
        GLib.threads_init()

        self.log.info("ECE 4760 Laser Projector Controller")
        self.log.info("Starting...")

        Gdk.threads_enter()
        Gtk.main()
        Gdk.threads_leave()
Ejemplo n.º 48
0
def _oldGiInit():
    """
    Make sure pygtk and gi aren't loaded at the same time, and import Glib if
    possible.
    """
    # We can't immediately prevent imports, because that confuses some buggy
    # code in gi:
    _glibbase.ensureNotImported(
        _PYGTK_MODULES,
        "Introspected and static glib/gtk bindings must not be mixed; can't "
        "import gireactor since pygtk2 module is already imported.")

    global GLib
    from gi.repository import GLib
    if getattr(GLib, "threads_init", None) is not None:
        GLib.threads_init()

    _glibbase.ensureNotImported([], "", preventImports=_PYGTK_MODULES)
Ejemplo n.º 49
0
def main():
    try:
        MetaData.init_path()
        FORMAT = "<%(asctime)s> [ %(levelname)s %(filename)s:%(lineno)s - %(funcName)20s()  ] %(message)s"
        logging.basicConfig(filename = MetaData.LOG_FILE_NAME, level = logging.DEBUG, format=FORMAT)
        get_lock(__file__)
        
        logging.debug('init start')
        GLib.threads_init()
        Gdk.threads_init()
        Gdk.threads_enter()
        SettingDialog.KeyBinder.bind_key()
        StatusIcon()
        Gtk.main()
        Gdk.threads_leave()
    except Exception,e:
        logging.error(str(e))
        print e
Ejemplo n.º 50
0
    def __init__(self, f_bottom_bar_changer: callable, f_bottom_bar_adder: callable):
        """ Constructor.

        :param f_bottom_bar_changer: change the bottom bar main text.
        :param f_bottom_bar_adder: add to the actions list in bottom bar.
        """
        # will be set from UI class
        self.window = None
        self.document = None
        self.view = None
        self.tab = None
        # initialize the settings class
        DictonatorSettings()
        # Using like a global function
        self.bottom_bar_text_set = f_bottom_bar_changer
        self.bottom_bar_add = f_bottom_bar_adder
        GLib.threads_init()
        self.recogniser = SpeechRecogniser(self.action_handler)
Ejemplo n.º 51
0
    def __init__(self, ListDevices, BlivetUtils, Builder, disk=None):

        GLib.threads_init()
        Gdk.threads_init()
        Gdk.threads_enter()

        self.list_devices = ListDevices
        self.b = BlivetUtils
        self.builder = Builder

        self.disk = disk

        # ListStores for partitions and actions
        self.partitions_list = Gtk.ListStore(str, str, str, str)
        self.actions_list = Gtk.ListStore(GdkPixbuf.Pixbuf, str)

        self.load_partitions()

        self.partitions_view = self.create_partitions_view()
        self.actions_view = self.create_actions_view()

        self.info_label = Gtk.Label("")
        self.builder.get_object("pv_viewport").add(self.info_label)

        self.darea = Gtk.DrawingArea()

        self.main_menu = main_menu(self.builder.get_object("MainWindow"), self, self.list_devices)
        self.popup_menu = actions_menu(self)
        self.toolbar = actions_toolbar(self)

        self.select = self.partitions_view.get_selection()
        self.path = self.select.select_path("1")

        self.on_partition_selection_changed(self.select)
        self.selection_signal = self.select.connect("changed", self.on_partition_selection_changed)

        self.actions = 0
        self.actions_label = self.builder.get_object("actions_page")
        self.actions_label.set_text(_("Pending actions ({0})").format(self.actions))

        self.partitions_label = self.builder.get_object("partitions_page")
        self.partitions_label.set_text(_("Partitions").format(self.actions))

        self.selected_partition = None
Ejemplo n.º 52
0
    def __init__(self, parent):
        Gtk.Window.__init__(self)
        GLib.threads_init()
        Gst.init(None)

        # Set parent widget
        self.parent = parent
        self.lock_location_updates = False

        # Init dialog
        self.dialog = None

        # Tweak window
        self.set_decorated(True)
        self.set_icon_name('silaty')
        self.set_modal(True)
        self.set_resizable(False)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.connect('delete-event', self.hide_window)
        #self.set_default_size(429, 440)
        self.headerbar = Gtk.HeaderBar()

        # Set up mainbox
        self.mainbox = Gtk.Box()
        self.mainbox.set_orientation(Gtk.Orientation.HORIZONTAL)

        self.prayertimes = Prayertime()
        self.prayertimes.calculate()
        #self.prayertimes.notify('Title', 'This is a test.')

        # Set language
        set_language(self.prayertimes.options.language)
        if self.prayertimes.options.language == 'Arabic':
            #self.set_gravity(Gdk.Gravity.NORTH_EAST)
            #self.set_direction(Gtk.TextDirection.RTL)
            Gtk.Widget.set_default_direction(Gtk.TextDirection.RTL)

        # Set layout
        self.set_layout()

        if self.prayertimes.options.start_minimized == False:
            self.show_all()
            self.sidebar.emit("window-shown")
Ejemplo n.º 53
0
def _oldGiInit():
    """
    Make sure pygtk and gi aren't loaded at the same time, and import Glib if
    possible.
    """
    # We can't immediately prevent imports, because that confuses some buggy
    # code in gi:
    _glibbase.ensureNotImported(
        _PYGTK_MODULES,
        "Introspected and static glib/gtk bindings must not be mixed; can't "
        "import gireactor since pygtk2 module is already imported.")

    global GLib
    from gi.repository import GLib
    if getattr(GLib, "threads_init", None) is not None:
        GLib.threads_init()

    _glibbase.ensureNotImported([], "",
                                preventImports=_PYGTK_MODULES)
Ejemplo n.º 54
0
    def __init__(self, parent):
        Gtk.Window.__init__(self)
        GLib.threads_init()
        Gst.init(None)

        # Set parent widget
        self.parent = parent
        self.lock_location_updates = False

        # Init dialog
        self.dialog = None

        # Tweak window
        self.set_decorated(True)
        self.set_icon_name('silaty')
        self.set_modal(True)
        self.set_resizable(False)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.connect('delete-event', self.hide_window)
        #self.set_default_size(429, 440)
        self.headerbar = Gtk.HeaderBar()

        # Set up mainbox
        self.mainbox = Gtk.Box()
        self.mainbox.set_orientation(Gtk.Orientation.HORIZONTAL)

        self.prayertimes = Prayertime()
        self.prayertimes.calculate()
        #self.prayertimes.notify('Title', 'This is a test.')

        # Set language
        set_language(self.prayertimes.options.language)
        if self.prayertimes.options.language == 'Arabic':
            #self.set_gravity(Gdk.Gravity.NORTH_EAST)
            #self.set_direction(Gtk.TextDirection.RTL)
            Gtk.Widget.set_default_direction(Gtk.TextDirection.RTL)

        # Set layout
        self.set_layout()

        if self.prayertimes.options.start_minimized == False:
            self.show_all()
            self.sidebar.emit("window-shown")
Ejemplo n.º 55
0
    def __init__(self, f_bottom_bar_changer: callable,
                 f_bottom_bar_adder: callable):
        """ Constructor.

        :param f_bottom_bar_changer: change the bottom bar main text.
        :param f_bottom_bar_adder: add to the actions list in bottom bar.
        """
        # will be set from UI class
        self.window = None
        self.document = None
        self.view = None
        self.tab = None
        # initialize the settings class
        DictonatorSettings()
        # Using like a global function
        self.bottom_bar_text_set = f_bottom_bar_changer
        self.bottom_bar_add = f_bottom_bar_adder
        GLib.threads_init()
        self.recogniser = SpeechRecogniser(self.action_handler)
Ejemplo n.º 56
0
def main(hook_func=None):
    """
    Where everything start.
    """
    LogTracker.init()

    set_locale()

    GLib.threads_init()
    GObject.threads_init()
    Gdk.threads_init()

    if hasattr(GLib, 'set_application_name'):
        GLib.set_application_name("Paperwork")
    if hasattr(GLib, "unix_signal_add"):
        GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT,
                             Gtk.main_quit, None)
        GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGTERM,
                             Gtk.main_quit, None)

    try:
        pyinsane2.init()

        config = load_config()
        config.read()

        main_win = MainWindow(config)
        ActionRefreshIndex(main_win, config).do()

        if hook_func:
            thread = threading.Thread(target=hook_func,
                                      args=(config, main_win))
            thread.start()

        Gtk.main()

        for scheduler in main_win.schedulers.values():
            scheduler.stop()

        config.write()
    finally:
        logger.info("Good bye")
Ejemplo n.º 57
0
def main():
    # This can be removed once pygobject-3.10 is a requirement.
    # https://bugzilla.gnome.org/show_bug.cgi?id=686914
    GLib.threads_init()

    Gst.init(sys.argv)

    _migrate_gconf_to_gsettings()

    cleanup_temporary_files()

    _start_window_manager()

    setup_timezone()
    setup_fonts()
    setup_theme()
    setup_proxy()

    # this must be added early, so that it executes and unfreezes the screen
    # even when we initially get blocked on the intro screen
    GLib.idle_add(unfreeze_screen_cb)

    GLib.idle_add(setup_cursortracker_cb)
    sound.restore()
    keyboard.setup()
    brightness.get_instance()

    sys.path.append(config.ext_path)

    if not _check_profile():
        _start_intro()
    elif not _check_group_label():
        _start_intro(start_on_age_page=True)
    else:
        _begin_desktop_startup()

    try:
        Gtk.main()
    except KeyboardInterrupt:
        print 'Ctrl+C pressed, exiting...'

    _stop_window_manager()
Ejemplo n.º 58
0
def main():
    # This can be removed once pygobject-3.10 is a requirement.
    # https://bugzilla.gnome.org/show_bug.cgi?id=686914
    GLib.threads_init()

    Gst.init(sys.argv)

    _migrate_gconf_to_gsettings()

    cleanup_temporary_files()

    _start_window_manager()

    setup_timezone()
    setup_fonts()
    setup_theme()
    setup_proxy()

    # this must be added early, so that it executes and unfreezes the screen
    # even when we initially get blocked on the intro screen
    GLib.idle_add(unfreeze_screen_cb)

    GLib.idle_add(setup_cursortracker_cb)
    sound.restore()
    keyboard.setup()
    brightness.get_instance()

    sys.path.append(config.ext_path)

    if not _check_profile():
        _start_intro()
    elif not _check_group_label():
        _start_intro(start_on_age_page=True)
    else:
        _begin_desktop_startup()

    try:
        Gtk.main()
    except KeyboardInterrupt:
        print 'Ctrl+C pressed, exiting...'

    _stop_window_manager()
Ejemplo n.º 59
0
    def __init__(self):
        GLib.threads_init()
        Gst.init(None)

        self.options = Options()

        year  = datetime.datetime.now().year
        month = datetime.datetime.now().month
        day   = datetime.datetime.now().day
        self.date = date(year, month, day)

        self._shrouk = None
        self._fajr = None
        self._zuhr = None
        self._asr = None
        self._maghrib = None
        self._isha = None
        self._nextprayer = ""
        self._tnprayer = 0
        self.dec = 0