[epiphany/in-tab-overview: 20/23] ephy-embed: add the overview and a overview-mode property



commit 4f6b7de7fde3690000fd2ec7c3a0ba2e825f7aed
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Mon Aug 20 13:54:32 2012 +0300

    ephy-embed: add the overview and a overview-mode property
    
    Toggling this property will toggle visibility of the overview and the
    paned with the normal embed contents.

 embed/ephy-embed.c |  113 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 embed/ephy-embed.h |    5 ++
 src/Makefile.am    |    2 +
 3 files changed, 120 insertions(+), 0 deletions(-)
---
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index 352294b..1283acb 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -79,6 +79,8 @@ struct _EphyEmbedPrivate
   GtkWidget *fullscreen_message_label;
   char *fullscreen_string;
 
+  GtkWidget *overview;
+  guint overview_mode : 1;
   GSList *messages;
   GSList *keys;
 
@@ -96,6 +98,12 @@ struct _EphyEmbedPrivate
   gulong progress_update_handler_id;
 };
 
+enum
+{
+  PROP_0,
+  PROP_OVERVIEW_MODE,
+};
+
 G_DEFINE_TYPE (EphyEmbed, ephy_embed, GTK_TYPE_BOX)
 
 /* Portions of the following code based on GTK+.
@@ -431,6 +439,44 @@ ephy_embed_finalize (GObject *object)
 }
 
 static void
+ephy_embed_set_property (GObject *object,
+                         guint prop_id,
+                         const GValue *value,
+                         GParamSpec *pspec)
+{
+  EphyEmbed *embed = EPHY_EMBED (object);
+
+  switch (prop_id)
+  {
+  case PROP_OVERVIEW_MODE:
+    ephy_embed_set_overview_mode (embed, g_value_get_boolean (value));
+    break;
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    break;
+  }
+}
+
+static void
+ephy_embed_get_property (GObject *object,
+                         guint prop_id,
+                         GValue *value,
+                         GParamSpec *pspec)
+{
+  EphyEmbed *embed = EPHY_EMBED (object);
+
+  switch (prop_id)
+  {
+  case PROP_OVERVIEW_MODE:
+    g_value_set_boolean (value, ephy_embed_get_overview_mode (embed));
+    break;
+  default:
+    G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    break;
+  }
+}
+
+static void
 ephy_embed_class_init (EphyEmbedClass *klass)
 {
   GObjectClass *object_class = (GObjectClass *)klass;
@@ -439,8 +485,18 @@ ephy_embed_class_init (EphyEmbedClass *klass)
   object_class->constructed = ephy_embed_constructed;
   object_class->finalize = ephy_embed_finalize;
   object_class->dispose = ephy_embed_dispose;
+  object_class->set_property = ephy_embed_set_property;
+  object_class->get_property = ephy_embed_get_property;
   widget_class->grab_focus = ephy_embed_grab_focus;
 
+  g_object_class_install_property (object_class,
+                                   PROP_OVERVIEW_MODE,
+                                   g_param_spec_boolean ("overview-mode",
+                                                         "Overview mode",
+                                                         "Whether the embed is showing the overview",
+                                                         FALSE,
+                                                         G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+
   g_type_class_add_private (G_OBJECT_CLASS (klass), sizeof(EphyEmbedPrivate));
 }
 
@@ -919,6 +975,22 @@ ephy_embed_constructed (GObject *object)
                     NULL);
 #endif
 
+  /* The overview */
+  priv->overview = ephy_overview_new ();
+  gtk_box_pack_start (GTK_BOX (embed),
+                      GTK_WIDGET (priv->overview),
+                      TRUE, TRUE, 0);
+  g_object_bind_property (embed, "overview-mode",
+                          priv->overview, "visible",
+                          G_BINDING_SYNC_CREATE
+                          | G_BINDING_BIDIRECTIONAL);
+
+  g_object_bind_property (embed, "overview-mode",
+                          paned, "visible",
+                          G_BINDING_SYNC_CREATE
+                          | G_BINDING_INVERT_BOOLEAN
+                          | G_BINDING_BIDIRECTIONAL);
+
   ephy_embed_prefs_add_embed (embed);
 }
 
@@ -1012,3 +1084,44 @@ ephy_embed_remove_top_widget (EphyEmbed *embed, GtkWidget *widget)
   gtk_container_remove (GTK_CONTAINER (embed->priv->top_widgets_vbox),
                         GTK_WIDGET (widget));
 }
+
+void
+ephy_embed_set_overview_mode (EphyEmbed *embed, gboolean overview_mode)
+{
+  EphyEmbedPrivate *priv;
+
+  g_return_if_fail (EPHY_IS_EMBED (embed));
+
+  priv = embed->priv;
+
+  if (priv->overview_mode == overview_mode)
+    return;
+
+  priv->overview_mode = overview_mode;
+
+  g_object_notify (G_OBJECT (embed), "overview-mode");
+}
+
+gboolean
+ephy_embed_get_overview_mode (EphyEmbed *embed)
+{
+  g_return_val_if_fail (EPHY_IS_EMBED (embed), FALSE);
+
+  return embed->priv->overview_mode;
+}
+
+/**
+ * ephy_embed_get_overview:
+ * @embed: a #EphyEmbed
+ *
+ * Gets the #EphyOverview in this @embed
+ *
+ * Returns: (transfer none): the overview widget
+ **/
+EphyOverview *
+ephy_embed_get_overview (EphyEmbed *embed)
+{
+  g_return_val_if_fail (EPHY_IS_EMBED (embed), NULL);
+
+  return EPHY_OVERVIEW (embed->priv->overview);
+}
diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h
index 91fc06e..7820318 100644
--- a/embed/ephy-embed.h
+++ b/embed/ephy-embed.h
@@ -22,6 +22,7 @@
 #ifndef EPHY_EMBED_H
 #define EPHY_EMBED_H
 
+#include "ephy-overview.h"
 #include "ephy-web-view.h"
 
 #include <gtk/gtk.h>
@@ -61,6 +62,10 @@ void         ephy_embed_auto_download_url        (EphyEmbed  *embed,
                                                   const char *url);
 void         ephy_embed_entering_fullscreen      (EphyEmbed *embed);
 void         ephy_embed_leaving_fullscreen       (EphyEmbed *embed);
+void         ephy_embed_set_overview_mode        (EphyEmbed *embed,
+                                                  gboolean   overview_mode);
+gboolean     ephy_embed_get_overview_mode        (EphyEmbed *embed);
+EphyOverview*ephy_embed_get_overview             (EphyEmbed *embed);
 
 G_END_DECLS
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 69045e3..0a01e93 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -240,6 +240,7 @@ EPHY_GIR_H_FILES = \
 	$(top_srcdir)/embed/ephy-embed-event.h \
 	$(top_srcdir)/embed/ephy-embed-shell.h \
 	$(top_srcdir)/embed/ephy-embed-single.h \
+	$(top_srcdir)/embed/ephy-overview.h \
 	$(top_srcdir)/embed/ephy-permission-manager.h \
 	$(top_srcdir)/embed/ephy-web-view.h \
 	$(top_srcdir)/lib/ephy-dialog.h \
@@ -269,6 +270,7 @@ EPHY_GIR_C_FILES = \
 	$(top_srcdir)/embed/ephy-embed-event.c \
 	$(top_srcdir)/embed/ephy-embed-shell.c \
 	$(top_srcdir)/embed/ephy-embed-single.c \
+	$(top_srcdir)/embed/ephy-overview.c \
 	$(top_srcdir)/embed/ephy-permission-manager.c \
 	$(top_srcdir)/embed/ephy-web-view.c \
 	$(top_srcdir)/lib/ephy-dialog.c \



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]