summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIulian Radu <iulian.radu67@gmail.com>2016-08-23 14:46:10 +0300
committerIulian Radu <iulian.radu67@gmail.com>2016-09-28 16:15:13 +0300
commited611b69bac58e5abb0ed9b0a5ab3f06f3f14570 (patch)
tree33b94474cba590cb130a28d765d73283af17d126
parent2d9fd242beb8c8b1910263142f74c6187c209d02 (diff)
downloadepiphany-ed611b69bac58e5abb0ed9b0a5ab3f06f3f14570.tar.gz
properties-grid: Toggle action's enabled state instead of button's sensitivity
-rw-r--r--src/ephy-bookmark-properties-grid.c21
-rw-r--r--src/resources/gtk/bookmark-properties-grid.ui1
2 files changed, 17 insertions, 5 deletions
diff --git a/src/ephy-bookmark-properties-grid.c b/src/ephy-bookmark-properties-grid.c
index 85b45b8ab..510216d3f 100644
--- a/src/ephy-bookmark-properties-grid.c
+++ b/src/ephy-bookmark-properties-grid.c
@@ -224,8 +224,10 @@ ephy_bookmarks_properties_grid_actions_add_tag (GSimpleAction *action,
widget = ephy_bookmark_properties_grid_create_tag_widget (self, text, TRUE);
gtk_flow_box_insert (GTK_FLOW_BOX (self->tags_box), widget, -1);
+ /* Empty entry and disable button's action until new text is inserted */
gtk_entry_set_text (GTK_ENTRY (self->add_tag_entry), "");
- gtk_widget_set_sensitive (GTK_WIDGET (self->add_tag_button), FALSE);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
+
gtk_widget_grab_focus (GTK_WIDGET (self->add_tag_entry));
}
@@ -248,16 +250,20 @@ ephy_bookmark_properties_grid_buffer_text_changed_cb (EphyBookmarkPropertiesGrid
GParamSpec *pspec,
GtkEntryBuffer *buffer)
{
+ GActionGroup *group;
+ GAction *action;
const char *text;
g_assert (EPHY_IS_BOOKMARK_PROPERTIES_GRID (self));
g_assert (GTK_IS_ENTRY_BUFFER (buffer));
+ group = gtk_widget_get_action_group (GTK_WIDGET (self), "grid");
+ action = g_action_map_lookup_action (G_ACTION_MAP (group), "add-tag");
text = gtk_entry_buffer_get_text (buffer);
- if (strlen (text) >= 3 && !ephy_bookmarks_manager_tag_exists (self->manager, text))
- gtk_widget_set_sensitive (self->add_tag_button, TRUE);
+ if (ephy_bookmarks_manager_tag_exists (self->manager, text))
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
else
- gtk_widget_set_sensitive (self->add_tag_button, FALSE);
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), TRUE);
}
static void
@@ -436,6 +442,7 @@ static void
ephy_bookmark_properties_grid_init (EphyBookmarkPropertiesGrid *self)
{
GSimpleActionGroup *group;
+ GAction *action;
gtk_widget_init_template (GTK_WIDGET (self));
@@ -450,6 +457,12 @@ ephy_bookmark_properties_grid_init (EphyBookmarkPropertiesGrid *self)
G_N_ELEMENTS (entries), self);
gtk_widget_insert_action_group (GTK_WIDGET (self), "grid",
G_ACTION_GROUP (group));
+
+ /* Disable the "add-tag" action until text is inserted in the corresponding
+ * entry */
+ action = g_action_map_lookup_action (G_ACTION_MAP (group), "add-tag");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
+
g_object_unref (group);
g_signal_connect_object (gtk_entry_get_buffer (GTK_ENTRY (self->add_tag_entry)),
diff --git a/src/resources/gtk/bookmark-properties-grid.ui b/src/resources/gtk/bookmark-properties-grid.ui
index efecc6d04..cc60cbda1 100644
--- a/src/resources/gtk/bookmark-properties-grid.ui
+++ b/src/resources/gtk/bookmark-properties-grid.ui
@@ -147,7 +147,6 @@
<property name="label" translatable="yes">_Add</property>
<property name="action-name">grid.add-tag</property>
<property name="can-default">true</property>
- <property name="sensitive">false</property>
<property name="use-underline">true</property>
<property name="visible">true</property>
</object>