[gnome-software/gnome-3-18] Get rid of gs_app_row_set_app and gs_app_addon_row_set_addon
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-3-18] Get rid of gs_app_row_set_app and gs_app_addon_row_set_addon
- Date: Mon, 12 Oct 2015 09:24:33 +0000 (UTC)
commit 772cbf78cff76ee0ee71d22fffbf0b057416944e
Author: Rafal Luzynski <digitalfreak lingonborough com>
Date: Tue Sep 29 00:32:01 2015 +0200
Get rid of gs_app_row_set_app and gs_app_addon_row_set_addon
These functions are supposed to be called only once per a lifetime
of their respective objects. To ensure this it's better to remove
them, or more precisely make them private. Also they are kinda
error prone so it's better to control how and when they are called.
https://bugzilla.gnome.org/show_bug.cgi?id=755763
src/gs-app-addon-row.c | 16 +++++++++-------
src/gs-app-addon-row.h | 4 +---
src/gs-app-row.c | 18 ++++++++++++------
src/gs-app-row.h | 4 +---
src/gs-shell-details.c | 3 +--
src/gs-shell-extras.c | 3 +--
src/gs-shell-installed.c | 3 +--
src/gs-shell-search.c | 3 +--
src/gs-update-list.c | 3 +--
9 files changed, 28 insertions(+), 29 deletions(-)
---
diff --git a/src/gs-app-addon-row.c b/src/gs-app-addon-row.c
index 7b0ace1..ca407a4 100644
--- a/src/gs-app-addon-row.c
+++ b/src/gs-app-addon-row.c
@@ -165,13 +165,9 @@ gs_app_addon_row_notify_props_changed_cb (GsApp *app,
g_idle_add (gs_app_addon_row_refresh_idle, g_object_ref (row));
}
-void
+static void
gs_app_addon_row_set_addon (GsAppAddonRow *row, GsApp *app)
{
- g_return_if_fail (GS_IS_APP_ADDON_ROW (row));
- g_return_if_fail (GS_IS_APP (app));
-
- g_assert (row->app == NULL);
row->app = g_object_ref (app);
g_signal_connect_object (row->app, "notify::state",
@@ -276,9 +272,15 @@ gs_app_addon_row_get_selected (GsAppAddonRow *row)
}
GtkWidget *
-gs_app_addon_row_new (void)
+gs_app_addon_row_new (GsApp *app)
{
- return g_object_new (GS_TYPE_APP_ADDON_ROW, NULL);
+ GtkWidget *row;
+
+ g_return_val_if_fail (GS_IS_APP (app), NULL);
+
+ row = g_object_new (GS_TYPE_APP_ADDON_ROW, NULL);
+ gs_app_addon_row_set_addon (GS_APP_ADDON_ROW (row), app);
+ return row;
}
/* vim: set noexpandtab: */
diff --git a/src/gs-app-addon-row.h b/src/gs-app-addon-row.h
index 0c38b45..f813afe 100644
--- a/src/gs-app-addon-row.h
+++ b/src/gs-app-addon-row.h
@@ -32,14 +32,12 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (GsAppAddonRow, gs_app_addon_row, GS, APP_ADDON_ROW, GtkListBoxRow)
-GtkWidget *gs_app_addon_row_new (void);
+GtkWidget *gs_app_addon_row_new (GsApp *app);
void gs_app_addon_row_refresh (GsAppAddonRow *row);
void gs_app_addon_row_set_selected (GsAppAddonRow *row,
gboolean selected);
gboolean gs_app_addon_row_get_selected (GsAppAddonRow *row);
GsApp *gs_app_addon_row_get_addon (GsAppAddonRow *row);
-void gs_app_addon_row_set_addon (GsAppAddonRow *row,
- GsApp *app);
G_END_DECLS
diff --git a/src/gs-app-row.c b/src/gs-app-row.c
index 8e6666f..a39acaa 100644
--- a/src/gs-app-row.c
+++ b/src/gs-app-row.c
@@ -349,14 +349,11 @@ gs_app_row_notify_props_changed_cb (GsApp *app,
/**
* gs_app_row_set_app:
**/
-void
+static void
gs_app_row_set_app (GsAppRow *app_row, GsApp *app)
{
GsAppRowPrivate *priv = gs_app_row_get_instance_private (app_row);
- g_return_if_fail (GS_IS_APP_ROW (app_row));
- g_return_if_fail (GS_IS_APP (app));
- g_assert (priv->app == NULL);
priv->app = g_object_ref (app);
g_signal_connect_object (priv->app, "notify::state",
@@ -514,6 +511,7 @@ gs_app_row_set_colorful (GsAppRow *app_row,
GsAppRowPrivate *priv = gs_app_row_get_instance_private (app_row);
priv->colorful = colorful;
+ gs_app_row_refresh (app_row);
}
void
@@ -522,6 +520,7 @@ gs_app_row_set_show_codec (GsAppRow *app_row, gboolean show_codec)
GsAppRowPrivate *priv = gs_app_row_get_instance_private (app_row);
priv->show_codec = show_codec;
+ gs_app_row_refresh (app_row);
}
/**
@@ -535,6 +534,7 @@ gs_app_row_set_show_update (GsAppRow *app_row, gboolean show_update)
GsAppRowPrivate *priv = gs_app_row_get_instance_private (app_row);
priv->show_update = show_update;
+ gs_app_row_refresh (app_row);
}
void
@@ -573,9 +573,15 @@ gs_app_row_get_selected (GsAppRow *app_row)
}
GtkWidget *
-gs_app_row_new (void)
+gs_app_row_new (GsApp *app)
{
- return g_object_new (GS_TYPE_APP_ROW, NULL);
+ GtkWidget *app_row;
+
+ g_return_val_if_fail (GS_IS_APP (app), NULL);
+
+ app_row = g_object_new (GS_TYPE_APP_ROW, NULL);
+ gs_app_row_set_app (GS_APP_ROW (app_row), app);
+ return app_row;
}
/* vim: set noexpandtab: */
diff --git a/src/gs-app-row.h b/src/gs-app-row.h
index 885f28b..00d3f28 100644
--- a/src/gs-app-row.h
+++ b/src/gs-app-row.h
@@ -39,7 +39,7 @@ struct _GsAppRowClass
void (*unrevealed) (GsAppRow *app_row);
};
-GtkWidget *gs_app_row_new (void);
+GtkWidget *gs_app_row_new (GsApp *app);
void gs_app_row_refresh (GsAppRow *app_row);
void gs_app_row_unreveal (GsAppRow *app_row);
void gs_app_row_set_colorful (GsAppRow *app_row,
@@ -54,8 +54,6 @@ void gs_app_row_set_selected (GsAppRow *app_row,
gboolean selected);
gboolean gs_app_row_get_selected (GsAppRow *app_row);
GsApp *gs_app_row_get_app (GsAppRow *app_row);
-void gs_app_row_set_app (GsAppRow *app_row,
- GsApp *app);
void gs_app_row_set_size_groups (GsAppRow *app_row,
GtkSizeGroup *image,
GtkSizeGroup *name);
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 3e7240e..28bbaa0 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -852,9 +852,8 @@ gs_shell_details_refresh_addons (GsShellDetails *self)
if (gs_app_get_state (addon) == AS_APP_STATE_UNAVAILABLE)
continue;
- row = gs_app_addon_row_new ();
+ row = gs_app_addon_row_new (addon);
- gs_app_addon_row_set_addon (GS_APP_ADDON_ROW (row), addon);
gtk_container_add (GTK_CONTAINER (self->list_box_addons), row);
gtk_widget_show (row);
diff --git a/src/gs-shell-extras.c b/src/gs-shell-extras.c
index 70dc6fd..5c5ec23 100644
--- a/src/gs-shell-extras.c
+++ b/src/gs-shell-extras.c
@@ -291,9 +291,8 @@ gs_shell_extras_add_app (GsShellExtras *self, GsApp *app, SearchData *search_dat
GTK_WIDGET (l->data));
}
- app_row = gs_app_row_new ();
+ app_row = gs_app_row_new (app);
gs_app_row_set_show_codec (GS_APP_ROW (app_row), TRUE);
- gs_app_row_set_app (GS_APP_ROW (app_row), app);
g_object_set_data_full (G_OBJECT (app_row), "missing-title", g_strdup (search_data->title), g_free);
diff --git a/src/gs-shell-installed.c b/src/gs-shell-installed.c
index f4a1f96..4051668 100644
--- a/src/gs-shell-installed.c
+++ b/src/gs-shell-installed.c
@@ -158,7 +158,7 @@ gs_shell_installed_add_app (GsShellInstalled *self, GsApp *app)
{
GtkWidget *app_row;
- app_row = gs_app_row_new ();
+ app_row = gs_app_row_new (app);
gs_app_row_set_colorful (GS_APP_ROW (app_row), FALSE);
g_signal_connect (app_row, "button-clicked",
G_CALLBACK (gs_shell_installed_app_remove_cb), self);
@@ -167,7 +167,6 @@ gs_shell_installed_add_app (GsShellInstalled *self, GsApp *app)
app_row, 0);
g_signal_connect_swapped (app_row, "notify::selected",
G_CALLBACK (selection_changed), self);
- gs_app_row_set_app (GS_APP_ROW (app_row), app);
gtk_container_add (GTK_CONTAINER (self->list_box_install), app_row);
gs_app_row_set_size_groups (GS_APP_ROW (app_row),
self->sizegroup_image,
diff --git a/src/gs-shell-search.c b/src/gs-shell-search.c
index f84793a..b20b2e0 100644
--- a/src/gs-shell-search.c
+++ b/src/gs-shell-search.c
@@ -122,11 +122,10 @@ gs_shell_search_get_search_cb (GObject *source_object,
gtk_stack_set_visible_child_name (GTK_STACK (self->stack_search), "results");
for (l = list; l != NULL; l = l->next) {
app = GS_APP (l->data);
- app_row = gs_app_row_new ();
+ app_row = gs_app_row_new (app);
g_signal_connect (app_row, "button-clicked",
G_CALLBACK (gs_shell_search_app_row_clicked_cb),
self);
- gs_app_row_set_app (GS_APP_ROW (app_row), app);
gtk_container_add (GTK_CONTAINER (self->list_box_search), app_row);
gs_app_row_set_size_groups (GS_APP_ROW (app_row),
self->sizegroup_image,
diff --git a/src/gs-update-list.c b/src/gs-update-list.c
index 46d5951..40e24e1 100644
--- a/src/gs-update-list.c
+++ b/src/gs-update-list.c
@@ -46,9 +46,8 @@ gs_update_list_add_app (GsUpdateList *update_list,
{
GtkWidget *app_row;
- app_row = gs_app_row_new ();
+ app_row = gs_app_row_new (app);
gs_app_row_set_show_update (GS_APP_ROW (app_row), TRUE);
- gs_app_row_set_app (GS_APP_ROW (app_row), app);
gtk_container_add (GTK_CONTAINER (update_list), app_row);
gs_app_row_set_size_groups (GS_APP_ROW (app_row),
update_list->sizegroup_image,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]