geany-plugins
geany-plugins copied to clipboard
commander: hidpi scaling?
I recently started using a 4k setup, doubling my font dpi, and noticed that the commander popup is still the same size as with a lower resolution, meaning that it can only show 2 entries. Any chance this could be scaled a bit?
Currently it's hard-coded to a 500×200 default size, and if resized the new size doesn't survives a Geany restart. There's 3 things I could do:
- adapt that default size to the display scale (which is not the DPI)
- adapt to the height of a line, but that's tricky to compute
- allow configuration (or at least, restoring) default size
First option seems easy enough, and see below for a test patch. Option 2 is probably best, but is clearly the most complicated of all. Option 3 would be fairly easy, but I'm not sure if it's really practical.
Here's the patch for solution 1 (untested, as I don't have a HiDPI monitor at hand). Note that this requires a Geany GTK3 build with GTK >= 3.10 (fairly old by now) and you having set the scaling factor rather than just raised the DPI through the roof.
diff --git a/commander/src/commander-plugin.c b/commander/src/commander-plugin.c
index 9f8d0718..a138ec41 100644
--- a/commander/src/commander-plugin.c
+++ b/commander/src/commander-plugin.c
@@ -654,11 +654,16 @@ create_panel (void)
GtkWidget *scroll;
GtkTreeViewColumn *col;
GtkCellRenderer *cell;
+ gint scale = 1;
+
+#if GTK_CHECK_VERSION (3, 10)
+ scale = gtk_widget_get_scale_factor (geany_data->main_widgets->window);
+#endif
plugin_data.panel = g_object_new (GTK_TYPE_WINDOW,
"decorated", FALSE,
- "default-width", 500,
- "default-height", 200,
+ "default-width", 500 * scale,
+ "default-height", 200 * scale,
"transient-for", geany_data->main_widgets->window,
"window-position", GTK_WIN_POS_CENTER_ON_PARENT,
"type-hint", GDK_WINDOW_TYPE_HINT_DIALOG,
Sorry for the delay. I can confirm that this works perfectly :thumbsup:
GTK_CHECK_VERSION() requires 3 args though, so probably you meant to add another , 0 in there :)
thanks!
hm actually though, there is a problem here: if I set GDK_SCALE instead of the usual Xft.dpi doubling, geany doesn't pick up the increased font size for the main editor and everything is tiny.
setting both GDK_SCALE and doubling Xft.dpi creates the same problem in the original issue, however, so I think more work is needed here...