Add dpi setting for launchpad

This commit is contained in:
daleclack 2024-09-22 20:34:45 +08:00
parent 7575e34a65
commit 4ea4e513d1
4 changed files with 70 additions and 28 deletions

View File

@ -245,7 +245,7 @@
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="image8">
<object class="GtkImage" id="padabout_image">
<property name="hexpand">0</property>
<property name="vexpand">0</property>
<property name="pixel-size">48</property>
@ -278,7 +278,7 @@
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="image10">
<object class="GtkImage" id="padaud_image">
<property name="pixel-size">48</property>
<property name="icon-name">audacious_whitesur</property>
</object>
@ -306,7 +306,7 @@
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="image9">
<object class="GtkImage" id="paddraw_image">
<property name="pixel-size">48</property>
<property name="icon-name">drawing_app</property>
</object>
@ -334,7 +334,7 @@
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="image11">
<object class="GtkImage" id="padfile_image">
<property name="pixel-size">48</property>
<property name="icon-name">file-app</property>
</object>
@ -362,7 +362,7 @@
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="image12">
<object class="GtkImage" id="padgedit_image">
<property name="pixel-size">48</property>
<property name="icon-name">my_textedit</property>
</object>
@ -390,7 +390,7 @@
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="image13">
<object class="GtkImage" id="padgame_image">
<property name="pixel-size">48</property>
<property name="icon-name">game</property>
</object>
@ -418,7 +418,7 @@
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="image14">
<object class="GtkImage" id="padimage_image">
<property name="pixel-size">48</property>
<property name="icon-name">image_app</property>
</object>
@ -446,7 +446,7 @@
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="image15">
<object class="GtkImage" id="padnote_image">
<property name="pixel-size">48</property>
<property name="icon-name">my_textedit</property>
</object>
@ -474,7 +474,7 @@
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="image16">
<object class="GtkImage" id="padedit_image">
<property name="pixel-size">48</property>
<property name="icon-name">my_textedit</property>
</object>
@ -502,7 +502,7 @@
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="image17">
<object class="GtkImage" id="padvlc_image">
<property name="pixel-size">48</property>
<property name="icon-name">vlc_whitesur</property>
</object>
@ -530,7 +530,7 @@
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="image18">
<object class="GtkImage" id="padvlc_win32_image">
<property name="pixel-size">48</property>
<property name="icon-name">vlc_whitesur</property>
</object>
@ -558,7 +558,7 @@
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="image19">
<object class="GtkImage" id="padrun_image">
<property name="pixel-size">48</property>
<property name="icon-name">myrunner</property>
</object>
@ -586,7 +586,7 @@
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="image20">
<object class="GtkImage" id="padset_image">
<property name="pixel-size">48</property>
<property name="icon-name">my_prefs</property>
</object>
@ -614,7 +614,7 @@
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="image22">
<object class="GtkImage" id="padgame24_image">
<property name="pixel-size">48</property>
<property name="icon-name">24game</property>
</object>
@ -642,7 +642,7 @@
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="image24">
<object class="GtkImage" id="padcalc_image">
<property name="pixel-size">48</property>
<property name="icon-name">calcapp</property>
</object>
@ -670,7 +670,7 @@
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="image27">
<object class="GtkImage" id="padmine_image">
<property name="icon-name">mines_app</property>
<property name="pixel-size">48</property>
</object>
@ -698,7 +698,7 @@
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
<object class="GtkImage" id="image28">
<object class="GtkImage" id="padmedia_image">
<property name="icon-name">media-app</property>
<property name="pixel-size">48</property>
</object>

View File

@ -1,5 +1,7 @@
#include "AppView.h"
static double dpi_value;
// Create a model for application
static GListModel *create_app_model()
{
@ -31,7 +33,7 @@ static void app_ext_view_setup(GtkListItemFactory *factory, GtkListItem *item)
app_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
image = gtk_image_new();
label = gtk_label_new(" ");
gtk_image_set_pixel_size(GTK_IMAGE(image), 40);
gtk_image_set_pixel_size(GTK_IMAGE(image), 36 * dpi_value);
gtk_widget_set_size_request(label, 76, 12);
gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_END);
@ -101,12 +103,14 @@ static void app_view_activate(GtkGridView *list, guint position, gpointer data)
g_object_unref(app_info);
}
GtkWidget *app_view_new(gboolean external)
GtkWidget *app_view_new(gboolean external, double dpi)
{
GtkWidget *list, *sw;
GListModel *model;
GtkListItemFactory *factory;
dpi_value = dpi;
// Create widgets
sw = gtk_scrolled_window_new();
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),

View File

@ -2,4 +2,4 @@
#include <gtk/gtk.h>
GtkWidget *app_view_new(gboolean external);
GtkWidget *app_view_new(gboolean external, double dpi);

View File

@ -46,6 +46,10 @@ struct _MyDock
GtkWidget *padabout, *padaud, *paddraw, *padfile, *padgedit, // Launchpad icons
*padgame, *padimage, *padnote, *padedit, *padvlc, *padvlc_win32,
*padrun, *padset, *padgame24, *padcalc, *padmine, *padmedia;
GtkWidget *padabout_image, *padaud_image, *paddraw_image, *padfile_image, // Launchpad icon images
*padgedit_image, *padgame_image, *padimage_image, *padnote_image,
*padedit_image, *padvlc_image, *padvlc_win32_image, *padrun_image,
*padset_image, *padgame24_image, *padcalc_image, *padmine_image, *padmedia_image;
PadPage current_page;
GtkBuilder *menu_builder;
GMenuModel *menu_model;
@ -162,7 +166,7 @@ static void my_dock_set_icon_name(MyDock *dock, GtkImage *image, const char *ico
char icon_name[NAME_MAX];
// Set icon with dock position setting
DockPos dock_pos = my_prefs_get_dock_pos(dock->prefs_win);
switch(dock_pos)
switch (dock_pos)
{
case DockPos::Pos_Left:
snprintf(icon_name, NAME_MAX - 1, "%s_running", icon_name1);
@ -676,6 +680,23 @@ static void my_dock_apply_dpi(MyDock *self, double dpi)
gtk_image_set_pixel_size(GTK_IMAGE(self->image_set), 40 * dpi);
gtk_image_set_pixel_size(GTK_IMAGE(self->image_media), 40 * dpi);
gtk_image_set_pixel_size(GTK_IMAGE(self->image_trash), 40 * dpi);
gtk_image_set_pixel_size(GTK_IMAGE(self->padabout_image), 40 * dpi);
gtk_image_set_pixel_size(GTK_IMAGE(self->padaud_image), 40 * dpi);
gtk_image_set_pixel_size(GTK_IMAGE(self->padcalc_image), 40 * dpi);
gtk_image_set_pixel_size(GTK_IMAGE(self->paddraw_image), 40 * dpi);
gtk_image_set_pixel_size(GTK_IMAGE(self->padedit_image), 40 * dpi);
gtk_image_set_pixel_size(GTK_IMAGE(self->padfile_image), 40 * dpi);
gtk_image_set_pixel_size(GTK_IMAGE(self->padgame24_image), 40 * dpi);
gtk_image_set_pixel_size(GTK_IMAGE(self->padgame_image), 40 * dpi);
gtk_image_set_pixel_size(GTK_IMAGE(self->padgedit_image), 40 * dpi);
gtk_image_set_pixel_size(GTK_IMAGE(self->padimage_image), 40 * dpi);
gtk_image_set_pixel_size(GTK_IMAGE(self->padmedia_image), 40 * dpi);
gtk_image_set_pixel_size(GTK_IMAGE(self->padmine_image), 40 * dpi);
gtk_image_set_pixel_size(GTK_IMAGE(self->padnote_image), 40 * dpi);
gtk_image_set_pixel_size(GTK_IMAGE(self->padrun_image), 40 * dpi);
gtk_image_set_pixel_size(GTK_IMAGE(self->padset_image), 40 * dpi);
gtk_image_set_pixel_size(GTK_IMAGE(self->padvlc_image), 40 * dpi);
gtk_image_set_pixel_size(GTK_IMAGE(self->padvlc_win32_image), 40 * dpi);
}
static void my_dock_get_widgets(MyDock *self)
@ -736,6 +757,23 @@ static void my_dock_get_widgets(MyDock *self)
self->padset = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "padset"));
self->padvlc = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "padvlc"));
self->padvlc_win32 = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "padvlc_win32"));
self->padaud_image = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "padaud_image"));
self->padabout_image = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "padabout_image"));
self->padcalc_image = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "padcalc_image"));
self->paddraw_image = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "paddraw_image"));
self->padedit_image = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "padedit_image"));
self->padfile_image = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "padfile_image"));
self->padgame24_image = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "padgame24_image"));
self->padgame_image = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "padgame_image"));
self->padgedit_image = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "padgedit_image"));
self->padimage_image = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "padimage_image"));
self->padmine_image = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "padmine_image"));
self->padmedia_image = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "padmedia_image"));
self->padnote_image = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "padnote_image"));
self->padrun_image = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "padrun_image"));
self->padset_image = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "padset_image"));
self->padvlc_image = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "padvlc_image"));
self->padvlc_win32_image = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "padvlc_win32_image"));
// Hide ScrollBar for icons scrolled window
GtkWidget *scrollbar = gtk_scrolled_window_get_vscrollbar(GTK_SCROLLED_WINDOW(self->icons_sw));
@ -906,6 +944,11 @@ static void my_dock_init(MyDock *self)
// Add Style for finder
my_finder_add_style(MY_FINDER(self->finder), provider);
// Apply DPI Setting for the dock and the finder
double dpi_value = my_prefs_get_dpi_value(self->prefs_win);
my_dock_apply_dpi(self, dpi_value);
my_finder_apply_dpi(MY_FINDER(self->finder), dpi_value);
// Add Apps grid
// To make the default view layout same as the addon apps view
self->appgrid_box = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);
@ -917,7 +960,7 @@ static void my_dock_init(MyDock *self)
gtk_grid_set_row_spacing(GTK_GRID(self->apps_grid), 20);
// Add Addon apps view
self->apps_view = app_view_new(TRUE);
self->apps_view = app_view_new(TRUE, dpi_value);
gtk_box_append(GTK_BOX(self->addon_box), self->apps_view);
gtk_widget_set_halign(self->addon_box, GTK_ALIGN_CENTER);
gtk_widget_set_halign(self->apps_view, GTK_ALIGN_CENTER);
@ -974,11 +1017,6 @@ static void my_dock_init(MyDock *self)
gtk_style_context_add_provider_for_display(gtk_widget_get_display(self->context_menu),
GTK_STYLE_PROVIDER(provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
// Apply DPI Setting for the dock and the finder
double dpi_value = my_prefs_get_dpi_value(self->prefs_win);
my_dock_apply_dpi(self, dpi_value);
my_finder_apply_dpi(MY_FINDER(self->finder), dpi_value);
}
static void my_dock_class_init(MyDockClass *klass)