/* Copyright (C) 2012 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see .
*/
#include
#include
namespace Gtk
{
ApplicationWindow::ApplicationWindow(const Glib::RefPtr& application)
:
// Mark this class as non-derived to allow C++ vfuncs to be skipped.
Glib::ObjectBase(nullptr),
Gtk::Window(Glib::ConstructParams(applicationwindow_class_.init()))
{
// Don't set the "application" property in ConstructParams. It would result in
// an attempt to set two C++ wrappers on the GApplicationWindow C object,
// if "application" is not a plain Gtk::Application, but derived from it.
// Like so:
// - Glib::Object::Object(const Glib::ConstructParams& construct_params) calls
// g_object_newv() to create a new GApplicationWindow.
// - In gtk+, gtk_application_add_window() is called. It emits the window_added
// signal with the new GApplicationWindow as a parameter.
// - Application_signal_window_added_callback() calls Glib::wrap(GWindow*)
// before *this has been set as the wrapper. Glib::wrap() then creates a
// wrapper (not *this).
// - Glib::Object::Object() calls Glib::ObjectBase::initialize(), which calls
// Glib::ObjectBase::_set_current_wrapper() to set *this as the C++ wrapper,
// but by then another wrapper has already been set.
// https://bugzilla.gnome.org/show_bug.cgi?id=758813
if (application)
application->add_window(*this);
}
void ApplicationWindow::unset_help_overlay()
{
gtk_application_window_set_help_overlay(gobj(), nullptr);
}
_DEPRECATE_IFDEF_START
GtkApplicationWindow* ApplicationWindow::gobj_copy()
{
reference();
return gobj();
}
_DEPRECATE_IFDEF_END
} // namespace Gtk
_DEPRECATE_IFDEF_START
namespace Glib
{
//TODO: This wrap() function is broken. Remove it at the next ABI-break.
Glib::RefPtr wrap(GtkApplicationWindow* object, bool take_copy)
{
g_warning("Glib::wrap(GtkApplicationWindow*, bool) is broken. See the reference documentation.\n");
return Glib::RefPtr(dynamic_cast(Glib::wrap_auto((GObject*)(object), take_copy)));
//We use dynamic_cast<> in case of multiple inheritance.
}
} /* namespace Glib */
_DEPRECATE_IFDEF_END