Cell_Renderer_Combo: how to act on characters typed to show match in combo

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Cell_Renderer_Combo: how to act on characters typed to show match in combo

Rob Groen
Hello,

With a Cell_Renderer_Combo in a Tree_View I would like to act on typed
characters and show the nearest match in the Combo. The
Cell_Renderer_Combo has the property Has_Entry_Property set to True.
However, I don't see an appropriate signal to react on, nor any way to
get to the entry and associated buffer; that is needed to show the
non-typed part of the match as being selected.

How can I do this with Gtkada?

Regards
Rob Groen

_______________________________________________
gtkada mailing list
[hidden email]
https://lists.adacore.com/mailman/listinfo/gtkada
Reply | Threaded
Open this post in threaded view
|

Re: Cell_Renderer_Combo: how to act on characters typed to show match in combo

Op de Coul, Manuel-2
Hoi Rob,

with Gtk.Entry_Completion; use Gtk.Entry_Completion;

      Result : Gtk_Entry;
      List   : Gtk_List_Store;
      Compl  : Gtk_Entry_Completion;
      Iter   : Gtk.Tree_Model.Gtk_Tree_Iter;

      Gtk_New (List, GType_Array'(GType_String, GType_String)); --example with two columns
-- fill this list with your items for example:

            Append (List, Iter);
            Set (List, Iter, 0, "item 1");

--create your combo box and renderer(s)

--create the entry completion

      Result := Get_Entry (The_Combo);

      Gtk_New (Compl);
      Set_Model (Compl, Gtk.Tree_Model.Gtk_Tree_Model(List));
      Set_Text_Column (Compl, 0);
      Set_Text_Column (Compl, 1);
      Set_Property (Compl, Text_Column_Property, 0);
      Set_Inline_Completion (Compl, True);
      Set_Popup_Single_Match (Compl, False);
      Set_Completion (Result, Compl);
      Unref (List);
      Unref (Compl);
      Combo_Box_Callback.Connect (The_Combo, "changed",
        Combo_Box_Callback.To_Marshaller (On_The_Combo_Changed'Access));
--end

Greetings,
Manuel

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Rob Groen
Sent: woensdag 25 april 2018 9:20
To: [hidden email]
Subject: [gtkada] Cell_Renderer_Combo: how to act on characters typed to show match in combo

Hello,

With a Cell_Renderer_Combo in a Tree_View I would like to act on typed characters and show the nearest match in the Combo. The Cell_Renderer_Combo has the property Has_Entry_Property set to True.
However, I don't see an appropriate signal to react on, nor any way to get to the entry and associated buffer; that is needed to show the non-typed part of the match as being selected.

How can I do this with Gtkada?

Regards
Rob Groen

_______________________________________________
gtkada mailing list
[hidden email]
https://lists.adacore.com/mailman/listinfo/gtkada
_______________________________________________
gtkada mailing list
[hidden email]
https://lists.adacore.com/mailman/listinfo/gtkada
Reply | Threaded
Open this post in threaded view
|

Re: Cell_Renderer_Combo: how to act on characters typed to show match in combo

Rob Groen

Hoi Manuel,


Thanks for your answer. The thing is, I don't have a GtkCombo, instead it is a GtkCellRendererCombo. On the latter I can't do a Get_Entry. However, when googling on this topic, I found a hint: connect the renderer to signal "edited-started", in the handler one of the params is a GtkEditable. I suppose that is the entry I need to do what you suggest.

Regards, Rob


 

On 2018-04-26 11:52, Op de Coul, Manuel wrote:

Hoi Rob,

with Gtk.Entry_Completion; use Gtk.Entry_Completion;

      Result : Gtk_Entry;
      List   : Gtk_List_Store;
      Compl  : Gtk_Entry_Completion;
      Iter   : Gtk.Tree_Model.Gtk_Tree_Iter;

      Gtk_New (List, GType_Array'(GType_String, GType_String)); --example with two columns
-- fill this list with your items for example:

            Append (List, Iter);
            Set (List, Iter, 0, "item 1");

--create your combo box and renderer(s)

--create the entry completion

      Result := Get_Entry (The_Combo);

      Gtk_New (Compl);
      Set_Model (Compl, Gtk.Tree_Model.Gtk_Tree_Model(List));
      Set_Text_Column (Compl, 0);
      Set_Text_Column (Compl, 1);
      Set_Property (Compl, Text_Column_Property, 0);
      Set_Inline_Completion (Compl, True);
      Set_Popup_Single_Match (Compl, False);
      Set_Completion (Result, Compl);
      Unref (List);
      Unref (Compl);
      Combo_Box_Callback.Connect (The_Combo, "changed",
        Combo_Box_Callback.To_Marshaller (On_The_Combo_Changed'Access));
--end

Greetings,
Manuel

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Rob Groen
Sent: woensdag 25 april 2018 9:20
To: [hidden email]
Subject: [gtkada] Cell_Renderer_Combo: how to act on characters typed to show match in combo

Hello,

With a Cell_Renderer_Combo in a Tree_View I would like to act on typed characters and show the nearest match in the Combo. The Cell_Renderer_Combo has the property Has_Entry_Property set to True.
However, I don't see an appropriate signal to react on, nor any way to get to the entry and associated buffer; that is needed to show the non-typed part of the match as being selected.

How can I do this with Gtkada?

Regards
Rob Groen

_______________________________________________
gtkada mailing list
[hidden email]
https://lists.adacore.com/mailman/listinfo/gtkada

_______________________________________________
gtkada mailing list
[hidden email]
https://lists.adacore.com/mailman/listinfo/gtkada
Reply | Threaded
Open this post in threaded view
|

Re: Cell_Renderer_Combo: how to act on characters typed to show match in combo

Op de Coul, Manuel-2

I see, then first try this, will be easier:

 

Result := Gtk_Entry(Get_Child (MyRendererCombo));

 

Cheers,

Manuel

 

From: Rob Groen [mailto:[hidden email]]
Sent: donderdag 26 april 2018 13:30
To: Op de Coul, Manuel <[hidden email]>
Cc: [hidden email]
Subject: Re: [gtkada] Cell_Renderer_Combo: how to act on characters typed to show match in combo

 

Hoi Manuel,

 

Thanks for your answer. The thing is, I don't have a GtkCombo, instead it is a GtkCellRendererCombo. On the latter I can't do a Get_Entry. However, when googling on this topic, I found a hint: connect the renderer to signal "edited-started", in the handler one of the params is a GtkEditable. I suppose that is the entry I need to do what you suggest.

Regards, Rob

 

 

On 2018-04-26 11:52, Op de Coul, Manuel wrote:

Hoi Rob,

with Gtk.Entry_Completion; use Gtk.Entry_Completion;

      Result : Gtk_Entry;
      List   : Gtk_List_Store;
      Compl  : Gtk_Entry_Completion;
      Iter   : Gtk.Tree_Model.Gtk_Tree_Iter;

      Gtk_New (List, GType_Array'(GType_String, GType_String)); --example with two columns
-- fill this list with your items for example:

            Append (List, Iter);
            Set (List, Iter, 0, "item 1");

--create your combo box and renderer(s)

--create the entry completion

      Result := Get_Entry (The_Combo);

      Gtk_New (Compl);
      Set_Model (Compl, Gtk.Tree_Model.Gtk_Tree_Model(List));
      Set_Text_Column (Compl, 0);
      Set_Text_Column (Compl, 1);
      Set_Property (Compl, Text_Column_Property, 0);
      Set_Inline_Completion (Compl, True);
      Set_Popup_Single_Match (Compl, False);
      Set_Completion (Result, Compl);
      Unref (List);
      Unref (Compl);
      Combo_Box_Callback.Connect (The_Combo, "changed",
        Combo_Box_Callback.To_Marshaller (On_The_Combo_Changed'Access));
--end

Greetings,
Manuel

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Rob Groen
Sent: woensdag 25 april 2018 9:20
To: [hidden email]
Subject: [gtkada] Cell_Renderer_Combo: how to act on characters typed to show match in combo

Hello,

With a Cell_Renderer_Combo in a Tree_View I would like to act on typed characters and show the nearest match in the Combo. The Cell_Renderer_Combo has the property Has_Entry_Property set to True.
However, I don't see an appropriate signal to react on, nor any way to get to the entry and associated buffer; that is needed to show the non-typed part of the match as being selected.

How can I do this with Gtkada?

Regards
Rob Groen

_______________________________________________
gtkada mailing list
[hidden email]
https://lists.adacore.com/mailman/listinfo/gtkada


_______________________________________________
gtkada mailing list
[hidden email]
https://lists.adacore.com/mailman/listinfo/gtkada
Reply | Threaded
Open this post in threaded view
|

Re: Cell_Renderer_Combo: how to act on characters typed to show match in combo

Rob Groen
Not possible, There is no Get_Child for a GtkCellRendererCombo; it is a Gobject, not a GtkWidget.

On 26-Apr-18 13:41, Op de Coul, Manuel wrote:

I see, then first try this, will be easier:

 

Result := Gtk_Entry(Get_Child (MyRendererCombo));

 

Cheers,

Manuel

 

From: Rob Groen [[hidden email]]
Sent: donderdag 26 april 2018 13:30
To: Op de Coul, Manuel [hidden email]
Cc: [hidden email]
Subject: Re: [gtkada] Cell_Renderer_Combo: how to act on characters typed to show match in combo

 

Hoi Manuel,

 

Thanks for your answer. The thing is, I don't have a GtkCombo, instead it is a GtkCellRendererCombo. On the latter I can't do a Get_Entry. However, when googling on this topic, I found a hint: connect the renderer to signal "edited-started", in the handler one of the params is a GtkEditable. I suppose that is the entry I need to do what you suggest.

Regards, Rob

 

 

On 2018-04-26 11:52, Op de Coul, Manuel wrote:

Hoi Rob,

with Gtk.Entry_Completion; use Gtk.Entry_Completion;

      Result : Gtk_Entry;
      List   : Gtk_List_Store;
      Compl  : Gtk_Entry_Completion;
      Iter   : Gtk.Tree_Model.Gtk_Tree_Iter;

      Gtk_New (List, GType_Array'(GType_String, GType_String)); --example with two columns
-- fill this list with your items for example:

            Append (List, Iter);
            Set (List, Iter, 0, "item 1");

--create your combo box and renderer(s)

--create the entry completion

      Result := Get_Entry (The_Combo);

      Gtk_New (Compl);
      Set_Model (Compl, Gtk.Tree_Model.Gtk_Tree_Model(List));
      Set_Text_Column (Compl, 0);
      Set_Text_Column (Compl, 1);
      Set_Property (Compl, Text_Column_Property, 0);
      Set_Inline_Completion (Compl, True);
      Set_Popup_Single_Match (Compl, False);
      Set_Completion (Result, Compl);
      Unref (List);
      Unref (Compl);
      Combo_Box_Callback.Connect (The_Combo, "changed",
        Combo_Box_Callback.To_Marshaller (On_The_Combo_Changed'Access));
--end

Greetings,
Manuel

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Rob Groen
Sent: woensdag 25 april 2018 9:20
To: [hidden email]
Subject: [gtkada] Cell_Renderer_Combo: how to act on characters typed to show match in combo

Hello,

With a Cell_Renderer_Combo in a Tree_View I would like to act on typed characters and show the nearest match in the Combo. The Cell_Renderer_Combo has the property Has_Entry_Property set to True.
However, I don't see an appropriate signal to react on, nor any way to get to the entry and associated buffer; that is needed to show the non-typed part of the match as being selected.

How can I do this with Gtkada?

Regards
Rob Groen

_______________________________________________
gtkada mailing list
[hidden email]
https://lists.adacore.com/mailman/listinfo/gtkada


-- 
Rob
---------------
There is a moral duty to be optimistic - Karl Popper

_______________________________________________
gtkada mailing list
[hidden email]
https://lists.adacore.com/mailman/listinfo/gtkada
Reply | Threaded
Open this post in threaded view
|

Re: Cell_Renderer_Combo: how to act on characters typed to show match in combo

Rob Groen
In reply to this post by Op de Coul, Manuel-2

I finally succeeded getting the code-sample from Manuel working.
The Gtk_Cell_Editable that is one of the params in the "editing-started" signal appears to be a Gtk_Combo_Box. Using Get_Child on the combo box gets the entry, using Get_Model on the combo gets the model. The rest is as Manuel described.
Thanks for setting me in the right direction.

Regards, Rob

On 26-Apr-18 13:41, Op de Coul, Manuel wrote:

I see, then first try this, will be easier:

 

Result := Gtk_Entry(Get_Child (MyRendererCombo));

 

Cheers,

Manuel

 

From: Rob Groen [[hidden email]]
Sent: donderdag 26 april 2018 13:30
To: Op de Coul, Manuel [hidden email]
Cc: [hidden email]
Subject: Re: [gtkada] Cell_Renderer_Combo: how to act on characters typed to show match in combo

 

Hoi Manuel,

 

Thanks for your answer. The thing is, I don't have a GtkCombo, instead it is a GtkCellRendererCombo. On the latter I can't do a Get_Entry. However, when googling on this topic, I found a hint: connect the renderer to signal "edited-started", in the handler one of the params is a GtkEditable. I suppose that is the entry I need to do what you suggest.

Regards, Rob

 

 

On 2018-04-26 11:52, Op de Coul, Manuel wrote:

Hoi Rob,

with Gtk.Entry_Completion; use Gtk.Entry_Completion;

      Result : Gtk_Entry;
      List   : Gtk_List_Store;
      Compl  : Gtk_Entry_Completion;
      Iter   : Gtk.Tree_Model.Gtk_Tree_Iter;

      Gtk_New (List, GType_Array'(GType_String, GType_String)); --example with two columns
-- fill this list with your items for example:

            Append (List, Iter);
            Set (List, Iter, 0, "item 1");

--create your combo box and renderer(s)

--create the entry completion

      Result := Get_Entry (The_Combo);

      Gtk_New (Compl);
      Set_Model (Compl, Gtk.Tree_Model.Gtk_Tree_Model(List));
      Set_Text_Column (Compl, 0);
      Set_Text_Column (Compl, 1);
      Set_Property (Compl, Text_Column_Property, 0);
      Set_Inline_Completion (Compl, True);
      Set_Popup_Single_Match (Compl, False);
      Set_Completion (Result, Compl);
      Unref (List);
      Unref (Compl);
      Combo_Box_Callback.Connect (The_Combo, "changed",
        Combo_Box_Callback.To_Marshaller (On_The_Combo_Changed'Access));
--end

Greetings,
Manuel

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Rob Groen
Sent: woensdag 25 april 2018 9:20
To: [hidden email]
Subject: [gtkada] Cell_Renderer_Combo: how to act on characters typed to show match in combo

Hello,

With a Cell_Renderer_Combo in a Tree_View I would like to act on typed characters and show the nearest match in the Combo. The Cell_Renderer_Combo has the property Has_Entry_Property set to True.
However, I don't see an appropriate signal to react on, nor any way to get to the entry and associated buffer; that is needed to show the non-typed part of the match as being selected.

How can I do this with Gtkada?

Regards
Rob Groen

_______________________________________________
gtkada mailing list
[hidden email]
https://lists.adacore.com/mailman/listinfo/gtkada


-- 
Rob
---------------
There is a moral duty to be optimistic - Karl Popper

_______________________________________________
gtkada mailing list
[hidden email]
https://lists.adacore.com/mailman/listinfo/gtkada