Re: What does "Pango-CRITICAL **: pango_layout_get_cursor_pos: assertion 'index >= 0 && index <= layout->length' failed" mean?

2017-02-08 Thread Norbert de Jonge
> It did not solve the Problem, [...]

Before I e-mailed my response I locally created a program that included
the function your posted. Double clicking the bottom field threw the
error you mentioned. After modifying the code as I described in my
previous post, the warning on the console disappeared. No warnings
remained; I solved your problem.

If I did not solve your problem and you're under the impression that I
gave you a "wrong answer", then either your question wasn't clear
enough or you did not include the code that actually caused the issue
you ran into.

I suggest that, next time you ask for help, you include a complete
working example program that reproduces the problematic behavior. This
prevents other people from having to do this work and getting back to
you with a solution that is valid but still insufficient.

> Thanks.

Sure.

Best regards,
Norbert
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: What does "Pango-CRITICAL **: pango_layout_get_cursor_pos: assertion 'index >= 0 && index <= layout->length' failed" mean?

2017-02-08 Thread Dirk Gottschalk via gtk-app-devel-list
Hello Norbert,

thank you very much for your answer.

It did not solve the Problem, but it made me think about my string
handling in the callback function. The field throwing the error was the
input, not the output.

I just split the string using the pointer of the input and not copying
it before manipulating.

Sometimes the wrong answer can help to find the right direction to the
solution.

Thanks.

Best regards,
Dirk

Am Donnerstag, den 09.02.2017, 02:51 +0100 schrieb Norbert de Jonge:
> > keybuf = gtk_entry_buffer_new ("Not yet generated", 45);
> 
> https://developer.gnome.org/gtk3/stable/GtkEntryBuffer.html#gtk-entry
> -buffer-new
> 
> The second parameter of gtk_entry_buffer_new() specifies the number
> of
> characters in the string.
> 
> Either change 45 to 17 or to -1.
> 
> Best regards,
> Norbert
> ___
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
-- 
Dirk Gottschalk, Aachen
Tel.: 01573 / 1152350
eMail: dirk.gottschalk1...@googlemail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Re: GtkPrintOperation; request for assistance

2017-02-08 Thread Norbert de Jonge
Hi Emmanuele,

Thank you for your reply.

> [...], instead of generating a massive string and then
> sending it to lpr, [...]

I'm slightly confused, is that a description of what my code is
currently doing? If it is: I was unaware that the code is generating a
massive string.

My intention and understanding was that it sets margins and a font,
then sets the starting location to the top-left with cairo_move_to(),
and then starts making multiple PrintIt() calls.

Each PrintIt() call
- sets and shows text with pango_layout_set_text() and
  pango_cairo_show_layout(), and subsequently
- prepares for the arrival of additional text by updating the output
  location to the next line with cairo_rel_move_to().

I was hoping a cairo_rel_move_to() call to a location below the bottom
margin would automatically trigger the library to increment the page
number.

A more general remark. It's unfortunate that the GtkPrintOperation
documentation lacks (a link to) source code of a, as small as possible
but still complete, stand-alone example program that allows the user to
select a file of any size, and then pick a printer, paper size and
orientation, including preview option, and print. Such an example would
be user-friendly. Users, in this context, being programmers who work
with GTK+ and would like to use GtkPrintOperation.

I lack the energy to study GNOME Dictionary's gdict-print.c file in
hopes of solving the bug. I thought that my current code related to
printing is close to being correct. If I can't use PrintIt() as I'm
currently doing, I don't see myself rewriting what's necessary to make
it work.

How can I be so far away from a solution that I would need to study the
code of another program? I've already invested many hours into creating
its current printing functionality.

Best regards,
Norbert
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: What does "Pango-CRITICAL **: pango_layout_get_cursor_pos: assertion 'index >= 0 && index <= layout->length' failed" mean?

2017-02-08 Thread Norbert de Jonge
> keybuf = gtk_entry_buffer_new ("Not yet generated", 45);

https://developer.gnome.org/gtk3/stable/GtkEntryBuffer.html#gtk-entry-buffer-new

The second parameter of gtk_entry_buffer_new() specifies the number of
characters in the string.

Either change 45 to 17 or to -1.

Best regards,
Norbert
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


What does "Pango-CRITICAL **: pango_layout_get_cursor_pos: assertion 'index >= 0 && index <= layout->length' failed" mean?

2017-02-08 Thread Dirk Gottschalk via gtk-app-devel-list
Hello,

I just started developing GTK+ Applications.

But now I get the following error message and a broken Text when clicking back 
in to the GTKEntry widget:

(gtk-keygen:18220): Pango-CRITICAL **: pango_layout_get_cursor_pos: assertion 
'index >= 0 && index <= layout->length' failed


Here is the code causing this Problem:


static void activate (GtkApplication *app, gpointer user_data)
{
GtkWidget *window;
GtkWidget *grid;
GtkWidget *label_exp_date;
GtkWidget *input_exp_date;
GtkWidget *spacer;
GtkWidget *out_head;
GtkWidget *out_gen;
GtkWidget *gen_button;

/* Create window */ 
window = gtk_application_window_new (app);
gtk_window_set_title (GTK_WINDOW (window), PACKAGE_STRING);
gtk_container_set_border_width (GTK_CONTAINER (window), 10);

/* Here we construct the container that is going pack our content */
grid = gtk_grid_new ();
gtk_grid_set_column_spacing (GTK_GRID (grid), 5);
gtk_grid_set_row_spacing (GTK_GRID (grid), 5);

/* Pack the container in the window */
gtk_container_add (GTK_CONTAINER (window), grid);

/* Create head label */
label_exp_date = gtk_label_new ("Key generator for garmin-srv.");
gtk_grid_attach (GTK_GRID (grid), label_exp_date, 0, 0, 3, 1);

/* Spacer */
spacer = gtk_label_new ("");
gtk_grid_attach (GTK_GRID (grid), spacer, 0, 1, 1, 1);

/* Key generator area */
label_exp_date = gtk_label_new ("Enter expiration date (dd.mm.):");
gtk_grid_attach (GTK_GRID (grid), label_exp_date, 0, 1, 1, 1);

input_exp_date = gtk_entry_new ();
gtk_entry_set_width_chars (GTK_ENTRY (input_exp_date), 10);
gtk_entry_set_max_length (GTK_ENTRY (input_exp_date), 10);
gtk_grid_attach (GTK_GRID (grid), input_exp_date, 1, 1, 1, 1);

gen_button = gtk_button_new_with_label ("Generate");
gtk_widget_set_halign (GTK_WIDGET (gen_button), GTK_ALIGN_END);
gtk_grid_attach (GTK_GRID (grid), gen_button, 2, 1, 1, 1);

/* Result area */
out_head = gtk_label_new ("Generated key:");
gtk_grid_attach (GTK_GRID (grid), out_head, 0, 2, 1, 1);

GtkEntryBuffer *keybuf;
keybuf = gtk_entry_buffer_new ("Not yet generated", 45);
out_gen = gtk_entry_new_with_buffer (GTK_ENTRY_BUFFER (keybuf));
gtk_entry_set_width_chars (GTK_ENTRY (out_gen), 50);
gtk_editable_set_editable (GTK_EDITABLE (out_gen), FALSE);
gtk_widget_set_can_focus (GTK_WIDGET (out_gen), FALSE);
gtk_grid_attach (GTK_GRID (grid), out_gen, 1, 2, 1, 1);


g_object_set_data (G_OBJECT(gen_button), "input", input_exp_date);
g_object_set_data (G_OBJECT(gen_button), "output", out_gen);

/* Exit when the window is closed */
g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL);

g_signal_connect (gen_button, "clicked", G_CALLBACK (gtkGenKey),
  gen_button);

// g_signal_connect (gen_button, "clicked", G_CALLBACK (showKey), 
keybuf);

gtk_widget_show_all (window);
}

Can somebody help me and tell me what I am doing wrong?

Best Regards,
Dirk

-- 
Dirk Gottschalk, Aachen
Tel.: 01573 / 1152350
eMail: dirk.gottschalk1...@googlemail.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

GObject Introspection, g-field-info-get-size

2017-02-08 Thread Stefan Salewski
https://developer.gnome.org/gi/1.50/gi-GIFieldInfo.html#g-field-info-get-size

Is someone still familiar with GObject Introspection?

I am investigating creating high level GObject Introspection based Nim bindings.

Most seems to work well, some not: For example

g-field-info-get-size()

seems to give always zero.

Is that intended?

I may need that for introspecting structs with bit fields. Well, there
are not many, but a few.

Low level Nim bindings already exists, generated from header files with
tool c2nim:

https://github.com/ngtk3

But I have the feeling that for higher level bindings GObject
Introspection may be fine -- when it works reliable.

Another problem is g_enum_info_get_n_methods() and
g_enum_info_get_method(). For some GTK3 enums n_methods seems to be
greater than zero, but g_enum_info_get_method() gives garbage or
crashes. But that is a minor problem, I may just ignore it.

___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list