xapp-status-icon.c: Sync the visible state of the fallback GtkStatusIcon when
it is first created.
It was only being updated when an explicit xapp_status_icon_set_visible was
called - refactor a bit so all relevant state is updated correctly, as well
as hiding the icon if no icon name has been set.
Michael Webster
4 years ago
787 | 787 | } |
788 | 788 | |
789 | 789 | static void |
790 | update_fallback_icon (XAppStatusIcon *self, | |
791 | const gchar *icon_name) | |
792 | { | |
793 | if (g_path_is_absolute (icon_name)) | |
794 | { | |
795 | gtk_status_icon_set_from_file (self->priv->gtk_status_icon, icon_name); | |
790 | update_fallback_icon (XAppStatusIcon *self) | |
791 | { | |
792 | XAppStatusIconPrivate *priv = self->priv; | |
793 | ||
794 | if (!priv->gtk_status_icon) | |
795 | { | |
796 | return; | |
797 | } | |
798 | ||
799 | gtk_status_icon_set_tooltip_text (priv->gtk_status_icon, priv->tooltip_text); | |
800 | gtk_status_icon_set_name (priv->gtk_status_icon, priv->name); | |
801 | ||
802 | if (priv->icon_name) | |
803 | { | |
804 | gtk_status_icon_set_visible (priv->gtk_status_icon, priv->visible); | |
805 | ||
806 | if (g_path_is_absolute (priv->icon_name)) | |
807 | { | |
808 | gtk_status_icon_set_from_file (priv->gtk_status_icon, priv->icon_name); | |
809 | } | |
810 | else | |
811 | { | |
812 | gtk_status_icon_set_from_icon_name (priv->gtk_status_icon, priv->icon_name); | |
813 | } | |
796 | 814 | } |
797 | 815 | else |
798 | 816 | { |
799 | gtk_status_icon_set_from_icon_name (self->priv->gtk_status_icon, icon_name); | |
817 | gtk_status_icon_set_visible (priv->gtk_status_icon, FALSE); | |
800 | 818 | } |
801 | 819 | } |
802 | 820 | |
851 | 869 | G_CALLBACK (on_gtk_status_icon_embedded_changed), |
852 | 870 | self); |
853 | 871 | |
854 | update_fallback_icon (self, priv->icon_name ? priv->icon_name : ""); | |
855 | gtk_status_icon_set_tooltip_text (self->priv->gtk_status_icon, priv->tooltip_text); | |
872 | update_fallback_icon (self); | |
856 | 873 | } |
857 | 874 | |
858 | 875 | static void |
1319 | 1336 | xapp_status_icon_interface_set_name (icon->priv->skeleton, name); |
1320 | 1337 | } |
1321 | 1338 | |
1322 | if (icon->priv->gtk_status_icon != NULL) | |
1323 | { | |
1324 | gtk_status_icon_set_name (icon->priv->gtk_status_icon, name); | |
1325 | } | |
1339 | update_fallback_icon (icon); | |
1326 | 1340 | } |
1327 | 1341 | |
1328 | 1342 | /** |
1348 | 1362 | xapp_status_icon_interface_set_icon_name (icon->priv->skeleton, icon_name); |
1349 | 1363 | } |
1350 | 1364 | |
1351 | if (icon->priv->gtk_status_icon != NULL) | |
1352 | { | |
1353 | update_fallback_icon (icon, icon_name); | |
1354 | } | |
1365 | update_fallback_icon (icon); | |
1355 | 1366 | } |
1356 | 1367 | |
1357 | 1368 | /** |
1377 | 1388 | xapp_status_icon_interface_set_tooltip_text (icon->priv->skeleton, tooltip_text); |
1378 | 1389 | } |
1379 | 1390 | |
1380 | if (icon->priv->gtk_status_icon != NULL) | |
1381 | { | |
1382 | gtk_status_icon_set_tooltip_text (icon->priv->gtk_status_icon, tooltip_text); | |
1383 | } | |
1391 | update_fallback_icon (icon); | |
1384 | 1392 | } |
1385 | 1393 | |
1386 | 1394 | /** |
1429 | 1437 | xapp_status_icon_interface_set_visible (icon->priv->skeleton, visible); |
1430 | 1438 | } |
1431 | 1439 | |
1432 | if (icon->priv->gtk_status_icon != NULL) | |
1433 | { | |
1434 | gtk_status_icon_set_visible (icon->priv->gtk_status_icon, visible); | |
1435 | } | |
1440 | update_fallback_icon (icon); | |
1436 | 1441 | } |
1437 | 1442 | |
1438 | 1443 | /** |