[gnome-software] feature tile: Derive directly from GtkButton
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] feature tile: Derive directly from GtkButton
- Date: Sun, 3 Aug 2014 15:26:26 +0000 (UTC)
commit f990bfc00f8c9abf9afbe9ba7e6d68968f070c00
Author: Kalev Lember <kalevlember gmail com>
Date: Sun Aug 3 16:16:31 2014 +0200
feature tile: Derive directly from GtkButton
src/feature-tile.ui | 107 +++++++++++++++++++++++-------------------------
src/gs-feature-tile.c | 35 +---------------
src/gs-feature-tile.h | 6 +--
3 files changed, 55 insertions(+), 93 deletions(-)
---
diff --git a/src/feature-tile.ui b/src/feature-tile.ui
index b69d353..c59f9a4 100644
--- a/src/feature-tile.ui
+++ b/src/feature-tile.ui
@@ -1,86 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.10 -->
- <template class="GsFeatureTile" parent="GtkBin">
+ <template class="GsFeatureTile" parent="GtkButton">
<property name="visible">True</property>
+ <property name="halign">fill</property>
+ <style>
+ <class name="featured-tile"/>
+ </style>
<child>
- <object class="GtkButton" id="button">
+ <object class="GtkOverlay" id="overlay">
<property name="visible">True</property>
<property name="halign">fill</property>
- <style>
- <class name="featured-tile"/>
- </style>
+ <property name="valign">fill</property>
+ <child type="overlay">
+ <object class="GtkImage" id="waiting">
+ <property name="visible">True</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="pixel-size">16</property>
+ <property name="icon-name">content-loading-symbolic</property>
+ <style>
+ <class name="dim-label"/>
+ </style>
+ </object>
+ </child>
<child>
- <object class="GtkOverlay" id="overlay">
+ <object class="GsBox" id="box">
<property name="visible">True</property>
- <property name="halign">fill</property>
- <property name="valign">fill</property>
- <child type="overlay">
- <object class="GtkImage" id="waiting">
+ <property name="hexpand">True</property>
+ <child>
+ <object class="GtkEventBox" id="image">
<property name="visible">True</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
- <property name="pixel-size">16</property>
- <property name="icon-name">content-loading-symbolic</property>
+ <property name="can_focus">False</property>
+ <property name="visible_window">True</property>
+ <property name="height_request">240</property>
<style>
- <class name="dim-label"/>
+ <class name="featured-image"/>
</style>
</object>
+ <packing>
+ <property name="relative_size">1.0</property>
+ </packing>
</child>
<child>
- <object class="GsBox" id="box">
+ <object class="GtkBox" id="box2">
<property name="visible">True</property>
- <property name="hexpand">True</property>
+ <property name="orientation">vertical</property>
+ <property name="margin">40</property>
<child>
- <object class="GtkEventBox" id="image">
+ <object class="GtkLabel" id="title">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="visible_window">True</property>
- <property name="height_request">240</property>
- <style>
- <class name="featured-image"/>
- </style>
+ <property name="xalign">0</property>
+ <property name="halign">start</property>
+ <property name="valign">end</property>
+ <property name="wrap">True</property>
+ <attributes>
+ <attribute name="scale" value="2.5"/>
+ <attribute name="weight" value="700"/>
+ </attributes>
</object>
<packing>
- <property name="relative_size">1.0</property>
+ <property name="expand">True</property>
</packing>
</child>
<child>
- <object class="GtkBox" id="box2">
+ <object class="GtkLabel" id="subtitle">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="margin">40</property>
- <child>
- <object class="GtkLabel" id="title">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="halign">start</property>
- <property name="valign">end</property>
- <property name="wrap">True</property>
- <attributes>
- <attribute name="scale" value="2.5"/>
- <attribute name="weight" value="700"/>
- </attributes>
- </object>
- <packing>
- <property name="expand">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="subtitle">
- <property name="visible">True</property>
- <property name="wrap">True</property>
- <property name="xalign">0</property>
- <property name="halign">start</property>
- <property name="valign">start</property>
- </object>
- </child>
+ <property name="wrap">True</property>
+ <property name="xalign">0</property>
+ <property name="halign">start</property>
+ <property name="valign">start</property>
</object>
- <packing>
- <property name="relative_size">1.0</property>
- </packing>
</child>
</object>
+ <packing>
+ <property name="relative_size">1.0</property>
+ </packing>
</child>
</object>
</child>
diff --git a/src/gs-feature-tile.c b/src/gs-feature-tile.c
index 33cc978..365ac36 100644
--- a/src/gs-feature-tile.c
+++ b/src/gs-feature-tile.c
@@ -29,7 +29,6 @@
struct _GsFeatureTilePrivate
{
GsApp *app;
- GtkWidget *button;
GtkWidget *image;
GtkWidget *title;
GtkWidget *subtitle;
@@ -37,14 +36,7 @@ struct _GsFeatureTilePrivate
GtkCssProvider *provider;
};
-G_DEFINE_TYPE_WITH_PRIVATE (GsFeatureTile, gs_feature_tile, GTK_TYPE_BIN)
-
-enum {
- SIGNAL_CLICKED,
- SIGNAL_LAST
-};
-
-static guint signals [SIGNAL_LAST] = { 0 };
+G_DEFINE_TYPE_WITH_PRIVATE (GsFeatureTile, gs_feature_tile, GTK_TYPE_BUTTON)
GsApp *
gs_feature_tile_get_app (GsFeatureTile *tile)
@@ -60,12 +52,10 @@ gs_feature_tile_get_app (GsFeatureTile *tile)
static void
app_state_changed (GsApp *app, GParamSpec *pspec, GsFeatureTile *tile)
{
- GsFeatureTilePrivate *priv;
AtkObject *accessible;
gchar *name;
- priv = gs_feature_tile_get_instance_private (tile);
- accessible = gtk_widget_get_accessible (priv->button);
+ accessible = gtk_widget_get_accessible (GTK_WIDGET (tile));
switch (gs_app_get_state (app)) {
case AS_APP_STATE_INSTALLED:
@@ -182,16 +172,6 @@ gs_feature_tile_destroy (GtkWidget *widget)
}
static void
-button_clicked (GsFeatureTile *tile)
-{
- GsFeatureTilePrivate *priv;
-
- priv = gs_feature_tile_get_instance_private (tile);
- if (priv->app)
- g_signal_emit (tile, signals[SIGNAL_CLICKED], 0);
-}
-
-static void
gs_feature_tile_init (GsFeatureTile *tile)
{
GsFeatureTilePrivate *priv;
@@ -199,8 +179,6 @@ gs_feature_tile_init (GsFeatureTile *tile)
gtk_widget_set_has_window (GTK_WIDGET (tile), FALSE);
gtk_widget_init_template (GTK_WIDGET (tile));
priv = gs_feature_tile_get_instance_private (tile);
- g_signal_connect_swapped (priv->button, "clicked",
- G_CALLBACK (button_clicked), tile);
priv->provider = gtk_css_provider_new ();
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
@@ -211,21 +189,12 @@ gs_feature_tile_init (GsFeatureTile *tile)
static void
gs_feature_tile_class_init (GsFeatureTileClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
widget_class->destroy = gs_feature_tile_destroy;
- signals [SIGNAL_CLICKED] =
- g_signal_new ("clicked",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GsFeatureTileClass, clicked),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Software/feature-tile.ui");
- gtk_widget_class_bind_template_child_private (widget_class, GsFeatureTile, button);
gtk_widget_class_bind_template_child_private (widget_class, GsFeatureTile, image);
gtk_widget_class_bind_template_child_private (widget_class, GsFeatureTile, title);
gtk_widget_class_bind_template_child_private (widget_class, GsFeatureTile, subtitle);
diff --git a/src/gs-feature-tile.h b/src/gs-feature-tile.h
index e8239b0..a12dce5 100644
--- a/src/gs-feature-tile.h
+++ b/src/gs-feature-tile.h
@@ -41,15 +41,13 @@ typedef struct _GsFeatureTilePrivate GsFeatureTilePrivate;
struct _GsFeatureTile
{
- GtkBin parent;
+ GtkButton parent;
GsFeatureTilePrivate *priv;
};
struct _GsFeatureTileClass
{
- GtkBinClass parent_class;
-
- void (*clicked) (GsFeatureTile *tile);
+ GtkButtonClass parent_class;
};
GType gs_feature_tile_get_type (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]