[gtk+/gtk-3-18] 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+/gtk-3-18] gtkplacesview: add a clear button to address entry
- Date: Thu, 15 Oct 2015 18:10:15 +0000 (UTC)
commit 343fafbc3018a8d2388322436289d17f57a3e094
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.
https://bugzilla.gnome.org/show_bug.cgi?id=756568
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 82c755e..2796c7a 100644
--- a/gtk/gtkplacesview.c
+++ b/gtk/gtkplacesview.c
@@ -1828,11 +1828,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)
@@ -1847,6 +1855,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)
@@ -2220,6 +2237,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]