Whitespace.
[gnumeric.git] / src / test-pango.c
blobf383d78ac86c8b4e2eac22440a8d9435ef708092
1 #include <gnumeric-config.h>
2 #include <glib/gi18n.h>
3 #include "gnumeric.h"
4 #include "libgnumeric.h"
6 #include "command-context.h"
7 #include "io-context-gtk.h"
8 /* TODO: Get rid of this one */
9 #include "command-context-stderr.h"
10 #include "wbc-gtk.h"
11 #include "workbook-view.h"
12 #include <goffice/goffice.h>
13 #include "selection.h"
14 #include "sheet-view.h"
15 #include "commands.h"
16 #include "workbook.h"
17 #include "sheet-control.h"
18 #include "gnumeric-paths.h"
19 #include "gnm-plugin.h"
20 #include "wbc-gtk-impl.h"
22 #include <gtk/gtk.h>
24 #define TEST_STEPS 50
25 #define STEP_SIZE 40
27 static gboolean
28 cb_kill_wbcg (WBCGtk *wbcg)
30 gboolean still_open = wbc_gtk_close (wbcg);
31 g_assert (!still_open);
32 return FALSE;
35 static gboolean
36 cb_exercise_pango (gpointer data)
38 static int state = 0;
40 WorkbookControl *wbc = data;
41 SheetView *sv = wb_control_cur_sheet_view (wbc);
43 if (state == 0) {
44 sv_selection_reset (sv);
45 sv_selection_add_full (sv, 0, 0, 0, 0, 40, STEP_SIZE*TEST_STEPS,
46 GNM_SELECTION_MODE_ADD);
47 cmd_area_set_text (wbc, sv, "=rand()", NULL);
48 } else if (state < TEST_STEPS) {
49 SHEET_VIEW_FOREACH_CONTROL(wb_control_cur_sheet_view (wbc),
50 sc, sc_set_top_left (sc, 0, state*STEP_SIZE););
51 } else if (state < (TEST_STEPS*2)) {
52 SHEET_VIEW_FOREACH_CONTROL(wb_control_cur_sheet_view (wbc),
53 sc, sc_set_top_left (sc, 0, (state-TEST_STEPS)*STEP_SIZE););
54 } else if (state == (TEST_STEPS*2)) {
55 go_doc_set_dirty (wb_control_get_doc (wbc), FALSE);
56 g_object_unref (wb_control_get_workbook (wbc));
59 if (state++ < TEST_STEPS*2)
60 return 1;
61 g_idle_add ((GSourceFunc)cb_kill_wbcg, wbc);
62 return 0;
65 int
66 main (int argc, char const **argv)
68 GOCmdContext *cc;
69 WBCGtk *wbc;
70 GOIOContext *ioc;
72 argv = gnm_pre_parse_init (argc, argv);
73 gtk_init (&argc, (char ***)&argv);
74 gnm_init ();
76 cc = gnm_cmd_context_stderr_new ();
77 ioc = go_io_context_new (cc);
78 g_object_unref (cc);
80 gnm_plugins_init (GO_CMD_CONTEXT (ioc));
81 g_object_unref (ioc);
83 initial_workbook_open_complete = TRUE; /* make the last unref exit */
85 wbc = wbc_gtk_new (NULL, workbook_new_with_sheets (1), NULL, NULL);
87 g_idle_add (cb_exercise_pango, wbc);
89 gtk_main ();
91 gnm_shutdown ();
92 gnm_pre_parse_shutdown ();
94 return 0;