summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-02-14 18:55:27 +0100
committerThomas Haller <thaller@redhat.com>2020-02-14 18:55:27 +0100
commit212b5accd3cf243402e6817313dbf9de96536904 (patch)
tree9622473e194b36487504d54d3cf511755088a446
parent360ad330ed2dc4c34a40e418a2a8c642459dd4f9 (diff)
parentb4cc939d46fab29eeee4b3828fae26a09bf85197 (diff)
downloadnetwork-manager-applet-212b5accd3cf243402e6817313dbf9de96536904.tar.gz
applet/menu-item: merge branch 'vkareh/hidpi-popup-icons'
https://gitlab.gnome.org/GNOME/network-manager-applet/merge_requests/72
-rw-r--r--src/ap-menu-item.c23
-rw-r--r--src/applet.c6
-rw-r--r--src/applet.h6
-rw-r--r--src/mb-menu-item.c13
4 files changed, 38 insertions, 10 deletions
diff --git a/src/ap-menu-item.c b/src/ap-menu-item.c
index 0fdb4483..0f4c3cbd 100644
--- a/src/ap-menu-item.c
+++ b/src/ap-menu-item.c
@@ -86,6 +86,7 @@ update_icon (NMNetworkMenuItem *item, NMApplet *applet)
NMNetworkMenuItemPrivate *priv = NM_NETWORK_MENU_ITEM_GET_PRIVATE (item);
gs_unref_object GdkPixbuf *icon_free = NULL, *icon_free2 = NULL;
GdkPixbuf *icon;
+ int icon_size, scale;
const char *icon_name = NULL;
if (priv->is_adhoc)
@@ -93,6 +94,13 @@ update_icon (NMNetworkMenuItem *item, NMApplet *applet)
else
icon_name = mobile_helper_get_quality_icon_name (priv->int_strength);
+ scale = gtk_widget_get_scale_factor (GTK_WIDGET (item));
+ icon_size = 24;
+ if (INDICATOR_ENABLED (applet)) {
+ /* Since app_indicator relies on GdkPixbuf, we should not scale it */
+ } else
+ icon_size *= scale;
+
icon = nma_icon_check_and_load (icon_name, applet);
if (icon) {
if (priv->is_encrypted) {
@@ -110,11 +118,20 @@ update_icon (NMNetworkMenuItem *item, NMApplet *applet)
}
/* Scale to menu size if larger so the menu doesn't look awful */
- if (gdk_pixbuf_get_height (icon) > 24 || gdk_pixbuf_get_width (icon) > 24)
- icon = icon_free2 = gdk_pixbuf_scale_simple (icon, 24, 24, GDK_INTERP_BILINEAR);
+ if (gdk_pixbuf_get_height (icon) > icon_size || gdk_pixbuf_get_width (icon) > icon_size)
+ icon = icon_free2 = gdk_pixbuf_scale_simple (icon, icon_size, icon_size, GDK_INTERP_BILINEAR);
}
- gtk_image_set_from_pixbuf (GTK_IMAGE (priv->strength), icon);
+ if (INDICATOR_ENABLED (applet)) {
+ /* app_indicator only uses GdkPixbuf */
+ gtk_image_set_from_pixbuf (GTK_IMAGE (priv->strength), icon);
+ } else {
+ cairo_surface_t *surface;
+
+ surface = gdk_cairo_surface_create_from_pixbuf (icon, scale, NULL);
+ gtk_image_set_from_surface (GTK_IMAGE (priv->strength), surface);
+ cairo_surface_destroy (surface);
+ }
}
void
diff --git a/src/applet.c b/src/applet.c
index 7f0883e6..88f4c9d1 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -42,12 +42,6 @@ extern gboolean shell_debug;
extern gboolean with_agent;
extern gboolean with_appindicator;
-#ifdef WITH_APPINDICATOR
-#define INDICATOR_ENABLED(a) ((a)->app_indicator)
-#else
-#define INDICATOR_ENABLED(a) (FALSE)
-#endif /* WITH_APPINDICATOR */
-
G_DEFINE_TYPE (NMApplet, nma, G_TYPE_APPLICATION)
/********************************************************************/
diff --git a/src/applet.h b/src/applet.h
index 7a0cb8ff..ebc775a5 100644
--- a/src/applet.h
+++ b/src/applet.h
@@ -40,6 +40,12 @@
#define NM_IS_APPLET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_APPLET))
#define NM_APPLET_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), NM_TYPE_APPLET, NMAppletClass))
+#ifdef WITH_APPINDICATOR
+#define INDICATOR_ENABLED(a) ((a)->app_indicator)
+#else
+#define INDICATOR_ENABLED(a) (FALSE)
+#endif /* WITH_APPINDICATOR */
+
typedef struct {
GApplicationClass parent_class;
} NMAppletClass;
diff --git a/src/mb-menu-item.c b/src/mb-menu-item.c
index e82735b0..cab10b66 100644
--- a/src/mb-menu-item.c
+++ b/src/mb-menu-item.c
@@ -166,8 +166,19 @@ nm_mb_menu_item_new (const char *connection_name,
/* And the strength icon, if we have strength information at all */
if (enabled && strength) {
const char *icon_name = mobile_helper_get_quality_icon_name (strength);
+ GdkPixbuf *icon = nma_icon_check_and_load (icon_name, applet);
- gtk_image_set_from_pixbuf (GTK_IMAGE (priv->strength), nma_icon_check_and_load (icon_name, applet));
+ if (INDICATOR_ENABLED (applet)) {
+ /* app_indicator only uses GdkPixbuf */
+ gtk_image_set_from_pixbuf (GTK_IMAGE (priv->strength), icon);
+ } else {
+ int scale = gtk_widget_get_scale_factor (GTK_WIDGET (priv->strength));
+ cairo_surface_t *surface;
+
+ surface = gdk_cairo_surface_create_from_pixbuf (icon, scale, NULL);
+ gtk_image_set_from_surface (GTK_IMAGE (priv->strength), surface);
+ cairo_surface_destroy (surface);
+ }
}
return GTK_WIDGET (item);