diff --git a/ChangeLog b/ChangeLog index dbadf1ab68..bef2a58412 100644 --- a/ChangeLog +++ b/ChangeLog @@ -37,7 +37,6 @@ * modules/input/imime.c: Include . (#317444, Kazuki Iwamoto) ->>>>>>> 1.7129 2005-09-27 Federico Mena Quintero Don't reload the current folder unnecessarily on ::map(). diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index dbadf1ab68..bef2a58412 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -37,7 +37,6 @@ * modules/input/imime.c: Include . (#317444, Kazuki Iwamoto) ->>>>>>> 1.7129 2005-09-27 Federico Mena Quintero Don't reload the current folder unnecessarily on ::map(). diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index 4d5cdbd46f..fb4f253f35 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -114,9 +114,9 @@ _gtk_file_chooser_profile_log (const char *func, int indent, const char *msg1, c profile_add_indent (indent); if (profile_indent == 0) - str = g_strdup_printf ("MARK: %s %s %s", func, msg1 ? msg1 : "", msg2 ? msg2 : ""); + str = g_strdup_printf ("MARK: %s %s %s", func ? func : "", msg1 ? msg1 : "", msg2 ? msg2 : ""); else - str = g_strdup_printf ("MARK: %*c %s %s %s", profile_indent - 1, ' ', func, msg1 ? msg1 : "", msg2 ? msg2 : ""); + str = g_strdup_printf ("MARK: %*c %s %s %s", profile_indent - 1, ' ', func ? func : "", msg1 ? msg1 : "", msg2 ? msg2 : ""); access (str, F_OK); g_free (str); @@ -3097,6 +3097,9 @@ shortcuts_list_create (GtkFileChooserDefault *impl) /* Tree */ impl->browse_shortcuts_tree_view = gtk_tree_view_new (); +#ifdef PROFILE_FILE_CHOOSER + g_object_set_data (impl->browse_shortcuts_tree_view, "fmq-name", "shortcuts"); +#endif g_signal_connect (impl->browse_shortcuts_tree_view, "key-press-event", G_CALLBACK (tree_view_keybinding_cb), impl); g_signal_connect (impl->browse_shortcuts_tree_view, "popup-menu", @@ -3605,6 +3608,9 @@ create_file_list (GtkFileChooserDefault *impl) /* Tree/list view */ impl->browse_files_tree_view = gtk_tree_view_new (); +#ifdef PROFILE_FILE_CHOOSER + g_object_set_data (impl->browse_files_tree_view, "fmq-name", "file_list"); +#endif g_object_set_data (G_OBJECT (impl->browse_files_tree_view), I_("GtkFileChooserDefault"), impl); atk_object_set_name (gtk_widget_get_accessible (impl->browse_files_tree_view), _("Files")); @@ -4574,13 +4580,17 @@ gtk_file_chooser_default_style_set (GtkWidget *widget, impl = GTK_FILE_CHOOSER_DEFAULT (widget); + profile_msg (" parent class style_set start", NULL); if (GTK_WIDGET_CLASS (parent_class)->style_set) GTK_WIDGET_CLASS (parent_class)->style_set (widget, previous_style); + profile_msg (" parent class style_set end", NULL); if (gtk_widget_has_screen (GTK_WIDGET (impl))) change_icon_theme (impl); + profile_msg (" emit default-size-changed start", NULL); g_signal_emit_by_name (widget, "default-size-changed"); + profile_msg (" emit default-size-changed end", NULL); profile_end ("end", NULL); } @@ -4858,9 +4868,12 @@ set_busy_cursor (GtkFileChooserDefault *impl, static void load_set_model (GtkFileChooserDefault *impl) { + profile_start ("start", NULL); + g_assert (impl->browse_files_model != NULL); g_assert (impl->sort_model == NULL); + profile_msg (" gtk_tree_model_sort_new_with_model start", NULL); impl->sort_model = (GtkTreeModelSort *)gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (impl->browse_files_model)); gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->sort_model), FILE_LIST_COL_NAME, name_sort_func, impl, NULL); gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (impl->sort_model), FILE_LIST_COL_SIZE, size_sort_func, impl, NULL); @@ -4868,15 +4881,20 @@ load_set_model (GtkFileChooserDefault *impl) gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (impl->sort_model), NULL, NULL, NULL); gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (impl->sort_model), FILE_LIST_COL_NAME, GTK_SORT_ASCENDING); impl->list_sort_ascending = TRUE; + profile_msg (" gtk_tree_model_sort_new_with_model end", NULL); g_signal_connect (impl->sort_model, "sort-column-changed", G_CALLBACK (list_sort_column_changed_cb), impl); + profile_msg (" gtk_tree_view_set_model start", NULL); gtk_tree_view_set_model (GTK_TREE_VIEW (impl->browse_files_tree_view), GTK_TREE_MODEL (impl->sort_model)); gtk_tree_view_columns_autosize (GTK_TREE_VIEW (impl->browse_files_tree_view)); gtk_tree_view_set_search_column (GTK_TREE_VIEW (impl->browse_files_tree_view), GTK_FILE_SYSTEM_MODEL_DISPLAY_NAME); + profile_msg (" gtk_tree_view_set_model end", NULL); + + profile_end ("end", NULL); } /* Timeout callback used when the loading timer expires */ diff --git a/tests/Makefile.am b/tests/Makefile.am index 4b04b7e1fa..01f9ae02c8 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -34,6 +34,7 @@ noinst_PROGRAMS = \ testcalendar \ testcombo \ testcombochange \ + testcellrenderertext \ testdnd \ testellipsise \ testentrycompletion \ @@ -83,6 +84,7 @@ testcairo_DEPENDENCIES = $(TEST_DEPS) testcalendar_DEPENDENCIES = $(TEST_DEPS) testcombo_DEPENDENCIES = $(TEST_DEPS) testcombochange_DEPENDENCIES = $(TEST_DEPS) +testcellrenderertext_DEPENDENCIES = $(TEST_DEPS) testdnd_DEPENDENCIES = $(TEST_DEPS) testellipsise_DEPENDENCIES = $(TEST_DEPS) testentrycompletion_DEPENDENCIES = $(TEST_DEPS) @@ -122,6 +124,7 @@ testcairo_LDADD = $(LDADDS) testcalendar_LDADD = $(LDADDS) testcombo_LDADD = $(LDADDS) testcombochange_LDADD = $(LDADDS) +testcellrenderertext_LDADD = $(LDADDS) testdnd_LDADD = $(LDADDS) testellipsise_LDADD = $(LDADDS) testentrycompletion_LDADD = $(LDADDS) diff --git a/tests/autotestfilechooser.c b/tests/autotestfilechooser.c index bc9002ff68..10f26c591f 100644 --- a/tests/autotestfilechooser.c +++ b/tests/autotestfilechooser.c @@ -1,3 +1,26 @@ +/* GTK - The GIMP Toolkit + * autotestfilechooser.c: Automated unit tests for the GtkFileChooser widget + * Copyright (C) 2005, Novell, Inc. + * + * Authors: + * Federico Mena-Quintero + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + #define GTK_FILE_SYSTEM_ENABLE_UNSUPPORTED #include diff --git a/tests/testcellrenderertext.c b/tests/testcellrenderertext.c new file mode 100644 index 0000000000..1a820b7d99 --- /dev/null +++ b/tests/testcellrenderertext.c @@ -0,0 +1,273 @@ +/* GTK - The GIMP Toolkit + * testcellrenderertext.c: Tests for the various properties of GtkCellRendererText + * Copyright (C) 2005, Novell, Inc. + * + * Authors: + * Federico Mena-Quintero + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include + +#define COL_BACKGROUND 14 +#define COL_LINE_NUM 15 +#define NUM_COLS 16 /* change this when adding columns */ + +struct cell_params { + char *description; /* 0 */ + char *test; /* 1 */ + int xpad; /* 2 */ + int ypad; /* 3 */ + double xalign; /* 4 */ + double yalign; /* 5 */ + gboolean sensitive; /* 6 */ + int width; /* 7 */ + int height; /* 8 */ + int width_chars; /* 9 */ + int wrap_width; /* 10 */ + PangoWrapMode wrap_mode; /* 11 */ + gboolean single_paragraph_mode; /* 12 */ + PangoEllipsizeMode ellipsize; /* 13 */ + /* COL_BACKGROUND */ /* 14 */ + /* COL_LINE_NUM */ /* 15 */ +}; + +#define WO PANGO_WRAP_WORD +#define CH PANGO_WRAP_CHAR +#define WC PANGO_WRAP_WORD_CHAR + +#define NO PANGO_ELLIPSIZE_NONE +#define ST PANGO_ELLIPSIZE_START +#define MI PANGO_ELLIPSIZE_MIDDLE +#define EN PANGO_ELLIPSIZE_END + + +#define TESTL "LEFT JUSTIFIED This is really truly verily some very long text\n\330\247\331\204\330\263\331\204\330\247\331\205 \330\271\331\204\331\212\331\203\331\205 \330\247\331\204\330\263\331\204\330\247\331\205 \330\271\331\204\331\212\331\203\331\205 \330\247\331\204\330\263\331\204\330\247\331\205 \330\271\331\204\331\212\331\203\331\205" + +#define TESTC "CENTERED This is really truly verily some very long text\n\330\247\331\204\330\263\331\204\330\247\331\205 \330\271\331\204\331\212\331\203\331\205 \330\247\331\204\330\263\331\204\330\247\331\205 \330\271\331\204\331\212\331\203\331\205 \330\247\331\204\330\263\331\204\330\247\331\205 \330\271\331\204\331\212\331\203\331\205" + +#define TESTR "RIGHT JUSTIFIED This is really truly verily some very long text\n\330\247\331\204\330\263\331\204\330\247\331\205 \330\271\331\204\331\212\331\203\331\205 \330\247\331\204\330\263\331\204\330\247\331\205 \330\271\331\204\331\212\331\203\331\205 \330\247\331\204\330\263\331\204\330\247\331\205 \330\271\331\204\331\212\331\203\331\205" + +static const struct cell_params cell_params[] = { + { "xp yp xa ya se wi he wc ww wm sp el", "", 0, 0, 0.0, 0.5, TRUE, -1, -1, -1, -1, CH, FALSE, NO }, /* 0 */ + + /* Test alignment */ + + { "0 0 0 0 T -1 -1 -1 -1 CH F NO", TESTL, 0, 0, 0.0, 0.0, TRUE, -1, -1, -1, -1, CH, FALSE, NO }, /* 1 */ + { "0 0 .5 0 T -1 -1 -1 -1 CH F NO", TESTC, 0, 0, 0.5, 0.0, TRUE, -1, -1, -1, -1, CH, FALSE, NO }, /* 2 */ + { "0 0 1 0 T -1 -1 -1 -1 CH F NO", TESTR, 0, 0, 1.0, 0.0, TRUE, -1, -1, -1, -1, CH, FALSE, NO }, /* 3 */ + { "0 0 0 .5 T -1 -1 -1 -1 CH F NO", TESTL, 0, 0, 0.0, 0.5, TRUE, -1, -1, -1, -1, CH, FALSE, NO }, /* 4 */ + { "0 0 .5 .5 T -1 -1 -1 -1 CH F NO", TESTC, 0, 0, 0.5, 0.5, TRUE, -1, -1, -1, -1, CH, FALSE, NO }, /* 5 */ + { "0 0 1 .5 T -1 -1 -1 -1 CH F NO", TESTR, 0, 0, 1.0, 0.5, TRUE, -1, -1, -1, -1, CH, FALSE, NO }, /* 6 */ + { "0 0 0 1 T -1 -1 -1 -1 CH F NO", TESTL, 0, 0, 0.0, 1.0, TRUE, -1, -1, -1, -1, CH, FALSE, NO }, /* 7 */ + { "0 0 .5 1 T -1 -1 -1 -1 CH F NO", TESTC, 0, 0, 0.5, 1.0, TRUE, -1, -1, -1, -1, CH, FALSE, NO }, /* 8 */ + { "0 0 1 1 T -1 -1 -1 -1 CH F NO", TESTR, 0, 0, 1.0, 1.0, TRUE, -1, -1, -1, -1, CH, FALSE, NO }, /* 9 */ + + /* Test padding */ + + { "10 10 0 0 T -1 -1 -1 -1 CH F NO", TESTL, 10, 10, 0.0, 0.0, TRUE, -1, -1, -1, -1, CH, FALSE, NO }, /* 10 */ + { "10 10 .5 0 T -1 -1 -1 -1 CH F NO", TESTC, 10, 10, 0.5, 0.0, TRUE, -1, -1, -1, -1, CH, FALSE, NO }, /* 11 */ + { "10 10 1 0 T -1 -1 -1 -1 CH F NO", TESTR, 10, 10, 1.0, 0.0, TRUE, -1, -1, -1, -1, CH, FALSE, NO }, /* 12 */ + { "10 10 0 .5 T -1 -1 -1 -1 CH F NO", TESTL, 10, 10, 0.0, 0.5, TRUE, -1, -1, -1, -1, CH, FALSE, NO }, /* 13 */ + { "10 10 .5 .5 T -1 -1 -1 -1 CH F NO", TESTC, 10, 10, 0.5, 0.5, TRUE, -1, -1, -1, -1, CH, FALSE, NO }, /* 14 */ + { "10 10 1 .5 T -1 -1 -1 -1 CH F NO", TESTR, 10, 10, 1.0, 0.5, TRUE, -1, -1, -1, -1, CH, FALSE, NO }, /* 15 */ + { "10 10 0 1 T -1 -1 -1 -1 CH F NO", TESTL, 10, 10, 0.0, 1.0, TRUE, -1, -1, -1, -1, CH, FALSE, NO }, /* 16 */ + { "10 10 .5 1 T -1 -1 -1 -1 CH F NO", TESTC, 10, 10, 0.5, 1.0, TRUE, -1, -1, -1, -1, CH, FALSE, NO }, /* 17 */ + { "10 10 1 1 T -1 -1 -1 -1 CH F NO", TESTR, 10, 10, 1.0, 1.0, TRUE, -1, -1, -1, -1, CH, FALSE, NO }, /* 18 */ + + +}; + +static GtkListStore * +create_list_store (void) +{ + GtkListStore *list_store; + int i; + + list_store = gtk_list_store_new (NUM_COLS, + G_TYPE_STRING, /* 0 */ + G_TYPE_STRING, /* 1 */ + G_TYPE_INT, /* 2 */ + G_TYPE_INT, /* 3 */ + G_TYPE_DOUBLE, /* 4 */ + G_TYPE_DOUBLE, /* 5 */ + G_TYPE_BOOLEAN, /* 6 */ + G_TYPE_INT, /* 7 */ + G_TYPE_INT, /* 8 */ + G_TYPE_INT, /* 9 */ + G_TYPE_INT, /* 10 */ + PANGO_TYPE_WRAP_MODE, /* 11 */ + G_TYPE_BOOLEAN, /* 12 */ + PANGO_TYPE_ELLIPSIZE_MODE, /* 13 */ + G_TYPE_STRING, /* 14 */ + G_TYPE_STRING); /* 15 */ + + for (i = 0; i < G_N_ELEMENTS (cell_params); i++) + { + const struct cell_params *p; + GtkTreeIter iter; + char buf[50]; + + p = cell_params + i; + + snprintf (buf, sizeof (buf), "%d", i); + + gtk_list_store_append (list_store, &iter); + gtk_list_store_set (list_store, &iter, + 0, p->description, + 1, p->test, + 2, p->xpad, + 3, p->ypad, + 4, p->xalign, + 5, p->yalign, + 6, p->sensitive, + 7, p->width, + 8, p->height, + 9, p->width_chars, + 10, p->wrap_width, + 11, p->wrap_mode, + 12, p->single_paragraph_mode, + 13, p->ellipsize, + 14, (i % 2 == 0) ? "gray50" : "gray80", + 15, buf, + -1); + } + + return list_store; +} + +static GtkWidget * +create_tree (gboolean rtl) +{ + GtkWidget *sw; + GtkWidget *treeview; + GtkListStore *list_store; + GtkTreeViewColumn *column; + GtkCellRenderer *renderer; + GdkPixbuf *pixbuf; + + sw = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN); + gtk_widget_set_direction (sw, rtl ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); + + list_store = create_list_store (); + + treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (list_store)); + gtk_widget_set_direction (treeview, rtl ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); + gtk_container_add (GTK_CONTAINER (sw), treeview); + + /* Line number */ + + renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes ("#", + renderer, + "text", COL_LINE_NUM, + NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); + + /* Description */ + + renderer = gtk_cell_renderer_text_new (); + g_object_set (renderer, + "font", "monospace", + NULL); + column = gtk_tree_view_column_new_with_attributes ("Description", + renderer, + "text", 0, + NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); + + /* Test text */ + + renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes ("Test", + renderer, + "text", 1, + "xpad", 2, + "ypad", 3, + "xalign", 4, + "yalign", 5, + "sensitive", 6, + "width", 7, + "height", 8, + "width_chars", 9, + "wrap_width", 10, + "wrap_mode", 11, + "single_paragraph_mode", 12, + "ellipsize", 13, + "cell_background", 14, + NULL); + gtk_tree_view_column_set_resizable (column, TRUE); + gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); + + /* Empty column */ + + pixbuf = gdk_pixbuf_new_from_file ("apple-red.png", NULL); + + renderer = gtk_cell_renderer_pixbuf_new (); + g_object_set (renderer, + "pixbuf", pixbuf, + "xpad", 10, + "ypad", 10, + NULL); + column = gtk_tree_view_column_new_with_attributes ("Empty", + renderer, + NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column); + + return sw; +} + +int +main (int argc, char **argv) +{ + GtkWidget *window; + GtkWidget *vbox; + GtkWidget *label; + GtkWidget *tree; + + gtk_init (&argc, &argv); + + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + g_signal_connect (window, "destroy", + G_CALLBACK (gtk_main_quit), NULL); + gtk_container_set_border_width (GTK_CONTAINER (window), 12); + + vbox = gtk_vbox_new (FALSE, 12); + gtk_container_add (GTK_CONTAINER (window), vbox); + + /* LTR */ + + label = gtk_label_new ("Left to right"); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + + tree = create_tree (FALSE); + gtk_box_pack_start (GTK_BOX (vbox), tree, TRUE, TRUE, 0); + + /* RTL */ + + label = gtk_label_new ("Right to left"); + gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0); + + tree = create_tree (TRUE); + gtk_box_pack_start (GTK_BOX (vbox), tree, TRUE, TRUE, 0); + + gtk_widget_show_all (window); + gtk_main (); + + return 0; +}