aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog31
-rw-r--r--lib/widgets/ephy-location-entry.c89
-rw-r--r--lib/widgets/ephy-location-entry.h4
-rw-r--r--src/ephy-shell.c4
-rw-r--r--src/ephy-tab.c53
-rw-r--r--src/ephy-window.c20
-rw-r--r--src/popup-commands.c4
-rwxr-xr-xsrc/toolbar.c73
-rw-r--r--src/toolbar.h2
9 files changed, 151 insertions, 129 deletions
diff --git a/ChangeLog b/ChangeLog
index f7962d7f8..921b1eff7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,36 @@
2003-06-20 Marco Pesenti Gritti <marco@it.gnome.org>
+ * embed/mozilla/EphyWrapper.cpp:
+ * lib/widgets/ephy-location-entry.c:
+ (ephy_location_entry_class_init), (location_focus_out_cb),
+ (ephy_location_entry_init), (insert_text_cb),
+ (ephy_location_entry_key_press_event_cb),
+ (ephy_location_entry_activate_cb),
+ (ephy_location_entry_set_location),
+ (ephy_location_entry_autocompletion_window_url_selected_cb),
+ (ephy_location_entry_autocompletion_window_url_activated_cb),
+ (ephy_location_entry_editable_changed_cb):
+ * lib/widgets/ephy-location-entry.h:
+ * src/ephy-shell.c: (ephy_shell_new_tab):
+ * src/ephy-tab.c: (ephy_tab_set_property),
+ (ephy_tab_set_link_message), (ephy_tab_set_window),
+ (ephy_tab_address_cb), (ensure_address), (ephy_tab_net_state_cb),
+ (ephy_tab_init), (ephy_tab_update_navigation_flags),
+ (ephy_tab_set_location):
+ * src/ephy-tab.h:
+ * src/ephy-window.c: (ephy_window_notebook_switch_page_cb):
+ * src/popup-commands.c: (get_event_info),
+ (popup_cmd_copy_link_address):
+ * src/toolbar.c: (get_location_entry), (location_user_changed_cb),
+ (toolbar_set_window), (toolbar_activate_location),
+ (toolbar_set_location), (toolbar_get_location),
+ (toolbar_clear_location_history):
+ * src/toolbar.h:
+
+ Rewrite the url typed by user overwrite logic to fix bugs.
+
+2003-06-20 Marco Pesenti Gritti <marco@it.gnome.org>
+
* src/ephy-tab.c: (ephy_tab_finalize), (ephy_tab_init):
* src/ephy-tab.h:
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index f595b2140..9cd984b80 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -45,7 +45,7 @@ struct _EphyLocationEntryPrivate {
gint show_alternatives_timeout;
gboolean block_set_autocompletion_key;
gboolean going_to_site;
- gboolean editing;
+ gboolean user_changed;
gchar *autocompletion_key;
gchar *last_completion;
@@ -104,6 +104,7 @@ static gpointer gtk_hbox_class;
enum EphyLocationEntrySignalsEnum {
ACTIVATED,
FINISHED,
+ USER_CHANGED,
LAST_SIGNAL
};
static gint EphyLocationEntrySignals[LAST_SIGNAL];
@@ -141,13 +142,20 @@ ephy_location_entry_class_init (EphyLocationEntryClass *klass)
G_TYPE_NONE,
0,
G_TYPE_NONE);
+ EphyLocationEntrySignals[USER_CHANGED] = g_signal_new (
+ "user_changed", G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST | G_SIGNAL_RUN_CLEANUP,
+ G_STRUCT_OFFSET (EphyLocationEntryClass, user_changed),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0,
+ G_TYPE_NONE);
}
static gboolean
location_focus_out_cb (GtkWidget *widget, GdkEventFocus *event, EphyLocationEntry *w)
{
- w->priv->editing = FALSE;
-
g_signal_emit (w, EphyLocationEntrySignals[FINISHED], 0);
return FALSE;
@@ -159,8 +167,8 @@ ephy_location_entry_init (EphyLocationEntry *w)
EphyLocationEntryPrivate *p = g_new0 (EphyLocationEntryPrivate, 1);
w->priv = p;
p->last_action_target = NULL;
- p->editing = FALSE;
p->before_completion = NULL;
+ p->user_changed = TRUE;
ephy_location_entry_build (w);
@@ -355,27 +363,6 @@ position_is_at_end (GtkEditable *editable)
}
static void
-real_entry_set_location (EphyLocationEntry *w,
- const gchar *new_location)
-{
- EphyLocationEntryPrivate *p = w->priv;
- int pos;
-
- g_signal_handlers_block_by_func (G_OBJECT (p->entry),
- delete_text_cb, w);
- gtk_editable_delete_text (GTK_EDITABLE (p->entry), 0, -1);
- g_signal_handlers_unblock_by_func (G_OBJECT (p->entry),
- delete_text_cb, w);
-
- g_signal_handlers_block_by_func (G_OBJECT (p->entry),
- insert_text_cb, w);
- gtk_editable_insert_text (GTK_EDITABLE (p->entry), new_location, strlen(new_location),
- &pos);
- g_signal_handlers_unblock_by_func (G_OBJECT (p->entry),
- insert_text_cb, w);
-}
-
-static void
delete_text_cb (GtkWidget *editable,
int start_pos,
int end_pos,
@@ -405,7 +392,6 @@ insert_text_cb (GtkWidget *editable,
p->show_alternatives_timeout = 0;
}
- w->priv->editing = TRUE;
ephy_location_entry_autocompletion_unselect_alternatives (w);
if (position_is_at_end (GTK_EDITABLE (editable)))
{
@@ -427,7 +413,7 @@ ephy_location_entry_key_press_event_cb (GtkWidget *entry, GdkEventKey *event, Ep
ephy_location_entry_autocompletion_hide_alternatives (w);
return FALSE;
case GDK_Escape:
- real_entry_set_location (w, p->before_completion);
+ ephy_location_entry_set_location (w, p->before_completion);
gtk_editable_set_position (GTK_EDITABLE (p->entry), -1);
ephy_location_entry_autocompletion_hide_alternatives (w);
return FALSE;
@@ -470,8 +456,6 @@ ephy_location_entry_activate_cb (GtkEntry *entry, EphyLocationEntry *w)
LOG ("In ephy_location_entry_activate_cb, activating %s", content)
- w->priv->editing = FALSE;
-
g_signal_emit (w, EphyLocationEntrySignals[ACTIVATED], 0, content, target);
g_signal_emit (w, EphyLocationEntrySignals[FINISHED], 0);
@@ -500,10 +484,25 @@ void
ephy_location_entry_set_location (EphyLocationEntry *w,
const gchar *new_location)
{
- if (!w->priv->editing)
- {
- real_entry_set_location (w, new_location);
- }
+ EphyLocationEntryPrivate *p = w->priv;
+ int pos;
+
+ p->user_changed = FALSE;
+
+ g_signal_handlers_block_by_func (G_OBJECT (p->entry),
+ delete_text_cb, w);
+ gtk_editable_delete_text (GTK_EDITABLE (p->entry), 0, -1);
+ g_signal_handlers_unblock_by_func (G_OBJECT (p->entry),
+ delete_text_cb, w);
+
+ g_signal_handlers_block_by_func (G_OBJECT (p->entry),
+ insert_text_cb, w);
+ gtk_editable_insert_text (GTK_EDITABLE (p->entry), new_location, strlen(new_location),
+ &pos);
+ g_signal_handlers_unblock_by_func (G_OBJECT (p->entry),
+ insert_text_cb, w);
+
+ p->user_changed = TRUE;
}
gchar *
@@ -521,11 +520,11 @@ ephy_location_entry_autocompletion_window_url_selected_cb (EphyAutocompletionWin
{
if (target)
{
- real_entry_set_location (w, action ? w->priv->before_completion : target);
+ ephy_location_entry_set_location (w, action ? w->priv->before_completion : target);
}
else
{
- real_entry_set_location (w, w->priv->before_completion);
+ ephy_location_entry_set_location (w, w->priv->before_completion);
gtk_editable_set_position (GTK_EDITABLE (w->priv->entry), -1);
}
}
@@ -589,7 +588,7 @@ ephy_location_entry_autocompletion_window_url_activated_cb (EphyAutocompletionWi
}
else
{
- real_entry_set_location (w, target);
+ ephy_location_entry_set_location (w, target);
}
content = gtk_editable_get_chars (GTK_EDITABLE(w->priv->entry), 0, -1);
@@ -628,19 +627,6 @@ ephy_location_entry_autocompletion_window_hidden_cb (EphyAutocompletionWindow *a
}
void
-ephy_location_entry_edit (EphyLocationEntry *w)
-{
- GtkWidget *toplevel;
-
- w->priv->editing = TRUE;
-
- toplevel = gtk_widget_get_toplevel (w->priv->entry);
-
- gtk_window_set_focus (GTK_WINDOW(toplevel),
- w->priv->entry);
-}
-
-void
ephy_location_entry_activate (EphyLocationEntry *w)
{
GtkWidget *toplevel;
@@ -683,6 +669,11 @@ ephy_location_entry_editable_changed_cb (GtkEditable *editable, EphyLocationEntr
g_free (url);
}
}
+
+ if (p->user_changed)
+ {
+ g_signal_emit (e, EphyLocationEntrySignals[USER_CHANGED], 0);
+ }
}
static void
diff --git a/lib/widgets/ephy-location-entry.h b/lib/widgets/ephy-location-entry.h
index 1b9f37f25..7191d918b 100644
--- a/lib/widgets/ephy-location-entry.h
+++ b/lib/widgets/ephy-location-entry.h
@@ -52,7 +52,10 @@ struct _EphyLocationEntryClass
void (*activated) (EphyLocationEntry *w,
const char *content,
const char *target);
+
void (*finished) (EphyLocationEntry *w);
+
+ void (*user_changed) (EphyLocationEntry *w);
};
/* Remember: fields are public read-only */
@@ -71,7 +74,6 @@ gchar *ephy_location_entry_get_location (EphyLocationEntry *w);
void ephy_location_entry_set_autocompletion (EphyLocationEntry *w,
EphyAutocompletion *ac);
void ephy_location_entry_activate (EphyLocationEntry *w);
-void ephy_location_entry_edit (EphyLocationEntry *w);
void ephy_location_entry_clear_history (EphyLocationEntry *w);
#endif
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 5489222d6..7af15a0a3 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -402,9 +402,9 @@ ephy_shell_new_tab (EphyShell *shell,
if (flags & EPHY_NEW_TAB_HOME_PAGE ||
flags & EPHY_NEW_TAB_NEW_PAGE)
{
- toolbar_edit_location (toolbar);
-
+ ephy_tab_set_location (tab, "", TAB_ADDRESS_EXPIRE_NEXT);
load_homepage (embed);
+ toolbar_activate_location (toolbar);
}
else if (flags & EPHY_NEW_TAB_OPEN_PAGE)
{
diff --git a/src/ephy-tab.c b/src/ephy-tab.c
index 35226b583..2c34b0542 100644
--- a/src/ephy-tab.c
+++ b/src/ephy-tab.c
@@ -59,6 +59,7 @@ struct EphyTabPrivate
int load_percent;
gboolean visibility;
gboolean load_status;
+ TabAddressExpire address_expire;
int cur_requests;
int total_requests;
int width;
@@ -152,7 +153,8 @@ ephy_tab_set_property (GObject *object,
{
case PROP_ADDRESS:
- ephy_tab_set_location (tab, g_value_get_string (value));
+ ephy_tab_set_location (tab, g_value_get_string (value),
+ TAB_ADDRESS_EXPIRE_NOW);
break;
case PROP_WINDOW:
ephy_tab_set_window (tab, g_value_get_object (value));
@@ -421,7 +423,7 @@ ephy_tab_set_link_message (EphyTab *tab, const char *message)
g_free (tab->priv->link_message);
tab->priv->link_message = g_strdup (message);
-
+
g_object_notify (G_OBJECT (tab), "message");
}
@@ -450,7 +452,7 @@ ephy_tab_set_window (EphyTab *tab, EphyWindow *window)
if (window != tab->priv->window)
{
tab->priv->window = window;
-
+
g_object_notify (G_OBJECT (tab), "window");
}
}
@@ -562,11 +564,14 @@ ephy_tab_link_message_cb (EphyEmbed *embed,
static void
ephy_tab_address_cb (EphyEmbed *embed, EphyTab *tab)
{
- char *address;
+ if (tab->priv->address_expire == TAB_ADDRESS_EXPIRE_NOW)
+ {
+ char *address;
- ephy_embed_get_location (embed, TRUE, &address);
- ephy_tab_set_location (tab, address);
- g_free (address);
+ ephy_embed_get_location (embed, TRUE, &address);
+ ephy_tab_set_location (tab, address, TAB_ADDRESS_EXPIRE_NOW);
+ g_free (address);
+ }
ephy_tab_set_link_message (tab, NULL);
ephy_tab_set_icon_address (tab, NULL);
@@ -709,9 +714,10 @@ build_progress_from_requests (EphyTab *tab, EmbedState state)
static void
ensure_address (EphyTab *tab, const char *address)
{
- if (tab->priv->address == NULL)
- {
- ephy_tab_set_location (tab, address);
+ if (tab->priv->address == NULL &&
+ tab->priv->address_expire == TAB_ADDRESS_EXPIRE_NOW)
+ {
+ ephy_tab_set_location (tab, address, TAB_ADDRESS_EXPIRE_NOW);
}
}
@@ -744,7 +750,7 @@ ephy_tab_net_state_cb (EphyEmbed *embed, const char *uri,
}
else if (state & EMBED_STATE_STOP)
{
- /* tab load completed, save in session */
+ /* tab load completed, save in session */
Session *s;
s = ephy_shell_get_session (ephy_shell);
session_save (s, SESSION_CRASHED);
@@ -752,6 +758,7 @@ ephy_tab_net_state_cb (EphyEmbed *embed, const char *uri,
ephy_tab_set_load_percent (tab, 0);
ephy_tab_set_load_status (tab, FALSE);
ephy_tab_update_navigation_flags (tab);
+ tab->priv->address_expire = TAB_ADDRESS_EXPIRE_NOW;
}
}
@@ -921,7 +928,7 @@ ephy_tab_init (EphyTab *tab)
char *id;
LOG ("EphyTab initialising %p", tab)
-
+
single = ephy_embed_shell_get_embed_single
(EPHY_EMBED_SHELL (ephy_shell));
@@ -942,7 +949,8 @@ ephy_tab_init (EphyTab *tab)
tab->priv->link_message = NULL;
tab->priv->security_level = STATE_IS_UNKNOWN;
tab->priv->status_message = NULL;
- tab->priv->zoom = 1.0;
+ tab->priv->zoom = 1.0;
+ tab->priv->address_expire = TAB_ADDRESS_EXPIRE_NOW;
tab->priv->embed = ephy_embed_new (G_OBJECT(single));
ephy_embed_shell_add_embed (EPHY_EMBED_SHELL (ephy_shell),
@@ -1063,9 +1071,9 @@ ephy_tab_update_navigation_flags (EphyTab *tab)
if (flags != tab->priv->nav_flags)
{
tab->priv->nav_flags = flags;
-
+
g_object_notify (G_OBJECT (tab), "navigation");
- }
+ }
}
TabNavigationFlags
@@ -1168,13 +1176,24 @@ ephy_tab_get_location (EphyTab *tab)
void
ephy_tab_set_location (EphyTab *tab,
- const char *address)
+ const char *address,
+ TabAddressExpire expire)
{
g_return_if_fail (IS_EPHY_TAB (tab));
if (tab->priv->address) g_free (tab->priv->address);
tab->priv->address = g_strdup (address);
-
+
+ if (expire == TAB_ADDRESS_EXPIRE_CURRENT &&
+ !tab->priv->load_status)
+ {
+ tab->priv->address_expire = TAB_ADDRESS_EXPIRE_NOW;
+ }
+ else
+ {
+ tab->priv->address_expire = expire;
+ }
+
g_object_notify (G_OBJECT (tab), "address");
}
diff --git a/src/ephy-window.c b/src/ephy-window.c
index dc2b39983..1af5df479 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -1792,16 +1792,6 @@ ephy_window_get_tabs (EphyWindow *window)
}
static void
-save_old_embed_status (EphyTab *tab, EphyWindow *window)
-{
- char *location;
-
- location = toolbar_get_location (window->priv->toolbar);
- ephy_tab_set_location (tab, location);
- g_free (location);
-}
-
-static void
update_embed_dialogs (EphyWindow *window,
EphyTab *tab)
{
@@ -1824,7 +1814,7 @@ ephy_window_notebook_switch_page_cb (GtkNotebook *notebook,
guint page_num,
EphyWindow *window)
{
- EphyTab *tab, *old_tab;
+ EphyTab *tab;
g_return_if_fail (IS_EPHY_WINDOW (window));
if (window->priv->closing) return;
@@ -1832,14 +1822,6 @@ ephy_window_notebook_switch_page_cb (GtkNotebook *notebook,
/* get the new tab */
tab = real_get_active_tab (window, page_num);
- /* update old tab */
- old_tab = window->priv->active_tab;
- if (old_tab && tab != old_tab)
- {
- g_return_if_fail (IS_EPHY_TAB (G_OBJECT (old_tab)));
- save_old_embed_status (old_tab, window);
- }
-
/* update new tab */
ephy_window_set_active_tab (window, tab);
diff --git a/src/popup-commands.c b/src/popup-commands.c
index 490982351..1b2c4d68a 100644
--- a/src/popup-commands.c
+++ b/src/popup-commands.c
@@ -32,7 +32,8 @@ get_event_info (EphyWindow *window)
{
EphyEmbedEvent *info;
- info = EPHY_EMBED_EVENT (g_object_get_data (window, "context_event"));
+ info = EPHY_EMBED_EVENT (g_object_get_data
+ (G_OBJECT (window), "context_event"));
g_return_val_if_fail (info != NULL, NULL);
return info;
@@ -228,7 +229,6 @@ popup_cmd_copy_link_address (EggAction *action,
EphyEmbedEvent *event;
const char *address;
const GValue *value;
- EphyEmbed *embed;
event = get_event_info (window);
g_return_if_fail (IS_EPHY_EMBED_EVENT (event));
diff --git a/src/toolbar.c b/src/toolbar.c
index 2896c7341..78c0d39f5 100755
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -81,7 +81,6 @@ struct ToolbarPrivate
EggMenuMerge *ui_merge;
EggActionGroup *action_group;
gboolean visibility;
- GtkWidget *location_entry;
GtkWidget *spinner;
GtkWidget *favicon;
GtkWidget *go;
@@ -457,6 +456,34 @@ update_toolbar_remove_flag (EphyToolbarsModel *model, gpointer data)
}
}
+static GtkWidget *
+get_location_entry (Toolbar *t)
+{
+ EggAction *action;
+ GtkWidget *location;
+
+ action = egg_action_group_get_action
+ (t->priv->action_group, "Location");
+ location = ephy_location_action_get_widget
+ (EPHY_LOCATION_ACTION (action));
+
+ return location;
+}
+
+static void
+location_user_changed_cb (GtkWidget *entry, EphyWindow *window)
+{
+ EphyTab *tab;
+ char *address;
+
+ tab = ephy_window_get_active_tab (window);
+ g_return_if_fail (IS_EPHY_TAB (tab));
+
+ address = ephy_location_entry_get_location (EPHY_LOCATION_ENTRY (entry));
+ ephy_tab_set_location (tab, address, TAB_ADDRESS_EXPIRE_CURRENT);
+ g_free (address);
+}
+
static void
toolbar_set_window (Toolbar *t, EphyWindow *window)
{
@@ -487,6 +514,10 @@ toolbar_set_window (Toolbar *t, EphyWindow *window)
"MenuMerge", t->priv->ui_merge,
NULL);
init_bookmarks_toolbar (t);
+
+ g_signal_connect_object (get_location_entry (t), "user_changed",
+ G_CALLBACK (location_user_changed_cb),
+ window, 0);
}
static void
@@ -539,22 +570,6 @@ toolbar_new (EphyWindow *window)
return t;
}
-void
-toolbar_edit_location (Toolbar *t)
-{
- EggAction *action;
- GtkWidget *location;
-
- action = egg_action_group_get_action
- (t->priv->action_group, "Location");
- location = ephy_location_action_get_widget
- (EPHY_LOCATION_ACTION (action));
- g_return_if_fail (location != NULL);
-
- ephy_location_entry_edit
- (EPHY_LOCATION_ENTRY(location));
-}
-
static void
location_finished_cb (GtkWidget *location, GtkWidget *toolbar)
{
@@ -568,14 +583,10 @@ location_finished_cb (GtkWidget *location, GtkWidget *toolbar)
void
toolbar_activate_location (Toolbar *t)
{
- EggAction *action;
GtkWidget *location;
GtkWidget *location_tb;
- action = egg_action_group_get_action
- (t->priv->action_group, "Location");
- location = ephy_location_action_get_widget
- (EPHY_LOCATION_ACTION (action));
+ location = get_location_entry (t);
g_return_if_fail (location != NULL);
location_tb = gtk_widget_get_ancestor (location, EGG_TYPE_TOOLBAR);
@@ -618,13 +629,9 @@ void
toolbar_set_location (Toolbar *t,
const char *alocation)
{
- EggAction *action;
GtkWidget *location;
- action = egg_action_group_get_action
- (t->priv->action_group, "Location");
- location = ephy_location_action_get_widget
- (EPHY_LOCATION_ACTION (action));
+ location = get_location_entry (t);
g_return_if_fail (location != NULL);
ephy_location_entry_set_location
@@ -650,13 +657,9 @@ toolbar_update_favicon (Toolbar *t)
char *
toolbar_get_location (Toolbar *t)
{
- EggAction *action;
GtkWidget *location;
- action = egg_action_group_get_action
- (t->priv->action_group, "Location");
- location = ephy_location_action_get_widget
- (EPHY_LOCATION_ACTION (action));
+ location = get_location_entry (t);
g_return_val_if_fail (location != NULL, NULL);
return ephy_location_entry_get_location
@@ -666,13 +669,9 @@ toolbar_get_location (Toolbar *t)
void
toolbar_clear_location_history (Toolbar *t)
{
- EggAction *action;
GtkWidget *location;
- action = egg_action_group_get_action
- (t->priv->action_group, "Location");
- location = ephy_location_action_get_widget
- (EPHY_LOCATION_ACTION (action));
+ location = get_location_entry (t),
g_return_if_fail (location != NULL);
ephy_location_entry_clear_history (EPHY_LOCATION_ENTRY (location));
diff --git a/src/toolbar.h b/src/toolbar.h
index e21d12d3c..0f1dabb4c 100644
--- a/src/toolbar.h
+++ b/src/toolbar.h
@@ -61,8 +61,6 @@ char *toolbar_get_location (Toolbar *t);
void toolbar_set_location (Toolbar *t,
const char *location);
-void toolbar_edit_location (Toolbar *t);
-
void toolbar_activate_location (Toolbar *t);
void toolbar_clear_location_history (Toolbar *t);