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

#include <Scintilla.h>
#include <SciLexer.h>
#define PLAT_GTK 1
#include <ScintillaWidget.h>
#include "fuser.h"

#include "editwindow.h"
// TODO 
// Create useful funcs in editwindow and call them from fuser.
// Add columns
// Add App level bar
//   Figure out what to do with FUSE command line parameters passed in on Apex cmd line
// focus border for each edit window
// Make drag button not get focus

// DONE
// Create edit-buffer struct and a list to hold them all
// Correct names to 'bar', etc from Acme paper
// Collect all the components into a single GtkWidget that is created with a single call
// Auto inject the base directory for the fuse location


int main(int argc, char **argv) {
  GtkWidget *app;

  gtk_init(&argc, &argv);
  app = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (app), "Apex");

  GtkWidget * vbox = gtk_vbox_new (FALSE, 0);  
  gtk_container_add (GTK_CONTAINER (app), vbox);

  GtkWidget * edit_window = apex_window_new(app);
  gtk_container_add (GTK_CONTAINER (vbox), edit_window);

  edit_window = apex_window_new(app);
  gtk_container_add (GTK_CONTAINER (vbox), edit_window);
 
  gtk_widget_show_all(app);
//  gtk_widget_grab_focus(GTK_WIDGET(bar));

  int fd = init_apex_fuse(argc, argv);
  if (fd > 0) { 
    GIOChannel * f = g_io_channel_unix_new(fd);
    g_io_add_watch(f, G_IO_IN, fuse_session_loop_middle, NULL);
  }
  
//  g_print("\nEditors list length [%d]\n", g_list_length(editors));

  gtk_main();
  finish_apex_fuse();

  return 0;
}
