GNOME Bugzilla – Bug 311912
Should come up showing the unicode block for the default language
Last modified: 2007-09-05 14:57:49 UTC
I start up gucharmap and it comes up showing the Arabic block, because it's the first in the list. It should come up showing Latin (or whichever block corresponds to my default language - English or Spanish in my case). Normally I use gucharmap to enter a character for which I don't know the dead-key combination, or the Compose sequence. So it makes sense for it to come up in the Unicode block that corresponds to my language.
While bug 140414 is not an exact duplicate, the approarch described in it would probably make more sense and this particular issue is mentioned in the comments. Closing as a duplicate. Please reopen if you disagree. *** This bug has been marked as a duplicate of 140414 ***
Bug #140414 is about remembering the settings across invocations. This bug is about coming up with the right script the first time. For example, I don't think the majority of Western users will be able to associate "Latin" with their script. Moreover, "Latin" does not appear in the first page of the list of scripts; you have to scroll way down to find it. I have a patch ready; will attach it next.
Created attachment 49949 [details] [review] gucharmap-311912-start-at-right-script.diff At startup, jump to the script corresponding to the user's language. 2005-07-29 Federico Mena Quintero <federico@ximian.com> Fixes bug #311912: * gucharmap/gucharmap-script-chapters.c (gucharmap_script_chapters_init): Call queue_select_default_script(). (select_default_script): New utility function to jump to the script that corresponds to the user's language. (queue_select_default_script): New utility function to queue a selection of the default script. We delay this until the tree view is mapped so that the tree will scroll to the selected row in addition to just selecting it.
Shouldn't you rather check for g_unichar_isalpha for each character?
I doubt that will work in languages that don't have letters. I just care about the first non-underscore character in the translation for "_File", which everyone translates.
... Except for those that don't translate them (there's no Hebrew translation right now, for instance). You know who you are :)
I agree with Christian, g_unichar_isalpha() should work at least equally well. It matches ideographs and syllabic characters too, as it turns out. In theory you could run into a digit or a directional control character or something like that which you’d want to skip. Also, the patch introduces some warnings for me. ** (lt-gucharmap:16458): CRITICAL **: gucharmap_codepoint_list_get_char: assertion `IS_GUCHARMAP_CODEPOINT_LIST (list)' failed If I put these lines back in, the warnings go away: - gtk_tree_model_get_iter_first (parent->tree_model, &iter); /* XXX: check return val */ - gtk_tree_selection_select_iter (selection, &iter); Great idea for figuring out script from locale, though.
Federico, have you somehow gotten your hands on my todo.txt file? =) Anyway... I would replace: + if (ch == -1 || ch == '_') + continue; + else + return ch; with: + if (ch != -1 && ch != '_') + return ch; Another thing, may I ask why you simply don't give translators a single character to translate (the one to select by default) and skip get_first_non_underscore_char() ? I guess it would mean extra translation and might be confusing if there is no way to make it obvious what it's for (you can't have comments in po files, right? But I wonder if this works correctly for every language out there. From you screen at pgo, it looks like A is selected and not F which is how one wants it to work... but the name gucharmap_chapters_go_to_character () makes me think F is selected and not A. Bear in mind I haven't tested the patch or looked at the code. Will do so later tonight. :)
Ok, gucharmap_charmap_go_to_character () scrolls to and selects a character and gucharmap_chapters_go_to_character () selects the first character in a script. Still, does this work correctly for every language? (I haven't got enough Unicode-fu to answer that question) and continues still (mostly) suck. ;) (Maybe the string could be _("A - char to select at start"))
Hum, perhaps I should clarify. Aren't there languages that use the same script and for some of these languages it would be useful to select another char than the first one in the script? Maybe this should be ignored. I'll shut up now.
I've looked it up and realize that the last comment is quite dumb. Sorry for the spam... I guess I shouldn't comment in bugzilla this late at night... err, early in the morning.
On comment #7 - thanks, Noah, for finding the cause of the warnings :) I guess some part of the code assumes that a row is always selected. I'll try to find some time to do this with g_unichar_isalnum() or whatever. I don't care about highlighting a particular character; just going to the right script. Highlighting a particular character is not meaningful in this context - you can't read the user's mind about which character he'll be looking for; at best you can think that he's launching gucharmap to insert a weird diacritic for which he doesn't know the key combination :) (E.g. as a Spanish user, typing a bibliography, you get to a François author and you need the goddamn cedilla...)
Humm, in case the translation is not available, we can borrow some strings in the locale's language from nl_langinfo(3). There are month names, etc there. Using the first month name if _("_File") == "_File" and then doing the isalpha (not isalnum) sounds like a robust approach to me.
Federico, can you attach an updated patch? I'm willing to commit and release this before Jan 16 deadline.
Sorry, I don't have time to work on this right now. I'll be busy until the end of January.
Requested in https://launchpad.net/distros/ubuntu/+source/gucharmap/+bug/73593 also.
Before testing the translation for "_File" or using the nl_langinfo(), should be worth trying pango_script_from_unichar(pango_language_get_sample_string(pango_language_get_default())[0]). Watch for that NULL pointer though. This will work better as it prefers $LANG to $LC_MESSAGES.
2007-09-05 Behdad Esfahbod <behdad@gnome.org> Bug 311912 – Should come up showing the unicode block for the default language Patch from Federico Mena Quintero * gucharmap/gucharmap-script-chapters.c (get_first_non_underscore_char), (select_default_script), (tree_view_map_event_cb), (queue_select_default_script), (gucharmap_script_chapters_init): Jump to default script for users selected languge (LC_MESSAGES). We do this by getting translation for "_File" and jumping to the block containing its first character. We delay this until the tree view is mapped so that the tree will scroll to the selected row in addition to just selecting it.
Thanks for taking care of this, Behdad :)