[gnome-software] app tile: Derive directly from GtkButton
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] app tile: Derive directly from GtkButton
- Date: Sun, 3 Aug 2014 12:41:43 +0000 (UTC)
commit 3ebba01e95b493a3d6ca0134abe49b6c7536c1a0
Author: Kalev Lember <kalevlember gmail com>
Date: Sun Aug 3 12:58:25 2014 +0200
app tile: Derive directly from GtkButton
src/app-tile.ui | 199 ++++++++++++++++++++++++++---------------------------
src/gs-app-tile.c | 33 +--------
src/gs-app-tile.h | 6 +-
3 files changed, 101 insertions(+), 137 deletions(-)
---
diff --git a/src/app-tile.ui b/src/app-tile.ui
index b234197..0e4caed 100644
--- a/src/app-tile.ui
+++ b/src/app-tile.ui
@@ -1,124 +1,119 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.10 -->
- <template class="GsAppTile" parent="GtkBin">
+ <template class="GsAppTile" parent="GtkButton">
<property name="visible">True</property>
+ <property name="hexpand">True</property>
+ <style>
+ <class name="view"/>
+ <class name="tile"/>
+ </style>
<child>
- <object class="GtkButton" id="button">
+ <object class="GtkOverlay" id="overlay">
<property name="visible">True</property>
- <property name="hexpand">True</property>
- <style>
- <class name="view"/>
- <class name="tile"/>
- </style>
+ <property name="halign">fill</property>
+ <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 type="overlay">
+ <object class="GtkEventBox" id="eventbox">
+ <property name="no_show_all">True</property>
+ <property name="visible_window">True</property>
+ <property name="halign">start</property>
+ <property name="valign">start</property>
+ <property name="margin-top">53</property>
+ <property name="margin-start">4</property>
+ <style>
+ <class name="installed-overlay-box"/>
+ </style>
+ <child>
+ <object class="GtkLabel" id="installed-label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Installed</property>
+ <property name="margin-start">16</property>
+ <property name="margin-end">16</property>
+ <property name="margin-top">4</property>
+ <property name="margin-bottom">4</property>
+ </object>
+ </child>
+ </object>
+ </child>
<child>
- <object class="GtkOverlay" id="overlay">
+ <object class="GtkGrid" id="grid">
<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="margin">9</property>
+ <property name="row-spacing">3</property>
+ <property name="column-spacing">12</property>
+ <child>
+ <object class="GtkImage" 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>
+ </object>
+ <packing>
+ <property name="left-attach">0</property>
+ <property name="top-attach">0</property>
+ <property name="width">1</property>
+ <property name="height">3</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="name">
+ <property name="visible">True</property>
+ <property name="ellipsize">end</property>
+ <property name="xalign">0.0</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
<style>
- <class name="dim-label"/>
+ <class name="app-tile-label"/>
</style>
</object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
</child>
- <child type="overlay">
- <object class="GtkEventBox" id="eventbox">
- <property name="no_show_all">True</property>
- <property name="visible_window">True</property>
+ <child>
+ <object class="GsStarWidget" id="stars">
+ <property name="visible">False</property>
<property name="halign">start</property>
- <property name="valign">start</property>
- <property name="margin-top">53</property>
- <property name="margin-start">4</property>
- <style>
- <class name="installed-overlay-box"/>
- </style>
- <child>
- <object class="GtkLabel" id="installed-label">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Installed</property>
- <property name="margin-start">16</property>
- <property name="margin-end">16</property>
- <property name="margin-top">4</property>
- <property name="margin-bottom">4</property>
- </object>
- </child>
</object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
</child>
<child>
- <object class="GtkGrid" id="grid">
+ <object class="GtkLabel" id="summary">
<property name="visible">True</property>
- <property name="margin">9</property>
- <property name="row-spacing">3</property>
- <property name="column-spacing">12</property>
- <child>
- <object class="GtkImage" id="image">
- <property name="visible">True</property>
- </object>
- <packing>
- <property name="left-attach">0</property>
- <property name="top-attach">0</property>
- <property name="width">1</property>
- <property name="height">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="name">
- <property name="visible">True</property>
- <property name="ellipsize">end</property>
- <property name="xalign">0.0</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- <style>
- <class name="app-tile-label"/>
- </style>
- </object>
- <packing>
- <property name="left-attach">1</property>
- <property name="top-attach">0</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GsStarWidget" id="stars">
- <property name="visible">False</property>
- <property name="halign">start</property>
- </object>
- <packing>
- <property name="left-attach">1</property>
- <property name="top-attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="summary">
- <property name="visible">True</property>
- <property name="ellipsize">end</property>
- <property name="xalign">0.0</property>
- <property name="yalign">0.0</property>
- <property name="lines">2</property>
- <property name="vexpand">True</property>
- <style>
- <class name="app-tile-label"/>
- </style>
- </object>
- <packing>
- <property name="left-attach">1</property>
- <property name="top-attach">2</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
+ <property name="ellipsize">end</property>
+ <property name="xalign">0.0</property>
+ <property name="yalign">0.0</property>
+ <property name="lines">2</property>
+ <property name="vexpand">True</property>
+ <style>
+ <class name="app-tile-label"/>
+ </style>
</object>
+ <packing>
+ <property name="left-attach">1</property>
+ <property name="top-attach">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
</child>
</object>
</child>
diff --git a/src/gs-app-tile.c b/src/gs-app-tile.c
index 0612dc1..0236643 100644
--- a/src/gs-app-tile.c
+++ b/src/gs-app-tile.c
@@ -30,7 +30,6 @@
struct _GsAppTilePrivate
{
GsApp *app;
- GtkWidget *button;
GtkWidget *image;
GtkWidget *name;
GtkWidget *summary;
@@ -39,14 +38,7 @@ struct _GsAppTilePrivate
GtkWidget *stars;
};
-G_DEFINE_TYPE_WITH_PRIVATE (GsAppTile, gs_app_tile, GTK_TYPE_BIN)
-
-enum {
- SIGNAL_CLICKED,
- SIGNAL_LAST
-};
-
-static guint signals [SIGNAL_LAST] = { 0 };
+G_DEFINE_TYPE_WITH_PRIVATE (GsAppTile, gs_app_tile, GTK_TYPE_BUTTON)
GsApp *
gs_app_tile_get_app (GsAppTile *tile)
@@ -69,7 +61,7 @@ app_state_changed (GsApp *app, GParamSpec *pspec, GsAppTile *tile)
gchar *name;
priv = gs_app_tile_get_instance_private (tile);
- accessible = gtk_widget_get_accessible (priv->button);
+ accessible = gtk_widget_get_accessible (GTK_WIDGET (tile));
label = gtk_bin_get_child (GTK_BIN (priv->eventbox));
switch (gs_app_get_state (app)) {
@@ -187,16 +179,6 @@ gs_app_tile_destroy (GtkWidget *widget)
}
static void
-button_clicked (GsAppTile *tile)
-{
- GsAppTilePrivate *priv;
-
- priv = gs_app_tile_get_instance_private (tile);
- if (priv->app)
- g_signal_emit (tile, signals[SIGNAL_CLICKED], 0);
-}
-
-static void
gs_app_tile_init (GsAppTile *tile)
{
GsAppTilePrivate *priv;
@@ -204,29 +186,18 @@ gs_app_tile_init (GsAppTile *tile)
gtk_widget_set_has_window (GTK_WIDGET (tile), FALSE);
gtk_widget_init_template (GTK_WIDGET (tile));
priv = gs_app_tile_get_instance_private (tile);
- g_signal_connect_swapped (priv->button, "clicked",
- G_CALLBACK (button_clicked), tile);
gs_star_widget_set_icon_size (GS_STAR_WIDGET (priv->stars), 12);
}
static void
gs_app_tile_class_init (GsAppTileClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
widget_class->destroy = gs_app_tile_destroy;
- signals [SIGNAL_CLICKED] =
- g_signal_new ("clicked",
- G_TYPE_FROM_CLASS (object_class), G_SIGNAL_RUN_LAST,
- G_STRUCT_OFFSET (GsAppTileClass, clicked),
- NULL, NULL, g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE, 0);
-
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Software/app-tile.ui");
- gtk_widget_class_bind_template_child_private (widget_class, GsAppTile, button);
gtk_widget_class_bind_template_child_private (widget_class, GsAppTile, image);
gtk_widget_class_bind_template_child_private (widget_class, GsAppTile, name);
gtk_widget_class_bind_template_child_private (widget_class, GsAppTile, summary);
diff --git a/src/gs-app-tile.h b/src/gs-app-tile.h
index 69afef3..92df174 100644
--- a/src/gs-app-tile.h
+++ b/src/gs-app-tile.h
@@ -41,15 +41,13 @@ typedef struct _GsAppTilePrivate GsAppTilePrivate;
struct _GsAppTile
{
- GtkBin parent;
+ GtkButton parent;
GsAppTilePrivate *priv;
};
struct _GsAppTileClass
{
- GtkBinClass parent_class;
-
- void (*clicked) (GsAppTile *tile);
+ GtkButtonClass parent_class;
};
GType gs_app_tile_get_type (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]