[gitg: 2/36] Add big contact list test case
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg: 2/36] Add big contact list test case
- Date: Tue, 19 Feb 2013 21:54:48 +0000 (UTC)
commit d53ce490a79bd8064db45e73112ef927780da856
Author: Xavier Claessens <xavier claessens collabora co uk>
Date: Thu Nov 8 13:21:16 2012 +0100
Add big contact list test case
Focus in/out this window used to take a lot of CPU. See
https://bugzilla.gnome.org/show_bug.cgi?id=687911
The dummy row widget code is copied from empathy-roster-contact.c to
make the test more realistic.
Makefile.am | 11 +++++-
test-focus.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 121 insertions(+), 1 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 420c8b9..4d3570d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,7 +15,7 @@ noinst_LTLIBRARIES = libegglistbox.la
libegglistbox_la_SOURCES = egg-list-box.c egg-list-box.h
libegglistbox_la_LIBADD = $(LISTBOX_LIBS)
-noinst_PROGRAMS = test-list test-scrolled
+noinst_PROGRAMS = test-list test-scrolled test-focus
test_list_SOURCES = \
test-list.vala \
@@ -45,6 +45,15 @@ test_scrolled_VALAFLAGS = \
--pkg egglistbox \
$(NULL)
+test_focus_SOURCES = \
+ test-focus.c \
+ $(NULL)
+
+test_focus_LDADD = \
+ $(LISTBOX_LIBS) \
+ libegglistbox.la \
+ $(NULL)
+
CLEANFILES = \
$(test_list_SOURCES:.vala=.c) \
$(test_scrolled_SOURCES:.vala=.c) \
diff --git a/test-focus.c b/test-focus.c
new file mode 100644
index 0000000..54d4273
--- /dev/null
+++ b/test-focus.c
@@ -0,0 +1,111 @@
+#include <gtk/gtk.h>
+#include <egg-list-box.h>
+
+static void
+add_row (EggListBox *view)
+{
+ GtkWidget *main_box, *box, *first_line_box;
+ GtkStyleContext *context;
+ GtkWidget *avatar;
+ GtkWidget *first_line_alig;
+ GtkWidget *alias;
+ GtkWidget *phone_icon;
+ GtkWidget *presence_msg;
+ GtkWidget *presence_icon;
+
+ main_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
+
+ /* Avatar */
+ avatar = gtk_image_new_from_icon_name ("avatar-default-symbolic", GTK_ICON_SIZE_LARGE_TOOLBAR);
+
+ gtk_widget_set_size_request (avatar, 48, 48);
+
+ gtk_box_pack_start (GTK_BOX (main_box), avatar, FALSE, FALSE, 0);
+ gtk_widget_show (avatar);
+
+ box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+
+ /* Alias and phone icon */
+ first_line_alig = gtk_alignment_new (0, 0.5, 1, 1);
+ first_line_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+
+ alias = gtk_label_new ("My Cool Alias");
+ gtk_label_set_ellipsize (GTK_LABEL (alias), PANGO_ELLIPSIZE_END);
+ gtk_box_pack_start (GTK_BOX (first_line_box), alias,
+ FALSE, FALSE, 0);
+ gtk_misc_set_alignment (GTK_MISC (alias), 0, 0.5);
+ gtk_widget_show (alias);
+
+ phone_icon = gtk_image_new_from_icon_name ("phone-symbolic",
+ GTK_ICON_SIZE_MENU);
+ gtk_misc_set_alignment (GTK_MISC (phone_icon), 0, 0.5);
+ gtk_box_pack_start (GTK_BOX (first_line_box), phone_icon,
+ TRUE, TRUE, 0);
+
+ gtk_container_add (GTK_CONTAINER (first_line_alig),
+ first_line_box);
+ gtk_widget_show (first_line_alig);
+
+ gtk_box_pack_start (GTK_BOX (box), first_line_alig,
+ TRUE, TRUE, 0);
+ gtk_widget_show (first_line_box);
+
+ gtk_box_pack_start (GTK_BOX (main_box), box, TRUE, TRUE, 0);
+ gtk_widget_show (box);
+
+ /* Presence */
+ presence_msg = gtk_label_new ("My Cool Presence Message");
+ gtk_label_set_ellipsize (GTK_LABEL (presence_msg),
+ PANGO_ELLIPSIZE_END);
+ gtk_box_pack_start (GTK_BOX (box), presence_msg, TRUE, TRUE, 0);
+ gtk_widget_show (presence_msg);
+
+ context = gtk_widget_get_style_context (presence_msg);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_DIM_LABEL);
+
+ /* Presence icon */
+ presence_icon = gtk_image_new_from_icon_name ("user-available", GTK_ICON_SIZE_MENU);
+
+ gtk_box_pack_start (GTK_BOX (main_box), presence_icon,
+ FALSE, FALSE, 0);
+ gtk_widget_show (presence_icon);
+
+ gtk_container_add (GTK_CONTAINER (view), main_box);
+ gtk_widget_show (main_box);
+}
+
+gint
+main (gint argc,
+ gchar ** argv)
+{
+ GtkWidget *window;
+ GtkWidget *sw;
+ EggListBox *view;
+ guint i;
+
+ gtk_init (&argc, &argv);
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ sw = gtk_scrolled_window_new (NULL, NULL);
+ gtk_container_add (GTK_CONTAINER (window), sw);
+ gtk_widget_show (sw);
+
+ view = egg_list_box_new ();
+ egg_list_box_add_to_scrolled (view, GTK_SCROLLED_WINDOW (sw));
+ gtk_widget_show (GTK_WIDGET (view));
+
+ for (i = 0; i < 1000; i++)
+ add_row (view);
+
+
+ gtk_widget_show (window);
+
+ gtk_main ();
+
+ gtk_widget_destroy (window);
+
+ return 0;
+}
+
+
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]