summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bc4de8e)
raw | patch | inline | side by side (parent: bc4de8e)
author | joncruz <joncruz@users.sourceforge.net> | |
Sun, 28 May 2006 06:53:12 +0000 (06:53 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Sun, 28 May 2006 06:53:12 +0000 (06:53 +0000) |
ChangeLog | patch | blob | history | |
src/dialogs/layers-panel.cpp | patch | blob | history | |
src/dialogs/layers-panel.h | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index 7b5fafb866f7f92fa1b659a4fe1a337fe3793688..4eca93a67fac2223a08b5ce3da9123cc1f47e38d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2006-05-28 Jon A. Cruz <jon@joncruz.org>
+
+ * src/dialogs/layers-panel.h, src/dialogs/layers-panel.cpp:
+
+ Changed clicking on visibility and locked toggles to not switch
+ selected layer.
+ Fixes bug #1495856.
+
2006-05-28 Michael Wybrow <mjwybrow@users.sourceforge.net>
* src/sp-conn-end-pair.cpp: Detach connectors from empty groups
index 4af154062b004563b70255de2cc2da51a3e5f028..2dc7c2a9e9918cf8c16079972df13ab48c4d59a2 100644 (file)
#include <glibmm/i18n.h>
#include <gtk/gtkstock.h>
+#include <gtk/gtkmain.h>
#include "inkscape.h"
return _signal_toggled;
}
+ sigc::signal<void, GdkEvent const *> signal_pre_toggle()
+ {
+ return _signal_pre_toggle;
+ }
+
Glib::PropertyProxy<bool> property_active() { return _property_active.get_proxy(); }
Glib::PropertyProxy<bool> property_activatable() { return _property_activatable.get_proxy(); }
Glib::PropertyProxy< Glib::RefPtr<Gdk::Pixbuf> > property_pixbuf_on();
// virtual Glib::PropertyProxy_Base _property_renderable(); //override
protected:
+
+ virtual void get_size_vfunc( Gtk::Widget& widget,
+ const Gdk::Rectangle* cell_area,
+ int* x_offset,
+ int* y_offset,
+ int* width,
+ int* height ) const
+ {
+ Gtk::CellRendererPixbuf::get_size_vfunc( widget, cell_area, x_offset, y_offset, width, height );
+
+ if ( width ) {
+ *width += (*width) >> 1;
+ }
+ if ( height ) {
+ *height += (*height) >> 1;
+ }
+ }
+
+
virtual void render_vfunc( const Glib::RefPtr<Gdk::Drawable>& window,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
const Gdk::Rectangle& cell_area,
Gtk::CellRendererState flags)
{
+ _signal_pre_toggle.emit(event);
_signal_toggled.emit(path);
+
return false;
}
Glib::Property< Glib::RefPtr<Gdk::Pixbuf> > _property_pixbuf_off;
sigc::signal<void, const Glib::ustring&> _signal_toggled;
+ sigc::signal<void, GdkEvent const *> _signal_pre_toggle;
};
class LayersPanel::InternalUIBounce
@@ -397,6 +425,7 @@ bool LayersPanel::_checkForSelected(const Gtk::TreePath &path, const Gtk::TreeIt
_tree.expand_to_path( path );
Glib::RefPtr<Gtk::TreeSelection> select = _tree.get_selection();
+
select->select(iter);
stopGoing = true;
@@ -446,6 +475,7 @@ void LayersPanel::_addLayer( SPDocument* doc, SPObject* layer, Gtk::TreeModel::R
Glib::RefPtr<Gtk::TreeSelection> select = _tree.get_selection();
select->select(iter);
+
_checkTreeSelection();
}
}
}
+void LayersPanel::_preToggle( GdkEvent const *event )
+{
+ if ( _toggleEvent ) {
+ gdk_event_free(_toggleEvent);
+ _toggleEvent = 0;
+ }
+
+ if ( event && (event->type == GDK_BUTTON_PRESS) ) {
+ // Make a copy so we can keep it around.
+ _toggleEvent = gdk_event_copy(const_cast<GdkEvent*>(event));
+ }
+}
+
void LayersPanel::_toggled( Glib::ustring const& str, int targetCol )
{
Gtk::TreeModel::Children::iterator iter = _tree.get_model()->get_iter(str);
void LayersPanel::_handleButtonEvent(GdkEventButton* evt)
{
+ // TODO - fix to a better is-popup function
if ( (evt->type == GDK_BUTTON_PRESS) && (evt->button == 3) ) {
@@ -585,6 +629,34 @@ void LayersPanel::_handleRowChange( Gtk::TreeModel::Path const& path, Gtk::TreeM
}
}
+bool LayersPanel::_rowSelectFunction( Glib::RefPtr<Gtk::TreeModel> const & model, Gtk::TreeModel::Path const & path, bool currentlySelected )
+{
+ bool val = true;
+ if ( !currentlySelected && _toggleEvent )
+ {
+ GdkEvent* event = gtk_get_current_event();
+ if ( event ) {
+ // (keep these checks separate, so we know when to call gdk_event_free()
+ if ( event->type == GDK_BUTTON_PRESS ) {
+ GdkEventButton const* target = reinterpret_cast<GdkEventButton const*>(_toggleEvent);
+ GdkEventButton const* evtb = reinterpret_cast<GdkEventButton const*>(event);
+
+ if ( (evtb->window == target->window)
+ && (evtb->send_event == target->send_event)
+ && (evtb->time == target->time)
+ && (evtb->state == target->state)
+ )
+ {
+ // Ooooh! It's a magic one
+ val = false;
+ }
+ }
+ gdk_event_free(event);
+ }
+ }
+ return val;
+}
+
/**
* Constructor
*/
_mgr(0),
_desktop(0),
_model(0),
- _pending(0)
+ _pending(0),
+ _toggleEvent(0)
{
_maxNestDepth = prefs_get_int_attribute_limited("dialogs.layers", "maxDepth", 20, 1, 1000);
ImageToggler* eyeRenderer = manage( new ImageToggler("visible", "hidden") );
int visibleColNum = _tree.append_column("vis", *eyeRenderer) - 1;
+ eyeRenderer->signal_pre_toggle().connect( sigc::mem_fun(*this, &LayersPanel::_preToggle) );
eyeRenderer->signal_toggled().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_toggled), (int)COL_VISIBLE) );
eyeRenderer->property_activatable() = true;
Gtk::TreeViewColumn* col = _tree.get_column(visibleColNum);
ImageToggler * renderer = manage( new ImageToggler("width_height_lock", "lock_unlocked") );
int lockedColNum = _tree.append_column("lock", *renderer) - 1;
+ renderer->signal_pre_toggle().connect( sigc::mem_fun(*this, &LayersPanel::_preToggle) );
renderer->signal_toggled().connect( sigc::bind( sigc::mem_fun(*this, &LayersPanel::_toggled), (int)COL_LOCKED) );
renderer->property_activatable() = true;
col = _tree.get_column(lockedColNum);
_tree.get_selection()->signal_changed().connect( sigc::mem_fun(*this, &LayersPanel::_pushTreeSelectionToCurrent) );
+ _tree.get_selection()->set_select_function( sigc::mem_fun(*this, &LayersPanel::_rowSelectFunction) );
_tree.get_model()->signal_row_changed().connect( sigc::mem_fun(*this, &LayersPanel::_handleRowChange) );
_tree.signal_button_press_event().connect_notify( sigc::mem_fun(*this, &LayersPanel::_handleButtonEvent) );
{
delete _model;
}
+
+ if ( _toggleEvent )
+ {
+ gdk_event_free( _toggleEvent );
+ _toggleEvent = 0;
+ }
}
index 63cff3ede2f16960bcb3e7be39974a5bd929baec..263a0105cf2834c7c8122958fc60621de5b75ecf 100644 (file)
void _fireAction( unsigned int code );
Gtk::MenuItem& _addPopupItem( SPDesktop *desktop, unsigned int code, char const* iconName, char const* fallback, int id );
+ void _preToggle( GdkEvent const *event );
void _toggled( Glib::ustring const& str, int targetCol );
void _handleButtonEvent(GdkEventButton* evt);
void _takeAction( int val );
bool _executeAction();
+ bool _rowSelectFunction( Glib::RefPtr<Gtk::TreeModel> const & model, Gtk::TreeModel::Path const & path, bool b );
+
void _updateLayer(SPObject *layer);
bool _checkForUpdated(const Gtk::TreePath &path, const Gtk::TreeIter& iter, SPObject* layer);
SPDesktop* _desktop;
ModelColumns* _model;
InternalUIBounce* _pending;
+ GdkEvent* _toggleEvent;
Glib::RefPtr<Gtk::TreeStore> _store;
std::vector<Gtk::Widget*> _watching;
std::vector<Gtk::Widget*> _watchingNonTop;