summaryrefslogtreecommitdiff
path: root/panels/wacom/cc-wacom-page.c
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2012-12-20 12:07:00 +0100
committerBastien Nocera <hadess@hadess.net>2012-12-20 12:07:00 +0100
commit7d147e06a660a7ad1ddd1e3cc3f26506d6043ac0 (patch)
treea925672153707384cdba53cdbe63731de85db4a3 /panels/wacom/cc-wacom-page.c
parentf5e8101dbdac3d4287119e57c1219da74cfab216 (diff)
downloadgnome-control-center-7d147e06a660a7ad1ddd1e3cc3f26506d6043ac0.tar.gz
wacom: Clean up action type sanity check
Diffstat (limited to 'panels/wacom/cc-wacom-page.c')
-rw-r--r--panels/wacom/cc-wacom-page.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/panels/wacom/cc-wacom-page.c b/panels/wacom/cc-wacom-page.c
index 5c91c3988..2bb6fa98f 100644
--- a/panels/wacom/cc-wacom-page.c
+++ b/panels/wacom/cc-wacom-page.c
@@ -277,6 +277,17 @@ calibrate_button_clicked_cb (GtkButton *button,
gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
}
+/* This avoids us crashing when a newer version of
+ * gnome-control-center has been used, and we load up an
+ * old one, as the action type if unknown to the old g-c-c */
+static gboolean
+action_type_is_valid (GsdWacomActionType type)
+{
+ if (type >= G_N_ELEMENTS(action_table))
+ return FALSE;
+ return TRUE;
+}
+
static char *
get_elevator_shortcut_string (GSettings *settings,
GtkDirectionType dir)
@@ -613,8 +624,7 @@ add_button_to_store (GtkListStore *model,
dir_name = NULL;
}
- /* Sanity check */
- if (type >= G_N_ELEMENTS(action_table))
+ if (action_type_is_valid (type) == FALSE)
type = GSD_WACOM_ACTION_TYPE_NONE;
gtk_list_store_append (model, &new_row);
@@ -671,8 +681,7 @@ action_set_func (GtkTreeViewColumn *tree_column,
}
type = g_settings_get_enum (button->settings, ACTION_TYPE_KEY);
- /* Sanity check */
- if (type >= G_N_ELEMENTS(action_table))
+ if (action_type_is_valid (type) == FALSE);
type = GSD_WACOM_ACTION_TYPE_NONE;
g_object_set (cell,