summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Wilmet <sebastien.wilmet@uclouvain.be>2015-09-24 10:59:32 +0200
committerMatthias Clasen <mclasen@redhat.com>2015-10-03 22:24:17 -0400
commit5a561a8ddb9bf71f09dfe32f140677e17117465d (patch)
treeb5d2c875a1dac36ec7b0b05c5489b674d941cba2
parentcc2224cc6278864c09f6cf1ae30e902f5f7b3b92 (diff)
downloadgtk+-5a561a8ddb9bf71f09dfe32f140677e17117465d.tar.gz
texttag: add gtk_text_tag_changed()
The function is useful for a GtkTextTag subclass that adds new properties. https://bugzilla.gnome.org/show_bug.cgi?id=755416
-rw-r--r--docs/reference/gtk/gtk3-sections.txt1
-rw-r--r--gtk/gtktexttag.c52
-rw-r--r--gtk/gtktexttag.h4
-rw-r--r--gtk/gtktexttagtable.c2
4 files changed, 44 insertions, 15 deletions
diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt
index 945726e2bd..e9c8ddc333 100644
--- a/docs/reference/gtk/gtk3-sections.txt
+++ b/docs/reference/gtk/gtk3-sections.txt
@@ -3809,6 +3809,7 @@ gtk_text_tag_new
gtk_text_tag_get_priority
gtk_text_tag_set_priority
gtk_text_tag_event
+gtk_text_tag_changed
GtkTextAttributes
GtkTextAppearance
gtk_text_attributes_new
diff --git a/gtk/gtktexttag.c b/gtk/gtktexttag.c
index a05a6bbfe8..13d234f96d 100644
--- a/gtk/gtktexttag.c
+++ b/gtk/gtktexttag.c
@@ -1822,20 +1822,12 @@ gtk_text_tag_set_property (GObject *object,
break;
}
- /* FIXME I would like to do this after all set_property in a single
- * g_object_set () have been called. But an idle function won't
- * work; we need to emit when the tag is changed, not when we get
- * around to the event loop. So blah, we eat some inefficiency.
+ /* The signal is emitted for each set_property(). A possible optimization is
+ * to send the signal only once when several properties are set at the same
+ * time with e.g. g_object_set(). The signal could be emitted when the notify
+ * signal is thawed.
*/
-
- /* This is also somewhat weird since we emit another object's
- * signal here, but the two objects are already tightly bound.
- */
-
- if (priv->table)
- g_signal_emit_by_name (priv->table,
- "tag_changed",
- text_tag, size_changed);
+ gtk_text_tag_changed (text_tag, size_changed);
}
static void
@@ -2294,6 +2286,40 @@ gtk_text_tag_event (GtkTextTag *tag,
return retval;
}
+/**
+ * gtk_text_tag_changed:
+ * @tag: a #GtkTextTag.
+ * @size_changed: whether the change affects the #GtkTextView layout.
+ *
+ * Emits the #GtkTextTagTable::tag-changed signal on the #GtkTextTagTable where
+ * the tag is included.
+ *
+ * The signal is already emitted when setting a #GtkTextTag property. This
+ * function is useful for a #GtkTextTag subclass.
+ *
+ * Since: 3.20
+ */
+void
+gtk_text_tag_changed (GtkTextTag *tag,
+ gboolean size_changed)
+{
+ GtkTextTagPrivate *priv;
+
+ g_return_if_fail (GTK_IS_TEXT_TAG (tag));
+
+ priv = tag->priv;
+
+ /* This is somewhat weird since we emit another object's signal here, but the
+ * two objects are already tightly bound. If a GtkTextTag::changed signal is
+ * added, this would increase significantly the number of signal connections.
+ */
+ if (priv->table != NULL)
+ g_signal_emit_by_name (priv->table,
+ "tag-changed",
+ tag,
+ size_changed);
+}
+
static int
tag_sort_func (gconstpointer first, gconstpointer second)
{
diff --git a/gtk/gtktexttag.h b/gtk/gtktexttag.h
index 1dae6024d2..3e4ed33cc0 100644
--- a/gtk/gtktexttag.h
+++ b/gtk/gtktexttag.h
@@ -112,7 +112,9 @@ gboolean gtk_text_tag_event (GtkTextTag *tag,
GObject *event_object,
GdkEvent *event,
const GtkTextIter *iter);
-
+GDK_AVAILABLE_IN_3_20
+void gtk_text_tag_changed (GtkTextTag *tag,
+ gboolean size_changed);
G_END_DECLS
diff --git a/gtk/gtktexttagtable.c b/gtk/gtktexttagtable.c
index e44fb0ada0..777cf310bd 100644
--- a/gtk/gtktexttagtable.c
+++ b/gtk/gtktexttagtable.c
@@ -103,7 +103,7 @@ gtk_text_tag_table_class_init (GtkTextTagTableClass *klass)
* GtkTextTagTable::tag-changed:
* @texttagtable: the object which received the signal.
* @tag: the changed tag.
- * @size_changed: whether the size has been changed.
+ * @size_changed: whether the change affects the #GtkTextView layout.
*/
signals[TAG_CHANGED] =
g_signal_new (I_("tag-changed"),