[network-manager-applet: 3/4] applet/menu-item: replace WITH_APPINDICATOR ifdefs with INDICATOR_ENABLED()
- From: Thomas Haller <thaller src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet: 3/4] applet/menu-item: replace WITH_APPINDICATOR ifdefs with INDICATOR_ENABLED()
- Date: Fri, 14 Feb 2020 17:57:20 +0000 (UTC)
commit b4cc939d46fab29eeee4b3828fae26a09bf85197
Author: Thomas Haller <thaller redhat com>
Date: Fri Feb 14 18:32:09 2020 +0100
applet/menu-item: replace WITH_APPINDICATOR ifdefs with INDICATOR_ENABLED()
It looks more C-like and does does not compile code conditionally (while
the compiler still sees when compiled without appindicator support and
can strip the unreachable code).
src/ap-menu-item.c | 26 ++++++++++----------------
src/mb-menu-item.c | 14 +++++++-------
2 files changed, 17 insertions(+), 23 deletions(-)
---
diff --git a/src/ap-menu-item.c b/src/ap-menu-item.c
index 0f4d32b8..0f4c3cbd 100644
--- a/src/ap-menu-item.c
+++ b/src/ap-menu-item.c
@@ -86,7 +86,6 @@ 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;
- cairo_surface_t *surface;
int icon_size, scale;
const char *icon_name = NULL;
@@ -96,15 +95,11 @@ update_icon (NMNetworkMenuItem *item, NMApplet *applet)
icon_name = mobile_helper_get_quality_icon_name (priv->int_strength);
scale = gtk_widget_get_scale_factor (GTK_WIDGET (item));
-#ifdef WITH_APPINDICATOR
- /* Since app_indicator relies on GdkPixbuf, we should not scale it */
- if (applet->app_indicator)
- icon_size = 24;
- else
-#endif /* WITH_APPINDICATOR */
- {
- icon_size = 24 * scale;
- }
+ 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) {
@@ -127,13 +122,12 @@ update_icon (NMNetworkMenuItem *item, NMApplet *applet)
icon = icon_free2 = gdk_pixbuf_scale_simple (icon, icon_size, icon_size,
GDK_INTERP_BILINEAR);
}
-#ifdef WITH_APPINDICATOR
- /* app_indicator only uses GdkPixbuf */
- if (applet->app_indicator)
+ if (INDICATOR_ENABLED (applet)) {
+ /* app_indicator only uses GdkPixbuf */
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->strength), icon);
- else
-#endif /* WITH_APPINDICATOR */
- {
+ } 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);
diff --git a/src/mb-menu-item.c b/src/mb-menu-item.c
index db802e95..cab10b66 100644
--- a/src/mb-menu-item.c
+++ b/src/mb-menu-item.c
@@ -167,15 +167,15 @@ nm_mb_menu_item_new (const char *connection_name,
if (enabled && strength) {
const char *icon_name = mobile_helper_get_quality_icon_name (strength);
GdkPixbuf *icon = nma_icon_check_and_load (icon_name, applet);
-#ifdef WITH_APPINDICATOR
- /* app_indicator only uses GdkPixbuf */
- if (applet->app_indicator)
+
+ if (INDICATOR_ENABLED (applet)) {
+ /* app_indicator only uses GdkPixbuf */
gtk_image_set_from_pixbuf (GTK_IMAGE (priv->strength), icon);
- else
-#endif /* WITH_APPINDICATOR */
- {
+ } else {
int scale = gtk_widget_get_scale_factor (GTK_WIDGET (priv->strength));
- cairo_surface_t *surface = gdk_cairo_surface_create_from_pixbuf (icon, scale, NULL);
+ 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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]