Example #1
0
static void
add_general_tag (char* tag_name, Preference text_pref,
                Preference background_pref, Preference font_pref)
{
        GdkRGBA *fg_color, *bg_color;
        char *font;
        char *key;

        /* initialize tag preferences */

        /* text color */
        key = preferences_get_key (text_pref);
        fg_color = preferences_get_color (key);
        preferences_notify_add (key, changed_text, tag_name);
        g_free (key);

        /* base color */
        key = preferences_get_key (background_pref);
        bg_color = preferences_get_color (key);
        preferences_notify_add (key, changed_background, tag_name);
        g_free (key);

        /* font */
        key = preferences_get_key (font_pref);
        font = preferences_get_string (key);
        preferences_notify_add (key, changed_font, tag_name);
        g_free (key);

        highlight_add_tag (tag_name, fg_color, bg_color, font);
}
Example #2
0
static void highlight_add (guint id)
{
        WarlockHighlight *highlight;
        const char *string;
        gboolean case_sensitive;
        guint i;
        char *name;

        string = preferences_get_string (preferences_get_highlight_key (id,
                                PREF_HIGHLIGHT_STRING));
        case_sensitive = preferences_get_bool (preferences_get_highlight_key
                        (id, PREF_HIGHLIGHT_CASE_SENSITIVE));

        highlight = g_new (WarlockHighlight, 1);
        highlight->id = id;
        highlight->regex = highlight_compile_regex (string, case_sensitive);
        highlight->gconf_connections = NULL;

        highlight_list = g_slist_append (highlight_list, highlight);

        highlight_add_tags (id);

        highlight->gconf_connections = g_slist_append
                (highlight->gconf_connections, GINT_TO_POINTER
                 (preferences_notify_add (preferences_get_highlight_key
                                          (id, PREF_HIGHLIGHT_STRING),
                                          change_string, highlight)));
        highlight->gconf_connections = g_slist_append
                (highlight->gconf_connections, GINT_TO_POINTER
                 (preferences_notify_add (preferences_get_highlight_key
                                          (id, PREF_HIGHLIGHT_CASE_SENSITIVE),
                                          change_string, highlight)));

        for (i = 0; i < HIGHLIGHT_MATCHES; i++) {
                name = mangle_name (id, i);
                highlight->gconf_connections = g_slist_append
                        (highlight->gconf_connections, GINT_TO_POINTER
                         (preferences_notify_add
                          (preferences_get_highlight_match_key
                           (id, i, PREF_HIGHLIGHT_MATCH_TEXT_COLOR),
                           changed_text, name)));

                highlight->gconf_connections = g_slist_append
                        (highlight->gconf_connections, GINT_TO_POINTER
                         (preferences_notify_add
                          (preferences_get_highlight_match_key
                           (id, i, PREF_HIGHLIGHT_MATCH_BASE_COLOR),
                           changed_background, name)));

                highlight->gconf_connections = g_slist_append
                        (highlight->gconf_connections, GINT_TO_POINTER
                         (preferences_notify_add
                          (preferences_get_highlight_match_key
                           (id, i, PREF_HIGHLIGHT_MATCH_FONT),
                           changed_font, name)));
        }
}
Example #3
0
void highlight_init (void)
{
        GSList *highlights, *cur;

        highlight_tag_table = gtk_text_tag_table_new();

        /* setup the tags */
        add_general_tag (TITLE_TAG, PREF_TITLE_TEXT_COLOR,
                        PREF_TITLE_BASE_COLOR, PREF_TITLE_FONT);
        add_general_tag (MONSTER_TAG, PREF_MONSTER_TEXT_COLOR,
                        PREF_MONSTER_BASE_COLOR, PREF_MONSTER_FONT);
        add_general_tag (ECHO_TAG, PREF_ECHO_TEXT_COLOR, PREF_ECHO_BASE_COLOR,
                        PREF_ECHO_FONT);

        /* add the user defined highlights */
        preferences_notify_add (preferences_get_key (PREF_HIGHLIGHTS_INDEX),
                        change_index, NULL);

        highlights = preferences_get_list (preferences_get_key
                        (PREF_HIGHLIGHTS_INDEX), PREFERENCES_VALUE_INT);

        for (cur = highlights; cur != NULL; cur = cur->next) {
                highlight_add (GPOINTER_TO_INT (cur->data));
        }
}
Example #4
0
void
warlock_log_init (void)
{
	char *key;

	log_toggle ();

	key = preferences_get_key (PREF_AUTO_LOG);

	(void)preferences_notify_add (key, log_notify, NULL);
}
Example #5
0
void
warlock_views_init (void)
{
        char *key;

        main_view = warlock_view_init ("main", _("Main"), NULL);

        warlock_view_init ("arrival", _("Arrivals and Departures"),
			"arrival_menu_item");
        warlock_view_init ("thoughts", _("Thoughts"), "thoughts_menu_item");
        warlock_view_init ("death", _("Deaths"), "deaths_menu_item");
        warlock_view_init ("familiar", _("Familiar"), "familiar_menu_item");

        // max buffer size init
        key = preferences_get_key (PREF_TEXT_BUFFER_SIZE);
        max_buffer_size = preferences_get_int (key);
        buffer_size_notification = preferences_notify_add (key,
                        buffer_size_change, NULL);

        //g_atexit (warlock_views_finish);
}
Example #6
0
static void
warlock_view_create_text_view (WarlockView *warlock_view)
{
        PangoFontDescription *font;
        GdkRGBA *color;
        GtkTextIter iter;
	GtkWidget *text_view;
        
        text_view = gtk_text_view_new ();
        gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view),
                        GTK_WRAP_WORD_CHAR);
        gtk_text_view_set_editable (GTK_TEXT_VIEW (text_view), FALSE);


	warlock_view->text_buffer = gtk_text_buffer_new (highlight_tag_table);
	warlock_view->text_view = text_view;
	gtk_text_view_set_buffer (GTK_TEXT_VIEW (text_view),
			warlock_view->text_buffer);

        gtk_text_buffer_get_end_iter (warlock_view->text_buffer, &iter);
        warlock_view->mark = gtk_text_buffer_create_mark
                (warlock_view->text_buffer, NULL, &iter, TRUE);

        /* set the text color */
        color = preferences_get_color (preferences_get_key
                        (PREF_DEFAULT_TEXT_COLOR));
        if (color == NULL) {
                color = g_new (GdkRGBA, 1);
                gdk_rgba_parse (color, "white");
        }
	gtk_widget_override_color (text_view, GTK_STATE_NORMAL, color);
        g_free (color);

        /* set the background color*/
        color = preferences_get_color (preferences_get_key
                        (PREF_DEFAULT_BASE_COLOR));
        if (color == NULL) {
                color = g_new (GdkRGBA, 1);
                gdk_rgba_parse (color, "black");
        }
	gtk_widget_override_background_color (text_view, GTK_STATE_NORMAL,
			color);
        g_free (color);

        /* set the font */
        font = preferences_get_font (preferences_get_key (PREF_DEFAULT_FONT));
        if (font == NULL) {
                font = pango_font_description_from_string ("sans");
        }
	gtk_widget_override_font (text_view, font);

        /* listen to gconf and change the text color when the gconf
         * value changes */
        preferences_notify_add (preferences_get_key (PREF_DEFAULT_TEXT_COLOR),
                        change_text_color, text_view);

        /* listen for background change */
        preferences_notify_add (preferences_get_key (PREF_DEFAULT_BASE_COLOR),
                        change_base_color, text_view);

        /* listen for font change */
        preferences_notify_add (preferences_get_key (PREF_DEFAULT_FONT),
                        change_font, text_view);
}