Commit f217a3f3 authored by Xan Lopez's avatar Xan Lopez

ephy-embed: we can now make the statusbar methods private

parent f88cd6dc
......@@ -95,6 +95,122 @@ struct _EphyEmbedPrivate
G_DEFINE_TYPE (EphyEmbed, ephy_embed, GTK_TYPE_BOX)
/* Portions of the following code based on GTK+.
* License block as follows:
*
* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
* GtkStatusbar Copyright (C) 1998 Shawn T. Amundson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*
*/
static guint
ephy_embed_statusbar_get_context_id (EphyEmbed *embed, const char *context_description)
{
char *string;
guint id;
g_return_val_if_fail (EPHY_IS_EMBED (embed), 0);
g_return_val_if_fail (context_description != NULL, 0);
/* we need to preserve namespaces on object datas */
string = g_strconcat ("ephy-embed-status-bar-context:", context_description, NULL);
id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (embed), string));
if (id == 0) {
EphyEmbedPrivate *priv = embed->priv;
id = priv->seq_context_id++;
g_object_set_data_full (G_OBJECT (embed), string, GUINT_TO_POINTER (id), NULL);
priv->keys = g_slist_prepend (priv->keys, string);
} else
g_free (string);
return id;
}
static void
ephy_embed_statusbar_update (EphyEmbed *embed, const char *text)
{
g_return_if_fail (EPHY_IS_EMBED (embed));
_ephy_embed_set_statusbar_label (embed, text);
}
static guint
ephy_embed_statusbar_push (EphyEmbed *embed, guint context_id, const char *text)
{
EphyEmbedPrivate *priv;
EphyEmbedStatusbarMsg *msg;
g_return_val_if_fail (EPHY_IS_EMBED (embed), 0);
g_return_val_if_fail (context_id != 0, 0);
g_return_val_if_fail (text != NULL, 0);
priv = embed->priv;
msg = g_slice_new (EphyEmbedStatusbarMsg);
msg->text = g_strdup (text);
msg->context_id = context_id;
msg->message_id = priv->seq_message_id++;
priv->messages = g_slist_prepend (priv->messages, msg);
ephy_embed_statusbar_update (embed, text);
return msg->message_id;
}
/* End of code based on GTK+ GtkStatusbar. */
static void
ephy_embed_statusbar_pop (EphyEmbed *embed, guint context_id)
{
EphyEmbedPrivate *priv;
EphyEmbedStatusbarMsg *msg;
GSList *list;
g_return_if_fail (EPHY_IS_EMBED (embed));
g_return_if_fail (context_id != 0);
priv = embed->priv;
for (list = priv->messages; list; list = list->next) {
EphyEmbedStatusbarMsg *msg = list->data;
if (msg->context_id == context_id) {
priv->messages = g_slist_remove_link (priv->messages, list);
g_free (msg->text);
g_slice_free (EphyEmbedStatusbarMsg, msg);
g_slist_free_1 (list);
break;
}
}
msg = priv->messages ? priv->messages->data : NULL;
ephy_embed_statusbar_update (embed, msg ? msg->text : NULL);
}
static void
restore_zoom_level (EphyEmbed *embed,
const char *address)
......@@ -774,117 +890,3 @@ ephy_embed_remove_top_widget (EphyEmbed *embed, GtkWidget *widget)
gtk_container_remove (GTK_CONTAINER (embed->priv->top_widgets_vbox),
GTK_WIDGET (widget));
}
static void
ephy_embed_statusbar_update (EphyEmbed *embed, const char *text)
{
g_return_if_fail (EPHY_IS_EMBED (embed));
_ephy_embed_set_statusbar_label (embed, text);
}
/* Portions of the following code based on GTK+.
* License block as follows:
*
* GTK - The GIMP Toolkit
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
* GtkStatusbar Copyright (C) 1998 Shawn T. Amundson
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GTK+ Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GTK+ at ftp://ftp.gtk.org/pub/gtk/.
*
*/
guint
ephy_embed_statusbar_get_context_id (EphyEmbed *embed, const char *context_description)
{
char *string;
guint id;
g_return_val_if_fail (EPHY_IS_EMBED (embed), 0);
g_return_val_if_fail (context_description != NULL, 0);
/* we need to preserve namespaces on object datas */
string = g_strconcat ("ephy-embed-status-bar-context:", context_description, NULL);
id = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (embed), string));
if (id == 0) {
EphyEmbedPrivate *priv = embed->priv;
id = priv->seq_context_id++;
g_object_set_data_full (G_OBJECT (embed), string, GUINT_TO_POINTER (id), NULL);
priv->keys = g_slist_prepend (priv->keys, string);
} else
g_free (string);
return id;
}
guint
ephy_embed_statusbar_push (EphyEmbed *embed, guint context_id, const char *text)
{
EphyEmbedPrivate *priv;
EphyEmbedStatusbarMsg *msg;
g_return_val_if_fail (EPHY_IS_EMBED (embed), 0);
g_return_val_if_fail (context_id != 0, 0);
g_return_val_if_fail (text != NULL, 0);
priv = embed->priv;
msg = g_slice_new (EphyEmbedStatusbarMsg);
msg->text = g_strdup (text);
msg->context_id = context_id;
msg->message_id = priv->seq_message_id++;
priv->messages = g_slist_prepend (priv->messages, msg);
ephy_embed_statusbar_update (embed, text);
return msg->message_id;
}
void
ephy_embed_statusbar_pop (EphyEmbed *embed, guint context_id)
{
EphyEmbedPrivate *priv;
EphyEmbedStatusbarMsg *msg;
GSList *list;
g_return_if_fail (EPHY_IS_EMBED (embed));
g_return_if_fail (context_id != 0);
priv = embed->priv;
for (list = priv->messages; list; list = list->next) {
EphyEmbedStatusbarMsg *msg = list->data;
if (msg->context_id == context_id) {
priv->messages = g_slist_remove_link (priv->messages, list);
g_free (msg->text);
g_slice_free (EphyEmbedStatusbarMsg, msg);
g_slist_free_1 (list);
break;
}
}
msg = priv->messages ? priv->messages->data : NULL;
ephy_embed_statusbar_update (embed, msg ? msg->text : NULL);
}
......@@ -65,14 +65,6 @@ void ephy_embed_auto_download_url (EphyEmbed *embed,
const char *url);
void _ephy_embed_set_statusbar_label (EphyEmbed *embed,
const char *label);
void ephy_embed_statusbar_pop (EphyEmbed *embed,
guint context_id);
guint ephy_embed_statusbar_push (EphyEmbed *embed,
guint context_id,
const char *text);
guint ephy_embed_statusbar_get_context_id (EphyEmbed *embed,
const char *context_description);
G_END_DECLS
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment