summaryrefslogtreecommitdiff
path: root/panels/keyboard/cc-keyboard-item.h
blob: afe99b6489cbc1078add15a549344fa298d18060 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
 *
 * Copyright (C) 2011 Red Hat, Inc.
 *
 * 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, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef __CC_KEYBOARD_ITEM_H
#define __CC_KEYBOARD_ITEM_H

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

G_BEGIN_DECLS

#define CC_TYPE_KEYBOARD_ITEM         (cc_keyboard_item_get_type ())
#define CC_KEYBOARD_ITEM(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), CC_TYPE_KEYBOARD_ITEM, CcKeyboardItem))
#define CC_KEYBOARD_ITEM_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), CC_TYPE_KEYBOARD_ITEM, CcKeyboardItemClass))
#define CC_IS_KEYBOARD_ITEM(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), CC_TYPE_KEYBOARD_ITEM))
#define CC_IS_KEYBOARD_ITEM_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), CC_TYPE_KEYBOARD_ITEM))
#define CC_KEYBOARD_ITEM_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), CC_TYPE_KEYBOARD_ITEM, CcKeyboardItemClass))

typedef enum
{
  BINDING_GROUP_SYSTEM,
  BINDING_GROUP_APPS,
  BINDING_GROUP_SEPARATOR,
  BINDING_GROUP_USER,
} BindingGroupType;

typedef enum {
	CC_KEYBOARD_ITEM_TYPE_NONE = 0,
	CC_KEYBOARD_ITEM_TYPE_GSETTINGS_PATH,
	CC_KEYBOARD_ITEM_TYPE_GSETTINGS
} CcKeyboardItemType;

typedef struct CcKeyboardItemPrivate CcKeyboardItemPrivate;

typedef struct
{
  GObject                parent;
  CcKeyboardItemPrivate *priv;

  /* Move to priv */
  CcKeyboardItemType type;

  /* common */
  /* FIXME move to priv? */
  guint keyval;
  guint keycode;
  BindingGroupType group;
  GdkModifierType mask;
  GtkTreeModel *model;
  char *description;
  gboolean editable;

  /* GSettings path */
  char *gsettings_path;
  gboolean desc_editable;
  char *command;
  gboolean cmd_editable;

  /* GSettings */
  char *schema;
  char *key;
  GSettings *settings;
} CcKeyboardItem;

typedef struct
{
  GObjectClass   parent_class;
} CcKeyboardItemClass;

GType              cc_keyboard_item_get_type (void);

CcKeyboardItem * cc_keyboard_item_new         (CcKeyboardItemType type);
gboolean cc_keyboard_item_load_from_gsettings_path (CcKeyboardItem *item,
					            const char     *path,
					            gboolean        reset);
gboolean cc_keyboard_item_load_from_gsettings (CcKeyboardItem *item,
					       const char *description,
					       const char *schema,
					       const char *key);

const char * cc_keyboard_item_get_description (CcKeyboardItem *item);
const char * cc_keyboard_item_get_command     (CcKeyboardItem *item);

gboolean     cc_keyboard_item_equal           (CcKeyboardItem *a,
					       CcKeyboardItem *b);

void         cc_keyboard_item_add_reverse_item (CcKeyboardItem *item,
						CcKeyboardItem *reverse_item,
						gboolean is_reversed);

CcKeyboardItem * cc_keyboard_item_get_reverse_item (CcKeyboardItem *item);
void             cc_keyboard_item_set_hidden       (CcKeyboardItem *item,
						    gboolean hidden);
gboolean         cc_keyboard_item_is_hidden        (CcKeyboardItem *item);

G_END_DECLS

#endif /* __CC_KEYBOARD_ITEM_H */