summaryrefslogtreecommitdiff
path: root/libs/gtkmm2ext
diff options
context:
space:
mode:
Diffstat (limited to 'libs/gtkmm2ext')
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/tabbable.h12
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/window_proxy.h10
-rw-r--r--libs/gtkmm2ext/tabbable.cc57
-rw-r--r--libs/gtkmm2ext/window_proxy.cc11
-rw-r--r--libs/gtkmm2ext/wscript2
5 files changed, 74 insertions, 18 deletions
diff --git a/libs/gtkmm2ext/gtkmm2ext/tabbable.h b/libs/gtkmm2ext/gtkmm2ext/tabbable.h
index 418602477e..7c7dd15d23 100644
--- a/libs/gtkmm2ext/gtkmm2ext/tabbable.h
+++ b/libs/gtkmm2ext/gtkmm2ext/tabbable.h
@@ -36,11 +36,14 @@ class VisibilityTracker;
class LIBGTKMM2EXT_API Tabbable : public WindowProxy {
public:
- Tabbable (Gtk::Widget&);
+ Tabbable (Gtk::Widget&, const std::string&);
~Tabbable ();
void add_to_notebook (Gtk::Notebook& notebook, const std::string& tab_title, int position);
-
+ void show_tab ();
+
+ Gtk::Widget& contents() const { return _contents; }
+
Gtk::Window* get (bool create = false);
Gtk::Window* own_window () { return get (false); }
Gtk::Notebook* tabbed_parent ();
@@ -52,12 +55,17 @@ class LIBGTKMM2EXT_API Tabbable : public WindowProxy {
virtual void show_window ();
bool window_visible ();
+
+ Gtk::Window* current_toplevel () const;
+
+ Gtk::Notebook* tab_root_drop ();
protected:
bool delete_event_handler (GdkEventAny *ev);
private:
Gtk::Widget& _contents;
+ Gtk::Notebook _own_notebook;
Gtk::Notebook* _parent_notebook;
std::string _tab_title;
int _notebook_position;
diff --git a/libs/gtkmm2ext/gtkmm2ext/window_proxy.h b/libs/gtkmm2ext/gtkmm2ext/window_proxy.h
index aefe38a07f..01f53826bd 100644
--- a/libs/gtkmm2ext/gtkmm2ext/window_proxy.h
+++ b/libs/gtkmm2ext/gtkmm2ext/window_proxy.h
@@ -25,7 +25,7 @@
#include <glibmm/refptr.h>
#include <sigc++/trackable.h>
-class XMLNode;
+#include "pbd/statefuldestructible.h"
#include "gtkmm2ext/visibility.h"
@@ -38,10 +38,10 @@ namespace Gtkmm2ext {
class VisibilityTracker;
-class LIBGTKMM2EXT_API WindowProxy : public virtual sigc::trackable
+class LIBGTKMM2EXT_API WindowProxy : public PBD::StatefulDestructible, public virtual sigc::trackable
{
public:
- WindowProxy ();
+ WindowProxy (const std::string& name);
WindowProxy (const std::string& name, const std::string& menu_name);
WindowProxy (const std::string& name, const std::string& menu_name, const XMLNode&);
virtual ~WindowProxy();
@@ -68,8 +68,8 @@ class LIBGTKMM2EXT_API WindowProxy : public virtual sigc::trackable
virtual void toggle ();
- virtual int set_state (const XMLNode&);
- virtual XMLNode& get_state () const;
+ virtual int set_state (const XMLNode&, int version);
+ virtual XMLNode& get_state ();
operator bool() const { return _window != 0; }
diff --git a/libs/gtkmm2ext/tabbable.cc b/libs/gtkmm2ext/tabbable.cc
index 123649036a..9c1452f11d 100644
--- a/libs/gtkmm2ext/tabbable.cc
+++ b/libs/gtkmm2ext/tabbable.cc
@@ -28,8 +28,9 @@ using namespace Gtkmm2ext;
using namespace Gtk;
using std::string;
-Tabbable::Tabbable (Widget& w)
- : _contents (w)
+Tabbable::Tabbable (Widget& w, const string& name)
+ : WindowProxy (name)
+ , _contents (w)
{
}
@@ -78,17 +79,45 @@ Tabbable::get (bool create)
if (!create) {
return 0;
}
+
+ /* From here on, we're creating the window
+ */
if ((_window = new Window (WINDOW_TOPLEVEL)) == 0) {
return 0;
}
- /* allow parent window to become the key focus window */
- _window->set_flags (CAN_FOCUS);
+ _window->add (_own_notebook);
+ _own_notebook.show ();
+ _own_notebook.set_show_tabs (false);
+
+ /* do other window-related setup */
+
+ setup ();
+ /* window should be ready for derived classes to do something with it */
+
return _window;
}
+Gtk::Notebook*
+Tabbable::tab_root_drop ()
+{
+ (void) use_own_window ();
+
+ /* This is called after a drop of a tab onto the root window. Its
+ * responsibility is to return the notebook that this Tabbable's
+ * contents should be packed into before the drop handling is
+ * completed. It is not responsible for actually taking care of this
+ * packing.
+ */
+
+ _window->show_all ();
+ _window->present ();
+
+ return &_own_notebook;
+}
+
void
Tabbable::show_window ()
{
@@ -119,6 +148,8 @@ Tabbable::delete_event_handler (GdkEventAny *ev)
if (_window == toplevel) {
+ std::cerr << " delete event for own window\n";
+
/* unpack Tabbable from parent, put it back in the main tabbed
* notebook
*/
@@ -132,13 +163,13 @@ Tabbable::delete_event_handler (GdkEventAny *ev)
_window->hide ();
if (_parent_notebook) {
+
+ std::cerr << "repack into parent notebook\n";
_parent_notebook->insert_page (_contents, _tab_title, _notebook_position);
_parent_notebook->set_tab_detachable (_contents);
}
- show_all ();
-
/* don't let anything else handle this */
return true;
@@ -163,3 +194,17 @@ Tabbable::is_tabbed () const
return false;
}
+
+void
+Tabbable::show_tab ()
+{
+ if (!window_visible() && _parent_notebook) {
+ _parent_notebook->set_current_page (_parent_notebook->page_num (_contents));
+ }
+}
+
+Gtk::Window*
+Tabbable::current_toplevel () const
+{
+ return dynamic_cast<Gtk::Window*> (contents().get_toplevel());
+}
diff --git a/libs/gtkmm2ext/window_proxy.cc b/libs/gtkmm2ext/window_proxy.cc
index 08dd2aedb0..d393f4d9bb 100644
--- a/libs/gtkmm2ext/window_proxy.cc
+++ b/libs/gtkmm2ext/window_proxy.cc
@@ -32,8 +32,9 @@ using namespace Gtk;
using namespace Gtkmm2ext;
using namespace PBD;
-WindowProxy::WindowProxy ()
- : _window (0)
+WindowProxy::WindowProxy (const std::string& name)
+ : _name (name)
+ , _window (0)
, _visible (false)
, _x_off (-1)
, _y_off (-1)
@@ -67,7 +68,7 @@ WindowProxy::WindowProxy (const std::string& name, const std::string& menu_name,
, _height (-1)
, vistracker (0)
{
- set_state (node);
+ set_state (node, 0);
}
WindowProxy::~WindowProxy ()
@@ -77,7 +78,7 @@ WindowProxy::~WindowProxy ()
}
int
-WindowProxy::set_state (const XMLNode& node)
+WindowProxy::set_state (const XMLNode& node, int /* version */)
{
XMLNodeList children = node.children ();
@@ -171,7 +172,7 @@ WindowProxy::toggle()
}
XMLNode&
-WindowProxy::get_state () const
+WindowProxy::get_state ()
{
XMLNode* node = new XMLNode (X_("Window"));
char buf[32];
diff --git a/libs/gtkmm2ext/wscript b/libs/gtkmm2ext/wscript
index 2e9df400e5..fdc4f48f0a 100644
--- a/libs/gtkmm2ext/wscript
+++ b/libs/gtkmm2ext/wscript
@@ -57,11 +57,13 @@ gtkmm2ext_sources = [
'selector.cc',
'slider_controller.cc',
'stateful_button.cc',
+ 'tabbable.cc',
'tearoff.cc',
'textviewer.cc',
'treeutils.cc',
'utils.cc',
'visibility_tracker.cc',
+ 'window_proxy.cc'
'window_title.cc'
]