diff options
author | Claudio Saavedra <csaavedra@igalia.com> | 2013-01-28 19:18:02 +0800 |
---|---|---|
committer | Claudio Saavedra <csaavedra@igalia.com> | 2013-02-08 05:54:58 +0800 |
commit | 946292f704d24d3e82761a97bc4666df3458bc5b (patch) | |
tree | 232ddfc8ebd4248d3f65ad4580dc0d6de127ce29 /src | |
parent | f0907d8fe648b6b8d345ca6434ddbe2cf90f1fc5 (diff) | |
download | gsoc2013-epiphany-946292f704d24d3e82761a97bc4666df3458bc5b.tar gsoc2013-epiphany-946292f704d24d3e82761a97bc4666df3458bc5b.tar.gz gsoc2013-epiphany-946292f704d24d3e82761a97bc4666df3458bc5b.tar.bz2 gsoc2013-epiphany-946292f704d24d3e82761a97bc4666df3458bc5b.tar.lz gsoc2013-epiphany-946292f704d24d3e82761a97bc4666df3458bc5b.tar.xz gsoc2013-epiphany-946292f704d24d3e82761a97bc4666df3458bc5b.tar.zst gsoc2013-epiphany-946292f704d24d3e82761a97bc4666df3458bc5b.zip |
ephy-session: add can-undo-tab-closed boolean property
https://bugzilla.gnome.org/show_bug.cgi?id=128184
Diffstat (limited to 'src')
-rw-r--r-- | src/ephy-session.c | 63 | ||||
-rw-r--r-- | src/ephy-session.h | 2 |
2 files changed, 65 insertions, 0 deletions
diff --git a/src/ephy-session.c b/src/ephy-session.c index fecfee236..3ad9dbb3d 100644 --- a/src/ephy-session.c +++ b/src/ephy-session.c @@ -62,6 +62,12 @@ struct _EphySessionPrivate #define SESSION_STATE "type:session_state" #define MAX_CLOSED_TABS 10 +enum +{ + PROP_0, + PROP_CAN_UNDO_TAB_CLOSED +}; + G_DEFINE_TYPE (EphySession, ephy_session, G_TYPE_OBJECT) /* Helper functions */ @@ -315,6 +321,9 @@ ephy_session_undo_close_tab (EphySession *session) } #endif closed_tab_free (tab); + + if (g_queue_is_empty (priv->closed_tabs)) + g_object_notify (G_OBJECT (session), "can-undo-tab-closed"); } static void @@ -364,10 +373,21 @@ ephy_session_tab_closed (EphySession *session, g_queue_push_head (priv->closed_tabs, tab); + if (g_queue_get_length (priv->closed_tabs) == 1) + g_object_notify (G_OBJECT (session), "can-undo-tab-closed"); + LOG ("Added: %s to the list (%d elements)", address, g_queue_get_legth (priv->closed_tabs)); } +gboolean +ephy_session_get_can_undo_tab_closed (EphySession *session) +{ + g_return_val_if_fail (EPHY_IS_SESSION (session), FALSE); + + return g_queue_is_empty (session->priv->closed_tabs) == FALSE; +} + static void notebook_page_added_cb (GtkWidget *notebook, EphyEmbed *embed, @@ -504,10 +524,53 @@ ephy_session_init (EphySession *session) } static void +ephy_session_dispose (GObject *object) +{ + EphySession *session = EPHY_SESSION (object); + + LOG ("EphySession disposing"); + + g_queue_free_full (session->priv->closed_tabs, + (GDestroyNotify)closed_tab_free); + + G_OBJECT_CLASS (ephy_session_parent_class)->dispose (object); +} + +static void +ephy_session_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + EphySession *session = EPHY_SESSION (object); + + switch (property_id) + { + case PROP_CAN_UNDO_TAB_CLOSED: + g_value_set_boolean (value, + ephy_session_get_can_undo_tab_closed (session)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void ephy_session_class_init (EphySessionClass *class) { GObjectClass *object_class = G_OBJECT_CLASS (class); + object_class->dispose = ephy_session_dispose; + object_class->get_property = ephy_session_get_property; + + g_object_class_install_property (object_class, + PROP_CAN_UNDO_TAB_CLOSED, + g_param_spec_boolean ("can-undo-tab-closed", + "Can undo tab close", + "Session can undo a tab closure", + FALSE, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + g_type_class_add_private (object_class, sizeof (EphySessionPrivate)); } diff --git a/src/ephy-session.h b/src/ephy-session.h index e6d0ab253..a26baa248 100644 --- a/src/ephy-session.h +++ b/src/ephy-session.h @@ -97,6 +97,8 @@ void ephy_session_close (EphySession *session); void ephy_session_undo_close_tab (EphySession *session); +gboolean ephy_session_get_can_undo_tab_closed (EphySession *session); + G_END_DECLS #endif |