Re: GtkEntry right aligned/justified (and Solution)
Steffen Gutmann wrote: However, there are a few odd things when using this method: 1) text gets clipped at the right end. This is because there are additional borders at the left and right end which you didn't consider. This could be fixed though. 2) Mouse clicks still believe the entry is left aligned and you get a strange behavior. 3) When the text is larger than the allocation can hold, you get a strange behavior, too. I think mouse handling can be fixed in top-level signal handlers, but all stuff cant be done without changing original code. After all, I think, your solution is more like a 'hack' that needs more tuning for making it really work. Sure, its a 'quick dirty hack'. Its possible to fix width (ignoring the fact that one size macro is defined in private file) and mouse handling from callbacks, but scrolling text correctly is not so easy... Olexiy ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: GtkEntry right aligned/justified (and Solution)
Steffen Gutmann wrote: O.K. I submitted a report to bugzilla, id 135177 (http://bugzilla.gnome.org/show_bug.cgi?id=135177). Thanks again for your help, Steffen Mariano Surez-Alvarez wrote: They surely are reading... but filing a request for enhancement bug in bugzilla, http://bugzilla.gnome.org/, is usually the recommended course of action. I think you will find that it is already covered in a more general way by: http://bugzilla.gnome.org/show_bug.cgi?id=59799 /Egon ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: GtkEntry right aligned/justified (and Solution)
Hi Egon! Egon Andersen wrote: Steffen Gutmann wrote: O.K. I submitted a report to bugzilla, id 135177 (http://bugzilla.gnome.org/show_bug.cgi?id=135177). I think you will find that it is already covered in a more general way by: http://bugzilla.gnome.org/show_bug.cgi?id=59799 Oh, I didn't see that. Maybe I should have searched the bug database first. I read id 59799 and it seems they cover the same aspect as I did, but then I read this: --- Additional Comments From [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 2003-03-30 03:17 -- I think this just shows the old knowledge - don't change things that are working :-) I did of course forget that the cursor do not need to be at the end of the text. Back in november/december this was all clear to me, but there has been so much going on since. Hopefully someone can complete the implementation, as I know I won't get time for this in the near future :-( --- So, it seems their implementation isn't complete yet... -- Steffen ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: GtkEntry right aligned/justified (and Solution)
Steffen Gutmann wrote: Hi Egon! Egon Andersen wrote: Steffen Gutmann wrote: O.K. I submitted a report to bugzilla, id 135177 (http://bugzilla.gnome.org/show_bug.cgi?id=135177). I think you will find that it is already covered in a more general way by: http://bugzilla.gnome.org/show_bug.cgi?id=59799 Oh, I didn't see that. Maybe I should have searched the bug database first. I read id 59799 and it seems they cover the same aspect as I did, but then I read this: --- Additional Comments From [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 2003-03-30 03:17 -- I think this just shows the old knowledge - don't change things that are working :-) I did of course forget that the cursor do not need to be at the end of the text. Back in november/december this was all clear to me, but there has been so much going on since. Hopefully someone can complete the implementation, as I know I won't get time for this in the near future :-( --- So, it seems their implementation isn't complete yet... Well, yours isn't complete either ;-) What is missing in 59799 is commented by Owen Taylor, something like the g_return_if_fail and then the description of the functions should be improved. The solution in 59799 give the possibility to have any alignment, not just right, left and center as your proposal. Furthermore there must be made test-instructions. Best regards Egon Andersen ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: GtkEntry right aligned/justified (and Solution)
Hi Egon! Egon Andersen wrote: So, it seems their implementation isn't complete yet... Well, yours isn't complete either ;-) I think, they were talking about scrolling and that the solution in 59799 didn't cover it correctly. I checked the scrolling in my version and seems to be ok. What is missing in 59799 is commented by Owen Taylor, something like the g_return_if_fail and then the description of the functions should be improved. Yes, I agree. Actually, the whole gtkentry.c could benefit from some more comments... The solution in 59799 give the possibility to have any alignment, not just right, left and center as your proposal. This is something I want to discuss. In principle I see no problem in making GtkEntry having any alignment (in [0;1]) and the solution would be straight-forward (given what I have now). But is there any need in having an entry aligned other then left, center, or right? For, a label I see that one might want to have it aligned with a value of 0.1 (so mainly left but also using little space on the left if available), but for a GtkEntry? Would that make sense? Editing a GtkEntry with an alignment of 0.1 might be a strange thing. I only see left, center and right useful like in an text editor: most time you have text left aligned, for numbers you might choose right aligned, and for something pretty, you center it. Furthermore there must be made test-instructions. How about, if the entry example covers this? A new choice-type field could be added to the example where the user can select the justification. Best regards, Steffen ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: GtkEntry right aligned/justified (and Solution)
Steffen Gutmann wrote: Hi Egon! Egon Andersen wrote: So, it seems their implementation isn't complete yet... Well, yours isn't complete either ;-) I think, they were talking about scrolling and that the solution in 59799 didn't cover it correctly. I checked the scrolling in my version and seems to be ok. There is nothing wrong with the scrolling in the solution in 59799. We just had some discussions about how the code could be written, but the results are the same. There was a little about clamp, where I had a short brain-damage, as at the time where Owen Taylor commented on it, it was almost 6 months since I looked at this. (And now it is another year.) Have you tried to set RTL and used your solution? You have default LEFT, which I believe will not be what was expected when RTL. 59799 respects the RTL and an adjustment equal to 0.0 is the default. An adjustment of 1.0 will do the opposite, which in LTR means right adjusted, but in RTL means left adjusted. What is missing in 59799 is commented by Owen Taylor, something like the g_return_if_fail and then the description of the functions should be improved. Yes, I agree. Actually, the whole gtkentry.c could benefit from some more comments... Couldn't agree more ... The solution in 59799 give the possibility to have any alignment, not just right, left and center as your proposal. This is something I want to discuss. In principle I see no problem in making GtkEntry having any alignment (in [0;1]) and the solution would be straight-forward (given what I have now). But is there any need in having an entry aligned other then left, center, or right? For, a label I see that one might want to have it aligned with a value of 0.1 (so mainly left but also using little space on the left if available), but for a GtkEntry? Would that make sense? Editing a GtkEntry with an alignment of 0.1 might be a strange thing. I only see left, center and right useful like in an text editor: most time you have text left aligned, for numbers you might choose right aligned, and for something pretty, you center it. Well, my experience it that whenever something is restricted, someone would like to do something that was not possible due to the restrictions. Furthermore there must be made test-instructions. How about, if the entry example covers this? A new choice-type field could be added to the example where the user can select the justification. I believe a test instruction is a little more than just an example. ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: GtkEntry right aligned/justified (and Solution)
Hi Egon! I think, they were talking about scrolling and that the solution in 59799 didn't cover it correctly. I checked the scrolling in my version and seems to be ok. There is nothing wrong with the scrolling in the solution in 59799. We just had some discussions about how the code could be written, but the results are the same. There was a little about clamp, where I had a short brain-damage, as at the time where Owen Taylor commented on it, it was almost 6 months since I looked at this. (And now it is another year.) Well, if your solution is approved then I have no problem in taking mine back in favor of yours. Just, I didn't find any alignment/justification in GtkEntry when I looked for it (gtk+-2.2.2) so I decided to write my own. Do you know which version of gtk contains your changes? Have you tried to set RTL and used your solution? No, but my guess is that a string 123 will be right aligned but printed as 321, right? Anyway, I also wanted to have center justification, so RTL won't work for me. You have default LEFT, which I believe will not be what was expected when RTL. 59799 respects the RTL and an adjustment equal to 0.0 is the default. An adjustment of 1.0 will do the opposite, which in LTR means right adjusted, but in RTL means left adjusted. Interesting. For RTL and an alignment in [0;1], this can make sense (but we could also argue on that), but for justification, I think GTK_JUSTIFY_LEFT should always jusify left, no matter what RTL says. But you are also right and I didn't test my version with RTL. The solution in 59799 give the possibility to have any alignment, not just right, left and center as your proposal. This is something I want to discuss. In principle I see no problem in making GtkEntry having any alignment (in [0;1]) and the solution would be straight-forward (given what I have now). But is there any need in having an entry aligned other then left, center, or right? For, a label I see that one might want to have it aligned with a value of 0.1 (so mainly left but also using little space on the left if available), but for a GtkEntry? Would that make sense? Editing a GtkEntry with an alignment of 0.1 might be a strange thing. I only see left, center and right useful like in an text editor: most time you have text left aligned, for numbers you might choose right aligned, and for something pretty, you center it. Well, my experience it that whenever something is restricted, someone would like to do something that was not possible due to the restrictions. PangoLayout also knows about left, right, and center aligned only. Furthermore there must be made test-instructions. How about, if the entry example covers this? A new choice-type field could be added to the example where the user can select the justification. I believe a test instruction is a little more than just an example. Could you please tell me, how such a test instruction could look like? Kind regards, Steffen ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: GtkEntry right aligned/justified (and Solution)
Hello Olexiy! I tried your 'solution' for obtaining right-aligned GtkEntries. Thanks for the modified entry example, it compiled and run without problems. [...] I solve this with connecting to GtkEntry' expose-event : static gboolean set_layout_align(GtkEntry *entry) { PangoLayout *pl; pl = gtk_entry_get_layout(entry); pango_layout_set_width(pl, GTK_WIDGET(entry)-allocation.width*PANGO_SCALE); pango_layout_set_alignment(pl, PANGO_ALIGN_RIGHT); return FALSE; } It sets layout width equal width of GtkEntry every time before real expose handler pops up. Modified entry sample from GTK+ tarball coming attached. However, there are a few odd things when using this method: 1) text gets clipped at the right end. This is because there are additional borders at the left and right end which you didn't consider. This could be fixed though. 2) Mouse clicks still believe the entry is left aligned and you get a strange behavior. 3) When the text is larger than the allocation can hold, you get a strange behavior, too. After all, I think, your solution is more like a 'hack' that needs more tuning for making it really work. But it is a good start and it made me spent a few hours looking into the source code of gtk+-2.2.2 and writing a new version of GtkEntry. I modified the original gtkentry.[ch] source and added two functions void gtk_entry_set_justify(GtkEntry *entry, GtkJustification jtype); GtkJustification gtk_entry_get_justify(GtkEntry *entry); I went through major parts of the source and made sure, mouse clicks, drag'n drop, text selection, etc. are handled correctly. So far I didn't experience any problems so I would like to open my solution to other developers. I put my replacments here: http://www.informatik.uni-freiburg.de/~gutmann/gtk/gtkentry.h http://www.informatik.uni-freiburg.de/~gutmann/gtk/gtkentry.c and if you do a diff to the original version, you will find out they only differ at a few places. Ideally, I would like to see these changes in a future version of gtk. Are the developers of gtk reading this list, or should I send another message to the developer list? Kind regards, Steffen ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: GtkEntry right aligned/justified (and Solution)
On Mon, 2004-02-23 at 12:08 +0900, Steffen Gutmann wrote: Ideally, I would like to see these changes in a future version of gtk. Are the developers of gtk reading this list, or should I send another message to the developer list? They surely are reading... but filing a request for enhancement bug in bugzilla, http://bugzilla.gnome.org/, is usually the recommended course of action. -- m -- Mariano Surez-Alvarez [EMAIL PROTECTED] ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: GtkEntry right aligned/justified (and Solution)
O.K. I submitted a report to bugzilla, id 135177 (http://bugzilla.gnome.org/show_bug.cgi?id=135177). Thanks again for your help, Steffen Mariano Surez-Alvarez wrote: They surely are reading... but filing a request for enhancement bug in bugzilla, http://bugzilla.gnome.org/, is usually the recommended course of action. -- m ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: GtkEntry right aligned/justified
Hi, On Fri, 2004-02-20 at 11:36 +0900, Steffen Gutmann wrote: So, is there a way to make a GtkEntry right aligned, like you want to have it for numbers in a calculator? You could look into the gnome calculator source to see what it does... -- m -- Mariano Surez-Alvarez [EMAIL PROTECTED] ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: GtkEntry right aligned/justified
Steffen Gutmann wrote: Hello, I saw this question posted at least twice but no answers were given, the FAQ doesn't mention it, and all my attempts to make a GtkEntry other then left-aligned failed including gtk_entry_get_layout for getting a pointer to the PangoLayout and playing around with several settings in there. So, is there a way to make a GtkEntry right aligned, like you want to have it for numbers in a calculator? Hi, GtkLabel is derived from GtkMisc. You have to try gtk_misc_set_alignment() function: http://developer.gnome.org/doc/API/2.0/gtk/GtkMisc.html#gtk-misc-set-alignment Default is 0.5, 0.5 alignment - set xalign parameter to 1.0 and label will be aligned in the way you want. By the way API reference mention about that, look at: http://developer.gnome.org/doc/API/2.0/gtk/GtkLabel.html near the string Text layout. Olexiy ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: GtkEntry right aligned/justified
Hello Olexiy! Well, your respose is for a GtkLabel which can surely be aligned in many ways. But my question was for a GtkEntry and I get the believe that for this class there is no other way than having it left aligned. I didn't try the other poster's answer yet (using gtk_widget_set_direction) but to me it seems chaning the direction is something completely different (reading from right to left) than alignment. So, there is no right (or center)-justified/aligned GtkEntry, is there? -- Steffen ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: GtkEntry right aligned/justified
Steffen Gutmann wrote: Hello Olexiy! Well, your respose is for a GtkLabel which can surely be aligned in many ways. Oops, my fault :( But my question was for a GtkEntry and I get the believe that for this class there is no other way than having it left aligned. I didn't try the other poster's answer yet (using gtk_widget_set_direction) but to me it seems chaning the direction is something completely different (reading from right to left) than alignment. Yes, I'm also unsure about the results. So, there is no right (or center)-justified/aligned GtkEntry, is there? There's no way to do this with GtkEntry/GtkEditable API. It's possible via PangoLayout, with pango_layout_set_alignment(pl, PANGO_ALIGN_RIGHT). The problem is that GtkEntry always sets the size of layout when text is changed, so alignment just dont working. I solve this with connecting to GtkEntry' expose-event : static gboolean set_layout_align(GtkEntry *entry) { PangoLayout *pl; pl = gtk_entry_get_layout(entry); pango_layout_set_width(pl, GTK_WIDGET(entry)-allocation.width*PANGO_SCALE); pango_layout_set_alignment(pl, PANGO_ALIGN_RIGHT); return FALSE; } It sets layout width equal width of GtkEntry every time before real expose handler pops up. Modified entry sample from GTK+ tarball coming attached. PS: excuse for my previous post ;) Olexiy #include stdio.h #include stdlib.h #include gtk/gtk.h void enter_callback( GtkWidget *widget, GtkWidget *entry ) { const gchar *entry_text; entry_text = gtk_entry_get_text (GTK_ENTRY (entry)); printf(Entry contents: %s\n, entry_text); } void entry_toggle_editable( GtkWidget *checkbutton, GtkWidget *entry ) { gtk_editable_set_editable (GTK_EDITABLE (entry), GTK_TOGGLE_BUTTON (checkbutton)-active); } void entry_toggle_visibility( GtkWidget *checkbutton, GtkWidget *entry ) { gtk_entry_set_visibility (GTK_ENTRY (entry), GTK_TOGGLE_BUTTON (checkbutton)-active); } static gboolean set_layout_align(GtkEntry *entry) { PangoLayout *pl; pl = gtk_entry_get_layout(entry); pango_layout_set_width(pl, GTK_WIDGET(entry)-allocation.width*PANGO_SCALE); pango_layout_set_alignment(pl, PANGO_ALIGN_RIGHT); return FALSE; } int main( int argc, char *argv[] ) { GtkWidget *window; GtkWidget *vbox, *hbox; GtkWidget *entry; GtkWidget *button; GtkWidget *check; gint tmp_pos; gtk_init (argc, argv); /* create a new window */ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_size_request (GTK_WIDGET (window), 200, 100); gtk_window_set_title (GTK_WINDOW (window), GTK Entry); g_signal_connect (G_OBJECT (window), destroy, G_CALLBACK (gtk_main_quit), NULL); g_signal_connect_swapped (G_OBJECT (window), delete_event, G_CALLBACK (gtk_widget_destroy), G_OBJECT (window)); vbox = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (window), vbox); gtk_widget_show (vbox); entry = gtk_entry_new (); g_signal_connect(entry, expose-event, G_CALLBACK(set_layout_align), entry); gtk_entry_set_max_length (GTK_ENTRY (entry), 50); g_signal_connect (G_OBJECT (entry), activate, G_CALLBACK (enter_callback), (gpointer) entry); gtk_entry_set_text (GTK_ENTRY (entry), hello); tmp_pos = GTK_ENTRY (entry)-text_length; gtk_editable_insert_text (GTK_EDITABLE (entry), world, -1, tmp_pos); gtk_editable_select_region (GTK_EDITABLE (entry), 0, GTK_ENTRY (entry)-text_length); gtk_box_pack_start (GTK_BOX (vbox), entry, TRUE, TRUE, 0); gtk_widget_show (entry); hbox = gtk_hbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (vbox), hbox); gtk_widget_show (hbox); check = gtk_check_button_new_with_label (Editable); gtk_box_pack_start (GTK_BOX (hbox), check, TRUE, TRUE, 0); g_signal_connect (G_OBJECT (check), toggled, G_CALLBACK (entry_toggle_editable), (gpointer) entry); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), TRUE); gtk_widget_show (check); check = gtk_check_button_new_with_label (Visible); gtk_box_pack_start (GTK_BOX (hbox), check, TRUE, TRUE, 0); g_signal_connect (G_OBJECT (check), toggled, G_CALLBACK (entry_toggle_visibility), (gpointer) entry); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), TRUE); gtk_widget_show (check); button = gtk_button_new_from_stock (GTK_STOCK_CLOSE); g_signal_connect_swapped (G_OBJECT (button), clicked, G_CALLBACK (gtk_widget_destroy), G_OBJECT (window));
GtkEntry right aligned/justified
Hello, I saw this question posted at least twice but no answers were given, the FAQ doesn't mention it, and all my attempts to make a GtkEntry other then left-aligned failed including gtk_entry_get_layout for getting a pointer to the PangoLayout and playing around with several settings in there. So, is there a way to make a GtkEntry right aligned, like you want to have it for numbers in a calculator? Regards, Steffen ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
GtkEntry right aligned/justified
Hello, I saw this question posted at least twice but no answers were given, the FAQ doesn't mention it, and all my attempts to make a GtkEntry other then left-aligned failed including gtk_entry_get_layout for getting a pointer to the PangoLayout and playing around with several settings in there. So, is there a way to make a GtkEntry right aligned, like you want to have it for numbers in a calculator? Regards, Steffen ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: GtkEntry right aligned/justified
Hello, So, is there a way to make a GtkEntry right aligned, like you want to have it for numbers in a calculator? Regards, Steffen use this for right justification. For further search for this in the reference manual gtk_widget_set_direction(entry, GTK_DIRECTION_RTL); for RightToLeft justification. Similarly for LTR for LeftToRight. gtk_widget_set_direction(entry, GTK_DIRECTION_LTR); cheers, bheemesh. ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list