/* ====================================================================
 * 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.
 */

#include <gdk/gdkkeysyms.h>
#include "ftd_gui_main.h"
#include "ftd_gui_menu.h"
#include "ftd_gui_config.h"

void
ftd_gui_menu_new(void)
{
    GtkWidget *amenu;
    FtdGuiMenu *menu = (FtdGuiMenu *) g_malloc(sizeof(FtdGuiMenu));

    g_assert(gui);
    gui->menu = menu;

    menu->widget = gtk_menu_bar_new ();
    gtk_widget_show (menu->widget);

    menu->accel = gtk_accel_group_new ();

    menu->programma = gtk_menu_item_new_with_mnemonic ("_Programma");
    gtk_widget_show(menu->programma);
    gtk_container_add(GTK_CONTAINER(menu->widget), menu->programma);

    amenu = gtk_menu_new ();
    gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu->programma), amenu);

    menu->updaten = gtk_menu_item_new_with_mnemonic ("_Updaten");
    gtk_widget_show (menu->updaten);
    gtk_container_add (GTK_CONTAINER (amenu), menu->updaten);
    gtk_widget_add_accelerator (menu->updaten, "activate", menu->accel,
                                GDK_space, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
                                GTK_ACCEL_VISIBLE);

    menu->config = gtk_menu_item_new_with_mnemonic ("_Configuratie");
    gtk_widget_show (menu->config);
    gtk_container_add (GTK_CONTAINER (amenu), menu->config);

    menu->afsluiten = gtk_menu_item_new_with_mnemonic ("_Afsluiten");
    gtk_widget_show (menu->afsluiten);
    gtk_container_add (GTK_CONTAINER (amenu), menu->afsluiten);
    gtk_widget_add_accelerator (menu->afsluiten, "activate", menu->accel,
                                GDK_F4, GDK_MOD1_MASK,
                                GTK_ACCEL_VISIBLE);

    menu->opties = gtk_menu_item_new_with_mnemonic ("_Opties");
    gtk_widget_show (menu->opties);
    gtk_container_add (GTK_CONTAINER(menu->widget), menu->opties);

    amenu = gtk_menu_new ();
    gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu->opties), amenu);

    menu->nieuw = gtk_menu_item_new_with_mnemonic ("_Nieuw binnen");
    gtk_widget_show (menu->nieuw);
    gtk_container_add (GTK_CONTAINER (amenu), menu->nieuw);
    gtk_widget_add_accelerator (menu->nieuw, "activate", menu->accel,
                                GDK_N, (GdkModifierType) GDK_CONTROL_MASK | GDK_MOD1_MASK,
                                GTK_ACCEL_VISIBLE);

    menu->dayselector = gtk_menu_item_new_with_mnemonic ("_Day Selector");
    gtk_widget_show (menu->dayselector);
    gtk_container_add (GTK_CONTAINER (amenu), menu->dayselector);
    gtk_widget_add_accelerator (menu->dayselector, "activate", menu->accel,
                                GDK_N, (GdkModifierType) GDK_CONTROL_MASK | GDK_MOD1_MASK,
                                GTK_ACCEL_VISIBLE);

    menu->vrienden = gtk_menu_item_new_with_mnemonic ("_Vrienden");
    gtk_widget_show (menu->vrienden);
    gtk_container_add (GTK_CONTAINER (amenu), menu->vrienden);
    gtk_widget_add_accelerator (menu->vrienden, "activate", menu->accel,
                                GDK_N, (GdkModifierType) GDK_CONTROL_MASK | GDK_MOD1_MASK,
                                GTK_ACCEL_VISIBLE);

    menu->mail = gtk_menu_item_new_with_mnemonic ("FTD _Mail");
    gtk_widget_show (menu->mail);
    gtk_container_add (GTK_CONTAINER (amenu), menu->mail);
    gtk_widget_add_accelerator (menu->mail, "activate", menu->accel,
                                GDK_M, (GdkModifierType) GDK_CONTROL_MASK | GDK_MOD1_MASK,
                                GTK_ACCEL_VISIBLE);

    menu->watchlist = gtk_menu_item_new_with_mnemonic ("_Watchlist");
    gtk_widget_show (menu->watchlist);
    gtk_container_add (GTK_CONTAINER (amenu), menu->watchlist);
    gtk_widget_add_accelerator (menu->watchlist, "activate", menu->accel,
                                GDK_W, (GdkModifierType) GDK_CONTROL_MASK | GDK_MOD1_MASK,
                                GTK_ACCEL_VISIBLE);

    menu->watcher = gtk_menu_item_new_with_mnemonic ("Watch_er");
    gtk_widget_show (menu->watcher);
    gtk_container_add (GTK_CONTAINER (amenu), menu->watcher);
    gtk_widget_add_accelerator (menu->watcher, "activate", menu->accel,
                                GDK_W, (GdkModifierType) GDK_CONTROL_MASK | GDK_MOD1_MASK,
                                GTK_ACCEL_VISIBLE);

    menu->modje = gtk_menu_item_new_with_mnemonic ("_Modje");
    gtk_widget_show (menu->modje);
    gtk_container_add (GTK_CONTAINER (amenu), menu->modje);

    menu->myftd = gtk_menu_item_new_with_mnemonic ("My_FTD");
    gtk_widget_show (menu->myftd);
    gtk_container_add (GTK_CONTAINER (amenu), menu->myftd);

#if 0
    menu->import = gtk_menu_item_new_with_mnemonic ("Importeer FTD 3.8 Database");
    gtk_widget_show (menu->import);
    gtk_container_add (GTK_CONTAINER (amenu), menu->import);
#endif

/*    menu->kudos = gtk_menu_item_new_with_mnemonic ("_Kudos overzicht");
    gtk_widget_show (menu->kudos);
    gtk_container_add (GTK_CONTAINER (amenu), menu->kudos);

    menu->gegevens = gtk_menu_item_new_with_mnemonic ("Mijn _Gegevens");
    gtk_widget_show (menu->gegevens);
    gtk_container_add (GTK_CONTAINER (amenu), menu->gegevens);
*/

    menu->refresh = gtk_menu_item_new_with_mnemonic("Refresh");
    gtk_widget_show(menu->refresh);
    gtk_container_add(GTK_CONTAINER (amenu), menu->refresh);

    menu->help = gtk_menu_item_new_with_mnemonic ("Help");
    gtk_widget_show (menu->help);
    gtk_container_add (GTK_CONTAINER (menu->widget), menu->help);

    amenu = gtk_menu_new ();
    gtk_menu_item_set_submenu (GTK_MENU_ITEM (menu->help), amenu);

    menu->about = gtk_menu_item_new_with_mnemonic ("About OpenFTD");
    gtk_widget_show (menu->about);
    gtk_container_add (GTK_CONTAINER (amenu), menu->about);

    g_signal_connect ((gpointer) menu->afsluiten, "activate",
                      G_CALLBACK (ftd_gui_callback_afsluiten), NULL);

    g_signal_connect ((gpointer) menu->updaten, "activate",
                      G_CALLBACK (ftd_gui_callback_updaten), NULL);

    g_signal_connect ((gpointer) menu->config, "activate",
                      G_CALLBACK (ftd_gui_callback_config), NULL);

    g_signal_connect ((gpointer) menu->mail, "activate",
                      G_CALLBACK (ftd_gui_callback_mail), NULL);

    g_signal_connect ((gpointer) menu->dayselector, "activate",
                      G_CALLBACK (ftd_gui_callback_dayselector), NULL);

    g_signal_connect ((gpointer) menu->vrienden, "activate",
                      G_CALLBACK (ftd_gui_callback_vrienden), NULL);

    g_signal_connect ((gpointer) menu->nieuw, "activate",
                      G_CALLBACK (ftd_gui_callback_nieuw), NULL);

    g_signal_connect ((gpointer) menu->watchlist, "activate",
                      G_CALLBACK (ftd_gui_callback_watchlist), NULL);

    g_signal_connect ((gpointer) menu->watcher, "activate",
                      G_CALLBACK (ftd_gui_callback_watcher), NULL);

    g_signal_connect ((gpointer) menu->myftd, "activate",
                      G_CALLBACK (ftd_gui_callback_myftd), NULL);

    g_signal_connect ((gpointer) menu->modje, "activate",
                      G_CALLBACK (ftd_gui_callback_modje), NULL);

#if 0
    g_signal_connect ((gpointer) menu->import, "activate",
                      G_CALLBACK (ftd_gui_callback_import), NULL);
#endif

    g_signal_connect ((gpointer) menu->refresh, "activate",
                      G_CALLBACK (ftd_gui_callback_refresh), NULL);

    g_signal_connect ((gpointer) menu->about, "activate",
                      G_CALLBACK (ftd_gui_callback_about), NULL);
}
