X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=libchimara%2Fstyle.c;h=2db2e09e45fcd8395f9cdf46476340adb25606a0;hb=d2379f1ae607ccb5391f36969d566bf6be0a24cd;hp=c3a8e43f9bafd67e018de7cc10a72e7f9435a117;hpb=a43e48ea904e764b9b7272230d4cd9e51e0505d6;p=projects%2Fchimara%2Fchimara.git diff --git a/libchimara/style.c b/libchimara/style.c index c3a8e43..2db2e09 100644 --- a/libchimara/style.c +++ b/libchimara/style.c @@ -4,22 +4,26 @@ extern ChimaraGlkPrivate *glk_data; /** * glk_set_style: - * @styl The style to apply + * @styl: The style to apply * - * This changes the style of the current output stream. After a style change, - * new text which is printed to that stream will be given the new style. For a - * window stream, the text will appear in that style. For other types of - * streams, this has no effect. + * Changes the style of the current output stream. @styl should be one of the + * style_ constants listed above. However, any value is actually + * legal; if the interpreter does not recognize the style value, it will treat + * it as %style_Normal. + * + * This policy allows for the future definition of styles without breaking old + * Glk libraries. + * */ void -glk_set_style(glui32 style) +glk_set_style(glui32 styl) { g_return_if_fail(glk_data->current_stream != NULL); - glk_set_style_stream(glk_data->current_stream, style); + glk_set_style_stream(glk_data->current_stream, styl); } /* Internal function: mapping from style enum to tag name */ -gchar* +static gchar * get_tag_name(glui32 style) { switch(style) { @@ -40,9 +44,16 @@ get_tag_name(glui32 style) return "normal"; } +/** + * glk_set_style_stream: + * @str: Output stream to change the style of + * @styl: The style to apply + * + * This changes the style of the stream @str. See glk_set_style(). + */ void -glk_set_style_stream(strid_t stream, glui32 style) { - stream->style = get_tag_name(style); +glk_set_style_stream(strid_t str, glui32 styl) { + str->style = get_tag_name(styl); } /* Internal function: call this to initialize the default styles to a textbuffer. */ @@ -54,8 +65,8 @@ style_init_textbuffer(GtkTextBuffer *buffer) gtk_text_buffer_create_tag(buffer, "normal", NULL); gtk_text_buffer_create_tag(buffer, "emphasized", "style", PANGO_STYLE_ITALIC, NULL); gtk_text_buffer_create_tag(buffer, "preformatted", "font-desc", glk_data->monospace_font_desc, NULL); - gtk_text_buffer_create_tag(buffer, "header", "size-points", 16.0, "weight", PANGO_WEIGHT_BOLD, NULL); - gtk_text_buffer_create_tag(buffer, "subheader", "size-points", 12.0, "weight", PANGO_WEIGHT_BOLD, NULL); + gtk_text_buffer_create_tag(buffer, "header", "size-points", 18.0, "weight", PANGO_WEIGHT_BOLD, NULL); + gtk_text_buffer_create_tag(buffer, "subheader", "size-points", 14.0, "weight", PANGO_WEIGHT_BOLD, NULL); gtk_text_buffer_create_tag(buffer, "alert", "foreground", "#aa0000", "weight", PANGO_WEIGHT_BOLD, NULL); gtk_text_buffer_create_tag(buffer, "note", "foreground", "#aaaa00", "weight", PANGO_WEIGHT_BOLD, NULL); gtk_text_buffer_create_tag(buffer, "block-quote", "justification", GTK_JUSTIFY_CENTER, "style", PANGO_STYLE_ITALIC, NULL); @@ -64,7 +75,7 @@ style_init_textbuffer(GtkTextBuffer *buffer) gtk_text_buffer_create_tag(buffer, "user2", NULL); } -void +static void color_format(glui32 val, gchar *buffer) { sprintf(buffer, "#%02X%02X%02X", @@ -75,7 +86,7 @@ color_format(glui32 val, gchar *buffer) } /* Internal function: changes a GTK tag to correspond with the given style. */ -void +static void apply_stylehint_to_tag(GtkTextTag *tag, glui32 hint, glsi32 val) { g_return_if_fail(tag != NULL); @@ -173,11 +184,25 @@ apply_stylehint_to_tag(GtkTextTag *tag, glui32 hint, glsi32 val) } } +/** + * glk_stylehint_set: + * @wintype: The window type to set a style hint on, or %wintype_AllTypes. + * @styl: The style to set a hint for. + * @hint: The type of style hint, one of the stylehint_ constants. + * @val: The style hint. The meaning of this depends on @hint. + * + * Sets a hint about the appearance of one style for a particular type of + * window. You can also set wintype to %wintype_AllTypes, which sets a hint for + * all types of window. + * + * There is no equivalent constant to set a hint for all styles of a single + * window type. + * + */ void -glk_stylehint_set(glui32 wintype, glui32 style, glui32 hint, glsi32 val) +glk_stylehint_set(glui32 wintype, glui32 styl, glui32 hint, glsi32 val) { - - gchar *tag_name = get_tag_name(style); + gchar *tag_name = get_tag_name(styl); /* Iterate over all the window and update their styles if nessecary */ winid_t win = glk_window_iterate(NULL, NULL);