[gnome-software/wip/jrocha/abstract-app-tiles: 3/3] Make GsFeatureTile a subclass of GsAppTile
- From: Joaquim Manuel Pereira Rocha <jrocha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/jrocha/abstract-app-tiles: 3/3] Make GsFeatureTile a subclass of GsAppTile
- Date: Thu, 23 Jun 2016 12:58:23 +0000 (UTC)
commit 455bb55aea18645352ba3e650e7f82e7e510c1d6
Author: Joaquim Rocha <jrocha endlessm com>
Date: Thu Jun 23 14:44:30 2016 +0200
Make GsFeatureTile a subclass of GsAppTile
Also adapt the code in gs-shell-overview accordingly.
src/gs-feature-tile.c | 24 +++++++++++++-----------
src/gs-feature-tile.h | 6 ++----
src/gs-feature-tile.ui | 2 +-
src/gs-shell-overview.c | 13 +------------
4 files changed, 17 insertions(+), 28 deletions(-)
---
diff --git a/src/gs-feature-tile.c b/src/gs-feature-tile.c
index 80a490d..e9b2a84 100644
--- a/src/gs-feature-tile.c
+++ b/src/gs-feature-tile.c
@@ -29,7 +29,7 @@
struct _GsFeatureTile
{
- GtkButton parent_instance;
+ GsAppTile parent_instance;
GsApp *app;
GtkWidget *image;
@@ -38,14 +38,12 @@ struct _GsFeatureTile
GtkWidget *subtitle;
};
-G_DEFINE_TYPE (GsFeatureTile, gs_feature_tile, GTK_TYPE_BUTTON)
+G_DEFINE_TYPE (GsFeatureTile, gs_feature_tile, GS_TYPE_APP_TILE)
-GsApp *
-gs_feature_tile_get_app (GsFeatureTile *tile)
+static GsApp *
+gs_feature_tile_get_app (GsAppTile *tile)
{
- g_return_val_if_fail (GS_IS_FEATURE_TILE (tile), NULL);
-
- return tile->app;
+ return GS_FEATURE_TILE (tile)->app;
}
static gboolean
@@ -88,12 +86,12 @@ app_state_changed (GsApp *app, GParamSpec *pspec, GsFeatureTile *tile)
g_idle_add (app_state_changed_idle, g_object_ref (tile));
}
-void
-gs_feature_tile_set_app (GsFeatureTile *tile, GsApp *app)
+static void
+gs_feature_tile_set_app (GsAppTile *app_tile, GsApp *app)
{
+ GsFeatureTile *tile = GS_FEATURE_TILE (app_tile);
g_autoptr(GString) data = NULL;
- g_return_if_fail (GS_IS_FEATURE_TILE (tile));
g_return_if_fail (GS_IS_APP (app) || app == NULL);
if (tile->app)
@@ -141,9 +139,13 @@ static void
gs_feature_tile_class_init (GsFeatureTileClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GsAppTileClass *app_tile_class = GS_APP_TILE_CLASS (klass);
widget_class->destroy = gs_feature_tile_destroy;
+ app_tile_class->set_app = gs_feature_tile_set_app;
+ app_tile_class->get_app = gs_feature_tile_get_app;
+
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Software/gs-feature-tile.ui");
gtk_widget_class_bind_template_child (widget_class, GsFeatureTile, image);
@@ -158,7 +160,7 @@ gs_feature_tile_new (GsApp *app)
GsFeatureTile *tile;
tile = g_object_new (GS_TYPE_FEATURE_TILE, NULL);
- gs_feature_tile_set_app (tile, app);
+ gs_app_tile_set_app (GS_APP_TILE (tile), app);
return GTK_WIDGET (tile);
}
diff --git a/src/gs-feature-tile.h b/src/gs-feature-tile.h
index 5a8848b..e8e707c 100644
--- a/src/gs-feature-tile.h
+++ b/src/gs-feature-tile.h
@@ -25,17 +25,15 @@
#include <gtk/gtk.h>
#include "gs-app.h"
+#include "gs-app-tile.h"
G_BEGIN_DECLS
#define GS_TYPE_FEATURE_TILE (gs_feature_tile_get_type ())
-G_DECLARE_FINAL_TYPE (GsFeatureTile, gs_feature_tile, GS, FEATURE_TILE, GtkButton)
+G_DECLARE_FINAL_TYPE (GsFeatureTile, gs_feature_tile, GS, FEATURE_TILE, GsAppTile)
GtkWidget *gs_feature_tile_new (GsApp *app);
-GsApp *gs_feature_tile_get_app (GsFeatureTile *tile);
-void gs_feature_tile_set_app (GsFeatureTile *tile,
- GsApp *app);
G_END_DECLS
diff --git a/src/gs-feature-tile.ui b/src/gs-feature-tile.ui
index 1d77f4d..d5c74cb 100644
--- a/src/gs-feature-tile.ui
+++ b/src/gs-feature-tile.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.10 -->
- <template class="GsFeatureTile" parent="GtkButton">
+ <template class="GsFeatureTile" parent="GsAppTile">
<property name="visible">True</property>
<property name="halign">fill</property>
<style>
diff --git a/src/gs-shell-overview.c b/src/gs-shell-overview.c
index 217a1e7..e89396d 100644
--- a/src/gs-shell-overview.c
+++ b/src/gs-shell-overview.c
@@ -231,17 +231,6 @@ out:
}
static void
-feature_tile_clicked (GsFeatureTile *tile, gpointer data)
-{
- GsShellOverview *self = GS_SHELL_OVERVIEW (data);
- GsShellOverviewPrivate *priv = gs_shell_overview_get_instance_private (self);
- GsApp *app;
-
- app = gs_feature_tile_get_app (tile);
- gs_shell_show_app (priv->shell, app);
-}
-
-static void
gs_shell_overview_get_featured_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
@@ -280,7 +269,7 @@ gs_shell_overview_get_featured_cb (GObject *source_object,
app = gs_app_list_index (list, 0);
tile = gs_feature_tile_new (app);
g_signal_connect (tile, "clicked",
- G_CALLBACK (feature_tile_clicked), self);
+ G_CALLBACK (app_tile_clicked), self);
gtk_container_add (GTK_CONTAINER (priv->bin_featured), tile);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]