[gnome-software: 1/29] gs-overview-page: Make the class final




commit f002de34f5237ea5a284dbb40926e81ca58e3588
Author: Philip Withnall <pwithnall endlessos org>
Date:   Wed Jan 20 21:58:55 2021 +0000

    gs-overview-page: Make the class final
    
    This simplifies the code a little.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 src/gs-overview-page.c | 317 +++++++++++++++++++++++--------------------------
 src/gs-overview-page.h |   9 +-
 2 files changed, 148 insertions(+), 178 deletions(-)
---
diff --git a/src/gs-overview-page.c b/src/gs-overview-page.c
index 32bc14a77..0a9500cb2 100644
--- a/src/gs-overview-page.c
+++ b/src/gs-overview-page.c
@@ -24,8 +24,10 @@
 
 #define N_TILES                                        9
 
-typedef struct
+struct _GsOverviewPage
 {
+       GsPage                   parent_instance;
+
        GsPluginLoader          *plugin_loader;
        GtkBuilder              *builder;
        GCancellable            *cancellable;
@@ -56,9 +58,9 @@ typedef struct
        GtkWidget               *recent_heading;
        GtkWidget               *scrolledwindow_overview;
        GtkWidget               *stack_overview;
-} GsOverviewPagePrivate;
+};
 
-G_DEFINE_TYPE_WITH_PRIVATE (GsOverviewPage, gs_overview_page, GS_TYPE_PAGE)
+G_DEFINE_TYPE (GsOverviewPage, gs_overview_page, GS_TYPE_PAGE)
 
 enum {
        SIGNAL_REFRESHED,
@@ -86,20 +88,17 @@ load_data_free (LoadData *data)
 static void
 gs_overview_page_invalidate (GsOverviewPage *self)
 {
-       GsOverviewPagePrivate *priv = gs_overview_page_get_instance_private (self);
-
-       priv->cache_valid = FALSE;
+       self->cache_valid = FALSE;
 }
 
 static void
 app_tile_clicked (GsAppTile *tile, gpointer data)
 {
        GsOverviewPage *self = GS_OVERVIEW_PAGE (data);
-       GsOverviewPagePrivate *priv = gs_overview_page_get_instance_private (self);
        GsApp *app;
 
        app = gs_app_tile_get_app (tile);
-       gs_shell_show_app (priv->shell, app);
+       gs_shell_show_app (self->shell, app);
 }
 
 static void
@@ -108,9 +107,8 @@ featured_carousel_app_clicked_cb (GsFeaturedCarousel *carousel,
                                   gpointer            user_data)
 {
        GsOverviewPage *self = GS_OVERVIEW_PAGE (user_data);
-       GsOverviewPagePrivate *priv = gs_overview_page_get_instance_private (self);
 
-       gs_shell_show_app (priv->shell, app);
+       gs_shell_show_app (self->shell, app);
 }
 
 static gboolean
@@ -124,24 +122,22 @@ filter_category (GsApp *app, gpointer user_data)
 static void
 gs_overview_page_decrement_action_cnt (GsOverviewPage *self)
 {
-       GsOverviewPagePrivate *priv = gs_overview_page_get_instance_private (self);
-
        /* every job increments this */
-       if (priv->action_cnt == 0) {
+       if (self->action_cnt == 0) {
                g_warning ("action_cnt already zero!");
                return;
        }
-       if (--priv->action_cnt > 0)
+       if (--self->action_cnt > 0)
                return;
 
        /* all done */
-       priv->cache_valid = TRUE;
+       self->cache_valid = TRUE;
        g_signal_emit (self, signals[SIGNAL_REFRESHED], 0);
-       priv->loading_categories = FALSE;
-       priv->loading_featured = FALSE;
-       priv->loading_popular = FALSE;
-       priv->loading_recent = FALSE;
-       priv->loading_popular_rotating = FALSE;
+       self->loading_categories = FALSE;
+       self->loading_featured = FALSE;
+       self->loading_popular = FALSE;
+       self->loading_recent = FALSE;
+       self->loading_popular_rotating = FALSE;
 }
 
 static void
@@ -150,7 +146,6 @@ gs_overview_page_get_popular_cb (GObject *source_object,
                                  gpointer user_data)
 {
        GsOverviewPage *self = GS_OVERVIEW_PAGE (user_data);
-       GsOverviewPagePrivate *priv = gs_overview_page_get_instance_private (self);
        GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
        guint i;
        GsApp *app;
@@ -170,28 +165,28 @@ gs_overview_page_get_popular_cb (GObject *source_object,
        if (gs_app_list_length (list) < N_TILES) {
                g_warning ("Only %u apps for popular list, hiding",
                           gs_app_list_length (list));
-               gtk_widget_set_visible (priv->box_popular, FALSE);
-               gtk_widget_set_visible (priv->popular_heading, FALSE);
+               gtk_widget_set_visible (self->box_popular, FALSE);
+               gtk_widget_set_visible (self->popular_heading, FALSE);
                goto out;
        }
 
        /* Don't show apps from the category that's currently featured as the category of the day */
-       gs_app_list_filter (list, filter_category, priv->category_of_day);
+       gs_app_list_filter (list, filter_category, self->category_of_day);
        gs_app_list_randomize (list);
 
-       gs_container_remove_all (GTK_CONTAINER (priv->box_popular));
+       gs_container_remove_all (GTK_CONTAINER (self->box_popular));
 
        for (i = 0; i < gs_app_list_length (list) && i < N_TILES; i++) {
                app = gs_app_list_index (list, i);
                tile = gs_popular_tile_new (app);
                g_signal_connect (tile, "clicked",
                          G_CALLBACK (app_tile_clicked), self);
-               gtk_container_add (GTK_CONTAINER (priv->box_popular), tile);
+               gtk_container_add (GTK_CONTAINER (self->box_popular), tile);
        }
-       gtk_widget_set_visible (priv->box_popular, TRUE);
-       gtk_widget_set_visible (priv->popular_heading, TRUE);
+       gtk_widget_set_visible (self->box_popular, TRUE);
+       gtk_widget_set_visible (self->popular_heading, TRUE);
 
-       priv->empty = FALSE;
+       self->empty = FALSE;
 
 out:
        gs_overview_page_decrement_action_cnt (self);
@@ -201,7 +196,6 @@ static void
 gs_overview_page_get_recent_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
 {
        GsOverviewPage *self = GS_OVERVIEW_PAGE (user_data);
-       GsOverviewPagePrivate *priv = gs_overview_page_get_instance_private (self);
        GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
        guint i;
        GsApp *app;
@@ -221,28 +215,28 @@ gs_overview_page_get_recent_cb (GObject *source_object, GAsyncResult *res, gpoin
        if (gs_app_list_length (list) < N_TILES) {
                g_warning ("Only %u apps for recent list, hiding",
                           gs_app_list_length (list));
-               gtk_widget_set_visible (priv->box_recent, FALSE);
-               gtk_widget_set_visible (priv->recent_heading, FALSE);
+               gtk_widget_set_visible (self->box_recent, FALSE);
+               gtk_widget_set_visible (self->recent_heading, FALSE);
                goto out;
        }
 
        /* Don't show apps from the category that's currently featured as the category of the day */
-       gs_app_list_filter (list, filter_category, priv->category_of_day);
+       gs_app_list_filter (list, filter_category, self->category_of_day);
        gs_app_list_randomize (list);
 
-       gs_container_remove_all (GTK_CONTAINER (priv->box_recent));
+       gs_container_remove_all (GTK_CONTAINER (self->box_recent));
 
        for (i = 0; i < gs_app_list_length (list) && i < N_TILES; i++) {
                app = gs_app_list_index (list, i);
                tile = gs_popular_tile_new (app);
                g_signal_connect (tile, "clicked",
                          G_CALLBACK (app_tile_clicked), self);
-               gtk_container_add (GTK_CONTAINER (priv->box_recent), tile);
+               gtk_container_add (GTK_CONTAINER (self->box_recent), tile);
        }
-       gtk_widget_set_visible (priv->box_recent, TRUE);
-       gtk_widget_set_visible (priv->recent_heading, TRUE);
+       gtk_widget_set_visible (self->box_recent, TRUE);
+       gtk_widget_set_visible (self->recent_heading, TRUE);
 
-       priv->empty = FALSE;
+       self->empty = FALSE;
 
 out:
        gs_overview_page_decrement_action_cnt (self);
@@ -251,17 +245,16 @@ out:
 static void
 gs_overview_page_category_more_cb (GtkButton *button, GsOverviewPage *self)
 {
-       GsOverviewPagePrivate *priv = gs_overview_page_get_instance_private (self);
        GsCategory *cat;
        const gchar *id;
 
        id = g_object_get_data (G_OBJECT (button), "GnomeSoftware::CategoryId");
        if (id == NULL)
                return;
-       cat = g_hash_table_lookup (priv->category_hash, id);
+       cat = g_hash_table_lookup (self->category_hash, id);
        if (cat == NULL)
                return;
-       gs_shell_show_category (priv->shell, cat);
+       gs_shell_show_category (self->shell, cat);
 }
 
 static void
@@ -271,7 +264,6 @@ gs_overview_page_get_category_apps_cb (GObject *source_object,
 {
        LoadData *load_data = (LoadData *) user_data;
        GsOverviewPage *self = load_data->self;
-       GsOverviewPagePrivate *priv = gs_overview_page_get_instance_private (self);
        GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
        guint i;
        GsApp *app;
@@ -329,14 +321,14 @@ gs_overview_page_get_category_apps_cb (GObject *source_object,
        g_signal_connect (button, "clicked",
                          G_CALLBACK (gs_overview_page_category_more_cb), self);
        gtk_container_add (GTK_CONTAINER (headerbox), button);
-       gtk_container_add (GTK_CONTAINER (priv->box_popular_rotating), headerbox);
+       gtk_container_add (GTK_CONTAINER (self->box_popular_rotating), headerbox);
 
        /* add hiding box */
        box = gs_hiding_box_new ();
        gs_hiding_box_set_spacing (GS_HIDING_BOX (box), 14);
        gtk_widget_set_visible (box, TRUE);
        gtk_widget_set_valign (box, GTK_ALIGN_START);
-       gtk_container_add (GTK_CONTAINER (priv->box_popular_rotating), box);
+       gtk_container_add (GTK_CONTAINER (self->box_popular_rotating), box);
 
        /* add all the apps */
        for (i = 0; i < gs_app_list_length (list) && i < N_TILES; i++) {
@@ -347,7 +339,7 @@ gs_overview_page_get_category_apps_cb (GObject *source_object,
                gtk_container_add (GTK_CONTAINER (box), tile);
        }
 
-       priv->empty = FALSE;
+       self->empty = FALSE;
 
 out:
        load_data_free (load_data);
@@ -376,7 +368,6 @@ gs_overview_page_get_featured_cb (GObject *source_object,
                                   gpointer user_data)
 {
        GsOverviewPage *self = GS_OVERVIEW_PAGE (user_data);
-       GsOverviewPagePrivate *priv = gs_overview_page_get_instance_private (self);
        GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
        g_autoptr(GError) error = NULL;
        g_autoptr(GsAppList) list = NULL;
@@ -388,13 +379,13 @@ gs_overview_page_get_featured_cb (GObject *source_object,
        if (list == NULL || gs_app_list_length (list) == 0) {
                g_warning ("failed to get featured apps: %s",
                           (error != NULL) ? error->message : "no apps to show");
-               gtk_widget_set_visible (priv->featured_carousel, FALSE);
+               gtk_widget_set_visible (self->featured_carousel, FALSE);
                goto out;
        }
 
        if (g_getenv ("GNOME_SOFTWARE_FEATURED") == NULL) {
                /* Don't show apps from the category that's currently featured as the category of the day */
-               gs_app_list_filter (list, filter_category, priv->category_of_day);
+               gs_app_list_filter (list, filter_category, self->category_of_day);
                gs_app_list_filter_duplicates (list, GS_APP_LIST_FILTER_FLAG_KEY_ID);
                gs_app_list_randomize (list);
        }
@@ -402,10 +393,10 @@ gs_overview_page_get_featured_cb (GObject *source_object,
        /* Filter out apps which don’t have a suitable hi-res icon. */
        gs_app_list_filter (list, filter_hi_res_icon, self);
 
-       gtk_widget_set_visible (priv->featured_carousel, gs_app_list_length (list) > 0);
-       gs_featured_carousel_set_apps (GS_FEATURED_CAROUSEL (priv->featured_carousel), list);
+       gtk_widget_set_visible (self->featured_carousel, gs_app_list_length (list) > 0);
+       gs_featured_carousel_set_apps (GS_FEATURED_CAROUSEL (self->featured_carousel), list);
 
-       priv->empty = priv->empty && (gs_app_list_length (list) == 0);
+       self->empty = self->empty && (gs_app_list_length (list) == 0);
 
 out:
        gs_overview_page_decrement_action_cnt (self);
@@ -415,11 +406,10 @@ static void
 category_tile_clicked (GsCategoryTile *tile, gpointer data)
 {
        GsOverviewPage *self = GS_OVERVIEW_PAGE (data);
-       GsOverviewPagePrivate *priv = gs_overview_page_get_instance_private (self);
        GsCategory *category;
 
        category = gs_category_tile_get_category (tile);
-       gs_shell_show_category (priv->shell, category);
+       gs_shell_show_category (self->shell, category);
 }
 
 static void
@@ -428,7 +418,6 @@ gs_overview_page_get_categories_cb (GObject *source_object,
                                     gpointer user_data)
 {
        GsOverviewPage *self = GS_OVERVIEW_PAGE (user_data);
-       GsOverviewPagePrivate *priv = gs_overview_page_get_instance_private (self);
        GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source_object);
        guint i;
        GsCategory *cat;
@@ -444,7 +433,7 @@ gs_overview_page_get_categories_cb (GObject *source_object,
                        g_warning ("failed to get categories: %s", error->message);
                goto out;
        }
-       gs_container_remove_all (GTK_CONTAINER (priv->flowbox_categories));
+       gs_container_remove_all (GTK_CONTAINER (self->flowbox_categories));
 
        /* add categories to the correct flowboxes, the second being hidden */
        for (i = 0; i < list->len; i++) {
@@ -454,21 +443,21 @@ gs_overview_page_get_categories_cb (GObject *source_object,
                tile = gs_category_tile_new (cat);
                g_signal_connect (tile, "clicked",
                                  G_CALLBACK (category_tile_clicked), self);
-               flowbox = GTK_FLOW_BOX (priv->flowbox_categories);
+               flowbox = GTK_FLOW_BOX (self->flowbox_categories);
                gtk_flow_box_insert (flowbox, tile, -1);
                gtk_widget_set_can_focus (gtk_widget_get_parent (tile), FALSE);
                added_cnt++;
 
                /* we save these for the 'More...' buttons */
-               g_hash_table_insert (priv->category_hash,
+               g_hash_table_insert (self->category_hash,
                                     g_strdup (gs_category_get_id (cat)),
                                     g_object_ref (cat));
        }
 
 out:
        if (added_cnt > 0)
-               priv->empty = FALSE;
-       gtk_widget_set_visible (priv->category_heading, added_cnt > 0);
+               self->empty = FALSE;
+       gtk_widget_set_visible (self->category_heading, added_cnt > 0);
 
        gs_overview_page_decrement_action_cnt (self);
 }
@@ -537,15 +526,13 @@ gs_overview_page_get_random_categories (void)
 static void
 refresh_third_party_repo (GsOverviewPage *self)
 {
-       GsOverviewPagePrivate *priv = gs_overview_page_get_instance_private (self);
-
        /* only show if never prompted and third party repo is available */
-       if (g_settings_get_boolean (priv->settings, "show-nonfree-prompt") &&
-           priv->third_party_repo != NULL &&
-           gs_app_get_state (priv->third_party_repo) == GS_APP_STATE_AVAILABLE) {
-               gtk_widget_set_visible (priv->infobar_third_party, TRUE);
+       if (g_settings_get_boolean (self->settings, "show-nonfree-prompt") &&
+           self->third_party_repo != NULL &&
+           gs_app_get_state (self->third_party_repo) == GS_APP_STATE_AVAILABLE) {
+               gtk_widget_set_visible (self->infobar_third_party, TRUE);
        } else {
-               gtk_widget_set_visible (priv->infobar_third_party, FALSE);
+               gtk_widget_set_visible (self->infobar_third_party, FALSE);
        }
 }
 
@@ -554,7 +541,6 @@ resolve_third_party_repo_cb (GsPluginLoader *plugin_loader,
                              GAsyncResult *res,
                              GsOverviewPage *self)
 {
-       GsOverviewPagePrivate *priv = gs_overview_page_get_instance_private (self);
        g_autoptr(GError) error = NULL;
        g_autoptr(GsAppList) list = NULL;
 
@@ -573,9 +559,9 @@ resolve_third_party_repo_cb (GsPluginLoader *plugin_loader,
        }
 
        /* save results for later */
-       g_clear_object (&priv->third_party_repo);
+       g_clear_object (&self->third_party_repo);
        if (gs_app_list_length (list) > 0)
-               priv->third_party_repo = g_object_ref (gs_app_list_index (list, 0));
+               self->third_party_repo = g_object_ref (gs_app_list_index (list, 0));
 
        /* refresh widget */
        refresh_third_party_repo (self);
@@ -601,12 +587,11 @@ is_fedora (void)
 static void
 reload_third_party_repo (GsOverviewPage *self)
 {
-       GsOverviewPagePrivate *priv = gs_overview_page_get_instance_private (self);
        const gchar *third_party_repo_package = "fedora-workstation-repositories";
        g_autoptr(GsPluginJob) plugin_job = NULL;
 
        /* only show if never prompted */
-       if (!g_settings_get_boolean (priv->settings, "show-nonfree-prompt"))
+       if (!g_settings_get_boolean (self->settings, "show-nonfree-prompt"))
                return;
 
        /* Fedora-specific functionality */
@@ -618,8 +603,8 @@ reload_third_party_repo (GsOverviewPage *self)
                                         "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_SETUP_ACTION |
                                                         GS_PLUGIN_REFINE_FLAGS_ALLOW_PACKAGES,
                                         NULL);
-       gs_plugin_loader_job_process_async (priv->plugin_loader, plugin_job,
-                                           priv->cancellable,
+       gs_plugin_loader_job_process_async (self->plugin_loader, plugin_job,
+                                           self->cancellable,
                                            (GAsyncReadyCallback) resolve_third_party_repo_cb,
                                            self);
 }
@@ -627,33 +612,32 @@ reload_third_party_repo (GsOverviewPage *self)
 static void
 gs_overview_page_load (GsOverviewPage *self)
 {
-       GsOverviewPagePrivate *priv = gs_overview_page_get_instance_private (self);
        guint i;
 
-       priv->empty = TRUE;
+       self->empty = TRUE;
 
-       if (!priv->loading_featured) {
+       if (!self->loading_featured) {
                g_autoptr(GsPluginJob) plugin_job = NULL;
 
-               priv->loading_featured = TRUE;
+               self->loading_featured = TRUE;
                plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_FEATURED,
                                                 "max-results", 5,
                                                 "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON,
                                                 "dedupe-flags", GS_APP_LIST_FILTER_FLAG_PREFER_INSTALLED |
                                                                 GS_APP_LIST_FILTER_FLAG_KEY_ID_PROVIDES,
                                                 NULL);
-               gs_plugin_loader_job_process_async (priv->plugin_loader,
+               gs_plugin_loader_job_process_async (self->plugin_loader,
                                                    plugin_job,
-                                                   priv->cancellable,
+                                                   self->cancellable,
                                                    gs_overview_page_get_featured_cb,
                                                    self);
-               priv->action_cnt++;
+               self->action_cnt++;
        }
 
-       if (!priv->loading_popular) {
+       if (!self->loading_popular) {
                g_autoptr(GsPluginJob) plugin_job = NULL;
 
-               priv->loading_popular = TRUE;
+               self->loading_popular = TRUE;
                plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_POPULAR,
                                                 "max-results", 20,
                                                 "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_RATING |
@@ -662,18 +646,18 @@ gs_overview_page_load (GsOverviewPage *self)
                                                 "dedupe-flags", GS_APP_LIST_FILTER_FLAG_PREFER_INSTALLED |
                                                                 GS_APP_LIST_FILTER_FLAG_KEY_ID_PROVIDES,
                                                 NULL);
-               gs_plugin_loader_job_process_async (priv->plugin_loader,
+               gs_plugin_loader_job_process_async (self->plugin_loader,
                                                    plugin_job,
-                                                   priv->cancellable,
+                                                   self->cancellable,
                                                    gs_overview_page_get_popular_cb,
                                                    self);
-               priv->action_cnt++;
+               self->action_cnt++;
        }
 
-       if (!priv->loading_recent) {
+       if (!self->loading_recent) {
                g_autoptr(GsPluginJob) plugin_job = NULL;
 
-               priv->loading_recent = TRUE;
+               self->loading_recent = TRUE;
                plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_RECENT,
                                                 "age", (guint64) (60 * 60 * 24 * 60),
                                                 "max-results", 20,
@@ -682,21 +666,21 @@ gs_overview_page_load (GsOverviewPage *self)
                                                 "dedupe-flags", GS_APP_LIST_FILTER_FLAG_PREFER_INSTALLED |
                                                                 GS_APP_LIST_FILTER_FLAG_KEY_ID_PROVIDES,
                                                 NULL);
-               gs_plugin_loader_job_process_async (priv->plugin_loader,
+               gs_plugin_loader_job_process_async (self->plugin_loader,
                                                    plugin_job,
-                                                   priv->cancellable,
+                                                   self->cancellable,
                                                    gs_overview_page_get_recent_cb,
                                                    self);
-               priv->action_cnt++;
+               self->action_cnt++;
        }
 
-       if (!priv->loading_popular_rotating) {
+       if (!self->loading_popular_rotating) {
                const guint MAX_CATS = 2;
                g_autoptr(GPtrArray) cats_random = NULL;
                cats_random = gs_overview_page_get_random_categories ();
 
                /* remove existing widgets, if any */
-               gs_container_remove_all (GTK_CONTAINER (priv->box_popular_rotating));
+               gs_container_remove_all (GTK_CONTAINER (self->box_popular_rotating));
 
                /* load all the categories */
                for (i = 0; i < cats_random->len && i < MAX_CATS; i++) {
@@ -708,10 +692,10 @@ gs_overview_page_load (GsOverviewPage *self)
 
                        cat_id = g_ptr_array_index (cats_random, i);
                        if (i == 0) {
-                               g_free (priv->category_of_day);
-                               priv->category_of_day = g_strdup (cat_id);
+                               g_free (self->category_of_day);
+                               self->category_of_day = g_strdup (cat_id);
                        }
-                       category = gs_category_manager_lookup (gs_plugin_loader_get_category_manager 
(priv->plugin_loader), cat_id);
+                       category = gs_category_manager_lookup (gs_plugin_loader_get_category_manager 
(self->plugin_loader), cat_id);
                        featured_category = gs_category_find_child (category, "featured");
 
                        load_data = g_slice_new0 (LoadData);
@@ -726,25 +710,25 @@ gs_overview_page_load (GsOverviewPage *self)
                                                         "dedupe-flags", 
GS_APP_LIST_FILTER_FLAG_PREFER_INSTALLED |
                                                                         
GS_APP_LIST_FILTER_FLAG_KEY_ID_PROVIDES,
                                                         NULL);
-                       gs_plugin_loader_job_process_async (priv->plugin_loader,
+                       gs_plugin_loader_job_process_async (self->plugin_loader,
                                                            plugin_job,
-                                                           priv->cancellable,
+                                                           self->cancellable,
                                                            gs_overview_page_get_category_apps_cb,
                                                            load_data);
-                       priv->action_cnt++;
+                       self->action_cnt++;
                }
-               priv->loading_popular_rotating = TRUE;
+               self->loading_popular_rotating = TRUE;
        }
 
-       if (!priv->loading_categories) {
+       if (!self->loading_categories) {
                g_autoptr(GsPluginJob) plugin_job = NULL;
-               priv->loading_categories = TRUE;
+               self->loading_categories = TRUE;
                plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_GET_CATEGORIES, NULL);
-               gs_plugin_loader_job_get_categories_async (priv->plugin_loader, plugin_job,
-                                                         priv->cancellable,
+               gs_plugin_loader_job_get_categories_async (self->plugin_loader, plugin_job,
+                                                         self->cancellable,
                                                          gs_overview_page_get_categories_cb,
                                                          self);
-               priv->action_cnt++;
+               self->action_cnt++;
        }
 
        reload_third_party_repo (self);
@@ -762,33 +746,32 @@ static void
 gs_overview_page_switch_to (GsPage *page, gboolean scroll_up)
 {
        GsOverviewPage *self = GS_OVERVIEW_PAGE (page);
-       GsOverviewPagePrivate *priv = gs_overview_page_get_instance_private (self);
        GtkWidget *widget;
        GtkAdjustment *adj;
 
-       if (gs_shell_get_mode (priv->shell) != GS_SHELL_MODE_OVERVIEW) {
+       if (gs_shell_get_mode (self->shell) != GS_SHELL_MODE_OVERVIEW) {
                g_warning ("Called switch_to(overview) when in mode %s",
-                          gs_shell_get_mode_string (priv->shell));
+                          gs_shell_get_mode_string (self->shell));
                return;
        }
 
        /* we hid the search bar */
-       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "search_button"));
+       widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "search_button"));
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
 
-       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "buttonbox_main"));
+       widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "buttonbox_main"));
        gtk_widget_show (widget);
-       widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "menu_button"));
+       widget = GTK_WIDGET (gtk_builder_get_object (self->builder, "menu_button"));
        gtk_widget_show (widget);
 
        if (scroll_up) {
-               adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW 
(priv->scrolledwindow_overview));
+               adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW 
(self->scrolledwindow_overview));
                gtk_adjustment_set_value (adj, gtk_adjustment_get_lower (adj));
        }
 
-       gs_grab_focus_when_mapped (priv->scrolledwindow_overview);
+       gs_grab_focus_when_mapped (self->scrolledwindow_overview);
 
-       if (priv->cache_valid || priv->action_cnt > 0)
+       if (self->cache_valid || self->action_cnt > 0)
                return;
        gs_overview_page_load (self);
 }
@@ -798,19 +781,18 @@ third_party_response_cb (GtkInfoBar *info_bar,
                          gint response_id,
                          GsOverviewPage *self)
 {
-       GsOverviewPagePrivate *priv = gs_overview_page_get_instance_private (self);
-       g_settings_set_boolean (priv->settings, "show-nonfree-prompt", FALSE);
+       g_settings_set_boolean (self->settings, "show-nonfree-prompt", FALSE);
        if (response_id == GTK_RESPONSE_CLOSE) {
-               gtk_widget_hide (priv->infobar_third_party);
+               gtk_widget_hide (self->infobar_third_party);
                return;
        }
        if (response_id != GTK_RESPONSE_YES)
                return;
 
-       if (gs_app_get_state (priv->third_party_repo) == GS_APP_STATE_AVAILABLE) {
-               gs_page_install_app (GS_PAGE (self), priv->third_party_repo,
+       if (gs_app_get_state (self->third_party_repo) == GS_APP_STATE_AVAILABLE) {
+               gs_page_install_app (GS_PAGE (self), self->third_party_repo,
                                     GS_SHELL_INTERACTION_FULL,
-                                    priv->cancellable);
+                                    self->cancellable);
        }
 
        refresh_third_party_repo (self);
@@ -825,7 +807,6 @@ gs_overview_page_setup (GsPage *page,
                         GError **error)
 {
        GsOverviewPage *self = GS_OVERVIEW_PAGE (page);
-       GsOverviewPagePrivate *priv = gs_overview_page_get_instance_private (self);
        GtkAdjustment *adj;
        GtkWidget *tile;
        gint i;
@@ -833,10 +814,10 @@ gs_overview_page_setup (GsPage *page,
 
        g_return_val_if_fail (GS_IS_OVERVIEW_PAGE (self), TRUE);
 
-       priv->plugin_loader = g_object_ref (plugin_loader);
-       priv->builder = g_object_ref (builder);
-       priv->cancellable = g_object_ref (cancellable);
-       priv->category_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
+       self->plugin_loader = g_object_ref (plugin_loader);
+       self->builder = g_object_ref (builder);
+       self->cancellable = g_object_ref (cancellable);
+       self->category_hash = g_hash_table_new_full (g_str_hash, g_str_equal,
                                                     g_free, (GDestroyNotify) g_object_unref);
 
        g_string_append (str,
@@ -851,74 +832,72 @@ gs_overview_page_setup (GsPage *page,
                                /* TRANSLATORS: this is the clickable
                                 * link on the third party repositories info bar */
                                _("Find out more…"));
-       gtk_label_set_markup (GTK_LABEL (priv->label_third_party), str->str);
+       gtk_label_set_markup (GTK_LABEL (self->label_third_party), str->str);
 
        /* create info bar if not already dismissed in initial-setup */
        refresh_third_party_repo (self);
        reload_third_party_repo (self);
-       gtk_info_bar_add_button (GTK_INFO_BAR (priv->infobar_third_party),
+       gtk_info_bar_add_button (GTK_INFO_BAR (self->infobar_third_party),
                                 /* TRANSLATORS: button to turn on third party software repositories */
                                 _("Enable"), GTK_RESPONSE_YES);
-       g_signal_connect (priv->infobar_third_party, "response",
+       g_signal_connect (self->infobar_third_party, "response",
                          G_CALLBACK (third_party_response_cb), self);
 
        /* avoid a ref cycle */
-       priv->shell = shell;
+       self->shell = shell;
 
-       adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->scrolledwindow_overview));
-       gtk_container_set_focus_vadjustment (GTK_CONTAINER (priv->box_overview), adj);
+       adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (self->scrolledwindow_overview));
+       gtk_container_set_focus_vadjustment (GTK_CONTAINER (self->box_overview), adj);
 
        for (i = 0; i < N_TILES; i++) {
                tile = gs_popular_tile_new (NULL);
-               gtk_container_add (GTK_CONTAINER (priv->box_popular), tile);
+               gtk_container_add (GTK_CONTAINER (self->box_popular), tile);
        }
 
        for (i = 0; i < N_TILES; i++) {
                tile = gs_popular_tile_new (NULL);
-               gtk_container_add (GTK_CONTAINER (priv->box_recent), tile);
+               gtk_container_add (GTK_CONTAINER (self->box_recent), tile);
        }
 
        return TRUE;
 }
 
+static void
+refreshed_cb (GsOverviewPage *self, gpointer user_data)
+{
+       if (self->empty) {
+               gtk_stack_set_visible_child_name (GTK_STACK (self->stack_overview), "no-results");
+       } else {
+               gtk_stack_set_visible_child_name (GTK_STACK (self->stack_overview), "overview");
+       }
+}
+
 static void
 gs_overview_page_init (GsOverviewPage *self)
 {
-       GsOverviewPagePrivate *priv = gs_overview_page_get_instance_private (self);
        gtk_widget_init_template (GTK_WIDGET (self));
 
-       priv->settings = g_settings_new ("org.gnome.software");
+       g_signal_connect (self, "refreshed", G_CALLBACK (refreshed_cb), self);
+
+       self->settings = g_settings_new ("org.gnome.software");
 }
 
 static void
 gs_overview_page_dispose (GObject *object)
 {
        GsOverviewPage *self = GS_OVERVIEW_PAGE (object);
-       GsOverviewPagePrivate *priv = gs_overview_page_get_instance_private (self);
 
-       g_clear_object (&priv->builder);
-       g_clear_object (&priv->plugin_loader);
-       g_clear_object (&priv->cancellable);
-       g_clear_object (&priv->settings);
-       g_clear_object (&priv->third_party_repo);
-       g_clear_pointer (&priv->category_of_day, g_free);
-       g_clear_pointer (&priv->category_hash, g_hash_table_unref);
+       g_clear_object (&self->builder);
+       g_clear_object (&self->plugin_loader);
+       g_clear_object (&self->cancellable);
+       g_clear_object (&self->settings);
+       g_clear_object (&self->third_party_repo);
+       g_clear_pointer (&self->category_of_day, g_free);
+       g_clear_pointer (&self->category_hash, g_hash_table_unref);
 
        G_OBJECT_CLASS (gs_overview_page_parent_class)->dispose (object);
 }
 
-static void
-gs_overview_page_refreshed (GsOverviewPage *self)
-{
-       GsOverviewPagePrivate *priv = gs_overview_page_get_instance_private (self);
-
-       if (priv->empty) {
-               gtk_stack_set_visible_child_name (GTK_STACK (priv->stack_overview), "no-results");
-       } else {
-               gtk_stack_set_visible_child_name (GTK_STACK (priv->stack_overview), "overview");
-       }
-}
-
 static void
 gs_overview_page_class_init (GsOverviewPageClass *klass)
 {
@@ -930,30 +909,28 @@ gs_overview_page_class_init (GsOverviewPageClass *klass)
        page_class->switch_to = gs_overview_page_switch_to;
        page_class->reload = gs_overview_page_reload;
        page_class->setup = gs_overview_page_setup;
-       klass->refreshed = gs_overview_page_refreshed;
 
        signals [SIGNAL_REFRESHED] =
                g_signal_new ("refreshed",
                              G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
-                             G_STRUCT_OFFSET (GsOverviewPageClass, refreshed),
-                             NULL, NULL, g_cclosure_marshal_VOID__VOID,
+                             0, NULL, NULL, g_cclosure_marshal_VOID__VOID,
                              G_TYPE_NONE, 0);
 
        gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Software/gs-overview-page.ui");
 
-       gtk_widget_class_bind_template_child_private (widget_class, GsOverviewPage, infobar_third_party);
-       gtk_widget_class_bind_template_child_private (widget_class, GsOverviewPage, label_third_party);
-       gtk_widget_class_bind_template_child_private (widget_class, GsOverviewPage, featured_carousel);
-       gtk_widget_class_bind_template_child_private (widget_class, GsOverviewPage, box_overview);
-       gtk_widget_class_bind_template_child_private (widget_class, GsOverviewPage, box_popular);
-       gtk_widget_class_bind_template_child_private (widget_class, GsOverviewPage, box_popular_rotating);
-       gtk_widget_class_bind_template_child_private (widget_class, GsOverviewPage, box_recent);
-       gtk_widget_class_bind_template_child_private (widget_class, GsOverviewPage, category_heading);
-       gtk_widget_class_bind_template_child_private (widget_class, GsOverviewPage, flowbox_categories);
-       gtk_widget_class_bind_template_child_private (widget_class, GsOverviewPage, popular_heading);
-       gtk_widget_class_bind_template_child_private (widget_class, GsOverviewPage, recent_heading);
-       gtk_widget_class_bind_template_child_private (widget_class, GsOverviewPage, scrolledwindow_overview);
-       gtk_widget_class_bind_template_child_private (widget_class, GsOverviewPage, stack_overview);
+       gtk_widget_class_bind_template_child (widget_class, GsOverviewPage, infobar_third_party);
+       gtk_widget_class_bind_template_child (widget_class, GsOverviewPage, label_third_party);
+       gtk_widget_class_bind_template_child (widget_class, GsOverviewPage, featured_carousel);
+       gtk_widget_class_bind_template_child (widget_class, GsOverviewPage, box_overview);
+       gtk_widget_class_bind_template_child (widget_class, GsOverviewPage, box_popular);
+       gtk_widget_class_bind_template_child (widget_class, GsOverviewPage, box_popular_rotating);
+       gtk_widget_class_bind_template_child (widget_class, GsOverviewPage, box_recent);
+       gtk_widget_class_bind_template_child (widget_class, GsOverviewPage, category_heading);
+       gtk_widget_class_bind_template_child (widget_class, GsOverviewPage, flowbox_categories);
+       gtk_widget_class_bind_template_child (widget_class, GsOverviewPage, popular_heading);
+       gtk_widget_class_bind_template_child (widget_class, GsOverviewPage, recent_heading);
+       gtk_widget_class_bind_template_child (widget_class, GsOverviewPage, scrolledwindow_overview);
+       gtk_widget_class_bind_template_child (widget_class, GsOverviewPage, stack_overview);
        gtk_widget_class_bind_template_callback (widget_class, featured_carousel_app_clicked_cb);
 }
 
diff --git a/src/gs-overview-page.h b/src/gs-overview-page.h
index 6bd53eb1d..49df243f8 100644
--- a/src/gs-overview-page.h
+++ b/src/gs-overview-page.h
@@ -15,14 +15,7 @@ G_BEGIN_DECLS
 
 #define GS_TYPE_OVERVIEW_PAGE (gs_overview_page_get_type ())
 
-G_DECLARE_DERIVABLE_TYPE (GsOverviewPage, gs_overview_page, GS, OVERVIEW_PAGE, GsPage)
-
-struct _GsOverviewPageClass
-{
-       GsPageClass              parent_class;
-
-       void    (*refreshed)    (GsOverviewPage *self);
-};
+G_DECLARE_FINAL_TYPE (GsOverviewPage, gs_overview_page, GS, OVERVIEW_PAGE, GsPage)
 
 GsOverviewPage *gs_overview_page_new           (void);
 void            gs_overview_page_set_category  (GsOverviewPage         *self,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]