2 * Gnumeric, the GNOME spreadsheet.
4 * Graphics Wizard bootstap file
7 * Miguel de Icaza (miguel@gnu.org)
12 #include <glade/glade.h>
13 #include "idl/Graph.h"
15 #include "graphic-type.h"
23 static subtype_info_t column_subtypes
[] = {
25 N_("Clustered columns. Compares values between categories"),
29 GNOME_Graph_CHART_TYPE_CLUSTERED
,
30 GNOME_Graph_PLOT_COLBAR
,
31 GNOME_Graph_COLBAR_FLAT
,
37 N_("Stacked columns. Compares the values brought by each category"),
41 GNOME_Graph_CHART_TYPE_STACKED
,
42 GNOME_Graph_PLOT_COLBAR
,
43 GNOME_Graph_COLBAR_FLAT
,
50 N_("Stacked columns, 100%. Compares between the categories the values broght to a total"),
54 GNOME_Graph_CHART_TYPE_STACKED_FULL
,
55 GNOME_Graph_PLOT_COLBAR
,
56 GNOME_Graph_COLBAR_FLAT
,
64 static subtype_info_t bar_subtypes
[] = {
66 N_("Clustered bars. Compares values between categories"),
70 GNOME_Graph_CHART_TYPE_CLUSTERED
,
71 GNOME_Graph_PLOT_COLBAR
,
72 GNOME_Graph_COLBAR_FLAT
,
78 N_("Stacked bars. Compares the values brought by each category"),
82 GNOME_Graph_CHART_TYPE_STACKED
,
83 GNOME_Graph_PLOT_COLBAR
,
84 GNOME_Graph_COLBAR_FLAT
,
91 N_("Stacked bars, 100%. Compares between the categories the values broght to a total"),
95 GNOME_Graph_CHART_TYPE_STACKED_FULL
,
96 GNOME_Graph_PLOT_COLBAR
,
97 GNOME_Graph_COLBAR_FLAT
,
105 static subtype_info_t lines_subtypes
[] = {
107 N_("Lines. FIXME: Add nice explanation"),
111 GNOME_Graph_CHART_TYPE_CLUSTERED
,
112 GNOME_Graph_PLOT_LINES
,
113 GNOME_Graph_COLBAR_FLAT
,
115 GNOME_Graph_LINE_PLAIN
,
120 N_("Stacked Lines. FIXME: Add nice explanation"),
124 GNOME_Graph_CHART_TYPE_STACKED
,
125 GNOME_Graph_PLOT_LINES
,
126 GNOME_Graph_COLBAR_FLAT
,
128 GNOME_Graph_LINE_PLAIN
134 N_("Stacked lines, 100%. FIXME: Add nice explanation"),
138 GNOME_Graph_CHART_TYPE_STACKED_FULL
,
139 GNOME_Graph_PLOT_LINES
,
140 GNOME_Graph_COLBAR_FLAT
,
142 GNOME_Graph_LINE_PLAIN
147 N_("Lines with markers. FIXME: Add nice explanation"),
151 GNOME_Graph_CHART_TYPE_CLUSTERED
,
152 GNOME_Graph_PLOT_LINES
,
153 GNOME_Graph_COLBAR_FLAT
,
155 GNOME_Graph_LINE_MARKERS
,
160 N_("Stacked lines with markers. FIXME: Add nice explanation"),
164 GNOME_Graph_CHART_TYPE_STACKED
,
165 GNOME_Graph_PLOT_LINES
,
166 GNOME_Graph_COLBAR_FLAT
,
168 GNOME_Graph_LINE_MARKERS
173 N_("Stacked lines with markers, 100%. FIXME: Add nice explanation"),
177 GNOME_Graph_CHART_TYPE_STACKED_FULL
,
178 GNOME_Graph_PLOT_LINES
,
179 GNOME_Graph_COLBAR_FLAT
,
181 GNOME_Graph_LINE_MARKERS
188 static subtype_info_t scatter_subtypes
[] = {
190 N_("Scatter points"),
194 GNOME_Graph_CHART_TYPE_SCATTER
,
195 0, /* plot_mode ignored */
196 0, /* col_bar_mode ignored */
197 0, /* direction ignored */
198 GNOME_Graph_LINE_PLAIN
,
199 0, /* pie_mode ignored */
200 0, /* pie_dim ignored */
201 GNOME_Graph_SCATTER_POINTS
,
202 GNOME_Graph_SCATTER_CONN_NONE
,
207 N_("Scatter points connected with lines"),
211 GNOME_Graph_CHART_TYPE_SCATTER
,
212 0, /* plot_mode ignored */
213 0, /* col_bar_mode ignored */
214 0, /* direction ignored */
215 GNOME_Graph_LINE_PLAIN
,
216 0, /* pie_mode ignored */
217 0, /* pie_dim ignored */
218 GNOME_Graph_SCATTER_POINTS
,
219 GNOME_Graph_SCATTER_CONN_LINES
,
224 N_("Scatter data connected with lines"),
228 GNOME_Graph_CHART_TYPE_SCATTER
,
229 0, /* plot_mode ignored */
230 0, /* col_bar_mode ignored */
231 0, /* direction ignored */
232 GNOME_Graph_LINE_PLAIN
,
233 0, /* pie_mode ignored */
234 0, /* pie_dim ignored */
235 GNOME_Graph_SCATTER_NONE
,
236 GNOME_Graph_SCATTER_CONN_LINES
,
243 static subtype_info_t area_subtypes
[] = {
245 N_("Area 1: FIXME add nice description"),
249 GNOME_Graph_CHART_TYPE_CLUSTERED
,
250 GNOME_Graph_PLOT_AREA
,
251 GNOME_Graph_COLBAR_FLAT
,
257 N_("Stacked area. FIXME: add nic description"),
261 GNOME_Graph_CHART_TYPE_STACKED
,
262 GNOME_Graph_PLOT_AREA
,
263 GNOME_Graph_COLBAR_FLAT
,
270 N_("Stacked Area, 100%. FIXME: add nice description"),
274 GNOME_Graph_CHART_TYPE_STACKED_FULL
,
275 GNOME_Graph_PLOT_AREA
,
276 GNOME_Graph_COLBAR_FLAT
,
287 subtype_info_t
*subtypes
;
288 } graphic_types
[] = {
289 { N_("Column"), "chart_column", column_subtypes
},
290 { N_("Bar"), "chart_bar", bar_subtypes
},
291 { N_("Lines"), "chart_line", lines_subtypes
},
292 { N_("Scatter"), "chart_scatter", scatter_subtypes
},
293 { N_("Areas"), "chart_area", area_subtypes
},
298 graphic_type_show_page (WizardGraphicContext
*gc
, int n
)
300 gtk_notebook_set_page (gc
->graphic_types_notebook
, n
);
301 graphic_type_set_chart_mode (gc
->chart
, &graphic_types
[n
].subtypes
[0].par
);
305 graphic_type_show_preview (WizardGraphicContext
*gc
)
307 gc
->last_graphic_type_page
= gtk_notebook_get_current_page (gc
->graphic_types_notebook
);
308 gtk_notebook_set_page (gc
->graphic_types_notebook
, 5);
312 graphic_type_restore_view (WizardGraphicContext
*gc
)
314 gtk_notebook_set_page (gc
->graphic_types_notebook
, gc
->last_graphic_type_page
);
315 gc
->last_graphic_type_page
= -1;
319 graphic_type_selected (GtkCList
*clist
, gint row
, gint column
, GdkEvent
*event
,
320 WizardGraphicContext
*gc
)
322 graphic_type_show_page (gc
, row
);
326 graphic_type_set_chart_mode (GNOME_Graph_Chart chart
, PlotParameters
*par
)
328 CORBA_Environment ev
;
330 CORBA_exception_init (&ev
);
332 GNOME_Graph_Chart__set_chart_type (chart
, par
->chart_type
, &ev
);
333 GNOME_Graph_Chart__set_plot_mode (chart
, par
->plot_mode
, &ev
);
334 GNOME_Graph_Chart__set_col_bar_mode (chart
, par
->col_bar_mode
, &ev
);
335 GNOME_Graph_Chart__set_direction (chart
, par
->direction
, &ev
);
336 GNOME_Graph_Chart__set_line_mode (chart
, par
->line_mode
, &ev
);
337 GNOME_Graph_Chart__set_pie_mode (chart
, par
->pie_mode
, &ev
);
338 GNOME_Graph_Chart__set_pie_dim (chart
, par
->pie_dim
, &ev
);
339 GNOME_Graph_Chart__set_scatter_mode (chart
, par
->scatter_mode
, &ev
);
340 GNOME_Graph_Chart__set_scatter_conn (chart
, par
->scatter_conn
, &ev
);
341 GNOME_Graph_Chart__set_surface_mode (chart
, par
->surface_mode
, &ev
);
342 GNOME_Graph_Chart__set_with_labels (chart
, par
->with_labels
, &ev
);
343 CORBA_exception_free (&ev
);
347 graph_type_button_clicked (GtkWidget
*widget
, subtype_info_t
*type
)
349 WizardGraphicContext
*gc
= gtk_object_get_user_data (GTK_OBJECT (widget
));
350 GtkLabel
*label
= GTK_LABEL (glade_xml_get_widget (gc
->gui
, "plot-description"));
352 gtk_label_set_text (label
, type
->description
);
353 graphic_type_set_chart_mode (gc
->chart
, &type
->par
);
357 show_sample_pressed (GtkWidget
*button
, WizardGraphicContext
*gc
)
359 graphic_type_show_preview (gc
);
363 show_sample_released (GtkWidget
*button
, WizardGraphicContext
*gc
)
365 graphic_type_restore_view (gc
);
369 graphic_type_boot (GladeXML
*gui
, WizardGraphicContext
*gc
)
371 GtkCList
*clist
= GTK_CLIST (glade_xml_get_widget (gui
, "graphic-type-clist"));
372 GtkTable
*table
= GTK_TABLE (glade_xml_get_widget (gui
, "graphic-selector-table"));
373 GtkObject
*show_sample
= GTK_OBJECT(glade_xml_get_widget (gui
, "show-sample"));
376 gc
->graphic_types_notebook
= GTK_NOTEBOOK (gtk_notebook_new ());
377 gtk_widget_show (GTK_WIDGET (gc
->graphic_types_notebook
));
378 gtk_table_attach (table
, GTK_WIDGET (gc
->graphic_types_notebook
),
380 GTK_EXPAND
| GTK_FILL
, GTK_EXPAND
| GTK_FILL
,
382 gtk_notebook_set_show_tabs (gc
->graphic_types_notebook
, FALSE
);
383 gtk_container_set_border_width (GTK_CONTAINER (gc
->graphic_types_notebook
), 0);
384 gtk_notebook_set_show_border (gc
->graphic_types_notebook
, FALSE
);
386 gtk_clist_set_column_width (clist
, 0, 16);
387 gtk_clist_set_column_justification (clist
, 1, GTK_JUSTIFY_LEFT
);
388 gtk_signal_connect (GTK_OBJECT (clist
), "select_row",
389 GTK_SIGNAL_FUNC (graphic_type_selected
), gc
);
391 for (i
= 0; graphic_types
[i
].text
; i
++){
392 GtkWidget
*display_table
;
393 subtype_info_t
*type_info
;
394 char *clist_text
[2];
398 clist_text
[1] = _(graphic_types
[i
].text
);
399 gtk_clist_append (clist
, clist_text
);
401 type_info
= graphic_types
[i
].subtypes
;
403 display_table
= gtk_table_new (0, 0, 0);
404 gtk_widget_show (display_table
);
405 gtk_notebook_append_page (gc
->graphic_types_notebook
, display_table
, NULL
);
407 for (j
= 0; type_info
[j
].description
!= NULL
; j
++){
408 GtkWidget
*happy_button
, *pix
;
411 happy_button
= gtk_button_new ();
412 gtk_widget_show (happy_button
);
413 gtk_button_set_relief (GTK_BUTTON (happy_button
), GTK_RELIEF_NONE
);
415 button_name
= g_strdup_printf (
417 GNUMERIC_ICONSDIR
, graphic_types
[i
].icon_name
,
418 type_info
[j
].col
, type_info
[j
].row
);
419 pix
= gnome_pixmap_new_from_file (button_name
);
421 gtk_container_add (GTK_CONTAINER (happy_button
), pix
);
422 gtk_widget_show (pix
);
424 g_free (button_name
);
427 GTK_TABLE (display_table
), happy_button
,
428 type_info
[j
].row
, type_info
[j
].row
+1,
429 type_info
[j
].col
, type_info
[j
].col
+1,
433 GTK_OBJECT (happy_button
), "clicked",
434 GTK_SIGNAL_FUNC(graph_type_button_clicked
), &type_info
[j
]);
435 gtk_object_set_user_data (GTK_OBJECT (happy_button
), gc
);
437 if (i
== 0 && j
== 0)
438 gtk_button_clicked (GTK_BUTTON (happy_button
));
444 BonoboViewFrame
*frame
;
447 frame
= graphic_context_new_chart_view_frame (gc
);
448 view
= bonobo_view_frame_get_wrapper (frame
);
449 gtk_widget_show (view
);
450 gtk_notebook_append_page (gc
->graphic_types_notebook
, view
, NULL
);
453 gtk_clist_select_row (clist
, 0, 1);
454 gtk_clist_thaw (clist
);
457 * Connect the "Show Preview" button
461 show_sample
, "pressed", GTK_SIGNAL_FUNC (show_sample_pressed
), gc
);
463 show_sample
, "released", GTK_SIGNAL_FUNC (show_sample_released
), gc
);
467 * Set a chart mode default
470 graphic_type_init_preview (WizardGraphicContext
*gc
)
472 graphic_type_set_chart_mode (gc
->chart
, &column_subtypes
[0].par
);