-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
exm-info-bar.c
107 lines (83 loc) · 2.54 KB
/
exm-info-bar.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "exm-info-bar.h"
#include "exm-info-bar-item.h"
#include <glib/gi18n.h>
struct _ExmInfoBar
{
GtkBox parent_instance;
ExmInfoBarItem *downloads_item;
ExmInfoBarItem *version_item;
guint signal_handler;
};
G_DEFINE_FINAL_TYPE (ExmInfoBar, exm_info_bar, GTK_TYPE_BOX)
enum {
PROP_0,
N_PROPS
};
static GParamSpec *properties [N_PROPS];
ExmInfoBar *
exm_info_bar_new (void)
{
return g_object_new (EXM_TYPE_INFO_BAR, NULL);
}
static void
exm_info_bar_finalize (GObject *object)
{
ExmInfoBar *self = (ExmInfoBar *)object;
G_OBJECT_CLASS (exm_info_bar_parent_class)->finalize (object);
}
static void
exm_info_bar_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
ExmInfoBar *self = EXM_INFO_BAR (object);
switch (prop_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
exm_info_bar_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
ExmInfoBar *self = EXM_INFO_BAR (object);
switch (prop_id)
{
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
void
exm_info_bar_set_downloads (ExmInfoBar *self,
guint downloads)
{
exm_info_bar_item_set_subtitle (self->downloads_item, g_strdup_printf ("%'d", downloads));
}
void
exm_info_bar_set_version (ExmInfoBar *self,
double version)
{
exm_info_bar_item_set_subtitle (self->version_item, version == -1 ? _("Unsupported") : g_strdup_printf("%.f", version));
}
static void
exm_info_bar_class_init (ExmInfoBarClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = exm_info_bar_finalize;
object_class->get_property = exm_info_bar_get_property;
object_class->set_property = exm_info_bar_set_property;
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
gtk_widget_class_set_template_from_resource (widget_class, "/com/mattjakeman/ExtensionManager/exm-info-bar.ui");
g_type_ensure (EXM_TYPE_INFO_BAR);
gtk_widget_class_bind_template_child (widget_class, ExmInfoBar, downloads_item);
gtk_widget_class_bind_template_child (widget_class, ExmInfoBar, version_item);
}
static void
exm_info_bar_init (ExmInfoBar *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
}