Re: Please help (core dump)

2020-07-28 Thread aitor

Hi,

On 27/7/20 14:00, Carlo Wood  wrote:

Hi aitor,

thank you so much for your examples!
I will definitely study them in depth as soon as I get
my current problem resolved of how to add a 'Mode' to
my menu having a separate Gtk::Builder (aka, how to
combine multiple Gtk::Builder objects into a single
menu). Or, alternatively, I could have just a single
Gtk::Builder object, but then I still need to be
able to somehow add a Gio::SimpleActionGroup to my
menu.

It seems that your approach is entirely different:
you have a MenuBar class that deals with everything
related to the menu. From an object oriented point
of view that makes a lot of sense. You're not using
Gtk::Builder at all, but - instead of using an xml
string - hardcode the menu into the constructor of
myMenuBar.



Yes, Gtk::Builder is cool, but the other point of view simplifies 
dynamic changes because
you can define an iterator which can be used for the addition/removal of 
the items in the

menu.



For some reason you're passing `*this` to every
sigc::mem_fun - aka*all*  `on_menu_*` menu callbacks
are member functions of myMenuBar. I'd prefer it
if I could use callbacks that are member functions
of several different objects (namely those that
they operate on). I suppose I can do that by passing
a pointer to all those objects to the constructor
of myMenuBar. Currently you pass only a WindowMain*,
for the on_menu_mode_quit method.

Why are you using the construct of passing this WindowMain*
as an argument to myMenuBar::on_menu_mode_quit?
Wouldn't it be possible, and make more sense, to do:

 m_QuitItem->signal_activate().connect (
 sigc::mem_fun(*caller, ::on_menu_mode_quit)
 );

?



The sort answer: Yes, you are write! It makes more sense in the other 
way around, so i left the

callbackas follows:

m_QuitItem->signal_activate().connect (
            sigc::mem_fun(*caller, ::hide)
);

Indeed, i was doing something similar in the callback of the status icon 
of my new
network manager. I still didn't finish it, but shortly i'll share the 
code here in the mailing list.

Anyway, I can give you a link to the backend so far:

https://git.devuan.org/aitor_czr/libnetaid

Thanks for your constructive correctness :)

Aitor.





___
gtkmm-list mailing list
gtkmm-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtkmm-list


Re: Merging UI strings into Gtk::Builder?

2020-07-28 Thread Kjell Ahlstedt via gtkmm-list
I made some tests with the menus_and_toolbars example in 
gtkmm-documentation. Something like this will probably work:


  Glib::ustring ui_info =
""
"  "
""
...
""
"  "
"";

  Glib::ustring ui_info2 =
""
"  "
""
...
""
"  "
"";

  m_refBuilder = Gtk::Builder::create();
  m_refBuilder->add_from_string(ui_info);
  m_refBuilder->add_from_string(ui_info2);   auto object = 
m_refBuilder->get_object("menu-linuxchess");
  auto gmenu = Glib::RefPtr::cast_dynamic(object);
  if (gmenu)
  {
auto subobject = m_refBuilder->get_object("xyz");
auto gsubmenu = Glib::RefPtr::cast_dynamic(subobject);
if (gsubmenu)
  gmenu->append_submenu("SomeLabel", gsubmenu);
  }

On 2020-07-27 15:50, Carlo Wood wrote:

Hi,

the documentation at

https://developer.gnome.org/gtkmm/stable/classGtk_1_1Builder.html#ae3520ee31a98ac30b728f93522de8df5

says: "Parses a string containing a GtkBuilder UI definition and merges
it with the current contents of the builder."

But when I try this:

   Glib::ustring ui_info =
 ""
 "  "
 ""
...
 ""
 "  "
 "";

   Glib::ustring ui_info2 =
 ""
 "  "
 ""
...
 ""
 "  "
 "";

   m_refBuilder = Gtk::Builder::create();
   m_refBuilder->add_from_string(ui_info);
   m_refBuilder->add_from_string(ui_info2);

Then the last line *replaces* the content of m_refBuilder.
Nothing is merged, I just get a menu with the definition
from ui_info2.

How can I do this?
___
gtkmm-list mailing list
gtkmm-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtkmm-list