After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 311912 - Should come up showing the unicode block for the default language
Should come up showing the unicode block for the default language
Status: RESOLVED FIXED
Product: gucharmap
Classification: Core
Component: general
1.4.x
Other All
: Normal enhancement
: ---
Assigned To: Noah Levitt
Noah Levitt
Depends on:
Blocks:
 
 
Reported: 2005-07-29 00:14 UTC by Federico Mena Quintero
Modified: 2007-09-05 14:57 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement


Attachments
gucharmap-311912-start-at-right-script.diff (3.52 KB, patch)
2005-07-29 16:51 UTC, Federico Mena Quintero
committed Details | Review

Description Federico Mena Quintero 2005-07-29 00:14:28 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.
Comment 1 Teppo Turtiainen 2005-07-29 05:13:57 UTC
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 ***
Comment 2 Federico Mena Quintero 2005-07-29 16:46:48 UTC
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.
Comment 3 Federico Mena Quintero 2005-07-29 16:51:12 UTC
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.
Comment 4 Christian Neumair 2005-07-29 19:35:14 UTC
Shouldn't you rather check for g_unichar_isalpha for each character?
Comment 5 Federico Mena Quintero 2005-07-29 20:52:54 UTC
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.
Comment 6 Federico Mena Quintero 2005-07-29 20:54:30 UTC
... Except for those that don't translate them (there's no Hebrew translation
right now, for instance).  You know who you are :)
Comment 7 Noah Levitt 2005-07-29 20:58:45 UTC
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.
Comment 8 Martin Ejdestig 2005-07-29 22:46:17 UTC
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. :)
Comment 9 Martin Ejdestig 2005-07-30 03:00:23 UTC
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"))
Comment 10 Martin Ejdestig 2005-07-30 03:08:38 UTC
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.
Comment 11 Martin Ejdestig 2005-07-30 04:21:41 UTC
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.
Comment 12 Federico Mena Quintero 2005-07-30 15:32:32 UTC
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...)
Comment 13 Behdad Esfahbod 2005-07-31 08:31:12 UTC
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.
Comment 14 Behdad Esfahbod 2006-01-05 17:03:56 UTC
Federico, can you attach an updated patch?  I'm willing to commit and release this before Jan 16 deadline.
Comment 15 Federico Mena Quintero 2006-01-06 01:16:51 UTC
Sorry, I don't have time to work on this right now.  I'll be busy until the end of January.
Comment 16 Daniel Holbach 2006-11-30 15:08:39 UTC
Requested in https://launchpad.net/distros/ubuntu/+source/gucharmap/+bug/73593 also.
Comment 17 Behdad Esfahbod 2007-08-22 00:08:39 UTC
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.
Comment 18 Behdad Esfahbod 2007-09-05 07:00:40 UTC
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.

Comment 19 Federico Mena Quintero 2007-09-05 14:57:49 UTC
Thanks for taking care of this, Behdad :)