summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCosimo Cecchi <[email protected]>2013-08-02 14:37:13 +0200
committerraveit65 <[email protected]>2018-04-05 09:07:22 +0200
commit4bf67ac8fff8555bf784d8cd7e1611829a9fca44 (patch)
tree343275a74d64866035b0850d5583c83eb20fe486 /src
parent35c4dc6021f36a5fc7df94b0332c7e5d6fa00d0a (diff)
downloadcaja-4bf67ac8fff8555bf784d8cd7e1611829a9fca44.tar.bz2
caja-4bf67ac8fff8555bf784d8cd7e1611829a9fca44.tar.xz
Support HiDpi icons
Port the rendering of icons to cairo surfaces, so that we can apply the GDK scale factor when rendering icons. origin commit: https://gitlab.gnome.org/GNOME/nautilus/commit/0d4555d7
Diffstat (limited to 'src')
-rw-r--r--src/caja-autorun-software.c3
-rw-r--r--src/caja-desktop-window.c3
-rw-r--r--src/caja-emblem-sidebar.c11
-rw-r--r--src/caja-file-management-properties.c5
-rw-r--r--src/caja-navigation-window.c3
-rw-r--r--src/caja-notes-viewer.c4
-rw-r--r--src/caja-pathbar.c23
-rw-r--r--src/caja-places-sidebar.c9
-rw-r--r--src/caja-property-browser.c8
-rw-r--r--src/caja-sidebar-title.c5
-rw-r--r--src/caja-spatial-window.c6
-rw-r--r--src/caja-window-menus.c2
-rw-r--r--src/caja-window-toolbars.c2
-rw-r--r--src/caja-x-content-bar.c5
-rw-r--r--src/file-manager/fm-desktop-icon-view.c7
-rw-r--r--src/file-manager/fm-directory-view.c32
-rw-r--r--src/file-manager/fm-icon-container.c5
-rw-r--r--src/file-manager/fm-list-model.c38
-rw-r--r--src/file-manager/fm-list-view.c14
-rw-r--r--src/file-manager/fm-properties-window.c23
-rw-r--r--src/file-manager/fm-tree-model.c10
21 files changed, 155 insertions, 63 deletions
diff --git a/src/caja-autorun-software.c b/src/caja-autorun-software.c
index 8bd4514d..4e24fa80 100644
--- a/src/caja-autorun-software.c
+++ b/src/caja-autorun-software.c
@@ -230,7 +230,8 @@ present_autorun_for_software_dialog (GMount *mount)
icon = g_mount_get_icon (mount);
icon_size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_DIALOG);
- icon_info = caja_icon_info_lookup (icon, icon_size);
+ icon_info = caja_icon_info_lookup (icon, icon_size,
+ gtk_widget_get_scale_factor (GTK_WIDGET (dialog)));
pixbuf = caja_icon_info_get_pixbuf_at_size (icon_info, icon_size);
image = gtk_image_new_from_pixbuf (pixbuf);
gtk_widget_set_halign (image, GTK_ALIGN_CENTER);
diff --git a/src/caja-desktop-window.c b/src/caja-desktop-window.c
index aae03b5e..2aa0c2f5 100644
--- a/src/caja-desktop-window.c
+++ b/src/caja-desktop-window.c
@@ -268,7 +268,8 @@ static CajaIconInfo *
real_get_icon (CajaWindow *window,
CajaWindowSlot *slot)
{
- return caja_icon_info_lookup_from_name (CAJA_ICON_DESKTOP, 48);
+ gint scale = gtk_widget_get_scale_factor (GTK_WIDGET (window));
+ return caja_icon_info_lookup_from_name (CAJA_ICON_DESKTOP, 48, scale);
}
static void
diff --git a/src/caja-emblem-sidebar.c b/src/caja-emblem-sidebar.c
index 0c5b0056..a1c7f573 100644
--- a/src/caja-emblem-sidebar.c
+++ b/src/caja-emblem-sidebar.c
@@ -386,14 +386,15 @@ create_emblem_widget_with_pixbuf (CajaEmblemSidebar *emblem_sidebar,
{
GtkWidget *image, *event_box;
GdkPixbuf *prelight_pixbuf;
-
+ gint scale;
image = eel_labeled_image_new (display_name, pixbuf);
+ scale = gtk_widget_get_scale_factor (image);
eel_labeled_image_set_fixed_image_height (EEL_LABELED_IMAGE (image),
- STANDARD_EMBLEM_HEIGHT);
+ STANDARD_EMBLEM_HEIGHT * scale);
eel_labeled_image_set_spacing (EEL_LABELED_IMAGE (image),
- EMBLEM_LABEL_SPACING);
+ EMBLEM_LABEL_SPACING * scale);
event_box = gtk_event_box_new ();
gtk_container_add (GTK_CONTAINER (event_box), image);
@@ -449,8 +450,10 @@ create_emblem_widget (CajaEmblemSidebar *emblem_sidebar,
char *keyword;
GdkPixbuf *pixbuf;
CajaIconInfo *info;
+ gint scale;
- info = caja_icon_info_lookup_from_name (name, CAJA_ICON_SIZE_STANDARD);
+ scale = gtk_widget_get_scale_factor (GTK_WIDGET (emblem_sidebar->details->emblems_table));
+ info = caja_icon_info_lookup_from_name (name, CAJA_ICON_SIZE_STANDARD, scale);
pixbuf = caja_icon_info_get_pixbuf_at_size (info, CAJA_ICON_SIZE_STANDARD);
diff --git a/src/caja-file-management-properties.c b/src/caja-file-management-properties.c
index 7800c7a4..dc687688 100644
--- a/src/caja-file-management-properties.c
+++ b/src/caja-file-management-properties.c
@@ -735,7 +735,7 @@ caja_file_management_properties_dialog_setup_media_page (GtkBuilder *builder)
GIcon *icon;
CajaIconInfo *icon_info;
GdkPixbuf *pixbuf;
- int icon_size;
+ int icon_size, icon_scale;
if (!g_str_has_prefix (content_type, "x-content/"))
continue;
@@ -748,13 +748,14 @@ caja_file_management_properties_dialog_setup_media_page (GtkBuilder *builder)
}
icon_size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
+ icon_scale = gtk_widget_get_scale_factor (other_type_combo_box);
description = g_content_type_get_description (content_type);
gtk_list_store_append (other_type_list_store, &iter);
icon = g_content_type_get_icon (content_type);
if (icon != NULL)
{
- icon_info = caja_icon_info_lookup (icon, icon_size);
+ icon_info = caja_icon_info_lookup (icon, icon_size, icon_scale);
g_object_unref (icon);
pixbuf = caja_icon_info_get_pixbuf_nodefault_at_size (icon_info, icon_size);
g_object_unref (icon_info);
diff --git a/src/caja-navigation-window.c b/src/caja-navigation-window.c
index 08a7704b..531c9ae0 100644
--- a/src/caja-navigation-window.c
+++ b/src/caja-navigation-window.c
@@ -756,7 +756,8 @@ static CajaIconInfo *
real_get_icon (CajaWindow *window,
CajaWindowSlot *slot)
{
- return caja_file_get_icon (slot->viewed_file, 48,
+ return caja_file_get_icon (slot->viewed_file,
+ 48, gtk_widget_get_scale_factor (GTK_WIDGET (window)),
CAJA_FILE_ICON_FLAGS_IGNORE_VISITING |
CAJA_FILE_ICON_FLAGS_USE_MOUNT_ICON);
}
diff --git a/src/caja-notes-viewer.c b/src/caja-notes-viewer.c
index b479cc56..46ffdeae 100644
--- a/src/caja-notes-viewer.c
+++ b/src/caja-notes-viewer.c
@@ -324,13 +324,15 @@ caja_notes_viewer_init (CajaNotesViewer *sidebar)
{
CajaNotesViewerDetails *details;
CajaIconInfo *info;
+ gint scale;
details = g_new0 (CajaNotesViewerDetails, 1);
sidebar->details = details;
details->uri = g_strdup ("");
- info = caja_icon_info_lookup_from_name ("emblem-note", 16);
+ scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
+ info = caja_icon_info_lookup_from_name ("emblem-note", 16, scale);
details->icon = caja_icon_info_get_pixbuf (info);
/* create the text container */
diff --git a/src/caja-pathbar.c b/src/caja-pathbar.c
index 863e0623..533f2f7f 100644
--- a/src/caja-pathbar.c
+++ b/src/caja-pathbar.c
@@ -206,8 +206,10 @@ trash_state_changed_cb (CajaTrashMonitor *monitor,
{
GFile *file;
GList *list;
+ gint scale;
file = g_file_new_for_uri ("trash:///");
+ scale = gtk_widget_get_scale_factor (GTK_WIDGET (path_bar));
for (list = path_bar->button_list; list; list = list->next)
{
ButtonData *button_data;
@@ -219,7 +221,7 @@ trash_state_changed_cb (CajaTrashMonitor *monitor,
GdkPixbuf *pixbuf;
icon = caja_trash_monitor_get_icon ();
- icon_info = caja_icon_info_lookup (icon, CAJA_PATH_BAR_ICON_SIZE);
+ icon_info = caja_icon_info_lookup (icon, CAJA_PATH_BAR_ICON_SIZE, scale);
pixbuf = caja_icon_info_get_pixbuf_at_size (icon_info, CAJA_PATH_BAR_ICON_SIZE);
gtk_image_set_from_pixbuf (GTK_IMAGE (button_data->image), pixbuf);
}
@@ -1339,25 +1341,30 @@ button_clicked_cb (GtkWidget *button,
static CajaIconInfo *
get_type_icon_info (ButtonData *button_data)
{
+ gint icon_scale = gtk_widget_get_scale_factor (GTK_WIDGET (button_data->button));
+
switch (button_data->type)
{
case ROOT_BUTTON:
return caja_icon_info_lookup_from_name (CAJA_ICON_FILESYSTEM,
- CAJA_PATH_BAR_ICON_SIZE);
+ CAJA_PATH_BAR_ICON_SIZE,
+ icon_scale);
case HOME_BUTTON:
return caja_icon_info_lookup_from_name (CAJA_ICON_HOME,
- CAJA_PATH_BAR_ICON_SIZE);
+ CAJA_PATH_BAR_ICON_SIZE,
+ icon_scale);
case DESKTOP_BUTTON:
return caja_icon_info_lookup_from_name (CAJA_ICON_DESKTOP,
- CAJA_PATH_BAR_ICON_SIZE);
+ CAJA_PATH_BAR_ICON_SIZE,
+ icon_scale);
case NORMAL_BUTTON:
if (button_data->is_base_dir)
{
return caja_file_get_icon (button_data->file,
- CAJA_PATH_BAR_ICON_SIZE,
+ CAJA_PATH_BAR_ICON_SIZE, icon_scale,
CAJA_FILE_ICON_FLAGS_NONE);
}
@@ -1529,10 +1536,12 @@ setup_file_path_mounted_mount (GFile *location, ButtonData *button_data)
GIcon *icon;
CajaIconInfo *info;
GFile *root, *default_location;
+ gint scale;
result = FALSE;
volume_monitor = g_volume_monitor_get ();
mounts = g_volume_monitor_get_mounts (volume_monitor);
+ scale = gtk_widget_get_scale_factor (GTK_WIDGET (button_data->button));
for (l = mounts; l != NULL; l = l->next)
{
mount = l->data;
@@ -1556,7 +1565,7 @@ setup_file_path_mounted_mount (GFile *location, ButtonData *button_data)
{
icon = g_themed_icon_new (CAJA_ICON_FOLDER);
}
- info = caja_icon_info_lookup (icon, CAJA_PATH_BAR_ICON_SIZE);
+ info = caja_icon_info_lookup (icon, CAJA_PATH_BAR_ICON_SIZE, scale);
g_object_unref (icon);
button_data->custom_icon = caja_icon_info_get_pixbuf_at_size (info, CAJA_PATH_BAR_ICON_SIZE);
g_object_unref (info);
@@ -1580,7 +1589,7 @@ setup_file_path_mounted_mount (GFile *location, ButtonData *button_data)
{
icon = g_themed_icon_new (CAJA_ICON_FOLDER);
}
- info = caja_icon_info_lookup (icon, CAJA_PATH_BAR_ICON_SIZE);
+ info = caja_icon_info_lookup (icon, CAJA_PATH_BAR_ICON_SIZE, scale);
g_object_unref (icon);
button_data->custom_icon = caja_icon_info_get_pixbuf_at_size (info, CAJA_PATH_BAR_ICON_SIZE);
g_object_unref (info);
diff --git a/src/caja-places-sidebar.c b/src/caja-places-sidebar.c
index 9d081f6d..49ca3e56 100644
--- a/src/caja-places-sidebar.c
+++ b/src/caja-places-sidebar.c
@@ -233,11 +233,12 @@ get_eject_icon (gboolean highlighted)
{
GdkPixbuf *eject;
CajaIconInfo *eject_icon_info;
- int icon_size;
+ int icon_size, icon_scale;
icon_size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
+ icon_scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
- eject_icon_info = caja_icon_info_lookup_from_name ("media-eject", icon_size);
+ eject_icon_info = caja_icon_info_lookup_from_name ("media-eject", icon_size, icon_scale);
eject = caja_icon_info_get_pixbuf_at_size (eject_icon_info, icon_size);
if (highlighted) {
@@ -342,6 +343,7 @@ add_place (CajaPlacesSidebar *sidebar,
GdkPixbuf *eject;
CajaIconInfo *icon_info;
int icon_size;
+ int icon_scale;
gboolean show_eject;
gboolean show_unmount;
gboolean show_eject_button;
@@ -349,7 +351,8 @@ add_place (CajaPlacesSidebar *sidebar,
check_heading_for_section (sidebar, section_type);
icon_size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
- icon_info = caja_icon_info_lookup (icon, icon_size);
+ icon_scale = gtk_widget_get_scale_factor (GTK_WIDGET (sidebar));
+ icon_info = caja_icon_info_lookup (icon, icon_size, icon_scale);
pixbuf = caja_icon_info_get_pixbuf_at_size (icon_info, icon_size);
g_object_unref (icon_info);
diff --git a/src/caja-property-browser.c b/src/caja-property-browser.c
index 09233e9c..90bcff16 100644
--- a/src/caja-property-browser.c
+++ b/src/caja-property-browser.c
@@ -722,6 +722,7 @@ make_drag_image (CajaPropertyBrowser *property_browser, const char* file_name)
char *icon_name;
gboolean is_reset;
CajaIconInfo *info;
+ gint icon_scale;
if (property_browser->details->category_type == CAJA_PROPERTY_EMBLEM)
{
@@ -739,7 +740,8 @@ make_drag_image (CajaPropertyBrowser *property_browser, const char* file_name)
else
{
icon_name = caja_emblem_get_icon_name_from_keyword (file_name);
- info = caja_icon_info_lookup_from_name (icon_name, CAJA_ICON_SIZE_STANDARD);
+ icon_scale = gtk_widget_get_scale_factor (GTK_WIDGET (property_browser->details->content_table));
+ info = caja_icon_info_lookup_from_name (icon_name, CAJA_ICON_SIZE_STANDARD, icon_scale);
pixbuf = caja_icon_info_get_pixbuf_at_size (info, CAJA_ICON_SIZE_STANDARD);
g_object_unref (info);
g_free (icon_name);
@@ -1795,6 +1797,7 @@ make_properties_from_directories (CajaPropertyBrowser *property_browser)
guint num_images;
char *path;
CajaIconInfo *info;
+ gint icon_scale;
g_return_if_fail (CAJA_IS_PROPERTY_BROWSER (property_browser));
g_return_if_fail (EEL_IS_IMAGE_TABLE (property_browser->details->content_table));
@@ -1807,6 +1810,7 @@ make_properties_from_directories (CajaPropertyBrowser *property_browser)
property_browser->details->keywords = NULL;
icons = caja_emblem_list_available ();
+ icon_scale = gtk_widget_get_scale_factor (GTK_WIDGET (property_browser->details->content_table));
property_browser->details->has_local = FALSE;
l = icons;
@@ -1830,7 +1834,7 @@ make_properties_from_directories (CajaPropertyBrowser *property_browser)
g_free (object_name);
continue;
}
- info = caja_icon_info_lookup_from_name (icon_name, CAJA_ICON_SIZE_STANDARD);
+ info = caja_icon_info_lookup_from_name (icon_name, CAJA_ICON_SIZE_STANDARD, icon_scale);
object_pixbuf = caja_icon_info_get_pixbuf_at_size (info, CAJA_ICON_SIZE_STANDARD);
object_label = g_strdup (caja_icon_info_get_display_name (info));
g_object_unref (info);
diff --git a/src/caja-sidebar-title.c b/src/caja-sidebar-title.c
index 372e7ee1..3b257230 100644
--- a/src/caja-sidebar-title.c
+++ b/src/caja-sidebar-title.c
@@ -356,16 +356,18 @@ update_icon (CajaSidebarTitle *sidebar_title)
CajaIconInfo *info;
char *icon_name;
gboolean leave_pixbuf_unchanged;
+ gint icon_scale;
leave_pixbuf_unchanged = FALSE;
/* see if the current content view is specifying an icon */
icon_name = get_property_from_component (sidebar_title, "icon_name");
+ icon_scale = gtk_widget_get_scale_factor (GTK_WIDGET (sidebar_title));
pixbuf = NULL;
if (icon_name != NULL && icon_name[0] != '\0')
{
- info = caja_icon_info_lookup_from_name (icon_name, CAJA_ICON_SIZE_LARGE);
+ info = caja_icon_info_lookup_from_name (icon_name, CAJA_ICON_SIZE_LARGE, icon_scale);
pixbuf = caja_icon_info_get_pixbuf_at_size (info, CAJA_ICON_SIZE_LARGE);
g_object_unref (info);
}
@@ -376,6 +378,7 @@ update_icon (CajaSidebarTitle *sidebar_title)
pixbuf = caja_file_get_icon_pixbuf (sidebar_title->details->file,
sidebar_title->details->best_icon_size,
TRUE,
+ icon_scale,
CAJA_FILE_ICON_FLAGS_USE_THUMBNAILS |
CAJA_FILE_ICON_FLAGS_USE_MOUNT_ICON_AS_EMBLEM);
}
diff --git a/src/caja-spatial-window.c b/src/caja-spatial-window.c
index 6d3d0112..22a0dd74 100644
--- a/src/caja-spatial-window.c
+++ b/src/caja-spatial-window.c
@@ -356,7 +356,8 @@ static CajaIconInfo *
real_get_icon (CajaWindow *window,
CajaWindowSlot *slot)
{
- return caja_file_get_icon (slot->viewed_file, 48,
+ return caja_file_get_icon (slot->viewed_file,
+ 48, gtk_widget_get_scale_factor (GTK_WIDGET (window)),
CAJA_FILE_ICON_FLAGS_IGNORE_VISITING |
CAJA_FILE_ICON_FLAGS_USE_MOUNT_ICON);
}
@@ -581,6 +582,7 @@ got_file_info_for_location_menu_callback (CajaFile *file,
pixbuf = caja_file_get_icon_pixbuf (file,
caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU),
TRUE,
+ gtk_widget_get_scale_factor (GTK_WIDGET (menu_item)),
CAJA_FILE_ICON_FLAGS_IGNORE_VISITING);
if (pixbuf != NULL)
@@ -785,6 +787,7 @@ location_button_drag_begin_callback (GtkWidget *widget,
pixbuf = caja_file_get_icon_pixbuf (slot->viewed_file,
get_dnd_icon_size (window),
FALSE,
+ gtk_widget_get_scale_factor (widget),
CAJA_FILE_ICON_FLAGS_IGNORE_VISITING | CAJA_FILE_ICON_FLAGS_FOR_DRAG_ACCEPT);
gtk_drag_set_icon_pixbuf (context, pixbuf, 0, 0);
@@ -862,6 +865,7 @@ caja_spatial_window_set_location_button (CajaSpatialWindow *window,
pixbuf = caja_file_get_icon_pixbuf (file,
caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU),
TRUE,
+ gtk_widget_get_scale_factor (window->details->location_button),
CAJA_FILE_ICON_FLAGS_IGNORE_VISITING);
if (pixbuf != NULL)
diff --git a/src/caja-window-menus.c b/src/caja-window-menus.c
index 8eefea3e..0cf325dc 100644
--- a/src/caja-window-menus.c
+++ b/src/caja-window-menus.c
@@ -1051,7 +1051,7 @@ add_extension_menu_items (CajaWindow *window,
g_object_get (item, "menu", &menu, NULL);
- action = caja_action_from_menu_item (item);
+ action = caja_action_from_menu_item (item, GTK_WIDGET (window));
gtk_action_group_add_action_with_accel (action_group, action, NULL);
path = g_build_path ("/", POPUP_PATH_EXTENSION_ACTIONS, subdirectory, NULL);
diff --git a/src/caja-window-toolbars.c b/src/caja-window-toolbars.c
index 0ad576fa..1611e16e 100644
--- a/src/caja-window-toolbars.c
+++ b/src/caja-window-toolbars.c
@@ -181,7 +181,7 @@ caja_navigation_window_load_extension_toolbar_items (CajaNavigationWindow *windo
{
item = CAJA_MENU_ITEM (l->data);
- action = caja_toolbar_action_from_menu_item (item);
+ action = caja_toolbar_action_from_menu_item (item, GTK_WIDGET (window));
gtk_action_group_add_action (action_group,
GTK_ACTION (action));
diff --git a/src/caja-x-content-bar.c b/src/caja-x-content-bar.c
index 0e2c916d..e38c75d8 100644
--- a/src/caja-x-content-bar.c
+++ b/src/caja-x-content-bar.c
@@ -130,10 +130,11 @@ caja_x_content_bar_set_x_content_type (CajaXContentBar *bar, const char *x_conte
if (icon != NULL)
{
GdkPixbuf *pixbuf;
- int icon_size;
+ int icon_size, icon_scale;
CajaIconInfo *icon_info;
icon_size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_BUTTON);
- icon_info = caja_icon_info_lookup (icon, icon_size);
+ icon_scale = gtk_widget_get_scale_factor (GTK_WIDGET (bar));
+ icon_info = caja_icon_info_lookup (icon, icon_size, icon_scale);
pixbuf = caja_icon_info_get_pixbuf_at_size (icon_info, icon_size);
image = gtk_image_new_from_pixbuf (pixbuf);
g_object_unref (pixbuf);
diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c
index 98a0258e..8cbf0b62 100644
--- a/src/file-manager/fm-desktop-icon-view.c
+++ b/src/file-manager/fm-desktop-icon-view.c
@@ -120,11 +120,10 @@ icon_container_set_workarea (CajaIconContainer *icon_container,
left = right = top = bottom = 0;
- screen_width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen));
- screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen));
-
scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen));
- scale = scale ? scale : 1;
+
+ screen_width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
+ screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
for (i = 0; i < n_items; i += 4)
{
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c
index 75e42397..62d4fec1 100644
--- a/src/file-manager/fm-directory-view.c
+++ b/src/file-manager/fm-directory-view.c
@@ -4888,18 +4888,20 @@ extension_action_callback (GtkAction *action,
}
static GdkPixbuf *
-get_menu_icon (const char *icon_name)
+get_menu_icon (const char *icon_name,
+ GtkWidget *widget)
{
CajaIconInfo *info;
GdkPixbuf *pixbuf;
- int size;
+ int size, scale;
size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
+ scale = gtk_widget_get_scale_factor (widget);
if (g_path_is_absolute (icon_name)) {
- info = caja_icon_info_lookup_from_path (icon_name, size);
+ info = caja_icon_info_lookup_from_path (icon_name, size, scale);
} else {
- info = caja_icon_info_lookup_from_name (icon_name, size);
+ info = caja_icon_info_lookup_from_name (icon_name, size, scale);
}
pixbuf = caja_icon_info_get_pixbuf_nodefault_at_size (info, size);
g_object_unref (info);
@@ -4908,15 +4910,17 @@ get_menu_icon (const char *icon_name)
}
static GdkPixbuf *
-get_menu_icon_for_file (CajaFile *file)
+get_menu_icon_for_file (CajaFile *file,
+ GtkWidget *widget)
{
CajaIconInfo *info;
GdkPixbuf *pixbuf;
- int size;
+ int size, scale;
size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
+ scale = gtk_widget_get_scale_factor (widget);
- info = caja_file_get_icon (file, size, 0);
+ info = caja_file_get_icon (file, size, scale, 0);
pixbuf = caja_icon_info_get_pixbuf_nodefault_at_size (info, size);
g_object_unref (info);
@@ -4947,7 +4951,7 @@ add_extension_action_for_files (FMDirectoryView *view,
icon);
if (icon != NULL) {
- pixbuf = get_menu_icon (icon);
+ pixbuf = get_menu_icon (icon, GTK_WIDGET (view));
if (pixbuf != NULL) {
g_object_set_data_full (G_OBJECT (action), "menu-icon",
pixbuf,
@@ -5414,7 +5418,7 @@ add_script_to_scripts_menus (FMDirectoryView *directory_view,
tip,
NULL);
- pixbuf = get_menu_icon_for_file (file);
+ pixbuf = get_menu_icon_for_file (file, GTK_WIDGET (directory_view));
if (pixbuf != NULL) {
g_object_set_data_full (G_OBJECT (action), "menu-icon",
pixbuf,
@@ -5478,7 +5482,7 @@ add_submenu_to_directory_menus (FMDirectoryView *directory_view,
ui_manager = caja_window_info_get_ui_manager (directory_view->details->window);
uri = caja_file_get_uri (file);
name = caja_file_get_display_name (file);
- pixbuf = get_menu_icon_for_file (file);
+ pixbuf = get_menu_icon_for_file (file, GTK_WIDGET (directory_view));
add_submenu (ui_manager, action_group, merge_id, menu_path, uri, name, pixbuf, TRUE);
add_submenu (ui_manager, action_group, merge_id, popup_path, uri, name, pixbuf, FALSE);
add_submenu (ui_manager, action_group, merge_id, popup_bg_path, uri, name, pixbuf, FALSE);
@@ -5665,7 +5669,7 @@ add_template_to_templates_menus (FMDirectoryView *directory_view,
tip,
NULL);
- pixbuf = get_menu_icon_for_file (file);
+ pixbuf = get_menu_icon_for_file (file, GTK_WIDGET (directory_view));
if (pixbuf != NULL) {
g_object_set_data_full (G_OBJECT (action), "menu-icon",
pixbuf,
@@ -6963,6 +6967,7 @@ action_connect_to_server_link_callback (GtkAction *action,
GtkWidget *entry;
GtkWidget *box;
char *title;
+ gint scale;
view = FM_DIRECTORY_VIEW (data);
@@ -6974,9 +6979,10 @@ action_connect_to_server_link_callback (GtkAction *action,
}
file = CAJA_FILE (selection->data);
+ scale = gtk_widget_get_scale_factor (GTK_WIDGET (view));
uri = caja_file_get_activation_uri (file);
- icon = caja_file_get_icon (file, CAJA_ICON_SIZE_STANDARD, 0);
+ icon = caja_file_get_icon (file, CAJA_ICON_SIZE_STANDARD, scale, 0);
icon_name = caja_icon_info_get_used_name (icon);
name = caja_file_get_display_name (file);
@@ -7561,7 +7567,7 @@ connect_proxy (FMDirectoryView *view,
if (strcmp (gtk_action_get_name (action), FM_ACTION_NEW_EMPTY_FILE) == 0 &&
GTK_IS_IMAGE_MENU_ITEM (proxy)) {
- pixbuf = get_menu_icon ("text-x-generic");
+ pixbuf = get_menu_icon ("text-x-generic", GTK_WIDGET (view));
if (pixbuf != NULL) {
image = gtk_image_new_from_pixbuf (pixbuf);
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (proxy), image);
diff --git a/src/file-manager/fm-icon-container.c b/src/file-manager/fm-icon-container.c
index be3acee2..f744d65a 100644
--- a/src/file-manager/fm-icon-container.c
+++ b/src/file-manager/fm-icon-container.c
@@ -65,6 +65,7 @@ fm_icon_container_get_icon_images (CajaIconContainer *container,
gboolean use_embedding;
CajaFileIconFlags flags;
guint emblem_size;
+ gint scale;
file = (CajaFile *) data;
@@ -119,7 +120,9 @@ fm_icon_container_get_icon_images (CajaIconContainer *container,
flags |= CAJA_FILE_ICON_FLAGS_FOR_DRAG_ACCEPT;
}
- return caja_file_get_icon (file, size, flags);
+ scale = gtk_widget_get_scale_factor (GTK_WIDGET (icon_view));
+
+ return caja_file_get_icon (file, size, scale, flags);
}
static char *
diff --git a/src/file-manager/fm-list-model.c b/src/file-manager/fm-list-model.c
index 315fef70..715303b5 100644
--- a/src/file-manager/fm-list-model.c
+++ b/src/file-manager/fm-list-model.c
@@ -34,10 +34,12 @@
#include <glib/gi18n.h>
#include <libcaja-private/caja-dnd.h>
#include <glib.h>
+#include <cairo-gobject.h>
enum
{
SUBDIRECTORY_UNLOADED,
+ GET_ICON_SCALE,
LAST_SIGNAL
};
@@ -163,7 +165,7 @@ fm_list_model_get_column_type (GtkTreeModel *tree_model, int index)
case FM_LIST_MODEL_LARGE_ICON_COLUMN:
case FM_LIST_MODEL_LARGER_ICON_COLUMN:
case FM_LIST_MODEL_LARGEST_ICON_COLUMN:
- return GDK_TYPE_PIXBUF;
+ return CAIRO_GOBJECT_TYPE_SURFACE;
case FM_LIST_MODEL_FILE_NAME_IS_EDITABLE_COLUMN:
return G_TYPE_BOOLEAN;
default:
@@ -259,6 +261,21 @@ fm_list_model_get_path (GtkTreeModel *tree_model, GtkTreeIter *iter)
return path;
}
+static gint
+fm_list_model_get_icon_scale (FMListModel *model)
+{
+ gint retval = -1;
+
+ g_signal_emit (model, list_model_signals[GET_ICON_SCALE], 0,
+ &retval);
+
+ if (retval == -1) {
+ retval = gdk_screen_get_monitor_scale_factor (gdk_screen_get_default (), 0);
+ }
+
+ return retval;
+}
+
static void
fm_list_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, int column, GValue *value)
{
@@ -271,12 +288,13 @@ fm_list_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, int column
CajaIconInfo *icon_info;
GEmblem *emblem;
GList *emblem_icons, *l;
- int icon_size;
+ int icon_size, icon_scale;
CajaZoomLevel zoom_level;
CajaFile *parent_file;
char *emblems_to_ignore[3];
int i;
CajaFileIconFlags flags;
+ cairo_surface_t *surface;
model = (FMListModel *)tree_model;
@@ -305,12 +323,13 @@ fm_list_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, int column
case FM_LIST_MODEL_LARGE_ICON_COLUMN:
case FM_LIST_MODEL_LARGER_ICON_COLUMN:
case FM_LIST_MODEL_LARGEST_ICON_COLUMN:
- g_value_init (value, GDK_TYPE_PIXBUF);
+ g_value_init (value, CAIRO_GOBJECT_TYPE_SURFACE);
if (file != NULL)
{
zoom_level = fm_list_model_get_zoom_level_from_column_id (column);
icon_size = caja_get_icon_size_for_zoom_level (zoom_level);
+ icon_scale = fm_list_model_get_icon_scale (model);
flags = CAJA_FILE_ICON_FLAGS_USE_THUMBNAILS |
CAJA_FILE_ICON_FLAGS_FORCE_THUMBNAIL_SIZE |
@@ -376,7 +395,7 @@ fm_list_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, int column
gicon = emblemed_icon;
}
- icon_info = caja_icon_info_lookup (gicon, icon_size);
+ icon_info = caja_icon_info_lookup (gicon, icon_size, icon_scale);
icon = caja_icon_info_get_pixbuf_at_size (icon_info, icon_size);
g_object_unref (icon_info);
@@ -395,7 +414,8 @@ fm_list_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, int column
}
}
- g_value_set_object (value, icon);
+ surface = gdk_cairo_surface_create_from_pixbuf (icon, icon_scale, NULL);
+ g_value_take_boxed (value, surface);
g_object_unref (icon);
}
break;
@@ -1675,6 +1695,14 @@ fm_list_model_class_init (FMListModelClass *klass)
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
CAJA_TYPE_DIRECTORY);
+
+ list_model_signals[GET_ICON_SCALE] =
+ g_signal_new ("get-icon-scale",
+ FM_TYPE_LIST_MODEL,
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL,
+ NULL,
+ G_TYPE_INT, 0);
}
static void
diff --git a/src/file-manager/fm-list-view.c b/src/file-manager/fm-list-view.c
index 32d965a1..ddae3415 100644
--- a/src/file-manager/fm-list-view.c
+++ b/src/file-manager/fm-list-view.c
@@ -1637,6 +1637,13 @@ focus_in_event_callback (GtkWidget *widget, GdkEventFocus *event, gpointer user_
return FALSE;
}
+static gint
+get_icon_scale_callback (FMListModel *model,
+ FMListView *view)
+{
+ return gtk_widget_get_scale_factor (GTK_WIDGET (view->details->tree_view));
+}
+
static void
create_and_set_up_tree_view (FMListView *view)
{
@@ -1726,6 +1733,9 @@ create_and_set_up_tree_view (FMListView *view)
g_signal_connect_object (view->details->model, "subdirectory_unloaded",
G_CALLBACK (subdirectory_unloaded_callback), view, 0);
+ g_signal_connect_object (view->details->model, "get-icon-scale",
+ G_CALLBACK (get_icon_scale_callback), view, 0);
+
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (view->details->tree_view), GTK_SELECTION_MULTIPLE);
caja_columns = caja_get_all_columns ();
@@ -1781,7 +1791,7 @@ create_and_set_up_tree_view (FMListView *view)
gtk_tree_view_column_pack_start (view->details->file_name_column, cell, FALSE);
gtk_tree_view_column_set_attributes (view->details->file_name_column,
cell,
- "pixbuf", FM_LIST_MODEL_SMALLEST_ICON_COLUMN,
+ "surface", FM_LIST_MODEL_SMALLEST_ICON_COLUMN,
NULL);
cell = gtk_cell_renderer_text_new ();
@@ -2773,7 +2783,7 @@ fm_list_view_set_zoom_level (FMListView *view,
column = fm_list_model_get_column_id_from_zoom_level (new_level);
gtk_tree_view_column_set_attributes (view->details->file_name_column,
GTK_CELL_RENDERER (view->details->pixbuf_cell),
- "pixbuf", column,
+ "surface", column,
NULL);
/* Scale text. */
diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c
index 7bfa219b..1d097f6f 100644
--- a/src/file-manager/fm-properties-window.c
+++ b/src/file-manager/fm-properties-window.c
@@ -363,17 +363,24 @@ get_image_for_properties_window (FMPropertiesWindow *window,
{
CajaIconInfo *icon, *new_icon;
GList *l;
+ gint icon_scale;
icon = NULL;
+ icon_scale = gtk_widget_get_scale_factor (GTK_WIDGET (window->details->notebook));
+
for (l = window->details->original_files; l != NULL; l = l->next) {
CajaFile *file;
file = CAJA_FILE (l->data);
if (!icon) {
- icon = caja_file_get_icon (file, CAJA_ICON_SIZE_STANDARD, CAJA_FILE_ICON_FLAGS_USE_THUMBNAILS | CAJA_FILE_ICON_FLAGS_IGNORE_VISITING);
+ icon = caja_file_get_icon (file, CAJA_ICON_SIZE_STANDARD, icon_scale,
+ CAJA_FILE_ICON_FLAGS_USE_THUMBNAILS |
+ CAJA_FILE_ICON_FLAGS_IGNORE_VISITING);
} else {
- new_icon = caja_file_get_icon (file, CAJA_ICON_SIZE_STANDARD, CAJA_FILE_ICON_FLAGS_USE_THUMBNAILS | CAJA_FILE_ICON_FLAGS_IGNORE_VISITING);
+ new_icon = caja_file_get_icon (file, CAJA_ICON_SIZE_STANDARD, icon_scale,
+ CAJA_FILE_ICON_FLAGS_USE_THUMBNAILS |
+ CAJA_FILE_ICON_FLAGS_IGNORE_VISITING);
if (!new_icon || new_icon != icon) {
g_object_unref (icon);
g_object_unref (new_icon);
@@ -385,7 +392,9 @@ get_image_for_properties_window (FMPropertiesWindow *window,
}
if (!icon) {
- icon = caja_icon_info_lookup_from_name ("text-x-generic", CAJA_ICON_SIZE_STANDARD);
+ icon = caja_icon_info_lookup_from_name ("text-x-generic",
+ CAJA_ICON_SIZE_STANDARD,
+ icon_scale);
}
if (icon_name != NULL) {
@@ -3412,6 +3421,7 @@ create_emblems_page (FMPropertiesWindow *window)
char *label;
GList *icons, *l;
CajaIconInfo *info;
+ gint scale;
/* The emblems wrapped table */
scroller = eel_scrolled_wrap_table_new (TRUE, GTK_SHADOW_NONE, &emblems_table);
@@ -3427,6 +3437,7 @@ create_emblems_page (FMPropertiesWindow *window)
scroller, gtk_label_new (_("Emblems")));
icons = caja_emblem_list_available ();
+ scale = gtk_widget_get_scale_factor (scroller);
window->details->initial_emblems = get_initial_emblems (window->details->original_files);
@@ -3439,7 +3450,7 @@ create_emblems_page (FMPropertiesWindow *window)
continue;
}
- info = caja_icon_info_lookup_from_name (emblem_name, CAJA_ICON_SIZE_SMALL);
+ info = caja_icon_info_lookup_from_name (emblem_name, CAJA_ICON_SIZE_SMALL, scale);
pixbuf = caja_icon_info_get_pixbuf_nodefault_at_size (info, CAJA_ICON_SIZE_SMALL);
if (pixbuf == NULL) {
@@ -3454,8 +3465,8 @@ create_emblems_page (FMPropertiesWindow *window)
}
button = eel_labeled_image_check_button_new (label, pixbuf);
- eel_labeled_image_set_fixed_image_height (EEL_LABELED_IMAGE (gtk_bin_get_child (GTK_BIN (button))), STANDARD_EMBLEM_HEIGHT);
- eel_labeled_image_set_spacing (EEL_LABELED_IMAGE (gtk_bin_get_child (GTK_BIN (button))), EMBLEM_LABEL_SPACING);
+ eel_labeled_image_set_fixed_image_height (EEL_LABELED_IMAGE (gtk_bin_get_child (GTK_BIN (button))), STANDARD_EMBLEM_HEIGHT * scale);
+ eel_labeled_image_set_spacing (EEL_LABELED_IMAGE (gtk_bin_get_child (GTK_BIN (button))), EMBLEM_LABEL_SPACING * scale);
g_free (label);
g_object_unref (pixbuf);
diff --git a/src/file-manager/fm-tree-model.c b/src/file-manager/fm-tree-model.c
index cf400375..e3bcfd3c 100644
--- a/src/file-manager/fm-tree-model.c
+++ b/src/file-manager/fm-tree-model.c
@@ -258,11 +258,12 @@ get_menu_icon (GIcon *icon)
{
CajaIconInfo *info;
GdkPixbuf *pixbuf;
- int size;
+ int size, scale;
size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
+ scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
- info = caja_icon_info_lookup (icon, size);
+ info = caja_icon_info_lookup (icon, size, scale);
pixbuf = caja_icon_info_get_pixbuf_nodefault_at_size (info, size);
g_object_unref (info);
@@ -279,13 +280,14 @@ get_menu_icon_for_file (TreeNode *node,
GEmblem *emblem;
GdkPixbuf *pixbuf, *retval;
gboolean highlight;
- int size;
+ int size, scale;
FMTreeModel *model;
GList *emblem_icons, *l;
char *emblems_to_ignore[3];
int i;
size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
+ scale = gdk_window_get_scale_factor (gdk_get_default_root_window ());
gicon = caja_file_get_gicon (file, flags);
@@ -321,7 +323,7 @@ get_menu_icon_for_file (TreeNode *node,
g_list_free_full (emblem_icons, g_object_unref);
- info = caja_icon_info_lookup (gicon, size);
+ info = caja_icon_info_lookup (gicon, size, scale);
retval = caja_icon_info_get_pixbuf_nodefault_at_size (info, size);
model = node->root->model;