/*  gfocustimer
 *  Copyright (C) 1999 James Cameron, <quozl@us.netrek.org>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <string.h>
#include <gtk/gtk.h>

#include "callbacks.h"
#include "interface.h"
#include "support.h"
#include "utilities.h"

/*
 * Manual Window						********
 */


/* called when the Help - About menu item is selected */
void
on_Manual_activate                     (GtkMenuItem     *menuitem,
                                        gpointer         user_data)
{
  GtkWidget *widget;
  GtkText *text;
  char *data;
  int size;
  int zero = 0;

  /* create the manual page widget */
  widget = create_manual ();

  /* find the widget pointer for the GtkEntry widget */
  text = GTK_TEXT(lookup(widget, "manual_entry"));

  size = gtk_text_get_length(text);
  if (size > 0) gtk_editable_delete_text(GTK_EDITABLE(text), 0, size);

  /*
   * set the text for the manual window.
   *
   *	70 column by 120 line xterm with small font
   *	man ./gfocustimer.1
   *	cut & paste
   *	quote and add \n using an emacs keyboard macro
   */
  data = 
    "gfocustimer(1)\n"
    "\n"
    "NAME\n"
    "       gfocustimer - prepare timesheet from X window usage\n"
    "\n"
    "SYNOPSIS\n"
    "       gfocustimer\n"
    "\n"
    "DESCRIPTION\n"
    "       gfocustimer captures information about which windows you\n"
    "       are spending your time in, to assist with personal\n"
    "       scheduling and preparing timesheets.\n"
    "\n"
    "       gfocustimer displays a list of chargable tasks which con-\n"
    "       sist of an entry name and the time spent on the task.   It\n"
    "       can be used in a manual mode, where the user selects a new\n"
    "       entry, or in a semi-automatic focus watching mode, where\n"
    "       the user connects windows on screen to tasks.\n"
    "\n"
    "       How to use the \"Watch Focus\" mode?\n"
    "\n"
    "       Make Entries\n"
    "               Set  up a list of entries using the Entry - Create\n"
    "               menu option a few times.\n"
    "\n"
    "       Start Charging\n"
    "               Click on the Charge Time toggle button, and time\n"
    "               will start being charged to the first entry on the\n"
    "               list ... the green highlight will indicates which\n"
    "               entry is  being charged to.  (If another entry is\n"
    "               selected, time will be charged to that instead.\n"
    "               This is the manual mode.)\n"
    "\n"
    "       Start Focus\n"
    "               Click on the Watch Focus toggle button.  This\n"
    "               enables the semi-automatic focus watching mode.\n"
    "\n"
    "       Select Entry\n"
    "               Click on an entry in the list to select it.  It\n"
    "               will turn red, indicating that gfocustimer is\n"
    "               waiting for a window to be selected.\n"
    "\n"
    "       Select Window\n"
    "               Immediately select the window that is to be\n"
    "               charged to that entry.  The entry will change to\n"
    "               green from red, and a beep may be heard.\n"
    "\n"
    "       Repeat the process (from select an entry) for each window\n"
    "       that is to be assigned to an entry.  When you move between\n"
    "       windows, gfocustimer will detect the change and highlight\n"
    "       the appropriate entry.  If it does not know about the win-\n"
    "       dow, it will continue charging to the current entry.\n"
    "\n"
    "ENVIRONMENT\n"
    "       DISPLAY default host, display number, and screen.\n"
    "\n"
    "       HOME    login directory\n"
    "\n"
    "FILES\n"
    "       ~/.gfocustimer\n"
    "               contains files created by the program.\n"
    "\n"
    "       ~/.gfocustimer/names\n"
    "               list of entry names, one per line, as of last\n"
    "               save, which will be used by gfocustimer when it is\n"
    "               started on a new day.\n"
    "\n"
    "       ~/.gfocustimer/1999-10-03\n"
    "               per-day timesheet files, one file per day in date\n"
    "               order.   Contents of each file is a list of\n"
    "               entries, one line per entry, containing time in\n"
    "               seconds followed by a tab character, then the\n"
    "               entry name in quotes.  Designed to be post-pro-\n"
    "               cessed by other tools.\n"
    "\n"
    "AUTHOR\n"
    "       James Cameron, quozl@us.netrek.org\n";

  gtk_editable_insert_text(GTK_EDITABLE(text), data, strlen(data), &zero);

  gtk_widget_show (widget);
}


gboolean
on_manual_delete_event                 (GtkWidget       *widget,
                                        GdkEvent        *event,
                                        gpointer         user_data)
{
  gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET(widget)));
  return FALSE;
}


void
on_manual_ok_clicked                   (GtkButton       *button,
                                        gpointer         user_data)
{
  gtk_widget_destroy (gtk_widget_get_toplevel (GTK_WIDGET(button)));
}


