Find path under mouse

2017-06-19 Thread Daniel Kasak
Hi all. Reposting from the gtk-perl list ... no responses there ...

Back in gtk+-2.x, I had some code that could find the path underneath
the mouse ( I was looking for double-click events in a treeview in
this case ):


my ( $self, $treeview, $event ) = @_;

if ( $event->type eq '2button-press' ) {

# A double-click event

if ( $event->window == $treeview->get_bin_window ) {

my ( $path, $column, $cell_x, $cell_y ) =
$treeview->get_path_at_pos ( $event->x, $event->y );


Now I'm doing something similar in gtk+-3.x. I've set up an event
handler for keypress events, and I'm successfully catching the CTRL-C
keypress event. But I don't see immediately how to get the path /
position under the mouse ...

gtk-app-devel-list mailing list

Re: turn on italics in TextView

2017-06-19 Thread Doug McCasland
​Thanks again.  That works, but ​the state is lost when the cursor is
moved.  Here is some code to discover multiple styles after the cursor is
moved.  The pointers to the style tags are saved in globals, then in the
callback for the cursor move, we look for those pointers in the linked-list
returned by gtk_text_iter_get_tag().  I tried to use some of the other
link-list functions/macros, such as g_slist_position, but could only
get gtk_text_iter_get_tag() to work.  Maybe there's a more efficient way to
do this.

// globals
GSList *gtk_text_iter_get_tags (const GtkTextIter *iter);
GtkTextTag *italp, *boldp, *ulinep;

// call back after cursor is moved
get_style(GtkTextView *tv, GtkMovementStep step,
gint count, gboolean extend, gpointer *user_data)  {
GSList *tlist;
GtkTextIter start;
GtkTextMark *mark;
GtkTextBuffer *buf;

buf = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tv));

mark = gtk_text_buffer_get_insert(buf);
gtk_text_buffer_get_iter_at_mark (buf, , mark);

tlist = gtk_text_iter_get_tags();

// look for each style -- could used to set bits in a bitfield
if (g_slist_find(tlist, italp))
g_printerr("got match for ital\n");
if (g_slist_find(tlist, boldp))
g_printerr("got match for bold\n");
if (g_slist_find(tlist, ulinep))
g_printerr("got match for uline\n");


. . .
 . . .
italp = gtk_text_buffer_create_tag(buffer, "ital", "style",
boldp =gtk_text_buffer_create_tag(buffer, "bold", "weight",
ulinep = gtk_text_buffer_create_tag(buffer, "uline", "underline",

g_signal_connect_after(text_view, "move-cursor", G_CALLBACK(get_style),
. . .

On Wed, Jun 14, 2017 at 10:48 AM,  wrote:

> Here are a few things that might improve the above code a little. Use
> gtk_button_set_focus_on_click(GTK_BUTTON(toggle1), FALSE);
> instead of a grab. Also the global gboolean can be eliminated if you pass
> the toggle button pointer to the "insert-text" callback. Then you can just
> use
> if(gtk_toggle_button_get_active(user_data))
> For the sequence of events it is my understanding that the text changes
> will be made during the event cycle before the window gets re-painted.
> Eric
> -Original Message-
> From: Doug McCasland 
> To: cecashon 
> Sent: Tue, Jun 13, 2017 4:09 pm
> Subject: Re: turn on italics in TextView
> cecashon, thanks so much for your great reply!
> I had tried all those calls, but I hadn't put them together as you did,
> nor did I apply the tag in the way your code does.  And I didn't think of
> having one signal/function for the button-down and another for the
> apply_tag_by_name.  Cool!
> So your code gets a signal after the character(s) is entered. Then the
> style is applied to that char, without moving the insert point.  Do you
> know if the un-tagged char is visibly displayed first, and then altered?
> Or is all the processing somehow finished before the display changes, and
> then only the tagged char is put on the screen.

Doug McCasland   
gtk-app-devel-list mailing list

Re: undefined reference to gtk label set xalign

2017-06-19 Thread Rúben Rodrigues
I add the full library path to linker and works, but now the function don't 
makes anything id xalign is 1.0. A change to 0.0 and works.. What's going on?


if(xHouseList[i].box == NULL){
xHouseList[i].box = gtk_box_new(GTK_ORIENTATION_VERTICAL,0);
xHouseList[i].button = gtk_button_new();
gtk_widget_set_size_request (xHouseList[i].button,256,-1);
gtk_box_pack_start (GTK_BOX(gtk_builder_get_object(builder, 
g_signal_connect (xHouseList[i].button, "clicked", 
G_CALLBACK (on_House_Button_clicked), NULL);


sprintf(pcTmp,"Pavilhão %d",i+1);
xHouseList[i].name_label = gtk_label_new(pcTmp);


gtk_widget_set_margin_top (xHouseList[i].name_label,10);
//HUmidity Box
box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
gtk_box_pack_start (GTK_BOX(xHouseList[i].box),box,TRUE,TRUE,0);
xHouseList[i].hum_label = gtk_label_new("50");

label = gtk_label_new("%");
gtk_label_set_xalign (GTK_LABEL(label),1.0);
gtk_box_pack_start (GTK_BOX(box),label,TRUE,TRUE,1);
//Temperature Box
box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL,0);
gtk_box_pack_start (GTK_BOX(xHouseList[i].box),box,TRUE,TRUE,0);
xHouseList[i].temp_label = gtk_label_new("32");

label = gtk_label_new("ºC");
gtk_label_set_xalign (GTK_LABEL(label),1.0);
gtk_box_pack_start (GTK_BOX(box),label,TRUE,TRUE,1);




Às 14:38 de 17/06/2017, Chris Moller escreveu:
ldconfig creates links and caches for runtime libraries.  It looks like, even 
though you've installed GTK+ 3.22, it's not yet in the runtime library path and 
you're still linking to GTK+ 3.14, which doesn't have gtk_label_set_xalign.  
Running ldconfig might fix this.

Chris Moller

On 06/17/17 06:11, Rúben Rodrigues wrote:


What this makes?

Às 03:04 de 17/06/2017, Chris Moller escreveu:
Have you tried running sudo /sbin/ldconfig since you installed 3.22.12?

On 06/16/17 04:58, Rúben Rodrigues wrote:

Hi guys,

Someone could help with this?


Este e-mail foi verificado em termos de vírus pelo software antivírus Avast.

gtk-app-devel-list mailing list

  Sem vírus.
gtk-app-devel-list mailing list