[gnome-initial-setup/shell/4765: 293/362] Incorporate keyboard detection heuristic
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup/shell/4765: 293/362] Incorporate keyboard detection heuristic
- Date: Thu, 19 Mar 2015 01:45:42 +0000 (UTC)
commit 7b8dae6f5555917251af39671f8ba5276c85c55c
Author: Philip Chimento <philip endlessm com>
Date: Thu Dec 4 14:36:28 2014 -0800
Incorporate keyboard detection heuristic
Hooks up the dialog box ported in the previous commit to the keyboard
layout selection page. If the user clicks "Add" after the keyboard has
been guessed, it will be added to the list of keyboards on the page, and
automatically selected so that the "Next" button becomes active. If the
guessed layout was already in the list, it will still be selected.
(Roddy, Philip)
[endlessm/eos-shell#3425]
.../pages/keyboard/gis-keyboard-page.c | 46 +++++++++++++++++--
1 files changed, 41 insertions(+), 5 deletions(-)
---
diff --git a/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
b/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
index 0a01ba1..f95619e 100644
--- a/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
+++ b/gnome-initial-setup/pages/keyboard/gis-keyboard-page.c
@@ -35,6 +35,7 @@
#include "gis-keyboard-page.h"
#include "keyboard-resources.h"
#include "cc-input-chooser.h"
+#include "cc-keyboard-query.h"
#define GNOME_DESKTOP_USE_UNSTABLE_API
#include <libgnome-desktop/gnome-xkb-info.h>
@@ -955,11 +956,46 @@ show_selected_layout (GisKeyboardPage *self)
}
static void
-auto_detect (GisKeyboardPage *self)
+detector_response (GtkDialog *detector, gint response_id, gpointer data)
{
- GisKeyboardPagePrivate *priv = gis_keyboard_page_get_instance_private (self);
- /* TODO Incorporate the keyboard detection heuristic */
- printf("auto_detect\n");
+ GisKeyboardPage *self = data;
+ const char *type;
+ char *id;
+ char *name;
+
+ if (response_id == GTK_RESPONSE_OK)
+ {
+ if (cc_keyboard_query_get_selected (CC_KEYBOARD_QUERY (detector), &id, &name))
+ {
+ if (name == NULL)
+ name = g_strdup (id);
+ if (!input_source_already_added (self, id))
+ {
+ type = INPUT_SOURCE_TYPE_XKB;
+ add_input_row (self, type, id, name, NULL);
+ update_buttons (self);
+ update_input (self);
+ }
+ select_input (self, id);
+
+ g_free (id);
+ g_free (name);
+ }
+ }
+ gtk_widget_destroy (GTK_WIDGET (detector));
+}
+
+static void
+show_keyboard_detector (GisKeyboardPage *self)
+{
+ GisKeyboardPagePrivate *priv = gis_keyboard_page_get_instance_private (self);
+ GtkWidget *detector;
+ GtkWidget *toplevel;
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self));
+ detector = cc_keyboard_query_new (GTK_WINDOW (toplevel), priv->xkb_info);
+ g_signal_connect (detector, "response", G_CALLBACK (detector_response), self);
+ cc_keyboard_query_run (CC_KEYBOARD_QUERY (detector));
}
static void
@@ -1018,7 +1054,7 @@ setup_input_section (GisKeyboardPage *self)
g_signal_connect_swapped (priv->show_layout, "clicked",
G_CALLBACK (show_selected_layout), self);
g_signal_connect_swapped (priv->auto_detect, "clicked",
- G_CALLBACK (auto_detect), self);
+ G_CALLBACK (show_keyboard_detector), self);
egg_list_box_set_selection_mode (EGG_LIST_BOX (priv->input_list),
GTK_SELECTION_SINGLE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]