--- languageicons.module.orig	2008-08-16 15:16:24.000000000 +0200
+++ languageicons.module	2008-08-28 05:57:24.000000000 +0200
@@ -47,14 +47,7 @@
  * Implementation of hook_menu().
  */
 function languageicons_menu() {
-  $items['admin/settings/language/configure/options'] = array(
-    'title' => 'Configure',
-    'weight' => 10,
-    'type' => MENU_DEFAULT_LOCAL_TASK,
-    'access arguments' => array('administer languages'),
-  );
-
-  $items['admin/settings/language/configure/icons'] = array(
+  $items['admin/settings/language/icons'] = array(
     'title' => 'Icons',
     'page callback' => 'drupal_get_form',
     'page arguments' => array('languageicons_admin_settings'),
@@ -116,16 +109,18 @@
  * This function can be overridden for no language icons.
  */
 function theme_languageicons_icon($language, $title = NULL) {
-  if ($path = variable_get('languageicons_path', drupal_get_path('module', 'languageicons') .'/flags/*.png')) {
+  if ($path = variable_get('languageicons_path', '')) {
     $src = base_path() . str_replace('*', $language->language, $path);
     $title = $title ? $title : $language->native;
-    $attribs = array('class' => 'language-icon', 'alt' => $title);
-    if ($size = variable_get('languageicons_size', '16x12')) {
+    $attribs = array('class' => 'language-icon', 'alt' => $title, 'style' => 'vertical-align: middle');
+    if ($size = variable_get('languageicons_size', '')) {
       list($width, $height) = explode('x', $size);
       $attribs += array('width' => $width, 'height' => $height);
     }
     return "<img src='$src' ". drupal_attributes($attribs) .' />';
   }
+  else
+    drupal_set_message(t('The flag icon theme is not set, this can be done at the !settingspage', array('!settingspage' => l(t('language icons settings page'), 'admin/settings/language/configure/icons'))), 'warning');
 }
 
 /**
--- languageicons.admin.inc.orig	2008-08-11 19:25:55.000000000 +0200
+++ languageicons.admin.inc	2008-08-28 06:00:44.000000000 +0200
@@ -36,21 +36,66 @@
     '#description' => t('Where to display the icon, relative to the link title.'),
   );
   $form['languageicons_path'] = array(
+    '#type' => 'radios',
+    '#title' => t('Flag icon set'),
+    '#default_value' => variable_get('languageicons_path', drupal_get_path('module', 'languageicons') .'/flags/plain/*.png'),
+    '#options' => array_merge(_languageicons_flagsets('options'), array('custom' => t('Custom (set below)'))),
+    '#description' => t('Flag icon sets are located within the flags folder within the languageicons module directory.'),
+  );
+  $form['languageicons_custompath'] = array(
     '#type' => 'textfield',
-    '#title' => t('Icons file path'),
-    '#default_value' => variable_get('languageicons_path', drupal_get_path('module', 'languageicons') .'/flags/*.png'),
+    '#title' => t('Custom icons file path'),
+    '#default_value' => variable_get('languageicons_path', drupal_get_path('module', 'languageicons') .'/flags/plain/*.png'),
     '#size' => 70,
     '#maxlength' => 180,
     '#description' => t('Path for language icons, relative to Drupal installation. \'*\' is a placeholder for language code.'),
   );
   $form['languageicons_size'] = array(
     '#type' => 'textfield',
-    '#title' => t('Image size'),
+    '#title' => t('Custom Icon size'),
     '#default_value' => variable_get('languageicons_size', '16x12'),
     '#size' => 10,
     '#maxlength' => 10,
-    '#description' => t('Image size for language icons, in the form "width x height".'),
+    '#description' => t('Image size for language icons, in the form "width x height" (only for custom Flag icon set).'),
   );
+  $form['#submit'][] = 'languageicons_admin_settings_submit';
 
   return system_settings_form($form);
 }
+
+/**
+ * Before saving icon path and size, set path to custompath if custom,
+ * otherwise retrieve size from flagsetinfo.
+ */
+function languageicons_admin_settings_submit($form, &$form_state) {
+  $languageicons_path =& $form_state['values']['languageicons_path'];
+  if ($languageicons_path == 'custom') {
+    $languageicons_path = $form_state['values']['languageicons_custompath'];
+  }
+  else {
+    $flagsetsizes = _languageicons_flagsets('dimensions');
+    $form_state['values']['languageicons_size'] = $flagsetsizes[$languageicons_path];
+  }
+}
+
+/**
+ * Searches for .flagsetinfo-files within the modules flags directory.
+ * Returns array with flagset info keyed on path.
+ */
+function _languageicons_flagsets($query) {
+  $flagsets = array();
+  $flagspath = drupal_get_path('module', 'languageicons') .'/flags/';
+  $setinfofiles = file_scan_directory($flagspath, '.*flagsetinfo');
+  foreach ($setinfofiles as $setinfofile) {
+    $setinfo = drupal_parse_info_file($setinfofile->filename);
+    $setpath = $flagspath . $setinfo['name'] .'/*.'. $setinfo['format'];
+    switch ($query) {
+      case 'dimensions':
+        $flagsets[$setpath] = $setinfo['dimensions'];
+        break;
+      case 'options':
+        $flagsets[$setpath] = $setinfo['name'] .' theme ('. $setinfo['dimensions'] .'px): '. $setinfo['description'];
+    }
+  }
+  return $flagsets;
+}
