It can be done by normal GTK CSS styling when we switch to that.
/* Hashtable containing the current styles set by CSS and GLK */
struct StyleSet *styles;
struct StyleSet *glk_styles;
- PangoAttrList *pager_attr_list;
/* Final message displayed when game exits */
gchar *final_message;
/* Image cache */
priv->protect = FALSE;
priv->styles = g_new0(StyleSet,1);
priv->glk_styles = g_new0(StyleSet,1);
- priv->pager_attr_list = pango_attr_list_new();
priv->final_message = g_strdup("[ The game has finished ]");
priv->running = FALSE;
priv->program = NULL;
g_hash_table_destroy(priv->styles->text_grid);
g_hash_table_destroy(priv->glk_styles->text_buffer);
g_hash_table_destroy(priv->glk_styles->text_grid);
- pango_attr_list_unref(priv->pager_attr_list);
-
+
/* Free the event queue */
g_mutex_lock(priv->event_lock);
g_queue_foreach(priv->event_queue, (GFunc)g_free, NULL);
return style_get_tag_names();
}
-/**
- * chimara_glk_update_style:
- * @glk: a #ChimaraGlk widget
- *
- * Processes style updates and updates the widget to reflect the new style.
- * Call this every time you change a property of a #GtkTextTag retrieved by
- * chimara_glk_get_tag().
- */
-void
-chimara_glk_update_style(ChimaraGlk *glk)
-{
- CHIMARA_GLK_USE_PRIVATE(glk, priv);
- style_update(glk);
-
- /* Schedule a redraw */
- g_mutex_lock(priv->arrange_lock);
- priv->needs_rearrange = TRUE;
- priv->ignore_next_arrange_event = TRUE;
- g_mutex_unlock(priv->arrange_lock);
- gtk_widget_queue_resize( GTK_WIDGET(priv->self) );
-}
-
/**
* chimara_glk_set_resource_load_callback:
* @glk: a #ChimaraGlk widget
"user1",
"user2",
"hyperlink",
- "pager",
"default"
};
str->glk_style = (gchar*) get_glk_tag_name(styl);
}
-/* Internal function: call this to initialize the layout of the 'more' prompt. */
-void
-style_init_more_prompt(winid_t win)
-{
- ChimaraGlkPrivate *glk_data = g_private_get(glk_data_key);
-
- win->pager_layout = gtk_widget_create_pango_layout(win->widget, "More");
- pango_layout_set_attributes(win->pager_layout, glk_data->pager_attr_list);
-}
-
/* Internal function: call this to initialize the default styles to a textbuffer. */
void
style_init_textbuffer(GtkTextBuffer *buffer)
g_object_set(tag, "foreground", "#0000ff", "foreground-set", TRUE, "underline", PANGO_UNDERLINE_SINGLE, "underline-set", TRUE, NULL);
g_hash_table_insert(default_text_buffer_styles, "hyperlink", tag);
- GtkTextTag *pager_tag = gtk_text_tag_new("pager");
- g_object_set(pager_tag, "family", "Monospace", "family-set", TRUE, "foreground", "#ffffff", "foreground-set", TRUE, "background", "#000000", "background-set", TRUE, NULL);
- g_hash_table_insert(default_text_buffer_styles, "pager", pager_tag);
- text_tag_to_attr_list(pager_tag, priv->pager_attr_list);
-
priv->styles->text_grid = default_text_grid_styles;
priv->styles->text_buffer = default_text_buffer_styles;
-
/* Initialize the GLK styles to empty tags */
int i;
for(i=0; i<style_NUMSTYLES; i++) {
}
g_scanner_destroy(scanner);
-
- /* Update the pager prompt to the new style */
- style_update(glk);
}
/* Internal function: parses a token */
}
}
-/* Update pager tag */
-void
-style_update(ChimaraGlk *glk)
-{
- CHIMARA_GLK_USE_PRIVATE(glk, priv);
-
- GtkTextTag *pager_tag = GTK_TEXT_TAG( g_hash_table_lookup(priv->styles->text_buffer, "pager") );
- text_tag_to_attr_list(pager_tag, priv->pager_attr_list);
-}
-
/* Determine the current colors used to render the text for a given stream.
* This can be set in a number of places */
static void
G_GNUC_INTERNAL void style_init_textbuffer(GtkTextBuffer *buffer);
G_GNUC_INTERNAL void style_init_textgrid(GtkTextBuffer *buffer);
-G_GNUC_INTERNAL void style_init_more_prompt(winid_t win);
G_GNUC_INTERNAL void style_init(ChimaraGlk *glk);
-G_GNUC_INTERNAL void style_update(ChimaraGlk *glk);
G_GNUC_INTERNAL const gchar** style_get_tag_names();
G_GNUC_INTERNAL void reset_default_styles(ChimaraGlk *glk);
G_GNUC_INTERNAL GScanner *create_css_file_scanner(void);
GHashTable *text_buffer;
} StyleSet;
-#define CHIMARA_NUM_STYLES 13
+#define CHIMARA_NUM_STYLES 12
//#define DEBUG_STYLES
cairo_surface_t *backing_store;
/* Pager (textbuffer only) */
gboolean currently_paging;
- PangoLayout *pager_layout;
};
#endif
if( !gtk_toggle_button_get_active(button) )
return;
g_object_set(current_tag, "justification", GTK_JUSTIFY_LEFT, "justification-set", TRUE, NULL);
- chimara_glk_update_style(glk);
}
void
if( !gtk_toggle_button_get_active(button) )
return;
g_object_set(current_tag, "justification", GTK_JUSTIFY_CENTER, "justification-set", TRUE, NULL);
- chimara_glk_update_style(glk);
}
void
if( !gtk_toggle_button_get_active(button) )
return;
g_object_set(current_tag, "justification", GTK_JUSTIFY_RIGHT, "justification-set", TRUE, NULL);
- chimara_glk_update_style(glk);
}
void
if( !gtk_toggle_button_get_active(button) )
return;
g_object_set(current_tag, "justification", GTK_JUSTIFY_FILL, "justification-set", TRUE, NULL);
- chimara_glk_update_style(glk);
}
void
g_object_set(current_tag, "weight", PANGO_WEIGHT_BOLD, "weight-set", TRUE, NULL);
else
g_object_set(current_tag, "weight", PANGO_WEIGHT_NORMAL, "weight-set", TRUE, NULL);
-
- chimara_glk_update_style(glk);
}
void
g_object_set(current_tag, "style", PANGO_STYLE_ITALIC, "style-set", TRUE, NULL);
else
g_object_set(current_tag, "style", PANGO_STYLE_NORMAL, "style-set", TRUE, NULL);
-
- chimara_glk_update_style(glk);
}
void
g_object_set(current_tag, "underline", PANGO_UNDERLINE_SINGLE, "underline-set", TRUE, NULL);
else
g_object_set(current_tag, "underline", PANGO_UNDERLINE_NONE, "underline-set", TRUE, NULL);
-
- chimara_glk_update_style(glk);
}
void
GdkColor color;
gtk_color_button_get_color(button, &color);
g_object_set(current_tag, "foreground-gdk", &color, "foreground-set", TRUE, NULL);
- chimara_glk_update_style(glk);
}
void
GdkColor color;
gtk_color_button_get_color(button, &color);
g_object_set(current_tag, "background-gdk", &color, "background-set", TRUE, NULL);
- chimara_glk_update_style(glk);
}
void
const gchar *font_name = gtk_font_button_get_font_name(button);
PangoFontDescription *font_description = pango_font_description_from_string(font_name);
g_object_set(current_tag, "font-desc", font_description, NULL);
- chimara_glk_update_style(glk);
}
void
buffer.user2 {
}
-
-buffer.pager {
- color: #ffffff;
- background-color: #303030;
-}