Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add InputMethod View #287

Merged
merged 38 commits into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0354de1
Initial work to port IM Plug to Keyboard Plug as a view
ryonakano May 7, 2020
6960e87
Fix wingpanel crash on clicking system tray switch when the list is b…
ryonakano May 7, 2020
6dbc697
Simplify namespace and condition
ryonakano May 7, 2020
e442c3d
Update POTFILES
ryonakano May 7, 2020
a0e2139
Update comment
ryonakano May 7, 2020
4568fe2
Clean the code
ryonakano May 7, 2020
87ca37f
Add test entry and move ibus_button to IMView
ryonakano May 8, 2020
768e0f1
Add reset method
ryonakano May 8, 2020
e9d1091
Merge branch 'master' into add-input-method-view
ryonakano May 15, 2020
fee796e
Add a view to enable starting IBus Daemon
ryonakano May 23, 2020
bb008ae
Merge branch 'master' into add-input-method-view
ryonakano May 23, 2020
95ae1b6
Clear liststore on update engines list
ryonakano May 23, 2020
88a3b0c
Update dependencies
ryonakano May 23, 2020
e576640
Update copyright
ryonakano May 23, 2020
df92f35
Use constant for readable code
ryonakano May 23, 2020
95ee600
Init ibus when Plug is loaded
ryonakano May 24, 2020
c3e09b4
Add spawn_failed_view
ryonakano May 24, 2020
bf574df
Use instance member instead of doing new every time
ryonakano May 24, 2020
f6a4174
Coding style
ryonakano May 24, 2020
dbe898b
Init IBus after debug text is shown
ryonakano May 24, 2020
44f14b5
Add matching search results
ryonakano May 24, 2020
70cbc7e
Update copyright headers
ryonakano May 25, 2020
843c5f0
Add anthy to installation candidates
ryonakano May 26, 2020
7c93689
Remove a switch for tray visibility
ryonakano May 26, 2020
8afd56a
Remove unneeded condition
ryonakano May 26, 2020
ef0f443
Remove unnecessary grids
ryonakano May 28, 2020
893dd83
Use Granite.accel_to_string
ryonakano May 28, 2020
b45d6e2
Use Gtk.MenuButton for popover
ryonakano May 28, 2020
bc7448e
aptd-client: namespace, explicit private
ryonakano May 28, 2020
490e478
Merge branch 'master' into add-input-method-view
Jun 8, 2020
4389ce9
Merge branch 'master' into add-input-method-view
ryonakano Jul 19, 2020
5cc43e4
AddEnginesPopover: Use ButtonBox and code style
danirabbit Jul 20, 2020
b8027f4
InstallEngineDialog: Use extension icon, code style
danirabbit Jul 20, 2020
b0861e8
ProgressDialog: code style
danirabbit Jul 20, 2020
c2574a5
remove reference to systray
danirabbit Jul 20, 2020
bb7afe7
InputMethod: Code style
danirabbit Jul 20, 2020
bcca138
EnginesRow: Code style
danirabbit Jul 20, 2020
f29678f
LanguagesRow: code style
danirabbit Jul 20, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Install Dependencies
run: |
apt update
apt install -y meson libgranite-dev libswitchboard-2.0-dev libxml2-dev libgnomekbd-dev libxklavier-dev valac
apt install -y meson libgranite-dev libswitchboard-2.0-dev libxml2-dev libgnomekbd-dev libibus-1.0-dev libxklavier-dev valac
- name: Build
env:
DESTDIR: out
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ You'll need the following dependencies:
* libgnomekbd-dev
* libgranite-dev
* libgtk-3-dev
* libibus-1.0-dev
* libxklavier-dev
* libxml2-dev
* meson
Expand Down
11 changes: 11 additions & 0 deletions po/POTFILES
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
src/Plug.vala
src/InputMethod/AddEnginesList.vala
src/InputMethod/Utils.vala
src/Dialogs/ConflictDialog.vala
src/Dialogs/InstallEngineDialog.vala
src/Dialogs/ProgressDialog.vala
src/InputMethod/Installer/aptd-client.vala
src/InputMethod/Installer/InstallList.vala
src/InputMethod/Installer/UbuntuInstaller.vala
src/Layout/AdvancedSettingsGrid.vala
src/Layout/AdvancedSettingsPanel.vala
src/Layout/Handler.vala
Expand All @@ -11,8 +18,12 @@ src/Shortcuts/Settings.vala
src/Shortcuts/Shortcut.vala
src/Views/AbstractPage.vala
src/Views/Behavior.vala
src/Views/InputMethod.vala
src/Views/Layout.vala
src/Views/Shortcuts.vala
src/Widgets/InputMethod/AddEnginesPopover.vala
src/Widgets/InputMethod/EnginesRow.vala
src/Widgets/InputMethod/LanguagesRow.vala
src/Widgets/Layout/AddLayoutPopover.vala
src/Widgets/Layout/Display.vala
src/Widgets/Shortcuts/CustomTree.vala
Expand Down
140 changes: 140 additions & 0 deletions src/Dialogs/InstallEngineDialog.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
/*
* Copyright 2019-2020 elementary, Inc. (https://elementary.io)
*
* 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 3 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 <https://www.gnu.org/licenses/>.
*/

public class Pantheon.Keyboard.InputMethodPage.InstallEngineDialog : Granite.MessageDialog {
private InstallList? engines_filter;

public InstallEngineDialog (Gtk.Window parent) {
Object (
primary_text: _("Choose an engine to install"),
secondary_text: _("Select an engine from the list to install and use."),
image_icon: new ThemedIcon ("extension"),
transient_for: parent,
buttons: Gtk.ButtonsType.CANCEL
);
}

construct {
var languages_list = new Gtk.ListBox () {
activate_on_single_click = true,
expand = true,
selection_mode = Gtk.SelectionMode.NONE
};

foreach (var language in InstallList.get_all ()) {
var lang = new LanguagesRow (language);
languages_list.add (lang);
}

var back_button = new Gtk.Button.with_label (_("Languages")) {
halign = Gtk.Align.START,
margin = 6
};
back_button.get_style_context ().add_class (Granite.STYLE_CLASS_BACK_BUTTON);

var language_title = new Gtk.Label ("");

var language_header = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6);
language_header.pack_start (back_button);
language_header.set_center_widget (language_title);

var listbox = new Gtk.ListBox () {
expand = true
};
listbox.set_filter_func (filter_function);
listbox.set_sort_func (sort_function);

foreach (var language in InstallList.get_all ()) {
foreach (var engine in language.get_components ()) {
listbox.add (new EnginesRow (engine));
}
}

var scrolled = new Gtk.ScrolledWindow (null, null);
scrolled.add (listbox);

var engine_list_grid = new Gtk.Grid () {
orientation = Gtk.Orientation.VERTICAL
};
engine_list_grid.get_style_context ().add_class (Gtk.STYLE_CLASS_VIEW);
engine_list_grid.add (language_header);
engine_list_grid.add (new Gtk.Separator (Gtk.Orientation.HORIZONTAL));
engine_list_grid.add (scrolled);

var stack = new Gtk.Stack () {
height_request = 200,
width_request = 300,
transition_type = Gtk.StackTransitionType.SLIDE_LEFT_RIGHT
};
stack.add (languages_list);
stack.add (engine_list_grid);

var frame = new Gtk.Frame (null);
frame.add (stack);

custom_bin.add (frame);
custom_bin.show_all ();

var install_button = add_button (_("Install"), Gtk.ResponseType.OK);
install_button.sensitive = false;
install_button.get_style_context ().add_class (Gtk.STYLE_CLASS_SUGGESTED_ACTION);

languages_list.row_activated.connect ((row) => {
stack.visible_child = engine_list_grid;
language_title.label = ((LanguagesRow) row).language.get_name ();
engines_filter = ((LanguagesRow) row).language;
listbox.invalidate_filter ();
var adjustment = scrolled.get_vadjustment ();
adjustment.set_value (adjustment.lower);
});

back_button.clicked.connect (() => {
stack.visible_child = languages_list;
install_button.sensitive = false;
});

listbox.selected_rows_changed.connect (() => {
foreach (var engines_row in listbox.get_children ()) {
((EnginesRow) engines_row).selected = false;
}

((EnginesRow) listbox.get_selected_row ()).selected = true;
install_button.sensitive = true;
});

response.connect ((response_id) => {
if (response_id == Gtk.ResponseType.OK) {
string engine_to_install = ((EnginesRow) listbox.get_selected_row ()).engine_name;
UbuntuInstaller.get_default ().install (engine_to_install);
}
});
}

[CCode (instance_pos = -1)]
private bool filter_function (Gtk.ListBoxRow row) {
if (InstallList.get_language_from_engine_name (((EnginesRow) row).engine_name) == engines_filter) {
return true;
}

return false;
}

[CCode (instance_pos = -1)]
private int sort_function (Gtk.ListBoxRow row1, Gtk.ListBoxRow row2) {
return ((EnginesRow) row1).engine_name.collate (((EnginesRow) row1).engine_name);
}
}
82 changes: 82 additions & 0 deletions src/Dialogs/ProgressDialog.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright 2011-2020 elementary, Inc. (https://elementary.io)
*
* This program is free software: you can redistribute it
* and/or modify it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 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/.
*/

public class Pantheon.Keyboard.InputMethodPage.ProgressDialog : Gtk.Dialog {
public int progress {
set {
if (value >= 100) {
destroy ();
}

progress_bar.fraction = value / 100.0;
}
}

private Gtk.ProgressBar progress_bar;

construct {
var image = new Gtk.Image.from_icon_name ("preferences-desktop-locale", Gtk.IconSize.DIALOG) {
valign = Gtk.Align.START
};

var primary_label = new Gtk.Label (null) {
max_width_chars = 50,
wrap = true,
xalign = 0
};
primary_label.get_style_context ().add_class (Granite.STYLE_CLASS_PRIMARY_LABEL);

unowned UbuntuInstaller installer = UbuntuInstaller.get_default ();
switch (installer.transaction_mode) {
case UbuntuInstaller.TransactionMode.INSTALL:
primary_label.label = _("Installing %s").printf (installer.engine_to_address);
break;
case UbuntuInstaller.TransactionMode.REMOVE:
primary_label.label = _("Removing %s").printf (installer.engine_to_address);
break;
}

progress_bar = new Gtk.ProgressBar () {
hexpand = true,
valign = Gtk.Align.START,
width_request = 300
};

var cancel_button = (Gtk.Button) add_button (_("Cancel"), 0);

installer.bind_property ("install-cancellable", cancel_button, "sensitive");

var grid = new Gtk.Grid () {
column_spacing = 12,
margin = 6,
row_spacing = 6
};
grid.attach (image, 0, 0, 1, 2);
grid.attach (primary_label, 1, 0);
grid.attach (progress_bar, 1, 1);
grid.show_all ();

border_width = 6;
deletable = false;
get_content_area ().add (grid);

cancel_button.clicked.connect (() => {
installer.cancel_install ();
destroy ();
});
}
}
38 changes: 38 additions & 0 deletions src/InputMethod/AddEnginesList.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 2019-2020 elementary, Inc. (https://elementary.io)
*
* 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 3 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 <https://www.gnu.org/licenses/>.
*/

public class Pantheon.Keyboard.InputMethodPage.AddEnginesList : Object {
/*
* Stores strings used to add/remove engines in the code and won't be shown in the UI.
* It consists from "<Engine name>",
* e.g. "mozc-jp" or "libpinyin"
*/
public string engine_id { get; private set; }

/*
* Stores strings used to show in the UI.
* It consists from "<Language name> - <Engine name>",
* e.g. "Japanese - Mozc" or "Chinese - Intelligent Pinyin"
*/
public string engine_full_name { get; private set; }

public AddEnginesList (IBus.EngineDesc engine) {
engine_id = engine.name;
engine_full_name = "%s - %s".printf (IBus.get_language_name (engine.language),
Utils.gettext_engine_longname (engine));
}
}
73 changes: 73 additions & 0 deletions src/InputMethod/Installer/InstallList.vala
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* 2019-2020 elementary, Inc. (https://elementary.io)
*
* 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 3 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 <https://www.gnu.org/licenses/>.
*/

public enum Pantheon.Keyboard.InputMethodPage.InstallList {
JA,
KO,
ZH;

public string get_name () {
switch (this) {
case JA:
return _("Japanese");
case KO:
return _("Korean");
case ZH:
return _("Chinese");
default:
assert_not_reached ();
}
}

public string[] get_components () {
switch (this) {
case JA:
return { "ibus-anthy", "ibus-mozc", "ibus-skk" };
case KO:
return { "ibus-hangul" };
case ZH:
return { "ibus-cangjie", "ibus-chewing", "ibus-pinyin" };
default:
assert_not_reached ();
}
}

public static InstallList get_language_from_engine_name (string engine_name) {
switch (engine_name) {
case "ibus-anthy":
return JA;
case "ibus-mozc":
return JA;
case "ibus-skk":
return JA;
case "ibus-hangul":
return KO;
case "ibus-cangjie":
return ZH;
case "ibus-chewing":
return ZH;
case "ibus-pinyin":
return ZH;
default:
assert_not_reached ();
}
}

public static InstallList[] get_all () {
return { JA, KO, ZH };
}
}
Loading