/* Erwann Chenede 2002 */

#include <config.h>

#include <string.h>
#include <gtk/gtk.h>
#include <gconf/gconf-client.h>
#include <gdk/gdkx.h>
#include <glade/glade.h>
#include <X11/Xatom.h>

#include "wm-common.h"
#include "capplet-util.h"
#include "eggcellrendererkeys.h"
#include "activate-settings-daemon.h"

#ifndef __CUSTOM_BINDING__H__
#define __CUSTOM_BINDING__H__

#define GCONF_CUSTOM_BINDING_DIR "/apps/gnome_settings_daemon/custom_keybindings"

typedef enum {
  ALWAYS_VISIBLE,
  N_WORKSPACES_GT
} KeyListEntryVisibility;

typedef struct
{
  const char *name;
  KeyListEntryVisibility visibility;
  gint data;
} KeyListEntry;

enum
{
  DESCRIPTION_COLUMN,
  KEYENTRY_COLUMN,
  N_COLUMNS
};

typedef struct
{
  char *gconf_key;
  guint keyval;
  guint keycode;
  EggVirtualModifierType mask;
  gboolean editable;
  GtkTreeModel *model;
  guint gconf_cnxn;
  gboolean custom_key;
  guint cmd_line_cnxn;
  char *action;
  char *binding;
  char *description;
} KeyEntry;

void
cmd_line_changed (GConfClient *client,
		  guint        cnxn_id,
		  GConfEntry  *entry,
		  gpointer     user_data);

void 
disable_custom (GtkWidget *widget, GtkTreeView *tree_view);

gboolean
grab_key_callback (GtkWidget    *widget,
                   GdkEventKey  *event,
                   void         *data);
void grab_key (GtkWidget *widget, GladeXML *dialog);

void custom_cancel (GtkWidget *widget, GladeXML *dialog);

void delete_event_cb (GtkWidget *widget, GdkEventAny *event, gpointer *user_data);

GladeXML *
setup_custom_binding_dialog ();

void 
add_custom (GtkWidget *widget);

void 
edit_custom (GtkWidget *widget);

void 
create_custom_bindings_list ();

KeyEntry *
custom_key_new (char *dir);

gboolean
is_gconf_key_custom_binding (char *key);

gboolean
keybinding_key_changed_foreach (GtkTreeModel *model,
				GtkTreePath  *path,
				GtkTreeIter  *iter,
				gpointer      user_data);

void
reload_key_entries (gpointer wm_name, GladeXML *dialog);
#endif /*__CUSTOM_BINDING__H__*/

