aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2012-01-19 01:59:57 +0800
committerCosimo Cecchi <cosimoc@gnome.org>2012-01-20 02:07:22 +0800
commit90e79ffec92b47fbc6ad8b575b9691b1f7621f3b (patch)
treeb7242ebaf9f6792a7253fb280e030ac7454029be /src
parent653966c7a52cd037dd86623f85ffdd7fcd47b822 (diff)
downloadgsoc2013-epiphany-90e79ffec92b47fbc6ad8b575b9691b1f7621f3b.tar
gsoc2013-epiphany-90e79ffec92b47fbc6ad8b575b9691b1f7621f3b.tar.gz
gsoc2013-epiphany-90e79ffec92b47fbc6ad8b575b9691b1f7621f3b.tar.bz2
gsoc2013-epiphany-90e79ffec92b47fbc6ad8b575b9691b1f7621f3b.tar.lz
gsoc2013-epiphany-90e79ffec92b47fbc6ad8b575b9691b1f7621f3b.tar.xz
gsoc2013-epiphany-90e79ffec92b47fbc6ad8b575b9691b1f7621f3b.tar.zst
gsoc2013-epiphany-90e79ffec92b47fbc6ad8b575b9691b1f7621f3b.zip
entry: make EphyLocationEntry a GtkEntry
Instead of a GtkToolItem. A future commit will move the code in EphyLocationAction not to be a GtkAction, which is why this was a GtkToolItem in the first place. https://bugzilla.gnome.org/show_bug.cgi?id=668206
Diffstat (limited to 'src')
-rw-r--r--src/ephy-location-action.c54
-rw-r--r--src/ephy-toolbar.c12
-rw-r--r--src/ephy-toolbar.h2
-rw-r--r--src/ephy-window.c74
4 files changed, 36 insertions, 106 deletions
diff --git a/src/ephy-location-action.c b/src/ephy-location-action.c
index 0a867a4eb..8223f38fd 100644
--- a/src/ephy-location-action.c
+++ b/src/ephy-location-action.c
@@ -177,21 +177,19 @@ action_activated_cb (GtkEntryCompletion *completion,
static void
entry_activate_cb (GtkEntry *entry,
- EphyLocationAction *proxy)
+ GtkAction *action)
{
EphyBookmarks *bookmarks;
const char *content;
char *address;
- GtkAction *action;
EphyLocationActionPrivate *priv;
-
- action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy));
+
priv = EPHY_LOCATION_ACTION (action)->priv;
if (priv->sync_address_is_blocked)
{
priv->sync_address_is_blocked = FALSE;
- g_signal_handlers_unblock_by_func (action, G_CALLBACK (sync_address), proxy);
+ g_signal_handlers_unblock_by_func (action, G_CALLBACK (sync_address), entry);
}
content = gtk_entry_get_text (entry);
@@ -252,10 +250,8 @@ sync_editable (GtkAction *gaction,
{
EphyLocationAction *action = EPHY_LOCATION_ACTION (gaction);
EphyLocationEntry *lentry = EPHY_LOCATION_ENTRY (proxy);
- GtkWidget *entry;
- entry = ephy_location_entry_get_entry (lentry);
- gtk_editable_set_editable (GTK_EDITABLE (entry), action->priv->editable);
+ gtk_editable_set_editable (GTK_EDITABLE (lentry), action->priv->editable);
}
static void
@@ -337,12 +333,10 @@ remove_completion_actions (GtkAction *gaction,
{
EphyLocationAction *action = EPHY_LOCATION_ACTION (gaction);
EphyLocationEntry *lentry = EPHY_LOCATION_ENTRY (proxy);
- GtkWidget *entry;
GtkEntryCompletion *completion;
GList *l;
- entry = ephy_location_entry_get_entry (lentry);
- completion = gtk_entry_get_completion (GTK_ENTRY (entry));
+ completion = gtk_entry_get_completion (GTK_ENTRY (lentry));
for (l = action->priv->actions; l != NULL; l = l->next)
{
@@ -359,12 +353,10 @@ add_completion_actions (GtkAction *gaction,
{
EphyLocationAction *action = EPHY_LOCATION_ACTION (gaction);
EphyLocationEntry *lentry = EPHY_LOCATION_ENTRY (proxy);
- GtkWidget *entry;
GtkEntryCompletion *completion;
GList *l;
- entry = ephy_location_entry_get_entry (lentry);
- completion = gtk_entry_get_completion (GTK_ENTRY (entry));
+ completion = gtk_entry_get_completion (GTK_ENTRY (lentry));
for (l = action->priv->actions; l != NULL; l = l->next)
{
@@ -385,18 +377,15 @@ add_completion_actions (GtkAction *gaction,
static gboolean
focus_in_event_cb (GtkWidget *entry,
GdkEventFocus *event,
- GtkWidget *proxy)
+ GtkAction *action)
{
- GtkAction *action;
EphyLocationActionPrivate *priv;
- action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy));
-
priv = EPHY_LOCATION_ACTION (action)->priv;
if (!priv->sync_address_is_blocked)
{
priv->sync_address_is_blocked = TRUE;
- g_signal_handlers_block_by_func (action, G_CALLBACK (sync_address), proxy);
+ g_signal_handlers_block_by_func (action, G_CALLBACK (sync_address), entry);
}
return FALSE;
@@ -405,18 +394,16 @@ focus_in_event_cb (GtkWidget *entry,
static gboolean
focus_out_event_cb (GtkWidget *entry,
GdkEventFocus *event,
- GtkWidget *proxy)
+ GtkAction *action)
{
- GtkAction *action;
EphyLocationActionPrivate *priv;
- action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy));
priv = EPHY_LOCATION_ACTION (action)->priv;
if (priv->sync_address_is_blocked)
{
priv->sync_address_is_blocked = FALSE;
- g_signal_handlers_unblock_by_func (action, G_CALLBACK (sync_address), proxy);
+ g_signal_handlers_unblock_by_func (action, G_CALLBACK (sync_address), entry);
}
return FALSE;
@@ -444,9 +431,7 @@ connect_proxy (GtkAction *action, GtkWidget *proxy)
{
if (EPHY_IS_LOCATION_ENTRY (proxy))
{
- EphyLocationEntry *lentry = EPHY_LOCATION_ENTRY (proxy);
EphyCompletionModel *model;
- GtkWidget *entry;
GtkWidget *notebook;
EphyLocationActionPrivate *priv;
@@ -496,10 +481,9 @@ connect_proxy (GtkAction *action, GtkWidget *proxy)
g_signal_connect_object (action, "notify::show-lock",
G_CALLBACK (sync_show_lock), proxy, 0);
- entry = ephy_location_entry_get_entry (lentry);
- g_signal_connect_object (entry, "activate",
+ g_signal_connect_object (proxy, "activate",
G_CALLBACK (entry_activate_cb),
- proxy, 0);
+ action, 0);
g_signal_connect_object (proxy, "user-changed",
G_CALLBACK (user_changed_cb), action, 0);
g_signal_connect_object (proxy, "lock-clicked",
@@ -508,10 +492,10 @@ connect_proxy (GtkAction *action, GtkWidget *proxy)
G_CALLBACK (get_location_cb), action, 0);
g_signal_connect_object (proxy, "get-title",
G_CALLBACK (get_title_cb), action, 0);
- g_signal_connect_object (entry, "focus-in-event",
- G_CALLBACK (focus_in_event_cb), proxy, 0);
- g_signal_connect_object (entry, "focus-out-event",
- G_CALLBACK (focus_out_event_cb), proxy, 0);
+ g_signal_connect_object (proxy, "focus-in-event",
+ G_CALLBACK (focus_in_event_cb), action, 0);
+ g_signal_connect_object (proxy, "focus-out-event",
+ G_CALLBACK (focus_out_event_cb), action, 0);
}
GTK_ACTION_CLASS (ephy_location_action_parent_class)->connect_proxy (action, proxy);
@@ -524,22 +508,18 @@ disconnect_proxy (GtkAction *action, GtkWidget *proxy)
if (EPHY_IS_LOCATION_ENTRY (proxy))
{
- EphyLocationEntry *lentry = EPHY_LOCATION_ENTRY (proxy);
- GtkWidget *entry, *notebook;
+ GtkWidget *notebook;
EphyLocationActionPrivate *priv;
priv = EPHY_LOCATION_ACTION (action)->priv;
priv->proxy = NULL;
- entry = ephy_location_entry_get_entry (lentry);
notebook = ephy_window_get_notebook (priv->window);
g_signal_handlers_disconnect_matched (action, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, proxy);
g_signal_handlers_disconnect_matched (proxy, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, action);
- g_signal_handlers_disconnect_matched (entry, G_SIGNAL_MATCH_DATA,
- 0, 0, NULL, NULL, action);
g_signal_handlers_disconnect_matched (notebook, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, action);
}
diff --git a/src/ephy-toolbar.c b/src/ephy-toolbar.c
index 48447eb0c..026363984 100644
--- a/src/ephy-toolbar.c
+++ b/src/ephy-toolbar.c
@@ -36,7 +36,8 @@ enum {
static GParamSpec *object_properties[N_PROPERTIES] = { NULL, };
struct _EphyToolbarPrivate {
- EphyWindow *window;
+ EphyWindow *window;
+ GtkWidget *entry;
};
static void
@@ -136,6 +137,7 @@ ephy_toolbar_constructed (GObject *object)
/* Location */
action = gtk_action_group_get_action (action_group, "Location");
location = gtk_action_create_tool_item (action);
+ priv->entry = location;
gtk_box_pack_start (GTK_BOX (box), location,
TRUE, TRUE, 0);
gtk_style_context_add_class (gtk_widget_get_style_context (box),
@@ -156,7 +158,7 @@ ephy_toolbar_constructed (GObject *object)
GTK_WIDGET (location_stop_reload),
"expand", TRUE,
NULL);
-
+
gtk_container_add (GTK_CONTAINER (toolbar), GTK_WIDGET (location_stop_reload));
gtk_widget_set_margin_right (GTK_WIDGET (location_stop_reload), 12);
gtk_widget_show_all (GTK_WIDGET (location_stop_reload));
@@ -214,3 +216,9 @@ ephy_toolbar_new (EphyWindow *window)
"window", window,
NULL));
}
+
+GtkWidget *
+ephy_toolbar_get_location_entry (EphyToolbar *toolbar)
+{
+ return toolbar->priv->entry;
+}
diff --git a/src/ephy-toolbar.h b/src/ephy-toolbar.h
index 2ecc97f4e..d1d26b85a 100644
--- a/src/ephy-toolbar.h
+++ b/src/ephy-toolbar.h
@@ -57,6 +57,8 @@ GType ephy_toolbar_get_type (void) G_GNUC_CONST;
GtkWidget *ephy_toolbar_new (EphyWindow *window);
+GtkWidget *ephy_toolbar_get_location_entry (EphyToolbar *toolbar);
+
G_END_DECLS
#endif /* EPHY_TOOLBAR_H */
diff --git a/src/ephy-window.c b/src/ephy-window.c
index e86188c5f..2492b1b93 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -426,7 +426,6 @@ struct _EphyWindowPrivate
GHashTable *tabs_to_remove;
EphyEmbedEvent *context_event;
guint idle_worker;
- GtkWidget *entry;
GtkWidget *downloads_box;
guint clear_progress_timeout_id;
@@ -759,26 +758,6 @@ sync_chromes_visibility (EphyWindow *window)
}
static void
-ensure_location_entry (EphyWindow *window)
-{
- GtkActionGroup *toolbar_action_group;
- GtkAction *action;
- GSList *proxies;
- GtkWidget *proxy;
- EphyWindowPrivate *priv = window->priv;
-
- toolbar_action_group = priv->toolbar_action_group;
- action = gtk_action_group_get_action (toolbar_action_group,
- "Location");
- proxies = gtk_action_get_proxies (action);
- if (proxies)
- {
- proxy = GTK_WIDGET (proxies->data);
- priv->entry = ephy_location_entry_get_entry (EPHY_LOCATION_ENTRY (proxy));
- }
-}
-
-static void
ephy_window_fullscreen (EphyWindow *window)
{
EphyWindowPrivate *priv = window->priv;
@@ -804,8 +783,6 @@ ephy_window_fullscreen (EphyWindow *window)
sync_tab_load_status (ephy_embed_get_web_view (embed), NULL, window);
sync_tab_security (ephy_embed_get_web_view (embed), NULL, window);
- ensure_location_entry (window);
-
sync_chromes_visibility (window);
}
@@ -816,8 +793,6 @@ ephy_window_unfullscreen (EphyWindow *window)
destroy_fullscreen_popup (window);
- ensure_location_entry (window);
-
sync_chromes_visibility (window);
}
@@ -1118,17 +1093,10 @@ update_edit_actions_sensitivity (EphyWindow *window, gboolean hide)
if (GTK_IS_EDITABLE (widget))
{
+ GtkWidget *entry;
gboolean has_selection;
- GtkActionGroup *action_group;
- GtkAction *location_action;
- GSList *proxies;
- GtkWidget *proxy;
-
- action_group = window->priv->toolbar_action_group;
- location_action = gtk_action_group_get_action (action_group,
- "Location");
- proxies = gtk_action_get_proxies (location_action);
- proxy = GTK_WIDGET (proxies->data);
+
+ entry = ephy_toolbar_get_location_entry (EPHY_TOOLBAR (window->priv->toolbar));
has_selection = gtk_editable_get_selection_bounds
(GTK_EDITABLE (widget), NULL, NULL);
@@ -1136,18 +1104,8 @@ update_edit_actions_sensitivity (EphyWindow *window, gboolean hide)
can_copy = has_selection;
can_cut = has_selection;
can_paste = TRUE;
- if (proxy != NULL &&
- EPHY_IS_LOCATION_ENTRY (proxy) &&
- widget == ephy_location_entry_get_entry (EPHY_LOCATION_ENTRY (proxy)))
- {
- can_undo = ephy_location_entry_get_can_undo (EPHY_LOCATION_ENTRY (proxy));
- can_redo = ephy_location_entry_get_can_redo (EPHY_LOCATION_ENTRY (proxy));
- }
- else
- {
- can_undo = FALSE;
- can_redo = FALSE;
- }
+ can_undo = ephy_location_entry_get_can_undo (EPHY_LOCATION_ENTRY (entry));
+ can_redo = ephy_location_entry_get_can_redo (EPHY_LOCATION_ENTRY (entry));
}
else
{
@@ -3779,8 +3737,6 @@ ephy_window_constructor (GType type,
sync_chromes_visibility (window);
- ensure_location_entry (window);
-
return object;
}
@@ -3843,26 +3799,10 @@ static void
_ephy_window_activate_location (EphyWindow *window)
{
EphyWindowPrivate *priv = window->priv;
- GtkAction *action;
- GSList *proxies;
- GtkWidget *entry = NULL;
+ GtkWidget *entry;
gboolean visible;
- action = gtk_action_group_get_action (priv->toolbar_action_group, "Location");
- proxies = gtk_action_get_proxies (action);
-
- if (proxies != NULL && EPHY_IS_LOCATION_ENTRY (proxies->data))
- {
- entry = GTK_WIDGET (proxies->data);
- }
-
- if (entry == NULL)
- {
- /* happens when the user has removed the location entry from
- * the toolbars.
- */
- return;
- }
+ entry = ephy_toolbar_get_location_entry (EPHY_TOOLBAR (priv->toolbar));
g_object_get (G_OBJECT (priv->toolbar), "visible", &visible, NULL);
if (visible == FALSE)