Index: /CKEditor/trunk/_source/core/command.js
===================================================================
--- /CKEditor/trunk/_source/core/command.js	(revision 3226)
+++ /CKEditor/trunk/_source/core/command.js	(revision 3227)
@@ -6,6 +6,4 @@
 CKEDITOR.command = function( editor, commandDefinition )
 {
-	this.state = ( 'state' in commandDefinition ) ? commandDefinition.state : CKEDITOR.TRISTATE_OFF;
-
 	this.exec = function( data )
 	{
@@ -16,5 +14,10 @@
 	};
 
-	CKEDITOR.tools.extend( this, commandDefinition );
+	CKEDITOR.tools.extend( this, commandDefinition,
+		// Defaults
+		{
+			modes : { wysiwyg : 1 },
+			state : CKEDITOR.TRISTATE_OFF
+		});
 
 	// Call the CKEDITOR.event constructor to initialize this instance.
Index: /CKEditor/trunk/_source/core/dom/element.js
===================================================================
--- /CKEditor/trunk/_source/core/dom/element.js	(revision 3226)
+++ /CKEditor/trunk/_source/core/dom/element.js	(revision 3227)
@@ -1186,4 +1186,26 @@
 			if ( offset > 0 && ( offset > currentScroll || offset < currentScroll - winHeight ) )
 				win.$.scrollTo( 0, offset );
+		},
+
+		setState : function( state )
+		{
+			switch ( state )
+			{
+				case CKEDITOR.TRISTATE_ON :
+					this.addClass( 'cke_on' );
+					this.removeClass( 'cke_off' );
+					this.removeClass( 'cke_disabled' );
+					break;
+				case CKEDITOR.TRISTATE_DISABLED :
+					this.addClass( 'cke_disabled' );
+					this.removeClass( 'cke_off' );
+					this.removeClass( 'cke_on' );
+					break;
+				default :
+					this.addClass( 'cke_off' );
+					this.removeClass( 'cke_on' );
+					this.removeClass( 'cke_disabled' );
+					break;
+			}
 		}
 	});
Index: /CKEditor/trunk/_source/core/editor.js
===================================================================
--- /CKEditor/trunk/_source/core/editor.js	(revision 3226)
+++ /CKEditor/trunk/_source/core/editor.js	(revision 3227)
@@ -273,4 +273,18 @@
 	};
 
+	function updateCommandsMode()
+	{
+		var command,
+			commands = this._.commands,
+			mode = this.mode;
+
+		for ( var name in commands )
+		{
+			command = commands[ name ];
+
+			command.setState( command.modes[ mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED );
+		}
+	}
+
 	/**
 	 * Initializes the editor instance. This function is called by the editor
@@ -347,4 +361,6 @@
 			CKEDITOR.fire( 'instanceCreated', null, this );
 
+			this.on( 'mode', updateCommandsMode );
+
 			initConfig( this, instanceConfig );
 		};
Index: /CKEditor/trunk/_source/plugins/button/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/button/plugin.js	(revision 3226)
+++ /CKEditor/trunk/_source/plugins/button/plugin.js	(revision 3227)
@@ -197,29 +197,10 @@
 	setState : function( state )
 	{
-		var element = CKEDITOR.document.getById( this._.id );
-
-		if ( this._.currentState == state )
+		if ( this._.state == state )
 			return;
 
-		switch ( state )
-		{
-			case CKEDITOR.TRISTATE_ON :
-				element.addClass( 'cke_on' );
-				element.removeClass( 'cke_off' );
-				element.removeClass( 'cke_disabled' );
-				break;
-			case CKEDITOR.TRISTATE_DISABLED :
-				element.addClass( 'cke_disabled' );
-				element.removeClass( 'cke_off' );
-				element.removeClass( 'cke_on' );
-				break;
-			default :
-				element.addClass( 'cke_off' );
-				element.removeClass( 'cke_on' );
-				element.removeClass( 'cke_disabled' );
-				break;
-		}
-
-		this._.currentState = state;
+		CKEDITOR.document.getById( this._.id ).setState( state );
+
+		this._.state = state;
 	}
 };
Index: /CKEditor/trunk/_source/plugins/newpage/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/newpage/plugin.js	(revision 3226)
+++ /CKEditor/trunk/_source/plugins/newpage/plugin.js	(revision 3227)
@@ -15,4 +15,6 @@
 		editor.addCommand( 'newpage',
 			{
+				modes : { wysiwyg:1, source:1 },
+
 				exec : function( editor )
 				{
Index: /CKEditor/trunk/_source/plugins/panelbutton/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/panelbutton/plugin.js	(revision 3226)
+++ /CKEditor/trunk/_source/plugins/panelbutton/plugin.js	(revision 3227)
@@ -28,5 +28,6 @@
 			// Set defaults.
 			{
-				title : definition.label
+				title : definition.label,
+				modes : { wysiwyg : 1 }
 			});
 
@@ -79,4 +80,7 @@
 				{
 					var _ = this._;
+
+					if ( _.state == CKEDITOR.TRISTATE_DISABLED )
+						return;
 
 					this.createPanel( editor );
@@ -120,4 +124,10 @@
 				classes += ' ' + this.className;
 
+			editor.on( 'mode', function()
+				{
+					this.setState( this.modes[ editor.mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED );
+				},
+				this );
+
 			output.push(
 				'<span class="cke_button">',
Index: /CKEditor/trunk/_source/plugins/preview/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/preview/plugin.js	(revision 3226)
+++ /CKEditor/trunk/_source/plugins/preview/plugin.js	(revision 3227)
@@ -12,4 +12,6 @@
 	var previewCmd =
 	{
+		modes : { wysiwyg:1, source:1 },
+
 		exec : function( editor )
 		{
Index: /CKEditor/trunk/_source/plugins/richcombo/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/richcombo/plugin.js	(revision 3226)
+++ /CKEditor/trunk/_source/plugins/richcombo/plugin.js	(revision 3227)
@@ -1,3 +1,3 @@
-/*
+﻿/*
 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
 For licensing, see LICENSE.html or http://ckeditor.com/license
@@ -6,5 +6,5 @@
 CKEDITOR.plugins.add( 'richcombo',
 {
-	requires : [ 'floatpanel', 'listblock' ],
+	requires : [ 'floatpanel', 'listblock', 'button' ],
 
 	beforeInit : function( editor )
@@ -29,5 +29,6 @@
 			// Set defaults.
 			{
-				title : definition.label
+				title : definition.label,
+				modes : { wysiwyg : 1 }
 			});
 
@@ -48,5 +49,6 @@
 		{
 			panelDefinition : panelDefinition,
-			items : {}
+			items : {},
+			state : CKEDITOR.TRISTATE_OFF
 		};
 	},
@@ -86,4 +88,7 @@
 				{
 					var _ = this._;
+					
+					if ( _.state == CKEDITOR.TRISTATE_DISABLED )
+						return;
 
 					this.createPanel( editor );
@@ -110,5 +115,5 @@
 				},
 				this );
-				
+
 			var instance = {
 				id : id,
@@ -121,4 +126,10 @@
 				execute : clickFn
 			};
+
+			editor.on( 'mode', function()
+				{
+					this.setState( this.modes[ editor.mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED );
+				},
+				this );
 
 			var keyDownFn = CKEDITOR.tools.addFunction( function( ev, element )
@@ -149,5 +160,5 @@
 
 			if ( this.className )
-				output.push( ' class="', this.className, '"');
+				output.push( ' class="', this.className, ' cke_off"');
 
 			output.push(
@@ -204,5 +215,5 @@
 						this.element.getFirst().addClass( me.className + '_panel' );
 
-					me.document.getById( 'cke_' + me.id ).addClass( 'cke_on');
+					me.setState( CKEDITOR.TRISTATE_ON );
 					
 					list.focus( !me.multiSelect && me.getValue() );
@@ -219,5 +230,5 @@
 						this.element.getFirst().removeClass( me.className + '_panel' );
 
-					me.document.getById( 'cke_' + me.id ).removeClass( 'cke_on');
+					me.setState( CKEDITOR.TRISTATE_OFF );
 
 					me._.on = 0;
@@ -310,4 +321,14 @@
 		{
 			this._.list.commit();
+		},
+
+		setState : function( state )
+		{
+			if ( this._.state == state )
+				return;
+
+			this.document.getById( 'cke_' + this.id ).setState( state );
+
+			this._.state = state;
 		}
 	}
Index: /CKEditor/trunk/_source/plugins/save/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/save/plugin.js	(revision 3226)
+++ /CKEditor/trunk/_source/plugins/save/plugin.js	(revision 3227)
@@ -12,4 +12,6 @@
 	var saveCmd =
 	{
+		modes : { wysiwyg:1, source:1 },
+
 		exec : function( editor )
 		{
Index: /CKEditor/trunk/_source/plugins/sourcearea/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/sourcearea/plugin.js	(revision 3226)
+++ /CKEditor/trunk/_source/plugins/sourcearea/plugin.js	(revision 3227)
@@ -141,4 +141,6 @@
 		source :
 		{
+			modes : { wysiwyg:1, source:1 },
+
 			exec : function( editor )
 			{
Index: /CKEditor/trunk/_source/plugins/undo/plugin.js
===================================================================
--- /CKEditor/trunk/_source/plugins/undo/plugin.js	(revision 3226)
+++ /CKEditor/trunk/_source/plugins/undo/plugin.js	(revision 3227)
@@ -67,19 +67,24 @@
 			editor.on( 'mode', function()
 				{
-					if ( !undoManager.enabled && editor.mode == 'wysiwyg' )
-					{
-						undoManager.enabled = true;
-
-						editor.document.on( 'keydown', function( event )
-							{
-								// Do not capture CTRL hotkeys.
-								if ( !event.data.$.ctrlKey && !event.data.$.metaKey )
-									undoManager.type();
-							});
-
-						// Being this the first call, let's get an undo snapshot.
-						if ( undoManager.index == -1 )
-							undoManager.save();
+					if ( editor.mode == 'wysiwyg' )
+					{
+						if ( !undoManager.enabled )
+						{
+							undoManager.enabled = true;
+
+							editor.document.on( 'keydown', function( event )
+								{
+									// Do not capture CTRL hotkeys.
+									if ( !event.data.$.ctrlKey && !event.data.$.metaKey )
+										undoManager.type();
+								});
+
+							// Being this the first call, let's get an undo snapshot.
+							if ( undoManager.index == -1 )
+								undoManager.save();
+						}
 					}
+					else
+						undoManager.enabled = false;
 
 					undoManager.onChange();
Index: /CKEditor/trunk/_source/skins/default/richcombo.css
===================================================================
--- /CKEditor/trunk/_source/skins/default/richcombo.css	(revision 3226)
+++ /CKEditor/trunk/_source/skins/default/richcombo.css	(revision 3227)
@@ -92,7 +92,7 @@
 }
 
-.cke_skin_default .cke_rcombo a:hover,
-.cke_skin_default .cke_rcombo a:focus,
-.cke_skin_default .cke_rcombo a:active,
+.cke_skin_default .cke_rcombo .cke_off a:hover,
+.cke_skin_default .cke_rcombo .cke_off a:focus,
+.cke_skin_default .cke_rcombo .cke_off a:active,
 .cke_skin_default .cke_rcombo .cke_on a
 {
@@ -101,7 +101,7 @@
 }
 
-.cke_skin_default .cke_rcombo a:hover .cke_text,
-.cke_skin_default .cke_rcombo a:focus .cke_text,
-.cke_skin_default .cke_rcombo a:active .cke_text,
+.cke_skin_default .cke_rcombo .cke_off a:hover .cke_text,
+.cke_skin_default .cke_rcombo .cke_off a:focus .cke_text,
+.cke_skin_default .cke_rcombo .cke_off a:active .cke_text,
 .cke_skin_default .cke_rcombo .cke_on .cke_text
 {
@@ -109,7 +109,7 @@
 }
 
-.cke_skin_default .cke_rcombo a:hover .cke_openbutton,
-.cke_skin_default .cke_rcombo a:focus .cke_openbutton,
-.cke_skin_default .cke_rcombo a:active .cke_openbutton,
+.cke_skin_default .cke_rcombo .cke_off a:hover .cke_openbutton,
+.cke_skin_default .cke_rcombo .cke_off a:focus .cke_openbutton,
+.cke_skin_default .cke_rcombo .cke_off a:active .cke_openbutton,
 .cke_skin_default .cke_rcombo .cke_on .cke_openbutton
 {
@@ -131,2 +131,20 @@
 	border-bottom-right-radius: 0px;
 }
+
+.cke_skin_default .cke_rcombo .cke_disabled .cke_label
+{
+	filter: alpha(opacity=30); /* IE */
+	opacity: 0.3; /* Safari, Opera and Mozilla */
+}
+
+.cke_skin_default .cke_rcombo .cke_disabled .cke_text,
+.cke_skin_default .cke_rcombo .cke_disabled .cke_openbutton
+{
+	filter: alpha(opacity=50); /* IE */
+	opacity: 0.5; /* Safari, Opera and Mozilla */
+}
+
+.cke_skin_default .cke_rcombo .cke_disabled .cke_text
+{
+	color: #fff;
+}
