Re: Template Widgets inside another GtkBuilder file

2015-10-07 Thread Victor Aurélio Santos
So the really question becomes, how to get `g_type_ensure` generated
in output code when subclassing Widgets in Vala ?

2015-10-05 17:54 GMT-03:00 Victor Aurélio Santos :
> Emmanuele,
>
>> In order to do that, you should use `g_type_ensure()` inside the
> instance initialization function of the parent's widget class
>
> Since using Vala, from what I can see in case of using [GtkTemplate]
> the g_type_ensure is generated, but when just subclassing a GtkWidget
> it doesn't exists in the generated .c, am I right ?
>
> And what I can do to g_type_ensure be present in generated .c in the
> second case ?
>
> Thanks.
>
> 2015-10-04 10:40 GMT-03:00 Emmanuele Bassi :
>> Hi;
>>
>> On 3 October 2015 at 02:14, Victor Aurélio Santos
>>  wrote:
>>> How can I do that ?
>>> Just build all together results in this warning:
>>>
 (ajami:3475): Gtk-CRITICAL **: Error building template class 
 'AjamiMainWindow' for an instance of type 'AjamiMainWindow': Invalid 
 object type 'HVMeter' on line 2
>>>
>>> I've asked on SO[1] and got only one answer.
>>>
>>> I stick at "_get_type" workaround/hack but I didn't like it and I
>>> can't do the same thing in Vala (I've not found how to do the same
>>> thing).
>>>
>>> More details can be found on SO question.
>>>
>>> So, what I really want to know is what is the best option to
>>> accomplish this in Vala and in C too.
>>>
>>> [1]: 
>>> http://stackoverflow.com/questions/24235937/custom-gtk-widget-with-template-ui
>>
>> If you have an internal, private widget that you use as a child in a
>> template, you'll need to ensure that the type system knows about the
>> child widget's type before initializing the template that references
>> it.
>>
>> In order to do that, you should use `g_type_ensure()` inside the
>> instance initialization function of the parent's widget class, right
>> before calling `gtk_widget_init_template()`; for instance:
>>
>>   g_type_ensure (hv_meter_get_type ());
>>
>> This is also what GTK+ itself does:
>> https://git.gnome.org/browse/gtk+/tree/gtk/gtkfilechooserwidget.c#n8598
>>
>> Ciao,
>>  Emmanuele.
>>
>> --
>> https://www.bassi.io
>> [@] ebassi [@gmail.com]
>
>
>
> --
> Victor Aurélio Santos



-- 
Victor Aurélio Santos
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Filechooserbuttons and gtk_widget_set_sensitive

2015-10-07 Thread Roger Matthews
To someone willing to help,
 
 1) Following the example Listing 4.10 of the GTK+ Development book 
filechooserbuttons.c I have created a filechooser button and label, which are 
attached to a grid rather than a box. When clicked a "dialogue" appears, I can 
then navigate directories to the filtered files, highlight the selected files, 
but when double-clicked or press 'open', nothing happens. That is, the 
path/filename is displayed in the label and the selected filename is displayed 
in the button but the file is not opened. How do I open the file?
 
2) I would like to activate/de-activate spinbuttons depending on whether 
certain other selections have been made (with other integer spinbuttons). I 
have tried using gtk_widget_set_sensitive ( GtkWidget *widget, gboolean 
sensitive) but get compilation warning: unknown type name 'gtk_widget_set'. I'm 
using GTK3. Any clues? 
 
3) I've built a GUI coded in C without using a builder.ui file and would like 
to make it into a stand-alone application, preferably all 'hand' coded, how do 
I do this? I'm having difficulty following the example in the documentation 
because it uses a buider.ui file, I am unsure of the form of the main() format, 
and I can't locate 
https://git.gnome.org/browse/gtk+/tree/examples/application2/exampleappwin.c 
 
Thanks,
Roger Matthews
  
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


gtk_text_buffer_delete ?

2015-10-07 Thread Pierre Wieser
Hello, 

On the application I'm currently working on [1], I want limit the size of the
text entered in a GtkTextBuffer to those saved in the DBMS, so 4096 chars.

I so connected to the 'changed' signal of the GtkTextBuffer, and the handler
is :

static void
on_notes_changed( GtkTextBuffer *buffer, void *empty )
{
static const gchar *thisfn = "my_utils_on_notes_changed";
static const gint MAX_LENGTH = 4096;
static gboolean in = FALSE;
gint count;
GtkTextIter start, end;

/* prevent an infinite recursion */
if( !in ){
count = gtk_text_buffer_get_char_count( buffer );
if( count >= MAX_LENGTH ){
/*
 * this code works, but emit the following Gtk-Warning:
 *
 * Invalid text buffer iterator: either the iterator is
 * uninitialized, or the characters/pixbufs/widgets in 
the
 * buffer have been modified since the iterator was 
created.
 * You must use marks, character numbers, or line 
numbers to
 * preserve a position across buffer modifications.
 * You can apply tags and insert marks without 
invalidating
 * your iterators, but any mutation that affects 
'indexable'
 * buffer contents (contents that can be referred to by 
character
 * offset) will invalidate all outstanding iterators
 */
gtk_text_buffer_get_iter_at_offset( buffer, , 
MAX_LENGTH-1 );
/*gtk_text_iter_backward_char(  );*/
/*gtk_text_buffer_get_iter_at_offset( buffer, , 
count );*/
gtk_text_buffer_get_end_iter( buffer,  );
/*gtk_text_iter_backward_char(  );*/
in = TRUE;
g_debug( "%s: count=%d, start=%d, end=%d",
thisfn, count, 
gtk_text_iter_get_offset(  ), gtk_text_iter_get_offset(  ));
gtk_text_buffer_delete( buffer, ,  );
in = FALSE;
}
}
}

As stated in the comment, the code works (the size if actually limited to 4095 
chars),
but each execution of gtk_text_buffer_delete() triggers the well-known warning
"Invalid text buffer iterator".

I am a bit stucked here, because I do not understand why this happens, as the 
buffer
is not modified between taking the iters and deleting the content...

Can anyone help me in this matter ?

Thanks in advance.
Regards
Pierre
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: gtk_text_buffer_delete ?

2015-10-07 Thread Pierre Wieser

> On the application I'm currently working on [1], I want limit the size of the
> [...]

I omit the application link, for reference ;)

[1] https://github.com/trychlos/openbook/
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: gtk_text_buffer_delete ?

2015-10-07 Thread Jim Charlton

On 15-10-07 04:14 AM, Pierre Wieser wrote:

Hello,

On the application I'm currently working on [1], I want limit the size of the
text entered in a GtkTextBuffer to those saved in the DBMS, so 4096 chars.

I so connected to the 'changed' signal of the GtkTextBuffer, and the handler
is :

static void
on_notes_changed( GtkTextBuffer *buffer, void *empty )
{
static const gchar *thisfn = "my_utils_on_notes_changed";
static const gint MAX_LENGTH = 4096;
static gboolean in = FALSE;
gint count;
GtkTextIter start, end;

/* prevent an infinite recursion */
if( !in ){
count = gtk_text_buffer_get_char_count( buffer );
if( count >= MAX_LENGTH ){
/*
 * this code works, but emit the following Gtk-Warning:
 *
 * Invalid text buffer iterator: either the iterator is
 * uninitialized, or the characters/pixbufs/widgets in 
the
 * buffer have been modified since the iterator was 
created.
 * You must use marks, character numbers, or line 
numbers to
 * preserve a position across buffer modifications.
 * You can apply tags and insert marks without 
invalidating
 * your iterators, but any mutation that affects 
'indexable'
 * buffer contents (contents that can be referred to by 
character
 * offset) will invalidate all outstanding iterators
 */
gtk_text_buffer_get_iter_at_offset( buffer, , 
MAX_LENGTH-1 );
/*gtk_text_iter_backward_char(  );*/
/*gtk_text_buffer_get_iter_at_offset( buffer, , 
count );*/
gtk_text_buffer_get_end_iter( buffer,  );
/*gtk_text_iter_backward_char(  );*/
in = TRUE;
g_debug( "%s: count=%d, start=%d, end=%d",
thisfn, count, gtk_text_iter_get_offset( 
 ), gtk_text_iter_get_offset(  ));
gtk_text_buffer_delete( buffer, ,  );
in = FALSE;
}
}
}

As stated in the comment, the code works (the size if actually limited to 4095 
chars),
but each execution of gtk_text_buffer_delete() triggers the well-known warning
"Invalid text buffer iterator".

I am a bit stucked here, because I do not understand why this happens, as the 
buffer
is not modified between taking the iters and deleting the content...

Can anyone help me in this matter ?

Thanks in advance.
Regards
Pierre
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
I do not have an answer to the problem as stated, but I have written 
code that achieves the overall purpose of pruning the text buffer.

I work in Gtkmm rather than in GTK3.  Here is a snippet of code.
*
start = tb1_ptr->begin();
end = tb1_ptr->end();
if (end.get_offset() > 254) end.set_offset(254);
text = tb1_ptr->get_text(start, end, FALSE);

where
tb1_ptr = Gtk::TextBuffer::create();
Gtk::TextIter start;
Gtk::TextIter end;
Glib::ustring text;

In your case, rather than using gtk_text_buffer_delete, you would use
gtk_text_iter_get_offset (/|const GtkTextIter 
 *iter|/);

and
gtk_text_iter_set_offset (/|GtkTextIter 
 *iter|/, 
/|gint 
 
char_offset|/);


to limit the text buffer to your desired length.

Hope this helps...   Jim...




text = tb1_ptr->get_text(start, end, FALSE);
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Broadway backend fails with ”can't write to client”

2015-10-07 Thread Jay Jay Billings
Everyone,

I am playing with the Broadway backend on Fedora 21 and I am getting a
”can't write to client” error. It works fine with simple applications like
gedit, but it hangs and prints this error on more complicated applications
like Eclipse. Specifically, I get one good click or tooltip access in
Eclipse before it fails and, after a bit, disconnects and prints a wall of
these errors in the broadwayd shell.

Fedora 22 makes it three clicks before crashing. On that machine I'm
running gtk3.16.7.

As far as I could tell from the Broadway source code, this is a generic
error printed whenever the output stream can't be written. Could anyone
give me some more suggestions on how to fix this? I'm willing to jump into
the code too if you have some developer "getting started" docs.

Thanks for your help and sorry if this is the wrong list.

Best,
Jay



-- 
Jay Jay Billings
Oak Ridge National Laboratory
Twitter Handle: @jayjaybillings
___
gtk-devel-list mailing list
gtk-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-devel-list


Re: gtk_text_buffer_delete ?

2015-10-07 Thread Stefan Salewski
On Wed, 2015-10-07 at 13:14 +0200, Pierre Wieser wrote:
> Hello, 
> 
> On the application I'm currently working on [1], I want limit the size
> of the
> text entered in a GtkTextBuffer to those saved in the DBMS, so 4096
> chars.

Seen that:

http://www.gtkforums.com/viewtopic.php?t=1012

Very similar to your solution, but I think that was GTK2, and your is
GTK3.

No other idea, sorry.
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: gtk_text_buffer_delete ?

2015-10-07 Thread Stefan Salewski
On Wed, 2015-10-07 at 13:14 +0200, Pierre Wieser wrote:
> I so connected to the 'changed' signal of the GtkTextBuffer,

Maybe try connecting to insert-text signal -- changed signal may be
emitted again when you delete. See

http://stackoverflow.com/questions/2791035/how-do-i-set-buffer-limit-for
-gtk-text-view-in-c
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


Re: gtk_text_buffer_delete ?

2015-10-07 Thread Pierre Wieser

On Wed, 2015-10-07 at 15:05 +0200, Stefan Salewski wrote:

> On Wed, 2015-10-07 at 13:14 +0200, Pierre Wieser wrote:
>> Hello, 
>> 
>> On the application I'm currently working on [1], I want limit the size
>> of the
>> text entered in a GtkTextBuffer to those saved in the DBMS, so 4096
>> chars.
>
> Seen that:
>
> http://www.gtkforums.com/viewtopic.php?t=1012
>
> Very similar to your solution, but I think that was GTK2, and your is
> GTK3.

Hi Stefan,

Thanks for your interest, but the thread you point to is actually the one
on which I based my own code.
I do not think that GTK2 vs GTK3 is a point in this matter, do you ?

> No other idea, sorry.

And Google has not been my friend further...
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list