1 /* 2 * oxygenwidgetexplorer.h 3 * printout widget information on button press, for debugging 4 * ------------------- 5 * 6 * Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr> 7 * 8 * Largely inspired from Qtcurve style 9 * Copyright (C) Craig Drummond, 2003 - 2010 craig.p.drummond@gmail.com 10 * 11 * This library is free software; you can redistribute it and/or 12 * modify it under the terms of the GNU Lesser General Public 13 * License as published by the Free Software Foundation; either 14 * version 2 of the License, or( at your option ) any later version. 15 * 16 * This library is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 * Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public 22 * License along with this library; if not, write to the Free 23 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, 24 * MA 02110-1301, USA. 25 */ 26 27 #include "oxygenwidgetexplorer.h" 28 29 #include "../oxygengtkutils.h" 30 #include "config.h" 31 32 #include <iostream> 33 34 namespace Oxygen 35 { 36 //___________________________________________________________ WidgetExplorer(void)37 WidgetExplorer::WidgetExplorer( void ): 38 _enabled( false ), 39 _hooksInitialized( false ) 40 { 41 42 #if OXYGEN_DEBUG 43 std::cerr << "Oxygen::WidgetExplorer::WidgetExplorer" << std::endl; 44 #endif 45 46 } 47 48 49 //_________________________________________________ ~WidgetExplorer(void)50 WidgetExplorer::~WidgetExplorer( void ) 51 { 52 53 #if OXYGEN_DEBUG 54 std::cerr << "Oxygen::WidgetExplorer::~WidgetExplorer" << std::endl; 55 #endif 56 57 _buttonPressHook.disconnect(); 58 59 } 60 61 //_________________________________________________ initializeHooks(void)62 void WidgetExplorer::initializeHooks( void ) 63 { 64 if( _hooksInitialized ) return; 65 66 _buttonPressHook.connect( "button-press-event", (GSignalEmissionHook)buttonPressHook, this ); 67 _hooksInitialized = true; 68 } 69 70 //_________________________________________________ setEnabled(bool value)71 void WidgetExplorer::setEnabled( bool value ) 72 { _enabled = value; } 73 74 //_________________________________________________________________ buttonPressHook(GSignalInvocationHint *,guint,const GValue * params,gpointer data)75 gboolean WidgetExplorer::buttonPressHook( GSignalInvocationHint*, guint, const GValue* params, gpointer data ) 76 { 77 78 // cast data to window manager 79 WidgetExplorer &explorer( *static_cast<WidgetExplorer*>(data) ); 80 if( !explorer._enabled ) return TRUE; 81 82 // get widget from params 83 GtkWidget* widget( GTK_WIDGET( g_value_get_object( params ) ) ); 84 if( !GTK_IS_WIDGET( widget ) ) return TRUE; 85 86 Gtk::gtk_widget_print_tree( widget ); 87 return TRUE; 88 89 } 90 91 } 92