aboutsummaryrefslogtreecommitdiffstats
path: root/embed/ephy-embed-utils.c
diff options
context:
space:
mode:
authorXan Lopez <xan@src.gnome.org>2007-10-26 04:01:00 +0800
committerXan Lopez <xan@src.gnome.org>2007-10-26 04:01:00 +0800
commit6638472fdbeee7c135c822ada01d09f407ca18e6 (patch)
tree9c9af360bfaaf544fd4ee45133b3eedb1ec7340c /embed/ephy-embed-utils.c
parent2be1a6942311c3f8fd0d9335820919d281b437db (diff)
downloadgsoc2013-epiphany-6638472fdbeee7c135c822ada01d09f407ca18e6.tar
gsoc2013-epiphany-6638472fdbeee7c135c822ada01d09f407ca18e6.tar.gz
gsoc2013-epiphany-6638472fdbeee7c135c822ada01d09f407ca18e6.tar.bz2
gsoc2013-epiphany-6638472fdbeee7c135c822ada01d09f407ca18e6.tar.lz
gsoc2013-epiphany-6638472fdbeee7c135c822ada01d09f407ca18e6.tar.xz
gsoc2013-epiphany-6638472fdbeee7c135c822ada01d09f407ca18e6.tar.zst
gsoc2013-epiphany-6638472fdbeee7c135c822ada01d09f407ca18e6.zip
Move title/address update on open-uri signal to EphyEmbed.
Also refactor some common code in ephy-embed-utils.c svn path=/trunk/; revision=7562
Diffstat (limited to 'embed/ephy-embed-utils.c')
-rw-r--r--embed/ephy-embed-utils.c119
1 files changed, 119 insertions, 0 deletions
diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c
new file mode 100644
index 000000000..ae8fd8826
--- /dev/null
+++ b/embed/ephy-embed-utils.c
@@ -0,0 +1,119 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright © 2000-2003 Marco Pesenti Gritti
+ * Copyright © 2003, 2004, 2005 Christian Persch
+ * Copyright © 2004 Crispin Flowerday
+ * Copyright © 2004 Adam Hooper
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $Id:
+ */
+
+#include "ephy-string.h"
+#include <string.h>
+
+#include <glib/gi18n.h>
+
+#include "ephy-embed-utils.h"
+
+char*
+ephy_embed_utils_link_message_parse (char *message)
+{
+
+ char *status_message;
+ char **splitted_message;
+
+ status_message = ephy_string_blank_chr (message);
+
+ if (status_message && g_str_has_prefix (status_message, "mailto:"))
+ {
+ int i = 1;
+ char *p;
+ GString *tmp;
+
+ /* We first want to eliminate all the things after "?", like
+ * cc, subject and alike.
+ */
+
+ p = strchr (status_message, '?');
+ if (p != NULL) *p = '\0';
+
+ /* Then we also want to check if there is more than an email address
+ * in the mailto: list.
+ */
+
+ splitted_message = g_strsplit_set (status_message, ";", -1);
+ tmp = g_string_new (g_strdup_printf (_("Send an email message to “%s”"),
+ (splitted_message[0] + 7)));
+
+ while (splitted_message [i] != NULL)
+ {
+ g_string_append_printf (tmp, ", “%s”", splitted_message[i]);
+ i++;
+ }
+
+ g_free (status_message);
+ g_strfreev (splitted_message);
+
+ return g_string_free (tmp, FALSE);
+ }
+ else
+ {
+ return status_message;
+ }
+}
+
+/**
+ * ephy_embed_utils_get_title_composite:
+ * @embed: an #EphyEmbed
+ *
+ * Returns the title of the web page loaded in @embed.
+ *
+ * This differs from #ephy_embed_utils_get_title in that this function
+ * will return a special title while the page is still loading.
+ *
+ * Return value: @embed's web page's title. Will never be %NULL.
+ **/
+const char *
+ephy_embed_utils_get_title_composite (EphyEmbed *embed)
+{
+ const char *title = "";
+ const char *loading_title;
+ gboolean is_loading, is_blank;
+
+ g_return_val_if_fail (EPHY_IS_EMBED (embed), NULL);
+
+ is_loading = ephy_embed_get_load_status (embed);
+ is_blank = ephy_embed_get_is_blank (embed);
+ loading_title = ephy_embed_get_loading_title (embed);
+
+ if (is_blank)
+ {
+ title = _("Blank page");
+ }
+ else if (is_loading &&
+ loading_title != NULL)
+ {
+ title = loading_title;
+ }
+ else
+ {
+ title = ephy_embed_get_title (embed);
+ }
+
+ return title != NULL ? title : "";
+}
+