+color_filters_add_tmp(GSList **cfl)
+{
+ gchar *name = NULL;
+ guint32 i;
+ gchar** bg_colors;
+ gchar** fg_colors;
+ unsigned long int cval;
+ color_t bg_color, fg_color;
+ color_filter_t *colorf;
+
+ g_assert(strlen(prefs.gui_colorized_fg)==69);
+ g_assert(strlen(prefs.gui_colorized_bg)==69);
+ fg_colors = g_strsplit(prefs.gui_colorized_fg, ",", -1);
+ bg_colors = g_strsplit(prefs.gui_colorized_bg, ",", -1);
+
+ for ( i=1 ; i<=10 ; i++ ) {
+ name = g_strdup_printf("%s%02d",CONVERSATION_COLOR_PREFIX,i);
+
+ /* retrieve background and foreground colors */
+ cval = strtoul(fg_colors[i-1], NULL, 16);
+ initialize_color(&fg_color, RED_COMPONENT(cval),
+ GREEN_COMPONENT(cval),
+ BLUE_COMPONENT(cval) );
+ cval = strtoul(bg_colors[i-1], NULL, 16);
+ initialize_color(&bg_color, RED_COMPONENT(cval),
+ GREEN_COMPONENT(cval),
+ BLUE_COMPONENT(cval) );
+ colorf = color_filter_new(name, NULL, &bg_color, &fg_color, TRUE);
+ colorf->filter_text = g_strdup("frame");
+ colorf->c_colorfilter = NULL;
+ *cfl = g_slist_append(*cfl, colorf);
+
+ g_free(name);
+ }
+
+ g_strfreev(fg_colors);
+ g_strfreev(bg_colors);
+
+ return;
+}
+
+static gint
+color_filters_find_by_name_cb(gconstpointer arg1, gconstpointer arg2)
+{
+ const color_filter_t *colorf = (const color_filter_t *)arg1;
+ const gchar *name = (const gchar *)arg2;
+
+ return (strstr(colorf->filter_name, name)==NULL) ? -1 : 0 ;
+}
+
+
+/* Set the filter off a temporary colorfilters and enable it */
+void
+color_filters_set_tmp(guint8 filt_nr, gchar *filter, gboolean disabled)
+{
+ gchar *name = NULL;
+ const gchar *tmpfilter = NULL;
+ GSList *cfl;
+ color_filter_t *colorf;
+ dfilter_t *compiled_filter;
+ guint8 i;
+
+ /* Go through the tomporary filters and look for the same filter string.
+ * If found, clear it so that a filter can be "moved" up and down the list
+ */
+ for ( i=1 ; i<=10 ; i++ ) {
+ /* If we need to reset the temporary filter (filter==NULL), don't look
+ * for other rules with the same filter string
+ */
+ if( i!=filt_nr && filter==NULL )
+ continue;
+
+ name = g_strdup_printf("%s%02d",CONVERSATION_COLOR_PREFIX,i);
+ cfl = g_slist_find_custom(color_filter_list, name, color_filters_find_by_name_cb);
+ colorf = (color_filter_t *)cfl->data;
+
+ /* Only change the filter rule if this is the rule to change or if
+ * a matching filter string has been found
+ */
+ if(colorf && ( (i==filt_nr) || (strstr(filter,colorf->filter_text)!=NULL) ) ) {
+ /* set filter string to "frame" if we are resetting the rules
+ * or if we found a matching filter string which need to be cleared
+ */
+ tmpfilter = ( (filter==NULL) || (i!=filt_nr) ) ? "frame" : filter;
+ if (!dfilter_compile(tmpfilter, &compiled_filter)) {
+ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
+ "Could not compile color filter name: \"%s\""
+ " text: \"%s\".\n%s", name, filter, dfilter_error_msg);
+ } else {
+ if (colorf->filter_text != NULL)
+ g_free(colorf->filter_text);
+ if (colorf->c_colorfilter != NULL)
+ dfilter_free(colorf->c_colorfilter);
+ colorf->filter_text = g_strdup(tmpfilter);
+ colorf->c_colorfilter = compiled_filter;
+ colorf->disabled = ((i!=filt_nr) ? TRUE : disabled);
+ /* Remember that there are now temporary coloring filters set */
+ if( filter )
+ tmp_colors_set = TRUE;
+ }
+ }
+ g_free(name);
+ }
+ return;
+}
+
+/* Reset the temporary colorfilters */
+void
+color_filters_reset_tmp(void)
+{
+ guint8 i;
+
+ for ( i=1 ; i<=10 ; i++ ) {
+ color_filters_set_tmp(i, NULL, TRUE);
+ }
+ /* Remember that there are now *no* temporary coloring filters set */
+ tmp_colors_set = FALSE;
+ return;
+}
+
+/* delete the specified filter */
+void
+color_filter_delete(color_filter_t *colorf)