Replace fitler entry with GtkSearchBar

This commit is contained in:
Simon Steinbeiss
2021-01-18 11:51:03 +01:00
committed by Simon Steinbeiß
parent 847ed1ad92
commit 19b888fcfe
2 changed files with 51 additions and 12 deletions

View File

@@ -54,6 +54,7 @@ struct _XtmProcessWindow
GtkBuilder * builder; GtkBuilder * builder;
GtkWidget * window; GtkWidget * window;
GtkWidget * filter_entry; GtkWidget * filter_entry;
GtkWidget * filter_searchbar;
GtkWidget * cpu_monitor; GtkWidget * cpu_monitor;
GtkWidget * mem_monitor; GtkWidget * mem_monitor;
GtkWidget * vpaned; GtkWidget * vpaned;
@@ -224,6 +225,16 @@ xtm_show_legend (XtmProcessWindow *window)
gtk_widget_set_visible (GTK_WIDGET (gtk_builder_get_object (window->builder, "legend")), show_legend); gtk_widget_set_visible (GTK_WIDGET (gtk_builder_get_object (window->builder, "legend")), show_legend);
} }
static void
show_filter_toggled_cb (GtkToggleButton *button, gpointer user_data)
{
XtmProcessWindow *window = user_data;
gboolean active;
active = gtk_toggle_button_get_active (button);
gtk_revealer_set_reveal_child (GTK_REVEALER (gtk_bin_get_child (GTK_BIN (window->filter_searchbar))), active);
}
static void static void
xtm_process_window_init (XtmProcessWindow *window) xtm_process_window_init (XtmProcessWindow *window)
{ {
@@ -257,6 +268,15 @@ xtm_process_window_init (XtmProcessWindow *window)
g_signal_connect (G_OBJECT (button), "clicked", g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (xwininfo_clicked_cb), window); G_CALLBACK (xwininfo_clicked_cb), window);
window->filter_searchbar = GTK_WIDGET (gtk_builder_get_object (window->builder, "filter-searchbar"));
button = GTK_WIDGET (gtk_builder_get_object (window->builder, "button-show-filter"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
gtk_revealer_get_reveal_child (GTK_REVEALER (gtk_bin_get_child (GTK_BIN (window->filter_searchbar)))));
g_signal_connect (G_OBJECT (button), "toggled",
G_CALLBACK (show_filter_toggled_cb), window);
g_object_bind_property (G_OBJECT (gtk_bin_get_child (GTK_BIN (window->filter_searchbar))), "reveal-child",
G_OBJECT (button), "active", G_BINDING_BIDIRECTIONAL);
{ {
GtkWidget *toolitem; GtkWidget *toolitem;
guint refresh_rate; guint refresh_rate;

View File

@@ -12,6 +12,11 @@
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="icon_name">preferences-system-symbolic</property> <property name="icon_name">preferences-system-symbolic</property>
</object> </object>
<object class="GtkImage" id="image3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">edit-find-symbolic</property>
</object>
<object class="GtkWindow" id="process-window"> <object class="GtkWindow" id="process-window">
<property name="can_focus">False</property> <property name="can_focus">False</property>
<child type="titlebar"> <child type="titlebar">
@@ -42,7 +47,15 @@
</packing> </packing>
</child> </child>
<child> <child>
<placeholder/> <object class="GtkToggleButton" id="button-show-filter">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">image3</property>
</object>
<packing>
<property name="position">2</property>
</packing>
</child> </child>
</object> </object>
</child> </child>
@@ -50,22 +63,28 @@
<object class="GtkBox"> <object class="GtkBox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="margin_top">6</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
<property name="spacing">3</property> <property name="spacing">3</property>
<child> <child>
<object class="GtkEntry" id="filter-entry"> <object class="GtkSearchBar" id="filter-searchbar">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="halign">center</property> <property name="search_mode_enabled">True</property>
<property name="invisible_char">•</property> <property name="show_close_button">True</property>
<property name="primary_icon_stock">gtk-find</property> <child>
<property name="secondary_icon_stock">gtk-clear</property> <object class="GtkSearchEntry" id="filter-entry">
<property name="secondary_icon_sensitive">False</property> <property name="visible">True</property>
<property name="can_focus">True</property>
<property name="primary_icon_name">edit-find-symbolic</property>
<property name="secondary_icon_name">edit-clear</property>
<property name="primary_icon_activatable">False</property>
<property name="primary_icon_sensitive">False</property>
</object>
</child>
</object> </object>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">True</property>
<property name="position">0</property> <property name="position">0</property>
</packing> </packing>
</child> </child>
@@ -108,7 +127,7 @@
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
<property name="fill">False</property> <property name="fill">False</property>
<property name="position">1</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
<child> <child>
@@ -271,7 +290,7 @@
<packing> <packing>
<property name="expand">True</property> <property name="expand">True</property>
<property name="fill">True</property> <property name="fill">True</property>
<property name="position">2</property> <property name="position">3</property>
</packing> </packing>
</child> </child>
</object> </object>