[epiphany] Create only an EphyLocationEntry *or* an EphyTitleBox



commit 0b1e5915d3c0ec456ed4baae99b8ed16c0c32d8a
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Wed Sep 21 22:44:23 2016 -0500

    Create only an EphyLocationEntry *or* an EphyTitleBox
    
    Now that EphyTitleBox no longer switches back and forth between location
    entry mode and title mode... instead of wastefully creating both an
    EphyLocationEntry and an EphyTitleBox and only ever using one or the
    other, only create the one that's needed: an EphyLocationEntry normally,
    but an EphyTitleBox if we're in app mode.
    
    This requires moving the lock-clicked signal of EphyLocationEntry and
    EphyTitleBox up to the EphyTitleWidget interface, and adjusting them to
    match (carry the GdkRectangle at which to position the
    EphySecurityPopover).

 lib/widgets/ephy-location-entry.c |   20 +-----
 lib/widgets/ephy-title-box.c      |   25 +-------
 lib/widgets/ephy-title-widget.c   |    8 ++
 src/ephy-header-bar.c             |   37 +++++------
 src/ephy-header-bar.h             |   17 ++---
 src/ephy-location-controller.c    |  128 ++++++++++++-------------------------
 src/ephy-shell.c                  |   15 ++---
 src/ephy-window.c                 |   82 ++++++++----------------
 8 files changed, 111 insertions(+), 221 deletions(-)
---
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index 55fbcf7..ed4123d 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -117,7 +117,6 @@ enum {
 
 enum signalsEnum {
   USER_CHANGED,
-  LOCK_CLICKED,
   GET_LOCATION,
   GET_TITLE,
   LAST_SIGNAL
@@ -461,21 +460,6 @@ ephy_location_entry_class_init (EphyLocationEntryClass *klass)
                                         G_TYPE_NONE);
 
   /**
-   * EphyLocationEntry::lock-clicked:
-   * @entry: the object on which the signal is emitted
-   *
-   * Emitted when the user clicks the security icon inside the
-   * #EphyLocationEntry.
-   *
-   */
-  signals[LOCK_CLICKED] = g_signal_new ("lock-clicked",
-                                        EPHY_TYPE_LOCATION_ENTRY,
-                                        G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
-                                        0, NULL, NULL, NULL,
-                                        G_TYPE_NONE,
-                                        0);
-
-  /**
    * EphyLocationEntry::get-location:
    * @entry: the object on which the signal is emitted
    * Returns: the current page address as a string
@@ -1014,7 +998,9 @@ icon_button_press_event_cb (GtkWidget           *entry,
 
       gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
     } else {
-      g_signal_emit (lentry, signals[LOCK_CLICKED], 0);
+      GdkRectangle lock_position;
+      gtk_entry_get_icon_area (GTK_ENTRY (entry), GTK_ENTRY_ICON_SECONDARY, &lock_position);
+      g_signal_emit_by_name (entry, "lock-clicked", &lock_position);
     }
 
     return TRUE;
diff --git a/lib/widgets/ephy-title-box.c b/lib/widgets/ephy-title-box.c
index 96879a7..6bbf023 100644
--- a/lib/widgets/ephy-title-box.c
+++ b/lib/widgets/ephy-title-box.c
@@ -30,13 +30,6 @@ enum {
   LAST_PROP
 };
 
-enum {
-  LOCK_CLICKED,
-  LAST_SIGNAL
-};
-
-static guint signals[LAST_SIGNAL];
-
 struct _EphyTitleBox {
   GtkEventBox parent_instance;
 
@@ -69,7 +62,7 @@ ephy_title_box_button_press_event (GtkWidget      *widget,
       event->x < lock_allocation.x + lock_allocation.width &&
       event->y >= lock_allocation.y &&
       event->y < lock_allocation.y + lock_allocation.height) {
-    g_signal_emit (title_box, signals[LOCK_CLICKED], 0, (GdkRectangle *)&lock_allocation);
+    g_signal_emit_by_name (title_box, "lock-clicked", (GdkRectangle *)&lock_allocation);
     return GDK_EVENT_STOP;
   }
 
@@ -248,22 +241,6 @@ ephy_title_box_class_init (EphyTitleBoxClass *klass)
 
   g_object_class_override_property (object_class, PROP_ADDRESS, "address");
   g_object_class_override_property (object_class, PROP_SECURITY_LEVEL, "security-level");
-
-  /**
-   * EphyTitleBox::lock-clicked:
-   * @title_box: the object on which the signal is emitted
-   * @lock_position: the position of the lock icon
-   *
-   * Emitted when the user clicks the security icon inside the
-   * #EphyTitleBox.
-   */
-  signals[LOCK_CLICKED] = g_signal_new ("lock-clicked",
-                                        EPHY_TYPE_TITLE_BOX,
-                                        G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
-                                        0, NULL, NULL, NULL,
-                                        G_TYPE_NONE,
-                                        1,
-                                        GDK_TYPE_RECTANGLE | G_SIGNAL_TYPE_STATIC_SCOPE);
 }
 
 static void
diff --git a/lib/widgets/ephy-title-widget.c b/lib/widgets/ephy-title-widget.c
index 6a33947..e83a188 100644
--- a/lib/widgets/ephy-title-widget.c
+++ b/lib/widgets/ephy-title-widget.c
@@ -39,6 +39,14 @@ ephy_title_widget_default_init (EphyTitleWidgetInterface *iface)
                                                           EPHY_TYPE_SECURITY_LEVEL,
                                                           EPHY_SECURITY_LEVEL_TO_BE_DETERMINED,
                                                           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+  g_signal_new ("lock-clicked",
+                EPHY_TYPE_TITLE_WIDGET,
+                G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
+                0, NULL, NULL, NULL,
+                G_TYPE_NONE,
+                1,
+                GDK_TYPE_RECTANGLE | G_SIGNAL_TYPE_STATIC_SCOPE);
 }
 
 const char *
diff --git a/src/ephy-header-bar.c b/src/ephy-header-bar.c
index 238d088..17c8516 100644
--- a/src/ephy-header-bar.c
+++ b/src/ephy-header-bar.c
@@ -35,6 +35,8 @@
 #include "ephy-middle-clickable-button.h"
 #include "ephy-private.h"
 #include "ephy-shell.h"
+#include "ephy-title-box.h"
+#include "ephy-title-widget.h"
 
 #include <glib/gi18n.h>
 #include <webkit2/webkit2.h>
@@ -54,8 +56,7 @@ struct _EphyHeaderBar {
   GtkHeaderBar parent_instance;
 
   EphyWindow *window;
-  EphyTitleBox *title_box;
-  GtkWidget *entry;
+  EphyTitleWidget *title_widget;
   GtkWidget *navigation_box;
   GtkWidget *new_tab_button;
   GtkWidget *combined_stop_reload_button;
@@ -546,7 +547,7 @@ static void
 ephy_header_bar_constructed (GObject *object)
 {
   EphyHeaderBar *header_bar = EPHY_HEADER_BAR (object);
-  GtkWidget *box, *button, *title_widget;
+  GtkWidget *box, *button;
   GtkMenu *menu;
   GMenu *page_menu;
   EphyDownloadsManager *downloads_manager;
@@ -626,16 +627,16 @@ ephy_header_bar_constructed (GObject *object)
   gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "win.new-tab");
   gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), button);
 
-  /* Location bar + Title */
-  header_bar->title_box = ephy_title_box_new ();
-  header_bar->entry = ephy_location_entry_new ();
+  /* Title widget (location entry or title box) */
   embed_shell = ephy_embed_shell_get_default ();
-  title_widget = ephy_embed_shell_get_mode (embed_shell) == EPHY_EMBED_SHELL_MODE_APPLICATION ? GTK_WIDGET 
(header_bar->title_box)
-                                                                                              : 
header_bar->entry;
-  gtk_widget_set_margin_start (title_widget, 54);
-  gtk_widget_set_margin_end (title_widget, 54);
-  gtk_header_bar_set_custom_title (GTK_HEADER_BAR (header_bar), title_widget);
-  gtk_widget_show (title_widget);
+  if (ephy_embed_shell_get_mode (embed_shell) == EPHY_EMBED_SHELL_MODE_APPLICATION)
+    header_bar->title_widget = EPHY_TITLE_WIDGET (ephy_title_box_new ());
+  else
+    header_bar->title_widget = EPHY_TITLE_WIDGET (ephy_location_entry_new ());
+  gtk_widget_set_margin_start (GTK_WIDGET (header_bar->title_widget), 54);
+  gtk_widget_set_margin_end (GTK_WIDGET (header_bar->title_widget), 54);
+  gtk_header_bar_set_custom_title (GTK_HEADER_BAR (header_bar), GTK_WIDGET (header_bar->title_widget));
+  gtk_widget_show (GTK_WIDGET (header_bar->title_widget));
 
   /* Page Menu */
   button = gtk_menu_button_new ();
@@ -748,16 +749,10 @@ ephy_header_bar_new (EphyWindow *window)
                                    NULL));
 }
 
-GtkWidget *
-ephy_header_bar_get_location_entry (EphyHeaderBar *header_bar)
-{
-  return header_bar->entry;
-}
-
-EphyTitleBox *
-ephy_header_bar_get_title_box (EphyHeaderBar *header_bar)
+EphyTitleWidget *
+ephy_header_bar_get_title_widget (EphyHeaderBar *header_bar)
 {
-  return header_bar->title_box;
+  return header_bar->title_widget;
 }
 
 GtkWidget *
diff --git a/src/ephy-header-bar.h b/src/ephy-header-bar.h
index f55ab2b..5cd4e75 100644
--- a/src/ephy-header-bar.h
+++ b/src/ephy-header-bar.h
@@ -20,7 +20,7 @@
 
 #include <gtk/gtk.h>
 
-#include "ephy-title-box.h"
+#include "ephy-title-widget.h"
 #include "ephy-window.h"
 
 G_BEGIN_DECLS
@@ -29,15 +29,14 @@ G_BEGIN_DECLS
 
 G_DECLARE_FINAL_TYPE (EphyHeaderBar, ephy_header_bar, EPHY, HEADER_BAR, GtkHeaderBar)
 
-GtkWidget    *ephy_header_bar_new                               (EphyWindow    *window);
+GtkWidget       *ephy_header_bar_new                               (EphyWindow    *window);
 
-void          ephy_header_bar_change_combined_stop_reload_state (GSimpleAction *action,
-                                                                 GVariant      *state,
-                                                                 gpointer       user_data);
+void             ephy_header_bar_change_combined_stop_reload_state (GSimpleAction *action,
+                                                                    GVariant      *state,
+                                                                    gpointer       user_data);
 
-GtkWidget    *ephy_header_bar_get_location_entry                (EphyHeaderBar *header_bar);
-EphyTitleBox *ephy_header_bar_get_title_box                     (EphyHeaderBar *header_bar);
-GtkWidget    *ephy_header_bar_get_page_menu_button              (EphyHeaderBar *header_bar);
-GtkWidget    *ephy_header_bar_get_new_tab_button                (EphyHeaderBar *header_bar);
+EphyTitleWidget *ephy_header_bar_get_title_widget                  (EphyHeaderBar *header_bar);
+GtkWidget       *ephy_header_bar_get_page_menu_button              (EphyHeaderBar *header_bar);
+GtkWidget       *ephy_header_bar_get_new_tab_button                (EphyHeaderBar *header_bar);
 
 G_END_DECLS
diff --git a/src/ephy-location-controller.c b/src/ephy-location-controller.c
index 8b1fa1f..585c949 100644
--- a/src/ephy-location-controller.c
+++ b/src/ephy-location-controller.c
@@ -26,10 +26,9 @@
 #include "ephy-embed-container.h"
 #include "ephy-embed-utils.h"
 #include "ephy-link.h"
-#include "ephy-dnd.h"
 #include "ephy-location-entry.h"
+#include "ephy-dnd.h"
 #include "ephy-shell.h"
-#include "ephy-title-box.h"
 #include "ephy-title-widget.h"
 
 #include <gdk/gdkkeysyms.h>
@@ -40,15 +39,14 @@
  * SECTION:ephy-location-controller
  * @short_description: An #EphyLink implementation
  *
- * #EphyLocationController handles navigation together with #EphyLocationEntry
+ * #EphyLocationController handles navigation together with an #EphyTitleWidget
  */
 
 struct _EphyLocationController {
   GObject parent_instance;
 
   EphyWindow *window;
-  EphyLocationEntry *location_entry;
-  EphyTitleBox *title_box;
+  EphyTitleWidget *title_widget;
   GList *actions;
   char *address;
   EphyNode *smart_bmks;
@@ -73,18 +71,11 @@ enum {
   PROP_ICON,
   PROP_SHOW_ICON,
   PROP_WINDOW,
-  PROP_LOCATION_ENTRY,
-  PROP_TITLE_BOX,
+  PROP_TITLE_WIDGET,
   LAST_PROP
 };
 static GParamSpec *obj_properties[LAST_PROP];
 
-enum {
-  LOCK_CLICKED,
-  LAST_SIGNAL
-};
-static guint signals[LAST_SIGNAL];
-
 G_DEFINE_TYPE_WITH_CODE (EphyLocationController, ephy_location_controller, G_TYPE_OBJECT,
                          G_IMPLEMENT_INTERFACE (EPHY_TYPE_LINK,
                                                 NULL))
@@ -258,24 +249,14 @@ user_changed_cb (GtkWidget *widget, EphyLocationController *controller)
 }
 
 static void
-lock_clicked_cb (GtkWidget              *widget,
-                 EphyLocationController *controller)
-{
-  g_signal_emit (controller, signals[LOCK_CLICKED], 0);
-}
-
-static void
 sync_address (EphyLocationController *controller,
               GParamSpec             *pspec,
               GtkWidget              *widget)
 {
-  EphyLocationEntry *lentry = EPHY_LOCATION_ENTRY (widget);
-
   LOG ("sync_address %s", controller->address);
 
   g_signal_handlers_block_by_func (widget, G_CALLBACK (user_changed_cb), controller);
-  ephy_title_widget_set_address (EPHY_TITLE_WIDGET (lentry), controller->address);
-  ephy_title_widget_set_address (EPHY_TITLE_WIDGET (controller->title_box), controller->address);
+  ephy_title_widget_set_address (controller->title_widget, controller->address);
   g_signal_handlers_unblock_by_func (widget, G_CALLBACK (user_changed_cb), controller);
 }
 
@@ -378,7 +359,7 @@ switch_page_cb (GtkNotebook            *notebook,
 {
   if (controller->sync_address_is_blocked == TRUE) {
     controller->sync_address_is_blocked = FALSE;
-    g_signal_handlers_unblock_by_func (controller, G_CALLBACK (sync_address), controller->location_entry);
+    g_signal_handlers_unblock_by_func (controller, G_CALLBACK (sync_address), controller->title_widget);
   }
 }
 
@@ -394,15 +375,22 @@ ephy_location_controller_constructed (GObject *object)
   G_OBJECT_CLASS (ephy_location_controller_parent_class)->constructed (object);
 
   notebook = ephy_window_get_notebook (controller->window);
-  widget = GTK_WIDGET (controller->location_entry);
+  widget = GTK_WIDGET (controller->title_widget);
 
   g_signal_connect (notebook, "switch-page",
                     G_CALLBACK (switch_page_cb), controller);
 
+  sync_address (controller, NULL, widget);
+  g_signal_connect_object (controller, "notify::address",
+                           G_CALLBACK (sync_address), widget, 0);
+
+  if (!EPHY_IS_LOCATION_ENTRY (controller->title_widget))
+    return;
+
   history_service = EPHY_HISTORY_SERVICE (ephy_embed_shell_get_global_history_service 
(ephy_embed_shell_get_default ()));
   bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
   model = ephy_completion_model_new (history_service, bookmarks);
-  ephy_location_entry_set_completion (controller->location_entry,
+  ephy_location_entry_set_completion (EPHY_LOCATION_ENTRY (controller->title_widget),
                                       GTK_TREE_MODEL (model),
                                       EPHY_COMPLETION_TEXT_COL,
                                       EPHY_COMPLETION_ACTION_COL,
@@ -413,26 +401,23 @@ ephy_location_controller_constructed (GObject *object)
                                       EPHY_COMPLETION_FAVICON_COL);
   g_object_unref (model);
 
-  ephy_location_entry_set_match_func (controller->location_entry,
+  ephy_location_entry_set_match_func (EPHY_LOCATION_ENTRY (controller->title_widget),
                                       match_func,
-                                      controller->location_entry,
+                                      controller->title_widget,
                                       NULL);
 
-  add_completion_actions (controller, controller->location_entry);
+  add_completion_actions (controller, EPHY_LOCATION_ENTRY (controller->title_widget));
 
-  sync_address (controller, NULL, widget);
-  g_signal_connect_object (controller, "notify::address",
-                           G_CALLBACK (sync_address), widget, 0);
   g_object_bind_property (controller, "editable",
-                          controller->location_entry, "editable",
+                          controller->title_widget, "editable",
                           G_BINDING_SYNC_CREATE);
 
   g_object_bind_property (controller, "icon",
-                          controller->location_entry, "favicon",
+                          controller->title_widget, "favicon",
                           G_BINDING_SYNC_CREATE);
 
   g_object_bind_property (controller, "show-icon",
-                          controller->location_entry, "show-favicon",
+                          controller->title_widget, "show-favicon",
                           G_BINDING_SYNC_CREATE);
 
   g_signal_connect_object (widget, "drag-data-received",
@@ -443,8 +428,6 @@ ephy_location_controller_constructed (GObject *object)
                            controller, 0);
   g_signal_connect_object (widget, "user-changed",
                            G_CALLBACK (user_changed_cb), controller, 0);
-  g_signal_connect_object (widget, "lock-clicked",
-                           G_CALLBACK (lock_clicked_cb), controller, 0);
   g_signal_connect_object (widget, "get-location",
                            G_CALLBACK (get_location_cb), controller, 0);
   g_signal_connect_object (widget, "get-title",
@@ -482,11 +465,8 @@ ephy_location_controller_set_property (GObject      *object,
     case PROP_WINDOW:
       controller->window = EPHY_WINDOW (g_value_get_object (value));
       break;
-    case PROP_LOCATION_ENTRY:
-      controller->location_entry = EPHY_LOCATION_ENTRY (g_value_get_object (value));
-      break;
-    case PROP_TITLE_BOX:
-      controller->title_box = EPHY_TITLE_BOX (g_value_get_object (value));
+    case PROP_TITLE_WIDGET:
+      controller->title_widget = EPHY_TITLE_WIDGET (g_value_get_object (value));
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -528,19 +508,19 @@ ephy_location_controller_dispose (GObject *object)
   notebook = ephy_window_get_notebook (controller->window);
 
   if (notebook == NULL ||
-      controller->location_entry == NULL) {
+      controller->title_widget == NULL) {
     return;
   }
 
-  g_signal_handlers_disconnect_matched (controller, G_SIGNAL_MATCH_DATA,
-                                        0, 0, NULL, NULL, controller->location_entry);
-  g_signal_handlers_disconnect_matched (controller->location_entry, G_SIGNAL_MATCH_DATA,
-                                        0, 0, NULL, NULL, controller);
-  g_signal_handlers_disconnect_matched (controller->title_box, G_SIGNAL_MATCH_DATA,
-                                        0, 0, NULL, NULL, controller);
+  if (EPHY_IS_LOCATION_ENTRY (controller->title_widget)) {
+    g_signal_handlers_disconnect_matched (controller, G_SIGNAL_MATCH_DATA,
+                                          0, 0, NULL, NULL, controller->title_widget);
+    g_signal_handlers_disconnect_matched (controller->title_widget, G_SIGNAL_MATCH_DATA,
+                                          0, 0, NULL, NULL, controller);
+  }
   g_signal_handlers_disconnect_matched (notebook, G_SIGNAL_MATCH_DATA,
                                         0, 0, NULL, NULL, controller);
-  controller->location_entry = NULL;
+  controller->title_widget = NULL;
 
   G_OBJECT_CLASS (ephy_location_controller_parent_class)->dispose (object);
 }
@@ -557,21 +537,6 @@ ephy_location_controller_class_init (EphyLocationControllerClass *class)
   object_class->set_property = ephy_location_controller_set_property;
 
   /**
-   * EphyLocationController::lock-clicked:
-   * @controller: the object which received the signal.
-   *
-   * Emitted when the user clicks on the security icon of the internal
-   * #EphyLocationEntry.
-   */
-  signals[LOCK_CLICKED] = g_signal_new (
-    "lock-clicked",
-    EPHY_TYPE_LOCATION_CONTROLLER,
-    G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
-    0, NULL, NULL, NULL,
-    G_TYPE_NONE,
-    0);
-
-  /**
    * EphyLocationController:address:
    *
    * The address of the current location.
@@ -632,26 +597,14 @@ ephy_location_controller_class_init (EphyLocationControllerClass *class)
                          G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
 
   /**
-   * EphyLocationController:location-entry:
+   * EphyLocationController:title-widget:
    *
-   * The controlled location entry.
+   * The #EphyLocationController sets the address of the #EphyTitleWidget.
    */
-  obj_properties[PROP_LOCATION_ENTRY] =
-    g_param_spec_object ("location-entry",
-                         "Location entry",
-                         "The controlled location entry",
-                         G_TYPE_OBJECT,
-                         G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
-
-  /**
-   * EphyLocationController:title-box:
-   *
-   * The #EphyLocationController sets the address of this title box.
-   */
-  obj_properties[PROP_TITLE_BOX] =
-    g_param_spec_object ("title-box",
-                         "Title box",
-                         "The title box whose address will be managed",
+  obj_properties[PROP_TITLE_WIDGET] =
+    g_param_spec_object ("title-widget",
+                         "Title widget",
+                         "The title widget whose address will be managed",
                          G_TYPE_OBJECT,
                          G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
 
@@ -710,13 +663,16 @@ init_actions_list (EphyLocationController *controller)
 static void
 update_actions_list (EphyLocationController *controller)
 {
-  remove_completion_actions (controller, controller->location_entry);
+  if (!EPHY_IS_LOCATION_ENTRY (controller->title_widget))
+    return;
+
+  remove_completion_actions (controller, EPHY_LOCATION_ENTRY (controller->title_widget));
 
   g_list_free (controller->actions);
   controller->actions = NULL;
   init_actions_list (controller);
 
-  add_completion_actions (controller, controller->location_entry);
+  add_completion_actions (controller, EPHY_LOCATION_ENTRY (controller->title_widget));
 }
 
 static void
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 8695539..eedcf56 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -970,6 +970,8 @@ static gboolean
 ephy_shell_open_uris_idle (OpenURIsData *data)
 {
   EphyEmbed *embed = NULL;
+  EphyHeaderBar *header_bar;
+  EphyTitleWidget *title_widget;
   EphyEmbedShellMode mode;
   EphyNewTabFlags page_flags = 0;
   gboolean reusing_empty_tab = FALSE;
@@ -1012,15 +1014,10 @@ ephy_shell_open_uris_idle (OpenURIsData *data)
     ephy_window_activate_location (data->window);
   }
 
-  /* Set the subtitle from the very beginning. Looks odd if it appears later on. */
-  if (mode == EPHY_EMBED_SHELL_MODE_APPLICATION) {
-    EphyHeaderBar *header_bar;
-    EphyTitleBox *title_box;
-
-    header_bar = EPHY_HEADER_BAR (ephy_window_get_header_bar (data->window));
-    title_box = ephy_header_bar_get_title_box (header_bar);
-    ephy_title_widget_set_address (EPHY_TITLE_WIDGET (title_box), url);
-  }
+  /* Set address from the very beginning. Looks odd in app mode if it appears later on. */
+  header_bar = EPHY_HEADER_BAR (ephy_window_get_header_bar (data->window));
+  title_widget = ephy_header_bar_get_title_widget (header_bar);
+  ephy_title_widget_set_address (title_widget, url);
 
   data->current_uri++;
   data->previous_embed = embed;
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 7503cf2..8437ba3 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -492,8 +492,7 @@ sync_tab_security (EphyWebView *view,
                    GParamSpec  *pspec,
                    EphyWindow  *window)
 {
-  EphyTitleBox *title_box;
-  GtkWidget *location_entry;
+  EphyTitleWidget *title_widget;
   EphySecurityLevel security_level;
 
   if (window->closing)
@@ -501,11 +500,8 @@ sync_tab_security (EphyWebView *view,
 
   ephy_web_view_get_security_level (view, &security_level, NULL, NULL);
 
-  title_box = ephy_header_bar_get_title_box (EPHY_HEADER_BAR (window->header_bar));
-  ephy_title_widget_set_security_level (EPHY_TITLE_WIDGET (title_box), security_level);
-
-  location_entry = ephy_header_bar_get_location_entry (EPHY_HEADER_BAR (window->header_bar));
-  ephy_title_widget_set_security_level (EPHY_TITLE_WIDGET (location_entry), security_level);
+  title_widget = ephy_header_bar_get_title_widget (EPHY_HEADER_BAR (window->header_bar));
+  ephy_title_widget_set_security_level (title_widget, security_level);
 }
 
 static void
@@ -701,19 +697,20 @@ update_edit_actions_sensitivity (EphyWindow *window, gboolean hide)
   gboolean can_copy, can_cut, can_undo, can_redo, can_paste;
 
   if (GTK_IS_EDITABLE (widget)) {
-    GtkWidget *entry;
+    EphyTitleWidget *title_widget;
     gboolean has_selection;
 
-    entry = ephy_header_bar_get_location_entry (EPHY_HEADER_BAR (window->header_bar));
+    title_widget = ephy_header_bar_get_title_widget (EPHY_HEADER_BAR (window->header_bar));
 
-    has_selection = gtk_editable_get_selection_bounds
-                      (GTK_EDITABLE (widget), NULL, NULL);
+    has_selection = gtk_editable_get_selection_bounds (GTK_EDITABLE (widget), NULL, NULL);
 
     can_copy = has_selection;
     can_cut = has_selection;
     can_paste = TRUE;
-    can_undo = ephy_location_entry_get_can_undo (EPHY_LOCATION_ENTRY (entry));
-    can_redo = ephy_location_entry_get_can_redo (EPHY_LOCATION_ENTRY (entry));
+    can_undo = EPHY_IS_LOCATION_ENTRY (title_widget) &&
+               ephy_location_entry_get_can_undo (EPHY_LOCATION_ENTRY (title_widget));
+    can_redo = EPHY_IS_LOCATION_ENTRY (title_widget) &&
+               ephy_location_entry_get_can_redo (EPHY_LOCATION_ENTRY (title_widget));
   } else {
     EphyEmbed *embed;
     WebKitWebView *view;
@@ -1799,7 +1796,7 @@ ephy_window_configure_for_view (EphyWindow    *window,
   if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) != EPHY_EMBED_SHELL_MODE_APPLICATION) {
     GtkWidget *entry;
 
-    entry = ephy_header_bar_get_location_entry (EPHY_HEADER_BAR (window->header_bar));
+    entry = GTK_WIDGET (ephy_header_bar_get_title_widget (EPHY_HEADER_BAR (window->header_bar)));
     gtk_editable_set_editable (GTK_EDITABLE (entry), FALSE);
 
     if (webkit_window_properties_get_menubar_visible (properties))
@@ -2746,23 +2743,22 @@ sync_user_input_cb (EphyLocationController *action,
 }
 
 static void
-open_security_popover (EphyWindow   *window,
-                       GtkWidget    *relative_to,
-                       GdkRectangle *lock_position)
+title_widget_lock_clicked_cb (EphyTitleWidget *title_widget,
+                              GdkRectangle    *lock_position,
+                              gpointer         user_data)
 {
+  EphyWindow *window = EPHY_WINDOW (user_data);
   EphyWebView *view;
   GTlsCertificate *certificate;
   GTlsCertificateFlags tls_errors;
   EphySecurityLevel security_level;
-  GtkWidget *location_entry;
   GtkWidget *security_popover;
 
   view = ephy_embed_get_web_view (window->active_embed);
   ephy_web_view_get_security_level (view, &security_level, &certificate, &tls_errors);
-  location_entry = ephy_header_bar_get_location_entry (EPHY_HEADER_BAR (window->header_bar));
 
-  security_popover = ephy_security_popover_new (relative_to,
-                                                ephy_title_widget_get_address (EPHY_TITLE_WIDGET 
(location_entry)),
+  security_popover = ephy_security_popover_new (GTK_WIDGET (title_widget),
+                                                ephy_title_widget_get_address (title_widget),
                                                 certificate,
                                                 tls_errors,
                                                 security_level);
@@ -2774,35 +2770,12 @@ open_security_popover (EphyWindow   *window,
   gtk_widget_show (security_popover);
 }
 
-static void
-location_controller_lock_clicked_cb (EphyLocationController *controller,
-                                     gpointer                user_data)
-{
-  EphyWindow *window = EPHY_WINDOW (user_data);
-  GtkWidget *location_entry;
-  GdkRectangle lock_position;
-
-  location_entry = ephy_header_bar_get_location_entry (EPHY_HEADER_BAR (window->header_bar));
-  gtk_entry_get_icon_area (GTK_ENTRY (location_entry), GTK_ENTRY_ICON_SECONDARY, &lock_position);
-  open_security_popover (window, location_entry, &lock_position);
-}
-
-static void
-title_box_lock_clicked_cb (EphyTitleBox *title_box,
-                           GdkRectangle *lock_position,
-                           gpointer      user_data)
-{
-  EphyWindow *window = EPHY_WINDOW (user_data);
-
-  open_security_popover (window, GTK_WIDGET (title_box), lock_position);
-}
-
 static GtkWidget *
 setup_header_bar (EphyWindow *window)
 {
   GtkWidget *header_bar;
   EphyEmbedShellMode app_mode;
-  EphyTitleBox *title_box;
+  EphyTitleWidget *title_widget;
 
   header_bar = ephy_header_bar_new (window);
   gtk_window_set_titlebar (GTK_WINDOW (window), header_bar);
@@ -2812,9 +2785,9 @@ setup_header_bar (EphyWindow *window)
   if (app_mode == EPHY_EMBED_SHELL_MODE_INCOGNITO)
     gtk_style_context_add_class (gtk_widget_get_style_context (header_bar), "incognito-mode");
 
-  title_box = ephy_header_bar_get_title_box (EPHY_HEADER_BAR (header_bar));
-  g_signal_connect (title_box, "lock-clicked",
-                    G_CALLBACK (title_box_lock_clicked_cb), window);
+  title_widget = ephy_header_bar_get_title_widget (EPHY_HEADER_BAR (header_bar));
+  g_signal_connect (title_widget, "lock-clicked",
+                    G_CALLBACK (title_widget_lock_clicked_cb), window);
 
   return header_bar;
 }
@@ -2828,15 +2801,12 @@ setup_location_controller (EphyWindow    *window,
   location_controller =
     g_object_new (EPHY_TYPE_LOCATION_CONTROLLER,
                   "window", window,
-                  "location-entry", ephy_header_bar_get_location_entry (header_bar),
-                  "title-box", ephy_header_bar_get_title_box (header_bar),
+                  "title-widget", ephy_header_bar_get_title_widget (header_bar),
                   NULL);
   g_signal_connect (location_controller, "notify::address",
                     G_CALLBACK (sync_user_input_cb), window);
   g_signal_connect_swapped (location_controller, "open-link",
                             G_CALLBACK (ephy_link_open), window);
-  g_signal_connect (location_controller, "lock-clicked",
-                    G_CALLBACK (location_controller_lock_clicked_cb), window);
 
   return location_controller;
 }
@@ -3201,13 +3171,15 @@ ephy_window_load_url (EphyWindow *window,
 void
 ephy_window_activate_location (EphyWindow *window)
 {
-  GtkWidget *entry;
+  EphyTitleWidget *title_widget;
 
   if (!(window->chrome & EPHY_WINDOW_CHROME_LOCATION))
     return;
 
-  entry = ephy_header_bar_get_location_entry (EPHY_HEADER_BAR (window->header_bar));
-  ephy_location_entry_activate (EPHY_LOCATION_ENTRY (entry));
+  title_widget = ephy_header_bar_get_title_widget (EPHY_HEADER_BAR (window->header_bar));
+
+  if (EPHY_IS_LOCATION_ENTRY (title_widget))
+    ephy_location_entry_activate (EPHY_LOCATION_ENTRY (title_widget));
 }
 
 /**


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