def open_uri_action_cb(self, action, param): shell = self.props.shell window = shell.props.window screen = window.get_screen() uri = param.get_string() Gtk.show_uri(screen, uri, Gdk.CURRENT_TIME)
def show_section(section, screen=None): if library.uninstalled: root = library.get_root() uri = os.path.join(root, 'docs', 'manual', 'pt_BR') if section != '': uri += '/' + section + '.page' else: if library.get_resource_exists('stoq', 'docs', 'manual', 'pt_BR'): manual_dir = library.get_resource_filename( 'stoq', 'docs', 'manual', 'pt_BR') if section: uri = os.path.join(manual_dir, section + '.page') else: uri = manual_dir else: uri = 'stoq' if section: uri += '?' + section if not screen: toplevel = get_current_toplevel() if toplevel: screen = toplevel.get_screen() try: Gtk.show_uri(screen, 'ghelp:' + uri, Gtk.get_current_event_time()) except GLib.GError: open_browser('http://doc.stoq.com.br/manual/%s/%s.html' % ( stoq.short_version, section or 'index', ), screen)
def open_uri(uri): """Opens a local or remote URI with the default application""" system.reset_library_preloads() try: Gtk.show_uri(None, uri, Gdk.CURRENT_TIME) except GLib.Error as ex: logger.exception("Failed to open URI %s: %s", uri, ex)
def show_yelp(widget): #import os #os.system("yelp /usr/share/gnome/help/lybniz/C/lybniz-manual.xml") try: Gtk.show_uri(None, "lybniz", 0) except: print ("Can't Show help")
def help_callback(self, action, parameter): if meld.conf.UNINSTALLED: uri = "http://meldmerge.org/help/" else: uri = "help:meld" Gtk.show_uri(Gdk.Screen.get_default(), uri, Gtk.get_current_event_time())
def open_url(self, action, url, parent_window=None, prompt=True): """Open an HTTP URL. Try to run as non-root.""" # drop privileges so the web browser is running as a normal process if 'posix' == os.name and 0 == os.getuid(): msg = _( "Because you are running as root, please manually open this link in a web browser:\n%s") % url message_dialog(None, msg, Gtk.MessageType.INFO) return if prompt: # find hostname import re ret = re.search('^http(s)?://([a-z.]+)', url) if None == ret: host = url else: host = ret.group(2) # TRANSLATORS: %s expands to www.bleachbit.org or similar msg = _("Open web browser to %s?") % host resp = message_dialog(parent_window, msg, Gtk.MessageType.QUESTION, Gtk.ButtonsType.OK_CANCEL) if Gtk.ResponseType.OK != resp: return # open web browser if 'nt' == os.name: # in Gtk.show_uri() avoid 'glib.GError: No application is registered as # handling this file' import webbrowser webbrowser.open(url) else: Gtk.show_uri(None, url, Gdk.CURRENT_TIME)
def button_press(self, terminal, event): """Handles the button press event in the terminal widget. If any match string is caught, another aplication is open to handle the matched resource uri. """ self.matched_value = '' matched_string = self.match_check( int(event.x / self.get_char_width()), int(event.y / self.get_char_height())) value, tag = matched_string if event.button == 1 \ and event.get_state() & Gdk.ModifierType.CONTROL_MASK \ and value: if TERMINAL_MATCH_TAGS[tag] == 'schema': # value here should not be changed, it is right and # ready to be used. pass elif TERMINAL_MATCH_TAGS[tag] == 'http': value = 'http://%s' % value elif TERMINAL_MATCH_TAGS[tag] == 'email': value = 'mailto:%s' % value Gtk.show_uri(self.get_screen(), value, GdkX11.x11_get_server_time(self.get_window())) elif event.button == 3 and matched_string: self.matched_value = matched_string[0]
def on_browse_files(self, widget): game = Game(self.view.selected_game) path = game.get_browse_dir() if path and os.path.exists(path): Gtk.show_uri(None, "file://" + path, Gdk.CURRENT_TIME) else: dialogs.NoticeDialog("Can't open %s \nThe folder doesn't exist." % path)
def __download_p2plink (self, result, albumid): if result is None: emsg = _("Error looking up p2plink for album %s on jamendo.com") % (albumid) Gtk.MessageDialog(None, 0, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, emsg).run() return Gtk.show_uri(self.props.shell.props.window.get_screen(), result, Gdk.CURRENT_TIME)
def on_contents_clicked(self, button): root_dir = utils.help_files print root_dir uri = "ghelp:%s/index.page" % root_dir print uri time_now = int(time.time()) Gtk.show_uri(None, uri, time_now)
def website(site): """Open the given URL in the user's default browser""" from gi.repository import Gtk, Gdk, GLib try: Gtk.show_uri(None, site, Gdk.CURRENT_TIME) except GLib.Error: print_exc()
def _url_handler(self, url): print('URL activated: ' + url) if self._is_url(url): # just to be sure and prevent shell injection rc = subprocess.call("xdg-open '%s'" % url, shell=True) # failover to gtk.show_uri, if xdg-open fails or is not installed if rc != 0: Gtk.show_uri(None, url, Gdk.CURRENT_TIME) else: self.frontend.warning("%s is not an URL" % url)
def os_open(path, uri): if not path: return if sys.platform == "win32": subprocess.Popen(["start", path], shell=True) elif sys.platform == "darwin": subprocess.Popen(["open", path]) else: Gtk.show_uri(Gdk.Screen.get_default(), uri, Gtk.get_current_event_time())
def show_url(url): """Open any @url with default viewer""" #from Gtk import show_uri, get_current_event_time #from Gtk.gdk import screen_get_default #from glib import GError try: Gtk.show_uri(Gdk.Screen.get_default(), url, Gtk.get_current_event_time()) except: logger.exception("Error in Gtk.show_uri: %s")
def _open_url(self, url): """Open URL in default browser.""" if misc.is_url(url): # just to be sure and prevent shell injection rc = subprocess.call('xdg-open %s' % url, shell=True) # failover to gtk.show_uri, if xdg-open fails or is not installed if rc != 0: Gtk.show_uri(None, url, Gdk.CURRENT_TIME) else: dialogs.show_information('%s is not an url' % url)
def navigation_request_cb(self, view, frame, request): # open HTTP URIs externally. this isn't a web browser. if request.get_uri().startswith('http'): print "opening uri %s" % request.get_uri() Gtk.show_uri(self.shell.props.window.get_screen(), request.get_uri(), Gdk.CURRENT_TIME) return 1 # WEBKIT_NAVIGATION_RESPONSE_IGNORE else: return 0 # WEBKIT_NAVIGATION_RESPONSE_ACCEPT
def _help(self, action, param): """ Show help in yelp @param action as Gio.SimpleAction @param param as GLib.Variant """ try: Gtk.show_uri(None, "help:lollypop", Gtk.get_current_event_time()) except: print(_("Lollypop: You need to install yelp."))
def display_artist_info(self): screen = self.props.shell.props.window.get_screen() tracks = self.get_entry_view().get_selected_entries() if len(tracks) == 0: return tr = tracks[0] sku = self.__sku_dict[tr.get_string(RB.RhythmDBPropType.LOCATION)] url = self.__home_dict[sku] Gtk.show_uri(screen, url, Gdk.CURRENT_TIME)
def download_redirect(self): screen = self.props.shell.props.window.get_screen() tracks = self.get_entry_view().get_selected_entries() if len(tracks) == 0: return tr = tracks[0] sku = self.__sku_dict[tr.get_string(RB.RhythmDBPropType.LOCATION)] url = magnatune_buy_album_uri + urllib.parse.urlencode({ 'sku': sku, 'ref': magnatune_partner_id }) Gtk.show_uri(screen, url, Gdk.CURRENT_TIME)
def display_artist_info(self): screen = self.props.shell.props.window.get_screen() tracks = self.get_entry_view().get_selected_entries() urls = set([]) for tr in tracks: sku = self.__sku_dict[tr.get_string(RB.RhythmDBPropType.LOCATION)] url = self.__home_dict[sku] if url not in urls: Gtk.show_uri(screen, url, Gdk.CURRENT_TIME) urls.add(url)
def download_redirect(self): screen = self.props.shell.props.window.get_screen() tracks = self.get_entry_view().get_selected_entries() urls = set([]) for tr in tracks: sku = self.__sku_dict[tr.get_string(RB.RhythmDBPropType.LOCATION)] url = magnatune_buy_album_uri + urllib.parse.urlencode({ 'sku': sku, 'ref': magnatune_partner_id }) if url not in urls: Gtk.show_uri(screen, url, Gdk.CURRENT_TIME) urls.add(url)
def on_report_chosen(widget, format, path): self.report_chooser = None reports.simple(self.facts, start, end, format, path) if format == ("html"): webbrowser.open_new("file://%s" % path) else: try: gtk.show_uri(gdk.Screen(), "file://%s" % os.path.split(path)[0], 0L) except: pass # bug 626656 - no use in capturing this one i think
def _onHelp(self, action, page=""): """ Shows the help dialog. @param widget: The widget that emitted the signal that this callback caught. @type widget: L{gtk.Widget} """ uri = "help:accerciser" if page: uri += "/%s" % page gtk.show_uri(gdk.Screen.get_default(), uri, gtk.get_current_event_time()) return True
def helpForOrca(script=None, inputEvent=None, page=""): """Show Orca Help window (part of the GNOME Access Guide). Returns True to indicate the input event has been consumed. """ uri = "help:orca" if page: uri += "?%s" % page Gtk.show_uri(Gdk.Screen.get_default(), uri, Gtk.get_current_event_time()) return True
def _on_webview_decide_policy(web_view, decision, decision_type): if decision_type == WebKit2.PolicyDecisionType.NAVIGATION_ACTION: uri = decision.get_request().get_uri() if uri != "about:blank" and decision.get_navigation_type() == WebKit2.NavigationType.LINK_CLICKED: decision.ignore() try: Gtk.show_uri(None, uri, Gdk.CURRENT_TIME) except GLib.Error: # for example, irc://irc.gimp.org/#guadec logger.warning("Couldn't open URI: %s" % uri) return True return False
def _get_token(self, data): """Open browser for authorization""" element = etree.fromstring(data) self.frob = element.find("frob").text base_url = "https://flickr.com/services/auth/?" values = {"api_key": self.api_key, "perms": self.perms, "frob": self.frob} values = add_api_sig(values, self.secret) url = base_url + urllib.urlencode(values) Gtk.show_uri(None, url, Gdk.CURRENT_TIME)
def _on_button_press_cb(self, actor, event): lat, lon = self.photo['geo'] title = self.photo['title'] or _('Untitled') title = title.replace("(", "[").replace(")", "]") \ .replace("<", "").replace(">", "").encode("utf-8") zoom = 0 if self.photo.is_my_photo() else 6 #zoom = SETTINGS_UI_GEO.get_int('zoom-level') zoom = "&z=%s" % zoom if zoom else "" url = "http://maps.google.com/maps?q=%s,%s+%%28%s%%29%s" % ( lat, lon, urllib.quote(title), zoom) Gtk.show_uri(None, url, event.time)
def on_button_press (self, widget, event): # on double clicks, open the cover image (if there is one) in the default # image viewer doubleclick = Gdk.EventType._2BUTTON_PRESS if event.type != doubleclick or event.button != 1: return if self.art_widget.current_uri is None: return f = Gio.file_new_for_uri(self.art_widget.current_uri) shell = self.object Gtk.show_uri(shell.props.window.get_screen(), f.get_uri(), event.time)
def open_browser(url, parent=None, timestamp=0): logging.info("Opening URL {}".format(url)) if not timestamp: timestamp = Gtk.get_current_event_time() try: if hasattr(Gtk, 'show_uri_on_window'): Gtk.show_uri_on_window(parent, url, timestamp) else: # Gtk <= 3.20 screen = None if parent: screen = parent.get_screen() Gtk.show_uri(screen, url, timestamp) except GLib.Error as e: logging.warning('Failed to open URL: {}'.format(e.message))
def cb_help_button(self, widget, data=None): uri = "ghelp:bookletimposer" try: Gtk.show_uri(screen = None, uri = uri, timestamp = Gtk.get_current_event_time()) except Gio.Error, error: dialog = Gtk.MessageDialog(parent=self.__main_window, flags=Gtk.DialogFlags.MODAL, type=Gtk.MessageType.ERROR, buttons=Gtk.ButtonsType.CLOSE, message_format=_("Unable to display help: %s") % str(error)) dialog.connect("response", lambda widget, data=None: widget.destroy()) dialog.run()
def _help(self, action, param): try: Gtk.show_uri(None, "help:gnome-music", Gdk.CURRENT_TIME) except GLib.Error: logging.warning("Help handler not available.")
def _open_browser(url): Gtk.show_uri(None, url, Gdk.CURRENT_TIME)
def show_uri(parent, link): screen = parent.get_screen() Gtk.show_uri(screen, link, Gtk.get_current_event_time())
def _help(self, action, param): import time Gtk.show_uri(None, 'https://github.com/tuhiproject/tuhi/wiki', time.time())
def on_website(self, btn, udata=None): """ Launch the main website """ try: Gtk.show_uri(None, self.url_website, 0) except: pass
def help_cb(self, action, _): Gtk.show_uri(None, "help:plots", Gdk.CURRENT_TIME)
def open_browser(uri, screen=None): try: Gtk.show_uri(screen, uri, Gdk.CURRENT_TIME) except Exception: webbrowser.open(uri, new=True)
def open_uri(uri): """Opens a local or remote URI with the default application""" for key in ('LD_LIBRARY_PATH', 'LD_PRELOAD'): if os.environ.get(key): del os.environ[key] Gtk.show_uri(None, uri, Gdk.CURRENT_TIME)
def open_browser(self, gameinfo_url): Gtk.show_uri(Gdk.Screen.get_default(), gameinfo_url, Gtk.get_current_event_time())
def on_help(self, component): Gtk.show_uri(None, 'help:glipper', Gdk.CURRENT_TIME)
def on_open_image_with(self, *args): Gtk.show_uri(None, self.image_uri_to_open, 0)
def _help(self, action, param): Gtk.show_uri(None, "help:gnome-music", Gdk.CURRENT_TIME)
def on_open_link_with(self, *args): Gtk.show_uri(None, self.link_uri_to_open, 0)
def action_help_cb(self, action, parameter): screen = Gdk.Screen.get_default() link = "help:d-feet" Gtk.show_uri(screen, link, Gtk.get_current_event_time())
def on_bug(self, btn, udata=None): """ Launch the bug website """ try: Gtk.show_uri(None, self.url_bug, 0) except: pass
def show_help(): Gtk.show_uri(None, "help:invest-applet", Gdk.CURRENT_TIME)
def _open_browser(self, url): try: subprocess.check_call(["xdg-open", url]) except subprocess.CalledProcessError: Gtk.show_uri(None, url, Gdk.CURRENT_TIME)
def _open_website(self, show_id): show = self._engine.get_show_info(show_id) if show['url']: Gtk.show_uri(None, show['url'], Gdk.CURRENT_TIME)
def open_uri(uri): """Opens a local or remote URI with the default application""" system.reset_library_preloads() Gtk.show_uri(None, uri, Gdk.CURRENT_TIME)
def on_cvetracker(self, widget): Gtk.show_uri( None, "https://people.canonical.com/~ubuntu-security/cve/pkg/linux.html", Gtk.get_current_event_time())
def show_help_section(id): Gtk.show_uri(None, "help:invest-applet?%s" % id, Gdk.CURRENT_TIME)
def on_goto_kernelorg(self, widget): Gtk.show_uri(None, "https://www.kernel.org/", Gtk.get_current_event_time())
def show_help_clicked(self, arg): try: Gtk.show_uri(None, 'help:labyrinth', 0) except GObject.GError: print ('Unable to display help:')
def show_url(url): Gtk.show_uri(None, url, Gdk.CURRENT_TIME)
def _help(self, action, params): Gtk.show_uri( self._main_window, urllib.parse.urljoin(Application.get_doc_uri(), 'index.html'), Gdk.CURRENT_TIME)
def show_uri(parent, link): from gi.repository import Gtk # pylint: disable=E0611 screen = parent.get_screen() Gtk.show_uri(screen, link, Gtk.get_current_event_time())
def on_runner_open_clicked(self, widget): Gtk.show_uri(None, 'file://' + settings.RUNNER_DIR, Gdk.CURRENT_TIME)
def on_donate(self, btn, udata=None): """ Launch the donation site """ try: Gtk.show_uri(None, self.url_donate, 0) except: pass
def on_help_activate(self, *args): Gtk.show_uri(None, 'help:dynamic-wallpaper-editor', Gdk.CURRENT_TIME)
def on_open_downloads_clicked(self, _widget): Gtk.show_uri(None, "http://lutris.net", Gdk.CURRENT_TIME)