diff options
| author | gustav_b <gustav_b@users.sourceforge.net> | 2007-09-10 21:20:06 +0000 |
|---|---|---|
| committer | gustav_b <gustav_b@users.sourceforge.net> | 2007-09-10 21:20:06 +0000 |
| commit | 3ffe9a61d1340f0c20034518510fd5c9a71b0142 (patch) | |
| tree | 95b94b0fe7fdc9b44b39f567c67ff5c74435d20c /src/ui/widget/dock-item.cpp | |
| parent | tweaking tweaks (diff) | |
| download | inkscape-3ffe9a61d1340f0c20034518510fd5c9a71b0142.tar.gz inkscape-3ffe9a61d1340f0c20034518510fd5c9a71b0142.zip | |
Allow GdlDockItems to take focus, and grab focus on present. Various
cleanups.
(bzr r3718)
Diffstat (limited to 'src/ui/widget/dock-item.cpp')
| -rw-r--r-- | src/ui/widget/dock-item.cpp | 181 |
1 files changed, 105 insertions, 76 deletions
diff --git a/src/ui/widget/dock-item.cpp b/src/ui/widget/dock-item.cpp index 58a0e87f4..d615de1ff 100644 --- a/src/ui/widget/dock-item.cpp +++ b/src/ui/widget/dock-item.cpp @@ -87,6 +87,7 @@ DockItem::DockItem(Dock& dock, const Glib::ustring& name, const Glib::ustring& l signal_show().connect(sigc::mem_fun(*this, &Inkscape::UI::Widget::DockItem::_onShow), false); signal_state_changed().connect(sigc::mem_fun(*this, &Inkscape::UI::Widget::DockItem::_onStateChanged)); signal_delete_event().connect(sigc::mem_fun(*this, &Inkscape::UI::Widget::DockItem::_onDeleteEvent)); + signal_realize().connect(sigc::mem_fun(*this, &Inkscape::UI::Widget::DockItem::_onRealize)); _dock.addItem(*this, (_prev_state == FLOATING_STATE ? FLOATING : TOP)); @@ -117,6 +118,74 @@ DockItem::get_vbox() } +void +DockItem::get_position(int& x, int& y) +{ + if (getWindow()) { + getWindow()->get_position(x, y); + } else { + x = _x; + y = _y; + } +} + +void +DockItem::get_size(int& width, int& height) +{ + if (_window) { + _window->get_size(width, height); + } else { + width = get_vbox()->get_width(); + height = get_vbox()->get_height(); + } +} + + +void +DockItem::resize(int width, int height) +{ + if (_window) + _window->resize(width, height); +} + + +void +DockItem::move(int x, int y) +{ + if (_window) + _window->move(x, y); +} + +void +DockItem::set_position(Gtk::WindowPosition position) +{ + if (_window) + _window->set_position(position); +} + +void +DockItem::set_size_request(int width, int height) +{ + getWidget().set_size_request(width, height); +} + +void +DockItem::size_request(Gtk::Requisition& requisition) +{ + getWidget().size_request(requisition); +} + +void +DockItem::set_title(Glib::ustring title) +{ + g_object_set (_gdl_dock_item, + "long-name", title.c_str(), + NULL); + + gdl_dock_item_set_tablabel(GDL_DOCK_ITEM(_gdl_dock_item), + gtk_label_new (title.c_str())); +} + bool DockItem::isAttached() const { @@ -200,20 +269,13 @@ DockItem::show_all() void DockItem::present() { - // iconified - if (isIconified()) { + // iconified or unattached + if (isIconified() || !isAttached()) { show(); - return; - } - - // unattached - if (!isAttached()) { - gdl_dock_item_show_item (GDL_DOCK_ITEM(_gdl_dock_item)); - return; - } + } // tabbed - if (getPlacement() == CENTER) { + else if (getPlacement() == CENTER) { int i = gtk_notebook_page_num (GTK_NOTEBOOK (_gdl_dock_item->parent), GTK_WIDGET (_gdl_dock_item)); if (i >= 0) @@ -221,79 +283,21 @@ DockItem::present() return; } - // we're already present, do nothing + // always grab focus, even if we're already present + grab_focus(); } -void -DockItem::get_position(int& x, int& y) -{ - if (getWindow()) { - getWindow()->get_position(x, y); - } else { - x = _x; - y = _y; - } -} - -void -DockItem::get_size(int& width, int& height) -{ - if (_window) { - _window->get_size(width, height); - } else { - width = get_vbox()->get_width(); - height = get_vbox()->get_height(); - } -} - - -void -DockItem::resize(int width, int height) -{ - if (_window) - _window->resize(width, height); -} - - -void -DockItem::move(int x, int y) -{ - if (_window) - _window->move(x, y); -} - -void -DockItem::set_position(Gtk::WindowPosition position) -{ - if (_window) - _window->set_position(position); -} - void -DockItem::set_size_request(int width, int height) +DockItem::grab_focus() { - getWidget().set_size_request(width, height); -} - -void -DockItem::size_request(Gtk::Requisition& requisition) -{ - getWidget().size_request(requisition); + if (GTK_WIDGET_REALIZED (_gdl_dock_item)) + gtk_widget_grab_focus (_gdl_dock_item); + else + _grab_focus_on_realize = true; } -void -DockItem::set_title(Glib::ustring title) -{ - g_object_set (_gdl_dock_item, - "long-name", title.c_str(), - NULL); - - gdl_dock_item_set_tablabel(GDL_DOCK_ITEM(_gdl_dock_item), - gtk_label_new (title.c_str())); -} - /* Signal wrappers */ Glib::SignalProxy0<void> @@ -338,6 +342,13 @@ DockItem::signal_drag_end() &_signal_drag_end_proxy); } +Glib::SignalProxy0<void> +DockItem::signal_realize() +{ + return Glib::SignalProxy0<void>(Glib::wrap(GTK_WIDGET(_gdl_dock_item)), + &_signal_realize_proxy); +} + sigc::signal<void, DockItem::State, DockItem::State> DockItem::signal_state_changed() { @@ -387,6 +398,15 @@ DockItem::_onDragEnd(bool) _prev_state = state; } +void +DockItem::_onRealize() +{ + if (_grab_focus_on_realize) { + _grab_focus_on_realize = false; + grab_focus(); + } +} + bool DockItem::_onKeyPress(GdkEventKey *event) { @@ -477,6 +497,15 @@ DockItem::_signal_drag_end_proxy = }; +const Glib::SignalProxyInfo +DockItem::_signal_realize_proxy = +{ + "realize", + (GCallback) &Glib::SignalProxyNormal::slot0_void_callback, + (GCallback) &Glib::SignalProxyNormal::slot0_void_callback +}; + + gboolean DockItem::_signal_delete_event_callback(GtkWidget *self, GdkEventAny *event, void *data) { |
