[feat] add a searching textbox

This commit is contained in:
Julian Sparber
2017-10-01 16:16:01 +02:00
parent d14a58d242
commit daaf5ed988
2 changed files with 47 additions and 9 deletions

View File

@@ -21,6 +21,7 @@ struct _TeleportAppWindowPrivate
GtkWidget *gears; GtkWidget *gears;
GtkWidget *remote_devices_list; GtkWidget *remote_devices_list;
GtkWidget *this_device_name_label; GtkWidget *this_device_name_label;
GtkWidget *remote_no_devices;
}; };
G_DEFINE_TYPE_WITH_PRIVATE(TeleportAppWindow, teleport_app_window, GTK_TYPE_APPLICATION_WINDOW); G_DEFINE_TYPE_WITH_PRIVATE(TeleportAppWindow, teleport_app_window, GTK_TYPE_APPLICATION_WINDOW);
@@ -96,6 +97,8 @@ void update_remote_device_list(TeleportAppWindow *win, Peer *device) {
priv = teleport_app_window_get_instance_private (win); priv = teleport_app_window_get_instance_private (win);
gtk_widget_hide (priv->remote_no_devices);
builder_remote_list = gtk_builder_new_from_resource ("/com/frac_tion/teleport/remote_list.ui"); builder_remote_list = gtk_builder_new_from_resource ("/com/frac_tion/teleport/remote_list.ui");
row = GTK_WIDGET (gtk_builder_get_object (builder_remote_list, "remote_device_row")); row = GTK_WIDGET (gtk_builder_get_object (builder_remote_list, "remote_device_row"));
@@ -123,7 +126,7 @@ void update_remote_device_list_remove(TeleportAppWindow *win, Peer *device) {
remote_row = gtk_list_box_get_row_at_index (GTK_LIST_BOX(box), i); remote_row = gtk_list_box_get_row_at_index (GTK_LIST_BOX(box), i);
while(remote_row != NULL) { while (remote_row != NULL) {
name_label = GTK_LABEL(find_child(GTK_WIDGET(remote_row), "GtkLabel")); name_label = GTK_LABEL(find_child(GTK_WIDGET(remote_row), "GtkLabel"));
if (name_label != NULL && g_strcmp0(device->name, gtk_label_get_text(name_label)) == 0) { if (name_label != NULL && g_strcmp0(device->name, gtk_label_get_text(name_label)) == 0) {
gtk_container_remove (GTK_CONTAINER(box), GTK_WIDGET(remote_row)); gtk_container_remove (GTK_CONTAINER(box), GTK_WIDGET(remote_row));
@@ -131,6 +134,10 @@ void update_remote_device_list_remove(TeleportAppWindow *win, Peer *device) {
i++; i++;
remote_row = gtk_list_box_get_row_at_index (GTK_LIST_BOX(box), i); remote_row = gtk_list_box_get_row_at_index (GTK_LIST_BOX(box), i);
} }
// the last row got removed and we have to display the searching box
if (i <= 2) {
gtk_widget_show (priv->remote_no_devices);
}
} }
GtkWidget * GtkWidget *
@@ -183,6 +190,7 @@ teleport_app_window_class_init (TeleportAppWindowClass *class)
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), TeleportAppWindow, gears); gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), TeleportAppWindow, gears);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), TeleportAppWindow, this_device_name_label); gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), TeleportAppWindow, this_device_name_label);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), TeleportAppWindow, remote_no_devices);
gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), TeleportAppWindow, remote_devices_list); gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (class), TeleportAppWindow, remote_devices_list);
} }

View File

@@ -65,12 +65,12 @@
<child> <child>
<object class="GtkListBox" id="this-device-listbox"> <object class="GtkListBox" id="this-device-listbox">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="selection_mode">none</property> <property name="selection_mode">none</property>
<child> <child>
<object class="GtkListBoxRow" id="this-device-row"> <object class="GtkListBoxRow" id="this-device-row">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">False</property>
<property name="activatable">false</property> <property name="activatable">false</property>
<child> <child>
<object class="GtkGrid" id="this-device-grid"> <object class="GtkGrid" id="this-device-grid">
@@ -202,12 +202,42 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="selection_mode">none</property> <property name="selection_mode">none</property>
</object> <child>
</child> <object class="GtkListBoxRow" id="remote_no_devices">
<child> <property name="visible">True</property>
<object class="GtkSeparator"> <property name="can_focus">False</property>
<property name="visible">true</property> <property name="activatable">False</property>
<property name="orientation">horizontal</property> <property name="selectable">False</property>
<child>
<object class="GtkAlignment">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="top_padding">50</property>
<property name="bottom_padding">50</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="spacing">20</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">Searching for other devices...</property>
</object>
</child>
<child>
<object class="GtkSpinner">
<property name="visible">True</property>
<property name="active">True</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object> </object>
</child> </child>
</object> </object>