feat: use Adw.HeaderBar
and download the proper file name
I have no idea what benefit `Adw.HeaderBar` would give me
This commit is contained in:
@@ -23,4 +23,4 @@ if __name__ == '__main__':
|
|||||||
resource._register()
|
resource._register()
|
||||||
|
|
||||||
from lemonade import main
|
from lemonade import main
|
||||||
sys.exit(0) # main.main(VERSION)
|
sys.exit(main.main(VERSION))
|
||||||
|
17
src/main.py
17
src/main.py
@@ -3,6 +3,7 @@ import gi
|
|||||||
import json
|
import json
|
||||||
import requests
|
import requests
|
||||||
import urllib.request
|
import urllib.request
|
||||||
|
import http
|
||||||
|
|
||||||
gi.require_version("Gtk", "4.0")
|
gi.require_version("Gtk", "4.0")
|
||||||
gi.require_version("Adw", "1")
|
gi.require_version("Adw", "1")
|
||||||
@@ -17,7 +18,7 @@ class LemonadeWindow(Gtk.ApplicationWindow):
|
|||||||
stack.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT)
|
stack.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT)
|
||||||
stack.set_transition_duration(1000)
|
stack.set_transition_duration(1000)
|
||||||
|
|
||||||
self.headerbar = Gtk.HeaderBar.new()
|
self.headerbar = Adw.HeaderBar.new()
|
||||||
self.set_titlebar(self.headerbar)
|
self.set_titlebar(self.headerbar)
|
||||||
|
|
||||||
home_button = Gtk.Button()
|
home_button = Gtk.Button()
|
||||||
@@ -83,11 +84,10 @@ class LemonadeWindow(Gtk.ApplicationWindow):
|
|||||||
|
|
||||||
if "icon" in community["community"]:
|
if "icon" in community["community"]:
|
||||||
try:
|
try:
|
||||||
name = community["community"]["name"]
|
name = community["community"]["icon"].split("/")[-1]
|
||||||
urllib.request.urlretrieve(community["community"]["icon"], f"/tmp/{name}.png")
|
urllib.request.urlretrieve(community["community"]["icon"], f"/tmp/{name}")
|
||||||
avatar.set_custom_image(Gdk.Texture.new_from_file(Gio.File.new_for_path(f"/tmp/{name}.png")))
|
avatar.set_custom_image(Gdk.Texture.new_from_file(Gio.File.new_for_path(f"/tmp/{name}")))
|
||||||
except urllib.error.HTTPError as e:
|
except:
|
||||||
print(f"Error while downloading icon: {e}")
|
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
@@ -121,6 +121,7 @@ class Lemonade(Adw.Application):
|
|||||||
self.win = LemonadeWindow(application=app)
|
self.win = LemonadeWindow(application=app)
|
||||||
self.win.present()
|
self.win.present()
|
||||||
|
|
||||||
app = Lemonade(application_id="ml.mdwalters.Lemonade")
|
def main(version):
|
||||||
app.run(sys.argv)
|
app = Lemonade(application_id="ml.mdwalters.Lemonade")
|
||||||
|
app.run(sys.argv)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user