Skip to content

Commit

Permalink
better scale support for userlist
Browse files Browse the repository at this point in the history
  • Loading branch information
sulincix committed Nov 26, 2024
1 parent 6af296c commit 6bfecbd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
4 changes: 1 addition & 3 deletions src/data/main.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1768,7 +1768,7 @@ WAN IP: </property>
<property name="relative-to">ui_button_userselect</property>
<property name="position">right</property>
<child>
<object class="GtkBox">
<object class="GtkBox" id="ui_box_userlist_main">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
Expand All @@ -1791,7 +1791,6 @@ WAN IP: </property>
</child>
<child>
<object class="GtkScrolledWindow" id="ui_scrolledwindow_userlist">
<property name="width-request">200</property>
<property name="height-request">-1</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
Expand All @@ -1802,7 +1801,6 @@ WAN IP: </property>
<property name="can-focus">False</property>
<child>
<object class="GtkBox" id="ui_box_userlist">
<property name="width-request">200</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
Expand Down
22 changes: 12 additions & 10 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@
def _(msg):
return msg

scale = float(get("scale", "0"))
if scale < 1:
scale = 1

os.environ["GDK_SCALE"] = str(int(scale))
#os.environ["GDK_DPI_SCALE"] = str(1/scale)

os.environ["UBUNTU_MENUPROXY"] = ""
os.environ["SESSION_MANAGER"] = "lightdm"
Expand Down Expand Up @@ -63,10 +57,18 @@ def _(msg):
else:
settings.set_property("gtk-icon-theme-name", "Adwaita")

settings.set_property(
"gtk-font-name", "{} {}".format(get("font", "Regular"), int(10*(scale % 1 + 1))))
settings.set_property("gtk-xft-dpi", 1024*96*scale)
settings.set_property("gtk-xft-antialias", True)
def set_scale(scale=0):
if scale <= 0:
scale = 1
os.environ["GDK_SCALE"] = str(int(scale))
#os.environ["GDK_DPI_SCALE"] = str(1/scale)
settings.set_property(
"gtk-font-name", "{} {}".format(get("font", "Regular"), int(10*(scale % 1 + 1))))
settings.set_property("gtk-xft-dpi", 1024*96*scale)
settings.set_property("gtk-xft-antialias", True)

scale = float(get("scale", "0"))
set_scale(scale)

loaded_modules = []
base_modules = ["lightdm.py", "gtkwindow.py", "monitor.py"]
Expand Down
4 changes: 2 additions & 2 deletions src/module/gtkwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ def apply_scale(self):
"ui_entry_new_password1", "ui_entry_new_password2", "ui_box_reset_buttons"]:
self.o(but).set_size_request(128*scale, 31*scale)
# user list
self.o("ui_popover_userlist").set_size_request(200*scale, self.height/3)
self.o("ui_box_userlist_main").set_size_request(250*scale, self.height/3)
self.o("ui_popover_userlist").set_size_request(250*scale, self.height/3)

############### css load ###############

Expand Down Expand Up @@ -435,7 +436,6 @@ def sync_resolution(self):
self.update_user_background()
else:
self.set_background(get("background", "user", "gtkwindow"))
self.o("ui_popover_userlist").set_size_request(250, self.height/3)
self.apply_scale()

############### windowmanager ###############
Expand Down

0 comments on commit 6bfecbd

Please sign in to comment.