|
Lines 876-882
Link Here
|
| 876 |
if (!new_value) |
876 |
if (!new_value) |
| 877 |
{ |
877 |
{ |
| 878 |
gtk_entry_reset_im_context (entry); |
878 |
gtk_entry_reset_im_context (entry); |
| 879 |
if (GTK_WIDGET_HAS_FOCUS (entry)) |
879 |
if (GTK_WIDGET_HAS_FOCUS (entry) && entry->visible) |
| 880 |
gtk_im_context_focus_out (entry->im_context); |
880 |
gtk_im_context_focus_out (entry->im_context); |
| 881 |
|
881 |
|
| 882 |
entry->preedit_length = 0; |
882 |
entry->preedit_length = 0; |
|
Lines 885-891
Link Here
|
| 885 |
|
885 |
|
| 886 |
entry->editable = new_value; |
886 |
entry->editable = new_value; |
| 887 |
|
887 |
|
| 888 |
if (new_value && GTK_WIDGET_HAS_FOCUS (entry)) |
888 |
if (new_value && GTK_WIDGET_HAS_FOCUS (entry) && entry->visible) |
| 889 |
gtk_im_context_focus_in (entry->im_context); |
889 |
gtk_im_context_focus_in (entry->im_context); |
| 890 |
|
890 |
|
| 891 |
gtk_entry_queue_draw (entry); |
891 |
gtk_entry_queue_draw (entry); |
|
Lines 1849-1855
Link Here
|
| 1849 |
|
1849 |
|
| 1850 |
gtk_entry_pend_cursor_blink (entry); |
1850 |
gtk_entry_pend_cursor_blink (entry); |
| 1851 |
|
1851 |
|
| 1852 |
if (entry->editable) |
1852 |
if (entry->editable && entry->visible) |
| 1853 |
{ |
1853 |
{ |
| 1854 |
if (gtk_im_context_filter_keypress (entry->im_context, event)) |
1854 |
if (gtk_im_context_filter_keypress (entry->im_context, event)) |
| 1855 |
{ |
1855 |
{ |
|
Lines 1876-1881
Link Here
|
| 1876 |
*/ |
1876 |
*/ |
| 1877 |
return TRUE; |
1877 |
return TRUE; |
| 1878 |
|
1878 |
|
|
|
1879 |
/* Commit key event directly if visible is set to FALSE. |
| 1880 |
*/ |
| 1881 |
if (entry->editable && !entry->visible) |
| 1882 |
{ |
| 1883 |
gunichar ch; |
| 1884 |
ch = gdk_keyval_to_unicode (event->keyval); |
| 1885 |
|
| 1886 |
if (g_unichar_validate (ch)) |
| 1887 |
{ |
| 1888 |
gchar buf[10]; |
| 1889 |
gint len; |
| 1890 |
len = g_unichar_to_utf8 (ch, buf); |
| 1891 |
buf[len] = '\0'; |
| 1892 |
|
| 1893 |
gtk_entry_enter_text (entry, buf); |
| 1894 |
|
| 1895 |
return TRUE; |
| 1896 |
} |
| 1897 |
} |
| 1898 |
|
| 1879 |
return FALSE; |
1899 |
return FALSE; |
| 1880 |
} |
1900 |
} |
| 1881 |
|
1901 |
|
|
Lines 1885-1891
Link Here
|
| 1885 |
{ |
1905 |
{ |
| 1886 |
GtkEntry *entry = GTK_ENTRY (widget); |
1906 |
GtkEntry *entry = GTK_ENTRY (widget); |
| 1887 |
|
1907 |
|
| 1888 |
if (entry->editable) |
1908 |
if (entry->editable && entry->visible) |
| 1889 |
{ |
1909 |
{ |
| 1890 |
if (gtk_im_context_filter_keypress (entry->im_context, event)) |
1910 |
if (gtk_im_context_filter_keypress (entry->im_context, event)) |
| 1891 |
{ |
1911 |
{ |
|
Lines 1905-1911
Link Here
|
| 1905 |
|
1925 |
|
| 1906 |
gtk_widget_queue_draw (widget); |
1926 |
gtk_widget_queue_draw (widget); |
| 1907 |
|
1927 |
|
| 1908 |
if (entry->editable) |
1928 |
if (entry->editable && entry->visible) |
| 1909 |
{ |
1929 |
{ |
| 1910 |
entry->need_im_reset = TRUE; |
1930 |
entry->need_im_reset = TRUE; |
| 1911 |
gtk_im_context_focus_in (entry->im_context); |
1931 |
gtk_im_context_focus_in (entry->im_context); |
|
Lines 1929-1935
Link Here
|
| 1929 |
|
1949 |
|
| 1930 |
gtk_widget_queue_draw (widget); |
1950 |
gtk_widget_queue_draw (widget); |
| 1931 |
|
1951 |
|
| 1932 |
if (entry->editable) |
1952 |
if (entry->editable && entry->visible) |
| 1933 |
{ |
1953 |
{ |
| 1934 |
entry->need_im_reset = TRUE; |
1954 |
entry->need_im_reset = TRUE; |
| 1935 |
gtk_im_context_focus_out (entry->im_context); |
1955 |
gtk_im_context_focus_out (entry->im_context); |
|
Lines 2727-2733
Link Here
|
| 2727 |
const gchar *str, |
2747 |
const gchar *str, |
| 2728 |
GtkEntry *entry) |
2748 |
GtkEntry *entry) |
| 2729 |
{ |
2749 |
{ |
| 2730 |
if (entry->editable) |
2750 |
if (entry->editable && entry->visible) |
| 2731 |
gtk_entry_enter_text (entry, str); |
2751 |
gtk_entry_enter_text (entry, str); |
| 2732 |
} |
2752 |
} |
| 2733 |
|
2753 |
|
|
Lines 2735-2741
Link Here
|
| 2735 |
gtk_entry_preedit_changed_cb (GtkIMContext *context, |
2755 |
gtk_entry_preedit_changed_cb (GtkIMContext *context, |
| 2736 |
GtkEntry *entry) |
2756 |
GtkEntry *entry) |
| 2737 |
{ |
2757 |
{ |
| 2738 |
if (entry->editable) |
2758 |
if (entry->editable && entry->visible) |
| 2739 |
{ |
2759 |
{ |
| 2740 |
gchar *preedit_string; |
2760 |
gchar *preedit_string; |
| 2741 |
gint cursor_pos; |
2761 |
gint cursor_pos; |
|
Lines 2756-2767
Link Here
|
| 2756 |
gtk_entry_retrieve_surrounding_cb (GtkIMContext *context, |
2776 |
gtk_entry_retrieve_surrounding_cb (GtkIMContext *context, |
| 2757 |
GtkEntry *entry) |
2777 |
GtkEntry *entry) |
| 2758 |
{ |
2778 |
{ |
| 2759 |
gtk_im_context_set_surrounding (context, |
2779 |
if (entry->visible) |
| 2760 |
entry->text, |
2780 |
{ |
| 2761 |
entry->n_bytes, |
2781 |
gtk_im_context_set_surrounding (context, |
| 2762 |
g_utf8_offset_to_pointer (entry->text, entry->current_pos) - entry->text); |
2782 |
entry->text, |
|
|
2783 |
entry->n_bytes, |
| 2784 |
g_utf8_offset_to_pointer (entry->text, entry->current_pos) - entry->text); |
| 2785 |
return TRUE; |
| 2786 |
} |
| 2763 |
|
2787 |
|
| 2764 |
return TRUE; |
2788 |
return FALSE; |
| 2765 |
} |
2789 |
} |
| 2766 |
|
2790 |
|
| 2767 |
static gboolean |
2791 |
static gboolean |
|
Lines 2770-2781
Link Here
|
| 2770 |
gint n_chars, |
2794 |
gint n_chars, |
| 2771 |
GtkEntry *entry) |
2795 |
GtkEntry *entry) |
| 2772 |
{ |
2796 |
{ |
| 2773 |
if (entry->editable) |
2797 |
if (entry->editable && entry->visible) |
| 2774 |
gtk_editable_delete_text (GTK_EDITABLE (entry), |
2798 |
{ |
| 2775 |
entry->current_pos + offset, |
2799 |
gtk_editable_delete_text (GTK_EDITABLE (entry), |
| 2776 |
entry->current_pos + offset + n_chars); |
2800 |
entry->current_pos + offset, |
|
|
2801 |
entry->current_pos + offset + n_chars); |
| 2777 |
|
2802 |
|
| 2778 |
return TRUE; |
2803 |
return TRUE; |
|
|
2804 |
} |
| 2805 |
|
| 2806 |
return FALSE; |
| 2779 |
} |
2807 |
} |
| 2780 |
|
2808 |
|
| 2781 |
/* Internal functions |
2809 |
/* Internal functions |
|
Lines 2851-2880
Link Here
|
| 2851 |
static void |
2879 |
static void |
| 2852 |
update_im_cursor_location (GtkEntry *entry) |
2880 |
update_im_cursor_location (GtkEntry *entry) |
| 2853 |
{ |
2881 |
{ |
| 2854 |
GdkRectangle area; |
2882 |
if (entry->visible) |
| 2855 |
gint strong_x; |
2883 |
{ |
| 2856 |
gint strong_xoffset; |
2884 |
GdkRectangle area; |
| 2857 |
gint area_width, area_height; |
2885 |
gint strong_x; |
|
|
2886 |
gint strong_xoffset; |
| 2887 |
gint area_width, area_height; |
| 2858 |
|
2888 |
|
| 2859 |
gtk_entry_get_cursor_locations (entry, CURSOR_STANDARD, &strong_x, NULL) |
2889 |
gtk_entry_get_cursor_locations (entry, CURSOR_STANDARD, &strong_x, NULL); |
| 2860 |
; |
2890 |
get_text_area_size (entry, NULL, NULL, &area_width, &area_height); |
| 2861 |
get_text_area_size (entry, NULL, NULL, &area_width, &area_height); |
|
|
| 2862 |
|
2891 |
|
| 2863 |
strong_xoffset = strong_x - entry->scroll_offset; |
2892 |
strong_xoffset = strong_x - entry->scroll_offset; |
| 2864 |
if (strong_xoffset < 0) |
2893 |
if (strong_xoffset < 0) |
| 2865 |
{ |
2894 |
{ |
| 2866 |
strong_xoffset = 0; |
2895 |
strong_xoffset = 0; |
| 2867 |
} |
2896 |
} |
| 2868 |
else if (strong_xoffset > area_width) |
2897 |
else if (strong_xoffset > area_width) |
| 2869 |
{ |
2898 |
{ |
| 2870 |
strong_xoffset = area_width; |
2899 |
strong_xoffset = area_width; |
| 2871 |
} |
2900 |
} |
| 2872 |
area.x = strong_xoffset; |
2901 |
area.x = strong_xoffset; |
| 2873 |
area.y = 0; |
2902 |
area.y = 0; |
| 2874 |
area.width = 0; |
2903 |
area.width = 0; |
| 2875 |
area.height = area_height; |
2904 |
area.height = area_height; |
| 2876 |
|
2905 |
|
| 2877 |
gtk_im_context_set_cursor_location (entry->im_context, &area); |
2906 |
gtk_im_context_set_cursor_location (entry->im_context, &area); |
|
|
2907 |
} |
| 2878 |
} |
2908 |
} |
| 2879 |
|
2909 |
|
| 2880 |
static gboolean |
2910 |
static gboolean |
|
Lines 2947-2953
Link Here
|
| 2947 |
|
2977 |
|
| 2948 |
pango_layout_set_single_paragraph_mode (layout, TRUE); |
2978 |
pango_layout_set_single_paragraph_mode (layout, TRUE); |
| 2949 |
|
2979 |
|
| 2950 |
if (include_preedit) |
2980 |
if (include_preedit && entry->visible) |
| 2951 |
{ |
2981 |
{ |
| 2952 |
gtk_im_context_get_preedit_string (entry->im_context, |
2982 |
gtk_im_context_get_preedit_string (entry->im_context, |
| 2953 |
&preedit_string, &preedit_attrs, NULL); |
2983 |
&preedit_string, &preedit_attrs, NULL); |
|
Lines 3295-3301
Link Here
|
| 3295 |
static void |
3325 |
static void |
| 3296 |
gtk_entry_reset_im_context (GtkEntry *entry) |
3326 |
gtk_entry_reset_im_context (GtkEntry *entry) |
| 3297 |
{ |
3327 |
{ |
| 3298 |
if (entry->need_im_reset) |
3328 |
if (entry->need_im_reset && entry->visible) |
| 3299 |
{ |
3329 |
{ |
| 3300 |
entry->need_im_reset = 0; |
3330 |
entry->need_im_reset = 0; |
| 3301 |
gtk_im_context_reset (entry->im_context); |
3331 |
gtk_im_context_reset (entry->im_context); |
|
Lines 3936-3945
Link Here
|
| 3936 |
gtk_entry_set_visibility (GtkEntry *entry, |
3966 |
gtk_entry_set_visibility (GtkEntry *entry, |
| 3937 |
gboolean visible) |
3967 |
gboolean visible) |
| 3938 |
{ |
3968 |
{ |
|
|
3969 |
gboolean old_visible; |
| 3970 |
|
| 3939 |
g_return_if_fail (GTK_IS_ENTRY (entry)); |
3971 |
g_return_if_fail (GTK_IS_ENTRY (entry)); |
| 3940 |
|
3972 |
|
|
|
3973 |
old_visible = entry->visible; |
| 3974 |
|
| 3941 |
entry->visible = visible ? TRUE : FALSE; |
3975 |
entry->visible = visible ? TRUE : FALSE; |
| 3942 |
g_object_notify (G_OBJECT (entry), "visibility"); |
3976 |
g_object_notify (G_OBJECT (entry), "visibility"); |
|
|
3977 |
|
| 3978 |
if (GTK_WIDGET_HAS_FOCUS (entry)) |
| 3979 |
{ |
| 3980 |
if (entry->visible && !old_visible) |
| 3981 |
gtk_im_context_focus_in (entry->im_context); |
| 3982 |
else if (!entry->visible && old_visible) |
| 3983 |
gtk_im_context_focus_out (entry->im_context); |
| 3984 |
} |
| 3985 |
|
| 3943 |
gtk_entry_recompute (entry); |
3986 |
gtk_entry_recompute (entry); |
| 3944 |
} |
3987 |
} |
| 3945 |
|
3988 |
|