Merge pull request #57 from JosephMcc/searchbar-close
searchbar: Make some improvements
This commit is contained in:
commit
4028e617fb
|
@ -42,6 +42,7 @@ struct _XedSearchbarPrivate
|
||||||
GtkWidget *find_prev_button;
|
GtkWidget *find_prev_button;
|
||||||
GtkWidget *replace_button;
|
GtkWidget *replace_button;
|
||||||
GtkWidget *replace_all_button;
|
GtkWidget *replace_all_button;
|
||||||
|
GtkWidget *close_button;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE(XedSearchbar, xed_searchbar, GTK_TYPE_BOX)
|
G_DEFINE_TYPE(XedSearchbar, xed_searchbar, GTK_TYPE_BOX)
|
||||||
|
@ -433,6 +434,7 @@ search_text_entry_changed (GtkEditable *editable,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
search_buttons_set_sensitive (searchbar, FALSE);
|
search_buttons_set_sensitive (searchbar, FALSE);
|
||||||
|
do_find (searchbar, FALSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,14 +508,24 @@ on_search_text_entry_activated (GtkEntry *widget,
|
||||||
do_find (searchbar, FALSE);
|
do_find (searchbar, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
close_button_clicked_callback (GtkWidget *button,
|
||||||
|
XedSearchbar *searchbar)
|
||||||
|
{
|
||||||
|
xed_searchbar_hide (searchbar);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_searchbar_init (XedSearchbar *searchbar)
|
xed_searchbar_init (XedSearchbar *searchbar)
|
||||||
{
|
{
|
||||||
GtkWidget *content;
|
GtkWidget *content;
|
||||||
GtkSizeGroup *size_group;
|
GtkSizeGroup *size_group;
|
||||||
GtkWidget *error_widget;
|
GtkWidget *error_widget;
|
||||||
|
GtkStyleContext *context;
|
||||||
|
GtkCssProvider *provider;
|
||||||
gchar *file;
|
gchar *file;
|
||||||
gchar *root_objects[] = { "searchbar_content", NULL };
|
gchar *root_objects[] = { "searchbar_content", NULL };
|
||||||
|
const gchar *data = ".button {padding: 0;}";
|
||||||
|
|
||||||
searchbar->priv = XED_SEARCHBAR_GET_PRIVATE (searchbar);
|
searchbar->priv = XED_SEARCHBAR_GET_PRIVATE (searchbar);
|
||||||
|
|
||||||
|
@ -533,6 +545,7 @@ xed_searchbar_init (XedSearchbar *searchbar)
|
||||||
"find_prev_button", &searchbar->priv->find_prev_button,
|
"find_prev_button", &searchbar->priv->find_prev_button,
|
||||||
"replace_button", &searchbar->priv->replace_button,
|
"replace_button", &searchbar->priv->replace_button,
|
||||||
"replace_all_button", &searchbar->priv->replace_all_button,
|
"replace_all_button", &searchbar->priv->replace_all_button,
|
||||||
|
"close_button", &searchbar->priv->close_button,
|
||||||
NULL);
|
NULL);
|
||||||
g_free (file);
|
g_free (file);
|
||||||
|
|
||||||
|
@ -561,6 +574,11 @@ xed_searchbar_init (XedSearchbar *searchbar)
|
||||||
gtk_label_set_mnemonic_widget (GTK_LABEL (searchbar->priv->search_label), searchbar->priv->search_entry);
|
gtk_label_set_mnemonic_widget (GTK_LABEL (searchbar->priv->search_label), searchbar->priv->search_entry);
|
||||||
gtk_label_set_mnemonic_widget (GTK_LABEL (searchbar->priv->replace_label), searchbar->priv->replace_entry);
|
gtk_label_set_mnemonic_widget (GTK_LABEL (searchbar->priv->replace_label), searchbar->priv->replace_entry);
|
||||||
|
|
||||||
|
provider = gtk_css_provider_new ();
|
||||||
|
context = gtk_widget_get_style_context (searchbar->priv->close_button);
|
||||||
|
gtk_css_provider_load_from_data (provider, data, -1, NULL);
|
||||||
|
gtk_style_context_add_provider (context, GTK_STYLE_PROVIDER (provider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||||
|
|
||||||
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
|
||||||
gtk_size_group_add_widget (size_group, GTK_WIDGET (searchbar->priv->find_button));
|
gtk_size_group_add_widget (size_group, GTK_WIDGET (searchbar->priv->find_button));
|
||||||
gtk_size_group_add_widget (size_group, GTK_WIDGET (searchbar->priv->find_prev_button));
|
gtk_size_group_add_widget (size_group, GTK_WIDGET (searchbar->priv->find_prev_button));
|
||||||
|
@ -600,6 +618,9 @@ xed_searchbar_init (XedSearchbar *searchbar)
|
||||||
|
|
||||||
g_signal_connect (searchbar->priv->replace_all_button, "clicked",
|
g_signal_connect (searchbar->priv->replace_all_button, "clicked",
|
||||||
G_CALLBACK (replace_all_button_clicked_callback), searchbar);
|
G_CALLBACK (replace_all_button_clicked_callback), searchbar);
|
||||||
|
|
||||||
|
g_signal_connect (searchbar->priv->close_button, "clicked",
|
||||||
|
G_CALLBACK (close_button_clicked_callback), searchbar);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
|
|
|
@ -184,6 +184,34 @@
|
||||||
<property name="top_attach">0</property>
|
<property name="top_attach">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="close_button">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="tooltip_text" translatable="yes">Close</property>
|
||||||
|
<property name="valign">start</property>
|
||||||
|
<property name="relief">none</property>
|
||||||
|
<property name="xalign">1</property>
|
||||||
|
<property name="yalign">0</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="image2">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="pixel_size">12</property>
|
||||||
|
<property name="icon_name">window-close-symbolic</property>
|
||||||
|
<property name="icon_size">0</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">5</property>
|
||||||
|
<property name="top_attach">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<placeholder/>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<placeholder/>
|
<placeholder/>
|
||||||
</child>
|
</child>
|
||||||
|
|
Loading…
Reference in New Issue