;;; -*- scheme -*-
;;; gnome.defs - Export Gnome interfaces to Guile.
;;; 
;;; Copyright (C) 1998 Tom Tromey
;;; 
;;; 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, 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.  */

(import "gtk.defs")

;;
;; Gnome util.
;;

(define-func gnome_libdir_file
  string
  ((string filename)))

(define-func gnome_datadir_file
  string
  ((string filename)))

(define-func gnome_pixmap_file
  string
  ((string filename)))

(define-func gnome_unconditional_libdir_file
  string
  ((string filename)))

(define-func gnome_unconditional_datadir_file
  string
  ((string filename)))

(define-func gnome_unconditional_pixmap_file
  string
  ((string filename)))

;;
;; Gnome config.
;; FIXME: iterators and _with_default functions not included.
;;

(define-func gnome_config_get_string
  string
  ((string path)))

(define-func gnome_config_get_int
  int
  ((string path)))

(define-func gnome_config_get_bool
  bool
  ((string path)))

(define-func gnome_config_set_string
  none
  ((string path)
   (string value)))

(define-func gnome_config_set_int
  none
  ((string path)
   (int value)))

(define-func gnome_config_set_bool
  none
  ((string path)
   (bool value)))

(define-func gnome_config_has_section
  bool
  ((string path)))

(define-func gnome_config_drop_all
  none
  ())

(define-func gnome_config_sync
  none
  ())

(define-func gnome_config_clean_file
  none
  ((string path)))

(define-func gnome_config_clean_section
  none
  ((string path)))

(define-func gnome_config_clean_key
  none
  ((string path)))

(define-func gnome_config_push_prefix
  none
  ((string path)))

(define-func gnome_config_pop_prefix
  none
  ())

;;
;; GnomeApp.
;;

(define-enum GnomeAppWidgetPositionType
  (top GNOME_APP_POS_TOP)
  (bottom GNOME_APP_POS_BOTTOM)
  (left GNOME_APP_POS_LEFT)
  (right GNOME_APP_POS_RIGHT)
  (floating GNOME_APP_POS_FLOATING))

(define-object GnomeApp (GtkWindow))

(define-func gnome_app_new
  GtkWidget
  ((string appname)
   (string title)))

(define-func gnome_app_set_menus
  none
  ((GnomeApp app)
   (GtkMenuBar menubar)))

(define-func gnome_app_set_toolbar
  none
  ((GnomeApp app)
   (GtkToolbar toolbar)))

(define-func gnome_app_toolbar_set_position
  none
  ((GnomeApp app)
   (GnomeAppWidgetPositionType pos_toolbar)))

(define-func gnome_app_menu_set_position
  none
  ((GnomeApp app)
   (GnomeAppWidgetPositionType pos_menu)))


;;
;; History.
;; FIXME: other functions done by hand due to build-guile-gtk limitations.
;;

(define-func gnome_history_recently_used
  none
  ((string filename)
   (string filetype)
   (string creator)
   (string desc)))


;;
;; Stock widgets.
;;

(define-string-enum GnomeStockButtonNameType
  (ok GNOME_STOCK_BUTTON_OK)
  (cancel GNOME_STOCK_BUTTON_CANCEL)
  (yes GNOME_STOCK_BUTTON_YES)
  (no GNOME_STOCK_BUTTON_NO)
  (close GNOME_STOCK_BUTTON_CLOSE)
  (apply GNOME_STOCK_BUTTON_APPLY)
  (help GNOME_STOCK_BUTTON_HELP))

(define-string-enum GnomeStockMenuNameType
  (blank GNOME_STOCK_MENU_BLANK)
  (new GNOME_STOCK_MENU_NEW)
  (save GNOME_STOCK_MENU_SAVE)
  (save-as GNOME_STOCK_MENU_SAVE_AS)
  (open GNOME_STOCK_MENU_OPEN)
  (quit GNOME_STOCK_MENU_QUIT)
  (cut GNOME_STOCK_MENU_CUT)
  (copy GNOME_STOCK_MENU_COPY)
  (paste GNOME_STOCK_MENU_PASTE)
  (prop GNOME_STOCK_MENU_PROP)
  (pref GNOME_STOCK_MENU_PREF)
  (about GNOME_STOCK_MENU_ABOUT)
  (scores GNOME_STOCK_MENU_SCORES)
  (undo GNOME_STOCK_MENU_UNDO)
  (print GNOME_STOCK_MENU_PRINT)
  (search GNOME_STOCK_MENU_SEARCH)
  (back GNOME_STOCK_MENU_BACK)
  (forward GNOME_STOCK_MENU_FORWARD)
  (home GNOME_STOCK_MENU_HOME)
  (stop GNOME_STOCK_MENU_STOP)
  (refresh GNOME_STOCK_MENU_REFRESH)
  (mail GNOME_STOCK_MENU_MAIL)
  (mail-receive GNOME_STOCK_MENU_MAIL_RCV)
  (mail-send GNOME_STOCK_MENU_MAIL_SND)
  (trash GNOME_STOCK_MENU_TRASH)
  (trash-full GNOME_STOCK_MENU_TRASH_FULL)
  ;; This is an alias for Quit for now.
  (exit GNOME_STOCK_MENU_QUIT))

(define-func gnome_stock_button
  GtkWidget
  ((GnomeStockButtonNameType type)))

(define-func gnome_stock_or_ordinary_button
  GtkWidget
  ((GnomeStockButtonNameType type)))

(define-func gnome_stock_menu_item
  GtkWidget
  ((GnomeStockMenuNameType type)
   (string text)))

;;
;; Messagebox.
;;

(define-object GnomeMessageBox (GtkWindow)
  ;; FIXME: can't represent contents.
  )

; gnome_message_box_new

(define-func gnome_message_box_set_modal
  none
  ((GnomeMessageBox message_box)))

(define-func gnome_message_box_set_default
  none
  ((GnomeMessageBox message_box)
   (int button)))


;;
;; Property box.
;;

(define-object GnomePropertyBox (GtkWindow)
  (fields 
   (GtkWidget notebook)
   (GtkWidget ok_button)
   (GtkWidget apply_button)
   (GtkWidget cancel_button)
   (GtkWidget help_button)
   ;; FIXME: can't represent `items'.
   )
  )

(define-func gnome_property_box_new
  GtkWidget
  ())

(define-func gnome_property_box_changed
  none
  ((GnomePropertyBox box)))

(define-func gnome_property_box_append_page
  int
  ((GnomePropertyBox box)
   (GtkWidget child)
   (GtkWidget tab_label)))



;;
;; Client code.
;; FIXME: Some functions still live in client.c, until argc/argv supported.
;;

(define-enum GnomeInteractStyle
  (none GNOME_INTERACT_NONE)
  (errors GNOME_INTERACT_ERRORS)
  (any GNOME_INTERACT_ANY))

(define-enum GnomeDialogType
  (error GNOME_DIALOG_ERROR)
  (normal GNOME_DIALOG_NORMAL))

(define-enum GnomeSaveStyle
  (global GNOME_SAVE_GLOBAL)
  (local GNOME_SAVE_LOCAL)
  (both GNOME_SAVE_BOTH))

(define-enum GnomeRestartStyle
  (if-running GNOME_RESTART_IF_RUNNING)
  (anyway GNOME_RESTART_ANYWAY)
  (immediately GNOME_RESTART_IMMEDIATELY)
  (never GNOME_RESTART_NEVER))

(define-object GnomeClient (GtkObject))

(define-func gnome_client_new_default
  GnomeClient
  ())

(define-func gnome_client_new
  GnomeClient
  ())

(define-func gnome_client_new_without_connection
  GnomeClient
  ())

(define-func gnome_client_connect
  none
  ((GnomeClient client)))

(define-func gnome_client_disconnect
  none
  ((GnomeClient client)))

(define-func gnome_client_flush
  none
  ((GnomeClient client)))

(define-func gnome_client_set_id
  none
  ((GnomeClient client)
   (string id)))

; gnome_client_set_clone_command

(define-func gnome_client_set_current_directory
  none
  ((GnomeClient client)
   (string dir)))     

; gnome_client_set_environment

(define-func gnome_client_set_process_id
  none
  ((GnomeClient client)
   (int id)))

(define-func gnome_client_set_program
  none
  ((GnomeClient client)
   (string program)))

; gnome_client_set_restart_command

; gnome_client_set_resign_command

(define-func gnome_client_set_restart_style
  none
  ((GnomeClient client)
   (GnomeRestartStyle style)))    

; gnome_client_set_shutdown_command

(define-func gnome_client_set_user_id
  none
  ((GnomeClient client)
   (string id)))

(define-func gnome_client_request_phase_2
  none
  ((GnomeClient client)))

(define-func gnome_client_request_save
  none
  ((GnomeClient client)
   (GnomeSaveStyle save_style)
   (bool shutdown)
   (GnomeInteractStyle interact_style)
   (bool fast)
   (bool global)))

(define-func gnome_client_request_interaction_interp
  none
  ((GnomeClient client)
   (GnomeDialogType dialog_type)
   (callback function)))

(define-func gnome_interaction_key_return
  none
  ((int key)
   (bool cancel_shutdown)))

;; Canvas test

(define-object GnomeCanvas (GtkContainer))

(define-object GnomeCanvasItem (GtkObject)
  (fields
   (GnomeCanvas canvas)
   (GnomeCanvasItem parent)
   (int x1)
   (int y1)
   (int x2)
   (int y2)))

(define-object GnomeCanvasGroup (GnomeCanvasItem)
  (fields
   (double xpos)
   (double ypos)))

;; XXX - build-guile-gtk needs varargs and GtkType to support these.
;; For now, there are `hand tweaked' versions in gnomeg.c

;;(define-func gnome_canvas_item_new
;;  GnomeCanvasItem
;;  ((GnomeCanvas canvas)
;;   (GnomeCanvasGroup group)
;;   (GtkType type)
;;   (args ...)))

;;(define-func gnome_canvas_item_set
;;  none
;;  ((GnomeCanvasItem item)
;;   (args ...)))

(define-func gnome_canvas_item_move
  none
  ((GnomeCanvasItem canvas)
   (double dx)
   (double dy)))

(define-func gdk_imlib_get_visual
  GdkVisual
  ())

(define-func gdk_imlib_get_colormap
  GdkColormap
  ())

(define-func gnome_canvas_new
  GtkWidget
  ())

(define-func gnome_canvas_root
  GnomeCanvasItem
  ((GnomeCanvas canvas)))

(define-func gnome_canvas_set_size
  none
  ((GnomeCanvas canvas)
   (int width)
   (int height)))

(define-func gnome_canvas_update_now
  none
  ((GnomeCanvas canvas)))

(define-func gnome_canvas_set_pixels_per_unit
  none
  ((GnomeCanvas canvas)
   (double n)))

(define-object GnomeCanvasRE (GnomeCanvasItem))
(define-object GnomeCanvasRect (GnomeCanvasRE))
(define-object GnomeCanvasEllipse (GnomeCanvasRE))
