mirror of
https://github.com/Afacanc38/browser.git
synced 2024-11-23 06:20:40 +03:00
Ported into Libadwaita
This commit is contained in:
parent
00e38f36e1
commit
01e9bb0686
1 changed files with 36 additions and 38 deletions
74
main.py
74
main.py
|
@ -1,15 +1,13 @@
|
|||
#!/usr/bin/env python3
|
||||
import gi, os, sys
|
||||
gi.require_version("Gtk", "3.0")
|
||||
gi.require_version("Handy", "1")
|
||||
gi.require_version("WebKit2", "4.0")
|
||||
from gi.repository import Gtk, Handy, GLib, GLib, WebKit2
|
||||
gi.require_version("Gtk", "4.0")
|
||||
gi.require_version("Adw", "1")
|
||||
gi.require_version("WebKit", "6.0")
|
||||
from gi.repository import Gtk, Adw, GLib, GLib, WebKit
|
||||
|
||||
Handy.init()
|
||||
|
||||
class MyWindow(Handy.Window):
|
||||
def __init__(self):
|
||||
super().__init__(title="Tarayıcı")
|
||||
class MyWindow(Adw.Window):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.set_title("Tarayıcı")
|
||||
GLib.set_application_name("Tarayıcı")
|
||||
GLib.set_prgname('Tarayıcı')
|
||||
|
@ -18,47 +16,39 @@ class MyWindow(Handy.Window):
|
|||
self.main_box = Gtk.Box(
|
||||
orientation = Gtk.Orientation.VERTICAL
|
||||
)
|
||||
self.add(self.main_box)
|
||||
self.hb = Handy.HeaderBar()
|
||||
self.hb.set_show_close_button(True)
|
||||
self.set_content(self.main_box)
|
||||
self.hb = Adw.HeaderBar()
|
||||
self.inp_url = Gtk.Entry(
|
||||
width_request = 370
|
||||
)
|
||||
self.scroll = Gtk.ScrolledWindow()
|
||||
self.web = WebKit2.WebView()
|
||||
self.web = WebKit.WebView(
|
||||
vexpand = True
|
||||
)
|
||||
self.web.load_uri("https://duckduckgo.com")
|
||||
self.inp_url.set_placeholder_text("Web'de arayın veya URL adresi girin...")
|
||||
self.web.connect('notify::estimated-load-progress', self.change_url)
|
||||
self.inp_url.connect("activate", self.on_inp_url_activate)
|
||||
self.hb.set_custom_title(self.inp_url)
|
||||
self.btn_prev = Gtk.Button()
|
||||
self.btn_prev = Gtk.Button.new_from_icon_name("go-previous-symbolic", Gtk.IconSize.MENU)
|
||||
self.btn_prev = Gtk.Button.new_from_icon_name("go-previous-symbolic")
|
||||
self.btn_prev.connect("clicked", self.on_btn_prev_clicked)
|
||||
self.btn_next = Gtk.Button()
|
||||
self.btn_next = Gtk.Button.new_from_icon_name("go-next-symbolic", Gtk.IconSize.MENU)
|
||||
self.btn_next = Gtk.Button.new_from_icon_name("go-next-symbolic")
|
||||
self.btn_next.connect("clicked", self.on_btn_next_clicked)
|
||||
self.btn_box = Gtk.ButtonBox(width_request = 0)
|
||||
self.btn_box.set_layout(Gtk.ButtonBoxStyle.EXPAND)
|
||||
self.btn_box.pack_start(self.btn_prev, True, True, 0)
|
||||
self.btn_box.pack_start(self.btn_next, True, True, 0)
|
||||
self.btn_box = Gtk.Box(
|
||||
spacing = 6
|
||||
)
|
||||
self.btn_box.append(self.btn_prev)
|
||||
self.btn_box.append(self.btn_next)
|
||||
self.btn_ref = Gtk.Button()
|
||||
self.btn_ref = Gtk.Button.new_from_icon_name("view-refresh-symbolic", Gtk.IconSize.MENU)
|
||||
self.btn_ref = Gtk.Button.new_from_icon_name("view-refresh-symbolic")
|
||||
self.btn_next.connect("clicked", self.on_btn_ref_clicked)
|
||||
self.hb.pack_start(self.btn_box)
|
||||
self.hb.pack_start(self.btn_ref)
|
||||
self.main_box.pack_start(
|
||||
self.hb,
|
||||
False,
|
||||
True,
|
||||
0
|
||||
)
|
||||
self.scroll.add(self.web)
|
||||
self.main_box.pack_start(
|
||||
self.scroll,
|
||||
True,
|
||||
True,
|
||||
0
|
||||
)
|
||||
self.hb.set_title_widget(self.inp_url)
|
||||
self.main_box.append(self.hb)
|
||||
self.scroll.set_child(self.web)
|
||||
self.main_box.append(self.scroll)
|
||||
def on_btn_next_clicked(self, widget):
|
||||
self.web.go_forward()
|
||||
def on_btn_prev_clicked(self, widget):
|
||||
|
@ -74,7 +64,15 @@ class MyWindow(Handy.Window):
|
|||
def change_url(self, widget, frame):
|
||||
url_text = self.web.get_uri()
|
||||
self.inp_url.set_text(url_text)
|
||||
win = MyWindow()
|
||||
win.connect("destroy", Gtk.main_quit)
|
||||
win.show_all()
|
||||
Gtk.main()
|
||||
|
||||
class MyApp(Adw.Application):
|
||||
def __init__(self, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
self.connect('activate', self.on_activate)
|
||||
|
||||
def on_activate(self, app):
|
||||
self.win = MyWindow(application=app)
|
||||
self.win.present()
|
||||
|
||||
app = MyApp(application_id="io.github.afacanc38.browser")
|
||||
app.run(sys.argv)
|
||||
|
|
Loading…
Reference in a new issue