LEFT | RIGHT |
1 /* vim:set et sts=4 sw=4: | 1 /* vim:set et sts=4 sw=4: |
2 * | 2 * |
3 * ibus - The Input Bus | 3 * ibus - The Input Bus |
4 * | 4 * |
5 * Copyright (c) 2017 Takao Fujiwara <takao.fujiwara1@gmail.com> | 5 * Copyright (c) 2017 Takao Fujiwara <takao.fujiwara1@gmail.com> |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Lesser General Public | 8 * modify it under the terms of the GNU Lesser General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2.1 of the License, or (at your option) any later version. | 10 * version 2.1 of the License, or (at your option) any later version. |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 y = (allocation.height - m_requisition.height) / 2.0; | 154 y = (allocation.height - m_requisition.height) / 2.0; |
155 cr.translate(x, y); | 155 cr.translate(x, y); |
156 m_fontset.draw_cairo_with_requisition_ex(cr, m_requisition); | 156 m_fontset.draw_cairo_with_requisition_ex(cr, m_requisition); |
157 cr.restore(); | 157 cr.restore(); |
158 normal_fg.free(); | 158 normal_fg.free(); |
159 normal_fg = null; | 159 normal_fg = null; |
160 return true; | 160 return true; |
161 } | 161 } |
162 #endif | 162 #endif |
163 } | 163 } |
164 //private class ESelectedLabel : Gtk.Label { | |
165 private class ESelectedLabel : EWhiteLabel { | 164 private class ESelectedLabel : EWhiteLabel { |
166 public ESelectedLabel(string text) { | 165 public ESelectedLabel(string text) { |
167 GLib.Object( | 166 GLib.Object( |
168 name : "IBusEmojierSelectedLabel" | 167 name : "IBusEmojierSelectedLabel" |
169 ); | 168 ); |
170 if (text != "") | 169 if (text != "") |
171 set_label(text); | 170 set_label(text); |
172 } | 171 } |
173 } | 172 } |
174 //private class EGoldLabel : Gtk.Label { | |
175 private class EGoldLabel : EWhiteLabel { | 173 private class EGoldLabel : EWhiteLabel { |
176 public EGoldLabel(string text) { | 174 public EGoldLabel(string text) { |
177 GLib.Object( | 175 GLib.Object( |
178 name : "IBusEmojierGoldLabel" | 176 name : "IBusEmojierGoldLabel" |
179 ); | 177 ); |
180 if (text != "") | 178 if (text != "") |
181 set_label(text); | 179 set_label(text); |
182 } | 180 } |
183 } | 181 } |
184 private class EPaddedLabel : Gtk.Label { | 182 private class EPaddedLabel : Gtk.Label { |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 m_emoji_max_seq_len = annotation.length; | 493 m_emoji_max_seq_len = annotation.length; |
496 } | 494 } |
497 } | 495 } |
498 | 496 |
499 | 497 |
500 private static void update_annotation_to_emojis_dict(IBus.EmojiData data) { | 498 private static void update_annotation_to_emojis_dict(IBus.EmojiData data) { |
501 string emoji = data.get_emoji(); | 499 string emoji = data.get_emoji(); |
502 unowned GLib.SList<string> annotations = data.get_annotations(); | 500 unowned GLib.SList<string> annotations = data.get_annotations(); |
503 foreach (string annotation in annotations) { | 501 foreach (string annotation in annotations) { |
504 bool has_emoji = false; | 502 bool has_emoji = false; |
505 unowned GLib.SList<string> hits = | 503 GLib.SList<string> hits = |
506 m_annotation_to_emojis_dict.lookup(annotation); | 504 m_annotation_to_emojis_dict.lookup(annotation).copy_deep( |
| 505 GLib.strdup); |
507 foreach (string hit_emoji in hits) { | 506 foreach (string hit_emoji in hits) { |
508 if (hit_emoji == emoji) { | 507 if (hit_emoji == emoji) { |
509 has_emoji = true; | 508 has_emoji = true; |
510 break; | 509 break; |
511 } | 510 } |
512 } | 511 } |
513 if (!has_emoji) { | 512 if (!has_emoji) { |
514 hits.append(emoji); | 513 hits.append(emoji); |
515 m_annotation_to_emojis_dict.replace( | 514 m_annotation_to_emojis_dict.replace( |
516 annotation, | 515 annotation, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 } | 555 } |
557 str = str.next_char(); | 556 str = str.next_char(); |
558 } | 557 } |
559 return buff.str; | 558 return buff.str; |
560 } | 559 } |
561 | 560 |
562 | 561 |
563 private static void | 562 private static void |
564 update_annotations_with_description (IBus.EmojiData data, | 563 update_annotations_with_description (IBus.EmojiData data, |
565 string description) { | 564 string description) { |
566 unowned GLib.SList<string> annotations = data.get_annotations(); | 565 GLib.SList<string> annotations = |
| 566 data.get_annotations().copy_deep(GLib.strdup); |
567 bool update_annotations = false; | 567 bool update_annotations = false; |
568 string former = null; | 568 string former = null; |
569 string later = null; | 569 string later = null; |
570 int index = description.index_of(": "); | 570 int index = description.index_of(": "); |
571 if (index > 0) { | 571 if (index > 0) { |
572 former = description.substring(0, index); | 572 former = description.substring(0, index); |
573 if (annotations.find_custom(former, GLib.strcmp) == null) { | 573 if (annotations.find_custom(former, GLib.strcmp) == null) { |
574 annotations.append(former); | 574 annotations.append(former); |
575 update_annotations = true; | 575 update_annotations = true; |
576 } | 576 } |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 // it's escaped in m_emoji_to_emoji_variants_dict and | 645 // it's escaped in m_emoji_to_emoji_variants_dict and |
646 // not shown by default. | 646 // not shown by default. |
647 if (has_variant) { | 647 if (has_variant) { |
648 unichar base_ch = emoji.get_char(); | 648 unichar base_ch = emoji.get_char(); |
649 string base_emoji = base_ch.to_string(); | 649 string base_emoji = base_ch.to_string(); |
650 var buff = new GLib.StringBuilder(); | 650 var buff = new GLib.StringBuilder(); |
651 buff.append_unichar(base_ch); | 651 buff.append_unichar(base_ch); |
652 buff.append_unichar(0xfe0f); | 652 buff.append_unichar(0xfe0f); |
653 if (m_emoji_to_data_dict.lookup(buff.str) != null) | 653 if (m_emoji_to_data_dict.lookup(buff.str) != null) |
654 base_emoji = buff.str; | 654 base_emoji = buff.str; |
655 unowned GLib.SList<string>? variants = | 655 GLib.SList<string>? variants = |
656 m_emoji_to_emoji_variants_dict.lookup(base_emoji); | 656 m_emoji_to_emoji_variants_dict.lookup( |
| 657 base_emoji).copy_deep(GLib.strdup); |
657 if (variants.find_custom(emoji, GLib.strcmp) == null) { | 658 if (variants.find_custom(emoji, GLib.strcmp) == null) { |
658 if (variants == null) | 659 if (variants == null) |
659 variants.append(base_emoji); | 660 variants.append(base_emoji); |
660 variants.append(emoji); | 661 variants.append(emoji); |
661 m_emoji_to_emoji_variants_dict.replace( | 662 m_emoji_to_emoji_variants_dict.replace( |
662 base_emoji, | 663 base_emoji, |
663 variants.copy_deep(GLib.strdup)); | 664 variants.copy_deep(GLib.strdup)); |
664 } | 665 } |
665 return; | 666 return; |
666 } | 667 } |
667 bool has_emoji = false; | 668 bool has_emoji = false; |
668 unowned GLib.SList<string> hits = | 669 GLib.SList<string> hits = |
669 m_category_to_emojis_dict.lookup(category); | 670 m_category_to_emojis_dict.lookup(category).copy_deep( |
| 671 GLib.strdup); |
670 foreach (string hit_emoji in hits) { | 672 foreach (string hit_emoji in hits) { |
671 if (hit_emoji == emoji) { | 673 if (hit_emoji == emoji) { |
672 has_emoji = true; | 674 has_emoji = true; |
673 break; | 675 break; |
674 } | 676 } |
675 } | 677 } |
676 if (!has_emoji) { | 678 if (!has_emoji) { |
677 hits.append(emoji); | 679 hits.append(emoji); |
678 m_category_to_emojis_dict.replace(category, | 680 m_category_to_emojis_dict.replace(category, |
679 hits.copy_deep(GLib.strdup)); | 681 hits.copy_deep(GLib.strdup)); |
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1741 m_favorites += favorite; | 1743 m_favorites += favorite; |
1742 } | 1744 } |
1743 for(int i = 0; i < unowned_favorite_annotations.length; i++) { | 1745 for(int i = 0; i < unowned_favorite_annotations.length; i++) { |
1744 string? favorite_annotation = unowned_favorite_annotations[i]; | 1746 string? favorite_annotation = unowned_favorite_annotations[i]; |
1745 GLib.return_if_fail(favorite_annotation != null); | 1747 GLib.return_if_fail(favorite_annotation != null); |
1746 m_favorite_annotations += favorite_annotation; | 1748 m_favorite_annotations += favorite_annotation; |
1747 } | 1749 } |
1748 update_favorite_emoji_dict(); | 1750 update_favorite_emoji_dict(); |
1749 } | 1751 } |
1750 } | 1752 } |
LEFT | RIGHT |