Plain C code bug example for the experts

2016-08-09 Thread Stefan Salewski
I told you about this bug some days ago, I get it in my Nim editor 
https://github.com/ngtk3/NEd

Here is some minimal C code which seems to show a very similar problem.
This is for gtk+-3.18.9 Linux AMD64

The task is to replace a GTK notebook with a paned widget containing two 
notebooks.
To reproduce:
Compile and run the program.
Click on Tab2 to make textview 2 visible.
Enter a long text line, so that bottom scrollbar becomes visible.
Click on Tab1 to make textview 1 visible.
Click into textview1 so that paned is created.
Resize window by dragging lower left corner of window.

You should get messages like

bassi:4400): Gdk-CRITICAL **: gdk_window_move_resize_internal: assertion 
'GDK_IS_WINDOW (window)' failed


It is really not easy to generate this bug, so my assumption is that the 
problem is
inside of GTK, but maybe I am doing something wrong indeed.


#include 

// based on 
https://developer.gnome.org/gtk3/stable/gtk-getting-started.html#id-1.2.3.5
// gcc `pkg-config --cflags gtk+-3.0` -o bassi bassi.c `pkg-config --libs 
gtk+-3.0`

#include 

static gboolean
button_press_cb (GtkWidget *widget,
 GdkEvent  *event,
 gpointer   window)
{
  GtkWidget *notebook1;
  GtkWidget *notebook2;
  GtkWidget *paned1;
  GtkWidget *textview3;
  GtkWidget *scrolled3;
notebook1 = gtk_bin_get_child (GTK_BIN(window));
  g_object_ref(notebook1);
  gtk_container_remove (GTK_CONTAINER (window), notebook1);
  paned1 = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
  gtk_paned_pack1 (GTK_PANED (paned1), notebook1, TRUE, FALSE);
  notebook2 = gtk_notebook_new ();
  scrolled3 = gtk_scrolled_window_new (NULL, NULL);
  textview3 = gtk_text_view_new ();
  gtk_container_add (GTK_CONTAINER (scrolled3), textview3);
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook2), scrolled3, NULL);
  gtk_paned_pack2 (GTK_PANED (paned1), notebook2, TRUE, FALSE);
  gtk_container_add (GTK_CONTAINER (window), paned1);
  gtk_widget_show_all (window);
  g_object_unref(notebook1);
return FALSE;
}

static void
activate (GtkApplication *app,
  gpointeruser_data)
{
  GtkWidget *window;
  GtkWidget *scrolled1;
  GtkWidget *scrolled2;
  GtkWidget *textview1;
  GtkWidget *textview2;
  GtkWidget *notebook1;
  window = gtk_application_window_new (app);
  gtk_window_set_title (GTK_WINDOW (window), "Window");
  gtk_window_set_default_size (GTK_WINDOW (window), 200, 200);
  notebook1 = gtk_notebook_new ();
  scrolled1 = gtk_scrolled_window_new (NULL, NULL);
  textview1 = gtk_text_view_new ();
  gtk_container_add (GTK_CONTAINER (scrolled1), textview1);
  g_signal_connect (textview1, "button-press-event", G_CALLBACK 
(button_press_cb), window);
  scrolled2 = gtk_scrolled_window_new (NULL, NULL);
  textview2 = gtk_text_view_new ();
  gtk_container_add (GTK_CONTAINER (scrolled2), textview2);
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook1), scrolled1, NULL);
  gtk_notebook_append_page (GTK_NOTEBOOK (notebook1), scrolled2, NULL);
  gtk_container_add (GTK_CONTAINER (window), notebook1);
  gtk_widget_show_all (window);
}

int
main (intargc,
  char **argv)
{
  GtkApplication *app;
  int status;
  app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
  g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
  status = g_application_run (G_APPLICATION (app), argc, argv);
  g_object_unref (app);
  return status;
}
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Using GTK+ with Broadway

2016-08-09 Thread Igor D
Hi all,

I consider to use GTK+ with Broadway for development of device control
application.
Device is with functionality similar to  broadband modem/router (I
intentionally selected example which is familiar for all :-)  ).
Device should be controlled remotely via web browser.

My concern is about performance of such control. I'm afraid that Broadway
may be a bottleneck.
Probably I'm wrong but even in simple pilot I built it looks not so good.

It will be very appreciated to have your inputs based on real experience.

Thanks a lot,
Igor
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: 'Cannot convert arbitrary SV to GValue' when setting child property of GtkStack

2016-08-09 Thread Torsten Schönfeld
"Daniel Kasak" :
> I'm trying to set the 'needs-attention' property of a GtkStack's child page.
> 
> When I go:
> 
> use Glib qw( TRUE FALSE );
> 
> my $needs_attention = FALSE;
> 
> if ( $self->{ 'Column' . $i . 'Datasheet' }->count ) {
> $needs_attention = TRUE;
> }
> 
> my $child = $self->{stack}->get_child_by_name( 'page' . $i );
> 
> $self->{stack}->child_set_property(
> $child
>   , 'needs-attention'
>   , $needs_attention
> );
> 
>  ... I get:
> 
> Cannot convert arbitrary SV to GValue'

Looks like the Gtk3::Container::child_set* and child_get* methods need 
overrides.  Fow now, child_set_property expects a GValue, so as a workaround, 
try something like this:

  my $gvalue = Glib::Object::Introspection::GValueWrapper->new (
'Glib::Boolean', $needs_attention);
  $self->{stack}->child_set_property ($child, 'needs-attention', $gvalue);
___
gtk-perl-list mailing list
gtk-perl-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-perl-list


Re: 'color-activated' signal not emitting

2016-08-09 Thread Craig Cabrey
Hi,

Thanks for your responses.

On Mon, Jul 25, 2016 at 6:15 AM, Emmanuele Bassi  wrote:

> Hi;
>
> On 23 July 2016 at 21:25, Craig Cabrey  wrote:
> > According to the docs [0], the "color-activated" signal is emitted upon
> > the user making any changes to the current color.
>
> Not really. The documentation says:
>
> """
> Emitted when a color is activated from the color chooser. This usually
> happens
> when the user clicks a color swatch, or a color is selected and the user
> presses
> one of the keys Space, Shift+Space, Return or Enter.
> """
>
> i.e. you need to activate the color, just like you'd activate a widget
> or a menu item.
>

That seems confusing to me. The way its written (or rather, the way I'm
reading it) implies the signal will be emitted on any color change
("activated"). However, using the "notify" signal seems to work as well,
although the signal is emitted a few times on startup that I'll have to
ignore.


>
> > I'm having trouble with this signal in two scenarios:
> >
> > 1) When a GtkColorChooserWidget is inside of a GtkPopover [1, 2]
> > 2) When a GtkColorChooserWidget is inside of a GtkWindow [3, 4]
> >
> > I am not sure if I'm using GtkBuilder, signals, or pygobject
> > incorrectly. The signal is being picked up correctly, because
> > when I comment it out, GtkBuilder complains. However, even
> > when I change a color, nothing is fired (and yes, I put a quick
> > print statement in as a sanity check).
>
> Can you create a small, self-contained test case that reproduces the
> behaviour you experience, so that we don't have to clone, build, and
> run a whole application?
>

I through together a standalone Python3 script really quick, hopefully this
works for you.

https://gist.github.com/craigcabrey/367eb0b411c0ffb3c4851f6dcd921837


> Ciao,
>  Emmanuele.
>
> --
> https://www.bassi.io
> [@] ebassi [@gmail.com]
>
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list


Re: 'color-activated' signal not emitting

2016-08-09 Thread Craig Cabrey
That makes much more sense and now it's working as I expect it.

Thank you!

On Mon, Jul 25, 2016 at 9:02 AM, Emmanuele Bassi  wrote:

> Hi;
>
> On 25 July 2016 at 13:47, Craig Cabrey  wrote:
>
> >> Not really. The documentation says:
> >>
> >> """
> >> Emitted when a color is activated from the color chooser. This usually
> >> happens
> >> when the user clicks a color swatch, or a color is selected and the user
> >> presses
> >> one of the keys Space, Shift+Space, Return or Enter.
> >> """
> >>
> >> i.e. you need to activate the color, just like you'd activate a widget
> >> or a menu item.
> >
> >
> > That seems confusing to me. The way its written (or rather, the way I'm
> > reading it) implies the signal will be emitted on any color change
> > ("activated").
>
> Nope. The term "activated" has a fairly specific meaning, in GTK+, and
> it usually refers to the behaviour of widgets with regards to keyboard
> interaction. See, for instance:
>
>
> https://lazka.github.io/pgi-docs/#Gtk-3.0/classes/Widget.html#Gtk.Widget.activate
>
> In your case, you're using the color editor, which does not have
> "activatable" parts.
>
> > However, using the "notify" signal seems to work as well,
> > although the signal is emitted a few times on startup that I'll have to
> > ignore.
>
> The `notify` signal is emitted every time a property changes; if you
> use `notify::rgba` signal you'll, thus, be notified every time the
> `rgba` property changes to a different value.
>
> In general, GTK+ uses ::changed signals on classes where multiple
> properties can change at the same time, or if what changes is not
> mapped to a property at all; if there are readable properties, it's
> much easier to get notification of changes straight from them.
>
> Ciao,
>  Emmanuele.
>
> --
> https://www.bassi.io
> [@] ebassi [@gmail.com]
>
___
gtk-list mailing list
gtk-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-list