Index: button_style.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/button_style/button_style.module,v
retrieving revision 1.4
diff -u -r1.4 button_style.module
--- button_style.module	14 Aug 2009 18:44:04 -0000	1.4
+++ button_style.module	22 Sep 2009 13:58:27 -0000
@@ -10,26 +10,48 @@
  * Implementation of hook_form_alter().
  */
 function button_style_form_alter(&$form, &$form_state, $form_id) {
-  $path = drupal_get_path('module', 'button_style');
-  drupal_add_css($path . '/button_style.css');
-  // drupal_add_js($path . '/button_style.js', 'module', 'footer', TRUE);
-
-  // Add container around form buttons.
-  $form['#after_build'][] = 'button_style_form_after_build';
-
-  // Prepare confirmation forms.
-  if (isset($form['#theme']) && $form['#theme'] == 'confirm_form') {
-    // Turn description into form item.
-    $form['description']['#type'] = 'item';
-    // Add Sliding Doors markup to cancel action in confirmation forms.
-    $cancel = $form['actions']['cancel']['#value'];
-    $cancel = substr($cancel, 0, 2) . ' class="button"' . substr($cancel, 2);
-    $cancel = preg_replace('@(<a [^>]+>)(.+)(</a>)@', '$1<span>$2</span>$3', $cancel);
-    $form['actions']['cancel']['#value'] = $cancel;
+  // Provide the Button Style toggle display on a per-theme basis.
+  if ($form_id == 'system_theme_settings' && $form['var']['#value'] != 'theme_settings') {
+    $form['theme_settings']['button_style'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Button style'),
+      '#default_value' => variable_get('button_style_'. $form['var']['#value'], TRUE),
+    );
+    $form['#submit'][] = 'button_style_form_submit';
+  }
+
+  // Check to see if we are to apply the button style on the current theme.
+  init_theme();
+  global $theme_key;
+  if (variable_get('button_style_theme_'. $theme_key .'_settings', TRUE)) {
+    $path = drupal_get_path('module', 'button_style');
+    drupal_add_css($path . '/button_style.css');
+    // drupal_add_js($path . '/button_style.js', 'module', 'footer', TRUE);
+  
+    // Add container around form buttons.
+    $form['#after_build'][] = 'button_style_form_after_build';
+  
+    // Prepare confirmation forms.
+    if (isset($form['#theme']) && $form['#theme'] == 'confirm_form') {
+      // Turn description into form item.
+      $form['description']['#type'] = 'item';
+      // Add Sliding Doors markup to cancel action in confirmation forms.
+      $cancel = $form['actions']['cancel']['#value'];
+      $cancel = substr($cancel, 0, 2) . ' class="button"' . substr($cancel, 2);
+      $cancel = preg_replace('@(<a [^>]+>)(.+)(</a>)@', '$1<span>$2</span>$3', $cancel);
+      $form['actions']['cancel']['#value'] = $cancel;
+    }
   }
 }
 
 /**
+ * Process system_theme_settings form submissions for the button style setting.
+ */
+function button_style_form_submit($form, &$form_state) {
+  variable_set('button_style_'. $form_state['values']['var'], $form_state['values']['button_style']);
+}
+
+/**
  * Form after build handler; add container around form buttons.
  */
 function button_style_form_after_build($form, $form_values) {
Index: button_style.install
===================================================================
RCS file: button_style.install
diff -N button_style.install
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ button_style.install	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,10 @@
+<?php
+// $Id$
+
+/**
+ * Implementation of hook_uninstall()
+ */ 
+function button_style_uninstall() {
+  db_query("DELETE FROM {variable} WHERE name LIKE 'button_style_%'");
+  cache_clear_all('variables', 'cache');
+}
