Re: Merging UI strings into Gtk::Builder?

2020-07-27 Thread Carlo Wood
On Mon, 27 Jul 2020 07:23:30 -0700
Phil Wolff via gtkmm-list  wrote:

> Both definitions specify the same string for the menu id, so the
> second definition updates/overwrites the first one. Try using 
> 'menu-linuxchess-2' in the second one...

That won't help... it is one single menu:

  auto object = m_refBuilder->get_object("menu-linuxchess");
  auto gmenu = Glib::RefPtr::cast_dynamic(object);
  if (!gmenu) {
g_warning("GMenu not found");
  }
  else
  {
set_menubar(gmenu);
  }

___
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-27 Thread Phil Wolff via gtkmm-list
Both definitions specify the same string for the menu id, so the second 
definition updates/overwrites the first one. Try using 
'menu-linuxchess-2' in the second one...


On 7/27/20 6:50 AM, 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

--
What was that about a rising tide lifting all boats? What if you don't 
have a boat?

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


Merging UI strings into Gtk::Builder?

2020-07-27 Thread Carlo Wood
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


Re: Please help

2020-07-27 Thread Carlo Wood
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.

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)
);

?


On Sun, 26 Jul 2020 20:56:15 +0200
aitor  wrote:

> Hi again,
> 
> On 26/7/20 14:00, aitor_czr  wrote:
> > In the next examples i'll explain how to add an icon factory for
> > your custom stock icons and how to add the toolbar to
> >
> > the project. They'll be uploaded to the following link:
> >
> > https://www.gnuinos.org/Gtkmm%20Examples/
> >
> > Hope this helps,  
> 
> Finally, I added the toolbar with the custom icons:
> 
> https://www.gnuinos.org/Gtkmm%20Examples/Example_4/
> 
> Quote.- The SeparatorToolItem at the left of the last item is missing
> in Gtkmm3:
> 
> https://www.gnuinos.org/Gtkmm%20Examples/Example_4/screenshot.png
> 
> This separator only appears in Gtkmm-2.4 ...
> 
> Cheers,
> 
> Aitor.
> 
> 

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


Re: Please help (core dump)

2020-07-27 Thread Kjell Ahlstedt via gtkmm-list

On 2020-07-27 09:40, Carlo Wood wrote:

Is there an example somewhere that shows how I can combine the
`void on_menu_mode_*()` member functions of a widget that is not
derived (indirectly) from Gio::ActionMap to the menu of the window
that this widgets belongs to?

Thanks,
Carlo Wood


Look at 
https://gitlab.gnome.org/GNOME/gtkmm-documentation/-/blob/gtkmm-3-24/examples/book/menus_and_toolbars/examplewindow.cc


I think that's what you can do. Create a Gio::SimpleActionGroup. Add 
your actions to it. Insert it in your widget with Gtk::Widget's 
insert_action_group() method. In the call to insert_action_group() you 
choose what prefix to use in the ui file.


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


Re: Please help (core dump)

2020-07-27 Thread Carlo Wood
On Sun, 26 Jul 2020 20:22:43 +0100
Daniel Boles via gtkmm-list  wrote:

> On Sun, 26 Jul 2020, 20:21 Carlo Wood,  wrote:
> 
> >
> > I'm not sure what you mean with doing
> >
> > LinuxChessboardWidget(..) : Glib::ObjectBase("myWidgetClass")
> >
> > since Glib::ObjectBase is a base class of Gio::ActionMap,
> > I can't call that from LinuxChessboardWidget no?
> >  
> 
> yes, you can: research "virtual base classes"

I don't have to research that :p. I realized that this is possible
when Glib::ObjectBase is a virtual base class; that is why I looked
on https://developer.gnome.org/glibmm/stable/classGio_1_1ActionMap.html

and since there I saw no indication whatsoever that ObjectBase would
be a virtual base class, I concluded it wasn't :/.

I hope my other questions can be answered too, since Kjell said
that deriving from Gio::ActionMap was very unusual and apparently
not the route I should take.

Is there an example somewhere that shows how I can combine the
`void on_menu_mode_*()` member functions of a widget that is not
derived (indirectly) from Gio::ActionMap to the menu of the window
that this widgets belongs to?

Thanks,
Carlo Wood

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