gchar * get_ui_color (GtkWidget * win, const gchar * name, const gchar * state) { GtkStyle *style; gchar *s; TRACE ("entering get_ui_color"); g_return_val_if_fail (win != NULL, NULL); g_return_val_if_fail (GTK_IS_WIDGET (win), NULL); g_return_val_if_fail (GTK_WIDGET_REALIZED (win), NULL); style = get_ui_style (win); s = print_rc_style (win, name, state, style); TRACE ("%s[%s]=%s", name, state, s); return (s); }
int main (int argc, char **argv) { GtkWidget *win; GtkStyle *style = 0; gtk_set_locale(); gtk_init (&argc, &argv); win = gtk_window_new (GTK_WINDOW_TOPLEVEL); style = gtk_rc_get_style (win); if (style == 0) style = gtk_widget_get_style (win); if (style != 0) { if (style->rc_style != 0) print_rc_style (style->rc_style, style); else print_style (style); } return 0; }
/** * Creates the content file. This is where most of the text (and the * code) actually resides. It is also the only file creation routine so * far that actually uses the data it is supplied with. * \param data A \a spreadconv_data structure from which to draw * information * \return 0 on success, -1 on error */ static int create_content_file(struct spreadconv_data *data) { FILE *f; int i, j; f = fopen("content.xml", "w"); if (f == 0) return -1; fprintf(f, "<?xml version=\"1.0\"?>\n"); fprintf(f, "<office:document-content "); print_namespaces(f); fprintf(f, ">\n"); /* print style information */ fprintf(f, "<office:automatic-styles>\n"); for (i=0; i<data->n_unique_rc_styles; i++) print_rc_style(&data->unique_rc_styles[i], f); for (i=0; i<data->n_unique_cell_styles; i++) print_cell_style(&data->unique_cell_styles[i], f); fprintf(f, "</office:automatic-styles>\n"); /* print the actual spreadsheet */ fprintf(f, "<office:body>\n"); fprintf(f, "<office:spreadsheet>\n"); /* avoid printing garbage if data->name is NULL */ if (data->name == 0) data->name = strdup("Sheet 1"); fprintf(f, "<table:table table:name=\"%s\">\n", data->name); /* print the columns */ for (i=0; i<data->n_cols; i++) { fprintf(f, "<table:table-column "); if (data->col_styles[i] != 0) { fprintf(f, "table:style-name=\""); print_escaped(f, data->col_styles[i]->name); fprintf(f, "\" "); } fprintf(f, "/>\n"); } /* print the rows, each with the associated cells */ for (i=0; i<data->n_rows; i++) { fprintf(f, "<table:table-row "); if (data->row_styles[i] != 0) { fprintf(f, "table:style-name=\""); print_escaped(f, data->row_styles[i]->name); fprintf(f, "\" "); } fprintf(f, ">\n"); for (j=0; j<data->n_cols; j++) print_table_cell(&data->cells[i][j], f); fprintf(f, "</table:table-row>\n"); } fprintf(f, "</table:table>\n"); fprintf(f, "</office:spreadsheet>\n"); fprintf(f, "</office:body>\n"); fprintf(f, "</office:document-content>\n"); fclose(f); return 0; }