Add database ID as a property of AgChart
This commit is contained in:
parent
05be162c03
commit
a7afd80235
@ -46,6 +46,7 @@ typedef struct _AgChartPrivate {
|
||||
gchar *save_buffer;
|
||||
GList *planet_list;
|
||||
gchar *note;
|
||||
gint db_id;
|
||||
} AgChartPrivate;
|
||||
|
||||
enum {
|
||||
@ -54,6 +55,7 @@ enum {
|
||||
PROP_COUNTRY,
|
||||
PROP_CITY,
|
||||
PROP_NOTE,
|
||||
PROP_DBID,
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
@ -148,6 +150,24 @@ ag_chart_class_init(AgChartClass *klass)
|
||||
PROP_NOTE,
|
||||
properties[PROP_NOTE]
|
||||
);
|
||||
|
||||
properties[PROP_DBID] = g_param_spec_int(
|
||||
"db-id",
|
||||
"DB ID",
|
||||
"Database ID",
|
||||
-1, G_MAXINT,
|
||||
-1,
|
||||
G_PARAM_STATIC_NICK
|
||||
| G_PARAM_STATIC_NAME
|
||||
| G_PARAM_STATIC_BLURB
|
||||
| G_PARAM_READABLE
|
||||
| G_PARAM_WRITABLE
|
||||
);
|
||||
g_object_class_install_property(
|
||||
gobject_class,
|
||||
PROP_DBID,
|
||||
properties[PROP_DBID]
|
||||
);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -189,6 +209,11 @@ ag_chart_set_property(GObject *gobject,
|
||||
|
||||
break;
|
||||
|
||||
case PROP_DBID:
|
||||
ag_chart_set_db_id(AG_CHART(gobject), g_value_get_int(value));
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, param_spec);
|
||||
|
||||
@ -225,6 +250,11 @@ ag_chart_get_property(GObject *gobject,
|
||||
|
||||
break;
|
||||
|
||||
case PROP_DBID:
|
||||
g_value_set_int(value, priv->db_id);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, param_spec);
|
||||
|
||||
@ -2060,3 +2090,21 @@ ag_chart_get_db_save(AgChart *chart, gint db_id)
|
||||
|
||||
return save_data;
|
||||
}
|
||||
|
||||
void
|
||||
ag_chart_set_db_id(AgChart *chart, gint id)
|
||||
{
|
||||
AgChartPrivate *priv = ag_chart_get_instance_private(chart);
|
||||
|
||||
priv->db_id = id;
|
||||
|
||||
g_object_notify_by_pspec(G_OBJECT(chart), properties[PROP_DBID]);
|
||||
}
|
||||
|
||||
int
|
||||
ag_chart_get_db_id(AgChart *chart)
|
||||
{
|
||||
AgChartPrivate *priv = ag_chart_get_instance_private(chart);
|
||||
|
||||
return priv->db_id;
|
||||
}
|
||||
|
@ -147,6 +147,10 @@ GdkPixbuf *ag_chart_get_pixbuf(AgChart *chart,
|
||||
AgDisplayTheme *theme,
|
||||
GError **err);
|
||||
|
||||
void ag_chart_set_db_id(AgChart *chart, gint db_id);
|
||||
|
||||
gint ag_chart_get_db_id(AgChart *chart);
|
||||
|
||||
#define AG_CHART_ERROR (ag_chart_error_quark())
|
||||
GQuark ag_chart_error_quark(void);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user