Commit a0a15588 authored by Georges Basile Stavracas Neto's avatar Georges Basile Stavracas Neto
Browse files

keyboard: introduce CcKeyboardShortcutEditor

The current CcKeyboardPanel used to manage keyboard
editing through GtkCellRendererAccel, which was replaced
when we moved to use a GtkListBox. Because of that,
the ability to edit shortcuts is now missing.

Re-add shortcut editing capabilities through a new dialog,
which is done according to the latest mockups available.

https://bugzilla.gnome.org/show_bug.cgi?id=769063
parent 847fe447
......@@ -15,6 +15,8 @@ libkeyboard_la_SOURCES = \
cc-keyboard-item.h \
cc-keyboard-option.c \
cc-keyboard-option.h \
cc-keyboard-shortcut-editor.c \
cc-keyboard-shortcut-editor.h \
wm-common.c \
wm-common.h \
keyboard-shortcuts.c \
......
This diff is collapsed.
......@@ -31,6 +31,8 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (CcKeyboardPanel, cc_keyboard_panel, CC, KEYBOARD_PANEL, CcPanel)
CcKeyboardItem* cc_keyboard_panel_create_custom_item (CcKeyboardPanel *self);
G_END_DECLS
#endif /* _CC_KEYBOARD_PANEL_H */
This diff is collapsed.
/* cc-keyboard-shortcut-editor.h
*
* Copyright (C) 2016 Endless, 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/>.
*
* Authors: Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
*/
#ifndef CC_KEYBOARD_SHORTCUT_EDITOR_H
#define CC_KEYBOARD_SHORTCUT_EDITOR_H
#include <gtk/gtk.h>
#include "cc-keyboard-item.h"
#include "cc-keyboard-panel.h"
G_BEGIN_DECLS
#define CC_TYPE_KEYBOARD_SHORTCUT_EDITOR (cc_keyboard_shortcut_editor_get_type())
typedef enum
{
CC_SHORTCUT_EDITOR_CREATE,
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 (CcKeyboardPanel *panel);
CcKeyboardItem* cc_keyboard_shortcut_editor_get_item (CcKeyboardShortcutEditor *self);
void cc_keyboard_shortcut_editor_set_item (CcKeyboardShortcutEditor *self,
CcKeyboardItem *item);
CcShortcutEditorMode cc_keyboard_shortcut_editor_get_mode (CcKeyboardShortcutEditor *self);
void cc_keyboard_shortcut_editor_set_mode (CcKeyboardShortcutEditor *self,
CcShortcutEditorMode mode);
G_END_DECLS
#endif /* CC_KEYBOARD_SHORTCUT_EDITOR_H */
......@@ -8,150 +8,6 @@
<property name="step_increment">200</property>
<property name="page_increment">200</property>
</object>
<object class="GtkDialog" id="custom_shortcut_dialog">
<property name="can_focus">False</property>
<property name="type_hint">dialog</property>
<property name="use_header_bar">1</property>
<property name="resizable">False</property>
<child internal-child="headerbar">
<object class="GtkHeaderBar" id="dialog-header-bar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">Custom Shortcut</property>
<property name="show_close_button">False</property>
<child>
<object class="GtkButton" id="custom_shortcut_cancel_button">
<property name="label" translatable="yes">_Cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="valign">center</property>
<style>
<class name="text-button"/>
</style>
</object>
<packing>
<property name="pack_type">start</property>
</packing>
</child>
<child>
<object class="GtkButton" id="custom_shortcut_ok_button">
<property name="label" translatable="yes">_Add</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
<property name="receives_default">False</property>
<property name="use_action_appearance">False</property>
<property name="use_underline">True</property>
<property name="valign">center</property>
<property name="sensitive">False</property>
<style>
<class name="text-button"/>
<class name="suggested-action"/>
</style>
</object>
<packing>
<property name="pack_type">end</property>
</packing>
</child>
</object>
</child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="spacing">6</property>
<child>
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_spacing">6</property>
<property name="column_spacing">6</property>
<child>
<object class="GtkLabel" id="label13">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Name:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">custom_shortcut_name_entry</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">C_ommand:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">custom_shortcut_command_entry</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="custom_shortcut_name_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="invisible_char"></property>
<property name="activates_default">True</property>
<signal name="changed" handler="shortcut_entry_changed" object="CcKeyboardPanel" swapped="no" />
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="custom_shortcut_command_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="invisible_char"></property>
<property name="activates_default">True</property>
<signal name="changed" handler="shortcut_entry_changed" object="CcKeyboardPanel" swapped="no" />
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-6">custom_shortcut_cancel_button</action-widget>
<action-widget response="-5">custom_shortcut_ok_button</action-widget>
</action-widgets>
</object>
<template class="CcKeyboardPanel" parent="CcPanel">
<property name="visible">True</property>
<property name="can_focus">False</property>
......
......@@ -2,5 +2,6 @@
<gresources>
<gresource prefix="/org/gnome/control-center/keyboard">
<file preprocess="xml-stripblanks">gnome-keyboard-panel.ui</file>
<file preprocess="xml-stripblanks">shortcut-editor.ui</file>
</gresource>
</gresources>
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.20"/>
<template class="CcKeyboardShortcutEditor" parent="GtkDialog">
<property name="can_focus">False</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="width_request">400</property>
<property name="height_request">300</property>
<property name="window_position">center</property>
<property name="type_hint">dialog</property>
<signal name="delete-event" handler="gtk_widget_hide_on_delete" object="CcKeyboardShortcutEditor" swapped="yes"/>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkStack" id="stack">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="border_width">12</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">18</property>
<child>
<object class="GtkLabel" id="top_info_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="wrap">True</property>
<property name="wrap_mode">word-char</property>
<property name="width_chars">15</property>
<property name="max_width_chars">20</property>
</object>
</child>
<child>
<object class="GtkShortcutLabel" id="shortcut_accel_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="disabled-text" translatable="yes">Disabled</property>
</object>
</child>
<child>
<object class="GtkButton" id="reset_button">
<property name="label" translatable="yes">Reset</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="halign">end</property>
</object>
</child>
</object>
<packing>
<property name="name">edit</property>
</packing>
</child>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="row_spacing">12</property>
<property name="column_spacing">12</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Name</property>
<property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Command</property>
<property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Shortcut</property>
<property name="xalign">1</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="new_shortcut_conflict_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="wrap">True</property>
<property name="wrap_mode">word-char</property>
<property name="width_chars">15</property>
<property name="max_width_chars">20</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="name_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="sensitive" bind-source="edit_button" bind-property="active" bind-flags="default|invert-boolean" />
<signal name="notify::text" handler="name_entry_changed_cb" object="CcKeyboardShortcutEditor" swapped="yes" />
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="command_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="sensitive" bind-source="edit_button" bind-property="active" bind-flags="default|invert-boolean" />
<signal name="notify::text" handler="command_entry_changed_cb" object="CcKeyboardShortcutEditor" swapped="yes" />
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkToggleButton" id="edit_button">
<property name="label" translatable="yes">Edit</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="notify::active" handler="edit_custom_shortcut_button_toggled_cb" object="CcKeyboardShortcutEditor" swapped="yes" />
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkShortcutLabel" id="custom_shortcut_accel_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="disabled-text" translatable="yes">None</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="remove_button">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Remove</property>
<property name="valign">end</property>
<property name="sensitive" bind-source="edit_button" bind-property="active" bind-flags="default|invert-boolean" />
<signal name="clicked" handler="remove_button_clicked_cb" object="CcKeyboardShortcutEditor" swapped="yes" />
<style>
<class name="destructive-action" />
</style>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">3</property>
</packing>
</child>
</object>
<packing>
<property name="name">custom</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child type="titlebar">
<object class="GtkHeaderBar" id="headerbar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="show_close_button">True</property>
<child>
<object class="GtkButton" id="cancel_button">
<property name="label" translatable="yes">Cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="cancel_button_clicked_cb" object="CcKeyboardShortcutEditor" swapped="no" />
</object>
</child>
<child>
<object class="GtkButton" id="add_button">
<property name="label" translatable="yes">Add</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="add_button_clicked_cb" object="CcKeyboardShortcutEditor" swapped="yes" />
<style>
<class name="suggested-action" />
</style>
</object>
<packing>
<property name="pack_type">end</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="replace_button">
<property name="label" translatable="yes">Replace</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
</object>
<packing>
<property name="pack_type">end</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</template>
<object class="GtkSizeGroup">
<widgets>
<widget name="cancel_button"/>
<widget name="add_button"/>
<widget name="replace_button"/>
<widget name="reset_button"/>
</widgets>
</object>
</interface>
......@@ -44,7 +44,9 @@ panels/keyboard/50-accessibility.xml.in
panels/keyboard/cc-keyboard-option.c
panels/keyboard/gnome-keyboard-panel.desktop.in.in
[type: gettext/glade]panels/keyboard/gnome-keyboard-panel.ui
[type: gettext/glade]panels/keyboard/shortcut-editor.ui
panels/keyboard/keyboard-shortcuts.c
panels/keyboard/cc-shortcut-editor.c
panels/mouse/cc-mouse-panel.c
panels/mouse/gnome-mouse-panel.desktop.in.in
panels/mouse/gnome-mouse-properties.c
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment