Python gi.repository.Gdk.threads_leave() Examples

The following are 26 code examples of gi.repository.Gdk.threads_leave(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module gi.repository.Gdk , or try the search function .
Example #1
Source File: scripting.py    From autokey with GNU General Public License v3.0 6 votes vote down vote up
def get_selection(self):
        """
        Read text from the X selection
        
        Usage: C{clipboard.get_selection()}

        @return: text contents of the mouse selection
        @rtype: C{str}
        @raise Exception: if no text was found in the selection
        """
        Gdk.threads_enter()
        text = self.selection.wait_for_text()
        Gdk.threads_leave()
        if text is not None:
            return text
        else:
            raise Exception("No text found in X selection") 
Example #2
Source File: dialogs.py    From autokey with GNU General Public License v3.0 6 votes vote down vote up
def set_key(self, key, modifiers: list=None):
        if modifiers is None:
            modifiers = []
        Gdk.threads_enter()
        if key in self.KEY_MAP:
            key = self.KEY_MAP[key]
        self._setKeyLabel(key)
        self.key = key
        self.controlButton.set_active(Key.CONTROL in modifiers)
        self.altButton.set_active(Key.ALT in modifiers)
        self.shiftButton.set_active(Key.SHIFT in modifiers)
        self.superButton.set_active(Key.SUPER in modifiers)
        self.hyperButton.set_active(Key.HYPER in modifiers)
        self.metaButton.set_active(Key.META in modifiers)

        self.setButton.set_sensitive(True)
        Gdk.threads_leave() 
Example #3
Source File: popupmenu.py    From autokey with GNU General Public License v3.0 5 votes vote down vote up
def remove_from_desktop(self):
        Gdk.threads_enter()
        self.popdown()
        Gdk.threads_leave() 
Example #4
Source File: browser_cef.py    From rednotebook with GNU General Public License v2.0 5 votes vote down vote up
def get_handle(self):
            Gdk.threads_enter()
            ctypes.pythonapi.PyCapsule_GetPointer.restype = ctypes.c_void_p
            ctypes.pythonapi.PyCapsule_GetPointer.argtypes = [ctypes.py_object]
            gpointer = ctypes.pythonapi.PyCapsule_GetPointer(
                self.get_property("window").__gpointer__, None
            )
            # The GTK 3.22 stack needs "gdk-3-3.0.dll".
            libgdk = ctypes.CDLL("libgdk-3-0.dll")
            handle = libgdk.gdk_win32_window_get_handle(gpointer)
            Gdk.threads_leave()
            return handle 
Example #5
Source File: backend_gtk3.py    From CogAlg with MIT License 5 votes vote down vote up
def flush_events(self):
        # docstring inherited
        Gdk.threads_enter()
        while Gtk.events_pending():
            Gtk.main_iteration()
        Gdk.flush()
        Gdk.threads_leave() 
Example #6
Source File: main.py    From ebook-viewer with GNU General Public License v3.0 5 votes vote down vote up
def on_quit(self, action, param):
        Gdk.threads_leave()
        Gtk.main_quit()
        self.quit() 
Example #7
Source File: scripting.py    From autokey with GNU General Public License v3.0 5 votes vote down vote up
def fill_clipboard(self, contents):
        """
        Copy text into the clipboard
        
        Usage: C{clipboard.fill_clipboard(contents)}
        
        @param contents: string to be placed in the selection
        """
        Gdk.threads_enter()
        if Gtk.get_major_version() >= 3:
            self.clipBoard.set_text(contents, -1)
        else:
            self.clipBoard.set_text(contents)
        Gdk.threads_leave() 
Example #8
Source File: scripting.py    From autokey with GNU General Public License v3.0 5 votes vote down vote up
def __fillSelection(self, string):
        Gdk.threads_enter()
        self.selection.set_text(string, -1)
        Gdk.threads_leave()
        #self.sem.release() 
Example #9
Source File: gtkapp.py    From autokey with GNU General Public License v3.0 5 votes vote down vote up
def main(self):
        logging.info("Entering main()")
        Gdk.threads_enter()
        Gtk.main()
        Gdk.threads_leave() 
Example #10
Source File: gtkapp.py    From autokey with GNU General Public License v3.0 5 votes vote down vote up
def show_configure_async(self):
        Gdk.threads_enter()
        self.show_configure()
        Gdk.threads_leave() 
Example #11
Source File: interface.py    From autokey with GNU General Public License v3.0 5 votes vote down vote up
def selection(self, new_content: str):
            Gdk.threads_enter()
            try:
                # This call might fail and raise an Exception.
                # If it does, make sure to release the mutex and not deadlock AutoKey.
                self._selection.set_text(new_content, -1)
            finally:
                Gdk.threads_leave() 
Example #12
Source File: interface.py    From autokey with GNU General Public License v3.0 5 votes vote down vote up
def selection(self):
            Gdk.threads_enter()
            text = self._selection.wait_for_text()
            Gdk.threads_leave()
            return text 
Example #13
Source File: interface.py    From autokey with GNU General Public License v3.0 5 votes vote down vote up
def text(self, new_content: str):
            Gdk.threads_enter()
            try:
                # This call might fail and raise an Exception.
                # If it does, make sure to release the mutex and not deadlock AutoKey.
                self._clipboard.set_text(new_content, -1)
            finally:
                Gdk.threads_leave() 
Example #14
Source File: interface.py    From autokey with GNU General Public License v3.0 5 votes vote down vote up
def text(self):
            Gdk.threads_enter()
            text = self._clipboard.wait_for_text()
            Gdk.threads_leave()
            return text 
Example #15
Source File: backend_gtk3.py    From Computable with MIT License 5 votes vote down vote up
def flush_events(self):
        Gdk.threads_enter()
        while Gtk.events_pending():
            Gtk.main_iteration(True)
        Gdk.flush()
        Gdk.threads_leave() 
Example #16
Source File: dialogs.py    From autokey with GNU General Public License v3.0 5 votes vote down vote up
def receive_window_info(self, info):
        Gdk.threads_enter()
        dlg = DetectDialog(self.ui)
        dlg.populate(info)
        response = dlg.run()

        if response == Gtk.ResponseType.OK:
            self.triggerRegexEntry.set_text(dlg.get_choice())

        self.detectButton.set_sensitive(True)
        Gdk.threads_leave() 
Example #17
Source File: dialogs.py    From autokey with GNU General Public License v3.0 5 votes vote down vote up
def cancel_grab(self):
        Gdk.threads_enter()
        self.setButton.set_sensitive(True)
        self._setKeyLabel(self.key)
        Gdk.threads_leave() 
Example #18
Source File: configwindow.py    From autokey with GNU General Public License v3.0 5 votes vote down vote up
def config_modified(self):
        if not self.__warnedOfChanges:
            Gdk.threads_enter()
            msg = _("Changes made in other programs will not be displayed until you\
close and reopen the AutoKey window.\nThis message is only shown once per session.")
            dlg = Gtk.MessageDialog(self.ui, type=Gtk.MessageType.QUESTION, buttons=Gtk.ButtonsType.OK,
                                   message_format= _("Configuration has been changed on disk."))
            dlg.format_secondary_text(msg)

            dlg.run()
            dlg.destroy()
            Gdk.threads_leave()
            self.__warnedOfChanges = True 
Example #19
Source File: notifier.py    From autokey with GNU General Public License v3.0 5 votes vote down vote up
def show_notify(self, message, iconName):
        Gdk.threads_enter()
        n = Notify.Notification.new("AutoKey", message, iconName)
        n.set_urgency(Notify.Urgency.LOW)
        n.show()
        Gdk.threads_leave() 
Example #20
Source File: gtk.py    From ubuntu-cleaner with GNU General Public License v3.0 5 votes vote down vote up
def post_ui(func):
    def func_wrapper(*args, **kwargs):
        Gdk.threads_enter()
        func(*args, **kwargs)
        Gdk.threads_leave()

    return func_wrapper 
Example #21
Source File: package.py    From ubuntu-cleaner with GNU General Public License v3.0 5 votes vote down vote up
def _on_finished(self, transaction, status, close, show_error):
        if close:
            self.hide()
            if status == EXIT_FAILED and show_error:
                Gdk.threads_enter()
                err_dia = AptErrorDialog(self._transaction.error, self)
                err_dia.run()
                err_dia.hide()
                Gdk.threads_leave()
        self.emit("finished") 
Example #22
Source File: backend_gtk3.py    From ImageFusion with MIT License 5 votes vote down vote up
def flush_events(self):
        Gdk.threads_enter()
        while Gtk.events_pending():
            Gtk.main_iteration(True)
        Gdk.flush()
        Gdk.threads_leave() 
Example #23
Source File: __main__.py    From pyWinUSB with MIT License 5 votes vote down vote up
def main():
    if not check_root_access():
        sys.exit("\nOnly root can run this script :(\n")

    win = AppWindow()
    win.show_all()

    Gdk.threads_enter()
    GObject.threads_init()
    Gtk.main()
    Gdk.threads_leave() 
Example #24
Source File: backend_gtk3.py    From neural-network-animation with MIT License 5 votes vote down vote up
def flush_events(self):
        Gdk.threads_enter()
        while Gtk.events_pending():
            Gtk.main_iteration(True)
        Gdk.flush()
        Gdk.threads_leave() 
Example #25
Source File: backend_gtk3.py    From matplotlib-4-abaqus with MIT License 5 votes vote down vote up
def flush_events(self):
        Gdk.threads_enter()
        while Gtk.events_pending():
            Gtk.main_iteration(True)
        Gdk.flush()
        Gdk.threads_leave() 
Example #26
Source File: backend_gtk3.py    From Mastering-Elasticsearch-7.0 with MIT License 5 votes vote down vote up
def flush_events(self):
        # docstring inherited
        Gdk.threads_enter()
        while Gtk.events_pending():
            Gtk.main_iteration()
        Gdk.flush()
        Gdk.threads_leave()