我们从Python开源项目中,提取了以下25个代码示例,用于说明如何使用gi.repository.Gtk.get_current_event_time()。
def show_context_menu(self, for_id): """ Sets sensitivity of popup menu items and displays it on screen """ mnuPopup = self.builder.get_object("mnuPopup") mnuCopy = self.builder.get_object("mnuCopy") mnuClear = self.builder.get_object("mnuClear") mnuPaste = self.builder.get_object("mnuPaste") mnuEPress = self.builder.get_object("mnuEditPress") mnuEPressS = self.builder.get_object("mnuEditPressSeparator") self.context_menu_for = for_id clp = Gtk.Clipboard.get_default(Gdk.Display.get_default()) mnuCopy.set_sensitive(bool(self.get_action(self.current, for_id))) mnuClear.set_sensitive(bool(self.get_action(self.current, for_id))) mnuPaste.set_sensitive(clp.wait_is_text_available()) mnuEPress.set_visible(for_id in STICKS + PADS) mnuEPressS.set_visible(mnuEPress.get_visible()) mnuPopup.popup(None, None, None, None, 3, Gtk.get_current_event_time())
def vte_menu(widget): menu = Gtk.Menu() copy = Gtk.ImageMenuItem.new_from_stock("gtk-copy", None) copy.connect("activate", lambda x: widget.copy_clipboard()) paste = Gtk.ImageMenuItem.new_from_stock("gtk-paste", None) paste.connect("activate", lambda x: widget.paste_clipboard()) menu.append(copy) menu.append(paste) menu.show_all() menu.popup(None, None, None, None, 0, Gtk.get_current_event_time()) return True
def signal_tv_button_pressed(self, _, event): if event.button == Gdk.BUTTON_SECONDARY: selected_tasks = self._get_selected_tasks() if not selected_tasks: self.menu_item_cancel.set_sensitive(False) self.menu_item_paused.set_sensitive(False) else: self.menu_item_cancel.set_sensitive(True) self.menu_item_paused.set_sensitive(True) tasks_are_paused = [task.state == 'Paused' for task in selected_tasks] if any(tasks_are_paused): self.menu_item_paused.set_active(True) self.menu_item_paused.set_inconsistent(not all(tasks_are_paused)) else: self.menu_item_paused.set_active(False) self.menu_item_paused.set_inconsistent(False) self.popup_menu.popup(None, None, None, None, event.button, Gtk.get_current_event_time()) return True return
def on_profile_right_clicked(self, ps): for name in ("mnuConfigureController", "mnuTurnoffController"): # Disable controller-related menu items if controller is not connected obj = self.builder.get_object(name) obj.set_sensitive(ps.get_controller() is not None) for name in ("mnuProfileNew", "mnuProfileCopy", "mnuProfileRename", "mnuProfileDetails", "mnuProfileSeparator1", "mnuProfileSeparator2"): # Hide profile-related menu items for all but 1st profile switcher obj = self.builder.get_object(name) obj.set_visible(ps == self.profile_switchers[0]) if ps == self.profile_switchers[0]: name = ps.get_profile_name() is_override = profile_is_override(name) is_default = profile_is_default(name) self.builder.get_object("mnuProfileDelete").set_visible(not is_default) self.builder.get_object("mnuProfileRevert").set_visible(is_override) self.builder.get_object("mnuProfileRename").set_visible(not is_default) else: self.builder.get_object("mnuProfileDelete").set_visible(False) self.builder.get_object("mnuProfileRevert").set_visible(False) mnuPS = self.builder.get_object("mnuPS") mnuPS.ps = ps mnuPS.popup(None, None, None, None, 3, Gtk.get_current_event_time())
def on_area_click(self, trash, what): stDialog = self.builder.get_object("stDialog") pages = stDialog.get_children() index = pages.index(stDialog.get_visible_child()) if index == 2: if what in STICK_PAD_AREAS: area_name, axes = STICK_PAD_AREAS[what] mnuStick = self.builder.get_object("mnuStick") mnuStick._what = what mnuStick._axes = [ self._axis_data[index] for index in axes ] mnuStick.popup(None, None, None, None, 1, Gtk.get_current_event_time()) elif what in TRIGGER_AREAS: self._grabber = TriggerGrabber(self, self._axis_data[TRIGGER_AREAS[what]]) elif hasattr(SCButtons, what): self._grabber = InputGrabber(self, getattr(SCButtons, what))
def pressEvent(self, keys): for k in keys: event = Gdk.Event.new(Gdk.EventType.KEY_PRESS) event.time = Gtk.get_current_event_time() event.hardware_keycode = KEY_TO_KEYCODE[k] event.keyval = KEY_TO_GDK[k] event.window = self.mapper.target_window event.set_device(self.device) Gtk.main_do_event(event)
def releaseEvent(self, keys=[]): for k in keys: event = Gdk.Event.new(Gdk.EventType.KEY_RELEASE) event.time = Gtk.get_current_event_time() event.hardware_keycode = KEY_TO_KEYCODE[k] event.keyval = KEY_TO_GDK[k] event.window = self.mapper.target_window event.set_device(self.device) Gtk.main_do_event(event)
def popup_menu(self, *args): self.popup.popup(None, None, None, None, 0, Gtk.get_current_event_time())
def show_menu(self): """ Displays right click context menu """ if self.content_provider.status: self.menu.popup(None, None, None, None, 0, Gtk.get_current_event_time())
def __on_properties_clicked(self, button): """ Handles settings button clicked event and displays context menu :param button: """ self.__menu.popup(None, button, None, button, 0, Gtk.get_current_event_time())
def popup_alsa_connection_list(self, widget): connection_list = soundcard.alsa_sequencer.get_connection_list() if connection_list: menu = Gtk.Menu() for clientid, portid, clientname, portname, labeltext in connection_list: item = Gtk.MenuItem(labeltext) menu.append(item) def ff(widget, clientid, portid): self.g_alsa_device.set_label(widget.get_child().get_text()) self.m_gui_client_port = (clientid, portid) self.g_alsa_radio.set_active(True) item.connect('activate', ff, clientid, portid) menu.show_all() menu.popup(None, None, None, None, 0, Gtk.get_current_event_time())
def file_clicked(self, widget): self.main_menu.popup( None, None, None, None, 0, Gtk.get_current_event_time())
def settings_clicked(self, widget): self.settings_menu.popup( None, None, None, None, 0, Gtk.get_current_event_time())
def help_clicked(self, widget): self.help_menu.popup( None, None, None, None, 0, Gtk.get_current_event_time())
def show_menu(self, widget, event): """show_menu Shows the right click menu of the current item. """ button = event.button if button == 3 and self.active != None: self.menu.show_all() self.menu.popup(None, None, None, None, 0, Gtk.get_current_event_time()) return None
def url_entry_menu(widget): menu = Gtk.Menu() cut = Gtk.ImageMenuItem.new_from_stock("gtk-cut", None) cut.connect("activate", lambda x: widget.cut_clipboard()) copy = Gtk.ImageMenuItem.new_from_stock("gtk-copy", None) copy.connect("activate", lambda x: widget.copy_clipboard()) paste = Gtk.ImageMenuItem.new_from_stock("gtk-paste", None) paste.connect("activate", lambda x: widget.paste_clipboard()) pastego = Gtk.ImageMenuItem.new_with_mnemonic(_("_Paste & Go")) pastego.set_image(Gtk.Image.new_from_stock("gtk-paste", Gtk.IconSize.MENU)) pastego.connect("activate", lambda x: on_pastego(widget)) delete = Gtk.ImageMenuItem.new_from_stock("gtk-delete", None) delete.connect("activate", lambda x: widget.delete_selection()) select = Gtk.ImageMenuItem.new_from_stock("gtk-select-all", None) select.connect("activate", lambda x: widget.select_region(0, -1)) menu.append(cut) menu.append(copy) menu.append(paste) menu.append(pastego) menu.append(delete) menu.append(Gtk.SeparatorMenuItem.new()) menu.append(select) menu.show_all() menu.popup(None, None, None, None, 0, Gtk.get_current_event_time()) return True
def __call__(self, tab): self.tab = tab self.menu.show_all() self.menu.popup(None, None, None, None, 0, Gtk.get_current_event_time())
def __call__(self, universe): self.universe = universe self.menu.show_all() self.menu.popup(None, None, None, None, 0, Gtk.get_current_event_time())
def signal_tv_button_press(self, _, event): if event.button == Gdk.BUTTON_SECONDARY: _, treeiter = self.treeview.get_selection().get_selected() sensitive = treeiter is not None for menu_item in self._menu_items_req_selection: menu_item.set_sensitive(sensitive) self.popup_menu.popup(None, None, None, None, event.button, Gtk.get_current_event_time()) return True return
def Raise(self): self.__app.window.setup_window() self.__app.window.present_with_time(Gtk.get_current_event_time())
def on_keyboard_clicked(self, button, menu): menu.popup(None, None, self.menu_positionner, (button, None), 1, Gtk.get_current_event_time())
def listbox_row_activated(self, listbox, listboxrow): """ docker container has been selected so open terminal """ self.current_container_id = listboxrow.get_name() self.current_container_info = get_container_info(self.current_container_id) self.menu.show_all() self.menu.popup(None, None, None, None, 0, Gtk.get_current_event_time())
def popup_menu(self, widget, event): print 'menu' if event.button == 3: print 'Right Click' self.menu.show_all() self.menu.popup(None, None, None, None, 0, Gtk.get_current_event_time())
def open_browser(self, gameinfo_url): Gtk.show_uri( Gdk.Screen.get_default(), gameinfo_url, Gtk.get_current_event_time() )