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 ...

Dan
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-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
  void
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");

}

. . .
main(...)
 . . .
italp = gtk_text_buffer_create_tag(buffer, "ital", "style",
PANGO_STYLE_ITALIC, NULL);
boldp =gtk_text_buffer_create_tag(buffer, "bold", "weight",
PANGO_WEIGHT_BOLD, NULL);
ulinep = gtk_text_buffer_create_tag(buffer, "uline", "underline",
PANGO_UNDERLINE_SINGLE, NULL);

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



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.
>
> https://developer.gnome.org/gtk3/stable/chap-drawing-model.html
>
> 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
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-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?

Code:

for(i=0;i<2;i++)
if(xHouseList[i].box == NULL){
xHouseList[i].box = gtk_box_new(GTK_ORIENTATION_VERTICAL,0);
xHouseList[i].button = gtk_button_new();
//gtk_grid_attach(GTK_GRID(),,i,j,1,1);
gtk_widget_set_size_request (xHouseList[i].button,256,-1);
//gtk_widget_get_preferred_width_for_height 
(xHouseList[i].button,266,256,NULL);
//gtk_widget_get_preferred_width 
(xHouseList[i].button,256,NULL);
gtk_box_pack_start (GTK_BOX(gtk_builder_get_object(builder, 
"Home_Houses_Box")),xHouseList[i].button,FALSE,TRUE,0);
if(i==0)
g_signal_connect (xHouseList[i].button, "clicked", 
G_CALLBACK (on_House_Button_clicked), NULL);

gtk_container_add(xHouseList[i].button,xHouseList[i].box);

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

gtk_widget_set_name(xHouseList[i].name_label,"House_Name_Label");

//gtk_style_context_add_class(gtk_widget_get_style_context(xHouseList[i].name_label),"House_Name_Label");
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");
gtk_box_pack_start 
(GTK_BOX(box),xHouseList[i].hum_label,TRUE,TRUE,0);
gtk_label_set_xalign(GTK_LABEL(xHouseList[i].hum_label),1.0);

gtk_widget_set_name(xHouseList[i].hum_label,"House_Hum_Num");
label = gtk_label_new("%");
gtk_label_set_xalign (GTK_LABEL(label),1.0);
gtk_box_pack_start (GTK_BOX(box),label,TRUE,TRUE,1);
gtk_widget_set_name(label,"House_Hum_Label");
//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");
gtk_box_pack_start 
(GTK_BOX(box),xHouseList[i].temp_label,TRUE,TRUE,1);
gtk_label_set_xalign(GTK_LABEL(xHouseList[i].temp_label),1);

gtk_widget_set_name(xHouseList[i].temp_label,"House_Temp_Num");
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);
gtk_widget_set_name(label,"House_Temp_Label");


gtk_style_context_add_class(gtk_widget_get_style_context(xHouseList[i].box),"House_Box");
//g_object_unref(label);

}


Thanks

À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:

No,

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?
https://stackoverflow.com/questions/44547398/undefined-reference-to-gtk-label-set-xalign

Thanks


---
Este e-mail foi verificado em termos de vírus pelo software antivírus Avast.
https://www.avast.com/antivirus

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





[https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]
  Sem vírus. 
www.avast.com
___
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list