[gtk+/wip/otherlocations-fixes: 137/139] gtkplacesview: add a clear button to address entry
- From: Carlos Soriano Sánchez <csoriano src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/otherlocations-fixes: 137/139] gtkplacesview: add a clear button to address entry
- Date: Wed, 14 Oct 2015 12:17:06 +0000 (UTC)
commit d8bc98460c4e0722d3f9c63d2c3ef15227e859f7
Author: Carlos Soriano <csoriano gnome org>
Date: Thu Sep 24 11:26:59 2015 +0200
gtkplacesview: add a clear button to address entry
So it allows a quick way to clear the entry.
gtk/gtkplacesview.c | 22 ++++++++++++++++++++--
gtk/ui/gtkplacesview.ui | 1 +
2 files changed, 21 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkplacesview.c b/gtk/gtkplacesview.c
index 328b52a..08f892b 100644
--- a/gtk/gtkplacesview.c
+++ b/gtk/gtkplacesview.c
@@ -1851,11 +1851,19 @@ on_address_entry_text_changed (GtkPlacesView *view)
priv = gtk_places_view_get_instance_private (view);
supported = FALSE;
supported_protocols = g_vfs_get_supported_uri_schemes (g_vfs_get_default ());
+ address = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->address_entry)));
+ if (strlen (address) > 0)
+ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (priv->address_entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ "edit-clear-symbolic");
+ else
+ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (priv->address_entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ NULL);
if (!supported_protocols)
- return;
+ goto out;
- address = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->address_entry)));
scheme = g_uri_parse_scheme (address);
if (!scheme)
@@ -1870,6 +1878,15 @@ out:
}
static void
+on_address_entry_clear_pressed (GtkPlacesView *view,
+ GtkEntryIconPosition icon_pos,
+ GdkEvent *event,
+ GtkEntry *entry)
+{
+ gtk_entry_set_text (entry, "");
+}
+
+static void
on_recent_servers_listbox_row_activated (GtkPlacesView *view,
GtkPlacesViewRow *row,
GtkWidget *listbox)
@@ -2243,6 +2260,7 @@ gtk_places_view_class_init (GtkPlacesViewClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GtkPlacesView, stack);
gtk_widget_class_bind_template_callback (widget_class, on_address_entry_text_changed);
+ gtk_widget_class_bind_template_callback (widget_class, on_address_entry_clear_pressed);
gtk_widget_class_bind_template_callback (widget_class, on_connect_button_clicked);
gtk_widget_class_bind_template_callback (widget_class, on_key_press_event);
gtk_widget_class_bind_template_callback (widget_class, on_listbox_row_activated);
diff --git a/gtk/ui/gtkplacesview.ui b/gtk/ui/gtkplacesview.ui
index 6978255..1a1b84c 100644
--- a/gtk/ui/gtkplacesview.ui
+++ b/gtk/ui/gtkplacesview.ui
@@ -247,6 +247,7 @@
<property name="completion">address_entry_completion</property>
<signal name="notify::text" handler="on_address_entry_text_changed" object="GtkPlacesView"
swapped="yes"/>
<signal name="activate" handler="on_connect_button_clicked" object="GtkPlacesView"
swapped="yes"/>
+ <signal name="icon-press" handler="on_address_entry_clear_pressed" object="GtkPlacesView"
swapped="yes"/>
</object>
</child>
<child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]