Gtk+2 Textview, (editor) compiled on Windows and 'i' interpreted as 'ctrl+i' (indent)?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Gtk+2 Textview, (editor) compiled on Windows and 'i' interpreted as 'ctrl+i' (indent)?

David C. Rankin
All,

  This is a bizarre issue. I have a small editor written in gtk+2 (with
optional build w/gktsourceview) It builds and runs without issue on Linux.
I've built it on windows (and it builds without issue), but when running the
editor, if I type and 'i' in the text view window, it 'indents' the paragraph
as if `ctrl+i` were pressed. Strangely, if I inter 'I' (shift+i), the
paragraph unindents. In either case no 'i' or 'I" ever makes it to the
textview buffer. Huh?

  The menu accelerator is set to use 'ctrl+i` for indent and 'ctrl+shift+i` to
unindent. The menu and accelerator (in gtk_menu.c) is as follows:

    /* define tools menu */
    toolsMi = gtk_menu_item_new_with_mnemonic ("_Tools");
    sep = gtk_separator_menu_item_new ();
    indentMi = gtk_image_menu_item_new_from_stock (GTK_STOCK_INDENT,
                                                  NULL);
    gtk_menu_item_set_label (GTK_MENU_ITEM (indentMi), "Incr_ease Indent");
    unindentMi = gtk_image_menu_item_new_from_stock (GTK_STOCK_UNINDENT,
                                                  NULL);
    ...
    /* create entries under 'Tools' then add to menubar */
    gtk_menu_item_set_submenu (GTK_MENU_ITEM (toolsMi), toolsMenu);
    gtk_menu_shell_append (GTK_MENU_SHELL (toolsMenu), sep);
    gtk_menu_shell_append (GTK_MENU_SHELL (toolsMenu), indentMi);
    gtk_menu_shell_append (GTK_MENU_SHELL (toolsMenu), unindentMi);
    gtk_menu_shell_append (GTK_MENU_SHELL (toolsMenu),
                           gtk_separator_menu_item_new());
    ...
    gtk_widget_add_accelerator (indentMi, "activate", mainaccel,
                                GDK_KEY_i, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
    gtk_widget_add_accelerator (unindentMi, "activate", mainaccel,
                                GDK_KEY_i, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
                                GTK_ACCEL_VISIBLE);

  There is no other keypress_handler intercepting keys other than the default
handler. I can't for the life of my figure out what in the menu accelerator
could be causing every 'i' to be interpreted as 'ctrl+i'. Has anyone seen
similar behavior? The gtk windows binaries are from gnome.org/downloads, e.g.


https://download.gnome.org/binaries/win32/gtk+/2.24/gtk+-bundle_2.24.10-20120208_win32.zip

https://download.gnome.org/binaries/win32/gtksourceview/2.10/gtksourceview-2.10.0.zip

https://download.gnome.org/binaries/win32/gtksourceview/2.10/gtksourceview-dev-2.10.0.zip
  http://xmlsoft.org/sources/win32/libxml2-2.7.8.win32.zip

  compiled with MinGW gcc and the above.

  Any ideas? Let me know if I can send any additional information.


--
David C. Rankin, J.D.,P.E.
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Gtk+2 Textview, (editor) compiled on Windows and 'i' interpreted as 'ctrl+i' (indent)?

Joël Krähemann-3
Hi

Probably different locales. On linux you probably have an ASCII compatible
character coding or just UTF-8.

Note on windows iso8859-15 is available, at most for old versions.

I assume that you are running a windows codepage like 1252.

Bests,
Joël


On Wed, Jun 21, 2017 at 11:11 AM, David C. Rankin
<[hidden email]> wrote:

> All,
>
>   This is a bizarre issue. I have a small editor written in gtk+2 (with
> optional build w/gktsourceview) It builds and runs without issue on Linux.
> I've built it on windows (and it builds without issue), but when running the
> editor, if I type and 'i' in the text view window, it 'indents' the paragraph
> as if `ctrl+i` were pressed. Strangely, if I inter 'I' (shift+i), the
> paragraph unindents. In either case no 'i' or 'I" ever makes it to the
> textview buffer. Huh?
>
>   The menu accelerator is set to use 'ctrl+i` for indent and 'ctrl+shift+i` to
> unindent. The menu and accelerator (in gtk_menu.c) is as follows:
>
>     /* define tools menu */
>     toolsMi = gtk_menu_item_new_with_mnemonic ("_Tools");
>     sep = gtk_separator_menu_item_new ();
>     indentMi = gtk_image_menu_item_new_from_stock (GTK_STOCK_INDENT,
>                                                   NULL);
>     gtk_menu_item_set_label (GTK_MENU_ITEM (indentMi), "Incr_ease Indent");
>     unindentMi = gtk_image_menu_item_new_from_stock (GTK_STOCK_UNINDENT,
>                                                   NULL);
>     ...
>     /* create entries under 'Tools' then add to menubar */
>     gtk_menu_item_set_submenu (GTK_MENU_ITEM (toolsMi), toolsMenu);
>     gtk_menu_shell_append (GTK_MENU_SHELL (toolsMenu), sep);
>     gtk_menu_shell_append (GTK_MENU_SHELL (toolsMenu), indentMi);
>     gtk_menu_shell_append (GTK_MENU_SHELL (toolsMenu), unindentMi);
>     gtk_menu_shell_append (GTK_MENU_SHELL (toolsMenu),
>                            gtk_separator_menu_item_new());
>     ...
>     gtk_widget_add_accelerator (indentMi, "activate", mainaccel,
>                                 GDK_KEY_i, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
>     gtk_widget_add_accelerator (unindentMi, "activate", mainaccel,
>                                 GDK_KEY_i, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
>                                 GTK_ACCEL_VISIBLE);
>
>   There is no other keypress_handler intercepting keys other than the default
> handler. I can't for the life of my figure out what in the menu accelerator
> could be causing every 'i' to be interpreted as 'ctrl+i'. Has anyone seen
> similar behavior? The gtk windows binaries are from gnome.org/downloads, e.g.
>
>
> https://download.gnome.org/binaries/win32/gtk+/2.24/gtk+-bundle_2.24.10-20120208_win32.zip
>
> https://download.gnome.org/binaries/win32/gtksourceview/2.10/gtksourceview-2.10.0.zip
>
> https://download.gnome.org/binaries/win32/gtksourceview/2.10/gtksourceview-dev-2.10.0.zip
>   http://xmlsoft.org/sources/win32/libxml2-2.7.8.win32.zip
>
>   compiled with MinGW gcc and the above.
>
>   Any ideas? Let me know if I can send any additional information.
>
>
> --
> David C. Rankin, J.D.,P.E.
> _______________________________________________
> gtk-app-devel-list mailing list
> [hidden email]
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Gtk+2 Textview, (editor) compiled on Windows and 'i' interpreted as 'ctrl+i' (indent)?

David C. Rankin
In reply to this post by David C. Rankin
On 06/21/2017 04:11 AM, David C. Rankin wrote:

  Well, I have identified the problem, and have a work-around, even if I
haven't solved it. Here is the code I originally posted which provides
'ctrl+i' for indent and 'shift+ctrl+i' for unindent:

>     ...
>     gtk_widget_add_accelerator (indentMi, "activate", mainaccel,
>                                 GDK_KEY_i, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE);
>     gtk_widget_add_accelerator (unindentMi, "activate", mainaccel,
>                                 GDK_KEY_i, GDK_CONTROL_MASK | GDK_SHIFT_MASK,
>                                 GTK_ACCEL_VISIBLE);
>

The problem was caused by the next set of menu accelerators that make use of
'i' with the GDK_SUPER_MASK. For whatever reason under the great God of
coding, setting the following 'win+i' (indent by fixed amount ignoring
tabstops) and 'win+shift+i' to unindent a fixed amount, causes the textview to
interpret 'i' as 'ctrl+i'. Commenting out the following code restored normal
operation to the 'i' and its 'ctrl' combinations, e.g.

    //~ gtk_widget_add_accelerator (indfixedMi, "activate", mainaccel,
                                //~ GDK_KEY_i, GDK_SUPER_MASK,
                                //~ GTK_ACCEL_VISIBLE);
    //~ gtk_widget_add_accelerator (undfixedMi, "activate", mainaccel,
                                //~ GDK_KEY_i, GDK_SUPER_MASK | GDK_SHIFT_MASK,
                                //~ GTK_ACCEL_VISIBLE);

(indent/unindent work fine)

There is no logic that I find that says using GDK_SUPER_MASK + 'i' will screw
up your GDK_CONTROL_MASK + 'i' accelerators. This is something funky. I like
Joël's thought that it may be a UFT-8, ASCII, (whatever western encoding
windows uses) problem, but why simply removing the GDK_SUPER_MASK accelerators
fixed my issues doesn't seem encoding related. It just seems like something is
wrong if the GDK_SUPER_MASK is assigned in Windows?

Given the removal of the GDK_SUPER_MASK resolved the issue, if anyone has any
information on what GDK_SUPER_MASK can be used for in gtk on windows (or if it
just can't be used), I would appreciate your thoughts or links.

------one down one to go----------

Now all I have to do is figure out how to fix
gtk_source_language_manager_set_search_path () on windows so it can find my
sourceview language files in
"C:\opt\gtk2\share\gtksourceview-2.0\language-specs" (which isn't the
/usr/share/... Linux has). I'll just dump the current defaults and add this to
the beginning. I guess there is no accommodation in the gtksourceview package,
or guards for win32, that would attempt to handle the language-specs location
in a way different from Linux...

Thanks again for all your help.


--
David C. Rankin, J.D.,P.E.
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Gtk+2 Textview, (editor) compiled on Windows and 'i' interpreted as 'ctrl+i' (indent)?

David C. Rankin
On 06/21/2017 05:52 AM, David C. Rankin wrote:
> Now all I have to do is figure out how to fix
> gtk_source_language_manager_set_search_path () on windows so it can find my
> sourceview language files in
> "C:\opt\gtk2\share\gtksourceview-2.0\language-specs"

  The search paths problem was the result of an earlier glib version in the
windows binaries requiring inclusion of glib-object.h and calling
g_type_init(). Resolved by adding a preprocessor check and guard around the
init, e.g.

#ifndef GLIB236
 #include <glib-object.h>
#endif
...
#ifndef GLIB236
    g_type_init();
#endif

  Are the windows binaries updated on any type of basis? I guess it's just up
to whoever at gnome.org takes an interest. It would be nice to have current
gtk+-2.0, 3.0 and glib versions (actually for all versions of binaries at
https://download.gnome.org/binaries/win32)

Thanks again for your help.

--
David C. Rankin, J.D.,P.E.
_______________________________________________
gtk-app-devel-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Loading...