| 1 |
/* Copyright (C) 2012 The gtkmm Development Team |
| 2 |
* |
| 3 |
* This library is free software; you can redistribute it and/or |
| 4 |
* modify it under the terms of the GNU Lesser General Public |
| 5 |
* License as published by the Free Software Foundation; either |
| 6 |
* version 2.1 of the License, or (at your option) any later version. |
| 7 |
* |
| 8 |
* This library is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 |
* Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public |
| 14 |
* License along with this library; if not, see <https://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
#include <gtkmm/applicationwindow.h> |
| 18 |
#include <gtkmm/shortcutswindow.h> |
| 19 |
|
| 20 |
namespace Gtk |
| 21 |
{ |
| 22 |
ApplicationWindow::ApplicationWindow(const Glib::RefPtr<Application>& application) |
| 23 |
: |
| 24 |
// Mark this class as non-derived to allow C++ vfuncs to be skipped. |
| 25 |
Glib::ObjectBase(nullptr), |
| 26 |
Gtk::Window(Glib::ConstructParams(applicationwindow_class_.init())) |
| 27 |
{ |
| 28 |
// Don't set the "application" property in ConstructParams. It would result in |
| 29 |
// an attempt to set two C++ wrappers on the GApplicationWindow C object, |
| 30 |
// if "application" is not a plain Gtk::Application, but derived from it. |
| 31 |
// Like so: |
| 32 |
// - Glib::Object::Object(const Glib::ConstructParams& construct_params) calls |
| 33 |
// g_object_newv() to create a new GApplicationWindow. |
| 34 |
// - In gtk+, gtk_application_add_window() is called. It emits the window_added |
| 35 |
// signal with the new GApplicationWindow as a parameter. |
| 36 |
// - Application_signal_window_added_callback() calls Glib::wrap(GWindow*) |
| 37 |
// before *this has been set as the wrapper. Glib::wrap() then creates a |
| 38 |
// wrapper (not *this). |
| 39 |
// - Glib::Object::Object() calls Glib::ObjectBase::initialize(), which calls |
| 40 |
// Glib::ObjectBase::_set_current_wrapper() to set *this as the C++ wrapper, |
| 41 |
// but by then another wrapper has already been set. |
| 42 |
// https://bugzilla.gnome.org/show_bug.cgi?id=758813 |
| 43 |
|
| 44 |
if (application) |
| 45 |
application->add_window(*this); |
| 46 |
} |
| 47 |
|
| 48 |
void ApplicationWindow::unset_help_overlay() |
| 49 |
{ |
| 50 |
gtk_application_window_set_help_overlay(gobj(), nullptr); |
| 51 |
} |
| 52 |
|
| 53 |
_DEPRECATE_IFDEF_START |
| 54 |
GtkApplicationWindow* ApplicationWindow::gobj_copy() |
| 55 |
{ |
| 56 |
reference(); |
| 57 |
return gobj(); |
| 58 |
} |
| 59 |
_DEPRECATE_IFDEF_END |
| 60 |
|
| 61 |
} // namespace Gtk |
| 62 |
|
| 63 |
_DEPRECATE_IFDEF_START |
| 64 |
namespace Glib |
| 65 |
{ |
| 66 |
//TODO: This wrap() function is broken. Remove it at the next ABI-break. |
| 67 |
Glib::RefPtr<Gtk::ApplicationWindow> wrap(GtkApplicationWindow* object, bool take_copy) |
| 68 |
{ |
| 69 |
g_warning("Glib::wrap(GtkApplicationWindow*, bool) is broken. See the reference documentation.\n"); |
| 70 |
return Glib::RefPtr<Gtk::ApplicationWindow>(dynamic_cast<Gtk::ApplicationWindow*>(Glib::wrap_auto((GObject*)(object), take_copy))); |
| 71 |
//We use dynamic_cast<> in case of multiple inheritance. |
| 72 |
} |
| 73 |
|
| 74 |
} /* namespace Glib */ |
| 75 |
_DEPRECATE_IFDEF_END |