Пример #1
0
 def on_activate(self, app):
     '''
     This method will activate the window, most of the time.
     This method gets called when the application is first run, so it needs
     to check if the hide flag was specified, if it was, it won't actually
     activate the window, and it won't populate the window with any data.
     The reason for this is because the data that needs to be displayed is
     inside a collection, which may be locked, asking the user for a
     password on login, which is when by default the application is run,
     will be an unintuitive experience. The password may be in the 'Login'
     keyring, in which case the collection will be unlocked automatically,
     but we can't rely on that, and so the data is only unlocked and loaded
     when the application is first shown. This will slow the first show a
     bit, but if the password to unlock the collection is required, the user
     will know why that popup asking for a password is showing.
     Also when the collection is first unlock, and the user doesn't input
     the correct password, or just cancels the popup, there will be
     different behaviour depending on whether the application was run
     initially hidden or not. We feel it's best to return the window to the
     previous state to deliver a more intuitive experience to the user.
     So if the window is hidden, then it's shown, and needs a password to
     unlock the collection, if that password query fails, it returns to
     being hidden. If the application is being started without the hide flag
     and a password query fails, then the application is shutdown.
     '''
     if self.hide_flag:
         self.hide_flag = False
         return
     # If the collection wasn't created quit
     if not self.main_view.secret.collection:
         self.quit()
         return
     if self.main_view.secret.unlock():
         # The app can start hidden to speed up showing it later,
         # but I wouldn't want to ask for a collection password right after
         # the user logs in, particularly because the collection would be
         # locked and the user would have to input the password again later
         # when showing the window. So I populate the buttons on the first
         # show instead. I also set the started_hidden flag, this makes the
         # app never quit when coming from hiding and the unlock fails,
         # it will just keep hidden.
         if self.first_run:
             self.first_run = False
             self.started_hidden = True
             self.main_view.init_buttons()
         self.window.show()
         if platform.system() == 'Windows':
             current_event_time = 0
         else:
             current_event_time = Keybinder.get_current_event_time()
         # This line will produce warnings on journalctl when passman
         # is activated without using the keyboard shortcut.
         # This happens because Gtk doesn't set this as the current event,
         # and so we have no object to get the time from.
         self.window.get_window().focus(current_event_time)
     else:
         # If the application starts hidden, I prefer to return the app to
         # the previous state, hidden, instead of quitting.
         if not self.started_hidden:
             self.quit()
Пример #2
0
	def hide_app(self, key_bind_hide, user_data):
		self.last_event_time = Keybinder.get_current_event_time()
		print ("Event time:", self.last_event_time)
		
		self.wnck.force_update()
		self.active_workspace = self.wnck.get_active_workspace()
#		print("Workspaces:", self.wnck.get_workspaces())
#		print("Active workspace:", self.active_workspace)
#		print("Last active workspace:", self.last_active_workspace)
#		
		if self.is_present:
			print("Hiding app")
			if self.parent.is_drop_down:
				self.hide()
			else:
				self.iconify()
			self.is_present = False

		else:
			print("Showing app")
			if self.parent.is_drop_down:
				if self.last_active_workspace != self.active_workspace:				
					self.last_active_workspace = self.active_workspace
					self.hide()

				self.show()
#				self.present()
#				self.set_icon_from_file(config.file_program_icon)
		
			self.present_with_time(self.last_event_time)
			self.main_box.active_term.grab_focus()
			self.is_present = True
Пример #3
0
 def on_activate(self, app):
     '''
     This method will activate the window, most of the time.
     This method gets called when the application is first run, so it needs
     to check if the hide flag was specified, if it was, it won't actually
     activate the window, and it won't populate the window with any data.
     The reason for this is because the data that needs to be displayed is
     inside a collection, which may be locked, asking the user for a
     password on login, which is when by default the application is run,
     will be an unintuitive experience. The password may be in the 'Login'
     keyring, in which case the collection will be unlocked automatically,
     but we can't rely on that, and so the data is only unlocked and loaded
     when the application is first shown. This will slow the first show a
     bit, but if the password to unlock the collection is required, the user
     will know why that popup asking for a password is showing.
     Also when the collection is first unlock, and the user doesn't input
     the correct password, or just cancels the popup, there will be
     different behaviour depending on whether the application was run
     initially hidden or not. We feel it's best to return the window to the
     previous state to deliver a more intuitive experience to the user.
     So if the window is hidden, then it's shown, and needs a password to
     unlock the collection, if that password query fails, it returns to
     being hidden. If the application is being started without the hide flag
     and a password query fails, then the application is shutdown.
     '''
     if self.hide_flag:
         self.hide_flag = False
         return
     # If the collection wasn't created quit
     if not self.main_view.secret.collection:
         self.quit()
         return
     if self.main_view.secret.unlock():
         # The app can start hidden to speed up showing it later,
         # but I wouldn't want to ask for a collection password right after
         # the user logs in, particularly because the collection would be
         # locked and the user would have to input the password again later
         # when showing the window. So I populate the buttons on the first
         # show instead. I also set the started_hidden flag, this makes the
         # app never quit when coming from hiding and the unlock fails,
         # it will just keep hidden.
         if self.first_run:
             self.first_run = False
             self.started_hidden = True
             self.main_view.init_buttons()
         self.window.show()
         if platform.system() == 'Windows':
             current_event_time = 0
         else:
             current_event_time = Keybinder.get_current_event_time()
         # This line will produce warnings on journalctl when passman
         # is activated without using the keyboard shortcut.
         # This happens because Gtk doesn't set this as the current event,
         # and so we have no object to get the time from.
         self.window.get_window().focus(current_event_time)
     else:
         # If the application starts hidden, I prefer to return the app to
         # the previous state, hidden, instead of quitting.
         if not self.started_hidden:
             self.quit()
    def hide_app(self, key_bind_hide, user_data):
        self.last_event_time = Keybinder.get_current_event_time()
        print("Event time:", self.last_event_time)

        self.wnck.force_update()
        self.active_workspace = self.wnck.get_active_workspace()
        # 		print("Workspaces:", self.wnck.get_workspaces())
        # 		print("Active workspace:", self.active_workspace)
        # 		print("Last active workspace:", self.last_active_workspace)
        #
        if self.is_present:
            print("Hiding app")
            if self.parent.is_drop_down:
                self.hide()
            else:
                self.iconify()
            self.is_present = False

        else:
            print("Showing app")
            if self.parent.is_drop_down:
                if self.last_active_workspace != self.active_workspace:
                    self.last_active_workspace = self.active_workspace
                    self.hide()

                self.show()
            # 				self.present()
            # 				self.set_icon_from_file(config.file_program_icon)

            self.present_with_time(self.last_event_time)
            self.main_box.active_term.grab_focus()
            self.is_present = True
Пример #5
0
    def popup(self, keystr, items = None):
        self._ungrab_keyboard()

        menu = _gtk.Menu()
        index = 0

        if _util.humanbool(self.options.get('show-current-selection', 'yes')) and len(self.history):
            item = _gtk.MenuItem("")
            item.get_children()[0].set_markup(
                "<b>%s</b>" % (self._printable(self.history.top, True),),
            )
            menu.append(item)
            menu.append(_gtk.SeparatorMenuItem())
            index += 1

        self._build_menu(menu, items or self.items())

        menu.show_all()
        menu.popup(
            None,
            None,
            None,
            None,
            0,
            _keybinder.get_current_event_time(),
        )
        menu.set_active(index)
        return True
Пример #6
0
 def create_picker_window(self, show_welcome=False):
     if self.picker_window:
         self.picker_window.destroy()
     self.picker_window = picker.EmojiPicker(
         Keybinder.get_current_event_time(), self.update_accelerator,
         show_welcome)
     self.picker_window.connect("destroy", self.handle_picker_destroy)
Пример #7
0
def relay_key(key):
    print("Relaying", key)
    time = keybinder.get_current_event_time()
    s_id = "kupfer-%d_TIME%s" % (os.getpid(), time)
    bus = dbus.Bus()
    obj = bus.get_object(SERV, OBJ, introspect=False)
    iface = dbus.Interface(obj, IFACE)
    iface.RelayKeysFromDisplay(key, os.getenv("DISPLAY", ":0"), s_id)
Пример #8
0
 def show_window(self):
     self._mainWindowWasActivated = True
     # works only when the following methods are called in that exact order
     self.input.set_text('')
     self.position_window()
     self.window.set_sensitive(True)
     self.window.present()
     self.present_with_time(Keybinder.get_current_event_time())
Пример #9
0
    def show_window(self):
        # works only when the following methods are called in that exact order
        self.present()
        self.position_window()
        if IS_X11_COMPATIBLE:
            self.present_with_time(Keybinder.get_current_event_time())

        if not self._get_input_text():
            # make sure frequent apps are shown if necessary
            self.show_results([])
        elif self.settings.get_property('clear-previous-query'):
            self.input.set_text('')
        else:
            self.input.grab_focus()
Пример #10
0
    def show_window(self):
        # works only when the following methods are called in that exact order
        self.position_window()
        self.window.set_sensitive(True)
        self.window.present()
        if not is_wayland_compatibility_on():
            self.present_with_time(Keybinder.get_current_event_time())

        if not self.input.get_text():
            # make sure frequent apps are shown if necessary
            self.show_results([])
        elif self.settings.get_property('clear-previous-query'):
            self.input.set_text('')
        else:
            self.input.grab_focus()
Пример #11
0
 def show(self):
     for plugin in self._plugins:
         plugin.on_window_show()
     self.set_sensitive(True)
     self.present()
     self._update_position()
     self.move(*self._position)
     timestamp = Keybinder.get_current_event_time()
     self.present_with_time(timestamp)
     self._result_list.unselect_all()
     self._result_scroller.hide()
     self._prev_query = ""
     self._input_entry.set_text("")
     self._input_entry.grab_focus()
     super().show()
Пример #12
0
    def show_window(self):
        # works only when the following methods are called in that exact order
        self.window.set_sensitive(True)
        self.window.present()
        self.position_window()
        if not is_wayland_compatibility_on():
            self.present_with_time(Keybinder.get_current_event_time())

        if not self.input.get_text():
            # make sure frequent apps are shown if necessary
            self.show_results([])
        elif self.settings.get_property('clear-previous-query'):
            self.input.set_text('')
        else:
            self.input.grab_focus()
Пример #13
0
def get_current_event_time():
    "Return current event time as given by keybinder"
    if Keybinder is None:
        return 0
    return Keybinder.get_current_event_time()
Пример #14
0
 def show_shortcut_callback(self, keystr, user_data):
     print("Handling", user_data)
     print("Event time:", Keybinder.get_current_event_time())
     return self.show_window()
Пример #15
0
 def _keybinding(self, target):
     time = Keybinder.get_current_event_time()
     self.emit("keybinding", target, "", time)
Пример #16
0
def callback(keystr, user_data):
    print "Handling", keystr, user_data
    print "Event time:", Keybinder.get_current_event_time()
    Gtk.main_quit()
Пример #17
0
def callback(keystr, user_data):
    print ("Handling", user_data)
    print ("Event time:", Keybinder.get_current_event_time())
    Gtk.main_quit()
Пример #18
0
def get_current_event_time():
    "Return current event time as given by keybinder"
    if Keybinder is None:
        return 0
    return Keybinder.get_current_event_time()
Пример #19
0
 def _keybinding(self, target):
     time = Keybinder.get_current_event_time()
     self.emit("keybinding", target, "", time)
Пример #20
0
 def _ungrab_keyboard(self):
     dm = _gdkx11.X11DeviceManagerCore(display=_gdk.Display.get_default())
     for dev in dm.list_devices(_gdk.DeviceType.MASTER):
         if dev.get_source() == _gdk.InputSource.KEYBOARD:
             dev.ungrab(_keybinder.get_current_event_time())
Пример #21
0
def callback(keystr, user_data):
    print("Handling", keystr, user_data)
    print("Event time:", Keybinder.get_current_event_time())
    run_other_window()
Пример #22
0
 def on_keyboard_shortcut(self, keystr, user_data=None):
     self.emit('activated', keybinder.get_current_event_time())