aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@it.gnome.org>2003-02-23 10:20:51 +0800
committerMarco Pesenti Gritti <mpeseng@src.gnome.org>2003-02-23 10:20:51 +0800
commitdb0e48d09abcc0134efac3ce2717c42a216b18e3 (patch)
treeb44b835ecd180d5efc0d3822613837c0c95131a5 /lib
parent6fb4ac671cbcfdd90fffb7752f3fdce8f80cc30e (diff)
downloadgsoc2013-epiphany-db0e48d09abcc0134efac3ce2717c42a216b18e3.tar
gsoc2013-epiphany-db0e48d09abcc0134efac3ce2717c42a216b18e3.tar.gz
gsoc2013-epiphany-db0e48d09abcc0134efac3ce2717c42a216b18e3.tar.bz2
gsoc2013-epiphany-db0e48d09abcc0134efac3ce2717c42a216b18e3.tar.lz
gsoc2013-epiphany-db0e48d09abcc0134efac3ce2717c42a216b18e3.tar.xz
gsoc2013-epiphany-db0e48d09abcc0134efac3ce2717c42a216b18e3.tar.zst
gsoc2013-epiphany-db0e48d09abcc0134efac3ce2717c42a216b18e3.zip
Update location entry with the urls selected on the drop down. Implement
2003-02-23 Marco Pesenti Gritti <marco@it.gnome.org> * lib/widgets/ephy-autocompletion-window.c: (ephy_autocompletion_window_class_init), (ephy_autocompletion_window_key_press_hack): * lib/widgets/ephy-autocompletion-window.h: * lib/widgets/ephy-editable-toolbar.c: (drag_data_delete_cb), (drag_data_get_cb), (connect_toolbar_drag_source), (disconnect_toolbar_drag_source), (do_merge), (editor_close_cb), (button_press_cb), (ephy_editable_toolbar_edit): * lib/widgets/ephy-location-entry.c: (location_focus_out_cb), (ephy_location_entry_init), (real_entry_set_location), (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_set_autocompletion), (ephy_location_entry_autocompletion_window_url_activated_cb), (ephy_location_entry_autocompletion_window_hidden_cb), (ephy_location_entry_edit): * lib/widgets/ephy-location-entry.h: * src/ephy-shell.c: (ephy_shell_new_tab): * src/ephy-window.c: (add_widget): * src/toolbar.c: (toolbar_edit_location): * src/toolbar.h: Update location entry with the urls selected on the drop down. Implement editing mode in location entry == when the user is typing an url try to do not disturb (mozilla still grab the focus damnit). Dont put the homepage url in the location. I'm not sure if this is a good behavior for normal urls (I dont see problems, but please prove me wrong), but for about:blank it's needed.
Diffstat (limited to 'lib')
-rw-r--r--lib/widgets/ephy-autocompletion-window.c29
-rw-r--r--lib/widgets/ephy-autocompletion-window.h4
-rwxr-xr-xlib/widgets/ephy-editable-toolbar.c92
-rw-r--r--lib/widgets/ephy-location-entry.c70
-rw-r--r--lib/widgets/ephy-location-entry.h1
5 files changed, 180 insertions, 16 deletions
diff --git a/lib/widgets/ephy-autocompletion-window.c b/lib/widgets/ephy-autocompletion-window.c
index 2eba9da66..8921c93f1 100644
--- a/lib/widgets/ephy-autocompletion-window.c
+++ b/lib/widgets/ephy-autocompletion-window.c
@@ -95,6 +95,7 @@ static gpointer g_object_class;
enum EphyAutocompletionWindowSignalsEnum {
ACTIVATED,
+ SELECTED,
EPHY_AUTOCOMPLETION_WINDOW_HIDDEN,
EPHY_AUTOCOMPLETION_WINDOW_LAST_SIGNAL
};
@@ -125,6 +126,17 @@ ephy_autocompletion_window_class_init (EphyAutocompletionWindowClass *klass)
G_TYPE_STRING,
G_TYPE_INT);
+ EphyAutocompletionWindowSignals[SELECTED] = g_signal_new (
+ "selected", G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST | G_SIGNAL_RUN_CLEANUP,
+ G_STRUCT_OFFSET (EphyAutocompletionWindowClass, selected),
+ NULL, NULL,
+ ephy_marshal_VOID__STRING_INT,
+ G_TYPE_NONE,
+ 2,
+ G_TYPE_STRING,
+ G_TYPE_INT);
+
EphyAutocompletionWindowSignals[EPHY_AUTOCOMPLETION_WINDOW_HIDDEN] = g_signal_new (
"hidden", G_OBJECT_CLASS_TYPE (klass),
G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST | G_SIGNAL_RUN_CLEANUP,
@@ -718,6 +730,23 @@ ephy_autocompletion_window_key_press_hack (EphyAutocompletionWindow *aw,
g_warning ("Unexpected keyval");
break;
}
+
+ switch (keyval)
+ {
+ case GDK_Up:
+ case GDK_Down:
+ case GDK_Page_Down:
+ case GDK_Page_Up:
+ if (aw->priv->selected)
+ {
+ g_signal_emit (aw, EphyAutocompletionWindowSignals
+ [SELECTED], 0, aw->priv->selected, action);
+ }
+ break;
+ default:
+ break;
+ }
+
return TRUE;
}
diff --git a/lib/widgets/ephy-autocompletion-window.h b/lib/widgets/ephy-autocompletion-window.h
index b390fc35c..63b4a4ed3 100644
--- a/lib/widgets/ephy-autocompletion-window.h
+++ b/lib/widgets/ephy-autocompletion-window.h
@@ -60,7 +60,9 @@ struct _EphyAutocompletionWindowClass
void (*activated) (EphyAutocompletionWindow *aw,
const char *target,
int action);
-
+ void (*selected) (EphyAutocompletionWindow *aw,
+ const char *target,
+ int action);
};
/* Remember: fields are public read-only */
diff --git a/lib/widgets/ephy-editable-toolbar.c b/lib/widgets/ephy-editable-toolbar.c
index eddb39bd9..9861f4bf4 100755
--- a/lib/widgets/ephy-editable-toolbar.c
+++ b/lib/widgets/ephy-editable-toolbar.c
@@ -258,8 +258,22 @@ drag_data_delete_cb (GtkWidget *widget,
g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar));
node = (EphyToolbarsItem *)g_object_get_data (G_OBJECT (widget), "item_data");
- g_return_if_fail (node != NULL);
- ephy_toolbars_group_remove_item (etoolbar->priv->group, node);
+ if (node)
+ {
+ ephy_toolbars_group_remove_item (etoolbar->priv->group, node);
+ }
+ else
+ {
+ EphyToolbarsToolbar *toolbar;
+ GtkWidget *child = GTK_BIN (widget)->child;
+
+ g_return_if_fail (child != NULL);
+ toolbar = (EphyToolbarsToolbar *)g_object_get_data
+ (G_OBJECT (child), "toolbar_data");
+ g_return_if_fail (toolbar != NULL);
+
+ ephy_toolbars_group_remove_toolbar (etoolbar->priv->group, toolbar);
+ }
etoolbar->priv->toolbars_dirty = TRUE;
queue_ui_update (etoolbar);
@@ -279,7 +293,7 @@ drag_data_get_cb (GtkWidget *widget,
g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar));
action = EGG_ACTION (g_object_get_data (G_OBJECT (widget), "egg-action"));
- target = action->name;
+ target = action ? action->name : "Toolbar";
LOG ("Drag data get %s", action->name);
@@ -352,6 +366,49 @@ disconnect_item_drag_source (EphyToolbarsItem *item, EphyEditableToolbar *etoolb
}
static void
+connect_toolbar_drag_source (EphyToolbarsToolbar *toolbar, EphyEditableToolbar *etoolbar)
+{
+ GtkWidget *widget;
+
+ g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar));
+ g_return_if_fail (toolbar != NULL);
+
+ widget = get_item_widget (etoolbar, toolbar);
+
+ if (!g_object_get_data (G_OBJECT (widget), "drag_source_set"))
+ {
+ g_object_set_data (G_OBJECT (widget), "drag_source_set",
+ GINT_TO_POINTER (TRUE));
+ g_signal_connect (widget->parent, "drag_data_get",
+ G_CALLBACK (drag_data_get_cb),
+ etoolbar);
+ g_signal_connect (widget->parent, "drag_data_delete",
+ G_CALLBACK (drag_data_delete_cb),
+ etoolbar);
+ }
+}
+
+static void
+disconnect_toolbar_drag_source (EphyToolbarsToolbar *toolbar, EphyEditableToolbar *etoolbar)
+{
+ GtkWidget *widget;
+
+ g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar));
+ g_return_if_fail (toolbar != NULL);
+
+ widget = get_item_widget (etoolbar, toolbar);
+
+ if (g_object_get_data (G_OBJECT (widget), "drag_source_set"))
+ {
+ g_object_set_data (G_OBJECT (widget), "drag_source_set",
+ GINT_TO_POINTER (FALSE));
+ g_signal_handlers_disconnect_by_func (widget->parent,
+ G_CALLBACK (drag_data_delete_cb),
+ etoolbar);
+ }
+}
+
+static void
setup_toolbar (EphyToolbarsToolbar *toolbar, EphyEditableToolbar *etoolbar)
{
GtkWidget *widget;
@@ -470,6 +527,9 @@ do_merge (EphyEditableToolbar *t)
ephy_toolbars_group_foreach_item (t->priv->group,
(EphyToolbarsGroupForeachItemFunc)
connect_item_drag_source, t);
+ ephy_toolbars_group_foreach_toolbar (t->priv->group,
+ (EphyToolbarsGroupForeachToolbarFunc)
+ connect_toolbar_drag_source, t);
}
ephy_toolbars_group_foreach_toolbar (t->priv->group,
@@ -733,6 +793,10 @@ editor_close_cb (GtkWidget *button, EphyEditableToolbar *etoolbar)
(EphyToolbarsGroupForeachItemFunc)
disconnect_item_drag_source,
etoolbar);
+ ephy_toolbars_group_foreach_toolbar (etoolbar->priv->group,
+ (EphyToolbarsGroupForeachToolbarFunc)
+ disconnect_toolbar_drag_source,
+ etoolbar);
hide_editor (etoolbar);
}
@@ -975,19 +1039,29 @@ button_press_cb (GtkWidget *w,
EphyEditableToolbar *etoolbar)
{
GtkWidget *widget;
- GtkWidget *toolitem;
+ GtkWidget *drag_widget;
+ GtkWidget *child;
g_return_val_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar), FALSE);
widget = gtk_get_event_widget (event);
- toolitem = gtk_widget_get_ancestor (widget, EGG_TYPE_TOOL_ITEM);
+ child = GTK_BIN (widget)->child;
+
+ if (EGG_IS_TOOLBAR (child))
+ {
+ drag_widget = widget;
+ }
+ else
+ {
+ drag_widget = gtk_widget_get_ancestor (widget, EGG_TYPE_TOOL_ITEM);
+ }
- if (toolitem == NULL) return FALSE;
+ if (drag_widget == NULL) return FALSE;
switch (event->type)
{
case GDK_BUTTON_PRESS:
- gtk_drag_begin (toolitem,
+ gtk_drag_begin (drag_widget,
gtk_target_list_new (source_drag_types, 1),
GDK_ACTION_MOVE, 1, event);
return TRUE;
@@ -1038,6 +1112,10 @@ ephy_editable_toolbar_edit (EphyEditableToolbar *etoolbar)
ephy_toolbars_group_foreach_item (etoolbar->priv->group,
(EphyToolbarsGroupForeachItemFunc)
connect_item_drag_source, etoolbar);
+ ephy_toolbars_group_foreach_toolbar (etoolbar->priv->group,
+ (EphyToolbarsGroupForeachToolbarFunc)
+ connect_toolbar_drag_source,
+ etoolbar);
ephy_toolbars_group_foreach_item (etoolbar->priv->group,
(EphyToolbarsGroupForeachItemFunc)
set_action_sensitive, etoolbar);
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index fbd8a8216..a2e86e345 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -45,6 +45,7 @@ struct _EphyLocationEntryPrivate {
gint show_alternatives_timeout;
gboolean block_set_autocompletion_key;
gboolean going_to_site;
+ gboolean editing;
gchar *autocompletion_key;
gchar *last_completion;
@@ -125,14 +126,28 @@ ephy_location_entry_class_init (EphyLocationEntryClass *klass)
G_TYPE_STRING);
}
+static gboolean
+location_focus_out_cb (GtkWidget *widget, GdkEventFocus *event, EphyLocationEntry *w)
+{
+ w->priv->editing = FALSE;
+
+ return FALSE;
+}
+
static void
ephy_location_entry_init (EphyLocationEntry *w)
{
EphyLocationEntryPrivate *p = g_new0 (EphyLocationEntryPrivate, 1);
w->priv = p;
p->last_action_target = NULL;
+ p->editing = FALSE;
ephy_location_entry_build (w);
+
+ g_signal_connect (w->priv->entry,
+ "focus_out_event",
+ G_CALLBACK (location_focus_out_cb),
+ w);
}
static void
@@ -360,6 +375,18 @@ position_is_at_end (GtkEditable *editable)
return gtk_editable_get_position (editable) == end;
}
+static void
+real_entry_set_location (EphyLocationEntry *w,
+ const gchar *new_location)
+{
+ EphyLocationEntryPrivate *p = w->priv;
+ int pos;
+
+ gtk_editable_delete_text (GTK_EDITABLE (p->entry), 0, -1);
+ gtk_editable_insert_text (GTK_EDITABLE (p->entry), new_location, g_utf8_strlen (new_location, -1),
+ &pos);
+}
+
/* this is from the old location entry, need to do the autocompletion before implementing this */
static gboolean
ephy_location_entry_key_press_event_cb (GtkWidget *entry, GdkEventKey *event, EphyLocationEntry *w)
@@ -428,7 +455,6 @@ ephy_location_entry_key_press_event_cb (GtkWidget *entry, GdkEventKey *event, Ep
case GDK_Page_Up:
case GDK_Page_Down:
ephy_location_entry_autocompletion_hide_alternatives (w);
- //ephy_embed_grab_focus (window->active_embed);
return FALSE;
case GDK_Tab:
{
@@ -479,7 +505,7 @@ ephy_location_entry_key_press_event_cb (GtkWidget *entry, GdkEventKey *event, Ep
ephy_location_entry_autocompletion_hide_alternatives (w);
if (p->before_completion)
{
- ephy_location_entry_set_location (w, p->before_completion);
+ real_entry_set_location (w, p->before_completion);
g_free (p->before_completion);
p->before_completion = NULL;
gtk_editable_set_position (GTK_EDITABLE (p->entry), -1);
@@ -487,6 +513,7 @@ ephy_location_entry_key_press_event_cb (GtkWidget *entry, GdkEventKey *event, Ep
}
break;
default:
+ w->priv->editing = TRUE;
ephy_location_entry_autocompletion_unselect_alternatives (w);
if ((event->string[0] > 32) && (event->string[0] < 126) &&
position_is_at_end (GTK_EDITABLE (entry)))
@@ -524,6 +551,8 @@ 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, target, content);
g_free (content);
}
@@ -558,11 +587,10 @@ void
ephy_location_entry_set_location (EphyLocationEntry *w,
const gchar *new_location)
{
- EphyLocationEntryPrivate *p = w->priv;
- int pos;
- gtk_editable_delete_text (GTK_EDITABLE (p->entry), 0, -1);
- gtk_editable_insert_text (GTK_EDITABLE (p->entry), new_location, g_utf8_strlen (new_location, -1),
- &pos);
+ if (!w->priv->editing)
+ {
+ real_entry_set_location (w, new_location);
+ }
}
gchar *
@@ -572,6 +600,15 @@ ephy_location_entry_get_location (EphyLocationEntry *w)
return location;
}
+static void
+ephy_location_entry_autocompletion_window_url_selected_cb (EphyAutocompletionWindow *aw,
+ const char *target,
+ int action,
+ EphyLocationEntry *w)
+{
+ real_entry_set_location (w, target);
+}
+
void
ephy_location_entry_set_autocompletion (EphyLocationEntry *w,
EphyAutocompletion *ac)
@@ -598,6 +635,10 @@ ephy_location_entry_set_autocompletion (EphyLocationEntry *w,
G_CALLBACK (ephy_location_entry_autocompletion_window_url_activated_cb),
w);
+ g_signal_connect (p->autocompletion_window, "selected",
+ G_CALLBACK (ephy_location_entry_autocompletion_window_url_selected_cb),
+ w);
+
g_signal_connect (p->autocompletion_window, "hidden",
G_CALLBACK (ephy_location_entry_autocompletion_window_hidden_cb),
w);
@@ -627,7 +668,7 @@ ephy_location_entry_autocompletion_window_url_activated_cb (EphyAutocompletionWi
}
else
{
- ephy_location_entry_set_location (w, target);
+ real_entry_set_location (w, target);
}
content = gtk_editable_get_chars (GTK_EDITABLE(w->priv->entry), 0, -1);
@@ -666,6 +707,19 @@ 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;
diff --git a/lib/widgets/ephy-location-entry.h b/lib/widgets/ephy-location-entry.h
index c56a25cc7..5a7014bae 100644
--- a/lib/widgets/ephy-location-entry.h
+++ b/lib/widgets/ephy-location-entry.h
@@ -70,6 +70,7 @@ 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