[devhelp] DhLink: modify get_type_as_string() -> type_to_string()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp] DhLink: modify get_type_as_string() -> type_to_string()
- Date: Sun, 4 Jun 2017 12:19:58 +0000 (UTC)
commit 974a112fc4ba58e4b18187c67143af2f41f85cab
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sun Jun 4 14:01:59 2017 +0200
DhLink: modify get_type_as_string() -> type_to_string()
The function is not used by gnome-builder or Anjuta, so we can break the
API.
dh_link_type_to_string() takes a DhLinkType argument. API-wise, it's
slightly less convenient to use for the two call sites in Devhelp, but
the function is more powerful, it can be used independently from DhLink.
docs/reference/api-breaks.xml | 8 ++++++++
docs/reference/devhelp-sections.txt | 2 +-
src/dh-assistant-view.c | 2 +-
src/dh-link.c | 18 ++++++++----------
src/dh-link.h | 2 +-
src/dh-sidebar.c | 2 +-
6 files changed, 20 insertions(+), 14 deletions(-)
---
diff --git a/docs/reference/api-breaks.xml b/docs/reference/api-breaks.xml
index a93d6be..62e90e5 100644
--- a/docs/reference/api-breaks.xml
+++ b/docs/reference/api-breaks.xml
@@ -123,6 +123,14 @@
because it was broken and used nowhere.
</para>
</listitem>
+ <listitem>
+ <para>
+ The <code>dh_link_get_type_as_string()</code> function (which took a
+ <link linkend="DhLink">DhLink</link> parameter) has been removed, it
+ has been replaced by <link linkend="dh-link-type-to-string">dh_link_type_to_string()</link>
+ which takes a <link linkend="DhLinkType">DhLinkType</link> parameter.
+ </para>
+ </listitem>
</itemizedlist>
</refsect1>
</part>
diff --git a/docs/reference/devhelp-sections.txt b/docs/reference/devhelp-sections.txt
index 6dc2d08..465372c 100644
--- a/docs/reference/devhelp-sections.txt
+++ b/docs/reference/devhelp-sections.txt
@@ -120,7 +120,7 @@ dh_link_get_uri
dh_link_get_flags
dh_link_set_flags
dh_link_get_link_type
-dh_link_get_type_as_string
+dh_link_type_to_string
<SUBSECTION Standard>
DH_TYPE_LINK
DH_TYPE_LINK_FLAGS
diff --git a/src/dh-assistant-view.c b/src/dh-assistant-view.c
index f096b07..ac688f1 100644
--- a/src/dh-assistant-view.c
+++ b/src/dh-assistant-view.c
@@ -393,7 +393,7 @@ dh_assistant_view_set_link (DhAssistantView *view,
stylesheet_html,
javascript_html,
function,
- dh_link_get_type_as_string (link),
+ dh_link_type_to_string (dh_link_get_link_type (link)),
dh_link_get_uri (link),
dh_link_get_name (link),
_("Book:"),
diff --git a/src/dh-link.c b/src/dh-link.c
index 1087ed6..8bcf609 100644
--- a/src/dh-link.c
+++ b/src/dh-link.c
@@ -388,18 +388,16 @@ dh_link_set_flags (DhLink *link,
}
/**
- * dh_link_get_type_as_string:
- * @link: a #DhLink.
+ * dh_link_type_to_string:
+ * @link_type: a #DhLinkType.
*
- * Returns: a string representation of the #DhLinkType of @link, translated in
- * the current language.
+ * Returns: a string representation of the #DhLinkType, translated in the
+ * current language.
*/
const gchar *
-dh_link_get_type_as_string (DhLink *link)
+dh_link_type_to_string (DhLinkType link_type)
{
- g_return_val_if_fail (link != NULL, NULL);
-
- switch (link->type) {
+ switch (link_type) {
case DH_LINK_TYPE_BOOK:
/* i18n: a documentation book */
return _("Book");
@@ -456,8 +454,8 @@ dh_link_get_type_as_string (DhLink *link)
return _("Signal");
default:
- g_assert_not_reached ();
+ break;
}
- return "";
+ g_return_val_if_reached ("");
}
diff --git a/src/dh-link.h b/src/dh-link.h
index 81970cb..5b20473 100644
--- a/src/dh-link.h
+++ b/src/dh-link.h
@@ -86,7 +86,7 @@ DhLinkFlags dh_link_get_flags (DhLink *link);
void dh_link_set_flags (DhLink *link,
DhLinkFlags flags);
DhLinkType dh_link_get_link_type (DhLink *link);
-const gchar *dh_link_get_type_as_string (DhLink *link);
+const gchar *dh_link_type_to_string (DhLinkType link_type);
G_END_DECLS
diff --git a/src/dh-sidebar.c b/src/dh-sidebar.c
index 9e6060c..d91a0da 100644
--- a/src/dh-sidebar.c
+++ b/src/dh-sidebar.c
@@ -440,7 +440,7 @@ hitlist_cell_data_func (GtkTreeViewColumn *tree_column,
name = g_markup_printf_escaped (
"%s <i><small><span weight=\"normal\">(%s)</span></small></i>",
dh_link_get_name (link),
- dh_link_get_type_as_string (link));
+ dh_link_type_to_string (dh_link_get_link_type (link)));
} else {
name = g_markup_printf_escaped ("%s", dh_link_get_name (link));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]