/* ====================================================================
 * FTD4Linux Software License, Version 1.0
 *
 * Copyright (c) 2000-2004 The FTD4Linux Development Team.  All rights
 * reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by the
 *        FTD4Linux Development Team (http://www.ftd4linux.2y.net/)."
 *    Alternately, this acknowledgment may appear in the software itself,
 *    if and wherever such third-party acknowledgments normally appear.
 *
 * 4. The names "FTD" and "FTD4Linux" must
 *    not be used to endorse or promote products derived from this
 *    software without prior written permission. For written
 *    permission, please contact alguno@ftd4linux.2y.net.
 *
 * 5. Products derived from this software may not be called "FTD4Linux",
 *    nor may "FTD4Linux" appear in their name, without prior written
 *    permission of the FTD4Linux Development Team.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE FTD4LINUX DEVELOPMENT TEAM OR
 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */

#ifndef _FTD_GUI_CONFIG_H_
#define _FTD_GUI_CONFIG_H_

#include "ftd4linux.h"

#include <gtk/gtk.h>

typedef struct _ftd_gui_config              FtdGuiConfig;
typedef struct _ftd_gui_config_user         FtdGuiConfigUser;
typedef struct _ftd_gui_config_settings     FtdGuiConfigSettings;
#ifndef BUILTIN_PLUGIN
typedef struct _ftd_gui_config_plugin       FtdGuiConfigPlugin;
#endif
typedef struct _ftd_gui_config_badwords     FtdGuiConfigBadwords;
typedef struct _ftd_gui_config_groupfilter  FtdGuiConfigGroupfilter;
typedef struct _ftd_gui_config_catfilters   FtdGuiConfigCatFilters;
typedef struct _ftd_gui_config_irc          FtdGuiConfigIRC;

#include "ftd_gui_signup.h"

struct _ftd_gui_config_user {
    GtkWidget               *username;
    GtkWidget               *password;
    GtkWidget               *proxyHost;
    GtkWidget               *proxyPort;
    GtkWidget               *proxyAuth;
    GtkWidget               *proxyUser;
    GtkWidget               *proxyPass;
    GtkWidget               *lblProxyUser;
    GtkWidget               *lblProxyPass;
    GtkWidget               *comboVerwijderPostsNaXDagen;
    GtkWidget               *ratingScale;
    GtkWidget               *lblRatingScale;
    GtkWidget               *widget;
};

struct _ftd_gui_config_settings {
    GtkWidget           *updatenBijOpstarten;
    GtkWidget           *toonInfoBijEenZoekresultaat;
    GtkWidget           *startMaximized;
    GtkWidget           *toonStatusBijLaden;
    GtkWidget           *toonCategoriseerdeLijstBijKnopNieuw;
    GtkWidget           *recursiveUpdate;
    GtkWidget           *geenTabbedBrowsing;
    GtkWidget           *gebruikFontFamily;
    GtkWidget           *htmlRenderer;
#ifndef DARWIN
    GtkWidget           *trayIcon;
#endif
    GtkWidget           *toonWatcherNotifications;
    GtkWidget           *openPostinfoOpAchtergrond;
    GtkWidget           *toonGUIGroupFilter;
    GtkWidget           *groupFilter;
    GtkWidget           *widget;
};

#ifndef BUILTIN_PLUGIN
struct _ftd_gui_config_plugin {
    GtkWidget               *authLocation;
    GtkWidget               *pluginList;
    GtkWidget               *filesel;
    GtkWidget               *widget;
};
#endif

struct _ftd_gui_config_badwords {
    GtkWidget           *widget;
    GtkWidget           *entryBadword;
    GtkWidget           *treeviewBadwords;
    GtkTreeStore        *treestoreBadwords;
    GtkWidget           *btnVerwijderBadword;
    FtdString           *selectedWord;
};

struct _ftd_gui_config_groupfilter {
    GtkWidget           *widget;
    GtkWidget           *treeGroups;
    GtkTreeStore        *treestoreGroups;
};

struct _ftd_gui_config_catfilters {
    GtkWidget           *widget;
    GtkWidget           *txtCat0Name;
    GtkWidget           *btnCat0Save;
    GtkWidget           *btnCat0Delete;
    GtkWidget           *txtCat0ExtraTag;
    GtkListStore        *lststoreCat0Filters;
    GtkWidget           *lstCat0Filters;
    GtkWidget           *btnCat0FilterUp;
    GtkWidget           *btnCat0FilterDown;
    FtdList             *cat0TagsA;
    FtdList             *cat0TagsB;
    FtdList             *cat0TagsC;
    FtdList             *cat0TagsD;
    GtkWidget           *txtCat1Name;
    GtkWidget           *btnCat1Save;
    GtkWidget           *btnCat1Delete;
    GtkWidget           *txtCat1ExtraTag;
    GtkListStore        *lststoreCat1Filters;
    GtkWidget           *lstCat1Filters;
    GtkWidget           *btnCat1FilterUp;
    GtkWidget           *btnCat1FilterDown;
    FtdList             *cat1TagsA;
    FtdList             *cat1TagsB;
    FtdList             *cat1TagsC;
    FtdList             *cat1TagsD;
    GtkWidget           *txtCat2Name;
    GtkWidget           *btnCat2Save;
    GtkWidget           *btnCat2Delete;
    GtkWidget           *txtCat2ExtraTag;
    GtkListStore        *lststoreCat2Filters;
    GtkWidget           *lstCat2Filters;
    GtkWidget           *btnCat2FilterUp;
    GtkWidget           *btnCat2FilterDown;
    FtdList             *cat2TagsA;
    FtdList             *cat2TagsB;
    FtdList             *cat2TagsC;
    GtkWidget           *txtCat3Name;
    GtkWidget           *btnCat3Save;
    GtkWidget           *btnCat3Delete;
    GtkWidget           *txtCat3ExtraTag;
    GtkListStore        *lststoreCat3Filters;
    GtkWidget           *lstCat3Filters;
    GtkWidget           *btnCat3FilterUp;
    GtkWidget           *btnCat3FilterDown;
    FtdList             *cat3TagsA;
    FtdList             *cat3TagsB;
    FtdList             *filters; //Working copy of the filters
    gboolean             changed_anything;
};

struct _ftd_gui_config_irc {
    GtkWidget           *widget;
    GtkWidget           *entryNickname;
    GtkWidget           *entryAltNickname;
    GtkWidget           *checkUsernameAsNickname;
    GtkWidget           *checkEnableIRCClient;
    GtkWidget           *frameSettings;
};

struct _ftd_gui_config {
    FtdGuiConfigUser        *user;
    FtdGuiConfigSettings    *settings;
#ifndef BUILTIN_PLUGIN
    FtdGuiConfigPlugin      *plugin;
#endif
    FtdGuiConfigBadwords    *badwords;
    FtdGuiSignup            *signup;
    FtdGuiConfigGroupfilter *groupfilter;
    FtdGuiConfigCatFilters  *catfilters;
    FtdGuiConfigIRC         *irc;
    GtkWidget               *window;
    GtkWidget               *notebook;
};

FtdGuiConfig    *ftd_gui_config_new(GtkWidget *, gboolean, gboolean);
void             ftd_gui_config_free(FtdGuiConfig *);

gboolean         ftd_gui_config_callback_destroy(GtkWidget *, gpointer);
gboolean         ftd_gui_config_callback_cancel(GtkWidget *, gpointer);
gboolean         ftd_gui_config_callback_ok(GtkWidget *, gpointer);

void             ftd_gui_config_user_new(FtdGuiConfig *);
void             ftd_gui_config_user_free(FtdGuiConfig *);
void             ftd_gui_config_user_proxyAuth_controle(FtdGuiConfig *, gboolean);
gboolean         ftd_gui_config_user_callback_registreer(GtkWidget *, gpointer);

void             ftd_gui_config_user_callback_proxyAuth(GtkWidget *, gpointer);
void             ftd_gui_config_user_callback_proxyPort(GtkWidget *, const gchar *,
                                                        gint, gint *, gpointer);

#ifndef BUILTIN_PLUGIN
void             ftd_gui_config_plugin_new(FtdGuiConfig *);
void             ftd_gui_config_plugin_free(FtdGuiConfig *);

void             ftd_gui_config_plugin_callback_find      (GtkWidget *, gpointer);
void             ftd_gui_config_plugin_callback_find_ok   (GtkWidget *, gpointer);
void             ftd_gui_config_plugin_callback_find_close(GtkWidget *, gpointer);
#endif

void             ftd_gui_config_settings_new(FtdGuiConfig *, gboolean);
void             ftd_gui_config_settings_free(FtdGuiConfig *);

void             ftd_gui_config_badwords_new(FtdGuiConfig *);
void             ftd_gui_config_badwords_free(FtdGuiConfig *);
void             ftd_gui_config_badwords_fill(FtdGuiConfig *);
void             ftd_gui_config_badwords_select(GtkTreeSelection *, gpointer);
gboolean         ftd_gui_config_badwords_toevoegen(GtkWidget *, gpointer);
gboolean         ftd_gui_config_badwords_verwijder(GtkWidget *, gpointer);

void             ftd_gui_config_groupfilter_new(FtdGuiConfig *);
void             ftd_gui_config_groupfilter_free(FtdGuiConfig *);
FtdList         *ftd_gui_config_groupfilter_get_list(FtdGuiConfig *);

void             ftd_gui_config_catfilters_new(FtdGuiConfig *);
void             ftd_gui_config_catfilters_free(FtdGuiConfig *);
void             ftd_gui_config_catfilters_callback_filter_up( GtkButton *, gpointer );
void             ftd_gui_config_catfilters_callback_filter_down( GtkButton *, gpointer );
void             ftd_gui_config_catfilters_callback_save( GtkButton *, gpointer );
void             ftd_gui_config_catfilters_callback_delete( GtkButton *, gpointer );
void             dumpfilters();
void             ftd_gui_config_catfilters_callback_selection_changed( GtkTreeSelection *, gpointer );
void             ftd_gui_config_catfilters_callback_name_changed( GtkWidget * widget, GdkEventKey * event, gpointer data );

void             ftd_gui_config_irc_new(FtdGuiConfig *config);
void             ftd_gui_config_irc_free(FtdGuiConfig *config);

typedef struct _ftd_gui_config_html_renderer {
    const char *name;
    const char *filename;
} FtdGuiConfigHTMLRenderer;

FtdList         *ftd_gui_config_get_html_renderers(void);
void             ftd_gui_config_free_html_renderers(FtdList *);

#endif /* _FTD_GUI_CONFIG_H_ */
