Commit 57975633 authored by Robert Ancell's avatar Robert Ancell Committed by Georges Basile Stavracas Neto

keyboard: Replace GObject boilerplace with G_DECLARE_TYPE

parent ed36688c
......@@ -28,20 +28,38 @@
#include "cc-keyboard-item.h"
#define CC_KEYBOARD_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_KEYBOARD_ITEM, CcKeyboardItemPrivate))
#define CUSTOM_KEYS_SCHEMA "org.gnome.settings-daemon.plugins.media-keys.custom-keybinding"
struct CcKeyboardItemPrivate
struct _CcKeyboardItem
{
/* properties */
/* common */
GObject parent_instance;
char *binding;
/* internal */
CcKeyboardItem *reverse_item;
gboolean is_reversed;
gboolean hidden;
CcKeyboardItemType type;
CcKeyCombo *primary_combo;
BindingGroupType group;
GtkTreeModel *model;
char *description;
gboolean editable;
GList *key_combos;
GList *default_combos;
/* GSettings path */
char *gsettings_path;
gboolean desc_editable;
char *command;
gboolean cmd_editable;
/* GSettings */
char *schema;
char *key;
GSettings *settings;
};
enum {
......@@ -117,6 +135,14 @@ cc_keyboard_item_get_description (CcKeyboardItem *item)
return item->description;
}
gboolean
cc_keyboard_item_get_desc_editable (CcKeyboardItem *item)
{
g_return_val_if_fail (CC_IS_KEYBOARD_ITEM (item), FALSE);
return item->desc_editable;
}
/* wrapper around g_settings_set_str[ing|v] */
static void
settings_set_binding (GSettings *settings,
......@@ -157,13 +183,13 @@ _set_binding (CcKeyboardItem *item,
CcKeyboardItem *reverse;
gboolean enabled;
reverse = item->priv->reverse_item;
reverse = item->reverse_item;
enabled = value && strlen (value) > 0;
g_clear_pointer (&item->priv->binding, g_free);
item->priv->binding = enabled ? g_strdup (value) : g_strdup ("");
g_clear_pointer (&item->binding, g_free);
item->binding = enabled ? g_strdup (value) : g_strdup ("");
binding_from_string (item->priv->binding, item->primary_combo);
binding_from_string (item->binding, item->primary_combo);
/*
* Always treat the pair (item, reverse) as a unit: setting one also
......@@ -176,26 +202,26 @@ _set_binding (CcKeyboardItem *item,
reverse_mask = enabled ? item->primary_combo->mask ^ GDK_SHIFT_MASK
: item->primary_combo->mask;
g_clear_pointer (&reverse->priv->binding, g_free);
g_clear_pointer (&reverse->binding, g_free);
if (enabled)
reverse->priv->binding = gtk_accelerator_name_with_keycode (NULL,
reverse->binding = gtk_accelerator_name_with_keycode (NULL,
item->primary_combo->keyval,
item->primary_combo->keycode,
reverse_mask);
binding_from_string (reverse->priv->binding, reverse->primary_combo);
binding_from_string (reverse->binding, reverse->primary_combo);
}
if (set_backend == FALSE)
return;
settings_set_binding (item->settings, item->key, item->priv->binding);
settings_set_binding (item->settings, item->key, item->binding);
g_object_notify (G_OBJECT (item), "is-value-default");
if (reverse)
{
settings_set_binding (reverse->settings, reverse->key, reverse->priv->binding);
settings_set_binding (reverse->settings, reverse->key, reverse->binding);
g_object_notify (G_OBJECT (reverse), "is-value-default");
}
}
......@@ -223,6 +249,14 @@ cc_keyboard_item_get_command (CcKeyboardItem *item)
return item->command;
}
gboolean
cc_keyboard_item_get_cmd_editable (CcKeyboardItem *item)
{
g_return_val_if_fail (CC_IS_KEYBOARD_ITEM (item), FALSE);
return item->cmd_editable;
}
static void
cc_keyboard_item_set_property (GObject *object,
guint prop_id,
......@@ -267,7 +301,7 @@ cc_keyboard_item_get_property (GObject *object,
g_value_set_string (value, self->description);
break;
case PROP_BINDING:
g_value_set_string (value, self->priv->binding);
g_value_set_string (value, self->binding);
break;
case PROP_EDITABLE:
g_value_set_boolean (value, self->editable);
......@@ -342,14 +376,11 @@ cc_keyboard_item_class_init (CcKeyboardItemClass *klass)
"is value default",
TRUE,
G_PARAM_READABLE));
g_type_class_add_private (klass, sizeof (CcKeyboardItemPrivate));
}
static void
cc_keyboard_item_init (CcKeyboardItem *item)
{
item->priv = CC_KEYBOARD_ITEM_GET_PRIVATE (item);
item->primary_combo = g_new0 (CcKeyCombo, 1);
}
......@@ -363,13 +394,11 @@ cc_keyboard_item_finalize (GObject *object)
item = CC_KEYBOARD_ITEM (object);
g_return_if_fail (item->priv != NULL);
if (item->settings != NULL)
g_object_unref (item->settings);
/* Free memory */
g_free (item->priv->binding);
g_free (item->binding);
g_free (item->primary_combo);
g_free (item->gsettings_path);
g_free (item->description);
......@@ -509,9 +538,9 @@ cc_keyboard_item_load_from_gsettings_path (CcKeyboardItem *item,
g_list_free_full (item->key_combos, g_free);
item->key_combos = settings_get_key_combos (item->settings, item->key, FALSE);
g_free (item->priv->binding);
item->priv->binding = settings_get_binding (item->settings, item->key);
binding_from_string (item->priv->binding, item->primary_combo);
g_free (item->binding);
item->binding = settings_get_binding (item->settings, item->key);
binding_from_string (item->binding, item->primary_combo);
g_signal_connect (G_OBJECT (item->settings), "changed::binding",
G_CALLBACK (binding_changed), item);
......@@ -531,10 +560,10 @@ cc_keyboard_item_load_from_gsettings (CcKeyboardItem *item,
item->description = g_strdup (description);
item->settings = g_settings_new (item->schema);
g_free (item->priv->binding);
item->priv->binding = settings_get_binding (item->settings, item->key);
g_free (item->binding);
item->binding = settings_get_binding (item->settings, item->key);
item->editable = g_settings_is_writable (item->settings, item->key);
binding_from_string (item->priv->binding, item->primary_combo);
binding_from_string (item->binding, item->primary_combo);
g_list_free_full (item->key_combos, g_free);
item->key_combos = settings_get_key_combos (item->settings, item->key, FALSE);
......@@ -576,36 +605,36 @@ cc_keyboard_item_add_reverse_item (CcKeyboardItem *item,
{
g_return_if_fail (item->key != NULL);
item->priv->reverse_item = reverse_item;
if (reverse_item->priv->reverse_item == NULL)
item->reverse_item = reverse_item;
if (reverse_item->reverse_item == NULL)
{
reverse_item->priv->reverse_item = item;
reverse_item->priv->is_reversed = !is_reversed;
reverse_item->reverse_item = item;
reverse_item->is_reversed = !is_reversed;
}
else
g_warn_if_fail (reverse_item->priv->is_reversed == !!is_reversed);
g_warn_if_fail (reverse_item->is_reversed == !!is_reversed);
item->priv->is_reversed = !!is_reversed;
item->is_reversed = !!is_reversed;
}
CcKeyboardItem *
cc_keyboard_item_get_reverse_item (CcKeyboardItem *item)
{
return item->priv->reverse_item;
return item->reverse_item;
}
void
cc_keyboard_item_set_hidden (CcKeyboardItem *item, gboolean hidden)
{
item->priv->hidden = !!hidden;
item->hidden = !!hidden;
}
gboolean
cc_keyboard_item_is_hidden (CcKeyboardItem *item)
{
return item->priv->hidden;
return item->hidden;
}
/**
......@@ -668,7 +697,7 @@ cc_keyboard_item_reset (CcKeyboardItem *self)
g_return_if_fail (CC_IS_KEYBOARD_ITEM (self));
reverse = self->priv->reverse_item;
reverse = self->reverse_item;
g_settings_reset (self->settings, self->key);
g_object_notify (G_OBJECT (self), "is-value-default");
......@@ -681,6 +710,63 @@ cc_keyboard_item_reset (CcKeyboardItem *self)
}
}
GList *
cc_keyboard_item_get_key_combos (CcKeyboardItem *item)
{
g_return_val_if_fail (CC_IS_KEYBOARD_ITEM (item), NULL);
return item->key_combos;
}
GList *
cc_keyboard_item_get_default_combos (CcKeyboardItem *item)
{
g_return_val_if_fail (CC_IS_KEYBOARD_ITEM (item), NULL);
return item->default_combos;
}
CcKeyCombo *
cc_keyboard_item_get_primary_combo (CcKeyboardItem *item)
{
g_return_val_if_fail (CC_IS_KEYBOARD_ITEM (item), NULL);
return item->primary_combo;
}
const gchar *
cc_keyboard_item_get_key (CcKeyboardItem *item)
{
g_return_val_if_fail (CC_IS_KEYBOARD_ITEM (item), NULL);
return item->key;
}
CcKeyboardItemType
cc_keyboard_item_get_item_type (CcKeyboardItem *item)
{
g_return_val_if_fail (CC_IS_KEYBOARD_ITEM (item), CC_KEYBOARD_ITEM_TYPE_NONE);
return item->type;
}
void
cc_keyboard_item_set_model (CcKeyboardItem *item, GtkTreeModel *model, BindingGroupType group)
{
g_return_if_fail (CC_IS_KEYBOARD_ITEM (item));
item->model = model;
item->group = group;
}
const gchar *
cc_keyboard_item_get_gsettings_path (CcKeyboardItem *item)
{
g_return_val_if_fail (CC_IS_KEYBOARD_ITEM (item), NULL);
return item->gsettings_path;
}
GSettings *
cc_keyboard_item_get_settings (CcKeyboardItem *item)
{
g_return_val_if_fail (CC_IS_KEYBOARD_ITEM (item), NULL);
return item->settings;
}
/*
* vim: sw=2 ts=8 cindent noai bs=2
*/
......@@ -25,12 +25,8 @@
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))
#define CC_TYPE_KEYBOARD_ITEM (cc_keyboard_item_get_type ())
G_DECLARE_FINAL_TYPE (CcKeyboardItem, cc_keyboard_item, CC, KEYBOARD_ITEM, GObject)
typedef enum
{
......@@ -52,45 +48,6 @@ typedef struct {
GdkModifierType mask;
} CcKeyCombo;
typedef struct CcKeyboardItemPrivate CcKeyboardItemPrivate;
typedef struct
{
GObject parent;
CcKeyboardItemPrivate *priv;
/* Move to priv */
CcKeyboardItemType type;
/* common */
/* FIXME move to priv? */
CcKeyCombo *primary_combo;
BindingGroupType group;
GtkTreeModel *model;
char *description;
gboolean editable;
GList *key_combos;
GList *default_combos;
/* 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,
......@@ -101,7 +58,9 @@ gboolean cc_keyboard_item_load_from_gsettings (CcKeyboardItem *item,
const char *key);
const char * cc_keyboard_item_get_description (CcKeyboardItem *item);
gboolean cc_keyboard_item_get_desc_editable (CcKeyboardItem *item);
const char * cc_keyboard_item_get_command (CcKeyboardItem *item);
gboolean cc_keyboard_item_get_cmd_editable (CcKeyboardItem *item);
gboolean cc_keyboard_item_equal (CcKeyboardItem *a,
CcKeyboardItem *b);
......@@ -119,6 +78,22 @@ gboolean cc_keyboard_item_is_value_default (CcKeyboardItem *self);
void cc_keyboard_item_reset (CcKeyboardItem *self);
GList * cc_keyboard_item_get_key_combos (CcKeyboardItem *self);
GList * cc_keyboard_item_get_default_combos (CcKeyboardItem *self);
CcKeyCombo * cc_keyboard_item_get_primary_combo (CcKeyboardItem *self);
const gchar * cc_keyboard_item_get_key (CcKeyboardItem *self);
CcKeyboardItemType cc_keyboard_item_get_item_type (CcKeyboardItem *self);
void cc_keyboard_item_set_model (CcKeyboardItem *self, GtkTreeModel *model, BindingGroupType group);
const gchar * cc_keyboard_item_get_gsettings_path (CcKeyboardItem *self);
GSettings * cc_keyboard_item_get_settings (CcKeyboardItem *self);
G_END_DECLS
#endif /* __CC_KEYBOARD_ITEM_H */
......@@ -94,7 +94,7 @@ find_conflict (CcUniquenessData *data,
if (data->orig_item && cc_keyboard_item_equal (data->orig_item, item))
return FALSE;
for (l = item->key_combos; l; l = l->next)
for (l = cc_keyboard_item_get_key_combos (item); l; l = l->next)
{
CcKeyCombo *combo = l->data;
......@@ -203,8 +203,8 @@ have_key_for_group (CcKeyboardManager *self,
{
CcKeyboardItem *item = g_ptr_array_index (keys, i);
if (item->type == CC_KEYBOARD_ITEM_TYPE_GSETTINGS &&
g_strcmp0 (name, item->key) == 0)
if (cc_keyboard_item_get_item_type (item) == CC_KEYBOARD_ITEM_TYPE_GSETTINGS &&
g_strcmp0 (name, cc_keyboard_item_get_key (item)) == 0)
{
return TRUE;
}
......@@ -259,7 +259,7 @@ add_shortcuts (CcKeyboardManager *self)
gtk_list_store_append (self->shortcuts_model, &new_row);
gtk_list_store_set (self->shortcuts_model,
&new_row,
DETAIL_DESCRIPTION_COLUMN, item->description,
DETAIL_DESCRIPTION_COLUMN, cc_keyboard_item_get_description (item),
DETAIL_KEYENTRY_COLUMN, item,
DETAIL_TYPE_COLUMN, SHORTCUT_TYPE_KEY_ENTRY,
-1);
......@@ -362,8 +362,7 @@ append_section (CcKeyboardManager *self,
}
cc_keyboard_item_set_hidden (item, keys_list[i].hidden);
item->model = shortcut_model;
item->group = group;
cc_keyboard_item_set_model (item, shortcut_model, group);
g_ptr_array_add (keys_array, item);
}
......@@ -753,8 +752,7 @@ cc_keyboard_manager_create_custom_shortcut (CcKeyboardManager *self)
settings_path = find_free_settings_path (self->binding_settings);
cc_keyboard_item_load_from_gsettings_path (item, settings_path, TRUE);
item->model = GTK_TREE_MODEL (self->shortcuts_model);
item->group = BINDING_GROUP_USER;
cc_keyboard_item_set_model (item, GTK_TREE_MODEL (self->shortcuts_model), BINDING_GROUP_USER);
return item;
}
......@@ -800,7 +798,7 @@ cc_keyboard_manager_add_custom_shortcut (CcKeyboardManager *self,
for (i = 0; settings_paths[i]; i++)
g_variant_builder_add (&builder, "s", settings_paths[i]);
g_variant_builder_add (&builder, "s", item->gsettings_path);
g_variant_builder_add (&builder, "s", cc_keyboard_item_get_gsettings_path (item));
g_settings_set_value (self->binding_settings, "custom-keybindings", g_variant_builder_end (&builder));
......@@ -827,6 +825,7 @@ cc_keyboard_manager_remove_custom_shortcut (CcKeyboardManager *self,
GPtrArray *keys_array;
GVariantBuilder builder;
gboolean valid;
GSettings *settings;
char **settings_paths;
int i;
......@@ -852,20 +851,21 @@ cc_keyboard_manager_remove_custom_shortcut (CcKeyboardManager *self,
/* Shortcut not found or not a custom shortcut */
g_assert (valid);
g_assert (item->type == CC_KEYBOARD_ITEM_TYPE_GSETTINGS_PATH);
g_settings_delay (item->settings);
g_settings_reset (item->settings, "name");
g_settings_reset (item->settings, "command");
g_settings_reset (item->settings, "binding");
g_settings_apply (item->settings);
g_assert (cc_keyboard_item_get_item_type (item) == CC_KEYBOARD_ITEM_TYPE_GSETTINGS_PATH);
settings = cc_keyboard_item_get_settings (item);
g_settings_delay (settings);
g_settings_reset (settings, "name");
g_settings_reset (settings, "command");
g_settings_reset (settings, "binding");
g_settings_apply (settings);
g_settings_sync ();
settings_paths = g_settings_get_strv (self->binding_settings, "custom-keybindings");
g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
for (i = 0; settings_paths[i]; i++)
if (strcmp (settings_paths[i], item->gsettings_path) != 0)
if (strcmp (settings_paths[i], cc_keyboard_item_get_gsettings_path (item)) != 0)
g_variant_builder_add (&builder, "s", settings_paths[i]);
g_settings_set_value (self->binding_settings,
......@@ -962,7 +962,7 @@ cc_keyboard_manager_reset_shortcut (CcKeyboardManager *self,
g_return_if_fail (CC_IS_KEYBOARD_ITEM (item));
/* Disables any shortcut that conflicts with the new shortcut's value */
for (l = item->default_combos; l; l = l->next)
for (l = cc_keyboard_item_get_default_combos (item); l; l = l->next)
{
CcKeyCombo *combo = l->data;
CcKeyboardItem *collision;
......
......@@ -29,8 +29,7 @@
G_BEGIN_DECLS
#define CC_TYPE_KEYBOARD_MANAGER (cc_keyboard_manager_get_type())
#define CC_TYPE_KEYBOARD_MANAGER (cc_keyboard_manager_get_type ())
G_DECLARE_FINAL_TYPE (CcKeyboardManager, cc_keyboard_manager, CC, KEYBOARD_MANAGER, GObject)
CcKeyboardManager* cc_keyboard_manager_new (void);
......
......@@ -49,8 +49,6 @@ enum
struct _CcKeyboardOption
{
GObject parent_object;
gchar *group;
gchar *description;
gchar *current_value;
......@@ -59,6 +57,8 @@ struct _CcKeyboardOption
const gchar * const *whitelist;
};
G_DEFINE_TYPE (CcKeyboardOption, cc_keyboard_option, G_TYPE_OBJECT);
static guint keyboard_option_signals[LAST_SIGNAL] = { 0 };
static GnomeXkbInfo *xkb_info = NULL;
......@@ -118,10 +118,6 @@ static const gchar *xkb_option_grp_whitelist[] = {
static GList *objects_list = NULL;
GType cc_keyboard_option_get_type (void);
G_DEFINE_TYPE (CcKeyboardOption, cc_keyboard_option, G_TYPE_OBJECT);
static gboolean
strv_contains (const gchar * const *strv,
const gchar *str)
......
......@@ -43,7 +43,7 @@ typedef struct {
struct _CcKeyboardPanel
{
CcPanel parent;
CcPanel parent_instance;
/* Search */
GtkWidget *empty_search_placeholder;
......@@ -113,7 +113,7 @@ transform_binding_to_accel (GBinding *binding,
gchar *accelerator;
item = CC_KEYBOARD_ITEM (g_binding_get_source (binding));
combo = item->primary_combo;
combo = cc_keyboard_item_get_primary_combo (item);
/* Embolden the label when the shortcut is modified */
if (!cc_keyboard_item_is_value_default (item))
......@@ -157,7 +157,7 @@ reset_all_shortcuts_cb (GtkWidget *widget,
data = g_object_get_data (G_OBJECT (widget), "data");
/* Don't reset custom shortcuts */
if (data->item->type == CC_KEYBOARD_ITEM_TYPE_GSETTINGS_PATH)
if (cc_keyboard_item_get_item_type (data->item) == CC_KEYBOARD_ITEM_TYPE_GSETTINGS_PATH)
return;
/* cc_keyboard_manager_reset_shortcut() already resets conflicting shortcuts,
......@@ -236,7 +236,7 @@ add_item (CcKeyboardPanel *self,
NULL);
/* Shortcut title */
label = gtk_label_new (item->description);
label = gtk_label_new (cc_keyboard_item_get_description (item));
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
gtk_label_set_line_wrap_mode (GTK_LABEL (label), PANGO_WRAP_WORD_CHAR);
......@@ -392,7 +392,7 @@ static gboolean
search_match_shortcut (CcKeyboardItem *item,
const gchar *search)
{
CcKeyCombo *combo = item->primary_combo;
CcKeyCombo *combo = cc_keyboard_item_get_primary_combo (item);
GStrv shortcut_tokens, search_tokens;
g_autofree gchar *normalized_accel = NULL;
g_autofree gchar *accel = NULL;
......@@ -452,9 +452,9 @@ sort_function (GtkListBoxRow *a,
b_data = g_object_get_data (G_OBJECT (b), "data");
/* Put custom shortcuts below everything else */
if (a_data->item->type == CC_KEYBOARD_ITEM_TYPE_GSETTINGS_PATH)
if (cc_keyboard_item_get_item_type (a_data->item) == CC_KEYBOARD_ITEM_TYPE_GSETTINGS_PATH)
return 1;
else if (b_data->item->type == CC_KEYBOARD_ITEM_TYPE_GSETTINGS_PATH)
else if (cc_keyboard_item_get_item_type (b_data->item) == CC_KEYBOARD_ITEM_TYPE_GSETTINGS_PATH)
return -1;
retval = g_strcmp0 (a_data->section_title, b_data->section_title);
......@@ -462,7 +462,7 @@ sort_function (GtkListBoxRow *a,
if (retval != 0)
return retval;
return g_strcmp0 (a_data->item->description, b_data->item->description);
return g_strcmp0 (cc_keyboard_item_get_description (a_data->item), cc_keyboard_item_get_description (b_data->item));
}
static void
......@@ -555,7 +555,7 @@ filter_function (GtkListBoxRow *row,
data = g_object_get_data (G_OBJECT (row), "data");
item = data->item;
name = cc_util_normalize_casefold_and_unaccent (item->description);
name = cc_util_normalize_casefold_and_unaccent (cc_keyboard_item_get_description (item));
search = cc_util_normalize_casefold_and_unaccent (gtk_entry_get_text (GTK_ENTRY (self->search_entry)));
terms = g_strsplit (search, " ", -1);
......
......@@ -27,8 +27,7 @@
G_BEGIN_DECLS
#define CC_TYPE_KEYBOARD_PANEL (cc_keyboard_panel_get_type())
#define CC_TYPE_KEYBOARD_PANEL (cc_keyboard_panel_get_type ())
G_DECLARE_FINAL_TYPE (CcKeyboardPanel, cc_keyboard_panel, CC, KEYBOARD_PANEL, CcPanel)
CcKeyboardItem* cc_keyboard_panel_create_custom_item (CcKeyboardPanel *self);
......
......@@ -152,7 +152,7 @@ apply_custom_item_fields (CcKeyboardShortcutEditor *self,
/* Only setup the binding when it was actually edited */
if (self->edited)
{
CcKeyCombo *combo = item->primary_combo;
CcKeyCombo *combo = cc_keyboard_item_get_primary_combo (item);
g_autofree gchar *binding = NULL;
combo->keycode = self->custom_combo->keycode;
......@@ -171,10 +171,10 @@ apply_custom_item_fields (CcKeyboardShortcutEditor *self,
}
/* Set the keyboard shortcut name and command for custom entries */
if (item->type == CC_KEYBOARD_ITEM_TYPE_GSETTINGS_PATH)
if (cc_keyboard_item_get_item_type (item) == CC_KEYBOARD_ITEM_TYPE_GSETTINGS_PATH)
{
g_settings_set_string (item->settings, "name", gtk_entry_get_text (GTK_ENTRY (self->name_entry)));
g_settings_set_string (item->settings, "command", gtk_entry_get_text (GTK_ENTRY (self->command_entry)));
g_settings_set_string (cc_keyboard_item_get_settings (item), "name", gtk_entry_get_text (GTK_ENTRY (self->name_entry)));
g_settings_set_string (cc_keyboard_item_get_settings (item), "command", gtk_entry_get_text (GTK_ENTRY (self->command_entry)));
}
}
......@@ -411,8 +411,8 @@ setup_custom_shortcut (CcKeyboardShortcutEditor *self)
collision_text = g_strdup_printf (_("%s is already being used for <b>%s</b>. If you "
"replace it, %s will be disabled"),
friendly_accelerator,
collision_item->description,
collision_item->description);
cc_keyboard_item_get_description (collision_item),
cc_keyboard_item_get_description (collision_item));
label = is_custom_shortcut (self) ? self->new_shortcut_conflict_label : self->shortcut_conflict_label;
......@@ -539,7 +539,7 @@ reset_item_clicked_cb (CcKeyboardShortcutEditor *self)
/* Reset first, then update the shortcut */
cc_keyboard_manager_reset_shortcut (self->manager, self->item);
combo = self->item->primary_combo;
combo = cc_keyboard_item_get_primary_combo (self->item);
accel = gtk_accelerator_name (combo->keyval, combo->mask);
gtk_shortcut_label_set_accelerator (GTK_SHORTCUT_LABEL (self->shortcut_accel_label), accel);
......@@ -565,8 +565,8 @@ setup_keyboard_item (CcKeyboardShortcutEditor *self,
if (!item)
return;
combo = item->primary_combo;
is_custom = item->type == CC_KEYBOARD_ITEM_TYPE_GSETTINGS_PATH;
combo = cc_keyboard_item_get_primary_combo (item);
is_custom = cc_keyboard_item_get_item_type (item) == CC_KEYBOARD_ITEM_TYPE_GSETTINGS_PATH;
accel = gtk_accelerator_name (combo->keyval, combo->mask);
/* To avoid accidentally thinking we unset the current keybinding, set the values
......@@ -587,7 +587,7 @@ setup_keyboard_item (CcKeyboardShortcutEditor *self,
gtk_widget_hide (self->replace_button);
/* Setup the top label */
text = g_strdup_printf (_("Enter new shortcut to change <b>%s</b>."), item->description);
text = g_strdup_printf (_("Enter new shortcut to change <b>%s</b>."), cc_keyboard_item_get_description (item));
gtk_label_set_markup (GTK_LABEL (self->top_info_label), text);
......@@ -611,12 +611,12 @@ setup_keyboard_item (CcKeyboardShortcutEditor *self,
g_signal_handlers_block_by_func (self->name_entry, name_entry_changed_cb, self);
/* Name entry */
gtk_entry_set_text (GTK_ENTRY (self->name_entry), item->description);
gtk_widget_set_sensitive (self->name_entry, item->desc_editable);
gtk_entry_set_text (GTK_ENTRY (self->name_entry), cc_keyboard_item_get_description (item));
gtk_widget_set_sensitive (self->name_entry, cc_keyboard_item_get_desc_editable (item));
/* Command entry */
gtk_entry_set_text (GTK_ENTRY (self->command_entry), item->command);
gtk_widget_set_sensitive (self->command_entry, item->cmd_editable);
gtk_entry_set_text (GTK_ENTRY (self->command_entry), cc_keyboard_item_get_command (item));
gtk_widget_set_sensitive (self->command_entry, cc_keyboard_item_get_cmd_editable (item));
/* If there is no accelerator set for this custom shortcut, show the "Set Shortcut" button. */
is_accel_empty = !accel || accel[0] == '\0';
......@@ -808,7 +808,7 @@ grab_idle (gpointer data)
{
CcKeyboardShortcutEditor *self = data;
if (self->item && self->item->type != CC_KEYBOARD_ITEM_TYPE_GSETTINGS_PATH)
if (self->item && cc_keyboard_item_get_item_type (self->item) != CC_KEYBOARD_ITEM_TYPE_GSETTINGS_PATH)
grab_seat (self);
self->grab_idle_id = 0;
......
......@@ -28,7 +28,8 @@
G_BEGIN_DECLS
#define CC_TYPE_KEYBOARD_SHORTCUT_EDITOR (cc_keyboard_shortcut_editor_get_type())
#define CC_TYPE_KEYBOARD_SHORTCUT_EDITOR (cc_keyboard_shortcut_editor_get_type ())
G_DECLARE_FINAL_TYPE (CcKeyboardShortcutEditor, cc_keyboard_shortcut_editor, CC, KEYBOARD_SHORTCUT_EDITOR, GtkDialog)
typedef enum
{
......@@ -36,8 +37,6 @@ typedef enum
CC_SHORTCUT_EDITOR_EDIT
} CcShortcutEditorMode;
G_DECLARE_FINAL_TYPE (CcKeyboardShortcutEditor, cc_keyboard_shortcut_editor, CC, KEYBOARD_SHORTCUT_EDITOR, GtkDialog)
GtkWidget* cc_keyboard_shortcut_editor_new (CcKeyboardManager *manager);