def bookmarksview(): tmp = [] bookmarks = [] tmp_ap = tmp.append bookmarks_ap = bookmarks.append with bookmarks_con: cur = bookmarks_con.cursor() cur.execute("SELECT * FROM bookmarks ORDER BY date DESC;") urls = cur.fetchall() for i in urls: tmp_ap([i[2]] + [minify(i[0],50)] + [minify(i[1],50)] + [i[1]]) for i in tmp: bookmarks_ap(tuple(i)) return bookmarks
def historyview(): tmp = [] history = [] tmp_ap = tmp.append history_ap = history.append with history_con: cur = history_con.cursor() cur.execute("SELECT * FROM history ORDER BY date DESC;") urls = cur.fetchall() for i in urls: tmp_ap([i[2]] + [minify(i[0],50)] + [minify(i[1],50)] + [i[1]]) for i in tmp: history_ap(tuple(i)) return history
def autocomplete(query, liststore): if query: liststore.clear() if autocomplete_policy == 1: tmp = [] tmp_ap = tmp.append with history_con: cur = history_con.cursor() cur.execute("SELECT DISTINCT title,url FROM history LIMIT {};".format(autocomplete_limit)) urls = cur.fetchall() if len(urls) != 0: for url in urls: tmp_ap(["{} | {}".format(minify(url[0], 50), minify(url[1], 100))] + [url[1]]) for i in tmp: liststore.append(tuple(i)) return True else: if autocomplete_policy == 2: url = ("https://ac.duckduckgo.com/ac/?q={}&type=list".format(query)) if autocomplete_policy == 3: url = ("https://{}.wikipedia.org/w/api.php?action=opensearch&search={}".format(language_list[language].split("_")[0], query)) if autocomplete_policy == 4: url = ("https://suggestqueries.google.com/complete/search?json&client=firefox&q={}".format(query)) if autocomplete_policy == 5: url = ("https://suggestqueries.google.com/complete/search?json&client=firefox&ds=yt&q={}".format(query)) if autocomplete_policy == 6: url = ("https://completion.amazon.co.uk/search/complete?method=completion&q={}&search-alias=aps&mkt=4".format(query)) request = requests.get(url, stream=True, verify=bool(verify_req)) request = json.loads(request.content.decode('utf-8')) for i in request: if i and type(i) == list: for a in i: try: liststore.append([a]) except ValueError: pass return True
def cookiesview(): tmp = [] cookies = [] tmp_ap = tmp.append cookies_ap = cookies.append with cookies_con: cur = cookies_con.cursor() cur.execute("SELECT * FROM moz_cookies;") cks = cur.fetchall() for i in cks: tmp_ap([i[0]] + [i[1]] + [minify(i[2],50)] + [i[3]] + [i[4]] +\ [i[5]] + [i[6]] + [i[7]] + [i[8]] + [i[2]]) for i in tmp: cookies_ap(tuple(i)) return cookies
def on_context_menu(self, view, menu, event, htr): ''' ################ # Custom Items # ################ ''' context = htr.get_context() action = WebKit2.ContextMenuAction.OUTLINE if context == 18: if htr.context_is_media(): for c, i in enumerate(menu.get_items()): if not i.is_separator(): if i.get_stock_action() ==\ WebKit2.ContextMenuAction.ENTER_VIDEO_FULLSCREEN: url = htr.get_media_uri() if "://" in url: item = WebKit2.ContextMenuItem().\ new_from_stock_action_with_label(action, _("Video pop out")) a = item.get_action() a.connect("activate", lambda x: self.video_popout(view.get_title(), url)) a.set_stock_id("gtk-fullscreen") item = item.new(a) menu.insert(item, c) if context == 14 or context == 10: if htr.context_is_image(): url = htr.get_image_uri() if "://" in url: item = WebKit2.ContextMenuItem().\ new_from_stock_action_with_label(action, _("Apply as theme")) a = item.get_action() a.connect("activate", lambda x: self.apply_theme(url)) a.set_stock_id("gtk-select-color") item = item.new(a) menu.insert(item, 0) menu.insert(WebKit2.ContextMenuItem().new_separator(), 1) if context == 130 or context == 134: if context == 134: menu.insert(WebKit2.ContextMenuItem().\ new_from_stock_action(WebKit2.ContextMenuAction.COPY), 4) if not search_engine: return True text = Gtk.Clipboard.get(Gdk.SELECTION_PRIMARY) if htr.context_is_selection(): text = text.wait_for_text() isurl = validators.url(text) if isurl: item = WebKit2.ContextMenuItem().\ new_from_stock_action_with_label(action, "{} \"{}\"."\ .format(_("Go to"), minify(text, 30))) else: item = WebKit2.ContextMenuItem().\ new_from_stock_action_with_label(action, "{} \"{}\" {}."\ .format(_("Search"), minify(text, 30), _("in the web"))) a = item.get_action() if isurl: a.connect("activate", lambda x: view.load_uri(text)) a.set_stock_id("gtk-open") else: a.connect("activate", lambda x: view.load_uri("{}{}"\ .format(search_engine, text))) a.set_stock_id("gtk-find") item = item.new(a) menu.insert(item, 0) menu.insert(WebKit2.ContextMenuItem().new_separator(), 1)