xapp-gtk3-module.c: Don't add a favorites section if there aren't
any favorites.
Michael Webster
3 years ago
23 | 23 | xapp_sidebar_constructed (GObject *object) |
24 | 24 | { |
25 | 25 | GtkPlacesSidebar *sidebar = GTK_PLACES_SIDEBAR (object); |
26 | GSettings *fav_settings; | |
27 | gchar **list; | |
26 | 28 | |
27 | 29 | (* original_sidebar_constructed) (object); |
28 | 30 | |
29 | GFile *favorites = g_file_new_for_uri ("favorites:///"); | |
30 | gtk_places_sidebar_add_shortcut (sidebar, favorites); | |
31 | g_object_unref (favorites); | |
31 | // This is better than initializing favorites to count. | |
32 | // That way if there aren't any favorites, fav_settings | |
33 | // will go away. XAppFavorites is a singleton. | |
34 | fav_settings = g_settings_new ("org.x.apps.favorites"); | |
35 | list = g_settings_get_strv (fav_settings, "list"); | |
36 | ||
37 | if (g_strv_length (list) > 0) | |
38 | { | |
39 | GFile *favorites = g_file_new_for_uri ("favorites:///"); | |
40 | gtk_places_sidebar_add_shortcut (sidebar, favorites); | |
41 | g_object_unref (favorites); | |
42 | } | |
43 | ||
44 | g_strfreev (list); | |
45 | g_object_unref (fav_settings); | |
32 | 46 | } |
33 | 47 | |
34 | 48 | G_MODULE_EXPORT void gtk_module_init (gint *argc, gchar ***argv[]) { |