6 #include "stuffkeeper-data-tag.h"
7 #include "stuffkeeper-data-schema.h"
8 #include "stuffkeeper-data-item.h"
12 class Stuffkeeper:Data:Label from Gtk:Label
14 private GObject *item = {NULL};
15 private gchar *field = {NULL} destroywith g_free;
16 private gulong changed_item_entry = {0};
21 field_item_changed(self,const gchar *id, Stuffkeeper:Data:Schema *schema)
24 value = stuffkeeper_data_schema_get_field_name(STUFFKEEPER_DATA_SCHEMA(self->_priv->item),self->_priv->field);
27 gchar *markup = g_markup_printf_escaped("<b>%s</b>", value);
28 gtk_label_set_text(GTK_LABEL(self), value);
29 gtk_label_set_markup(GTK_LABEL(self), markup);
38 schema_item_changed(self,GObject *item, gpointer data)
41 if(STUFFKEEPER_IS_DATA_SCHEMA(self->_priv->item))
43 value = stuffkeeper_data_schema_get_title(STUFFKEEPER_DATA_SCHEMA(self->_priv->item));
46 gtk_label_set_text(GTK_LABEL(self), value);
54 tag_item_changed(self, GObject *item, gpointer data)
57 if (STUFFKEEPER_IS_DATA_TAG(self->_priv->item))
59 value = stuffkeeper_data_tag_get_title(STUFFKEEPER_DATA_TAG(self->_priv->item));
62 gtk_label_set_text(GTK_LABEL(self), value);
71 item_changed(self, char *field,GObject *item)
73 if (STUFFKEEPER_IS_DATA_ITEM(self->_priv->item))
75 time_t time = stuffkeeper_data_item_get_modification_time(STUFFKEEPER_DATA_ITEM(item));
76 struct tm *t = localtime(&time);
78 strftime(buffer,256, "%x", t);
79 gtk_label_set(GTK_LABEL(self), buffer);
86 * Creates a label that keeps track of the name of a tag.
90 new_tag(StuffkeeperDataTag *tag)
95 gtk_misc_set_alignment(GTK_MISC(obj), 0, 0.5);
98 obj->_priv->item = G_OBJECT(tag);
100 obj->_priv->changed_item_entry = g_signal_connect_swapped(G_OBJECT(obj->_priv->item), "tag-changed", G_CALLBACK(self_tag_item_changed), obj);
102 value = stuffkeeper_data_tag_get_title(STUFFKEEPER_DATA_TAG(obj->_priv->item));
105 gtk_label_set_text(GTK_LABEL(obj), value);
108 return GTK_WIDGET(obj);
112 * Creates a label that keeps track of the name of a schema
116 new_schema(StuffkeeperDataSchema *schema)
121 gtk_misc_set_alignment(GTK_MISC(obj), 0, 0.5);
124 obj->_priv->item = G_OBJECT(schema);
127 obj->_priv->changed_item_entry = g_signal_connect_swapped(G_OBJECT(obj->_priv->item), "schema-changed", G_CALLBACK(self_schema_item_changed), obj);
129 value = stuffkeeper_data_schema_get_title(STUFFKEEPER_DATA_SCHEMA(obj->_priv->item));
132 gtk_label_set_text(GTK_LABEL(obj), value);
135 return GTK_WIDGET(obj);
139 * Creates a label that keeps track of the name of a field in a schema
143 new_schema_field(StuffkeeperDataSchema *schema,const gchar *field)
148 gtk_misc_set_alignment(GTK_MISC(obj), 0, 0.5);
151 obj->_priv->item = G_OBJECT(schema);
153 obj->_priv->field = g_strdup(field);
154 obj->_priv->changed_item_entry = g_signal_connect_swapped(G_OBJECT(obj->_priv->item),
155 "schema-field-changed",
156 G_CALLBACK(self_field_item_changed),
159 value = stuffkeeper_data_schema_get_field_name(STUFFKEEPER_DATA_SCHEMA(obj->_priv->item),obj->_priv->field);
162 gchar *markup = g_markup_printf_escaped("<b>%s</b>", value);
163 gtk_label_set_text(GTK_LABEL(obj), value);
164 gtk_label_set_markup(GTK_LABEL(obj), markup);
168 return GTK_WIDGET(obj);
172 * Creates a label that keeps track of the modification time of a tag
176 new_modifcation_time_item(StuffkeeperDataItem *item)
179 gtk_misc_set_alignment(GTK_MISC(obj), 0, 0.5);
182 obj->_priv->item = G_OBJECT(item);
184 obj->_priv->changed_item_entry = g_signal_connect_swapped(G_OBJECT(obj->_priv->item), "item-changed", G_CALLBACK(self_item_changed), obj);
186 /* update the label */
187 self_item_changed(obj,NULL, obj->_priv->item);
189 return GTK_WIDGET(obj);
196 finalize (G:Object *obj)
198 Self *self = SELF(obj);
199 if(self->_priv->changed_item_entry)
201 g_signal_handler_disconnect(self->_priv->item,self->_priv->changed_item_entry);
202 self->_priv->changed_item_entry = 0;