[gnome-control-center/wip/gbsneto/new-keyboard-panel: 9/9] wip on reversible shortcuts
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/gbsneto/new-keyboard-panel: 9/9] wip on reversible shortcuts
- Date: Fri, 15 Jul 2016 15:51:02 +0000 (UTC)
commit 609b85fbf16c0e87000b766aec857a248ff79013
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Fri Jul 15 12:49:24 2016 -0300
wip on reversible shortcuts
panels/keyboard/cc-keyboard-panel.c | 61 ++++++++++++++++++++++++++++++++--
1 files changed, 57 insertions(+), 4 deletions(-)
---
diff --git a/panels/keyboard/cc-keyboard-panel.c b/panels/keyboard/cc-keyboard-panel.c
index 2d4b106..919b952 100644
--- a/panels/keyboard/cc-keyboard-panel.c
+++ b/panels/keyboard/cc-keyboard-panel.c
@@ -61,6 +61,11 @@ enum {
PROP_PARAMETERS
};
+static const gchar* custom_css =
+"button.revert-shortcut-button {"
+" padding: 0;"
+"}";
+
/*
* RowData functions
*/
@@ -102,7 +107,25 @@ transform_binding_to_accel (GBinding *binding,
item = CC_KEYBOARD_ITEM (g_binding_get_source (binding));
- accelerator = convert_keysym_state_to_string (item->keyval, item->mask, item->keycode);
+ /* Bold the label when the binding can be reverted */
+ if (cc_keyboard_item_get_reverse_item (item))
+ {
+ gchar *tmp;
+
+ tmp = convert_keysym_state_to_string (item->keyval,
+ item->mask,
+ item->keycode);
+
+ accelerator = g_strdup_printf ("<b>%s</b>", tmp);
+
+ g_free (tmp);
+ }
+ else
+ {
+ accelerator = convert_keysym_state_to_string (item->keyval,
+ item->mask,
+ item->keycode);
+ }
g_value_set_string (to_value, accelerator);
@@ -117,11 +140,17 @@ add_item (CcKeyboardPanel *self,
const gchar *section_id,
const gchar *section_title)
{
- GtkWidget *row, *box, *label;
+ GtkWidget *row, *box, *label, *revert_button;
/* Horizontal box */
- box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
- gtk_container_set_border_width (GTK_CONTAINER (box), 6);
+ box = g_object_new (GTK_TYPE_BOX,
+ "orientation", GTK_ORIENTATION_HORIZONTAL,
+ "spacing", 18,
+ "margin-start", 6,
+ "margin-end", 6,
+ "margin-bottom", 4,
+ "margin-top", 4,
+ NULL);
/* Shortcut title */
label = gtk_label_new (item->description);
@@ -139,6 +168,7 @@ add_item (CcKeyboardPanel *self,
/* Shortcut accelerator */
label = gtk_label_new ("");
+ gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
g_object_bind_property_full (item,
"binding",
@@ -152,6 +182,18 @@ add_item (CcKeyboardPanel *self,
gtk_style_context_add_class (gtk_widget_get_style_context (label), "dim-label");
+ /* Revert shortcut button */
+ revert_button = gtk_button_new_from_icon_name ("window-close-symbolic", GTK_ICON_SIZE_BUTTON);
+
+ gtk_button_set_relief (GTK_BUTTON (revert_button), GTK_RELIEF_NONE);
+ gtk_widget_set_child_visible (revert_button, cc_keyboard_item_get_reverse_item (item) != NULL);
+
+ gtk_container_add (GTK_CONTAINER (box), revert_button);
+
+ gtk_style_context_add_class (gtk_widget_get_style_context (revert_button), "flat");
+ gtk_style_context_add_class (gtk_widget_get_style_context (revert_button), "circular");
+ gtk_style_context_add_class (gtk_widget_get_style_context (revert_button), "revert-shortcut-button");
+
/* The row */
row = gtk_list_box_row_new ();
gtk_container_add (GTK_CONTAINER (row), box);
@@ -392,11 +434,22 @@ cc_keyboard_panel_class_init (CcKeyboardPanelClass *klass)
static void
cc_keyboard_panel_init (CcKeyboardPanel *self)
{
+ GtkCssProvider *provider;
g_resources_register (cc_keyboard_get_resource ());
gtk_widget_init_template (GTK_WIDGET (self));
+ /* Custom CSS */
+ provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (provider, custom_css, -1, NULL);
+
+ gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION + 1);
+
+ g_object_unref (provider);
+
/* Shortcut manager */
self->manager = cc_keyboard_manager_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]